diff --git a/es2panda/compiler/core/function.cpp b/es2panda/compiler/core/function.cpp index fe4e8b0f89b99f8d45832033c65f29af1f355137..5e758d92be8b6afab94b5434a36f6d8d0d0e6d33 100644 --- a/es2panda/compiler/core/function.cpp +++ b/es2panda/compiler/core/function.cpp @@ -207,12 +207,12 @@ static void CompileFunctionOrProgram(PandaGen *pg) void Function::Compile(PandaGen *pg) { CompileFunctionOrProgram(pg); - pg->AdjustSpillInsns(); pg->SetFunctionKind(); pg->SetSourceLocationFlag(lexer::SourceLocationFlag::INVALID_SOURCE_LOCATION); pg->CopyFunctionArguments(pg->RootNode()); pg->InitializeLexEnv(pg->RootNode()); pg->SetSourceLocationFlag(lexer::SourceLocationFlag::VALID_SOURCE_LOCATION); + pg->AdjustSpillInsns(); pg->SortCatchTables(); } diff --git a/es2panda/compiler/core/pandagen.cpp b/es2panda/compiler/core/pandagen.cpp index a7c61bf5f4494790c6178411b33788f1e2a0cdaf..4069401e8f750f057d99b57851c04cb61006fa36 100644 --- a/es2panda/compiler/core/pandagen.cpp +++ b/es2panda/compiler/core/pandagen.cpp @@ -210,8 +210,6 @@ void PandaGen::InitializeLexEnv(const ir::AstNode *node) void PandaGen::CopyFunctionArguments(const ir::AstNode *node) { FrontAllocator fa(this); - auto spillRegsCount = ra_.GetSpillRegsCount(); - totalRegs_ += spillRegsCount; VReg targetReg = totalRegs_; for (const auto *param : topScope_->ParamScope()->Params()) { @@ -223,11 +221,11 @@ void PandaGen::CopyFunctionArguments(const ir::AstNode *node) auto typeIndex = context_->TypeRecorder()->GetVariableTypeIndex(param); if (typeIndex != extractor::TypeRecorder::PRIMITIVETYPE_ANY) { // Simply encode type index for params - MoveVregWithType(node, -(typeIndex + 1), param->Vreg() + spillRegsCount, targetReg++); + MoveVregWithType(node, -(typeIndex + 1), param->Vreg(), targetReg++); continue; } } - MoveVreg(node, param->Vreg() + spillRegsCount, targetReg++); + MoveVreg(node, param->Vreg(), targetReg++); } } diff --git a/es2panda/compiler/core/pandagen.h b/es2panda/compiler/core/pandagen.h index 7bdf525e81f91f95410e22d5caaf34508748498a..4b17ee205ca3f1a2b594cb4b54622e3dd54fcf8d 100644 --- a/es2panda/compiler/core/pandagen.h +++ b/es2panda/compiler/core/pandagen.h @@ -217,6 +217,7 @@ public: void AdjustSpillInsns() { ra_.AdjustInsRegWhenHasSpill(); + totalRegs_ += ra_.GetSpillRegsCount(); } panda::panda_file::FunctionKind GetFunctionKind() const diff --git a/es2panda/test/compiler/js/cocos_worker_test-expected.txt b/es2panda/test/compiler/js/cocos_worker_test-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..b0cf3887c43dee8a3b8f8f685fe312dfabce12a7 --- /dev/null +++ b/es2panda/test/compiler/js/cocos_worker_test-expected.txt @@ -0,0 +1 @@ +compiling done diff --git a/es2panda/test/compiler/js/cocos_worker_test.js b/es2panda/test/compiler/js/cocos_worker_test.js new file mode 100644 index 0000000000000000000000000000000000000000..290f674e166155ecc6b0da57c62bdda2597d2fcd --- /dev/null +++ b/es2panda/test/compiler/js/cocos_worker_test.js @@ -0,0 +1,137282 @@ +/*! For license information please see cocos_worker.js.LICENSE.txt */ +var _050c3e31727995d1749ba30b8ad948d6; + +() => { + var t = { + 991: function(t, e, i) { + "use strict"; + var s = this && this.__importDefault || function(t) { + return t && t.__esModule ? t : { + default: t + }; + }; + Object.defineProperty(e, "__esModule", { + value: !0 + }); + e.launchEngine = e.loadModule = void 0; + const n = s(i(582)); + const r = { + "/src/application.js"() { + i(915); + }, + "/src/chunks/bundle.js"() { + i(513); + }, + "/src/cocos-js/cc.js"() { + i(61); + }, + "assets/internal/index.js"() { + i(390); + }, + "assets/main/index.js"() { + i(289); + } + }; + function o(t) { + const e = r[t]; + null == e || e(); + } + e.loadModule = o; + const a = {}; + console.time = function(t) { + a[t] = Date.now(); + }; + console.timeEnd = function(t) { + console.log(t + " " + (Date.now() - a[t])); + delete a[t]; + }; + e.launchEngine = function() { + return new Promise(((t, e) => { + window.global = window; + i(935)().then((() => { + window.oh.loadModule = o; + try { + i(693); + } catch (t) { + console.error("error in builtin ", t.stack, t.message); + } + i(457); + System.warmup({ + importMap: n.default, + importMapUrl: "./src/import-map.js", + defaultHandler: t => { + console.info("urlNoSchema ", t); + o(t); + } + }); + System.import("./src/application.js").then((({Application: t}) => new t)).then((t => { + System.import("cc").then((e => { + i(48); + e.macro.CLEANUP_IMAGE_CACHE = !1; + return t.init(e); + })).then((() => t.start())).catch((t => { + console.log("error in importing cc " + t.stack); + })); + })).catch((t => { + console.error("imported failed", t.message, t.stack); + e(t); + })); + })); + })); + }; + }, + 31: (t, e) => { + "use strict"; + Object.defineProperty(e, "__esModule", { + value: !0 + }); + e.Constants = e.ContextType = void 0; + !function(t) { + t[t.APP_LIFECYCLE = 0] = "APP_LIFECYCLE"; + t[t.JSPAGE_LIFECYCLE = 1] = "JSPAGE_LIFECYCLE"; + t[t.XCOMPONENT_CONTEXT = 2] = "XCOMPONENT_CONTEXT"; + t[t.XCOMPONENT_REGISTER_LIFECYCLE_CALLBACK = 3] = "XCOMPONENT_REGISTER_LIFECYCLE_CALLBACK"; + t[t.NATIVE_RENDER_API = 4] = "NATIVE_RENDER_API"; + t[t.WORKER_INIT = 5] = "WORKER_INIT"; + t[t.ENGINE_UTILS = 6] = "ENGINE_UTILS"; + t[t.UV_ASYNC_SEND = 7] = "UV_ASYNC_SEND"; + }(e.ContextType || (e.ContextType = {})); + class i {} + e.Constants = i; + i.APP_KEY_WORKER_MANAGER = "app_key_worker_manager"; + }, + 565: function(t, e, i) { + "use strict"; + this && this.__importDefault; + Object.defineProperty(e, "__esModule", { + value: !0 + }); + var s = globalThis.requireNapi("worker") || (isSystemplugin("worker", "ohos") ? globalThis.ohosplugin.worker : isSystemplugin("worker", "system") ? globalThis.systemplugin.worker : void 0); + var n = globalThis.requireNapi("cocos", !0); + const r = i(31); + const o = i(991); + n.getContext(r.ContextType.WORKER_INIT).workerInit(); + s.parentPort.onmessage = function(t) { + if ("onXCLoad" === t.data.type) { + const t = n.getContext(r.ContextType.NATIVE_RENDER_API); + t.nativeEngineInit(); + o.launchEngine().then((() => { + console.info("launch CC engien finished"); + })).catch((t => { + console.error("launch CC engien failed"); + })); + t.nativeEngineStart(); + } else console.error("cocos worker: message type unknown"); + }; + }, + 390: () => { + "use strict"; + System.register("chunks:///_virtual/internal", [], (function() { + return { + execute: function() {} + }; + })); + t = "virtual:///prerequisite-imports/internal", e = "chunks:///_virtual/internal", + System.register(t, [ e ], (function(t, e) { + return { + setters: [ function(e) { + var i = {}; + for (var s in e) "default" !== s && "__esModule" !== s && (i[s] = e[s]); + t(i); + } ], + execute: function() {} + }; + })); + var t, e; + }, + 289: () => { + "use strict"; + System.register("chunks:///_virtual/AudioManager.ts", [ "./rollupPluginModLoBabelHelpers.js", "cc" ], (function(t) { + var e, i, s, n, r, o, a; + return { + setters: [ function(t) { + e = t.applyDecoratedDescriptor; + i = t.initializerDefineProperty; + }, function(t) { + s = t.cclegacy; + n = t.AudioClip; + r = t._decorator; + o = t.Component; + a = t.AudioSource; + } ], + execute: function() { + var l, h, c, u, _; + s._RF.push({}, "cf05c4BsxJE975rw6fkExNU", "AudioManager", void 0); + const {ccclass: d, property: p} = r; + t("AudioManager", (l = d("AudioManager"), h = p([ n ]), l(c = (_ = e((u = class extends o { + constructor(...t) { + super(...t); + i(this, "audioList", _, this); + this._dict = {}; + this._audioSource = null; + } + start() { + for (let t = 0; t < this.audioList.length; t++) { + const e = this.audioList[t]; + this._dict[e.name] = e; + } + this._audioSource = this.getComponent(a); + } + play(t) { + const e = this._dict[t]; + void 0 !== e && this._audioSource.playOneShot(e); + } + }).prototype, "audioList", [ h ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), u)) || c)); + s._RF.pop(); + } + }; + })); + System.register("chunks:///_virtual/Bullet.ts", [ "cc", "./Constant.ts", "./PoolManager.ts" ], (function(t) { + var e, i, s, n, r, o; + return { + setters: [ function(t) { + e = t.cclegacy; + i = t.Component; + s = t.Collider; + n = t._decorator; + }, function(t) { + r = t.Constant; + }, function(t) { + o = t.PoolManager; + } ], + execute: function() { + var a; + e._RF.push({}, "016d0bZIrlBGY2GbVGZZg1M", "Bullet", void 0); + const {ccclass: l, property: h} = n; + t("Bullet", l("Bullet")(a = class extends i { + constructor(...t) { + super(...t); + this._bulletSpeed = 0; + this._direction = r.Direction.MIDDLE; + this._isEnemyBullet = !1; + } + onEnable() { + this.getComponent(s).on("onTriggerEnter", this._onTriggerEnter, this); + } + onDisable() { + this.getComponent(s).off("onTriggerEnter", this._onTriggerEnter, this); + } + update(t) { + const e = this.node.position; + let i = 0; + if (this._isEnemyBullet) { + i = e.z + this._bulletSpeed; + this.node.setPosition(e.x, e.y, i); + i > 50 && o.instance().putNode(this.node); + } else { + i = e.z - this._bulletSpeed; + this._direction === r.Direction.LEFT ? this.node.setPosition(e.x - .2 * this._bulletSpeed, e.y, i) : this._direction === r.Direction.RIGHT ? this.node.setPosition(e.x + .2 * this._bulletSpeed, e.y, i) : this.node.setPosition(e.x, e.y, i); + i < -50 && o.instance().putNode(this.node); + } + } + show(t, e, i = r.Direction.MIDDLE) { + this._bulletSpeed = t; + this._isEnemyBullet = e; + this._direction = i; + } + _onTriggerEnter(t) { + o.instance().putNode(this.node); + } + }) || a); + e._RF.pop(); + } + }; + })); + System.register("chunks:///_virtual/BulletProp.ts", [ "cc", "./Constant.ts", "./PoolManager.ts" ], (function(t) { + var e, i, s, n, r, o; + return { + setters: [ function(t) { + e = t.cclegacy; + i = t.Component; + s = t.Collider; + n = t._decorator; + }, function(t) { + r = t.Constant; + }, function(t) { + o = t.PoolManager; + } ], + execute: function() { + var a; + e._RF.push({}, "83e2f0O6xJMU7LXZMbv8Q8U", "BulletProp", void 0); + const {ccclass: l, property: h} = n; + t("BulletProp", l("BulletProp")(a = class extends i { + constructor(...t) { + super(...t); + this._propSpeed = .3; + this._propXSpeed = .3; + this._gameManager = null; + } + onEnable() { + this.getComponent(s).on("onTriggerEnter", this._onTriggerEnter, this); + } + onDisable() { + this.getComponent(s).off("onTriggerEnter", this._onTriggerEnter, this); + } + update(t) { + let e = this.node.position; + e.x >= 15 ? this._propXSpeed = this._propSpeed : e.x <= -15 && (this._propXSpeed = -this._propSpeed); + this.node.setPosition(e.x + this._propXSpeed, e.y, e.z - this._propSpeed); + e = this.node.position; + e.z > 50 && o.instance().putNode(this.node); + } + show(t, e) { + this._gameManager = t; + this._propSpeed = e; + } + _onTriggerEnter(t) { + const e = t.selfCollider.node.name; + "bulletH" === e ? this._gameManager.changeBulletType(r.BulletPropType.BULLET_H) : "bulletS" === e ? this._gameManager.changeBulletType(r.BulletPropType.BULLET_S) : this._gameManager.changeBulletType(r.BulletPropType.BULLET_M); + o.instance().putNode(this.node); + } + }) || a); + e._RF.pop(); + } + }; + })); + System.register("chunks:///_virtual/Constant.ts", [ "cc" ], (function(t) { + var e; + return { + setters: [ function(t) { + e = t.cclegacy; + } ], + execute: function() { + e._RF.push({}, "9ba7ak0TVBK4bJaIq49qiJK", "Constant", void 0); + class i {} + t("Constant", i); + i.EnemyType = { + TYPE1: 1, + TYPE2: 2 + }; + i.Combination = { + PLAN1: 1, + PLAN2: 2, + PLAN3: 3 + }; + i.CollisionType = { + SELF_PLANE: 2, + ENEMY_PLANE: 4, + SELF_BULLET: 8, + ENEMY_BULLET: 16, + BULLET_PROP: 32 + }; + i.BulletPropType = { + BULLET_M: 1, + BULLET_H: 2, + BULLET_S: 3 + }; + i.Direction = { + LEFT: 1, + MIDDLE: 2, + RIGHT: 3 + }; + e._RF.pop(); + } + }; + })); + System.register("chunks:///_virtual/EnemyPlane.ts", [ "./rollupPluginModLoBabelHelpers.js", "cc", "./Constant.ts", "./PoolManager.ts" ], (function(t) { + var e, i, s, n, r, o, a, l; + return { + setters: [ function(t) { + e = t.applyDecoratedDescriptor; + i = t.initializerDefineProperty; + }, function(t) { + s = t.cclegacy; + n = t._decorator; + r = t.Component; + o = t.Collider; + }, function(t) { + a = t.Constant; + }, function(t) { + l = t.PoolManager; + } ], + execute: function() { + var h, c, u; + s._RF.push({}, "e4b84GYhj9IHoWH4mrALeYo", "EnemyPlane", void 0); + const {ccclass: _, property: d} = n; + t("EnemyPlane", _("EnemyPlane")(h = (u = e((c = class extends r { + constructor(...t) { + super(...t); + i(this, "createBulletTime", u, this); + this._enemySpeed = 0; + this._needBullet = !1; + this._gameManager = null; + this._currCreateBulletTime = 0; + } + onEnable() { + this.getComponent(o).on("onTriggerEnter", this._onTriggerEnter, this); + } + onDisable() { + this.getComponent(o).off("onTriggerEnter", this._onTriggerEnter, this); + } + update(t) { + const e = this.node.position; + const i = e.z + this._enemySpeed; + this.node.setPosition(e.x, e.y, i); + if (this._needBullet) { + this._currCreateBulletTime += t; + if (this._currCreateBulletTime > this.createBulletTime) { + this._gameManager.createEnemyBullet(this.node.position); + this._currCreateBulletTime = 0; + } + } + i > 50 && l.instance().putNode(this.node); + } + show(t, e, i) { + this._gameManager = t; + this._enemySpeed = e; + this._needBullet = i; + } + _onTriggerEnter(t) { + const e = t.otherCollider.getGroup(); + if (e === a.CollisionType.SELF_PLANE || e === a.CollisionType.SELF_BULLET) { + this._gameManager.playAudioEffect("enemy"); + l.instance().putNode(this.node); + this._gameManager.addScore(); + this._gameManager.createEnemyEffect(this.node.position); + } + } + }).prototype, "createBulletTime", [ d ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .5; + } + }), c)) || h); + s._RF.pop(); + } + }; + })); + System.register("chunks:///_virtual/Explode.ts", [ "cc", "./PoolManager.ts" ], (function(t) { + var e, i, s, n; + return { + setters: [ function(t) { + e = t.cclegacy; + i = t.Component; + s = t._decorator; + }, function(t) { + n = t.PoolManager; + } ], + execute: function() { + var r; + e._RF.push({}, "aa341Z9YJdBX5Rd640Hxh42", "Explode", void 0); + const {ccclass: o, property: a} = s; + t("Explode", o("Explode")(r = class extends i { + onEnable() { + this.scheduleOnce(this._putBack, 1); + } + _putBack() { + n.instance().putNode(this.node); + } + }) || r); + e._RF.pop(); + } + }; + })); + System.register("chunks:///_virtual/GameManager.ts", [ "./rollupPluginModLoBabelHelpers.js", "cc", "./Bullet.ts", "./BulletProp.ts", "./EnemyPlane.ts", "./SelfPlane.ts", "./AudioManager.ts", "./Constant.ts", "./PoolManager.ts" ], (function(t) { + var e, i, s, n, r, o, a, l, h, c, u, _, d, p, m, f, g, y, b; + return { + setters: [ function(t) { + e = t.applyDecoratedDescriptor; + i = t.initializerDefineProperty; + }, function(t) { + s = t.cclegacy; + n = t.Prefab; + r = t.Node; + o = t.Label; + a = t.Animation; + l = t._decorator; + h = t.Component; + c = t.math; + u = t.BoxCollider; + _ = t.macro; + }, function(t) { + d = t.Bullet; + }, function(t) { + p = t.BulletProp; + }, function(t) { + m = t.EnemyPlane; + }, function(t) { + f = t.SelfPlane; + }, function(t) { + g = t.AudioManager; + }, function(t) { + y = t.Constant; + }, function(t) { + b = t.PoolManager; + } ], + execute: function() { + var S, A, T, v, E, C, x, w, R, I, M, B, D, P, O, N, L, F, V, k, U, G, z, H, j, X, W, Y, q, K, J, Z, Q, $, tt, et, it, st, nt, rt, ot, at, lt, ht, ct, ut, _t; + s._RF.push({}, "83611dElfRHkaQJyGfbjwko", "GameManager", void 0); + const {ccclass: dt, property: pt} = l; + t("GameManager", (S = dt("GameManager"), A = pt(f), T = pt(n), v = pt(n), E = pt(n), + C = pt(n), x = pt(n), w = pt(r), R = pt(n), I = pt(n), M = pt(n), B = pt(n), D = pt(n), + P = pt(n), O = pt(r), N = pt(r), L = pt(o), F = pt(o), V = pt(a), k = pt(g), S(U = (z = e((G = class extends h { + constructor(...t) { + super(...t); + i(this, "playerPlane", z, this); + i(this, "bullet01", H, this); + i(this, "bullet02", j, this); + i(this, "bullet03", X, this); + i(this, "bullet04", W, this); + i(this, "bullet05", Y, this); + i(this, "shootTime", q, this); + i(this, "bulletSpeed", K, this); + i(this, "bulletRoot", J, this); + i(this, "enemy01", Z, this); + i(this, "enemy02", Q, this); + i(this, "createEnemyTime", $, this); + i(this, "enemy1Speed", tt, this); + i(this, "enemy2Speed", et, this); + i(this, "enemyExplode", it, this); + i(this, "bulletPropM", st, this); + i(this, "bulletPropH", nt, this); + i(this, "bulletPropS", rt, this); + i(this, "bulletPropSpeed", ot, this); + i(this, "gamePage", at, this); + i(this, "gameOverPage", lt, this); + i(this, "gameScore", ht, this); + i(this, "gameOverScore", ct, this); + i(this, "overAnim", ut, this); + i(this, "audioEffect", _t, this); + this.isGameStart = !1; + this._currShootTime = 0; + this._isShooting = !1; + this._currCreateEnemyTime = 0; + this._combinationInterval = y.Combination.PLAN1; + this._bulletType = y.BulletPropType.BULLET_M; + this._score = 0; + } + start() { + this._init(); + } + update(t) { + if (this.isGameStart) if (this.playerPlane.isDie) this.gameOver(); else { + this._currShootTime += t; + if (this._isShooting && this._currShootTime > this.shootTime) { + this._bulletType === y.BulletPropType.BULLET_H ? this.createPlayerBulletH() : this._bulletType === y.BulletPropType.BULLET_S ? this.createPlayerBulletS() : this.createPlayerBulletM(); + const t = "bullet" + (this._bulletType % 2 + 1); + this.playAudioEffect(t); + this._currShootTime = 0; + } + this._currCreateEnemyTime += t; + if (this._combinationInterval === y.Combination.PLAN1) { + if (this._currCreateEnemyTime > this.createEnemyTime) { + this.createEnemyPlane(); + this._currCreateEnemyTime = 0; + } + } else if (this._combinationInterval === y.Combination.PLAN2) { + if (this._currCreateEnemyTime > 3 * this.createEnemyTime) { + c.randomRangeInt(1, 3) === y.Combination.PLAN2 ? this.createCombination1() : this.createEnemyPlane(); + this._currCreateEnemyTime = 0; + } + } else if (this._currCreateEnemyTime > 2 * this.createEnemyTime) { + const t = c.randomRangeInt(1, 4); + t === y.Combination.PLAN2 ? this.createCombination1() : t === y.Combination.PLAN3 ? this.createCombination2() : this.createEnemyPlane(); + this._currCreateEnemyTime = 0; + } + } + } + returnMain() { + this._currShootTime = 0; + this._currCreateEnemyTime = 0; + this._combinationInterval = y.Combination.PLAN1; + this._bulletType = y.BulletPropType.BULLET_M; + this.playerPlane.node.setPosition(0, 0, 15); + this._score = 0; + } + gameStart() { + this.isGameStart = !0; + this._changePlaneMode(); + this._score = 0; + this.gameScore.string = this._score.toString(); + this.playerPlane.init(); + } + gameReStart() { + this.gameStart(); + this._currShootTime = 0; + this._currCreateEnemyTime = 0; + this._combinationInterval = y.Combination.PLAN1; + this._bulletType = y.BulletPropType.BULLET_M; + this.playerPlane.node.setPosition(0, 0, 15); + } + gameOver() { + this.isGameStart = !1; + this.gamePage.active = !1; + this.gameOverPage.active = !0; + this.gameOverScore.string = this._score.toString(); + this.overAnim.play(); + this._isShooting = !1; + this.unschedule(this._modeChanged); + this._destroyAll(); + } + addScore() { + this._score++; + this.gameScore.string = this._score.toString(); + } + createPlayerBulletM() { + const t = b.instance().getNode(this.bullet01, this.bulletRoot); + const e = this.playerPlane.node.position; + t.setPosition(e.x, e.y, e.z - 7); + t.getComponent(d).show(this.bulletSpeed, !1); + } + createPlayerBulletH() { + const t = this.playerPlane.node.position; + const e = b.instance().getNode(this.bullet03, this.bulletRoot); + e.setPosition(t.x - 2.5, t.y, t.z - 7); + e.getComponent(d).show(this.bulletSpeed, !1); + const i = b.instance().getNode(this.bullet03, this.bulletRoot); + i.setPosition(t.x + 2.5, t.y, t.z - 7); + i.getComponent(d).show(this.bulletSpeed, !1); + } + createPlayerBulletS() { + const t = this.playerPlane.node.position; + const e = b.instance().getNode(this.bullet05, this.bulletRoot); + e.setPosition(t.x, t.y, t.z - 7); + e.getComponent(d).show(this.bulletSpeed, !1); + const i = b.instance().getNode(this.bullet05, this.bulletRoot); + i.setPosition(t.x - 4, t.y, t.z - 7); + i.getComponent(d).show(this.bulletSpeed, !1, y.Direction.LEFT); + const s = b.instance().getNode(this.bullet05, this.bulletRoot); + s.setPosition(t.x + 4, t.y, t.z - 7); + s.getComponent(d).show(this.bulletSpeed, !1, y.Direction.RIGHT); + } + createEnemyBullet(t) { + const e = b.instance().getNode(this.bullet02, this.bulletRoot); + e.setPosition(t.x, t.y, t.z + 6); + e.getComponent(d).show(1, !0); + const i = e.getComponent(u); + i.setGroup(y.CollisionType.ENEMY_BULLET); + i.setMask(y.CollisionType.SELF_PLANE); + } + createEnemyPlane() { + let t = null; + let e = 0; + if (c.randomRangeInt(1, 3) === y.EnemyType.TYPE1) { + t = this.enemy01; + e = this.enemy1Speed; + } else { + t = this.enemy02; + e = this.enemy2Speed; + } + const i = b.instance().getNode(t, this.node); + i.getComponent(m).show(this, e, !0); + const s = c.randomRangeInt(-25, 26); + i.setPosition(s, 0, -50); + } + createCombination1() { + const t = new Array(5); + for (let e = 0; e < t.length; e++) { + t[e] = b.instance().getNode(this.enemy01, this.node); + const i = t[e]; + i.setPosition(10 * e - 20, 0, -50); + i.getComponent(m).show(this, this.enemy1Speed, !1); + } + } + createCombination2() { + const t = new Array(7); + const e = [ -21, 0, -60, -14, 0, -55, -7, 0, -50, 0, 0, -45, 7, 0, -50, 14, 0, -55, 21, 0, -60 ]; + for (let i = 0; i < t.length; i++) { + t[i] = b.instance().getNode(this.enemy02, this.node); + const s = t[i]; + s.parent = this.node; + const n = 3 * i; + s.setPosition(e[n], e[n + 1], e[n + 2]); + s.getComponent(m).show(this, this.enemy2Speed, !1); + } + } + createEnemyEffect(t) { + b.instance().getNode(this.enemyExplode, this.node).setPosition(t); + } + createBulletProp() { + const t = c.randomRangeInt(1, 4); + let e = null; + e = t === y.BulletPropType.BULLET_H ? this.bulletPropH : t === y.BulletPropType.BULLET_H ? this.bulletPropS : this.bulletPropM; + const i = b.instance().getNode(e, this.node); + i.setPosition(15, 0, -50); + i.getComponent(p).show(this, -this.bulletPropSpeed); + } + isShooting(t) { + this._isShooting = t; + } + changeBulletType(t) { + this._bulletType = t; + } + playAudioEffect(t) { + this.audioEffect.play(t); + } + _init() { + this._currShootTime = this.shootTime; + this.playerPlane.init(); + } + _changePlaneMode() { + this.schedule(this._modeChanged, 10, _.REPEAT_FOREVER); + } + _modeChanged() { + this._combinationInterval++; + this.createBulletProp(); + } + _destroyAll() { + let t = this.node.children; + let e = t.length; + let i = 0; + for (i = e - 1; i >= 0; i--) { + const e = t[i]; + b.instance().putNode(e); + } + t = this.bulletRoot.children; + e = t.length; + for (i = e - 1; i >= 0; i--) { + const e = t[i]; + b.instance().putNode(e); + } + } + }).prototype, "playerPlane", [ A ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), H = e(G.prototype, "bullet01", [ T ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), j = e(G.prototype, "bullet02", [ v ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), X = e(G.prototype, "bullet03", [ E ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), W = e(G.prototype, "bullet04", [ C ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Y = e(G.prototype, "bullet05", [ x ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), q = e(G.prototype, "shootTime", [ pt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .3; + } + }), K = e(G.prototype, "bulletSpeed", [ pt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), J = e(G.prototype, "bulletRoot", [ w ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Z = e(G.prototype, "enemy01", [ R ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Q = e(G.prototype, "enemy02", [ I ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), $ = e(G.prototype, "createEnemyTime", [ pt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), tt = e(G.prototype, "enemy1Speed", [ pt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .5; + } + }), et = e(G.prototype, "enemy2Speed", [ pt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .7; + } + }), it = e(G.prototype, "enemyExplode", [ M ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), st = e(G.prototype, "bulletPropM", [ B ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), nt = e(G.prototype, "bulletPropH", [ D ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), rt = e(G.prototype, "bulletPropS", [ P ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), ot = e(G.prototype, "bulletPropSpeed", [ pt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .3; + } + }), at = e(G.prototype, "gamePage", [ O ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), lt = e(G.prototype, "gameOverPage", [ N ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), ht = e(G.prototype, "gameScore", [ L ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), ct = e(G.prototype, "gameOverScore", [ F ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), ut = e(G.prototype, "overAnim", [ V ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), _t = e(G.prototype, "audioEffect", [ k ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), G)) || U)); + s._RF.pop(); + } + }; + })); + System.register("chunks:///_virtual/main", [ "./Explode.ts", "./MovingSceneBg.ts", "./Bullet.ts", "./BulletProp.ts", "./AudioManager.ts", "./Constant.ts", "./GameManager.ts", "./PoolManager.ts", "./EnemyPlane.ts", "./SelfPlane.ts", "./UIMain.ts" ], (function() { + return { + setters: [ null, null, null, null, null, null, null, null, null, null, null ], + execute: function() {} + }; + })); + System.register("chunks:///_virtual/MovingSceneBg.ts", [ "./rollupPluginModLoBabelHelpers.js", "cc" ], (function(t) { + var e, i, s, n, r, o; + return { + setters: [ function(t) { + e = t.applyDecoratedDescriptor; + i = t.initializerDefineProperty; + }, function(t) { + s = t.cclegacy; + n = t.Node; + r = t._decorator; + o = t.Component; + } ], + execute: function() { + var a, l, h, c, u, _, d; + s._RF.push({}, "96ab9fWUgFHu4WZkXRj7lzH", "MovingSceneBg", void 0); + const {ccclass: p, property: m} = r; + t("MovingSceneBg", (a = p("MovingSceneBg"), l = m(n), h = m(n), a(c = (_ = e((u = class extends o { + constructor(...t) { + super(...t); + i(this, "bg01", _, this); + i(this, "bg02", d, this); + this._bgSpeed = 10; + this._bgMovingRange = 90; + } + start() { + this._init(); + } + update(t) { + this._moveBackground(t); + } + _init() { + this.bg01.setPosition(0, 0, 0); + this.bg02.setPosition(0, 0, -this._bgMovingRange); + } + _moveBackground(t) { + this.bg01.setPosition(0, 0, this.bg01.position.z + this._bgSpeed * t); + this.bg02.setPosition(0, 0, this.bg02.position.z + this._bgSpeed * t); + this.bg01.position.z > this._bgMovingRange ? this.bg01.setPosition(0, 0, this.bg02.position.z - this._bgMovingRange) : this.bg02.position.z > this._bgMovingRange && this.bg02.setPosition(0, 0, this.bg01.position.z - this._bgMovingRange); + } + }).prototype, "bg01", [ l ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), d = e(u.prototype, "bg02", [ h ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), u)) || c)); + s._RF.pop(); + } + }; + })); + System.register("chunks:///_virtual/PoolManager.ts", [ "cc" ], (function(t) { + var e, i, s, n; + return { + setters: [ function(t) { + e = t.cclegacy; + i = t._decorator; + s = t.instantiate; + n = t.NodePool; + } ], + execute: function() { + var r, o; + e._RF.push({}, "f490aFvLS9C/bqwLGmSZgIL", "PoolManager", void 0); + const {ccclass: a, property: l} = i; + t("PoolManager", a("PoolManager")(r = (o = class t { + constructor() { + this._dictPool = {}; + this._dictPrefab = {}; + } + static instance() { + this._instance || (this._instance = new t); + return this._instance; + } + getNode(t, e) { + let i = t.data.name; + let r = null; + this._dictPrefab[i] = t; + const o = this._dictPool[i]; + if (o) r = o.size() > 0 ? o.get() : s(t); else { + this._dictPool[i] = new n; + r = s(t); + } + r.parent = e; + r.active = !0; + return r; + } + putNode(t) { + let e = t.name; + t.parent = null; + this._dictPool[e] || (this._dictPool[e] = new n); + this._dictPool[e].put(t); + } + }, o._instance = void 0, o)) || r); + e._RF.pop(); + } + }; + })); + System.register("chunks:///_virtual/SelfPlane.ts", [ "./rollupPluginModLoBabelHelpers.js", "cc", "./Constant.ts" ], (function(t) { + var e, i, s, n, r, o, a, l, h; + return { + setters: [ function(t) { + e = t.applyDecoratedDescriptor; + i = t.initializerDefineProperty; + }, function(t) { + s = t.cclegacy; + n = t.Node; + r = t._decorator; + o = t.Component; + a = t.AudioSource; + l = t.Collider; + }, function(t) { + h = t.Constant; + } ], + execute: function() { + var c, u, _, d, p, m, f, g, y; + s._RF.push({}, "c839482eSFDR5T6mXfibPxw", "SelfPlane", void 0); + const {ccclass: b, property: S} = r; + t("SelfPlane", (c = b("SelfPlane"), u = S(n), _ = S(n), d = S(n), c(p = (f = e((m = class extends o { + constructor(...t) { + super(...t); + i(this, "explode", f, this); + i(this, "bloodFace", g, this); + i(this, "blood", y, this); + this.lifeValue = 5; + this.isDie = !1; + this._currLife = 0; + this._audioEffect = null; + } + start() { + this._audioEffect = this.getComponent(a); + } + onEnable() { + this.getComponent(l).on("onTriggerEnter", this._onTriggerEnter, this); + } + onDisable() { + this.getComponent(l).off("onTriggerEnter", this._onTriggerEnter, this); + } + init() { + this._currLife = this.lifeValue; + this.isDie = !1; + this.explode.active = !1; + this.bloodFace.setScale(1, 1, 1); + } + _onTriggerEnter(t) { + if (100 == t.otherCollider.material.friction) return; + const e = t.otherCollider.getGroup(); + if (e === h.CollisionType.ENEMY_PLANE || e === h.CollisionType.ENEMY_BULLET) { + this._currLife === this.lifeValue && (this.blood.active = !0); + this._currLife--; + this.bloodFace.setScale(this._currLife / this.lifeValue, 1, 1); + if (this._currLife <= 0) { + this.isDie = !0; + this._audioEffect.play(); + this.explode.active = !0; + this.blood.active = !1; + console.log("self plane is die"); + } + } + } + }).prototype, "explode", [ u ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), g = e(m.prototype, "bloodFace", [ _ ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), y = e(m.prototype, "blood", [ d ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), m)) || p)); + s._RF.pop(); + } + }; + })); + System.register("chunks:///_virtual/UIMain.ts", [ "./rollupPluginModLoBabelHelpers.js", "cc", "./GameManager.ts" ], (function(t) { + var e, i, s, n, r, o, a, l; + return { + setters: [ function(t) { + e = t.applyDecoratedDescriptor; + i = t.initializerDefineProperty; + }, function(t) { + s = t.cclegacy; + n = t.Node; + r = t._decorator; + o = t.Component; + a = t.SystemEvent; + }, function(t) { + l = t.GameManager; + } ], + execute: function() { + var h, c, u, _, d, p, m, f, g, y, b, S, A, T; + s._RF.push({}, "e690bV0ZVNGGaTOefuPwiRP", "UIMain", void 0); + const {ccclass: v, property: E} = r; + t("UIMain", (h = v("UIMain"), c = E(n), u = E(l), _ = E(n), d = E(n), p = E(n), + h(m = (g = e((f = class extends o { + constructor(...t) { + super(...t); + i(this, "planeSpeed", g, this); + i(this, "playerPlane", y, this); + i(this, "gameManager", b, this); + i(this, "gameStart", S, this); + i(this, "game", A, this); + i(this, "gameOver", T, this); + } + start() { + this.node.on(a.EventType.TOUCH_START, this._touchStart, this); + this.node.on(a.EventType.TOUCH_MOVE, this._touchMove, this); + this.node.on(a.EventType.TOUCH_END, this._touchEnd, this); + this.gameStart.active = !0; + } + reStart() { + this.gameOver.active = !1; + this.game.active = !0; + this.gameManager.playAudioEffect("button"); + this.gameManager.gameReStart(); + } + returnMain() { + this.gameOver.active = !1; + this.gameStart.active = !0; + this.gameManager.playAudioEffect("button"); + this.gameManager.returnMain(); + } + _touchStart(t, e) { + if (this.gameManager.isGameStart) this.gameManager.isShooting(!0); else { + this.gameStart.active = !1; + this.game.active = !0; + this.gameManager.playAudioEffect("button"); + this.gameManager.gameStart(); + } + } + _touchMove(t, e) { + if (!this.gameManager.isGameStart) return; + const i = t.getDelta(); + let s = this.playerPlane.position; + this.playerPlane.setPosition(s.x + .01 * this.planeSpeed * i.x, s.y, s.z - .01 * this.planeSpeed * i.y); + } + _touchEnd(t, e) { + this.gameManager.isGameStart && this.gameManager.isShooting(!1); + } + }).prototype, "planeSpeed", [ E ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), y = e(f.prototype, "playerPlane", [ c ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), b = e(f.prototype, "gameManager", [ u ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), S = e(f.prototype, "gameStart", [ _ ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), A = e(f.prototype, "game", [ d ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), T = e(f.prototype, "gameOver", [ p ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), f)) || m)); + s._RF.pop(); + } + }; + })); + t = "virtual:///prerequisite-imports/main", e = "chunks:///_virtual/main", System.register(t, [ e ], (function(t, e) { + return { + setters: [ function(e) { + var i = {}; + for (var s in e) "default" !== s && "__esModule" !== s && (i[s] = e[s]); + t(i); + } ], + execute: function() {} + }; + })); + var t, e; + }, + 48: () => { + "use strict"; + !function t(e, i, s) { + function n(o, a) { + if (!i[o]) { + if (!e[o]) { + if (r) return r(o, !0); + var l = new Error("Cannot find module '" + o + "'"); + throw l.code = "MODULE_NOT_FOUND", l; + } + var h = i[o] = { + exports: {} + }; + e[o][0].call(h.exports, (function(t) { + return n(e[o][1][t] || t); + }), h, h.exports, t, e, i, s); + } + return i[o].exports; + } + for (var r = void 0, o = 0; o < s.length; o++) n(s[o]); + return n; + }({ + 1: [ function(t, e, i) { + t("./jsb-assets-manager.js"); + t("./jsb-game.js"); + t("./jsb-gfx.js"); + t("./jsb-loader.js"); + t("./jsb-videoplayer.js"); + t("./jsb-webview.js"); + t("./jsb-editbox.js"); + t("./jsb-editor-support.js"); + t("./jsb-spine-skeleton.js"); + t("./jsb-dragonbones.js"); + cc.physics && cc.physics.PhysicsSystem.PHYSICS_PHYSX && t("./jsb-physics.js"); + }, { + "./jsb-assets-manager.js": 2, + "./jsb-dragonbones.js": 4, + "./jsb-editbox.js": 5, + "./jsb-editor-support.js": 6, + "./jsb-game.js": 8, + "./jsb-gfx.js": 9, + "./jsb-loader.js": 10, + "./jsb-physics.js": 11, + "./jsb-spine-skeleton.js": 12, + "./jsb-videoplayer.js": 13, + "./jsb-webview.js": 14 + } ], + 2: [ function(t, e, i) { + if (jsb.AssetsManager) { + jsb.AssetsManager.State = { + UNINITED: 0, + UNCHECKED: 1, + PREDOWNLOAD_VERSION: 2, + DOWNLOADING_VERSION: 3, + VERSION_LOADED: 4, + PREDOWNLOAD_MANIFEST: 5, + DOWNLOADING_MANIFEST: 6, + MANIFEST_LOADED: 7, + NEED_UPDATE: 8, + READY_TO_UPDATE: 9, + UPDATING: 10, + UNZIPPING: 11, + UP_TO_DATE: 12, + FAIL_TO_UPDATE: 13 + }; + jsb.Manifest.DownloadState = { + UNSTARTED: 0, + DOWNLOADING: 1, + SUCCESSED: 2, + UNMARKED: 3 + }; + jsb.EventAssetsManager.ERROR_NO_LOCAL_MANIFEST = 0; + jsb.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST = 1; + jsb.EventAssetsManager.ERROR_PARSE_MANIFEST = 2; + jsb.EventAssetsManager.NEW_VERSION_FOUND = 3; + jsb.EventAssetsManager.ALREADY_UP_TO_DATE = 4; + jsb.EventAssetsManager.UPDATE_PROGRESSION = 5; + jsb.EventAssetsManager.ASSET_UPDATED = 6; + jsb.EventAssetsManager.ERROR_UPDATING = 7; + jsb.EventAssetsManager.UPDATE_FINISHED = 8; + jsb.EventAssetsManager.UPDATE_FAILED = 9; + jsb.EventAssetsManager.ERROR_DECOMPRESS = 10; + } + }, {} ], + 3: [ function(t, e, i) { + const {getUserDataPath: s, readJsonSync: n, makeDirSync: r, writeFileSync: o, deleteFile: a, rmdirSync: l} = t("./jsb-fs-utils"); + var h = null; + var c = !1; + const u = /^\w+:\/\/.*/; + var _ = { + cacheDir: "gamecaches", + cachedFileName: "cacheList.json", + deleteInterval: 500, + writeFileInterval: 2e3, + cachedFiles: null, + version: "1.1", + getCache(t) { + this.updateLastTime(t); + return this.cachedFiles.has(t) ? `${this.cacheDir}/${this.cachedFiles.get(t).url}` : ""; + }, + getTemp: t => "", + init() { + this.cacheDir = s() + "/" + this.cacheDir; + var t = this.cacheDir + "/" + this.cachedFileName; + var e = n(t); + if (e instanceof Error || !e.version || e.version !== this.version) { + e instanceof Error || l(this.cacheDir, !0); + this.cachedFiles = new cc.AssetManager.Cache; + r(this.cacheDir, !0); + o(t, JSON.stringify({ + files: this.cachedFiles._map, + version: this.version + }), "utf8"); + } else this.cachedFiles = new cc.AssetManager.Cache(e.files); + }, + updateLastTime(t) { + if (this.cachedFiles.has(t)) { + this.cachedFiles.get(t).lastTime = Date.now(); + } + }, + _write() { + h = null; + o(this.cacheDir + "/" + this.cachedFileName, JSON.stringify({ + files: this.cachedFiles._map, + version: this.version + }), "utf8"); + }, + writeCacheFile() { + h || (h = setTimeout(this._write.bind(this), this.writeFileInterval)); + }, + cacheFile(t, e, i) { + this.cachedFiles.add(t, { + bundle: i, + url: e, + lastTime: Date.now() + }); + this.writeCacheFile(); + }, + clearCache() { + l(this.cacheDir, !0); + this.cachedFiles = new cc.AssetManager.Cache; + r(this.cacheDir, !0); + clearTimeout(h); + this._write(); + cc.assetManager.bundles.forEach((t => { + u.test(t.base) && this.makeBundleFolder(t.name); + })); + }, + clearLRU() { + if (!c) { + c = !0; + var t = []; + var e = this; + this.cachedFiles.forEach(((e, i) => { + "internal" !== e.bundle && t.push({ + originUrl: i, + url: this.getCache(i), + lastTime: e.lastTime + }); + })); + t.sort((function(t, e) { + return t.lastTime - e.lastTime; + })); + t.length = Math.floor(t.length / 3); + if (0 !== t.length) { + for (var i = 0, s = t.length; i < s; i++) this.cachedFiles.remove(t[i].originUrl); + clearTimeout(h); + this._write(); + setTimeout((function i() { + var s = t.pop(); + a(s.url); + t.length > 0 ? setTimeout(i, e.deleteInterval) : c = !1; + }), e.deleteInterval); + } + } + }, + removeCache(t) { + if (this.cachedFiles.has(t)) { + var e = this.getCache(t); + this.cachedFiles.remove(t); + clearTimeout(h); + this._write(); + a(e); + } + }, + makeBundleFolder(t) { + r(this.cacheDir + "/" + t, !0); + } + }; + cc.assetManager.cacheManager = e.exports = _; + }, { + "./jsb-fs-utils": 7 + } ], + 4: [ function(t, e, i) { + const s = t("./jsb-cache-manager"); + !function() { + if (void 0 === window.dragonBones || void 0 === window.middleware) return; + const t = cc.internal.ArmatureDisplay; + if (void 0 === t) return; + const e = window.dragonBones; + const i = window.middleware; + Object.defineProperty(e, "timeScale", { + get() { + return this._timeScale; + }, + set(t) { + this._timeScale = t; + this.CCFactory.getInstance().setTimeScale(t); + }, + configurable: !0 + }); + i.generateGetSet(e); + const n = cc.color(0, 0, 255, 255); + const r = cc.color(255, 0, 0, 255); + const o = cc.color(0, 255, 0, 255); + e.EventObject.START = "start"; + e.EventObject.LOOP_COMPLETE = "loopComplete"; + e.EventObject.COMPLETE = "complete"; + e.EventObject.FADE_IN = "fadeIn"; + e.EventObject.FADE_IN_COMPLETE = "fadeInComplete"; + e.EventObject.FADE_OUT = "fadeOut"; + e.EventObject.FADE_OUT_COMPLETE = "fadeOutComplete"; + e.EventObject.FRAME_EVENT = "frameEvent"; + e.EventObject.SOUND_EVENT = "soundEvent"; + e.DragonBones = { + ANGLE_TO_RADIAN: Math.PI / 180, + RADIAN_TO_ANGLE: 180 / Math.PI + }; + const a = e.CCFactory.prototype; + a.createArmatureNode = function(e, i, s) { + let n = (s = s || new cc.Node).getComponent(t); + n || (n = s.addComponent(t)); + s.name = i; + n._armatureName = i; + n._dragonAsset = e.dragonAsset; + n._dragonAtlasAsset = e.dragonAtlasAsset; + n._init(); + return n; + }; + const l = a.replaceSkin; + a.replaceSkin = function(t, e, i, s) { + void 0 === i && (i = !1); + s = s || []; + l.call(this, t, e, i, s); + }; + const h = a.changeSkin; + a.changeSkin = function(t, e, i) { + h.call(this, t, e, i); + }; + e.CCFactory.getInstance = function() { + return e.CCFactory.getFactory(); + }; + const c = e.AnimationState.prototype; + const u = c.isPlaying; + Object.defineProperty(c, "isPlaying", { + get() { + return u.call(this); + } + }); + const _ = e.Armature.prototype; + _.addEventListener = function(t, e, i) { + this.__persistentDisplay__ = this.getDisplay(); + this.__persistentDisplay__.on(t, e, i); + }; + _.removeEventListener = function(t, e, i) { + this.__persistentDisplay__ = this.getDisplay(); + this.__persistentDisplay__.off(t, e, i); + }; + const d = e.CCArmatureDisplay.prototype; + Object.defineProperty(d, "node", { + get() { + return this; + } + }); + d.getRootNode = function() { + const t = this.getRootDisplay(); + return t && t._ccNode; + }; + d.convertToWorldSpace = function(t) { + let e = this.convertToRootSpace(t.x, t.y); + e = cc.v3(e.x, e.y, 0); + const i = this.getRootNode(); + if (!i) return e; + return i._uiProps.uiTransformComp.convertToWorldSpaceAR(e); + }; + d.initEvent = function() { + if (!this._eventTarget) { + this._eventTarget = new cc.EventTarget; + this.setDBEventCallback((function(t) { + this._eventTarget.emit(t.type, t); + })); + } + }; + d.on = function(t, e, i) { + this.initEvent(); + this._eventTarget.on(t, e, i); + this.addDBEventListener(t, e); + }; + d.off = function(t, e, i) { + this.initEvent(); + this._eventTarget.off(t, e, i); + this.removeDBEventListener(t, e); + }; + d.once = function(t, e, i) { + this.initEvent(); + this._eventTarget.once(t, e, i); + this.addDBEventListener(t, e); + }; + const p = cc.internal.DragonBonesAtlasAsset.prototype; + let m = 1; + const f = {}; + const g = new WeakMap; + const y = {}; + p.removeRecordTexture = function(t) { + if (!t) return; + delete y[t.image.url]; + const e = t.__textureIndex__; + if (e) { + const t = f[e]; + if (t && g.has(t)) { + g.delete(t); + delete f[e]; + } + } + }; + p.recordTexture = function() { + if (this._texture && this._oldTexture !== this._texture) { + this.removeRecordTexture(this._oldTexture); + const t = f[m] = { + key: m + }; + g.set(t, this._texture); + this._oldTexture = this._texture; + this._texture.__textureIndex__ = m; + m++; + } + }; + p.getTextureByIndex = function(t) { + const e = f[t]; + return e ? g.get(e) : null; + }; + p.updateTextureAtlasData = function(t) { + const e = this._texture.image.url; + const s = y[e]; + let n; + if (s) { + n = s.index; + this._textureAtlasData = t.getTextureAtlasDataByIndex(s.name, n); + const e = f[s.index]; + g.set(e, this._texture); + this._texture.__textureIndex__ = n; + if (this._textureAtlasData) return; + } else this.recordTexture(); + n = this._texture.__textureIndex__; + this.jsbTexture = new i.Texture2D; + this.jsbTexture.setRealTextureIndex(n); + this.jsbTexture.setPixelsWide(this._texture.width); + this.jsbTexture.setPixelsHigh(this._texture.height); + this._textureAtlasData = t.parseTextureAtlasData(this.atlasJson, this.jsbTexture, this._uuid); + y[e] = { + name: this._textureAtlasData.name, + index: n + }; + }; + p.init = function(t) { + this._factory = t; + if (!this._uuid) { + const t = JSON.parse(this.atlasJson); + this._uuid = t.name; + } + this._textureAtlasData ? t.addTextureAtlasData(this._textureAtlasData, this._uuid) : this.updateTextureAtlasData(t); + }; + p._clear = function(t) { + if (this._factory) { + this._factory.removeTextureAtlasData(this._uuid, !0); + this._factory.removeDragonBonesDataByUUID(this._uuid, !0); + } + this._textureAtlasData = null; + t || this.recordTexture(); + }; + p.destroy = function() { + this.removeRecordTexture(this._texture); + this._clear(!0); + cc.Asset.prototype.destroy.call(this); + }; + const b = cc.internal.DragonBonesAsset.prototype; + b.init = function(t, e) { + this._factory = t; + if (!this._uuid && this.dragonBonesJson) { + const t = JSON.parse(this.dragonBonesJson); + this._uuid = t.name; + } + const i = `${this._uuid}#${e}`; + if (this._factory.getDragonBonesData(i)) return i; + let n = null; + n = this.dragonBonesJson ? this.dragonBonesJson : s.getCache(this.nativeUrl) || this.nativeUrl; + this._factory.parseDragonBonesDataByPath(n, i); + return i; + }; + const S = e.ArmatureCacheMgr.getInstance(); + e.armatureCacheMgr = S; + b._clear = function() { + this._factory && this._factory.removeDragonBonesDataByUUID(this._uuid, !0); + S.removeArmatureCache(this._uuid); + }; + const A = cc.internal.UIRenderer.prototype; + const T = cc.internal.ArmatureDisplay.prototype; + const v = cc.internal.ArmatureDisplay.AnimationCacheMode; + const E = cc.internal.ArmatureSystem; + T.initFactory = function() { + this._factory = e.CCFactory.getFactory(); + }; + Object.defineProperty(T, "armatureName", { + get() { + return this._armatureName; + }, + set(t) { + this._armatureName = t; + const e = this.getAnimationNames(this._armatureName); + (!this.animationName || e.indexOf(this.animationName) < 0) && (this.animationName = ""); + const i = this._armature; + if (this._armature) { + this.isAnimationCached() || this._factory.remove(this._armature); + this._armature = null; + } + this._nativeDisplay = null; + this._refresh(); + i && i !== this._armature && i.dispose(); + this._armature && !this.isAnimationCached() && this._factory.add(this._armature); + }, + visible: !1 + }); + Object.defineProperty(T, "premultipliedAlpha", { + get() { + return void 0 !== this._premultipliedAlpha && this._premultipliedAlpha; + }, + set(t) { + this._premultipliedAlpha = t; + this._nativeDisplay && this._nativeDisplay.setOpacityModifyRGB(this._premultipliedAlpha); + } + }); + const C = T._initDebugDraw; + T._initDebugDraw = function() { + C.call(this); + this._armature && !this.isAnimationCached() && this._nativeDisplay.setDebugBonesEnabled(this.debugBones); + }; + T._buildArmature = function() { + if (!this.dragonAsset || !this.dragonAtlasAsset || !this.armatureName) return; + if (this._nativeDisplay) { + this._nativeDisplay.dispose(); + this._nativeDisplay._comp = null; + this._nativeDisplay = null; + } + const t = this.dragonAtlasAsset._uuid; + this._armatureKey = this.dragonAsset.init(this._factory, t); + if (this.isAnimationCached()) { + const i = this._cacheMode === v.SHARED_CACHE; + this._nativeDisplay = new e.CCArmatureCacheDisplay(this.armatureName, this._armatureKey, t, i); + this._armature = this._nativeDisplay.armature(); + } else { + this._nativeDisplay = this._factory.buildArmatureDisplay(this.armatureName, this._armatureKey, "", t); + if (!this._nativeDisplay) return; + this._nativeDisplay.setDebugBonesEnabled(this.debugBones); + this._armature = this._nativeDisplay.armature(); + this._armature.animation.timeScale = this.timeScale; + this._factory.add(this._armature); + } + const i = this._eventTarget._callbackTable; + const s = function() {}; + for (const t in i) { + const e = i[t]; + e && e.callbackInfos && e.callbackInfos.length && (this.isAnimationCached() ? this._nativeDisplay.addDBEventListener(t) : this._nativeDisplay.addDBEventListener(t, s)); + } + this._preCacheMode = this._cacheMode; + this._nativeDisplay._ccNode = this.node; + this._nativeDisplay._comp = this; + this._nativeDisplay._eventTarget = this._eventTarget; + this._sharedBufferOffset = this._nativeDisplay.getSharedBufferOffset(); + this._sharedBufferOffset[0] = 0; + this._useAttach = !1; + this._renderOrder = -1; + this._paramsBuffer = this._nativeDisplay.getParamsBuffer(); + this._paramsBuffer[0] = -1; + this._nativeDisplay.setOpacityModifyRGB(this.premultipliedAlpha); + const n = this.color; + this._nativeDisplay.setColor(n.r, n.g, n.b, n.a); + this._nativeDisplay.setDBEventCallback((function(t) { + this._eventTarget.emit(t.type, t); + })); + this.attachUtil.init(this); + this.animationName && this.playAnimation(this.animationName, this.playTimes); + this.syncTransform(!0); + this.markForUpdateRenderData(); + }; + T._updateColor = function() { + if (this._nativeDisplay) { + const t = this.color; + this._nativeDisplay.setColor(t.r, t.g, t.b, t.a); + } + }; + T.playAnimation = function(t, e) { + this.playTimes = void 0 === e ? -1 : e; + this.animationName = t; + if (this._nativeDisplay) { + if (this.isAnimationCached()) return this._nativeDisplay.playAnimation(t, this.playTimes); + if (this._armature) return this._armature.animation.play(t, this.playTimes); + } + return null; + }; + T.updateAnimationCache = function(t) { + this.isAnimationCached() && this._nativeDisplay && (t ? this._nativeDisplay.updateAnimationCache(t) : this._nativeDisplay.updateAllAnimationCache()); + }; + T.invalidAnimationCache = function() { + this.isAnimationCached() && this._nativeDisplay && this._nativeDisplay.updateAllAnimationCache(); + }; + const x = A.onEnable; + T.onEnable = function() { + x && x.call(this); + this._armature && !this.isAnimationCached() && this._factory.add(this._armature); + this.syncTransform(!0); + this._flushAssembler(); + E.getInstance().add(this); + i.retain(); + }; + const w = A.onDisable; + T.onDisable = function() { + w && w.call(this); + this._armature && !this.isAnimationCached() && this._factory.remove(this._armature); + E.getInstance().remove(this); + i.release(); + }; + T.once = function(t, e, i) { + this._nativeDisplay && (this.isAnimationCached() ? this._nativeDisplay.addDBEventListener(t) : this._nativeDisplay.addDBEventListener(t, e)); + this._eventTarget.once(t, e, i); + }; + T.addEventListener = function(t, e, i) { + this._nativeDisplay && (this.isAnimationCached() ? this._nativeDisplay.addDBEventListener(t) : this._nativeDisplay.addDBEventListener(t, e)); + this._eventTarget.on(t, e, i); + }; + T.removeEventListener = function(t, e, i) { + this._nativeDisplay && (this.isAnimationCached() ? this._nativeDisplay.removeDBEventListener(t) : this._nativeDisplay.removeDBEventListener(t, e)); + this._eventTarget.off(t, e, i); + }; + const R = T.onDestroy; + T.onDestroy = function() { + R.call(this); + if (this._nativeDisplay) { + this._nativeDisplay.dispose(); + this._nativeDisplay._comp = null; + this._nativeDisplay = null; + } + }; + T.syncTransform = function(t) { + const e = this.node; + if (!e) return; + const i = this._paramsBuffer; + if (i && (t || e.hasChangedFlags || e._dirtyFlags)) { + const t = e.getWorldMatrix(); + i[1] = t.m00; + i[2] = t.m01; + i[3] = t.m02; + i[4] = t.m03; + i[5] = t.m04; + i[6] = t.m05; + i[7] = t.m06; + i[8] = t.m07; + i[9] = t.m08; + i[10] = t.m09; + i[11] = t.m10; + i[12] = t.m11; + i[13] = t.m12; + i[14] = t.m13; + i[15] = t.m14; + i[16] = t.m15; + } + }; + T.setAnimationCacheMode = function(t) { + if (this._preCacheMode !== t) { + this._cacheMode = t; + this._buildArmature(); + this._armature && !this.isAnimationCached() && this._factory.add(this._armature); + this._updateSocketBindings(); + this.markForUpdateRenderData(); + } + }; + T.updateAnimation = function() { + const t = this._nativeDisplay; + if (!t) return; + if (!this.node) return; + const e = this._paramsBuffer; + if (this._renderOrder !== i.renderOrder) { + e[0] = i.renderOrder; + this._renderOrder = i.renderOrder; + i.renderOrder++; + } + this.syncTransform(); + if (void 0 === this.__preColor__ || !this.color.equals(this.__preColor__)) { + const e = this.color; + t.setColor(e.r, e.g, e.b, e.a); + this.__preColor__ = e; + } + const s = this.socketNodes; + if (!this._useAttach && s.size > 0) { + this._useAttach = !0; + t.setAttachEnabled(!0); + } + this.markForUpdateRenderData(); + if (!this.isAnimationCached() && this._debugDraw && this.debugBones) { + const t = this._nativeDisplay; + this._debugData = this._debugData || t.getDebugData(); + if (!this._debugData) return; + const e = this._debugDraw; + e.clear(); + const i = this._debugData; + let s = 0; + e.lineWidth = 5; + e.strokeColor = r; + e.fillColor = n; + const a = i[s++]; + for (let t = 0; t < a; t += 4) { + const n = i[s++]; + const r = i[s++]; + const a = i[s++]; + const l = i[s++]; + e.moveTo(n, r); + e.lineTo(a, l); + e.stroke(); + e.circle(n, r, 2 * Math.PI); + e.fill(); + 0 === t && (e.fillColor = o); + } + } + }; + const I = cc.mat4(); + let M; + let B; + let D; + T._render = function(t) { + if (!this._nativeDisplay) return; + if (!this.node) return; + const e = this.renderEntity; + e.clearDynamicRenderDrawInfos(); + const s = this._sharedBufferOffset; + if (!s) return; + const n = s[0]; + s[0] = 0; + const r = this.sockets; + if (r.length > 0) { + const t = i.attachInfoMgr.attachInfo; + const e = s[1]; + s[1] = 0; + const n = this.socketNodes; + for (let i = r.length - 1; i >= 0; i--) { + const s = r[i]; + const o = s.target; + const a = s.boneIndex; + if (!o) continue; + if (!o.isValid) { + n.delete(s.path); + r.splice(i, 1); + continue; + } + const l = I; + const h = e + 16 * a; + l.m00 = t[h]; + l.m01 = t[h + 1]; + l.m04 = t[h + 4]; + l.m05 = t[h + 5]; + l.m12 = t[h + 12]; + l.m13 = t[h + 13]; + o.matrix = l; + } + } + const o = i.renderInfoMgr.renderInfo; + let a = 0; + let l; + let h; + if (4294967295 !== o[n + a++]) return; + const c = o[n + a++]; + if (0 !== c) for (let t = 0; t < c; t++) { + l = o[n + a++]; + h = this.dragonAtlasAsset.getTextureByIndex(l); + if (!h) return; + const s = this.material; + this.material = this.getMaterialForBlend(o[n + a++], o[n + a++]); + M = o[n + a++]; + B = o[n + a++]; + D = o[n + a++]; + const r = i.RenderInfoLookup[i.vfmtPosUvColor][M]; + const c = this.requestDrawInfo(t); + c.setDrawInfoType(r.drawInfoType); + c.setAccAndBuffer(r.accessor.id, r.chunk.bufferId); + c.setTexture(h.getGFXTexture()); + c.setSampler(h.getGFXSampler()); + c.setMaterial(this.material); + c.setIndexOffset(B); + c.setIBCount(D); + e.setDynamicRenderDrawInfo(c, t); + this.material = s; + } + }; + const P = cc.internal.DragonBonesAssembler; + P.createData = function(t) {}; + P.updateRenderData = function(t) { + t._render(); + }; + P.fillBuffers = function(t, e) {}; + }(); + }, { + "./jsb-cache-manager": 3 + } ], + 5: [ function(t, e, i) { + !function() { + if (!(cc && cc.internal && cc.internal.EditBox)) return; + const t = cc.internal.EditBox; + const e = t.KeyboardReturnType; + const i = t.InputMode; + const s = t.InputFlag; + const n = cc.mat4(); + function r(t) { + switch (t) { + case e.DEFAULT: + case e.DONE: + return "done"; + + case e.SEND: + return "send"; + + case e.SEARCH: + return "search"; + + case e.GO: + return "go"; + + case e.NEXT: + return "next"; + } + return "done"; + } + const o = t._EditBoxImpl; + t._EditBoxImpl = class extends o { + init(t) { + t ? this._delegate = t : cc.error("EditBox init failed"); + } + beginEditing() { + const t = this; + const e = this._delegate; + const n = e.inputMode === i.ANY; + const o = this._getRect(); + this.setMaxLength(e.maxLength); + let a = function(t) { + switch (t) { + case i.EMAIL_ADDR: + return "email"; + + case i.NUMERIC: + case i.DECIMAL: + return "number"; + + case i.PHONE_NUMBER: + return "phone"; + + case i.URL: + return "url"; + + case i.SINGLE_LINE: + case i.ANY: + default: + return "text"; + } + }(e.inputMode); + e.inputFlag === s.PASSWORD && (a = "password"); + jsb.inputBox.onInput((function(i) { + i.value.length > t._maxLength && (i.value = i.value.slice(0, t._maxLength)); + e.string !== i.value && e._editBoxTextChanged(i.value); + })); + jsb.inputBox.onConfirm((function(t) { + e._editBoxEditingReturn(); + })); + jsb.inputBox.onComplete((function(e) { + t.endEditing(); + })); + cc.sys.isMobile || e._hideLabels(); + const l = e.textLabel; + jsb.inputBox.show({ + defaultValue: e.string, + maxLength: t._maxLength, + multiple: n, + confirmHold: !1, + confirmType: r(e.returnType), + inputType: a, + originX: o.x, + originY: o.y, + width: o.width, + height: o.height, + isBold: l.isBold, + isItalic: l.isItalic, + isUnderline: l.isUnderline, + underlineColor: 0, + fontSize: l.fontSize, + fontColor: l.color.toRGBValue(), + backColor: 16777215, + backgroundColor: e.placeholderLabel.color.toRGBValue(), + textAlignment: l.horizontalAlign + }); + this._editing = !0; + e._editBoxEditingDidBegan(); + } + endEditing() { + this._editing = !1; + cc.sys.isMobile || this._delegate._showLabels(); + jsb.inputBox.offConfirm(); + jsb.inputBox.offInput(); + jsb.inputBox.offComplete(); + jsb.inputBox.hide(); + this._delegate._editBoxEditingDidEnded(); + } + setMaxLength(t) { + if (!isNaN(t)) { + t < 0 && (t = 65535); + this._maxLength = t; + } + } + _getRect() { + const t = this._delegate.node; + let e = cc.view._scaleX; + let i = cc.view._scaleY; + const s = jsb.device.getDevicePixelRatio() || 1; + t.getWorldMatrix(n); + const r = t._uiProps.uiTransformComp; + const o = cc.v3(); + let a = 0; + let l = 0; + if (r) { + const t = r.contentSize; + const e = r.anchorPoint; + a = t.width; + l = t.height; + o.x = -e.x * a; + o.y = -e.y * l; + } + cc.Mat4.translate(n, n, o); + e /= s; + i /= s; + const h = n.m00 * e; + const c = n.m05 * i; + const u = cc.view._viewportRect; + const _ = u.x / s; + const d = u.y / s; + return { + x: n.m12 * e + _, + y: n.m13 * i + d, + width: a * h, + height: l * c + }; + } + }; + }(); + }, {} ], + 6: [ function(t, e, i) { + !function() { + if (!window.middleware) return; + const t = window.middleware; + const e = t.MiddlewareManager.getInstance(); + let i = 0; + const s = cc.director; + const n = cc.game; + const r = []; + const o = t.vfmtPosUvColor = 6; + const a = t.vfmtPosUvTwoColor = 7; + const l = cc.internal.vfmtPosUvColor4B; + const h = cc.internal.vfmtPosUvTwoColor4B; + const c = t.RenderInfoLookup = {}; + c[o] = []; + c[a] = []; + t.reset = function() { + t.preRenderComponent = null; + t.preRenderBufferIndex = 0; + t.preRenderBufferType = o; + t.renderOrder = 0; + t.indicesStart = 0; + t.resetIndicesStart = !1; + }; + t.reset(); + t.retain = function() { + i++; + }; + t.release = function() { + if (0 !== i) { + i--; + if (0 === i) { + const t = c[o]; + for (let e = 0; e < t.length; e++) cc.UI.RenderData.remove(t[e]); + t.length = 0; + const e = c[a]; + for (let t = 0; t < e.length; t++) cc.UI.RenderData.remove(e[t]); + e.length = 0; + r.forEach((t => { + t.destroy(); + })); + } + } else cc.warn("middleware reference error: reference count should be greater than 0"); + }; + function u(t, i, s) { + if (!t) return; + const n = e.getBufferCount(i); + for (let t = 0; t < n; t++) { + let e = c[i][t]; + if (!e) { + r[s] || (r[s] = cc.UI.RenderData.createStaticVBAccessor(s, 65535, 524280)); + e = cc.UI.RenderData.add(s, r[s]); + e.multiOwner = !0; + e.drawInfoType = 2; + e.resize(65535, 524280); + e.getMeshBuffer().useLinkedData = !0; + c[i][t] = e; + } + } + } + s.on(cc.Director.EVENT_BEFORE_UPDATE, (() => { + 0 !== i && e.update(n.deltaTime); + })); + s.on(cc.Director.EVENT_BEFORE_DRAW, (() => { + if (0 === i) return; + e.render(n.deltaTime); + t.reset(); + const r = s.root.batcher2D; + u(r, o, l); + u(r, a, h); + if (window.dragonBones) { + cc.internal.ArmatureSystem.getInstance().prepareRenderData(); + } + if (window.spine) { + cc.internal.SpineSkeletonSystem.getInstance().prepareRenderData(); + } + })); + const _ = e.getRenderInfoMgr(); + _.renderInfo = _.getSharedBuffer(); + _.setResizeCallback((function() { + this.attachInfo = this.getSharedBuffer(); + })); + _.__middleware__ = t; + const d = e.getAttachInfoMgr(); + d.attachInfo = d.getSharedBuffer(); + d.setResizeCallback((function() { + this.attachInfo = this.getSharedBuffer(); + })); + t.renderInfoMgr = _; + t.attachInfoMgr = d; + t.generateGetSet = function(t) { + for (const e in t) { + const i = t[e] && t[e].prototype; + if (i) for (const t in i) { + if (-1 === t.search(/^get/)) continue; + let e = t.replace(/^get/, ""); + const s = e.split(""); + const n = s[0].toLowerCase(); + const r = s[0].toUpperCase(); + s.splice(0, 1); + const o = s.join(""); + e = n + o; + const a = `set${r}${o}`; + if (i.hasOwnProperty(e)) continue; + "function" == typeof i[a] ? Object.defineProperty(i, e, { + get() { + return this[t](); + }, + set(t) { + this[a](t); + }, + configurable: !0 + }) : Object.defineProperty(i, e, { + get() { + return this[t](); + }, + configurable: !0 + }); + } + } + }; + }(); + }, {} ], + 7: [ function(t, e, i) { + const s = jsb.fileUtils; + let n = null; + const r = new cc.AssetManager.Cache; + let o = ""; + window.oh || (jsb.Downloader.prototype._ctor = function() { + this.__nativeRefs = {}; + }); + var a = { + fs: s, + initJsbDownloader(t, e) { + n = new jsb.Downloader({ + countOfMaxProcessingTasks: t || 32, + timeoutInSeconds: e || 30, + tempFileNameSuffix: ".tmp" + }); + o = `${a.getUserDataPath()}/temp`; + !s.isDirectoryExist(o) && s.createDirectory(o); + n.onSuccess = t => { + if (!r.has(t.requestURL)) return; + const {onComplete: e} = r.remove(t.requestURL); + e && e(null, t.storagePath); + }; + n.onError = (t, e, i, s) => { + if (!r.has(t.requestURL)) return; + const {onComplete: n} = r.remove(t.requestURL); + cc.error(`Download file failed: path: ${t.requestURL} message: ${s}, ${e}`); + n(new Error(s), null); + }; + n.onProgress = (t, e, i, s) => { + if (!r.has(t.requestURL)) return; + const {onProgress: n} = r.get(t.requestURL); + n && n(i, s); + }; + }, + getUserDataPath: () => s.getWritablePath().replace(/[\/\\]*$/, ""), + checkFsValid() { + if (!s) { + cc.warn("can not get the file system!"); + return !1; + } + return !0; + }, + deleteFile(t, e) { + if (!0 === s.removeFile(t)) e && e(null); else { + cc.warn(`Delete file failed: path: ${t}`); + e && e(new Error("delete file failed")); + } + }, + downloadFile(t, e, i, s, a) { + r.add(t, { + onProgress: s, + onComplete: a + }); + let l = e; + l || (l = `${o}/${performance.now()}${cc.path.extname(t)}`); + n.createDownloadTask(t, l, i); + }, + saveFile(t, e, i) { + let n = null; + const r = s.writeDataToFile(s.getDataFromFile(t), e); + s.removeFile(t); + if (!r) { + n = new Error(`Save file failed: path: ${t}`); + cc.warn(n.message); + } + i && i(n); + }, + copyFile(t, e, i) { + let n = null; + if (!s.writeDataToFile(s.getDataFromFile(t), e)) { + n = new Error(`Copy file failed: path: ${t}`); + cc.warn(n.message); + } + i && i(n); + }, + writeFile(t, e, i, n) { + let r = null; + let o = null; + r = "utf-8" === i || "utf8" === i ? s.writeStringToFile(e, t) : s.writeDataToFile(e, t); + if (!r) { + o = new Error(`Write file failed: path: ${t}`); + cc.warn(o.message); + } + n && n(o); + }, + writeFileSync(t, e, i) { + let n = null; + n = "utf-8" === i || "utf8" === i ? s.writeStringToFile(e, t) : s.writeDataToFile(e, t); + if (!n) { + cc.warn(`Write file failed: path: ${t}`); + return new Error(`Write file failed: path: ${t}`); + } + }, + readFile(t, e, i) { + let n = null; + let r = null; + n = "utf-8" === e || "utf8" === e ? s.getStringFromFile(t) : s.getDataFromFile(t); + if (!n) { + r = new Error(`Read file failed: path: ${t}`); + cc.warn(r.message); + } + i && i(r, n); + }, + readDir(t, e) { + let i = null; + let n = null; + try { + i = s.listFiles(t); + } catch (e) { + cc.warn(`Read dir failed: path: ${t} message: ${e.message}`); + n = new Error(e.message); + } + e && e(n, i); + }, + readText(t, e) { + a.readFile(t, "utf8", e); + }, + readArrayBuffer(t, e) { + a.readFile(t, "", e); + }, + readJson(t, e) { + a.readFile(t, "utf8", ((i, s) => { + let n = null; + if (!i) try { + n = JSON.parse(s); + } catch (e) { + cc.warn(`Read json failed: path: ${t} message: ${e.message}`); + i = new Error(e.message); + } + e && e(i, n); + })); + }, + readJsonSync(t) { + try { + const e = s.getStringFromFile(t); + return JSON.parse(e); + } catch (e) { + cc.warn(`Read json failed: path: ${t} message: ${e.message}`); + return new Error(e.message); + } + }, + makeDirSync(t, e) { + if (!s.createDirectory(t)) { + cc.warn(`Make directory failed: path: ${t}`); + return new Error(`Make directory failed: path: ${t}`); + } + }, + rmdirSync(t, e) { + if (!s.removeDirectory(t)) { + cc.warn(`rm directory failed: path: ${t}`); + return new Error(`rm directory failed: path: ${t}`); + } + }, + exists(t, e) { + const i = s.isFileExist(t); + e && e(i); + }, + loadSubpackage(t, e, i) { + throw new Error("not implement"); + } + }; + window.fsUtils = e.exports = a; + }, {} ], + 8: [ function(t, e, i) { + cc.game.restart = function() { + cc.director.getScene().destroy(); + cc.Object._deferredDestroy(); + __restartVM(); + }; + jsb.onError((function(t, e, i) { + console.error(t, e, i); + })); + jsb.onMemoryWarning = function() { + cc.game.emit(cc.Game.EVENT_LOW_MEMORY); + }; + }, {} ], + 9: [ function(t, e, i) { + const s = gfx.Device.prototype; + const n = gfx.Swapchain.prototype; + const r = gfx.Buffer.prototype; + const o = gfx.Texture.prototype; + const a = gfx.DescriptorSet.prototype; + const l = s.copyTexImagesToTexture; + s.copyTexImagesToTexture = function(t, e, i) { + const s = []; + if (t) for (let e = 0; e < t.length; ++e) { + const i = t[e]; + if (i instanceof HTMLCanvasElement) s.push(i._data.data); else { + if (!(i instanceof HTMLImageElement)) { + console.log("copyTexImagesToTexture: Convert texImages to data buffers failed"); + return; + } + s.push(i._data); + } + } + l.call(this, s, e, i); + }; + const h = s.createSwapchain; + s.createSwapchain = function(t) { + t.windowHandle = window.oh ? jsb.device.getWindowHandle() : window.windowHandler; + return h.call(this, t); + }; + const c = n.initialize; + n.initialize = function(t) { + t.windowHandle = window.windowHandler; + c.call(this, t); + }; + const u = r.update; + r.update = function(t, e) { + if (0 === t.byteLength) return; + let i; + if (64 & this.cachedUsage) { + const {drawInfos: e} = t; + t = new Uint32Array(7 * e.length); + let s = 0; + let n; + for (let i = 0; i < e.length; ++i) { + s = 7 * i; + n = e[i]; + t[s] = n.vertexCount; + t[s + 1] = n.firstVertex; + t[s + 2] = n.indexCount; + t[s + 3] = n.firstIndex; + t[s + 4] = n.vertexOffset; + t[s + 5] = n.instanceCount; + t[s + 6] = n.firstInstance; + } + i = t.byteLength; + } else i = void 0 !== e ? e : t.byteLength; + u.call(this, t, i); + }; + const _ = s.createBuffer; + s.createBuffer = function(t) { + let e; + e = t.buffer ? _.call(this, t, !0) : _.call(this, t, !1); + e.cachedUsage = t.usage; + return e; + }; + const d = r.initialize; + r.initialize = function(t) { + t.buffer ? d.call(this, t, !0) : d.call(this, t, !1); + }; + const p = s.createTexture; + s.createTexture = function(t) { + return t.texture ? p.call(this, t, !0) : p.call(this, t, !1); + }; + const m = o.initialize; + o.initialize = function(t) { + t.texture ? m.call(this, t, !0) : m.call(this, t, !1); + }; + a.bindBuffer = function(t, e, i) { + this.dirtyJSB = a.bindBufferJSB.call(this, t, e, i || 0); + }; + a.bindSampler = function(t, e, i) { + this.dirtyJSB = a.bindSamplerJSB.call(this, t, e, i || 0); + }; + a.bindTexture = function(t, e, i) { + this.dirtyJSB = a.bindTextureJSB.call(this, t, e, i || 0); + }; + const f = a.update; + a.update = function() { + if (this.dirtyJSB) { + f.call(this); + this.dirtyJSB = !1; + } + }; + Object.defineProperty(s, "uboOffsetAlignment", { + get() { + void 0 === this.cachedUboOffsetAlignment && (this.cachedUboOffsetAlignment = this.getUboOffsetAlignment()); + return this.cachedUboOffsetAlignment; + } + }); + }, {} ], + 10: [ function(t, e, i) { + const s = t("./jsb-cache-manager"); + const {downloadFile: n, readText: r, readArrayBuffer: o, readJson: a, getUserDataPath: l, initJsbDownloader: h} = t("./jsb-fs-utils"); + const c = /^\w+:\/\/.*/; + const u = cc.assetManager.downloader; + const _ = cc.assetManager.parser; + const d = cc.assetManager.presets; + u.maxConcurrency = 30; + u.maxRequestsPerFrame = 60; + d.preload.maxConcurrency = 15; + d.preload.maxRequestsPerFrame = 30; + d.scene.maxConcurrency = 32; + d.scene.maxRequestsPerFrame = 64; + d.bundle.maxConcurrency = 32; + d.bundle.maxRequestsPerFrame = 64; + let p = 0; + const m = {}; + const f = {}; + function g(t, e, i) { + if ("function" == typeof e) { + i = e; + e = null; + } + if (f[t]) return i && i(); + y(t, (function(e, i, s) { + window.oh ? window.oh.loadModule(e) : window.require(e); + f[t] = !0; + s && s(null); + }), e, e.onFileProgress, i); + } + function y(t, e, i, r, o) { + var a = function(t, e) { + var i = !1; + var n = !1; + if (c.test(t)) { + if (e.reload) return { + url: t + }; + var r = s.getCache(t); + if (r) { + n = !0; + t = r; + } + } else i = !0; + return { + url: t, + inLocal: i, + inCache: n + }; + }(t, i); + if (a.inLocal) e(a.url, i, o); else if (a.inCache) { + s.updateLastTime(t); + e(a.url, i, (function(e, i) { + e && s.removeCache(t); + o(e, i); + })); + } else { + var l = Date.now(); + var h = ""; + var u = m[t]; + h = u ? u.storagePath : i.__cacheBundleRoot__ ? `${i.__cacheBundleRoot__}/${l}${p++}${cc.path.extname(t)}` : `${l}${p++}${cc.path.extname(t)}`; + n(t, `${s.cacheDir}/${h}`, i.header, r, (function(n, r) { + if (n) { + if (u) { + u.retryCount++; + u.retryCount >= 5 && delete m[t]; + } else m[t] = { + retryCount: 0, + storagePath: h + }; + o(n, null); + } else { + delete m[t]; + e(r, i, (function(e, n) { + e || s.cacheFile(t, h, i.__cacheBundleRoot__); + o(e, n); + })); + } + })); + } + } + function b(t, e, i) { + i(null, t); + } + function S(t, e, i) { + y(t, b, e, e.onFileProgress, i); + } + function A(t, e, i) { + r(t, i); + } + function T(t, e, i) { + a(t, i); + } + function v(t, e, i) { + o(t, i); + } + function E(t, e, i) { + y(t, T, e, e.onFileProgress, i); + } + function C(t, e, i) { + y(t, v, e, e.onFileProgress, i); + } + function x(t, e, i) { + let s = function(t) { + var e = t.lastIndexOf(".ttf"); + if (-1 === e) return t; + var i = t.lastIndexOf("/"); + var s; + -1 !== (s = -1 === i ? t.substring(0, e) + "_LABEL" : t.substring(i + 1, e) + "_LABEL").indexOf(" ") && (s = '"' + s + '"'); + return s; + }(t); + let n = new FontFace(s, "url('" + t + "')"); + document.fonts.add(n); + n.load(); + n.loaded.then((function() { + i(null, s); + }), (function() { + cc.warnID(4933, s); + i(null, s); + })); + } + const w = _.parsePlist; + let R = function(t, e, i) { + r(t, (function(t, s) { + if (t) return i(t); + w(s, e, i); + })); + }; + _.parsePVRTex = u.downloadDomImage; + _.parsePKMTex = u.downloadDomImage; + _.parseASTCTex = u.downloadDomImage; + _.parsePlist = R; + u.downloadScript = g; + function I(t, e, i) { + cc.AudioPlayer.load(t).then((e => { + const s = { + player: e, + url: t, + duration: e.duration, + type: e.type + }; + i(null, s); + })).catch((t => { + i(t); + })); + } + u.register({ + ".js": g, + ".jsc": g, + ".png": S, + ".jpg": S, + ".bmp": S, + ".jpeg": S, + ".gif": S, + ".ico": S, + ".tiff": S, + ".webp": S, + ".image": S, + ".pvr": S, + ".pkm": S, + ".astc": S, + ".mp3": S, + ".ogg": S, + ".wav": S, + ".m4a": S, + ".ccon": (t, e, i) => { + E(t, e, ((e, s) => { + if (e) { + i(e); + return; + } + const n = cc.internal.parseCCONJson(s); + Promise.all(n.chunks.map((e => new Promise(((i, s) => { + C(`${cc.path.mainFileName(t)}${e}`, {}, ((t, e) => { + t ? s(t) : i(new Uint8Array(e)); + })); + }))))).then((t => { + const e = new cc.internal.CCON(n.document, t); + i(null, e); + })).catch((t => { + i(t); + })); + })); + }, + ".cconb": (t, e, i) => { + C(t, e, ((t, e) => { + if (t) i(t); else try { + const t = cc.internal.decodeCCONBinary(new Uint8Array(e)); + i(null, t); + } catch (t) { + i(t); + } + })); + }, + ".mp4": S, + ".avi": S, + ".mov": S, + ".mpg": S, + ".mpeg": S, + ".rm": S, + ".rmvb": S, + ".txt": S, + ".xml": S, + ".vsh": S, + ".fsh": S, + ".atlas": S, + ".tmx": S, + ".tsx": S, + ".fnt": S, + ".plist": S, + ".json": E, + ".ExportJson": S, + ".binary": S, + ".bin": S, + ".dbbin": S, + ".skel": S, + ".font": S, + ".eot": S, + ".ttf": S, + ".woff": S, + ".svg": S, + ".ttc": S, + bundle: function(t, e, i) { + let n = cc.path.basename(t); + var r = e.version || u.bundleVers[n]; + let o; + if (c.test(t) || t.startsWith(l())) { + o = t; + s.makeBundleFolder(n); + } else if (-1 !== u.remoteBundles.indexOf(n)) { + o = `${u.remoteServerAddress}remote/${n}`; + s.makeBundleFolder(n); + } else o = `assets/${n}`; + var a = `${o}/cc.config.${r ? r + "." : ""}json`; + e.__cacheBundleRoot__ = n; + E(a, e, (function(t, s) { + if (t) return i(t, null); + let n = s; + n && (n.base = o + "/"); + g(`${o}/index.${r ? r + "." : ""}${n.encrypted ? "jsc" : "js"}`, e, (function(t) { + if (t) return i(t, null); + i(null, n); + })); + })); + }, + default: function(t, e, i) { + y(t, A, e, e.onFileProgress, i); + } + }); + _.register({ + ".png": u.downloadDomImage, + ".jpg": u.downloadDomImage, + ".bmp": u.downloadDomImage, + ".jpeg": u.downloadDomImage, + ".gif": u.downloadDomImage, + ".ico": u.downloadDomImage, + ".tiff": u.downloadDomImage, + ".webp": u.downloadDomImage, + ".image": u.downloadDomImage, + ".mp3": I, + ".ogg": I, + ".wav": I, + ".m4a": I, + ".pvr": u.downloadDomImage, + ".pkm": u.downloadDomImage, + ".astc": u.downloadDomImage, + ".binary": v, + ".bin": v, + ".dbbin": v, + ".skel": v, + ".txt": A, + ".xml": A, + ".vsh": A, + ".fsh": A, + ".atlas": A, + ".tmx": A, + ".tsx": A, + ".fnt": A, + ".plist": R, + ".font": x, + ".eot": x, + ".ttf": x, + ".woff": x, + ".svg": x, + ".ttc": x, + ".ExportJson": T + }); + cc.assetManager.transformPipeline.append((function(t) { + var e = t.output = t.input; + for (var i = 0, s = e.length; i < s; i++) { + var n = e[i]; + n.config && (n.options.__cacheBundleRoot__ = n.config.name); + ".cconb" === n.ext ? n.url = n.url.replace(n.ext, ".bin") : ".ccon" === n.ext && (n.url = n.url.replace(n.ext, ".json")); + } + })); + var M = cc.assetManager.init; + cc.assetManager.init = function(t) { + M.call(cc.assetManager, t); + if (!window.oh) { + const t = cc.settings.querySettings("assets", "jsbDownloaderMaxTasks"); + const e = cc.settings.querySettings("assets", "jsbDownloaderTimeout"); + h(t, e); + } + s.init(); + }; + }, { + "./jsb-cache-manager": 3, + "./jsb-fs-utils": 7 + } ], + 11: [ function(t, e, i) { + const s = globalThis["jsb.physics"]; + s.CACHE = { + trimesh: {}, + convex: {}, + height: {}, + material: {} + }; + s.OBJECT = { + books: [], + ptrToObj: {}, + raycastOptions: { + origin: null, + unitDir: null, + distance: 0, + mask: 0, + queryTrigger: !0 + } + }; + s.CONFIG = { + heightScale: 1 / 512 + }; + const n = s.OBJECT.books; + const r = s.OBJECT.ptrToObj; + const o = s.OBJECT.raycastOptions; + const a = { + type: "onTriggerEnter", + selfCollider: null, + otherCollider: null, + impl: null + }; + const l = { + type: "onCollisionEnter", + selfCollider: null, + otherCollider: null, + contacts: [], + impl: null + }; + function h(t, e, i, s) { + a.type = t; + a.impl = s; + if (e.needTriggerEvent) { + a.selfCollider = e; + a.otherCollider = i; + e.emit(t, a); + } + if (i.needTriggerEvent) { + a.selfCollider = i; + a.otherCollider = e; + i.emit(t, a); + } + } + const c = new cc.Quat; + const u = []; + class _ { + constructor(t) { + this.event = t; + this.impl = null; + this.colliderA = null; + this.colliderB = null; + this.index = 0; + } + get isBodyA() { + return this.colliderA.uuid === this.event.selfCollider.uuid; + } + getLocalPointOnA(t) { + this.getWorldPointOnB(t); + cc.Vec3.subtract(t, t, this.colliderA.node.worldPosition); + } + getLocalPointOnB(t) { + this.getWorldPointOnB(t); + cc.Vec3.subtract(t, t, this.colliderB.node.worldPosition); + } + getWorldPointOnA(t) { + this.getWorldPointOnB(t); + } + getWorldPointOnB(t) { + const e = 12 * this.index; + t.x = this.impl[e]; + t.y = this.impl[e + 1]; + t.z = this.impl[e + 2]; + } + getLocalNormalOnA(t) { + this.getWorldNormalOnA(t); + cc.Quat.conjugate(c, this.colliderA.node.worldRotation); + cc.Vec3.transformQuat(t, t, c); + } + getLocalNormalOnB(t) { + this.getWorldNormalOnB(t); + cc.Quat.conjugate(c, this.colliderB.node.worldRotation); + cc.Vec3.transformQuat(out, out, c); + } + getWorldNormalOnA(t) { + this.getWorldNormalOnB(t); + this.isBodyA || cc.Vec3.negate(t, t); + } + getWorldNormalOnB(t) { + const e = 12 * this.index + 3; + t.x = this.impl[e]; + t.y = this.impl[e + 1]; + t.z = this.impl[e + 2]; + } + } + function d(t, e, i, s, n) { + l.type = t; + l.impl = s; + const r = l.contacts; + u.push.apply(u, r); + r.length = 0; + const o = n.length / 12; + for (let t = 0; t < o; t++) { + const s = u.length > 0 ? u.pop() : new _(l); + s.colliderA = e; + s.colliderB = i; + s.impl = n; + s.index = t; + r.push(s); + } + if (e.needCollisionEvent) { + l.selfCollider = e; + l.otherCollider = i; + e.emit(t, l); + } + if (i.needCollisionEvent) { + l.selfCollider = i; + l.otherCollider = e; + i.emit(t, l); + } + } + function p(t) { + if (void 0 === t._physicsBookIndex) { + t._physicsBookIndex = n.length; + n.push(t); + } + } + function m(t) { + const e = t._physicsBookIndex; + if (void 0 !== e) { + n[e] = n[n.length - 1]; + n[e]._physicsBookIndex = e; + n.length -= 1; + t._physicsBookIndex = void 0; + } + } + function f() { + const t = cc.PhysicsSystem.instance; + const e = t.physicsWorld.impl; + const i = t.collisionMatrix; + if (i.updateArray && i.updateArray.length > 0) { + i.updateArray.forEach((t => { + const s = i["" + (1 << t)]; + e.setCollisionMatrix(t, s); + })); + i.updateArray.length = 0; + } + } + const g = { + NONE: 0, + QUERY_FILTER: 1, + QUERY_SINGLE_HIT: 4, + DETECT_TRIGGER_EVENT: 8, + DETECT_CONTACT_EVENT: 16, + DETECT_CONTACT_POINT: 32, + DETECT_CONTACT_CCD: 64 + }; + class y { + get impl() { + return this._impl; + } + get collider() { + return this._com; + } + get attachedRigidBody() { + return this._attachedRigidBody; + } + constructor() { + f(); + } + initialize(t) { + t.node.updateWorldTransform(); + this._com = t; + this._impl.initialize(t.node); + r[this._impl.getObjectID()] = this; + p(t.node); + } + onLoad() { + this.setMaterial(this._com.sharedMaterial); + this.setCenter(this._com.center); + this.setAsTrigger(this._com.isTrigger); + } + onEnable() { + this._impl.onEnable(); + } + onDisable() { + this._impl.onDisable(); + } + onDestroy() { + m(this._com.node); + delete r[this._impl.getObjectID()]; + r[this._impl.getObjectID()] = null; + this._impl.onDestroy(); + } + setMaterial(t) { + const e = cc.PhysicsSystem.instance; + t || (t = e.defaultMaterial); + s.CACHE.material[t.id] || (s.CACHE.material[t.id] = e.physicsWorld.impl.createMaterial(t.id, t.friction, t.friction, t.restitution, 2, 2)); + this._impl.setMaterial(t.id, t.friction, t.friction, t.restitution, 2, 2); + } + setAsTrigger(t) { + this._impl.setAsTrigger(t); + } + setCenter(t) { + this._impl.setCenter(t.x, t.y, t.z); + } + getAABB(t) { + t.copy(this._impl.getAABB()); + } + getBoundingSphere(t) { + t.copy(this._impl.getBoundingSphere()); + } + updateEventListener() { + let t = 0; + t |= g.DETECT_CONTACT_CCD; + this._com.isTrigger && (t |= g.IS_TRIGGER); + (this._com.needTriggerEvent || this._com.needCollisionEvent) && (t |= g.NEED_EVENT); + this._impl.updateEventListener(t); + } + setGroup(t) { + this._impl.setGroup(t); + } + getGroup() { + return this._impl.getGroup(); + } + addGroup(t) { + this.setGroup(this.getGroup() | t); + } + removeGroup(t) { + this.setGroup(this.getGroup() & ~t); + } + setMask(t) { + this._impl.setMask(t >>> 0); + } + getMask() { + return this._impl.getMask(); + } + addMask(t) { + this.setMask(this.getMask() | t); + } + removeMask(t) { + this.setMask(this.getMask() & ~t); + } + } + class b { + get impl() { + return this._impl; + } + get joint() { + return this._com; + } + setEnableCollision(t) { + this._impl.setEnableCollision(t); + } + setConnectedBody(t) { + this._impl.setConnectedBody(t ? t.body.impl.getObjectID() : 0); + } + initialize(t) { + this._com = t; + this._impl.initialize(t.node); + r[this._impl.getObjectID()] = this; + this.onLoad(); + } + onLoad() { + this.setConnectedBody(this._com.connectedBody); + this.setEnableCollision(this._com.enableCollision); + } + onEnable() { + this._impl.onEnable(); + } + onDisable() { + this._impl.onDisable(); + } + onDestroy() { + delete r[this._impl.getObjectID()]; + r[this._impl.getObjectID()] = null; + this._impl.onDestroy(); + } + } + cc.physics.selector.register("physx", { + PhysicsWorld: class { + get impl() { + return this._impl; + } + constructor() { + this._impl = new s.World; + } + setGravity(t) { + this._impl.setGravity(t.x, t.y, t.z); + } + setAllowSleep(t) { + this._impl.setAllowSleep(t); + } + setDefaultMaterial(t) {} + step(t, e, i) { + this._impl.step(t); + } + raycast(t, e, i, s) { + o.origin = t.o; + o.unitDir = t.d; + o.mask = e.mask >>> 0; + o.distance = e.maxDistance; + o.queryTrigger = !!e.queryTrigger; + const n = this._impl.raycast(o); + if (n) { + const t = this._impl.raycastResult(); + for (let e = 0; e < t.length; e++) { + const n = t[e]; + const o = i.add(); + o._assign(n.hitPoint, n.distance, r[n.shape].collider, n.hitNormal); + s.push(o); + } + } + return n; + } + raycastClosest(t, e, i) { + o.origin = t.o; + o.unitDir = t.d; + o.mask = e.mask >>> 0; + o.distance = e.maxDistance; + o.queryTrigger = !!e.queryTrigger; + const s = this._impl.raycastClosest(o); + if (s) { + const t = this._impl.raycastClosestResult(); + i._assign(t.hitPoint, t.distance, r[t.shape].collider, t.hitNormal); + } + return s; + } + emitEvents() { + this.emitTriggerEvent(); + this.emitCollisionEvent(); + this._impl.emitEvents(); + } + syncSceneToPhysics() { + this._impl.syncSceneToPhysics(); + } + syncAfterEvents() {} + destroy() { + this._impl.destroy(); + } + emitTriggerEvent() { + const t = this._impl.getTriggerEventPairs(); + const e = t.length / 3; + for (let i = 0; i < e; i++) { + const e = 3 * i; + const s = r[t[e + 0]]; + const n = r[t[e + 1]]; + if (!s || !n) continue; + const o = s.collider; + const a = n.collider; + if (!(o && o.isValid && a && a.isValid)) continue; + if (!o.needTriggerEvent && !a.needTriggerEvent) continue; + const l = t[e + 2]; + h(1 === l ? "onTriggerStay" : 0 === l ? "onTriggerEnter" : "onTriggerExit", o, a, t); + } + } + emitCollisionEvent() { + const t = this._impl.getContactEventPairs(); + const e = t.length / 4; + for (let i = 0; i < e; i++) { + const e = 4 * i; + const s = r[t[e + 0]]; + const n = r[t[e + 1]]; + if (!s || !n) continue; + const o = s.collider; + const a = n.collider; + if (!(o && o.isValid && a && a.isValid)) continue; + if (!o.needCollisionEvent && !a.needCollisionEvent) continue; + const l = t[e + 2]; + d(1 === l ? "onCollisionStay" : 0 === l ? "onCollisionEnter" : "onCollisionExit", o, a, t, t[e + 3]); + } + } + }, + RigidBody: class { + get impl() { + return this._impl; + } + get rigidBody() { + return this._com; + } + get isAwake() { + return this._impl.isAwake(); + } + get isSleepy() { + return !1; + } + get isSleeping() { + return this._impl.isSleeping(); + } + constructor() { + f(); + this._impl = new s.RigidBody; + this._isUsingCCD = !1; + } + initialize(t) { + t.node.updateWorldTransform(); + this._com = t; + this._impl.initialize(t.node, t.type, t._group); + p(t.node); + } + onEnable() { + this.setType(this._com.type); + this.setMass(this._com.mass); + this.setAllowSleep(this._com.allowSleep); + this.setLinearDamping(this._com.linearDamping); + this.setAngularDamping(this._com.angularDamping); + this.setLinearFactor(this._com.linearFactor); + this.setAngularFactor(this._com.angularFactor); + this.useGravity(this._com.useGravity); + this._impl.onEnable(); + } + onDisable() { + this._impl.onDisable(); + } + onDestroy() { + m(this._com.node); + this._impl.onDestroy(); + } + setGroup(t) { + this._impl.setGroup(t); + } + getGroup() { + return this._impl.getGroup(); + } + addGroup(t) { + this.setGroup(this.getGroup() | t); + } + removeGroup(t) { + this.setGroup(this.getGroup() & ~t); + } + setMask(t) { + this._impl.setMask(t >>> 0); + } + getMask() { + return this._impl.getMask(); + } + addMask(t) { + this.setMask(this.getMask() | t); + } + removeMask(t) { + this.setMask(this.getMask() & ~t); + } + setType(t) { + this._impl.setType(t); + } + setMass(t) { + this._impl.setMass(t); + } + setAllowSleep(t) { + this._impl.setAllowSleep(t); + } + setLinearDamping(t) { + const e = cc.PhysicsSystem.instance.fixedTimeStep; + this._impl.setLinearDamping((1 - (1 - t) ** e) / e); + } + setAngularDamping(t) { + const e = cc.PhysicsSystem.instance.fixedTimeStep; + this._impl.setAngularDamping((1 - (1 - t) ** e) / e); + } + isUsingCCD() { + return this._isUsingCCD; + } + useCCD(t) { + this._isUsingCCD = t; + return this._impl.useCCD(t); + } + useGravity(t) { + this._impl.useGravity(t); + } + setLinearFactor(t) { + this._impl.setLinearFactor(t.x, t.y, t.z); + } + setAngularFactor(t) { + this._impl.setAngularFactor(t.x, t.y, t.z); + } + wakeUp() { + this._impl.wakeUp(); + } + sleep() { + this._impl.sleep(); + } + clearState() { + this._impl.clearState(); + } + clearForces() { + this._impl.clearForces(); + } + clearVelocity() { + this._impl.clearVelocity(); + } + setSleepThreshold(t) { + this._impl.setSleepThreshold(t); + } + getSleepThreshold() { + return this._impl.getSleepThreshold(); + } + getLinearVelocity(t) { + t.set(this._impl.getLinearVelocity()); + } + setLinearVelocity(t) { + this._impl.setLinearVelocity(t.x, t.y, t.z); + } + getAngularVelocity(t) { + t.set(this._impl.getAngularVelocity()); + } + setAngularVelocity(t) { + this._impl.setAngularVelocity(t.x, t.y, t.z); + } + applyForce(t, e) { + null == e && (e = cc.Vec3.ZERO); + this._impl.applyForce(t.x, t.y, t.z, e.x, e.y, e.z); + } + applyLocalForce(t, e) { + null == e && (e = cc.Vec3.ZERO); + this._impl.applyLocalForce(t.x, t.y, t.z, e.x, e.y, e.z); + } + applyImpulse(t, e) { + null == e && (e = cc.Vec3.ZERO); + this._impl.applyImpulse(t.x, t.y, t.z, e.x, e.y, e.z); + } + applyLocalImpulse(t, e) { + null == e && (e = cc.Vec3.ZERO); + this._impl.applyLocalImpulse(t.x, t.y, t.z, e.x, e.y, e.z); + } + applyTorque(t) { + this._impl.applyTorque(t.x, t.y, t.z); + } + applyLocalTorque(t) { + this._impl.applyLocalTorque(t.x, t.y, t.z); + } + }, + SphereShape: class extends y { + constructor() { + super(); + this._impl = new s.SphereShape; + } + updateRadius() { + this._impl.setRadius(this.collider.radius); + } + onLoad() { + super.onLoad(); + this.updateRadius(); + } + }, + BoxShape: class extends y { + constructor() { + super(); + this._impl = new s.BoxShape; + } + updateSize() { + const t = this.collider.size; + this._impl.setSize(t.x, t.y, t.z); + } + onLoad() { + super.onLoad(); + this.updateSize(); + } + }, + PlaneShape: class extends y { + constructor() { + super(); + this._impl = new s.PlaneShape; + } + setConstant(t) { + this._impl.setConstant(t); + } + setNormal(t) { + this._impl.setNormal(t.x, t.y, t.z); + } + onLoad() { + super.onLoad(); + this.setNormal(this._com.normal); + this.setConstant(this._com.constant); + } + }, + CapsuleShape: class extends y { + constructor() { + super(); + this._impl = new s.CapsuleShape; + } + setRadius(t) { + this._impl.setRadius(t); + } + setDirection(t) { + this._impl.setDirection(t); + } + setCylinderHeight(t) { + this._impl.setCylinderHeight(t); + } + onLoad() { + super.onLoad(); + this.setRadius(this._com.radius); + this.setDirection(this._com.direction); + this.setCylinderHeight(this._com.cylinderHeight); + } + }, + ConeShape: class extends y { + constructor() { + super(); + this._impl = new s.ConeShape; + } + setRadius(t) { + this.updateGeometry(); + } + setDirection(t) { + this.updateGeometry(); + } + setHeight(t) { + this.updateGeometry(); + } + updateGeometry() { + this._impl.setCone(this._com.radius, this._com.height, this._com.direction); + } + initialize(t) { + if (!s.CACHE.convex.CONE) { + const t = cc.physics.utils.cylinder(0, .5, 1, { + radialSegments: 32, + heightSegments: 1 + }); + const e = cc.physics.utils.shrinkPositions(t.positions); + const i = { + positions: new Float32Array(e), + positionLength: e.length / 3 + }; + const n = cc.PhysicsSystem.instance.physicsWorld.impl.createConvex(i); + s.CACHE.convex.CONE = n; + } + this._com = t; + this._impl.setCone(t.radius, t.height, t.direction); + this._impl.setConvex(s.CACHE.convex.CONE); + super.initialize(t); + } + }, + CylinderShape: class extends y { + constructor() { + super(); + this._impl = new s.CylinderShape; + } + setRadius(t) { + this.updateGeometry(); + } + setDirection(t) { + this.updateGeometry(); + } + setHeight(t) { + this.updateGeometry(); + } + updateGeometry() { + this._impl.setCylinder(this._com.radius, this._com.height, this._com.direction); + } + initialize(t) { + if (!s.CACHE.convex.CYLINDER) { + const t = cc.physics.utils.cylinder(.5, .5, 2, { + radialSegments: 32, + heightSegments: 1 + }); + const e = cc.physics.utils.shrinkPositions(t.positions); + const i = { + positions: new Float32Array(e), + positionLength: e.length / 3 + }; + const n = cc.PhysicsSystem.instance.physicsWorld.impl.createConvex(i); + s.CACHE.convex.CYLINDER = n; + } + this._com = t; + this._impl.setCylinder(t.radius, t.height, t.direction); + this._impl.setConvex(s.CACHE.convex.CYLINDER); + super.initialize(t); + } + }, + TrimeshShape: class extends y { + constructor() { + super(); + this._impl = new s.TrimeshShape; + } + setConvex(t) { + this._impl.useConvex(t); + } + setMesh(t) { + if (!t) return; + const e = this._com.convex; + this._impl.useConvex(e); + const i = e ? function(t) { + if (!s.CACHE.convex[t._uuid]) { + const e = cc.physics.utils.shrinkPositions(t.readAttribute(0, "a_position")); + const i = cc.PhysicsSystem.instance.physicsWorld.impl; + const n = { + positions: new Float32Array(e), + positionLength: e.length / 3 + }; + s.CACHE.convex[t._uuid] = i.createConvex(n); + } + return s.CACHE.convex[t._uuid]; + }(t) : function(t) { + if (!s.CACHE.trimesh[t._uuid]) { + const e = t.readIndices(0); + const i = t.readAttribute(0, "a_position"); + const n = cc.PhysicsSystem.instance.physicsWorld.impl; + const r = { + positions: new Float32Array(i), + positionLength: i.length / 3, + triangles: new Uint16Array(e), + triangleLength: e.length / 3, + isU16: !0 + }; + s.CACHE.trimesh[t._uuid] = n.createTrimesh(r); + } + return s.CACHE.trimesh[t._uuid]; + }(t); + this._impl.setMesh(i); + } + initialize(t) { + this._com = t; + this.setConvex(t.convex); + this.setMesh(t.mesh); + super.initialize(t); + } + }, + TerrainShape: class extends y { + constructor() { + super(); + this._impl = new s.TerrainShape; + } + setTerrain(t) { + if (!t) return; + const e = function(t) { + if (!s.CACHE.height[t._uuid]) { + const e = t.getVertexCountI(); + const i = t.getVertexCountJ(); + const n = new Int16Array(e * i); + const r = s.CONFIG.heightScale; + for (let s = 0; s < e; s++) for (let e = 0; e < i; e++) n[e + s * i] = t.getHeight(s, e) / r; + const o = { + rows: e, + columns: i, + samples: n + }; + const a = cc.PhysicsSystem.instance.physicsWorld.impl; + s.CACHE.height[t._uuid] = a.createHeightField(o); + } + return s.CACHE.height[t._uuid]; + }(t); + this._impl.setTerrain(e, t.tileSize, t.tileSize, s.CONFIG.heightScale); + } + initialize(t) { + this._com = t; + this.setTerrain(t.terrain); + super.initialize(t); + } + }, + PointToPointConstraint: class extends b { + constructor() { + super(); + this._impl = new s.DistanceJoint; + } + setPivotA(t) { + this._impl.setPivotA(t.x, t.y, t.z); + } + setPivotB(t) { + this._impl.setPivotB(t.x, t.y, t.z); + } + onLoad() { + super.onLoad(); + this.setPivotA(this._com.pivotA); + this.setPivotB(this._com.pivotB); + } + }, + HingeConstraint: class extends b { + constructor() { + super(); + this._impl = new s.RevoluteJoint; + } + setAxis(t) { + this._impl.setAxis(t.x, t.y, t.z); + } + setPivotA(t) { + this._impl.setPivotA(t.x, t.y, t.z); + } + setPivotB(t) { + this._impl.setPivotB(t.x, t.y, t.z); + } + onLoad() { + super.onLoad(); + this.setAxis(this._com.axis); + this.setPivotA(this._com.pivotA); + this.setPivotB(this._com.pivotB); + } + } + }); + }, {} ], + 12: [ function(t, e, i) { + const s = t("./jsb-cache-manager"); + !function() { + if (void 0 === window.spine || void 0 === window.middleware) return; + if (void 0 === cc.internal.SpineSkeletonData) return; + const t = window.spine; + const e = window.middleware; + e.generateGetSet(t); + Object.defineProperty(t, "timeScale", { + get() { + return this._timeScale; + }, + set(e) { + this._timeScale = e; + t.SkeletonAnimation.setGlobalTimeScale(e); + }, + configurable: !0 + }); + const i = cc.color(0, 0, 255, 255); + const n = cc.color(255, 0, 0, 255); + const r = cc.color(255, 255, 0, 255); + const o = cc.color(0, 255, 0, 255); + const a = cc.internal.SpineSkeletonData.prototype; + let l = 1; + const h = {}; + const c = new WeakMap; + const u = t.SkeletonDataMgr.getInstance(); + t.skeletonDataMgr = u; + u.setDestroyCallback((t => { + if (!t) return; + const e = h[t]; + if (e && c.has(e)) { + c.delete(e); + delete h[t]; + } + })); + const _ = t.SkeletonCacheMgr.getInstance(); + t.skeletonCacheMgr = _; + a.destroy = function() { + this.reset(); + _.removeSkeletonCache(this._uuid); + cc.Asset.prototype.destroy.call(this); + }; + a.reset = function() { + if (this._skeletonCache) { + t.disposeSkeletonData(this._uuid); + this._jsbTextures = null; + this._skeletonCache = null; + } + this._atlasCache = null; + }; + a.getRuntimeData = function() { + this._skeletonCache || this.init(); + return this._skeletonCache; + }; + a.init = function() { + if (this._skeletonCache) return; + const i = this._uuid; + if (!i) { + cc.errorID(7504); + return; + } + const n = this.atlasText; + if (!n) { + cc.errorID(7508, this.name); + return; + } + const r = this.textures; + const o = this.textureNames; + if (!(r && r.length > 0 && o && o.length > 0)) { + cc.errorID(7507, this.name); + return; + } + const a = {}; + for (let t = 0; t < r.length; ++t) { + const i = r[t]; + const s = this.recordTexture(i); + const n = new e.Texture2D; + n.setRealTextureIndex(s); + n.setPixelsWide(i.width); + n.setPixelsHigh(i.height); + a[o[t]] = n; + } + this._jsbTextures = a; + let l = null; + l = this.skeletonJsonStr ? this.skeletonJsonStr : s.getCache(this.nativeUrl) || this.nativeUrl; + this._skeletonCache = t.initSkeletonData(i, l, n, a, this.scale); + if (this._skeletonCache) { + this.width = this._skeletonCache.getWidth(); + this.height = this._skeletonCache.getHeight(); + } + }; + a.recordTexture = function(t) { + const e = l; + const i = h[e] = { + key: e + }; + c.set(i, t); + l++; + return e; + }; + a.getTextureByIndex = function(t) { + const e = h[t]; + return e ? c.get(e) : null; + }; + const d = t.SkeletonAnimation.prototype; + d.setCompleteListener = function(t) { + this._compeleteListener = t; + this.setCompleteListenerNative((function(t) { + const e = Math.floor(t.trackTime / t.animationEnd); + this._compeleteListener && this._compeleteListener(t, e); + })); + }; + d.setTrackCompleteListener = function(t, e) { + this._trackCompeleteListener = e; + this.setTrackCompleteListenerNative(t, (function(t) { + const e = Math.floor(t.trackTime / t.animationEnd); + this._trackCompeleteListener && this._trackCompeleteListener(t, e); + })); + }; + d.setAnimationListener = function(t, e) { + this._target = t; + this._callback = e; + const i = legacyCC.internal.SpineAnimationEventType; + this.setStartListener((function(t) { + this._target && this._callback && this._callback.call(this._target, this, t, i.START, null, 0); + })); + this.setInterruptListener((function(t) { + this._target && this._callback && this._callback.call(this._target, this, t, i.INTERRUPT, null, 0); + })); + this.setEndListener((function(t) { + this._target && this._callback && this._callback.call(this._target, this, t, i.END, null, 0); + })); + this.setDisposeListener((function(t) { + this._target && this._callback && this._callback.call(this._target, this, t, i.DISPOSE, null, 0); + })); + this.setCompleteListener((function(t, e) { + this._target && this._callback && this._callback.call(this._target, this, t, i.COMPLETE, null, e); + })); + this.setEventListener((function(t, e) { + this._target && this._callback && this._callback.call(this._target, this, t, i.EVENT, e, 0); + })); + }; + const p = cc.internal.SpineSkeleton.prototype; + const m = cc.internal.SpineSkeleton.AnimationCacheMode; + Object.defineProperty(p, "paused", { + get() { + return this._paused || !1; + }, + set(t) { + this._paused = t; + this._nativeSkeleton && this._nativeSkeleton.paused(t); + } + }); + Object.defineProperty(p, "premultipliedAlpha", { + get() { + return void 0 === this._premultipliedAlpha || this._premultipliedAlpha; + }, + set(t) { + this._premultipliedAlpha = t; + this._nativeSkeleton && this._nativeSkeleton.setOpacityModifyRGB(this._premultipliedAlpha); + } + }); + Object.defineProperty(p, "timeScale", { + get() { + return void 0 === this._timeScale ? 1 : this._timeScale; + }, + set(t) { + this._timeScale = t; + this._nativeSkeleton && this._nativeSkeleton.setTimeScale(this._timeScale); + } + }); + const f = p._updateDebugDraw; + p._updateDebugDraw = function() { + f.call(this); + if (this._nativeSkeleton && !this.isAnimationCached()) { + this._nativeSkeleton.setDebugMeshEnabled(this.debugMesh); + this._nativeSkeleton.setDebugSlotsEnabled(this.debugSlots); + this._nativeSkeleton.setDebugBonesEnabled(this.debugBones); + } + }; + const g = p._updateUseTint; + p._updateUseTint = function() { + g.call(this); + this._nativeSkeleton && this._nativeSkeleton.setUseTint(this.useTint); + }; + p.setSkeletonData = function(e) { + if (null != e.width && null != e.height) { + this.node._uiProps.uiTransformComp.setContentSize(e.width, e.height); + } + const i = e._uuid; + if (!i) { + cc.errorID(7504); + return; + } + const s = e.textures; + const n = e.textureNames; + if (!(s && s.length > 0 && n && n.length > 0)) { + cc.errorID(7507, e.name); + return; + } + if (this._nativeSkeleton) { + this._nativeSkeleton.stopSchedule(); + this._nativeSkeleton._comp = null; + this._nativeSkeleton = null; + } + let r = null; + if (this.isAnimationCached()) r = new t.SkeletonCacheAnimation(i, this._cacheMode === m.SHARED_CACHE); else { + r = new t.SkeletonAnimation; + try { + t.initSkeletonRenderer(r, i); + } catch (t) { + cc._throw(t); + return; + } + r.setDebugSlotsEnabled(this.debugSlots); + r.setDebugMeshEnabled(this.debugMesh); + r.setDebugBonesEnabled(this.debugBones); + } + this._nativeSkeleton = r; + r._comp = this; + r.setUseTint(this.useTint); + r.setOpacityModifyRGB(this.premultipliedAlpha); + r.setTimeScale(this.timeScale); + r.setBatchEnabled(this.enableBatch); + const o = this.color; + r.setColor(o.r, o.g, o.b, o.a); + this._skeleton = r.getSkeleton(); + this._startListener && this.setStartListener(this._startListener); + this._endListener && this.setEndListener(this._endListener); + this._completeListener && this.setCompleteListener(this._completeListener); + this._eventListener && this.setEventListener(this._eventListener); + this._interruptListener && this.setInterruptListener(this._interruptListener); + this._disposeListener && this.setDisposeListener(this._disposeListener); + this._sharedBufferOffset = r.getSharedBufferOffset(); + this._sharedBufferOffset[0] = 0; + this._useAttach = !1; + this._renderOrder = -1; + this._paramsBuffer = r.getParamsBuffer(); + this.syncTransform(!0); + this.markForUpdateRenderData(); + }; + p._updateColor = function() { + if (this._nativeSkeleton) { + const t = this.color; + this._nativeSkeleton.setColor(t.r, t.g, t.b, t.a); + this.markForUpdateRenderData(); + } + }; + p.setAnimationStateData = function(t) { + if (this._nativeSkeleton && !this.isAnimationCached()) { + this._stateData = t; + this._nativeSkeleton.setAnimationStateData(t); + } + }; + const y = p.onEnable; + p.onEnable = function() { + y && y.call(this); + this._nativeSkeleton && this._nativeSkeleton.onEnable(); + this.syncTransform(!0); + e.retain(); + }; + const b = p.onDisable; + p.onDisable = function() { + b && b.call(this); + this._nativeSkeleton && this._nativeSkeleton.onDisable(); + e.release(); + }; + p.setVertexEffectDelegate = function(t) { + this._nativeSkeleton && !this.isAnimationCached() && this._nativeSkeleton.setVertexEffectDelegate(t); + }; + p.syncTransform = function(t) { + const e = this.node; + if (!e) return; + const i = this._paramsBuffer; + if (i && (t || e.hasChangedFlags || e._dirtyFlags)) { + const t = e.getWorldMatrix(); + i[1] = t.m00; + i[2] = t.m01; + i[3] = t.m02; + i[4] = t.m03; + i[5] = t.m04; + i[6] = t.m05; + i[7] = t.m06; + i[8] = t.m07; + i[9] = t.m08; + i[10] = t.m09; + i[11] = t.m10; + i[12] = t.m11; + i[13] = t.m12; + i[14] = t.m13; + i[15] = t.m14; + i[16] = t.m15; + } + }; + p.updateAnimation = function(t) { + const s = this._nativeSkeleton; + if (!s) return; + if (!this.node) return; + const a = this._paramsBuffer; + if (this._renderOrder !== e.renderOrder) { + a[0] = e.renderOrder; + this._renderOrder = e.renderOrder; + e.renderOrder++; + } + this.syncTransform(); + if (void 0 === this.__preColor__ || !this.color.equals(this.__preColor__)) { + const t = this.color; + s.setColor(t.r, t.g, t.b, t.a); + this.__preColor__ = t; + } + const l = this.socketNodes; + if (!this._useAttach && l.size > 0) { + this._useAttach = !0; + s.setAttachEnabled(!0); + } + if (!this.isAnimationCached() && (this.debugBones || this.debugSlots || this.debugMesh) && this._debugRenderer) { + const t = this._debugRenderer; + t.clear(); + t.lineWidth = 5; + const e = this._debugData || s.getDebugData(); + if (!e) return; + let a = 0; + let l = 0; + let h = 0; + l = e[a++]; + for (;0 !== l; ) { + h = e[a++]; + switch (l) { + case 1: + t.strokeColor = i; + for (let i = 0; i < h; i += 8) { + t.moveTo(e[a++], e[a++]); + t.lineTo(e[a++], e[a++]); + t.lineTo(e[a++], e[a++]); + t.lineTo(e[a++], e[a++]); + t.close(); + t.stroke(); + } + break; + + case 2: + t.strokeColor = r; + for (let i = 0; i < h; i += 6) { + t.moveTo(e[a++], e[a++]); + t.lineTo(e[a++], e[a++]); + t.lineTo(e[a++], e[a++]); + t.close(); + t.stroke(); + } + break; + + case 3: + t.strokeColor = n; + t.fillColor = i; + for (let i = 0; i < h; i += 4) { + const s = e[a++]; + const n = e[a++]; + const r = e[a++]; + const l = e[a++]; + t.moveTo(s, n); + t.lineTo(r, l); + t.stroke(); + t.circle(s, n, 1.5 * Math.PI); + t.fill(); + 0 === i && (t.fillColor = o); + } + break; + + default: + return; + } + l = e[a++]; + } + } + }; + p.updateWorldTransform = function() { + this._nativeSkeleton && !this.isAnimationCached() && this._nativeSkeleton.updateWorldTransform(); + }; + p.setToSetupPose = function() { + this._nativeSkeleton && this._nativeSkeleton.setToSetupPose(); + }; + p.setBonesToSetupPose = function() { + this._nativeSkeleton && this._nativeSkeleton.setBonesToSetupPose(); + }; + p.setSlotsToSetupPose = function() { + this._nativeSkeleton && this._nativeSkeleton.setSlotsToSetupPose(); + }; + p.setSlotsRange = function(t, e) { + this._nativeSkeleton && !this.isAnimationCached() && this._nativeSkeleton.setSlotsRange(t, e); + }; + p.updateAnimationCache = function(t) { + this.isAnimationCached() && this._nativeSkeleton && (t ? this._nativeSkeleton.updateAnimationCache(t) : this._nativeSkeleton.updateAllAnimationCache()); + }; + p.invalidAnimationCache = function() { + this.isAnimationCached() && this._nativeSkeleton && this._nativeSkeleton.updateAllAnimationCache(); + }; + p.findBone = function(t) { + return this._nativeSkeleton ? this._nativeSkeleton.findBone(t) : null; + }; + p.findSlot = function(t) { + return this._nativeSkeleton ? this._nativeSkeleton.findSlot(t) : null; + }; + p.setSkin = function(t) { + return this._nativeSkeleton ? this._nativeSkeleton.setSkin(t) : null; + }; + p.getAttachment = function(t, e) { + return this._nativeSkeleton ? this._nativeSkeleton.getAttachment(t, e) : null; + }; + p.setAttachment = function(t, e) { + this._nativeSkeleton && this._nativeSkeleton.setAttachment(t, e); + }; + p.getTextureAtlas = function(t) { + cc.warn("Spine Skeleton getTextureAtlas not support in native"); + return null; + }; + p.setMix = function(t, e, i) { + this._nativeSkeleton && !this.isAnimationCached() && this._nativeSkeleton.setMix(t, e, i); + }; + p.setAnimation = function(t, e, i) { + const s = e.toString(); + this._animationName = s; + this._playTimes = i ? 0 : 1; + let n = null; + if (this._nativeSkeleton) { + n = this.isAnimationCached() ? this._nativeSkeleton.setAnimation(s, i) : this._nativeSkeleton.setAnimation(t, s, i); + this._nativeSkeleton.update(0); + } + return n; + }; + p.addAnimation = function(t, e, i, s) { + if (this._nativeSkeleton) { + s = s || 0; + return this.isAnimationCached() ? this._nativeSkeleton.addAnimation(e, i, s) : this._nativeSkeleton.addAnimation(t, e, i, s); + } + return null; + }; + p.findAnimation = function(t) { + return this._nativeSkeleton ? this._nativeSkeleton.findAnimation(t) : null; + }; + p.getCurrent = function(t) { + return this._nativeSkeleton && !this.isAnimationCached() ? this._nativeSkeleton.getCurrent(t) : null; + }; + p.clearTracks = function() { + this._nativeSkeleton && !this.isAnimationCached() && this._nativeSkeleton.clearTracks(); + }; + p.clearTrack = function(t) { + this._nativeSkeleton && !this.isAnimationCached() && this._nativeSkeleton.clearTrack(t); + }; + p.setStartListener = function(t) { + this._startListener = t; + this._nativeSkeleton && (this.isAnimationCached() ? this._nativeSkeleton.setStartListener((function(t) { + const e = this._comp; + e._startEntry.animation.name = t; + e._startListener && e._startListener(e._startEntry); + })) : this._nativeSkeleton.setStartListener(t)); + }; + p.setInterruptListener = function(t) { + this._interruptListener = t; + this._nativeSkeleton && !this.isAnimationCached() && this._nativeSkeleton.setInterruptListener(t); + }; + p.setEndListener = function(t) { + this._endListener = t; + this._nativeSkeleton && (this.isAnimationCached() ? this._nativeSkeleton.setEndListener((function(t) { + const e = this._comp; + e._endEntry.animation.name = t; + e._endListener && e._endListener(e._endEntry); + })) : this._nativeSkeleton.setEndListener(t)); + }; + p.setDisposeListener = function(t) { + this._disposeListener = t; + this._nativeSkeleton && !this.isAnimationCached() && this._nativeSkeleton.setDisposeListener(t); + }; + p.setCompleteListener = function(t) { + this._completeListener = t; + this._nativeSkeleton && (this.isAnimationCached() ? this._nativeSkeleton.setCompleteListener((function(t) { + const e = this._comp; + e._endEntry.animation.name = t; + e._completeListener && e._completeListener(e._endEntry); + })) : this._nativeSkeleton.setCompleteListener(t)); + }; + p.setEventListener = function(t) { + this._eventListener = t; + this._nativeSkeleton && !this.isAnimationCached() && this._nativeSkeleton.setEventListener(t); + }; + p.setTrackStartListener = function(t, e) { + this._nativeSkeleton && !this.isAnimationCached() && this._nativeSkeleton.setTrackStartListener(t, e); + }; + p.setTrackInterruptListener = function(t, e) { + this._nativeSkeleton && !this.isAnimationCached() && this._nativeSkeleton.setTrackInterruptListener(t, e); + }; + p.setTrackEndListener = function(t, e) { + this._nativeSkeleton && !this.isAnimationCached() && this._nativeSkeleton.setTrackEndListener(t, e); + }; + p.setTrackDisposeListener = function(t, e) { + this._nativeSkeleton && !this.isAnimationCached() && this._nativeSkeleton.setTrackDisposeListener(t, e); + }; + p.setTrackCompleteListener = function(t, e) { + this._nativeSkeleton && !this.isAnimationCached() && this._nativeSkeleton.setTrackCompleteListener(t, e); + }; + p.setTrackEventListener = function(t, e) { + this._nativeSkeleton && !this.isAnimationCached() && this._nativeSkeleton.setTrackEventListener(t, e); + }; + p.getState = function() { + return this._nativeSkeleton && !this.isAnimationCached() ? this._nativeSkeleton.getState() : null; + }; + p._ensureListener = function() { + cc.warn("Spine Skeleton _ensureListener not need in native"); + }; + p._updateSkeletonData = function() { + if (this.skeletonData) { + this.skeletonData.init(); + this.setSkeletonData(this.skeletonData); + this._indexBoneSockets(); + this.attachUtil.init(this); + this._preCacheMode = this._cacheMode; + this.defaultSkin && this._nativeSkeleton.setSkin(this.defaultSkin); + this.animation = this.defaultAnimation; + } else if (this._nativeSkeleton) { + this._nativeSkeleton.stopSchedule(); + this._nativeSkeleton._comp = null; + this._nativeSkeleton = null; + } + this._needUpdateSkeltonData = !1; + }; + const S = p.onDestroy; + p.onDestroy = function() { + S.call(this); + if (this._nativeSkeleton) { + this._nativeSkeleton.stopSchedule(); + this._nativeSkeleton._comp = null; + this._nativeSkeleton = null; + } + this._stateData = null; + }; + const A = cc.mat4(); + let T; + let v; + let E; + let C; + p._render = function(t) { + if (!this._nativeSkeleton) return; + if (!this.node) return; + const i = this.renderEntity; + i.clearDynamicRenderDrawInfos(); + const s = this._sharedBufferOffset; + if (!s) return; + const n = s[0]; + s[0] = 0; + const r = this.socketNodes; + if (r.size > 0) { + const t = e.attachInfoMgr.attachInfo; + const i = s[1]; + s[1] = 0; + for (const e of r.keys()) { + const s = r.get(e); + if (!s || !s.isValid) { + r.delete(e); + continue; + } + const n = A; + const o = i + 16 * e; + n.m00 = t[o]; + n.m01 = t[o + 1]; + n.m04 = t[o + 4]; + n.m05 = t[o + 5]; + n.m12 = t[o + 12]; + n.m13 = t[o + 13]; + s.matrix = n; + } + } + const o = e.renderInfoMgr.renderInfo; + let a = 0; + let l; + let h; + if (4294967295 !== o[n + a++]) return; + const c = o[n + a++]; + const u = this.useTint || this.isAnimationCached(); + const _ = u ? e.vfmtPosUvTwoColor : e.vfmtPosUvColor; + T = _; + if (0 !== c) for (let t = 0; t < c; t++) { + l = o[n + a++]; + h = this.skeletonData.getTextureByIndex(l); + if (!h) return; + const s = this.material; + this.material = this.getMaterialForBlendAndTint(o[n + a++], o[n + a++], u ? 1 : 0); + v = o[n + a++]; + E = o[n + a++]; + C = o[n + a++]; + const r = e.RenderInfoLookup[T][v]; + const c = this.requestDrawInfo(t); + c.setDrawInfoType(r.drawInfoType); + c.setAccAndBuffer(r.accessor.id, r.chunk.bufferId); + c.setTexture(h.getGFXTexture()); + c.setSampler(h.getGFXSampler()); + c.setMaterial(this.material); + c.setIndexOffset(E); + c.setIBCount(C); + i.setDynamicRenderDrawInfo(c, t); + this.material = s; + } + }; + const x = cc.internal.SpineAssembler; + x.createData = function(t) {}; + x.updateRenderData = function(t) { + t._render(); + }; + x.fillBuffers = function(t, e) {}; + }(); + }, { + "./jsb-cache-manager": 3 + } ], + 13: [ function(t, e, i) { + if (cc.internal.VideoPlayer) { + const {EventType: t} = cc.internal.VideoPlayer; + let e = cc.Vec3; + let i = cc.Mat4; + let s = new i; + let n = new e; + let r = new e; + cc.internal.VideoPlayerImplManager.getImpl = function(t) { + return new o(t); + }; + class o extends cc.internal.VideoPlayerImpl { + constructor(t) { + super(t); + this._matViewProj_temp = new i; + } + syncClip(t) { + this.removeVideoPlayer(); + t && this.createVideoPlayer(t._nativeAsset); + } + syncURL(t) { + this.removeVideoPlayer(); + t && this.createVideoPlayer(t); + } + onCanplay() { + if (!this._loaded) { + this._loaded = !0; + this.video.setVisible(this._visible); + this.dispatchEvent(t.READY_TO_PLAY); + this.delayedPlay(); + } + } + _bindEvent() { + this.video.addEventListener("loadedmetadata", this.onLoadedMetadata.bind(this)); + this.video.addEventListener("suspend", this.onCanPlay.bind(this)); + this.video.addEventListener("play", this.onPlay.bind(this)); + this.video.addEventListener("pause", this.onPause.bind(this)); + this.video.addEventListener("stoped", this.onStoped.bind(this)); + this.video.addEventListener("click", this.onClick.bind(this)); + this.video.addEventListener("ended", this.onEnded.bind(this)); + } + onLoadedMetadata() { + this._loadedMeta = !0; + this._forceUpdate = !0; + this._visible ? this.enable() : this.disable(); + this.dispatchEvent(t.META_LOADED); + this.delayedFullScreen(); + this.delayedPlay(); + } + createVideoPlayer(t) { + this._video = new jsb.VideoPlayer; + this._bindEvent(); + this._video.setVisible(this._visible); + this._video.setURL(t); + this._forceUpdate = !0; + } + removeVideoPlayer() { + let t = this.video; + if (t) { + t.stop(); + t.setVisible(!1); + t.destroy(); + this._playing = !1; + this._loaded = !1; + this._loadedMeta = !1; + this._ignorePause = !1; + this._cachedCurrentTime = 0; + this._video = null; + } + } + getDuration() { + return this.video ? this.video.duration() : -1; + } + syncPlaybackRate() { + cc.warn("The platform does not support"); + } + syncVolume() { + cc.warn("The platform does not support"); + } + syncMute() { + cc.warn("The platform does not support"); + } + syncLoop() { + cc.warn("The platform does not support"); + } + syncStayOnBottom() { + cc.warn("The platform does not support"); + } + getCurrentTime() { + if (this.video) { + this._cachedCurrentTime = this.video.currentTime(); + return this._cachedCurrentTime; + } + return -1; + } + seekTo(t) { + let e = this._video; + if (e) { + e.seekTo(t); + this._cachedCurrentTime = t; + } + } + disable(t) { + if (this.video) { + t || this.video.pause(); + this.video.setVisible(!1); + this._visible = !1; + } + } + enable() { + if (this.video) { + this.video.setVisible(!0); + this._visible = !0; + } + } + canPlay() { + this.video.play(); + this.syncCurrentTime(); + } + resume() { + if (this.video) { + this.video.resume(); + this.syncCurrentTime(); + this._playing = !0; + } + } + pause() { + if (this.video) { + this._cachedCurrentTime = this.video.currentTime(); + this.video.pause(); + } + } + stop() { + if (this.video) { + this._ignorePause = !0; + this.video.seekTo(0); + this._cachedCurrentTime = 0; + this.video.stop(); + } + } + canFullScreen(t) { + this.video && this.video.setFullScreenEnabled(t); + } + syncKeepAspectRatio(t) { + this.video && this.video.setKeepAspectRatioEnabled(t); + } + syncMatrix() { + if (!this._video || !this._component || !this._uiTrans) return; + const t = this.UICamera; + if (!t) return; + this._component.node.getWorldMatrix(s); + const {width: i, height: o} = this._uiTrans.contentSize; + if (!this._forceUpdate && t.matViewProj.equals(this._matViewProj_temp) && this._m00 === s.m00 && this._m01 === s.m01 && this._m04 === s.m04 && this._m05 === s.m05 && this._m12 === s.m12 && this._m13 === s.m13 && this._w === i && this._h === o) return; + this._matViewProj_temp.set(t.matViewProj); + this._m00 = s.m00; + this._m01 = s.m01; + this._m04 = s.m04; + this._m05 = s.m05; + this._m12 = s.m12; + this._m13 = s.m13; + this._w = i; + this._h = o; + cc.game.canvas.width; + let a = cc.game.canvas.height; + let l = this._uiTrans.anchorPoint; + e.set(n, -l.x * this._w, (1 - l.y) * this._h, 0); + e.set(r, (1 - l.x) * this._w, -l.y * this._h, 0); + e.transformMat4(n, n, s); + e.transformMat4(r, r, s); + t.update(); + t.worldToScreen(n, n); + t.worldToScreen(r, r); + let h = r.x - n.x; + let c = n.y - r.y; + this._video.setFrame(n.x, a - n.y, h, c); + this._forceUpdate = !1; + } + } + } + }, {} ], + 14: [ function(t, e, i) { + if (cc.internal.WebView) { + const {EventType: t} = cc.internal.WebView; + let e = cc.Vec3; + let i = cc.Mat4; + let s = new i; + let n = new e; + let r = new e; + cc.internal.WebViewImplManager.getImpl = function(t) { + return new o(t); + }; + class o extends cc.internal.WebViewImpl { + constructor(t) { + super(t); + this.jsCallback = null; + this.interfaceSchema = null; + this._matViewProj_temp = new i; + } + _bindEvent() { + this.webview.setOnDidFinishLoading((() => { + this._forceUpdate = !0; + this.dispatchEvent(t.LOADED); + })); + this.webview.setOnDidFailLoading((() => { + this.dispatchEvent(t.ERROR); + })); + this.jsCallback && this.setOnJSCallback(this.jsCallback); + this.interfaceSchema && this.setJavascriptInterfaceScheme(this.interfaceSchema); + this.jsCallback = null; + this.interfaceSchema = null; + } + createWebView() { + if (jsb.WebView) { + this._webview = jsb.WebView.create(); + this._bindEvent(); + } else console.warn("jsb.WebView is null"); + } + removeWebView() { + if (this.webview) { + this.webview.destroy(); + this.reset(); + } + } + disable() { + this.webview && this.webview.setVisible(!1); + } + enable() { + this.webview && this.webview.setVisible(!0); + } + setOnJSCallback(t) { + let e = this.webview; + e ? e.setOnJSCallback(t) : this.jsCallback = t; + } + setJavascriptInterfaceScheme(t) { + let e = this.webview; + e ? e.setJavascriptInterfaceScheme(t) : this.interfaceSchema = t; + } + loadURL(e) { + let i = this.webview; + if (i) { + i.src = e; + i.loadURL(e); + this.dispatchEvent(t.LOADING); + } + } + evaluateJS(t) { + let e = this.webview; + if (e) return e.evaluateJS(t); + } + syncMatrix() { + if (!this._webview || !this._component || !this._uiTrans) return; + const t = this.UICamera; + if (!t) return; + this._component.node.getWorldMatrix(s); + const {width: i, height: o} = this._uiTrans.contentSize; + if (!this._forceUpdate && t.matViewProj.equals(this._matViewProj_temp) && this._m00 === s.m00 && this._m01 === s.m01 && this._m04 === s.m04 && this._m05 === s.m05 && this._m12 === s.m12 && this._m13 === s.m13 && this._w === i && this._h === o) return; + this._matViewProj_temp.set(t.matViewProj); + this._m00 = s.m00; + this._m01 = s.m01; + this._m04 = s.m04; + this._m05 = s.m05; + this._m12 = s.m12; + this._m13 = s.m13; + this._w = i; + this._h = o; + cc.game.canvas.width; + let a = cc.game.canvas.height; + let l = this._uiTrans.anchorPoint; + e.set(n, -l.x * this._w, (1 - l.y) * this._h, 0); + e.set(r, (1 - l.x) * this._w, -l.y * this._h, 0); + e.transformMat4(n, n, s); + e.transformMat4(r, r, s); + t.update(); + t.worldToScreen(n, n); + t.worldToScreen(r, r); + let h = r.x - n.x; + let c = n.y - r.y; + this._webview.setFrame(n.x, a - n.y, h, c); + this._forceUpdate = !1; + } + } + } + }, {} ] + }, {}, [ 1 ]); + }, + 935: t => { + "use strict"; + var e = globalThis.requireNapi("display") || (isSystemplugin("display", "ohos") ? globalThis.ohosplugin.display : isSystemplugin("display", "system") ? globalThis.systemplugin.display : void 0); + window.oh = {}; + t.exports = function() { + return new Promise((t => { + "undefined" == typeof XMLHttpRequest && (window.XMLHttpRequest = function() {}); + e.getDefaultDisplay(((t, e) => { + window.oh.display = e; + })); + t(); + })); + }; + }, + 693: (t, e, i) => { + "use strict"; + var s; + var n, r; + !function t(e, i, s) { + function n(o, a) { + if (!i[o]) { + if (!e[o]) { + if (r) return r(o, !0); + var l = new Error("Cannot find module '" + o + "'"); + throw l.code = "MODULE_NOT_FOUND", l; + } + var h = i[o] = { + exports: {} + }; + e[o][0].call(h.exports, (function(t) { + return n(e[o][1][t] || t); + }), h, h.exports, t, e, i, s); + } + return i[o].exports; + } + for (var r = void 0, o = 0; o < s.length; o++) n(s[o]); + return n; + }({ + 1: [ function(t, e, i) { + var s = e.exports = {}; + var n; + var r; + function o() { + throw new Error("setTimeout has not been defined"); + } + function a() { + throw new Error("clearTimeout has not been defined"); + } + !function() { + try { + n = "function" == typeof setTimeout ? setTimeout : o; + } catch (t) { + n = o; + } + try { + r = "function" == typeof clearTimeout ? clearTimeout : a; + } catch (t) { + r = a; + } + }(); + function l(t) { + if (n === setTimeout) return setTimeout(t, 0); + if ((n === o || !n) && setTimeout) { + n = setTimeout; + return setTimeout(t, 0); + } + try { + return n(t, 0); + } catch (e) { + try { + return n.call(null, t, 0); + } catch (e) { + return n.call(this, t, 0); + } + } + } + var h = []; + var c = !1; + var u; + var _ = -1; + function d() { + if (c && u) { + c = !1; + u.length ? h = u.concat(h) : _ = -1; + h.length && p(); + } + } + function p() { + if (!c) { + var t = l(d); + c = !0; + var e = h.length; + for (;e; ) { + u = h; + h = []; + for (;++_ < e; ) u && u[_].run(); + _ = -1; + e = h.length; + } + u = null; + c = !1; + !function(t) { + if (r === clearTimeout) return clearTimeout(t); + if ((r === a || !r) && clearTimeout) { + r = clearTimeout; + return clearTimeout(t); + } + try { + r(t); + } catch (e) { + try { + return r.call(null, t); + } catch (e) { + return r.call(this, t); + } + } + }(t); + } + } + s.nextTick = function(t) { + var e = new Array(arguments.length - 1); + if (arguments.length > 1) for (var i = 1; i < arguments.length; i++) e[i - 1] = arguments[i]; + h.push(new m(t, e)); + 1 !== h.length || c || l(p); + }; + function m(t, e) { + this.fun = t; + this.array = e; + } + m.prototype.run = function() { + this.fun.apply(null, this.array); + }; + s.title = "browser"; + s.browser = !0; + s.env = {}; + s.argv = []; + s.version = ""; + s.versions = {}; + function f() {} + s.on = f; + s.addListener = f; + s.once = f; + s.off = f; + s.removeListener = f; + s.removeAllListeners = f; + s.emit = f; + s.prependListener = f; + s.prependOnceListener = f; + s.listeners = function(t) { + return []; + }; + s.binding = function(t) { + throw new Error("process.binding is not supported"); + }; + s.cwd = function() { + return "/"; + }; + s.chdir = function(t) { + throw new Error("process.chdir is not supported"); + }; + s.umask = function() { + return 0; + }; + }, {} ], + 2: [ function(t, e, i) { + (function(e, s) { + (function() { + var n = t("process/browser.js").nextTick; + var r = Function.prototype.apply; + var o = Array.prototype.slice; + var a = {}; + var l = 0; + i.setTimeout = function() { + return new h(r.call(setTimeout, window, arguments), clearTimeout); + }; + i.setInterval = function() { + return new h(r.call(setInterval, window, arguments), clearInterval); + }; + i.clearTimeout = i.clearInterval = function(t) { + t.close(); + }; + function h(t, e) { + this._id = t; + this._clearFn = e; + } + h.prototype.unref = h.prototype.ref = function() {}; + h.prototype.close = function() { + this._clearFn.call(window, this._id); + }; + i.enroll = function(t, e) { + clearTimeout(t._idleTimeoutId); + t._idleTimeout = e; + }; + i.unenroll = function(t) { + clearTimeout(t._idleTimeoutId); + t._idleTimeout = -1; + }; + i._unrefActive = i.active = function(t) { + clearTimeout(t._idleTimeoutId); + var e = t._idleTimeout; + e >= 0 && (t._idleTimeoutId = setTimeout((function() { + t._onTimeout && t._onTimeout(); + }), e)); + }; + i.setImmediate = "function" == typeof e ? e : function(t) { + var e = l++; + var s = !(arguments.length < 2) && o.call(arguments, 1); + a[e] = !0; + n((function() { + if (a[e]) { + s ? t.apply(null, s) : t.call(null); + i.clearImmediate(e); + } + })); + return e; + }; + i.clearImmediate = "function" == typeof s ? s : function(t) { + delete a[t]; + }; + }).call(this); + }).call(this, t("timers").setImmediate, t("timers").clearImmediate); + }, { + "process/browser.js": 1, + timers: 2 + } ], + 3: [ function(t, e, i) { + (function(t) { + (function() { + !function(t) { + s = [ i ], n = function(e) { + e.URL = t.URL || t.webkitURL; + if (t.Blob && t.URL) try { + new Blob; + return; + } catch (t) {} + var i = t.BlobBuilder || t.WebKitBlobBuilder || t.MozBlobBuilder || function() { + var i = function(t) { + return Object.prototype.toString.call(t).match(/^\[object\s(.*)\]$/)[1]; + }, s = function() { + this.data = []; + }, n = function(t, e, i) { + this.data = t; + this.size = t.length; + this.type = e; + this.encoding = i; + }, r = s.prototype, o = n.prototype, a = t.FileReaderSync, l = function(t) { + this.code = this[this.name = t]; + }, h = "NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR".split(" "), c = h.length, u = t.URL || t.webkitURL || e, _ = u.createObjectURL, d = u.revokeObjectURL, p = u, m = t.btoa, f = t.atob, g = t.ArrayBuffer, y = t.Uint8Array, b = /^[\w-]+:\/*\[?[\w\.:-]+\]?(?::[0-9]+)?/; + n.fake = o.fake = !0; + for (;c--; ) l.prototype[h[c]] = c + 1; + u.createObjectURL || (p = e.URL = function(t) { + var e, i = document.createElementNS("http://www.w3.org/1999/xhtml", "a"); + i.href = t; + if (!("origin" in i)) if ("data:" === i.protocol.toLowerCase()) i.origin = null; else { + e = t.match(b); + i.origin = e && e[1]; + } + return i; + }); + p.createObjectURL = function(t) { + var e, i = t.type; + null === i && (i = "application/octet-stream"); + if (t instanceof n) { + e = "data:" + i; + return "base64" === t.encoding ? e + ";base64," + t.data : "URI" === t.encoding ? e + "," + decodeURIComponent(t.data) : m ? e + ";base64," + m(t.data) : e + "," + encodeURIComponent(t.data); + } + if (_) return _.call(u, t); + }; + p.revokeObjectURL = function(t) { + "data:" !== t.substring(0, 5) && d && d.call(u, t); + }; + r.append = function(t) { + var e = this.data; + if (y && (t instanceof g || t instanceof y)) { + var s = "", r = new y(t), o = 0, h = r.length; + for (;o < h; o++) s += String.fromCharCode(r[o]); + e.push(s); + } else if ("Blob" === i(t) || "File" === i(t)) { + if (!a) throw new l("NOT_READABLE_ERR"); + var c = new a; + e.push(c.readAsBinaryString(t)); + } else if (t instanceof n) "base64" === t.encoding && f ? e.push(f(t.data)) : "URI" === t.encoding ? e.push(decodeURIComponent(t.data)) : "raw" === t.encoding && e.push(t.data); else { + "string" != typeof t && (t += ""); + e.push(unescape(encodeURIComponent(t))); + } + }; + r.getBlob = function(t) { + arguments.length || (t = null); + return new n(this.data.join(""), t, "raw"); + }; + r.toString = function() { + return "[object BlobBuilder]"; + }; + o.slice = function(t, e, i) { + var s = arguments.length; + s < 3 && (i = null); + return new n(this.data.slice(t, s > 1 ? e : this.data.length), i, this.encoding); + }; + o.toString = function() { + return "[object Blob]"; + }; + o.close = function() { + this.size = 0; + delete this.data; + }; + return s; + }(); + e.Blob = function(t, e) { + var s = e && e.type || ""; + var n = new i; + if (t) for (var r = 0, o = t.length; r < o; r++) Uint8Array && t[r] instanceof Uint8Array ? n.append(t[r].buffer) : n.append(t[r]); + var a = n.getBlob(s); + !a.slice && a.webkitSlice && (a.slice = a.webkitSlice); + return a; + }; + var s = Object.getPrototypeOf || function(t) { + return t.__proto__; + }; + e.Blob.prototype = s(new e.Blob); + }, void 0 !== (r = "function" == typeof n ? n.apply(i, s) : n) && (e.exports = r); + }("undefined" != typeof self && self || "undefined" != typeof window && window || void 0 !== t && t || (void 0).content || void 0); + }).call(this); + }).call(this, "undefined" != typeof global ? global : "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}); + }, {} ], + 4: [ function(t, e, i) { + !function() { + function t(t) { + this.message = t; + } + var e = void 0 !== i ? i : "undefined" != typeof self ? self : $.global, s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + t.prototype = new Error, t.prototype.name = "InvalidCharacterError", e.btoa || (e.btoa = function(e) { + for (var i, n, r = String(e), o = 0, a = s, l = ""; r.charAt(0 | o) || (a = "=", + o % 1); l += a.charAt(63 & i >> 8 - o % 1 * 8)) { + if ((n = r.charCodeAt(o += .75)) > 255) throw new t("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range."); + i = i << 8 | n; + } + return l; + }), e.atob || (e.atob = function(e) { + var i = String(e).replace(/[=]+$/, ""); + if (i.length % 4 == 1) throw new t("'atob' failed: The string to be decoded is not correctly encoded."); + for (var n, r, o = 0, a = 0, l = ""; r = i.charAt(a++); ~r && (n = o % 4 ? 64 * n + r : r, + o++ % 4) ? l += String.fromCharCode(255 & n >> (-2 * o & 6)) : 0) r = s.indexOf(r); + return l; + }); + }(); + }, {} ], + 5: [ function(t, e, i) { + jsb.device = jsb.Device; + const {btoa: s, atob: n} = t("./base64/base64.min"); + window.btoa = s; + window.atob = n; + const {Blob: r, URL: o} = t("./Blob"); + window.Blob = r; + window.URL = o; + window.DOMParser = t("./xmldom/dom-parser").DOMParser; + t("./jsb_prepare"); + t("./jsb-adapter"); + t("./jsb_audioengine"); + t("./jsb_input"); + let a = null; + let l = 0; + let h = {}; + let c = !0; + window.requestAnimationFrame = function(t) { + let e = ++l; + h[e] = t; + return e; + }; + window.cancelAnimationFrame = function(t) { + delete h[t]; + }; + let u = 0; + class _ { + constructor(t, e, i, s, n) { + this.cb = t; + this.id = ++u; + this.start = performance.now(); + this.delay = e; + this.isRepeat = i; + this.target = s; + this.args = n; + } + } + let d = {}; + function p(t, e) { + let i = t[0]; + if (!i) { + console.error("createTimeoutInfo doesn't pass a callback ..."); + return 0; + } + let s = t.length > 1 ? t[1] : 0; + let n; + t.length > 2 && (n = Array.prototype.slice.call(t, 2)); + let r = new _(i, s, e, this, n); + d[r.id] = r; + return r.id; + } + if (!window.oh) { + window.setTimeout = function(t) { + return p(arguments, !1); + }; + window.clearTimeout = function(t) { + delete d[t]; + }; + window.setInterval = function(t) { + return p(arguments, !0); + }; + window.clearInterval = window.clearTimeout; + } + window.alert = console.error.bind(console); + if (void 0 !== jsb.FileUtils) { + jsb.fileUtils = jsb.FileUtils.getInstance(); + delete jsb.FileUtils; + } + XMLHttpRequest.prototype.addEventListener = function(t, e, i) { + this["on" + t] = e; + }; + XMLHttpRequest.prototype.removeEventListener = function(t, e, i) { + this["on" + t] = null; + }; + if (window.SocketIO) { + window.io = window.SocketIO; + SocketIO.prototype._Emit = SocketIO.prototype.emit; + SocketIO.prototype.emit = function(t, e) { + "object" == typeof e && (e = JSON.stringify(e)); + this._Emit(t, e); + }; + } + window.gameTick = function(t) { + if (c) { + c = !1; + if (window.onload) { + var e = new Event("load"); + e._target = window; + window.onload(e); + } + } + !function(t) { + let e; + for (let i in d) { + e = d[i]; + if (e && e.cb && t - e.start >= e.delay) { + "string" == typeof e.cb ? Function(e.cb)() : "function" == typeof e.cb && e.cb.apply(e.target, e.args); + e.isRepeat ? e.start = t : delete d[i]; + } + } + }(t); + for (let e in h) { + a = h[e]; + if (a) { + delete h[e]; + a(t); + } + } + }; + jsb.generateGetSet = function(t) { + for (let e in t) { + let i = t[e] && t[e].prototype; + if (i) for (let t in i) { + if (-1 == t.search(/^get/)) continue; + let e = t.replace(/^get/, ""); + let s = e.split(""); + let n = s[0].toLowerCase(); + let r = s[0].toUpperCase(); + s.splice(0, 1); + let o = s.join(""); + e = n + o; + let a = "set" + r + o; + if (i.hasOwnProperty(e)) continue; + "function" == typeof i[a] ? Object.defineProperty(i, e, { + get() { + return this[t](); + }, + set(t) { + this[a](t); + }, + configurable: !0 + }) : Object.defineProperty(i, e, { + get() { + return this[t](); + }, + configurable: !0 + }); + } + } + }; + t("./promise.min"); + }, { + "./Blob": 3, + "./base64/base64.min": 4, + "./jsb-adapter": 30, + "./jsb_audioengine": 35, + "./jsb_input": 36, + "./jsb_prepare": 37, + "./promise.min": 38, + "./xmldom/dom-parser": 39 + } ], + 6: [ function(t, e, i) { + const s = t("./ImageData"); + class n { + constructor() { + this.lineWidth = void 0; + this.lineJoin = void 0; + this.fillStyle = void 0; + this.font = void 0; + this.lineCap = void 0; + this.textAlign = void 0; + this.textBaseline = void 0; + this.strokeStyle = void 0; + this.globalCompositeOperation = void 0; + this.shadowBlur = void 0; + this.shadowColor = void 0; + this.shadowOffsetX = void 0; + this.shadowOffsetY = void 0; + } + } + jsb.CanvasRenderingContext2D.prototype._ctor = function() { + this.__nativeRefs = {}; + }; + e.exports = class { + constructor(t, e) { + this._nativeObj = new jsb.CanvasRenderingContext2D(t, e); + this._attris = new n; + } + get width() { + return this._nativeObj.width; + } + set width(t) { + this._nativeObj.width = t; + } + get height() { + return this._nativeObj.height; + } + set height(t) { + this._nativeObj.height = t; + } + get lineWidth() { + return this._attris.lineWidth; + } + set lineWidth(t) { + this._attris.lineWidth = t; + } + get lineJoin() { + return this._attris.lineJoin; + } + set lineJoin(t) { + this._attris.lineJoin = t; + } + get fillStyle() { + return this._attris.fillStyle; + } + set fillStyle(t) { + this._attris.fillStyle = t; + } + get font() { + return this._attris.font; + } + set font(t) { + this._attris.font = t; + } + get lineCap() { + return this._attris.lineCap; + } + set lineCap(t) { + this._attris.lineCap = t; + } + get textAlign() { + return this._attris.textAlign; + } + set textAlign(t) { + this._attris.textAlign = t; + } + get textBaseline() { + return this._attris.textBaseline; + } + set textBaseline(t) { + this._attris.textBaseline = t; + } + get strokeStyle() { + return this._attris.strokeStyle; + } + set strokeStyle(t) { + this._attris.strokeStyle = t; + } + get globalCompositeOperation() { + return this._attris.globalCompositeOperation; + } + set globalCompositeOperation(t) { + this._attris.globalCompositeOperation = t; + } + get shadowBlur() { + return this._attris.shadowBlur; + } + set shadowBlur(t) { + this._attris.shadowBlur = t; + } + get shadowColor() { + return this._attris.shadowColor; + } + set shadowColor(t) { + this._attris.shadowColor = t; + } + get shadowOffsetX() { + return this._attris.shadowOffsetX; + } + set shadowOffsetX(t) { + this._attris.shadowOffsetX = t; + } + get shadowOffsetY() { + return this._attris.shadowOffsetY; + } + set shadowOffsetY(t) { + this._attris.shadowOffsetY = t; + } + restore() { + this._nativeObj.restore(); + } + moveTo(t, e) { + this._nativeObj.moveTo(t, e); + } + lineTo(t, e) { + this._nativeObj.lineTo(t, e); + } + setTransform(t, e, i, s, n, r) { + this._nativeObj.setTransform(t, e, i, s, n, r); + } + stroke() { + this._canvas._dataInner = null; + this._nativeObj.stroke(); + } + measureText(t) { + return this._nativeObj.measureText(t, this._attris); + } + fill() { + this._canvas._dataInner = null; + this._nativeObj.fill(); + } + _fillImageData(t, e, i, s, n) { + this._canvas._dataInner = null; + this._nativeObj._fillImageData(t, e, i, s, n); + } + scale(t, e) { + this._nativeObj.scale(t, e); + } + clearRect(t, e, i, s) { + this._canvas._dataInner = null; + this._nativeObj.clearRect(t, e, i, s); + } + transform(t, e, i, s, n, r) { + this._nativeObj.transform(t, e, i, s, n, r); + } + fillText(t, e, i, s) { + this._canvas._dataInner = null; + this._nativeObj.fillText(t, e, i, s, this._attris); + } + strokeText(t, e, i, s) { + this._canvas._dataInner = null; + this._nativeObj.strokeText(t, e, i, s, this._attris); + } + save() { + this._nativeObj.save(); + } + fillRect(t, e, i, s) { + this._canvas._dataInner = null; + this._nativeObj.fillRect(t, e, i, s, this._attris); + } + fetchData() { + void 0 !== this._nativeObj.fetchData && this._nativeObj.fetchData(); + } + rotate(t) { + this._nativeObj.rotate(t); + } + beginPath() { + this._nativeObj.beginPath(); + } + rect(t, e, i, s) { + this._nativeObj.rect(t, e, i, s); + } + translate(t, e) { + this._nativeObj.translate(t, e); + } + createLinearGradient(t, e, i, s) { + return this._nativeObj.createLinearGradient(t, e, i, s); + } + closePath() { + this._nativeObj.closePath(); + } + putImageData(t, e, i, s, n, r, o) { + this._canvas._data = t; + } + createImageData(t, e) { + return "number" == typeof t && "number" == typeof e ? new s(t, e) : t instanceof s ? new s(t.data, t.width, t.height) : void 0; + } + _setCanvasBufferUpdatedCallback(t) { + this._nativeObj._setCanvasBufferUpdatedCallback(t); + } + }; + }, { + "./ImageData": 22 + } ], + 7: [ function(t, e, i) { + e.exports = class { + constructor(t, e, i, s) { + this.x = t || 0; + this.y = e || 0; + this.width = i || 0; + this.height = s || 0; + this.left = this.x; + this.top = this.y; + this.right = this.x + this.width; + this.bottom = this.y + this.height; + } + }; + }, {} ], + 8: [ function(t, e, i) { + const s = t("./Event"); + e.exports = class extends s { + constructor(t) { + super("devicemotion"); + if (t) { + this._acceleration = t.acceleration ? t.acceleration : { + x: 0, + y: 0, + z: 0 + }; + this._accelerationIncludingGravity = t.accelerationIncludingGravity ? t.accelerationIncludingGravity : { + x: 0, + y: 0, + z: 0 + }; + this._rotationRate = t.rotationRate ? t.rotationRate : { + alpha: 0, + beta: 0, + gamma: 0 + }; + this._interval = t.interval; + } else { + this._acceleration = { + x: 0, + y: 0, + z: 0 + }; + this._accelerationIncludingGravity = { + x: 0, + y: 0, + z: 0 + }; + this._rotationRate = { + alpha: 0, + beta: 0, + gamma: 0 + }; + this._interval = 0; + } + } + get acceleration() { + return this._acceleration; + } + get accelerationIncludingGravity() { + return this._accelerationIncludingGravity; + } + get rotationRate() { + return this._rotationRate; + } + get interval() { + return this._interval; + } + }; + }, { + "./Event": 10 + } ], + 9: [ function(t, e, i) { + const s = t("./Node"); + const n = t("./DOMRect"); + e.exports = class extends s { + constructor() { + super(); + this.className = ""; + this.children = []; + this.clientLeft = 0; + this.clientTop = 0; + this.scrollLeft = 0; + this.scrollTop = 0; + } + get clientWidth() { + return 0; + } + get clientHeight() { + return 0; + } + getBoundingClientRect() { + return new n(0, 0, window.innerWidth, window.innerHeight); + } + removeAttribute(t) {} + }; + }, { + "./DOMRect": 7, + "./Node": 26 + } ], + 10: [ function(t, e, i) { + class s { + constructor(t, e) { + this._type = t; + this._target = null; + this._eventPhase = 2; + this._currentTarget = null; + this._canceled = !1; + this._stopped = !1; + this._passiveListener = null; + this._timeStamp = Date.now(); + } + get type() { + return this._type; + } + get target() { + return this._target; + } + get currentTarget() { + return this._currentTarget; + } + get isTrusted() { + return !1; + } + get timeStamp() { + return this._timeStamp; + } + composedPath() { + const t = this._currentTarget; + return null === t ? [] : [ t ]; + } + get eventPhase() { + return this._eventPhase; + } + stopPropagation() {} + stopImmediatePropagation() { + this._stopped = !0; + } + get bubbles() { + return !1; + } + get cancelable() { + return !0; + } + preventDefault() { + null === this._passiveListener ? this.cancelable && (this._canceled = !0) : console.warn("Event#preventDefault() was called from a passive listener:", this._passiveListener); + } + get defaultPrevented() { + return this._canceled; + } + get composed() { + return !1; + } + get timeStamp() { + return this._timeStamp; + } + } + s.NONE = 0; + s.CAPTURING_PHASE = 1; + s.AT_TARGET = 2; + s.BUBBLING_PHASE = 3; + e.exports = s; + }, {} ], + 11: [ function(t, e, i) { + var s = 0; + var n = { + touch: {}, + mouse: {}, + keyboard: {}, + devicemotion: {} + }; + var r = { + touch: 0, + mouse: 0, + keyboard: 0, + devicemotion: 0 + }; + var o = { + touch: null, + mouse: null, + keyboard: null, + devicemotion: null + }; + var a = { + touch: null, + mouse: null, + keyboard: null, + devicemotion: null + }; + const l = { + touch: [ "touchstart", "touchmove", "touchend", "touchcancel" ], + mouse: [ "mousedown", "mousemove", "mouseup", "mousewheel" ], + keyboard: [ "keydown", "keyup", "keypress" ], + devicemotion: [ "devicemotion" ] + }; + function h(t) { + return t && "object" == typeof t; + } + e.exports = class { + constructor() { + this._targetID = ++s; + this._listenerCount = { + touch: 0, + mouse: 0, + keyboard: 0, + devicemotion: 0 + }; + this._listeners = new Map; + } + _associateSystemEventListener(t) { + for (var e in l) if (l[e].indexOf(t) > -1) { + o[e] && 0 === r[e] && o[e](); + 0 === this._listenerCount[e] && (n[e][this._targetID] = this); + ++this._listenerCount[e]; + ++r[e]; + break; + } + } + _dissociateSystemEventListener(t) { + for (var e in l) if (l[e].indexOf(t) > -1) { + this._listenerCount[e] <= 0 && delete n[e][this._targetID]; + --r[e]; + a[e] && 0 === r[e] && a[e](); + break; + } + } + addEventListener(t, e, i) { + if (!e) return !1; + if ("function" != typeof e && !h(e)) throw new TypeError("'listener' should be a function or an object."); + const s = this._listeners; + const n = h(i); + const r = (n ? Boolean(i.capture) : Boolean(i)) ? 1 : 2; + const o = { + listener: e, + listenerType: r, + passive: n && Boolean(i.passive), + once: n && Boolean(i.once), + next: null + }; + let a = s.get(t); + if (void 0 === a) { + s.set(t, o); + this._associateSystemEventListener(t); + return !0; + } + let l = null; + for (;a; ) { + if (a.listener === e && a.listenerType === r) return !1; + l = a; + a = a.next; + } + l.next = o; + this._associateSystemEventListener(t); + return !0; + } + removeEventListener(t, e, i) { + if (!e) return !1; + const s = this._listeners; + const n = (h(i) ? Boolean(i.capture) : Boolean(i)) ? 1 : 2; + let r = null; + let o = s.get(t); + for (;o; ) { + if (o.listener === e && o.listenerType === n) { + r ? r.next = o.next : o.next ? s.set(t, o.next) : s.delete(t); + this._dissociateSystemEventListener(t); + return !0; + } + r = o; + o = o.next; + } + return !1; + } + dispatchEvent(t) { + if (!t || "string" != typeof t.type) throw new TypeError('"event.type" should be a string.'); + const e = t.type; + var i = this["on" + e]; + if (i && "function" == typeof i) { + t._target = t._currentTarget = this; + i.call(this, t); + t._target = t._currentTarget = null; + t._eventPhase = 0; + t._passiveListener = null; + if (t.defaultPrevented) return !1; + } + const s = this._listeners; + let n = s.get(e); + if (!n) return !0; + t._target = t._currentTarget = this; + let r = null; + for (;n; ) { + n.once ? r ? r.next = n.next : n.next ? s.set(e, n.next) : s.delete(e) : r = n; + t._passiveListener = n.passive ? n.listener : null; + "function" == typeof n.listener && n.listener.call(this, t); + if (t._stopped) break; + n = n.next; + } + t._target = t._currentTarget = null; + t._eventPhase = 0; + t._passiveListener = null; + return !t.defaultPrevented; + } + }; + }, {} ], + 12: [ function(t, e, i) { + const s = t("./EventTarget"); + e.exports = class extends s { + construct() { + this.result = null; + } + abort() {} + readAsArrayBuffer() {} + readAsDataURL(t) { + this.result = "data:image/png;base64," + window.btoa(t); + var e = new Event("load"); + this.dispatchEvent(e); + } + readAsText() {} + }; + }, { + "./EventTarget": 11 + } ], + 13: [ function(t, e, i) { + e.exports = class { + constructor(t, e, i) { + this.family = t; + this.source = e; + this.descriptors = i; + this._status = "unloaded"; + this._loaded = new Promise(((t, e) => { + this._resolveCB = t; + this._rejectCB = e; + })); + } + load() {} + get status() { + return this._status; + } + get loaded() { + return this._loaded; + } + }; + }, {} ], + 14: [ function(t, e, i) { + const s = t("./EventTarget"); + const n = t("./Event"); + e.exports = class extends s { + constructor() { + super(); + this._status = "loading"; + } + get status() { + return this._status; + } + set onloading(t) { + this.addEventListener("loading", t); + } + set onloadingdone(t) { + this.addEventListener("loadingdone", t); + } + set onloadingerror(t) { + this.addEventListener("loadingerror", t); + } + add(t) { + this._status = t._status = "loading"; + this.dispatchEvent(new n("loading")); + let e = jsb.loadFont(t.family, t.source); + setTimeout((() => { + if (e) { + t._status = this._status = "loaded"; + t._resolveCB(); + this.dispatchEvent(new n("loadingdone")); + } else { + t._status = this._status = "error"; + t._rejectCB(); + this.dispatchEvent(new n("loadingerror")); + } + }), 0); + } + clear() {} + delete() {} + load() {} + ready() {} + }; + }, { + "./Event": 10, + "./EventTarget": 11 + } ], + 15: [ function(t, e, i) { + const s = t("./HTMLElement"); + const n = t("./ImageData"); + const r = t("./DOMRect"); + const o = t("./CanvasRenderingContext2D"); + e.exports = class extends s { + constructor(t, e) { + super("canvas"); + this.id = "glcanvas"; + this.type = "canvas"; + this.top = 0; + this.left = 0; + this._width = t ? Math.ceil(t) : 0; + this._height = e ? Math.ceil(e) : 0; + this._context2D = null; + this._dataInner = null; + } + getContext(t, e) { + const i = this; + if ("2d" === t) { + if (!this._context2D) { + this._context2D = new o(this._width, this._height); + this._context2D._canvas = this; + this._context2D._setCanvasBufferUpdatedCallback((t => { + i._dataInner = new n(t, i._width, i._height); + })); + } + return this._context2D; + } + return null; + } + get _data() { + if (null === this._context2D) return null; + this._dataInner || this._context2D.fetchData(); + return this._dataInner; + } + set _data(t) { + this._dataInner = t; + } + set width(t) { + t = Math.ceil(t); + if (this._width !== t) { + this._dataInner = null; + this._width = t; + this._context2D && (this._context2D.width = t); + } + } + get width() { + return this._width; + } + set height(t) { + t = Math.ceil(t); + if (this._height !== t) { + this._dataInner = null; + this._height = t; + this._context2D && (this._context2D.height = t); + } + } + get height() { + return this._height; + } + get clientWidth() { + return window.innerWidth; + } + get clientHeight() { + return window.innerHeight; + } + get data() { + return this._data ? this._data.data : null; + } + getBoundingClientRect() { + return new r(0, 0, window.innerWidth, window.innerHeight); + } + requestPointerLock() { + jsb.setCursorEnabled(!1); + } + }; + }, { + "./CanvasRenderingContext2D": 6, + "./DOMRect": 7, + "./HTMLElement": 16, + "./ImageData": 22 + } ], + 16: [ function(t, e, i) { + const s = t("./Element"); + const {noop: n} = t("./util"); + e.exports = class extends s { + constructor(t = "") { + super(); + this.tagName = t.toUpperCase(); + this.className = ""; + this.children = []; + this.style = { + width: `${window.innerWidth}px`, + height: `${window.innerHeight}px` + }; + this.innerHTML = ""; + this.parentElement = window.__canvas; + } + setAttribute(t, e) { + this[t] = e; + } + getAttribute(t) { + return this[t]; + } + focus() {} + }; + }, { + "./Element": 9, + "./util": 33 + } ], + 17: [ function(t, e, i) { + const s = t("./HTMLElement"); + const n = t("./Event"); + e.exports = class extends s { + constructor(t, e, i) { + if (!i) throw new TypeError("Illegal constructor, use 'new Image(w, h); instead!'"); + super("img"); + this.width = t || 0; + this.height = e || 0; + this._data = null; + this._src = null; + this.complete = !1; + this.crossOrigin = null; + } + destroy() { + if (this._data) { + jsb.destroyImage(this._data); + this._data = null; + } + this._src = null; + } + set src(t) { + this._src = t; + "" !== t && jsb.loadImage(t, (t => { + if (t) { + this.width = this.naturalWidth = t.width; + this.height = this.naturalHeight = t.height; + this._data = t.data; + this.complete = !0; + e = new n("load"); + this.dispatchEvent(e); + } else { + this._data = null; + var e = new n("error"); + this.dispatchEvent(e); + } + })); + } + get src() { + return this._src; + } + get clientWidth() { + return this.width; + } + get clientHeight() { + return this.height; + } + getBoundingClientRect() { + return new DOMRect(0, 0, this.width, this.height); + } + }; + }, { + "./Event": 10, + "./HTMLElement": 16 + } ], + 18: [ function(t, e, i) { + const s = t("./HTMLElement"); + const n = t("./MediaError"); + e.exports = class extends s { + constructor(t) { + super(t); + this._volume = 1; + this._duration = 0; + this._isEnded = !1; + this._isMute = !1; + this._readyState = 0; + this._error = new n; + } + addTextTrack() {} + captureStream() {} + fastSeek() {} + load() {} + pause() {} + play() {} + canPlayType(t) { + return ""; + } + set volume(t) { + this._volume = t; + } + get volume() { + return this._volume; + } + get duration() { + return this._duration; + } + get ended() { + return this._isEnded; + } + get muted() { + return this._isMute; + } + get readyState() { + return this._readyState; + } + get error() { + return this._error; + } + get currentTime() { + return 0; + } + }; + }, { + "./HTMLElement": 16, + "./MediaError": 24 + } ], + 19: [ function(t, e, i) { + const s = t("./HTMLElement"); + const n = t("./Event"); + const r = []; + class o extends s { + constructor(t, e) { + super("script"); + } + set type(t) { + "systemjs-importmap" === t && -1 === r.indexOf(this) && r.push(this); + } + set src(e) { + setTimeout((() => { + t(e); + this.dispatchEvent(new n("load")); + }), 0); + } + } + o._getAllScriptElementsSystemJSImportType = function() { + return r; + }; + e.exports = o; + }, { + "./Event": 10, + "./HTMLElement": 16 + } ], + 20: [ function(t, e, i) { + const s = t("./HTMLMediaElement"); + e.exports = class extends s { + constructor() { + super("video"); + } + canPlayType(t) { + return "video/mp4" === t; + } + }; + }, { + "./HTMLMediaElement": 18 + } ], + 21: [ function(t, e, i) { + let s = t("./HTMLImageElement"); + e.exports = class extends s { + constructor(t, e) { + super(t, e, !0); + } + }; + }, { + "./HTMLImageElement": 17 + } ], + 22: [ function(t, e, i) { + e.exports = class { + constructor(t, e, i) { + if ("number" == typeof t && "number" == typeof e) { + i = e; + e = t; + t = null; + } + this._data = null === t ? new Uint8ClampedArray(e * i * 4) : t; + this._width = e; + this._height = i; + } + get data() { + return this._data; + } + get width() { + return this._width; + } + get height() { + return this._height; + } + }; + }, {} ], + 23: [ function(t, e, i) { + const s = t("./Event"); + const n = { + 48: ")", + 49: "!", + 50: "@", + 51: "#", + 52: "$", + 53: "%", + 54: "^", + 55: "&", + 56: "*", + 57: "(" + }; + var r = !1; + e.exports = class extends s { + constructor(t, e) { + super(t); + if ("object" == typeof e) { + this._altKeyActive = !!e.altKey && e.altKey; + this._ctrlKeyActive = !!e.ctrlKey && e.ctrlKey; + this._metaKeyActive = !!e.metaKey && e.metaKey; + this._shiftKeyActive = !!e.shiftKey && e.shiftKey; + this._keyCode = e.keyCode ? e.keyCode : -1; + this._repeat = !!e.repeat && e.repeat; + } else { + this._altKeyActive = !1; + this._ctrlKeyActive = !1; + this._metaKeyActive = !1; + this._shiftKeyActive = !1; + this._keyCode = -1; + this._repeat = !1; + } + var i = this._keyCode; + if (i >= 48 && i <= 57) { + var s = i - 48; + this._code = "Digit" + s; + this._key = this._shiftKeyActive ? n[i] : "" + s; + } else if (i >= 10048 && i <= 10057) { + s = (i = this._keyCode = i - 1e4) - 48; + this._code = "Numpad" + s; + this._key = "" + s; + } else if (i >= 65 && i <= 90) { + var o = String.fromCharCode(i); + this._code = "Key" + o; + this._key = this._shiftKeyActive ^ r ? o : o.toLowerCase(); + } else if (i >= 97 && i <= 122) { + o = String.fromCharCode(i); + this._keyCode = i - 32; + this._code = "Key" + o; + this._key = this._shiftKeyActive ^ r ? o.toUpperCase() : o; + } else if (i >= 112 && i <= 123) this._code = this._key = "F" + (i - 111); else if (27 === i) this._code = this._key = "Escape"; else if (189 === i) { + this._code = "Minus"; + this._key = this._shiftKeyActive ? "_" : "-"; + } else if (187 === i) { + this._code = "Equal"; + this._key = this._shiftKeyActive ? "+" : "="; + } else if (220 === i) { + this._code = "Backslash"; + this._key = this._shiftKeyActive ? "|" : "\\"; + } else if (192 === i) { + this._code = "Backquote"; + this._key = this._shiftKeyActive ? "~" : "`"; + } else if (8 === i) this._code = this._key = "Backspace"; else if (13 === i) this._code = this._key = "Enter"; else if (219 === i) { + this._code = "BracketLeft"; + this._key = this._shiftKeyActive ? "{" : "["; + } else if (221 === i) { + this._code = "BracketRight"; + this._key = this._shiftKeyActive ? "}" : "]"; + } else if (186 === i) { + this._code = "Semicolon"; + this._key = this._shiftKeyActive ? ":" : ";"; + } else if (222 === i) { + this._code = "Quote"; + this._key = this._shiftKeyActive ? '"' : "'"; + } else if (9 === i) this._code = this._key = "Tab"; else if (17 === i) { + this._code = "ControlLeft"; + this._key = "Control"; + } else if (20017 === i) { + this._keyCode = 17; + this._code = "ControlRight"; + this._key = "Control"; + } else if (16 === i) { + this._code = "ShiftLeft"; + this._key = "Shift"; + } else if (20016 === i) { + this._keyCode = 16; + this._code = "ShiftRight"; + this._key = "Shift"; + } else if (18 === i) { + this._code = "AltLeft"; + this._key = "Alt"; + } else if (20018 === i) { + this._keyCode = 18; + this._code = "AltRight"; + this._key = "Alt"; + } else if (91 === i) { + this._code = "MetaLeft"; + this._key = "Meta"; + } else if (93 === i) { + this._code = "MetaRight"; + this._key = "Meta"; + } else if (37 === i) this._code = this._key = "ArrowLeft"; else if (38 === i) this._code = this._key = "ArrowUp"; else if (39 === i) this._code = this._key = "ArrowRight"; else if (40 === i) this._code = this._key = "ArrowDown"; else if (20093 === i) { + this._keyCode = 93; + this._code = this._key = "ContextMenu"; + } else if (20013 === i) { + this._keyCode = 13; + this._code = "NumpadEnter"; + this._key = "Enter"; + } else if (107 === i) { + this._code = "NumpadAdd"; + this._key = "+"; + } else if (109 === i) { + this._code = "NumpadSubtract"; + this._key = "-"; + } else if (106 === i) { + this._code = "NumpadMultiply"; + this._key = "*"; + } else if (111 === i) { + this._code = "NumpadDivide"; + this._key = "/"; + } else if (12 === i) { + this._code = "NumLock"; + this._key = "Clear"; + } else if (124 === i) this._code = this._key = "F13"; else if (36 === i) this._code = this._key = "Home"; else if (33 === i) this._code = this._key = "PageUp"; else if (34 === i) this._code = this._key = "PageDown"; else if (35 === i) this._code = this._key = "End"; else if (188 === i) { + this._code = "Comma"; + this._key = this._shiftKeyActive ? "<" : ","; + } else if (190 === i) { + this._code = "Period"; + this._key = this._shiftKeyActive ? ">" : "."; + } else if (191 === i) { + this._code = "Slash"; + this._key = this._shiftKeyActive ? "?" : "/"; + } else if (32 === i) { + this._code = "Space"; + this._key = " "; + } else if (46 === i) this._code = this._key = "Delete"; else if (110 === i) { + this._code = "NumpadDecimal"; + this._key = "."; + } else if (20 === i) { + this._code = this._key = "CapsLock"; + "keyup" === t && (r = !r); + } else console.log("Unknown keyCode: " + this._keyCode); + } + getModifierState() { + return !1; + } + get altKey() { + return this._altKeyActive; + } + get code() { + return this._code; + } + get ctrlKey() { + return this._ctrlKeyActive; + } + get isComposing() { + return !1; + } + get key() { + return this._key; + } + get keyCode() { + return this._keyCode; + } + get location() { + return 0; + } + get metaKey() { + return this._metaKeyActive; + } + get repeat() { + return this._repeat; + } + get shiftKey() { + return this._shiftKeyActive; + } + }; + }, { + "./Event": 10 + } ], + 24: [ function(t, e, i) { + e.exports = class { + constructor() {} + get code() { + return 1; + } + get message() { + return ""; + } + }; + }, {} ], + 25: [ function(t, e, i) { + const s = t("./Event"); + e.exports = class extends s { + constructor(t, e) { + super(t); + this._button = e.button; + this._which = e.which; + this._wheelDelta = e.wheelDelta; + this._clientX = e.clientX; + this._clientY = e.clientY; + this._screenX = e.screenX; + this._screenY = e.screenY; + this._pageX = e.pageX; + this._pageY = e.pageY; + } + get button() { + return this._button; + } + get which() { + return this._which; + } + get wheelDelta() { + return this._wheelDelta; + } + get clientX() { + return this._clientX; + } + get clientY() { + return this._clientY; + } + get screenX() { + return this._screenX; + } + get screenY() { + return this._screenY; + } + get pageX() { + return this._pageX; + } + get pageY() { + return this._pageY; + } + }; + }, { + "./Event": 10 + } ], + 26: [ function(t, e, i) { + const s = t("./EventTarget"); + class n extends s { + constructor() { + super(); + this.childNodes = []; + this.parentNode = window.__canvas; + } + appendChild(t) { + if (!(t instanceof n)) throw new TypeError("Failed to executed 'appendChild' on 'Node': parameter 1 is not of type 'Node'."); + this.childNodes.push(t); + } + insertBefore(t, e) { + return t; + } + replaceChild(t, e) { + return e; + } + cloneNode() { + const t = Object.create(this); + Object.assign(t, this); + return t; + } + removeChild(t) { + const e = this.childNodes.findIndex((e => e === t)); + return e > -1 ? this.childNodes.splice(e, 1) : null; + } + contains(t) { + return this.childNodes.indexOf(t) > -1; + } + } + e.exports = n; + }, { + "./EventTarget": 11 + } ], + 27: [ function(t, e, i) { + const s = t("./Event"); + e.exports = class extends s { + constructor(t, e) { + super(t); + this.touches = []; + this.targetTouches = []; + this.changedTouches = []; + } + }; + }, { + "./Event": 10 + } ], + 28: [ function(t, e, i) { + const s = t("./HTMLElement"); + const n = t("./Image"); + const r = t("./HTMLCanvasElement"); + const o = t("./HTMLVideoElement"); + const a = t("./HTMLScriptElement"); + const l = t("./Node"); + const h = t("./FontFaceSet"); + let c = new class extends l { + constructor() { + super(); + this.readyState = "complete"; + this.visibilityState = "visible"; + this.documentElement = window; + this.hidden = !1; + this.style = {}; + this.location = t("./location"); + this.head = new s("head"); + this.body = new s("body"); + this.fonts = new h; + this.scripts = []; + } + createElementNS(t, e, i) { + return this.createElement(e); + } + createElement(t) { + return "canvas" === t ? new r(1, 1) : "img" === t ? new n : "video" === t ? new o : "script" === t ? new a : new s(t); + } + getElementById(t) { + return t === window.__canvas.id || "canvas" === t ? window.__canvas : new s(t); + } + getElementsByTagName(t) { + return "head" === t ? [ c.head ] : "body" === t ? [ c.body ] : "canvas" === t ? [ window.__canvas ] : [ new s(t) ]; + } + getElementsByName(t) { + return "head" === t ? [ c.head ] : "body" === t ? [ c.body ] : "canvas" === t ? [ window.__canvas ] : [ new s(t) ]; + } + querySelector(t) { + return "head" === t ? c.head : "body" === t ? c.body : "canvas" === t || t === `#${window.__canvas.id}` ? window.__canvas : new s(t); + } + querySelectorAll(t) { + return "head" === t ? [ c.head ] : "body" === t ? [ c.body ] : "canvas" === t ? [ window.__canvas ] : t.startsWith('script[type="systemjs-importmap"]') ? a._getAllScriptElementsSystemJSImportType() : [ new s(t) ]; + } + createTextNode() { + return new s("text"); + } + elementFromPoint() { + return window.canvas; + } + createEvent(t) { + return window[t] ? new window[t] : null; + } + exitPointerLock() { + jsb.setCursorEnabled(!0); + } + }; + e.exports = c; + }, { + "./FontFaceSet": 14, + "./HTMLCanvasElement": 15, + "./HTMLElement": 16, + "./HTMLScriptElement": 19, + "./HTMLVideoElement": 20, + "./Image": 21, + "./Node": 26, + "./location": 31 + } ], + 29: [ function(t, e, i) { + Object.defineProperty(i, "__esModule", { + value: !0 + }); + i.Headers = p; + i.Request = A; + i.Response = E; + i.fetch = w; + i.DOMException = void 0; + var s = window; + var n = "URLSearchParams" in s, r = "Symbol" in s && "iterator" in Symbol, o = "FileReader" in s && "Blob" in s && function() { + try { + new Blob; + return !0; + } catch (t) { + return !1; + } + }(), a = "FormData" in s, l = "ArrayBuffer" in s; + if (l) { + var h = [ "[object Int8Array]", "[object Uint8Array]", "[object Uint8ClampedArray]", "[object Int16Array]", "[object Uint16Array]", "[object Int32Array]", "[object Uint32Array]", "[object Float32Array]", "[object Float64Array]" ]; + var c = ArrayBuffer.isView || function(t) { + return t && h.indexOf(Object.prototype.toString.call(t)) > -1; + }; + } + function u(t) { + "string" != typeof t && (t = String(t)); + if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t) || "" === t) throw new TypeError("Invalid character in header field name"); + return t.toLowerCase(); + } + function _(t) { + "string" != typeof t && (t = String(t)); + return t; + } + function d(t) { + var e = { + next: function() { + var e = t.shift(); + return { + done: void 0 === e, + value: e + }; + } + }; + r && (e[Symbol.iterator] = function() { + return e; + }); + return e; + } + function p(t) { + this.map = {}; + t instanceof p ? t.forEach((function(t, e) { + this.append(e, t); + }), this) : Array.isArray(t) ? t.forEach((function(t) { + this.append(t[0], t[1]); + }), this) : t && Object.getOwnPropertyNames(t).forEach((function(e) { + this.append(e, t[e]); + }), this); + } + p.prototype.append = function(t, e) { + t = u(t); + e = _(e); + var i = this.map[t]; + this.map[t] = i ? i + ", " + e : e; + }; + p.prototype.delete = function(t) { + delete this.map[u(t)]; + }; + p.prototype.get = function(t) { + t = u(t); + return this.has(t) ? this.map[t] : null; + }; + p.prototype.has = function(t) { + return this.map.hasOwnProperty(u(t)); + }; + p.prototype.set = function(t, e) { + this.map[u(t)] = _(e); + }; + p.prototype.forEach = function(t, e) { + for (var i in this.map) this.map.hasOwnProperty(i) && t.call(e, this.map[i], i, this); + }; + p.prototype.keys = function() { + var t = []; + this.forEach((function(e, i) { + t.push(i); + })); + return d(t); + }; + p.prototype.values = function() { + var t = []; + this.forEach((function(e) { + t.push(e); + })); + return d(t); + }; + p.prototype.entries = function() { + var t = []; + this.forEach((function(e, i) { + t.push([ i, e ]); + })); + return d(t); + }; + r && (p.prototype[Symbol.iterator] = p.prototype.entries); + function m(t) { + if (t.bodyUsed) return Promise.reject(new TypeError("Already read")); + t.bodyUsed = !0; + } + function f(t) { + return new Promise((function(e, i) { + t.onload = function() { + e(t.result); + }; + t.onerror = function() { + i(t.error); + }; + })); + } + function g(t) { + var e = new FileReader; + var i = f(e); + e.readAsArrayBuffer(t); + return i; + } + function y(t) { + if (t.slice) return t.slice(0); + var e = new Uint8Array(t.byteLength); + e.set(new Uint8Array(t)); + return e.buffer; + } + function b() { + this.bodyUsed = !1; + this._initBody = function(t) { + this._bodyInit = t; + if (t) if ("string" == typeof t) this._bodyText = t; else if (o && Blob.prototype.isPrototypeOf(t)) this._bodyBlob = t; else if (a && FormData.prototype.isPrototypeOf(t)) this._bodyFormData = t; else if (n && URLSearchParams.prototype.isPrototypeOf(t)) this._bodyText = t.toString(); else if (l && o && ((e = t) && DataView.prototype.isPrototypeOf(e))) { + this._bodyArrayBuffer = y(t.buffer); + this._bodyInit = new Blob([ this._bodyArrayBuffer ]); + } else l && (ArrayBuffer.prototype.isPrototypeOf(t) || c(t)) ? this._bodyArrayBuffer = y(t) : this._bodyText = t = Object.prototype.toString.call(t); else this._bodyText = ""; + var e; + this.headers.get("content-type") || ("string" == typeof t ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : n && URLSearchParams.prototype.isPrototypeOf(t) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8")); + }; + if (o) { + this.blob = function() { + var t = m(this); + if (t) return t; + if (this._bodyBlob) return Promise.resolve(this._bodyBlob); + if (this._bodyArrayBuffer) return Promise.resolve(new Blob([ this._bodyArrayBuffer ])); + if (this._bodyFormData) throw new Error("could not read FormData body as blob"); + return Promise.resolve(new Blob([ this._bodyText ])); + }; + this.arrayBuffer = function() { + return this._bodyArrayBuffer ? m(this) || Promise.resolve(this._bodyArrayBuffer) : this.blob().then(g); + }; + } + this.text = function() { + var t = m(this); + if (t) return t; + if (this._bodyBlob) return function(t) { + var e = new FileReader; + var i = f(e); + e.readAsText(t); + return i; + }(this._bodyBlob); + if (this._bodyArrayBuffer) return Promise.resolve(function(t) { + var e = new Uint8Array(t); + var i = new Array(e.length); + for (var s = 0; s < e.length; s++) i[s] = String.fromCharCode(e[s]); + return i.join(""); + }(this._bodyArrayBuffer)); + if (this._bodyFormData) throw new Error("could not read FormData body as text"); + return Promise.resolve(this._bodyText); + }; + a && (this.formData = function() { + return this.text().then(T); + }); + this.json = function() { + return this.text().then(JSON.parse); + }; + return this; + } + var S = [ "DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT" ]; + function A(t, e) { + var i = (e = e || {}).body; + if (t instanceof A) { + if (t.bodyUsed) throw new TypeError("Already read"); + this.url = t.url; + this.credentials = t.credentials; + e.headers || (this.headers = new p(t.headers)); + this.method = t.method; + this.mode = t.mode; + this.signal = t.signal; + if (!i && null != t._bodyInit) { + i = t._bodyInit; + t.bodyUsed = !0; + } + } else this.url = String(t); + this.credentials = e.credentials || this.credentials || "same-origin"; + !e.headers && this.headers || (this.headers = new p(e.headers)); + this.method = (s = e.method || this.method || "GET", n = s.toUpperCase(), S.indexOf(n) > -1 ? n : s); + var s, n; + this.mode = e.mode || this.mode || null; + this.signal = e.signal || this.signal; + this.referrer = null; + if (("GET" === this.method || "HEAD" === this.method) && i) throw new TypeError("Body not allowed for GET or HEAD requests"); + this._initBody(i); + } + A.prototype.clone = function() { + return new A(this, { + body: this._bodyInit + }); + }; + function T(t) { + var e = new FormData; + t.trim().split("&").forEach((function(t) { + if (t) { + var i = t.split("="); + var s = i.shift().replace(/\+/g, " "); + var n = i.join("=").replace(/\+/g, " "); + e.append(decodeURIComponent(s), decodeURIComponent(n)); + } + })); + return e; + } + function v(t) { + var e = new p; + t.replace(/\r?\n[\t ]+/g, " ").split(/\r?\n/).forEach((function(t) { + var i = t.split(":"); + var s = i.shift().trim(); + if (s) { + var n = i.join(":").trim(); + e.append(s, n); + } + })); + return e; + } + b.call(A.prototype); + function E(t, e) { + e || (e = {}); + this.type = "default"; + this.status = void 0 === e.status ? 200 : e.status; + this.ok = this.status >= 200 && this.status < 300; + this.statusText = "statusText" in e ? e.statusText : "OK"; + this.headers = new p(e.headers); + this.url = e.url || ""; + this._initBody(t); + } + b.call(E.prototype); + E.prototype.clone = function() { + return new E(this._bodyInit, { + status: this.status, + statusText: this.statusText, + headers: new p(this.headers), + url: this.url + }); + }; + E.error = function() { + var t = new E(null, { + status: 0, + statusText: "" + }); + t.type = "error"; + return t; + }; + var C = [ 301, 302, 303, 307, 308 ]; + E.redirect = function(t, e) { + if (-1 === C.indexOf(e)) throw new RangeError("Invalid status code"); + return new E(null, { + status: e, + headers: { + location: t + } + }); + }; + var x = s.DOMException; + i.DOMException = x; + try { + new x; + } catch (t) { + i.DOMException = x = function(t, e) { + this.message = t; + this.name = e; + var i = Error(t); + this.stack = i.stack; + }; + x.prototype = Object.create(Error.prototype); + x.prototype.constructor = x; + } + function w(t, e) { + return new Promise((function(i, s) { + var n = new A(t, e); + if (n.signal && n.signal.aborted) return s(new x("Aborted", "AbortError")); + var r = new XMLHttpRequest; + function a() { + r.abort(); + } + r.onload = function() { + var t = { + status: r.status, + statusText: r.statusText, + headers: v(r.getAllResponseHeaders() || "") + }; + t.url = "responseURL" in r ? r.responseURL : t.headers.get("X-Request-URL"); + var e = "response" in r ? r.response : r.responseText; + i(new E(e, t)); + }; + r.onerror = function() { + s(new TypeError("Network request failed")); + }; + r.ontimeout = function() { + s(new TypeError("Network request failed")); + }; + r.onabort = function() { + s(new x("Aborted", "AbortError")); + }; + r.open(n.method, n.url, !0); + "include" === n.credentials ? r.withCredentials = !0 : "omit" === n.credentials && (r.withCredentials = !1); + "responseType" in r && o && (r.responseType = "blob"); + n.headers.forEach((function(t, e) { + r.setRequestHeader(e, t); + })); + if (n.signal) { + n.signal.addEventListener("abort", a); + r.onreadystatechange = function() { + 4 === r.readyState && n.signal.removeEventListener("abort", a); + }; + } + r.send(void 0 === n._bodyInit ? null : n._bodyInit); + })); + } + w.polyfill = !0; + }, {} ], + 30: [ function(t, e, i) { + t("./window"); + }, { + "./window": 34 + } ], + 31: [ function(t, e, i) { + const s = { + href: "game.js", + pathname: "game.js", + search: "", + hash: "", + protocol: "", + reload() {} + }; + e.exports = s; + }, {} ], + 32: [ function(t, e, i) { + let {noop: s} = t("./util"); + const n = { + platform: __getOS(), + language: __getCurrentLanguage(), + appVersion: "5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1", + userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Mobile/14E8301 NetType/WIFI Language/zh_CN", + onLine: !0, + geolocation: { + getCurrentPosition: s, + watchPosition: s, + clearWatch: s + }, + maxTouchPoints: 10 + }; + e.exports = n; + }, { + "./util": 33 + } ], + 33: [ function(t, e, i) { + e.exports = function() {}; + }, {} ], + 34: [ function(t, e, i) { + window._isInjected || function() { + window.top = window.parent = window; + window.ontouchstart = null; + window.ontouchmove = null; + window.ontouchend = null; + window.ontouchcancel = null; + window.pageXOffset = window.pageYOffset = window.clientTop = window.clientLeft = 0; + window.outerWidth = window.innerWidth; + window.outerHeight = window.innerHeight; + window.clientWidth = window.innerWidth; + window.clientHeight = window.innerHeight; + window.location = t("./location"); + window.document = t("./document"); + window.CanvasRenderingContext2D = t("./CanvasRenderingContext2D"); + window.Element = t("./Element"); + window.HTMLElement = t("./HTMLElement"); + window.HTMLCanvasElement = t("./HTMLCanvasElement"); + window.HTMLImageElement = t("./HTMLImageElement"); + window.HTMLMediaElement = t("./HTMLMediaElement"); + window.HTMLVideoElement = t("./HTMLVideoElement"); + window.HTMLScriptElement = t("./HTMLScriptElement"); + window.__canvas = new HTMLCanvasElement; + window.__canvas._width = window.innerWidth; + window.__canvas._height = window.innerHeight; + window.navigator = t("./navigator"); + window.Image = t("./Image"); + window.FileReader = t("./FileReader"); + window.FontFace = t("./FontFace"); + window.FontFaceSet = t("./FontFaceSet"); + window.EventTarget = t("./EventTarget"); + window.Event = t("./Event"); + window.TouchEvent = t("./TouchEvent"); + window.MouseEvent = t("./MouseEvent"); + window.KeyboardEvent = t("./KeyboardEvent"); + window.DeviceMotionEvent = t("./DeviceMotionEvent"); + var e = t("./fetch"); + window.fetch = e.fetch; + window.Headers = e.Headers; + window.Request = e.Request; + window.Response = e.Response; + window.orientation = jsb.device.getDeviceOrientation(); + Object.defineProperty(window, "devicePixelRatio", { + get: function() { + return jsb.device.getDevicePixelRatio ? jsb.device.getDevicePixelRatio() : 1; + }, + set: function(t) {}, + enumerable: !0, + configurable: !0 + }); + window.screen = { + availTop: 0, + availLeft: 0, + availHeight: window.innerWidth, + availWidth: window.innerHeight, + colorDepth: 8, + pixelDepth: 8, + left: 0, + top: 0, + width: window.innerWidth, + height: window.innerHeight, + orientation: { + type: "portrait-primary" + }, + onorientationchange: function(t) {} + }; + window.addEventListener = function(t, e, i) { + window.__canvas.addEventListener(t, e, i); + }; + window.removeEventListener = function(t, e, i) { + window.__canvas.removeEventListener(t, e, i); + }; + window.dispatchEvent = function(t) { + window.__canvas.dispatchEvent(t); + }; + window.getComputedStyle = function(t) { + return { + position: "absolute", + left: "0px", + top: "0px", + height: "0px" + }; + }; + window.resize = function(t, e) { + window.innerWidth = t; + window.innerHeight = e; + window.outerWidth = window.innerWidth; + window.outerHeight = window.innerHeight; + window.__canvas._width = window.innerWidth; + window.__canvas._height = window.innerHeight; + window.screen.availWidth = window.innerWidth; + window.screen.availHeight = window.innerHeight; + window.screen.width = window.innerWidth; + window.screen.height = window.innerHeight; + window.clientWidth = window.innerWidth; + window.clientHeight = window.innerHeight; + let i = new Event("resize"); + i._target = window; + window.dispatchEvent(i); + }; + window.focus = function() {}; + window.scroll = function() {}; + window._isInjected = !0; + }(); + window.localStorage = sys.localStorage; + }, { + "./CanvasRenderingContext2D": 6, + "./DeviceMotionEvent": 8, + "./Element": 9, + "./Event": 10, + "./EventTarget": 11, + "./FileReader": 12, + "./FontFace": 13, + "./FontFaceSet": 14, + "./HTMLCanvasElement": 15, + "./HTMLElement": 16, + "./HTMLImageElement": 17, + "./HTMLMediaElement": 18, + "./HTMLScriptElement": 19, + "./HTMLVideoElement": 20, + "./Image": 21, + "./KeyboardEvent": 23, + "./MouseEvent": 25, + "./TouchEvent": 27, + "./document": 28, + "./fetch": 29, + "./location": 31, + "./navigator": 32 + } ], + 35: [ function(t, e, i) { + !function(t) { + if (t && t.AudioEngine) { + t.AudioEngine.AudioState = { + ERROR: -1, + INITIALZING: 0, + PLAYING: 1, + PAUSED: 2, + STOPPED: 3 + }; + t.AudioEngine.INVALID_AUDIO_ID = -1; + t.AudioEngine.TIME_UNKNOWN = -1; + t.AudioEngine.play = t.AudioEngine.play2d; + t.AudioEngine.setErrorCallback = () => {}; + } + }(jsb); + }, {} ], + 36: [ function(t, e, i) { + const s = t("./jsb-adapter/EventTarget"); + const n = t("./jsb-adapter/Event"); + var r = new s; + var o = {}; + var a = {}; + var l = 1; + var h = function(t) { + if (!t) return null; + var e = function(e) { + t({ + value: e.text + }); + }; + t.___index = l++; + o[t.___index] = e; + return e; + }; + var c = function(t, e) { + if (e) r.removeEventListener(t, function(t) { + if (t && t.___index) { + var e = o[t.___index]; + delete o[t.___index]; + return e; + } + return null; + }(e)); else { + var i = a[t]; + if (!i) return; + for (var s = 0, n = i.length; s < n; ++s) r.removeEventListener(t, i[s]); + delete a[t]; + } + }; + var u = function(t, e) { + if (e && t && "" !== t) { + a[t] || (a[t] = []); + a[t].push(e); + } + }; + jsb.inputBox = { + onConfirm: function(t) { + var e = h(t); + r.addEventListener("confirm", e); + u("confirm", e); + }, + offConfirm: function(t) { + c("confirm", t); + }, + onComplete: function(t) { + var e = h(t); + r.addEventListener("complete", e); + u("complete", e); + }, + offComplete: function(t) { + c("complete", t); + }, + onInput: function(t) { + var e = h(t); + r.addEventListener("input", e); + u("input", e); + }, + offInput: function(t) { + c("input", t); + }, + show: function(t) { + jsb.showInputBox(t); + }, + hide: function() { + jsb.hideInputBox(); + } + }; + jsb.onTextInput = function(t, e) { + var i = new n(t); + i.text = e; + r.dispatchEvent(i); + }; + }, { + "./jsb-adapter/Event": 10, + "./jsb-adapter/EventTarget": 11 + } ], + 37: [ function(t, e, i) { + jsb.__obj_ref_id = 0; + jsb.registerNativeRef = function(t, e) { + if (t && e && t !== e) { + let i = e.__jsb_ref_id; + void 0 === i && (i = e.__jsb_ref_id = jsb.__obj_ref_id++); + let s = t.__nativeRefs; + s || (s = t.__nativeRefs = {}); + s[i] = e; + } + }; + jsb.unregisterNativeRef = function(t, e) { + if (t && e && t !== e) { + let i = e.__jsb_ref_id; + if (void 0 === i) return; + let s = t.__nativeRefs; + if (!s) return; + delete s[i]; + } + }; + jsb.unregisterAllNativeRefs = function(t) { + t && delete t.__nativeRefs; + }; + jsb.unregisterChildRefsForNode = function(t, e) { + e = !!e; + let i, s, n, r = t.getChildren(); + for (i = 0, s = r.length; i < s; ++i) { + n = r[i]; + jsb.unregisterNativeRef(t, n); + e && jsb.unregisterChildRefsForNode(n, e); + } + }; + }, {} ], + 38: [ function(t, e, s) { + (function(t, o) { + (function() { + a = function() { + function e(t) { + var e = this.constructor; + return this.then((function(i) { + return e.resolve(t()).then((function() { + return i; + })); + }), (function(i) { + return e.resolve(t()).then((function() { + return e.reject(i); + })); + })); + } + function i() {} + function s(t) { + if (!(this instanceof s)) throw new TypeError("Promises must be constructed via new"); + if ("function" != typeof t) throw new TypeError("not a function"); + this._state = 0, this._handled = !1, this._value = void 0, this._deferreds = [], + h(t, this); + } + function n(t, e) { + for (;3 === t._state; ) t = t._value; + 0 !== t._state ? (t._handled = !0, s._immediateFn((function() { + var i = 1 === t._state ? e.onFulfilled : e.onRejected; + if (null !== i) { + var s; + try { + s = i(t._value); + } catch (t) { + return void a(e.promise, t); + } + r(e.promise, s); + } else (1 === t._state ? r : a)(e.promise, t._value); + }))) : t._deferreds.push(e); + } + function r(t, e) { + try { + if (e === t) throw new TypeError("A promise cannot be resolved with itself."); + if (e && ("object" == typeof e || "function" == typeof e)) { + var i = e.then; + if (e instanceof s) return t._state = 3, t._value = e, void l(t); + if ("function" == typeof i) return void h(function(t, e) { + return function() { + t.apply(e, arguments); + }; + }(i, e), t); + } + t._state = 1, t._value = e, l(t); + } catch (e) { + a(t, e); + } + } + function a(t, e) { + t._state = 2, t._value = e, l(t); + } + function l(t) { + 2 === t._state && 0 === t._deferreds.length && s._immediateFn((function() { + t._handled || s._unhandledRejectionFn(t._value); + })); + for (var e = 0, i = t._deferreds.length; i > e; e++) n(t, t._deferreds[e]); + t._deferreds = null; + } + function h(t, e) { + var i = !1; + try { + t((function(t) { + i || (i = !0, r(e, t)); + }), (function(t) { + i || (i = !0, a(e, t)); + })); + } catch (t) { + if (i) return; + i = !0, a(e, t); + } + } + var c = setTimeout; + s.prototype.catch = function(t) { + return this.then(null, t); + }, s.prototype.then = function(t, e) { + var s = new this.constructor(i); + return n(this, new function(t, e, i) { + this.onFulfilled = "function" == typeof t ? t : null, this.onRejected = "function" == typeof e ? e : null, + this.promise = i; + }(t, e, s)), s; + }, s.prototype.finally = e, s.all = function(t) { + return new s((function(e, i) { + function s(t, o) { + try { + if (o && ("object" == typeof o || "function" == typeof o)) { + var a = o.then; + if ("function" == typeof a) return void a.call(o, (function(e) { + s(t, e); + }), i); + } + n[t] = o, 0 == --r && e(n); + } catch (t) { + i(t); + } + } + if (!t || void 0 === t.length) throw new TypeError("Promise.all accepts an array"); + var n = Array.prototype.slice.call(t); + if (0 === n.length) return e([]); + for (var r = n.length, o = 0; n.length > o; o++) s(o, n[o]); + })); + }, s.resolve = function(t) { + return t && "object" == typeof t && t.constructor === s ? t : new s((function(e) { + e(t); + })); + }, s.reject = function(t) { + return new s((function(e, i) { + i(t); + })); + }, s.race = function(t) { + return new s((function(e, i) { + for (var s = 0, n = t.length; n > s; s++) t[s].then(e, i); + })); + }, s._immediateFn = "function" == typeof o && function(t) { + o(t); + } || function(t) { + c(t, 0); + }, s._unhandledRejectionFn = function(t) { + void 0 !== console && console && console.warn("Possible Unhandled Promise Rejection:", t); + }; + var u = function() { + if ("undefined" != typeof self) return self; + if ("undefined" != typeof window) return window; + if (void 0 !== t) return t; + throw Error("unable to locate global object"); + }(); + "Promise" in u ? u.Promise.prototype.finally || (u.Promise.prototype.finally = e) : u.Promise = s; + }, "object" == typeof s && void 0 !== e ? a() : void 0 !== (r = "function" == typeof (n = a) ? n.call(s, i, s, e) : n) && (e.exports = r); + var a; + }).call(this); + }).call(this, "undefined" != typeof global ? global : "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}, t("timers").setImmediate); + }, { + timers: 2 + } ], + 39: [ function(t, e, i) { + function s(t) { + this.options = t || { + locator: {} + }; + } + s.prototype.parseFromString = function(t, e) { + var i = this.options; + var s = new c; + var r = i.domBuilder || new n; + var a = i.errorHandler; + var l = i.locator; + var u = i.xmlns || {}; + var _ = /\/x?html?$/.test(e); + var d = _ ? h.entityMap : { + lt: "<", + gt: ">", + amp: "&", + quot: '"', + apos: "'" + }; + l && r.setDocumentLocator(l); + s.errorHandler = function(t, e, i) { + if (!t) { + if (e instanceof n) return e; + t = e; + } + var s = {}; + var r = t instanceof Function; + i = i || {}; + function a(e) { + var n = t[e]; + !n && r && (n = 2 == t.length ? function(i) { + t(e, i); + } : t); + s[e] = n && function(t) { + n("[xmldom " + e + "]\t" + t + o(i)); + } || function() {}; + } + a("warning"); + a("error"); + a("fatalError"); + return s; + }(a, r, l); + s.domBuilder = i.domBuilder || r; + _ && (u[""] = "http://www.w3.org/1999/xhtml"); + u.xml = u.xml || "http://www.w3.org/XML/1998/namespace"; + t ? s.parse(t, u, d) : s.errorHandler.error("invalid doc source"); + return r.doc; + }; + function n() { + this.cdata = !1; + } + function r(t, e) { + e.lineNumber = t.lineNumber; + e.columnNumber = t.columnNumber; + } + n.prototype = { + startDocument: function() { + this.doc = (new u).createDocument(null, null, null); + this.locator && (this.doc.documentURI = this.locator.systemId); + }, + startElement: function(t, e, i, s) { + var n = this.doc; + var o = n.createElementNS(t, i || e); + var a = s.length; + l(this, o); + this.currentElement = o; + this.locator && r(this.locator, o); + for (var h = 0; h < a; h++) { + t = s.getURI(h); + var c = s.getValue(h); + i = s.getQName(h); + var u = n.createAttributeNS(t, i); + this.locator && r(s.getLocator(h), u); + u.value = u.nodeValue = c; + o.setAttributeNode(u); + } + }, + endElement: function(t, e, i) { + var s = this.currentElement; + s.tagName; + this.currentElement = s.parentNode; + }, + startPrefixMapping: function(t, e) {}, + endPrefixMapping: function(t) {}, + processingInstruction: function(t, e) { + var i = this.doc.createProcessingInstruction(t, e); + this.locator && r(this.locator, i); + l(this, i); + }, + ignorableWhitespace: function(t, e, i) {}, + characters: function(t, e, i) { + if (t = a.apply(this, arguments)) { + if (this.cdata) var s = this.doc.createCDATASection(t); else s = this.doc.createTextNode(t); + this.currentElement ? this.currentElement.appendChild(s) : /^\s*$/.test(t) && this.doc.appendChild(s); + this.locator && r(this.locator, s); + } + }, + skippedEntity: function(t) {}, + endDocument: function() { + this.doc.normalize(); + }, + setDocumentLocator: function(t) { + (this.locator = t) && (t.lineNumber = 0); + }, + comment: function(t, e, i) { + t = a.apply(this, arguments); + var s = this.doc.createComment(t); + this.locator && r(this.locator, s); + l(this, s); + }, + startCDATA: function() { + this.cdata = !0; + }, + endCDATA: function() { + this.cdata = !1; + }, + startDTD: function(t, e, i) { + var s = this.doc.implementation; + if (s && s.createDocumentType) { + var n = s.createDocumentType(t, e, i); + this.locator && r(this.locator, n); + l(this, n); + } + }, + warning: function(t) { + console.warn("[xmldom warning]\t" + t, o(this.locator)); + }, + error: function(t) { + console.error("[xmldom error]\t" + t, o(this.locator)); + }, + fatalError: function(t) { + console.error("[xmldom fatalError]\t" + t, o(this.locator)); + throw t; + } + }; + function o(t) { + if (t) return "\n@" + (t.systemId || "") + "#[line:" + t.lineNumber + ",col:" + t.columnNumber + "]"; + } + function a(t, e, i) { + return "string" == typeof t ? t.substr(e, i) : t.length >= e + i || e ? new java.lang.String(t, e, i) + "" : t; + } + "endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g, (function(t) { + n.prototype[t] = function() { + return null; + }; + })); + function l(t, e) { + t.currentElement ? t.currentElement.appendChild(e) : t.doc.appendChild(e); + } + var h = t("./entities"); + var c = t("./sax").XMLReader; + var u = i.DOMImplementation = t("./dom").DOMImplementation; + i.XMLSerializer = t("./dom").XMLSerializer; + i.DOMParser = s; + }, { + "./dom": 40, + "./entities": 41, + "./sax": 42 + } ], + 40: [ function(t, e, i) { + function s(t, e) { + for (var i in t) e[i] = t[i]; + } + function n(t, e) { + var i = t.prototype; + if (!(i instanceof e)) { + function n() {} + n.prototype = e.prototype; + s(i, n = new n); + t.prototype = i = n; + } + if (i.constructor != t) { + "function" != typeof t && console.error("unknow Class:" + t); + i.constructor = t; + } + } + var r = {}; + var o = r.ELEMENT_NODE = 1; + var a = r.ATTRIBUTE_NODE = 2; + var l = r.TEXT_NODE = 3; + var h = r.CDATA_SECTION_NODE = 4; + var c = r.ENTITY_REFERENCE_NODE = 5; + var u = r.ENTITY_NODE = 6; + var _ = r.PROCESSING_INSTRUCTION_NODE = 7; + var d = r.COMMENT_NODE = 8; + var p = r.DOCUMENT_NODE = 9; + var m = r.DOCUMENT_TYPE_NODE = 10; + var f = r.DOCUMENT_FRAGMENT_NODE = 11; + var g = r.NOTATION_NODE = 12; + var y = {}; + var b = {}; + y.INDEX_SIZE_ERR = (b[1] = "Index size error", 1); + y.DOMSTRING_SIZE_ERR = (b[2] = "DOMString size error", 2); + var S = y.HIERARCHY_REQUEST_ERR = (b[3] = "Hierarchy request error", 3); + y.WRONG_DOCUMENT_ERR = (b[4] = "Wrong document", 4); + y.INVALID_CHARACTER_ERR = (b[5] = "Invalid character", 5); + y.NO_DATA_ALLOWED_ERR = (b[6] = "No data allowed", 6); + y.NO_MODIFICATION_ALLOWED_ERR = (b[7] = "No modification allowed", 7); + var A = y.NOT_FOUND_ERR = (b[8] = "Not found", 8); + y.NOT_SUPPORTED_ERR = (b[9] = "Not supported", 9); + var T = y.INUSE_ATTRIBUTE_ERR = (b[10] = "Attribute in use", 10); + y.INVALID_STATE_ERR = (b[11] = "Invalid state", 11); + y.SYNTAX_ERR = (b[12] = "Syntax error", 12); + y.INVALID_MODIFICATION_ERR = (b[13] = "Invalid modification", 13); + y.NAMESPACE_ERR = (b[14] = "Invalid namespace", 14); + y.INVALID_ACCESS_ERR = (b[15] = "Invalid access", 15); + function v(t, e) { + if (e instanceof Error) var i = e; else { + i = this; + Error.call(this, b[t]); + this.message = b[t]; + Error.captureStackTrace && Error.captureStackTrace(this, v); + } + i.code = t; + e && (this.message = this.message + ": " + e); + return i; + } + v.prototype = Error.prototype; + s(y, v); + function E() {} + E.prototype = { + length: 0, + item: function(t) { + return this[t] || null; + }, + toString: function(t, e) { + for (var i = [], s = 0; s < this.length; s++) et(this[s], i, t, e); + return i.join(""); + } + }; + function C(t, e) { + this._node = t; + this._refresh = e; + x(this); + } + function x(t) { + var e = t._node._inc || t._node.ownerDocument._inc; + if (t._inc != e) { + var i = t._refresh(t._node); + nt(t, "length", i.length); + s(i, t); + t._inc = e; + } + } + C.prototype.item = function(t) { + x(this); + return this[t]; + }; + n(C, E); + function w() {} + function R(t, e) { + var i = t.length; + for (;i--; ) if (t[i] === e) return i; + } + function I(t, e, i, s) { + s ? e[R(e, s)] = i : e[e.length++] = i; + if (t) { + i.ownerElement = t; + var n = t.ownerDocument; + if (n) { + s && L(n, t, s); + !function(t, e, i) { + t && t._inc++; + "http://www.w3.org/2000/xmlns/" == i.namespaceURI && (e._nsMap[i.prefix ? i.localName : ""] = i.value); + }(n, t, i); + } + } + } + function M(t, e, i) { + var s = R(e, i); + if (!(s >= 0)) throw v(A, new Error(t.tagName + "@" + i)); + var n = e.length - 1; + for (;s < n; ) e[s] = e[++s]; + e.length = n; + if (t) { + var r = t.ownerDocument; + if (r) { + L(r, t, i); + i.ownerElement = null; + } + } + } + w.prototype = { + length: 0, + item: E.prototype.item, + getNamedItem: function(t) { + var e = this.length; + for (;e--; ) { + var i = this[e]; + if (i.nodeName == t) return i; + } + }, + setNamedItem: function(t) { + var e = t.ownerElement; + if (e && e != this._ownerElement) throw new v(T); + var i = this.getNamedItem(t.nodeName); + I(this._ownerElement, this, t, i); + return i; + }, + setNamedItemNS: function(t) { + var e, i = t.ownerElement; + if (i && i != this._ownerElement) throw new v(T); + e = this.getNamedItemNS(t.namespaceURI, t.localName); + I(this._ownerElement, this, t, e); + return e; + }, + removeNamedItem: function(t) { + var e = this.getNamedItem(t); + M(this._ownerElement, this, e); + return e; + }, + removeNamedItemNS: function(t, e) { + var i = this.getNamedItemNS(t, e); + M(this._ownerElement, this, i); + return i; + }, + getNamedItemNS: function(t, e) { + var i = this.length; + for (;i--; ) { + var s = this[i]; + if (s.localName == e && s.namespaceURI == t) return s; + } + return null; + } + }; + function B(t) { + this._features = {}; + if (t) for (var e in t) this._features = t[e]; + } + B.prototype = { + hasFeature: function(t, e) { + var i = this._features[t.toLowerCase()]; + return !(!i || e && !(e in i)); + }, + createDocument: function(t, e, i) { + var s = new N; + s.implementation = this; + s.childNodes = new E; + s.doctype = i; + i && s.appendChild(i); + if (e) { + var n = s.createElementNS(t, e); + s.appendChild(n); + } + return s; + }, + createDocumentType: function(t, e, i) { + var s = new W; + s.name = t; + s.nodeName = t; + s.publicId = e; + s.systemId = i; + return s; + } + }; + function D() {} + D.prototype = { + firstChild: null, + lastChild: null, + previousSibling: null, + nextSibling: null, + attributes: null, + parentNode: null, + childNodes: null, + ownerDocument: null, + nodeValue: null, + namespaceURI: null, + prefix: null, + localName: null, + insertBefore: function(t, e) { + return k(this, t, e); + }, + replaceChild: function(t, e) { + this.insertBefore(t, e); + e && this.removeChild(e); + }, + removeChild: function(t) { + return V(this, t); + }, + appendChild: function(t) { + return this.insertBefore(t, null); + }, + hasChildNodes: function() { + return null != this.firstChild; + }, + cloneNode: function(t) { + return st(this.ownerDocument || this, this, t); + }, + normalize: function() { + var t = this.firstChild; + for (;t; ) { + var e = t.nextSibling; + if (e && e.nodeType == l && t.nodeType == l) { + this.removeChild(e); + t.appendData(e.data); + } else { + t.normalize(); + t = e; + } + } + }, + isSupported: function(t, e) { + return this.ownerDocument.implementation.hasFeature(t, e); + }, + hasAttributes: function() { + return this.attributes.length > 0; + }, + lookupPrefix: function(t) { + var e = this; + for (;e; ) { + var i = e._nsMap; + if (i) for (var s in i) if (i[s] == t) return s; + e = e.nodeType == a ? e.ownerDocument : e.parentNode; + } + return null; + }, + lookupNamespaceURI: function(t) { + var e = this; + for (;e; ) { + var i = e._nsMap; + if (i && t in i) return i[t]; + e = e.nodeType == a ? e.ownerDocument : e.parentNode; + } + return null; + }, + isDefaultNamespace: function(t) { + return null == this.lookupPrefix(t); + } + }; + function P(t) { + return ("<" == t ? "<" : ">" == t && ">") || "&" == t && "&" || '"' == t && """ || "&#" + t.charCodeAt() + ";"; + } + s(r, D); + s(r, D.prototype); + function O(t, e) { + if (e(t)) return !0; + if (t = t.firstChild) do { + if (O(t, e)) return !0; + } while (t = t.nextSibling); + } + function N() {} + function L(t, e, i, s) { + t && t._inc++; + "http://www.w3.org/2000/xmlns/" == i.namespaceURI && delete e._nsMap[i.prefix ? i.localName : ""]; + } + function F(t, e, i) { + if (t && t._inc) { + t._inc++; + var s = e.childNodes; + if (i) s[s.length++] = i; else { + var n = e.firstChild; + var r = 0; + for (;n; ) { + s[r++] = n; + n = n.nextSibling; + } + s.length = r; + } + } + } + function V(t, e) { + var i = e.previousSibling; + var s = e.nextSibling; + i ? i.nextSibling = s : t.firstChild = s; + s ? s.previousSibling = i : t.lastChild = i; + F(t.ownerDocument, t); + return e; + } + function k(t, e, i) { + var s = e.parentNode; + s && s.removeChild(e); + if (e.nodeType === f) { + var n = e.firstChild; + if (null == n) return e; + var r = e.lastChild; + } else n = r = e; + var o = i ? i.previousSibling : t.lastChild; + n.previousSibling = o; + r.nextSibling = i; + o ? o.nextSibling = n : t.firstChild = n; + null == i ? t.lastChild = r : i.previousSibling = r; + do { + n.parentNode = t; + } while (n !== r && (n = n.nextSibling)); + F(t.ownerDocument || t, t); + e.nodeType == f && (e.firstChild = e.lastChild = null); + return e; + } + N.prototype = { + nodeName: "#document", + nodeType: p, + doctype: null, + documentElement: null, + _inc: 1, + insertBefore: function(t, e) { + if (t.nodeType == f) { + var i = t.firstChild; + for (;i; ) { + var s = i.nextSibling; + this.insertBefore(i, e); + i = s; + } + return t; + } + null == this.documentElement && t.nodeType == o && (this.documentElement = t); + return k(this, t, e), t.ownerDocument = this, t; + }, + removeChild: function(t) { + this.documentElement == t && (this.documentElement = null); + return V(this, t); + }, + importNode: function(t, e) { + return it(this, t, e); + }, + getElementById: function(t) { + var e = null; + O(this.documentElement, (function(i) { + if (i.nodeType == o && i.getAttribute("id") == t) { + e = i; + return !0; + } + })); + return e; + }, + createElement: function(t) { + var e = new U; + e.ownerDocument = this; + e.nodeName = t; + e.tagName = t; + e.childNodes = new E; + (e.attributes = new w)._ownerElement = e; + return e; + }, + createDocumentFragment: function() { + var t = new J; + t.ownerDocument = this; + t.childNodes = new E; + return t; + }, + createTextNode: function(t) { + var e = new H; + e.ownerDocument = this; + e.appendData(t); + return e; + }, + createComment: function(t) { + var e = new j; + e.ownerDocument = this; + e.appendData(t); + return e; + }, + createCDATASection: function(t) { + var e = new X; + e.ownerDocument = this; + e.appendData(t); + return e; + }, + createProcessingInstruction: function(t, e) { + var i = new Z; + i.ownerDocument = this; + i.tagName = i.target = t; + i.nodeValue = i.data = e; + return i; + }, + createAttribute: function(t) { + var e = new G; + e.ownerDocument = this; + e.name = t; + e.nodeName = t; + e.localName = t; + e.specified = !0; + return e; + }, + createEntityReference: function(t) { + var e = new K; + e.ownerDocument = this; + e.nodeName = t; + return e; + }, + createElementNS: function(t, e) { + var i = new U; + var s = e.split(":"); + var n = i.attributes = new w; + i.childNodes = new E; + i.ownerDocument = this; + i.nodeName = e; + i.tagName = e; + i.namespaceURI = t; + if (2 == s.length) { + i.prefix = s[0]; + i.localName = s[1]; + } else i.localName = e; + n._ownerElement = i; + return i; + }, + createAttributeNS: function(t, e) { + var i = new G; + var s = e.split(":"); + i.ownerDocument = this; + i.nodeName = e; + i.name = e; + i.namespaceURI = t; + i.specified = !0; + if (2 == s.length) { + i.prefix = s[0]; + i.localName = s[1]; + } else i.localName = e; + return i; + } + }; + n(N, D); + function U() { + this._nsMap = {}; + } + U.prototype = { + nodeType: o, + hasAttribute: function(t) { + return null != this.getAttributeNode(t); + }, + getAttribute: function(t) { + var e = this.getAttributeNode(t); + return e && e.value || ""; + }, + getAttributeNode: function(t) { + return this.attributes.getNamedItem(t); + }, + setAttribute: function(t, e) { + var i = this.ownerDocument.createAttribute(t); + i.value = i.nodeValue = "" + e; + this.setAttributeNode(i); + }, + removeAttribute: function(t) { + var e = this.getAttributeNode(t); + e && this.removeAttributeNode(e); + }, + appendChild: function(t) { + return t.nodeType === f ? this.insertBefore(t, null) : function(t, e) { + var i = e.parentNode; + if (i) { + var s = t.lastChild; + i.removeChild(e); + s = t.lastChild; + } + s = t.lastChild; + e.parentNode = t; + e.previousSibling = s; + e.nextSibling = null; + s ? s.nextSibling = e : t.firstChild = e; + t.lastChild = e; + F(t.ownerDocument, t, e); + return e; + }(this, t); + }, + setAttributeNode: function(t) { + return this.attributes.setNamedItem(t); + }, + setAttributeNodeNS: function(t) { + return this.attributes.setNamedItemNS(t); + }, + removeAttributeNode: function(t) { + return this.attributes.removeNamedItem(t.nodeName); + }, + removeAttributeNS: function(t, e) { + var i = this.getAttributeNodeNS(t, e); + i && this.removeAttributeNode(i); + }, + hasAttributeNS: function(t, e) { + return null != this.getAttributeNodeNS(t, e); + }, + getAttributeNS: function(t, e) { + var i = this.getAttributeNodeNS(t, e); + return i && i.value || ""; + }, + setAttributeNS: function(t, e, i) { + var s = this.ownerDocument.createAttributeNS(t, e); + s.value = s.nodeValue = "" + i; + this.setAttributeNode(s); + }, + getAttributeNodeNS: function(t, e) { + return this.attributes.getNamedItemNS(t, e); + }, + getElementsByTagName: function(t) { + return new C(this, (function(e) { + var i = []; + O(e, (function(s) { + s === e || s.nodeType != o || "*" !== t && s.tagName != t || i.push(s); + })); + return i; + })); + }, + getElementsByTagNameNS: function(t, e) { + return new C(this, (function(i) { + var s = []; + O(i, (function(n) { + n === i || n.nodeType !== o || "*" !== t && n.namespaceURI !== t || "*" !== e && n.localName != e || s.push(n); + })); + return s; + })); + } + }; + N.prototype.getElementsByTagName = U.prototype.getElementsByTagName; + N.prototype.getElementsByTagNameNS = U.prototype.getElementsByTagNameNS; + n(U, D); + function G() {} + G.prototype.nodeType = a; + n(G, D); + function z() {} + z.prototype = { + data: "", + substringData: function(t, e) { + return this.data.substring(t, t + e); + }, + appendData: function(t) { + t = this.data + t; + this.nodeValue = this.data = t; + this.length = t.length; + }, + insertData: function(t, e) { + this.replaceData(t, 0, e); + }, + appendChild: function(t) { + throw new Error(b[S]); + }, + deleteData: function(t, e) { + this.replaceData(t, e, ""); + }, + replaceData: function(t, e, i) { + i = this.data.substring(0, t) + i + this.data.substring(t + e); + this.nodeValue = this.data = i; + this.length = i.length; + } + }; + n(z, D); + function H() {} + H.prototype = { + nodeName: "#text", + nodeType: l, + splitText: function(t) { + var e = this.data; + var i = e.substring(t); + e = e.substring(0, t); + this.data = this.nodeValue = e; + this.length = e.length; + var s = this.ownerDocument.createTextNode(i); + this.parentNode && this.parentNode.insertBefore(s, this.nextSibling); + return s; + } + }; + n(H, z); + function j() {} + j.prototype = { + nodeName: "#comment", + nodeType: d + }; + n(j, z); + function X() {} + X.prototype = { + nodeName: "#cdata-section", + nodeType: h + }; + n(X, z); + function W() {} + W.prototype.nodeType = m; + n(W, D); + function Y() {} + Y.prototype.nodeType = g; + n(Y, D); + function q() {} + q.prototype.nodeType = u; + n(q, D); + function K() {} + K.prototype.nodeType = c; + n(K, D); + function J() {} + J.prototype.nodeName = "#document-fragment"; + J.prototype.nodeType = f; + n(J, D); + function Z() {} + Z.prototype.nodeType = _; + n(Z, D); + function Q() {} + Q.prototype.serializeToString = function(t, e, i) { + return $.call(t, e, i); + }; + D.prototype.toString = $; + function $(t, e) { + var i = []; + var s = 9 == this.nodeType && this.documentElement || this; + var n = s.prefix; + var r = s.namespaceURI; + if (r && null == n) { + if (null == (n = s.lookupPrefix(r))) var o = [ { + namespace: r, + prefix: null + } ]; + } + et(this, i, t, e, o); + return i.join(""); + } + function tt(t, e, i) { + var s = t.prefix || ""; + var n = t.namespaceURI; + if (!s && !n) return !1; + if ("xml" === s && "http://www.w3.org/XML/1998/namespace" === n || "http://www.w3.org/2000/xmlns/" == n) return !1; + var r = i.length; + for (;r--; ) { + var o = i[r]; + if (o.prefix == s) return o.namespace != n; + } + return !0; + } + function et(t, e, i, s, n) { + if (s) { + if (!(t = s(t))) return; + if ("string" == typeof t) { + e.push(t); + return; + } + } + switch (t.nodeType) { + case o: + n || (n = []); + n.length; + var r = t.attributes; + var u = r.length; + var g = t.firstChild; + var y = t.tagName; + i = "http://www.w3.org/1999/xhtml" === t.namespaceURI || i; + e.push("<", y); + for (var b = 0; b < u; b++) { + "xmlns" == (S = r.item(b)).prefix ? n.push({ + prefix: S.localName, + namespace: S.value + }) : "xmlns" == S.nodeName && n.push({ + prefix: "", + namespace: S.value + }); + } + for (b = 0; b < u; b++) { + var S; + if (tt(S = r.item(b), 0, n)) { + var A = S.prefix || ""; + var T = S.namespaceURI; + var v = A ? " xmlns:" + A : " xmlns"; + e.push(v, '="', T, '"'); + n.push({ + prefix: A, + namespace: T + }); + } + et(S, e, i, s, n); + } + if (tt(t, 0, n)) { + A = t.prefix || ""; + T = t.namespaceURI; + v = A ? " xmlns:" + A : " xmlns"; + e.push(v, '="', T, '"'); + n.push({ + prefix: A, + namespace: T + }); + } + if (g || i && !/^(?:meta|link|img|br|hr|input)$/i.test(y)) { + e.push(">"); + if (i && /^script$/i.test(y)) for (;g; ) { + g.data ? e.push(g.data) : et(g, e, i, s, n); + g = g.nextSibling; + } else for (;g; ) { + et(g, e, i, s, n); + g = g.nextSibling; + } + e.push(""); + } else e.push("/>"); + return; + + case p: + case f: + g = t.firstChild; + for (;g; ) { + et(g, e, i, s, n); + g = g.nextSibling; + } + return; + + case a: + return e.push(" ", t.name, '="', t.value.replace(/[<&"]/g, P), '"'); + + case l: + return e.push(t.data.replace(/[<&]/g, P)); + + case h: + return e.push(""); + + case d: + return e.push("\x3c!--", t.data, "--\x3e"); + + case m: + var E = t.publicId; + var C = t.systemId; + e.push("'); + } else if (C && "." != C) e.push(' SYSTEM "', C, '">'); else { + var x = t.internalSubset; + x && e.push(" [", x, "]"); + e.push(">"); + } + return; + + case _: + return e.push(""); + + case c: + return e.push("&", t.nodeName, ";"); + + default: + e.push("??", t.nodeName); + } + } + function it(t, e, i) { + var s; + switch (e.nodeType) { + case o: + (s = e.cloneNode(!1)).ownerDocument = t; + + case f: + break; + + case a: + i = !0; + } + s || (s = e.cloneNode(!1)); + s.ownerDocument = t; + s.parentNode = null; + if (i) { + var n = e.firstChild; + for (;n; ) { + s.appendChild(it(t, n, i)); + n = n.nextSibling; + } + } + return s; + } + function st(t, e, i) { + var s = new e.constructor; + for (var n in e) { + var r = e[n]; + "object" != typeof r && r != s[n] && (s[n] = r); + } + e.childNodes && (s.childNodes = new E); + s.ownerDocument = t; + switch (s.nodeType) { + case o: + var l = e.attributes; + var h = s.attributes = new w; + var c = l.length; + h._ownerElement = s; + for (var u = 0; u < c; u++) s.setAttributeNode(st(t, l.item(u), !0)); + break; + + case a: + i = !0; + } + if (i) { + var _ = e.firstChild; + for (;_; ) { + s.appendChild(st(t, _, i)); + _ = _.nextSibling; + } + } + return s; + } + function nt(t, e, i) { + t[e] = i; + } + try { + if (Object.defineProperty) { + Object.defineProperty(C.prototype, "length", { + get: function() { + x(this); + return this.$$length; + } + }); + Object.defineProperty(D.prototype, "textContent", { + get: function() { + return rt(this); + }, + set: function(t) { + switch (this.nodeType) { + case o: + case f: + for (;this.firstChild; ) this.removeChild(this.firstChild); + (t || String(t)) && this.appendChild(this.ownerDocument.createTextNode(t)); + break; + + default: + this.data = t; + this.value = t; + this.nodeValue = t; + } + } + }); + function rt(t) { + switch (t.nodeType) { + case o: + case f: + var e = []; + t = t.firstChild; + for (;t; ) { + 7 !== t.nodeType && 8 !== t.nodeType && e.push(rt(t)); + t = t.nextSibling; + } + return e.join(""); + + default: + return t.nodeValue; + } + } + nt = function(t, e, i) { + t["$$" + e] = i; + }; + } + } catch (ot) {} + i.DOMImplementation = B; + i.XMLSerializer = Q; + }, {} ], + 41: [ function(t, e, i) { + i.entityMap = { + lt: "<", + gt: ">", + amp: "&", + quot: '"', + apos: "'", + Agrave: "À", + Aacute: "Á", + Acirc: "Â", + Atilde: "Ã", + Auml: "Ä", + Aring: "Å", + AElig: "Æ", + Ccedil: "Ç", + Egrave: "È", + Eacute: "É", + Ecirc: "Ê", + Euml: "Ë", + Igrave: "Ì", + Iacute: "Í", + Icirc: "Î", + Iuml: "Ï", + ETH: "Ð", + Ntilde: "Ñ", + Ograve: "Ò", + Oacute: "Ó", + Ocirc: "Ô", + Otilde: "Õ", + Ouml: "Ö", + Oslash: "Ø", + Ugrave: "Ù", + Uacute: "Ú", + Ucirc: "Û", + Uuml: "Ü", + Yacute: "Ý", + THORN: "Þ", + szlig: "ß", + agrave: "à", + aacute: "á", + acirc: "â", + atilde: "ã", + auml: "ä", + aring: "å", + aelig: "æ", + ccedil: "ç", + egrave: "è", + eacute: "é", + ecirc: "ê", + euml: "ë", + igrave: "ì", + iacute: "í", + icirc: "î", + iuml: "ï", + eth: "ð", + ntilde: "ñ", + ograve: "ò", + oacute: "ó", + ocirc: "ô", + otilde: "õ", + ouml: "ö", + oslash: "ø", + ugrave: "ù", + uacute: "ú", + ucirc: "û", + uuml: "ü", + yacute: "ý", + thorn: "þ", + yuml: "ÿ", + nbsp: " ", + iexcl: "¡", + cent: "¢", + pound: "£", + curren: "¤", + yen: "¥", + brvbar: "¦", + sect: "§", + uml: "¨", + copy: "©", + ordf: "ª", + laquo: "«", + not: "¬", + shy: "­­", + reg: "®", + macr: "¯", + deg: "°", + plusmn: "±", + sup2: "²", + sup3: "³", + acute: "´", + micro: "µ", + para: "¶", + middot: "·", + cedil: "¸", + sup1: "¹", + ordm: "º", + raquo: "»", + frac14: "¼", + frac12: "½", + frac34: "¾", + iquest: "¿", + times: "×", + divide: "÷", + forall: "∀", + part: "∂", + exist: "∃", + empty: "∅", + nabla: "∇", + isin: "∈", + notin: "∉", + ni: "∋", + prod: "∏", + sum: "∑", + minus: "−", + lowast: "∗", + radic: "√", + prop: "∝", + infin: "∞", + ang: "∠", + and: "∧", + or: "∨", + cap: "∩", + cup: "∪", + int: "∫", + there4: "∴", + sim: "∼", + cong: "≅", + asymp: "≈", + ne: "≠", + equiv: "≡", + le: "≤", + ge: "≥", + sub: "⊂", + sup: "⊃", + nsub: "⊄", + sube: "⊆", + supe: "⊇", + oplus: "⊕", + otimes: "⊗", + perp: "⊥", + sdot: "⋅", + Alpha: "Α", + Beta: "Β", + Gamma: "Γ", + Delta: "Δ", + Epsilon: "Ε", + Zeta: "Ζ", + Eta: "Η", + Theta: "Θ", + Iota: "Ι", + Kappa: "Κ", + Lambda: "Λ", + Mu: "Μ", + Nu: "Ν", + Xi: "Ξ", + Omicron: "Ο", + Pi: "Π", + Rho: "Ρ", + Sigma: "Σ", + Tau: "Τ", + Upsilon: "Υ", + Phi: "Φ", + Chi: "Χ", + Psi: "Ψ", + Omega: "Ω", + alpha: "α", + beta: "β", + gamma: "γ", + delta: "δ", + epsilon: "ε", + zeta: "ζ", + eta: "η", + theta: "θ", + iota: "ι", + kappa: "κ", + lambda: "λ", + mu: "μ", + nu: "ν", + xi: "ξ", + omicron: "ο", + pi: "π", + rho: "ρ", + sigmaf: "ς", + sigma: "σ", + tau: "τ", + upsilon: "υ", + phi: "φ", + chi: "χ", + psi: "ψ", + omega: "ω", + thetasym: "ϑ", + upsih: "ϒ", + piv: "ϖ", + OElig: "Œ", + oelig: "œ", + Scaron: "Š", + scaron: "š", + Yuml: "Ÿ", + fnof: "ƒ", + circ: "ˆ", + tilde: "˜", + ensp: " ", + emsp: " ", + thinsp: " ", + zwnj: "‌", + zwj: "‍", + lrm: "‎", + rlm: "‏", + ndash: "–", + mdash: "—", + lsquo: "‘", + rsquo: "’", + sbquo: "‚", + ldquo: "“", + rdquo: "”", + bdquo: "„", + dagger: "†", + Dagger: "‡", + bull: "•", + hellip: "…", + permil: "‰", + prime: "′", + Prime: "″", + lsaquo: "‹", + rsaquo: "›", + oline: "‾", + euro: "€", + trade: "™", + larr: "←", + uarr: "↑", + rarr: "→", + darr: "↓", + harr: "↔", + crarr: "↵", + lceil: "⌈", + rceil: "⌉", + lfloor: "⌊", + rfloor: "⌋", + loz: "◊", + spades: "♠", + clubs: "♣", + hearts: "♥", + diams: "♦" + }; + }, {} ], + 42: [ function(t, e, i) { + var s = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/; + var n = new RegExp("[\\-\\.0-9" + s.source.slice(1, -1) + "\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"); + var r = new RegExp("^" + s.source + n.source + "*(?::" + s.source + n.source + "*)?$"); + function o() {} + o.prototype = { + parse: function(t, e, i) { + var s = this.domBuilder; + s.startDocument(); + _(e, e = {}); + !function(t, e, i, s, n) { + function r(t) { + if (t > 65535) { + var e = 55296 + ((t -= 65536) >> 10), i = 56320 + (1023 & t); + return String.fromCharCode(e, i); + } + return String.fromCharCode(t); + } + function o(t) { + var e = t.slice(1, -1); + if (e in i) return i[e]; + if ("#" === e.charAt(0)) return r(parseInt(e.substr(1).replace("x", "0x"))); + n.error("entity not found:" + t); + return t; + } + function _(e) { + if (e > v) { + var i = t.substring(v, e).replace(/&#?\w+;/g, o); + S && f(v); + s.characters(i, 0, e - v); + v = e; + } + } + function f(e, i) { + for (;e >= y && (i = b.exec(t)); ) { + g = i.index; + y = g + i[0].length; + S.lineNumber++; + } + S.columnNumber = e - g + 1; + } + var g = 0; + var y = 0; + var b = /.*(?:\r\n?|\n)|.*$/g; + var S = s.locator; + var A = [ { + currentNSMap: e + } ]; + var T = {}; + var v = 0; + for (;;) { + try { + var E = t.indexOf("<", v); + if (E < 0) { + if (!t.substr(v).match(/^\s*$/)) { + var C = s.doc; + var x = C.createTextNode(t.substr(v)); + C.appendChild(x); + s.currentElement = x; + } + return; + } + E > v && _(E); + switch (t.charAt(E + 1)) { + case "/": + var w = t.indexOf(">", E + 3); + var R = t.substring(E + 2, w); + var I = A.pop(); + if (w < 0) { + R = t.substring(E + 2).replace(/[\s<].*/, ""); + n.error("end tag name: " + R + " is not complete:" + I.tagName); + w = E + 1 + R.length; + } else if (R.match(/\s v ? v = w : _(Math.max(E, v) + 1); + } + }(t, e, i, s, this.errorHandler); + s.endDocument(); + } + }; + function a(t, e) { + e.lineNumber = t.lineNumber; + e.columnNumber = t.columnNumber; + return e; + } + function l(t, e, i, s, n, r) { + var o; + var a = ++e; + var l = 0; + for (;;) { + var h = t.charAt(a); + switch (h) { + case "=": + if (1 === l) { + o = t.slice(e, a); + l = 3; + } else { + if (2 !== l) throw new Error("attribute equal must after attrName"); + l = 3; + } + break; + + case "'": + case '"': + if (3 === l || 1 === l) { + if (1 === l) { + r.warning('attribute value must after "="'); + o = t.slice(e, a); + } + e = a + 1; + if (!((a = t.indexOf(h, e)) > 0)) throw new Error("attribute value no end '" + h + "' match"); + c = t.slice(e, a).replace(/&#?\w+;/g, n); + i.add(o, c, e - 1); + l = 5; + } else { + if (4 != l) throw new Error('attribute value must after "="'); + c = t.slice(e, a).replace(/&#?\w+;/g, n); + i.add(o, c, e); + r.warning('attribute "' + o + '" missed start quot(' + h + ")!!"); + e = a + 1; + l = 5; + } + break; + + case "/": + switch (l) { + case 0: + i.setTagName(t.slice(e, a)); + + case 5: + case 6: + case 7: + l = 7; + i.closed = !0; + + case 4: + case 1: + case 2: + break; + + default: + throw new Error("attribute invalid close char('/')"); + } + break; + + case "": + r.error("unexpected end of input"); + 0 == l && i.setTagName(t.slice(e, a)); + return a; + + case ">": + switch (l) { + case 0: + i.setTagName(t.slice(e, a)); + + case 5: + case 6: + case 7: + break; + + case 4: + case 1: + if ("/" === (c = t.slice(e, a)).slice(-1)) { + i.closed = !0; + c = c.slice(0, -1); + } + + case 2: + 2 === l && (c = o); + if (4 == l) { + r.warning('attribute "' + c + '" missed quot(")!!'); + i.add(o, c.replace(/&#?\w+;/g, n), e); + } else { + "http://www.w3.org/1999/xhtml" === s[""] && c.match(/^(?:disabled|checked|selected)$/i) || r.warning('attribute "' + c + '" missed value!! "' + c + '" instead!!'); + i.add(c, c, e); + } + break; + + case 3: + throw new Error("attribute value missed!!"); + } + return a; + + case "€": + h = " "; + + default: + if (h <= " ") switch (l) { + case 0: + i.setTagName(t.slice(e, a)); + l = 6; + break; + + case 1: + o = t.slice(e, a); + l = 2; + break; + + case 4: + var c = t.slice(e, a).replace(/&#?\w+;/g, n); + r.warning('attribute "' + c + '" missed quot(")!!'); + i.add(o, c, e); + + case 5: + l = 6; + } else switch (l) { + case 2: + i.tagName; + "http://www.w3.org/1999/xhtml" === s[""] && o.match(/^(?:disabled|checked|selected)$/i) || r.warning('attribute "' + o + '" missed value!! "' + o + '" instead2!!'); + i.add(o, o, e); + e = a; + l = 1; + break; + + case 5: + r.warning('attribute space is required"' + o + '"!!'); + + case 6: + l = 1; + e = a; + break; + + case 3: + l = 4; + e = a; + break; + + case 7: + throw new Error("elements closed character '/' and '>' must be connected to"); + } + } + a++; + } + } + function h(t, e, i) { + var s = t.tagName; + var n = null; + var r = t.length; + for (;r--; ) { + var o = t[r]; + var a = o.qName; + var l = o.value; + if ((d = a.indexOf(":")) > 0) { + var h = o.prefix = a.slice(0, d); + var c = a.slice(d + 1); + var u = "xmlns" === h && c; + } else { + c = a; + h = null; + u = "xmlns" === a && ""; + } + o.localName = c; + if (!1 !== u) { + if (null == n) { + n = {}; + _(i, i = {}); + } + i[u] = n[u] = l; + o.uri = "http://www.w3.org/2000/xmlns/"; + e.startPrefixMapping(u, l); + } + } + r = t.length; + for (;r--; ) { + if (h = (o = t[r]).prefix) { + "xml" === h && (o.uri = "http://www.w3.org/XML/1998/namespace"); + "xmlns" !== h && (o.uri = i[h || ""]); + } + } + var d; + if ((d = s.indexOf(":")) > 0) { + h = t.prefix = s.slice(0, d); + c = t.localName = s.slice(d + 1); + } else { + h = null; + c = t.localName = s; + } + var p = t.uri = i[h || ""]; + e.startElement(p, c, s, t); + if (!t.closed) { + t.currentNSMap = i; + t.localNSMap = n; + return !0; + } + e.endElement(p, c, s); + if (n) for (h in n) e.endPrefixMapping(h); + } + function c(t, e, i, s, n) { + if (/^(?:script|textarea)$/i.test(i)) { + var r = t.indexOf("", e); + var o = t.substring(e + 1, r); + if (/[&<]/.test(o)) { + if (/^script$/i.test(i)) { + n.characters(o, 0, o.length); + return r; + } + o = o.replace(/&#?\w+;/g, s); + n.characters(o, 0, o.length); + return r; + } + } + return e + 1; + } + function u(t, e, i, s) { + var n = s[i]; + if (null == n) { + (n = t.lastIndexOf("")) < e && (n = t.lastIndexOf(" e) { + i.comment(t, e + 4, n - e - 4); + return n + 3; + } + s.error("Unclosed comment"); + return -1; + } + return -1; + } + if ("CDATA[" == t.substr(e + 3, 6)) { + var n = t.indexOf("]]>", e + 9); + i.startCDATA(); + i.characters(t, e + 9, n - e - 9); + i.endCDATA(); + return n + 3; + } + var r = function(t, e) { + var i; + var s = []; + var n = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g; + n.lastIndex = e; + n.exec(t); + for (;i = n.exec(t); ) { + s.push(i); + if (i[1]) return s; + } + }(t, e); + var o = r.length; + if (o > 1 && /!doctype/i.test(r[0][0])) { + var a = r[1][0]; + var l = o > 3 && /^public$/i.test(r[2][0]) && r[3][0]; + var h = o > 4 && r[4][0]; + var c = r[o - 1]; + i.startDTD(a, l && l.replace(/^(['"])(.*?)\1$/, "$2"), h && h.replace(/^(['"])(.*?)\1$/, "$2")); + i.endDTD(); + return c.index + c[0].length; + } + return -1; + } + function p(t, e, i) { + var s = t.indexOf("?>", e); + if (s) { + var n = t.substring(e, s).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/); + if (n) { + n[0].length; + i.processingInstruction(n[1], n[2]); + return s + 2; + } + return -1; + } + return -1; + } + function m(t) {} + m.prototype = { + setTagName: function(t) { + if (!r.test(t)) throw new Error("invalid tagName:" + t); + this.tagName = t; + }, + add: function(t, e, i) { + if (!r.test(t)) throw new Error("invalid attribute:" + t); + this[this.length++] = { + qName: t, + value: e, + offset: i + }; + }, + length: 0, + getLocalName: function(t) { + return this[t].localName; + }, + getLocator: function(t) { + return this[t].locator; + }, + getQName: function(t) { + return this[t].qName; + }, + getURI: function(t) { + return this[t].uri; + }, + getValue: function(t) { + return this[t].value; + } + }; + i.XMLReader = o; + }, {} ] + }, {}, [ 5 ]); + }, + 915: () => { + "use strict"; + System.register([], (function(t, e) { + var i; + t("Application", void 0); + return { + setters: [], + execute: function() { + t("Application", class { + constructor() { + this.settingsPath = "src/settings.json"; + this.showFPS = !0; + } + init(t) { + (i = t).game.onPostBaseInitDelegate.add(this.onPostInitBase.bind(this)); + i.game.onPostSubsystemInitDelegate.add(this.onPostSystemInit.bind(this)); + } + onPostInitBase() {} + onPostSystemInit() {} + start() { + return i.game.init({ + debugMode: i.DebugMode.INFO, + settingsPath: this.settingsPath, + overrideSettings: { + profiling: { + showFPS: this.showFPS + } + } + }).then((() => i.game.run())); + } + }); + } + }; + })); + }, + 513: () => { + "use strict"; + System.register([], (function(t, e) { + return { + execute: function() { + System.register("chunks:///_virtual/rollupPluginModLoBabelHelpers.js", [], (function(t) { + return { + execute: function() { + t({ + applyDecoratedDescriptor: function(t, e, i, s, n) { + var r = {}; + Object.keys(s).forEach((function(t) { + r[t] = s[t]; + })); + r.enumerable = !!r.enumerable; + r.configurable = !!r.configurable; + ("value" in r || r.initializer) && (r.writable = !0); + r = i.slice().reverse().reduce((function(i, s) { + return s(t, e, i) || i; + }), r); + if (n && void 0 !== r.initializer) { + r.value = r.initializer ? r.initializer.call(n) : void 0; + r.initializer = void 0; + } + if (void 0 === r.initializer) { + Object.defineProperty(t, e, r); + r = null; + } + return r; + }, + initializerDefineProperty: function(t, e, i, s) { + if (!i) return; + Object.defineProperty(t, e, { + enumerable: i.enumerable, + configurable: i.configurable, + writable: i.writable, + value: i.initializer ? i.initializer.call(s) : void 0 + }); + } + }); + } + }; + })); + } + }; + })); + }, + 61: (t, e, i) => { + "use strict"; + System.register([], (function(t, e) { + return { + execute: function() { + t({ + AntiAliasing: void 0, + BitMask: ie, + CCClass: si, + CacheMode: void 0, + DebugMode: void 0, + DeviceType: void 0, + EAxisDirection: void 0, + ECollider2DType: void 0, + EJoint2DType: void 0, + EPhysics2DDrawFlags: void 0, + ERaycast2DType: void 0, + ERigidBody2DType: void 0, + ERigidBodyType: void 0, + Enum: oe, + Eventify: To, + ExtrapolationMode: void 0, + HorizontalTextAlignment: void 0, + InstanceMaterialType: void 0, + KeyCode: void 0, + NodeEventType: void 0, + Overflow: void 0, + Physics2DManifoldType: void 0, + PhysicsGroup: void 0, + PipelineEventType: void 0, + QuatInterpolationMode: void 0, + RealInterpolationMode: void 0, + SystemEventType: void 0, + TangentWeightMode: void 0, + VerticalTextAlignment: void 0, + WorldNode3DToLocalNodeUI: UR, + WorldNode3DToWorldNodeUI: GR, + XrControlEventType: void 0, + XrKeyboardEventType: void 0, + XrUIPressEventType: void 0, + __checkObsoleteInNamespace__: function(t) { + st || (st = "undefined" == typeof Proxy ? {} : new Proxy(t, { + get(t, e, i) { + it(e); + return Reflect.get(t, e, i); + } + })); + return st; + }, + __checkObsolete__: function(t) { + for (let e of t) it(e); + }, + absMax: Ri, + absMaxComponent: wi, + approx: ui, + assert: w, + assertID: k, + bezier: Qd, + bezierByTime: rp, + buildShadowPass: hI, + buildShadowPasses: uI, + ccenum: he, + clamp: _i, + clamp01: di, + color: Di, + computeRatioByType: KZ, + debug: R, + deprecateModuleExportedName: et, + deserialize: o_, + earcut: Dk, + enumerableProps: Ii, + equals: ci, + error: x, + errorID: F, + find: mv, + fragmentText: MM, + getBaselineOffset: fM, + getCameraUniqueID: dI, + getEnglishWordPartAtFirst: RM, + getEnglishWordPartAtLast: IM, + getError: G, + getLoadOpOfClearFlag: pI, + getPathFromRoot: function(t, e) { + let i = t; + let s = ""; + for (;null !== i && i !== e; ) { + s = `${i.name}/${s}`; + i = i.parent; + } + return s.slice(0, -1); + }, + getRenderArea: lI, + getSerializationMetadata: function(t) { + return t[Wl]; + }, + getWorldTransformUntilRoot: KW, + instantiate: d_, + inverseLerp: xi, + isDisplayStats: z, + isEnglishWordPartAtFirst: function(t) { + return vM.test(t); + }, + isEnglishWordPartAtLast: function(t) { + return TM.test(t); + }, + isUnicodeCJK: EM, + isUnicodeSpace: CM, + isValid: po, + lerp: pi, + log: E, + logID: P, + markAsWarning: void 0, + mat4: Zi, + murmurhash2_32_gc: Ur, + nextPow2: vi, + pingPong: Ci, + pseudoRandom: Si, + pseudoRandomRange: Ai, + pseudoRandomRangeInt: Ti, + quat: Wi, + randomRange: yi, + randomRangeInt: bi, + rect: ls, + removeProperty: void 0, + repeat: Ei, + replaceProperty: void 0, + safeMeasureText: xM, + sampleAnimationCurve: qZ, + setDefaultLogTimes: function(t) { + t > 0 && (X = t); + }, + setDisplayStats: H, + size: os, + toDegree: fi, + toRadian: mi, + tween: _Ft, + tweenUtil: dFt, + v2: es, + v3: Li, + v4: ss, + validPunctualLightsCulling: gI, + warn: C, + warnID: N + }); + const s = 2147483647; + function n(t) { + return (t > 0) - (t < 0); + } + function r(t) { + let e; + let i; + e = (t > 65535) << 4; + i = ((t >>>= e) > 255) << 3; + e |= i; + i = ((t >>>= i) > 15) << 2; + e |= i; + i = ((t >>>= i) > 3) << 1; + e |= i; + return e | (t >>>= i) >> 1; + } + function o(t) { + return 16843009 * ((t = (858993459 & (t -= t >>> 1 & 1431655765)) + (t >>> 2 & 858993459)) + (t >>> 4) & 252645135) >>> 24; + } + function a(t) { + let e = 32; + (t &= -t) && e--; + 65535 & t && (e -= 16); + 16711935 & t && (e -= 8); + 252645135 & t && (e -= 4); + 858993459 & t && (e -= 2); + 1431655765 & t && (e -= 1); + return e; + } + function l(t) { + --t; + t |= t >>> 1; + t |= t >>> 2; + t |= t >>> 4; + t |= t >>> 8; + return (t |= t >>> 16) + 1; + } + const h = new Array(256); + (t => { + for (let e = 0; e < 256; ++e) { + let i = e; + let s = e; + let n = 7; + for (i >>>= 1; i; i >>>= 1) { + s <<= 1; + s |= 1 & i; + --n; + } + t[e] = s << n & 255; + } + })(h); + var c = Object.freeze({ + __proto__: null, + INT_BITS: 32, + INT_MAX: s, + INT_MIN: -2147483648, + sign: n, + abs: function(t) { + const e = t >> 31; + return (t ^ e) - e; + }, + min: function(t, e) { + return e ^ (t ^ e) & -(t < e); + }, + max: function(t, e) { + return t ^ (t ^ e) & -(t < e); + }, + isPow2: function(t) { + return !(t & t - 1 || !t); + }, + log2: r, + log10: function(t) { + return t >= 1e9 ? 9 : t >= 1e8 ? 8 : t >= 1e7 ? 7 : t >= 1e6 ? 6 : t >= 1e5 ? 5 : t >= 1e4 ? 4 : t >= 1e3 ? 3 : t >= 100 ? 2 : t >= 10 ? 1 : 0; + }, + popCount: o, + countTrailingZeros: a, + nextPow2: l, + prevPow2: function(t) { + t |= t >>> 1; + t |= t >>> 2; + t |= t >>> 4; + t |= t >>> 8; + return (t |= t >>> 16) - (t >>> 1); + }, + parity: function(t) { + t ^= t >>> 16; + t ^= t >>> 8; + t ^= t >>> 4; + return 27030 >>> (t &= 15) & 1; + }, + reverse: function(t) { + return h[255 & t] << 24 | h[t >>> 8 & 255] << 16 | h[t >>> 16 & 255] << 8 | h[t >>> 24 & 255]; + }, + interleave2: function(t, e) { + return (t = 1431655765 & ((t = 858993459 & ((t = 252645135 & ((t = 16711935 & ((t &= 65535) | t << 8)) | t << 4)) | t << 2)) | t << 1)) | (e = 1431655765 & ((e = 858993459 & ((e = 252645135 & ((e = 16711935 & ((e &= 65535) | e << 8)) | e << 4)) | e << 2)) | e << 1)) << 1; + }, + deinterleave2: function(t, e) { + return (t = 65535 & ((t = 16711935 & ((t = 252645135 & ((t = 858993459 & ((t = t >>> e & 1431655765) | t >>> 1)) | t >>> 2)) | t >>> 4)) | t >>> 16)) << 16 >> 16; + }, + interleave3: function(t, e, i) { + t = 1227133513 & ((t = 3272356035 & ((t = 251719695 & ((t = 4278190335 & ((t &= 1023) | t << 16)) | t << 8)) | t << 4)) | t << 2); + return (t |= (e = 1227133513 & ((e = 3272356035 & ((e = 251719695 & ((e = 4278190335 & ((e &= 1023) | e << 16)) | e << 8)) | e << 4)) | e << 2)) << 1) | (i = 1227133513 & ((i = 3272356035 & ((i = 251719695 & ((i = 4278190335 & ((i &= 1023) | i << 16)) | i << 8)) | i << 4)) | i << 2)) << 2; + }, + deinterleave3: function(t, e) { + return (t = 1023 & ((t = 4278190335 & ((t = 251719695 & ((t = 3272356035 & ((t = t >>> e & 1227133513) | t >>> 2)) | t >>> 4)) | t >>> 8)) | t >>> 16)) << 22 >> 22; + }, + nextCombination: function(t) { + const e = t | t - 1; + return e + 1 | (~e & -~e) - 1 >>> a(t) + 1; + } + }); + t("bits", c); + function u(t, e) { + const i = "undefined" == typeof window ? global : window; + return void 0 === i[t] ? i[t] = e : i[t]; + } + u("CC_WECHAT", !1); + u("CC_BAIDU", !1); + u("CC_XIAOMI", !1); + u("CC_ALIPAY", !1); + u("CC_BYTEDANCE", !1); + u("CC_OPPO", !1); + u("CC_VIVO", !1); + u("CC_HUAWEI", !1); + u("CC_COCOSPLAY", !1); + u("CC_QTT", !1); + u("CC_LINKSURE", !1); + const _ = !1; + u("CC_EDITOR", !1); + u("CC_PREVIEW", !1); + u("CC_BUILD", !0); + u("CC_TEST", !1); + u("CC_DEBUG", !0); + u("CC_DEV", !1); + u("CC_MINIGAME", !1); + u("CC_RUNTIME_BASED", !1); + u("CC_SUPPORT_JIT", !1); + u("CC_JSB", !0); + var d = { + 1006: "[Action step]. override me", + 1007: "[Action update]. override me", + 1008: "[Action reverse]. override me", + 1100: "Expected 'data' dict, but not found. Config file: %s", + 1101: "Please load the resource first : %s", + 1200: "cocos2d: Director: Error in gettimeofday", + 1204: "Running scene should not be null", + 1205: "The scene should not be null", + 1206: "loadScene: The scene index to load (%s) is out of range.", + 1207: "loadScene: Unknown name type to load: '%s'", + 1208: "loadScene: Failed to load scene '%s' because '%s' is already being loaded.", + 1209: "loadScene: Can not load the scene '%s' because it was not in the build settings before playing.", + 1210: "Failed to preload '%s', %s", + 1211: "loadScene: The scene index to load (%s) is out of range.", + 1212: "loadScene: Unknown name type to load: '%s'", + 1213: "loadScene: Failed to load scene '%s' because '%s' is already loading", + 1214: "loadScene: Can not load the scene '%s' because it was not in the build settings before playing.", + 1215: "Failed to preload '%s', %s", + 1216: "Director.runSceneImmediate: scene is not valid", + 1217: "Director._initOnEngineInitialized: renderer root initialization failed", + 1218: "Forward render pipeline initialized.", + 1219: "Deferred render pipeline initialized. Note that non-transparent materials with no lighting will not be rendered, such as builtin-unlit.", + 1220: "Failed to set shading scale, pipelineSceneData is invalid.", + 1221: "Setting orientation is not supported yet.", + 1300: "%s is not in the model pool and cannot be destroyed by destroyModel.", + 1400: "'%s' is deprecated, please use '%s' instead.", + 1404: "cc.spriteFrameCache is removed, please use cc.loader to load and cache sprite frames of atlas format.", + 1406: "'%s.%s' is removed", + 1408: "'%s' is removed", + 1409: "element type is wrong!", + 1502: "cc.scheduler.scheduleCallbackForTarget(): target should be non-null.", + 1503: "cc.Scheduler.pauseTarget():target should be non-null", + 1504: "cc.Scheduler.resumeTarget():target should be non-null", + 1505: "cc.Scheduler.isTargetPaused():target should be non-null", + 1506: "warning: you CANNOT change update priority in scheduled function", + 1507: "scheduler#scheduleSelector. Selector already scheduled. Updating interval from: %.4f to %.4f", + 1508: "Argument callback must not be empty", + 1509: "Argument target must be non-nullptr", + 1510: "cc.Scheduler: Illegal target which doesn't have id, you should do Scheduler.enableForTarget(target) before all scheduler API usage on target", + 1511: "cc.Scheduler: pause state of the scheduled task doesn't match the element pause state in Scheduler, the given paused state will be ignored.", + 1513: "cc.Scheduler: scheduler stopped using `__instanceId` as id since v2.0, you should do Scheduler.enableForTarget(target) before all scheduler API usage on target", + 1607: "removeFromParentAndCleanup is deprecated. Use removeFromParent instead", + 1619: "callback function must be non-null", + 1620: "interval must be positive", + 1623: "Set '%s' to normal node (not persist root node).", + 1624: "Replacing with the same sgNode", + 1625: "The replacement sgNode should not contain any child.", + 1626: "Should not set alpha via 'color', set 'opacity' please.", + 1627: "Not support for asynchronous creating node in SG", + 1632: "Node name can not include '/'.", + 1633: "Internal error, should not remove unknown node from parent.", + 1635: "reorderChild: this child is not in children list.", + 1636: "Node's zIndex value can't be greater than cc.macro.MAX_ZINDEX, setting to the maximum value", + 1637: "Node's zIndex value can't be smaller than cc.macro.MIN_ZINDEX, setting to the minimum value", + 1638: "Private node's zIndex can't be set, it will keep cc.macro.MIN_ZINDEX as its value", + 1800: "cc._EventListenerKeyboard.checkAvailable(): Invalid EventListenerKeyboard!", + 1801: "cc._EventListenerTouchOneByOne.checkAvailable(): Invalid EventListenerTouchOneByOne!", + 1802: "cc._EventListenerTouchAllAtOnce.checkAvailable(): Invalid EventListenerTouchAllAtOnce!", + 1803: "cc._EventListenerAcceleration.checkAvailable():_onAccelerationEvent must be non-nil", + 1900: "Invalid parameter.", + 2104: "Layer collision. The name of layer (%s) is collided with the name or value of some layer", + 2200: "Design resolution not valid", + 2201: "should set resolutionPolicy", + 2300: "The touches is more than MAX_TOUCHES, nUnusedIndex = %s", + 2402: "Forward pipeline startup failed!", + 3103: "cc.Texture.addImage(): path should be non-null", + 3119: "Lazy init texture with image element failed due to image loading failure: %s", + 3120: "Loading texture with unsupported type: '%s'. Add '%s' into 'cc.macro.SUPPORT_TEXTURE_FORMATS' please.", + 3121: "Can't find a texture format supported by the current platform! Please add a fallback format in the editor.", + 3122: "Error Texture in %s.", + 3123: "Set same texture %s.", + 3124: "Texture: setMipRange failed because base level is larger than max level", + 3300: "Rect width exceeds maximum margin: %s", + 3301: "Rect height exceeds maximum margin: %s", + 3500: "0 priority is forbidden for fixed priority since it's used for scene graph based priority.", + 3501: "Invalid listener type!", + 3502: "Can't set fixed priority with scene graph based listener.", + 3503: "Invalid parameters.", + 3504: "listener must be a cc.EventListener object when adding a fixed priority listener", + 3505: "The listener has been registered, please don't register it again.", + 3506: "Unsupported listener target.", + 3507: "Invalid scene graph priority!", + 3508: "If program goes here, there should be event in dispatch.", + 3509: "_inDispatch should be 1 here.", + 3510: "%s's scene graph node not contains in the parent's children", + 3511: "event is undefined", + 3512: "Event manager only support scene graph priority for ui nodes which contain UIComponent", + 3520: "Device Motion Event request permission: %s", + 3521: "Device Motion Event request permission failed: %s", + 3601: "The editor property 'playOnFocus' should be used with 'executeInEditMode' in class '%s'", + 3602: "Unknown editor property '%s' in class '%s'.", + 3603: "Use 'cc.Float' or 'cc.Integer' instead of 'cc.Number' please.", + 3604: "Can only indicate one type attribute for %s.", + 3605: "The default value of %s is not instance of %s.", + 3606: "No needs to indicate the '%s' attribute for %s, which its default value is type of %s.", + 3607: "The default value of %s must be an empty string.", + 3608: "The type of %s must be CCString, not String.", + 3609: "The type of %s must be CCBoolean, not Boolean.", + 3610: "The type of %s must be CCFloat or CCInteger, not Number.", + 3611: "Can not indicate the '%s' attribute for %s, which its default value is type of %s.", + 3612: "%s Just set the default value to 'new %s()' and it will be handled properly.", + 3613: "'No need to use 'serializable: false' or 'editorOnly: true' for the getter of '%s.%s', every getter is actually non-serialized.", + 3614: "Should not define constructor for cc.Component %s.", + 3615: "Each script can have at most one Component.", + 3616: "Should not specify class name %s for Component which defines in project.", + 3618: "ctor of '%s' can not be another CCClass", + 3623: "Can not use 'editor' attribute, '%s' not inherits from Components.", + 3625: "[isChildClassOf] superclass should be function type, not", + 3626: "Can't remove '%s' because '%s' depends on it.", + 3627: "Should not add renderer component (%s) to a Canvas node.", + 3628: "Should not add %s to a node which size is already used by its other component.", + 3633: "Properties function of '%s' should return an object!", + 3634: "Disallow to use '.' in property name", + 3637: "Can not declare %s.%s, it is already defined in the prototype of %s", + 3639: "Can not apply the specified attribute to the getter of '%s.%s', attribute index: %s", + 3640: "'%s': the setter of '%s' is already defined!", + 3641: "Can not construct %s because it contains object property.", + 3644: "Please define 'type' parameter of %s.%s as the actual constructor.", + 3645: "Please define 'type' parameter of %s.%s as the constructor of %s.", + 3646: "Unknown 'type' parameter of %s.%s:%s", + 3647: "The length of range array must be equal or greater than 2", + 3648: "Can not declare %s.%s method, it is already defined in the properties of %s.", + 3652: "Failed to `new %s()` under the hood, %s\nIt is used for getting default values declared in TypeScript in the first place.\nPlease ensure the constructor can be called during the script's initialization.", + 3653: 'Please do not specifiy "default" attribute in decorator of "%s" property in "%s" class.\nDefault value must be initialized at their declaration:\n\n \n// Before:\n@property({\n type: cc.SpriteFrame\n default: null // <--\n})\nmyProp;\n// After:\n@property({\n type: cc.SpriteFrame\n})\nmyProp = null; // <--', + 3654: 'Please specifiy a default value for "%s.%s" property at its declaration:\n\n \n// Before:\n@property(...)\nmyProp;\n// After:\n@property(...)\nmyProp = 0;', + 3655: 'Can not specifiy "get" or "set" attribute in decorator for "%s" property in "%s" class.\nPlease use:\n\n \n@property(...)\nget %s () {\n ...\n}\n@property\nset %s (value) {\n ...\n}', + 3659: "Violation error: extending enumerations shall have non-overlaped member names or member values", + 3660: "You are explicitly specifying `undefined` type to cc property \"%s\" of cc class \"%s\".\nIs this intended? If not, this may indicate a circular reference.\nFor example:\n\n \n// foo.ts\nimport { _decorator } from 'cc';\nimport { Bar } from './bar'; // Given that './bar' also reference 'foo.ts'.\n // When importing './bar', execution of './bar' is hung on to wait execution of 'foo.ts',\n // the `Bar` imported here is `undefined` until './bar' finish its execution.\n // It leads to that\n@_decorator.ccclass // ↓\nexport class Foo { // ↓\n @_decorator.type(Bar) // → is equivalent to `@_decorator.type(undefined)`\n public bar: Bar; // To eliminate this error, either:\n // - Refactor your module structure(recommended), or\n // - specify the type as cc class name: `@_decorator.type('Bar'/* or any name you specified for `Bar` */)`\n}", + 3700: "internal error: _prefab is undefined", + 3701: "Failed to load prefab asset for node '%s'", + 3800: "The target can not be made persist because it's not a cc.Node or it doesn't have _id property.", + 3801: "The node can not be made persist because it's not under root node.", + 3802: "The node can not be made persist because it's not in current scene.", + 3803: "The target can not be made persist because it's not a cc.Node or it doesn't have _id property.", + 3804: "getComponent: Type must be non-nil", + 3805: "Can't add component '%s' because %s already contains the same component.", + 3806: "Can't add component '%s' to %s because it conflicts with the existing '%s' derived component.", + 3807: "addComponent: Failed to get class '%s'", + 3808: "addComponent: Should not add component ('%s') when the scripts are still loading.", + 3809: "addComponent: The component to add must be a constructor", + 3810: "addComponent: The component to add must be child class of cc.Component", + 3811: "_addComponentAt: The component to add must be a constructor", + 3812: "_addComponentAt: Index out of range", + 3813: "removeComponent: Component must be non-nil", + 3814: "Argument must be non-nil", + 3815: "Component not owned by this entity", + 3816: "Node '%s' is already activating", + 3817: "Sorry, the component of '%s' which with an index of %s is corrupted! It has been removed.", + 3818: "Failed to read or parse project.json", + 3819: "Warning: target element is not a DIV or CANVAS", + 3820: "The renderer doesn't support the renderMode %s", + 3821: "Cannot change hierarchy while activating or deactivating the parent.", + 3822: "addComponent: Cannot add any component to the scene.", + 3823: "The enabled component (id: %s, name: %s) doesn't have a valid node", + 3900: "Invalid clip to add", + 3901: "Invalid clip to remove", + 3902: "clip is defaultClip, set force to true to force remove clip and animation state", + 3903: "animation state is playing, set force to true to force stop and remove clip and animation state", + 3904: "motion path of target [%s] in prop [%s] frame [%s] is not valid", + 3905: "sprite frames must be an Array.", + 3906: "Can't find easing type [%s]", + 3907: "Animation state is not playing or already removed", + 3912: "already-playing", + 3920: "Current context does not allow root motion.", + 3921: "You provided a ill-formed track path. The last component of track path should be property key, or the setter should not be empty.", + 3923: "Root motion is ignored since root bone could not be located in animation.", + 3924: "Root motion is ignored since the root bone could not be located in scene.", + 3925: "Target of hierarchy path should be of type Node.", + 3926: 'Node "%s" has no path "%s".', + 3927: "Target of component path should be of type Node.", + 3928: 'Node "%s" has no component "%s".', + 3929: 'Target object has no property "%s".', + 3930: "Can not decide type for untyped track: runtime binding does not provide a getter.", + 3931: "Can not decide type for untyped track: got a unsupported value from runtime binding.", + 3932: "Common targets should only target Vectors/`Size`/`Color`.", + 3933: "Each curve that has common target should be numeric curve and targets string property.", + 3934: "Misconfigured legacy curve: the first keyframe value is number but others aren't.", + 3935: "We don't currently support conversion of \\`CubicSplineQuatValue\\`.", + 3936: "Instancing/Batching enabled for non-baked skinning model '%s', this may result in unexpected rendering artifacts. Consider turning it off in the material if you do not intend to do this.", + 3937: "Previous error occurred when instantiating animation clip %s on node %s.", + 3938: "'%s' is not found from '%s'. It's specified as the root node to play animation clip '%s'.", + 4003: "Label font size can't be shirnked less than 0!", + 4004: "force notify all fonts loaded!", + 4011: "Property spriteFrame of Font '%s' is invalid. Using system font instead.", + 4012: "The texture of Font '%s' must be already loaded on JSB. Using system font instead.", + 4013: "Sorry, lineHeight of system font not supported on JSB.", + 4200: "MaskType: IMAGE_STENCIL only support WebGL mode.", + 4201: "The alphaThreshold invalid in Canvas Mode.", + 4202: "The inverted invalid in Canvas Mode.", + 4300: "Can not found the %s page.", + 4301: "Can not add a page without UITransform.", + 4302: "Can not set the scroll view content when it hasn't UITransform or its parent hasn't UITransform.", + 4400: "Invalid RichText img tag! The sprite frame name can't be found in the ImageAtlas!", + 4500: "Graphics: There is no model in %s.", + 4600: "Script attached to '%s' is missing or invalid.", + 4700: "The dom control is not created!", + 4800: "unknown asset type", + 4901: "loadRes: should not specify the extname in %s %s", + 4902: "No need to release non-cached asset.", + 4914: "Resources url '%s' does not exist.", + 4915: "Pack indices and data do not match in size", + 4916: "Failed to download package for %s", + 4921: "Invalid pipe or invalid index provided!", + 4922: "The pipe to be inserted is already in the pipeline!", + 4923: "Uuid Loader: Parse asset [ %s ] failed : %s", + 4924: "JSON Loader: Input item doesn't contain string content", + 4925: "Uuid Loader: Deserialize asset [ %s ] failed : %s", + 4926: "Audio Downloader: no web audio context.", + 4927: "Audio Downloader: audio not supported on this browser!", + 4928: "Load %s failed!", + 4929: "Load Webp ( %s ) failed", + 4930: "Load image ( %s ) failed", + 4932: 'Since v1.10, for any atlas ("%s") in the "resources" directory, it is not possible to find the contained SpriteFrames via `loadRes`, `getRes` or `releaseRes`. Load the SpriteAtlas first and then use `spriteAtlas.getSpriteFrame(name)` instead please.', + 4933: "Download Font [ %s ] failed, using Arial or system default font instead", + 4934: "Please assure that the full path of sub asset is correct!", + 4935: "Failed to skip prefab asset while deserializing PrefabInfo", + 5e3: "You are trying to destroy a object twice or more.", + 5001: "object not yet destroyed", + 5100: "Not a plist file!", + 5200: "Warning: localStorage isn't enabled. Please confirm browser cookie or privacy option", + 5201: "browser don't support web audio", + 5202: "This feature supports WebGL render mode only.", + 5300: "Type of target to deserialize not matched with data: target is %s, data is %s", + 5301: "Can not find script '%s'", + 5302: "Can not find class '%s'", + 5303: "Failed to deserialize %s, missing _deserialize function.", + 5304: "Unable to deserialize version %s data.", + 5402: "cc.js.addon called on non-object:", + 5403: "cc.js.mixin: arguments must be type object:", + 5404: "The base class to extend from must be non-nil", + 5405: "The class to extend must be non-nil", + 5406: "Class should be extended before assigning any prototype members.", + 5500: "'notify' can not be used in 'get/set' !", + 5501: "'notify' must be used with 'default' !", + 5507: "The 'default' attribute of '%s.%s' must be an array", + 5508: "Invalid type of %s.%s", + 5510: "The 'type' attribute of '%s.%s' can not be 'Number', use cc.Float or cc.Integer instead please.", + 5511: "The 'type' attribute of '%s.%s' is undefined when loading script", + 5512: "Can not serialize '%s.%s' because the specified type is anonymous, please provide a class name or set the 'serializable' attribute of '%s.%s' to 'false'.", + 5513: "The 'default' value of '%s.%s' should not be used with a 'get' function.", + 5514: "The 'default' value of '%s.%s' should not be used with a 'set' function.", + 5515: "The 'default' value of '%s.%s' can not be an constructor. Set default to null please.", + 5517: "'%s.%s' hides inherited property '%s.%s'. To make the current property override that implementation, add the `override: true` attribute please.", + 5601: "Can not get current scene.", + 5602: "Scene is destroyed", + 5603: "reference node is destroyed", + 5700: "no %s or %s on %s", + 5800: "%s.lerp not yet implemented.", + 5801: "%s.clone not yet implemented.", + 5802: "%s.equals not yet implemented.", + 5900: "MotionStreak only support WebGL mode.", + 5901: "cc.MotionStreak.getOpacity has not been supported.", + 5902: "cc.MotionStreak.setOpacity has not been supported.", + 6e3: "Custom should not be false if file is not specified.", + 6001: "The new %s must not be NaN", + 6017: "Incomplete or corrupt PNG file", + 6018: "Invalid filter algorithm: %s", + 6019: "Invalid byte order value.", + 6020: "You forgot your towel!", + 6021: "Unknown Field Tag: %s", + 6022: "Too many bits requested", + 6023: "No bits requested", + 6024: "Cannot recover from missing StripByteCounts", + 6025: "Cannot handle sub-byte bits per sample", + 6026: "Cannot handle sub-byte bits per pixel", + 6027: "Palette image missing color map", + 6028: "Unknown Photometric Interpretation: %s", + 6029: "Unkown error", + 6030: "cc.ParticleSystem: error decoding or ungzipping textureImageData", + 6031: "cc.ParticleSystem: unknown image format with Data", + 6032: "cc.ParticleSystem.initWithDictionary() : error loading the texture", + 6033: "cc.ParticleSystem: not allowing create to be invoked twice with different particle system", + 6034: "cc.ParticleSystem: shouldn't be initialized repetitively, otherwise there will be potential leak", + 6035: "cc.ParticleSystem: change material failed, please use proper particle material", + 6036: "cc.ParticleSystem: life time should bigger than 1 or buffer will be insufficient", + 6400: "asset.url is not usable in core process", + 6402: "AssetLibrary has already been initialized!", + 6500: "Widget target must be one of the parent nodes of it", + 6600: "collider not added or already removed", + 6601: "Can't find testFunc for (%s, $s).", + 6700: "Can't init canvas '%s' because it conflicts with the existing '%s', the scene should only have one active canvas at the same time.", + 6705: "Argument must be non-nil", + 6706: "Priority can't be set in RenderRoot2D node", + 6800: "Callback of event must be non-nil", + 6801: "The message must be provided", + 6900: "The thing you want to instantiate must be an object", + 6901: "The thing you want to instantiate is nil", + 6902: "The thing you want to instantiate is destroyed", + 6903: "The instantiate method for given asset do not implemented", + 6904: "Can not instantiate array", + 6905: "Can not instantiate DOM element", + 7100: "%s already defined in Enum.", + 7101: "Sorry, 'cc.Enum' not available on this platform, please report this error here: ", + 7200: "Method 'initWithTMXFile' is no effect now, please set property 'tmxAsset' instead.", + 7201: "Method 'initWithXML' is no effect now, please set property 'tmxAsset' instead.", + 7202: "Add component TiledLayer into node failed.", + 7203: "Property 'mapLoaded' is unused now. Please write the logic to the callback 'start'.", + 7210: "TMX Hexa zOrder not supported", + 7211: "TMX invalid value", + 7215: "cocos2d: Warning: TMX Layer %s has no tiles", + 7216: "cocos2d: TMXFormat: Unsupported TMX version: %s", + 7217: "cocos2d: TMXFomat: Unsupported orientation: %s", + 7218: "cc.TMXMapInfo.parseXMLFile(): unsupported compression method", + 7219: "cc.TMXMapInfo.parseXMLFile(): Only base64 and/or gzip/zlib maps are supported", + 7221: "cc.TMXMapInfo.parseXMLFile(): Texture '%s' not found.", + 7222: "Parse %s failed.", + 7236: "cc.TMXLayer.getTileAt(): TMXLayer: the tiles map has been released", + 7237: "cc.TMXLayer.getTileGIDAt(): TMXLayer: the tiles map has been released", + 7238: "cc.TMXLayer.setTileGID(): TMXLayer: the tiles map has been released", + 7239: "cc.TMXLayer.setTileGID(): invalid gid: %s", + 7240: "cc.TMXLayer.getTileFlagsAt(): TMXLayer: the tiles map has been released", + 7241: "cc.TiledMap.initWithXML(): Map not found. Please check the filename.", + 7401: "Failed to set _defaultArmatureIndex for '%s' because the index is out of range.", + 7402: "Failed to set _animationIndex for '%s' because the index is out of range.", + 7501: "Failed to set _defaultSkinIndex for '%s' because the index is out of range.", + 7502: "Failed to set _animationIndex for '%s' because its skeletonData is invalid.", + 7503: "Failed to set _animationIndex for '%s' because the index is out of range.", + 7504: "Can not render dynamic created SkeletonData", + 7506: "Failed to load spine atlas '$s'", + 7507: "Please re-import '%s' because its textures is not initialized! (This workflow will be improved in the future.)", + 7508: "The atlas asset of '%s' is not exists!", + 7509: "Spine: Animation not found: %s", + 7510: "Spine: Animation not found: %s", + 7600: "The context of RenderTexture is invalid.", + 7601: "cc.RenderTexture._initWithWidthAndHeightForWebGL() : only RGB and RGBA formats are valid for a render texture;", + 7602: "Could not attach texture to the framebuffer", + 7603: "clearDepth isn't supported on Cocos2d-Html5", + 7604: "saveToFile isn't supported on Cocos2d-Html5", + 7605: "newCCImage isn't supported on Cocos2d-Html5", + 7606: "GFXTexture is null", + 7607: "readPixels buffer size smaller than %d", + 7700: "On the web is always keep the aspect ratio", + 7701: "Can't know status", + 7702: "Video player's duration is not ready to get now!", + 7703: "Video Downloader: video not supported on this browser!", + 7800: "Web does not support loading", + 7801: "Web does not support query history", + 7802: "Web does not support query history", + 7803: "The current browser does not support the GoBack", + 7804: "The current browser does not support the GoForward", + 7805: "Web does not support zoom", + 7900: "cc.math.Matrix3.assign(): current matrix equals matIn", + 7901: "cc.math.mat4Assign(): pOut equals pIn", + 7902: "cc.mat.Matrix4.assignFrom(): mat4 equals current matrix", + 7903: "cc.math.Matrix4 equal: pMat1 and pMat2 are same object.", + 7904: "cc.math.Matrix4.extractPlane: Invalid plane index", + 7905: "cc.math.mat4Assign(): pOut equals pIn", + 7906: "cc.mat.Matrix4.assignFrom(): mat4 equals current matrix", + 7907: "cc.math.Matrix4 equals: pMat1 and pMat2 are same object.", + 7908: "Invalid matrix mode specified", + 7909: "current quaternion is an invalid value", + 8e3: "Can't handle this field type or size", + 8001: "No bytes requested", + 8002: "Too many bytes requested", + 8003: "Missing StripByteCounts!", + 8100: "cocos2d: ERROR: Failed to compile shader:\n %s", + 8101: "cocos2d: ERROR: Failed to compile vertex shader", + 8102: "cocos2d: ERROR: Failed to compile fragment shader", + 8103: "cc.GLProgram.link(): Cannot link invalid program", + 8104: "cocos2d: ERROR: Failed to link program: %s", + 8105: "cocos2d: cc.shaderCache._loadDefaultShader, error shader type", + 8106: "Please load the resource firset : %s", + 8107: "cc.GLProgram.getUniformLocationForName(): uniform name should be non-null", + 8108: "cc.GLProgram.getUniformLocationForName(): Invalid operation. Cannot get uniform location when program is not initialized", + 8109: "modelView matrix is undefined.", + 8200: "Please set node's active instead of rigidbody's enabled.", + 8300: "Should only one camera exists, please check your project.", + 8301: "Camera does not support Canvas Mode.", + 8302: "Camera.viewport is deprecated, please use setViewportInOrientedSpace instead.", + 8400: "Wrong type arguments, 'filePath' must be a String.", + 9e3: "Stencil manager does not support level bigger than %d in this device.", + 9001: "Stencil manager is already empty, cannot pop any mask", + 9002: "Failed to request any buffer from a mesh buffer without accessor", + 9003: "The internal state of LinearBufferAccessor have severe issue and irreversible, please check the reason", + 9004: "Failed to allocate chunk in StaticVBAccessor, the requested buffer might be too large: %d bytes", + 9005: "BATCHER2D_MEM_INCREMENT is too large, the Max value for BATCHER2D_MEM_INCREMENT is 2303KB (smaller than 65536 *9* 4 / 1024 = 2304KB)", + 9006: "QuadRenderData is removed, please use MeshRenderData instead.", + 9007: "Since v3.6, Because mask changes the inheritance relationship, you can directly manipulate the rendering components under the same node to complete the operation.", + 9100: "texture size exceeds current device limits %d/%d", + 9201: "Cannot access game frame or container.", + 9202: "Setting window size is not supported.", + 9300: "The current buffer beyond the limit in ui static component, please reduce the amount", + 9301: "The UI has not been initialized", + 9302: "Can't getGFXSampler with out device", + 9600: "[Physics]: please check to see if physics modules are included", + 9610: "[Physics]: cannon.js physics system doesn't support capsule collider", + 9611: "[Physics]: builtin physics system doesn't support mesh collider", + 9612: "[Physics]: builtin physics system doesn't support cylinder collider", + 9620: "[Physics][Ammo]: changing the mesh is not supported after the initialization is completed", + 10001: "The sub-mesh contains %d vertices, which beyonds the capability (%d vertices most) of renderer of your platform.", + 10002: "Sub-mesh may include at most %d morph targets, but you specified %d.", + 11e3: "WebGL context lost.", + 12001: "BlendFactors are disabled when using custom material, please modify the blend state in the material instead.", + 12002: "Can't add renderable component to this node because it already have one.", + 12004: "SubModel can only support %d passes.", + 12005: "Material already initialized, request aborted.", + 12006: "Pass already destroyed.", + 12007: "This is old usage, please swap the parameters.", + 12008: "GeometryRenderer: too many lines.", + 12009: "GeometryRenderer: too many triangles.", + 12100: "The font size is too big to be fitted into texture atlas. Please switch to other label cache modes or choose a smaller font size.", + 12101: "The asset %s has been destroyed!", + 13100: "Incorrect CCON magic.", + 13101: "Unknown CCON version number: %d.", + 13102: "CCON Format error.", + 13103: "Can not encode CCON binary: lack of text encoder.", + 13104: "Can not decode CCON binary: lack of text decoder.", + 14e3: "Graph update has been interrupted since too many transitions(greater than %s) occurred during one frame.", + 14100: "Pool.destroy no longer take a function as parameter, Please specify destruct function in the construction of Pool instead", + 14200: "Can not update a static mesh.", + 14201: "The primitiveIndex is out of range.", + 14300: "Can not keep world transform due to the zero scaling of parent node", + 14400: "Spline error: less than 2 knots.", + 14401: "Spline error: less than 4 knots or not a multiple of 4.\n\n\x3c!-- Rendering algorithm reserved: 15000 - 16000 --\x3e", + 15e3: "Can not find corresponding diffuse map for environment lighting, use hemisphere diffuse instead, change environment lighting type to regenerate diffuse map", + 15001: "Can not find environment map, disable IBL lighting", + 15002: "Diffuse map resource is missing, please change environment lighting type to regenerate resource", + 15003: "The shadow visible distance is so small that CSM stratification is not effective, Please change the value of shadowDistance so that it is 10 times greater than 0.1", + 15004: "The native folder may be generated from older versions, please refer https://docs.cocos.com/creator/manual/en/release-notes/ to upgrade.", + 16e3: "'%s' is deprecated since v%s.", + 16001: "'%s' is deprecated since v%s, please use '%s' instead.", + 16002: "'%s' is removed since v%s.", + 16003: "'%s' is removed since v%s, please use '%s' instead.", + 16101: "The effect('%s') you are looking for does not exist, please confirm the effect name in the editor. NOTE: Since 3.6, the name of the built-in effect has been changed to its name in the editor, please check it out. More information please refer to https://docs.cocos.com/creator/manual/en/shader/effect-inspector.html", + 16201: "The asset replacing failed, can not found override asset('%s') for '%s'", + "0100": "%s not yet implemented.", + "0200": "You should specify a valid DOM canvas element." + }; + const p = "undefined" == typeof window ? global : window; + const m = t("cclegacy", { + _global: p + }); + m.internal = {}; + const f = t("VERSION", "3.6.1"); + p.CocosEngine = m.ENGINE_VERSION = f; + p.cc = m; + let g = null; + let y = console.log.bind(console); + let b = y; + let S = y; + let A = (t, e, ...i) => { + t || console.log(`ASSERT: ${v(e, ...i)}`); + }; + let T = y; + function v(t, ...e) { + return m.js.formatStr.apply(null, [ t ].concat(e)); + } + function E(t, ...e) { + return y(t, ...e); + } + function C(t, ...e) { + return b(t, ...e); + } + function x(t, ...e) { + return S(t, ...e); + } + function w(t, e, ...i) { + return A(t, e, ...i); + } + function R(...t) { + return T(...t); + } + function I(t) { + y = b = S = A = T = () => {}; + if (t !== U.NONE) { + if (t > U.ERROR) { + const e = t => { + if (m.game.canvas) { + if (!g) { + const t = document.createElement("Div"); + t.setAttribute("id", "logInfoDiv"); + t.setAttribute("width", "200"); + t.setAttribute("height", m.game.canvas.height); + const e = t.style; + e.zIndex = "99999"; + e.position = "absolute"; + e.top = e.left = "0"; + g = document.createElement("textarea"); + g.setAttribute("rows", "20"); + g.setAttribute("cols", "30"); + g.setAttribute("disabled", "true"); + const i = g.style; + i.backgroundColor = "transparent"; + i.borderBottom = "1px solid #cccccc"; + i.borderTopWidth = i.borderLeftWidth = i.borderRightWidth = "0px"; + i.borderTopStyle = i.borderLeftStyle = i.borderRightStyle = "none"; + i.padding = "0px"; + i.margin = "0px"; + t.appendChild(g); + m.game.canvas.parentNode.appendChild(t); + } + g.value = `${g.value + t}\r\n`; + g.scrollTop = g.scrollHeight; + } + }; + S = (t, ...i) => { + e(`ERROR : ${v(t, ...i)}`); + }; + A = (t, i, ...s) => { + t || e(`ASSERT: ${v(i, ...s)}`); + }; + t !== U.ERROR_FOR_WEB_PAGE && (b = (t, ...i) => { + e(`WARN : ${v(t, ...i)}`); + }); + t === U.INFO_FOR_WEB_PAGE && (y = (t, ...i) => { + e(v(t, ...i)); + }); + } else if (console) { + console.error || (console.error = console.log); + console.warn || (console.warn = console.log); + S = console.error.bind ? console.error.bind(console) : console.error; + A = (t, e, ...i) => { + if (!t) { + const t = v(e, ...i); + throw new Error(t); + } + }; + } + t !== U.ERROR && (b = console.warn.bind && !window.oh ? console.warn.bind(console) : console.warn); + t <= U.INFO && (y = "JavaScriptCore" === scriptEngineType ? (t, ...e) => console.log.apply(console, [ t, ...e ]) : console.log); + if (t <= U.VERBOSE && "function" == typeof console.debug) { + const t = console.debug.bind(console); + T = (...e) => t(...e); + } + } + } + function M(t) { + { + const e = t.stack; + x(e ? `${t}\n${e}` : t); + return; + } + } + function B(t) { + return (t, ...e) => { + const i = d[t] || "unknown id"; + return 0 === e.length ? i : v(i, ...e); + }; + } + const D = B(); + function P(t, ...e) { + E(D(t, ...e)); + } + const O = B(); + function N(t, ...e) { + C(O(t, ...e)); + } + const L = B(); + function F(t, ...e) { + x(L(t, ...e)); + } + const V = B(); + function k(t, e, ...i) { + t || w(!1, V(e, ...i)); + } + let U; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.VERBOSE = 1] = "VERBOSE"; + t[t.INFO = 2] = "INFO"; + t[t.WARN = 3] = "WARN"; + t[t.ERROR = 4] = "ERROR"; + t[t.INFO_FOR_WEB_PAGE = 5] = "INFO_FOR_WEB_PAGE"; + t[t.WARN_FOR_WEB_PAGE = 6] = "WARN_FOR_WEB_PAGE"; + t[t.ERROR_FOR_WEB_PAGE = 7] = "ERROR_FOR_WEB_PAGE"; + }(U || (U = t("DebugMode", {}))); + function G(t, ...e) { + return L(t, ...e); + } + function z() { + return !!m.profiler && m.profiler.isShowingStats(); + } + function H(t) { + m.profiler && (t ? m.profiler.showStats() : m.profiler.hideStats()); + } + var j = Object.freeze({ + __proto__: null, + log: E, + warn: C, + error: x, + assert: w, + debug: R, + _resetDebugSetting: I, + _throw: M, + logID: P, + warnID: N, + errorID: F, + assertID: k, + get DebugMode() { + return U; + }, + getError: G, + isDisplayStats: z, + setDisplayStats: H + }); + let X = 10; + let W; + let Y; + let q; + let K; + let J; + let Z; + let Q = 0; + const $ = new Map; + K = (t, e, i, s, n, r, o) => { + const a = $.get(r); + if (a && a.logTimes > a.count) { + n(`'%s' is deprecated, please use '%s' instead. ${o}`, `${t}.${e}`, `${i}.${s}`); + a.count++; + } + }; + W = t("replaceProperty", ((t, e, i) => { + null != t && i.forEach((i => { + const s = Q++; + $.set(s, { + id: s, + count: 0, + logTimes: void 0 !== i.logTimes ? i.logTimes : X + }); + const n = null != i.target ? i.target : t; + const r = null != i.newName ? i.newName : i.name; + const o = null != i.targetName ? i.targetName : e; + const a = n === t; + const l = i.suggest ? `(${i.suggest})` : ""; + if (null != i.customFunction) t[i.name] = function() { + K(e, i.name, o, r, C, s, l); + return i.customFunction.call(this, ...arguments); + }; else if (null != i.customSetter || null != i.customGetter) { + const n = null != i.customSetter; + const a = null != i.customGetter; + n && a ? Object.defineProperty(t, i.name, { + get() { + K(e, i.name, o, r, C, s, l); + return i.customGetter.call(this); + }, + set(t) { + K(e, i.name, o, r, C, s, l); + i.customSetter.call(this, t); + }, + enumerable: !1 + }) : n ? Object.defineProperty(t, i.name, { + set(t) { + K(e, i.name, o, r, C, s, l); + i.customSetter.call(this, t); + }, + enumerable: !1 + }) : a && Object.defineProperty(t, i.name, { + get() { + K(e, i.name, o, r, C, s, l); + return i.customGetter.call(this); + }, + enumerable: !1 + }); + } else Object.defineProperty(t, i.name, { + get() { + K(e, i.name, o, r, C, s, l); + return a ? this[r] : n[r]; + }, + set(t) { + K(e, i.name, o, r, C, s, l); + a ? this[r] = t : n[r] = t; + }, + enumerable: !1 + }); + })); + })); + Z = (t, e, i, s, n) => { + const r = $.get(s); + if (r && r.logTimes > r.count) { + i(`'%s' has been removed. ${n}`, `${t}.${e}`); + r.count++; + } + }; + Y = t("removeProperty", ((t, e, i) => { + null != t && i.forEach((i => { + const s = Q++; + $.set(s, { + id: s, + count: 0, + logTimes: void 0 !== i.logTimes ? i.logTimes : X + }); + const n = i.suggest ? `(${i.suggest})` : ""; + Object.defineProperty(t, i.name, { + get: () => Z(e, i.name, x, s, n), + set() { + Z(e, i.name, x, s, n); + }, + enumerable: !1 + }); + })); + })); + J = (t, e, i, s, n) => { + const r = $.get(s); + if (r && r.logTimes > r.count) { + i(`'%s' is deprecated. ${n}`, `${t}.${e}`); + r.count++; + } + }; + q = t("markAsWarning", ((t, e, i) => { + if (null == t) return; + const s = (e, i, s, n, r, o) => { + if (e.get) { + const t = e.get; + e.get = function() { + J(i, s, n, r, o); + return t.call(this); + }; + } + if (e.set) { + const t = e.set; + e.set = function(e) { + J(i, s, n, r, o); + t.call(this, e); + }; + } + Object.defineProperty(t, s, e); + }; + i.forEach((i => { + const n = i.name; + const r = Object.getOwnPropertyDescriptor(t, n); + if (!r || !r.configurable) return; + const o = Q++; + $.set(o, { + id: o, + count: 0, + logTimes: void 0 !== i.logTimes ? i.logTimes : X + }); + const a = i.suggest ? `(${i.suggest})` : ""; + if (void 0 !== r.value) if ("function" == typeof r.value) { + const i = r.value; + t[n] = function() { + J(e, n, C, o, a); + return i.call(this, ...arguments); + }; + } else { + let i = r.value; + Object.defineProperty(t, n, { + configurable: !0, + get() { + J(e, n, C, o, a); + return i; + } + }); + r.writable && Object.defineProperty(t, n, { + set(t) { + J(e, n, C, o, a); + i = t; + } + }); + } else s(r, e, n, C, o, a); + Object.defineProperty(t, n, { + enumerable: !1 + }); + })); + })); + const tt = {}; + function et(t) { + for (let e in t) { + const i = t[e]; + tt[e] = i; + } + } + function it(t) { + const e = tt[t]; + if (!e) return; + const {newName: i, since: s, removed: n} = e; + n ? i ? F(16003, t, s, i) : F(16002, t, s) : i ? N(16001, t, s, i) : N(16e3, t, s); + } + let st; + class nt { + constructor(t) { + this.i = 0; + this.array = t; + } + get length() { + return this.array.length; + } + set length(t) { + this.array.length = t; + this.i >= t && (this.i = t - 1); + } + remove(t) { + const e = this.array.indexOf(t); + e >= 0 && this.removeAt(e); + } + removeAt(t) { + this.array.splice(t, 1); + t <= this.i && --this.i; + } + fastRemove(t) { + const e = this.array.indexOf(t); + e >= 0 && this.fastRemoveAt(e); + } + fastRemoveAt(t) { + const e = this.array; + e[t] = e[e.length - 1]; + --e.length; + t <= this.i && --this.i; + } + push(t) { + this.array.push(t); + } + } + function rt(t, e) { + t.splice(e, 1); + } + function ot(t, e) { + const i = t.length; + if (!(e < 0 || e >= i)) { + t[e] = t[i - 1]; + t.length = i - 1; + } + } + function at(t, e) { + const i = t.indexOf(e); + if (i >= 0) { + rt(t, i); + return !0; + } + return !1; + } + function lt(t, e) { + const i = t.findIndex(e); + if (i >= 0) { + const e = t[i]; + rt(t, i); + return e; + } + } + function ht(t, e) { + return t.indexOf(e) >= 0; + } + var ct = Object.freeze({ + __proto__: null, + removeAt: rt, + fastRemoveAt: ot, + remove: at, + fastRemove: function(t, e) { + const i = t.indexOf(e); + if (i >= 0) { + t[i] = t[t.length - 1]; + --t.length; + } + }, + removeIf: lt, + verifyType: function(t, e) { + if (t && t.length > 0) for (const i of t) if (!(i instanceof e)) { + P(1300); + return !1; + } + return !0; + }, + removeArray: function(t, e) { + for (let i = 0, s = e.length; i < s; i++) at(t, e[i]); + }, + appendObjectsAt: function(t, e, i) { + t.splice.apply(t, [ i, 0, ...e ]); + return t; + }, + contains: ht, + copy: function(t) { + const e = t.length; + const i = new Array(e); + for (let s = 0; s < e; s += 1) i[s] = t[s]; + return i; + }, + MutableForwardIterator: nt + }); + class ut { + constructor(t) { + this.id = void 0; + this.prefix = void 0; + this.id = 0 | 998 * Math.random(); + this.prefix = t ? t + "." : ""; + } + getNewId() { + return this.prefix + ++this.id; + } + } + ut.global = new ut("global"); + const _t = new ut("TmpCId."); + const dt = "undefined" == typeof Symbol ? "__aliases__" : Symbol("[[Aliases]]"); + const pt = "__classname__"; + const mt = "__cid__"; + function ft(t) { + return "number" == typeof t || t instanceof Number; + } + function gt(t) { + return "string" == typeof t || t instanceof String; + } + function yt(t) { + for (const e in t) return !1; + return !0; + } + const bt = (() => { + const t = { + value: void 0, + enumerable: !1, + writable: !1, + configurable: !0 + }; + return (e, i, s, n, r) => { + t.value = s; + t.writable = n; + t.enumerable = r; + Object.defineProperty(e, i, t); + t.value = void 0; + }; + })(); + const St = (() => { + const t = { + get: void 0, + set: void 0, + enumerable: !1 + }; + return (e, i, s, n, r = !1, o = !1) => { + if ("boolean" == typeof n) { + r = n; + n = void 0; + } + t.get = s; + t.set = n; + t.enumerable = r; + t.configurable = o; + Object.defineProperty(e, i, t); + t.get = void 0; + t.set = void 0; + }; + })(); + const At = (() => { + const t = { + get: void 0, + enumerable: !1, + configurable: !1 + }; + return (e, i, s, n, r) => { + t.get = s; + t.enumerable = n; + t.configurable = r; + Object.defineProperty(e, i, t); + t.get = void 0; + }; + })(); + const Tt = (() => { + const t = { + set: void 0, + enumerable: !1, + configurable: !1 + }; + return (e, i, s, n, r) => { + t.set = s; + t.enumerable = n; + t.configurable = r; + Object.defineProperty(e, i, t); + t.set = void 0; + }; + })(); + function vt(t) { + const e = Object.create(null); + if (t) { + const t = "."; + const i = "/"; + e[t] = 1; + e[i] = 1; + delete e[t]; + delete e[i]; + } + return e; + } + function Et(t) { + if ("function" == typeof t) { + const e = t.prototype; + if (e && e.hasOwnProperty(pt) && e.__classname__) return e.__classname__; + let i = ""; + t.name && (i = t.name); + if (t.toString) { + let e; + const s = t.toString(); + e = "[" === s.charAt(0) ? /\[\w+\s*(\w+)\]/.exec(s) : /function\s*(\w+)/.exec(s); + e && 2 === e.length && (i = e[1]); + } + return "Object" !== i ? i : ""; + } + return t && t.constructor ? Et(t.constructor) : ""; + } + function Ct(t, e, i, s) { + const n = /([^.]+)$/; + const r = n.exec(e)[0]; + const o = n.exec(i)[0]; + function a() { + return this[o]; + } + s ? St(t, r, a, (function(t) { + this[o] = t; + })) : At(t, r, a); + } + function xt(t, e, i, s) { + for (const n in i) { + Ct(t, `${e}.${n}`, i[n], s); + } + } + const wt = /(%d)|(%s)/; + const Rt = /%s/; + function It(t, ...e) { + if (0 === arguments.length) return ""; + if (0 === e.length) return `${t}`; + const i = "string" == typeof t && wt.test(t); + if (i) for (const i of e) { + const e = "number" == typeof i ? wt : Rt; + if (e.test(t)) { + const s = `${i}`; + t = t.replace(e, s); + } else t += ` ${i}`; + } else for (const i of e) t += ` ${i}`; + return t; + } + function Mt() { + const t = arguments.length - 1; + const e = new Array(t); + for (let i = 0; i < t; ++i) e[i] = arguments[i + 1]; + return e; + } + function Bt(t, e) { + for (;t; ) { + const i = Object.getOwnPropertyDescriptor(t, e); + if (i) return i; + t = Object.getPrototypeOf(t); + } + return null; + } + function Dt(t, e, i) { + const s = Bt(e, t); + s && Object.defineProperty(i, t, s); + } + function Pt(t, e, i) { + const s = Object.getOwnPropertyNames(t); + for (let n = 0, r = s.length; n < r; ++n) { + const r = s[n]; + -1 === i.indexOf(r) && Dt(r, t, e); + } + } + function Ot(t, ...e) { + t = t || {}; + for (const i of e) if (i) { + if ("object" != typeof i) { + F(5402, i); + continue; + } + for (const e in i) e in t || Dt(e, i, t); + } + return t; + } + function Nt(t, ...e) { + t = t || {}; + for (const i of e) if (i) { + if ("object" != typeof i) { + F(5403, i); + continue; + } + for (const e in i) Dt(e, i, t); + } + return t; + } + function Lt(t, e) { + for (const i in e) e.hasOwnProperty(i) && (t[i] = e[i]); + t.prototype = Object.create(e.prototype, { + constructor: { + value: t, + writable: !0, + configurable: !0 + } + }); + return t; + } + function Ft(t) { + const e = t.prototype; + const i = e && Object.getPrototypeOf(e); + return i && i.constructor; + } + function Vt(t, e) { + if (t && e) { + if ("function" != typeof t) return !1; + if ("function" != typeof e) return !1; + if (t === e) return !0; + for (;;) { + if (!(t = Ft(t))) return !1; + if (t === e) return !0; + } + } + return !1; + } + function kt(t) { + for (const e of Object.keys(t)) delete t[e]; + } + const Ut = vt(!0); + const Gt = vt(!0); + function zt(t, e, i) { + return function(s, n) { + n.prototype.hasOwnProperty(t) && delete e[n.prototype[t]]; + bt(n.prototype, t, s); + if (s) { + const r = e[s]; + if (!i && r && r !== n) { + x(`A Class already exists with the same ${t} : "${s}".`); + } else e[s] = n; + } + }; + } + const Ht = zt("__cid__", Ut, !1); + const jt = zt("__classname__", Gt, !0); + function Xt(t, e) { + jt(t, e); + if (!e.prototype.hasOwnProperty(mt)) { + const i = t || _t.getNewId(); + i && Ht(i, e); + } + } + function Wt(t, e) { + const i = Gt[e]; + const s = Ut[e]; + let n = !0; + if (i && i !== t) { + x(`"${e}" has already been set as name or alias of another class.`); + n = !1; + } + if (s && s !== t) { + x(`"${e}" has already been set as id or alias of another class.`); + n = !1; + } + if (n) { + let i = t[dt]; + if (!i) { + i = []; + t[dt] = i; + } + i.push(e); + Gt[e] = t; + Ut[e] = t; + } + } + function Yt(...t) { + for (const e of t) { + const t = e.prototype; + const i = t.__cid__; + i && delete Ut[i]; + const s = t.__classname__; + s && delete Gt[s]; + const n = t[dt]; + if (n) for (let t = 0; t < n.length; ++t) { + const e = n[t]; + delete Gt[e]; + delete Ut[e]; + } + } + } + function qt(t) { + return Kt(t); + } + function Kt(t) { + return Ut[t]; + } + function Jt(t) { + return Gt[t]; + } + function Zt(t, e) { + return Qt(t, e); + } + function Qt(t, e) { + e = void 0 === e || e; + let i; + if ("function" == typeof t && t.prototype.hasOwnProperty(mt)) { + i = t.prototype.__cid__; + 0; + return i; + } + if (t && t.constructor) { + const e = t.constructor.prototype; + if (e && e.hasOwnProperty(mt)) { + i = t.__cid__; + 0; + return i; + } + } + return ""; + } + class $t { + get() { + return this._get(); + } + constructor(t, e) { + this.count = void 0; + this._pool = void 0; + this._cleanup = void 0; + const i = void 0 === e ? t : e; + const s = void 0 === e ? null : t; + this.count = 0; + this._pool = new Array(i); + this._cleanup = s; + } + _get() { + if (this.count > 0) { + --this.count; + const t = this._pool[this.count]; + this._pool[this.count] = null; + return t; + } + return null; + } + put(t) { + const e = this._pool; + if (this.count < e.length) { + if (this._cleanup && !1 === this._cleanup(t)) return; + e[this.count] = t; + ++this.count; + } + } + resize(t) { + if (t >= 0) { + this._pool.length = t; + this.count > t && (this.count = t); + } + } + } + const te = ct; + const ee = { + IDGenerator: ut, + Pool: $t, + array: ct, + isNumber: ft, + isString: gt, + isEmptyObject: yt, + getPropertyDescriptor: Bt, + addon: Ot, + mixin: Nt, + extend: Lt, + getSuper: Ft, + isChildClassOf: Vt, + clear: kt, + value: bt, + getset: St, + get: At, + set: Tt, + unregisterClass: Yt, + getClassName: Et, + setClassName: Xt, + setClassAlias: Wt, + getClassByName: Jt, + getClassById: Kt, + get _registeredClassNames() { + return { + ...Gt + }; + }, + set _registeredClassNames(t) { + kt(Gt); + Object.assign(Gt, t); + }, + get _registeredClassIds() { + return { + ...Ut + }; + }, + set _registeredClassIds(t) { + kt(Ut); + Object.assign(Ut, t); + }, + _getClassId: Zt, + getClassId: Qt, + _setClassId: Ht, + _getClassById: qt, + obsolete: Ct, + obsoletes: xt, + formatStr: It, + shiftArguments: Mt, + createMap: vt + }; + m.js = ee; + t("js", Object.freeze({ + __proto__: null, + array: te, + js: ee, + IDGenerator: ut, + Pool: $t, + isNumber: ft, + isString: gt, + isEmptyObject: yt, + value: bt, + getset: St, + get: At, + set: Tt, + createMap: vt, + getClassName: Et, + obsolete: Ct, + obsoletes: xt, + formatStr: It, + shiftArguments: Mt, + getPropertyDescriptor: Bt, + copyAllProperties: Pt, + addon: Ot, + mixin: Nt, + extend: Lt, + getSuper: Ft, + isChildClassOf: Vt, + clear: kt, + _idToClass: Ut, + _nameToClass: Gt, + _setClassId: Ht, + setClassName: Xt, + setClassAlias: Wt, + unregisterClass: Yt, + _getClassById: qt, + getClassById: Kt, + getClassByName: Jt, + _getClassId: Zt, + getClassId: Qt + })); + function ie(t) { + if ("__bitmask__" in t) return t; + bt(t, "__bitmask__", null, !0); + let e = -1; + const i = Object.keys(t); + for (let s = 0; s < i.length; s++) { + const n = i[s]; + let r = t[n]; + if (-1 === r) { + r = ++e; + t[n] = r; + } else if ("number" == typeof r) e = r; else if ("string" == typeof r && Number.isInteger(parseFloat(n))) continue; + const o = `${r}`; + n !== o && bt(t, o, n); + } + return t; + } + ie.isBitMask = t => t && t.hasOwnProperty("__bitmask__"); + ie.getList = t => { + if (t.__bitmask__) return t.__bitmask__; + const e = t.__bitmask__ = []; + for (const i in t) { + const s = t[i]; + Number.isInteger(s) && e.push({ + name: i, + value: s + }); + } + e.sort(((t, e) => t.value - e.value)); + return e; + }; + m.BitMask = ie; + function se(t, e) { + ne(!(null == t), e); + } + function ne(t, e) { + if (!t) throw new Error(`Assertion failed: ${null != e ? e : ""}`); + } + function re(t, e) { + ne(e >= 0 && e < t.length, `Array index ${e} out of bounds: [0, ${t.length})`); + } + function oe(t) { + if ("__enums__" in t) return t; + bt(t, "__enums__", null, !0); + return oe.update(t); + } + oe.update = t => { + let e = -1; + const i = Object.keys(t); + for (let s = 0; s < i.length; s++) { + const n = i[s]; + let r = t[n]; + if (-1 === r) { + r = ++e; + t[n] = r; + } else if ("number" == typeof r) e = r; else if ("string" == typeof r && Number.isInteger(parseFloat(n))) continue; + const o = `${r}`; + n !== o && bt(t, o, n); + } + Array.isArray(t.__enums__) && le(t); + return t; + }; + oe || (oe = t("Enum", {})); + oe.isEnum = t => t && t.hasOwnProperty("__enums__"); + function ae(t) { + ne(t.hasOwnProperty("__enums__")); + } + oe.getList = t => { + ae(t); + return t.__enums__ ? t.__enums__ : le(t); + }; + function le(t) { + ae(t); + const e = t.__enums__ || []; + e.length = 0; + for (const i in t) { + const s = t[i]; + Number.isInteger(s) && e.push({ + name: i, + value: s + }); + } + e.sort(((t, e) => t.value - e.value)); + t.__enums__ = e; + return e; + } + function he(t) { + "__enums__" in t || bt(t, "__enums__", null, !0); + } + m.Enum = oe; + class ce { + clone() { + F(100, `${Et(this)}.clone`); + return this; + } + equals(t) { + return !1; + } + set(t) { + F(100, `${Et(this)}.set`); + } + toString() { + return ""; + } + } + t("ValueType", ce); + Xt("cc.ValueType", ce); + m.ValueType = ce; + var ue; + !function(t) { + t.PATH = "path"; + t.ENGINE = "engine"; + t.ASSETS = "assets"; + t.SCRIPTING = "scripting"; + t.PHYSICS = "physics"; + t.RENDERING = "rendering"; + t.LAUNCH = "launch"; + t.SCREEN = "screen"; + t.SPLASH_SCREEN = "splashScreen"; + t.ANIMATION = "animation"; + t.PROFILING = "profiling"; + t.PLUGINS = "plugins"; + }(ue || (ue = {})); + class _e { + constructor() { + this._settings = {}; + this._override = {}; + } + init(t = "", e = {}) { + for (const t in e) { + const i = e[t]; + if (i) for (const e in i) this.overrideSettings(t, e, i[e]); + } + if (!t) return Promise.resolve(); + if (window.oh) { + this._settings = i(266); + return Promise.resolve(); + } + return new Promise(((e, i) => { + if (t.startsWith("http")) { + const s = new XMLHttpRequest; + s.open("GET", t); + s.responseType = "text"; + s.onload = () => { + this._settings = JSON.parse(s.response); + e(); + }; + s.onerror = () => { + i(new Error("request settings failed!")); + }; + s.send(null); + } else { + const s = fsUtils.readJsonSync(t); + if (s instanceof Error) i(s); else { + this._settings = s; + e(); + } + } + })); + } + overrideSettings(t, e, i) { + t in this._override || (this._override[t] = {}); + this._override[t][e] = i; + } + querySettings(t, e) { + if (t in this._override) { + const i = this._override[t]; + if (i && e in i) return i[e]; + } + if (t in this._settings) { + const i = this._settings[t]; + if (i && e in i) return i[e]; + } + return null; + } + } + t("Settings", _e); + _e.Category = ue; + const de = t("settings", new _e); + m.settings = de; + const pe = t("macro", { + SUPPORT_TEXTURE_FORMATS: [ ".astc", ".pkm", ".pvr", ".webp", ".jpg", ".jpeg", ".bmp", ".png" ], + KEY: { + none: 0, + back: 6, + menu: 18, + backspace: 8, + tab: 9, + enter: 13, + shift: 16, + ctrl: 17, + alt: 18, + pause: 19, + capslock: 20, + escape: 27, + space: 32, + pageup: 33, + pagedown: 34, + end: 35, + home: 36, + left: 37, + up: 38, + right: 39, + down: 40, + select: 41, + insert: 45, + Delete: 46, + 0: 48, + 1: 49, + 2: 50, + 3: 51, + 4: 52, + 5: 53, + 6: 54, + 7: 55, + 8: 56, + 9: 57, + a: 65, + b: 66, + c: 67, + d: 68, + e: 69, + f: 70, + g: 71, + h: 72, + i: 73, + j: 74, + k: 75, + l: 76, + m: 77, + n: 78, + o: 79, + p: 80, + q: 81, + r: 82, + s: 83, + t: 84, + u: 85, + v: 86, + w: 87, + x: 88, + y: 89, + z: 90, + num0: 96, + num1: 97, + num2: 98, + num3: 99, + num4: 100, + num5: 101, + num6: 102, + num7: 103, + num8: 104, + num9: 105, + "*": 106, + "+": 107, + "-": 109, + numdel: 110, + "/": 111, + f1: 112, + f2: 113, + f3: 114, + f4: 115, + f5: 116, + f6: 117, + f7: 118, + f8: 119, + f9: 120, + f10: 121, + f11: 122, + f12: 123, + numlock: 144, + scrolllock: 145, + ";": 186, + semicolon: 186, + equal: 187, + "=": 187, + ",": 188, + comma: 188, + dash: 189, + ".": 190, + period: 190, + forwardslash: 191, + grave: 192, + "[": 219, + openbracket: 219, + backslash: 220, + "]": 221, + closebracket: 221, + quote: 222, + dpadLeft: 1e3, + dpadRight: 1001, + dpadUp: 1003, + dpadDown: 1004, + dpadCenter: 1005 + }, + RAD: Math.PI / 180, + DEG: 180 / Math.PI, + REPEAT_FOREVER: Number.MAX_VALUE - 1, + FLT_EPSILON: 1.192092896e-7, + ORIENTATION_PORTRAIT: 1, + ORIENTATION_LANDSCAPE: 2, + ORIENTATION_AUTO: 3, + ENABLE_TILEDMAP_CULLING: !0, + TOUCH_TIMEOUT: 5e3, + ENABLE_TRANSPARENT_CANVAS: !1, + ENABLE_WEBGL_ANTIALIAS: !0, + ENABLE_ANTIALIAS_FXAA: !1, + ENABLE_BLOOM: !1, + CLEANUP_IMAGE_CACHE: !1, + ENABLE_MULTI_TOUCH: !0, + MAX_LABEL_CANVAS_POOL_SIZE: 20, + ENABLE_WEBGL_HIGHP_STRUCT_VALUES: !1, + BATCHER2D_MEM_INCREMENT: 144, + CUSTOM_PIPELINE_NAME: "", + init() { + this.CLEANUP_IMAGE_CACHE = !0; + const t = de.querySettings(_e.Category.ENGINE, "macros"); + if (t) for (const e in t) pe[e] = t[e]; + } + }); + m.macro = pe; + const me = /^(?:cc|dragonBones|sp|ccsg)\..+/; + const fe = new Array(123); + for (let t = 0; t < 123; ++t) fe[t] = 64; + for (let t = 0; t < 64; ++t) fe["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charCodeAt(t)] = t; + const ge = fe; + function ye(t, e, i) { + function s(t, e, i, s) { + const n = Object.getOwnPropertyDescriptor(t, e); + if (n) { + n.get && (t[i] = n.get); + n.set && s && (t[s] = n.set); + } else { + const n = t[i]; + St(t, e, n, t[s]); + } + } + let n; + const r = t.prototype; + for (let t = 0; t < e.length; t++) { + n = e[t]; + const i = n[0].toUpperCase() + n.slice(1); + s(r, n, `get${i}`, `set${i}`); + } + for (n in i) { + const t = i[n]; + s(r, n, t[0], t[1]); + } + } + function be(t, e, i, s) { + const n = t[e]; + if (n) if (Array.isArray(n)) if (s) { + n.push(n[0]); + n[0] = i; + } else n.push(i); else t[e] = s ? [ i, n ] : [ n, i ]; else t[e] = i; + } + function Se(t, e) { + if ("function" == typeof t.contains) return t.contains(e); + if ("function" == typeof t.compareDocumentPosition) return !!(16 & t.compareDocumentPosition(e)); + { + let i = e.parentNode; + if (i) do { + if (i === t) return !0; + i = i.parentNode; + } while (null !== i); + return !1; + } + } + function Ae(t) { + return "object" == typeof window && "function" == typeof Node ? t instanceof Node : !!t && "object" == typeof t && "number" == typeof t.nodeType && "string" == typeof t.nodeName; + } + function Te(t, e, i) { + t && setTimeout((() => { + t(e, i); + }), 0); + } + function ve(t) { + return !(!t || t.constructor !== Object) && yt(t); + } + function Ee(t, e, i) { + if (e > i) { + const t = e; + e = i; + i = t; + } + return t < e ? e : t < i ? t : i; + } + function Ce(t) { + return t * pe.RAD; + } + function xe(t) { + return t * pe.DEG; + } + m.misc = { + BUILTIN_CLASSID_RE: me, + BASE64_VALUES: ge, + propertyDefine: ye, + pushToMap: be, + contains: Se, + isDomNode: Ae, + callInNextTick: Te, + isPlainEmptyObj_DEV: ve, + clampf: Ee, + degreesToRadians: Ce, + radiansToDegrees: xe + }; + t("misc", Object.freeze({ + __proto__: null, + BUILTIN_CLASSID_RE: me, + BASE64_VALUES: ge, + propertyDefine: ye, + pushToMap: be, + contains: Se, + isDomNode: Ae, + callInNextTick: Te, + tryCatchFunctor_EDITOR: function(t) { + return Function("target", `try {\n target.${t}();\n}\ncatch (e) {\n cc._throw(e);\n}`); + }, + isPlainEmptyObj_DEV: ve, + clampf: Ee, + degreesToRadians: Ce, + radiansToDegrees: xe + })); + const we = "$_$"; + function Re(t, e) { + const i = e ? Object.create(e) : {}; + bt(t, "__attrs__", i); + return i; + } + function Ie(t) { + if ("function" != typeof t) { + return Re(t, Be(t.constructor)); + } + let e; + const i = m.Class.getInheritanceChain(t); + for (let t = i.length - 1; t >= 0; t--) { + const s = i[t]; + if (!(s.hasOwnProperty("__attrs__") && s.__attrs__)) { + e = i[t + 1]; + Re(s, e && e.__attrs__); + } + } + e = i[0]; + Re(t, e && e.__attrs__); + return t.__attrs__; + } + function Me(t, e) { + const i = Be(t); + const s = e + we; + const n = {}; + for (const t in i) t.startsWith(s) && (n[t.slice(s.length)] = i[t]); + return n; + } + function Be(t) { + return t.hasOwnProperty("__attrs__") && t.__attrs__ || Ie(t); + } + function De(t, e, i, s) { + Be(t)[e + we + i] = s; + } + class Pe { + constructor(t, e) { + this.name = void 0; + this.default = void 0; + this.name = t; + this.default = e; + } + toString() { + return this.name; + } + } + const Oe = t("CCInteger", new Pe("Integer", 0)); + m.Integer = Oe; + m.CCInteger = Oe; + const Ne = t("CCFloat", new Pe("Float", 0)); + m.Float = Ne; + m.CCFloat = Ne; + const Le = t("CCBoolean", new Pe("Boolean", !1)); + m.Boolean = Le; + m.CCBoolean = Le; + const Fe = t("CCString", new Pe("String", "")); + m.String = Fe; + m.CCString = Fe; + function Ve(t, e) { + return function(i, s) { + const n = `"${Et(i)}.${s}"`; + const r = Me(i, s); + let o = r.type; + o === Oe || o === Ne ? o = "Number" : o !== Fe && o !== Le || (o = `${o}`); + if (o !== t) { + N(3604, n); + return; + } + if (!r.hasOwnProperty("default")) return; + const a = r.default; + if (void 0 === a) return; + if (Array.isArray(a) || ve(a)) return; + const l = typeof a; + const h = t.toLowerCase(); + if (l === h) if ("object" === h) { + if (!a || a instanceof r.ctor) return; + N(3605, n, Et(r.ctor)); + } else "Number" !== t && N(3606, e, n, t); else { + if ("function" === l) return; + t === Fe.default && null == a ? N(3607, n) : N(3611, e, n, l); + } + delete r.type; + }; + } + var ke = Object.freeze({ + __proto__: null, + DELIMETER: we, + createAttrsSingle: Re, + createAttrs: Ie, + attr: Me, + getClassAttrs: Be, + setClassAttr: De, + PrimitiveType: Pe, + CCInteger: Oe, + CCFloat: Ne, + CCBoolean: Le, + CCString: Fe, + getTypeChecker_ET: Ve, + getObjTypeChecker_ET: function(t) { + return function(e, i) { + Ve("Object", "type")(e, i); + const s = Be(e)[`${i + we}default`]; + const n = m.Class.getDefault(s); + if (!Array.isArray(n) && Vt(t, m.ValueType)) { + const n = Et(t); + const r = It('No need to specify the "type" of "%s.%s" because %s is a child class of ValueType.', Et(e), i, n); + s ? E(r) : N(3612, r, n, Et(e), i, n); + } + }; + } + }); + const Ue = { + default: {}, + serializable: {}, + editorOnly: {}, + formerlySerializedAs: {} + }; + function Ge(t, e, i, s) { + if (!t.get && !t.set && t.hasOwnProperty("default")) { + const n = `_N$${e}`; + t.get = function() { + return this[n]; + }; + t.set = function(t) { + const e = this[n]; + this[n] = t; + i.call(this, e); + }; + const r = {}; + s[n] = r; + for (const e in Ue) { + const i = Ue[e]; + if (t.hasOwnProperty(e)) { + r[e] = t[e]; + i.canUsedInGet || delete t[e]; + } + } + } + } + function ze(t, e, i, s) { + if (Array.isArray(e)) { + if (!(e.length > 0)) return F(5508, i, s); + t.type = e = e[0]; + } + "function" == typeof e && (e === String ? t.type = m.String : e === Boolean ? t.type = m.Boolean : e === Number && (t.type = m.Float)); + } + function He(t, e, i) { + const s = t ? { + _short: !0 + } : { + _short: !0, + default: e + }; + i && (s.type = i); + return s; + } + function je(t, e) { + if (!(t && t.constructor === Object)) { + if (Array.isArray(t) && t.length > 0) return He(e, [], t); + if ("function" == typeof t) { + const i = t; + return He(e, Vt(i, m.ValueType) ? new i : null, i); + } + return He(e, t instanceof Pe ? t.default : t); + } + return null; + } + let Xe = []; + function We() { + return Xe[Xe.length - 1]; + } + m._RF = { + push: function(t, e, i, s) { + if (void 0 === i) { + i = e; + e = ""; + } + Xe.push({ + uuid: e, + script: i, + module: t, + exports: t.exports, + beh: null, + importMeta: s + }); + }, + pop: function() { + const t = Xe.pop(); + const e = t.module; + let i = e.exports; + if (i === t.exports) { + for (const t in i) return; + e.exports = i = t.cls; + } + }, + peek: We + }; + let Ye; + !function(t) { + t[t.STANDALONE = 1] = "STANDALONE"; + t[t.IMPLICIT_VISIBLE = 2] = "IMPLICIT_VISIBLE"; + t[t.IMPLICIT_SERIALIZABLE = 4] = "IMPLICIT_SERIALIZABLE"; + }(Ye || (Ye = {})); + const qe = we; + const Ke = "__ctors__"; + const Je = "Enum"; + const Ze = "BitMask"; + function Qe(t, e, i, s) { + !function(t, e) { + !function(t, e) { + t.indexOf(e) < 0 && t.push(e); + }(t.__props__, e); + }(t, i); + oi(t, s, e, i); + } + function $e(t, e, i, s) { + const n = s.get; + s.set; + if (n) { + oi(t, s, e, i); + De(t, i, "serializable", !1); + } + } + function ti(t) { + return "function" == typeof t ? t() : t; + } + function ei(t, e, i) { + const s = m.Component; + const n = We(); + if (n && Vt(e, s)) { + if (Vt(n.cls, s)) { + F(3615); + return null; + } + t = t || n.script; + } + const r = function(t, e, i) { + const s = i.ctor; + bt(s, Ke, !0, !0); + s.prototype; + e && (s.$super = e); + Xt(t, s); + return s; + }(t, e, i); + if (n) if (Vt(e, s)) { + const t = n.uuid; + t && Ht(t, r); + n.cls = r; + } else Vt(n.cls, s) || (n.cls = r); + return r; + } + function ii(t, e, i, s) { + t.__props__ = []; + s && s.__props__ && (t.__props__ = s.__props__.slice()); + if (i) { + !function(t, e, i) { + for (const i in t) { + let s = t[i]; + const n = je(s, !1); + n && (s = t[i] = n); + if (s) { + const n = s.notify; + n && Ge(s, i, n, t); + "type" in s && ze(s, s.type, e, i); + } + } + }(i, e); + for (const s in i) { + const n = i[s]; + n.get || n.set ? $e(t, e, s, n) : Qe(t, e, s, n); + } + } + const n = Be(t); + t.__values__ = t.__props__.filter((t => !1 !== n[`${t + qe}serializable`])); + } + function si(t) { + let e = t.name; + const i = t.extends; + const s = ei(e, i, t); + e || (e = m.js.getClassName(s)); + s._sealed = !0; + i && (i._sealed = !1); + ii(s, e, t.properties, i); + const n = t.editor; + n && Vt(i, m.Component) && m.Component._registerEditorProps(s, n); + return s; + } + si._isCCClass = function(t) { + var e; + return null == t || null === (e = t.hasOwnProperty) || void 0 === e ? void 0 : e.call(t, Ke); + }; + si.fastDefine = function(t, e, i) { + Xt(t, e); + const s = e.__props__ = e.__values__ = Object.keys(i); + const n = Be(e); + for (let t = 0; t < s.length; t++) { + const e = s[t]; + n[`${e + qe}visible`] = !1; + n[`${e + qe}default`] = i[e]; + } + }; + si.Attr = ke; + si.attr = Me; + function ni(t) { + var e; + return null == t || null === (e = t.hasOwnProperty) || void 0 === e ? void 0 : e.call(t, "__values__"); + } + si.isCCClassOrFastDefined = ni; + si.getInheritanceChain = function(t) { + const e = []; + for (;t = Ft(t); ) t !== Object && e.push(t); + return e; + }; + const ri = { + Integer: "Number", + Float: "Number", + Boolean: "Boolean", + String: "String" + }; + function oi(t, e, i, s, n) { + let r = null; + let o = ""; + function a() { + o = s + qe; + return r = Be(t); + } + "type" in e && void 0 === e.type && N(3660, s, i); + const l = e.type; + if (l) { + if (ri[l]) (r || a())[`${o}type`] = l; else if ("Object" === l) ; else if ("object" == typeof l) { + if (oe.isEnum(l)) { + (r || a())[`${o}type`] = Je; + r[`${o}enumList`] = oe.getList(l); + } else if (ie.isBitMask(l)) { + (r || a())[`${o}type`] = Ze; + r[`${o}bitmaskList`] = ie.getList(l); + } + } else if ("function" == typeof l) { + (r || a())[`${o}type`] = "Object"; + r[`${o}ctor`] = l; + } + } + "default" in e && ((r || a())[`${o}default`] = e.default); + const h = (t, i) => { + if (t in e) { + const s = e[t]; + typeof s === i && ((r || a())[o + t] = s); + } + }; + e.editorOnly && ((r || a())[`${o}editorOnly`] = !0); + let c; + e.__internalFlags & Ye.STANDALONE ? c = !0 === e.serializable || 0 != (e.__internalFlags & Ye.IMPLICIT_SERIALIZABLE) : !1 === e.serializable && (c = !1); + void 0 !== c && ((r || a())[`${o}serializable`] = c); + h("formerlySerializedAs", "string"); + const u = e.range; + if (u && Array.isArray(u) && u.length >= 2) { + (r || a())[`${o}min`] = u[0]; + r[`${o}max`] = u[1]; + u.length > 2 && (r[`${o}step`] = u[2]); + } + h("min", "number"); + h("max", "number"); + h("step", "number"); + } + si.isArray = function(t) { + t = ti(t); + return Array.isArray(t); + }; + si.getDefault = ti; + si.escapeForJS = function(t) { + return JSON.stringify(t).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029"); + }; + si.IDENTIFIER_RE = /^[A-Za-z_$][0-9A-Za-z_$]*$/; + si.getNewValueTypeCode = !1; + m.Class = si; + const ai = Math.PI / 180; + const li = 180 / Math.PI; + const hi = t("EPSILON", 1e-6); + function ci(t, e) { + return Math.abs(t - e) <= hi * Math.max(1, Math.abs(t), Math.abs(e)); + } + function ui(t, e, i) { + i = i || hi; + return Math.abs(t - e) <= i; + } + function _i(t, e, i) { + if (e > i) { + const t = e; + e = i; + i = t; + } + return t < e ? e : t > i ? i : t; + } + function di(t) { + return t < 0 ? 0 : t > 1 ? 1 : t; + } + function pi(t, e, i) { + return t + (e - t) * i; + } + function mi(t) { + return t * ai; + } + function fi(t) { + return t * li; + } + const gi = t("random", Math.random); + function yi(t, e) { + return Math.random() * (e - t) + t; + } + function bi(t, e) { + return Math.floor(yi(t, e)); + } + function Si(t) { + return (t = (9301 * t + 49297) % 233280) / 233280; + } + function Ai(t, e, i) { + return Si(t) * (i - e) + e; + } + function Ti(t, e, i) { + return Math.floor(Ai(t, e, i)); + } + function vi(t) { + --t; + t |= t >> 1; + t |= t >> 2; + t |= t >> 4; + t |= t >> 8; + t |= t >> 16; + return ++t; + } + function Ei(t, e) { + return t - Math.floor(t / e) * e; + } + function Ci(t, e) { + t = Ei(t, 2 * e); + return t = e - Math.abs(t - e); + } + function xi(t, e, i) { + return (i - t) / (e - t); + } + function wi(t) { + return Math.abs(t.x) > Math.abs(t.y) ? Math.abs(t.x) > Math.abs(t.z) ? t.x : t.z : Math.abs(t.y) > Math.abs(t.z) ? t.y : t.z; + } + function Ri(t, e) { + return Math.abs(t) > Math.abs(e) ? t : e; + } + function Ii(t, e) { + e.forEach((e => { + Object.defineProperty(t, e, { + enumerable: !0 + }); + })); + } + const Mi = 1 / 255; + class Bi extends ce { + static clone(t) { + const e = new Bi; + t._val ? e._val = t._val : e._val = (t.a << 24 >>> 0) + (t.b << 16) + (t.g << 8) + t.r; + return e; + } + static copy(t, e) { + t.r = e.r; + t.g = e.g; + t.b = e.b; + t.a = e.a; + return t; + } + static set(t, e, i, s, n) { + t.r = e; + t.g = i; + t.b = s; + t.a = n; + return t; + } + static fromHEX(t, e) { + e = 0 === e.indexOf("#") ? e.substring(1) : e; + t.r = parseInt(e.substr(0, 2), 16) || 0; + t.g = parseInt(e.substr(2, 2), 16) || 0; + t.b = parseInt(e.substr(4, 2), 16) || 0; + const i = parseInt(e.substr(6, 2), 16); + t.a = Number.isNaN(i) ? 255 : i; + t._val = (t.a << 24 >>> 0) + (t.b << 16) + (t.g << 8) + t.r; + return t; + } + static add(t, e, i) { + t.r = e.r + i.r; + t.g = e.g + i.g; + t.b = e.b + i.b; + t.a = e.a + i.a; + return t; + } + static subtract(t, e, i) { + t.r = e.r - i.r; + t.g = e.g - i.g; + t.b = e.b - i.b; + t.a = e.a - i.a; + return t; + } + static multiply(t, e, i) { + t.r = e.r * i.r; + t.g = e.g * i.g; + t.b = e.b * i.b; + t.a = e.a * i.a; + return t; + } + static divide(t, e, i) { + t.r = e.r / i.r; + t.g = e.g / i.g; + t.b = e.b / i.b; + t.a = e.a / i.a; + return t; + } + static scale(t, e, i) { + t.r = e.r * i; + t.g = e.g * i; + t.b = e.b * i; + t.a = e.a * i; + return t; + } + static lerp(t, e, i, s) { + let n = e.r; + let r = e.g; + let o = e.b; + let a = e.a; + n += (i.r - n) * s; + r += (i.g - r) * s; + o += (i.b - o) * s; + a += (i.a - a) * s; + t._val = Math.floor((a << 24 >>> 0) + (o << 16) + (r << 8) + n); + return t; + } + static toArray(t, e, i = 0) { + const s = e instanceof Bi || e.a > 1 ? 1 / 255 : 1; + t[i + 0] = e.r * s; + t[i + 1] = e.g * s; + t[i + 2] = e.b * s; + t[i + 3] = e.a * s; + return t; + } + static fromArray(t, e, i = 0) { + e.r = 255 * t[i + 0]; + e.g = 255 * t[i + 1]; + e.b = 255 * t[i + 2]; + e.a = 255 * t[i + 3]; + return e; + } + static strictEquals(t, e) { + return t.r === e.r && t.g === e.g && t.b === e.b && t.a === e.a; + } + static equals(t, e, i = hi) { + return Math.abs(t.r - e.r) <= i * Math.max(1, Math.abs(t.r), Math.abs(e.r)) && Math.abs(t.g - e.g) <= i * Math.max(1, Math.abs(t.g), Math.abs(e.g)) && Math.abs(t.b - e.b) <= i * Math.max(1, Math.abs(t.b), Math.abs(e.b)) && Math.abs(t.a - e.a) <= i * Math.max(1, Math.abs(t.a), Math.abs(e.a)); + } + static hex(t) { + return (255 * t.r << 24 | 255 * t.g << 16 | 255 * t.b << 8 | 255 * t.a) >>> 0; + } + get r() { + return 255 & this._val; + } + set r(t) { + t = ~~_i(t, 0, 255); + this._val = (4294967040 & this._val | t) >>> 0; + } + get g() { + return (65280 & this._val) >> 8; + } + set g(t) { + t = ~~_i(t, 0, 255); + this._val = (4294902015 & this._val | t << 8) >>> 0; + } + get b() { + return (16711680 & this._val) >> 16; + } + set b(t) { + t = ~~_i(t, 0, 255); + this._val = (4278255615 & this._val | t << 16) >>> 0; + } + get a() { + return (4278190080 & this._val) >>> 24; + } + set a(t) { + t = ~~_i(t, 0, 255); + this._val = (16777215 & this._val | t << 24) >>> 0; + } + get x() { + return this.r * Mi; + } + set x(t) { + this.r = 255 * t; + } + get y() { + return this.g * Mi; + } + set y(t) { + this.g = 255 * t; + } + get z() { + return this.b * Mi; + } + set z(t) { + this.b = 255 * t; + } + get w() { + return this.a * Mi; + } + set w(t) { + this.a = 255 * t; + } + constructor(t, e, i, s) { + super(); + this._val = 0; + "string" == typeof t ? this.fromHEX(t) : void 0 !== e ? this.set(t, e, i, s) : this.set(t); + } + clone() { + const t = new Bi; + t._val = this._val; + return t; + } + equals(t) { + return t && this._val === t._val; + } + lerp(t, e) { + let i = this.r; + let s = this.g; + let n = this.b; + let r = this.a; + i += (t.r - i) * e; + s += (t.g - s) * e; + n += (t.b - n) * e; + r += (t.a - r) * e; + this._val = Math.floor((r << 24 >>> 0) + (n << 16) + (s << 8) + i); + return this; + } + toString() { + return `rgba(${this.r.toFixed()}, ${this.g.toFixed()}, ${this.b.toFixed()}, ${this.a.toFixed()})`; + } + toCSS(t = "rgba") { + return "rgba" === t ? `rgba(${this.r},${this.g},${this.b},${(this.a * Mi).toFixed(2)})` : "rgb" === t ? `rgb(${this.r},${this.g},${this.b})` : `#${this.toHEX(t)}`; + } + fromHEX(t) { + t = 0 === t.indexOf("#") ? t.substring(1) : t; + const e = parseInt(t.substr(0, 2), 16) || 0; + const i = parseInt(t.substr(2, 2), 16) || 0; + const s = parseInt(t.substr(4, 2), 16) || 0; + let n = parseInt(t.substr(6, 2), 16); + n = Number.isNaN(n) ? 255 : n; + this._val = (n << 24 >>> 0) + (s << 16) + (i << 8) + (0 | e); + return this; + } + toHEX(t = "#rrggbb") { + const e = "0"; + const i = [ (this.r < 16 ? e : "") + this.r.toString(16), (this.g < 16 ? e : "") + this.g.toString(16), (this.b < 16 ? e : "") + this.b.toString(16) ]; + if ("#rgb" === t) { + i[0] = i[0][0]; + i[1] = i[1][0]; + i[2] = i[2][0]; + } else "#rrggbbaa" === t && i.push((this.a < 16 ? e : "") + this.a.toString(16)); + return i.join(""); + } + toRGBValue() { + return 16777215 & this._val; + } + fromHSV(t, e, i) { + let s = 0; + let n = 0; + let r = 0; + if (0 === e) s = n = r = i; else if (0 === i) s = n = r = 0; else { + 1 === t && (t = 0); + t *= 6; + const o = Math.floor(t); + const a = t - o; + const l = i * (1 - e); + const h = i * (1 - e * a); + const c = i * (1 - e * (1 - a)); + switch (o) { + case 0: + s = i; + n = c; + r = l; + break; + + case 1: + s = h; + n = i; + r = l; + break; + + case 2: + s = l; + n = i; + r = c; + break; + + case 3: + s = l; + n = h; + r = i; + break; + + case 4: + s = c; + n = l; + r = i; + break; + + case 5: + s = i; + n = l; + r = h; + } + } + s *= 255; + n *= 255; + r *= 255; + this._val = (this.a << 24 >>> 0) + (r << 16) + (n << 8) + (0 | s); + return this; + } + toHSV() { + const t = this.r * Mi; + const e = this.g * Mi; + const i = this.b * Mi; + const s = { + h: 0, + s: 0, + v: 0 + }; + const n = Math.max(t, e, i); + const r = Math.min(t, e, i); + let o = 0; + s.v = n; + s.s = n ? (n - r) / n : 0; + if (s.s) { + o = n - r; + s.h = t === n ? (e - i) / o : e === n ? 2 + (i - t) / o : 4 + (t - e) / o; + s.h /= 6; + s.h < 0 && (s.h += 1); + } else s.h = 0; + return s; + } + set(t, e, i, s) { + if ("object" == typeof t) if (null != t._val) this._val = t._val; else { + e = t.g || 0; + i = t.b || 0; + s = "number" == typeof t.a ? t.a : 255; + t = t.r || 0; + this._val = (s << 24 >>> 0) + (i << 16) + (e << 8) + (0 | t); + } else { + t = t || 0; + e = e || 0; + i = i || 0; + s = "number" == typeof s ? s : 255; + this._val = (s << 24 >>> 0) + (i << 16) + (e << 8) + (0 | t); + } + return this; + } + multiply(t) { + const e = (255 & this._val) * t.r >> 8; + const i = (65280 & this._val) * t.g >> 8; + const s = (16711680 & this._val) * t.b >> 8; + const n = ((4278190080 & this._val) >>> 8) * t.a; + this._val = 4278190080 & n | 16711680 & s | 65280 & i | 255 & e; + return this; + } + _set_r_unsafe(t) { + this._val = (4294967040 & this._val | t) >>> 0; + return this; + } + _set_g_unsafe(t) { + this._val = (4294902015 & this._val | t << 8) >>> 0; + return this; + } + _set_b_unsafe(t) { + this._val = (4278255615 & this._val | t << 16) >>> 0; + return this; + } + _set_a_unsafe(t) { + this._val = (16777215 & this._val | t << 24) >>> 0; + return this; + } + } + t("Color", Bi); + Bi.WHITE = Object.freeze(new Bi(255, 255, 255, 255)); + Bi.GRAY = Object.freeze(new Bi(127, 127, 127, 255)); + Bi.BLACK = Object.freeze(new Bi(0, 0, 0, 255)); + Bi.TRANSPARENT = Object.freeze(new Bi(0, 0, 0, 0)); + Bi.RED = Object.freeze(new Bi(255, 0, 0, 255)); + Bi.GREEN = Object.freeze(new Bi(0, 255, 0, 255)); + Bi.BLUE = Object.freeze(new Bi(0, 0, 255, 255)); + Bi.CYAN = Object.freeze(new Bi(0, 255, 255, 255)); + Bi.MAGENTA = Object.freeze(new Bi(255, 0, 255, 255)); + Bi.YELLOW = Object.freeze(new Bi(255, 255, 0, 255)); + si.fastDefine("cc.Color", Bi, { + r: 0, + g: 0, + b: 0, + a: 255 + }); + m.Color = Bi; + function Di(t, e, i, s) { + return new Bi(t, e, i, s); + } + m.color = Di; + class Pi extends ce { + static zero(t) { + t.x = 0; + t.y = 0; + t.z = 0; + return t; + } + static clone(t) { + return new Pi(t.x, t.y, t.z); + } + static copy(t, e) { + t.x = e.x; + t.y = e.y; + t.z = e.z; + return t; + } + static set(t, e, i, s) { + t.x = e; + t.y = i; + t.z = s; + return t; + } + static add(t, e, i) { + t.x = e.x + i.x; + t.y = e.y + i.y; + t.z = e.z + i.z; + return t; + } + static subtract(t, e, i) { + t.x = e.x - i.x; + t.y = e.y - i.y; + t.z = e.z - i.z; + return t; + } + static multiply(t, e, i) { + t.x = e.x * i.x; + t.y = e.y * i.y; + t.z = e.z * i.z; + return t; + } + static divide(t, e, i) { + t.x = e.x / i.x; + t.y = e.y / i.y; + t.z = e.z / i.z; + return t; + } + static ceil(t, e) { + t.x = Math.ceil(e.x); + t.y = Math.ceil(e.y); + t.z = Math.ceil(e.z); + return t; + } + static floor(t, e) { + t.x = Math.floor(e.x); + t.y = Math.floor(e.y); + t.z = Math.floor(e.z); + return t; + } + static min(t, e, i) { + t.x = Math.min(e.x, i.x); + t.y = Math.min(e.y, i.y); + t.z = Math.min(e.z, i.z); + return t; + } + static max(t, e, i) { + t.x = Math.max(e.x, i.x); + t.y = Math.max(e.y, i.y); + t.z = Math.max(e.z, i.z); + return t; + } + static round(t, e) { + t.x = Math.round(e.x); + t.y = Math.round(e.y); + t.z = Math.round(e.z); + return t; + } + static multiplyScalar(t, e, i) { + t.x = e.x * i; + t.y = e.y * i; + t.z = e.z * i; + return t; + } + static scaleAndAdd(t, e, i, s) { + t.x = e.x + i.x * s; + t.y = e.y + i.y * s; + t.z = e.z + i.z * s; + return t; + } + static distance(t, e) { + const i = e.x - t.x; + const s = e.y - t.y; + const n = e.z - t.z; + return Math.sqrt(i * i + s * s + n * n); + } + static squaredDistance(t, e) { + const i = e.x - t.x; + const s = e.y - t.y; + const n = e.z - t.z; + return i * i + s * s + n * n; + } + static len(t) { + const e = t.x; + const i = t.y; + const s = t.z; + return Math.sqrt(e * e + i * i + s * s); + } + static lengthSqr(t) { + const e = t.x; + const i = t.y; + const s = t.z; + return e * e + i * i + s * s; + } + static negate(t, e) { + t.x = -e.x; + t.y = -e.y; + t.z = -e.z; + return t; + } + static invert(t, e) { + t.x = 1 / e.x; + t.y = 1 / e.y; + t.z = 1 / e.z; + return t; + } + static invertSafe(t, e) { + const i = e.x; + const s = e.y; + const n = e.z; + Math.abs(i) < hi ? t.x = 0 : t.x = 1 / i; + Math.abs(s) < hi ? t.y = 0 : t.y = 1 / s; + Math.abs(n) < hi ? t.z = 0 : t.z = 1 / n; + return t; + } + static normalize(t, e) { + const i = e.x; + const s = e.y; + const n = e.z; + let r = i * i + s * s + n * n; + if (r > 0) { + r = 1 / Math.sqrt(r); + t.x = i * r; + t.y = s * r; + t.z = n * r; + } + return t; + } + static dot(t, e) { + return t.x * e.x + t.y * e.y + t.z * e.z; + } + static cross(t, e, i) { + const {x: s, y: n, z: r} = e; + const {x: o, y: a, z: l} = i; + t.x = n * l - r * a; + t.y = r * o - s * l; + t.z = s * a - n * o; + return t; + } + static lerp(t, e, i, s) { + t.x = e.x + s * (i.x - e.x); + t.y = e.y + s * (i.y - e.y); + t.z = e.z + s * (i.z - e.z); + return t; + } + static random(t, e) { + e = e || 1; + const i = 2 * gi() * Math.PI; + const s = 2 * gi() - 1; + const n = Math.sqrt(1 - s * s); + t.x = n * Math.cos(i) * e; + t.y = n * Math.sin(i) * e; + t.z = s * e; + return t; + } + static transformMat4(t, e, i) { + const s = e.x; + const n = e.y; + const r = e.z; + let o = i.m03 * s + i.m07 * n + i.m11 * r + i.m15; + o = o ? Math.abs(1 / o) : 1; + t.x = (i.m00 * s + i.m04 * n + i.m08 * r + i.m12) * o; + t.y = (i.m01 * s + i.m05 * n + i.m09 * r + i.m13) * o; + t.z = (i.m02 * s + i.m06 * n + i.m10 * r + i.m14) * o; + return t; + } + static transformMat4Normal(t, e, i) { + const s = e.x; + const n = e.y; + const r = e.z; + let o = i.m03 * s + i.m07 * n + i.m11 * r; + o = o ? Math.abs(1 / o) : 1; + t.x = (i.m00 * s + i.m04 * n + i.m08 * r) * o; + t.y = (i.m01 * s + i.m05 * n + i.m09 * r) * o; + t.z = (i.m02 * s + i.m06 * n + i.m10 * r) * o; + return t; + } + static transformMat3(t, e, i) { + const s = e.x; + const n = e.y; + const r = e.z; + t.x = s * i.m00 + n * i.m03 + r * i.m06; + t.y = s * i.m01 + n * i.m04 + r * i.m07; + t.z = s * i.m02 + n * i.m05 + r * i.m08; + return t; + } + static transformAffine(t, e, i) { + const s = e.x; + const n = e.y; + const r = e.z; + t.x = i.m00 * s + i.m04 * n + i.m08 * r + i.m12; + t.y = i.m01 * s + i.m05 * n + i.m09 * r + i.m13; + t.z = i.m02 * s + i.m06 * n + i.m10 * r + i.m14; + return t; + } + static transformQuat(t, e, i) { + const s = i.w * e.x + i.y * e.z - i.z * e.y; + const n = i.w * e.y + i.z * e.x - i.x * e.z; + const r = i.w * e.z + i.x * e.y - i.y * e.x; + const o = -i.x * e.x - i.y * e.y - i.z * e.z; + t.x = s * i.w + o * -i.x + n * -i.z - r * -i.y; + t.y = n * i.w + o * -i.y + r * -i.x - s * -i.z; + t.z = r * i.w + o * -i.z + s * -i.y - n * -i.x; + return t; + } + static transformRTS(t, e, i, s, n) { + const r = e.x * n.x; + const o = e.y * n.y; + const a = e.z * n.z; + const l = i.w * r + i.y * a - i.z * o; + const h = i.w * o + i.z * r - i.x * a; + const c = i.w * a + i.x * o - i.y * r; + const u = -i.x * r - i.y * o - i.z * a; + t.x = l * i.w + u * -i.x + h * -i.z - c * -i.y + s.x; + t.y = h * i.w + u * -i.y + c * -i.x - l * -i.z + s.y; + t.z = c * i.w + u * -i.z + l * -i.y - h * -i.x + s.z; + return t; + } + static transformInverseRTS(t, e, i, s, n) { + const r = e.x - s.x; + const o = e.y - s.y; + const a = e.z - s.z; + const l = i.w * r - i.y * a + i.z * o; + const h = i.w * o - i.z * r + i.x * a; + const c = i.w * a - i.x * o + i.y * r; + const u = i.x * r + i.y * o + i.z * a; + t.x = (l * i.w + u * i.x + h * i.z - c * i.y) / n.x; + t.y = (h * i.w + u * i.y + c * i.x - l * i.z) / n.y; + t.z = (c * i.w + u * i.z + l * i.y - h * i.x) / n.z; + return t; + } + static rotateX(t, e, i, s) { + const n = e.x - i.x; + const r = e.y - i.y; + const o = e.z - i.z; + const a = Math.cos(s); + const l = Math.sin(s); + const h = n; + const c = r * a - o * l; + const u = r * l + o * a; + t.x = h + i.x; + t.y = c + i.y; + t.z = u + i.z; + return t; + } + static rotateY(t, e, i, s) { + const n = e.x - i.x; + const r = e.y - i.y; + const o = e.z - i.z; + const a = Math.cos(s); + const l = Math.sin(s); + const h = o * l + n * a; + const c = r; + const u = o * a - n * l; + t.x = h + i.x; + t.y = c + i.y; + t.z = u + i.z; + return t; + } + static rotateZ(t, e, i, s) { + const n = e.x - i.x; + const r = e.y - i.y; + const o = e.z - i.z; + const a = Math.cos(s); + const l = Math.sin(s); + const h = n * a - r * l; + const c = n * l + r * a; + const u = o; + t.x = h + i.x; + t.y = c + i.y; + t.z = u + i.z; + return t; + } + static toArray(t, e, i = 0) { + t[i + 0] = e.x; + t[i + 1] = e.y; + t[i + 2] = e.z; + return t; + } + static fromArray(t, e, i = 0) { + t.x = e[i + 0]; + t.y = e[i + 1]; + t.z = e[i + 2]; + return t; + } + static strictEquals(t, e) { + return t.x === e.x && t.y === e.y && t.z === e.z; + } + static equals(t, e, i = hi) { + const {x: s, y: n, z: r} = t; + const {x: o, y: a, z: l} = e; + return Math.abs(s - o) <= i * Math.max(1, Math.abs(s), Math.abs(o)) && Math.abs(n - a) <= i * Math.max(1, Math.abs(n), Math.abs(a)) && Math.abs(r - l) <= i * Math.max(1, Math.abs(r), Math.abs(l)); + } + static angle(t, e) { + Pi.normalize(Oi, t); + Pi.normalize(Ni, e); + const i = Pi.dot(Oi, Ni); + return i > 1 ? 0 : i < -1 ? Math.PI : Math.acos(i); + } + static projectOnPlane(t, e, i) { + return Pi.subtract(t, e, Pi.project(t, e, i)); + } + static project(t, e, i) { + const s = Pi.lengthSqr(i); + return s < 1e-6 ? Pi.set(t, 0, 0, 0) : Pi.multiplyScalar(t, i, Pi.dot(e, i) / s); + } + constructor(t, e, i) { + super(); + if (t && "object" == typeof t) { + this.x = t.x; + this.y = t.y; + this.z = t.z; + } else { + this.x = t || 0; + this.y = e || 0; + this.z = i || 0; + } + } + clone() { + return new Pi(this.x, this.y, this.z); + } + set(t, e, i) { + if (t && "object" == typeof t) { + this.x = t.x; + this.y = t.y; + this.z = t.z; + } else { + this.x = t || 0; + this.y = e || 0; + this.z = i || 0; + } + return this; + } + equals(t, e = hi) { + return Math.abs(this.x - t.x) <= e * Math.max(1, Math.abs(this.x), Math.abs(t.x)) && Math.abs(this.y - t.y) <= e * Math.max(1, Math.abs(this.y), Math.abs(t.y)) && Math.abs(this.z - t.z) <= e * Math.max(1, Math.abs(this.z), Math.abs(t.z)); + } + equals3f(t, e, i, s = hi) { + return Math.abs(this.x - t) <= s * Math.max(1, Math.abs(this.x), Math.abs(t)) && Math.abs(this.y - e) <= s * Math.max(1, Math.abs(this.y), Math.abs(e)) && Math.abs(this.z - i) <= s * Math.max(1, Math.abs(this.z), Math.abs(i)); + } + strictEquals(t) { + return this.x === t.x && this.y === t.y && this.z === t.z; + } + strictEquals3f(t, e, i) { + return this.x === t && this.y === e && this.z === i; + } + toString() { + return `(${this.x.toFixed(2)}, ${this.y.toFixed(2)}, ${this.z.toFixed(2)})`; + } + lerp(t, e) { + this.x += e * (t.x - this.x); + this.y += e * (t.y - this.y); + this.z += e * (t.z - this.z); + return this; + } + add(t) { + this.x += t.x; + this.y += t.y; + this.z += t.z; + return this; + } + add3f(t, e, i) { + this.x += t; + this.y += e; + this.z += i; + return this; + } + subtract(t) { + this.x -= t.x; + this.y -= t.y; + this.z -= t.z; + return this; + } + subtract3f(t, e, i) { + this.x -= t; + this.y -= e; + this.z -= i; + return this; + } + multiplyScalar(t) { + "object" == typeof t && console.warn("should use Vec3.multiply for vector * vector operation"); + this.x *= t; + this.y *= t; + this.z *= t; + return this; + } + multiply(t) { + "object" != typeof t && console.warn("should use Vec3.scale for vector * scalar operation"); + this.x *= t.x; + this.y *= t.y; + this.z *= t.z; + return this; + } + multiply3f(t, e, i) { + this.x *= t; + this.y *= e; + this.z *= i; + return this; + } + divide(t) { + this.x /= t.x; + this.y /= t.y; + this.z /= t.z; + return this; + } + divide3f(t, e, i) { + this.x /= t; + this.y /= e; + this.z /= i; + return this; + } + negative() { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + return this; + } + clampf(t, e) { + this.x = _i(this.x, t.x, e.x); + this.y = _i(this.y, t.y, e.y); + this.z = _i(this.z, t.z, e.z); + return this; + } + dot(t) { + return this.x * t.x + this.y * t.y + this.z * t.z; + } + cross(t) { + const {x: e, y: i, z: s} = this; + const {x: n, y: r, z: o} = t; + this.x = i * o - s * r; + this.y = s * n - e * o; + this.z = e * r - i * n; + return this; + } + length() { + return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); + } + lengthSqr() { + return this.x * this.x + this.y * this.y + this.z * this.z; + } + normalize() { + const t = this.x; + const e = this.y; + const i = this.z; + let s = t * t + e * e + i * i; + if (s > 0) { + s = 1 / Math.sqrt(s); + this.x = t * s; + this.y = e * s; + this.z = i * s; + } + return this; + } + transformMat4(t) { + const e = this.x; + const i = this.y; + const s = this.z; + let n = t.m03 * e + t.m07 * i + t.m11 * s + t.m15; + n = n ? 1 / n : 1; + this.x = (t.m00 * e + t.m04 * i + t.m08 * s + t.m12) * n; + this.y = (t.m01 * e + t.m05 * i + t.m09 * s + t.m13) * n; + this.z = (t.m02 * e + t.m06 * i + t.m10 * s + t.m14) * n; + return this; + } + } + t("Vec3", Pi); + Pi.UNIT_X = Object.freeze(new Pi(1, 0, 0)); + Pi.UNIT_Y = Object.freeze(new Pi(0, 1, 0)); + Pi.UNIT_Z = Object.freeze(new Pi(0, 0, 1)); + Pi.RIGHT = Object.freeze(new Pi(1, 0, 0)); + Pi.UP = Object.freeze(new Pi(0, 1, 0)); + Pi.FORWARD = Object.freeze(new Pi(0, 0, -1)); + Pi.ZERO = Object.freeze(new Pi(0, 0, 0)); + Pi.ONE = Object.freeze(new Pi(1, 1, 1)); + Pi.NEG_ONE = Object.freeze(new Pi(-1, -1, -1)); + const Oi = new Pi; + const Ni = new Pi; + si.fastDefine("cc.Vec3", Pi, { + x: 0, + y: 0, + z: 0 + }); + m.Vec3 = Pi; + function Li(t, e, i) { + return new Pi(t, e, i); + } + m.v3 = Li; + class Fi extends ce { + static clone(t) { + return new Fi(t.m00, t.m01, t.m02, t.m03, t.m04, t.m05, t.m06, t.m07, t.m08); + } + static copy(t, e) { + t.m00 = e.m00; + t.m01 = e.m01; + t.m02 = e.m02; + t.m03 = e.m03; + t.m04 = e.m04; + t.m05 = e.m05; + t.m06 = e.m06; + t.m07 = e.m07; + t.m08 = e.m08; + return t; + } + static set(t, e, i, s, n, r, o, a, l, h) { + t.m00 = e; + t.m01 = i; + t.m02 = s; + t.m03 = n; + t.m04 = r; + t.m05 = o; + t.m06 = a; + t.m07 = l; + t.m08 = h; + return t; + } + static identity(t) { + t.m00 = 1; + t.m01 = 0; + t.m02 = 0; + t.m03 = 0; + t.m04 = 1; + t.m05 = 0; + t.m06 = 0; + t.m07 = 0; + t.m08 = 1; + return t; + } + static transpose(t, e) { + if (t === e) { + const i = e.m01; + const s = e.m02; + const n = e.m05; + t.m01 = e.m03; + t.m02 = e.m06; + t.m03 = i; + t.m05 = e.m07; + t.m06 = s; + t.m07 = n; + } else { + t.m00 = e.m00; + t.m01 = e.m03; + t.m02 = e.m06; + t.m03 = e.m01; + t.m04 = e.m04; + t.m05 = e.m07; + t.m06 = e.m02; + t.m07 = e.m05; + t.m08 = e.m08; + } + return t; + } + static invert(t, e) { + const i = e.m00; + const s = e.m01; + const n = e.m02; + const r = e.m03; + const o = e.m04; + const a = e.m05; + const l = e.m06; + const h = e.m07; + const c = e.m08; + const u = c * o - a * h; + const _ = -c * r + a * l; + const d = h * r - o * l; + let p = i * u + s * _ + n * d; + if (0 === p) { + t.m00 = 0; + t.m01 = 0; + t.m02 = 0; + t.m03 = 0; + t.m04 = 0; + t.m05 = 0; + t.m06 = 0; + t.m07 = 0; + t.m08 = 0; + return t; + } + p = 1 / p; + t.m00 = u * p; + t.m01 = (-c * s + n * h) * p; + t.m02 = (a * s - n * o) * p; + t.m03 = _ * p; + t.m04 = (c * i - n * l) * p; + t.m05 = (-a * i + n * r) * p; + t.m06 = d * p; + t.m07 = (-h * i + s * l) * p; + t.m08 = (o * i - s * r) * p; + return t; + } + static determinant(t) { + const e = t.m00; + const i = t.m01; + const s = t.m02; + const n = t.m03; + const r = t.m04; + const o = t.m05; + const a = t.m06; + const l = t.m07; + const h = t.m08; + return e * (h * r - o * l) + i * (-h * n + o * a) + s * (l * n - r * a); + } + static multiply(t, e, i) { + const s = e.m00; + const n = e.m01; + const r = e.m02; + const o = e.m03; + const a = e.m04; + const l = e.m05; + const h = e.m06; + const c = e.m07; + const u = e.m08; + const _ = i.m00; + const d = i.m01; + const p = i.m02; + const m = i.m03; + const f = i.m04; + const g = i.m05; + const y = i.m06; + const b = i.m07; + const S = i.m08; + t.m00 = _ * s + d * o + p * h; + t.m01 = _ * n + d * a + p * c; + t.m02 = _ * r + d * l + p * u; + t.m03 = m * s + f * o + g * h; + t.m04 = m * n + f * a + g * c; + t.m05 = m * r + f * l + g * u; + t.m06 = y * s + b * o + S * h; + t.m07 = y * n + b * a + S * c; + t.m08 = y * r + b * l + S * u; + return t; + } + static multiplyMat4(t, e, i) { + const s = e.m00; + const n = e.m01; + const r = e.m02; + const o = e.m03; + const a = e.m04; + const l = e.m05; + const h = e.m06; + const c = e.m07; + const u = e.m08; + const _ = i.m00; + const d = i.m01; + const p = i.m02; + const m = i.m04; + const f = i.m05; + const g = i.m06; + const y = i.m08; + const b = i.m09; + const S = i.m10; + t.m00 = _ * s + d * o + p * h; + t.m01 = _ * n + d * a + p * c; + t.m02 = _ * r + d * l + p * u; + t.m03 = m * s + f * o + g * h; + t.m04 = m * n + f * a + g * c; + t.m05 = m * r + f * l + g * u; + t.m06 = y * s + b * o + S * h; + t.m07 = y * n + b * a + S * c; + t.m08 = y * r + b * l + S * u; + return t; + } + static transform(t, e, i) { + const s = e.m00; + const n = e.m01; + const r = e.m02; + const o = e.m03; + const a = e.m04; + const l = e.m05; + const h = e.m06; + const c = e.m07; + const u = e.m08; + const _ = i.x; + const d = i.y; + t.m00 = s; + t.m01 = n; + t.m02 = r; + t.m03 = o; + t.m04 = a; + t.m05 = l; + t.m06 = _ * s + d * o + h; + t.m07 = _ * n + d * a + c; + t.m08 = _ * r + d * l + u; + return t; + } + static scale(t, e, i) { + const s = i.x; + const n = i.y; + t.m00 = s * e.m00; + t.m01 = s * e.m01; + t.m02 = s * e.m02; + t.m03 = n * e.m03; + t.m04 = n * e.m04; + t.m05 = n * e.m05; + t.m06 = e.m06; + t.m07 = e.m07; + t.m08 = e.m08; + return t; + } + static rotate(t, e, i) { + const s = e.m00; + const n = e.m01; + const r = e.m02; + const o = e.m03; + const a = e.m04; + const l = e.m05; + const h = e.m06; + const c = e.m07; + const u = e.m08; + const _ = Math.sin(i); + const d = Math.cos(i); + t.m00 = d * s + _ * o; + t.m01 = d * n + _ * a; + t.m02 = d * r + _ * l; + t.m03 = d * o - _ * s; + t.m04 = d * a - _ * n; + t.m05 = d * l - _ * r; + t.m06 = h; + t.m07 = c; + t.m08 = u; + return t; + } + static fromMat4(t, e) { + t.m00 = e.m00; + t.m01 = e.m01; + t.m02 = e.m02; + t.m03 = e.m04; + t.m04 = e.m05; + t.m05 = e.m06; + t.m06 = e.m08; + t.m07 = e.m09; + t.m08 = e.m10; + return t; + } + static fromViewUp(t, e, i) { + if (Pi.lengthSqr(e) < hi * hi) { + Fi.identity(t); + return t; + } + i = i || Pi.UNIT_Y; + Pi.normalize(Vi, Pi.cross(Vi, i, e)); + if (Pi.lengthSqr(Vi) < hi * hi) { + Fi.identity(t); + return t; + } + Pi.cross(ki, e, Vi); + Fi.set(t, Vi.x, Vi.y, Vi.z, ki.x, ki.y, ki.z, e.x, e.y, e.z); + return t; + } + static fromTranslation(t, e) { + t.m00 = 1; + t.m01 = 0; + t.m02 = 0; + t.m03 = 0; + t.m04 = 1; + t.m05 = 0; + t.m06 = e.x; + t.m07 = e.y; + t.m08 = 1; + return t; + } + static fromScaling(t, e) { + t.m00 = e.x; + t.m01 = 0; + t.m02 = 0; + t.m03 = 0; + t.m04 = e.y; + t.m05 = 0; + t.m06 = 0; + t.m07 = 0; + t.m08 = 1; + return t; + } + static fromRotation(t, e) { + const i = Math.sin(e); + const s = Math.cos(e); + t.m00 = s; + t.m01 = i; + t.m02 = 0; + t.m03 = -i; + t.m04 = s; + t.m05 = 0; + t.m06 = 0; + t.m07 = 0; + t.m08 = 1; + return t; + } + static fromQuat(t, e) { + const i = e.x; + const s = e.y; + const n = e.z; + const r = e.w; + const o = i + i; + const a = s + s; + const l = n + n; + const h = i * o; + const c = s * o; + const u = s * a; + const _ = n * o; + const d = n * a; + const p = n * l; + const m = r * o; + const f = r * a; + const g = r * l; + t.m00 = 1 - u - p; + t.m03 = c - g; + t.m06 = _ + f; + t.m01 = c + g; + t.m04 = 1 - h - p; + t.m07 = d - m; + t.m02 = _ - f; + t.m05 = d + m; + t.m08 = 1 - h - u; + return t; + } + static inverseTransposeMat4(t, e) { + const i = e.m00; + const s = e.m01; + const n = e.m02; + const r = e.m03; + const o = e.m04; + const a = e.m05; + const l = e.m06; + const h = e.m07; + const c = e.m08; + const u = e.m09; + const _ = e.m10; + const d = e.m11; + const p = e.m12; + const m = e.m13; + const f = e.m14; + const g = e.m15; + const y = i * a - s * o; + const b = i * l - n * o; + const S = i * h - r * o; + const A = s * l - n * a; + const T = s * h - r * a; + const v = n * h - r * l; + const E = c * m - u * p; + const C = c * f - _ * p; + const x = c * g - d * p; + const w = u * f - _ * m; + const R = u * g - d * m; + const I = _ * g - d * f; + let M = y * I - b * R + S * w + A * x - T * C + v * E; + if (!M) return null; + M = 1 / M; + t.m00 = (a * I - l * R + h * w) * M; + t.m01 = (l * x - o * I - h * C) * M; + t.m02 = (o * R - a * x + h * E) * M; + t.m03 = (n * R - s * I - r * w) * M; + t.m04 = (i * I - n * x + r * C) * M; + t.m05 = (s * x - i * R - r * E) * M; + t.m06 = (m * v - f * T + g * A) * M; + t.m07 = (f * S - p * v - g * b) * M; + t.m08 = (p * T - m * S + g * y) * M; + return t; + } + static toArray(t, e, i = 0) { + t[i + 0] = e.m00; + t[i + 1] = e.m01; + t[i + 2] = e.m02; + t[i + 3] = e.m03; + t[i + 4] = e.m04; + t[i + 5] = e.m05; + t[i + 6] = e.m06; + t[i + 7] = e.m07; + t[i + 8] = e.m08; + return t; + } + static fromArray(t, e, i = 0) { + t.m00 = e[i + 0]; + t.m01 = e[i + 1]; + t.m02 = e[i + 2]; + t.m03 = e[i + 3]; + t.m04 = e[i + 4]; + t.m05 = e[i + 5]; + t.m06 = e[i + 6]; + t.m07 = e[i + 7]; + t.m08 = e[i + 8]; + return t; + } + static add(t, e, i) { + t.m00 = e.m00 + i.m00; + t.m01 = e.m01 + i.m01; + t.m02 = e.m02 + i.m02; + t.m03 = e.m03 + i.m03; + t.m04 = e.m04 + i.m04; + t.m05 = e.m05 + i.m05; + t.m06 = e.m06 + i.m06; + t.m07 = e.m07 + i.m07; + t.m08 = e.m08 + i.m08; + return t; + } + static subtract(t, e, i) { + t.m00 = e.m00 - i.m00; + t.m01 = e.m01 - i.m01; + t.m02 = e.m02 - i.m02; + t.m03 = e.m03 - i.m03; + t.m04 = e.m04 - i.m04; + t.m05 = e.m05 - i.m05; + t.m06 = e.m06 - i.m06; + t.m07 = e.m07 - i.m07; + t.m08 = e.m08 - i.m08; + return t; + } + static multiplyScalar(t, e, i) { + t.m00 = e.m00 * i; + t.m01 = e.m01 * i; + t.m02 = e.m02 * i; + t.m03 = e.m03 * i; + t.m04 = e.m04 * i; + t.m05 = e.m05 * i; + t.m06 = e.m06 * i; + t.m07 = e.m07 * i; + t.m08 = e.m08 * i; + return t; + } + static multiplyScalarAndAdd(t, e, i, s) { + t.m00 = i.m00 * s + e.m00; + t.m01 = i.m01 * s + e.m01; + t.m02 = i.m02 * s + e.m02; + t.m03 = i.m03 * s + e.m03; + t.m04 = i.m04 * s + e.m04; + t.m05 = i.m05 * s + e.m05; + t.m06 = i.m06 * s + e.m06; + t.m07 = i.m07 * s + e.m07; + t.m08 = i.m08 * s + e.m08; + return t; + } + static strictEquals(t, e) { + return t.m00 === e.m00 && t.m01 === e.m01 && t.m02 === e.m02 && t.m03 === e.m03 && t.m04 === e.m04 && t.m05 === e.m05 && t.m06 === e.m06 && t.m07 === e.m07 && t.m08 === e.m08; + } + static equals(t, e, i = hi) { + return Math.abs(t.m00 - e.m00) <= i * Math.max(1, Math.abs(t.m00), Math.abs(e.m00)) && Math.abs(t.m01 - e.m01) <= i * Math.max(1, Math.abs(t.m01), Math.abs(e.m01)) && Math.abs(t.m02 - e.m02) <= i * Math.max(1, Math.abs(t.m02), Math.abs(e.m02)) && Math.abs(t.m03 - e.m03) <= i * Math.max(1, Math.abs(t.m03), Math.abs(e.m03)) && Math.abs(t.m04 - e.m04) <= i * Math.max(1, Math.abs(t.m04), Math.abs(e.m04)) && Math.abs(t.m05 - e.m05) <= i * Math.max(1, Math.abs(t.m05), Math.abs(e.m05)) && Math.abs(t.m06 - e.m06) <= i * Math.max(1, Math.abs(t.m06), Math.abs(e.m06)) && Math.abs(t.m07 - e.m07) <= i * Math.max(1, Math.abs(t.m07), Math.abs(e.m07)) && Math.abs(t.m08 - e.m08) <= i * Math.max(1, Math.abs(t.m08), Math.abs(e.m08)); + } + constructor(t = 1, e = 0, i = 0, s = 0, n = 1, r = 0, o = 0, a = 0, l = 1) { + super(); + if ("object" == typeof t) { + this.m00 = t.m00; + this.m01 = t.m01; + this.m02 = t.m02; + this.m03 = t.m03; + this.m04 = t.m04; + this.m05 = t.m05; + this.m06 = t.m06; + this.m07 = t.m07; + this.m08 = t.m08; + } else { + this.m00 = t; + this.m01 = e; + this.m02 = i; + this.m03 = s; + this.m04 = n; + this.m05 = r; + this.m06 = o; + this.m07 = a; + this.m08 = l; + } + } + clone() { + const t = this; + return new Fi(t.m00, t.m01, t.m02, t.m03, t.m04, t.m05, t.m06, t.m07, t.m08); + } + set(t = 1, e = 0, i = 0, s = 0, n = 1, r = 0, o = 0, a = 0, l = 1) { + if ("object" == typeof t) { + this.m00 = t.m00; + this.m01 = t.m01; + this.m02 = t.m02; + this.m03 = t.m03; + this.m04 = t.m04; + this.m05 = t.m05; + this.m06 = t.m06; + this.m07 = t.m07; + this.m08 = t.m08; + } else { + this.m00 = t; + this.m01 = e; + this.m02 = i; + this.m03 = s; + this.m04 = n; + this.m05 = r; + this.m06 = o; + this.m07 = a; + this.m08 = l; + } + return this; + } + equals(t, e = hi) { + return Math.abs(this.m00 - t.m00) <= e * Math.max(1, Math.abs(this.m00), Math.abs(t.m00)) && Math.abs(this.m01 - t.m01) <= e * Math.max(1, Math.abs(this.m01), Math.abs(t.m01)) && Math.abs(this.m02 - t.m02) <= e * Math.max(1, Math.abs(this.m02), Math.abs(t.m02)) && Math.abs(this.m03 - t.m03) <= e * Math.max(1, Math.abs(this.m03), Math.abs(t.m03)) && Math.abs(this.m04 - t.m04) <= e * Math.max(1, Math.abs(this.m04), Math.abs(t.m04)) && Math.abs(this.m05 - t.m05) <= e * Math.max(1, Math.abs(this.m05), Math.abs(t.m05)) && Math.abs(this.m06 - t.m06) <= e * Math.max(1, Math.abs(this.m06), Math.abs(t.m06)) && Math.abs(this.m07 - t.m07) <= e * Math.max(1, Math.abs(this.m07), Math.abs(t.m07)) && Math.abs(this.m08 - t.m08) <= e * Math.max(1, Math.abs(this.m08), Math.abs(t.m08)); + } + strictEquals(t) { + return this.m00 === t.m00 && this.m01 === t.m01 && this.m02 === t.m02 && this.m03 === t.m03 && this.m04 === t.m04 && this.m05 === t.m05 && this.m06 === t.m06 && this.m07 === t.m07 && this.m08 === t.m08; + } + toString() { + const t = this; + return `[\n${t.m00}, ${t.m01}, ${t.m02},\n${t.m03},\n${t.m04}, ${t.m05},\n${t.m06}, ${t.m07},\n${t.m08}\n]`; + } + identity() { + this.m00 = 1; + this.m01 = 0; + this.m02 = 0; + this.m03 = 0; + this.m04 = 1; + this.m05 = 0; + this.m06 = 0; + this.m07 = 0; + this.m08 = 1; + return this; + } + transpose() { + const t = this.m01; + const e = this.m02; + const i = this.m05; + this.m01 = this.m03; + this.m02 = this.m06; + this.m03 = t; + this.m05 = this.m07; + this.m06 = e; + this.m07 = i; + return this; + } + invert() { + const t = this.m00; + const e = this.m01; + const i = this.m02; + const s = this.m03; + const n = this.m04; + const r = this.m05; + const o = this.m06; + const a = this.m07; + const l = this.m08; + const h = l * n - r * a; + const c = -l * s + r * o; + const u = a * s - n * o; + let _ = t * h + e * c + i * u; + if (0 === _) { + this.set(0, 0, 0, 0, 0, 0, 0, 0, 0); + return this; + } + _ = 1 / _; + this.m00 = h * _; + this.m01 = (-l * e + i * a) * _; + this.m02 = (r * e - i * n) * _; + this.m03 = c * _; + this.m04 = (l * t - i * o) * _; + this.m05 = (-r * t + i * s) * _; + this.m06 = u * _; + this.m07 = (-a * t + e * o) * _; + this.m08 = (n * t - e * s) * _; + return this; + } + determinant() { + const t = this.m00; + const e = this.m01; + const i = this.m02; + const s = this.m03; + const n = this.m04; + const r = this.m05; + const o = this.m06; + const a = this.m07; + const l = this.m08; + return t * (l * n - r * a) + e * (-l * s + r * o) + i * (a * s - n * o); + } + add(t) { + this.m00 += t.m00; + this.m01 += t.m01; + this.m02 += t.m02; + this.m03 += t.m03; + this.m04 += t.m04; + this.m05 += t.m05; + this.m06 += t.m06; + this.m07 += t.m07; + this.m08 += t.m08; + return this; + } + subtract(t) { + this.m00 -= t.m00; + this.m01 -= t.m01; + this.m02 -= t.m02; + this.m03 -= t.m03; + this.m04 -= t.m04; + this.m05 -= t.m05; + this.m06 -= t.m06; + this.m07 -= t.m07; + this.m08 -= t.m08; + return this; + } + multiply(t) { + const e = this.m00; + const i = this.m01; + const s = this.m02; + const n = this.m03; + const r = this.m04; + const o = this.m05; + const a = this.m06; + const l = this.m07; + const h = this.m08; + const c = t.m00; + const u = t.m01; + const _ = t.m02; + const d = t.m03; + const p = t.m04; + const m = t.m05; + const f = t.m06; + const g = t.m07; + const y = t.m08; + this.m00 = c * e + u * n + _ * a; + this.m01 = c * i + u * r + _ * l; + this.m02 = c * s + u * o + _ * h; + this.m03 = d * e + p * n + m * a; + this.m04 = d * i + p * r + m * l; + this.m05 = d * s + p * o + m * h; + this.m06 = f * e + g * n + y * a; + this.m07 = f * i + g * r + y * l; + this.m08 = f * s + g * o + y * h; + return this; + } + multiplyScalar(t) { + this.m00 *= t; + this.m01 *= t; + this.m02 *= t; + this.m03 *= t; + this.m04 *= t; + this.m05 *= t; + this.m06 *= t; + this.m07 *= t; + this.m08 *= t; + return this; + } + scale(t) { + const e = t.x; + const i = t.y; + this.m00 = e * this.m00; + this.m01 = e * this.m01; + this.m02 = e * this.m02; + this.m03 = i * this.m03; + this.m04 = i * this.m04; + this.m05 = i * this.m05; + this.m06 = this.m06; + this.m07 = this.m07; + this.m08 = this.m08; + return this; + } + rotate(t) { + const e = this.m00; + const i = this.m01; + const s = this.m02; + const n = this.m03; + const r = this.m04; + const o = this.m05; + const a = this.m06; + const l = this.m07; + const h = this.m08; + const c = Math.sin(t); + const u = Math.cos(t); + this.m00 = u * e + c * n; + this.m01 = u * i + c * r; + this.m02 = u * s + c * o; + this.m03 = u * n - c * e; + this.m04 = u * r - c * i; + this.m05 = u * o - c * s; + this.m06 = a; + this.m07 = l; + this.m08 = h; + return this; + } + fromQuat(t) { + const e = t.x; + const i = t.y; + const s = t.z; + const n = t.w; + const r = e + e; + const o = i + i; + const a = s + s; + const l = e * r; + const h = i * r; + const c = i * o; + const u = s * r; + const _ = s * o; + const d = s * a; + const p = n * r; + const m = n * o; + const f = n * a; + this.m00 = 1 - c - d; + this.m03 = h - f; + this.m06 = u + m; + this.m01 = h + f; + this.m04 = 1 - l - d; + this.m07 = _ - p; + this.m02 = u - m; + this.m05 = _ + p; + this.m08 = 1 - l - c; + return this; + } + } + t("Mat3", Fi); + Fi.IDENTITY = Object.freeze(new Fi); + const Vi = new Pi; + const ki = new Pi; + si.fastDefine("cc.Mat3", Fi, { + m00: 1, + m01: 0, + m02: 0, + m03: 0, + m04: 1, + m05: 0, + m06: 0, + m07: 0, + m08: 1 + }); + m.Mat3 = Fi; + class Ui extends ce { + static clone(t) { + return new Ui(t.x, t.y, t.z, t.w); + } + static copy(t, e) { + t.x = e.x; + t.y = e.y; + t.z = e.z; + t.w = e.w; + return t; + } + static set(t, e, i, s, n) { + t.x = e; + t.y = i; + t.z = s; + t.w = n; + return t; + } + static identity(t) { + t.x = 0; + t.y = 0; + t.z = 0; + t.w = 1; + return t; + } + static rotationTo(t, e, i) { + const s = Pi.dot(e, i); + if (s < -.999999) { + Pi.cross(Hi, Pi.UNIT_X, e); + Hi.length() < 1e-6 && Pi.cross(Hi, Pi.UNIT_Y, e); + Pi.normalize(Hi, Hi); + Ui.fromAxisAngle(t, Hi, Math.PI); + return t; + } + if (s > .999999) { + t.x = 0; + t.y = 0; + t.z = 0; + t.w = 1; + return t; + } + Pi.cross(Hi, e, i); + t.x = Hi.x; + t.y = Hi.y; + t.z = Hi.z; + t.w = 1 + s; + return Ui.normalize(t, t); + } + static getAxisAngle(t, e) { + const i = 2 * Math.acos(e.w); + const s = Math.sin(i / 2); + if (0 !== s) { + t.x = e.x / s; + t.y = e.y / s; + t.z = e.z / s; + } else { + t.x = 1; + t.y = 0; + t.z = 0; + } + return i; + } + static multiply(t, e, i) { + const s = e.x * i.w + e.w * i.x + e.y * i.z - e.z * i.y; + const n = e.y * i.w + e.w * i.y + e.z * i.x - e.x * i.z; + const r = e.z * i.w + e.w * i.z + e.x * i.y - e.y * i.x; + const o = e.w * i.w - e.x * i.x - e.y * i.y - e.z * i.z; + t.x = s; + t.y = n; + t.z = r; + t.w = o; + return t; + } + static multiplyScalar(t, e, i) { + t.x = e.x * i; + t.y = e.y * i; + t.z = e.z * i; + t.w = e.w * i; + return t; + } + static scaleAndAdd(t, e, i, s) { + t.x = e.x + i.x * s; + t.y = e.y + i.y * s; + t.z = e.z + i.z * s; + t.w = e.w + i.w * s; + return t; + } + static rotateX(t, e, i) { + i *= .5; + const s = Math.sin(i); + const n = Math.cos(i); + const {x: r, y: o, z: a, w: l} = e; + t.x = r * n + l * s; + t.y = o * n + a * s; + t.z = a * n - o * s; + t.w = l * n - r * s; + return t; + } + static rotateY(t, e, i) { + i *= .5; + const s = Math.sin(i); + const n = Math.cos(i); + const {x: r, y: o, z: a, w: l} = e; + t.x = r * n - a * s; + t.y = o * n + l * s; + t.z = a * n + r * s; + t.w = l * n - o * s; + return t; + } + static rotateZ(t, e, i) { + i *= .5; + const s = Math.sin(i); + const n = Math.cos(i); + const {x: r, y: o, z: a, w: l} = e; + t.x = r * n + o * s; + t.y = o * n - r * s; + t.z = a * n + l * s; + t.w = l * n - a * s; + return t; + } + static rotateAround(t, e, i, s) { + Ui.invert(Gi, e); + Pi.transformQuat(Hi, i, Gi); + Ui.fromAxisAngle(Gi, Hi, s); + Ui.multiply(t, e, Gi); + return t; + } + static rotateAroundLocal(t, e, i, s) { + Ui.fromAxisAngle(Gi, i, s); + Ui.multiply(t, e, Gi); + return t; + } + static calculateW(t, e) { + t.x = e.x; + t.y = e.y; + t.z = e.z; + t.w = Math.sqrt(Math.abs(1 - e.x * e.x - e.y * e.y - e.z * e.z)); + return t; + } + static dot(t, e) { + return t.x * e.x + t.y * e.y + t.z * e.z + t.w * e.w; + } + static lerp(t, e, i, s) { + t.x = e.x + s * (i.x - e.x); + t.y = e.y + s * (i.y - e.y); + t.z = e.z + s * (i.z - e.z); + t.w = e.w + s * (i.w - e.w); + return t; + } + static slerp(t, e, i, s) { + let n = 0; + let r = 0; + let o = i.x; + let a = i.y; + let l = i.z; + let h = i.w; + let c = e.x * i.x + e.y * i.y + e.z * i.z + e.w * i.w; + if (c < 0) { + c = -c; + o = -o; + a = -a; + l = -l; + h = -h; + } + if (1 - c > 1e-6) { + const t = Math.acos(c); + const e = Math.sin(t); + n = Math.sin((1 - s) * t) / e; + r = Math.sin(s * t) / e; + } else { + n = 1 - s; + r = s; + } + t.x = n * e.x + r * o; + t.y = n * e.y + r * a; + t.z = n * e.z + r * l; + t.w = n * e.w + r * h; + return t; + } + static sqlerp(t, e, i, s, n, r) { + Ui.slerp(Gi, e, n, r); + Ui.slerp(zi, i, s, r); + Ui.slerp(t, Gi, zi, 2 * r * (1 - r)); + return t; + } + static invert(t, e) { + const i = e.x * e.x + e.y * e.y + e.z * e.z + e.w * e.w; + const s = i ? 1 / i : 0; + t.x = -e.x * s; + t.y = -e.y * s; + t.z = -e.z * s; + t.w = e.w * s; + return t; + } + static conjugate(t, e) { + t.x = -e.x; + t.y = -e.y; + t.z = -e.z; + t.w = e.w; + return t; + } + static len(t) { + return Math.sqrt(t.x * t.x + t.y * t.y + t.z * t.z + t.w * t.w); + } + static lengthSqr(t) { + return t.x * t.x + t.y * t.y + t.z * t.z + t.w * t.w; + } + static normalize(t, e) { + let i = e.x * e.x + e.y * e.y + e.z * e.z + e.w * e.w; + if (i > 0) { + i = 1 / Math.sqrt(i); + t.x = e.x * i; + t.y = e.y * i; + t.z = e.z * i; + t.w = e.w * i; + } + return t; + } + static fromAxes(t, e, i, s) { + Fi.set(ji, e.x, e.y, e.z, i.x, i.y, i.z, s.x, s.y, s.z); + return Ui.normalize(t, Ui.fromMat3(t, ji)); + } + static fromViewUp(t, e, i) { + Fi.fromViewUp(ji, e, i); + return Ui.normalize(t, Ui.fromMat3(t, ji)); + } + static fromAxisAngle(t, e, i) { + i *= .5; + const s = Math.sin(i); + t.x = s * e.x; + t.y = s * e.y; + t.z = s * e.z; + t.w = Math.cos(i); + return t; + } + static fromMat3(t, e) { + const {m00: i, m03: s, m06: n, m01: r, m04: o, m07: a, m02: l, m05: h, m08: c} = e; + const u = i + o + c; + if (u > 0) { + const e = .5 / Math.sqrt(u + 1); + t.w = .25 / e; + t.x = (h - a) * e; + t.y = (n - l) * e; + t.z = (r - s) * e; + } else if (i > o && i > c) { + const e = 2 * Math.sqrt(1 + i - o - c); + t.w = (h - a) / e; + t.x = .25 * e; + t.y = (s + r) / e; + t.z = (n + l) / e; + } else if (o > c) { + const e = 2 * Math.sqrt(1 + o - i - c); + t.w = (n - l) / e; + t.x = (s + r) / e; + t.y = .25 * e; + t.z = (a + h) / e; + } else { + const e = 2 * Math.sqrt(1 + c - i - o); + t.w = (r - s) / e; + t.x = (n + l) / e; + t.y = (a + h) / e; + t.z = .25 * e; + } + return t; + } + static fromEuler(t, e, i, s) { + e *= Xi; + i *= Xi; + s *= Xi; + const n = Math.sin(e); + const r = Math.cos(e); + const o = Math.sin(i); + const a = Math.cos(i); + const l = Math.sin(s); + const h = Math.cos(s); + t.x = n * a * h + r * o * l; + t.y = r * o * h + n * a * l; + t.z = r * a * l - n * o * h; + t.w = r * a * h - n * o * l; + return t; + } + static fromAngleZ(t, e) { + e *= Xi; + t.x = t.y = 0; + t.z = Math.sin(e); + t.w = Math.cos(e); + return t; + } + static toAxisX(t, e) { + const i = 2 * e.y; + const s = 2 * e.z; + t.x = 1 - i * e.y - s * e.z; + t.y = i * e.x + s * e.w; + t.z = s * e.x + i * e.w; + return t; + } + static toAxisY(t, e) { + const i = 2 * e.x; + const s = 2 * e.y; + const n = 2 * e.z; + t.x = s * e.x - n * e.w; + t.y = 1 - i * e.x - n * e.z; + t.z = n * e.y + i * e.w; + return t; + } + static toAxisZ(t, e) { + const i = 2 * e.x; + const s = 2 * e.y; + const n = 2 * e.z; + t.x = n * e.x - s * e.w; + t.y = n * e.y - i * e.w; + t.z = 1 - i * e.x - s * e.y; + return t; + } + static toEuler(t, e, i) { + const {x: s, y: n, z: r, w: o} = e; + let a = 0; + let l = 0; + let h = 0; + const c = s * n + r * o; + if (c > .499999) { + a = 0; + l = fi(2 * Math.atan2(s, o)); + h = 90; + } else if (c < -.499999) { + a = 0; + l = -fi(2 * Math.atan2(s, o)); + h = -90; + } else { + const t = s * s; + const e = n * n; + const u = r * r; + a = fi(Math.atan2(2 * s * o - 2 * n * r, 1 - 2 * t - 2 * u)); + l = fi(Math.atan2(2 * n * o - 2 * s * r, 1 - 2 * e - 2 * u)); + h = fi(Math.asin(2 * c)); + if (i) { + a = -180 * Math.sign(a + 1e-6) + a; + l = -180 * Math.sign(l + 1e-6) + l; + h = 180 * Math.sign(h + 1e-6) - h; + } + } + t.x = a; + t.y = l; + t.z = h; + return t; + } + static toArray(t, e, i = 0) { + t[i + 0] = e.x; + t[i + 1] = e.y; + t[i + 2] = e.z; + t[i + 3] = e.w; + return t; + } + static fromArray(t, e, i = 0) { + t.x = e[i + 0]; + t.y = e[i + 1]; + t.z = e[i + 2]; + t.w = e[i + 3]; + return t; + } + static strictEquals(t, e) { + return t.x === e.x && t.y === e.y && t.z === e.z && t.w === e.w; + } + static equals(t, e, i = hi) { + return Math.abs(t.x - e.x) <= i * Math.max(1, Math.abs(t.x), Math.abs(e.x)) && Math.abs(t.y - e.y) <= i * Math.max(1, Math.abs(t.y), Math.abs(e.y)) && Math.abs(t.z - e.z) <= i * Math.max(1, Math.abs(t.z), Math.abs(e.z)) && Math.abs(t.w - e.w) <= i * Math.max(1, Math.abs(t.w), Math.abs(e.w)); + } + constructor(t, e, i, s) { + super(); + if (t && "object" == typeof t) { + this.x = t.x; + this.y = t.y; + this.z = t.z; + this.w = t.w; + } else { + this.x = t || 0; + this.y = e || 0; + this.z = i || 0; + this.w = null != s ? s : 1; + } + } + clone() { + return new Ui(this.x, this.y, this.z, this.w); + } + set(t, e, i, s) { + if (t && "object" == typeof t) { + this.x = t.x; + this.y = t.y; + this.z = t.z; + this.w = t.w; + } else { + this.x = t || 0; + this.y = e || 0; + this.z = i || 0; + this.w = null != s ? s : 1; + } + return this; + } + equals(t, e = hi) { + return Math.abs(this.x - t.x) <= e * Math.max(1, Math.abs(this.x), Math.abs(t.x)) && Math.abs(this.y - t.y) <= e * Math.max(1, Math.abs(this.y), Math.abs(t.y)) && Math.abs(this.z - t.z) <= e * Math.max(1, Math.abs(this.z), Math.abs(t.z)) && Math.abs(this.w - t.w) <= e * Math.max(1, Math.abs(this.w), Math.abs(t.w)); + } + strictEquals(t) { + return t && this.x === t.x && this.y === t.y && this.z === t.z && this.w === t.w; + } + getEulerAngles(t) { + return Ui.toEuler(t, this); + } + lerp(t, e) { + this.x += e * (t.x - this.x); + this.y += e * (t.y - this.y); + this.z += e * (t.z - this.z); + this.w += e * (t.w - this.w); + return this; + } + slerp(t, e) { + return Ui.slerp(this, this, t, e); + } + length() { + return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w); + } + lengthSqr() { + return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w; + } + } + t("Quat", Ui); + Ui.IDENTITY = Object.freeze(new Ui); + const Gi = new Ui; + const zi = new Ui; + const Hi = new Pi; + const ji = new Fi; + const Xi = .5 * Math.PI / 180; + si.fastDefine("cc.Quat", Ui, { + x: 0, + y: 0, + z: 0, + w: 1 + }); + m.Quat = Ui; + function Wi(t = 0, e = 0, i = 0, s = 1) { + return new Ui(t, e, i, s); + } + m.quat = Wi; + const Yi = Object.freeze([ Object.freeze([ 1, 0, 0, 1 ]), Object.freeze([ 0, 1, -1, 0 ]), Object.freeze([ -1, 0, 0, -1 ]), Object.freeze([ 0, -1, 1, 0 ]) ]); + class qi extends ce { + static clone(t) { + return new qi(t.m00, t.m01, t.m02, t.m03, t.m04, t.m05, t.m06, t.m07, t.m08, t.m09, t.m10, t.m11, t.m12, t.m13, t.m14, t.m15); + } + static copy(t, e) { + t.m00 = e.m00; + t.m01 = e.m01; + t.m02 = e.m02; + t.m03 = e.m03; + t.m04 = e.m04; + t.m05 = e.m05; + t.m06 = e.m06; + t.m07 = e.m07; + t.m08 = e.m08; + t.m09 = e.m09; + t.m10 = e.m10; + t.m11 = e.m11; + t.m12 = e.m12; + t.m13 = e.m13; + t.m14 = e.m14; + t.m15 = e.m15; + return t; + } + static set(t, e, i, s, n, r, o, a, l, h, c, u, _, d, p, m, f) { + t.m00 = e; + t.m01 = i; + t.m02 = s; + t.m03 = n; + t.m04 = r; + t.m05 = o; + t.m06 = a; + t.m07 = l; + t.m08 = h; + t.m09 = c; + t.m10 = u; + t.m11 = _; + t.m12 = d; + t.m13 = p; + t.m14 = m; + t.m15 = f; + return t; + } + static identity(t) { + t.m00 = 1; + t.m01 = 0; + t.m02 = 0; + t.m03 = 0; + t.m04 = 0; + t.m05 = 1; + t.m06 = 0; + t.m07 = 0; + t.m08 = 0; + t.m09 = 0; + t.m10 = 1; + t.m11 = 0; + t.m12 = 0; + t.m13 = 0; + t.m14 = 0; + t.m15 = 1; + return t; + } + static transpose(t, e) { + if (t === e) { + const i = e.m01; + const s = e.m02; + const n = e.m03; + const r = e.m06; + const o = e.m07; + const a = e.m11; + t.m01 = e.m04; + t.m02 = e.m08; + t.m03 = e.m12; + t.m04 = i; + t.m06 = e.m09; + t.m07 = e.m13; + t.m08 = s; + t.m09 = r; + t.m11 = e.m14; + t.m12 = n; + t.m13 = o; + t.m14 = a; + } else { + t.m00 = e.m00; + t.m01 = e.m04; + t.m02 = e.m08; + t.m03 = e.m12; + t.m04 = e.m01; + t.m05 = e.m05; + t.m06 = e.m09; + t.m07 = e.m13; + t.m08 = e.m02; + t.m09 = e.m06; + t.m10 = e.m10; + t.m11 = e.m14; + t.m12 = e.m03; + t.m13 = e.m07; + t.m14 = e.m11; + t.m15 = e.m15; + } + return t; + } + static invert(t, e) { + const i = e.m00; + const s = e.m01; + const n = e.m02; + const r = e.m03; + const o = e.m04; + const a = e.m05; + const l = e.m06; + const h = e.m07; + const c = e.m08; + const u = e.m09; + const _ = e.m10; + const d = e.m11; + const p = e.m12; + const m = e.m13; + const f = e.m14; + const g = e.m15; + const y = i * a - s * o; + const b = i * l - n * o; + const S = i * h - r * o; + const A = s * l - n * a; + const T = s * h - r * a; + const v = n * h - r * l; + const E = c * m - u * p; + const C = c * f - _ * p; + const x = c * g - d * p; + const w = u * f - _ * m; + const R = u * g - d * m; + const I = _ * g - d * f; + let M = y * I - b * R + S * w + A * x - T * C + v * E; + if (0 === M) { + t.m00 = 0; + t.m01 = 0; + t.m02 = 0; + t.m03 = 0; + t.m04 = 0; + t.m05 = 0; + t.m06 = 0; + t.m07 = 0; + t.m08 = 0; + t.m09 = 0; + t.m10 = 0; + t.m11 = 0; + t.m12 = 0; + t.m13 = 0; + t.m14 = 0; + t.m15 = 0; + return t; + } + M = 1 / M; + t.m00 = (a * I - l * R + h * w) * M; + t.m01 = (n * R - s * I - r * w) * M; + t.m02 = (m * v - f * T + g * A) * M; + t.m03 = (_ * T - u * v - d * A) * M; + t.m04 = (l * x - o * I - h * C) * M; + t.m05 = (i * I - n * x + r * C) * M; + t.m06 = (f * S - p * v - g * b) * M; + t.m07 = (c * v - _ * S + d * b) * M; + t.m08 = (o * R - a * x + h * E) * M; + t.m09 = (s * x - i * R - r * E) * M; + t.m10 = (p * T - m * S + g * y) * M; + t.m11 = (u * S - c * T - d * y) * M; + t.m12 = (a * C - o * w - l * E) * M; + t.m13 = (i * w - s * C + n * E) * M; + t.m14 = (m * b - p * A - f * y) * M; + t.m15 = (c * A - u * b + _ * y) * M; + return t; + } + static determinant(t) { + const e = t.m00; + const i = t.m01; + const s = t.m02; + const n = t.m03; + const r = t.m04; + const o = t.m05; + const a = t.m06; + const l = t.m07; + const h = t.m08; + const c = t.m09; + const u = t.m10; + const _ = t.m11; + const d = t.m12; + const p = t.m13; + const m = t.m14; + const f = t.m15; + return (e * o - i * r) * (u * f - _ * m) - (e * a - s * r) * (c * f - _ * p) + (e * l - n * r) * (c * m - u * p) + (i * a - s * o) * (h * f - _ * d) - (i * l - n * o) * (h * m - u * d) + (s * l - n * a) * (h * p - c * d); + } + static multiply(t, e, i) { + const s = e.m00; + const n = e.m01; + const r = e.m02; + const o = e.m03; + const a = e.m04; + const l = e.m05; + const h = e.m06; + const c = e.m07; + const u = e.m08; + const _ = e.m09; + const d = e.m10; + const p = e.m11; + const m = e.m12; + const f = e.m13; + const g = e.m14; + const y = e.m15; + let b = i.m00; + let S = i.m01; + let A = i.m02; + let T = i.m03; + t.m00 = b * s + S * a + A * u + T * m; + t.m01 = b * n + S * l + A * _ + T * f; + t.m02 = b * r + S * h + A * d + T * g; + t.m03 = b * o + S * c + A * p + T * y; + b = i.m04; + S = i.m05; + A = i.m06; + T = i.m07; + t.m04 = b * s + S * a + A * u + T * m; + t.m05 = b * n + S * l + A * _ + T * f; + t.m06 = b * r + S * h + A * d + T * g; + t.m07 = b * o + S * c + A * p + T * y; + b = i.m08; + S = i.m09; + A = i.m10; + T = i.m11; + t.m08 = b * s + S * a + A * u + T * m; + t.m09 = b * n + S * l + A * _ + T * f; + t.m10 = b * r + S * h + A * d + T * g; + t.m11 = b * o + S * c + A * p + T * y; + b = i.m12; + S = i.m13; + A = i.m14; + T = i.m15; + t.m12 = b * s + S * a + A * u + T * m; + t.m13 = b * n + S * l + A * _ + T * f; + t.m14 = b * r + S * h + A * d + T * g; + t.m15 = b * o + S * c + A * p + T * y; + return t; + } + static transform(t, e, i) { + const s = i.x; + const n = i.y; + const r = i.z; + if (e === t) { + t.m12 = e.m00 * s + e.m04 * n + e.m08 * r + e.m12; + t.m13 = e.m01 * s + e.m05 * n + e.m09 * r + e.m13; + t.m14 = e.m02 * s + e.m06 * n + e.m10 * r + e.m14; + t.m15 = e.m03 * s + e.m07 * n + e.m11 * r + e.m15; + } else { + const i = e.m00; + const o = e.m01; + const a = e.m02; + const l = e.m03; + const h = e.m04; + const c = e.m05; + const u = e.m06; + const _ = e.m07; + const d = e.m08; + const p = e.m09; + const m = e.m10; + const f = e.m11; + e.m12; + e.m13; + e.m14; + e.m15; + t.m00 = i; + t.m01 = o; + t.m02 = a; + t.m03 = l; + t.m04 = h; + t.m05 = c; + t.m06 = u; + t.m07 = _; + t.m08 = d; + t.m09 = p; + t.m10 = m; + t.m11 = f; + t.m12 = i * s + h * n + d * r + e.m12; + t.m13 = o * s + c * n + p * r + e.m13; + t.m14 = a * s + u * n + m * r + e.m14; + t.m15 = l * s + _ * n + f * r + e.m15; + } + return t; + } + static translate(t, e, i) { + if (e === t) { + t.m12 += i.x; + t.m13 += i.y; + t.m14 += i.z; + } else { + t.m00 = e.m00; + t.m01 = e.m01; + t.m02 = e.m02; + t.m03 = e.m03; + t.m04 = e.m04; + t.m05 = e.m05; + t.m06 = e.m06; + t.m07 = e.m07; + t.m08 = e.m08; + t.m09 = e.m09; + t.m10 = e.m10; + t.m11 = e.m11; + t.m12 += i.x; + t.m13 += i.y; + t.m14 += i.z; + t.m15 = e.m15; + } + return t; + } + static scale(t, e, i) { + const s = i.x; + const n = i.y; + const r = i.z; + t.m00 = e.m00 * s; + t.m01 = e.m01 * s; + t.m02 = e.m02 * s; + t.m03 = e.m03 * s; + t.m04 = e.m04 * n; + t.m05 = e.m05 * n; + t.m06 = e.m06 * n; + t.m07 = e.m07 * n; + t.m08 = e.m08 * r; + t.m09 = e.m09 * r; + t.m10 = e.m10 * r; + t.m11 = e.m11 * r; + t.m12 = e.m12; + t.m13 = e.m13; + t.m14 = e.m14; + t.m15 = e.m15; + return t; + } + static rotate(t, e, i, s) { + let n = s.x; + let r = s.y; + let o = s.z; + let a = Math.sqrt(n * n + r * r + o * o); + if (Math.abs(a) < hi) return null; + a = 1 / a; + n *= a; + r *= a; + o *= a; + const l = Math.sin(i); + const h = Math.cos(i); + const c = 1 - h; + const u = e.m00; + const _ = e.m01; + const d = e.m02; + const p = e.m03; + const m = e.m04; + const f = e.m05; + const g = e.m06; + const y = e.m07; + const b = e.m08; + const S = e.m09; + const A = e.m10; + const T = e.m11; + const v = n * n * c + h; + const E = r * n * c + o * l; + const C = o * n * c - r * l; + const x = n * r * c - o * l; + const w = r * r * c + h; + const R = o * r * c + n * l; + const I = n * o * c + r * l; + const M = r * o * c - n * l; + const B = o * o * c + h; + t.m00 = u * v + m * E + b * C; + t.m01 = _ * v + f * E + S * C; + t.m02 = d * v + g * E + A * C; + t.m03 = p * v + y * E + T * C; + t.m04 = u * x + m * w + b * R; + t.m05 = _ * x + f * w + S * R; + t.m06 = d * x + g * w + A * R; + t.m07 = p * x + y * w + T * R; + t.m08 = u * I + m * M + b * B; + t.m09 = _ * I + f * M + S * B; + t.m10 = d * I + g * M + A * B; + t.m11 = p * I + y * M + T * B; + if (e !== t) { + t.m12 = e.m12; + t.m13 = e.m13; + t.m14 = e.m14; + t.m15 = e.m15; + } + return t; + } + static rotateX(t, e, i) { + const s = Math.sin(i); + const n = Math.cos(i); + const r = e.m04; + const o = e.m05; + const a = e.m06; + const l = e.m07; + const h = e.m08; + const c = e.m09; + const u = e.m10; + const _ = e.m11; + if (e !== t) { + t.m00 = e.m00; + t.m01 = e.m01; + t.m02 = e.m02; + t.m03 = e.m03; + t.m12 = e.m12; + t.m13 = e.m13; + t.m14 = e.m14; + t.m15 = e.m15; + } + t.m04 = r * n + h * s; + t.m05 = o * n + c * s; + t.m06 = a * n + u * s; + t.m07 = l * n + _ * s; + t.m08 = h * n - r * s; + t.m09 = c * n - o * s; + t.m10 = u * n - a * s; + t.m11 = _ * n - l * s; + return t; + } + static rotateY(t, e, i) { + const s = Math.sin(i); + const n = Math.cos(i); + const r = e.m00; + const o = e.m01; + const a = e.m02; + const l = e.m03; + const h = e.m08; + const c = e.m09; + const u = e.m10; + const _ = e.m11; + if (e !== t) { + t.m04 = e.m04; + t.m05 = e.m05; + t.m06 = e.m06; + t.m07 = e.m07; + t.m12 = e.m12; + t.m13 = e.m13; + t.m14 = e.m14; + t.m15 = e.m15; + } + t.m00 = r * n - h * s; + t.m01 = o * n - c * s; + t.m02 = a * n - u * s; + t.m03 = l * n - _ * s; + t.m08 = r * s + h * n; + t.m09 = o * s + c * n; + t.m10 = a * s + u * n; + t.m11 = l * s + _ * n; + return t; + } + static rotateZ(t, e, i) { + const s = Math.sin(i); + const n = Math.cos(i); + const r = e.m00; + const o = e.m01; + const a = e.m02; + const l = e.m03; + const h = e.m04; + const c = e.m05; + const u = e.m06; + const _ = e.m07; + if (e !== t) { + t.m08 = e.m08; + t.m09 = e.m09; + t.m10 = e.m10; + t.m11 = e.m11; + t.m12 = e.m12; + t.m13 = e.m13; + t.m14 = e.m14; + t.m15 = e.m15; + } + t.m00 = r * n + h * s; + t.m01 = o * n + c * s; + t.m02 = a * n + u * s; + t.m03 = l * n + _ * s; + t.m04 = h * n - r * s; + t.m05 = c * n - o * s; + t.m06 = u * n - a * s; + t.m07 = _ * n - l * s; + return t; + } + static fromTranslation(t, e) { + t.m00 = 1; + t.m01 = 0; + t.m02 = 0; + t.m03 = 0; + t.m04 = 0; + t.m05 = 1; + t.m06 = 0; + t.m07 = 0; + t.m08 = 0; + t.m09 = 0; + t.m10 = 1; + t.m11 = 0; + t.m12 = e.x; + t.m13 = e.y; + t.m14 = e.z; + t.m15 = 1; + return t; + } + static fromScaling(t, e) { + t.m00 = e.x; + t.m01 = 0; + t.m02 = 0; + t.m03 = 0; + t.m04 = 0; + t.m05 = e.y; + t.m06 = 0; + t.m07 = 0; + t.m08 = 0; + t.m09 = 0; + t.m10 = e.z; + t.m11 = 0; + t.m12 = 0; + t.m13 = 0; + t.m14 = 0; + t.m15 = 1; + return t; + } + static fromRotation(t, e, i) { + let s = i.x; + let n = i.y; + let r = i.z; + let o = Math.sqrt(s * s + n * n + r * r); + if (Math.abs(o) < hi) return null; + o = 1 / o; + s *= o; + n *= o; + r *= o; + const a = Math.sin(e); + const l = Math.cos(e); + const h = 1 - l; + t.m00 = s * s * h + l; + t.m01 = n * s * h + r * a; + t.m02 = r * s * h - n * a; + t.m03 = 0; + t.m04 = s * n * h - r * a; + t.m05 = n * n * h + l; + t.m06 = r * n * h + s * a; + t.m07 = 0; + t.m08 = s * r * h + n * a; + t.m09 = n * r * h - s * a; + t.m10 = r * r * h + l; + t.m11 = 0; + t.m12 = 0; + t.m13 = 0; + t.m14 = 0; + t.m15 = 1; + return t; + } + static fromXRotation(t, e) { + const i = Math.sin(e); + const s = Math.cos(e); + t.m00 = 1; + t.m01 = 0; + t.m02 = 0; + t.m03 = 0; + t.m04 = 0; + t.m05 = s; + t.m06 = i; + t.m07 = 0; + t.m08 = 0; + t.m09 = -i; + t.m10 = s; + t.m11 = 0; + t.m12 = 0; + t.m13 = 0; + t.m14 = 0; + t.m15 = 1; + return t; + } + static fromYRotation(t, e) { + const i = Math.sin(e); + const s = Math.cos(e); + t.m00 = s; + t.m01 = 0; + t.m02 = -i; + t.m03 = 0; + t.m04 = 0; + t.m05 = 1; + t.m06 = 0; + t.m07 = 0; + t.m08 = i; + t.m09 = 0; + t.m10 = s; + t.m11 = 0; + t.m12 = 0; + t.m13 = 0; + t.m14 = 0; + t.m15 = 1; + return t; + } + static fromZRotation(t, e) { + const i = Math.sin(e); + const s = Math.cos(e); + t.m00 = s; + t.m01 = i; + t.m02 = 0; + t.m03 = 0; + t.m04 = -i; + t.m05 = s; + t.m06 = 0; + t.m07 = 0; + t.m08 = 0; + t.m09 = 0; + t.m10 = 1; + t.m11 = 0; + t.m12 = 0; + t.m13 = 0; + t.m14 = 0; + t.m15 = 1; + return t; + } + static fromRT(t, e, i) { + const s = e.x; + const n = e.y; + const r = e.z; + const o = e.w; + const a = s + s; + const l = n + n; + const h = r + r; + const c = s * a; + const u = s * l; + const _ = s * h; + const d = n * l; + const p = n * h; + const m = r * h; + const f = o * a; + const g = o * l; + const y = o * h; + t.m00 = 1 - (d + m); + t.m01 = u + y; + t.m02 = _ - g; + t.m03 = 0; + t.m04 = u - y; + t.m05 = 1 - (c + m); + t.m06 = p + f; + t.m07 = 0; + t.m08 = _ + g; + t.m09 = p - f; + t.m10 = 1 - (c + d); + t.m11 = 0; + t.m12 = i.x; + t.m13 = i.y; + t.m14 = i.z; + t.m15 = 1; + return t; + } + static getTranslation(t, e) { + t.x = e.m12; + t.y = e.m13; + t.z = e.m14; + return t; + } + static getScaling(t, e) { + const i = Ji.m00 = e.m00; + const s = Ji.m01 = e.m01; + const n = Ji.m02 = e.m02; + const r = Ji.m03 = e.m04; + const o = Ji.m04 = e.m05; + const a = Ji.m05 = e.m06; + const l = Ji.m06 = e.m08; + const h = Ji.m07 = e.m09; + const c = Ji.m08 = e.m10; + t.x = Math.sqrt(i * i + s * s + n * n); + t.y = Math.sqrt(r * r + o * o + a * a); + t.z = Math.sqrt(l * l + h * h + c * c); + Fi.determinant(Ji) < 0 && (t.x *= -1); + return t; + } + static getRotation(t, e) { + const i = e.m00 + e.m05 + e.m10; + let s = 0; + if (i > 0) { + s = 2 * Math.sqrt(i + 1); + t.w = .25 * s; + t.x = (e.m06 - e.m09) / s; + t.y = (e.m08 - e.m02) / s; + t.z = (e.m01 - e.m04) / s; + } else if (e.m00 > e.m05 && e.m00 > e.m10) { + s = 2 * Math.sqrt(1 + e.m00 - e.m05 - e.m10); + t.w = (e.m06 - e.m09) / s; + t.x = .25 * s; + t.y = (e.m01 + e.m04) / s; + t.z = (e.m08 + e.m02) / s; + } else if (e.m05 > e.m10) { + s = 2 * Math.sqrt(1 + e.m05 - e.m00 - e.m10); + t.w = (e.m08 - e.m02) / s; + t.x = (e.m01 + e.m04) / s; + t.y = .25 * s; + t.z = (e.m06 + e.m09) / s; + } else { + s = 2 * Math.sqrt(1 + e.m10 - e.m00 - e.m05); + t.w = (e.m01 - e.m04) / s; + t.x = (e.m08 + e.m02) / s; + t.y = (e.m06 + e.m09) / s; + t.z = .25 * s; + } + return t; + } + static toRTS(t, e, i, s) { + s.x = Pi.set(Ki, t.m00, t.m01, t.m02).length(); + Ji.m00 = t.m00 / s.x; + Ji.m01 = t.m01 / s.x; + Ji.m02 = t.m02 / s.x; + s.y = Pi.set(Ki, t.m04, t.m05, t.m06).length(); + Ji.m03 = t.m04 / s.y; + Ji.m04 = t.m05 / s.y; + Ji.m05 = t.m06 / s.y; + s.z = Pi.set(Ki, t.m08, t.m09, t.m10).length(); + Ji.m06 = t.m08 / s.z; + Ji.m07 = t.m09 / s.z; + Ji.m08 = t.m10 / s.z; + if (Fi.determinant(Ji) < 0) { + s.x *= -1; + Ji.m00 *= -1; + Ji.m01 *= -1; + Ji.m02 *= -1; + } + Ui.fromMat3(e, Ji); + Pi.set(i, t.m12, t.m13, t.m14); + } + static fromRTS(t, e, i, s) { + const n = e.x; + const r = e.y; + const o = e.z; + const a = e.w; + const l = n + n; + const h = r + r; + const c = o + o; + const u = n * l; + const _ = n * h; + const d = n * c; + const p = r * h; + const m = r * c; + const f = o * c; + const g = a * l; + const y = a * h; + const b = a * c; + const S = s.x; + const A = s.y; + const T = s.z; + t.m00 = (1 - (p + f)) * S; + t.m01 = (_ + b) * S; + t.m02 = (d - y) * S; + t.m03 = 0; + t.m04 = (_ - b) * A; + t.m05 = (1 - (u + f)) * A; + t.m06 = (m + g) * A; + t.m07 = 0; + t.m08 = (d + y) * T; + t.m09 = (m - g) * T; + t.m10 = (1 - (u + p)) * T; + t.m11 = 0; + t.m12 = i.x; + t.m13 = i.y; + t.m14 = i.z; + t.m15 = 1; + return t; + } + static fromRTSOrigin(t, e, i, s, n) { + const r = e.x; + const o = e.y; + const a = e.z; + const l = e.w; + const h = r + r; + const c = o + o; + const u = a + a; + const _ = r * h; + const d = r * c; + const p = r * u; + const m = o * c; + const f = o * u; + const g = a * u; + const y = l * h; + const b = l * c; + const S = l * u; + const A = s.x; + const T = s.y; + const v = s.z; + const E = n.x; + const C = n.y; + const x = n.z; + t.m00 = (1 - (m + g)) * A; + t.m01 = (d + S) * A; + t.m02 = (p - b) * A; + t.m03 = 0; + t.m04 = (d - S) * T; + t.m05 = (1 - (_ + g)) * T; + t.m06 = (f + y) * T; + t.m07 = 0; + t.m08 = (p + b) * v; + t.m09 = (f - y) * v; + t.m10 = (1 - (_ + m)) * v; + t.m11 = 0; + t.m12 = i.x + E - (t.m00 * E + t.m04 * C + t.m08 * x); + t.m13 = i.y + C - (t.m01 * E + t.m05 * C + t.m09 * x); + t.m14 = i.z + x - (t.m02 * E + t.m06 * C + t.m10 * x); + t.m15 = 1; + return t; + } + static fromQuat(t, e) { + const i = e.x; + const s = e.y; + const n = e.z; + const r = e.w; + const o = i + i; + const a = s + s; + const l = n + n; + const h = i * o; + const c = s * o; + const u = s * a; + const _ = n * o; + const d = n * a; + const p = n * l; + const m = r * o; + const f = r * a; + const g = r * l; + t.m00 = 1 - u - p; + t.m01 = c + g; + t.m02 = _ - f; + t.m03 = 0; + t.m04 = c - g; + t.m05 = 1 - h - p; + t.m06 = d + m; + t.m07 = 0; + t.m08 = _ + f; + t.m09 = d - m; + t.m10 = 1 - h - u; + t.m11 = 0; + t.m12 = 0; + t.m13 = 0; + t.m14 = 0; + t.m15 = 1; + return t; + } + static frustum(t, e, i, s, n, r, o) { + const a = 1 / (i - e); + const l = 1 / (n - s); + const h = 1 / (r - o); + t.m00 = 2 * r * a; + t.m01 = 0; + t.m02 = 0; + t.m03 = 0; + t.m04 = 0; + t.m05 = 2 * r * l; + t.m06 = 0; + t.m07 = 0; + t.m08 = (i + e) * a; + t.m09 = (n + s) * l; + t.m10 = (o + r) * h; + t.m11 = -1; + t.m12 = 0; + t.m13 = 0; + t.m14 = o * r * 2 * h; + t.m15 = 0; + return t; + } + static perspective(t, e, i, s, n, r = !0, o = -1, a = 1, l = 0) { + const h = 1 / Math.tan(e / 2); + const c = 1 / (s - n); + const u = r ? h / i : h; + const _ = (r ? h : h * i) * a; + const d = Yi[l]; + t.m00 = u * d[0]; + t.m01 = u * d[1]; + t.m02 = 0; + t.m03 = 0; + t.m04 = _ * d[2]; + t.m05 = _ * d[3]; + t.m06 = 0; + t.m07 = 0; + t.m08 = 0; + t.m09 = 0; + t.m10 = (n - o * s) * c; + t.m11 = -1; + t.m12 = 0; + t.m13 = 0; + t.m14 = n * s * c * (1 - o); + t.m15 = 0; + return t; + } + static ortho(t, e, i, s, n, r, o, a = -1, l = 1, h = 0) { + const c = 1 / (e - i); + const u = 1 / (s - n) * l; + const _ = 1 / (r - o); + const d = -2 * c; + const p = -2 * u; + const m = (e + i) * c; + const f = (n + s) * u; + const g = Yi[h]; + t.m00 = d * g[0]; + t.m01 = d * g[1]; + t.m02 = 0; + t.m03 = 0; + t.m04 = p * g[2]; + t.m05 = p * g[3]; + t.m06 = 0; + t.m07 = 0; + t.m08 = 0; + t.m09 = 0; + t.m10 = _ * (1 - a); + t.m11 = 0; + t.m12 = m * g[0] + f * g[2]; + t.m13 = m * g[1] + f * g[3]; + t.m14 = (r - a * o) * _; + t.m15 = 1; + return t; + } + static lookAt(t, e, i, s) { + const n = e.x; + const r = e.y; + const o = e.z; + const a = s.x; + const l = s.y; + const h = s.z; + let c = n - i.x; + let u = r - i.y; + let _ = o - i.z; + let d = 1 / Math.sqrt(c * c + u * u + _ * _); + c *= d; + u *= d; + _ *= d; + let p = l * _ - h * u; + let m = h * c - a * _; + let f = a * u - l * c; + d = 1 / Math.sqrt(p * p + m * m + f * f); + p *= d; + m *= d; + f *= d; + const g = u * f - _ * m; + const y = _ * p - c * f; + const b = c * m - u * p; + t.m00 = p; + t.m01 = g; + t.m02 = c; + t.m03 = 0; + t.m04 = m; + t.m05 = y; + t.m06 = u; + t.m07 = 0; + t.m08 = f; + t.m09 = b; + t.m10 = _; + t.m11 = 0; + t.m12 = -(p * n + m * r + f * o); + t.m13 = -(g * n + y * r + b * o); + t.m14 = -(c * n + u * r + _ * o); + t.m15 = 1; + return t; + } + static inverseTranspose(t, e) { + const i = e.m00; + const s = e.m01; + const n = e.m02; + const r = e.m03; + const o = e.m04; + const a = e.m05; + const l = e.m06; + const h = e.m07; + const c = e.m08; + const u = e.m09; + const _ = e.m10; + const d = e.m11; + const p = e.m12; + const m = e.m13; + const f = e.m14; + const g = e.m15; + const y = i * a - s * o; + const b = i * l - n * o; + const S = i * h - r * o; + const A = s * l - n * a; + const T = s * h - r * a; + const v = n * h - r * l; + const E = c * m - u * p; + const C = c * f - _ * p; + const x = c * g - d * p; + const w = u * f - _ * m; + const R = u * g - d * m; + const I = _ * g - d * f; + let M = y * I - b * R + S * w + A * x - T * C + v * E; + if (!M) return null; + M = 1 / M; + t.m00 = (a * I - l * R + h * w) * M; + t.m01 = (l * x - o * I - h * C) * M; + t.m02 = (o * R - a * x + h * E) * M; + t.m03 = 0; + t.m04 = (n * R - s * I - r * w) * M; + t.m05 = (i * I - n * x + r * C) * M; + t.m06 = (s * x - i * R - r * E) * M; + t.m07 = 0; + t.m08 = (m * v - f * T + g * A) * M; + t.m09 = (f * S - p * v - g * b) * M; + t.m10 = (p * T - m * S + g * y) * M; + t.m11 = 0; + t.m12 = 0; + t.m13 = 0; + t.m14 = 0; + t.m15 = 1; + return t; + } + static toArray(t, e, i = 0) { + t[i + 0] = e.m00; + t[i + 1] = e.m01; + t[i + 2] = e.m02; + t[i + 3] = e.m03; + t[i + 4] = e.m04; + t[i + 5] = e.m05; + t[i + 6] = e.m06; + t[i + 7] = e.m07; + t[i + 8] = e.m08; + t[i + 9] = e.m09; + t[i + 10] = e.m10; + t[i + 11] = e.m11; + t[i + 12] = e.m12; + t[i + 13] = e.m13; + t[i + 14] = e.m14; + t[i + 15] = e.m15; + return t; + } + static fromArray(t, e, i = 0) { + t.m00 = e[i + 0]; + t.m01 = e[i + 1]; + t.m02 = e[i + 2]; + t.m03 = e[i + 3]; + t.m04 = e[i + 4]; + t.m05 = e[i + 5]; + t.m06 = e[i + 6]; + t.m07 = e[i + 7]; + t.m08 = e[i + 8]; + t.m09 = e[i + 9]; + t.m10 = e[i + 10]; + t.m11 = e[i + 11]; + t.m12 = e[i + 12]; + t.m13 = e[i + 13]; + t.m14 = e[i + 14]; + t.m15 = e[i + 15]; + return t; + } + static add(t, e, i) { + t.m00 = e.m00 + i.m00; + t.m01 = e.m01 + i.m01; + t.m02 = e.m02 + i.m02; + t.m03 = e.m03 + i.m03; + t.m04 = e.m04 + i.m04; + t.m05 = e.m05 + i.m05; + t.m06 = e.m06 + i.m06; + t.m07 = e.m07 + i.m07; + t.m08 = e.m08 + i.m08; + t.m09 = e.m09 + i.m09; + t.m10 = e.m10 + i.m10; + t.m11 = e.m11 + i.m11; + t.m12 = e.m12 + i.m12; + t.m13 = e.m13 + i.m13; + t.m14 = e.m14 + i.m14; + t.m15 = e.m15 + i.m15; + return t; + } + static subtract(t, e, i) { + t.m00 = e.m00 - i.m00; + t.m01 = e.m01 - i.m01; + t.m02 = e.m02 - i.m02; + t.m03 = e.m03 - i.m03; + t.m04 = e.m04 - i.m04; + t.m05 = e.m05 - i.m05; + t.m06 = e.m06 - i.m06; + t.m07 = e.m07 - i.m07; + t.m08 = e.m08 - i.m08; + t.m09 = e.m09 - i.m09; + t.m10 = e.m10 - i.m10; + t.m11 = e.m11 - i.m11; + t.m12 = e.m12 - i.m12; + t.m13 = e.m13 - i.m13; + t.m14 = e.m14 - i.m14; + t.m15 = e.m15 - i.m15; + return t; + } + static multiplyScalar(t, e, i) { + t.m00 = e.m00 * i; + t.m01 = e.m01 * i; + t.m02 = e.m02 * i; + t.m03 = e.m03 * i; + t.m04 = e.m04 * i; + t.m05 = e.m05 * i; + t.m06 = e.m06 * i; + t.m07 = e.m07 * i; + t.m08 = e.m08 * i; + t.m09 = e.m09 * i; + t.m10 = e.m10 * i; + t.m11 = e.m11 * i; + t.m12 = e.m12 * i; + t.m13 = e.m13 * i; + t.m14 = e.m14 * i; + t.m15 = e.m15 * i; + return t; + } + static multiplyScalarAndAdd(t, e, i, s) { + t.m00 = e.m00 + i.m00 * s; + t.m01 = e.m01 + i.m01 * s; + t.m02 = e.m02 + i.m02 * s; + t.m03 = e.m03 + i.m03 * s; + t.m04 = e.m04 + i.m04 * s; + t.m05 = e.m05 + i.m05 * s; + t.m06 = e.m06 + i.m06 * s; + t.m07 = e.m07 + i.m07 * s; + t.m08 = e.m08 + i.m08 * s; + t.m09 = e.m09 + i.m09 * s; + t.m10 = e.m10 + i.m10 * s; + t.m11 = e.m11 + i.m11 * s; + t.m12 = e.m12 + i.m12 * s; + t.m13 = e.m13 + i.m13 * s; + t.m14 = e.m14 + i.m14 * s; + t.m15 = e.m15 + i.m15 * s; + return t; + } + static strictEquals(t, e) { + return t.m00 === e.m00 && t.m01 === e.m01 && t.m02 === e.m02 && t.m03 === e.m03 && t.m04 === e.m04 && t.m05 === e.m05 && t.m06 === e.m06 && t.m07 === e.m07 && t.m08 === e.m08 && t.m09 === e.m09 && t.m10 === e.m10 && t.m11 === e.m11 && t.m12 === e.m12 && t.m13 === e.m13 && t.m14 === e.m14 && t.m15 === e.m15; + } + static equals(t, e, i = hi) { + return Math.abs(t.m00 - e.m00) <= i * Math.max(1, Math.abs(t.m00), Math.abs(e.m00)) && Math.abs(t.m01 - e.m01) <= i * Math.max(1, Math.abs(t.m01), Math.abs(e.m01)) && Math.abs(t.m02 - e.m02) <= i * Math.max(1, Math.abs(t.m02), Math.abs(e.m02)) && Math.abs(t.m03 - e.m03) <= i * Math.max(1, Math.abs(t.m03), Math.abs(e.m03)) && Math.abs(t.m04 - e.m04) <= i * Math.max(1, Math.abs(t.m04), Math.abs(e.m04)) && Math.abs(t.m05 - e.m05) <= i * Math.max(1, Math.abs(t.m05), Math.abs(e.m05)) && Math.abs(t.m06 - e.m06) <= i * Math.max(1, Math.abs(t.m06), Math.abs(e.m06)) && Math.abs(t.m07 - e.m07) <= i * Math.max(1, Math.abs(t.m07), Math.abs(e.m07)) && Math.abs(t.m08 - e.m08) <= i * Math.max(1, Math.abs(t.m08), Math.abs(e.m08)) && Math.abs(t.m09 - e.m09) <= i * Math.max(1, Math.abs(t.m09), Math.abs(e.m09)) && Math.abs(t.m10 - e.m10) <= i * Math.max(1, Math.abs(t.m10), Math.abs(e.m10)) && Math.abs(t.m11 - e.m11) <= i * Math.max(1, Math.abs(t.m11), Math.abs(e.m11)) && Math.abs(t.m12 - e.m12) <= i * Math.max(1, Math.abs(t.m12), Math.abs(e.m12)) && Math.abs(t.m13 - e.m13) <= i * Math.max(1, Math.abs(t.m13), Math.abs(e.m13)) && Math.abs(t.m14 - e.m14) <= i * Math.max(1, Math.abs(t.m14), Math.abs(e.m14)) && Math.abs(t.m15 - e.m15) <= i * Math.max(1, Math.abs(t.m15), Math.abs(e.m15)); + } + constructor(t = 1, e = 0, i = 0, s = 0, n = 0, r = 1, o = 0, a = 0, l = 0, h = 0, c = 1, u = 0, _ = 0, d = 0, p = 0, m = 1) { + super(); + this.m00 = void 0; + this.m01 = void 0; + this.m02 = void 0; + this.m03 = void 0; + this.m04 = void 0; + this.m05 = void 0; + this.m06 = void 0; + this.m07 = void 0; + this.m08 = void 0; + this.m09 = void 0; + this.m10 = void 0; + this.m11 = void 0; + this.m12 = void 0; + this.m13 = void 0; + this.m14 = void 0; + this.m15 = void 0; + if ("object" == typeof t) { + this.m00 = t.m00; + this.m01 = t.m01; + this.m02 = t.m02; + this.m03 = t.m03; + this.m04 = t.m04; + this.m05 = t.m05; + this.m06 = t.m06; + this.m07 = t.m07; + this.m08 = t.m08; + this.m09 = t.m09; + this.m10 = t.m10; + this.m11 = t.m11; + this.m12 = t.m12; + this.m13 = t.m13; + this.m14 = t.m14; + this.m15 = t.m15; + } else { + this.m00 = t; + this.m01 = e; + this.m02 = i; + this.m03 = s; + this.m04 = n; + this.m05 = r; + this.m06 = o; + this.m07 = a; + this.m08 = l; + this.m09 = h; + this.m10 = c; + this.m11 = u; + this.m12 = _; + this.m13 = d; + this.m14 = p; + this.m15 = m; + } + } + clone() { + return new qi(this.m00, this.m01, this.m02, this.m03, this.m04, this.m05, this.m06, this.m07, this.m08, this.m09, this.m10, this.m11, this.m12, this.m13, this.m14, this.m15); + } + set(t = 1, e = 0, i = 0, s = 0, n = 0, r = 1, o = 0, a = 0, l = 0, h = 0, c = 1, u = 0, _ = 0, d = 0, p = 0, m = 1) { + if ("object" == typeof t) { + this.m01 = t.m01; + this.m02 = t.m02; + this.m03 = t.m03; + this.m04 = t.m04; + this.m05 = t.m05; + this.m06 = t.m06; + this.m07 = t.m07; + this.m08 = t.m08; + this.m09 = t.m09; + this.m10 = t.m10; + this.m11 = t.m11; + this.m12 = t.m12; + this.m13 = t.m13; + this.m14 = t.m14; + this.m15 = t.m15; + this.m00 = t.m00; + } else { + this.m01 = e; + this.m02 = i; + this.m03 = s; + this.m04 = n; + this.m05 = r; + this.m06 = o; + this.m07 = a; + this.m08 = l; + this.m09 = h; + this.m10 = c; + this.m11 = u; + this.m12 = _; + this.m13 = d; + this.m14 = p; + this.m15 = m; + this.m00 = t; + } + return this; + } + equals(t, e = hi) { + return Math.abs(this.m00 - t.m00) <= e * Math.max(1, Math.abs(this.m00), Math.abs(t.m00)) && Math.abs(this.m01 - t.m01) <= e * Math.max(1, Math.abs(this.m01), Math.abs(t.m01)) && Math.abs(this.m02 - t.m02) <= e * Math.max(1, Math.abs(this.m02), Math.abs(t.m02)) && Math.abs(this.m03 - t.m03) <= e * Math.max(1, Math.abs(this.m03), Math.abs(t.m03)) && Math.abs(this.m04 - t.m04) <= e * Math.max(1, Math.abs(this.m04), Math.abs(t.m04)) && Math.abs(this.m05 - t.m05) <= e * Math.max(1, Math.abs(this.m05), Math.abs(t.m05)) && Math.abs(this.m06 - t.m06) <= e * Math.max(1, Math.abs(this.m06), Math.abs(t.m06)) && Math.abs(this.m07 - t.m07) <= e * Math.max(1, Math.abs(this.m07), Math.abs(t.m07)) && Math.abs(this.m08 - t.m08) <= e * Math.max(1, Math.abs(this.m08), Math.abs(t.m08)) && Math.abs(this.m09 - t.m09) <= e * Math.max(1, Math.abs(this.m09), Math.abs(t.m09)) && Math.abs(this.m10 - t.m10) <= e * Math.max(1, Math.abs(this.m10), Math.abs(t.m10)) && Math.abs(this.m11 - t.m11) <= e * Math.max(1, Math.abs(this.m11), Math.abs(t.m11)) && Math.abs(this.m12 - t.m12) <= e * Math.max(1, Math.abs(this.m12), Math.abs(t.m12)) && Math.abs(this.m13 - t.m13) <= e * Math.max(1, Math.abs(this.m13), Math.abs(t.m13)) && Math.abs(this.m14 - t.m14) <= e * Math.max(1, Math.abs(this.m14), Math.abs(t.m14)) && Math.abs(this.m15 - t.m15) <= e * Math.max(1, Math.abs(this.m15), Math.abs(t.m15)); + } + strictEquals(t) { + return this.m00 === t.m00 && this.m01 === t.m01 && this.m02 === t.m02 && this.m03 === t.m03 && this.m04 === t.m04 && this.m05 === t.m05 && this.m06 === t.m06 && this.m07 === t.m07 && this.m08 === t.m08 && this.m09 === t.m09 && this.m10 === t.m10 && this.m11 === t.m11 && this.m12 === t.m12 && this.m13 === t.m13 && this.m14 === t.m14 && this.m15 === t.m15; + } + toString() { + return `[\n${this.m00}, ${this.m01}, ${this.m02}, ${this.m03},\n${this.m04}, ${this.m05}, ${this.m06}, ${this.m07},\n${this.m08}, ${this.m09}, ${this.m10}, ${this.m11},\n${this.m12}, ${this.m13}, ${this.m14}, ${this.m15}\n]`; + } + identity() { + this.m00 = 1; + this.m01 = 0; + this.m02 = 0; + this.m03 = 0; + this.m04 = 0; + this.m05 = 1; + this.m06 = 0; + this.m07 = 0; + this.m08 = 0; + this.m09 = 0; + this.m10 = 1; + this.m11 = 0; + this.m12 = 0; + this.m13 = 0; + this.m14 = 0; + this.m15 = 1; + return this; + } + zero() { + this.m00 = 0; + this.m01 = 0; + this.m02 = 0; + this.m03 = 0; + this.m04 = 0; + this.m05 = 0; + this.m06 = 0; + this.m07 = 0; + this.m08 = 0; + this.m09 = 0; + this.m10 = 0; + this.m11 = 0; + this.m12 = 0; + this.m13 = 0; + this.m14 = 0; + this.m15 = 0; + return this; + } + transpose() { + const t = this.m01; + const e = this.m02; + const i = this.m03; + const s = this.m06; + const n = this.m07; + const r = this.m11; + this.m01 = this.m04; + this.m02 = this.m08; + this.m03 = this.m12; + this.m04 = t; + this.m06 = this.m09; + this.m07 = this.m13; + this.m08 = e; + this.m09 = s; + this.m11 = this.m14; + this.m12 = i; + this.m13 = n; + this.m14 = r; + return this; + } + invert() { + const t = this.m00; + const e = this.m01; + const i = this.m02; + const s = this.m03; + const n = this.m04; + const r = this.m05; + const o = this.m06; + const a = this.m07; + const l = this.m08; + const h = this.m09; + const c = this.m10; + const u = this.m11; + const _ = this.m12; + const d = this.m13; + const p = this.m14; + const m = this.m15; + const f = t * r - e * n; + const g = t * o - i * n; + const y = t * a - s * n; + const b = e * o - i * r; + const S = e * a - s * r; + const A = i * a - s * o; + const T = l * d - h * _; + const v = l * p - c * _; + const E = l * m - u * _; + const C = h * p - c * d; + const x = h * m - u * d; + const w = c * m - u * p; + let R = f * w - g * x + y * C + b * E - S * v + A * T; + if (0 === R) { + this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + return this; + } + R = 1 / R; + this.m00 = (r * w - o * x + a * C) * R; + this.m01 = (i * x - e * w - s * C) * R; + this.m02 = (d * A - p * S + m * b) * R; + this.m03 = (c * S - h * A - u * b) * R; + this.m04 = (o * E - n * w - a * v) * R; + this.m05 = (t * w - i * E + s * v) * R; + this.m06 = (p * y - _ * A - m * g) * R; + this.m07 = (l * A - c * y + u * g) * R; + this.m08 = (n * x - r * E + a * T) * R; + this.m09 = (e * E - t * x - s * T) * R; + this.m10 = (_ * S - d * y + m * f) * R; + this.m11 = (h * y - l * S - u * f) * R; + this.m12 = (r * v - n * C - o * T) * R; + this.m13 = (t * C - e * v + i * T) * R; + this.m14 = (d * g - _ * b - p * f) * R; + this.m15 = (l * b - h * g + c * f) * R; + return this; + } + determinant() { + const t = this.m00; + const e = this.m01; + const i = this.m02; + const s = this.m03; + const n = this.m04; + const r = this.m05; + const o = this.m06; + const a = this.m07; + const l = this.m08; + const h = this.m09; + const c = this.m10; + const u = this.m11; + const _ = this.m12; + const d = this.m13; + const p = this.m14; + const m = this.m15; + return (t * r - e * n) * (c * m - u * p) - (t * o - i * n) * (h * m - u * d) + (t * a - s * n) * (h * p - c * d) + (e * o - i * r) * (l * m - u * _) - (e * a - s * r) * (l * p - c * _) + (i * a - s * o) * (l * d - h * _); + } + add(t) { + this.m00 += t.m00; + this.m01 += t.m01; + this.m02 += t.m02; + this.m03 += t.m03; + this.m04 += t.m04; + this.m05 += t.m05; + this.m06 += t.m06; + this.m07 += t.m07; + this.m08 += t.m08; + this.m09 += t.m09; + this.m10 += t.m10; + this.m11 += t.m11; + this.m12 += t.m12; + this.m13 += t.m13; + this.m14 += t.m14; + this.m15 += t.m15; + return this; + } + subtract(t) { + this.m00 -= t.m00; + this.m01 -= t.m01; + this.m02 -= t.m02; + this.m03 -= t.m03; + this.m04 -= t.m04; + this.m05 -= t.m05; + this.m06 -= t.m06; + this.m07 -= t.m07; + this.m08 -= t.m08; + this.m09 -= t.m09; + this.m10 -= t.m10; + this.m11 -= t.m11; + this.m12 -= t.m12; + this.m13 -= t.m13; + this.m14 -= t.m14; + this.m15 -= t.m15; + return this; + } + multiply(t) { + const e = this.m00; + const i = this.m01; + const s = this.m02; + const n = this.m03; + const r = this.m04; + const o = this.m05; + const a = this.m06; + const l = this.m07; + const h = this.m08; + const c = this.m09; + const u = this.m10; + const _ = this.m11; + const d = this.m12; + const p = this.m13; + const m = this.m14; + const f = this.m15; + let g = t.m00; + let y = t.m01; + let b = t.m02; + let S = t.m03; + this.m00 = g * e + y * r + b * h + S * d; + this.m01 = g * i + y * o + b * c + S * p; + this.m02 = g * s + y * a + b * u + S * m; + this.m03 = g * n + y * l + b * _ + S * f; + g = t.m04; + y = t.m05; + b = t.m06; + S = t.m07; + this.m04 = g * e + y * r + b * h + S * d; + this.m05 = g * i + y * o + b * c + S * p; + this.m06 = g * s + y * a + b * u + S * m; + this.m07 = g * n + y * l + b * _ + S * f; + g = t.m08; + y = t.m09; + b = t.m10; + S = t.m11; + this.m08 = g * e + y * r + b * h + S * d; + this.m09 = g * i + y * o + b * c + S * p; + this.m10 = g * s + y * a + b * u + S * m; + this.m11 = g * n + y * l + b * _ + S * f; + g = t.m12; + y = t.m13; + b = t.m14; + S = t.m15; + this.m12 = g * e + y * r + b * h + S * d; + this.m13 = g * i + y * o + b * c + S * p; + this.m14 = g * s + y * a + b * u + S * m; + this.m15 = g * n + y * l + b * _ + S * f; + return this; + } + multiplyScalar(t) { + this.m00 *= t; + this.m01 *= t; + this.m02 *= t; + this.m03 *= t; + this.m04 *= t; + this.m05 *= t; + this.m06 *= t; + this.m07 *= t; + this.m08 *= t; + this.m09 *= t; + this.m10 *= t; + this.m11 *= t; + this.m12 *= t; + this.m13 *= t; + this.m14 *= t; + this.m15 *= t; + return this; + } + translate(t) { + this.m12 += t.x; + this.m13 += t.y; + this.m14 += t.z; + return this; + } + scale(t) { + const e = t.x; + const i = t.y; + const s = t.z; + this.m00 *= e; + this.m01 *= e; + this.m02 *= e; + this.m03 *= e; + this.m04 *= i; + this.m05 *= i; + this.m06 *= i; + this.m07 *= i; + this.m08 *= s; + this.m09 *= s; + this.m10 *= s; + this.m11 *= s; + return this; + } + rotate(t, e) { + let i = e.x; + let s = e.y; + let n = e.z; + let r = Math.sqrt(i * i + s * s + n * n); + if (Math.abs(r) < hi) return null; + r = 1 / r; + i *= r; + s *= r; + n *= r; + const o = Math.sin(t); + const a = Math.cos(t); + const l = 1 - a; + const h = this.m00; + const c = this.m01; + const u = this.m02; + const _ = this.m03; + const d = this.m04; + const p = this.m05; + const m = this.m06; + const f = this.m07; + const g = this.m08; + const y = this.m09; + const b = this.m10; + const S = this.m11; + const A = i * i * l + a; + const T = s * i * l + n * o; + const v = n * i * l - s * o; + const E = i * s * l - n * o; + const C = s * s * l + a; + const x = n * s * l + i * o; + const w = i * n * l + s * o; + const R = s * n * l - i * o; + const I = n * n * l + a; + this.m00 = h * A + d * T + g * v; + this.m01 = c * A + p * T + y * v; + this.m02 = u * A + m * T + b * v; + this.m03 = _ * A + f * T + S * v; + this.m04 = h * E + d * C + g * x; + this.m05 = c * E + p * C + y * x; + this.m06 = u * E + m * C + b * x; + this.m07 = _ * E + f * C + S * x; + this.m08 = h * w + d * R + g * I; + this.m09 = c * w + p * R + y * I; + this.m10 = u * w + m * R + b * I; + this.m11 = _ * w + f * R + S * I; + return this; + } + getTranslation(t) { + t.x = this.m12; + t.y = this.m13; + t.z = this.m14; + return t; + } + getScale(t) { + const e = Ji.m00 = this.m00; + const i = Ji.m01 = this.m01; + const s = Ji.m02 = this.m02; + const n = Ji.m03 = this.m04; + const r = Ji.m04 = this.m05; + const o = Ji.m05 = this.m06; + const a = Ji.m06 = this.m08; + const l = Ji.m07 = this.m09; + const h = Ji.m08 = this.m10; + t.x = Math.sqrt(e * e + i * i + s * s); + t.y = Math.sqrt(n * n + r * r + o * o); + t.z = Math.sqrt(a * a + l * l + h * h); + Fi.determinant(Ji) < 0 && (t.x *= -1); + return t; + } + getRotation(t) { + const e = this.m00 + this.m05 + this.m10; + let i = 0; + if (e > 0) { + i = 2 * Math.sqrt(e + 1); + t.w = .25 * i; + t.x = (this.m06 - this.m09) / i; + t.y = (this.m08 - this.m02) / i; + t.z = (this.m01 - this.m04) / i; + } else if (this.m00 > this.m05 && this.m00 > this.m10) { + i = 2 * Math.sqrt(1 + this.m00 - this.m05 - this.m10); + t.w = (this.m06 - this.m09) / i; + t.x = .25 * i; + t.y = (this.m01 + this.m04) / i; + t.z = (this.m08 + this.m02) / i; + } else if (this.m05 > this.m10) { + i = 2 * Math.sqrt(1 + this.m05 - this.m00 - this.m10); + t.w = (this.m08 - this.m02) / i; + t.x = (this.m01 + this.m04) / i; + t.y = .25 * i; + t.z = (this.m06 + this.m09) / i; + } else { + i = 2 * Math.sqrt(1 + this.m10 - this.m00 - this.m05); + t.w = (this.m01 - this.m04) / i; + t.x = (this.m08 + this.m02) / i; + t.y = (this.m06 + this.m09) / i; + t.z = .25 * i; + } + return t; + } + fromRTS(t, e, i) { + const s = t.x; + const n = t.y; + const r = t.z; + const o = t.w; + const a = s + s; + const l = n + n; + const h = r + r; + const c = s * a; + const u = s * l; + const _ = s * h; + const d = n * l; + const p = n * h; + const m = r * h; + const f = o * a; + const g = o * l; + const y = o * h; + const b = i.x; + const S = i.y; + const A = i.z; + this.m00 = (1 - (d + m)) * b; + this.m01 = (u + y) * b; + this.m02 = (_ - g) * b; + this.m03 = 0; + this.m04 = (u - y) * S; + this.m05 = (1 - (c + m)) * S; + this.m06 = (p + f) * S; + this.m07 = 0; + this.m08 = (_ + g) * A; + this.m09 = (p - f) * A; + this.m10 = (1 - (c + d)) * A; + this.m11 = 0; + this.m12 = e.x; + this.m13 = e.y; + this.m14 = e.z; + this.m15 = 1; + return this; + } + fromQuat(t) { + const e = t.x; + const i = t.y; + const s = t.z; + const n = t.w; + const r = e + e; + const o = i + i; + const a = s + s; + const l = e * r; + const h = i * r; + const c = i * o; + const u = s * r; + const _ = s * o; + const d = s * a; + const p = n * r; + const m = n * o; + const f = n * a; + this.m00 = 1 - c - d; + this.m01 = h + f; + this.m02 = u - m; + this.m03 = 0; + this.m04 = h - f; + this.m05 = 1 - l - d; + this.m06 = _ + p; + this.m07 = 0; + this.m08 = u + m; + this.m09 = _ - p; + this.m10 = 1 - l - c; + this.m11 = 0; + this.m12 = 0; + this.m13 = 0; + this.m14 = 0; + this.m15 = 1; + return this; + } + } + t("Mat4", qi); + qi.IDENTITY = Object.freeze(new qi); + const Ki = new Pi; + const Ji = new Fi; + si.fastDefine("cc.Mat4", qi, { + m00: 1, + m01: 0, + m02: 0, + m03: 0, + m04: 0, + m05: 1, + m06: 0, + m07: 0, + m08: 0, + m09: 0, + m10: 1, + m11: 0, + m12: 0, + m13: 0, + m14: 0, + m15: 1 + }); + m.Mat4 = qi; + function Zi(t, e, i, s, n, r, o, a, l, h, c, u, _, d, p, m) { + return new qi(t, e, i, s, n, r, o, a, l, h, c, u, _, d, p, m); + } + m.mat4 = Zi; + class Qi extends ce { + static clone(t) { + return new Qi(t.x, t.y); + } + static copy(t, e) { + t.x = e.x; + t.y = e.y; + return t; + } + static set(t, e, i) { + t.x = e; + t.y = i; + return t; + } + static add(t, e, i) { + t.x = e.x + i.x; + t.y = e.y + i.y; + return t; + } + static subtract(t, e, i) { + t.x = e.x - i.x; + t.y = e.y - i.y; + return t; + } + static multiply(t, e, i) { + t.x = e.x * i.x; + t.y = e.y * i.y; + return t; + } + static divide(t, e, i) { + t.x = e.x / i.x; + t.y = e.y / i.y; + return t; + } + static ceil(t, e) { + t.x = Math.ceil(e.x); + t.y = Math.ceil(e.y); + return t; + } + static floor(t, e) { + t.x = Math.floor(e.x); + t.y = Math.floor(e.y); + return t; + } + static min(t, e, i) { + t.x = Math.min(e.x, i.x); + t.y = Math.min(e.y, i.y); + return t; + } + static max(t, e, i) { + t.x = Math.max(e.x, i.x); + t.y = Math.max(e.y, i.y); + return t; + } + static round(t, e) { + t.x = Math.round(e.x); + t.y = Math.round(e.y); + return t; + } + static multiplyScalar(t, e, i) { + t.x = e.x * i; + t.y = e.y * i; + return t; + } + static scaleAndAdd(t, e, i, s) { + t.x = e.x + i.x * s; + t.y = e.y + i.y * s; + return t; + } + static distance(t, e) { + const i = e.x - t.x; + const s = e.y - t.y; + return Math.sqrt(i * i + s * s); + } + static squaredDistance(t, e) { + const i = e.x - t.x; + const s = e.y - t.y; + return i * i + s * s; + } + static len(t) { + const e = t.x; + const i = t.y; + return Math.sqrt(e * e + i * i); + } + static lengthSqr(t) { + const e = t.x; + const i = t.y; + return e * e + i * i; + } + static negate(t, e) { + t.x = -e.x; + t.y = -e.y; + return t; + } + static inverse(t, e) { + t.x = 1 / e.x; + t.y = 1 / e.y; + return t; + } + static inverseSafe(t, e) { + const i = e.x; + const s = e.y; + Math.abs(i) < hi ? t.x = 0 : t.x = 1 / i; + Math.abs(s) < hi ? t.y = 0 : t.y = 1 / s; + return t; + } + static normalize(t, e) { + const i = e.x; + const s = e.y; + let n = i * i + s * s; + if (n > 0) { + n = 1 / Math.sqrt(n); + t.x = i * n; + t.y = s * n; + } + return t; + } + static dot(t, e) { + return t.x * e.x + t.y * e.y; + } + static cross(t, e, i) { + if (t instanceof Pi) { + t.x = t.y = 0; + t.z = e.x * i.y - e.y * i.x; + return t; + } + return t.x * e.y - t.y * e.x; + } + static lerp(t, e, i, s) { + const n = e.x; + const r = e.y; + t.x = n + s * (i.x - n); + t.y = r + s * (i.y - r); + return t; + } + static random(t, e) { + e = e || 1; + const i = 2 * gi() * Math.PI; + t.x = Math.cos(i) * e; + t.y = Math.sin(i) * e; + return t; + } + static transformMat3(t, e, i) { + const s = e.x; + const n = e.y; + t.x = i.m00 * s + i.m03 * n + i.m06; + t.y = i.m01 * s + i.m04 * n + i.m07; + return t; + } + static transformMat4(t, e, i) { + const s = e.x; + const n = e.y; + t.x = i.m00 * s + i.m04 * n + i.m12; + t.y = i.m01 * s + i.m05 * n + i.m13; + return t; + } + static str(t) { + return `Vec2(${t.x}, ${t.y})`; + } + static toArray(t, e, i = 0) { + t[i + 0] = e.x; + t[i + 1] = e.y; + return t; + } + static fromArray(t, e, i = 0) { + t.x = e[i + 0]; + t.y = e[i + 1]; + return t; + } + static strictEquals(t, e) { + return t.x === e.x && t.y === e.y; + } + static equals(t, e, i = hi) { + return Math.abs(t.x - e.x) <= i * Math.max(1, Math.abs(t.x), Math.abs(e.x)) && Math.abs(t.y - e.y) <= i * Math.max(1, Math.abs(t.y), Math.abs(e.y)); + } + static angle(t, e) { + Qi.normalize($i, t); + Qi.normalize(ts, e); + const i = Qi.dot($i, ts); + return i > 1 ? 0 : i < -1 ? Math.PI : Math.acos(i); + } + constructor(t, e) { + super(); + if (t && "object" == typeof t) { + this.x = t.x; + this.y = t.y; + } else { + this.x = t || 0; + this.y = e || 0; + } + } + clone() { + return new Qi(this.x, this.y); + } + set(t, e) { + if (t && "object" == typeof t) { + this.x = t.x; + this.y = t.y; + } else { + this.x = t || 0; + this.y = e || 0; + } + return this; + } + equals(t, e = hi) { + return Math.abs(this.x - t.x) <= e * Math.max(1, Math.abs(this.x), Math.abs(t.x)) && Math.abs(this.y - t.y) <= e * Math.max(1, Math.abs(this.y), Math.abs(t.y)); + } + equals2f(t, e, i = hi) { + return Math.abs(this.x - t) <= i * Math.max(1, Math.abs(this.x), Math.abs(t)) && Math.abs(this.y - e) <= i * Math.max(1, Math.abs(this.y), Math.abs(e)); + } + strictEquals(t) { + return t && this.x === t.x && this.y === t.y; + } + strictEquals2f(t, e) { + return this.x === t && this.y === e; + } + toString() { + return `(${this.x.toFixed(2)}, ${this.y.toFixed(2)})`; + } + lerp(t, e) { + const i = this.x; + const s = this.y; + this.x = i + e * (t.x - i); + this.y = s + e * (t.y - s); + return this; + } + clampf(t, e) { + this.x = _i(this.x, t.x, e.x); + this.y = _i(this.y, t.y, e.y); + return this; + } + add(t) { + this.x += t.x; + this.y += t.y; + return this; + } + add2f(t, e) { + this.x += t; + this.y += e; + return this; + } + subtract(t) { + this.x -= t.x; + this.y -= t.y; + return this; + } + subtract2f(t, e) { + this.x -= t; + this.y -= e; + return this; + } + multiplyScalar(t) { + "object" == typeof t && console.warn("should use Vec2.multiply for vector * vector operation"); + this.x *= t; + this.y *= t; + return this; + } + multiply(t) { + "object" != typeof t && console.warn("should use Vec2.scale for vector * scalar operation"); + this.x *= t.x; + this.y *= t.y; + return this; + } + multiply2f(t, e) { + this.x *= t; + this.y *= e; + return this; + } + divide(t) { + this.x /= t.x; + this.y /= t.y; + return this; + } + divide2f(t, e) { + this.x /= t; + this.y /= e; + return this; + } + negative() { + this.x = -this.x; + this.y = -this.y; + return this; + } + dot(t) { + return this.x * t.x + this.y * t.y; + } + cross(t) { + return this.x * t.y - this.y * t.x; + } + length() { + return Math.sqrt(this.x * this.x + this.y * this.y); + } + lengthSqr() { + return this.x * this.x + this.y * this.y; + } + normalize() { + const t = this.x; + const e = this.y; + let i = t * t + e * e; + if (i > 0) { + i = 1 / Math.sqrt(i); + this.x *= i; + this.y *= i; + } + return this; + } + angle(t) { + const e = this.lengthSqr(); + const i = t.lengthSqr(); + if (0 === e || 0 === i) { + console.warn("Can't get angle between zero vector"); + return 0; + } + let s = this.dot(t) / Math.sqrt(e * i); + s = _i(s, -1, 1); + return Math.acos(s); + } + signAngle(t) { + const e = this.angle(t); + return this.cross(t) < 0 ? -e : e; + } + rotate(t) { + const e = this.x; + const i = this.y; + const s = Math.sin(t); + const n = Math.cos(t); + this.x = n * e - s * i; + this.y = s * e + n * i; + return this; + } + project(t) { + const e = this.dot(t) / t.dot(t); + this.x = t.x * e; + this.y = t.y * e; + return this; + } + transformMat4(t) { + const e = this.x; + const i = this.y; + this.x = t.m00 * e + t.m04 * i + t.m12; + this.y = t.m01 * e + t.m05 * i + t.m13; + return this; + } + } + t("Vec2", Qi); + Qi.ZERO = Object.freeze(new Qi(0, 0)); + Qi.ONE = Object.freeze(new Qi(1, 1)); + Qi.NEG_ONE = Object.freeze(new Qi(-1, -1)); + Qi.UNIT_X = Object.freeze(new Qi(1, 0)); + Qi.UNIT_Y = Object.freeze(new Qi(0, 1)); + const $i = new Qi; + const ts = new Qi; + si.fastDefine("cc.Vec2", Qi, { + x: 0, + y: 0 + }); + m.Vec2 = Qi; + function es(t, e) { + return new Qi(t, e); + } + m.v2 = es; + class is extends ce { + static clone(t) { + return new is(t.x, t.y, t.z, t.w); + } + static copy(t, e) { + t.x = e.x; + t.y = e.y; + t.z = e.z; + t.w = e.w; + return t; + } + static set(t, e, i, s, n) { + t.x = e; + t.y = i; + t.z = s; + t.w = n; + return t; + } + static add(t, e, i) { + t.x = e.x + i.x; + t.y = e.y + i.y; + t.z = e.z + i.z; + t.w = e.w + i.w; + return t; + } + static subtract(t, e, i) { + t.x = e.x - i.x; + t.y = e.y - i.y; + t.z = e.z - i.z; + t.w = e.w - i.w; + return t; + } + static multiply(t, e, i) { + t.x = e.x * i.x; + t.y = e.y * i.y; + t.z = e.z * i.z; + t.w = e.w * i.w; + return t; + } + static divide(t, e, i) { + t.x = e.x / i.x; + t.y = e.y / i.y; + t.z = e.z / i.z; + t.w = e.w / i.w; + return t; + } + static ceil(t, e) { + t.x = Math.ceil(e.x); + t.y = Math.ceil(e.y); + t.z = Math.ceil(e.z); + t.w = Math.ceil(e.w); + return t; + } + static floor(t, e) { + t.x = Math.floor(e.x); + t.y = Math.floor(e.y); + t.z = Math.floor(e.z); + t.w = Math.floor(e.w); + return t; + } + static min(t, e, i) { + t.x = Math.min(e.x, i.x); + t.y = Math.min(e.y, i.y); + t.z = Math.min(e.z, i.z); + t.w = Math.min(e.w, i.w); + return t; + } + static max(t, e, i) { + t.x = Math.max(e.x, i.x); + t.y = Math.max(e.y, i.y); + t.z = Math.max(e.z, i.z); + t.w = Math.max(e.w, i.w); + return t; + } + static round(t, e) { + t.x = Math.round(e.x); + t.y = Math.round(e.y); + t.z = Math.round(e.z); + t.w = Math.round(e.w); + return t; + } + static multiplyScalar(t, e, i) { + t.x = e.x * i; + t.y = e.y * i; + t.z = e.z * i; + t.w = e.w * i; + return t; + } + static scaleAndAdd(t, e, i, s) { + t.x = e.x + i.x * s; + t.y = e.y + i.y * s; + t.z = e.z + i.z * s; + t.w = e.w + i.w * s; + return t; + } + static distance(t, e) { + const i = e.x - t.x; + const s = e.y - t.y; + const n = e.z - t.z; + const r = e.w - t.w; + return Math.sqrt(i * i + s * s + n * n + r * r); + } + static squaredDistance(t, e) { + const i = e.x - t.x; + const s = e.y - t.y; + const n = e.z - t.z; + const r = e.w - t.w; + return i * i + s * s + n * n + r * r; + } + static len(t) { + const e = t.x; + const i = t.y; + const s = t.z; + const n = t.w; + return Math.sqrt(e * e + i * i + s * s + n * n); + } + static lengthSqr(t) { + const e = t.x; + const i = t.y; + const s = t.z; + const n = t.w; + return e * e + i * i + s * s + n * n; + } + static negate(t, e) { + t.x = -e.x; + t.y = -e.y; + t.z = -e.z; + t.w = -e.w; + return t; + } + static inverse(t, e) { + t.x = 1 / e.x; + t.y = 1 / e.y; + t.z = 1 / e.z; + t.w = 1 / e.w; + return t; + } + static inverseSafe(t, e) { + const i = e.x; + const s = e.y; + const n = e.z; + const r = e.w; + Math.abs(i) < hi ? t.x = 0 : t.x = 1 / i; + Math.abs(s) < hi ? t.y = 0 : t.y = 1 / s; + Math.abs(n) < hi ? t.z = 0 : t.z = 1 / n; + Math.abs(r) < hi ? t.w = 0 : t.w = 1 / r; + return t; + } + static normalize(t, e) { + const i = e.x; + const s = e.y; + const n = e.z; + const r = e.w; + let o = i * i + s * s + n * n + r * r; + if (o > 0) { + o = 1 / Math.sqrt(o); + t.x = i * o; + t.y = s * o; + t.z = n * o; + t.w = r * o; + } + return t; + } + static dot(t, e) { + return t.x * e.x + t.y * e.y + t.z * e.z + t.w * e.w; + } + static lerp(t, e, i, s) { + t.x = e.x + s * (i.x - e.x); + t.y = e.y + s * (i.y - e.y); + t.z = e.z + s * (i.z - e.z); + t.w = e.w + s * (i.w - e.w); + return t; + } + static random(t, e) { + e = e || 1; + const i = 2 * gi() * Math.PI; + const s = 2 * gi() - 1; + const n = Math.sqrt(1 - s * s); + t.x = n * Math.cos(i) * e; + t.y = n * Math.sin(i) * e; + t.z = s * e; + t.w = 0; + return t; + } + static transformMat4(t, e, i) { + const s = e.x; + const n = e.y; + const r = e.z; + const o = e.w; + t.x = i.m00 * s + i.m04 * n + i.m08 * r + i.m12 * o; + t.y = i.m01 * s + i.m05 * n + i.m09 * r + i.m13 * o; + t.z = i.m02 * s + i.m06 * n + i.m10 * r + i.m14 * o; + t.w = i.m03 * s + i.m07 * n + i.m11 * r + i.m15 * o; + return t; + } + static transformAffine(t, e, i) { + const s = e.x; + const n = e.y; + const r = e.z; + const o = e.w; + t.x = i.m00 * s + i.m04 * n + i.m08 * r + i.m12 * o; + t.y = i.m01 * s + i.m05 * n + i.m09 * r + i.m13 * o; + t.z = i.m02 * s + i.m06 * n + i.m10 * r + i.m14 * o; + t.w = e.w; + return t; + } + static transformQuat(t, e, i) { + const {x: s, y: n, z: r} = e; + const o = i.x; + const a = i.y; + const l = i.z; + const h = i.w; + const c = h * s + a * r - l * n; + const u = h * n + l * s - o * r; + const _ = h * r + o * n - a * s; + const d = -o * s - a * n - l * r; + t.x = c * h + d * -o + u * -l - _ * -a; + t.y = u * h + d * -a + _ * -o - c * -l; + t.z = _ * h + d * -l + c * -a - u * -o; + t.w = e.w; + return t; + } + static toArray(t, e, i = 0) { + t[i + 0] = e.x; + t[i + 1] = e.y; + t[i + 2] = e.z; + t[i + 3] = e.w; + return t; + } + static fromArray(t, e, i = 0) { + t.x = e[i + 0]; + t.y = e[i + 1]; + t.z = e[i + 2]; + t.w = e[i + 3]; + return t; + } + static strictEquals(t, e) { + return t.x === e.x && t.y === e.y && t.z === e.z && t.w === e.w; + } + static equals(t, e, i = hi) { + return Math.abs(t.x - e.x) <= i * Math.max(1, Math.abs(t.x), Math.abs(e.x)) && Math.abs(t.y - e.y) <= i * Math.max(1, Math.abs(t.y), Math.abs(e.y)) && Math.abs(t.z - e.z) <= i * Math.max(1, Math.abs(t.z), Math.abs(e.z)) && Math.abs(t.w - e.w) <= i * Math.max(1, Math.abs(t.w), Math.abs(e.w)); + } + constructor(t, e, i, s) { + super(); + if (t && "object" == typeof t) { + this.x = t.x; + this.y = t.y; + this.z = t.z; + this.w = t.w; + } else { + this.x = t || 0; + this.y = e || 0; + this.z = i || 0; + this.w = s || 0; + } + } + clone() { + return new is(this.x, this.y, this.z, this.w); + } + set(t, e, i, s) { + if (t && "object" == typeof t) { + this.x = t.x; + this.y = t.y; + this.z = t.z; + this.w = t.w; + } else { + this.x = t || 0; + this.y = e || 0; + this.z = i || 0; + this.w = s || 0; + } + return this; + } + equals(t, e = hi) { + return Math.abs(this.x - t.x) <= e * Math.max(1, Math.abs(this.x), Math.abs(t.x)) && Math.abs(this.y - t.y) <= e * Math.max(1, Math.abs(this.y), Math.abs(t.y)) && Math.abs(this.z - t.z) <= e * Math.max(1, Math.abs(this.z), Math.abs(t.z)) && Math.abs(this.w - t.w) <= e * Math.max(1, Math.abs(this.w), Math.abs(t.w)); + } + equals4f(t, e, i, s, n = hi) { + return Math.abs(this.x - t) <= n * Math.max(1, Math.abs(this.x), Math.abs(t)) && Math.abs(this.y - e) <= n * Math.max(1, Math.abs(this.y), Math.abs(e)) && Math.abs(this.z - i) <= n * Math.max(1, Math.abs(this.z), Math.abs(i)) && Math.abs(this.w - s) <= n * Math.max(1, Math.abs(this.w), Math.abs(s)); + } + strictEquals(t) { + return this.x === t.x && this.y === t.y && this.z === t.z && this.w === t.w; + } + strictEquals4f(t, e, i, s) { + return this.x === t && this.y === e && this.z === i && this.w === s; + } + lerp(t, e) { + const i = this.x; + const s = this.y; + const n = this.z; + const r = this.w; + this.x = i + e * (t.x - i); + this.y = s + e * (t.y - s); + this.z = n + e * (t.z - n); + this.w = r + e * (t.w - r); + return this; + } + toString() { + return `(${this.x.toFixed(2)}, ${this.y.toFixed(2)}, ${this.z.toFixed(2)}, ${this.w.toFixed(2)})`; + } + clampf(t, e) { + this.x = _i(this.x, t.x, e.x); + this.y = _i(this.y, t.y, e.y); + this.z = _i(this.z, t.z, e.z); + this.w = _i(this.w, t.w, e.w); + return this; + } + add(t) { + this.x += t.x; + this.y += t.y; + this.z += t.z; + this.w += t.w; + return this; + } + add4f(t, e, i, s) { + this.x += t; + this.y += e; + this.z += i; + this.w += s; + return this; + } + subtract(t) { + this.x -= t.x; + this.y -= t.y; + this.z -= t.z; + this.w -= t.w; + return this; + } + subtract4f(t, e, i, s) { + this.x -= t; + this.y -= e; + this.z -= i; + this.w -= s; + return this; + } + multiplyScalar(t) { + "object" == typeof t && console.warn("should use Vec4.multiply for vector * vector operation"); + this.x *= t; + this.y *= t; + this.z *= t; + this.w *= t; + return this; + } + multiply(t) { + "object" != typeof t && console.warn("should use Vec4.scale for vector * scalar operation"); + this.x *= t.x; + this.y *= t.y; + this.z *= t.z; + this.w *= t.w; + return this; + } + multiply4f(t, e, i, s) { + this.x *= t; + this.y *= e; + this.z *= i; + this.w *= s; + return this; + } + divide(t) { + this.x /= t.x; + this.y /= t.y; + this.z /= t.z; + this.w /= t.w; + return this; + } + divide4f(t, e, i, s) { + this.x /= t; + this.y /= e; + this.z /= i; + this.w /= s; + return this; + } + negative() { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + this.w = -this.w; + return this; + } + dot(t) { + return this.x * t.x + this.y * t.y + this.z * t.z + this.w * t.w; + } + cross(t) { + const {x: e, y: i, z: s} = this; + const {x: n, y: r, z: o} = t; + this.x = i * o - s * r; + this.y = s * n - e * o; + this.z = e * r - i * n; + return this; + } + length() { + const t = this.x; + const e = this.y; + const i = this.z; + const s = this.w; + return Math.sqrt(t * t + e * e + i * i + s * s); + } + lengthSqr() { + const t = this.x; + const e = this.y; + const i = this.z; + const s = this.w; + return t * t + e * e + i * i + s * s; + } + normalize() { + const t = this.x; + const e = this.y; + const i = this.z; + const s = this.w; + let n = t * t + e * e + i * i + s * s; + if (n > 0) { + n = 1 / Math.sqrt(n); + this.x = t * n; + this.y = e * n; + this.z = i * n; + this.w = s * n; + } + return this; + } + transformMat4(t) { + const e = this.x; + const i = this.y; + const s = this.z; + const n = this.w; + this.x = t.m00 * e + t.m04 * i + t.m08 * s + t.m12 * n; + this.y = t.m01 * e + t.m05 * i + t.m09 * s + t.m13 * n; + this.z = t.m02 * e + t.m06 * i + t.m10 * s + t.m14 * n; + this.w = t.m03 * e + t.m07 * i + t.m11 * s + t.m15 * n; + return this; + } + } + t("Vec4", is); + is.ZERO = Object.freeze(new is(0, 0, 0, 0)); + is.ONE = Object.freeze(new is(1, 1, 1, 1)); + is.NEG_ONE = Object.freeze(new is(-1, -1, -1, -1)); + si.fastDefine("cc.Vec4", is, { + x: 0, + y: 0, + z: 0, + w: 0 + }); + m.Vec4 = is; + function ss(t, e, i, s) { + return new is(t, e, i, s); + } + m.v4 = ss; + W(Qi, "Vec2", [ { + name: "sub", + newName: "subtract", + target: Qi, + targetName: "Vec2" + }, { + name: "mul", + newName: "multiply", + target: Qi, + targetName: "Vec2" + }, { + name: "div", + newName: "divide", + target: Qi, + targetName: "Vec2" + }, { + name: "dist", + newName: "distance", + target: Qi, + targetName: "Vec2" + }, { + name: "sqrDist", + newName: "squaredDistance", + target: Qi, + targetName: "Vec2" + }, { + name: "mag", + newName: "len", + target: Qi, + targetName: "Vec2" + }, { + name: "sqrMag", + newName: "lengthSqr", + target: Qi, + targetName: "Vec2" + }, { + name: "scale", + newName: "multiplyScalar", + target: Qi, + targetName: "Vec2" + }, { + name: "exactEquals", + newName: "strictEquals", + target: Qi, + targetName: "Vec2" + } ]); + W(Qi.prototype, "Vec2", [ { + name: "mag", + newName: "length", + target: Qi.prototype, + targetName: "Vec2" + }, { + name: "magSqr", + newName: "lengthSqr", + target: Qi.prototype, + targetName: "Vec2" + }, { + name: "scale", + newName: "multiplyScalar", + target: Qi.prototype, + targetName: "Vec2" + }, { + name: "exactEquals", + newName: "strictEquals", + target: Qi.prototype, + targetName: "Vec2" + } ]); + W(Pi, "Vec3", [ { + name: "sub", + newName: "subtract", + target: Pi, + targetName: "Vec3" + }, { + name: "mul", + newName: "multiply", + target: Pi, + targetName: "Vec3" + }, { + name: "div", + newName: "divide", + target: Pi, + targetName: "Vec3" + }, { + name: "dist", + newName: "distance", + target: Pi, + targetName: "Vec3" + }, { + name: "sqrDist", + newName: "squaredDistance", + target: Pi, + targetName: "Vec3" + }, { + name: "mag", + newName: "len", + target: Pi, + targetName: "Vec3" + }, { + name: "sqrMag", + newName: "lengthSqr", + target: Pi, + targetName: "Vec3" + }, { + name: "scale", + newName: "multiplyScalar", + target: Pi, + targetName: "Vec3" + }, { + name: "exactEquals", + newName: "strictEquals", + target: Pi, + targetName: "Vec3" + } ]); + W(Pi.prototype, "Vec3", [ { + name: "mag", + newName: "length", + target: Pi.prototype, + targetName: "Vec3" + }, { + name: "magSqr", + newName: "lengthSqr", + target: Pi.prototype, + targetName: "Vec3" + }, { + name: "scale", + newName: "multiplyScalar", + target: Pi.prototype, + targetName: "Vec3" + }, { + name: "exactEquals", + newName: "strictEquals", + target: Pi.prototype, + targetName: "Vec3" + } ]); + W(is, "Vec4", [ { + name: "sub", + newName: "subtract", + target: is, + targetName: "Vec4" + }, { + name: "mul", + newName: "multiply", + target: is, + targetName: "Vec4" + }, { + name: "div", + newName: "divide", + target: is, + targetName: "Vec4" + }, { + name: "dist", + newName: "distance", + target: is, + targetName: "Vec4" + }, { + name: "sqrDist", + newName: "squaredDistance", + target: is, + targetName: "Vec4" + }, { + name: "mag", + newName: "len", + target: is, + targetName: "Vec4" + }, { + name: "sqrMag", + newName: "lengthSqr", + target: is, + targetName: "Vec4" + }, { + name: "scale", + newName: "multiplyScalar", + target: is, + targetName: "Vec4" + }, { + name: "exactEquals", + newName: "strictEquals", + target: is, + targetName: "Vec4" + } ]); + W(is.prototype, "Vec4", [ { + name: "mag", + newName: "length", + target: is.prototype, + targetName: "Vec4" + }, { + name: "magSqr", + newName: "lengthSqr", + target: is.prototype, + targetName: "Vec4" + }, { + name: "scale", + newName: "multiplyScalar", + target: is.prototype, + targetName: "Vec4" + }, { + name: "exactEquals", + newName: "strictEquals", + target: is.prototype, + targetName: "Vec4" + } ]); + W(Ui, "Quat", [ { + name: "mag", + newName: "len", + target: Ui, + targetName: "Quat" + }, { + name: "mul", + newName: "multiply", + target: Ui, + targetName: "Quat" + }, { + name: "sqrMag", + newName: "lengthSqr", + target: Ui, + targetName: "Quat" + }, { + name: "scale", + newName: "multiplyScalar", + target: Ui, + targetName: "Quat" + }, { + name: "exactEquals", + newName: "strictEquals", + target: Ui, + targetName: "Quat" + } ]); + W(Ui.prototype, "Quat", [ { + name: "scale", + newName: "multiplyScalar", + target: Ui.prototype, + targetName: "Quat" + }, { + name: "exactEquals", + newName: "strictEquals", + target: Ui.prototype, + targetName: "Quat" + } ]); + W(Bi, "Color", [ { + name: "sub", + newName: "subtract", + target: Bi, + targetName: "Color" + }, { + name: "mul", + newName: "multiply", + target: Bi, + targetName: "Color" + }, { + name: "div", + newName: "divide", + target: Bi, + targetName: "Color" + }, { + name: "exactEquals", + newName: "strictEquals", + target: Bi, + targetName: "Color" + }, { + name: "fromHex", + newName: "fromHEX", + customFunction(...t) { + const e = t[1].toString(16); + return m.Color.fromHEX(t[0], e); + } + } ]); + W(Fi, "Mat3", [ { + name: "sub", + newName: "subtract", + target: Fi, + targetName: "Mat3" + }, { + name: "mul", + newName: "multiply", + target: Fi, + targetName: "Mat3" + }, { + name: "exactEquals", + newName: "strictEquals", + target: Fi, + targetName: "Mat3" + }, { + name: "transfrom", + newName: "transform", + target: Fi, + targetName: "Mat3" + } ]); + W(Fi.prototype, "Mat3", [ { + name: "sub", + newName: "subtract", + target: Fi.prototype, + targetName: "Mat3" + }, { + name: "mul", + newName: "multiply", + target: Fi.prototype, + targetName: "Mat3" + }, { + name: "mulScalar", + newName: "multiplyScalar", + target: Fi.prototype, + targetName: "Mat3" + }, { + name: "exactEquals", + newName: "strictEquals", + target: Fi.prototype, + targetName: "Mat3" + } ]); + W(qi, "Mat4", [ { + name: "sub", + newName: "subtract", + target: qi, + targetName: "Mat4" + }, { + name: "mul", + newName: "multiply", + target: qi, + targetName: "Mat4" + }, { + name: "exactEquals", + newName: "strictEquals", + target: qi, + targetName: "Mat4" + } ]); + W(qi.prototype, "Mat4", [ { + name: "sub", + newName: "subtract", + target: qi.prototype, + targetName: "Mat4" + }, { + name: "mul", + newName: "multiply", + target: qi.prototype, + targetName: "Mat4" + }, { + name: "mulScalar", + newName: "multiplyScalar", + target: qi.prototype, + targetName: "Mat4" + }, { + name: "exactEquals", + newName: "strictEquals", + target: qi.prototype, + targetName: "Mat4" + } ]); + class ns { + static identity() { + return new ns; + } + static clone(t) { + return new ns(t.a, t.b, t.c, t.d, t.tx, t.ty); + } + static concat(t, e, i) { + const s = e.a; + const n = e.b; + const r = e.c; + const o = e.d; + const a = e.tx; + const l = e.ty; + t.a = s * i.a + n * i.c; + t.b = s * i.b + n * i.d; + t.c = r * i.a + o * i.c; + t.d = r * i.b + o * i.d; + t.tx = a * i.a + l * i.c + i.tx; + t.ty = a * i.b + l * i.d + i.ty; + } + static invert(t, e) { + const i = 1 / (e.a * e.d - e.b * e.c); + t.a = i * e.d; + t.b = -i * e.b; + t.c = -i * e.c; + t.d = i * e.a; + t.tx = i * (e.c * e.ty - e.d * e.tx); + t.ty = i * (e.b * e.tx - e.a * e.ty); + } + static fromMat4(t, e) { + t.a = e.m00; + t.b = e.m01; + t.c = e.m04; + t.d = e.m05; + t.tx = e.m12; + t.ty = e.m13; + } + static transformVec2(t, e, i, s) { + let n; + let r; + if (s) { + n = e; + r = i; + } else { + s = i; + n = e.x; + r = e.y; + } + t.x = s.a * n + s.c * r + s.tx; + t.y = s.b * n + s.d * r + s.ty; + } + static transformSize(t, e, i) { + t.width = i.a * e.width + i.c * e.height; + t.height = i.b * e.width + i.d * e.height; + } + static transformRect(t, e, i) { + const s = e.x + e.width; + const n = e.y + e.height; + const r = i.a * e.x + i.c * e.y + i.tx; + const o = i.b * e.x + i.d * e.y + i.ty; + const a = i.a * s + i.c * e.y + i.tx; + const l = i.b * s + i.d * e.y + i.ty; + const h = i.a * e.x + i.c * n + i.tx; + const c = i.b * e.x + i.d * n + i.ty; + const u = i.a * s + i.c * n + i.tx; + const _ = i.b * s + i.d * n + i.ty; + const d = Math.min(r, a, h, u); + const p = Math.max(r, a, h, u); + const m = Math.min(o, l, c, _); + const f = Math.max(o, l, c, _); + t.x = d; + t.y = m; + t.width = p - d; + t.height = f - m; + } + static transformObb(t, e, i, s, n, r) { + const o = r.a * n.x + r.c * n.y + r.tx; + const a = r.b * n.x + r.d * n.y + r.ty; + const l = r.a * n.width; + const h = r.b * n.width; + const c = r.c * n.height; + const u = r.d * n.height; + e.x = o; + e.y = a; + i.x = l + o; + i.y = h + a; + t.x = c + o; + t.y = u + a; + s.x = l + c + o; + s.y = h + u + a; + } + constructor(t = 1, e = 0, i = 0, s = 1, n = 0, r = 0) { + this.a = t; + this.b = e; + this.c = i; + this.d = s; + this.tx = n; + this.ty = r; + } + } + t("AffineTransform", ns); + m.AffineTransform = ns; + class rs extends ce { + static lerp(t, e, i, s) { + t.width = e.width + (i.width - e.width) * s; + t.height = e.height + (i.height - e.height) * s; + return t; + } + set x(t) { + this.width = t; + } + get x() { + return this.width; + } + set y(t) { + this.height = t; + } + get y() { + return this.height; + } + constructor(t, e) { + super(); + if (t && "object" == typeof t) { + this.width = t.width; + this.height = t.height; + } else { + this.width = t || 0; + this.height = e || 0; + } + } + clone() { + return new rs(this.width, this.height); + } + set(t, e) { + if (t && "object" == typeof t) { + this.height = t.height; + this.width = t.width; + } else { + this.width = t || 0; + this.height = e || 0; + } + return this; + } + equals(t) { + return this.width === t.width && this.height === t.height; + } + lerp(t, e) { + this.width += (t.width - this.width) * e; + this.height += (t.height - this.height) * e; + return this; + } + toString() { + return `(${this.width.toFixed(2)}, ${this.height.toFixed(2)})`; + } + } + t("Size", rs); + rs.ZERO = Object.freeze(new rs(0, 0)); + rs.ONE = Object.freeze(new rs(1, 1)); + si.fastDefine("cc.Size", rs, { + width: 0, + height: 0 + }); + function os(t = 0, e = 0) { + return new rs(t, e); + } + m.size = os; + m.Size = rs; + class as extends ce { + static fromMinMax(t, e, i) { + const s = Math.min(e.x, i.x); + const n = Math.min(e.y, i.y); + const r = Math.max(e.x, i.x); + const o = Math.max(e.y, i.y); + t.x = s; + t.y = n; + t.width = r - s; + t.height = o - n; + return t; + } + static lerp(t, e, i, s) { + const n = e.x; + const r = e.y; + const o = e.width; + const a = e.height; + t.x = n + (i.x - n) * s; + t.y = r + (i.y - r) * s; + t.width = o + (i.width - o) * s; + t.height = a + (i.height - a) * s; + return t; + } + static intersection(t, e, i) { + const s = e.x; + const n = e.y; + const r = e.x + e.width; + const o = e.y + e.height; + const a = i.x; + const l = i.y; + const h = i.x + i.width; + const c = i.y + i.height; + t.x = Math.max(s, a); + t.y = Math.max(n, l); + t.width = Math.min(r, h) - t.x; + t.height = Math.min(o, c) - t.y; + return t; + } + static union(t, e, i) { + const s = e.x; + const n = e.y; + const r = e.width; + const o = e.height; + const a = i.x; + const l = i.y; + const h = i.width; + const c = i.height; + t.x = Math.min(s, a); + t.y = Math.min(n, l); + t.width = Math.max(s + r, a + h) - t.x; + t.height = Math.max(n + o, l + c) - t.y; + return t; + } + get xMin() { + return this.x; + } + set xMin(t) { + this.width += this.x - t; + this.x = t; + } + get yMin() { + return this.y; + } + set yMin(t) { + this.height += this.y - t; + this.y = t; + } + get xMax() { + return this.x + this.width; + } + set xMax(t) { + this.width = t - this.x; + } + get yMax() { + return this.y + this.height; + } + set yMax(t) { + this.height = t - this.y; + } + get center() { + return new Qi(this.x + .5 * this.width, this.y + .5 * this.height); + } + set center(t) { + this.x = t.x - .5 * this.width; + this.y = t.y - .5 * this.height; + } + get origin() { + return new Qi(this.x, this.y); + } + set origin(t) { + this.x = t.x; + this.y = t.y; + } + get size() { + return new rs(this.width, this.height); + } + set size(t) { + this.width = t.width; + this.height = t.height; + } + set z(t) { + this.width = t; + } + get z() { + return this.width; + } + set w(t) { + this.height = t; + } + get w() { + return this.height; + } + constructor(t, e, i, s) { + super(); + if (t && "object" == typeof t) { + this.y = t.y; + this.width = t.width; + this.height = t.height; + this.x = t.x; + } else { + this.x = t || 0; + this.y = e || 0; + this.width = i || 0; + this.height = s || 0; + } + } + clone() { + return new as(this.x, this.y, this.width, this.height); + } + set(t, e, i, s) { + if (t && "object" == typeof t) { + this.y = t.y; + this.width = t.width; + this.height = t.height; + this.x = t.x; + } else { + this.x = t || 0; + this.y = e || 0; + this.width = i || 0; + this.height = s || 0; + } + return this; + } + equals(t) { + return this.x === t.x && this.y === t.y && this.width === t.width && this.height === t.height; + } + lerp(t, e) { + const i = this.x; + const s = this.y; + const n = this.width; + const r = this.height; + this.x = i + (t.x - i) * e; + this.y = s + (t.y - s) * e; + this.width = n + (t.width - n) * e; + this.height = r + (t.height - r) * e; + return this; + } + toString() { + return `(${this.x.toFixed(2)}, ${this.y.toFixed(2)}, ${this.width.toFixed(2)}, ${this.height.toFixed(2)})`; + } + intersects(t) { + const e = this.x + this.width; + const i = this.y + this.height; + const s = t.x + t.width; + const n = t.y + t.height; + return !(e < t.x || s < this.x || i < t.y || n < this.y); + } + contains(t) { + return this.x <= t.x && this.x + this.width >= t.x && this.y <= t.y && this.y + this.height >= t.y; + } + containsRect(t) { + return this.x <= t.x && this.x + this.width >= t.x + t.width && this.y <= t.y && this.y + this.height >= t.y + t.height; + } + transformMat4(t) { + const e = this.x; + const i = this.y; + const s = e + this.width; + const n = i + this.height; + const r = t.m00 * e + t.m04 * i + t.m12; + const o = t.m01 * e + t.m05 * i + t.m13; + const a = t.m00 * s + t.m04 * i + t.m12; + const l = t.m01 * s + t.m05 * i + t.m13; + const h = t.m00 * e + t.m04 * n + t.m12; + const c = t.m01 * e + t.m05 * n + t.m13; + const u = t.m00 * s + t.m04 * n + t.m12; + const _ = t.m01 * s + t.m05 * n + t.m13; + const d = Math.min(r, a, h, u); + const p = Math.max(r, a, h, u); + const m = Math.min(o, l, c, _); + const f = Math.max(o, l, c, _); + this.x = d; + this.y = m; + this.width = p - d; + this.height = f - m; + return this; + } + transformMat4ToPoints(t, e, i, s, n) { + const r = this.x; + const o = this.y; + const a = r + this.width; + const l = o + this.height; + e.x = t.m00 * r + t.m04 * o + t.m12; + e.y = t.m01 * r + t.m05 * o + t.m13; + n.x = t.m00 * a + t.m04 * o + t.m12; + n.y = t.m01 * a + t.m05 * o + t.m13; + i.x = t.m00 * r + t.m04 * l + t.m12; + i.y = t.m01 * r + t.m05 * l + t.m13; + s.x = t.m00 * a + t.m04 * l + t.m12; + s.y = t.m01 * a + t.m05 * l + t.m13; + } + } + t("Rect", as); + si.fastDefine("cc.Rect", as, { + x: 0, + y: 0, + width: 0, + height: 0 + }); + m.Rect = as; + function ls(t = 0, e = 0, i = 0, s = 0) { + return new as(t, e, i, s); + } + m.rect = ls; + const hs = t("MATH_FLOAT_ARRAY", Float32Array); + class cs extends ce { + static createFloatArray(t) { + return new hs(t); + } + get array() { + return this._array; + } + } + t("MathBase", cs); + var us = Object.freeze({ + __proto__: null, + bits: c, + Vec2: Qi, + v2: es, + Vec3: Pi, + v3: Li, + Vec4: is, + v4: ss, + Quat: Ui, + quat: Wi, + Mat3: Fi, + Mat4: qi, + mat4: Zi, + AffineTransform: ns, + Size: rs, + size: os, + Rect: as, + rect: ls, + Color: Bi, + color: Di, + EPSILON: hi, + equals: ci, + approx: ui, + clamp: _i, + clamp01: di, + lerp: pi, + toRadian: mi, + toDegree: fi, + random: gi, + randomRange: yi, + randomRangeInt: bi, + pseudoRandom: Si, + pseudoRandomRange: Ai, + pseudoRandomRangeInt: Ti, + nextPow2: vi, + repeat: Ei, + pingPong: Ci, + inverseLerp: xi, + absMaxComponent: wi, + absMax: Ri, + enumerableProps: Ii, + MATH_FLOAT_ARRAY: hs, + MathBase: cs + }); + t("math", us); + const _s = new class { + constructor() { + this._finalizationRegistry = null; + this._gcObjects = new WeakMap; + } + registerGCObject(t) { + return t; + } + init() {} + finalizationRegistryCallback(t) { + const e = this._gcObjects.get(t); + if (e) { + this._gcObjects.delete(t); + e.destroy(); + } + this._finalizationRegistry.unregister(t); + } + destroy() {} + }; + const ds = (t, e, i) => { + for (let s = 0; s < e.length; ++s) { + t.length <= s && t.push(new i); + t[s].copy(e[s]); + } + t.length = e.length; + }; + let ps; + !function(t) { + t[t.UNKNOWN = 0] = "UNKNOWN"; + t[t.SWAPCHAIN = 1] = "SWAPCHAIN"; + t[t.BUFFER = 2] = "BUFFER"; + t[t.TEXTURE = 3] = "TEXTURE"; + t[t.RENDER_PASS = 4] = "RENDER_PASS"; + t[t.FRAMEBUFFER = 5] = "FRAMEBUFFER"; + t[t.SAMPLER = 6] = "SAMPLER"; + t[t.SHADER = 7] = "SHADER"; + t[t.DESCRIPTOR_SET_LAYOUT = 8] = "DESCRIPTOR_SET_LAYOUT"; + t[t.PIPELINE_LAYOUT = 9] = "PIPELINE_LAYOUT"; + t[t.PIPELINE_STATE = 10] = "PIPELINE_STATE"; + t[t.DESCRIPTOR_SET = 11] = "DESCRIPTOR_SET"; + t[t.INPUT_ASSEMBLER = 12] = "INPUT_ASSEMBLER"; + t[t.COMMAND_BUFFER = 13] = "COMMAND_BUFFER"; + t[t.QUEUE = 14] = "QUEUE"; + t[t.QUERY_POOL = 15] = "QUERY_POOL"; + t[t.GLOBAL_BARRIER = 16] = "GLOBAL_BARRIER"; + t[t.TEXTURE_BARRIER = 17] = "TEXTURE_BARRIER"; + t[t.BUFFER_BARRIER = 18] = "BUFFER_BARRIER"; + t[t.COUNT = 19] = "COUNT"; + }(ps || (ps = {})); + let ms; + !function(t) { + t[t.UNREADY = 0] = "UNREADY"; + t[t.FAILED = 1] = "FAILED"; + t[t.SUCCESS = 2] = "SUCCESS"; + }(ms || (ms = {})); + let fs; + !function(t) { + t[t.UNKNOWN = 0] = "UNKNOWN"; + t[t.GLES2 = 1] = "GLES2"; + t[t.GLES3 = 2] = "GLES3"; + t[t.METAL = 3] = "METAL"; + t[t.VULKAN = 4] = "VULKAN"; + t[t.NVN = 5] = "NVN"; + t[t.WEBGL = 6] = "WEBGL"; + t[t.WEBGL2 = 7] = "WEBGL2"; + t[t.WEBGPU = 8] = "WEBGPU"; + }(fs || (fs = {})); + let gs; + !function(t) { + t[t.IDENTITY = 0] = "IDENTITY"; + t[t.ROTATE_90 = 1] = "ROTATE_90"; + t[t.ROTATE_180 = 2] = "ROTATE_180"; + t[t.ROTATE_270 = 3] = "ROTATE_270"; + }(gs || (gs = {})); + let ys; + !function(t) { + t[t.ELEMENT_INDEX_UINT = 0] = "ELEMENT_INDEX_UINT"; + t[t.INSTANCED_ARRAYS = 1] = "INSTANCED_ARRAYS"; + t[t.MULTIPLE_RENDER_TARGETS = 2] = "MULTIPLE_RENDER_TARGETS"; + t[t.BLEND_MINMAX = 3] = "BLEND_MINMAX"; + t[t.COMPUTE_SHADER = 4] = "COMPUTE_SHADER"; + t[t.INPUT_ATTACHMENT_BENEFIT = 5] = "INPUT_ATTACHMENT_BENEFIT"; + t[t.COUNT = 6] = "COUNT"; + }(ys || (ys = {})); + let bs; + !function(t) { + t[t.UNKNOWN = 0] = "UNKNOWN"; + t[t.A8 = 1] = "A8"; + t[t.L8 = 2] = "L8"; + t[t.LA8 = 3] = "LA8"; + t[t.R8 = 4] = "R8"; + t[t.R8SN = 5] = "R8SN"; + t[t.R8UI = 6] = "R8UI"; + t[t.R8I = 7] = "R8I"; + t[t.R16F = 8] = "R16F"; + t[t.R16UI = 9] = "R16UI"; + t[t.R16I = 10] = "R16I"; + t[t.R32F = 11] = "R32F"; + t[t.R32UI = 12] = "R32UI"; + t[t.R32I = 13] = "R32I"; + t[t.RG8 = 14] = "RG8"; + t[t.RG8SN = 15] = "RG8SN"; + t[t.RG8UI = 16] = "RG8UI"; + t[t.RG8I = 17] = "RG8I"; + t[t.RG16F = 18] = "RG16F"; + t[t.RG16UI = 19] = "RG16UI"; + t[t.RG16I = 20] = "RG16I"; + t[t.RG32F = 21] = "RG32F"; + t[t.RG32UI = 22] = "RG32UI"; + t[t.RG32I = 23] = "RG32I"; + t[t.RGB8 = 24] = "RGB8"; + t[t.SRGB8 = 25] = "SRGB8"; + t[t.RGB8SN = 26] = "RGB8SN"; + t[t.RGB8UI = 27] = "RGB8UI"; + t[t.RGB8I = 28] = "RGB8I"; + t[t.RGB16F = 29] = "RGB16F"; + t[t.RGB16UI = 30] = "RGB16UI"; + t[t.RGB16I = 31] = "RGB16I"; + t[t.RGB32F = 32] = "RGB32F"; + t[t.RGB32UI = 33] = "RGB32UI"; + t[t.RGB32I = 34] = "RGB32I"; + t[t.RGBA8 = 35] = "RGBA8"; + t[t.BGRA8 = 36] = "BGRA8"; + t[t.SRGB8_A8 = 37] = "SRGB8_A8"; + t[t.RGBA8SN = 38] = "RGBA8SN"; + t[t.RGBA8UI = 39] = "RGBA8UI"; + t[t.RGBA8I = 40] = "RGBA8I"; + t[t.RGBA16F = 41] = "RGBA16F"; + t[t.RGBA16UI = 42] = "RGBA16UI"; + t[t.RGBA16I = 43] = "RGBA16I"; + t[t.RGBA32F = 44] = "RGBA32F"; + t[t.RGBA32UI = 45] = "RGBA32UI"; + t[t.RGBA32I = 46] = "RGBA32I"; + t[t.R5G6B5 = 47] = "R5G6B5"; + t[t.R11G11B10F = 48] = "R11G11B10F"; + t[t.RGB5A1 = 49] = "RGB5A1"; + t[t.RGBA4 = 50] = "RGBA4"; + t[t.RGB10A2 = 51] = "RGB10A2"; + t[t.RGB10A2UI = 52] = "RGB10A2UI"; + t[t.RGB9E5 = 53] = "RGB9E5"; + t[t.DEPTH = 54] = "DEPTH"; + t[t.DEPTH_STENCIL = 55] = "DEPTH_STENCIL"; + t[t.BC1 = 56] = "BC1"; + t[t.BC1_ALPHA = 57] = "BC1_ALPHA"; + t[t.BC1_SRGB = 58] = "BC1_SRGB"; + t[t.BC1_SRGB_ALPHA = 59] = "BC1_SRGB_ALPHA"; + t[t.BC2 = 60] = "BC2"; + t[t.BC2_SRGB = 61] = "BC2_SRGB"; + t[t.BC3 = 62] = "BC3"; + t[t.BC3_SRGB = 63] = "BC3_SRGB"; + t[t.BC4 = 64] = "BC4"; + t[t.BC4_SNORM = 65] = "BC4_SNORM"; + t[t.BC5 = 66] = "BC5"; + t[t.BC5_SNORM = 67] = "BC5_SNORM"; + t[t.BC6H_UF16 = 68] = "BC6H_UF16"; + t[t.BC6H_SF16 = 69] = "BC6H_SF16"; + t[t.BC7 = 70] = "BC7"; + t[t.BC7_SRGB = 71] = "BC7_SRGB"; + t[t.ETC_RGB8 = 72] = "ETC_RGB8"; + t[t.ETC2_RGB8 = 73] = "ETC2_RGB8"; + t[t.ETC2_SRGB8 = 74] = "ETC2_SRGB8"; + t[t.ETC2_RGB8_A1 = 75] = "ETC2_RGB8_A1"; + t[t.ETC2_SRGB8_A1 = 76] = "ETC2_SRGB8_A1"; + t[t.ETC2_RGBA8 = 77] = "ETC2_RGBA8"; + t[t.ETC2_SRGB8_A8 = 78] = "ETC2_SRGB8_A8"; + t[t.EAC_R11 = 79] = "EAC_R11"; + t[t.EAC_R11SN = 80] = "EAC_R11SN"; + t[t.EAC_RG11 = 81] = "EAC_RG11"; + t[t.EAC_RG11SN = 82] = "EAC_RG11SN"; + t[t.PVRTC_RGB2 = 83] = "PVRTC_RGB2"; + t[t.PVRTC_RGBA2 = 84] = "PVRTC_RGBA2"; + t[t.PVRTC_RGB4 = 85] = "PVRTC_RGB4"; + t[t.PVRTC_RGBA4 = 86] = "PVRTC_RGBA4"; + t[t.PVRTC2_2BPP = 87] = "PVRTC2_2BPP"; + t[t.PVRTC2_4BPP = 88] = "PVRTC2_4BPP"; + t[t.ASTC_RGBA_4X4 = 89] = "ASTC_RGBA_4X4"; + t[t.ASTC_RGBA_5X4 = 90] = "ASTC_RGBA_5X4"; + t[t.ASTC_RGBA_5X5 = 91] = "ASTC_RGBA_5X5"; + t[t.ASTC_RGBA_6X5 = 92] = "ASTC_RGBA_6X5"; + t[t.ASTC_RGBA_6X6 = 93] = "ASTC_RGBA_6X6"; + t[t.ASTC_RGBA_8X5 = 94] = "ASTC_RGBA_8X5"; + t[t.ASTC_RGBA_8X6 = 95] = "ASTC_RGBA_8X6"; + t[t.ASTC_RGBA_8X8 = 96] = "ASTC_RGBA_8X8"; + t[t.ASTC_RGBA_10X5 = 97] = "ASTC_RGBA_10X5"; + t[t.ASTC_RGBA_10X6 = 98] = "ASTC_RGBA_10X6"; + t[t.ASTC_RGBA_10X8 = 99] = "ASTC_RGBA_10X8"; + t[t.ASTC_RGBA_10X10 = 100] = "ASTC_RGBA_10X10"; + t[t.ASTC_RGBA_12X10 = 101] = "ASTC_RGBA_12X10"; + t[t.ASTC_RGBA_12X12 = 102] = "ASTC_RGBA_12X12"; + t[t.ASTC_SRGBA_4X4 = 103] = "ASTC_SRGBA_4X4"; + t[t.ASTC_SRGBA_5X4 = 104] = "ASTC_SRGBA_5X4"; + t[t.ASTC_SRGBA_5X5 = 105] = "ASTC_SRGBA_5X5"; + t[t.ASTC_SRGBA_6X5 = 106] = "ASTC_SRGBA_6X5"; + t[t.ASTC_SRGBA_6X6 = 107] = "ASTC_SRGBA_6X6"; + t[t.ASTC_SRGBA_8X5 = 108] = "ASTC_SRGBA_8X5"; + t[t.ASTC_SRGBA_8X6 = 109] = "ASTC_SRGBA_8X6"; + t[t.ASTC_SRGBA_8X8 = 110] = "ASTC_SRGBA_8X8"; + t[t.ASTC_SRGBA_10X5 = 111] = "ASTC_SRGBA_10X5"; + t[t.ASTC_SRGBA_10X6 = 112] = "ASTC_SRGBA_10X6"; + t[t.ASTC_SRGBA_10X8 = 113] = "ASTC_SRGBA_10X8"; + t[t.ASTC_SRGBA_10X10 = 114] = "ASTC_SRGBA_10X10"; + t[t.ASTC_SRGBA_12X10 = 115] = "ASTC_SRGBA_12X10"; + t[t.ASTC_SRGBA_12X12 = 116] = "ASTC_SRGBA_12X12"; + t[t.COUNT = 117] = "COUNT"; + }(bs || (bs = {})); + let Ss; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.UNORM = 1] = "UNORM"; + t[t.SNORM = 2] = "SNORM"; + t[t.UINT = 3] = "UINT"; + t[t.INT = 4] = "INT"; + t[t.UFLOAT = 5] = "UFLOAT"; + t[t.FLOAT = 6] = "FLOAT"; + }(Ss || (Ss = {})); + let As; + !function(t) { + t[t.UNKNOWN = 0] = "UNKNOWN"; + t[t.BOOL = 1] = "BOOL"; + t[t.BOOL2 = 2] = "BOOL2"; + t[t.BOOL3 = 3] = "BOOL3"; + t[t.BOOL4 = 4] = "BOOL4"; + t[t.INT = 5] = "INT"; + t[t.INT2 = 6] = "INT2"; + t[t.INT3 = 7] = "INT3"; + t[t.INT4 = 8] = "INT4"; + t[t.UINT = 9] = "UINT"; + t[t.UINT2 = 10] = "UINT2"; + t[t.UINT3 = 11] = "UINT3"; + t[t.UINT4 = 12] = "UINT4"; + t[t.FLOAT = 13] = "FLOAT"; + t[t.FLOAT2 = 14] = "FLOAT2"; + t[t.FLOAT3 = 15] = "FLOAT3"; + t[t.FLOAT4 = 16] = "FLOAT4"; + t[t.MAT2 = 17] = "MAT2"; + t[t.MAT2X3 = 18] = "MAT2X3"; + t[t.MAT2X4 = 19] = "MAT2X4"; + t[t.MAT3X2 = 20] = "MAT3X2"; + t[t.MAT3 = 21] = "MAT3"; + t[t.MAT3X4 = 22] = "MAT3X4"; + t[t.MAT4X2 = 23] = "MAT4X2"; + t[t.MAT4X3 = 24] = "MAT4X3"; + t[t.MAT4 = 25] = "MAT4"; + t[t.SAMPLER1D = 26] = "SAMPLER1D"; + t[t.SAMPLER1D_ARRAY = 27] = "SAMPLER1D_ARRAY"; + t[t.SAMPLER2D = 28] = "SAMPLER2D"; + t[t.SAMPLER2D_ARRAY = 29] = "SAMPLER2D_ARRAY"; + t[t.SAMPLER3D = 30] = "SAMPLER3D"; + t[t.SAMPLER_CUBE = 31] = "SAMPLER_CUBE"; + t[t.SAMPLER = 32] = "SAMPLER"; + t[t.TEXTURE1D = 33] = "TEXTURE1D"; + t[t.TEXTURE1D_ARRAY = 34] = "TEXTURE1D_ARRAY"; + t[t.TEXTURE2D = 35] = "TEXTURE2D"; + t[t.TEXTURE2D_ARRAY = 36] = "TEXTURE2D_ARRAY"; + t[t.TEXTURE3D = 37] = "TEXTURE3D"; + t[t.TEXTURE_CUBE = 38] = "TEXTURE_CUBE"; + t[t.IMAGE1D = 39] = "IMAGE1D"; + t[t.IMAGE1D_ARRAY = 40] = "IMAGE1D_ARRAY"; + t[t.IMAGE2D = 41] = "IMAGE2D"; + t[t.IMAGE2D_ARRAY = 42] = "IMAGE2D_ARRAY"; + t[t.IMAGE3D = 43] = "IMAGE3D"; + t[t.IMAGE_CUBE = 44] = "IMAGE_CUBE"; + t[t.SUBPASS_INPUT = 45] = "SUBPASS_INPUT"; + t[t.COUNT = 46] = "COUNT"; + }(As || (As = {})); + let Ts; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.TRANSFER_SRC = 1] = "TRANSFER_SRC"; + t[t.TRANSFER_DST = 2] = "TRANSFER_DST"; + t[t.INDEX = 4] = "INDEX"; + t[t.VERTEX = 8] = "VERTEX"; + t[t.UNIFORM = 16] = "UNIFORM"; + t[t.STORAGE = 32] = "STORAGE"; + t[t.INDIRECT = 64] = "INDIRECT"; + }(Ts || (Ts = {})); + let vs; + !function(t) { + t[t.NONE = 0] = "NONE"; + }(vs || (vs = {})); + let Es; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.READ_ONLY = 1] = "READ_ONLY"; + t[t.WRITE_ONLY = 2] = "WRITE_ONLY"; + t[t.READ_WRITE = 3] = "READ_WRITE"; + }(Es || (Es = {})); + let Cs; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.DEVICE = 1] = "DEVICE"; + t[t.HOST = 2] = "HOST"; + }(Cs || (Cs = {})); + let xs; + !function(t) { + t[t.TEX1D = 0] = "TEX1D"; + t[t.TEX2D = 1] = "TEX2D"; + t[t.TEX3D = 2] = "TEX3D"; + t[t.CUBE = 3] = "CUBE"; + t[t.TEX1D_ARRAY = 4] = "TEX1D_ARRAY"; + t[t.TEX2D_ARRAY = 5] = "TEX2D_ARRAY"; + }(xs || (xs = {})); + let ws; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.TRANSFER_SRC = 1] = "TRANSFER_SRC"; + t[t.TRANSFER_DST = 2] = "TRANSFER_DST"; + t[t.SAMPLED = 4] = "SAMPLED"; + t[t.STORAGE = 8] = "STORAGE"; + t[t.COLOR_ATTACHMENT = 16] = "COLOR_ATTACHMENT"; + t[t.DEPTH_STENCIL_ATTACHMENT = 32] = "DEPTH_STENCIL_ATTACHMENT"; + t[t.INPUT_ATTACHMENT = 64] = "INPUT_ATTACHMENT"; + }(ws || (ws = {})); + let Rs; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.GEN_MIPMAP = 1] = "GEN_MIPMAP"; + t[t.GENERAL_LAYOUT = 2] = "GENERAL_LAYOUT"; + }(Rs || (Rs = {})); + let Is; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.RENDER_TARGET = 1] = "RENDER_TARGET"; + t[t.SAMPLED_TEXTURE = 2] = "SAMPLED_TEXTURE"; + t[t.LINEAR_FILTER = 4] = "LINEAR_FILTER"; + t[t.STORAGE_TEXTURE = 8] = "STORAGE_TEXTURE"; + t[t.VERTEX_ATTRIBUTE = 16] = "VERTEX_ATTRIBUTE"; + }(Is || (Is = {})); + let Ms; + !function(t) { + t[t.ONE = 0] = "ONE"; + t[t.MULTIPLE_PERFORMANCE = 1] = "MULTIPLE_PERFORMANCE"; + t[t.MULTIPLE_BALANCE = 2] = "MULTIPLE_BALANCE"; + t[t.MULTIPLE_QUALITY = 3] = "MULTIPLE_QUALITY"; + }(Ms || (Ms = {})); + let Bs; + !function(t) { + t[t.OFF = 0] = "OFF"; + t[t.ON = 1] = "ON"; + t[t.RELAXED = 2] = "RELAXED"; + t[t.MAILBOX = 3] = "MAILBOX"; + t[t.HALF = 4] = "HALF"; + }(Bs || (Bs = {})); + let Ds; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.POINT = 1] = "POINT"; + t[t.LINEAR = 2] = "LINEAR"; + t[t.ANISOTROPIC = 3] = "ANISOTROPIC"; + }(Ds || (Ds = {})); + let Ps; + !function(t) { + t[t.WRAP = 0] = "WRAP"; + t[t.MIRROR = 1] = "MIRROR"; + t[t.CLAMP = 2] = "CLAMP"; + t[t.BORDER = 3] = "BORDER"; + }(Ps || (Ps = {})); + let Os; + !function(t) { + t[t.NEVER = 0] = "NEVER"; + t[t.LESS = 1] = "LESS"; + t[t.EQUAL = 2] = "EQUAL"; + t[t.LESS_EQUAL = 3] = "LESS_EQUAL"; + t[t.GREATER = 4] = "GREATER"; + t[t.NOT_EQUAL = 5] = "NOT_EQUAL"; + t[t.GREATER_EQUAL = 6] = "GREATER_EQUAL"; + t[t.ALWAYS = 7] = "ALWAYS"; + }(Os || (Os = {})); + let Ns; + !function(t) { + t[t.ZERO = 0] = "ZERO"; + t[t.KEEP = 1] = "KEEP"; + t[t.REPLACE = 2] = "REPLACE"; + t[t.INCR = 3] = "INCR"; + t[t.DECR = 4] = "DECR"; + t[t.INVERT = 5] = "INVERT"; + t[t.INCR_WRAP = 6] = "INCR_WRAP"; + t[t.DECR_WRAP = 7] = "DECR_WRAP"; + }(Ns || (Ns = {})); + let Ls; + !function(t) { + t[t.ZERO = 0] = "ZERO"; + t[t.ONE = 1] = "ONE"; + t[t.SRC_ALPHA = 2] = "SRC_ALPHA"; + t[t.DST_ALPHA = 3] = "DST_ALPHA"; + t[t.ONE_MINUS_SRC_ALPHA = 4] = "ONE_MINUS_SRC_ALPHA"; + t[t.ONE_MINUS_DST_ALPHA = 5] = "ONE_MINUS_DST_ALPHA"; + t[t.SRC_COLOR = 6] = "SRC_COLOR"; + t[t.DST_COLOR = 7] = "DST_COLOR"; + t[t.ONE_MINUS_SRC_COLOR = 8] = "ONE_MINUS_SRC_COLOR"; + t[t.ONE_MINUS_DST_COLOR = 9] = "ONE_MINUS_DST_COLOR"; + t[t.SRC_ALPHA_SATURATE = 10] = "SRC_ALPHA_SATURATE"; + t[t.CONSTANT_COLOR = 11] = "CONSTANT_COLOR"; + t[t.ONE_MINUS_CONSTANT_COLOR = 12] = "ONE_MINUS_CONSTANT_COLOR"; + t[t.CONSTANT_ALPHA = 13] = "CONSTANT_ALPHA"; + t[t.ONE_MINUS_CONSTANT_ALPHA = 14] = "ONE_MINUS_CONSTANT_ALPHA"; + }(Ls || (Ls = {})); + let Fs; + !function(t) { + t[t.ADD = 0] = "ADD"; + t[t.SUB = 1] = "SUB"; + t[t.REV_SUB = 2] = "REV_SUB"; + t[t.MIN = 3] = "MIN"; + t[t.MAX = 4] = "MAX"; + }(Fs || (Fs = {})); + let Vs; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.R = 1] = "R"; + t[t.G = 2] = "G"; + t[t.B = 4] = "B"; + t[t.A = 8] = "A"; + t[t.ALL = 15] = "ALL"; + }(Vs || (Vs = {})); + let ks; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.VERTEX = 1] = "VERTEX"; + t[t.CONTROL = 2] = "CONTROL"; + t[t.EVALUATION = 4] = "EVALUATION"; + t[t.GEOMETRY = 8] = "GEOMETRY"; + t[t.FRAGMENT = 16] = "FRAGMENT"; + t[t.COMPUTE = 32] = "COMPUTE"; + t[t.ALL = 63] = "ALL"; + }(ks || (ks = {})); + let Us; + !function(t) { + t[t.LOAD = 0] = "LOAD"; + t[t.CLEAR = 1] = "CLEAR"; + t[t.DISCARD = 2] = "DISCARD"; + }(Us || (Us = {})); + let Gs; + !function(t) { + t[t.STORE = 0] = "STORE"; + t[t.DISCARD = 1] = "DISCARD"; + }(Gs || (Gs = {})); + let zs; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.INDIRECT_BUFFER = 1] = "INDIRECT_BUFFER"; + t[t.INDEX_BUFFER = 2] = "INDEX_BUFFER"; + t[t.VERTEX_BUFFER = 4] = "VERTEX_BUFFER"; + t[t.VERTEX_SHADER_READ_UNIFORM_BUFFER = 8] = "VERTEX_SHADER_READ_UNIFORM_BUFFER"; + t[t.VERTEX_SHADER_READ_TEXTURE = 16] = "VERTEX_SHADER_READ_TEXTURE"; + t[t.VERTEX_SHADER_READ_OTHER = 32] = "VERTEX_SHADER_READ_OTHER"; + t[t.FRAGMENT_SHADER_READ_UNIFORM_BUFFER = 64] = "FRAGMENT_SHADER_READ_UNIFORM_BUFFER"; + t[t.FRAGMENT_SHADER_READ_TEXTURE = 128] = "FRAGMENT_SHADER_READ_TEXTURE"; + t[t.FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT = 256] = "FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT"; + t[t.FRAGMENT_SHADER_READ_DEPTH_STENCIL_INPUT_ATTACHMENT = 512] = "FRAGMENT_SHADER_READ_DEPTH_STENCIL_INPUT_ATTACHMENT"; + t[t.FRAGMENT_SHADER_READ_OTHER = 1024] = "FRAGMENT_SHADER_READ_OTHER"; + t[t.COLOR_ATTACHMENT_READ = 2048] = "COLOR_ATTACHMENT_READ"; + t[t.DEPTH_STENCIL_ATTACHMENT_READ = 4096] = "DEPTH_STENCIL_ATTACHMENT_READ"; + t[t.COMPUTE_SHADER_READ_UNIFORM_BUFFER = 8192] = "COMPUTE_SHADER_READ_UNIFORM_BUFFER"; + t[t.COMPUTE_SHADER_READ_TEXTURE = 16384] = "COMPUTE_SHADER_READ_TEXTURE"; + t[t.COMPUTE_SHADER_READ_OTHER = 32768] = "COMPUTE_SHADER_READ_OTHER"; + t[t.TRANSFER_READ = 65536] = "TRANSFER_READ"; + t[t.HOST_READ = 131072] = "HOST_READ"; + t[t.PRESENT = 262144] = "PRESENT"; + t[t.VERTEX_SHADER_WRITE = 524288] = "VERTEX_SHADER_WRITE"; + t[t.FRAGMENT_SHADER_WRITE = 1048576] = "FRAGMENT_SHADER_WRITE"; + t[t.COLOR_ATTACHMENT_WRITE = 2097152] = "COLOR_ATTACHMENT_WRITE"; + t[t.DEPTH_STENCIL_ATTACHMENT_WRITE = 4194304] = "DEPTH_STENCIL_ATTACHMENT_WRITE"; + t[t.COMPUTE_SHADER_WRITE = 8388608] = "COMPUTE_SHADER_WRITE"; + t[t.TRANSFER_WRITE = 16777216] = "TRANSFER_WRITE"; + t[t.HOST_PREINITIALIZED = 33554432] = "HOST_PREINITIALIZED"; + t[t.HOST_WRITE = 67108864] = "HOST_WRITE"; + }(zs || (zs = {})); + let Hs; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.SAMPLE_ZERO = 1] = "SAMPLE_ZERO"; + t[t.AVERAGE = 2] = "AVERAGE"; + t[t.MIN = 3] = "MIN"; + t[t.MAX = 4] = "MAX"; + }(Hs || (Hs = {})); + let js; + !function(t) { + t[t.GRAPHICS = 0] = "GRAPHICS"; + t[t.COMPUTE = 1] = "COMPUTE"; + t[t.RAY_TRACING = 2] = "RAY_TRACING"; + }(js || (js = {})); + let Xs; + !function(t) { + t[t.POINT_LIST = 0] = "POINT_LIST"; + t[t.LINE_LIST = 1] = "LINE_LIST"; + t[t.LINE_STRIP = 2] = "LINE_STRIP"; + t[t.LINE_LOOP = 3] = "LINE_LOOP"; + t[t.LINE_LIST_ADJACENCY = 4] = "LINE_LIST_ADJACENCY"; + t[t.LINE_STRIP_ADJACENCY = 5] = "LINE_STRIP_ADJACENCY"; + t[t.ISO_LINE_LIST = 6] = "ISO_LINE_LIST"; + t[t.TRIANGLE_LIST = 7] = "TRIANGLE_LIST"; + t[t.TRIANGLE_STRIP = 8] = "TRIANGLE_STRIP"; + t[t.TRIANGLE_FAN = 9] = "TRIANGLE_FAN"; + t[t.TRIANGLE_LIST_ADJACENCY = 10] = "TRIANGLE_LIST_ADJACENCY"; + t[t.TRIANGLE_STRIP_ADJACENCY = 11] = "TRIANGLE_STRIP_ADJACENCY"; + t[t.TRIANGLE_PATCH_ADJACENCY = 12] = "TRIANGLE_PATCH_ADJACENCY"; + t[t.QUAD_PATCH_LIST = 13] = "QUAD_PATCH_LIST"; + }(Xs || (Xs = {})); + let Ws; + !function(t) { + t[t.FILL = 0] = "FILL"; + t[t.POINT = 1] = "POINT"; + t[t.LINE = 2] = "LINE"; + }(Ws || (Ws = {})); + let Ys; + !function(t) { + t[t.GOURAND = 0] = "GOURAND"; + t[t.FLAT = 1] = "FLAT"; + }(Ys || (Ys = {})); + let qs; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.FRONT = 1] = "FRONT"; + t[t.BACK = 2] = "BACK"; + }(qs || (qs = {})); + let Ks; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.LINE_WIDTH = 1] = "LINE_WIDTH"; + t[t.DEPTH_BIAS = 2] = "DEPTH_BIAS"; + t[t.BLEND_CONSTANTS = 4] = "BLEND_CONSTANTS"; + t[t.DEPTH_BOUNDS = 8] = "DEPTH_BOUNDS"; + t[t.STENCIL_WRITE_MASK = 16] = "STENCIL_WRITE_MASK"; + t[t.STENCIL_COMPARE_MASK = 32] = "STENCIL_COMPARE_MASK"; + }(Ks || (Ks = {})); + let Js; + !function(t) { + t[t.FRONT = 1] = "FRONT"; + t[t.BACK = 2] = "BACK"; + t[t.ALL = 3] = "ALL"; + }(Js || (Js = {})); + let Zs; + !function(t) { + t[t.UNKNOWN = 0] = "UNKNOWN"; + t[t.UNIFORM_BUFFER = 1] = "UNIFORM_BUFFER"; + t[t.DYNAMIC_UNIFORM_BUFFER = 2] = "DYNAMIC_UNIFORM_BUFFER"; + t[t.STORAGE_BUFFER = 4] = "STORAGE_BUFFER"; + t[t.DYNAMIC_STORAGE_BUFFER = 8] = "DYNAMIC_STORAGE_BUFFER"; + t[t.SAMPLER_TEXTURE = 16] = "SAMPLER_TEXTURE"; + t[t.SAMPLER = 32] = "SAMPLER"; + t[t.TEXTURE = 64] = "TEXTURE"; + t[t.STORAGE_IMAGE = 128] = "STORAGE_IMAGE"; + t[t.INPUT_ATTACHMENT = 256] = "INPUT_ATTACHMENT"; + }(Zs || (Zs = {})); + let Qs; + !function(t) { + t[t.GRAPHICS = 0] = "GRAPHICS"; + t[t.COMPUTE = 1] = "COMPUTE"; + t[t.TRANSFER = 2] = "TRANSFER"; + }(Qs || (Qs = {})); + let $s; + !function(t) { + t[t.OCCLUSION = 0] = "OCCLUSION"; + t[t.PIPELINE_STATISTICS = 1] = "PIPELINE_STATISTICS"; + t[t.TIMESTAMP = 2] = "TIMESTAMP"; + }($s || ($s = {})); + let tn; + !function(t) { + t[t.PRIMARY = 0] = "PRIMARY"; + t[t.SECONDARY = 1] = "SECONDARY"; + }(tn || (tn = {})); + let en; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.COLOR = 1] = "COLOR"; + t[t.DEPTH = 2] = "DEPTH"; + t[t.STENCIL = 4] = "STENCIL"; + t[t.DEPTH_STENCIL = 6] = "DEPTH_STENCIL"; + t[t.ALL = 7] = "ALL"; + }(en || (en = {})); + let sn; + !function(t) { + t[t.FULL = 0] = "FULL"; + t[t.SPLIT_BEGIN = 1] = "SPLIT_BEGIN"; + t[t.SPLIT_END = 2] = "SPLIT_END"; + }(sn || (sn = {})); + let nn; + !function(t) { + t[t.RASTER = 0] = "RASTER"; + t[t.COMPUTE = 1] = "COMPUTE"; + t[t.COPY = 2] = "COPY"; + t[t.MOVE = 3] = "MOVE"; + t[t.RAYTRACE = 4] = "RAYTRACE"; + t[t.PRESENT = 5] = "PRESENT"; + }(nn || (nn = {})); + class rn { + constructor(t = 0, e = 0, i = 0) { + this.x = t; + this.y = e; + this.z = i; + } + copy(t) { + this.x = t.x; + this.y = t.y; + this.z = t.z; + return this; + } + } + class on { + constructor(t = 0, e = 0, i = 0, s = 0, n = 0, r = 0, o = 0, a = 0, l = 0, h = 0, c = 0, u = 0, _ = 0, d = 1, p = 0, m = 0, f = new rn, g = new rn, y = !1, b = -1, S = 1, A = 1) { + this.maxVertexAttributes = t; + this.maxVertexUniformVectors = e; + this.maxFragmentUniformVectors = i; + this.maxTextureUnits = s; + this.maxImageUnits = n; + this.maxVertexTextureUnits = r; + this.maxColorRenderTargets = o; + this.maxShaderStorageBufferBindings = a; + this.maxShaderStorageBlockSize = l; + this.maxUniformBufferBindings = h; + this.maxUniformBlockSize = c; + this.maxTextureSize = u; + this.maxCubeMapTextureSize = _; + this.uboOffsetAlignment = d; + this.maxComputeSharedMemorySize = p; + this.maxComputeWorkGroupInvocations = m; + this.maxComputeWorkGroupSize = f; + this.maxComputeWorkGroupCount = g; + this.supportQuery = y; + this.clipSpaceMinZ = b; + this.screenSpaceSignY = S; + this.clipSpaceSignY = A; + } + copy(t) { + this.maxVertexAttributes = t.maxVertexAttributes; + this.maxVertexUniformVectors = t.maxVertexUniformVectors; + this.maxFragmentUniformVectors = t.maxFragmentUniformVectors; + this.maxTextureUnits = t.maxTextureUnits; + this.maxImageUnits = t.maxImageUnits; + this.maxVertexTextureUnits = t.maxVertexTextureUnits; + this.maxColorRenderTargets = t.maxColorRenderTargets; + this.maxShaderStorageBufferBindings = t.maxShaderStorageBufferBindings; + this.maxShaderStorageBlockSize = t.maxShaderStorageBlockSize; + this.maxUniformBufferBindings = t.maxUniformBufferBindings; + this.maxUniformBlockSize = t.maxUniformBlockSize; + this.maxTextureSize = t.maxTextureSize; + this.maxCubeMapTextureSize = t.maxCubeMapTextureSize; + this.uboOffsetAlignment = t.uboOffsetAlignment; + this.maxComputeSharedMemorySize = t.maxComputeSharedMemorySize; + this.maxComputeWorkGroupInvocations = t.maxComputeWorkGroupInvocations; + this.maxComputeWorkGroupSize.copy(t.maxComputeWorkGroupSize); + this.maxComputeWorkGroupCount.copy(t.maxComputeWorkGroupCount); + this.supportQuery = t.supportQuery; + this.clipSpaceMinZ = t.clipSpaceMinZ; + this.screenSpaceSignY = t.screenSpaceSignY; + this.clipSpaceSignY = t.clipSpaceSignY; + return this; + } + } + class an { + constructor(t = !0) { + this.enableBarrierDeduce = t; + } + copy(t) { + this.enableBarrierDeduce = t.enableBarrierDeduce; + return this; + } + } + class ln { + constructor(t = 0, e = 0, i = 0) { + this.x = t; + this.y = e; + this.z = i; + } + copy(t) { + this.x = t.x; + this.y = t.y; + this.z = t.z; + return this; + } + } + class hn { + constructor(t = 0, e = 0, i = 0, s = 0) { + this.x = t; + this.y = e; + this.width = i; + this.height = s; + } + copy(t) { + this.x = t.x; + this.y = t.y; + this.width = t.width; + this.height = t.height; + return this; + } + } + class cn { + constructor(t = 0, e = 0, i = 1) { + this.width = t; + this.height = e; + this.depth = i; + } + copy(t) { + this.width = t.width; + this.height = t.height; + this.depth = t.depth; + return this; + } + } + class un { + constructor(t = 0, e = 0, i = 1) { + this.mipLevel = t; + this.baseArrayLayer = e; + this.layerCount = i; + } + copy(t) { + this.mipLevel = t.mipLevel; + this.baseArrayLayer = t.baseArrayLayer; + this.layerCount = t.layerCount; + return this; + } + } + class _n { + constructor(t = 0, e = 1, i = 0, s = 1) { + this.baseMipLevel = t; + this.levelCount = e; + this.baseArrayLayer = i; + this.layerCount = s; + } + copy(t) { + this.baseMipLevel = t.baseMipLevel; + this.levelCount = t.levelCount; + this.baseArrayLayer = t.baseArrayLayer; + this.layerCount = t.layerCount; + return this; + } + } + class dn { + constructor(t = new un, e = new ln, i = new un, s = new ln, n = new cn) { + this.srcSubres = t; + this.srcOffset = e; + this.dstSubres = i; + this.dstOffset = s; + this.extent = n; + } + copy(t) { + this.srcSubres.copy(t.srcSubres); + this.srcOffset.copy(t.srcOffset); + this.dstSubres.copy(t.dstSubres); + this.dstOffset.copy(t.dstOffset); + this.extent.copy(t.extent); + return this; + } + } + class pn { + constructor(t = new un, e = new ln, i = new cn, s = new un, n = new ln, r = new cn) { + this.srcSubres = t; + this.srcOffset = e; + this.srcExtent = i; + this.dstSubres = s; + this.dstOffset = n; + this.dstExtent = r; + } + copy(t) { + this.srcSubres.copy(t.srcSubres); + this.srcOffset.copy(t.srcOffset); + this.srcExtent.copy(t.srcExtent); + this.dstSubres.copy(t.dstSubres); + this.dstOffset.copy(t.dstOffset); + this.dstExtent.copy(t.dstExtent); + return this; + } + } + class mn { + constructor(t = 0, e = 0, i = 0, s = new ln, n = new cn, r = new un) { + this.buffOffset = t; + this.buffStride = e; + this.buffTexHeight = i; + this.texOffset = s; + this.texExtent = n; + this.texSubres = r; + } + copy(t) { + this.buffOffset = t.buffOffset; + this.buffStride = t.buffStride; + this.buffTexHeight = t.buffTexHeight; + this.texOffset.copy(t.texOffset); + this.texExtent.copy(t.texExtent); + this.texSubres.copy(t.texSubres); + return this; + } + } + class fn { + constructor(t = 0, e = 0, i = 0, s = 0, n = 0, r = 1) { + this.left = t; + this.top = e; + this.width = i; + this.height = s; + this.minDepth = n; + this.maxDepth = r; + } + copy(t) { + this.left = t.left; + this.top = t.top; + this.width = t.width; + this.height = t.height; + this.minDepth = t.minDepth; + this.maxDepth = t.maxDepth; + return this; + } + } + class gn { + constructor(t = 0, e = 0, i = 0, s = 0) { + this.x = t; + this.y = e; + this.z = i; + this.w = s; + } + copy(t) { + this.x = t.x; + this.y = t.y; + this.z = t.z; + this.w = t.w; + return this; + } + } + class yn { + constructor(t = [ 0 ], e = [ 0 ], i = [ 0 ], s = [ 0 ], n = [ 0 ], r = [ 0 ], o = [ 0 ], a = [ 0 ]) { + this.maxBlockCounts = t; + this.maxSamplerTextureCounts = e; + this.maxSamplerCounts = i; + this.maxTextureCounts = s; + this.maxBufferCounts = n; + this.maxImageCounts = r; + this.maxSubpassInputCounts = o; + this.setIndices = a; + } + copy(t) { + this.maxBlockCounts = t.maxBlockCounts.slice(); + this.maxSamplerTextureCounts = t.maxSamplerTextureCounts.slice(); + this.maxSamplerCounts = t.maxSamplerCounts.slice(); + this.maxTextureCounts = t.maxTextureCounts.slice(); + this.maxBufferCounts = t.maxBufferCounts.slice(); + this.maxImageCounts = t.maxImageCounts.slice(); + this.maxSubpassInputCounts = t.maxSubpassInputCounts.slice(); + this.setIndices = t.setIndices.slice(); + return this; + } + } + class bn { + constructor(t = null, e = Bs.ON, i = 0, s = 0) { + this.windowHandle = t; + this.vsyncMode = e; + this.width = i; + this.height = s; + } + copy(t) { + this.windowHandle = t.windowHandle; + this.vsyncMode = t.vsyncMode; + this.width = t.width; + this.height = t.height; + return this; + } + } + class Sn { + constructor(t = new yn) { + this.bindingMappingInfo = t; + } + copy(t) { + this.bindingMappingInfo.copy(t.bindingMappingInfo); + return this; + } + } + class An { + constructor(t = Ts.NONE, e = Cs.NONE, i = 0, s = 1, n = vs.NONE) { + this.usage = t; + this.memUsage = e; + this.size = i; + this.stride = s; + this.flags = n; + } + copy(t) { + this.usage = t.usage; + this.memUsage = t.memUsage; + this.size = t.size; + this.stride = t.stride; + this.flags = t.flags; + return this; + } + } + class Tn { + constructor(t = null, e = 0, i = 0) { + this.buffer = t; + this.offset = e; + this.range = i; + } + copy(t) { + this.buffer = t.buffer; + this.offset = t.offset; + this.range = t.range; + return this; + } + } + class vn { + constructor(t = 0, e = 0, i = 0, s = 0, n = 0, r = 0, o = 0) { + this.vertexCount = t; + this.firstVertex = e; + this.indexCount = i; + this.firstIndex = s; + this.vertexOffset = n; + this.instanceCount = r; + this.firstInstance = o; + } + copy(t) { + this.vertexCount = t.vertexCount; + this.firstVertex = t.firstVertex; + this.indexCount = t.indexCount; + this.firstIndex = t.firstIndex; + this.vertexOffset = t.vertexOffset; + this.instanceCount = t.instanceCount; + this.firstInstance = t.firstInstance; + return this; + } + } + class En { + constructor(t = 0, e = 0, i = 0, s = null, n = 0) { + this.groupCountX = t; + this.groupCountY = e; + this.groupCountZ = i; + this.indirectBuffer = s; + this.indirectOffset = n; + } + copy(t) { + this.groupCountX = t.groupCountX; + this.groupCountY = t.groupCountY; + this.groupCountZ = t.groupCountZ; + this.indirectBuffer = t.indirectBuffer; + this.indirectOffset = t.indirectOffset; + return this; + } + } + class Cn { + constructor(t = []) { + this.drawInfos = t; + } + copy(t) { + ds(this.drawInfos, t.drawInfos, vn); + return this; + } + } + class xn { + constructor(t = xs.TEX2D, e = ws.NONE, i = bs.UNKNOWN, s = 0, n = 0, r = Rs.NONE, o = 1, a = 1, l = Ms.ONE, h = 1, c = 0) { + this.type = t; + this.usage = e; + this.format = i; + this.width = s; + this.height = n; + this.flags = r; + this.layerCount = o; + this.levelCount = a; + this.samples = l; + this.depth = h; + this.externalRes = c; + } + copy(t) { + this.type = t.type; + this.usage = t.usage; + this.format = t.format; + this.width = t.width; + this.height = t.height; + this.flags = t.flags; + this.layerCount = t.layerCount; + this.levelCount = t.levelCount; + this.samples = t.samples; + this.depth = t.depth; + this.externalRes = t.externalRes; + return this; + } + } + class wn { + constructor(t = null, e = xs.TEX2D, i = bs.UNKNOWN, s = 0, n = 1, r = 0, o = 1) { + this.texture = t; + this.type = e; + this.format = i; + this.baseLevel = s; + this.levelCount = n; + this.baseLayer = r; + this.layerCount = o; + } + copy(t) { + this.texture = t.texture; + this.type = t.type; + this.format = t.format; + this.baseLevel = t.baseLevel; + this.levelCount = t.levelCount; + this.baseLayer = t.baseLayer; + this.layerCount = t.layerCount; + return this; + } + } + class Rn { + constructor(t = Ds.LINEAR, e = Ds.LINEAR, i = Ds.NONE, s = Ps.WRAP, n = Ps.WRAP, r = Ps.WRAP, o = 0, a = Os.ALWAYS) { + this.minFilter = t; + this.magFilter = e; + this.mipFilter = i; + this.addressU = s; + this.addressV = n; + this.addressW = r; + this.maxAnisotropy = o; + this.cmpFunc = a; + } + copy(t) { + this.minFilter = t.minFilter; + this.magFilter = t.magFilter; + this.mipFilter = t.mipFilter; + this.addressU = t.addressU; + this.addressV = t.addressV; + this.addressW = t.addressW; + this.maxAnisotropy = t.maxAnisotropy; + this.cmpFunc = t.cmpFunc; + return this; + } + } + class In { + constructor(t = "", e = As.UNKNOWN, i = 0) { + this.name = t; + this.type = e; + this.count = i; + } + copy(t) { + this.name = t.name; + this.type = t.type; + this.count = t.count; + return this; + } + } + class Mn { + constructor(t = 0, e = 0, i = "", s = [], n = 0) { + this.set = t; + this.binding = e; + this.name = i; + this.members = s; + this.count = n; + } + copy(t) { + this.set = t.set; + this.binding = t.binding; + this.name = t.name; + ds(this.members, t.members, In); + this.count = t.count; + return this; + } + } + class Bn { + constructor(t = 0, e = 0, i = "", s = As.UNKNOWN, n = 0) { + this.set = t; + this.binding = e; + this.name = i; + this.type = s; + this.count = n; + } + copy(t) { + this.set = t.set; + this.binding = t.binding; + this.name = t.name; + this.type = t.type; + this.count = t.count; + return this; + } + } + class Dn { + constructor(t = 0, e = 0, i = "", s = 0) { + this.set = t; + this.binding = e; + this.name = i; + this.count = s; + } + copy(t) { + this.set = t.set; + this.binding = t.binding; + this.name = t.name; + this.count = t.count; + return this; + } + } + class Pn { + constructor(t = 0, e = 0, i = "", s = As.UNKNOWN, n = 0) { + this.set = t; + this.binding = e; + this.name = i; + this.type = s; + this.count = n; + } + copy(t) { + this.set = t.set; + this.binding = t.binding; + this.name = t.name; + this.type = t.type; + this.count = t.count; + return this; + } + } + class On { + constructor(t = 0, e = 0, i = "", s = As.UNKNOWN, n = 0, r = Es.READ_WRITE) { + this.set = t; + this.binding = e; + this.name = i; + this.type = s; + this.count = n; + this.memoryAccess = r; + } + copy(t) { + this.set = t.set; + this.binding = t.binding; + this.name = t.name; + this.type = t.type; + this.count = t.count; + this.memoryAccess = t.memoryAccess; + return this; + } + } + class Nn { + constructor(t = 0, e = 0, i = "", s = 0, n = Es.READ_WRITE) { + this.set = t; + this.binding = e; + this.name = i; + this.count = s; + this.memoryAccess = n; + } + copy(t) { + this.set = t.set; + this.binding = t.binding; + this.name = t.name; + this.count = t.count; + this.memoryAccess = t.memoryAccess; + return this; + } + } + class Ln { + constructor(t = 0, e = 0, i = "", s = 0) { + this.set = t; + this.binding = e; + this.name = i; + this.count = s; + } + copy(t) { + this.set = t.set; + this.binding = t.binding; + this.name = t.name; + this.count = t.count; + return this; + } + } + class Fn { + constructor(t = ks.NONE, e = "") { + this.stage = t; + this.source = e; + } + copy(t) { + this.stage = t.stage; + this.source = t.source; + return this; + } + } + class Vn { + constructor(t = "", e = bs.UNKNOWN, i = !1, s = 0, n = !1, r = 0) { + this.name = t; + this.format = e; + this.isNormalized = i; + this.stream = s; + this.isInstanced = n; + this.location = r; + } + copy(t) { + this.name = t.name; + this.format = t.format; + this.isNormalized = t.isNormalized; + this.stream = t.stream; + this.isInstanced = t.isInstanced; + this.location = t.location; + return this; + } + } + class kn { + constructor(t = "", e = [], i = [], s = [], n = [], r = [], o = [], a = [], l = [], h = []) { + this.name = t; + this.stages = e; + this.attributes = i; + this.blocks = s; + this.buffers = n; + this.samplerTextures = r; + this.samplers = o; + this.textures = a; + this.images = l; + this.subpassInputs = h; + } + copy(t) { + this.name = t.name; + ds(this.stages, t.stages, Fn); + ds(this.attributes, t.attributes, Vn); + ds(this.blocks, t.blocks, Mn); + ds(this.buffers, t.buffers, Nn); + ds(this.samplerTextures, t.samplerTextures, Bn); + ds(this.samplers, t.samplers, Dn); + ds(this.textures, t.textures, Pn); + ds(this.images, t.images, On); + ds(this.subpassInputs, t.subpassInputs, Ln); + return this; + } + } + class Un { + constructor(t = [], e = [], i = null, s = null) { + this.attributes = t; + this.vertexBuffers = e; + this.indexBuffer = i; + this.indirectBuffer = s; + } + copy(t) { + ds(this.attributes, t.attributes, Vn); + this.vertexBuffers = t.vertexBuffers.slice(); + this.indexBuffer = t.indexBuffer; + this.indirectBuffer = t.indirectBuffer; + return this; + } + } + class Gn { + constructor(t = bs.UNKNOWN, e = Ms.ONE, i = Us.CLEAR, s = Gs.STORE, n = null, r = !1) { + this.format = t; + this.sampleCount = e; + this.loadOp = i; + this.storeOp = s; + this.barrier = n; + this.isGeneralLayout = r; + } + copy(t) { + this.format = t.format; + this.sampleCount = t.sampleCount; + this.loadOp = t.loadOp; + this.storeOp = t.storeOp; + this.barrier = t.barrier; + this.isGeneralLayout = t.isGeneralLayout; + return this; + } + } + class zn { + constructor(t = bs.UNKNOWN, e = Ms.ONE, i = Us.CLEAR, s = Gs.STORE, n = Us.CLEAR, r = Gs.STORE, o = null, a = !1) { + this.format = t; + this.sampleCount = e; + this.depthLoadOp = i; + this.depthStoreOp = s; + this.stencilLoadOp = n; + this.stencilStoreOp = r; + this.barrier = o; + this.isGeneralLayout = a; + } + copy(t) { + this.format = t.format; + this.sampleCount = t.sampleCount; + this.depthLoadOp = t.depthLoadOp; + this.depthStoreOp = t.depthStoreOp; + this.stencilLoadOp = t.stencilLoadOp; + this.stencilStoreOp = t.stencilStoreOp; + this.barrier = t.barrier; + this.isGeneralLayout = t.isGeneralLayout; + return this; + } + } + class Hn { + constructor(t = [], e = [], i = [], s = [], n = -1, r = -1, o = Hs.NONE, a = Hs.NONE) { + this.inputs = t; + this.colors = e; + this.resolves = i; + this.preserves = s; + this.depthStencil = n; + this.depthStencilResolve = r; + this.depthResolveMode = o; + this.stencilResolveMode = a; + } + copy(t) { + this.inputs = t.inputs.slice(); + this.colors = t.colors.slice(); + this.resolves = t.resolves.slice(); + this.preserves = t.preserves.slice(); + this.depthStencil = t.depthStencil; + this.depthStencilResolve = t.depthStencilResolve; + this.depthResolveMode = t.depthResolveMode; + this.stencilResolveMode = t.stencilResolveMode; + return this; + } + } + class jn { + constructor(t = 0, e = 0, i = null, s = null, n = null, r = 0, o = null, a = null, l = 0) { + this.srcSubpass = t; + this.dstSubpass = e; + this.generalBarrier = i; + this.bufferBarriers = s; + this.buffers = n; + this.bufferBarrierCount = r; + this.textureBarriers = o; + this.textures = a; + this.textureBarrierCount = l; + } + copy(t) { + this.srcSubpass = t.srcSubpass; + this.dstSubpass = t.dstSubpass; + this.generalBarrier = t.generalBarrier; + this.bufferBarriers = t.bufferBarriers; + this.buffers = t.buffers; + this.bufferBarrierCount = t.bufferBarrierCount; + this.textureBarriers = t.textureBarriers; + this.textures = t.textures; + this.textureBarrierCount = t.textureBarrierCount; + return this; + } + } + class Xn { + constructor(t = [], e = new zn, i = [], s = []) { + this.colorAttachments = t; + this.depthStencilAttachment = e; + this.subpasses = i; + this.dependencies = s; + } + copy(t) { + ds(this.colorAttachments, t.colorAttachments, Gn); + this.depthStencilAttachment.copy(t.depthStencilAttachment); + ds(this.subpasses, t.subpasses, Hn); + ds(this.dependencies, t.dependencies, jn); + return this; + } + } + class Wn { + constructor(t = zs.NONE, e = zs.NONE, i = sn.FULL) { + this.prevAccesses = t; + this.nextAccesses = e; + this.type = i; + } + copy(t) { + this.prevAccesses = t.prevAccesses; + this.nextAccesses = t.nextAccesses; + this.type = t.type; + return this; + } + } + class Yn { + constructor(t = zs.NONE, e = zs.NONE, i = sn.FULL, s = 0, n = 1, r = 0, o = 1, a = !1, l = null, h = null) { + this.prevAccesses = t; + this.nextAccesses = e; + this.type = i; + this.baseMipLevel = s; + this.levelCount = n; + this.baseSlice = r; + this.sliceCount = o; + this.discardContents = a; + this.srcQueue = l; + this.dstQueue = h; + } + copy(t) { + this.prevAccesses = t.prevAccesses; + this.nextAccesses = t.nextAccesses; + this.type = t.type; + this.baseMipLevel = t.baseMipLevel; + this.levelCount = t.levelCount; + this.baseSlice = t.baseSlice; + this.sliceCount = t.sliceCount; + this.discardContents = t.discardContents; + this.srcQueue = t.srcQueue; + this.dstQueue = t.dstQueue; + return this; + } + } + class qn { + constructor(t = zs.NONE, e = zs.NONE, i = sn.FULL, s = 0, n = 0, r = !1, o = null, a = null) { + this.prevAccesses = t; + this.nextAccesses = e; + this.type = i; + this.offset = s; + this.size = n; + this.discardContents = r; + this.srcQueue = o; + this.dstQueue = a; + } + copy(t) { + this.prevAccesses = t.prevAccesses; + this.nextAccesses = t.nextAccesses; + this.type = t.type; + this.offset = t.offset; + this.size = t.size; + this.discardContents = t.discardContents; + this.srcQueue = t.srcQueue; + this.dstQueue = t.dstQueue; + return this; + } + } + class Kn { + constructor(t = null, e = [], i = null) { + this.renderPass = t; + this.colorTextures = e; + this.depthStencilTexture = i; + } + copy(t) { + this.renderPass = t.renderPass; + this.colorTextures = t.colorTextures.slice(); + this.depthStencilTexture = t.depthStencilTexture; + return this; + } + } + class Jn { + constructor(t = -1, e = Zs.UNKNOWN, i = 0, s = ks.NONE, n = []) { + this.binding = t; + this.descriptorType = e; + this.count = i; + this.stageFlags = s; + this.immutableSamplers = n; + } + copy(t) { + this.binding = t.binding; + this.descriptorType = t.descriptorType; + this.count = t.count; + this.stageFlags = t.stageFlags; + this.immutableSamplers = t.immutableSamplers.slice(); + return this; + } + } + class Zn { + constructor(t = []) { + this.bindings = t; + } + copy(t) { + ds(this.bindings, t.bindings, Jn); + return this; + } + } + class Qn { + constructor(t = null) { + this.layout = t; + } + copy(t) { + this.layout = t.layout; + return this; + } + } + class $n { + constructor(t = []) { + this.setLayouts = t; + } + copy(t) { + this.setLayouts = t.setLayouts.slice(); + return this; + } + } + class tr { + constructor(t = []) { + this.attributes = t; + } + copy(t) { + ds(this.attributes, t.attributes, Vn); + return this; + } + } + class er { + constructor(t = null, e = tn.PRIMARY) { + this.queue = t; + this.type = e; + } + copy(t) { + this.queue = t.queue; + this.type = t.type; + return this; + } + } + class ir { + constructor(t = Qs.GRAPHICS) { + this.type = t; + } + copy(t) { + this.type = t.type; + return this; + } + } + class sr { + constructor(t = $s.OCCLUSION, e = 32767, i = !0) { + this.type = t; + this.maxQueryObjects = e; + this.forceWait = i; + } + copy(t) { + this.type = t.type; + this.maxQueryObjects = t.maxQueryObjects; + this.forceWait = t.forceWait; + return this; + } + } + class rr { + constructor(t = "", e = 0, i = 0, s = Ss.NONE, n = !1, r = !1, o = !1, a = !1) { + this.name = t; + this.size = e; + this.count = i; + this.type = s; + this.hasAlpha = n; + this.hasDepth = r; + this.hasStencil = o; + this.isCompressed = a; + } + } + class or { + constructor(t = 0, e = 0) { + this.bufferSize = t; + this.textureSize = e; + } + copy(t) { + this.bufferSize = t.bufferSize; + this.textureSize = t.textureSize; + return this; + } + } + class ar { + constructor(t = 0, e = 0, i = 0) { + this.writeMask = t; + this.compareMask = e; + this.reference = i; + } + copy(t) { + this.writeMask = t.writeMask; + this.compareMask = t.compareMask; + this.reference = t.reference; + return this; + } + } + class lr { + constructor(t = new fn, e = new hn, i = new gn, s = 1, n = 0, r = 0, o = 0, a = 0, l = 0, h = new ar, c = new ar) { + this.viewport = t; + this.scissor = e; + this.blendConstant = i; + this.lineWidth = s; + this.depthBiasConstant = n; + this.depthBiasClamp = r; + this.depthBiasSlope = o; + this.depthMinBounds = a; + this.depthMaxBounds = l; + this.stencilStatesFront = h; + this.stencilStatesBack = c; + } + copy(t) { + this.viewport.copy(t.viewport); + this.scissor.copy(t.scissor); + this.blendConstant.copy(t.blendConstant); + this.lineWidth = t.lineWidth; + this.depthBiasConstant = t.depthBiasConstant; + this.depthBiasClamp = t.depthBiasClamp; + this.depthBiasSlope = t.depthBiasSlope; + this.depthMinBounds = t.depthMinBounds; + this.depthMaxBounds = t.depthMaxBounds; + this.stencilStatesFront.copy(t.stencilStatesFront); + this.stencilStatesBack.copy(t.stencilStatesBack); + return this; + } + } + class hr extends class { + constructor() { + return _s.registerGCObject(this); + } + destroy() {} + } { + get objectType() { + return this._objectType; + } + get objectID() { + return this._objectID; + } + get typedID() { + return this._typedID; + } + constructor(t) { + super(); + this._objectType = ps.UNKNOWN; + this._objectID = 0; + this._typedID = 0; + this._objectType = t; + this._objectID = hr._idTable[ps.UNKNOWN]++; + this._typedID = hr._idTable[t]++; + } + } + hr._idTable = Array(ps.COUNT).fill(65536); + let cr; + !function(t) { + t.ATTR_POSITION = "a_position"; + t.ATTR_NORMAL = "a_normal"; + t.ATTR_TANGENT = "a_tangent"; + t.ATTR_BITANGENT = "a_bitangent"; + t.ATTR_WEIGHTS = "a_weights"; + t.ATTR_JOINTS = "a_joints"; + t.ATTR_COLOR = "a_color"; + t.ATTR_COLOR1 = "a_color1"; + t.ATTR_COLOR2 = "a_color2"; + t.ATTR_TEX_COORD = "a_texCoord"; + t.ATTR_TEX_COORD1 = "a_texCoord1"; + t.ATTR_TEX_COORD2 = "a_texCoord2"; + t.ATTR_TEX_COORD3 = "a_texCoord3"; + t.ATTR_TEX_COORD4 = "a_texCoord4"; + t.ATTR_TEX_COORD5 = "a_texCoord5"; + t.ATTR_TEX_COORD6 = "a_texCoord6"; + t.ATTR_TEX_COORD7 = "a_texCoord7"; + t.ATTR_TEX_COORD8 = "a_texCoord8"; + t.ATTR_BATCH_ID = "a_batch_id"; + t.ATTR_BATCH_UV = "a_batch_uv"; + }(cr || (cr = {})); + const ur = Object.freeze([ new rr("UNKNOWN", 0, 0, Ss.NONE, !1, !1, !1, !1), new rr("A8", 1, 1, Ss.UNORM, !0, !1, !1, !1), new rr("L8", 1, 1, Ss.UNORM, !1, !1, !1, !1), new rr("LA8", 1, 2, Ss.UNORM, !0, !1, !1, !1), new rr("R8", 1, 1, Ss.UNORM, !1, !1, !1, !1), new rr("R8SN", 1, 1, Ss.SNORM, !1, !1, !1, !1), new rr("R8UI", 1, 1, Ss.UINT, !1, !1, !1, !1), new rr("R8I", 1, 1, Ss.INT, !1, !1, !1, !1), new rr("R16F", 2, 1, Ss.FLOAT, !1, !1, !1, !1), new rr("R16UI", 2, 1, Ss.UINT, !1, !1, !1, !1), new rr("R16I", 2, 1, Ss.INT, !1, !1, !1, !1), new rr("R32F", 4, 1, Ss.FLOAT, !1, !1, !1, !1), new rr("R32UI", 4, 1, Ss.UINT, !1, !1, !1, !1), new rr("R32I", 4, 1, Ss.INT, !1, !1, !1, !1), new rr("RG8", 2, 2, Ss.UNORM, !1, !1, !1, !1), new rr("RG8SN", 2, 2, Ss.SNORM, !1, !1, !1, !1), new rr("RG8UI", 2, 2, Ss.UINT, !1, !1, !1, !1), new rr("RG8I", 2, 2, Ss.INT, !1, !1, !1, !1), new rr("RG16F", 4, 2, Ss.FLOAT, !1, !1, !1, !1), new rr("RG16UI", 4, 2, Ss.UINT, !1, !1, !1, !1), new rr("RG16I", 4, 2, Ss.INT, !1, !1, !1, !1), new rr("RG32F", 8, 2, Ss.FLOAT, !1, !1, !1, !1), new rr("RG32UI", 8, 2, Ss.UINT, !1, !1, !1, !1), new rr("RG32I", 8, 2, Ss.INT, !1, !1, !1, !1), new rr("RGB8", 3, 3, Ss.UNORM, !1, !1, !1, !1), new rr("SRGB8", 3, 3, Ss.UNORM, !1, !1, !1, !1), new rr("RGB8SN", 3, 3, Ss.SNORM, !1, !1, !1, !1), new rr("RGB8UI", 3, 3, Ss.UINT, !1, !1, !1, !1), new rr("RGB8I", 3, 3, Ss.INT, !1, !1, !1, !1), new rr("RGB16F", 6, 3, Ss.FLOAT, !1, !1, !1, !1), new rr("RGB16UI", 6, 3, Ss.UINT, !1, !1, !1, !1), new rr("RGB16I", 6, 3, Ss.INT, !1, !1, !1, !1), new rr("RGB32F", 12, 3, Ss.FLOAT, !1, !1, !1, !1), new rr("RGB32UI", 12, 3, Ss.UINT, !1, !1, !1, !1), new rr("RGB32I", 12, 3, Ss.INT, !1, !1, !1, !1), new rr("RGBA8", 4, 4, Ss.UNORM, !0, !1, !1, !1), new rr("BGRA8", 4, 4, Ss.UNORM, !0, !1, !1, !1), new rr("SRGB8_A8", 4, 4, Ss.UNORM, !0, !1, !1, !1), new rr("RGBA8SN", 4, 4, Ss.SNORM, !0, !1, !1, !1), new rr("RGBA8UI", 4, 4, Ss.UINT, !0, !1, !1, !1), new rr("RGBA8I", 4, 4, Ss.INT, !0, !1, !1, !1), new rr("RGBA16F", 8, 4, Ss.FLOAT, !0, !1, !1, !1), new rr("RGBA16UI", 8, 4, Ss.UINT, !0, !1, !1, !1), new rr("RGBA16I", 8, 4, Ss.INT, !0, !1, !1, !1), new rr("RGBA32F", 16, 4, Ss.FLOAT, !0, !1, !1, !1), new rr("RGBA32UI", 16, 4, Ss.UINT, !0, !1, !1, !1), new rr("RGBA32I", 16, 4, Ss.INT, !0, !1, !1, !1), new rr("R5G6B5", 2, 3, Ss.UNORM, !1, !1, !1, !1), new rr("R11G11B10F", 4, 3, Ss.FLOAT, !1, !1, !1, !1), new rr("RGB5A1", 2, 4, Ss.UNORM, !0, !1, !1, !1), new rr("RGBA4", 2, 4, Ss.UNORM, !0, !1, !1, !1), new rr("RGB10A2", 2, 4, Ss.UNORM, !0, !1, !1, !1), new rr("RGB10A2UI", 2, 4, Ss.UINT, !0, !1, !1, !1), new rr("RGB9E5", 2, 4, Ss.FLOAT, !0, !1, !1, !1), new rr("DEPTH", 4, 1, Ss.FLOAT, !1, !0, !1, !1), new rr("DEPTH_STENCIL", 5, 2, Ss.FLOAT, !1, !0, !0, !1), new rr("BC1", 1, 3, Ss.UNORM, !1, !1, !1, !0), new rr("BC1_ALPHA", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("BC1_SRGB", 1, 3, Ss.UNORM, !1, !1, !1, !0), new rr("BC1_SRGB_ALPHA", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("BC2", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("BC2_SRGB", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("BC3", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("BC3_SRGB", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("BC4", 1, 1, Ss.UNORM, !1, !1, !1, !0), new rr("BC4_SNORM", 1, 1, Ss.SNORM, !1, !1, !1, !0), new rr("BC5", 1, 2, Ss.UNORM, !1, !1, !1, !0), new rr("BC5_SNORM", 1, 2, Ss.SNORM, !1, !1, !1, !0), new rr("BC6H_UF16", 1, 3, Ss.UFLOAT, !1, !1, !1, !0), new rr("BC6H_SF16", 1, 3, Ss.FLOAT, !1, !1, !1, !0), new rr("BC7", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("BC7_SRGB", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ETC_RGB8", 1, 3, Ss.UNORM, !1, !1, !1, !0), new rr("ETC2_RGB8", 1, 3, Ss.UNORM, !1, !1, !1, !0), new rr("ETC2_SRGB8", 1, 3, Ss.UNORM, !1, !1, !1, !0), new rr("ETC2_RGB8_A1", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ETC2_SRGB8_A1", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ETC2_RGBA8", 2, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ETC2_SRGB8_A8", 2, 4, Ss.UNORM, !0, !1, !1, !0), new rr("EAC_R11", 1, 1, Ss.UNORM, !1, !1, !1, !0), new rr("EAC_R11SN", 1, 1, Ss.SNORM, !1, !1, !1, !0), new rr("EAC_RG11", 2, 2, Ss.UNORM, !1, !1, !1, !0), new rr("EAC_RG11SN", 2, 2, Ss.SNORM, !1, !1, !1, !0), new rr("PVRTC_RGB2", 2, 3, Ss.UNORM, !1, !1, !1, !0), new rr("PVRTC_RGBA2", 2, 4, Ss.UNORM, !0, !1, !1, !0), new rr("PVRTC_RGB4", 2, 3, Ss.UNORM, !1, !1, !1, !0), new rr("PVRTC_RGBA4", 2, 4, Ss.UNORM, !0, !1, !1, !0), new rr("PVRTC2_2BPP", 2, 4, Ss.UNORM, !0, !1, !1, !0), new rr("PVRTC2_4BPP", 2, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_RGBA_4x4", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_RGBA_5x4", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_RGBA_5x5", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_RGBA_6x5", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_RGBA_6x6", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_RGBA_8x5", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_RGBA_8x6", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_RGBA_8x8", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_RGBA_10x5", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_RGBA_10x6", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_RGBA_10x8", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_RGBA_10x10", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_RGBA_12x10", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_RGBA_12x12", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_SRGBA_4x4", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_SRGBA_5x4", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_SRGBA_5x5", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_SRGBA_6x5", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_SRGBA_6x6", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_SRGBA_8x5", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_SRGBA_8x6", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_SRGBA_8x8", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_SRGBA_10x5", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_SRGBA_10x6", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_SRGBA_10x8", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_SRGBA_10x10", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_SRGBA_12x10", 1, 4, Ss.UNORM, !0, !1, !1, !0), new rr("ASTC_SRGBA_12x12", 1, 4, Ss.UNORM, !0, !1, !1, !0) ]); + const _r = Zs.UNIFORM_BUFFER | Zs.DYNAMIC_UNIFORM_BUFFER | Zs.STORAGE_BUFFER | Zs.DYNAMIC_STORAGE_BUFFER; + const dr = Zs.SAMPLER_TEXTURE | Zs.SAMPLER | Zs.TEXTURE | Zs.STORAGE_IMAGE | Zs.INPUT_ATTACHMENT; + const pr = Zs.DYNAMIC_STORAGE_BUFFER | Zs.DYNAMIC_UNIFORM_BUFFER; + const mr = 28; + function fr(t) { + return t > 0 && 0 == (t & t - 1); + } + function gr(t, e, i, s) { + if (!ur[t].isCompressed) return e * i * s * ur[t].size; + switch (t) { + case bs.BC1: + case bs.BC1_ALPHA: + case bs.BC1_SRGB: + case bs.BC1_SRGB_ALPHA: + return Math.ceil(e / 4) * Math.ceil(i / 4) * 8 * s; + + case bs.BC2: + case bs.BC2_SRGB: + case bs.BC3: + case bs.BC3_SRGB: + case bs.BC4: + case bs.BC4_SNORM: + case bs.BC6H_SF16: + case bs.BC6H_UF16: + case bs.BC7: + case bs.BC7_SRGB: + return Math.ceil(e / 4) * Math.ceil(i / 4) * 16 * s; + + case bs.BC5: + case bs.BC5_SNORM: + return Math.ceil(e / 4) * Math.ceil(i / 4) * 32 * s; + + case bs.ETC_RGB8: + case bs.ETC2_RGB8: + case bs.ETC2_SRGB8: + case bs.ETC2_RGB8_A1: + case bs.EAC_R11: + case bs.EAC_R11SN: + return Math.ceil(e / 4) * Math.ceil(i / 4) * 8 * s; + + case bs.ETC2_RGBA8: + case bs.ETC2_SRGB8_A1: + case bs.EAC_RG11: + case bs.EAC_RG11SN: + return Math.ceil(e / 4) * Math.ceil(i / 4) * 16 * s; + + case bs.PVRTC_RGB2: + case bs.PVRTC_RGBA2: + case bs.PVRTC2_2BPP: + return Math.ceil(e / 8) * Math.ceil(i / 4) * 8 * s; + + case bs.PVRTC_RGB4: + case bs.PVRTC_RGBA4: + case bs.PVRTC2_4BPP: + return Math.ceil(e / 4) * Math.ceil(i / 4) * 8 * s; + + case bs.ASTC_RGBA_4X4: + case bs.ASTC_SRGBA_4X4: + return Math.ceil(e / 4) * Math.ceil(i / 4) * 16 * s; + + case bs.ASTC_RGBA_5X4: + case bs.ASTC_SRGBA_5X4: + return Math.ceil(e / 5) * Math.ceil(i / 4) * 16 * s; + + case bs.ASTC_RGBA_5X5: + case bs.ASTC_SRGBA_5X5: + return Math.ceil(e / 5) * Math.ceil(i / 5) * 16 * s; + + case bs.ASTC_RGBA_6X5: + case bs.ASTC_SRGBA_6X5: + return Math.ceil(e / 6) * Math.ceil(i / 5) * 16 * s; + + case bs.ASTC_RGBA_6X6: + case bs.ASTC_SRGBA_6X6: + return Math.ceil(e / 6) * Math.ceil(i / 6) * 16 * s; + + case bs.ASTC_RGBA_8X5: + case bs.ASTC_SRGBA_8X5: + return Math.ceil(e / 8) * Math.ceil(i / 5) * 16 * s; + + case bs.ASTC_RGBA_8X6: + case bs.ASTC_SRGBA_8X6: + return Math.ceil(e / 8) * Math.ceil(i / 6) * 16 * s; + + case bs.ASTC_RGBA_8X8: + case bs.ASTC_SRGBA_8X8: + return Math.ceil(e / 8) * Math.ceil(i / 8) * 16 * s; + + case bs.ASTC_RGBA_10X5: + case bs.ASTC_SRGBA_10X5: + return Math.ceil(e / 10) * Math.ceil(i / 5) * 16 * s; + + case bs.ASTC_RGBA_10X6: + case bs.ASTC_SRGBA_10X6: + return Math.ceil(e / 10) * Math.ceil(i / 6) * 16 * s; + + case bs.ASTC_RGBA_10X8: + case bs.ASTC_SRGBA_10X8: + return Math.ceil(e / 10) * Math.ceil(i / 8) * 16 * s; + + case bs.ASTC_RGBA_10X10: + case bs.ASTC_SRGBA_10X10: + return Math.ceil(e / 10) * Math.ceil(i / 10) * 16 * s; + + case bs.ASTC_RGBA_12X10: + case bs.ASTC_SRGBA_12X10: + return Math.ceil(e / 12) * Math.ceil(i / 10) * 16 * s; + + case bs.ASTC_RGBA_12X12: + case bs.ASTC_SRGBA_12X12: + return Math.ceil(e / 12) * Math.ceil(i / 12) * 16 * s; + + default: + return 0; + } + } + function yr(t, e, i, s, n) { + let r = 0; + for (let o = 0; o < n; ++o) { + r += gr(t, e, i, s); + e = Math.max(e >> 1, 1); + i = Math.max(i >> 1, 1); + } + return r; + } + const br = [ 0, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 16, 24, 32, 24, 36, 48, 32, 48, 64, 4, 4, 4, 4, 4, 4 ]; + function Sr(t) { + return br[t] || 0; + } + function Ar(t) { + if (t.isCompressed) return Uint8Array; + const e = t.size / t.count; + switch (t.type) { + case Ss.UNORM: + case Ss.UINT: + switch (e) { + case 1: + default: + return Uint8Array; + + case 2: + return Uint16Array; + + case 4: + return Uint32Array; + } + + case Ss.SNORM: + case Ss.INT: + switch (e) { + case 1: + default: + return Int8Array; + + case 2: + return Int16Array; + + case 4: + return Int32Array; + } + + case Ss.FLOAT: + return Float32Array; + } + return Float32Array; + } + function Tr(t) { + switch (t) { + case bs.BC1: + case bs.BC1_ALPHA: + case bs.BC1_SRGB: + case bs.BC1_SRGB_ALPHA: + case bs.BC2: + case bs.BC2_SRGB: + case bs.BC3: + case bs.BC3_SRGB: + case bs.BC4: + case bs.BC4_SNORM: + case bs.BC6H_SF16: + case bs.BC6H_UF16: + case bs.BC7: + case bs.BC7_SRGB: + case bs.BC5: + case bs.BC5_SNORM: + case bs.ETC_RGB8: + case bs.ETC2_RGB8: + case bs.ETC2_SRGB8: + case bs.ETC2_RGB8_A1: + case bs.EAC_R11: + case bs.EAC_R11SN: + case bs.ETC2_RGBA8: + case bs.ETC2_SRGB8_A1: + case bs.EAC_RG11: + case bs.EAC_RG11SN: + return { + width: 4, + height: 4 + }; + + case bs.PVRTC_RGB2: + case bs.PVRTC_RGBA2: + case bs.PVRTC2_2BPP: + return { + width: 8, + height: 4 + }; + + case bs.PVRTC_RGB4: + case bs.PVRTC_RGBA4: + case bs.PVRTC2_4BPP: + case bs.ASTC_RGBA_4X4: + case bs.ASTC_SRGBA_4X4: + return { + width: 4, + height: 4 + }; + + case bs.ASTC_RGBA_5X4: + case bs.ASTC_SRGBA_5X4: + return { + width: 5, + height: 4 + }; + + case bs.ASTC_RGBA_5X5: + case bs.ASTC_SRGBA_5X5: + return { + width: 5, + height: 5 + }; + + case bs.ASTC_RGBA_6X5: + case bs.ASTC_SRGBA_6X5: + return { + width: 6, + height: 5 + }; + + case bs.ASTC_RGBA_6X6: + case bs.ASTC_SRGBA_6X6: + return { + width: 6, + height: 6 + }; + + case bs.ASTC_RGBA_8X5: + case bs.ASTC_SRGBA_8X5: + return { + width: 8, + height: 5 + }; + + case bs.ASTC_RGBA_8X6: + case bs.ASTC_SRGBA_8X6: + return { + width: 8, + height: 6 + }; + + case bs.ASTC_RGBA_8X8: + case bs.ASTC_SRGBA_8X8: + return { + width: 8, + height: 8 + }; + + case bs.ASTC_RGBA_10X5: + case bs.ASTC_SRGBA_10X5: + return { + width: 10, + height: 5 + }; + + case bs.ASTC_RGBA_10X6: + case bs.ASTC_SRGBA_10X6: + return { + width: 10, + height: 6 + }; + + case bs.ASTC_RGBA_10X8: + case bs.ASTC_SRGBA_10X8: + return { + width: 10, + height: 8 + }; + + case bs.ASTC_RGBA_10X10: + case bs.ASTC_SRGBA_10X10: + return { + width: 10, + height: 10 + }; + + case bs.ASTC_RGBA_12X10: + case bs.ASTC_SRGBA_12X10: + return { + width: 12, + height: 10 + }; + + case bs.ASTC_RGBA_12X12: + case bs.ASTC_SRGBA_12X12: + return { + width: 12, + height: 12 + }; + + default: + return { + width: 1, + height: 1 + }; + } + } + function vr(t, e) { + return Math.ceil(t / e) * e; + } + var Er = Object.freeze({ + __proto__: null, + get ObjectType() { + return ps; + }, + get Status() { + return ms; + }, + get API() { + return fs; + }, + get SurfaceTransform() { + return gs; + }, + get Feature() { + return ys; + }, + get Format() { + return bs; + }, + get FormatType() { + return Ss; + }, + get Type() { + return As; + }, + get BufferUsageBit() { + return Ts; + }, + get BufferFlagBit() { + return vs; + }, + get MemoryAccessBit() { + return Es; + }, + get MemoryUsageBit() { + return Cs; + }, + get TextureType() { + return xs; + }, + get TextureUsageBit() { + return ws; + }, + get TextureFlagBit() { + return Rs; + }, + get FormatFeatureBit() { + return Is; + }, + get SampleCount() { + return Ms; + }, + get VsyncMode() { + return Bs; + }, + get Filter() { + return Ds; + }, + get Address() { + return Ps; + }, + get ComparisonFunc() { + return Os; + }, + get StencilOp() { + return Ns; + }, + get BlendFactor() { + return Ls; + }, + get BlendOp() { + return Fs; + }, + get ColorMask() { + return Vs; + }, + get ShaderStageFlagBit() { + return ks; + }, + get LoadOp() { + return Us; + }, + get StoreOp() { + return Gs; + }, + get AccessFlagBit() { + return zs; + }, + get ResolveMode() { + return Hs; + }, + get PipelineBindPoint() { + return js; + }, + get PrimitiveMode() { + return Xs; + }, + get PolygonMode() { + return Ws; + }, + get ShadeModel() { + return Ys; + }, + get CullMode() { + return qs; + }, + get DynamicStateFlagBit() { + return Ks; + }, + get StencilFace() { + return Js; + }, + get DescriptorType() { + return Zs; + }, + get QueueType() { + return Qs; + }, + get QueryType() { + return $s; + }, + get CommandBufferType() { + return tn; + }, + get ClearFlagBit() { + return en; + }, + get BarrierType() { + return sn; + }, + get PassType() { + return nn; + }, + Size: rn, + DeviceCaps: on, + DeviceOptions: an, + Offset: ln, + Rect: hn, + Extent: cn, + TextureSubresLayers: un, + TextureSubresRange: _n, + TextureCopy: dn, + TextureBlit: pn, + BufferTextureCopy: mn, + Viewport: fn, + Color: gn, + BindingMappingInfo: yn, + SwapchainInfo: bn, + DeviceInfo: Sn, + BufferInfo: An, + BufferViewInfo: Tn, + DrawInfo: vn, + DispatchInfo: En, + IndirectBuffer: Cn, + TextureInfo: xn, + TextureViewInfo: wn, + SamplerInfo: Rn, + Uniform: In, + UniformBlock: Mn, + UniformSamplerTexture: Bn, + UniformSampler: Dn, + UniformTexture: Pn, + UniformStorageImage: On, + UniformStorageBuffer: Nn, + UniformInputAttachment: Ln, + ShaderStage: Fn, + Attribute: Vn, + ShaderInfo: kn, + InputAssemblerInfo: Un, + ColorAttachment: Gn, + DepthStencilAttachment: zn, + SubpassInfo: Hn, + SubpassDependency: jn, + RenderPassInfo: Xn, + GeneralBarrierInfo: Wn, + TextureBarrierInfo: Yn, + BufferBarrierInfo: qn, + FramebufferInfo: Kn, + DescriptorSetLayoutBinding: Jn, + DescriptorSetLayoutInfo: Zn, + DescriptorSetInfo: Qn, + PipelineLayoutInfo: $n, + InputState: tr, + CommandBufferInfo: er, + QueueInfo: ir, + QueryPoolInfo: sr, + FormatInfo: rr, + MemoryStatus: or, + DynamicStencilStates: ar, + DynamicStates: lr, + GFXObject: hr, + get AttributeName() { + return cr; + }, + FormatInfos: ur, + DESCRIPTOR_BUFFER_TYPE: _r, + DESCRIPTOR_SAMPLER_TYPE: dr, + DESCRIPTOR_DYNAMIC_TYPE: pr, + DRAW_INFO_SIZE: mr, + IsPowerOf2: fr, + FormatSize: gr, + FormatSurfaceSize: yr, + GetTypeSize: Sr, + getTypedArrayConstructor: Ar, + formatAlignment: Tr, + alignTo: vr + }); + class Cr { + constructor(t = !1, e = Ws.FILL, i = Ys.GOURAND, s = qs.BACK, n = !0, r = !1, o = 0, a = 0, l = 0, h = !0, c = !1, u = 1) { + this._nativeObj = void 0; + this._isDiscard = !1; + this._polygonMode = Ws.FILL; + this._shadeModel = Ys.GOURAND; + this._cullMode = qs.BACK; + this._isFrontFaceCCW = !0; + this._depthBiasEnabled = !1; + this._depthBias = 0; + this._depthBiasClamp = 0; + this._depthBiasSlop = 0; + this._isDepthClip = !0; + this._isMultisample = !1; + this._lineWidth = 1; + this._nativeObj = new gfx.RasterizerState; + this.assignProperties(t, e, i, s, n, r, o, a, l, h, c, u); + } + get native() { + return this._nativeObj; + } + get isDiscard() { + return this._isDiscard; + } + set isDiscard(t) { + this._isDiscard = t; + this._nativeObj.isDiscard = t; + } + get polygonMode() { + return this._polygonMode; + } + set polygonMode(t) { + this._polygonMode = t; + this._nativeObj.polygonMode = t; + } + get shadeModel() { + return this._shadeModel; + } + set shadeModel(t) { + this._shadeModel = t; + this._nativeObj.shadeModel = t; + } + get cullMode() { + return this._cullMode; + } + set cullMode(t) { + this._cullMode = t; + this._nativeObj.cullMode = t; + } + get isFrontFaceCCW() { + return this._isFrontFaceCCW; + } + set isFrontFaceCCW(t) { + this._isFrontFaceCCW = t; + this._nativeObj.isFrontFaceCCW = t; + } + get depthBiasEnabled() { + return this._depthBiasEnabled; + } + set depthBiasEnabled(t) { + this._depthBiasEnabled = t; + this._nativeObj.depthBiasEnabled = t; + } + get depthBias() { + return this._depthBias; + } + set depthBias(t) { + this._depthBias = t; + this._nativeObj.depthBias = t; + } + get depthBiasClamp() { + return this._depthBiasClamp; + } + set depthBiasClamp(t) { + this._depthBiasClamp = t; + this._nativeObj.depthBiasClamp = t; + } + get depthBiasSlop() { + return this._depthBiasSlop; + } + set depthBiasSlop(t) { + this._depthBiasSlop = t; + this._nativeObj.depthBiasSlop = t; + } + get isDepthClip() { + return this._isDepthClip; + } + set isDepthClip(t) { + this._isDepthClip = t; + this._nativeObj.isDepthClip = t; + } + get isMultisample() { + return this._isMultisample; + } + set isMultisample(t) { + this._isMultisample = t; + this._nativeObj.isMultisample = t; + } + get lineWidth() { + return this._lineWidth; + } + set lineWidth(t) { + this._lineWidth = t; + this._nativeObj.lineWidth = t; + } + reset() { + this.assignProperties(!1, Ws.FILL, Ys.GOURAND, qs.BACK, !0, !1, 0, 0, 0, !0, !1, 1); + } + assign(t) { + t && this.assignProperties(t.isDiscard, t.polygonMode, t.shadeModel, t.cullMode, t.isFrontFaceCCW, t.depthBiasEnabled, t.depthBias, t.depthBiasClamp, t.depthBiasSlop, t.isDepthClip, t.isMultisample, t.lineWidth); + } + destroy() { + this._nativeObj = null; + } + assignProperties(t, e, i, s, n, r, o, a, l, h, c, u) { + void 0 !== t && (this.isDiscard = t); + void 0 !== e && (this.polygonMode = e); + void 0 !== i && (this.shadeModel = i); + void 0 !== s && (this.cullMode = s); + void 0 !== n && (this.isFrontFaceCCW = n); + void 0 !== r && (this.depthBiasEnabled = r); + void 0 !== o && (this.depthBias = o); + void 0 !== a && (this.depthBiasClamp = a); + void 0 !== l && (this.depthBiasSlop = l); + void 0 !== h && (this.isDepthClip = h); + void 0 !== c && (this.isMultisample = c); + void 0 !== u && (this.lineWidth = u); + } + } + class wr { + constructor(t = !0, e = !0, i = Os.LESS, s = !1, n = Os.ALWAYS, r = 65535, o = 65535, a = Ns.KEEP, l = Ns.KEEP, h = Ns.KEEP, c = 1, u = !1, _ = Os.ALWAYS, d = 65535, p = 65535, m = Ns.KEEP, f = Ns.KEEP, g = Ns.KEEP, y = 1) { + this._nativeObj = void 0; + this._depthTest = !0; + this._depthWrite = !0; + this._depthFunc = Os.LESS; + this._stencilTestFront = !1; + this._stencilFuncFront = Os.ALWAYS; + this._stencilReadMaskFront = 65535; + this._stencilWriteMaskFront = 65535; + this._stencilFailOpFront = Ns.KEEP; + this._stencilZFailOpFront = Ns.KEEP; + this._stencilPassOpFront = Ns.KEEP; + this._stencilRefFront = 1; + this._stencilTestBack = !1; + this._stencilFuncBack = Os.ALWAYS; + this._stencilReadMaskBack = 65535; + this._stencilWriteMaskBack = 65535; + this._stencilFailOpBack = Ns.KEEP; + this._stencilZFailOpBack = Ns.KEEP; + this._stencilPassOpBack = Ns.KEEP; + this._stencilRefBack = 1; + this._nativeObj = new gfx.DepthStencilState; + this.assignProperties(t, e, i, s, n, r, o, a, l, h, c, u, _, d, p, m, f, g, y); + } + get native() { + return this._nativeObj; + } + get depthTest() { + return this._depthTest; + } + set depthTest(t) { + this._depthTest = t; + this._nativeObj.depthTest = t; + } + get depthWrite() { + return this._depthWrite; + } + set depthWrite(t) { + this._depthWrite = t; + this._nativeObj.depthWrite = t; + } + get depthFunc() { + return this._depthFunc; + } + set depthFunc(t) { + this._depthFunc = t; + this._nativeObj.depthFunc = t; + } + get stencilTestFront() { + return this._stencilTestFront; + } + set stencilTestFront(t) { + this._stencilTestFront = t; + this._nativeObj.stencilTestFront = t; + } + get stencilFuncFront() { + return this._stencilFuncFront; + } + set stencilFuncFront(t) { + this._stencilFuncFront = t; + this._nativeObj.stencilFuncFront = t; + } + get stencilReadMaskFront() { + return this._stencilReadMaskFront; + } + set stencilReadMaskFront(t) { + this._stencilReadMaskFront = t; + this._nativeObj.stencilReadMaskFront = t; + } + get stencilWriteMaskFront() { + return this._stencilWriteMaskFront; + } + set stencilWriteMaskFront(t) { + this._stencilWriteMaskFront = t; + this._nativeObj.stencilWriteMaskFront = t; + } + get stencilFailOpFront() { + return this._stencilFailOpFront; + } + set stencilFailOpFront(t) { + this._stencilFailOpFront = t; + this._nativeObj.stencilFailOpFront = t; + } + get stencilZFailOpFront() { + return this._stencilZFailOpFront; + } + set stencilZFailOpFront(t) { + this._stencilZFailOpFront = t; + this._nativeObj.stencilZFailOpFront = t; + } + get stencilPassOpFront() { + return this._stencilPassOpFront; + } + set stencilPassOpFront(t) { + this._stencilPassOpFront = t; + this._nativeObj.stencilPassOpFront = t; + } + get stencilRefFront() { + return this._stencilRefFront; + } + set stencilRefFront(t) { + this._stencilRefFront = t; + this._nativeObj.stencilRefFront = t; + } + get stencilTestBack() { + return this._stencilTestBack; + } + set stencilTestBack(t) { + this._stencilTestBack = t; + this._nativeObj.stencilTestBack = t; + } + get stencilFuncBack() { + return this._stencilFuncBack; + } + set stencilFuncBack(t) { + this._stencilFuncBack = t; + this._nativeObj.stencilFuncBack = t; + } + get stencilReadMaskBack() { + return this._stencilReadMaskBack; + } + set stencilReadMaskBack(t) { + this._stencilReadMaskBack = t; + this._nativeObj.stencilReadMaskBack = t; + } + get stencilWriteMaskBack() { + return this._stencilWriteMaskBack; + } + set stencilWriteMaskBack(t) { + this._stencilWriteMaskBack = t; + this._nativeObj.stencilWriteMaskBack = t; + } + get stencilFailOpBack() { + return this._stencilFailOpBack; + } + set stencilFailOpBack(t) { + this._stencilFailOpBack = t; + this._nativeObj.stencilFailOpBack = t; + } + get stencilZFailOpBack() { + return this._stencilZFailOpBack; + } + set stencilZFailOpBack(t) { + this._stencilZFailOpBack = t; + this._nativeObj.stencilZFailOpBack = t; + } + get stencilPassOpBack() { + return this._stencilPassOpBack; + } + set stencilPassOpBack(t) { + this._stencilPassOpBack = t; + this._nativeObj.stencilPassOpBack = t; + } + get stencilRefBack() { + return this._stencilRefBack; + } + set stencilRefBack(t) { + this._stencilRefBack = t; + this._nativeObj.stencilRefBack = t; + } + reset() { + this.assignProperties(!0, !0, Os.LESS, !1, Os.ALWAYS, 65535, 65535, Ns.KEEP, Ns.KEEP, Ns.KEEP, 1, !1, Os.ALWAYS, 65535, 65535, Ns.KEEP, Ns.KEEP, Ns.KEEP, 1); + } + assign(t) { + t && this.assignProperties(t.depthTest, t.depthWrite, t.depthFunc, t.stencilTestFront, t.stencilFuncFront, t.stencilReadMaskFront, t.stencilWriteMaskFront, t.stencilFailOpFront, t.stencilZFailOpFront, t.stencilPassOpFront, t.stencilRefFront, t.stencilTestBack, t.stencilFuncBack, t.stencilReadMaskBack, t.stencilWriteMaskBack, t.stencilFailOpBack, t.stencilZFailOpBack, t.stencilPassOpBack, t.stencilRefBack); + } + destroy() { + this._nativeObj = null; + } + assignProperties(t, e, i, s, n, r, o, a, l, h, c, u, _, d, p, m, f, g, y) { + void 0 !== t && (this.depthTest = t); + void 0 !== e && (this.depthWrite = e); + void 0 !== i && (this.depthFunc = i); + void 0 !== s && (this.stencilTestFront = s); + void 0 !== n && (this.stencilFuncFront = n); + void 0 !== r && (this.stencilReadMaskFront = r); + void 0 !== o && (this.stencilWriteMaskFront = o); + void 0 !== a && (this.stencilFailOpFront = a); + void 0 !== l && (this.stencilZFailOpFront = l); + void 0 !== h && (this.stencilPassOpFront = h); + void 0 !== c && (this.stencilRefFront = c); + void 0 !== u && (this.stencilTestBack = u); + void 0 !== _ && (this.stencilFuncBack = _); + void 0 !== d && (this.stencilReadMaskBack = d); + void 0 !== p && (this.stencilWriteMaskBack = p); + void 0 !== m && (this.stencilFailOpBack = m); + void 0 !== f && (this.stencilZFailOpBack = f); + void 0 !== g && (this.stencilPassOpBack = g); + void 0 !== y && (this.stencilRefBack = y); + } + } + class Rr { + get native() { + return this._nativeObj; + } + constructor(t = !1, e = Ls.ONE, i = Ls.ZERO, s = Fs.ADD, n = Ls.ONE, r = Ls.ZERO, o = Fs.ADD, a = Vs.ALL) { + this._nativeObj = void 0; + this._blend = !1; + this._blendSrc = Ls.ONE; + this._blendDst = Ls.ZERO; + this._blendEq = Fs.ADD; + this._blendSrcAlpha = Ls.ONE; + this._blendDstAlpha = Ls.ZERO; + this._blendAlphaEq = Fs.ADD; + this._blendColorMask = Vs.ALL; + this._nativeObj = new gfx.BlendTarget; + this.assignProperties(t, e, i, s, n, r, o, a); + } + get blend() { + return this._blend; + } + set blend(t) { + this._blend = t; + this._nativeObj.blend = t; + } + get blendSrc() { + return this._blendSrc; + } + set blendSrc(t) { + this._blendSrc = t; + this._nativeObj.blendSrc = t; + } + get blendDst() { + return this._blendDst; + } + set blendDst(t) { + this._blendDst = t; + this._nativeObj.blendDst = t; + } + get blendEq() { + return this._blendEq; + } + set blendEq(t) { + this._blendEq = t; + this._nativeObj.blendEq = t; + } + get blendSrcAlpha() { + return this._blendSrcAlpha; + } + set blendSrcAlpha(t) { + this._blendSrcAlpha = t; + this._nativeObj.blendSrcAlpha = t; + } + get blendDstAlpha() { + return this._blendDstAlpha; + } + set blendDstAlpha(t) { + this._blendDstAlpha = t; + this._nativeObj.blendDstAlpha = t; + } + get blendAlphaEq() { + return this._blendAlphaEq; + } + set blendAlphaEq(t) { + this._blendAlphaEq = t; + this._nativeObj.blendAlphaEq = t; + } + get blendColorMask() { + return this._blendColorMask; + } + set blendColorMask(t) { + this._blendColorMask = t; + this._nativeObj.blendColorMask = t; + } + reset() { + this.assignProperties(!1, Ls.ONE, Ls.ZERO, Fs.ADD, Ls.ONE, Ls.ZERO, Fs.ADD, Vs.ALL); + } + destroy() { + this._nativeObj = null; + } + assign(t) { + t && this.assignProperties(t.blend, t.blendSrc, t.blendDst, t.blendEq, t.blendSrcAlpha, t.blendDstAlpha, t.blendAlphaEq, t.blendColorMask); + } + assignProperties(t, e, i, s, n, r, o, a) { + void 0 !== t && (this.blend = t); + void 0 !== e && (this.blendSrc = e); + void 0 !== i && (this.blendDst = i); + void 0 !== s && (this.blendEq = s); + void 0 !== n && (this.blendSrcAlpha = n); + void 0 !== r && (this.blendDstAlpha = r); + void 0 !== o && (this.blendAlphaEq = o); + void 0 !== a && (this.blendColorMask = a); + } + } + class Ir { + _setTargets(t) { + this.targets = t; + const e = "$__nativeObj"; + this._syncTargetsToNativeObj(e); + !function(t, e, i, s, n) { + for (let r = 0, o = e.length; r < o; r++) { + let o = e[r]; + let a = o[i][s] || o[i]; + o[i] = new Proxy(a, { + get: (t, e) => e === s ? t : Reflect.get(t, e), + set: (e, i, s) => { + Reflect.set(e, i, s); + n(t, r, e, i, s); + return !0; + } + }); + } + }(this, this.targets, "_nativeObj", e, ((t, i, s, n, r) => { + t._syncTargetsToNativeObj(e); + })); + } + _syncTargetsToNativeObj(t) { + const e = this.targets.map((e => e.native[t] || e.native)); + this._nativeObj.targets = e; + } + get native() { + return this._nativeObj; + } + constructor(t = !1, e = !1, i = new gn, s = [ new Rr ]) { + this.targets = void 0; + this._blendColor = void 0; + this._nativeObj = void 0; + this._isA2C = !1; + this._isIndepend = !1; + this._nativeObj = new gfx.BlendState; + this._setTargets(s); + this.blendColor = i; + this.isA2c = t; + this.isIndepend = e; + } + get isA2c() { + return this._isA2C; + } + set isA2c(t) { + this._isA2C = t; + this._nativeObj.isA2C = t; + } + get isIndepend() { + return this._isIndepend; + } + set isIndepend(t) { + this._isIndepend = t; + this._nativeObj.isIndepend = t; + } + get blendColor() { + return this._blendColor; + } + set blendColor(t) { + this._blendColor = t; + this._nativeObj.blendColor = t; + } + setTarget(t, e) { + let i = this.targets[t]; + i || (i = this.targets[t] = new Rr); + i.assign(e); + this._setTargets(this.targets); + } + reset() { + this.isA2c = !1; + this.isIndepend = !1; + this.blendColor = new gn(0, 0, 0, 0); + const t = this.targets; + for (let e = 1, i = t.length; e < i; ++e) t[e].destroy(); + t.length = 1; + t[0].reset(); + this._setTargets(t); + } + destroy() { + for (let t = 0, e = this.targets.length; t < e; ++t) this.targets[t].destroy(); + this.targets = null; + this._nativeObj = null; + } + } + const Mr = gfx.PipelineState; + const Br = gfx.PipelineStateInfo; + class Dr extends hr { + get layout() { + return this._layout; + } + constructor() { + super(ps.DESCRIPTOR_SET); + this._layout = null; + this._buffers = []; + this._textures = []; + this._samplers = []; + this._isDirty = !1; + } + bindBuffer(t, e, i = 0) { + const s = this._layout.bindingIndices[t]; + const n = this._layout.bindings[s]; + if (n && n.descriptorType & _r) { + const s = this._layout.descriptorIndices[t]; + if (this._buffers[s + i] !== e) { + this._buffers[s + i] = e; + this._isDirty = !0; + } + } + } + bindSampler(t, e, i = 0) { + const s = this._layout.bindingIndices[t]; + const n = this._layout.bindings[s]; + if (n && n.descriptorType & dr) { + const s = this._layout.descriptorIndices[t]; + if (this._samplers[s + i] !== e) { + this._samplers[s + i] = e; + this._isDirty = !0; + } + } + } + bindTexture(t, e, i = 0) { + const s = this._layout.bindingIndices[t]; + const n = this._layout.bindings[s]; + if (n && n.descriptorType & dr) { + const s = this._layout.descriptorIndices[t]; + if (this._textures[s + i] !== e) { + this._textures[s + i] = e; + this._isDirty = !0; + } + } + } + getBuffer(t, e = 0) { + const i = this._layout.descriptorIndices[t]; + return this._buffers[i + e]; + } + getSampler(t, e = 0) { + const i = this._layout.descriptorIndices[t]; + return this._samplers[i + e]; + } + getTexture(t, e = 0) { + const i = this._layout.descriptorIndices[t]; + return this._textures[i + e]; + } + } + class Pr extends hr { + get usage() { + return this._usage; + } + get memUsage() { + return this._memUsage; + } + get size() { + return this._size; + } + get stride() { + return this._stride; + } + get count() { + return this._count; + } + get flags() { + return this._flags; + } + constructor() { + super(ps.BUFFER); + this._usage = Ts.NONE; + this._memUsage = Cs.NONE; + this._size = 0; + this._stride = 1; + this._count = 0; + this._flags = vs.NONE; + this._isBufferView = !1; + } + } + class Or extends hr { + get type() { + return this._type; + } + get queue() { + return this._queue; + } + get numDrawCalls() { + return this._numDrawCalls; + } + get numInstances() { + return this._numInstances; + } + get numTris() { + return this._numTris; + } + constructor() { + super(ps.COMMAND_BUFFER); + this._queue = null; + this._type = tn.PRIMARY; + this._numDrawCalls = 0; + this._numInstances = 0; + this._numTris = 0; + } + } + class Nr { + constructor() { + this._gfxAPI = fs.UNKNOWN; + this._renderer = ""; + this._vendor = ""; + this._features = new Array(ys.COUNT); + this._formatFeatures = new Array(bs.COUNT); + this._queue = null; + this._cmdBuff = null; + this._numDrawCalls = 0; + this._numInstances = 0; + this._numTris = 0; + this._memoryStatus = new or; + this._caps = new on; + this._bindingMappingInfo = new yn; + this._samplers = new Map; + this._generalBarrierss = new Map; + this._textureBarriers = new Map; + this._bufferBarriers = new Map; + } + get gfxAPI() { + return this._gfxAPI; + } + get queue() { + return this._queue; + } + get commandBuffer() { + return this._cmdBuff; + } + get renderer() { + return this._renderer; + } + get vendor() { + return this._vendor; + } + get numDrawCalls() { + return this._numDrawCalls; + } + get numInstances() { + return this._numInstances; + } + get numTris() { + return this._numTris; + } + get memoryStatus() { + return this._memoryStatus; + } + get capabilities() { + return this._caps; + } + get bindingMappingInfo() { + return this._bindingMappingInfo; + } + hasFeature(t) { + return this._features[t]; + } + getFormatFeatures(t) { + return this._formatFeatures[t]; + } + } + Nr.canvas = void 0; + class Lr extends hr { + get colorTexture() { + return this._colorTexture; + } + get depthStencilTexture() { + return this._depthStencilTexture; + } + get surfaceTransform() { + return this._transform; + } + get width() { + return this._colorTexture.width; + } + get height() { + return this._colorTexture.height; + } + constructor() { + super(ps.SWAPCHAIN); + this._transform = gs.IDENTITY; + this._colorTexture = null; + this._depthStencilTexture = null; + } + } + class Fr extends hr { + get renderPass() { + return this._renderPass; + } + get colorTextures() { + return this._colorTextures; + } + get depthStencilTexture() { + return this._depthStencilTexture; + } + constructor() { + super(ps.FRAMEBUFFER); + this._renderPass = null; + this._colorTextures = []; + this._depthStencilTexture = null; + } + } + const Vr = String.prototype.charCodeAt; + function kr(t) { + return this[t]; + } + function Ur(t, e) { + let i = t.length; + let s = e ^ i; + let n = 0; + const r = "string" == typeof t ? Vr : kr; + for (;i >= 4; ) { + let e = 255 & r.call(t, n) | (255 & r.call(t, ++n)) << 8 | (255 & r.call(t, ++n)) << 16 | (255 & r.call(t, ++n)) << 24; + e = 1540483477 * (65535 & e) + ((1540483477 * (e >>> 16) & 65535) << 16); + e ^= e >>> 24; + e = 1540483477 * (65535 & e) + ((1540483477 * (e >>> 16) & 65535) << 16); + s = 1540483477 * (65535 & s) + ((1540483477 * (s >>> 16) & 65535) << 16) ^ e; + i -= 4; + ++n; + } + switch (i) { + case 3: + s ^= (255 & r.call(t, n + 2)) << 16; + + case 2: + s ^= (255 & r.call(t, n + 1)) << 8; + + case 1: + s ^= 255 & r.call(t, n); + s = 1540483477 * (65535 & s) + ((1540483477 * (s >>> 16) & 65535) << 16); + } + s ^= s >>> 13; + s = 1540483477 * (65535 & s) + ((1540483477 * (s >>> 16) & 65535) << 16); + s ^= s >>> 15; + return s >>> 0; + } + class Gr extends hr { + get attributes() { + return this._attributes; + } + get vertexBuffers() { + return this._vertexBuffers; + } + get indexBuffer() { + return this._indexBuffer; + } + get indirectBuffer() { + return this._indirectBuffer; + } + get attributesHash() { + return this._attributesHash; + } + set vertexCount(t) { + this._drawInfo.vertexCount = t; + } + get vertexCount() { + return this._drawInfo.vertexCount; + } + set firstVertex(t) { + this._drawInfo.firstVertex = t; + } + get firstVertex() { + return this._drawInfo.firstVertex; + } + set indexCount(t) { + this._drawInfo.indexCount = t; + } + get indexCount() { + return this._drawInfo.indexCount; + } + set firstIndex(t) { + this._drawInfo.firstIndex = t; + } + get firstIndex() { + return this._drawInfo.firstIndex; + } + set vertexOffset(t) { + this._drawInfo.vertexOffset = t; + } + get vertexOffset() { + return this._drawInfo.vertexOffset; + } + set instanceCount(t) { + this._drawInfo.instanceCount = t; + } + get instanceCount() { + return this._drawInfo.instanceCount; + } + set firstInstance(t) { + this._drawInfo.firstInstance = t; + } + get firstInstance() { + return this._drawInfo.firstInstance; + } + set drawInfo(t) { + this._drawInfo = t; + } + get drawInfo() { + return this._drawInfo; + } + constructor() { + super(ps.INPUT_ASSEMBLER); + this._attributes = []; + this._attributesHash = 0; + this._vertexBuffers = []; + this._indexBuffer = null; + this._indirectBuffer = null; + this._drawInfo = new vn; + } + getVertexBuffer(t = 0) { + return t < this._vertexBuffers.length ? this._vertexBuffers[t] : null; + } + computeAttributesHash() { + let t = "attrs"; + for (let e = 0; e < this.attributes.length; ++e) { + const i = this.attributes[e]; + t += `,${i.name},${i.format},${i.isNormalized},${i.stream},${i.isInstanced},${i.location}`; + } + return Ur(t, 666); + } + } + class zr extends hr { + get bindings() { + return this._bindings; + } + get bindingIndices() { + return this._bindingIndices; + } + get descriptorIndices() { + return this._descriptorIndices; + } + constructor() { + super(ps.DESCRIPTOR_SET_LAYOUT); + this._bindings = []; + this._bindingIndices = []; + this._descriptorIndices = []; + } + } + class Hr extends hr { + get setLayouts() { + return this._setLayouts; + } + constructor() { + super(ps.PIPELINE_LAYOUT); + this._setLayouts = []; + } + } + class jr extends hr { + get type() { + return this._type; + } + constructor() { + super(ps.QUEUE); + this._type = Qs.GRAPHICS; + } + } + class Xr extends hr { + get colorAttachments() { + return this._colorInfos; + } + get depthStencilAttachment() { + return this._depthStencilInfo; + } + get subPasses() { + return this._subpasses; + } + get hash() { + return this._hash; + } + constructor() { + super(ps.RENDER_PASS); + this._colorInfos = []; + this._depthStencilInfo = null; + this._subpasses = []; + this._hash = 0; + } + computeHash() { + let t = ""; + if (this._subpasses.length) for (let e = 0; e < this._subpasses.length; ++e) { + const i = this._subpasses[e]; + if (i.inputs.length) { + t += "ia"; + for (let e = 0; e < i.inputs.length; ++e) { + const s = this._colorInfos[i.inputs[e]]; + t += `,${s.format},${s.sampleCount}`; + } + } + if (i.colors.length) { + t += "ca"; + for (let e = 0; e < i.inputs.length; ++e) { + const s = this._colorInfos[i.inputs[e]]; + t += `,${s.format},${s.sampleCount}`; + } + } + if (i.depthStencil >= 0) { + const e = this._colorInfos[i.depthStencil]; + t += `ds,${e.format},${e.sampleCount}`; + } + } else { + t += "ca"; + for (let e = 0; e < this._colorInfos.length; ++e) { + const i = this._colorInfos[e]; + t += `,${i.format},${i.sampleCount}`; + } + const e = this._depthStencilInfo; + e && (t += `ds,${e.format},${e.sampleCount}`); + } + return Ur(t, 666); + } + } + class Wr extends hr { + get name() { + return this._name; + } + get attributes() { + return this._attributes; + } + get blocks() { + return this._blocks; + } + get samplers() { + return this._samplers; + } + constructor() { + super(ps.SHADER); + this._name = ""; + this._stages = []; + this._attributes = []; + this._blocks = []; + this._samplers = []; + } + } + class Yr extends hr { + get type() { + return this._info.type; + } + get usage() { + return this._info.usage; + } + get format() { + return this._info.format; + } + get width() { + return this._info.width; + } + get height() { + return this._info.height; + } + get depth() { + return this._info.depth; + } + get layerCount() { + return this._info.layerCount; + } + get levelCount() { + return this._info.levelCount; + } + get samples() { + return this._info.samples; + } + get flags() { + return this._info.flags; + } + get size() { + return this._size; + } + get info() { + return this._info; + } + get viewInfo() { + return this._viewInfo; + } + get isTextureView() { + return this._isTextureView; + } + constructor() { + super(ps.TEXTURE); + this._info = new xn; + this._viewInfo = new wn; + this._isPowerOf2 = !1; + this._isTextureView = !1; + this._size = 0; + } + static getLevelCount(t, e) { + return Math.floor(Math.log2(Math.max(t, e))); + } + } + class qr extends hr { + get info() { + return this._info; + } + get hash() { + return this._hash; + } + constructor(t, e) { + super(ps.SAMPLER); + this._info = new Rn; + this._hash = 0; + this._info.copy(t); + this._hash = e; + } + static computeHash(t) { + let e = t.minFilter; + e |= t.magFilter << 2; + e |= t.mipFilter << 4; + e |= t.addressU << 6; + e |= t.addressV << 8; + e |= t.addressW << 10; + e |= t.maxAnisotropy << 12; + e |= t.cmpFunc << 16; + return e; + } + static unpackFromHash(t) { + const e = new Rn; + e.minFilter = (3 & t) >> 0; + e.magFilter = (3 & t) >> 2; + e.mipFilter = (3 & t) >> 4; + e.addressU = (3 & t) >> 6; + e.addressV = (3 & t) >> 8; + e.addressW = (3 & t) >> 10; + e.maxAnisotropy = (15 & t) >> 12; + e.cmpFunc = (7 & t) >> 16; + return e; + } + } + class Kr extends hr { + get info() { + return this._info; + } + get hash() { + return this._hash; + } + constructor(t, e) { + super(ps.GLOBAL_BARRIER); + this._info = new Wn; + this._hash = 0; + this._info.copy(t); + this._hash = e; + } + static computeHash(t) { + return Ur(`${t.prevAccesses} ${t.nextAccesses} ${t.type}`, 666); + } + } + class Jr extends hr { + get info() { + return this._info; + } + get hash() { + return this._hash; + } + constructor(t, e) { + super(ps.TEXTURE_BARRIER); + this._info = new Yn; + this._hash = 0; + this._info.copy(t); + this._hash = e; + } + static computeHash(t) { + let e = `${t.prevAccesses} ${t.nextAccesses}`; + e += t.type; + e += t.baseMipLevel; + e += t.levelCount; + e += t.baseSlice; + e += t.sliceCount; + e += t.discardContents; + e += t.srcQueue ? t.srcQueue.type : 0; + e += t.dstQueue ? t.dstQueue.type : 0; + return Ur(e, 666); + } + } + const Zr = new class { + constructor() { + this._pools = []; + this._lastShrinkPassed = 0; + this.shrinkTimeSpan = 5; + } + addContainer(t) { + if (-1 === t._poolHandle) { + t._poolHandle = this._pools.length; + this._pools.push(t); + } + } + removeContainer(t) { + if (-1 !== t._poolHandle) { + this._pools[this._pools.length - 1]._poolHandle = t._poolHandle; + ot(this._pools, t._poolHandle); + t._poolHandle = -1; + } + } + tryShrink() { + for (let t = 0; t < this._pools.length; t++) this._pools[t].tryShrink(); + } + update(t) { + this._lastShrinkPassed += t; + if (this._lastShrinkPassed > this.shrinkTimeSpan) { + this.tryShrink(); + this._lastShrinkPassed -= this.shrinkTimeSpan; + } + } + }; + class Qr { + constructor() { + this._poolHandle = -1; + Zr.addContainer(this); + } + destroy() { + Zr.removeContainer(this); + } + } + class $r extends Qr { + constructor(t, e, i) { + super(); + this._ctor = void 0; + this._elementsPerBatch = void 0; + this._nextAvail = void 0; + this._freepool = []; + this._dtor = void 0; + this._ctor = t; + this._dtor = i || null; + this._elementsPerBatch = Math.max(e, 1); + this._nextAvail = this._elementsPerBatch - 1; + for (let e = 0; e < this._elementsPerBatch; ++e) this._freepool.push(t()); + } + alloc() { + if (this._nextAvail < 0) { + this._freepool.length = this._elementsPerBatch; + for (let t = 0; t < this._elementsPerBatch; t++) this._freepool[t] = this._ctor(); + this._nextAvail = this._elementsPerBatch - 1; + } + return this._freepool[this._nextAvail--]; + } + free(t) { + this._freepool[++this._nextAvail] = t; + } + freeArray(t) { + this._freepool.length = this._nextAvail + 1; + Array.prototype.push.apply(this._freepool, t); + this._nextAvail += t.length; + } + tryShrink() { + if (this._nextAvail >> 1 > this._elementsPerBatch) { + if (this._dtor) for (let t = this._nextAvail >> 1; t <= this._nextAvail; t++) this._dtor(this._freepool[t]); + this._freepool.length = this._nextAvail >> 1; + this._nextAvail = this._freepool.length - 1; + } + } + destroy() { + const t = arguments.length > 0 ? arguments[0] : null; + t && N(14100); + const e = t || this._dtor; + if (e) for (let t = 0; t <= this._nextAvail; t++) e(this._freepool[t]); + this._freepool.length = 0; + this._nextAvail = -1; + super.destroy(); + } + } + t("Pool", $r); + class to extends Qr { + constructor(t, e, i) { + super(); + this._fn = void 0; + this._dtor = null; + this._count = 0; + this._data = void 0; + this._initSize = 0; + this._fn = t; + this._dtor = i || null; + this._data = new Array(e); + this._initSize = e; + for (let i = 0; i < e; ++i) this._data[i] = t(); + } + get length() { + return this._count; + } + get data() { + return this._data; + } + reset() { + this._count = 0; + } + resize(t) { + if (t > this._data.length) for (let e = this._data.length; e < t; ++e) this._data[e] = this._fn(); + } + add() { + this._count >= this._data.length && this.resize(this._data.length << 1); + return this._data[this._count++]; + } + destroy() { + if (this._dtor) for (let t = 0; t < this._data.length; t++) this._dtor(this._data[t]); + this._data.length = 0; + this._count = 0; + super.destroy(); + } + tryShrink() { + if (this._data.length >> 2 > this._count) { + const t = Math.max(this._initSize, this._data.length >> 1); + if (this._dtor) for (let e = t; e < this._data.length; e++) this._dtor(this._data[e]); + this._data.length = t; + } + } + removeAt(t) { + if (t >= this._count) return; + const e = this._count - 1; + const i = this._data[t]; + this._data[t] = this._data[e]; + this._data[e] = i; + this._count -= 1; + } + } + t("RecyclePool", to); + class eo extends Qr { + constructor(t, e) { + super(); + this.array = void 0; + this.length = 0; + this._compareFn = void 0; + this._initSize = 0; + this.array = new Array(t); + this._initSize = t; + this.length = 0; + this._compareFn = e; + } + push(t) { + this.array[this.length++] = t; + } + pop() { + return this.array[--this.length]; + } + get(t) { + return this.array[t]; + } + clear() { + this.length = 0; + } + destroy() { + this.length = 0; + this.array.length = 0; + super.destroy(); + } + tryShrink() { + this.array.length >> 2 > this.length && (this.array.length = Math.max(this._initSize, this.array.length >> 1)); + } + sort() { + this.array.length = this.length; + this.array.sort(this._compareFn); + } + concat(t) { + for (let e = 0; e < t.length; ++e) this.array[this.length++] = t[e]; + } + fastRemove(t) { + if (t >= this.length || t < 0) return; + const e = --this.length; + this.array[t] = this.array[e]; + } + indexOf(t) { + for (let e = 0, i = this.length; e < i; ++e) if (this.array[e] === t) return e; + return -1; + } + } + t("CachedArray", eo); + t("memop", Object.freeze({ + __proto__: null, + Pool: $r, + RecyclePool: to, + CachedArray: eo + })); + const io = t("editorExtrasTag", "__editorExtras__"); + const so = 1 << 17; + const no = 1 << 18; + const ro = 1 << 19; + const oo = 1 << 20; + const ao = 1 << 21; + const lo = 1 << 22; + const ho = []; + class co { + static _deferredDestroy() { + const t = ho.length; + for (let e = 0; e < t; ++e) { + const t = ho[e]; + 1 & t._objFlags || t._destroyImmediate(); + } + t === ho.length ? ho.length = 0 : ho.splice(0, t); + } + constructor(t = "") { + this._objFlags = void 0; + this._name = void 0; + this._name = t; + this._objFlags = 0; + } + get name() { + return this._name; + } + set name(t) { + this._name = t; + } + set hideFlags(t) { + const e = t & co.Flags.AllHideMasks; + this._objFlags = this._objFlags & ~co.Flags.AllHideMasks | e; + } + get hideFlags() { + return this._objFlags & co.Flags.AllHideMasks; + } + set replicated(t) { + t ? this._objFlags |= lo : this._objFlags &= -4194305; + } + get replicated() { + return !!(this._objFlags & lo); + } + get isValid() { + return !(1 & this._objFlags); + } + destroy() { + if (1 & this._objFlags) { + N(5e3); + return !1; + } + if (4 & this._objFlags) return !1; + this._objFlags |= 4; + ho.push(this); + this._destroy(); + return !0; + } + _destruct() { + const t = this.constructor; + let e = t.__destruct__; + if (!e) { + e = function(t, e) { + const i = t instanceof m._BaseNode || t instanceof m.Component; + const s = i ? "_id" : null; + let n; + const r = {}; + for (n in t) if (t.hasOwnProperty(n)) { + if (n === s) continue; + switch (typeof t[n]) { + case "string": + r[n] = ""; + break; + + case "object": + case "function": + r[n] = null; + } + } + if (si._isCCClass(e)) { + const t = m.Class.Attr.getClassAttrs(e); + const s = e.__props__; + for (let e = 0; e < s.length; e++) { + n = s[e]; + const o = `${n}`; + if (o in t) { + if (i && "_id" === n) continue; + switch (typeof t[o]) { + case "string": + r[n] = ""; + break; + + case "object": + case "function": + r[n] = null; + break; + + case "undefined": + r[n] = void 0; + } + } + } + } + return t => { + for (const e in r) t[e] = r[e]; + }; + }(this, t); + bt(t, "__destruct__", e, !0); + } + e(this); + } + _destroyImmediate() { + if (1 & this._objFlags) F(5e3); else { + this._onPreDestroy && this._onPreDestroy(); + this._destruct(); + this._objFlags |= 1; + } + } + } + t("CCObject", co); + const uo = co.prototype; + uo._deserialize = null; + uo._onPreDestroy = null; + si.fastDefine("cc.Object", co, { + _name: "", + _objFlags: 0, + [io]: {} + }); + si.Attr.setClassAttr(co, io, "editorOnly", !0); + si.Attr.setClassAttr(co, "replicated", "visible", !1); + bt(co, "Flags", { + Destroyed: 1, + DontSave: 8, + EditorOnly: 16, + Dirty: 32, + DontDestroy: 64, + PersistentMask: -4192741, + Destroying: 128, + Deactivating: 256, + LockedInEditor: 512, + HideInHierarchy: 1024, + AllHideMasks: 1560, + IsPreloadStarted: 8192, + IsOnLoadStarted: 32768, + IsOnLoadCalled: 16384, + IsOnEnableCalled: 2048, + IsStartCalled: 65536, + IsEditorOnEnableCalled: 4096, + IsPositionLocked: ao, + IsRotationLocked: so, + IsScaleLocked: no, + IsAnchorLocked: ro, + IsSizeLocked: oo + }); + function _o(t) { + return t instanceof co; + } + function po(t, e) { + return "object" == typeof t ? !(!t || t._objFlags & (e ? 5 : 1)) : void 0 !== t; + } + m.isValid = po; + Pt(co, jsb.CCObject, [ "prototype", "length", "name" ]); + Pt(co.prototype, jsb.CCObject.prototype, [ "constructor", "name", "hideFlags", "replicated", "isValid" ]); + co = t("CCObject", jsb.CCObject); + m.Object = co; + const mo = te.fastRemoveAt; + function fo() {} + class go { + constructor() { + this.callback = fo; + this.target = void 0; + this.once = !1; + } + set(t, e, i) { + this.callback = t || fo; + this.target = e; + this.once = !!i; + } + reset() { + this.target = void 0; + this.callback = fo; + this.once = !1; + } + check() { + return !(_o(this.target) && !po(this.target, !0)); + } + } + const yo = new $r((() => new go), 32); + class bo { + constructor() { + this.callbackInfos = []; + this.isInvoking = !1; + this.containCanceled = !1; + } + removeByCallback(t) { + for (let e = 0; e < this.callbackInfos.length; ++e) { + const i = this.callbackInfos[e]; + if (i && i.callback === t) { + i.reset(); + yo.free(i); + mo(this.callbackInfos, e); + --e; + } + } + } + removeByTarget(t) { + for (let e = 0; e < this.callbackInfos.length; ++e) { + const i = this.callbackInfos[e]; + if (i && i.target === t) { + i.reset(); + yo.free(i); + mo(this.callbackInfos, e); + --e; + } + } + } + cancel(t) { + const e = this.callbackInfos[t]; + if (e) { + e.reset(); + this.isInvoking ? this.callbackInfos[t] = null : mo(this.callbackInfos, t); + yo.free(e); + } + this.containCanceled = !0; + } + cancelAll() { + for (let t = 0; t < this.callbackInfos.length; t++) { + const e = this.callbackInfos[t]; + if (e) { + e.reset(); + yo.free(e); + this.callbackInfos[t] = null; + } + } + this.containCanceled = !0; + } + purgeCanceled() { + for (let t = this.callbackInfos.length - 1; t >= 0; --t) { + this.callbackInfos[t] || mo(this.callbackInfos, t); + } + this.containCanceled = !1; + } + clear() { + this.cancelAll(); + this.callbackInfos.length = 0; + this.isInvoking = !1; + this.containCanceled = !1; + } + } + const So = new $r((() => new bo), 16); + class Ao { + constructor() { + this._callbackTable = vt(!0); + this._offCallback = void 0; + } + on(t, e, i, s) { + if (!this.hasEventListener(t, e, i)) { + let n = this._callbackTable[t]; + n || (n = this._callbackTable[t] = So.alloc()); + const r = yo.alloc(); + r.set(e, i, s); + n.callbackInfos.push(r); + } + return e; + } + hasEventListener(t, e, i) { + const s = this._callbackTable && this._callbackTable[t]; + if (!s) return !1; + const n = s.callbackInfos; + if (!e) { + if (s.isInvoking) { + for (let t = 0; t < n.length; ++t) if (n[t]) return !0; + return !1; + } + return n.length > 0; + } + for (let t = 0; t < n.length; ++t) { + const s = n[t]; + if (s && s.check() && s.callback === e && s.target === i) return !0; + } + return !1; + } + removeAll(t) { + const e = typeof t; + if ("string" === e || "number" === e) { + const e = this._callbackTable && this._callbackTable[t]; + if (e) if (e.isInvoking) e.cancelAll(); else { + e.clear(); + So.free(e); + delete this._callbackTable[t]; + } + } else if (t) for (const e in this._callbackTable) { + const i = this._callbackTable[e]; + if (i.isInvoking) { + const e = i.callbackInfos; + for (let s = 0; s < e.length; ++s) { + const n = e[s]; + n && n.target === t && i.cancel(s); + } + } else i.removeByTarget(t); + } + } + off(t, e, i) { + var s; + const n = this._callbackTable && this._callbackTable[t]; + if (n) { + const s = n.callbackInfos; + if (e) for (let t = 0; t < s.length; ++t) { + const r = s[t]; + if (r && r.callback === e && r.target === i) { + n.cancel(t); + break; + } + } else this.removeAll(t); + } + null === (s = this._offCallback) || void 0 === s || s.call(this); + } + emit(t, e, i, s, n, r) { + const o = this._callbackTable && this._callbackTable[t]; + if (o) { + const a = !o.isInvoking; + o.isInvoking = !0; + const l = o.callbackInfos; + for (let o = 0, a = l.length; o < a; ++o) { + const a = l[o]; + if (a) { + const o = a.callback; + const l = a.target; + a.once && this.off(t, o, l); + a.check() ? l ? o.call(l, e, i, s, n, r) : o(e, i, s, n, r) : this.off(t, o, l); + } + } + if (a) { + o.isInvoking = !1; + o.containCanceled && o.purgeCanceled(); + } + } + } + clear() { + for (const t in this._callbackTable) { + const e = this._callbackTable[t]; + if (e) { + e.clear(); + So.free(e); + delete this._callbackTable[t]; + } + } + } + _registerOffCallback(t) { + this._offCallback = t; + } + } + function To(t) { + class e extends t { + constructor(...t) { + super(...t); + this._callbackTable = vt(!0); + } + once(t, e, i) { + return this.on(t, e, i, !0); + } + targetOff(t) { + this.removeAll(t); + } + } + const i = Ao.prototype; + const s = Object.getOwnPropertyNames(i).concat(Object.getOwnPropertySymbols(i)); + for (let t = 0; t < s.length; ++t) { + const n = s[t]; + if (!(n in e.prototype)) { + const t = Object.getOwnPropertyDescriptor(i, n); + t && Object.defineProperty(e.prototype, n, t); + } + } + return e; + } + const vo = t("EventTarget", To(class {})); + m.EventTarget = vo; + class Eo { + constructor() { + this._delegates = []; + } + add(t) { + this._delegates.includes(t) || this._delegates.push(t); + } + hasListener(t) { + return this._delegates.includes(t); + } + remove(t) { + ee.array.fastRemove(this._delegates, t); + } + dispatch(...t) { + return Promise.all(this._delegates.map((t => t(...arguments))).filter(Boolean)); + } + } + t("AsyncDelegate", Eo); + let Co; + !function(t) { + t.UNKNOWN = "unknown"; + t.WECHAT = "wechat"; + t.ANDROID = "androidbrowser"; + t.IE = "ie"; + t.EDGE = "edge"; + t.QQ = "qqbrowser"; + t.MOBILE_QQ = "mqqbrowser"; + t.UC = "ucbrowser"; + t.UCBS = "ucbs"; + t.BROWSER_360 = "360browser"; + t.BAIDU_APP = "baiduboxapp"; + t.BAIDU = "baidubrowser"; + t.MAXTHON = "maxthon"; + t.OPERA = "opera"; + t.OUPENG = "oupeng"; + t.MIUI = "miuibrowser"; + t.FIREFOX = "firefox"; + t.SAFARI = "safari"; + t.CHROME = "chrome"; + t.LIEBAO = "liebao"; + t.QZONE = "qzone"; + t.SOUGOU = "sogou"; + t.HUAWEI = "huawei"; + }(Co || (Co = {})); + let xo; + !function(t) { + t.UNKNOWN = "unknown"; + t.ENGLISH = "en"; + t.CHINESE = "zh"; + t.FRENCH = "fr"; + t.ITALIAN = "it"; + t.GERMAN = "de"; + t.SPANISH = "es"; + t.DUTCH = "du"; + t.RUSSIAN = "ru"; + t.KOREAN = "ko"; + t.JAPANESE = "ja"; + t.HUNGARIAN = "hu"; + t.PORTUGUESE = "pt"; + t.ARABIC = "ar"; + t.NORWEGIAN = "no"; + t.POLISH = "pl"; + t.TURKISH = "tr"; + t.UKRAINIAN = "uk"; + t.ROMANIAN = "ro"; + t.BULGARIAN = "bg"; + }(xo || (xo = {})); + let wo; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.LAN = 1] = "LAN"; + t[t.WWAN = 2] = "WWAN"; + }(wo || (wo = {})); + let Ro; + !function(t) { + t.UNKNOWN = "Unknown"; + t.IOS = "iOS"; + t.ANDROID = "Android"; + t.WINDOWS = "Windows"; + t.LINUX = "Linux"; + t.OSX = "OS X"; + t.OHOS = "OHOS"; + }(Ro || (Ro = {})); + let Io; + !function(t) { + t.UNKNOWN = "UNKNOWN"; + t.EDITOR_PAGE = "EDITOR_PAGE"; + t.EDITOR_CORE = "EDITOR_CORE"; + t.MOBILE_BROWSER = "MOBILE_BROWSER"; + t.DESKTOP_BROWSER = "DESKTOP_BROWSER"; + t.WIN32 = "WIN32"; + t.ANDROID = "ANDROID"; + t.IOS = "IOS"; + t.MACOS = "MACOS"; + t.OHOS = "OHOS"; + t.WECHAT_GAME = "WECHAT_GAME"; + t.BAIDU_MINI_GAME = "BAIDU_MINI_GAME"; + t.XIAOMI_QUICK_GAME = "XIAOMI_QUICK_GAME"; + t.ALIPAY_MINI_GAME = "ALIPAY_MINI_GAME"; + t.BYTEDANCE_MINI_GAME = "BYTEDANCE_MINI_GAME"; + t.OPPO_MINI_GAME = "OPPO_MINI_GAME"; + t.VIVO_MINI_GAME = "VIVO_MINI_GAME"; + t.HUAWEI_QUICK_GAME = "HUAWEI_QUICK_GAME"; + t.COCOSPLAY = "COCOSPLAY"; + t.LINKSURE_MINI_GAME = "LINKSURE_MINI_GAME"; + t.QTT_MINI_GAME = "QTT_MINI_GAME"; + }(Io || (Io = {})); + let Mo; + !function(t) { + t.WEBP = "WEBP"; + t.IMAGE_BITMAP = "IMAGE_BITMAP"; + t.WEB_VIEW = "WEB_VIEW"; + t.VIDEO_PLAYER = "VIDEO_PLAYER"; + t.SAFE_AREA = "SAFE_AREA"; + t.INPUT_TOUCH = "INPUT_TOUCH"; + t.EVENT_KEYBOARD = "EVENT_KEYBOARD"; + t.EVENT_MOUSE = "EVENT_MOUSE"; + t.EVENT_TOUCH = "EVENT_TOUCH"; + t.EVENT_ACCELEROMETER = "EVENT_ACCELEROMETER"; + t.EVENT_GAMEPAD = "EVENT_GAMEPAD"; + t.EVENT_HANDLE = "EVENT_HANDLE"; + t.EVENT_HMD = "EVENT_HMD"; + }(Mo || (Mo = {})); + const Bo = { + 0: wo.NONE, + 1: wo.LAN, + 2: wo.WWAN + }; + const Do = { + 0: Io.WIN32, + 2: Io.MACOS, + 3: Io.ANDROID, + 4: Io.IOS, + 5: Io.IOS, + 6: Io.OHOS + }; + const Po = new class extends vo { + get networkType() { + return Bo[jsb.device.getNetworkType()]; + } + constructor() { + super(); + this.isNative = void 0; + this.isBrowser = void 0; + this.isMobile = void 0; + this.isLittleEndian = void 0; + this.platform = void 0; + this.language = void 0; + this.nativeLanguage = void 0; + this.os = void 0; + this.osVersion = void 0; + this.osMainVersion = void 0; + this.browserType = void 0; + this.browserVersion = void 0; + this.isXR = void 0; + this._featureMap = void 0; + this.isNative = !0; + this.isBrowser = !1; + this.platform = Do[__getPlatform()]; + this.isMobile = this.platform === Io.ANDROID || this.platform === Io.IOS || this.platform === Io.OHOS; + this.isLittleEndian = (() => { + const t = new ArrayBuffer(2); + new DataView(t).setInt16(0, 256, !0); + return 256 === new Int16Array(t)[0]; + })(); + const t = __getCurrentLanguageCode(); + this.nativeLanguage = t ? t.toLowerCase() : xo.UNKNOWN; + this.language = __getCurrentLanguage(); + this.os = __getOS(); + this.osVersion = __getOSVersion(); + this.osMainVersion = parseInt(this.osVersion); + this.browserType = Co.UNKNOWN; + this.browserVersion = ""; + this.isXR = "undefined" != typeof xr; + this._featureMap = { + [Mo.WEBP]: !0, + [Mo.IMAGE_BITMAP]: !1, + [Mo.WEB_VIEW]: this.isMobile, + [Mo.VIDEO_PLAYER]: this.isMobile, + [Mo.SAFE_AREA]: this.isMobile, + [Mo.INPUT_TOUCH]: this.isMobile, + [Mo.EVENT_KEYBOARD]: !0, + [Mo.EVENT_MOUSE]: !this.isMobile, + [Mo.EVENT_TOUCH]: !0, + [Mo.EVENT_ACCELEROMETER]: this.isMobile, + [Mo.EVENT_GAMEPAD]: !0, + [Mo.EVENT_HANDLE]: this.isXR, + [Mo.EVENT_HMD]: this.isXR + }; + this._registerEvent(); + } + _registerEvent() { + jsb.onPause = () => { + this.emit("hide"); + }; + jsb.onResume = () => { + this.emit("show"); + }; + jsb.onClose = () => { + this.emit("close"); + }; + } + hasFeature(t) { + return this._featureMap[t]; + } + getBatteryLevel() { + return jsb.device.getBatteryLevel(); + } + triggerGC() { + jsb.garbageCollect(); + } + openURL(t) { + jsb.openURL(t); + } + now() { + return Date.now ? Date.now() : +new Date; + } + restartJSVM() { + __restartVM(); + } + close() { + __close(); + } + }; + let Oo; + !function(t) { + t[t.PORTRAIT = 1] = "PORTRAIT"; + t[t.PORTRAIT_UPSIDE_DOWN = 2] = "PORTRAIT_UPSIDE_DOWN"; + t[t.LANDSCAPE_LEFT = 4] = "LANDSCAPE_LEFT"; + t[t.LANDSCAPE_RIGHT = 8] = "LANDSCAPE_RIGHT"; + t[t.LANDSCAPE = 12] = "LANDSCAPE"; + t[t.AUTO = 13] = "AUTO"; + }(Oo || (Oo = {})); + const No = { + 0: Oo.PORTRAIT, + "-90": Oo.LANDSCAPE_LEFT, + 90: Oo.LANDSCAPE_RIGHT, + 180: Oo.PORTRAIT_UPSIDE_DOWN + }; + const Lo = new class extends vo { + get supportFullScreen() { + return !1; + } + get isFullScreen() { + return !1; + } + get devicePixelRatio() { + return jsb.device.getDevicePixelRatio() || 1; + } + get windowSize() { + const t = this.devicePixelRatio; + const e = globalThis.oh ? jsb.device.getInnerWidth() : window.innerWidth; + const i = globalThis.oh ? jsb.device.getInnerHeight() : window.innerHeight; + const s = Math.round(e); + const n = Math.round(i); + return new rs(s * t, n * t); + } + set windowSize(t) { + console.warn("Setting window size is not supported yet."); + } + get resolution() { + const t = this.windowSize; + const e = this.resolutionScale; + return new rs(t.width * e, t.height * e); + } + get resolutionScale() { + return this._resolutionScale; + } + set resolutionScale(t) { + var e; + if (t !== this._resolutionScale) { + this._resolutionScale = t; + null === (e = this._cbToUpdateFrameBuffer) || void 0 === e || e.call(this); + } + } + get orientation() { + return No[jsb.device.getDeviceOrientation()]; + } + set orientation(t) { + console.warn("Setting orientation is not supported yet."); + } + get safeAreaEdge() { + const t = jsb.device.getSafeAreaEdge(); + const e = this.devicePixelRatio; + let i = t.x * e; + let s = t.z * e; + let n = t.y * e; + let r = t.w * e; + this.orientation === Oo.PORTRAIT ? i < s ? i = s : s = i : n < r ? n = r : r = n; + return { + top: i, + bottom: s, + left: n, + right: r + }; + } + get isProportionalToFrame() { + return this._isProportionalToFrame; + } + set isProportionalToFrame(t) {} + constructor() { + super(); + this.isFrameRotated = !1; + this.handleResizeEvent = !0; + this._cbToUpdateFrameBuffer = void 0; + this._resolutionScale = 1; + this._isProportionalToFrame = !1; + this._registerEvent(); + } + init(t, e) { + this._cbToUpdateFrameBuffer = e; + this._cbToUpdateFrameBuffer(); + } + requestFullScreen() { + return Promise.reject(new Error("request fullscreen has not been supported yet on this platform.")); + } + exitFullScreen() { + return Promise.reject(new Error("exit fullscreen has not been supported yet on this platform.")); + } + _registerEvent() { + jsb.onResize = t => { + if (0 !== t.width && 0 !== t.height) { + t.width /= this.devicePixelRatio; + t.height /= this.devicePixelRatio; + window.resize(t.width, t.height); + this.emit("window-resize"); + } + }; + jsb.onOrientationChanged = t => { + this.emit("orientation-change"); + }; + } + }; + const Fo = t("screen", new class { + init() { + var t, e; + const i = null === (t = de.querySettings(_e.Category.SCREEN, "exactFitScreen")) || void 0 === t || t; + const s = null !== (e = de.querySettings(_e.Category.SCREEN, "orientation")) && void 0 !== e ? e : "auto"; + Lo.init({ + exactFitScreen: i, + configOrientation: s + }, (() => { + var t; + const e = m.director; + (null === (t = e.root) || void 0 === t ? void 0 : t.pipeline) ? e.root.pipeline.shadingScale = Lo.resolutionScale : N(1220); + })); + } + get devicePixelRatio() { + return Lo.devicePixelRatio; + } + get windowSize() { + return Lo.windowSize; + } + set windowSize(t) { + Lo.windowSize = t; + } + get resolution() { + return Lo.resolution; + } + get supportsFullScreen() { + return Lo.supportFullScreen; + } + fullScreen() { + return Lo.isFullScreen; + } + requestFullScreen(t, e, i) { + arguments.length > 0 && N(1400, "screen.requestFullScreen(element, onFullScreenChange?, onFullScreenError?)", "screen.requestFullScreen(): Promise"); + return Lo.requestFullScreen().then((() => { + null == e || e(); + })).catch((t => { + console.error(t); + null == i || i(); + })); + } + exitFullScreen() { + return Lo.exitFullScreen(); + } + autoFullScreen(t, e) { + var i; + null === (i = this.requestFullScreen(t, e)) || void 0 === i || i.catch((t => {})); + } + disableAutoFullScreen(t) {} + }); + m.screen = Fo; + const Vo = t("sys", { + Feature: Mo, + hasFeature: t => Po.hasFeature(t), + NetworkType: wo, + Language: xo, + OS: Ro, + Platform: Io, + BrowserType: Co, + isNative: Po.isNative, + isBrowser: Po.isBrowser, + isMobile: Po.isMobile, + isLittleEndian: Po.isLittleEndian, + platform: Po.platform, + language: Po.language, + languageCode: Po.nativeLanguage, + os: Po.os, + osVersion: Po.osVersion, + osMainVersion: Po.osMainVersion, + browserType: Po.browserType, + browserVersion: Po.browserVersion, + isXR: Po.isXR, + windowPixelResolution: Fo.windowSize, + capabilities: { + canvas: !0, + opengl: !0, + webp: Po.hasFeature(Mo.WEBP), + imageBitmap: Po.hasFeature(Mo.IMAGE_BITMAP), + touches: Po.hasFeature(Mo.INPUT_TOUCH), + mouse: Po.hasFeature(Mo.EVENT_MOUSE), + keyboard: Po.hasFeature(Mo.EVENT_KEYBOARD), + accelerometer: Po.hasFeature(Mo.EVENT_ACCELEROMETER) + }, + localStorage: {}, + getNetworkType: () => Po.networkType, + getBatteryLevel: () => Po.getBatteryLevel(), + garbageCollect() { + Po.triggerGC(); + }, + isObjectValid: t => null != t, + dump() { + let t = ""; + t += `isMobile : ${this.isMobile}\r\n`; + t += `language : ${this.language}\r\n`; + t += `browserType : ${this.browserType}\r\n`; + t += `browserVersion : ${this.browserVersion}\r\n`; + t += `capabilities : ${JSON.stringify(this.capabilities)}\r\n`; + t += `os : ${this.os}\r\n`; + t += `osVersion : ${this.osVersion}\r\n`; + t += `platform : ${this.platform}\r\n`; + t += `Using ${m.game.renderType === m.game.RENDER_TYPE_WEBGL ? "WEBGL" : "CANVAS"} renderer.\r\n`; + E(t); + }, + openURL(t) { + Po.openURL(t); + }, + init() { + try { + let t = Vo.localStorage = window.localStorage; + t.setItem("storage", ""); + t.removeItem("storage"); + t = null; + } catch (t) { + const e = function() { + N(5200); + }; + this.localStorage = { + getItem: e, + setItem: e, + clear: e, + removeItem: e + }; + } + this.__isWebIOS14OrIPadOS14Env = (Vo.os === Ro.IOS || Vo.os === Ro.OSX) && Po.isBrowser && /(OS 14)|(Version\/14)/.test(window.navigator.userAgent); + }, + now: () => Po.now(), + restartVM() { + Po.restartJSVM(); + }, + getSafeAreaRect() { + const t = m.view; + const e = Lo.safeAreaEdge; + const i = Lo.windowSize; + const s = new Qi(e.left, e.bottom); + const n = new Qi(i.width - e.right, i.height - e.top); + t._convertToUISpace(s); + t._convertToUISpace(n); + const r = s.x; + const o = s.y; + const a = n.x - s.x; + const l = n.y - s.y; + return new as(r, o, a, l); + } + }); + m.sys = Vo; + let ko; + !function(t) { + t[t.AUTO = 0] = "AUTO"; + t[t.CANVAS = 1] = "CANVAS"; + t[t.WEBGL = 2] = "WEBGL"; + t[t.HEADLESS = 3] = "HEADLESS"; + }(ko || (ko = {})); + let Uo; + !function(t) { + t[t.UNKNOWN = -1] = "UNKNOWN"; + t[t.CANVAS = 0] = "CANVAS"; + t[t.WEBGL = 1] = "WEBGL"; + t[t.OPENGL = 2] = "OPENGL"; + t[t.HEADLESS = 3] = "HEADLESS"; + }(Uo || (Uo = {})); + class Go { + constructor() { + this.initialized = !1; + this._canvas = null; + this._renderType = Uo.UNKNOWN; + } + get gfxDevice() { + return this._gfxDevice; + } + get swapchain() { + return this._swapchain; + } + init(t, e) { + if (this.initialized) return; + const i = de.querySettings(_e.Category.RENDERING, "renderMode"); + this._canvas = t; + this._renderType = this._determineRenderType(i); + if (this._renderType === Uo.WEBGL) { + const i = new Sn(e); + if (window.gfx) this._gfxDevice = gfx.DeviceManager.create(i); else { + let e = !!window.WebGL2RenderingContext; + const s = window.navigator.userAgent.toLowerCase(); + (-1 !== s.indexOf("safari") && -1 === s.indexOf("chrome") || Vo.browserType === Co.UC) && (e = !1); + const n = []; + e && m.WebGL2Device && n.push(m.WebGL2Device); + m.WebGLDevice && n.push(m.WebGLDevice); + m.EmptyDevice && n.push(m.EmptyDevice); + Nr.canvas = t; + for (let t = 0; t < n.length; t++) { + this._gfxDevice = new n[t]; + if (this._gfxDevice.initialize(i)) break; + } + } + } else if (this._renderType === Uo.HEADLESS && m.EmptyDevice) { + this._gfxDevice = new m.EmptyDevice; + this._gfxDevice.initialize(new Sn(e)); + } + if (!this._gfxDevice) { + x("can not support canvas rendering in 3D"); + this._renderType = Uo.UNKNOWN; + return; + } + const s = new bn(this._canvas); + const n = Fo.windowSize; + s.width = n.width; + s.height = n.height; + this._swapchain = this._gfxDevice.createSwapchain(s); + this._canvas && (this._canvas.oncontextmenu = () => !1); + } + _determineRenderType(t) { + ("number" != typeof t || t > Uo.HEADLESS || t < ko.AUTO) && (t = ko.AUTO); + let e = Uo.CANVAS; + let i = !1; + if (t === ko.CANVAS) { + e = Uo.CANVAS; + i = !0; + } else if (t === ko.AUTO || t === ko.WEBGL) { + e = Uo.WEBGL; + i = !0; + } else if (t === ko.HEADLESS) { + e = Uo.HEADLESS; + i = !0; + } + if (!i) throw new Error(G(3820, t)); + return e; + } + } + const zo = new Go; + const Ho = { + GFXDevice: !0, + GFXBuffer: !0, + GFXTexture: !0, + GFXSampler: !0, + GFXShader: !0, + GFXInputAssembler: !0, + GFXRenderPass: !0, + GFXFramebuffer: !0, + GFXPipelineState: !0, + GFXCommandBuffer: !0, + GFXQueue: !0, + GFXObjectType: !0, + GFXObject: !1, + GFXAttributeName: !0, + GFXType: !0, + GFXFormat: !0, + GFXBufferUsageBit: !0, + GFXMemoryUsageBit: !0, + GFXBufferFlagBit: !0, + GFXBufferAccessBit: "MemoryAccessBit", + GFXPrimitiveMode: !0, + GFXPolygonMode: !0, + GFXShadeModel: !0, + GFXCullMode: !0, + GFXComparisonFunc: !0, + GFXStencilOp: !0, + GFXBlendOp: !0, + GFXBlendFactor: !0, + GFXColorMask: !0, + GFXFilter: !0, + GFXAddress: !0, + GFXTextureType: !0, + GFXTextureUsageBit: !0, + GFXSampleCount: !0, + GFXTextureFlagBit: !0, + GFXShaderStageFlagBit: !0, + GFXDescriptorType: !0, + GFXCommandBufferType: !0, + GFXLoadOp: !0, + GFXStoreOp: !0, + GFXPipelineBindPoint: !0, + GFXDynamicStateFlagBit: !0, + GFXStencilFace: !0, + GFXQueueType: !0, + GFXRect: !0, + GFXViewport: !0, + GFXColor: !0, + GFXClearFlag: !0, + GFXOffset: !0, + GFXExtent: !0, + GFXTextureSubres: "TextureSubresLayers", + GFXTextureCopy: !0, + GFXBufferTextureCopy: !0, + GFXFormatType: !0, + GFXFormatInfo: !0, + GFXMemoryStatus: !0, + GFXFormatInfos: !0, + GFXFormatSize: !0, + GFXFormatSurfaceSize: !0, + GFXGetTypeSize: !0, + getTypedArrayConstructor: !1 + }; + for (const t in Ho) { + let e = Ho[t]; + !0 === e ? e = t.slice(3) : !1 === e && (e = t); + W(m, "cc", [ { + name: t, + newName: e, + target: m.gfx, + targetName: "cc.gfx" + } ]); + } + Y(m, "cc", [ { + name: "GFX_MAX_VERTEX_ATTRIBUTES" + }, { + name: "GFX_MAX_TEXTURE_UNITS" + }, { + name: "GFX_MAX_ATTACHMENTS" + }, { + name: "GFX_MAX_BUFFER_BINDINGS" + }, { + name: "GFXTextureLayout" + } ]); + const jo = Object.assign({}, Er); + jo.Device = gfx.Device; + jo.Swapchain = gfx.Swapchain; + jo.Buffer = gfx.Buffer; + jo.Texture = gfx.Texture; + jo.Sampler = gfx.Sampler; + jo.Shader = gfx.Shader; + jo.InputAssembler = gfx.InputAssembler; + jo.RenderPass = gfx.RenderPass; + jo.Framebuffer = gfx.Framebuffer; + jo.DescriptorSet = gfx.DescriptorSet; + jo.DescriptorSetLayout = gfx.DescriptorSetLayout; + jo.PipelineLayout = gfx.PipelineLayout; + jo.PipelineState = gfx.PipelineState; + jo.CommandBuffer = gfx.CommandBuffer; + jo.Queue = gfx.Queue; + m.gfx = jo; + jo.BlendTarget = Rr; + jo.BlendState = Ir; + jo.RasterizerState = Cr; + jo.DepthStencilState = wr; + jo.PipelineStateInfo = Br; + t("gfx", Object.freeze({ + __proto__: null, + DescriptorSet: Dr, + Buffer: Pr, + CommandBuffer: Or, + get ObjectType() { + return ps; + }, + get Status() { + return ms; + }, + get API() { + return fs; + }, + get SurfaceTransform() { + return gs; + }, + get Feature() { + return ys; + }, + get Format() { + return bs; + }, + get FormatType() { + return Ss; + }, + get Type() { + return As; + }, + get BufferUsageBit() { + return Ts; + }, + get BufferFlagBit() { + return vs; + }, + get MemoryAccessBit() { + return Es; + }, + get MemoryUsageBit() { + return Cs; + }, + get TextureType() { + return xs; + }, + get TextureUsageBit() { + return ws; + }, + get TextureFlagBit() { + return Rs; + }, + get FormatFeatureBit() { + return Is; + }, + get SampleCount() { + return Ms; + }, + get VsyncMode() { + return Bs; + }, + get Filter() { + return Ds; + }, + get Address() { + return Ps; + }, + get ComparisonFunc() { + return Os; + }, + get StencilOp() { + return Ns; + }, + get BlendFactor() { + return Ls; + }, + get BlendOp() { + return Fs; + }, + get ColorMask() { + return Vs; + }, + get ShaderStageFlagBit() { + return ks; + }, + get LoadOp() { + return Us; + }, + get StoreOp() { + return Gs; + }, + get AccessFlagBit() { + return zs; + }, + get ResolveMode() { + return Hs; + }, + get PipelineBindPoint() { + return js; + }, + get PrimitiveMode() { + return Xs; + }, + get PolygonMode() { + return Ws; + }, + get ShadeModel() { + return Ys; + }, + get CullMode() { + return qs; + }, + get DynamicStateFlagBit() { + return Ks; + }, + get StencilFace() { + return Js; + }, + get DescriptorType() { + return Zs; + }, + get QueueType() { + return Qs; + }, + get QueryType() { + return $s; + }, + get CommandBufferType() { + return tn; + }, + get ClearFlagBit() { + return en; + }, + get BarrierType() { + return sn; + }, + get PassType() { + return nn; + }, + Size: rn, + DeviceCaps: on, + DeviceOptions: an, + Offset: ln, + Rect: hn, + Extent: cn, + TextureSubresLayers: un, + TextureSubresRange: _n, + TextureCopy: dn, + TextureBlit: pn, + BufferTextureCopy: mn, + Viewport: fn, + Color: gn, + BindingMappingInfo: yn, + SwapchainInfo: bn, + DeviceInfo: Sn, + BufferInfo: An, + BufferViewInfo: Tn, + DrawInfo: vn, + DispatchInfo: En, + IndirectBuffer: Cn, + TextureInfo: xn, + TextureViewInfo: wn, + SamplerInfo: Rn, + Uniform: In, + UniformBlock: Mn, + UniformSamplerTexture: Bn, + UniformSampler: Dn, + UniformTexture: Pn, + UniformStorageImage: On, + UniformStorageBuffer: Nn, + UniformInputAttachment: Ln, + ShaderStage: Fn, + Attribute: Vn, + ShaderInfo: kn, + InputAssemblerInfo: Un, + ColorAttachment: Gn, + DepthStencilAttachment: zn, + SubpassInfo: Hn, + SubpassDependency: jn, + RenderPassInfo: Xn, + GeneralBarrierInfo: Wn, + TextureBarrierInfo: Yn, + BufferBarrierInfo: qn, + FramebufferInfo: Kn, + DescriptorSetLayoutBinding: Jn, + DescriptorSetLayoutInfo: Zn, + DescriptorSetInfo: Qn, + PipelineLayoutInfo: $n, + InputState: tr, + CommandBufferInfo: er, + QueueInfo: ir, + QueryPoolInfo: sr, + FormatInfo: rr, + MemoryStatus: or, + DynamicStencilStates: ar, + DynamicStates: lr, + GFXObject: hr, + get AttributeName() { + return cr; + }, + FormatInfos: ur, + DESCRIPTOR_BUFFER_TYPE: _r, + DESCRIPTOR_SAMPLER_TYPE: dr, + DESCRIPTOR_DYNAMIC_TYPE: pr, + DRAW_INFO_SIZE: mr, + IsPowerOf2: fr, + FormatSize: gr, + FormatSurfaceSize: yr, + GetTypeSize: Sr, + getTypedArrayConstructor: Ar, + formatAlignment: Tr, + alignTo: vr, + Device: Nr, + Swapchain: Lr, + Framebuffer: Fr, + InputAssembler: Gr, + DescriptorSetLayout: zr, + PipelineLayout: Hr, + RasterizerState: Cr, + DepthStencilState: wr, + BlendTarget: Rr, + BlendState: Ir, + PipelineState: Mr, + PipelineStateInfo: Br, + Queue: jr, + RenderPass: Xr, + Shader: Wr, + Texture: Yr, + Sampler: qr, + GeneralBarrier: Kr, + TextureBarrier: Jr, + get LegacyRenderMode() { + return ko; + }, + get RenderType() { + return Uo; + }, + DeviceManager: Go, + deviceManager: zo + })); + const Xo = new Pi; + const Wo = new Pi; + const Yo = new Pi; + const qo = new Pi; + const Ko = new Pi; + const Jo = new Pi; + const Zo = new Array(3); + const Qo = new Array(3); + function $o(t, e) { + return Pi.dot(e.n, t) - e.d; + } + function ta(t, e, i) { + Pi.copy(t, e); + Pi.subtract(Ko, i.center, i.halfExtents); + Pi.add(Jo, i.center, i.halfExtents); + t.x = t.x < Ko.x ? Ko.x : t.x; + t.y = t.y < Ko.y ? Ko.y : t.y; + t.z = t.z < Ko.z ? Ko.z : t.z; + t.x = t.x > Jo.x ? Jo.x : t.x; + t.y = t.y > Jo.y ? Jo.y : t.y; + t.z = t.z > Jo.z ? Jo.z : t.z; + return t; + } + function ea(t, e, i) { + Pi.set(Xo, i.orientation.m00, i.orientation.m01, i.orientation.m02); + Pi.set(Wo, i.orientation.m03, i.orientation.m04, i.orientation.m05); + Pi.set(Yo, i.orientation.m06, i.orientation.m07, i.orientation.m08); + Zo[0] = Xo; + Zo[1] = Wo; + Zo[2] = Yo; + Qo[0] = i.halfExtents.x; + Qo[1] = i.halfExtents.y; + Qo[2] = i.halfExtents.z; + Pi.subtract(qo, e, i.center); + Pi.set(t, i.center.x, i.center.y, i.center.z); + for (let e = 0; e < 3; e++) { + let i = Pi.dot(qo, Zo[e]); + i > Qo[e] && (i = Qo[e]); + i < -Qo[e] && (i = -Qo[e]); + t.x += i * Zo[e].x; + t.y += i * Zo[e].y; + t.z += i * Zo[e].z; + } + return t; + } + var ia = Object.freeze({ + __proto__: null, + point_plane: $o, + pt_point_plane: function(t, e, i) { + const s = $o(e, i); + return Pi.subtract(t, e, Pi.multiplyScalar(t, i.n, s)); + }, + pt_point_aabb: ta, + pt_point_obb: ea, + pt_point_line: function(t, e, i, s) { + Pi.subtract(Xo, i, s); + const n = Xo; + const r = Pi.lengthSqr(n); + if (0 == r) Pi.copy(t, i); else { + Pi.subtract(Xo, e, i); + const o = Pi.dot(Xo, n) / r; + o < 0 ? Pi.copy(t, i) : o > 1 ? Pi.copy(t, s) : Pi.scaleAndAdd(t, i, n, o); + } + } + }); + var sa = { + SHAPE_RAY: 1, + SHAPE_LINE: 2, + SHAPE_SPHERE: 4, + SHAPE_AABB: 8, + SHAPE_OBB: 16, + SHAPE_PLANE: 32, + SHAPE_TRIANGLE: 64, + SHAPE_FRUSTUM: 128, + SHAPE_FRUSTUM_ACCURATE: 256, + SHAPE_CAPSULE: 512, + SHAPE_SPLINE: 1024 + }; + class na { + static create(t, e, i, s, n, r) { + return new na(t, e, i, s, n, r); + } + static clone(t) { + return new na(t.s.x, t.s.y, t.s.z, t.e.x, t.e.y, t.e.z); + } + static copy(t, e) { + Pi.copy(t.s, e.s); + Pi.copy(t.e, e.e); + return t; + } + static fromPoints(t, e, i) { + Pi.copy(t.s, e); + Pi.copy(t.e, i); + return t; + } + static set(t, e, i, s, n, r, o) { + t.s.x = e; + t.s.y = i; + t.s.z = s; + t.e.x = n; + t.e.y = r; + t.e.z = o; + return t; + } + static len(t) { + return Pi.distance(t.s, t.e); + } + get type() { + return this._type; + } + constructor(t = 0, e = 0, i = 0, s = 0, n = 0, r = -1) { + this.s = void 0; + this.e = void 0; + this._type = void 0; + this._type = sa.SHAPE_LINE; + this.s = new Pi(t, e, i); + this.e = new Pi(s, n, r); + } + length() { + return Pi.distance(this.s, this.e); + } + } + class ra { + static create(t = 0, e = 0, i = 0, s = 0, n = 0, r = 1) { + return new ra(t, e, i, s, n, r); + } + static clone(t) { + return new ra(t.o.x, t.o.y, t.o.z, t.d.x, t.d.y, t.d.z); + } + static copy(t, e) { + Pi.copy(t.o, e.o); + Pi.copy(t.d, e.d); + return t; + } + static fromPoints(t, e, i) { + Pi.copy(t.o, e); + Pi.normalize(t.d, Pi.subtract(t.d, i, e)); + return t; + } + static set(t, e, i, s, n, r, o) { + t.o.x = e; + t.o.y = i; + t.o.z = s; + t.d.x = n; + t.d.y = r; + t.d.z = o; + return t; + } + get type() { + return this._type; + } + constructor(t = 0, e = 0, i = 0, s = 0, n = 0, r = -1) { + this.o = void 0; + this.d = void 0; + this._type = void 0; + this._type = sa.SHAPE_RAY; + this.o = new Pi(t, e, i); + this.d = new Pi(s, n, r); + } + computeHit(t, e) { + Pi.normalize(t, this.d); + Pi.scaleAndAdd(t, this.o, t, e); + } + } + const oa = new Pi; + const aa = new Pi; + const la = new Pi; + const ha = new Pi; + function ca(t) { + return Math.max(Math.max(t.x, t.y), t.z); + } + class ua { + static create(t, e, i, s) { + return new ua(t, e, i, s); + } + static clone(t) { + return new ua(t.center.x, t.center.y, t.center.z, t.radius); + } + static copy(t, e) { + Pi.copy(t.center, e.center); + t.radius = e.radius; + return t; + } + static fromPoints(t, e, i) { + Pi.multiplyScalar(t.center, Pi.add(oa, e, i), .5); + t.radius = .5 * Pi.subtract(oa, i, e).length(); + return t; + } + static set(t, e, i, s, n) { + t.center.x = e; + t.center.y = i; + t.center.z = s; + t.radius = n; + return t; + } + get center() { + return this._center; + } + set center(t) { + this._center = t; + } + get radius() { + return this._radius; + } + set radius(t) { + this._radius = t; + } + get type() { + return this._type; + } + constructor(t = 0, e = 0, i = 0, s = 1) { + this._center = new Pi(0, 0, 0); + this._radius = 0; + this._type = void 0; + this._type = sa.SHAPE_SPHERE; + this._center = new Pi(t, e, i); + this._radius = s; + } + destroy() {} + clone() { + return ua.clone(this); + } + copy(t) { + return ua.copy(this, t); + } + getBoundary(t, e) { + Pi.set(t, this.center.x - this.radius, this.center.y - this.radius, this.center.z - this.radius); + Pi.set(e, this.center.x + this.radius, this.center.y + this.radius, this.center.z + this.radius); + } + transform(t, e, i, s, n) { + Pi.transformMat4(n.center, this.center, t); + n.radius = this.radius * ca(s); + } + translateAndRotate(t, e, i) { + Pi.transformMat4(i.center, this.center, t); + } + setScale(t, e) { + e.radius = this.radius * ca(t); + } + mergePoint(t) { + if (this.radius < 0) { + this.center.set(t); + this.radius = 0; + } + Pi.subtract(aa, t, this.center); + const e = aa.length(); + if (e > this.radius) { + const t = .5 * (e - this.radius); + this.radius += t; + Pi.multiplyScalar(aa, aa, t / e); + Pi.add(this.center, this.center, aa); + } + } + mergePoints(t) { + const e = t.length; + if (!(e < 1)) { + this.radius = -1; + for (let i = 0; i < e; i++) this.mergePoint(t[i]); + } + } + mergeAABB(t) { + t.getBoundary(la, ha); + this.mergePoint(la); + this.mergePoint(ha); + } + } + class _a { + static create(t = 1, e = 0, i = 0, s = 0, n = 0, r = 0, o = 0, a = 0, l = 1) { + return new _a(t, e, i, s, n, r, o, a, l); + } + static clone(t) { + return new _a(t.a.x, t.a.y, t.a.z, t.b.x, t.b.y, t.b.z, t.c.x, t.c.y, t.c.z); + } + static copy(t, e) { + Pi.copy(t.a, e.a); + Pi.copy(t.b, e.b); + Pi.copy(t.c, e.c); + return t; + } + static fromPoints(t, e, i, s) { + Pi.copy(t.a, e); + Pi.copy(t.b, i); + Pi.copy(t.c, s); + return t; + } + static set(t, e, i, s, n, r, o, a, l, h) { + t.a.x = e; + t.a.y = i; + t.a.z = s; + t.b.x = n; + t.b.y = r; + t.b.z = o; + t.c.x = a; + t.c.y = l; + t.c.z = h; + return t; + } + get type() { + return this._type; + } + constructor(t = 0, e = 0, i = 0, s = 1, n = 0, r = 0, o = 0, a = 1, l = 0) { + this.a = void 0; + this.b = void 0; + this.c = void 0; + this._type = void 0; + this._type = sa.SHAPE_TRIANGLE; + this.a = new Pi(t, e, i); + this.b = new Pi(s, n, r); + this.c = new Pi(o, a, l); + } + } + let da; + !function(t) { + t[t.ALL = 0] = "ALL"; + t[t.CLOSEST = 1] = "CLOSEST"; + t[t.ANY = 2] = "ANY"; + }(da || (da = {})); + const pa = function() { + const t = new Pi(0, 0, 0); + return function(e, i) { + const s = Pi.dot(e.d, i.n); + if (Math.abs(s) < Number.EPSILON) return 0; + Pi.multiplyScalar(t, i.n, i.d); + const n = Pi.dot(Pi.subtract(t, t, e.o), i.n) / s; + return n < 0 ? 0 : n; + }; + }(); + const ma = function() { + const t = new Pi(0, 0, 0); + const e = new Pi(0, 0, 0); + const i = new Pi(0, 0, 0); + const s = new Pi(0, 0, 0); + const n = new Pi(0, 0, 0); + return function(r, o, a) { + Pi.subtract(t, o.b, o.a); + Pi.subtract(e, o.c, o.a); + Pi.cross(i, r.d, e); + const l = Pi.dot(t, i); + if (l < Number.EPSILON && (!a || l > -Number.EPSILON)) return 0; + const h = 1 / l; + Pi.subtract(s, r.o, o.a); + const c = Pi.dot(s, i) * h; + if (c < 0 || c > 1) return 0; + Pi.cross(n, s, t); + const u = Pi.dot(r.d, n) * h; + if (u < 0 || c + u > 1) return 0; + const _ = Pi.dot(e, n) * h; + return _ < 0 ? 0 : _; + }; + }(); + const fa = function() { + const t = new Pi(0, 0, 0); + return function(e, i) { + const s = i.radius; + const n = i.center; + const r = e.o; + const o = e.d; + const a = s * s; + Pi.subtract(t, n, r); + const l = t.lengthSqr(); + const h = Pi.dot(t, o); + const c = a - (l - h * h); + if (c < 0) return 0; + const u = Math.sqrt(c); + const _ = l < a ? h + u : h - u; + return _ < 0 ? 0 : _; + }; + }(); + const ga = function() { + const t = new Pi; + const e = new Pi; + return function(i, s) { + Pi.subtract(t, s.center, s.halfExtents); + Pi.add(e, s.center, s.halfExtents); + return ya(i, t, e); + }; + }(); + function ya(t, e, i) { + const s = t.o; + const n = t.d; + const r = 1 / n.x; + const o = 1 / n.y; + const a = 1 / n.z; + const l = (e.x - s.x) * r; + const h = (i.x - s.x) * r; + const c = (e.y - s.y) * o; + const u = (i.y - s.y) * o; + const _ = (e.z - s.z) * a; + const d = (i.z - s.z) * a; + const p = Math.max(Math.max(Math.min(l, h), Math.min(c, u)), Math.min(_, d)); + const m = Math.min(Math.min(Math.max(l, h), Math.max(c, u)), Math.max(_, d)); + return m < 0 || p > m ? 0 : p > 0 ? p : m; + } + const ba = function() { + let t = new Pi; + let e = new Pi; + let i = new Pi; + const s = new Pi; + const n = new Pi; + const r = new Pi; + const o = new Pi; + const a = new Array(3); + const l = new Array(3); + const h = new Array(3); + const c = new Array(6); + return function(u, _) { + a[0] = _.halfExtents.x; + a[1] = _.halfExtents.y; + a[2] = _.halfExtents.z; + t = _.center; + e = u.o; + i = u.d; + Pi.set(s, _.orientation.m00, _.orientation.m01, _.orientation.m02); + Pi.set(n, _.orientation.m03, _.orientation.m04, _.orientation.m05); + Pi.set(r, _.orientation.m06, _.orientation.m07, _.orientation.m08); + Pi.subtract(o, t, e); + l[0] = Pi.dot(s, i); + l[1] = Pi.dot(n, i); + l[2] = Pi.dot(r, i); + h[0] = Pi.dot(s, o); + h[1] = Pi.dot(n, o); + h[2] = Pi.dot(r, o); + for (let t = 0; t < 3; ++t) { + if (0 === l[t]) { + if (-h[t] - a[t] > 0 || -h[t] + a[t] < 0) return 0; + l[t] = 1e-7; + } + c[2 * t + 0] = (h[t] + a[t]) / l[t]; + c[2 * t + 1] = (h[t] - a[t]) / l[t]; + } + const d = Math.max(Math.max(Math.min(c[0], c[1]), Math.min(c[2], c[3])), Math.min(c[4], c[5])); + const p = Math.min(Math.min(Math.max(c[0], c[1]), Math.max(c[2], c[3])), Math.max(c[4], c[5])); + return p < 0 || d > p ? 0 : d > 0 ? d : p; + }; + }(); + const Sa = function() { + const t = new Pi; + const e = new Pi; + const i = new Pi; + const s = new Pi; + const n = new Pi; + const r = new Pi; + const o = new Pi; + const a = new ua; + return function(l, h) { + const c = h.radius * h.radius; + const u = Pi.normalize(t, l.d); + const _ = h.ellipseCenter0; + const d = h.ellipseCenter1; + const p = Pi.subtract(e, d, _); + if (p.equals(Pi.ZERO)) { + a.radius = h.radius; + a.center.set(h.ellipseCenter0); + return Za.raySphere(l, a); + } + const m = l.o; + const f = Pi.subtract(i, m, _); + const g = Pi.cross(s, u, p); + const y = g.lengthSqr(); + if (0 === y) { + a.radius = h.radius; + const t = Pi.subtract(n, d, m); + f.lengthSqr() < t.lengthSqr() ? a.center.set(h.ellipseCenter0) : a.center.set(h.ellipseCenter1); + return Za.raySphere(l, a); + } + const b = Pi.cross(n, f, p); + const S = p.lengthSqr(); + const A = 2 * Pi.dot(g, b); + const T = A * A - 4 * y * (b.lengthSqr() - c * S); + if (T < 0) return 0; + const v = (-A - Math.sqrt(T)) / (2 * y); + if (v < 0) { + a.radius = h.radius; + const t = Pi.subtract(r, d, m); + f.lengthSqr() < t.lengthSqr() ? a.center.set(h.ellipseCenter0) : a.center.set(h.ellipseCenter1); + return Za.raySphere(l, a); + } + { + const t = Pi.scaleAndAdd(r, l.o, u, v); + const e = Pi.subtract(o, t, _); + const i = Pi.dot(e, p) / S; + if (i >= 0 && i <= 1) return v; + if (i < 0) { + a.radius = h.radius; + a.center.set(h.ellipseCenter0); + return Za.raySphere(l, a); + } + if (i > 1) { + a.radius = h.radius; + a.center.set(h.ellipseCenter1); + return Za.raySphere(l, a); + } + return 0; + } + }; + }(); + const Aa = function() { + const t = _a.create(); + const e = { + distance: 1 / 0, + doubleSided: !1, + mode: da.ANY + }; + let i = 0; + const s = (t, e, s, n, r, o) => { + if (t === da.CLOSEST) { + if (i > e || 0 === i) { + i = e; + if (o) if (0 === o.length) o.push({ + distance: e, + vertexIndex0: s / 3, + vertexIndex1: n / 3, + vertexIndex2: r / 3 + }); else { + o[0].distance = e; + o[0].vertexIndex0 = s / 3; + o[0].vertexIndex1 = n / 3; + o[0].vertexIndex2 = r / 3; + } + } + } else { + i = e; + o && o.push({ + distance: e, + vertexIndex0: s / 3, + vertexIndex1: n / 3, + vertexIndex2: r / 3 + }); + } + }; + return function(n, r, o) { + i = 0; + if (0 === r.geometricInfo.positions.length) return i; + const a = void 0 === o ? e : o; + if (ya(n, r.geometricInfo.boundingBox.min, r.geometricInfo.boundingBox.max)) { + const e = r.primitiveMode; + const {positions: i, indices: o} = r.geometricInfo; + ((e, i, n, r, o) => { + if (n === Xs.TRIANGLE_LIST) { + const n = i.length; + for (let a = 0; a < n; a += 3) { + const n = 3 * i[a]; + const l = 3 * i[a + 1]; + const h = 3 * i[a + 2]; + Pi.set(t.a, e[n], e[n + 1], e[n + 2]); + Pi.set(t.b, e[l], e[l + 1], e[l + 2]); + Pi.set(t.c, e[h], e[h + 1], e[h + 2]); + const c = Za.rayTriangle(r, t, o.doubleSided); + if (!(0 === c || c > o.distance)) { + s(o.mode, c, n, l, h, o.result); + if (o.mode === da.ANY) return c; + } + } + } else if (n === Xs.TRIANGLE_STRIP) { + const n = i.length - 2; + let a = 0; + for (let l = 0; l < n; l += 1) { + const n = 3 * i[l - a]; + const h = 3 * i[l + a + 1]; + const c = 3 * i[l + 2]; + Pi.set(t.a, e[n], e[n + 1], e[n + 2]); + Pi.set(t.b, e[h], e[h + 1], e[h + 2]); + Pi.set(t.c, e[c], e[c + 1], e[c + 2]); + a = ~a; + const u = Za.rayTriangle(r, t, o.doubleSided); + if (!(0 === u || u > o.distance)) { + s(o.mode, u, n, h, c, o.result); + if (o.mode === da.ANY) return u; + } + } + } else if (n === Xs.TRIANGLE_FAN) { + const n = i.length - 1; + const a = 3 * i[0]; + Pi.set(t.a, e[a], e[a + 1], e[a + 2]); + for (let l = 1; l < n; l += 1) { + const n = 3 * i[l]; + const h = 3 * i[l + 1]; + Pi.set(t.b, e[n], e[n + 1], e[n + 2]); + Pi.set(t.c, e[h], e[h + 1], e[h + 2]); + const c = Za.rayTriangle(r, t, o.doubleSided); + if (!(0 === c || c > o.distance)) { + s(o.mode, c, a, n, h, o.result); + if (o.mode === da.ANY) return c; + } + } + } + })(i, o, e, n, a); + } + return i; + }; + }(); + const Ta = function() { + let t = 0; + const e = { + distance: 1 / 0, + doubleSided: !1, + mode: da.ANY + }; + return function(i, s, n) { + t = 0; + const r = void 0 === n ? e : n; + const o = s.renderingSubMeshes.length; + const a = s.struct.minPosition; + const l = s.struct.maxPosition; + if (a && l && !ya(i, a, l)) return t; + for (let e = 0; e < o; e++) { + const n = s.renderingSubMeshes[e]; + const o = Aa(i, n, r); + if (o) if (r.mode === da.CLOSEST) { + if (0 === t || t > o) { + t = o; + r.subIndices && (r.subIndices[0] = e); + } + } else { + t = o; + r.subIndices && r.subIndices.push(e); + if (r.mode === da.ANY) return o; + } + } + if (t && r.mode === da.CLOSEST) { + if (r.result) { + r.result[0].distance = t; + r.result.length = 1; + } + r.subIndices && (r.subIndices.length = 1); + } + return t; + }; + }(); + const va = function() { + let t = 0; + const e = { + distance: 1 / 0, + doubleSided: !1, + mode: da.ANY + }; + const i = new ra; + const s = new qi; + return function(n, r, o) { + t = 0; + const a = void 0 === o ? e : o; + const l = r.worldBounds; + if (l && !ga(n, l)) return t; + ra.copy(i, n); + if (r.node) { + qi.invert(s, r.node.getWorldMatrix(s)); + Pi.transformMat4(i.o, n.o, s); + Pi.transformMat4Normal(i.d, n.d, s); + } + const h = r.subModels; + for (let e = 0; e < h.length; e++) { + const s = h[e].subMesh; + const n = Aa(i, s, a); + if (n) if (a.mode === da.CLOSEST) { + if (0 === t || t > n) { + t = n; + a.subIndices && (a.subIndices[0] = e); + } + } else { + t = n; + a.subIndices && a.subIndices.push(e); + if (a.mode === da.ANY) return n; + } + } + if (t && a.mode === da.CLOSEST) { + if (a.result) { + a.result[0].distance = t; + a.result.length = 1; + } + a.subIndices && (a.subIndices.length = 1); + } + return t; + }; + }(); + const Ea = function() { + const t = new Pi(0, 0, 0); + return function(e, i) { + Pi.subtract(t, e.e, e.s); + const s = (i.d - Pi.dot(e.s, i.n)) / Pi.dot(t, i.n); + return s < 0 || s > 1 ? 0 : s; + }; + }(); + const Ca = function() { + const t = new Pi(0, 0, 0); + const e = new Pi(0, 0, 0); + const i = new Pi(0, 0, 0); + const s = new Pi(0, 0, 0); + const n = new Pi(0, 0, 0); + const r = new Pi(0, 0, 0); + return function(o, a, l) { + Pi.subtract(t, a.b, a.a); + Pi.subtract(e, a.c, a.a); + Pi.subtract(i, o.s, o.e); + Pi.cross(n, t, e); + const h = Pi.dot(i, n); + if (h <= 0) return 0; + Pi.subtract(s, o.s, a.a); + const c = Pi.dot(s, n); + if (c < 0 || c > h) return 0; + Pi.cross(r, i, s); + let u = Pi.dot(e, r); + if (u < 0 || u > h) return 0; + let _ = -Pi.dot(t, r); + if (_ < 0 || u + _ > h) return 0; + if (l) { + const t = 1 / h; + u *= t; + _ *= t; + const e = 1 - u - _; + Pi.set(l, a.a.x * e + a.b.x * u + a.c.x * _, a.a.y * e + a.b.y * u + a.c.y * _, a.a.z * e + a.b.z * u + a.c.z * _); + } + return 1; + }; + }(); + const xa = new ra; + function wa(t, e) { + xa.o.set(t.s); + Pi.subtract(xa.d, t.e, t.s); + xa.d.normalize(); + const i = ga(xa, e); + return i <= t.length() ? i : 0; + } + function Ra(t, e) { + xa.o.set(t.s); + Pi.subtract(xa.d, t.e, t.s); + xa.d.normalize(); + const i = ba(xa, e); + return i <= t.length() ? i : 0; + } + function Ia(t, e) { + xa.o.set(t.s); + Pi.subtract(xa.d, t.e, t.s); + xa.d.normalize(); + const i = fa(xa, e); + return i <= t.length() ? i : 0; + } + const Ma = function() { + const t = new Pi; + const e = new Pi; + const i = new Pi; + const s = new Pi; + return function(n, r) { + Pi.subtract(t, n.center, n.halfExtents); + Pi.add(e, n.center, n.halfExtents); + Pi.subtract(i, r.center, r.halfExtents); + Pi.add(s, r.center, r.halfExtents); + return t.x <= s.x && e.x >= i.x && t.y <= s.y && e.y >= i.y && t.z <= s.z && e.z >= i.z; + }; + }(); + function Ba(t, e, i, s, n, r) { + Pi.set(r[0], t.x + i.x * e.x + s.x * e.y + n.x * e.z, t.y + i.y * e.x + s.y * e.y + n.y * e.z, t.z + i.z * e.x + s.z * e.y + n.z * e.z); + Pi.set(r[1], t.x - i.x * e.x + s.x * e.y + n.x * e.z, t.y - i.y * e.x + s.y * e.y + n.y * e.z, t.z - i.z * e.x + s.z * e.y + n.z * e.z); + Pi.set(r[2], t.x + i.x * e.x - s.x * e.y + n.x * e.z, t.y + i.y * e.x - s.y * e.y + n.y * e.z, t.z + i.z * e.x - s.z * e.y + n.z * e.z); + Pi.set(r[3], t.x + i.x * e.x + s.x * e.y - n.x * e.z, t.y + i.y * e.x + s.y * e.y - n.y * e.z, t.z + i.z * e.x + s.z * e.y - n.z * e.z); + Pi.set(r[4], t.x - i.x * e.x - s.x * e.y - n.x * e.z, t.y - i.y * e.x - s.y * e.y - n.y * e.z, t.z - i.z * e.x - s.z * e.y - n.z * e.z); + Pi.set(r[5], t.x + i.x * e.x - s.x * e.y - n.x * e.z, t.y + i.y * e.x - s.y * e.y - n.y * e.z, t.z + i.z * e.x - s.z * e.y - n.z * e.z); + Pi.set(r[6], t.x - i.x * e.x + s.x * e.y - n.x * e.z, t.y - i.y * e.x + s.y * e.y - n.y * e.z, t.z - i.z * e.x + s.z * e.y - n.z * e.z); + Pi.set(r[7], t.x - i.x * e.x - s.x * e.y + n.x * e.z, t.y - i.y * e.x - s.y * e.y + n.y * e.z, t.z - i.z * e.x - s.z * e.y + n.z * e.z); + } + function Da(t, e) { + let i = Pi.dot(e, t[0]); + let s = i; + for (let n = 1; n < 8; ++n) { + const r = Pi.dot(e, t[n]); + i = r < i ? r : i; + s = r > s ? r : s; + } + return [ i, s ]; + } + const Pa = function() { + const t = new Array(15); + for (let e = 0; e < 15; e++) t[e] = new Pi(0, 0, 0); + const e = new Array(8); + const i = new Array(8); + for (let t = 0; t < 8; t++) { + e[t] = new Pi(0, 0, 0); + i[t] = new Pi(0, 0, 0); + } + const s = new Pi; + const n = new Pi; + return function(r, o) { + Pi.set(t[0], 1, 0, 0); + Pi.set(t[1], 0, 1, 0); + Pi.set(t[2], 0, 0, 1); + Pi.set(t[3], o.orientation.m00, o.orientation.m01, o.orientation.m02); + Pi.set(t[4], o.orientation.m03, o.orientation.m04, o.orientation.m05); + Pi.set(t[5], o.orientation.m06, o.orientation.m07, o.orientation.m08); + for (let e = 0; e < 3; ++e) { + Pi.cross(t[6 + 3 * e + 0], t[e], t[3]); + Pi.cross(t[6 + 3 * e + 1], t[e], t[4]); + Pi.cross(t[6 + 3 * e + 1], t[e], t[5]); + } + Pi.subtract(s, r.center, r.halfExtents); + Pi.add(n, r.center, r.halfExtents); + !function(t, e, i) { + Pi.set(i[0], t.x, e.y, e.z); + Pi.set(i[1], t.x, e.y, t.z); + Pi.set(i[2], t.x, t.y, e.z); + Pi.set(i[3], t.x, t.y, t.z); + Pi.set(i[4], e.x, e.y, e.z); + Pi.set(i[5], e.x, e.y, t.z); + Pi.set(i[6], e.x, t.y, e.z); + Pi.set(i[7], e.x, t.y, t.z); + }(s, n, e); + Ba(o.center, o.halfExtents, t[3], t[4], t[5], i); + for (let s = 0; s < 15; ++s) { + const n = Da(e, t[s]); + const r = Da(i, t[s]); + if (r[0] > n[1] || n[0] > r[1]) return 0; + } + return 1; + }; + }(); + const Oa = function(t, e) { + const i = t.halfExtents.x * Math.abs(e.n.x) + t.halfExtents.y * Math.abs(e.n.y) + t.halfExtents.z * Math.abs(e.n.z); + const s = Pi.dot(e.n, t.center); + return s + i < e.d ? -1 : s - i > e.d ? 0 : 1; + }; + const Na = function(t, e) { + for (let i = 0; i < e.planes.length; i++) if (-1 === Oa(t, e.planes[i])) return 0; + return 1; + }; + const La = function() { + const t = new Array(8); + let e = 0; + let i = 0; + for (let e = 0; e < t.length; e++) t[e] = new Pi(0, 0, 0); + return function(s, n) { + let r = 0; + let o = !1; + for (let t = 0; t < n.planes.length; t++) { + r = Oa(s, n.planes[t]); + if (-1 === r) return 0; + 1 === r && (o = !0); + } + if (!o) return 1; + for (let e = 0; e < n.vertices.length; e++) Pi.subtract(t[e], n.vertices[e], s.center); + e = 0, i = 0; + for (let r = 0; r < n.vertices.length; r++) t[r].x > s.halfExtents.x ? e++ : t[r].x < -s.halfExtents.x && i++; + if (e === n.vertices.length || i === n.vertices.length) return 0; + e = 0; + i = 0; + for (let r = 0; r < n.vertices.length; r++) t[r].y > s.halfExtents.y ? e++ : t[r].y < -s.halfExtents.y && i++; + if (e === n.vertices.length || i === n.vertices.length) return 0; + e = 0; + i = 0; + for (let r = 0; r < n.vertices.length; r++) t[r].z > s.halfExtents.z ? e++ : t[r].z < -s.halfExtents.z && i++; + return e === n.vertices.length || i === n.vertices.length ? 0 : 1; + }; + }(); + const Fa = function() { + const t = new Pi(0, 0, 0); + const e = new Fi; + return function(i, s) { + Pi.subtract(t, s, i.center); + Pi.transformMat3(t, t, Fi.transpose(e, i.orientation)); + return n = t, r = i.halfExtents, Math.abs(n.x) < r.x && Math.abs(n.y) < r.y && Math.abs(n.z) < r.z; + var n, r; + }; + }(); + const Va = function() { + const t = function(t, e, i, s) { + return Math.abs(t.x * e + t.y * i + t.z * s); + }; + return function(e, i) { + const s = e.halfExtents.x * t(i.n, e.orientation.m00, e.orientation.m01, e.orientation.m02) + e.halfExtents.y * t(i.n, e.orientation.m03, e.orientation.m04, e.orientation.m05) + e.halfExtents.z * t(i.n, e.orientation.m06, e.orientation.m07, e.orientation.m08); + const n = Pi.dot(i.n, e.center); + return n + s < i.d ? -1 : n - s > i.d ? 0 : 1; + }; + }(); + const ka = function(t, e) { + for (let i = 0; i < e.planes.length; i++) if (-1 === Va(t, e.planes[i])) return 0; + return 1; + }; + const Ua = function() { + const t = new Array(8); + let e = 0; + let i = 0; + let s = 0; + for (let e = 0; e < t.length; e++) t[e] = new Pi(0, 0, 0); + const n = function(t, e, i, s) { + return t.x * e + t.y * i + t.z * s; + }; + return function(r, o) { + let a = 0; + let l = !1; + for (let t = 0; t < o.planes.length; t++) { + a = Va(r, o.planes[t]); + if (-1 === a) return 0; + 1 === a && (l = !0); + } + if (!l) return 1; + for (let e = 0; e < o.vertices.length; e++) Pi.subtract(t[e], o.vertices[e], r.center); + i = 0, s = 0; + for (let a = 0; a < o.vertices.length; a++) { + e = n(t[a], r.orientation.m00, r.orientation.m01, r.orientation.m02); + e > r.halfExtents.x ? i++ : e < -r.halfExtents.x && s++; + } + if (i === o.vertices.length || s === o.vertices.length) return 0; + i = 0; + s = 0; + for (let a = 0; a < o.vertices.length; a++) { + e = n(t[a], r.orientation.m03, r.orientation.m04, r.orientation.m05); + e > r.halfExtents.y ? i++ : e < -r.halfExtents.y && s++; + } + if (i === o.vertices.length || s === o.vertices.length) return 0; + i = 0; + s = 0; + for (let a = 0; a < o.vertices.length; a++) { + e = n(t[a], r.orientation.m06, r.orientation.m07, r.orientation.m08); + e > r.halfExtents.z ? i++ : e < -r.halfExtents.z && s++; + } + return i === o.vertices.length || s === o.vertices.length ? 0 : 1; + }; + }(); + const Ga = function() { + const t = new Array(15); + for (let e = 0; e < 15; e++) t[e] = new Pi(0, 0, 0); + const e = new Array(8); + const i = new Array(8); + for (let t = 0; t < 8; t++) { + e[t] = new Pi(0, 0, 0); + i[t] = new Pi(0, 0, 0); + } + return function(s, n) { + Pi.set(t[0], s.orientation.m00, s.orientation.m01, s.orientation.m02); + Pi.set(t[1], s.orientation.m03, s.orientation.m04, s.orientation.m05); + Pi.set(t[2], s.orientation.m06, s.orientation.m07, s.orientation.m08); + Pi.set(t[3], n.orientation.m00, n.orientation.m01, n.orientation.m02); + Pi.set(t[4], n.orientation.m03, n.orientation.m04, n.orientation.m05); + Pi.set(t[5], n.orientation.m06, n.orientation.m07, n.orientation.m08); + for (let e = 0; e < 3; ++e) { + Pi.cross(t[6 + 3 * e + 0], t[e], t[3]); + Pi.cross(t[6 + 3 * e + 1], t[e], t[4]); + Pi.cross(t[6 + 3 * e + 2], t[e], t[5]); + } + Ba(s.center, s.halfExtents, t[0], t[1], t[2], e); + Ba(n.center, n.halfExtents, t[3], t[4], t[5], i); + for (let s = 0; s < 15; ++s) { + const n = Da(e, t[s]); + const r = Da(i, t[s]); + if (r[0] > n[1] || n[0] > r[1]) return 0; + } + return 1; + }; + }(); + const za = function() { + const t = new ua; + const e = new Pi; + const i = new Pi; + const s = new Pi; + const n = new Array(8); + for (let t = 0; t < 8; t++) n[t] = new Pi; + const r = new Array(8); + for (let t = 0; t < 8; t++) r[t] = new Pi; + return function(o, a) { + if (0 === Pi.squaredDistance(a.ellipseCenter0, a.ellipseCenter1)) { + t.radius = a.radius; + t.center.set(a.ellipseCenter0); + return Za.sphereOBB(t, o); + } + { + e.x = o.orientation.m00; + e.y = o.orientation.m01; + e.z = o.orientation.m02; + i.x = o.orientation.m03; + i.y = o.orientation.m04; + i.z = o.orientation.m05; + s.x = o.orientation.m06; + s.y = o.orientation.m07; + s.z = o.orientation.m08; + Ba(o.center, o.halfExtents, e, i, s, n); + const t = r; + const l = Pi.copy(t[0], e); + const h = Pi.copy(t[1], i); + const c = Pi.copy(t[2], s); + Pi.subtract(t[3], a.center, o.center).normalize(); + const u = Pi.subtract(t[4], a.ellipseCenter0, a.ellipseCenter1); + u.normalize(); + Pi.cross(t[5], l, u); + Pi.cross(t[6], h, u); + Pi.cross(t[7], c, u); + for (let e = 0; e < 8; ++e) { + const i = Da(n, t[e]); + const s = Pi.dot(t[e], a.ellipseCenter0); + const r = Pi.dot(t[e], a.ellipseCenter1); + const o = Math.max(s, r); + const l = Math.min(s, r) - a.radius; + const h = o + a.radius; + if (l > i[1] || i[0] > h) return 0; + } + return 1; + } + }; + }(); + const Ha = function(t, e) { + const i = Pi.dot(e.n, t.center); + const s = t.radius * e.n.length(); + return i + s < e.d ? -1 : i - s > e.d ? 0 : 1; + }; + const ja = function(t, e) { + for (let i = 0; i < e.planes.length; i++) if (-1 === Ha(t, e.planes[i])) return 0; + return 1; + }; + const Xa = function() { + const t = new Pi(0, 0, 0); + const e = [ 1, -1, 1, -1, 1, -1 ]; + return function(i, s) { + for (let n = 0; n < 6; n++) { + const r = s.planes[n]; + const o = i.radius; + const a = i.center; + const l = r.n; + const h = r.d; + const c = Pi.dot(l, a); + if (c + o < h) return 0; + if (!(c - o > h)) { + Pi.add(t, a, Pi.multiplyScalar(t, l, o)); + for (let i = 0; i < 6; i++) { + if (i === n || i === n + e[n]) continue; + const r = s.planes[i]; + if (Pi.dot(r.n, t) < r.d) return 0; + } + } + } + return 1; + }; + }(); + const Wa = function(t, e) { + const i = t.radius + e.radius; + return Pi.squaredDistance(t.center, e.center) < i * i; + }; + const Ya = function() { + const t = new Pi; + return function(e, i) { + ta(t, e.center, i); + return Pi.squaredDistance(e.center, t) < e.radius * e.radius; + }; + }(); + const qa = function() { + const t = new Pi; + return function(e, i) { + ea(t, e.center, i); + return Pi.squaredDistance(e.center, t) < e.radius * e.radius; + }; + }(); + const Ka = function() { + const t = new Pi; + const e = new Pi; + return function(i, s) { + const n = i.radius + s.radius; + const r = n * n; + const o = Pi.squaredDistance(s.ellipseCenter0, s.ellipseCenter1); + if (0 === o) return Pi.squaredDistance(i.center, s.center) < r; + { + Pi.subtract(t, i.center, s.ellipseCenter0); + Pi.subtract(e, s.ellipseCenter1, s.ellipseCenter0); + const n = Pi.dot(t, e) / o; + if (n < 0) return Pi.squaredDistance(i.center, s.ellipseCenter0) < r; + if (n > 1) return Pi.squaredDistance(i.center, s.ellipseCenter1) < r; + Pi.scaleAndAdd(t, s.ellipseCenter0, e, n); + return Pi.squaredDistance(i.center, t) < r; + } + }; + }(); + const Ja = function() { + const t = new Pi; + const e = new Pi; + const i = new Pi; + const s = new Pi; + const n = new Pi; + const r = new Pi; + return function(o, a) { + const l = Pi.subtract(t, o.ellipseCenter1, o.ellipseCenter0); + const h = Pi.subtract(e, a.ellipseCenter1, a.ellipseCenter0); + const c = Pi.subtract(i, o.ellipseCenter0, a.ellipseCenter0); + const u = Pi.dot(l, l); + const _ = Pi.dot(l, h); + const d = Pi.dot(h, h); + const p = Pi.dot(l, c); + const m = Pi.dot(h, c); + const f = u * d - _ * _; + let g; + let y = f; + let b; + let S = f; + if (f < hi) { + g = 0; + y = 1; + b = m; + S = d; + } else { + g = _ * m - d * p; + b = u * m - _ * p; + if (g < 0) { + g = 0; + b = m; + S = d; + } else if (g > y) { + g = y; + b = m + _; + S = d; + } + } + if (b < 0) { + b = 0; + if (-p < 0) g = 0; else if (-p > u) g = y; else { + g = -p; + y = u; + } + } else if (b > S) { + b = S; + if (-p + _ < 0) g = 0; else if (-p + _ > u) g = y; else { + g = -p + _; + y = u; + } + } + const A = Math.abs(g) < hi ? 0 : g / y; + const T = Math.abs(b) < hi ? 0 : b / S; + const v = s; + v.set(c); + v.add(Pi.multiplyScalar(n, l, A)); + v.subtract(Pi.multiplyScalar(r, h, T)); + const E = o.radius + a.radius; + return v.lengthSqr() < E * E; + }; + }(); + const Za = { + raySphere: fa, + rayAABB: ga, + rayOBB: ba, + rayPlane: pa, + rayTriangle: ma, + rayCapsule: Sa, + raySubMesh: Aa, + rayMesh: Ta, + rayModel: va, + lineSphere: Ia, + lineAABB: wa, + lineOBB: Ra, + linePlane: Ea, + lineTriangle: Ca, + sphereWithSphere: Wa, + sphereAABB: Ya, + sphereOBB: qa, + spherePlane: Ha, + sphereFrustum: ja, + sphereFrustumAccurate: Xa, + sphereCapsule: Ka, + aabbWithAABB: Ma, + aabbWithOBB: Pa, + aabbPlane: Oa, + aabbFrustum: Na, + aabbFrustumAccurate: La, + obbWithOBB: Ga, + obbPlane: Va, + obbFrustum: ka, + obbFrustumAccurate: Ua, + obbPoint: Fa, + obbCapsule: za, + aabbFrustumCompletelyInside: function(t, e) { + for (let i = 0; i < e.planes.length; i++) if (0 !== Oa(t, e.planes[i])) return 0; + return 1; + }, + capsuleWithCapsule: Ja, + resolve(t, e, i = null) { + const s = t._type; + const n = e._type; + const r = this[s | n]; + return s < n ? r(t, e, i) : r(e, t, i); + } + }; + Za[sa.SHAPE_RAY | sa.SHAPE_SPHERE] = fa; + Za[sa.SHAPE_RAY | sa.SHAPE_AABB] = ga; + Za[sa.SHAPE_RAY | sa.SHAPE_OBB] = ba; + Za[sa.SHAPE_RAY | sa.SHAPE_PLANE] = pa; + Za[sa.SHAPE_RAY | sa.SHAPE_TRIANGLE] = ma; + Za[sa.SHAPE_RAY | sa.SHAPE_CAPSULE] = Sa; + Za[sa.SHAPE_LINE | sa.SHAPE_SPHERE] = Ia; + Za[sa.SHAPE_LINE | sa.SHAPE_AABB] = wa; + Za[sa.SHAPE_LINE | sa.SHAPE_OBB] = Ra; + Za[sa.SHAPE_LINE | sa.SHAPE_PLANE] = Ea; + Za[sa.SHAPE_LINE | sa.SHAPE_TRIANGLE] = Ca; + Za[sa.SHAPE_SPHERE] = Wa; + Za[sa.SHAPE_SPHERE | sa.SHAPE_AABB] = Ya; + Za[sa.SHAPE_SPHERE | sa.SHAPE_OBB] = qa; + Za[sa.SHAPE_SPHERE | sa.SHAPE_PLANE] = Ha; + Za[sa.SHAPE_SPHERE | sa.SHAPE_FRUSTUM] = ja; + Za[sa.SHAPE_SPHERE | sa.SHAPE_FRUSTUM_ACCURATE] = Xa; + Za[sa.SHAPE_SPHERE | sa.SHAPE_CAPSULE] = Ka; + Za[sa.SHAPE_AABB] = Ma; + Za[sa.SHAPE_AABB | sa.SHAPE_OBB] = Pa; + Za[sa.SHAPE_AABB | sa.SHAPE_PLANE] = Oa; + Za[sa.SHAPE_AABB | sa.SHAPE_FRUSTUM] = Na; + Za[sa.SHAPE_AABB | sa.SHAPE_FRUSTUM_ACCURATE] = La; + Za[sa.SHAPE_OBB] = Ga; + Za[sa.SHAPE_OBB | sa.SHAPE_PLANE] = Va; + Za[sa.SHAPE_OBB | sa.SHAPE_FRUSTUM] = ka; + Za[sa.SHAPE_OBB | sa.SHAPE_FRUSTUM_ACCURATE] = Ua; + Za[sa.SHAPE_OBB | sa.SHAPE_CAPSULE] = za; + Za[sa.SHAPE_CAPSULE] = Ja; + W(na.prototype, "line", [ { + name: "mag", + newName: "len" + }, { + name: "magnitude", + newName: "len" + } ]); + Y(Za, "intersect", [ { + name: "line_quad" + } ]); + const Qa = new Pi(0, 0, 0); + const $a = new Pi(0, 0, 0); + const tl = m.mat4(); + const el = m.v4(); + class il { + static create(t, e, i, s) { + return new il(t, e, i, s); + } + static clone(t) { + return new il(t.n.x, t.n.y, t.n.z, t.d); + } + static copy(t, e) { + Pi.copy(t.n, e.n); + t.d = e.d; + return t; + } + static fromPoints(t, e, i, s) { + Pi.subtract(Qa, i, e); + Pi.subtract($a, s, e); + Pi.normalize(t.n, Pi.cross(t.n, Qa, $a)); + t.d = Pi.dot(t.n, e); + return t; + } + static set(t, e, i, s, n) { + t.n.x = e; + t.n.y = i; + t.n.z = s; + t.d = n; + return t; + } + static fromNormalAndPoint(t, e, i) { + Pi.copy(t.n, e); + t.d = Pi.dot(e, i); + return t; + } + static normalize(t, e) { + const i = e.n.length(); + Pi.normalize(t.n, e.n); + i > 0 && (t.d = e.d / i); + return t; + } + get type() { + return this._type; + } + set x(t) { + this.n.x = t; + } + get x() { + return this.n.x; + } + set y(t) { + this.n.y = t; + } + get y() { + return this.n.y; + } + set z(t) { + this.n.z = t; + } + get z() { + return this.n.z; + } + set w(t) { + this.d = t; + } + get w() { + return this.d; + } + constructor(t = 0, e = 1, i = 0, s = 0) { + this.n = void 0; + this.d = void 0; + this._type = void 0; + this._type = sa.SHAPE_PLANE; + this.n = new Pi(t, e, i); + this.d = s; + } + transform(t) { + qi.invert(tl, t); + qi.transpose(tl, tl); + is.set(el, this.n.x, this.n.y, this.n.z, this.d); + is.transformMat4(el, el, tl); + Pi.set(this.n, el.x, el.y, el.z); + this.d = el.w; + } + } + const sl = new Pi; + const nl = new Pi; + const rl = new Pi; + const ol = new Pi; + const al = new Fi; + const ll = (t, e, i) => { + al.m00 = Math.abs(i.m00); + al.m01 = Math.abs(i.m01); + al.m02 = Math.abs(i.m02); + al.m03 = Math.abs(i.m04); + al.m04 = Math.abs(i.m05); + al.m05 = Math.abs(i.m06); + al.m06 = Math.abs(i.m08); + al.m07 = Math.abs(i.m09); + al.m08 = Math.abs(i.m10); + Pi.transformMat3(t, e, al); + }; + class hl { + static create(t, e, i, s, n, r) { + return new hl(t, e, i, s, n, r); + } + static clone(t) { + return new hl(t.center.x, t.center.y, t.center.z, t.halfExtents.x, t.halfExtents.y, t.halfExtents.z); + } + static copy(t, e) { + Pi.copy(t.center, e.center); + Pi.copy(t.halfExtents, e.halfExtents); + return t; + } + static fromPoints(t, e, i) { + Pi.add(sl, i, e); + Pi.subtract(nl, i, e); + Pi.multiplyScalar(t.center, sl, .5); + Pi.multiplyScalar(t.halfExtents, nl, .5); + return t; + } + static set(t, e, i, s, n, r, o) { + t.center.set(e, i, s); + t.halfExtents.set(n, r, o); + return t; + } + static merge(t, e, i) { + Pi.subtract(sl, e.center, e.halfExtents); + Pi.subtract(nl, i.center, i.halfExtents); + Pi.add(rl, e.center, e.halfExtents); + Pi.add(ol, i.center, i.halfExtents); + Pi.max(ol, rl, ol); + Pi.min(rl, sl, nl); + return hl.fromPoints(t, rl, ol); + } + static toBoundingSphere(t, e) { + t.center.set(e.center); + t.radius = e.halfExtents.length(); + return t; + } + static transform(t, e, i) { + Pi.transformMat4(t.center, e.center, i); + ll(t.halfExtents, e.halfExtents, i); + return t; + } + get type() { + return this._type; + } + constructor(t = 0, e = 0, i = 0, s = 1, n = 1, r = 1) { + this.center = void 0; + this.halfExtents = void 0; + this._type = void 0; + this._type = sa.SHAPE_AABB; + this.center = new Pi(t, e, i); + this.halfExtents = new Pi(s, n, r); + } + getBoundary(t, e) { + Pi.subtract(t, this.center, this.halfExtents); + Pi.add(e, this.center, this.halfExtents); + } + transform(t, e, i, s, n) { + Pi.transformMat4(n.center, this.center, t); + ll(n.halfExtents, this.halfExtents, t); + } + clone() { + return hl.clone(this); + } + copy(t) { + return hl.copy(this, t); + } + mergePoint(t) { + this.getBoundary(sl, nl); + t.x < sl.x && (sl.x = t.x); + t.y < sl.y && (sl.y = t.y); + t.z < sl.z && (sl.z = t.z); + t.x > nl.x && (nl.x = t.x); + t.y > nl.y && (nl.y = t.y); + t.z > nl.z && (nl.z = t.z); + Pi.add(rl, sl, nl); + this.center.set(Pi.multiplyScalar(rl, rl, .5)); + this.halfExtents.set(nl.x - rl.x, nl.y - rl.y, nl.z - rl.z); + } + mergePoints(t) { + if (!(t.length < 1)) for (let e = 0; e < t.length; e++) this.mergePoint(t[e]); + } + mergeFrustum(t) { + return this.mergePoints(t.vertices); + } + } + const cl = new Pi; + const ul = new Pi; + const _l = new Fi; + class dl { + static create(t, e, i, s, n, r, o, a, l, h, c, u, _, d, p) { + return new dl(t, e, i, s, n, r, o, a, l, h, c, u, _, d, p); + } + static clone(t) { + return new dl(t.center.x, t.center.y, t.center.z, t.halfExtents.x, t.halfExtents.y, t.halfExtents.z, t.orientation.m00, t.orientation.m01, t.orientation.m02, t.orientation.m03, t.orientation.m04, t.orientation.m05, t.orientation.m06, t.orientation.m07, t.orientation.m08); + } + static copy(t, e) { + Pi.copy(t.center, e.center); + Pi.copy(t.halfExtents, e.halfExtents); + Fi.copy(t.orientation, e.orientation); + return t; + } + static fromPoints(t, e, i) { + Pi.multiplyScalar(t.center, Pi.add(cl, e, i), .5); + Pi.multiplyScalar(t.halfExtents, Pi.subtract(ul, i, e), .5); + Fi.identity(t.orientation); + return t; + } + static set(t, e, i, s, n, r, o, a, l, h, c, u, _, d, p, m) { + Pi.set(t.center, e, i, s); + Pi.set(t.halfExtents, n, r, o); + Fi.set(t.orientation, a, l, h, c, u, _, d, p, m); + return t; + } + get type() { + return this._type; + } + constructor(t = 0, e = 0, i = 0, s = 1, n = 1, r = 1, o = 1, a = 0, l = 0, h = 0, c = 1, u = 0, _ = 0, d = 0, p = 1) { + this.center = void 0; + this.halfExtents = void 0; + this.orientation = void 0; + this._type = void 0; + this._type = sa.SHAPE_OBB; + this.center = new Pi(t, e, i); + this.halfExtents = new Pi(s, n, r); + this.orientation = new Fi(o, a, l, h, c, u, _, d, p); + } + getBoundary(t, e) { + ((t, e, i) => { + _l.m00 = Math.abs(i.m00); + _l.m01 = Math.abs(i.m01); + _l.m02 = Math.abs(i.m02); + _l.m03 = Math.abs(i.m03); + _l.m04 = Math.abs(i.m04); + _l.m05 = Math.abs(i.m05); + _l.m06 = Math.abs(i.m06); + _l.m07 = Math.abs(i.m07); + _l.m08 = Math.abs(i.m08); + Pi.transformMat3(t, e, _l); + })(cl, this.halfExtents, this.orientation); + Pi.subtract(t, this.center, cl); + Pi.add(e, this.center, cl); + } + transform(t, e, i, s, n) { + Pi.transformMat4(n.center, this.center, t); + Fi.fromQuat(n.orientation, i); + Pi.multiply(n.halfExtents, this.halfExtents, s); + } + translateAndRotate(t, e, i) { + Pi.transformMat4(i.center, this.center, t); + Fi.fromQuat(i.orientation, e); + } + setScale(t, e) { + Pi.multiply(e.halfExtents, this.halfExtents, t); + } + } + class pl { + get type() { + return this._type; + } + constructor(t = .5, e = .5, i = 1) { + this._type = void 0; + this.radius = void 0; + this.halfHeight = void 0; + this.axis = void 0; + this.center = void 0; + this.rotation = void 0; + this.ellipseCenter0 = void 0; + this.ellipseCenter1 = void 0; + this._type = sa.SHAPE_CAPSULE; + this.radius = t; + this.halfHeight = e; + this.axis = i; + this.center = new Pi; + this.rotation = new Ui; + this.ellipseCenter0 = new Pi(0, e, 0); + this.ellipseCenter1 = new Pi(0, -e, 0); + this.updateCache(); + } + transform(t, e, i, s, n) { + const r = s; + const o = wi(r); + n.radius = this.radius * Math.abs(o); + let a = (this.halfHeight + this.radius) * Math.abs(r.y) - n.radius; + a < 0 && (a = 0); + n.halfHeight = a; + Pi.transformMat4(n.center, this.center, t); + Ui.multiply(n.rotation, this.rotation, i); + n.updateCache(); + } + updateCache() { + this.updateLocalCenter(); + Pi.transformQuat(this.ellipseCenter0, this.ellipseCenter0, this.rotation); + Pi.transformQuat(this.ellipseCenter1, this.ellipseCenter1, this.rotation); + this.ellipseCenter0.add(this.center); + this.ellipseCenter1.add(this.center); + } + updateLocalCenter() { + const t = this.halfHeight; + switch (this.axis) { + case 0: + this.ellipseCenter0.set(t, 0, 0); + this.ellipseCenter1.set(-t, 0, 0); + break; + + case 1: + this.ellipseCenter0.set(0, t, 0); + this.ellipseCenter1.set(0, -t, 0); + break; + + case 2: + this.ellipseCenter0.set(0, 0, t); + this.ellipseCenter1.set(0, 0, -t); + } + } + } + const ml = new Array(8); + ml[0] = new Pi(1, 1, 1); + ml[1] = new Pi(-1, 1, 1); + ml[2] = new Pi(-1, -1, 1); + ml[3] = new Pi(1, -1, 1); + ml[4] = new Pi(1, 1, -1); + ml[5] = new Pi(-1, 1, -1); + ml[6] = new Pi(-1, -1, -1); + ml[7] = new Pi(1, -1, -1); + const fl = new Pi; + const gl = new Pi; + const yl = new Pi; + class bl { + static createFromAABB(t, e) { + const i = new Pi; + const s = new Pi; + Pi.subtract(i, e.center, e.halfExtents); + Pi.add(s, e.center, e.halfExtents); + t.vertices[0].set(i.x, s.y, i.z); + t.vertices[1].set(s.x, s.y, i.z); + t.vertices[2].set(s.x, i.y, i.z); + t.vertices[3].set(i.x, i.y, i.z); + t.vertices[4].set(i.x, s.y, s.z); + t.vertices[5].set(s.x, s.y, s.z); + t.vertices[6].set(s.x, i.y, s.z); + t.vertices[7].set(i.x, i.y, s.z); + if (t._type !== sa.SHAPE_FRUSTUM_ACCURATE) return t; + t.updatePlanes(); + return t; + } + static split(t, e, i, s, n) { + const r = Math.tan(.5 * e.fov); + const o = r * e.aspect; + fl.set(s * o, s * r, s); + gl.set(n * o, n * r, n); + const a = t.vertices; + yl.set(fl.x, fl.y, fl.z); + Pi.transformMat4(a[0], yl, i); + yl.set(-fl.x, fl.y, fl.z); + Pi.transformMat4(a[1], yl, i); + yl.set(-fl.x, -fl.y, fl.z); + Pi.transformMat4(a[2], yl, i); + yl.set(fl.x, -fl.y, fl.z); + Pi.transformMat4(a[3], yl, i); + yl.set(gl.x, gl.y, gl.z); + Pi.transformMat4(a[4], yl, i); + yl.set(-gl.x, gl.y, gl.z); + Pi.transformMat4(a[5], yl, i); + yl.set(-gl.x, -gl.y, gl.z); + Pi.transformMat4(a[6], yl, i); + yl.set(gl.x, -gl.y, gl.z); + Pi.transformMat4(a[7], yl, i); + t.updatePlanes(); + return t; + } + static create() { + return new bl; + } + static clone(t) { + return bl.copy(new bl, t); + } + static copy(t, e) { + t._type = e.type; + for (let i = 0; i < 6; ++i) il.copy(t.planes[i], e.planes[i]); + for (let i = 0; i < 8; ++i) Pi.copy(t.vertices[i], e.vertices[i]); + return t; + } + set accurate(t) { + this._type = t ? sa.SHAPE_FRUSTUM_ACCURATE : sa.SHAPE_FRUSTUM; + } + get type() { + return this._type; + } + constructor() { + this.planes = void 0; + this.vertices = void 0; + this._type = void 0; + this._type = sa.SHAPE_FRUSTUM; + this.planes = new Array(6); + for (let t = 0; t < 6; ++t) this.planes[t] = il.create(0, 0, 0, 0); + this.vertices = new Array(8); + for (let t = 0; t < 8; ++t) this.vertices[t] = new Pi; + } + update(t, e) { + Pi.set(this.planes[0].n, t.m03 + t.m00, t.m07 + t.m04, t.m11 + t.m08); + this.planes[0].d = -(t.m15 + t.m12); + Pi.set(this.planes[1].n, t.m03 - t.m00, t.m07 - t.m04, t.m11 - t.m08); + this.planes[1].d = -(t.m15 - t.m12); + Pi.set(this.planes[2].n, t.m03 + t.m01, t.m07 + t.m05, t.m11 + t.m09); + this.planes[2].d = -(t.m15 + t.m13); + Pi.set(this.planes[3].n, t.m03 - t.m01, t.m07 - t.m05, t.m11 - t.m09); + this.planes[3].d = -(t.m15 - t.m13); + Pi.set(this.planes[4].n, t.m03 + t.m02, t.m07 + t.m06, t.m11 + t.m10); + this.planes[4].d = -(t.m15 + t.m14); + Pi.set(this.planes[5].n, t.m03 - t.m02, t.m07 - t.m06, t.m11 - t.m10); + this.planes[5].d = -(t.m15 - t.m14); + if (this._type === sa.SHAPE_FRUSTUM_ACCURATE) { + for (let t = 0; t < 6; t++) { + const e = this.planes[t]; + const i = 1 / e.n.length(); + Pi.multiplyScalar(e.n, e.n, i); + e.d *= i; + } + for (let t = 0; t < 8; t++) Pi.transformMat4(this.vertices[t], ml[t], e); + } + } + transform(t) { + if (this._type === sa.SHAPE_FRUSTUM_ACCURATE) { + for (let e = 0; e < 8; e++) Pi.transformMat4(this.vertices[e], this.vertices[e], t); + this.updatePlanes(); + } + } + zero() { + for (let t = 0; t < 8; t++) this.vertices[t].set(0, 0, 0); + this.updatePlanes(); + } + updatePlanes() { + il.fromPoints(this.planes[0], this.vertices[1], this.vertices[6], this.vertices[5]); + il.fromPoints(this.planes[1], this.vertices[3], this.vertices[4], this.vertices[7]); + il.fromPoints(this.planes[2], this.vertices[6], this.vertices[3], this.vertices[7]); + il.fromPoints(this.planes[3], this.vertices[0], this.vertices[5], this.vertices[4]); + il.fromPoints(this.planes[4], this.vertices[2], this.vertices[0], this.vertices[3]); + il.fromPoints(this.planes[5], this.vertices[7], this.vertices[5], this.vertices[6]); + } + } + bl.createOrtho = (t, e, i, s, n, r) => { + const o = e / 2; + const a = i / 2; + Pi.set(yl, o, a, -s); + Pi.transformMat4(t.vertices[0], yl, r); + Pi.set(yl, -o, a, -s); + Pi.transformMat4(t.vertices[1], yl, r); + Pi.set(yl, -o, -a, -s); + Pi.transformMat4(t.vertices[2], yl, r); + Pi.set(yl, o, -a, -s); + Pi.transformMat4(t.vertices[3], yl, r); + Pi.set(yl, o, a, -n); + Pi.transformMat4(t.vertices[4], yl, r); + Pi.set(yl, -o, a, -n); + Pi.transformMat4(t.vertices[5], yl, r); + Pi.set(yl, -o, -a, -n); + Pi.transformMat4(t.vertices[6], yl, r); + Pi.set(yl, o, -a, -n); + Pi.transformMat4(t.vertices[7], yl, r); + il.fromPoints(t.planes[0], t.vertices[1], t.vertices[6], t.vertices[5]); + il.fromPoints(t.planes[1], t.vertices[3], t.vertices[4], t.vertices[7]); + il.fromPoints(t.planes[2], t.vertices[6], t.vertices[3], t.vertices[7]); + il.fromPoints(t.planes[3], t.vertices[0], t.vertices[5], t.vertices[4]); + il.fromPoints(t.planes[4], t.vertices[2], t.vertices[0], t.vertices[3]); + il.fromPoints(t.planes[5], t.vertices[7], t.vertices[5], t.vertices[6]); + }; + let Sl; + !function(t) { + t[t.Default = 0] = "Default"; + t[t.Normal = 1] = "Normal"; + t[t.Loop = 2] = "Loop"; + t[t.ShouldWrap = 4] = "ShouldWrap"; + t[t.Clamp = 8] = "Clamp"; + t[t.PingPong = 22] = "PingPong"; + t[t.Reverse = 36] = "Reverse"; + }(Sl || (Sl = {})); + let Al; + !function(t) { + t[t.Default = Sl.Default] = "Default"; + t[t.Normal = Sl.Normal] = "Normal"; + t[t.Reverse = Sl.Reverse] = "Reverse"; + t[t.Loop = Sl.Loop] = "Loop"; + t[t.LoopReverse = Sl.Loop | Sl.Reverse] = "LoopReverse"; + t[t.PingPong = Sl.PingPong] = "PingPong"; + t[t.PingPongReverse = Sl.PingPong | Sl.Reverse] = "PingPongReverse"; + }(Al || (Al = {})); + he(Al); + class Tl { + constructor(t) { + this.ratio = 0; + this.time = 0; + this.direction = 1; + this.stopped = !0; + this.iterations = 0; + this.frameIndex = void 0; + t && this.set(t); + } + set(t) { + this.ratio = t.ratio; + this.time = t.time; + this.direction = t.direction; + this.stopped = t.stopped; + this.iterations = t.iterations; + this.frameIndex = t.frameIndex; + } + } + function vl(t, e, i = 1e-6) { + let s = 0; + let n = t.length - 1; + let r = n >>> 1; + for (;s <= n; r = s + n >>> 1) { + const o = t[r]; + if (o > e + i) n = r - 1; else { + if (!(o < e - i)) return r; + s = r + 1; + } + } + return ~s; + } + let El; + El = Symbol.iterator; + class Cl { + constructor() { + this._times = []; + this._values = []; + } + get keyFramesCount() { + return this._times.length; + } + get rangeMin() { + return this._times[0]; + } + get rangeMax() { + return this._times[this._values.length - 1]; + } + [El]() { + let t = 0; + return { + next: () => { + if (t >= this._times.length) return { + done: !0, + value: void 0 + }; + { + const e = [ this._times[t], this._values[t] ]; + ++t; + return { + done: !1, + value: e + }; + } + } + }; + } + keyframes() { + return this; + } + times() { + return this._times; + } + values() { + return this._values; + } + getKeyframeTime(t) { + return this._times[t]; + } + getKeyframeValue(t) { + return this._values[t]; + } + addKeyFrame(t, e) { + return this._insertNewKeyframe(t, e); + } + removeKeyframe(t) { + this._times.splice(t, 1); + this._values.splice(t, 1); + } + indexOfKeyframe(t) { + return vl(this._times, t); + } + updateTime(t, e) { + const i = this._values[t]; + this.removeKeyframe(t); + this._insertNewKeyframe(e, i); + } + assignSorted(t, e) { + if (void 0 !== e) { + ne(Array.isArray(t)); + this.setKeyframes(t.slice(), e.slice()); + } else { + const e = Array.from(t); + this.setKeyframes(e.map((([t]) => t)), e.map((([, t]) => t))); + } + } + clear() { + this._times.length = 0; + this._values.length = 0; + } + searchKeyframe(t) { + return vl(this._times, t); + } + setKeyframes(t, e) { + ne(t.length === e.length); + ne(function(t) { + return t.every(((t, e, i) => 0 === e || t > i[e - 1] || ui(t, i[e - 1], 1e-6))); + }(t)); + this._times = t; + this._values = e; + } + _insertNewKeyframe(t, e) { + const i = this._times; + const s = this._values; + const n = i.length; + const r = vl(i, t); + if (r >= 0) return r; + const o = ~r; + if (0 === o) { + i.unshift(t); + s.unshift(e); + } else if (o === n) { + i.push(t); + s.push(e); + } else { + ne(n > 1); + i.splice(o - 1, 0, t); + s.splice(o - 1, 0, e); + } + return o; + } + } + si.fastDefine("cc.KeyframeCurve", Cl, { + _times: [], + _values: [] + }); + let xl; + !function(t) { + t[t.LINEAR = 0] = "LINEAR"; + t[t.CONSTANT = 1] = "CONSTANT"; + t[t.CUBIC = 2] = "CUBIC"; + }(xl || (xl = t("RealInterpolationMode", {}))); + let wl; + !function(t) { + t[t.LINEAR = 0] = "LINEAR"; + t[t.CLAMP = 1] = "CLAMP"; + t[t.LOOP = 2] = "LOOP"; + t[t.PING_PONG = 3] = "PING_PONG"; + }(wl || (wl = t("ExtrapolationMode", {}))); + let Rl; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.LEFT = 1] = "LEFT"; + t[t.RIGHT = 2] = "RIGHT"; + t[t.BOTH = 3] = "BOTH"; + }(Rl || (Rl = t("TangentWeightMode", {}))); + function Il(t) { + return t > -1e-9 && t < 1e-9; + } + function Ml(t, e, i, s) { + i && Object.defineProperty(t, e, { + enumerable: i.enumerable, + configurable: i.configurable, + writable: i.writable, + value: i.initializer ? i.initializer.call(s) : void 0 + }); + } + function Bl(t, e, i, s, n) { + var r = {}; + Object.keys(s).forEach((function(t) { + r[t] = s[t]; + })); + r.enumerable = !!r.enumerable; + r.configurable = !!r.configurable; + ("value" in r || r.initializer) && (r.writable = !0); + r = i.slice().reverse().reduce((function(i, s) { + return s(t, e, i) || i; + }), r); + if (n && void 0 !== r.initializer) { + r.value = r.initializer ? r.initializer.call(n) : void 0; + r.initializer = void 0; + } + if (void 0 === r.initializer) { + Object.defineProperty(t, e, r); + r = null; + } + return r; + } + const Dl = () => {}; + const Pl = () => Dl; + const Ol = Nl((() => {})); + function Nl(t) { + return function(e) { + return "function" == typeof e ? t(e) : function(i) { + return t(i, e); + }; + }; + } + function Ll(t) { + return e => i => { + !function(t, e, i) { + const s = Vl(t); + if (s) { + const t = kl(s, "proto"); + kl(t, "editor")[e] = i; + } + }(i, t, e); + }; + } + const Fl = "__ccclassCache__"; + function Vl(t, e) { + return kl(t, Fl); + } + function kl(t, e) { + return t[e] || (t[e] = {}); + } + const Ul = Nl(((t, e) => { + let i = ee.getSuper(t); + i === Object && (i = null); + const s = { + name: e, + extends: i, + ctor: t + }; + const n = t[Fl]; + if (n) { + const e = n.proto; + e && ee.mixin(s, e); + t[Fl] = void 0; + } + return si(s); + })); + const Gl = Ll("requireComponent"); + const zl = Ll("executionOrder"); + const Hl = Ol; + function jl(t, e, i) { + let s = null; + function n(t, e, i) { + !function(t) { + Vl(t.constructor); + }(t); + const n = function(t, e) { + var i, s; + const n = kl(Vl(t.constructor), "proto"); + const r = kl(n, "properties"); + return null !== (s = r[i = e]) && void 0 !== s ? s : r[i] = {}; + }(t, e); + t.constructor; + !function(t, e, i, s, n, r) { + let o; + const a = r && (r.get || r.set); + n && (o = je(n, a)); + const l = ee.mixin(e, o || n || {}); + if (a) { + r.get && (l.get = r.get); + r.set && (l.set = r.set); + } + }(0, n, 0, 0, s, i); + } + if (void 0 === t) return jl({ + type: void 0 + }); + if (void 0 === e) { + s = t; + return n; + } + n(t, e, i); + } + function Xl(t, e, i) { + var s, n; + const r = Vl(t.constructor); + const o = kl(r, "proto"); + const a = kl(o, "properties"); + const l = null !== (n = a[s = e]) && void 0 !== n ? n : a[s] = {}; + l.__internalFlags |= Ye.STANDALONE; + if (i && (i.get || i.set)) { + i.get && (l.get = i.get); + i.set && (l.set = i.set); + } else t.constructor; + return l; + } + const Wl = Symbol("cc:SerializationMetadata"); + const Yl = (t, e, i) => { + Jl(Xl(t, e, i)); + }; + function ql(t) { + return (e, i, s) => { + const n = Xl(e, i, s); + n.formerlySerializedAs = t; + Jl(n); + }; + } + const Kl = (t, e, i) => { + const s = Xl(t, e, i); + s.editorOnly = !0; + Jl(s); + }; + function Jl(t) { + t.__internalFlags |= Ye.IMPLICIT_SERIALIZABLE; + } + const Zl = Dl; + const Ql = Ol; + const $l = Pl; + const th = Ol; + const eh = Pl; + const ih = Pl; + const sh = Pl; + const nh = Dl; + const rh = Pl; + const oh = Dl; + const ah = Pl; + const lh = Pl; + const hh = Pl; + const ch = Pl; + const uh = Pl; + const _h = Pl; + const dh = Dl; + const ph = Pl; + const mh = Dl; + const fh = Dl; + const gh = Dl; + const yh = Th(Oe); + const bh = Th(Ne); + const Sh = Th(Le); + const Ah = Th(Fe); + function Th(t) { + return jl({ + type: t + }); + } + const vh = (t, e, i) => { + Xl(t, e, i).override = !0; + }; + class Eh {} + const Ch = null != xh ? xh : Eh; + var xh; + ne("__editorExtras__" === io, "editorExtrasTag needs to be updated."); + var wh = Object.freeze({ + __proto__: null, + uniquelyReferenced: Zl, + ccclass: Ul, + property: jl, + requireComponent: Gl, + executionOrder: zl, + disallowMultiple: Hl, + allowReplicated: t => { + si.Attr.setClassAttr(t, "replicated", "visible", !0); + }, + executeInEditMode: Ql, + menu: $l, + playOnFocus: th, + inspector: eh, + icon: ih, + help: sh, + type: Th, + integer: yh, + float: bh, + boolean: Sh, + string: Ah + }); + t("_decorator", wh); + class Rh { + constructor(t) { + this._map = null; + this._count = 0; + if (t) { + this._map = t; + this._count = Object.keys(t).length; + } else { + this._map = ee.createMap(!0); + this._count = 0; + } + } + add(t, e) { + t in this._map || this._count++; + return this._map[t] = e; + } + get(t) { + return this._map[t]; + } + has(t) { + return t in this._map; + } + remove(t) { + const e = this._map[t]; + if (t in this._map) { + delete this._map[t]; + this._count--; + } + return e; + } + clear() { + if (0 !== this._count) { + this._map = ee.createMap(!0); + this._count = 0; + } + } + forEach(t) { + for (const e in this._map) t(this._map[e], e); + } + find(t) { + for (const e in this._map) if (t(this._map[e], e)) return this._map[e]; + return null; + } + get count() { + return this._count; + } + destroy() { + this._map = null; + } + } + class Ih { + constructor(t, e) { + this.id = Ih._pipelineId++; + this.name = ""; + this.pipes = []; + this.name = t; + for (let t = 0, i = e.length; t < i; t++) this.pipes.push(e[t]); + } + insert(t, e) { + if (e > this.pipes.length) { + N(4921); + return this; + } + this.pipes.splice(e, 0, t); + return this; + } + append(t) { + this.pipes.push(t); + return this; + } + remove(t) { + this.pipes.splice(t, 1); + return this; + } + sync(t) { + const e = this.pipes; + if (0 === e.length) return null; + t.isFinish = !1; + for (let i = 0, s = e.length; i < s; ) { + const n = (0, e[i])(t); + if (n) { + t.isFinish = !0; + return n; + } + i++; + if (i !== s) { + t.input = t.output; + t.output = null; + } + } + t.isFinish = !0; + return t.output; + } + async(t) { + if (0 !== this.pipes.length) { + t.isFinish = !1; + this._flow(0, t); + } + } + _flow(t, e) { + (0, this.pipes[t])(e, (i => { + if (i) { + e.isFinish = !0; + e.dispatch("complete", i); + } else if (++t < this.pipes.length) { + e.input = e.output; + e.output = null; + this._flow(t, e); + } else { + e.isFinish = !0; + e.dispatch("complete", i, e.output); + } + })); + } + } + Ih._pipelineId = 0; + const Mh = new Rh; + const Bh = new Rh; + const Dh = new Rh; + const Ph = new Rh; + const Oh = new Ih("normal load", []); + const Nh = new Ih("fetch", []); + const Lh = new Ih("transform url", []); + const Fh = new Map; + let Vh; + !function(t) { + t.UUID = "uuid"; + t.PATH = "path"; + t.DIR = "dir"; + t.URL = "url"; + t.SCENE = "scene"; + }(Vh || (Vh = {})); + const kh = { + default: { + priority: 0 + }, + preload: { + maxConcurrency: 6, + maxRequestsPerFrame: 2, + priority: -1 + }, + scene: { + maxConcurrency: 20, + maxRequestsPerFrame: 20, + priority: 1 + }, + bundle: { + maxConcurrency: 20, + maxRequestsPerFrame: 20, + priority: 2 + }, + remote: { + maxRetryCount: 4 + } + }; + let Uh; + !function(t) { + t.INTERNAL = "internal"; + t.RESOURCES = "resources"; + t.MAIN = "main"; + t.START_SCENE = "start-scene"; + }(Uh || (Uh = {})); + class Gh { + static create(t) { + let e; + if (0 !== Gh._deadPool.length) { + e = Gh._deadPool.pop(); + e.set(t); + } else e = new Gh(t); + return e; + } + constructor(t) { + this.id = Gh._taskId++; + this.onComplete = null; + this.onProgress = null; + this.onError = null; + this.source = null; + this.output = null; + this.input = null; + this.progress = null; + this.options = null; + this.isFinish = !0; + this.set(t); + } + set(t = Object.create(null)) { + this.onComplete = t.onComplete || null; + this.onProgress = t.onProgress || null; + this.onError = t.onError || null; + this.source = this.input = t.input; + this.output = null; + this.progress = t.progress; + this.options = t.options || Object.create(null); + } + dispatch(t, e, i, s, n) { + switch (t) { + case "complete": + this.onComplete && this.onComplete(e, i); + break; + + case "progress": + this.onProgress && this.onProgress(e, i, s, n); + break; + + case "error": + this.onError && this.onError(e, i, s, n); + break; + + default: + { + const r = `on${t[0].toUpperCase()}${t.substr(1)}`; + "function" == typeof this[r] && this[r](e, i, s, n); + break; + } + } + } + recycle() { + if (Gh._deadPool.length !== Gh.MAX_DEAD_NUM) { + this.onComplete = null; + this.onProgress = null; + this.onError = null; + this.source = this.output = this.input = null; + this.progress = null; + this.options = null; + Gh._deadPool.push(this); + } + } + } + Gh.MAX_DEAD_NUM = 500; + Gh._taskId = 0; + Gh._deadPool = []; + const zh = "0123456789abcdef".split(""); + const Hh = [ "", "", "", "" ]; + const jh = Hh.concat(Hh, "-", Hh, "-", Hh, "-", Hh, "-", Hh, Hh, Hh); + const Xh = jh.map(((t, e) => "-" === t ? NaN : e)).filter(isFinite); + function Wh(t) { + const e = t.split("@")[0]; + if (22 !== e.length) return t; + jh[0] = t[0]; + jh[1] = t[1]; + for (let e = 2, i = 2; e < 22; e += 2) { + const s = ge[t.charCodeAt(e)]; + const n = ge[t.charCodeAt(e + 1)]; + jh[Xh[i++]] = zh[s >> 2]; + jh[Xh[i++]] = zh[(3 & s) << 2 | n >> 4]; + jh[Xh[i++]] = zh[15 & n]; + } + return t.replace(e, jh.join("")); + } + const Yh = /.*[/\\][0-9a-fA-F]{2}[/\\]([0-9a-fA-F-@]{8,}).*/; + function qh(t) { + const e = Yh.exec(t); + return e ? e[1] : ""; + } + function Kh(t, e) { + (e = e || Object.create(null)).__isNative__ = e.isNative; + e.nativeExt && (e.ext = e.nativeExt); + const i = Ph.find((e => !!e.getAssetInfo(t))); + i && (e.bundle = i.name); + return Qh(t, e); + } + function Jh(t) { + return !!t && (t instanceof m.SceneAsset || t instanceof m.Scene); + } + function Zh(t) { + t && (46 === t.charCodeAt(0) && 47 === t.charCodeAt(1) ? t = t.slice(2) : 47 === t.charCodeAt(0) && (t = t.slice(1))); + return t; + } + function Qh(t, e) { + const i = Gh.create({ + input: t, + options: e + }); + const s = []; + try { + const t = Lh.sync(i); + for (const e of t) { + const t = e.url; + e.recycle(); + s.push(t); + } + } catch (t) { + for (const t of i.output) t.recycle(); + x(t.message, t.stack); + } + i.recycle(); + return s.length > 1 ? s : s[0]; + } + var $h = Object.freeze({ + __proto__: null, + getUuidFromURL: qh, + getUrlWithUuid: Kh, + isScene: Jh, + normalize: Zh, + transform: Qh, + decodeUuid: Wh + }); + const tc = /(\.[^\.\/\?\\]*)(\?.*)?$/; + const ec = /((.*)(\/|\\|\\\\))?(.*?\..*$)?/; + const ic = /[^\.\/]+\/\.\.\//; + function sc(...t) { + let e = ""; + for (const i of t) e = (e + ("" === e ? "" : "/") + i).replace(/(\/|\\\\)$/, ""); + return e; + } + function nc(t) { + const e = tc.exec(t); + return e ? e[1] : ""; + } + function rc(t) { + if (t) { + const e = t.lastIndexOf("."); + if (-1 !== e) return t.substring(0, e); + } + return t; + } + function oc(t, e) { + const i = t.indexOf("?"); + i > 0 && (t = t.substring(0, i)); + const s = /(\/|\\)([^\/\\]+)$/g.exec(t.replace(/(\/|\\)$/, "")); + if (!s) return t; + const n = s[2]; + return e && t.substring(t.length - e.length).toLowerCase() === e.toLowerCase() ? n.substring(0, n.length - e.length) : n; + } + function ac(t) { + const e = ec.exec(t); + return e ? e[2] : ""; + } + function lc(t, e) { + e = e || ""; + let i = t.indexOf("?"); + let s = ""; + if (i > 0) { + s = t.substring(i); + t = t.substring(0, i); + } + i = t.lastIndexOf("."); + return i < 0 ? t + e + s : t.substring(0, i) + e + s; + } + function hc(t, e, i) { + if (0 === e.indexOf(".")) return lc(t, e); + let s = t.indexOf("?"); + let n = ""; + const r = i ? nc(t) : ""; + if (s > 0) { + n = t.substring(s); + t = t.substring(0, s); + } + s = t.lastIndexOf("/"); + s = s <= 0 ? 0 : s + 1; + return t.substring(0, s) + e + r + n; + } + function cc(t) { + let e = t = String(t); + do { + e = t; + t = t.replace(ic, ""); + } while (e.length !== t.length); + return t; + } + function uc(t) { + return t.replace(/[\/\\]$/, ""); + } + function _c() { + return Po.os === Ro.WINDOWS ? "\\" : "/"; + } + t("path", Object.freeze({ + __proto__: null, + join: sc, + extname: nc, + mainFileName: rc, + basename: oc, + dirname: ac, + changeExtname: lc, + changeBasename: hc, + _normalize: cc, + stripSep: uc, + getSeperator: _c + })); + function dc(t) { + if (!t) return; + const e = t._children; + if (!e) return; + const i = e.length; + if (i) { + t._setChildren(e); + for (let t = 0; t < i; ++t) { + dc(e[t]); + } + } + } + function pc() {} + pc.prototype.once = function(t, e, i) { + return this.on(t, e, i, !0); + }; + pc.prototype.targetOff = function(t) { + this.removeAll(t); + }; + mc = jsb.Asset, [ Ao, pc ].forEach((t => { + Object.getOwnPropertyNames(t.prototype).forEach((e => { + "constructor" !== e && Object.defineProperty(mc.prototype, e, Object.getOwnPropertyDescriptor(t.prototype, e)); + })); + })); + var mc; + const fc = jsb.Asset.prototype; + fc._ctor = function() { + this._ref = 0; + this.__nativeRefs = {}; + this.__jsb_ref_id = void 0; + this._iN$t = null; + this.__editorExtras__ = { + editorOnly: !0 + }; + this._callbackTable = vt(!0); + this._file = null; + }; + Object.defineProperty(fc, "_nativeAsset", { + get() { + return this._file; + }, + set(t) { + this._file = t; + } + }); + Object.defineProperty(fc, "nativeUrl", { + get() { + if (!this._nativeUrl) { + if (!this._native) return ""; + const t = this._native; + if (47 === t.charCodeAt(0)) return t.slice(1); + 46 === t.charCodeAt(0) ? this._nativeUrl = Kh(this._uuid, { + nativeExt: t, + isNative: !0 + }) : this._nativeUrl = Kh(this._uuid, { + __nativeName__: t, + nativeExt: nc(t), + isNative: !0 + }); + } + return this._nativeUrl; + } + }); + Object.defineProperty(fc, "refCount", { + configurable: !0, + enumerable: !0, + get() { + return this._ref; + } + }); + fc.addRef = function() { + this._ref++; + this.addAssetRef(); + return this; + }; + fc.decRef = function(t = !0) { + this.decAssetRef(); + this._ref > 0 && this._ref--; + t && m.assetManager._releaseManager.tryRelease(this); + return this; + }; + fc.toString = function() { + return this.nativeUrl; + }; + fc.createNode = null; + const gc = t("Asset", jsb.Asset); + m.Asset = jsb.Asset; + const yc = gc.prototype; + Yl(yc, "_native"); + jl(yc, "_nativeAsset", Object.getOwnPropertyDescriptor(yc, "_nativeAsset")); + Ul("cc.Asset")(gc); + var bc, Sc, Ac; + let Tc = t("Script", Ul("cc.Script")(bc = class extends gc {}) || bc); + m._Script = Tc; + let vc = t("JavaScript", Ul("cc.JavaScript")(Sc = class extends Tc {}) || Sc); + m._JavaScript = vc; + let Ec = t("TypeScript", Ul("cc.TypeScript")(Ac = class extends Tc {}) || Ac); + m._TypeScript = Ec; + var Cc, xc, wc, Rc, Ic, Mc, Bc, Dc, Pc, Oc, Nc, Lc, Fc; + let Vc = t("EventHandler", (Cc = Ul("cc.ClickEvent"), xc = lh(), wc = lh(), Rc = lh(), + Ic = lh(), Cc(Mc = (Bc = (Fc = class t { + constructor() { + Ml(this, "target", Dc, this); + Ml(this, "component", Pc, this); + Ml(this, "_componentId", Oc, this); + Ml(this, "handler", Nc, this); + Ml(this, "customEventData", Lc, this); + } + get _componentName() { + this._genCompIdIfNeeded(); + return this._compId2Name(this._componentId); + } + set _componentName(t) { + this._componentId = this._compName2Id(t); + } + static emitEvents(e, ...i) { + for (let s = 0, n = e.length; s < n; s++) { + const n = e[s]; + n instanceof t && n.emit(i); + } + } + emit(t) { + const e = this.target; + if (!m.isValid(e)) return; + this._genCompIdIfNeeded(); + const i = m.js.getClassById(this._componentId); + const s = e.getComponent(i); + if (!m.isValid(s)) return; + const n = s[this.handler]; + if ("function" == typeof n) { + null != this.customEventData && "" !== this.customEventData && (t = t.slice()).push(this.customEventData); + n.apply(s, t); + } + } + _compName2Id(t) { + const e = m.js.getClassByName(t); + return m.js.getClassId(e); + } + _compId2Name(t) { + const e = m.js.getClassById(t); + return m.js.getClassName(e); + } + _genCompIdIfNeeded() { + if (!this._componentId) { + this._componentName = this.component; + this.component = ""; + } + } + }, Fc), Dc = Bl(Bc.prototype, "target", [ Yl, xc ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Pc = Bl(Bc.prototype, "component", [ Yl, nh, wc ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), Oc = Bl(Bc.prototype, "_componentId", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), Nc = Bl(Bc.prototype, "handler", [ Yl, nh, Rc ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), Lc = Bl(Bc.prototype, "customEventData", [ Yl, nh, Ic ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), Bc)) || Mc)); + var kc, Uc, Gc, zc, Hc, jc, Xc, Wc, Yc, qc, Kc; + const Jc = new ut("Comp"); + const Zc = co.Flags.IsOnLoadCalled; + let Qc = t("Component", (kc = Ul("cc.Component"), Uc = ah(), Gc = Th(Tc), zc = lh(), + kc(Hc = (jc = (Kc = qc = class extends co { + constructor(...t) { + super(...t); + Ml(this, "node", Xc, this); + Ml(this, "_enabled", Wc, this); + Ml(this, "__prefab", Yc, this); + this._sceneGetter = null; + this._id = Jc.getNewId(); + } + get name() { + if (this._name) return this._name; + let t = Et(this); + const e = t.lastIndexOf("."); + e >= 0 && (t = t.slice(e + 1)); + return this.node ? `${this.node.name}<${t}>` : t; + } + set name(t) { + this._name = t; + } + get uuid() { + return this._id; + } + get __scriptAsset() { + return null; + } + get enabled() { + return this._enabled; + } + set enabled(t) { + if (this._enabled !== t) { + this._enabled = t; + if (this.node.activeInHierarchy) { + const e = m.director._compScheduler; + t ? e.enableComp(this) : e.disableComp(this); + } + } + } + get enabledInHierarchy() { + return this._enabled && this.node && this.node.activeInHierarchy; + } + get _isOnLoadCalled() { + return this._objFlags & Zc; + } + _getRenderScene() { + return this._sceneGetter ? this._sceneGetter() : this.node.scene.renderScene; + } + addComponent(t) { + return this.node.addComponent(t); + } + getComponent(t) { + return this.node.getComponent(t); + } + getComponents(t) { + return this.node.getComponents(t); + } + getComponentInChildren(t) { + return this.node.getComponentInChildren(t); + } + getComponentsInChildren(t) { + return this.node.getComponentsInChildren(t); + } + destroy() { + if (super.destroy()) { + this._enabled && this.node.activeInHierarchy && m.director._compScheduler.disableComp(this); + return !0; + } + return !1; + } + _onPreDestroy() { + this.unscheduleAllCallbacks(); + m.director._nodeActivator.destroyComp(this); + this.node._removeComponent(this); + } + _instantiate(t) { + t || (t = m.instantiate._clone(this, this)); + t && (t.node = null); + return t; + } + schedule(t, e = 0, i = m.macro.REPEAT_FOREVER, s = 0) { + k(t, 1619); + k((e = e || 0) >= 0, 1620); + i = Number.isNaN(i) ? m.macro.REPEAT_FOREVER : i; + s = s || 0; + const n = m.director.getScheduler(); + const r = n.isTargetPaused(this); + n.schedule(t, this, e, i, s, r); + } + scheduleOnce(t, e = 0) { + this.schedule(t, 0, 0, e); + } + unschedule(t) { + t && m.director.getScheduler().unschedule(t, this); + } + unscheduleAllCallbacks() { + m.director.getScheduler().unscheduleAllForTarget(this); + } + }, qc.EventHandler = Vc, qc.system = null, Kc), Bl(jc.prototype, "__scriptAsset", [ Uc, Gc, zc, gh ], Object.getOwnPropertyDescriptor(jc.prototype, "__scriptAsset"), jc.prototype), + Xc = Bl(jc.prototype, "node", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Wc = Bl(jc.prototype, "_enabled", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), Yc = Bl(jc.prototype, "__prefab", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), jc)) || Hc)); + const $c = Qc.prototype; + $c.update = null; + $c.lateUpdate = null; + $c.__preload = null; + $c.onLoad = null; + $c.start = null; + $c.onEnable = null; + $c.onDisable = null; + $c.onDestroy = null; + $c.onFocusInEditor = null; + $c.onLostFocusInEditor = null; + $c.resetInEditor = null; + $c._getLocalBounds = null; + $c.onRestore = null; + Qc._requireComponent = null; + Qc._executionOrder = 0; + bt(Qc, "_registerEditorProps", ((t, e) => { + let i = e.requireComponent; + if (i) { + Array.isArray(i) && (i = i.filter(Boolean)); + t._requireComponent = i; + } + const s = e.executionOrder; + s && "number" == typeof s && (t._executionOrder = s); + })); + m.Component = Qc; + var tu, eu, iu; + let su = t("MissingScript", Ul("cc.MissingScript")(tu = eh()(tu = (eu = class extends Qc { + static safeFindClass(t) { + const e = Kt(t); + if (e) return e; + m.deserialize.reportMissingClass(t); + } + constructor() { + super(); + Ml(this, "_$erialized", iu, this); + } + onLoad() { + N(4600, this.node.name); + } + }, iu = Bl(eu.prototype, "_$erialized", [ Yl, Kl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), eu)) || tu) || tu); + m._MissingScript = su; + try { + const t = su.__values__; + if (0 === t.length || "_$erialized" !== t[t.length - 1]) { + x("The '_$erialized' prop in MissingScript is missing. Please contact jare."); + x(` Error props: ['${t}']`); + } + } catch (Qo) { + x(`Error when checking MissingScript 5, ${Qo}`); + } + const nu = t("serializeTag", Symbol("[[Serialize]]")); + const ru = t("deserializeTag", Symbol("[[Deserialize]]")); + class ou { + constructor(t, e) { + this._document = void 0; + this._chunks = void 0; + this._document = t; + this._chunks = e; + } + get document() { + return this._document; + } + get chunks() { + return this._chunks; + } + } + function au(t) { + const e = t; + return { + chunks: e.chunks, + document: e.document + }; + } + function lu(t) { + if (t.length < 16) throw new hu(G(13102)); + const e = new DataView(t.buffer, t.byteOffset, t.byteLength); + if (1313817411 !== e.getUint32(0, !0)) throw new hu(G(13100)); + const i = e.getUint32(4, !0); + if (1 !== i) throw new hu(G(13101, i)); + if (e.getUint32(8, !0) !== e.byteLength) throw new hu(G(13102)); + let s = 12; + const n = e.getUint32(s, !0); + s += 4; + const r = new Uint8Array(e.buffer, s + e.byteOffset, n); + s += n; + const o = function(t) { + if ("undefined" != typeof TextDecoder) return (new TextDecoder).decode(t); + if ("Buffer" in globalThis) { + const {Buffer: e} = globalThis; + return e.from(t.buffer, t.byteOffset, t.byteLength).toString(); + } + throw new Error(G(13104)); + }(r); + let a; + try { + a = JSON.parse(o); + } catch (t) { + throw new hu(t); + } + const l = []; + for (;s < e.byteLength; ) { + if (s % 8 != 0) { + s += 8 - s % 8; + } + const t = e.getUint32(s, !0); + s += 4; + l.push(new Uint8Array(e.buffer, s + e.byteOffset, t)); + s += t; + } + if (s !== e.byteLength) throw new hu(G(13102)); + return new ou(a, l); + } + class hu extends Error {} + m.internal.parseCCONJson = au; + m.internal.decodeCCONBinary = lu; + m.internal.CCON = ou; + const cu = function(t, e) { + const i = me.test(Qt(e)); + const s = Vt(e, m._BaseNode) || Vt(e, m.Component); + let n = !1; + const r = []; + let o = r; + const a = []; + let l = a; + const h = []; + (() => { + const t = e.__values__; + n = "_$erialized" === t[t.length - 1]; + const s = Be(e); + for (let e = 0; e < t.length; e++) { + const n = t[e]; + let c = n; + s[n + du] && (c = s[n + du]); + const u = si.getDefault(s[n + _u]); + const _ = s[n + uu]; + let d = !1; + if (i && (void 0 !== u || _)) if (void 0 === u) d = _ instanceof Pe || _ === Je || _ === Ze; else { + const t = typeof u; + d = "string" === t || "number" === t || "boolean" === t; + } + if (i && d) { + c !== n && o === r && (o = r.slice()); + r.push(n); + o !== r && o.push(c); + } else { + c !== n && l === a && (l = a.slice()); + a.push(n); + l !== a && l.push(c); + h.push(u instanceof m.ValueType && u.constructor); + } + } + })(); + return (t, e, c, u) => { + for (let t = 0; t < r.length; ++t) { + const i = c[o[t]]; + void 0 !== i && (e[r[t]] = i); + } + for (let s = 0; s < a.length; ++s) { + const n = a[s]; + const r = c[l[s]]; + if (void 0 !== r) if ("object" != typeof r) e[n] = r; else { + const o = h[s]; + o ? i || r ? t._deserializeFastDefinedObject(e[n], r, o) : e[n] = null : r ? t._deserializeAndAssignField(e, r, n) : e[n] = null; + } + } + s && c._id && (e._id = c._id); + if (n) { + e._$erialized = JSON.parse(JSON.stringify(c)); + t._fillPlainObject(e._$erialized, c); + } + }; + }; + const uu = "$_$type"; + const _u = "$_$default"; + const du = "$_$formerlySerializedAs"; + class pu { + constructor(t, e, i, s, n) { + this.deserializedList = void 0; + this.deserializedData = void 0; + this._ignoreEditorOnly = void 0; + this.result = t; + this.customEnv = s; + this.deserializedList = []; + this.deserializedData = null; + this._classFinder = e; + this._reportMissingClass = i; + this._onDereferenced = null == e ? void 0 : e.onDereferenced; + } + reset(t, e, i, s, n) { + this.result = t; + this.customEnv = s; + this._classFinder = e; + this._reportMissingClass = i; + this._onDereferenced = null == e ? void 0 : e.onDereferenced; + } + clear() { + this.result = null; + this.customEnv = null; + this.deserializedList.length = 0; + this.deserializedData = null; + this._classFinder = null; + this._reportMissingClass = null; + this._onDereferenced = null; + } + deserialize(t) { + let e = !1; + let i; + if (t instanceof ou) { + e = !0; + i = t.document; + if (t.chunks.length > 0) { + ne(1 === t.chunks.length); + this._mainBinChunk = t.chunks[0]; + } + } else i = t; + this._serializedData = i; + this._context = { + fromCCON: e + }; + const s = Array.isArray(i) ? i[0] : i; + this.deserializedData = this._deserializeObject(s, 0); + this._serializedData = void 0; + this._mainBinChunk = void 0; + this._context = void 0; + return this.deserializedData; + } + _deserializeObject(t, e, i, s) { + switch (t.__type__) { + case "TypedArray": + return this._deserializeTypedArrayView(t); + + case "TypedArrayRef": + return this._deserializeTypedArrayViewRef(t); + + default: + return t.__type__ ? this._deserializeTypeTaggedObject(t, e, i, s) : Array.isArray(t) ? this._deserializeArray(t) : this._deserializePlainObject(t); + } + } + _deserializeTypedArrayView(t) { + return globalThis[t.ctor].from(t.array); + } + _deserializeTypedArrayViewRef(t) { + const {offset: e, length: i, ctor: s} = t; + return new globalThis[s](this._mainBinChunk.buffer, this._mainBinChunk.byteOffset + e, i); + } + _deserializeArray(t) { + const e = new Array(t.length); + let i; + for (let s = 0; s < t.length; s++) { + i = t[s]; + if ("object" == typeof i && i) { + this._deserializeAndAssignField(e, i, `${s}`) && (e[s] = null); + } else e[s] = i; + } + return e; + } + _deserializePlainObject(t) { + const e = {}; + this._fillPlainObject(e, t); + return e; + } + _deserializeTypeTaggedObject(t, e, i, s) { + const n = t.__type__; + const r = this._classFinder(n, t, i, s); + if (!r) { + this._classFinder === Kt && this._reportMissingClass(n); + return null; + } + const o = t => { + const i = new t; + e >= 0 && (this.deserializedList[e] = i); + return i; + }; + { + const e = o(r); + this._deserializeInto(t, e, r); + return e; + } + } + _deserializeInto(t, e, i, s = !1) { + s || !e[ru] ? e._deserialize ? e._deserialize(t.content, this) : m.Class._isCCClass(i) ? this._deserializeFireClass(e, t, i) : this._deserializeFastDefinedObject(e, t, i) : this._runCustomizedDeserialize(t, e, i); + } + _runCustomizedDeserialize(t, e, i) { + const s = { + readProperty: e => { + const i = t[e]; + return "object" == typeof i && i ? this._deserializeObjectField(i) : i; + }, + readThis: () => { + this._deserializeInto(t, e, i, !0); + }, + readSuper: () => { + const s = Ft(i); + s && this._deserializeInto(t, e, s); + } + }; + e[ru](s, this._context); + } + _deserializeFireClass(t, e, i) { + let s; + if (i.hasOwnProperty("__deserialize__")) s = i.__deserialize__; else { + s = cu(this, i); + try { + if (i === su) { + const t = i.__values__; + if (0 === t.length || "_$erialized" !== t[t.length - 1]) { + x("The '_$erialized' prop of MissingScript is missing. Will force the raw data to be save."); + x(` Error props: ['${t}']. Please contact jare.`); + } + const e = s; + s = function(t, i, s, n) { + e(t, i, s, n); + i._$erialized || x(`Unable to stash previously serialized data. ${JSON.stringify(s)}`); + }; + } + } catch (t) { + x(`Error when checking MissingScript 6, ${t}`); + } + bt(i, "__deserialize__", s, !0); + } + s(this, t, e, i); + } + _deserializeAndAssignField(t, e, i) { + const s = e.__id__; + if ("number" == typeof s) { + const e = this.deserializedList[s]; + if (e) t[i] = e; else { + var n; + const e = this._serializedData[s]; + t[i] = this._deserializeObject(e, s, void 0, i); + null === (n = this._onDereferenced) || void 0 === n || n.call(this, this.deserializedList, s, t, i); + } + } else { + const s = e.__uuid__; + if (s) { + const n = e.__expectedType__; + this.result.push(t, i, s, n); + } else t[i] = this._deserializeObject(e, -1); + } + return !1; + } + _deserializeObjectField(t) { + const e = t.__id__; + if ("number" == typeof e) { + const t = this.deserializedList[e]; + if (t) return t; + { + const t = this._serializedData[e]; + return this._deserializeObject(t, e, void 0, void 0); + } + } + if (t.__uuid__) { + t.__expectedType__; + throw new Error("Asset reference field serialization is currently not supported in custom serialization."); + } + return this._deserializeObject(t, -1); + } + _fillPlainObject(t, e) { + for (const i in e) { + if (!e.hasOwnProperty(i)) continue; + const s = e[i]; + if ("object" != typeof s) "__type__" !== i && (t[i] = s); else if (s) { + this._deserializeAndAssignField(t, s, i) && (t[i] = null); + } else t[i] = null; + } + } + _deserializeFastDefinedObject(t, e, i) { + if (i === m.Vec2) { + t.x = e.x || 0; + t.y = e.y || 0; + return; + } + if (i === m.Vec3) { + t.x = e.x || 0; + t.y = e.y || 0; + t.z = e.z || 0; + return; + } + if (i === m.Color) { + t.r = e.r || 0; + t.g = e.g || 0; + t.b = e.b || 0; + const i = e.a; + t.a = void 0 === i ? 255 : i; + return; + } + if (i === m.Size) { + t.width = e.width || 0; + t.height = e.height || 0; + return; + } + const s = Be(i); + const n = i.__values__; + n || x(`Unable to deserialize ${Et(i)}. For non-CCClass types, they can only be marked as serializable by \`CCClass.fastDefine\`.`); + for (let i = 0; i < n.length; i++) { + const r = n[i]; + let o = e[r]; + void 0 !== o || e.hasOwnProperty(r) || (o = si.getDefault(s[r + _u])); + "object" != typeof o ? t[r] = o : o ? this._deserializeAndAssignField(t, o, r) : t[r] = null; + } + } + } + pu.pool = new class extends $t { + constructor() { + super((t => { + t.clear(); + }), 1); + } + get(t, e, i, s, n) { + const r = this._get(); + if (r) { + r.reset(t, e, i, s, n); + return r; + } + return new pu(t, e, i, s, n); + } + }; + const mu = [ Qi, Pi, is, Ui, Bi, rs, as, qi ]; + function fu(t, e) { + t.x = e[1]; + t.y = e[2]; + t.z = e[3]; + t.w = e[4]; + } + const gu = [ (t, e) => { + t.x = e[1]; + t.y = e[2]; + }, (t, e) => { + t.x = e[1]; + t.y = e[2]; + t.z = e[3]; + }, fu, fu, (t, e) => { + t._val = e[1]; + }, (t, e) => { + t.width = e[1]; + t.height = e[2]; + }, (t, e) => { + t.x = e[1]; + t.y = e[2]; + t.width = e[3]; + t.height = e[4]; + }, (t, e) => { + qi.fromArray(t, e, 1); + } ]; + const yu = 0, bu = 1, Su = 2, Au = 3, Tu = 4, vu = 5, Eu = 6, Cu = 7, xu = 8, wu = 9, Ru = 10, Iu = 11, Mu = 12, Bu = 13; + const Du = 3, Pu = 1, Ou = 2; + const Nu = 0, Lu = 0, Fu = 1, Vu = 2, ku = 3, Uu = 4, Gu = 5, zu = 6, Hu = 7, ju = 8, Xu = 9, Wu = 10; + const Yu = Gu; + class qu { + constructor() { + this.uuidObjList = null; + this.uuidPropList = null; + this.uuidList = null; + this.uuidTypeList = []; + } + init(t) { + if (t) { + this.uuidObjList = t[ju]; + this.uuidPropList = t[Xu]; + this.uuidList = t[Wu]; + } else { + if (!this.uuidList) { + this.uuidList = []; + this.uuidObjList = []; + this.uuidPropList = []; + this.uuidTypeList = []; + } + } + } + reset() { + if (this.uuidList) { + this.uuidList.length = 0; + this.uuidObjList.length = 0; + this.uuidPropList.length = 0; + this.uuidTypeList.length = 0; + } + } + push(t, e, i, s) { + this.uuidObjList.push(t); + this.uuidPropList.push(e); + this.uuidList.push(i); + this.uuidTypeList.push(s || ""); + } + } + t("Details", qu); + qu.pool = new $t((t => { + t.reset(); + }), 5); + qu.pool.get = function() { + return this._get() || new qu; + }; + function Ku(t, e) { + const i = t[Uu][e[0]]; + const s = i[0]; + const n = new (0, s[0]); + const r = s[1]; + const o = s[2]; + const a = i[i.length - 1]; + let l = 1; + for (;l < a; ++l) { + n[r[i[l]]] = e[l]; + } + for (;l < e.length; ++l) { + const a = r[i[l]]; + const h = s[i[l] + o]; + (0, e_[h])(t, n, a, e[l]); + } + return n; + } + function Ju(t, e, i) { + const s = new e; + s._deserialize ? s._deserialize(i, t[Lu]) : F(5303, Et(e)); + return s; + } + function Zu(t, e, i, s) { + s >= 0 ? e[i] = t[Gu][s] : t[Hu][~s * Du] = e; + } + function Qu(t) { + return (e, i, s, n) => { + i[s] = n; + for (let i = 0; i < n.length; ++i) t(e, n, i, n[i]); + }; + } + function $u(t, e, i, s) { + e[i] = null; + t[ju][s] = e; + } + function t_(t, e, i, s) { + e[i] = Ku(t, s); + } + const e_ = new Array(Bu); + e_[yu] = function(t, e, i, s) { + e[i] = s; + }; + e_[bu] = Zu; + e_[Su] = Qu(Zu); + e_[Au] = Qu($u); + e_[Tu] = t_; + e_[vu] = function(t, e, i, s) { + { + const t = e[i]; + gu[s[0]](t, s); + e[i] = t; + } + }; + e_[Eu] = $u; + e_[Cu] = function(t, e, i, s) { + e[i].set(s); + }; + e_[xu] = function(t, e, i, s) { + const n = new mu[s[0]]; + gu[s[0]](n, s); + e[i] = n; + }; + e_[wu] = Qu(t_); + e_[Ru] = function(t, e, i, s) { + const n = t[ku][s[0]]; + e[i] = Ju(t, n, s[1]); + }; + e_[Iu] = function(t, e, i, s) { + const n = s[0]; + e[i] = n; + for (let e = 1; e < s.length; e += 3) { + const i = s[e]; + const r = s[e + 1]; + const o = s[e + 2]; + (0, e_[r])(t, n, i, o); + } + }; + e_[Mu] = function(t, e, i, s) { + const n = s[0]; + e[i] = n; + for (let e = 0; e < n.length; ++e) { + const i = n[e]; + const r = s[e + 1]; + if (r !== yu) { + (0, e_[r])(t, n, e, i); + } + } + }; + function i_(t, e, i) { + t || i(e); + return Object; + } + function s_(t, e, i, s, n, r, o) { + let a = t(e); + if (!a) { + if (n) { + i[s] = (l = i, h = s, c = e, function() { + const e = t(c) || i_(r, c, o); + l[h] = e; + return new e; + }); + return; + } + a = i_(r, e, o); + } + var l, h, c; + i[s] = a; + } + function n_(t, e, i, s) { + const n = i || Kt; + const r = t[ku]; + for (let t = 0; t < r.length; ++t) { + const o = r[t]; + if ("string" != typeof o) { + if ("function" == typeof o[0]) throw new Error("Can not deserialize the same JSON data again."); + s_(n, o[0], o, 0, e, i, s); + } else s_(n, o, r, t, e, i, s); + } + } + function r_(t) { + const e = t[Uu]; + if (e) { + const i = t[ku]; + for (let t = 0; t < e.length; ++t) { + const s = e[t]; + s[0] = i[s[0]]; + } + } + } + function o_(t, e, i) { + "string" == typeof t && (t = JSON.parse(t)); + const s = !e; + e = e || qu.pool.get(); + let n; + if (function(t) { + if (Array.isArray(t)) { + const e = t[0]; + return "number" == typeof e || e instanceof a_; + } + return !1; + }(t)) { + e.init(t); + i = i || {}; + let s = t[Nu]; + let o = !1; + if ("object" == typeof s) { + o = s.preprocessed; + s = s.version; + } + if (s < 1) throw new Error(G(5304, s)); + i._version = s; + i.result = e; + t[Lu] = i; + if (!o) { + var r; + n_(t, !1, i.classFinder, null !== (r = i.reportMissingClass) && void 0 !== r ? r : o_.reportMissingClass); + r_(t); + } + m.game._isCloning = !0; + const a = t[Gu]; + const l = function(t) { + const e = t[Gu]; + const i = t[zu]; + const s = 0 === i ? 0 : i.length; + let n = e[e.length - 1]; + let r = e.length - s; + if ("number" != typeof n) n = 0; else { + n < 0 && (n = ~n); + --r; + } + let o = 0; + for (;o < r; ++o) e[o] = Ku(t, e[o]); + const a = t[ku]; + for (let n = 0; n < s; ++n, ++o) { + let s = i[n]; + const r = e[o]; + if (s >= 0) { + const i = a[s]; + e[o] = Ju(t, i, r); + } else { + s = ~s; + (0, e_[s])(t, e, o, r); + } + } + return n; + }(t); + m.game._isCloning = !1; + t[Hu] && function(t, e, i) { + const s = t.length - 1; + let n = 0; + const r = t[s] * Du; + for (;n < r; n += Du) { + const s = t[n]; + const r = e[t[n + Ou]]; + const o = t[n + Pu]; + o >= 0 ? s[i[o]] = r : s[~o] = r; + } + for (;n < s; n += Du) { + const s = e[t[n]]; + const r = e[t[n + Ou]]; + const o = t[n + Pu]; + o >= 0 ? s[i[o]] = r : s[~o] = r; + } + }(t[Hu], a, t[Vu]); + !function(t) { + const e = t[Gu]; + const i = t[Vu]; + const s = t[Fu]; + const n = t[ju]; + const r = t[Xu]; + const o = t[Wu]; + for (let t = 0; t < n.length; ++t) { + const a = n[t]; + "number" == typeof a && (n[t] = e[a]); + let l = r[t]; + if ("number" == typeof l) { + l = l >= 0 ? i[l] : ~l; + r[t] = l; + } + const h = o[t]; + "number" == typeof h && (o[t] = s[h]); + } + }(t); + n = a[l]; + } else n = function(t, e, i) { + var s; + const n = (i = i || {}).classFinder || Kt; + const r = i.createAssetRefs || Vo.platform === Io.EDITOR_CORE; + const o = i.customEnv; + const a = i.ignoreEditorOnly; + const l = null !== (s = i.reportMissingClass) && void 0 !== s ? s : m.deserialize.reportMissingClass; + e.init(); + const h = pu.pool.get(e, n, l, o, a); + m.game._isCloning = !0; + const c = h.deserialize(t); + m.game._isCloning = !1; + pu.pool.put(h); + r && e.assignAssetsBy(((t, e) => EditorExtends.serialize.asAsset(t, e.type))); + return c; + }(t, e, i); + s && qu.pool.put(e); + return n; + } + o_.Details = qu; + o_.reportMissingClass = function(t) { + F(5302, t); + }; + class a_ { + constructor(t) { + this.preprocessed = !0; + this.version = t; + } + } + function l_(t, e, i) { + return [ 1, 0, 0, [ t ], 0, i ? [ e, -1 ] : [ e ], [ 0 ], 0, [], [], [] ]; + } + function h_(t) { + return function(t) { + const e = t[Fu]; + return t[Wu].map((t => e[t])); + }(t); + } + m.deserialize = o_; + const c_ = co.Flags.Destroyed; + const u_ = co.Flags.PersistentMask; + const __ = []; + function d_(t, e) { + let i; + if (_o(t)) { + if (t._instantiate) { + m.game._isCloning = !0; + i = t._instantiate(null, !0); + m.game._isCloning = !1; + dc(i); + return i; + } + if (t instanceof m.Asset) throw new TypeError(G(6903)); + } + m.game._isCloning = !0; + i = p_(t); + m.game._isCloning = !1; + dc(i); + return i; + } + function p_(t, e) { + let i; + if (t._iN$t) i = t._iN$t; else if (t.constructor) { + i = new (0, t.constructor); + } else i = Object.create(null); + m_(t, i, e); + for (let t = 0, e = __.length; t < e; ++t) __[t]._iN$t = null; + __.length = 0; + return i; + } + function m_(t, e, i) { + ee.value(t, "_iN$t", e, !0); + __.push(t); + const s = t.constructor; + if (ni(s)) !function(t, e, i, s) { + const n = t.__values__; + for (let t = 0; t < n.length; t++) { + const r = n[t]; + const o = e[r]; + if ("object" == typeof o && o) { + const t = i[r]; + t instanceof ce && t.constructor === o.constructor ? t.set(o) : i[r] = o._iN$t || f_(o, s); + } else i[r] = o; + } + }(s, t, e, i); else for (const s in t) { + if (!t.hasOwnProperty(s) || 95 === s.charCodeAt(0) && 95 === s.charCodeAt(1) && "__type__" !== s && "__prefab" !== s) continue; + const n = t[s]; + if ("object" == typeof n && n) { + if (n === e) continue; + e[s] = n._iN$t || f_(n, i); + } else e[s] = n; + } + _o(t) && (e._objFlags &= u_); + } + function f_(t, e) { + if (t instanceof ce) return t.clone(); + if (t instanceof m.Asset) return t; + let i; + if (ArrayBuffer.isView(t)) { + const e = t.length; + i = new t.constructor(e); + t._iN$t = i; + __.push(t); + for (let s = 0; s < e; ++s) i[s] = t[s]; + return i; + } + if (Array.isArray(t)) { + const s = t.length; + i = new Array(s); + t._iN$t = i; + __.push(t); + for (let n = 0; n < s; ++n) { + const s = t[n]; + i[n] = "object" == typeof s && s ? s._iN$t || f_(s, e) : s; + } + return i; + } + if (t._objFlags & c_) return null; + const s = t.constructor; + if (ni(s)) { + if (e) if (e instanceof m.Component) { + if (t instanceof m._BaseNode || t instanceof m.Component) return t; + } else if (e instanceof m._BaseNode) if (t instanceof m._BaseNode) { + if (!t.isChildOf(e)) return t; + } else if (t instanceof m.Component && t.node && !t.node.isChildOf(e)) return t; + i = new s; + } else if (s === Object) i = {}; else { + if (s) return t; + i = Object.create(null); + } + m_(t, i, e); + return i; + } + d_._clone = p_; + m.instantiate = d_; + var g_, y_, b_, S_, A_, T_, v_, E_; + let C_; + !function(t) { + t[t.Uint8 = 0] = "Uint8"; + t[t.Uint16 = 1] = "Uint16"; + t[t.Uint32 = 2] = "Uint32"; + t[t.Int8 = 3] = "Int8"; + t[t.Int16 = 4] = "Int16"; + t[t.Int32 = 5] = "Int32"; + t[t.Float32 = 6] = "Float32"; + t[t.Float64 = 7] = "Float64"; + }(C_ || (C_ = {})); + let x_; + !function(t) { + t[t.Scalar = 0] = "Scalar"; + t[t.Vec2 = 1] = "Vec2"; + t[t.Vec3 = 2] = "Vec3"; + t[t.Vec4 = 3] = "Vec4"; + t[t.Quat = 4] = "Quat"; + t[t.Mat4 = 5] = "Mat4"; + }(x_ || (x_ = {})); + function w_(t, e) { + return (e << 3) + t; + } + t("CompactValueTypeArray", Ul("cc.CompactValueTypeArray")(g_ = (y_ = (E_ = v_ = class t { + constructor() { + Ml(this, "_byteOffset", b_, this); + Ml(this, "_unitCount", S_, this); + Ml(this, "_unitElement", A_, this); + Ml(this, "_length", T_, this); + } + static lengthFor(t, e, i) { + return R_(e).requiredUnits * t.length * I_(i).BYTES_PER_ELEMENT; + } + static compress(e, i, s, n, r, o) { + const a = R_(i); + const l = I_(s); + const h = a.requiredUnits * e.length; + const c = new l(n, r, h); + for (let t = 0; t < e.length; ++t) a.compress(c, t, e[t]); + const u = new t; + u._unitElement = w_(s, i); + u._byteOffset = o; + u._unitCount = h; + u._length = e.length; + return u; + } + decompress(t) { + const {storageUnit: e, elementType: i} = { + storageUnit: 7 & (s = this._unitElement), + elementType: s >> 3 + }; + var s; + const n = R_(i); + const r = new (I_(e))(t, this._byteOffset, this._unitCount); + const o = new Array(this._length); + for (let t = 0; t < this._length; ++t) o[t] = n.decompress(r, t); + return o; + } + }, v_.StorageUnit = C_, v_.ElementType = x_, E_), b_ = Bl(y_.prototype, "_byteOffset", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), S_ = Bl(y_.prototype, "_unitCount", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), A_ = Bl(y_.prototype, "_unitElement", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return w_(C_.Uint8, x_.Scalar); + } + }), T_ = Bl(y_.prototype, "_length", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), y_)) || g_); + function R_(t) { + return M_[t]; + } + function I_(t) { + switch (t) { + case C_.Uint8: + return Uint8Array; + + case C_.Uint16: + return Uint16Array; + + case C_.Uint32: + return Uint32Array; + + case C_.Int8: + return Int8Array; + + case C_.Int16: + return Int16Array; + + case C_.Int32: + return Int32Array; + + case C_.Float32: + return Float32Array; + + case C_.Float64: + return Float64Array; + } + } + const M_ = { + [x_.Scalar]: { + requiredUnits: 1, + compress(t, e, i) { + t[e] = i; + }, + decompress: (t, e) => t[e] + }, + [x_.Vec2]: { + requiredUnits: 2, + compress(t, e, i) { + t[2 * e] = i.x; + t[2 * e + 1] = i.y; + }, + decompress: (t, e) => new Pi(t[2 * e], t[2 * e + 1]) + }, + [x_.Vec3]: { + requiredUnits: 3, + compress(t, e, i) { + t[3 * e] = i.x; + t[3 * e + 1] = i.y; + t[3 * e + 2] = i.z; + }, + decompress: (t, e) => new Pi(t[3 * e], t[3 * e + 1], t[3 * e + 2]) + }, + [x_.Vec4]: { + requiredUnits: 4, + compress(t, e, i) { + t[4 * e] = i.x; + t[4 * e + 1] = i.y; + t[4 * e + 2] = i.z; + t[4 * e + 3] = i.w; + }, + decompress: (t, e) => new is(t[4 * e], t[4 * e + 1], t[4 * e + 2], t[4 * e + 3]) + }, + [x_.Quat]: { + requiredUnits: 4, + compress(t, e, i) { + t[4 * e] = i.x; + t[4 * e + 1] = i.y; + t[4 * e + 2] = i.z; + t[4 * e + 3] = i.w; + }, + decompress: (t, e) => new Ui(t[4 * e], t[4 * e + 1], t[4 * e + 2], t[4 * e + 3]) + }, + [x_.Mat4]: { + requiredUnits: 16, + compress(t, e, i) { + qi.toArray(t, i, 16 * e); + }, + decompress: (t, e) => qi.fromArray(new qi, t, 16 * e) + } + }; + m._decorator = wh; + function B_() { + return 0; + } + function D_(t) { + return t; + } + function P_(t) { + return t * t; + } + function O_(t) { + return t * (2 - t); + } + function N_(t) { + return (t *= 2) < 1 ? .5 * t * t : -.5 * (--t * (t - 2) - 1); + } + function L_(t) { + return t * t * t; + } + function F_(t) { + return --t * t * t + 1; + } + function V_(t) { + return (t *= 2) < 1 ? .5 * t * t * t : .5 * ((t -= 2) * t * t + 2); + } + function k_(t) { + return t * t * t * t; + } + function U_(t) { + return 1 - --t * t * t * t; + } + function G_(t) { + return (t *= 2) < 1 ? .5 * t * t * t * t : -.5 * ((t -= 2) * t * t * t - 2); + } + function z_(t) { + return t * t * t * t * t; + } + function H_(t) { + return --t * t * t * t * t + 1; + } + function j_(t) { + return (t *= 2) < 1 ? .5 * t * t * t * t * t : .5 * ((t -= 2) * t * t * t * t + 2); + } + function X_(t) { + return 1 === t ? 1 : 1 - Math.cos(t * Math.PI / 2); + } + function W_(t) { + return Math.sin(t * Math.PI / 2); + } + function Y_(t) { + return .5 * (1 - Math.cos(Math.PI * t)); + } + function q_(t) { + return 0 === t ? 0 : Math.pow(1024, t - 1); + } + function K_(t) { + return 1 === t ? 1 : 1 - Math.pow(2, -10 * t); + } + function J_(t) { + return 0 === t ? 0 : 1 === t ? 1 : (t *= 2) < 1 ? .5 * Math.pow(1024, t - 1) : .5 * (2 - Math.pow(2, -10 * (t - 1))); + } + function Z_(t) { + return 1 - Math.sqrt(1 - t * t); + } + function Q_(t) { + return Math.sqrt(1 - --t * t); + } + function $_(t) { + return (t *= 2) < 1 ? -.5 * (Math.sqrt(1 - t * t) - 1) : .5 * (Math.sqrt(1 - (t -= 2) * t) + 1); + } + function td(t) { + let e; + let i = .1; + if (0 === t) return 0; + if (1 === t) return 1; + if (!i || i < 1) { + i = 1; + e = .1; + } else e = .4 * Math.asin(1 / i) / (2 * Math.PI); + return -i * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - e) * (2 * Math.PI) / .4); + } + function ed(t) { + let e; + let i = .1; + if (0 === t) return 0; + if (1 === t) return 1; + if (!i || i < 1) { + i = 1; + e = .1; + } else e = .4 * Math.asin(1 / i) / (2 * Math.PI); + return i * Math.pow(2, -10 * t) * Math.sin((t - e) * (2 * Math.PI) / .4) + 1; + } + function id(t) { + let e; + let i = .1; + const s = .4; + if (0 === t) return 0; + if (1 === t) return 1; + if (!i || i < 1) { + i = 1; + e = .1; + } else e = s * Math.asin(1 / i) / (2 * Math.PI); + return (t *= 2) < 1 ? i * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - e) * (2 * Math.PI) / s) * -.5 : i * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - e) * (2 * Math.PI) / s) * .5 + 1; + } + function sd(t) { + if (1 === t) return 1; + const e = 1.70158; + return t * t * ((e + 1) * t - e); + } + function nd(t) { + if (0 === t) return 0; + const e = 1.70158; + return --t * t * ((e + 1) * t + e) + 1; + } + function rd(t) { + const e = 2.5949095; + return (t *= 2) < 1 ? t * t * ((e + 1) * t - e) * .5 : .5 * ((t -= 2) * t * ((e + 1) * t + e) + 2); + } + function od(t) { + return 1 - ad(1 - t); + } + function ad(t) { + return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375; + } + function ld(t) { + return t < .5 ? .5 * od(2 * t) : .5 * ad(2 * t - 1) + .5; + } + function hd(t) { + return t <= 0 ? 0 : t >= 1 ? 1 : t * t * (3 - 2 * t); + } + function cd(t) { + return t <= 0 ? 0 : t >= 1 ? 1 : t * t * t * (t * (6 * t - 15) + 10); + } + const ud = Ad(P_, O_); + const _d = Ad(L_, F_); + const dd = Ad(k_, U_); + const pd = Ad(z_, H_); + const md = Ad(X_, W_); + const fd = Ad(q_, K_); + const gd = Ad(Z_, Q_); + const yd = Ad(td, ed); + const bd = Ad(sd, nd); + const Sd = Ad(od, ad); + function Ad(t, e) { + return i => i < .5 ? e(2 * i) / 2 : t(2 * i - 1) / 2 + .5; + } + var Td = Object.freeze({ + __proto__: null, + constant: B_, + linear: D_, + quadIn: P_, + quadOut: O_, + quadInOut: N_, + cubicIn: L_, + cubicOut: F_, + cubicInOut: V_, + quartIn: k_, + quartOut: U_, + quartInOut: G_, + quintIn: z_, + quintOut: H_, + quintInOut: j_, + sineIn: X_, + sineOut: W_, + sineInOut: Y_, + expoIn: q_, + expoOut: K_, + expoInOut: J_, + circIn: Z_, + circOut: Q_, + circInOut: $_, + elasticIn: td, + elasticOut: ed, + elasticInOut: id, + backIn: sd, + backOut: nd, + backInOut: rd, + bounceIn: od, + bounceOut: ad, + bounceInOut: ld, + smooth: hd, + fade: cd, + quadOutIn: ud, + cubicOutIn: _d, + quartOutIn: dd, + quintOutIn: pd, + sineOutIn: md, + expoOutIn: fd, + circOutIn: gd, + elasticOutIn: yd, + backOutIn: bd, + bounceOutIn: Sd + }); + t("easing", Td); + let vd; + !function(t) { + t[t.LINEAR = 0] = "LINEAR"; + t[t.CONSTANT = 1] = "CONSTANT"; + t[t.QUAD_IN = 2] = "QUAD_IN"; + t[t.QUAD_OUT = 3] = "QUAD_OUT"; + t[t.QUAD_IN_OUT = 4] = "QUAD_IN_OUT"; + t[t.QUAD_OUT_IN = 5] = "QUAD_OUT_IN"; + t[t.CUBIC_IN = 6] = "CUBIC_IN"; + t[t.CUBIC_OUT = 7] = "CUBIC_OUT"; + t[t.CUBIC_IN_OUT = 8] = "CUBIC_IN_OUT"; + t[t.CUBIC_OUT_IN = 9] = "CUBIC_OUT_IN"; + t[t.QUART_IN = 10] = "QUART_IN"; + t[t.QUART_OUT = 11] = "QUART_OUT"; + t[t.QUART_IN_OUT = 12] = "QUART_IN_OUT"; + t[t.QUART_OUT_IN = 13] = "QUART_OUT_IN"; + t[t.QUINT_IN = 14] = "QUINT_IN"; + t[t.QUINT_OUT = 15] = "QUINT_OUT"; + t[t.QUINT_IN_OUT = 16] = "QUINT_IN_OUT"; + t[t.QUINT_OUT_IN = 17] = "QUINT_OUT_IN"; + t[t.SINE_IN = 18] = "SINE_IN"; + t[t.SINE_OUT = 19] = "SINE_OUT"; + t[t.SINE_IN_OUT = 20] = "SINE_IN_OUT"; + t[t.SINE_OUT_IN = 21] = "SINE_OUT_IN"; + t[t.EXPO_IN = 22] = "EXPO_IN"; + t[t.EXPO_OUT = 23] = "EXPO_OUT"; + t[t.EXPO_IN_OUT = 24] = "EXPO_IN_OUT"; + t[t.EXPO_OUT_IN = 25] = "EXPO_OUT_IN"; + t[t.CIRC_IN = 26] = "CIRC_IN"; + t[t.CIRC_OUT = 27] = "CIRC_OUT"; + t[t.CIRC_IN_OUT = 28] = "CIRC_IN_OUT"; + t[t.CIRC_OUT_IN = 29] = "CIRC_OUT_IN"; + t[t.ELASTIC_IN = 30] = "ELASTIC_IN"; + t[t.ELASTIC_OUT = 31] = "ELASTIC_OUT"; + t[t.ELASTIC_IN_OUT = 32] = "ELASTIC_IN_OUT"; + t[t.ELASTIC_OUT_IN = 33] = "ELASTIC_OUT_IN"; + t[t.BACK_IN = 34] = "BACK_IN"; + t[t.BACK_OUT = 35] = "BACK_OUT"; + t[t.BACK_IN_OUT = 36] = "BACK_IN_OUT"; + t[t.BACK_OUT_IN = 37] = "BACK_OUT_IN"; + t[t.BOUNCE_IN = 38] = "BOUNCE_IN"; + t[t.BOUNCE_OUT = 39] = "BOUNCE_OUT"; + t[t.BOUNCE_IN_OUT = 40] = "BOUNCE_IN_OUT"; + t[t.BOUNCE_OUT_IN = 41] = "BOUNCE_OUT_IN"; + t[t.SMOOTH = 42] = "SMOOTH"; + t[t.FADE = 43] = "FADE"; + }(vd || (vd = {})); + const Ed = { + [vd.CONSTANT]: B_, + [vd.LINEAR]: D_, + [vd.QUAD_IN]: P_, + [vd.QUAD_OUT]: O_, + [vd.QUAD_IN_OUT]: N_, + [vd.QUAD_OUT_IN]: ud, + [vd.CUBIC_IN]: L_, + [vd.CUBIC_OUT]: F_, + [vd.CUBIC_IN_OUT]: V_, + [vd.CUBIC_OUT_IN]: _d, + [vd.QUART_IN]: k_, + [vd.QUART_OUT]: U_, + [vd.QUART_IN_OUT]: G_, + [vd.QUART_OUT_IN]: dd, + [vd.QUINT_IN]: z_, + [vd.QUINT_OUT]: H_, + [vd.QUINT_IN_OUT]: j_, + [vd.QUINT_OUT_IN]: pd, + [vd.SINE_IN]: X_, + [vd.SINE_OUT]: W_, + [vd.SINE_IN_OUT]: Y_, + [vd.SINE_OUT_IN]: md, + [vd.EXPO_IN]: q_, + [vd.EXPO_OUT]: K_, + [vd.EXPO_IN_OUT]: J_, + [vd.EXPO_OUT_IN]: fd, + [vd.CIRC_IN]: Z_, + [vd.CIRC_OUT]: Q_, + [vd.CIRC_IN_OUT]: $_, + [vd.CIRC_OUT_IN]: gd, + [vd.ELASTIC_IN]: td, + [vd.ELASTIC_OUT]: ed, + [vd.ELASTIC_IN_OUT]: id, + [vd.ELASTIC_OUT_IN]: yd, + [vd.BACK_IN]: sd, + [vd.BACK_OUT]: nd, + [vd.BACK_IN_OUT]: rd, + [vd.BACK_OUT_IN]: bd, + [vd.BOUNCE_IN]: od, + [vd.BOUNCE_OUT]: ad, + [vd.BOUNCE_IN_OUT]: ld, + [vd.BOUNCE_OUT_IN]: Sd, + [vd.SMOOTH]: hd, + [vd.FADE]: cd + }; + function Cd(t) { + ne(t in Ed); + return Ed[t]; + } + const xd = 65280; + const wd = 255 << 16; + ne(8 === 0 + o(255)); + ne(16 === 8 + o(xd)); + const Rd = xl.LINEAR << 0 | Rl.NONE << 8 | vd.LINEAR << 16; + class Id extends Ch { + constructor(...t) { + super(...t); + this.value = 0; + this.rightTangent = 0; + this.rightTangentWeight = 0; + this.leftTangent = 0; + this.leftTangentWeight = 0; + this._flags = Rd; + } + get interpolationMode() { + return (255 & this._flags) >> 0; + } + set interpolationMode(t) { + this._flags &= -256; + this._flags |= t << 0; + } + get tangentWeightMode() { + return (this._flags & xd) >> 8; + } + set tangentWeightMode(t) { + this._flags &= -65281; + this._flags |= t << 8; + } + get easingMethod() { + return (this._flags & wd) >> 16; + } + set easingMethod(t) { + this._flags &= -16711681; + this._flags |= t << 16; + } + } + si.fastDefine("cc.RealKeyframeValue", Id, { + interpolationMode: xl.LINEAR, + tangentWeightMode: Rl.NONE, + value: 0, + rightTangent: 0, + rightTangentWeight: 0, + leftTangent: 0, + leftTangentWeight: 0, + easingMethod: vd.LINEAR, + [io]: void 0 + }); + si.Attr.setClassAttr(Id, io, "editorOnly", !0); + (Md = Id, null !== (Dd = (Bd = Md)[Wl]) && void 0 !== Dd ? Dd : Bd[Wl] = {}).uniquelyReferenced = !0; + var Md, Bd, Dd; + function Pd(t) { + const e = new Id; + if ("number" == typeof t) e.value = t; else { + const {interpolationMode: i, tangentWeightMode: s, value: n, rightTangent: r, rightTangentWeight: o, leftTangent: a, leftTangentWeight: l, easingMethod: h, [io]: c} = t; + e.value = null != n ? n : e.value; + e.rightTangent = null != r ? r : e.rightTangent; + e.rightTangentWeight = null != o ? o : e.rightTangentWeight; + e.leftTangent = null != a ? a : e.leftTangent; + e.leftTangentWeight = null != l ? l : e.leftTangentWeight; + e.interpolationMode = null != i ? i : e.interpolationMode; + e.tangentWeightMode = null != s ? s : e.tangentWeightMode; + e.easingMethod = null != h ? h : e.easingMethod; + c && (e[io] = c); + } + return e; + } + class Od extends Cl { + constructor(...t) { + super(...t); + this.preExtrapolation = wl.CLAMP; + this.postExtrapolation = wl.CLAMP; + } + evaluate(t) { + const {_times: e, _values: i} = this; + const s = e.length; + if (0 === s) return 0; + const n = e[0]; + const r = e[s - 1]; + if (t < n) { + const {preExtrapolation: o} = this; + const a = i[0]; + if (o === wl.CLAMP || s < 2) return a.value; + switch (o) { + case wl.LINEAR: + return Jd(n, i[0].value, e[1], i[1].value, t); + + case wl.LOOP: + t = qd(t, n, r); + break; + + case wl.PING_PONG: + t = Kd(t, n, r); + break; + + default: + return a.value; + } + } else if (t > r) { + const {postExtrapolation: o} = this; + const a = i[s - 1]; + if (o === wl.CLAMP || s < 2) return a.value; + switch (o) { + case wl.LINEAR: + return Jd(r, a.value, e[s - 2], i[s - 2].value, t); + + case wl.LOOP: + t = qd(t, n, r); + break; + + case wl.PING_PONG: + t = Kd(t, n, r); + break; + + default: + return a.value; + } + } + const o = vl(e, t); + if (o >= 0) return i[o].value; + const a = ~o; + ne(0 !== a && a !== s && s > 1); + const l = a - 1; + const h = e[l]; + const c = i[l]; + const u = e[a]; + const _ = i[a]; + ne(u > t && t > h); + return function(t, e, i, s, n) { + const r = i - t; + switch (e.interpolationMode) { + default: + case xl.CONSTANT: + return e.value; + + case xl.LINEAR: + { + const t = e.easingMethod === vd.LINEAR ? n : Cd(e.easingMethod)(n); + return pi(e.value, s.value, t); + } + + case xl.CUBIC: + { + const o = 1 / 3; + const {rightTangent: a, rightTangentWeight: l} = e; + const h = 0 != (e.tangentWeightMode & Rl.RIGHT); + const {leftTangent: c, leftTangentWeight: u} = s; + const _ = function(t) { + return 0 != (t & Rl.LEFT); + }(s.tangentWeightMode); + if (h || _) { + let d = 0; + if (h) d = l; else { + const t = r; + const e = r * a; + d = Math.sqrt(t * t + e * e) * o; + } + const p = Math.atan(a); + const m = Math.cos(p) * d + t; + const f = Math.sin(p) * d + e.value; + let g = 0; + if (_) g = u; else { + const t = r; + const e = r * c; + g = Math.sqrt(t * t + e * e) * o; + } + const y = Math.atan(c); + const b = (m - t) / r; + const S = (-Math.cos(y) * g + i - t) / r; + const A = f; + const T = -Math.sin(y) * g + s.value; + const v = [ 0, 0, 0 ]; + const E = function(t, e, i, s, n) { + const r = i / s; + const o = e / s; + const a = r * r; + const l = 1 / 3 * (-1 / 3 * a + o); + const h = .5 * (2 / 27 * r * a - 1 / 3 * r * o + t / s); + const c = l * l * l; + const u = h * h + c; + let _ = 0; + if (Il(u)) { + if (Il(h)) { + n[0] = 0; + return 1; + } + { + const t = Math.cbrt(-h); + n[0] = 2 * t; + n[1] = -t; + return 2; + } + } + if (u < 0) { + const t = 1 / 3 * Math.acos(-h / Math.sqrt(-c)); + const e = 2 * Math.sqrt(-l); + n[0] = e * Math.cos(t); + n[1] = -e * Math.cos(t + Math.PI / 3); + n[2] = -e * Math.cos(t - Math.PI / 3); + _ = 3; + } else { + const t = Math.sqrt(u); + const e = Math.cbrt(t - h); + const i = -Math.cbrt(t + h); + n[0] = e + i; + _ = 1; + } + const d = 1 / 3 * r; + for (let t = 0; t < _; ++t) n[t] -= d; + return _; + }(0 - n, 3 * b, 3 * S - 6 * b, 3 * (b - S) + 1, v); + const C = function(t, e, i) { + let s = i; + if (1 === e) s = t[0]; else { + s = -1 / 0; + for (let i = 0; i < e; ++i) { + const e = t[i]; + e >= 0 && e <= 1 && e > s && (s = e); + } + s === -1 / 0 && (s = 0); + } + return s; + }(v, E, n); + return Zd(e.value, A, T, s.value, C); + } + { + const t = e.value + o * a * r; + const i = s.value - o * c * r; + return Zd(e.value, t, i, s.value, n); + } + } + } + }(h, c, u, _, (t - h) / (u - h)); + } + addKeyFrame(t, e) { + return super.addKeyFrame(t, Pd(e)); + } + assignSorted(t, e) { + if (void 0 !== e) { + ne(Array.isArray(t)); + this.setKeyframes(t.slice(), e.map((t => Pd(t)))); + } else { + const e = Array.from(t); + this.setKeyframes(e.map((([t]) => t)), e.map((([, t]) => Pd(t)))); + } + } + isConstant(t) { + if (this._values.length <= 1) return !0; + const e = this._values[0].value; + return this._values.every((i => ui(i.value, e, t))); + } + [nu](t, e) { + if (!e.toCCON) { + t.writeThis(); + return; + } + const {_times: i, _values: s} = this; + const n = i.length; + const r = new DataView(new ArrayBuffer(0 + Ld + Ld + Fd + Vd * n + Xd * n)); + let o = 0; + r.setUint8(o, this.preExtrapolation); + o += Ld; + r.setUint8(o, this.postExtrapolation); + o += Ld; + r.setUint32(o, n, !0); + o += Fd; + i.forEach(((t, e) => r.setFloat32(o + Vd * e, t, !0))); + o += Vd * n; + for (const t of s) o = Wd(r, t, o); + const a = new Uint8Array(r.buffer, 0, o); + t.writeProperty("bytes", a); + const l = s.map((t => t[io])); + l.some((t => void 0 !== t)) && t.writeProperty("keyframeValueEditorExtras", l); + } + [ru](t, e) { + if (!e.fromCCON) { + t.readThis(); + return; + } + const i = t.readProperty("bytes"); + const s = new DataView(i.buffer, i.byteOffset, i.byteLength); + let n = 0; + this.preExtrapolation = s.getUint8(n); + n += Ld; + this.postExtrapolation = s.getUint8(n); + n += Ld; + const r = s.getUint32(n, !0); + n += Fd; + const o = Array.from({ + length: r + }, ((t, e) => s.getFloat32(n + Vd * e, !0))); + n += Vd * r; + const a = new Array(r); + for (let t = 0; t < r; ++t) { + const e = Pd({}); + n = Yd(s, e, n); + a[t] = e; + } + ne(n === i.byteLength); + const l = t.readProperty("keyframeValueEditorExtras"); + if (l) { + ne(l.length === r); + l.forEach(((t, e) => a[e][io] = t)); + } + this._times = o; + this._values = a; + } + } + t("RealCurve", Od); + si.fastDefine("cc.RealCurve", Od, { + _times: [], + _values: [], + preExtrapolation: wl.CLAMP, + postExtrapolation: wl.CLAMP + }); + var Nd; + !function(t) { + t[t.VALUE = 1] = "VALUE"; + t[t.INTERPOLATION_MODE = 2] = "INTERPOLATION_MODE"; + t[t.TANGENT_WEIGHT_MODE = 4] = "TANGENT_WEIGHT_MODE"; + t[t.LEFT_TANGENT = 8] = "LEFT_TANGENT"; + t[t.LEFT_TANGENT_WEIGHT = 16] = "LEFT_TANGENT_WEIGHT"; + t[t.RIGHT_TANGENT = 32] = "RIGHT_TANGENT"; + t[t.RIGHT_TANGENT_WEIGHT = 64] = "RIGHT_TANGENT_WEIGHT"; + }(Nd || (Nd = {})); + const Ld = 1; + const Fd = 4; + const Vd = 4; + const {interpolationMode: kd, tangentWeightMode: Ud, leftTangent: Gd, leftTangentWeight: zd, rightTangent: Hd, rightTangentWeight: jd} = Pd({}); + const Xd = 26; + function Wd(t, e, i) { + let s = 0; + let n = i; + const r = n; + n += 4; + const {value: o, interpolationMode: a, tangentWeightMode: l, rightTangent: h, rightTangentWeight: c, leftTangent: u, leftTangentWeight: _, easingMethod: d} = e; + t.setFloat32(n, o, !0); + n += 4; + if (a !== kd) { + s |= Nd.INTERPOLATION_MODE; + t.setUint8(n, a); + n += 1; + } + if (l !== Ud) { + s |= Nd.TANGENT_WEIGHT_MODE; + t.setUint8(n, l); + n += 1; + } + if (u !== Gd) { + s |= Nd.LEFT_TANGENT; + t.setFloat32(n, u, !0); + n += 4; + } + if (_ !== zd) { + s |= Nd.LEFT_TANGENT_WEIGHT; + t.setFloat32(n, _, !0); + n += 4; + } + if (h !== Hd) { + s |= Nd.RIGHT_TANGENT; + t.setFloat32(n, h, !0); + n += 4; + } + if (c !== jd) { + s |= Nd.RIGHT_TANGENT_WEIGHT; + t.setFloat32(n, c, !0); + n += 4; + } + s |= d << 8; + t.setUint32(r, s, !0); + return n; + } + function Yd(t, e, i) { + let s = i; + const n = t.getUint32(s, !0); + s += 4; + e.value = t.getFloat32(s, !0); + s += 4; + if (n & Nd.INTERPOLATION_MODE) { + e.interpolationMode = t.getUint8(s); + s += 1; + } + if (n & Nd.TANGENT_WEIGHT_MODE) { + e.tangentWeightMode = t.getUint8(s); + s += 1; + } + if (n & Nd.LEFT_TANGENT) { + e.leftTangent = t.getFloat32(s, !0); + s += 4; + } + if (n & Nd.LEFT_TANGENT_WEIGHT) { + e.leftTangentWeight = t.getFloat32(s, !0); + s += 4; + } + if (n & Nd.RIGHT_TANGENT) { + e.rightTangent = t.getFloat32(s, !0); + s += 4; + } + if (n & Nd.RIGHT_TANGENT_WEIGHT) { + e.rightTangentWeight = t.getFloat32(s, !0); + s += 4; + } + const r = (65280 & n) >> 8; + e.easingMethod = r; + return s; + } + function qd(t, e, i) { + return e + Ei(t - e, i - e); + } + function Kd(t, e, i) { + return e + Ci(t - e, i - e); + } + function Jd(t, e, i, s, n) { + return e + (n - t) * ((s - e) / (i - t)); + } + function Zd(t, e, i, s, n) { + const r = 1 - n; + return r * r * r * t + 3 * r * r * n * e + 3 * r * n * n * i + n * n * n * s; + } + function Qd(t, e, i, s, n) { + const r = 1 - n; + return r * (r * (t + (3 * e - t) * n) + 3 * i * n * n) + s * n * n * n; + } + m.bezier = Qd; + const $d = Math.cos; + const tp = Math.acos; + const ep = Math.max; + const ip = 2 * Math.PI; + const sp = Math.sqrt; + function np(t) { + return t < 0 ? -Math.pow(-t, 1 / 3) : Math.pow(t, 1 / 3); + } + function rp(t, e) { + const i = function(t, e) { + const i = e - 0; + const s = e - t[0]; + const n = 3 * i; + const r = 3 * s; + const o = 3 * (e - t[2]); + const a = 1 / (-i + r - o + (e - 1)); + const l = 1 / 3; + const h = (n - 6 * s + o) * a; + const c = h * l; + const u = (-n + r) * a; + const _ = (3 * u - h * h) * l; + const d = _ * l; + const p = (2 * h * h * h - 9 * h * u + i * a * 27) / 27; + const m = p / 2; + const f = m * m + d * d * d; + let g; + let y; + let b; + let S; + let A; + if (f < 0) { + const t = -_ * l; + const e = sp(t * t * t); + const i = -p / (2 * e); + const s = tp(i < -1 ? -1 : i > 1 ? 1 : i); + const n = 2 * np(e); + b = n * $d(s * l) - c; + S = n * $d((s + ip) * l) - c; + A = n * $d((s + 2 * ip) * l) - c; + return b >= 0 && b <= 1 ? S >= 0 && S <= 1 ? A >= 0 && A <= 1 ? ep(b, S, A) : ep(b, S) : A >= 0 && A <= 1 ? ep(b, A) : b : S >= 0 && S <= 1 ? A >= 0 && A <= 1 ? ep(S, A) : S : A; + } + if (0 === f) { + g = m < 0 ? np(-m) : -np(m); + b = 2 * g - c; + S = -g - c; + return b >= 0 && b <= 1 ? S >= 0 && S <= 1 ? ep(b, S) : b : S; + } + { + const t = sp(f); + g = np(-m + t); + y = np(m + t); + b = g - y - c; + return b; + } + }(t, e); + const s = t[1]; + return ((1 - i) * (s + (t[3] - s) * i) * 3 + i * i) * i; + } + m.bezierByTime = rp; + var op, ap, lp, hp, cp, up, _p, dp, pp, mp, fp; + let gp; + !function(t) { + t[t.SLERP = 0] = "SLERP"; + t[t.CONSTANT = 1] = "CONSTANT"; + }(gp || (gp = t("QuatInterpolationMode", {}))); + let yp = Ul("cc.QuatKeyframeValue")(op = Zl(op = (ap = (up = class { + constructor({value: t, interpolationMode: e, easingMethod: i} = {}) { + Ml(this, "interpolationMode", lp, this); + Ml(this, "value", hp, this); + Ml(this, "easingMethod", cp, this); + this.value = t ? Ui.clone(t) : this.value; + this.interpolationMode = null != e ? e : this.interpolationMode; + this.easingMethod = null != i ? i : this.easingMethod; + } + }, up), lp = Bl(ap.prototype, "interpolationMode", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return gp.SLERP; + } + }), hp = Bl(ap.prototype, "value", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Ui.clone(Ui.IDENTITY); + } + }), cp = Bl(ap.prototype, "easingMethod", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return vd.LINEAR; + } + }), ap)) || op) || op; + function bp(t) { + return new yp(t); + } + let Sp = t("QuatCurve", Ul("cc.QuatCurve")(_p = (dp = (fp = class extends Cl { + constructor(...t) { + super(...t); + Ml(this, "preExtrapolation", pp, this); + Ml(this, "postExtrapolation", mp, this); + } + evaluate(t, e) { + var i; + null !== (i = e) && void 0 !== i || (e = new Ui); + const {_times: s, _values: n, postExtrapolation: r, preExtrapolation: o} = this; + const a = s.length; + if (0 === a) return e; + const l = s[0]; + const h = s[a - 1]; + if (t < l) { + const i = n[0]; + switch (o) { + case wl.LOOP: + t = l + Ei(t - l, h - l); + break; + + case wl.PING_PONG: + t = l + Ci(t - l, h - l); + break; + + case wl.CLAMP: + default: + return Ui.copy(e, i.value); + } + } else if (t > h) { + const i = n[a - 1]; + switch (r) { + case wl.LOOP: + t = l + Ei(t - l, h - l); + break; + + case wl.PING_PONG: + t = l + Ci(t - l, h - l); + break; + + case wl.CLAMP: + default: + return Ui.copy(e, i.value); + } + } + const c = vl(s, t); + if (c >= 0) return Ui.copy(e, n[c].value); + const u = ~c; + ne(0 !== u && u !== a && a > 1); + const _ = u - 1; + const d = s[_]; + const p = n[_]; + const m = s[u]; + const f = n[u]; + ne(m > t && t > d); + const g = (t - d) / (m - d); + switch (p.interpolationMode) { + default: + case gp.CONSTANT: + return Ui.copy(e, p.value); + + case gp.SLERP: + { + const {easingMethod: t} = p; + const i = t === vd.LINEAR ? g : Array.isArray(t) ? rp(t, g) : Cd(t)(g); + return Ui.slerp(e, p.value, f.value, i); + } + } + } + addKeyFrame(t, e) { + const i = new yp(e); + return super.addKeyFrame(t, i); + } + assignSorted(t, e) { + if (void 0 !== e) { + ne(Array.isArray(t)); + this.setKeyframes(t.slice(), e.map((t => bp(t)))); + } else { + const e = Array.from(t); + this.setKeyframes(e.map((([t]) => t)), e.map((([, t]) => bp(t)))); + } + } + [nu](t, e) { + if (!e.toCCON) { + t.writeThis(); + return; + } + const {_times: i, _values: s} = this; + let n = !0; + s.forEach(((t, e, [i]) => { + n && t.interpolationMode !== i.interpolationMode && (n = !1); + })); + const r = i.length; + const o = xp * (n ? 1 : r); + const a = s.reduce(((t, {easingMethod: e}) => t + (Array.isArray(e) ? wp + 4 * Ip : wp)), 0); + let l = 0; + l += Tp + vp + Ep * r + 4 * Cp * r + a + o + 0; + const h = new DataView(new ArrayBuffer(l)); + let c = 0; + let u = 0; + n && (u |= Ap.INTERPOLATION_MODE); + h.setUint32(c, u, !0); + c += Tp; + h.setUint32(c, r, !0); + c += vp; + i.forEach(((t, e) => h.setFloat32(c + Ep * e, t, !0))); + c += Ep * r; + s.forEach((({value: {x: t, y: e, z: i, w: s}}, n) => { + const r = c + 4 * Cp * n; + h.setFloat32(r + 0 * Cp, t, !0); + h.setFloat32(r + 1 * Cp, e, !0); + h.setFloat32(r + 2 * Cp, i, !0); + h.setFloat32(r + 3 * Cp, s, !0); + })); + c += 4 * Cp * r; + s.forEach((({easingMethod: t}, e) => { + if (Array.isArray(t)) { + h.setUint8(c, Rp); + ++c; + h.setFloat32(c + 0 * Ip, t[0], !0); + h.setFloat32(c + 1 * Ip, t[1], !0); + h.setFloat32(c + 2 * Ip, t[2], !0); + h.setFloat32(c + 3 * Ip, t[3], !0); + c += 4 * Ip; + } else { + h.setUint8(c, t); + ++c; + } + })); + const _ = c; + c += o; + let d = _; + s.forEach((({interpolationMode: t}) => { + h.setUint8(d, t); + n || (d += xp); + })); + const p = new Uint8Array(h.buffer); + t.writeProperty("bytes", p); + } + [ru](t, e) { + if (!e.fromCCON) { + t.readThis(); + return; + } + const i = t.readProperty("bytes"); + const s = new DataView(i.buffer, i.byteOffset, i.byteLength); + let n = 0; + const r = s.getUint32(n, !0); + n += Tp; + const o = r & Ap.INTERPOLATION_MODE; + const a = s.getUint32(n, !0); + n += vp; + const l = Array.from({ + length: a + }, ((t, e) => s.getFloat32(n + Ep * e, !0))); + n += Ep * a; + const h = n; + n += 4 * Cp * a; + const c = Array.from({ + length: a + }, ((t, e) => { + const i = h + 4 * Cp * e; + const r = s.getFloat32(i + 0 * Cp, !0); + const o = s.getFloat32(i + 1 * Cp, !0); + const a = s.getFloat32(i + 2 * Cp, !0); + const l = s.getFloat32(i + 3 * Cp, !0); + const c = s.getUint8(n); + ++n; + const u = bp({ + value: { + x: r, + y: o, + z: a, + w: l + } + }); + if (c !== Rp) u.easingMethod = c; else { + u.easingMethod = [ s.getFloat32(n + 0 * Ip, !0), s.getFloat32(n + 1 * Ip, !0), s.getFloat32(n + 2 * Ip, !0), s.getFloat32(n + 3 * Ip, !0) ]; + n += 4 * Ip; + } + return u; + })); + if (o) { + const t = s.getUint8(n); + ++n; + for (let e = 0; e < a; ++e) c[e].interpolationMode = t; + } else { + for (let t = 0; t < a; ++t) { + const e = s.getUint8(n + t); + c[t].interpolationMode = e; + } + n += a; + } + this._times = l; + this._values = c; + } + }, fp), pp = Bl(dp.prototype, "preExtrapolation", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return wl.CLAMP; + } + }), mp = Bl(dp.prototype, "postExtrapolation", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return wl.CLAMP; + } + }), dp)) || _p); + var Ap; + !function(t) { + t[t.INTERPOLATION_MODE = 1] = "INTERPOLATION_MODE"; + }(Ap || (Ap = {})); + const Tp = 1; + const vp = 4; + const Ep = 4; + const Cp = 4; + const xp = 1; + const wp = 1; + const Rp = 255; + const Ip = 4; + var Mp; + let Bp = t("ObjectCurve", Ul("cc.ObjectCurve")(Mp = class extends Cl { + evaluate(t) { + const e = this.searchKeyframe(t); + if (e >= 0) return this._values[e]; + const i = _i(~e - 1, 0, this._values.length - 1); + return this._values[i]; + } + }) || Mp); + class Dp { + constructor() { + this.time = 0; + this.value = 0; + this.inTangent = 0; + this.outTangent = 0; + } + } + si.fastDefine("cc.Keyframe", Dp, { + time: 0, + value: 0, + inTangent: 0, + outTangent: 0 + }); + class Pp { + constructor() { + this.index = void 0; + this.time = void 0; + this.endTime = void 0; + this.coefficient = void 0; + this.index = -1; + this.time = 0; + this.endTime = 0; + this.coefficient = new Float32Array(4); + } + evaluate(t) { + return function(t, e) { + return t * (t * (t * e[0] + e[1]) + e[2]) + e[3]; + }(t - this.time, this.coefficient); + } + } + class Op { + get _internalCurve() { + return this._curve; + } + get keyFrames() { + return Array.from(this._curve.keyframes()).map((([t, e]) => { + const i = new Dp; + i.time = t; + i.value = e.value; + i.inTangent = e.leftTangent; + i.outTangent = e.rightTangent; + return i; + })); + } + set keyFrames(t) { + this._curve.assignSorted(t.map((t => [ t.time, { + interpolationMode: xl.CUBIC, + value: t.value, + leftTangent: t.inTangent, + rightTangent: t.outTangent + } ]))); + } + get preWrapMode() { + return Lp(this._curve.preExtrapolation); + } + set preWrapMode(t) { + this._curve.preExtrapolation = Np(t); + } + get postWrapMode() { + return Lp(this._curve.postExtrapolation); + } + set postWrapMode(t) { + this._curve.postExtrapolation = Np(t); + } + constructor(t = null) { + this.cachedKey = void 0; + if (t instanceof Od) this._curve = t; else { + const e = new Od; + this._curve = e; + e.preExtrapolation = wl.LOOP; + e.postExtrapolation = wl.CLAMP; + t ? e.assignSorted(t.map((t => [ t.time, { + interpolationMode: xl.CUBIC, + value: t.value, + leftTangent: t.inTangent, + rightTangent: t.outTangent + } ]))) : e.assignSorted([ [ 0, { + interpolationMode: xl.CUBIC, + value: 1 + } ], [ 1, { + interpolationMode: xl.CUBIC, + value: 1 + } ] ]); + } + this.cachedKey = new Pp; + } + addKey(t) { + t ? this._curve.addKeyFrame(t.time, { + interpolationMode: xl.CUBIC, + value: t.value, + leftTangent: t.inTangent, + rightTangent: t.outTangent + }) : this._curve.clear(); + } + evaluate_slow(t) { + return this._curve.evaluate(t); + } + evaluate(t) { + const {cachedKey: e, _curve: i} = this; + const s = i.keyFramesCount - 1; + let n = t; + const r = t < 0 ? i.preExtrapolation : i.postExtrapolation; + const o = i.getKeyframeTime(0); + const a = i.getKeyframeTime(s); + switch (r) { + case wl.LOOP: + n = Ei(t - o, a - o) + o; + break; + + case wl.PING_PONG: + n = Ci(t - o, a - o) + o; + break; + + case wl.CLAMP: + default: + n = _i(t, o, a); + } + if (n >= e.time && n < e.endTime) return e.evaluate(n); + const l = this.findIndex(e, n); + const h = Math.min(l + 1, s); + this.calcOptimizedKey(e, l, h); + return e.evaluate(n); + } + calcOptimizedKey(t, e, i) { + const s = this._curve.getKeyframeTime(e); + const n = this._curve.getKeyframeTime(i); + const {value: r, leftTangent: o} = this._curve.getKeyframeValue(e); + const {value: a, rightTangent: l} = this._curve.getKeyframeValue(i); + t.index = e; + t.time = s; + t.endTime = n; + const h = n - s; + const c = a - r; + const u = 1 / (h * h); + const _ = o * h; + const d = l * h; + t.coefficient[0] = (_ + d - c - c) * u / h; + t.coefficient[1] = (c + c + c - _ - _ - d) * u; + t.coefficient[2] = o; + t.coefficient[3] = r; + } + findIndex(t, e) { + const {_curve: i} = this; + const s = i.keyFramesCount; + const n = t.index; + if (-1 !== n) { + if (e > i.getKeyframeTime(n)) for (let t = 0; t < 3; t++) { + const r = n + t; + if (r + 1 < s && i.getKeyframeTime(r + 1) > e) return r; + } else for (let t = 0; t < 3; t++) { + const s = n - t; + if (s >= 0 && i.getKeyframeTime(s - 1) <= e) return s - 1; + } + } + let r = 0; + let o = s; + let a; + for (;o - r > 1; ) { + a = Math.floor((r + o) / 2); + i.getKeyframeTime(a) >= e ? o = a : r = a; + } + return r; + } + } + Op.defaultKF = [ { + time: 0, + value: 1, + inTangent: 0, + outTangent: 0 + }, { + time: 1, + value: 1, + inTangent: 0, + outTangent: 0 + } ]; + si.fastDefine("cc.AnimationCurve", Op, { + _curve: null + }); + function Np(t) { + switch (t) { + default: + case Sl.Default: + case Sl.Normal: + case Sl.Clamp: + return wl.CLAMP; + + case Sl.PingPong: + return wl.PING_PONG; + + case Sl.Loop: + return wl.LOOP; + } + } + function Lp(t) { + switch (t) { + default: + case wl.LINEAR: + case wl.CLAMP: + return Sl.Clamp; + + case wl.PING_PONG: + return Sl.PingPong; + + case wl.LOOP: + return Sl.Loop; + } + } + function Fp() { + const t = new Od; + t.assignSorted([ [ 0, { + interpolationMode: xl.CUBIC, + value: 1 + } ], [ 1, { + interpolationMode: xl.CUBIC, + value: 1 + } ] ]); + return t; + } + let Vp; + !function(t) { + t[t.LINEAR = 0] = "LINEAR"; + t[t.BEZIER = 1] = "BEZIER"; + t[t.CATMULL_ROM = 2] = "CATMULL_ROM"; + }(Vp || (Vp = {})); + const kp = 4294967295; + const Up = new Pi; + const Gp = new Pi; + const zp = new Pi; + const Hp = new Pi; + class jp { + constructor(t = Vp.CATMULL_ROM, e = []) { + this._type = void 0; + this._mode = Vp.CATMULL_ROM; + this._knots = []; + this._type = sa.SHAPE_SPLINE; + this._mode = t; + for (let t = 0; t < e.length; t++) this._knots[t] = new Pi(e[t]); + } + static create(t, e = []) { + return new jp(t, e); + } + static clone(t) { + return new jp(t.mode, t.knots); + } + static copy(t, e) { + t._mode = e.mode; + t._knots.length = 0; + const i = e.knots; + const s = i.length; + for (let e = 0; e < s; e++) t._knots[e] = new Pi(i[e]); + return t; + } + get type() { + return this._type; + } + get mode() { + return this._mode; + } + get knots() { + return this._knots; + } + setModeAndKnots(t, e) { + this._mode = t; + this._knots.length = 0; + for (let t = 0; t < e.length; t++) this._knots[t] = new Pi(e[t]); + } + clearKnots() { + this._knots.length = 0; + } + getKnotCount() { + return this._knots.length; + } + addKnot(t) { + this._knots.push(new Pi(t)); + } + insertKnot(t, e) { + const i = new Pi(e); + t >= this._knots.length ? this._knots.push(i) : this._knots.splice(t, 0, i); + } + removeKnot(t) { + ne(t >= 0 && t < this._knots.length, "Spline: invalid index"); + this._knots.splice(t, 1); + } + setKnot(t, e) { + ne(t >= 0 && t < this._knots.length, "Spline: invalid index"); + this._knots[t].set(e); + } + getKnot(t) { + ne(t >= 0 && t < this._knots.length, "Spline: invalid index"); + return this._knots[t]; + } + getPoint(t, e = 4294967295) { + t = _i(t, 0, 1); + const i = this.getSegments(); + if (0 == i) return new Pi(0, 0, 0); + if (e == kp) { + const s = 1 / i; + e = Math.floor(t / s); + t = t % s / s; + } + if (e >= i) return new Pi(this._knots[this._knots.length - 1]); + switch (this._mode) { + case Vp.LINEAR: + return jp.calcLinear(this._knots[e], this._knots[e + 1], t); + + case Vp.BEZIER: + return jp.calcBezier(this._knots[4 * e], this._knots[4 * e + 1], this._knots[4 * e + 2], this._knots[4 * e + 3], t); + + case Vp.CATMULL_ROM: + { + const i = e > 0 ? this._knots[e - 1] : this._knots[e]; + const s = e + 2 < this._knots.length ? this._knots[e + 2] : this._knots[e + 1]; + return jp.calcCatmullRom(i, this._knots[e], this._knots[e + 1], s, t); + } + + default: + return new Pi(0, 0, 0); + } + } + getPoints(t, e = 4294967295) { + if (0 == t) return []; + if (1 == t) { + return [ this.getPoint(0, e) ]; + } + const i = []; + const s = 1 / (t - 1); + for (let n = 0; n < t; n++) { + const t = n * s; + const r = this.getPoint(t, e); + i.push(r); + } + return i; + } + getSegments() { + const t = this._knots.length; + switch (this._mode) { + case Vp.LINEAR: + case Vp.CATMULL_ROM: + if (t < 2) { + N(14300); + return 0; + } + return t - 1; + + case Vp.BEZIER: + if (t < 4 || t % 4 != 0) { + N(14301); + return 0; + } + return t / 4; + + default: + ne(!1, "Spline error: invalid mode"); + } + } + static calcLinear(t, e, i) { + const s = new Pi; + Pi.multiplyScalar(Up, t, 1 - i); + Pi.multiplyScalar(Gp, e, i); + Pi.add(s, Up, Gp); + return s; + } + static calcBezier(t, e, i, s, n) { + const r = new Pi; + const o = 1 - n; + Pi.multiplyScalar(Up, t, o * o * o); + Pi.multiplyScalar(Gp, e, 3 * n * o * o); + Pi.multiplyScalar(zp, i, 3 * n * n * o); + Pi.multiplyScalar(Hp, s, n * n * n); + Pi.add(Up, Up, Gp); + Pi.add(zp, zp, Hp); + Pi.add(r, Up, zp); + return r; + } + static calcCatmullRom(t, e, i, s, n) { + const r = new Pi; + const o = n * n; + const a = o * n; + Pi.multiplyScalar(Up, t, -.5 * a + o - .5 * n); + Pi.multiplyScalar(Gp, e, 1.5 * a - 2.5 * o + 1); + Pi.multiplyScalar(zp, i, -1.5 * a + 2 * o + .5 * n); + Pi.multiplyScalar(Hp, s, .5 * a - .5 * o); + Pi.add(Up, Up, Gp); + Pi.add(zp, zp, Hp); + Pi.add(r, Up, zp); + return r; + } + } + W(Za, "intersect", [ { + name: "ray_aabb", + newName: "rayAABB" + }, { + name: "ray_plane", + newName: "rayPlane" + }, { + name: "ray_triangle", + newName: "rayTriangle" + }, { + name: "ray_sphere", + newName: "raySphere" + }, { + name: "ray_obb", + newName: "rayOBB" + }, { + name: "ray_capsule", + newName: "rayCapsule" + }, { + name: "ray_subMesh", + newName: "raySubMesh" + }, { + name: "ray_mesh", + newName: "rayMesh" + }, { + name: "ray_model", + newName: "rayModel" + }, { + name: "line_plane", + newName: "linePlane" + }, { + name: "line_triangle", + newName: "lineTriangle" + }, { + name: "line_aabb", + newName: "lineAABB" + }, { + name: "line_obb", + newName: "lineOBB" + }, { + name: "line_sphere", + newName: "lineSphere" + }, { + name: "aabb_aabb", + newName: "aabbWithAABB" + }, { + name: "aabb_obb", + newName: "aabbWithOBB" + }, { + name: "aabb_plane", + newName: "aabbPlane" + }, { + name: "aabb_frustum", + newName: "aabbFrustum" + }, { + name: "aabbFrustum_accurate", + newName: "aabbFrustumAccurate" + }, { + name: "obb_point", + newName: "obbPoint" + }, { + name: "obb_plane", + newName: "obbPlane" + }, { + name: "obb_frustum", + newName: "obbFrustum" + }, { + name: "obbFrustum_accurate", + newName: "obbFrustumAccurate" + }, { + name: "obb_obb", + newName: "obbWithOBB" + }, { + name: "obb_capsule", + newName: "obbCapsule" + }, { + name: "sphere_plane", + newName: "spherePlane" + }, { + name: "sphere_frustum", + newName: "sphereFrustum" + }, { + name: "sphereFrustum_accurate", + newName: "sphereFrustumAccurate" + }, { + name: "sphere_sphere", + newName: "sphereWithSphere" + }, { + name: "sphere_aabb", + newName: "sphereAABB" + }, { + name: "sphere_obb", + newName: "sphereOBB" + }, { + name: "sphere_capsule", + newName: "sphereCapsule" + }, { + name: "capsule_capsule", + newName: "capsuleWithCapsule" + } ]); + function Xp(t, e) { + console.warn(`${t} is deprecated, please use ${e} instead.`); + } + var Wp = Object.freeze({ + __proto__: null, + distance: ia, + enums: sa, + intersect: Za, + Line: na, + Plane: il, + Ray: ra, + Triangle: _a, + Sphere: ua, + AABB: hl, + OBB: dl, + Capsule: pl, + Frustum: bl, + Keyframe: Dp, + AnimationCurve: Op, + get SplineMode() { + return Vp; + }, + Spline: jp, + get ERaycastMode() { + return da; + }, + line: class extends na { + constructor() { + super(); + Xp("line", "Line"); + } + }, + plane: class extends il { + constructor() { + super(); + Xp("plane", "Plane"); + } + }, + ray: class extends ra { + constructor() { + super(); + Xp("ray", "Ray"); + } + }, + triangle: class extends _a { + constructor() { + super(); + Xp("triangle", "Triangle"); + } + }, + sphere: class extends ua { + constructor() { + super(); + Xp("sphere", "Sphere"); + } + }, + aabb: class extends hl { + constructor() { + super(); + Xp("aabb", "AABB"); + } + }, + obb: class extends dl { + constructor() { + super(); + Xp("obb", "OBB"); + } + }, + capsule: class extends pl { + constructor() { + super(); + Xp("capsule", "Capsule"); + } + }, + frustum: class extends bl { + constructor() { + super(); + Xp("frustum", "Frustum"); + } + } + }); + t("geometry", Wp); + const Yp = t("EffectAsset", jsb.EffectAsset); + m.EffectAsset = Yp; + Yp.prototype._ctor = function() { + jsb.Asset.prototype._ctor.apply(this, arguments); + this.hideInEditor = !1; + }; + const qp = Yp.prototype; + Yl(qp, "techniques"); + Yl(qp, "shaders"); + Yl(qp, "combinations"); + Kl(qp, "hideInEditor"); + Yl(qp, "hideInEditor"); + Ul("cc.EffectAsset")(Yp); + const Kp = 1024; + let Jp; + !function(t) { + t[t.RGB565 = bs.R5G6B5] = "RGB565"; + t[t.RGB5A1 = bs.RGB5A1] = "RGB5A1"; + t[t.RGBA4444 = bs.RGBA4] = "RGBA4444"; + t[t.RGB888 = bs.RGB8] = "RGB888"; + t[t.RGB32F = bs.RGB32F] = "RGB32F"; + t[t.RGBA8888 = bs.RGBA8] = "RGBA8888"; + t[t.RGBA32F = bs.RGBA32F] = "RGBA32F"; + t[t.A8 = bs.A8] = "A8"; + t[t.I8 = bs.L8] = "I8"; + t[t.AI8 = bs.LA8] = "AI8"; + t[t.RGB_PVRTC_2BPPV1 = bs.PVRTC_RGB2] = "RGB_PVRTC_2BPPV1"; + t[t.RGBA_PVRTC_2BPPV1 = bs.PVRTC_RGBA2] = "RGBA_PVRTC_2BPPV1"; + t[t.RGB_A_PVRTC_2BPPV1 = Kp] = "RGB_A_PVRTC_2BPPV1"; + t[t.RGB_PVRTC_4BPPV1 = bs.PVRTC_RGB4] = "RGB_PVRTC_4BPPV1"; + t[t.RGBA_PVRTC_4BPPV1 = bs.PVRTC_RGBA4] = "RGBA_PVRTC_4BPPV1"; + t[t.RGB_A_PVRTC_4BPPV1 = 1025] = "RGB_A_PVRTC_4BPPV1"; + t[t.RGB_ETC1 = bs.ETC_RGB8] = "RGB_ETC1"; + t[t.RGBA_ETC1 = 1026] = "RGBA_ETC1"; + t[t.RGB_ETC2 = bs.ETC2_RGB8] = "RGB_ETC2"; + t[t.RGBA_ETC2 = bs.ETC2_RGBA8] = "RGBA_ETC2"; + t[t.RGBA_ASTC_4x4 = bs.ASTC_RGBA_4X4] = "RGBA_ASTC_4x4"; + t[t.RGBA_ASTC_5x4 = bs.ASTC_RGBA_5X4] = "RGBA_ASTC_5x4"; + t[t.RGBA_ASTC_5x5 = bs.ASTC_RGBA_5X5] = "RGBA_ASTC_5x5"; + t[t.RGBA_ASTC_6x5 = bs.ASTC_RGBA_6X5] = "RGBA_ASTC_6x5"; + t[t.RGBA_ASTC_6x6 = bs.ASTC_RGBA_6X6] = "RGBA_ASTC_6x6"; + t[t.RGBA_ASTC_8x5 = bs.ASTC_RGBA_8X5] = "RGBA_ASTC_8x5"; + t[t.RGBA_ASTC_8x6 = bs.ASTC_RGBA_8X6] = "RGBA_ASTC_8x6"; + t[t.RGBA_ASTC_8x8 = bs.ASTC_RGBA_8X8] = "RGBA_ASTC_8x8"; + t[t.RGBA_ASTC_10x5 = bs.ASTC_RGBA_10X5] = "RGBA_ASTC_10x5"; + t[t.RGBA_ASTC_10x6 = bs.ASTC_RGBA_10X6] = "RGBA_ASTC_10x6"; + t[t.RGBA_ASTC_10x8 = bs.ASTC_RGBA_10X8] = "RGBA_ASTC_10x8"; + t[t.RGBA_ASTC_10x10 = bs.ASTC_RGBA_10X10] = "RGBA_ASTC_10x10"; + t[t.RGBA_ASTC_12x10 = bs.ASTC_RGBA_12X10] = "RGBA_ASTC_12x10"; + t[t.RGBA_ASTC_12x12 = bs.ASTC_RGBA_12X12] = "RGBA_ASTC_12x12"; + }(Jp || (Jp = {})); + let Zp; + !function(t) { + t[t.REPEAT = Ps.WRAP] = "REPEAT"; + t[t.CLAMP_TO_EDGE = Ps.CLAMP] = "CLAMP_TO_EDGE"; + t[t.MIRRORED_REPEAT = Ps.MIRROR] = "MIRRORED_REPEAT"; + t[t.CLAMP_TO_BORDER = Ps.BORDER] = "CLAMP_TO_BORDER"; + }(Zp || (Zp = {})); + let Qp; + !function(t) { + t[t.NONE = Ds.NONE] = "NONE"; + t[t.LINEAR = Ds.LINEAR] = "LINEAR"; + t[t.NEAREST = Ds.POINT] = "NEAREST"; + }(Qp || (Qp = {})); + const $p = jsb.TextureBase.prototype; + $p._serialize = function(t) { + return EDITOR || TEST ? `${this._minFilter},${this._magFilter},${this._wrapS},${this._wrapT},${this._mipFilter},${this._anisotropy}` : ""; + }; + $p._deserialize = function(t, e) { + const i = t.split(","); + i.unshift(""); + if (i.length >= 5) { + this.setFilters(parseInt(i[1]), parseInt(i[2])); + this.setWrapMode(parseInt(i[3]), parseInt(i[4])); + } + if (i.length >= 7) { + this.setMipFilter(parseInt(i[5])); + this.setAnisotropy(parseInt(i[6])); + } + }; + $p._getGFXDevice = function() { + return zo.gfxDevice; + }; + $p._getGFXFormat = function() { + return this._getGFXPixelFormat(this.format); + }; + $p._setGFXFormat = function(t) { + this.format = void 0 === t ? Jp.RGBA8888 : t; + }; + $p._getGFXPixelFormat = function(t) { + t === Jp.RGBA_ETC1 ? t = Jp.RGB_ETC1 : t === Jp.RGB_A_PVRTC_4BPPV1 ? t = Jp.RGB_PVRTC_4BPPV1 : t === Jp.RGB_A_PVRTC_2BPPV1 && (t = Jp.RGB_PVRTC_2BPPV1); + return t; + }; + $p.createNode = null; + const tm = jsb.TextureBase; + tm.Filter = Qp; + tm.PixelFormat = Jp; + tm.WrapMode = Zp; + $p._ctor = function() { + jsb.Asset.prototype._ctor.apply(this, arguments); + this._gfxSampler = null; + this._samplerInfo = null; + this._textureHash = 0; + this._registerGFXSamplerUpdatedListener(); + }; + const em = $p.getGFXSampler; + $p.getGFXSampler = function() { + this._gfxSampler || (this._gfxSampler = em.call(this)); + return this._gfxSampler; + }; + const im = $p.getHash; + $p.getHash = function() { + 0 === this._textureHash && (this._textureHash = im.call(this)); + return this._textureHash; + }; + const sm = $p.getSamplerInfo; + $p.getSamplerInfo = function() { + this._samplerInfo || (this._samplerInfo = sm.call(this)); + return this._samplerInfo; + }; + const nm = $p.destroy; + $p.destroy = function() { + var t; + (null === (t = m.director.root) || void 0 === t ? void 0 : t.batcher2D) && m.director.root.batcher2D._releaseDescriptorSetCache(this.getGFXTexture(), this.getGFXSampler()); + return nm.call(this); + }; + $p._onGFXSamplerUpdated = function(t, e) { + this._gfxSampler = t; + this._samplerInfo = e; + }; + m.TextureBase = jsb.TextureBase; + const rm = tm.prototype; + Yl(rm, "_format"); + Yl(rm, "_minFilter"); + Yl(rm, "_magFilter"); + Yl(rm, "_mipFilter"); + Yl(rm, "_wrapS"); + Yl(rm, "_wrapT"); + Yl(rm, "_wrapR"); + Yl(rm, "_anisotropy"); + Ul("cc.TextureBase")(tm); + const om = jsb.Material.prototype; + function am(t, e, i, s, n) { + null != n ? t.call(e, i, s, n) : t.call(e, i, s); + } + var lm; + !function(t) { + t[t.VEC2 = 0] = "VEC2"; + t[t.VEC3 = 1] = "VEC3"; + t[t.VEC4 = 2] = "VEC4"; + t[t.QUATERNION = 3] = "QUATERNION"; + t[t.MAT3 = 4] = "MAT3"; + t[t.MAT4 = 5] = "MAT4"; + t[t.SIZE = 6] = "SIZE"; + t[t.RECT = 7] = "RECT"; + t[t.COLOR = 8] = "COLOR"; + }(lm || (lm = {})); + om.setProperty = function(t, e, i) { + if (Array.isArray(e)) { + const s = e[0]; + "number" == typeof s ? Number.isInteger(s) ? am(this.setPropertyInt32Array, this, t, e, i) : am(this.setPropertyFloat32Array, this, t, e, i) : s instanceof Qi ? am(this.setPropertyVec2Array, this, t, e, i) : s instanceof Pi ? am(this.setPropertyVec3Array, this, t, e, i) : s instanceof is ? am(this.setPropertyVec4Array, this, t, e, i) : s instanceof Bi ? am(this.setPropertyColorArray, this, t, e, i) : s instanceof Fi ? am(this.setPropertyMat3Array, this, t, e, i) : s instanceof qi ? am(this.setPropertyMat4Array, this, t, e, i) : s instanceof Ui ? am(this.setPropertyQuatArray, this, t, e, i) : s instanceof tm ? am(this.setPropertyTextureBaseArray, this, t, e, i) : s instanceof Yr ? am(this.setPropertyGFXTextureArray, this, t, e, i) : m.error(`Material.setProperty Unknown type: ${e}`); + } else "number" == typeof e ? Number.isInteger(e) ? am(this.setPropertyInt32, this, t, e, i) : am(this.setPropertyFloat32, this, t, e, i) : e instanceof Qi ? am(this.setPropertyVec2, this, t, e, i) : e instanceof Pi ? am(this.setPropertyVec3, this, t, e, i) : e instanceof is ? am(this.setPropertyVec4, this, t, e, i) : e instanceof Bi ? am(this.setPropertyColor, this, t, e, i) : e instanceof Fi ? am(this.setPropertyMat3, this, t, e, i) : e instanceof qi ? am(this.setPropertyMat4, this, t, e, i) : e instanceof Ui ? am(this.setPropertyQuat, this, t, e, i) : e instanceof tm ? am(this.setPropertyTextureBase, this, t, e, i) : e instanceof Yr ? am(this.setPropertyGFXTexture, this, t, e, i) : null === e ? i ? this.setPropertyNull(t, i) : this.setPropertyNull(t) : m.error(`Material.setProperty Unknown type: ${e}`); + }; + om.getProperty = function(t, e) { + let i; + i = void 0 !== e ? this._getProperty(t, e) : this._getProperty(t); + if (Array.isArray(i)) { + const t = i[0]; + const e = []; + if (t instanceof jsb.Vec2 || t.type === lm.VEC2) for (let t = 0, s = i.length; t < s; ++t) { + const s = i[t]; + e.push(new Qi(s.x, s.y)); + } else if (t.type === lm.VEC3) for (let t = 0, s = i.length; t < s; ++t) { + const s = i[t]; + e.push(new Pi(s.x, s.y, s.z)); + } else if (t.type === lm.VEC4) for (let t = 0, s = i.length; t < s; ++t) { + const s = i[t]; + e.push(new is(s.x, s.y, s.z, s.w)); + } else if (t instanceof jsb.Color) for (let t = 0, s = i.length; t < s; ++t) { + const s = i[t]; + e.push(new Bi(s.r, s.g, s.b, s.a)); + } else if (t.type === lm.MAT3) for (let t = 0, s = i.length; t < s; ++t) { + const s = i[t]; + e.push(new Fi(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8])); + } else if (t.type === lm.MAT4) for (let t = 0, s = i.length; t < s; ++t) { + const s = i[t]; + e.push(new qi(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8], s[9], s[10], s[11], s[12], s[13], s[14], s[15])); + } else if (t.type === lm.QUATERNION) for (let t = 0, s = i.length; t < s; ++t) { + const s = i[t]; + e.push(new Ui(s.x, s.y, s.z, s.w)); + } + return e || i; + } + let s; + const n = i; + i instanceof jsb.Vec2 || i.type === lm.VEC2 ? s = new Pi(n.x, n.y) : i.type === lm.VEC3 ? s = new Pi(n.x, n.y, n.z) : i.type === lm.VEC4 ? s = new is(n.x, n.y, n.z, n.w) : i instanceof jsb.Color ? s = new Bi(n.r, n.g, n.b, n.a) : i.type === lm.MAT3 ? s = new Fi(n[0], n[1], n[2], n[3], n[4], n[5], n[6], n[7], n[8]) : i.type === lm.MAT4 ? s = new qi(n[0], n[1], n[2], n[3], n[4], n[5], n[6], n[7], n[8], n[9], n[10], n[11], n[12], n[13], n[14], n[15]) : i.type === lm.QUATERNION && (s = new Ui(n.x, n.y, n.z, n.w)); + return s || i; + }; + const hm = t("Material", jsb.Material); + m.Material = hm; + const cm = hm.prototype; + cm._ctor = function() { + jsb.Asset.prototype._ctor.apply(this, arguments); + this._props = []; + this._passes = []; + this._registerPassesUpdatedListener(); + this._isCtorCalled = !0; + }; + const um = cm.onLoaded; + cm.onLoaded = function() { + this._propsInternal = this._props; + um.call(this); + }; + cm._onPassesUpdated = function() { + this._passes = this.getPasses(); + }; + Object.defineProperty(cm, "passes", { + enumerable: !0, + configurable: !0, + get() { + if (!this._isCtorCalled) { + this._ctor(); + this._passes = this.getPasses(); + } + return this._passes; + } + }); + const _m = hm.prototype; + Th(Yp)(_m, "_effectAsset"); + Yl(_m, "_techIdx"); + Yl(_m, "_defines"); + Yl(_m, "_states"); + Yl(_m, "_props"); + Ul("cc.Material")(hm); + const dm = (() => { + const t = new Map; + let e = 0; + return i => { + if ("number" == typeof i) return i; + if (!t.has(i)) { + t.set(i, 1 << e); + e++; + } + return t.get(i); + }; + })(); + const pm = { + NONE: 0, + IGNORE_RAYCAST: 1 << 20, + GIZMOS: 1 << 21, + EDITOR: 1 << 22, + UI_3D: 1 << 23, + SCENE_GIZMO: 1 << 24, + UI_2D: 1 << 25, + PROFILER: 1 << 28, + DEFAULT: 1 << 30, + ALL: 4294967295 + }; + class mm { + static init() { + const t = de.querySettings(_e.Category.ENGINE, "customLayers"); + if (t) for (let e = 0; e < t.length; e++) { + const i = t[e]; + mm.addLayer(i.name, i.bit); + } + } + static makeMaskInclude(t) { + let e = 0; + for (const i of t) e |= i; + return e; + } + static makeMaskExclude(t) { + return ~mm.makeMaskInclude(t); + } + static addLayer(t, e) { + if (void 0 === e) { + console.warn("bitNum can't be undefined"); + return; + } + if (e > 19 || e < 0) { + console.warn("maximum layers reached."); + return; + } + const i = 1 << e; + ne(!mm.Enum[t], G(2104, t)); + mm.Enum[t] = i; + ee.value(mm.Enum, String(i), t); + mm.BitMask[t] = i; + ee.value(mm.BitMask, String(i), t); + } + static deleteLayer(t) { + if (t > 19 || t < 0) { + console.warn("do not change buildin layers."); + return; + } + const e = 1 << t; + delete mm.Enum[mm.Enum[e]]; + delete mm.Enum[e]; + delete mm.BitMask[mm.BitMask[e]]; + delete mm.BitMask[e]; + } + static nameToLayer(t) { + if (void 0 === t) { + console.warn("name can't be undefined"); + return -1; + } + return r(mm.Enum[t]); + } + static layerToName(t) { + if (t > 31 || t < 0) { + console.warn("Unable to access unknown layer."); + return ""; + } + return mm.Enum[1 << t]; + } + } + t("Layers", mm); + mm.Enum = oe(pm); + mm.BitMask = ie({ + ...pm + }); + m.Layers = mm; + let fm; + !function(t) { + t[t.DEFAULT = 100] = "DEFAULT"; + t[t.UI = 200] = "UI"; + }(fm || (fm = {})); + m.RenderPassStage = fm; + let gm; + !function(t) { + t[t.MIN = 0] = "MIN"; + t[t.MAX = 255] = "MAX"; + t[t.DEFAULT = 128] = "DEFAULT"; + }(gm || (gm = {})); + const ym = { + bindings: [], + layouts: {} + }; + const bm = { + bindings: [], + layouts: {} + }; + let Sm; + !function(t) { + t[t.UBO_GLOBAL = 0] = "UBO_GLOBAL"; + t[t.UBO_CAMERA = 1] = "UBO_CAMERA"; + t[t.UBO_SHADOW = 2] = "UBO_SHADOW"; + t[t.UBO_CSM = 3] = "UBO_CSM"; + t[t.SAMPLER_SHADOWMAP = 4] = "SAMPLER_SHADOWMAP"; + t[t.SAMPLER_ENVIRONMENT = 5] = "SAMPLER_ENVIRONMENT"; + t[t.SAMPLER_SPOT_SHADOW_MAP = 6] = "SAMPLER_SPOT_SHADOW_MAP"; + t[t.SAMPLER_DIFFUSEMAP = 7] = "SAMPLER_DIFFUSEMAP"; + t[t.COUNT = 8] = "COUNT"; + }(Sm || (Sm = {})); + const Am = Sm.SAMPLER_SHADOWMAP; + const Tm = Sm.COUNT - Am; + let vm; + !function(t) { + t[t.UBO_LOCAL = 0] = "UBO_LOCAL"; + t[t.UBO_FORWARD_LIGHTS = 1] = "UBO_FORWARD_LIGHTS"; + t[t.UBO_SKINNING_ANIMATION = 2] = "UBO_SKINNING_ANIMATION"; + t[t.UBO_SKINNING_TEXTURE = 3] = "UBO_SKINNING_TEXTURE"; + t[t.UBO_MORPH = 4] = "UBO_MORPH"; + t[t.UBO_UI_LOCAL = 5] = "UBO_UI_LOCAL"; + t[t.SAMPLER_JOINTS = 6] = "SAMPLER_JOINTS"; + t[t.SAMPLER_MORPH_POSITION = 7] = "SAMPLER_MORPH_POSITION"; + t[t.SAMPLER_MORPH_NORMAL = 8] = "SAMPLER_MORPH_NORMAL"; + t[t.SAMPLER_MORPH_TANGENT = 9] = "SAMPLER_MORPH_TANGENT"; + t[t.SAMPLER_LIGHTMAP = 10] = "SAMPLER_LIGHTMAP"; + t[t.SAMPLER_SPRITE = 11] = "SAMPLER_SPRITE"; + t[t.SAMPLER_REFLECTION = 12] = "SAMPLER_REFLECTION"; + t[t.STORAGE_REFLECTION = 13] = "STORAGE_REFLECTION"; + t[t.COUNT = 14] = "COUNT"; + }(vm || (vm = {})); + const Em = vm.SAMPLER_JOINTS; + const Cm = vm.STORAGE_REFLECTION - Em; + const xm = vm.COUNT - Em - Cm; + let wm; + !function(t) { + t[t.GLOBAL = 0] = "GLOBAL"; + t[t.MATERIAL = 1] = "MATERIAL"; + t[t.LOCAL = 2] = "LOCAL"; + }(wm || (wm = {})); + const Rm = new yn([ Am, 0, Em ], [ Tm, 0, Cm ], [ 0, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, xm ], [ 0, 0, 0 ], [ 0, 2, 1 ]); + class Im {} + Im.TIME_OFFSET = 0; + Im.SCREEN_SIZE_OFFSET = Im.TIME_OFFSET + 4; + Im.NATIVE_SIZE_OFFSET = Im.SCREEN_SIZE_OFFSET + 4; + Im.DEBUG_VIEW_MODE_OFFSET = Im.NATIVE_SIZE_OFFSET + 4; + Im.DEBUG_VIEW_COMPOSITE_PACK_1_OFFSET = Im.DEBUG_VIEW_MODE_OFFSET + 4; + Im.DEBUG_VIEW_COMPOSITE_PACK_2_OFFSET = Im.DEBUG_VIEW_COMPOSITE_PACK_1_OFFSET + 4; + Im.DEBUG_VIEW_COMPOSITE_PACK_3_OFFSET = Im.DEBUG_VIEW_COMPOSITE_PACK_2_OFFSET + 4; + Im.COUNT = Im.DEBUG_VIEW_COMPOSITE_PACK_3_OFFSET + 4; + Im.SIZE = 4 * Im.COUNT; + Im.NAME = "CCGlobal"; + Im.BINDING = Sm.UBO_GLOBAL; + Im.DESCRIPTOR = new Jn(Im.BINDING, Zs.UNIFORM_BUFFER, 1, ks.ALL); + Im.LAYOUT = new Mn(wm.GLOBAL, Im.BINDING, Im.NAME, [ new In("cc_time", As.FLOAT4, 1), new In("cc_screenSize", As.FLOAT4, 1), new In("cc_nativeSize", As.FLOAT4, 1), new In("cc_debug_view_mode", As.FLOAT, 4), new In("cc_debug_view_composite_pack_1", As.FLOAT, 4), new In("cc_debug_view_composite_pack_2", As.FLOAT, 4), new In("cc_debug_view_composite_pack_3", As.FLOAT, 4) ], 1); + ym.layouts[Im.NAME] = Im.LAYOUT; + ym.bindings[Im.BINDING] = Im.DESCRIPTOR; + class Mm {} + Mm.MAT_VIEW_OFFSET = 0; + Mm.MAT_VIEW_INV_OFFSET = Mm.MAT_VIEW_OFFSET + 16; + Mm.MAT_PROJ_OFFSET = Mm.MAT_VIEW_INV_OFFSET + 16; + Mm.MAT_PROJ_INV_OFFSET = Mm.MAT_PROJ_OFFSET + 16; + Mm.MAT_VIEW_PROJ_OFFSET = Mm.MAT_PROJ_INV_OFFSET + 16; + Mm.MAT_VIEW_PROJ_INV_OFFSET = Mm.MAT_VIEW_PROJ_OFFSET + 16; + Mm.CAMERA_POS_OFFSET = Mm.MAT_VIEW_PROJ_INV_OFFSET + 16; + Mm.SURFACE_TRANSFORM_OFFSET = Mm.CAMERA_POS_OFFSET + 4; + Mm.SCREEN_SCALE_OFFSET = Mm.SURFACE_TRANSFORM_OFFSET + 4; + Mm.EXPOSURE_OFFSET = Mm.SCREEN_SCALE_OFFSET + 4; + Mm.MAIN_LIT_DIR_OFFSET = Mm.EXPOSURE_OFFSET + 4; + Mm.MAIN_LIT_COLOR_OFFSET = Mm.MAIN_LIT_DIR_OFFSET + 4; + Mm.AMBIENT_SKY_OFFSET = Mm.MAIN_LIT_COLOR_OFFSET + 4; + Mm.AMBIENT_GROUND_OFFSET = Mm.AMBIENT_SKY_OFFSET + 4; + Mm.GLOBAL_FOG_COLOR_OFFSET = Mm.AMBIENT_GROUND_OFFSET + 4; + Mm.GLOBAL_FOG_BASE_OFFSET = Mm.GLOBAL_FOG_COLOR_OFFSET + 4; + Mm.GLOBAL_FOG_ADD_OFFSET = Mm.GLOBAL_FOG_BASE_OFFSET + 4; + Mm.NEAR_FAR_OFFSET = Mm.GLOBAL_FOG_ADD_OFFSET + 4; + Mm.VIEW_PORT_OFFSET = Mm.NEAR_FAR_OFFSET + 4; + Mm.COUNT = Mm.VIEW_PORT_OFFSET + 4; + Mm.SIZE = 4 * Mm.COUNT; + Mm.NAME = "CCCamera"; + Mm.BINDING = Sm.UBO_CAMERA; + Mm.DESCRIPTOR = new Jn(Mm.BINDING, Zs.UNIFORM_BUFFER, 1, ks.ALL); + Mm.LAYOUT = new Mn(wm.GLOBAL, Mm.BINDING, Mm.NAME, [ new In("cc_matView", As.MAT4, 1), new In("cc_matViewInv", As.MAT4, 1), new In("cc_matProj", As.MAT4, 1), new In("cc_matProjInv", As.MAT4, 1), new In("cc_matViewProj", As.MAT4, 1), new In("cc_matViewProjInv", As.MAT4, 1), new In("cc_cameraPos", As.FLOAT4, 1), new In("cc_surfaceTransform", As.FLOAT4, 1), new In("cc_screenScale", As.FLOAT4, 1), new In("cc_exposure", As.FLOAT4, 1), new In("cc_mainLitDir", As.FLOAT4, 1), new In("cc_mainLitColor", As.FLOAT4, 1), new In("cc_ambientSky", As.FLOAT4, 1), new In("cc_ambientGround", As.FLOAT4, 1), new In("cc_fogColor", As.FLOAT4, 1), new In("cc_fogBase", As.FLOAT4, 1), new In("cc_fogAdd", As.FLOAT4, 1), new In("cc_nearFar", As.FLOAT4, 1), new In("cc_viewPort", As.FLOAT4, 1) ], 1); + ym.layouts[Mm.NAME] = Mm.LAYOUT; + ym.bindings[Mm.BINDING] = Mm.DESCRIPTOR; + class Bm {} + Bm.MAT_LIGHT_VIEW_OFFSET = 0; + Bm.MAT_LIGHT_VIEW_PROJ_OFFSET = Bm.MAT_LIGHT_VIEW_OFFSET + 16; + Bm.SHADOW_INV_PROJ_DEPTH_INFO_OFFSET = Bm.MAT_LIGHT_VIEW_PROJ_OFFSET + 16; + Bm.SHADOW_PROJ_DEPTH_INFO_OFFSET = Bm.SHADOW_INV_PROJ_DEPTH_INFO_OFFSET + 4; + Bm.SHADOW_PROJ_INFO_OFFSET = Bm.SHADOW_PROJ_DEPTH_INFO_OFFSET + 4; + Bm.SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET = Bm.SHADOW_PROJ_INFO_OFFSET + 4; + Bm.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET = Bm.SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET + 4; + Bm.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET = Bm.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET + 4; + Bm.SHADOW_COLOR_OFFSET = Bm.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET + 4; + Bm.PLANAR_NORMAL_DISTANCE_INFO_OFFSET = Bm.SHADOW_COLOR_OFFSET + 4; + Bm.COUNT = Bm.PLANAR_NORMAL_DISTANCE_INFO_OFFSET + 4; + Bm.SIZE = 4 * Bm.COUNT; + Bm.NAME = "CCShadow"; + Bm.BINDING = Sm.UBO_SHADOW; + Bm.DESCRIPTOR = new Jn(Bm.BINDING, Zs.UNIFORM_BUFFER, 1, ks.ALL); + Bm.LAYOUT = new Mn(wm.GLOBAL, Bm.BINDING, Bm.NAME, [ new In("cc_matLightView", As.MAT4, 1), new In("cc_matLightViewProj", As.MAT4, 1), new In("cc_shadowInvProjDepthInfo", As.FLOAT4, 1), new In("cc_shadowProjDepthInfo", As.FLOAT4, 1), new In("cc_shadowProjInfo", As.FLOAT4, 1), new In("cc_shadowNFLSInfo", As.FLOAT4, 1), new In("cc_shadowWHPBInfo", As.FLOAT4, 1), new In("cc_shadowLPNNInfo", As.FLOAT4, 1), new In("cc_shadowColor", As.FLOAT4, 1), new In("cc_planarNDInfo", As.FLOAT4, 1) ], 1); + ym.layouts[Bm.NAME] = Bm.LAYOUT; + ym.bindings[Bm.BINDING] = Bm.DESCRIPTOR; + class Dm {} + Dm.CSM_LEVEL_COUNT = 4; + Dm.CSM_VIEW_DIR_0_OFFSET = 0; + Dm.CSM_VIEW_DIR_1_OFFSET = Dm.CSM_VIEW_DIR_0_OFFSET + 4 * Dm.CSM_LEVEL_COUNT; + Dm.CSM_VIEW_DIR_2_OFFSET = Dm.CSM_VIEW_DIR_1_OFFSET + 4 * Dm.CSM_LEVEL_COUNT; + Dm.CSM_ATLAS_OFFSET = Dm.CSM_VIEW_DIR_2_OFFSET + 4 * Dm.CSM_LEVEL_COUNT; + Dm.MAT_CSM_VIEW_PROJ_OFFSET = Dm.CSM_ATLAS_OFFSET + 4 * Dm.CSM_LEVEL_COUNT; + Dm.CSM_PROJ_DEPTH_INFO_OFFSET = Dm.MAT_CSM_VIEW_PROJ_OFFSET + 16 * Dm.CSM_LEVEL_COUNT; + Dm.CSM_PROJ_INFO_OFFSET = Dm.CSM_PROJ_DEPTH_INFO_OFFSET + 4 * Dm.CSM_LEVEL_COUNT; + Dm.CSM_SPLITS_INFO_OFFSET = Dm.CSM_PROJ_INFO_OFFSET + 4 * Dm.CSM_LEVEL_COUNT; + Dm.COUNT = Dm.CSM_SPLITS_INFO_OFFSET + 4; + Dm.SIZE = 4 * Dm.COUNT; + Dm.NAME = "CCCSM"; + Dm.BINDING = Sm.UBO_CSM; + Dm.DESCRIPTOR = new Jn(Dm.BINDING, Zs.UNIFORM_BUFFER, 1, ks.ALL); + Dm.LAYOUT = new Mn(wm.GLOBAL, Dm.BINDING, Dm.NAME, [ new In("cc_csmViewDir0", As.FLOAT4, Dm.CSM_LEVEL_COUNT), new In("cc_csmViewDir1", As.FLOAT4, Dm.CSM_LEVEL_COUNT), new In("cc_csmViewDir2", As.FLOAT4, Dm.CSM_LEVEL_COUNT), new In("cc_csmAtlas", As.FLOAT4, Dm.CSM_LEVEL_COUNT), new In("cc_matCSMViewProj", As.MAT4, Dm.CSM_LEVEL_COUNT), new In("cc_csmProjDepthInfo", As.FLOAT4, Dm.CSM_LEVEL_COUNT), new In("cc_csmProjInfo", As.FLOAT4, Dm.CSM_LEVEL_COUNT), new In("cc_csmSplitsInfo", As.FLOAT4, 1) ], 1); + ym.layouts[Dm.NAME] = Dm.LAYOUT; + ym.bindings[Dm.BINDING] = Dm.DESCRIPTOR; + const Pm = "cc_shadowMap"; + const Om = Sm.SAMPLER_SHADOWMAP; + const Nm = new Jn(Om, Zs.SAMPLER_TEXTURE, 1, ks.FRAGMENT); + const Lm = new Bn(wm.GLOBAL, Om, Pm, As.SAMPLER2D, 1); + ym.layouts.cc_shadowMap = Lm; + ym.bindings[Om] = Nm; + const Fm = "cc_environment"; + const Vm = Sm.SAMPLER_ENVIRONMENT; + const km = new Jn(Vm, Zs.SAMPLER_TEXTURE, 1, ks.FRAGMENT); + const Um = new Bn(wm.GLOBAL, Vm, Fm, As.SAMPLER_CUBE, 1); + ym.layouts.cc_environment = Um; + ym.bindings[Vm] = km; + const Gm = "cc_diffuseMap"; + const zm = Sm.SAMPLER_DIFFUSEMAP; + const Hm = new Jn(zm, Zs.SAMPLER_TEXTURE, 1, ks.FRAGMENT); + const jm = new Bn(wm.GLOBAL, zm, Gm, As.SAMPLER_CUBE, 1); + ym.layouts.cc_diffuseMap = jm; + ym.bindings[zm] = Hm; + const Xm = "cc_spotShadowMap"; + const Wm = Sm.SAMPLER_SPOT_SHADOW_MAP; + const Ym = new Jn(Wm, Zs.SAMPLER_TEXTURE, 1, ks.FRAGMENT); + const qm = new Bn(wm.GLOBAL, Wm, Xm, As.SAMPLER2D, 1); + ym.layouts.cc_spotShadowMap = qm; + ym.bindings[Wm] = Ym; + class Km {} + Km.MAT_WORLD_OFFSET = 0; + Km.MAT_WORLD_IT_OFFSET = Km.MAT_WORLD_OFFSET + 16; + Km.LIGHTINGMAP_UVPARAM = Km.MAT_WORLD_IT_OFFSET + 16; + Km.LOCAL_SHADOW_BIAS = Km.LIGHTINGMAP_UVPARAM + 4; + Km.COUNT = Km.LOCAL_SHADOW_BIAS + 4; + Km.SIZE = 4 * Km.COUNT; + Km.NAME = "CCLocal"; + Km.BINDING = vm.UBO_LOCAL; + Km.DESCRIPTOR = new Jn(Km.BINDING, Zs.UNIFORM_BUFFER, 1, ks.VERTEX | ks.COMPUTE); + Km.LAYOUT = new Mn(wm.LOCAL, Km.BINDING, Km.NAME, [ new In("cc_matWorld", As.MAT4, 1), new In("cc_matWorldIT", As.MAT4, 1), new In("cc_lightingMapUVParam", As.FLOAT4, 1), new In("cc_localShadowBias", As.FLOAT4, 1) ], 1); + bm.layouts[Km.NAME] = Km.LAYOUT; + bm.bindings[Km.BINDING] = Km.DESCRIPTOR; + class Jm {} + Jm.WORLD_BOUND_CENTER = 0; + Jm.WORLD_BOUND_HALF_EXTENTS = Jm.WORLD_BOUND_CENTER + 4; + Jm.COUNT = Jm.WORLD_BOUND_HALF_EXTENTS + 4; + Jm.SIZE = 4 * Jm.COUNT; + Jm.NAME = "CCWorldBound"; + Jm.BINDING = vm.UBO_LOCAL; + Jm.DESCRIPTOR = new Jn(Jm.BINDING, Zs.UNIFORM_BUFFER, 1, ks.VERTEX | ks.COMPUTE); + Jm.LAYOUT = new Mn(wm.LOCAL, Jm.BINDING, Jm.NAME, [ new In("cc_worldBoundCenter", As.FLOAT4, 1), new In("cc_worldBoundHalfExtents", As.FLOAT4, 1) ], 1); + bm.layouts[Jm.NAME] = Jm.LAYOUT; + bm.bindings[Jm.BINDING] = Jm.DESCRIPTOR; + class Zm {} + Zm.BATCHING_COUNT = 10; + Zm.MAT_WORLDS_OFFSET = 0; + Zm.COUNT = 16 * Zm.BATCHING_COUNT; + Zm.SIZE = 4 * Zm.COUNT; + Zm.NAME = "CCLocalBatched"; + Zm.BINDING = vm.UBO_LOCAL; + Zm.DESCRIPTOR = new Jn(Zm.BINDING, Zs.UNIFORM_BUFFER, 1, ks.VERTEX | ks.COMPUTE); + Zm.LAYOUT = new Mn(wm.LOCAL, Zm.BINDING, Zm.NAME, [ new In("cc_matWorlds", As.MAT4, Zm.BATCHING_COUNT) ], 1); + bm.layouts[Zm.NAME] = Zm.LAYOUT; + bm.bindings[Zm.BINDING] = Zm.DESCRIPTOR; + class Qm {} + Qm.LIGHTS_PER_PASS = 1; + Qm.LIGHT_POS_OFFSET = 0; + Qm.LIGHT_COLOR_OFFSET = Qm.LIGHT_POS_OFFSET + 4 * Qm.LIGHTS_PER_PASS; + Qm.LIGHT_SIZE_RANGE_ANGLE_OFFSET = Qm.LIGHT_COLOR_OFFSET + 4 * Qm.LIGHTS_PER_PASS; + Qm.LIGHT_DIR_OFFSET = Qm.LIGHT_SIZE_RANGE_ANGLE_OFFSET + 4 * Qm.LIGHTS_PER_PASS; + Qm.COUNT = Qm.LIGHT_DIR_OFFSET + 4 * Qm.LIGHTS_PER_PASS; + Qm.SIZE = 4 * Qm.COUNT; + Qm.NAME = "CCForwardLight"; + Qm.BINDING = vm.UBO_FORWARD_LIGHTS; + Qm.DESCRIPTOR = new Jn(Qm.BINDING, Zs.DYNAMIC_UNIFORM_BUFFER, 1, ks.FRAGMENT); + Qm.LAYOUT = new Mn(wm.LOCAL, Qm.BINDING, Qm.NAME, [ new In("cc_lightPos", As.FLOAT4, Qm.LIGHTS_PER_PASS), new In("cc_lightColor", As.FLOAT4, Qm.LIGHTS_PER_PASS), new In("cc_lightSizeRangeAngle", As.FLOAT4, Qm.LIGHTS_PER_PASS), new In("cc_lightDir", As.FLOAT4, Qm.LIGHTS_PER_PASS) ], 1); + bm.layouts[Qm.NAME] = Qm.LAYOUT; + bm.bindings[Qm.BINDING] = Qm.DESCRIPTOR; + class $m {} + $m.LIGHTS_PER_PASS = 10; + class tf {} + tf.JOINTS_TEXTURE_INFO_OFFSET = 0; + tf.COUNT = tf.JOINTS_TEXTURE_INFO_OFFSET + 4; + tf.SIZE = 4 * tf.COUNT; + tf.NAME = "CCSkinningTexture"; + tf.BINDING = vm.UBO_SKINNING_TEXTURE; + tf.DESCRIPTOR = new Jn(tf.BINDING, Zs.UNIFORM_BUFFER, 1, ks.VERTEX); + tf.LAYOUT = new Mn(wm.LOCAL, tf.BINDING, tf.NAME, [ new In("cc_jointTextureInfo", As.FLOAT4, 1) ], 1); + bm.layouts[tf.NAME] = tf.LAYOUT; + bm.bindings[tf.BINDING] = tf.DESCRIPTOR; + class ef {} + ef.JOINTS_ANIM_INFO_OFFSET = 0; + ef.COUNT = ef.JOINTS_ANIM_INFO_OFFSET + 4; + ef.SIZE = 4 * ef.COUNT; + ef.NAME = "CCSkinningAnimation"; + ef.BINDING = vm.UBO_SKINNING_ANIMATION; + ef.DESCRIPTOR = new Jn(ef.BINDING, Zs.UNIFORM_BUFFER, 1, ks.VERTEX); + ef.LAYOUT = new Mn(wm.LOCAL, ef.BINDING, ef.NAME, [ new In("cc_jointAnimInfo", As.FLOAT4, 1) ], 1); + bm.layouts[ef.NAME] = ef.LAYOUT; + bm.bindings[ef.BINDING] = ef.DESCRIPTOR; + class sf { + static get JOINT_UNIFORM_CAPACITY() { + return sf._jointUniformCapacity; + } + static get COUNT() { + return sf._count; + } + static get SIZE() { + return sf._size; + } + static initLayout(t) { + sf._jointUniformCapacity = t; + sf._count = 12 * t; + sf._size = 4 * sf._count; + sf.LAYOUT.members[0].count = 3 * t; + } + } + sf._jointUniformCapacity = 0; + sf._count = 0; + sf._size = 0; + sf.NAME = "CCSkinning"; + sf.BINDING = vm.UBO_SKINNING_TEXTURE; + sf.DESCRIPTOR = new Jn(sf.BINDING, Zs.UNIFORM_BUFFER, 1, ks.VERTEX); + sf.LAYOUT = new Mn(wm.LOCAL, sf.BINDING, sf.NAME, [ new In("cc_joints", As.FLOAT4, 1) ], 1); + class nf {} + nf.MAX_MORPH_TARGET_COUNT = 60; + nf.OFFSET_OF_WEIGHTS = 0; + nf.OFFSET_OF_DISPLACEMENT_TEXTURE_WIDTH = 4 * nf.MAX_MORPH_TARGET_COUNT; + nf.OFFSET_OF_DISPLACEMENT_TEXTURE_HEIGHT = nf.OFFSET_OF_DISPLACEMENT_TEXTURE_WIDTH + 4; + nf.OFFSET_OF_VERTICES_COUNT = nf.OFFSET_OF_DISPLACEMENT_TEXTURE_HEIGHT + 4; + nf.COUNT_BASE_4_BYTES = 4 * Math.ceil(nf.MAX_MORPH_TARGET_COUNT / 4) + 4; + nf.SIZE = 4 * nf.COUNT_BASE_4_BYTES; + nf.NAME = "CCMorph"; + nf.BINDING = vm.UBO_MORPH; + nf.DESCRIPTOR = new Jn(nf.BINDING, Zs.UNIFORM_BUFFER, 1, ks.VERTEX); + nf.LAYOUT = new Mn(wm.LOCAL, nf.BINDING, nf.NAME, [ new In("cc_displacementWeights", As.FLOAT4, nf.MAX_MORPH_TARGET_COUNT / 4), new In("cc_displacementTextureInfo", As.FLOAT4, 1) ], 1); + bm.layouts[nf.NAME] = nf.LAYOUT; + bm.bindings[nf.BINDING] = nf.DESCRIPTOR; + class rf {} + rf.NAME = "CCUILocal"; + rf.BINDING = vm.UBO_UI_LOCAL; + rf.DESCRIPTOR = new Jn(rf.BINDING, Zs.DYNAMIC_UNIFORM_BUFFER, 1, ks.VERTEX); + rf.LAYOUT = new Mn(wm.LOCAL, rf.BINDING, rf.NAME, [ new In("cc_local_data", As.FLOAT4, 1) ], 1); + bm.layouts[rf.NAME] = rf.LAYOUT; + bm.bindings[rf.BINDING] = rf.DESCRIPTOR; + const of = "cc_jointTexture"; + const af = vm.SAMPLER_JOINTS; + const lf = new Jn(af, Zs.SAMPLER_TEXTURE, 1, ks.VERTEX); + const hf = new Bn(wm.LOCAL, af, of, As.SAMPLER2D, 1); + bm.layouts.cc_jointTexture = hf; + bm.bindings[af] = lf; + const cf = "cc_realtimeJoint"; + const uf = vm.SAMPLER_JOINTS; + const _f = new Jn(uf, Zs.SAMPLER_TEXTURE, 1, ks.VERTEX); + const df = new Bn(wm.LOCAL, uf, cf, As.SAMPLER2D, 1); + bm.layouts.cc_realtimeJoint = df; + bm.bindings[uf] = _f; + const pf = "cc_PositionDisplacements"; + const mf = vm.SAMPLER_MORPH_POSITION; + const ff = new Jn(mf, Zs.SAMPLER_TEXTURE, 1, ks.VERTEX); + const gf = new Bn(wm.LOCAL, mf, pf, As.SAMPLER2D, 1); + bm.layouts.cc_PositionDisplacements = gf; + bm.bindings[mf] = ff; + const yf = "cc_NormalDisplacements"; + const bf = vm.SAMPLER_MORPH_NORMAL; + const Sf = new Jn(bf, Zs.SAMPLER_TEXTURE, 1, ks.VERTEX); + const Af = new Bn(wm.LOCAL, bf, yf, As.SAMPLER2D, 1); + bm.layouts.cc_NormalDisplacements = Af; + bm.bindings[bf] = Sf; + const Tf = "cc_TangentDisplacements"; + const vf = vm.SAMPLER_MORPH_TANGENT; + const Ef = new Jn(vf, Zs.SAMPLER_TEXTURE, 1, ks.VERTEX); + const Cf = new Bn(wm.LOCAL, vf, Tf, As.SAMPLER2D, 1); + bm.layouts.cc_TangentDisplacements = Cf; + bm.bindings[vf] = Ef; + const xf = "cc_lightingMap"; + const wf = vm.SAMPLER_LIGHTMAP; + const Rf = new Jn(wf, Zs.SAMPLER_TEXTURE, 1, ks.FRAGMENT); + const If = new Bn(wm.LOCAL, wf, xf, As.SAMPLER2D, 1); + bm.layouts.cc_lightingMap = If; + bm.bindings[wf] = Rf; + const Mf = "cc_spriteTexture"; + const Bf = vm.SAMPLER_SPRITE; + const Df = new Jn(Bf, Zs.SAMPLER_TEXTURE, 1, ks.FRAGMENT); + const Pf = new Bn(wm.LOCAL, Bf, Mf, As.SAMPLER2D, 1); + bm.layouts.cc_spriteTexture = Pf; + bm.bindings[Bf] = Df; + const Of = "cc_reflectionTexture"; + const Nf = vm.SAMPLER_REFLECTION; + const Lf = new Jn(Nf, Zs.SAMPLER_TEXTURE, 1, ks.FRAGMENT); + const Ff = new Bn(wm.LOCAL, Nf, Of, As.SAMPLER2D, 1); + bm.layouts.cc_reflectionTexture = Ff; + bm.bindings[Nf] = Lf; + const Vf = "cc_reflectionStorage"; + const kf = vm.STORAGE_REFLECTION; + const Uf = new Jn(kf, Zs.STORAGE_IMAGE, 1, ks.COMPUTE); + const Gf = new On(wm.LOCAL, kf, Vf, As.IMAGE2D, 1); + bm.layouts.cc_reflectionStorage = Gf; + bm.bindings[kf] = Uf; + const zf = mm.makeMaskExclude([ mm.BitMask.UI_2D, mm.BitMask.GIZMOS, mm.BitMask.EDITOR, mm.BitMask.SCENE_GIZMO, mm.BitMask.PROFILER ]); + const Hf = mm.makeMaskExclude([ mm.BitMask.UI_2D, mm.BitMask.PROFILER ]); + const jf = mm.Enum.ALL; + function Xf(t) { + return (t.getFormatFeatures(bs.R32F) & (Is.RENDER_TARGET | Is.SAMPLED_TEXTURE)) == (Is.RENDER_TARGET | Is.SAMPLED_TEXTURE); + } + t("pipeline", Object.freeze({ + __proto__: null, + PIPELINE_FLOW_MAIN: "MainFlow", + PIPELINE_FLOW_FORWARD: "ForwardFlow", + PIPELINE_FLOW_SHADOW: "ShadowFlow", + PIPELINE_FLOW_SMAA: "SMAAFlow", + PIPELINE_FLOW_TONEMAP: "ToneMapFlow", + get RenderPassStage() { + return fm; + }, + get RenderPriority() { + return gm; + }, + globalDescriptorSetLayout: ym, + localDescriptorSetLayout: bm, + get PipelineGlobalBindings() { + return Sm; + }, + get ModelLocalBindings() { + return vm; + }, + get SetIndex() { + return wm; + }, + bindingMappingInfo: Rm, + UBOGlobal: Im, + UBOCamera: Mm, + UBOShadow: Bm, + UBOCSM: Dm, + UNIFORM_SHADOWMAP_BINDING: Om, + UNIFORM_ENVIRONMENT_BINDING: Vm, + UNIFORM_DIFFUSEMAP_BINDING: zm, + UNIFORM_SPOT_SHADOW_MAP_TEXTURE_BINDING: Wm, + UBOLocal: Km, + UBOWorldBound: Jm, + INST_MAT_WORLD: "a_matWorld0", + UBOLocalBatched: Zm, + UBOForwardLight: Qm, + UBODeferredLight: $m, + JOINT_UNIFORM_CAPACITY: 30, + UBOSkinningTexture: tf, + UBOSkinningAnimation: ef, + INST_JOINT_ANIM_INFO: "a_jointAnimInfo", + UBOSkinning: sf, + localDescriptorSetLayout_ResizeMaxJoints: function(t) { + sf.initLayout(t); + bm.layouts[sf.NAME] = sf.LAYOUT; + bm.bindings[sf.BINDING] = sf.DESCRIPTOR; + }, + UBOMorph: nf, + UBOUILocal: rf, + UNIFORM_JOINT_TEXTURE_BINDING: af, + UNIFORM_REALTIME_JOINT_TEXTURE_BINDING: uf, + UNIFORM_POSITION_MORPH_TEXTURE_BINDING: mf, + UNIFORM_NORMAL_MORPH_TEXTURE_BINDING: bf, + UNIFORM_TANGENT_MORPH_TEXTURE_BINDING: vf, + UNIFORM_LIGHTMAP_TEXTURE_BINDING: wf, + UNIFORM_SPRITE_TEXTURE_BINDING: Bf, + UNIFORM_REFLECTION_TEXTURE_BINDING: Nf, + UNIFORM_REFLECTION_STORAGE_BINDING: kf, + CAMERA_DEFAULT_MASK: zf, + CAMERA_EDITOR_MASK: Hf, + MODEL_ALWAYS_MASK: jf, + supportsR16HalfFloatTexture: function(t) { + return (t.getFormatFeatures(bs.R16F) & (Is.RENDER_TARGET | Is.SAMPLED_TEXTURE)) == (Is.RENDER_TARGET | Is.SAMPLED_TEXTURE); + }, + supportsR32FloatTexture: Xf + })); + let Wf; + !function(t) { + t.RENDER_FRAME_BEGIN = "render-frame-begin"; + t.RENDER_FRAME_END = "render-frame-end"; + t.RENDER_CAMERA_BEGIN = "render-camera-begin"; + t.RENDER_CAMERA_END = "render-camera-end"; + t.ATTACHMENT_SCALE_CAHNGED = "attachment-scale-changed"; + }(Wf || (Wf = t("PipelineEventType", {}))); + nr.getPhaseID = dm; + t("RenderPipeline", nr.RenderPipeline); + t("RenderFlow", nr.RenderFlow); + t("RenderStage", nr.RenderStage); + t("InstancedBuffer", nr.InstancedBuffer); + const Yf = t("PipelineStateManager", nr.PipelineStateManager); + const qf = t("ForwardPipeline", nr.ForwardPipeline); + const Kf = t("ForwardFlow", nr.ForwardFlow); + const Jf = t("ShadowFlow", nr.ShadowFlow); + const Zf = t("ForwardStage", nr.ForwardStage); + const Qf = t("ShadowStage", nr.ShadowStage); + const $f = t("DeferredPipeline", nr.DeferredPipeline); + const tg = t("MainFlow", nr.MainFlow); + const eg = t("LightingStage", nr.LightingStage); + const ig = t("PostProcessStage", nr.PostProcessStage); + const sg = t("GbufferStage", nr.GbufferStage); + const ng = t("BloomStage", nr.BloomStage); + let rg = nr.PipelineStateManager.getOrCreatePipelineState; + nr.PipelineStateManager.getOrCreatePipelineState = function(t, e, i, s, n) { + return rg(e, i, s, n); + }; + const og = qf.prototype; + og._ctor = function() { + this._tag = 0; + this._flows = []; + }; + og.init = function() { + for (let t = 0; t < this._flows.length; t++) this._flows[t].init(this); + const t = new nr.RenderPipelineInfo(this._tag, this._flows); + this.initialize(t); + }; + const ag = og.onLoaded; + og.onLoaded = function() { + ag && ag.call(this); + for (let t = 0; t < this._flows.length; t++) this._flows[t].init(this); + const t = new nr.RenderPipelineInfo(this._tag, this._flows); + this.initialize(t); + }; + const lg = Kf.prototype; + lg._ctor = function() { + this._name = 0; + this._priority = 0; + this._tag = 0; + this._stages = []; + }; + lg.init = function(t) { + for (let e = 0; e < this._stages.length; e++) this._stages[e].init(t); + const e = new nr.RenderFlowInfo(this._name, this._priority, this._tag, this._stages); + this.initialize(e); + }; + const hg = Jf.prototype; + hg._ctor = function() { + this._name = 0; + this._priority = 0; + this._tag = 0; + this._stages = []; + }; + hg.init = function(t) { + for (let e = 0; e < this._stages.length; e++) this._stages[e].init(t); + const e = new nr.RenderFlowInfo(this._name, this._priority, this._tag, this._stages); + this.initialize(e); + }; + const cg = Zf.prototype; + cg._ctor = function() { + this._name = 0; + this._priority = 0; + this._tag = 0; + this.renderQueues = []; + }; + cg.init = function(t) { + const e = []; + for (let t = 0; t < this.renderQueues.length; t++) e.push(this.renderQueues[t].init()); + const i = new nr.RenderStageInfo(this._name, this._priority, this._tag, e); + this.initialize(i); + }; + const ug = Qf.prototype; + ug._ctor = function() { + this._name = 0; + this._priority = 0; + this._tag = 0; + }; + ug.init = function(t) { + const e = new nr.RenderStageInfo(this._name, this._priority, this._tag, []); + this.initialize(e); + }; + class _g { + constructor() { + this.isTransparent = !1; + this.sortMode = 0; + this.stages = []; + this.isTransparent = !1; + this.sortMode = 0; + this.stages = []; + } + init() { + return new nr.RenderQueueDesc(this.isTransparent, this.sortMode, this.stages); + } + } + t("RenderQueueDesc", _g); + const dg = $f.prototype; + dg._ctor = function() { + this._tag = 0; + this._flows = []; + this.renderTextures = []; + this.materials = []; + }; + const pg = dg.onLoaded; + dg.onLoaded = function() { + pg && pg.call(this); + for (let t = 0; t < this._flows.length; t++) this._flows[t].init(this); + let t = new nr.RenderPipelineInfo(this._tag, this._flows); + this.initialize(t); + }; + const mg = tg.prototype; + mg._ctor = function() { + this._name = 0; + this._priority = 0; + this._tag = 0; + this._stages = []; + }; + mg.init = function(t) { + for (let e = 0; e < this._stages.length; e++) this._stages[e].init(t); + let e = new nr.RenderFlowInfo(this._name, this._priority, this._tag, this._stages); + this.initialize(e); + }; + const fg = sg.prototype; + fg._ctor = function() { + this._name = 0; + this._priority = 0; + this._tag = 0; + this.renderQueues = []; + }; + fg.init = function(t) { + const e = []; + for (let t = 0; t < this.renderQueues.length; t++) e.push(this.renderQueues[t].init()); + let i = new nr.RenderStageInfo(this._name, this._priority, this._tag, e); + this.initialize(i); + }; + const gg = eg.prototype; + gg._ctor = function() { + this._name = 0; + this._priority = 0; + this._tag = 0; + this.renderQueues = []; + this._deferredMaterial = null; + }; + gg.init = function(t) { + const e = []; + for (let t = 0; t < this.renderQueues.length; t++) e.push(this.renderQueues[t].init()); + t.pipelineSceneData.deferredLightingMaterial = this._deferredMaterial; + let i = new nr.RenderStageInfo(this._name, this._priority, this._tag, e); + this.initialize(i); + }; + const yg = ng.prototype; + yg._ctor = function() { + this._name = 0; + this._priority = 0; + this._tag = 0; + this.renderQueues = []; + this._bloomMaterial = null; + }; + yg.init = function(t) { + const e = []; + for (let t = 0; t < this.renderQueues.length; t++) e.push(this.renderQueues[t].init()); + t.pipelineSceneData.bloomMaterial = this._bloomMaterial; + let i = new nr.RenderStageInfo(this._name, this._priority, this._tag, e); + this.initialize(i); + }; + const bg = ig.prototype; + bg._ctor = function() { + this._name = 0; + this._priority = 0; + this._tag = 0; + this.renderQueues = []; + this._postProcessMaterial = null; + }; + bg.init = function(t) { + const e = []; + for (let t = 0; t < this.renderQueues.length; t++) e.push(this.renderQueues[t].init()); + t.pipelineSceneData.postProcessMaterial = this._postProcessMaterial; + let i = new nr.RenderStageInfo(this._name, this._priority, this._tag, e); + this.initialize(i); + }; + Xt("DeferredPipeline", $f); + Xt("MainFlow", tg); + Xt("GbufferStage", sg); + Xt("LightingStage", eg); + Xt("BloomStage", ng); + Xt("PostProcessStage", ig); + Xt("ForwardPipeline", qf); + Xt("ForwardFlow", Kf); + Xt("ShadowFlow", Jf); + Xt("ForwardStage", Zf); + Xt("ShadowStage", Qf); + Xt("RenderQueueDesc", _g); + const Sg = new Qi; + class Ag { + get isFinished() { + return this._curTime >= this.settings.totalTime; + } + set curTime(t) { + this._curTime = t; + } + get curTime() { + return this._curTime; + } + init() { + var t, e, i, s, n, r, o; + this.settings = { + enabled: null === (t = de.querySettings(_e.Category.SPLASH_SCREEN, "enabled")) || void 0 === t || t, + totalTime: null !== (e = de.querySettings(_e.Category.SPLASH_SCREEN, "totalTime")) && void 0 !== e ? e : 3e3, + base64src: null !== (i = de.querySettings(_e.Category.SPLASH_SCREEN, "base64src")) && void 0 !== i ? i : "", + effect: null !== (s = de.querySettings(_e.Category.SPLASH_SCREEN, "effect")) && void 0 !== s ? s : "FADE-INOUT", + clearColor: null !== (n = de.querySettings(_e.Category.SPLASH_SCREEN, "clearColor")) && void 0 !== n ? n : new gn(.88, .88, .88, 1), + displayRatio: null !== (r = de.querySettings(_e.Category.SPLASH_SCREEN, "displayRatio")) && void 0 !== r ? r : .4, + displayWatermark: null === (o = de.querySettings(_e.Category.SPLASH_SCREEN, "displayWatermark")) || void 0 === o || o + }; + this._curTime = 0; + if (this.settings.enabled && "" !== this.settings.base64src && !(this.settings.totalTime <= 0)) { + this.device = m.director.root.device; + this.swapchain = m.director.root.mainWindow.swapchain; + this.framebuffer = m.director.root.mainWindow.framebuffer; + this.preInit(); + this.settings.displayWatermark && this.initWarterMark(); + return new Promise(((t, e) => { + this.logoImage = new Image; + this.logoImage.onload = () => { + this.initLogo(); + t(); + }; + this.logoImage.onerror = () => { + e(); + }; + this.logoImage.src = this.settings.base64src; + })); + } + this.settings.totalTime = 0; + return Promise.resolve(); + } + preInit() { + const t = this.settings.clearColor; + this.clearColors = [ new gn(t.x, t.y, t.z, t.w) ]; + const {device: e, swapchain: i} = this; + this.renderArea = new hn(0, 0, i.width, i.height); + this.cmdBuff = e.commandBuffer; + const s = new Float32Array([ .5, .5, 1, 0, -.5, .5, 0, 0, .5, -.5, 1, 1, -.5, -.5, 0, 1 ]); + const n = 4 * Float32Array.BYTES_PER_ELEMENT; + const r = 4 * n; + this.vertexBuffers = e.createBuffer(new An(Ts.VERTEX | Ts.TRANSFER_DST, Cs.DEVICE, r, n)); + this.vertexBuffers.update(s); + const o = new Uint16Array([ 0, 1, 2, 1, 3, 2 ]); + const a = Uint16Array.BYTES_PER_ELEMENT; + const l = 6 * a; + this.indicesBuffers = e.createBuffer(new An(Ts.INDEX | Ts.TRANSFER_DST, Cs.DEVICE, l, a)); + this.indicesBuffers.update(o); + const h = [ new Vn("a_position", bs.RG32F), new Vn("a_texCoord", bs.RG32F) ]; + const c = new Un(h, [ this.vertexBuffers ], this.indicesBuffers); + this.quadAssmebler = e.createInputAssembler(c); + this.projection = new qi; + qi.ortho(this.projection, -1, 1, -1, 1, -1, 1, e.capabilities.clipSpaceMinZ, e.capabilities.clipSpaceSignY, i.surfaceTransform); + } + update(t) { + const e = this.settings; + const {device: i, swapchain: s} = this; + qi.ortho(this.projection, -1, 1, -1, 1, -1, 1, i.capabilities.clipSpaceMinZ, i.capabilities.clipSpaceSignY, s.surfaceTransform); + const n = s.width; + const r = s.height; + const o = n < r ? n : r; + this._curTime += 1e3 * t; + let a = F_(di(this._curTime / e.totalTime)); + "NONE" === e.effect && (a = 1); + const l = this.logoTexture.width; + const h = this.logoTexture.height; + const c = o * e.displayRatio; + let u = c * l / h; + let _ = c; + if (s.surfaceTransform === gs.ROTATE_90 || s.surfaceTransform === gs.ROTATE_270) { + u = c * n / r; + _ = c * h / l * r / n; + } + this.logoMat.setProperty("resolution", Sg.set(n, r), 0); + this.logoMat.setProperty("scale", Sg.set(u, _), 0); + this.logoMat.setProperty("translate", Sg.set(.5 * n, .5 * r), 0); + this.logoMat.setProperty("percent", a); + this.logoMat.setProperty("u_projection", this.projection); + this.logoMat.passes[0].update(); + if (e.displayWatermark && this.watermarkMat) { + const t = .5 * o; + const e = this.watermarkTexture.width; + let i = t; + let l = t * this.watermarkTexture.height / e; + if (s.surfaceTransform === gs.ROTATE_90 || s.surfaceTransform === gs.ROTATE_270) { + i = .5 * t; + l = t * n / r * .5; + } + this.watermarkMat.setProperty("resolution", Sg.set(n, r), 0); + this.watermarkMat.setProperty("scale", Sg.set(i, l), 0); + this.watermarkMat.setProperty("translate", Sg.set(.5 * n, .1 * r), 0); + this.watermarkMat.setProperty("percent", a); + this.watermarkMat.setProperty("u_projection", this.projection); + this.watermarkMat.passes[0].update(); + } + this.frame(); + } + initLogo() { + const t = this.device; + this.logoMat = new hm; + this.logoMat.initialize({ + effectName: "util/splash-screen" + }); + const e = new Rn; + e.addressU = Ps.CLAMP; + e.addressV = Ps.CLAMP; + e.addressW = Ps.CLAMP; + this.sampler = t.getSampler(e); + this.logoTexture = t.createTexture(new xn(xs.TEX2D, ws.SAMPLED | ws.TRANSFER_DST, bs.RGBA8, this.logoImage.width, this.logoImage.height)); + const i = this.logoMat.passes[0]; + const s = i.getBinding("mainTexture"); + i.bindTexture(s, this.logoTexture); + this.shader = i.getShaderVariant(); + const n = i.descriptorSet; + n.bindSampler(s, this.sampler); + n.update(); + const r = new mn; + r.texExtent.width = this.logoImage.width; + r.texExtent.height = this.logoImage.height; + r.texExtent.depth = 1; + t.copyTexImagesToTexture([ this.logoImage ], this.logoTexture, [ r ]); + } + initWarterMark() { + const t = document.createElement("canvas"); + t.width = 330; + t.height = 30; + t.style.width = `${t.width}`; + t.style.height = `${t.height}`; + const e = t.getContext("2d"); + e.font = "18px Arial"; + e.textBaseline = "top"; + e.textAlign = "left"; + e.fillStyle = "`#424242`"; + const i = "Powered by Cocos Creator"; + const s = e.measureText(i); + e.fillText(i, (330 - s.width) / 2, 6); + const n = new mn; + n.texExtent.width = t.width; + n.texExtent.height = t.height; + n.texExtent.depth = 1; + this.watermarkTexture = this.device.createTexture(new xn(xs.TEX2D, ws.SAMPLED | ws.TRANSFER_DST, bs.RGBA8, t.width, t.height)); + this.device.copyTexImagesToTexture([ t ], this.watermarkTexture, [ n ]); + this.watermarkMat = new hm; + this.watermarkMat.initialize({ + effectName: "util/splash-screen" + }); + const r = this.watermarkMat.passes[0]; + const o = r.getBinding("mainTexture"); + r.bindTexture(o, this.watermarkTexture); + r.descriptorSet.update(); + } + frame() { + const {device: t, swapchain: e} = this; + if (!Vo.isXR || xr.entry.isRenderAllowable()) { + const i = Vo.isXR ? 2 : 1; + for (let s = 0; s < i; s++) { + Vo.isXR && xr.entry.renderLoopStart(s); + t.acquire([ e ]); + const i = this.cmdBuff; + const n = this.framebuffer; + const r = this.renderArea; + r.width = e.width; + r.height = e.height; + i.begin(); + i.beginRenderPass(n.renderPass, n, r, this.clearColors, 1, 0); + const o = this.logoMat.passes[0]; + const a = Yf.getOrCreatePipelineState(t, o, this.shader, n.renderPass, this.quadAssmebler); + i.bindPipelineState(a); + i.bindDescriptorSet(wm.MATERIAL, o.descriptorSet); + i.bindInputAssembler(this.quadAssmebler); + i.draw(this.quadAssmebler); + if (this.settings.displayWatermark && this.watermarkMat) { + const e = this.watermarkMat.passes[0]; + const s = Yf.getOrCreatePipelineState(t, e, this.shader, n.renderPass, this.quadAssmebler); + i.bindPipelineState(s); + i.bindDescriptorSet(wm.MATERIAL, e.descriptorSet); + i.bindInputAssembler(this.quadAssmebler); + i.draw(this.quadAssmebler); + } + i.endRenderPass(); + i.end(); + t.flushCommands([ i ]); + t.queue.submit([ i ]); + t.present(); + Vo.isXR && xr.entry.renderLoopEnd(s); + } + } + } + destroy() { + this.device = null; + this.swapchain = null; + this.clearColors = null; + this.logoImage.destroy && this.logoImage.destroy(); + this.logoImage = null; + this.framebuffer = null; + this.renderArea = null; + this.cmdBuff = null; + this.shader = null; + this.logoMat.destroy(); + this.logoMat = null; + this.logoTexture.destroy(); + this.logoTexture = null; + this.quadAssmebler.destroy(); + this.quadAssmebler = null; + this.vertexBuffers.destroy(); + this.vertexBuffers = null; + this.indicesBuffers.destroy(); + this.indicesBuffers = null; + this.sampler = null; + if (this.watermarkTexture) { + this.watermarkMat.destroy(); + this.watermarkMat = null; + this.watermarkTexture.destroy(); + this.watermarkTexture = null; + } + this.settings = null; + } + static get instance() { + Ag._ins || (Ag._ins = new Ag); + return Ag._ins; + } + constructor() { + this._curTime = 0; + } + } + Ag._ins = void 0; + m.internal.SplashScreen = Ag; + class Tg { + constructor() { + this._id = ""; + this._priority = 0; + this._executeInEditMode = !1; + } + set priority(t) { + this._priority = t; + } + get priority() { + return this._priority; + } + set id(t) { + this._id = t; + } + get id() { + return this._id; + } + static sortByPriority(t, e) { + return t._priority < e._priority ? 1 : t._priority > e.priority ? -1 : 0; + } + init() {} + update(t) {} + postUpdate(t) {} + destroy() {} + } + t("System", Tg); + Tg.Priority = oe({ + LOW: 0, + MEDIUM: 100, + HIGH: 200, + SCHEDULER: 1 << 31 >>> 0 + }); + const vg = new ut("Scheduler"); + class Eg { + constructor(t, e, i, s) { + this.target = void 0; + this.priority = void 0; + this.paused = void 0; + this.markedForDeletion = void 0; + this.target = t; + this.priority = e; + this.paused = i; + this.markedForDeletion = s; + } + } + Eg.get = (t, e, i, s) => { + let n = Eg._listEntries.pop(); + if (n) { + n.target = t; + n.priority = e; + n.paused = i; + n.markedForDeletion = s; + } else n = new Eg(t, e, i, s); + return n; + }; + Eg.put = t => { + if (Eg._listEntries.length < 20) { + t.target = null; + Eg._listEntries.push(t); + } + }; + Eg._listEntries = []; + class Cg { + constructor(t, e, i, s) { + this.list = void 0; + this.entry = void 0; + this.target = void 0; + this.callback = void 0; + this.list = t; + this.entry = e; + this.target = i; + this.callback = s; + } + } + Cg.get = (t, e, i, s) => { + let n = Cg._hashUpdateEntries.pop(); + if (n) { + n.list = t; + n.entry = e; + n.target = i; + n.callback = s; + } else n = new Cg(t, e, i, s); + return n; + }; + Cg.put = t => { + if (Cg._hashUpdateEntries.length < 20) { + t.list = t.entry = t.target = t.callback = null; + Cg._hashUpdateEntries.push(t); + } + }; + Cg._hashUpdateEntries = []; + class xg { + constructor(t, e, i, s, n, r) { + this.timers = void 0; + this.target = void 0; + this.timerIndex = void 0; + this.currentTimer = void 0; + this.currentTimerSalvaged = void 0; + this.paused = void 0; + this.timers = t; + this.target = e; + this.timerIndex = i; + this.currentTimer = s; + this.currentTimerSalvaged = n; + this.paused = r; + } + } + xg.get = (t, e, i, s, n, r) => { + let o = xg._hashTimerEntries.pop(); + if (o) { + o.timers = t; + o.target = e; + o.timerIndex = i; + o.currentTimer = s; + o.currentTimerSalvaged = n; + o.paused = r; + } else o = new xg(t, e, i, s, n, r); + return o; + }; + xg.put = t => { + if (xg._hashTimerEntries.length < 20) { + t.timers = t.target = t.currentTimer = null; + xg._hashTimerEntries.push(t); + } + }; + xg._hashTimerEntries = []; + class wg { + constructor() { + this._lock = void 0; + this._scheduler = void 0; + this._elapsed = void 0; + this._runForever = void 0; + this._useDelay = void 0; + this._timesExecuted = void 0; + this._repeat = void 0; + this._delay = void 0; + this._interval = void 0; + this._target = void 0; + this._callback = void 0; + this._lock = !1; + this._scheduler = null; + this._elapsed = -1; + this._runForever = !1; + this._useDelay = !1; + this._timesExecuted = 0; + this._repeat = 0; + this._delay = 0; + this._interval = 0; + this._target = null; + this._callback = null; + } + initWithCallback(t, e, i, s, n, r) { + this._lock = !1; + this._scheduler = t; + this._target = i; + this._callback = e; + this._elapsed = -1; + this._interval = s; + this._delay = r; + this._useDelay = this._delay > 0; + this._repeat = n; + this._runForever = this._repeat === m.macro.REPEAT_FOREVER; + return !0; + } + getInterval() { + return this._interval; + } + setInterval(t) { + this._interval = t; + } + update(t) { + if (-1 === this._elapsed) { + this._elapsed = 0; + this._timesExecuted = 0; + } else { + this._elapsed += t; + if (this._runForever && !this._useDelay) { + if (this._elapsed >= this._interval) { + this.trigger(); + this._elapsed = 0; + } + } else { + if (this._useDelay) { + if (this._elapsed >= this._delay) { + this.trigger(); + this._elapsed -= this._delay; + this._timesExecuted += 1; + this._useDelay = !1; + } + } else if (this._elapsed >= this._interval) { + this.trigger(); + this._elapsed = 0; + this._timesExecuted += 1; + } + this._callback && !this._runForever && this._timesExecuted > this._repeat && this.cancel(); + } + } + } + getCallback() { + return this._callback; + } + trigger() { + if (this._target && this._callback) { + this._lock = !0; + this._callback.call(this._target, this._elapsed); + this._lock = !1; + } + } + cancel() { + this._scheduler.unschedule(this._callback, this._target); + } + } + wg._timers = []; + wg.get = () => wg._timers.pop() || new wg; + wg.put = t => { + if (wg._timers.length < 20 && !t._lock) { + t._scheduler = t._target = t._callback = null; + wg._timers.push(t); + } + }; + class Rg extends Tg { + static enableForTarget(t) { + let e = !1; + (t.uuid || t.id) && (e = !0); + e || (t.__instanceId ? N(1513) : t.id = vg.getNewId()); + } + constructor() { + super(); + this._timeScale = void 0; + this._updatesNegList = void 0; + this._updates0List = void 0; + this._updatesPosList = void 0; + this._hashForUpdates = void 0; + this._hashForTimers = void 0; + this._currentTarget = void 0; + this._currentTargetSalvaged = void 0; + this._updateHashLocked = void 0; + this._arrayForTimers = void 0; + this._timeScale = 1; + this._updatesNegList = []; + this._updates0List = []; + this._updatesPosList = []; + this._hashForUpdates = vt(!0); + this._hashForTimers = vt(!0); + this._currentTarget = null; + this._currentTargetSalvaged = !1; + this._updateHashLocked = !1; + this._arrayForTimers = []; + } + setTimeScale(t) { + this._timeScale = t; + } + getTimeScale() { + return this._timeScale; + } + update(t) { + this._updateHashLocked = !0; + 1 !== this._timeScale && (t *= this._timeScale); + let e; + let i; + let s; + let n; + for (e = 0, i = this._updatesNegList, s = i.length; e < s; e++) { + n = i[e]; + n.paused || n.markedForDeletion || n.target.update(t); + } + for (e = 0, i = this._updates0List, s = i.length; e < s; e++) { + n = i[e]; + n.paused || n.markedForDeletion || n.target.update(t); + } + for (e = 0, i = this._updatesPosList, s = i.length; e < s; e++) { + n = i[e]; + n.paused || n.markedForDeletion || n.target.update(t); + } + let r; + const o = this._arrayForTimers; + for (e = 0; e < o.length; e++) { + r = o[e]; + this._currentTarget = r; + this._currentTargetSalvaged = !1; + if (!r.paused) for (r.timerIndex = 0; r.timerIndex < r.timers.length; ++r.timerIndex) { + r.currentTimer = r.timers[r.timerIndex]; + r.currentTimerSalvaged = !1; + r.currentTimer.update(t); + r.currentTimer = null; + } + if (this._currentTargetSalvaged && 0 === this._currentTarget.timers.length) { + this._removeHashElement(this._currentTarget); + --e; + } + } + for (e = 0, i = this._updatesNegList; e < i.length; ) { + n = i[e]; + n.markedForDeletion ? this._removeUpdateFromHash(n) : e++; + } + for (e = 0, i = this._updates0List; e < i.length; ) { + n = i[e]; + n.markedForDeletion ? this._removeUpdateFromHash(n) : e++; + } + for (e = 0, i = this._updatesPosList; e < i.length; ) { + n = i[e]; + n.markedForDeletion ? this._removeUpdateFromHash(n) : e++; + } + this._updateHashLocked = !1; + this._currentTarget = null; + } + schedule(t, e, i, s, n, r) { + if ("function" != typeof t) { + const i = t; + t = e; + e = i; + } + if (3 === arguments.length || 4 === arguments.length || 5 === arguments.length) { + r = !!s; + s = m.macro.REPEAT_FOREVER; + n = 0; + } + k(e, 1502); + const o = e.uuid || e.id; + if (!o) { + F(1510); + return; + } + let a = this._hashForTimers[o]; + if (a) a.paused !== r && N(1511); else { + a = xg.get(null, e, 0, null, null, r); + this._arrayForTimers.push(a); + this._hashForTimers[o] = a; + } + let l; + let h; + if (null == a.timers) a.timers = []; else for (h = 0; h < a.timers.length; ++h) { + l = a.timers[h]; + if (l && t === l._callback) { + P(1507, l.getInterval(), i); + l._interval = i; + return; + } + } + l = wg.get(); + l.initWithCallback(this, t, e, i, s, n); + a.timers.push(l); + this._currentTarget === a && this._currentTargetSalvaged && (this._currentTargetSalvaged = !1); + } + scheduleUpdate(t, e, i) { + const s = t.uuid || t.id; + if (!s) { + F(1510); + return; + } + const n = this._hashForUpdates[s]; + if (n && n.entry) { + if (n.entry.priority === e) { + n.entry.markedForDeletion = !1; + n.entry.paused = i; + return; + } + if (this._updateHashLocked) { + P(1506); + n.entry.markedForDeletion = !1; + n.entry.paused = i; + return; + } + this.unscheduleUpdate(t); + } + const r = Eg.get(t, e, i, !1); + let o; + if (0 === e) { + o = this._updates0List; + this._appendIn(o, r); + } else { + o = e < 0 ? this._updatesNegList : this._updatesPosList; + this._priorityIn(o, r, e); + } + this._hashForUpdates[s] = Cg.get(o, r, t, null); + } + unschedule(t, e) { + if (!e || !t) return; + const i = e.uuid || e.id; + if (!i) { + F(1510); + return; + } + const s = this._hashForTimers[i]; + if (s) { + const e = s.timers; + for (let i = 0, n = e.length; i < n; i++) { + const n = e[i]; + if (t === n._callback) { + n !== s.currentTimer || s.currentTimerSalvaged || (s.currentTimerSalvaged = !0); + e.splice(i, 1); + wg.put(n); + s.timerIndex >= i && s.timerIndex--; + 0 === e.length && (this._currentTarget === s ? this._currentTargetSalvaged = !0 : this._removeHashElement(s)); + return; + } + } + } + } + unscheduleUpdate(t) { + if (!t) return; + const e = t.uuid || t.id; + if (!e) { + F(1510); + return; + } + const i = this._hashForUpdates[e]; + i && (this._updateHashLocked ? i.entry.markedForDeletion = !0 : this._removeUpdateFromHash(i.entry)); + } + unscheduleAllForTarget(t) { + if (!t) return; + const e = t.uuid || t.id; + if (!e) { + F(1510); + return; + } + const i = this._hashForTimers[e]; + if (i) { + const t = i.timers; + t.indexOf(i.currentTimer) > -1 && !i.currentTimerSalvaged && (i.currentTimerSalvaged = !0); + for (let e = 0, i = t.length; e < i; e++) wg.put(t[e]); + t.length = 0; + this._currentTarget === i ? this._currentTargetSalvaged = !0 : this._removeHashElement(i); + } + this.unscheduleUpdate(t); + } + unscheduleAll() { + this.unscheduleAllWithMinPriority(Tg.Priority.SCHEDULER); + } + unscheduleAllWithMinPriority(t) { + let e; + let i; + const s = this._arrayForTimers; + for (e = s.length - 1; e >= 0; e--) { + i = s[e]; + this.unscheduleAllForTarget(i.target); + } + let n; + let r = 0; + if (t < 0) for (e = 0; e < this._updatesNegList.length; ) { + r = this._updatesNegList.length; + n = this._updatesNegList[e]; + n && n.priority >= t && this.unscheduleUpdate(n.target); + r === this._updatesNegList.length && e++; + } + if (t <= 0) for (e = 0; e < this._updates0List.length; ) { + r = this._updates0List.length; + n = this._updates0List[e]; + n && this.unscheduleUpdate(n.target); + r === this._updates0List.length && e++; + } + for (e = 0; e < this._updatesPosList.length; ) { + r = this._updatesPosList.length; + n = this._updatesPosList[e]; + n && n.priority >= t && this.unscheduleUpdate(n.target); + r === this._updatesPosList.length && e++; + } + } + isScheduled(t, e) { + k(t, 1508); + k(e, 1509); + const i = e.uuid || e.id; + if (!i) { + F(1510); + return !1; + } + const s = this._hashForTimers[i]; + if (!s) return !1; + if (null == s.timers) return !1; + { + const e = s.timers; + for (let i = 0; i < e.length; ++i) { + if (t === e[i]._callback) return !0; + } + return !1; + } + } + pauseAllTargets() { + return this.pauseAllTargetsWithMinPriority(Tg.Priority.SCHEDULER); + } + pauseAllTargetsWithMinPriority(t) { + const e = []; + let i; + const s = this._arrayForTimers; + let n; + let r; + for (n = 0, r = s.length; n < r; n++) { + i = s[n]; + if (i) { + i.paused = !0; + e.push(i.target); + } + } + let o; + if (t < 0) for (n = 0; n < this._updatesNegList.length; n++) { + o = this._updatesNegList[n]; + if (o && o.priority >= t) { + o.paused = !0; + e.push(o.target); + } + } + if (t <= 0) for (n = 0; n < this._updates0List.length; n++) { + o = this._updates0List[n]; + if (o) { + o.paused = !0; + e.push(o.target); + } + } + for (n = 0; n < this._updatesPosList.length; n++) { + o = this._updatesPosList[n]; + if (o && o.priority >= t) { + o.paused = !0; + e.push(o.target); + } + } + return e; + } + resumeTargets(t) { + if (t) for (let e = 0; e < t.length; e++) this.resumeTarget(t[e]); + } + pauseTarget(t) { + k(t, 1503); + const e = t.uuid || t.id; + if (!e) { + F(1510); + return; + } + const i = this._hashForTimers[e]; + i && (i.paused = !0); + const s = this._hashForUpdates[e]; + s && (s.entry.paused = !0); + } + resumeTarget(t) { + k(t, 1504); + const e = t.uuid || t.id; + if (!e) { + F(1510); + return; + } + const i = this._hashForTimers[e]; + i && (i.paused = !1); + const s = this._hashForUpdates[e]; + s && (s.entry.paused = !1); + } + isTargetPaused(t) { + k(t, 1505); + const e = t.uuid || t.id; + if (!e) { + F(1510); + return !1; + } + const i = this._hashForTimers[e]; + if (i) return i.paused; + const s = this._hashForUpdates[e]; + return !!s && s.entry.paused; + } + _removeHashElement(t) { + const e = t.target.uuid || t.target.id; + delete this._hashForTimers[e]; + const i = this._arrayForTimers; + for (let e = 0, s = i.length; e < s; e++) if (i[e] === t) { + i.splice(e, 1); + break; + } + xg.put(t); + } + _removeUpdateFromHash(t) { + const e = t.target.uuid || t.target.id; + const i = this._hashForUpdates[e]; + if (i) { + const t = i.list; + const s = i.entry; + for (let e = 0, i = t.length; e < i; e++) if (t[e] === s) { + t.splice(e, 1); + break; + } + delete this._hashForUpdates[e]; + Eg.put(s); + Cg.put(i); + } + } + _priorityIn(t, e, i) { + for (let s = 0; s < t.length; s++) if (i < t[s].priority) { + t.splice(s, 0, e); + return; + } + t.push(e); + } + _appendIn(t, e) { + t.push(e); + } + } + t("Scheduler", Rg); + Rg.ID = "scheduler"; + m.Scheduler = Rg; + const Ig = jsb.SubModel; + const Mg = 0, Bg = 1, Dg = 2; + const Pg = 0; + const Og = 12; + class Ng { + get singleMode() { + return this._singleMode; + } + set singleMode(t) { + this._singleMode = t; + this._updatePipeline(); + this._nativeConfig && (this._nativeConfig.singleMode = this._singleMode); + } + get lightingWithAlbedo() { + return this._lightingWithAlbedo; + } + set lightingWithAlbedo(t) { + this._lightingWithAlbedo = t; + this._updatePipeline(); + this._nativeConfig && (this._nativeConfig.lightingWithAlbedo = this._lightingWithAlbedo); + } + get csmLayerColoration() { + return this._csmLayerColoration; + } + set csmLayerColoration(t) { + this._csmLayerColoration = t; + this._updatePipeline(); + this._nativeConfig && (this._nativeConfig.csmLayerColoration = this._csmLayerColoration); + } + constructor() { + this._singleMode = Pg; + this._compositeModeValue = 0; + this._lightingWithAlbedo = !0; + this._csmLayerColoration = !1; + this._nativeConfig = null; + this._activate(); + if (null === this._nativeConfig) { + this._nativeConfig = new jsb.DebugViewConfig; + this._nativeConfig.compositeModeBitCount = Og; + } + } + isCompositeModeEnabled(t) { + return 0 !== (this._compositeModeValue & 1 << t); + } + enableCompositeMode(t, e) { + this._enableCompositeMode(t, e); + this._updatePipeline(); + } + enableAllCompositeMode(t) { + this._enableAllCompositeMode(t); + this._updatePipeline(); + } + isEnabled() { + return this._getType() !== Mg; + } + reset() { + this._activate(); + this._updatePipeline(); + } + _activate() { + this._singleMode = Pg; + this._enableAllCompositeMode(!0); + this._lightingWithAlbedo = !0; + this._csmLayerColoration = !1; + if (this._nativeConfig) { + this._nativeConfig.singleMode = this._singleMode; + this._nativeConfig.compositeModeValue = this._compositeModeValue; + this._nativeConfig.lightingWithAlbedo = this._lightingWithAlbedo; + this._nativeConfig.csmLayerColoration = this._csmLayerColoration; + } + } + _updatePipeline() { + const t = m.director.root; + const e = t.pipeline; + const i = this._getType(); + if (e.macros.CC_USE_DEBUG_VIEW !== i) { + e.macros.CC_USE_DEBUG_VIEW = i; + t.onGlobalPipelineStateChanged(); + } + } + _enableCompositeMode(t, e) { + e ? this._compositeModeValue |= 1 << t : this._compositeModeValue &= ~(1 << t); + this._nativeConfig && (this._nativeConfig.compositeModeValue = this._compositeModeValue); + } + _enableAllCompositeMode(t) { + for (let e = 0; e < Og; e++) { + t ? this._compositeModeValue |= 1 << e : this._compositeModeValue &= ~(1 << e); + this._nativeConfig && (this._nativeConfig.compositeModeValue = this._compositeModeValue); + } + } + _getType() { + if (this._singleMode !== Pg) return Bg; + if (!0 !== this._lightingWithAlbedo || !1 !== this._csmLayerColoration) return Dg; + for (let t = 0; t < Og; t++) if (!this.isCompositeModeEnabled(t)) return Dg; + return Mg; + } + } + const Lg = jsb.RenderTexture.prototype; + const Fg = jsb.TextureBase.prototype; + Lg.createNode = null; + const Vg = t("RenderTexture", jsb.RenderTexture); + Vg.Filter = Qp; + Vg.PixelFormat = Jp; + Vg.WrapMode = Zp; + Lg._serialize = function(t) { + return {}; + }; + Lg._deserialize = function(t, e) { + const i = t; + this._width = i.w; + this._height = i.h; + this._name = i.n; + Fg._deserialize.call(this, i.base, e); + }; + const kg = Lg.readPixels; + Lg.readPixels = function(t, e, i, s, n) { + t = t || 0; + e = e || 0; + i = i || this.width; + s = s || this.height; + let r = kg.call(this, t, e, i, s); + return 0 == r.length ? null : r; + }; + m.RenderTexture = jsb.RenderTexture; + Ul("cc.RenderTexture")(Vg); + Y(tm.prototype, "TextureBase.prototype", [ { + name: "hasPremultipliedAlpha" + }, { + name: "setPremultiplyAlpha" + }, { + name: "setFlipY" + } ]); + W(Vg.prototype, "RenderTexture.prototype", [ { + name: "getGFXWindow", + customFunction() { + return this._window; + } + } ]); + const Ug = t("BufferAsset", jsb.BufferAsset); + m.BufferAsset = jsb.BufferAsset; + const Gg = Ug.prototype; + vh(Gg, "_nativeAsset", Object.getOwnPropertyDescriptor(Gg, "_nativeAsset")); + Ul("cc.BufferAsset")(Ug); + function zg(t, e) { + for (const i of e) Array.isArray(i) ? zg(t, i) : t.push(i); + } + function Hg(t) { + const e = []; + zg(e, t); + return e.join(""); + } + const jg = co.Flags.Destroyed; + const Xg = co.Flags.PersistentMask; + const Wg = si.IDENTIFIER_RE; + const Yg = "var "; + const qg = "o"; + const Kg = { + "cc.ClickEvent": !1, + "cc.PrefabInfo": !1 + }; + const Jg = si.escapeForJS; + class Zg { + constructor(t, e) { + this.varName = void 0; + this.expression = void 0; + this.varName = t; + this.expression = e; + } + toString() { + return `${Yg + this.varName}=${this.expression};`; + } + } + function Qg(t, e) { + return e instanceof Zg ? new Zg(e.varName, t + e.expression) : t + e; + } + function $g(t, e, i) { + if (Array.isArray(i)) { + i[0] = Qg(e, i[0]); + t.push(i); + } else t.push(`${Qg(e, i)};`); + } + class ty { + constructor(t) { + this._exps = void 0; + this._targetExp = void 0; + this._exps = []; + this._targetExp = t; + } + append(t, e) { + this._exps.push([ t, e ]); + } + writeCode(t) { + let e; + if (this._exps.length > 1) { + t.push(`t=${this._targetExp};`); + e = "t"; + } else { + if (1 !== this._exps.length) return; + e = this._targetExp; + } + for (let i = 0; i < this._exps.length; i++) { + const s = this._exps[i]; + $g(t, `${e + ey(s[0])}=`, s[1]); + } + } + } + ty.pool = void 0; + ty.pool = new $t((t => { + t._exps.length = 0; + t._targetExp = null; + }), 1); + ty.pool.get = function(t) { + const e = this._get() || new ty; + e._targetExp = t; + return e; + }; + function ey(t) { + return Wg.test(t) ? `.${t}` : `[${Jg(t)}]`; + } + class iy { + constructor(t, e) { + this.parent = void 0; + this.objsToClear_iN$t = void 0; + this.codeArray = void 0; + this.objs = void 0; + this.funcs = void 0; + this.funcModuleCache = void 0; + this.globalVariables = void 0; + this.globalVariableId = void 0; + this.localVariableId = void 0; + this.result = void 0; + this.parent = e; + this.objsToClear_iN$t = []; + this.codeArray = []; + this.objs = []; + this.funcs = []; + this.funcModuleCache = vt(); + Nt(this.funcModuleCache, Kg); + this.globalVariables = []; + this.globalVariableId = 0; + this.localVariableId = 0; + this.codeArray.push("var o,t;", "if(R){", "o=R;", "}else{", `o=R=new ${this.getFuncModule(t.constructor, !0)}();`, "}"); + t._iN$t = { + globalVar: "R" + }; + this.objsToClear_iN$t.push(t); + this.enumerateObject(this.codeArray, t); + let i; + this.globalVariables.length > 0 && (i = `${Yg + this.globalVariables.join(",")};`); + const s = Hg([ "return (function(R){", i || [], this.codeArray, "return o;", "})" ]); + this.result = Function("O", "F", s)(this.objs, this.funcs); + for (let t = 0, e = this.objsToClear_iN$t.length; t < e; ++t) this.objsToClear_iN$t[t]._iN$t = null; + this.objsToClear_iN$t.length = 0; + } + getFuncModule(t, e) { + const i = Et(t); + if (i) { + const e = this.funcModuleCache[i]; + if (e) return e; + if (void 0 === e) { + let e = -1 !== i.indexOf("."); + if (e) try { + e = t === Function(`return ${i}`)(); + if (e) { + this.funcModuleCache[i] = i; + return i; + } + } catch (t) {} + } + } + let s = this.funcs.indexOf(t); + if (s < 0) { + s = this.funcs.length; + this.funcs.push(t); + } + let n = `F[${s}]`; + e && (n = `(${n})`); + this.funcModuleCache[i] = n; + return n; + } + getObjRef(t) { + let e = this.objs.indexOf(t); + if (e < 0) { + e = this.objs.length; + this.objs.push(t); + } + return `O[${e}]`; + } + setValueType(t, e, i, s) { + const n = ty.pool.get(s); + let r = e.constructor.__props__; + r || (r = Object.keys(e)); + for (let t = 0; t < r.length; t++) { + const s = r[t]; + const o = i[s]; + if (e[s] === o) continue; + const a = this.enumerateField(i, s, o); + n.append(s, a); + } + n.writeCode(t); + ty.pool.put(n); + } + enumerateCCClass(t, e, i) { + const s = i.__values__; + const n = Be(i); + for (let i = 0; i < s.length; i++) { + const r = s[i]; + const o = e[r]; + let a = n[r + "$_$default"]; + if (!sy(a, o)) { + if ("object" == typeof o && o instanceof m.ValueType) { + a = si.getDefault(a); + if (a && a.constructor === o.constructor) { + const e = qg + ey(r); + this.setValueType(t, a, o, e); + continue; + } + } + this.setObjProp(t, e, r, o); + } + } + } + instantiateArray(t) { + if (0 === t.length) return "[]"; + const e = "a" + ++this.localVariableId; + const i = [ new Zg(e, `new Array(${t.length})`) ]; + t._iN$t = { + globalVar: "", + source: i + }; + this.objsToClear_iN$t.push(t); + for (let s = 0; s < t.length; ++s) { + $g(i, `${e}[${s}]=`, this.enumerateField(t, s, t[s])); + } + return i; + } + instantiateTypedArray(t) { + const e = t.constructor.name; + if (0 === t.length) return `new ${e}`; + const i = "a" + ++this.localVariableId; + const s = [ new Zg(i, `new ${e}(${t.length})`) ]; + t._iN$t = { + globalVar: "", + source: s + }; + this.objsToClear_iN$t.push(t); + for (let e = 0; e < t.length; ++e) if (0 !== t[e]) { + $g(s, `${i}[${e}]=`, t[e]); + } + return s; + } + enumerateField(t, e, i) { + if ("object" == typeof i && i) { + const t = i._iN$t; + if (t) { + let e = t.globalVar; + if (!e) { + e = t.globalVar = "v" + ++this.globalVariableId; + this.globalVariables.push(e); + const i = t.source[0]; + t.source[0] = Qg(`${e}=`, i); + } + return e; + } + return ArrayBuffer.isView(i) ? this.instantiateTypedArray(i) : Array.isArray(i) ? this.instantiateArray(i) : this.instantiateObj(i); + } + if ("function" == typeof i) return this.getFuncModule(i); + if ("string" == typeof i) return Jg(i); + "_objFlags" === e && _o(t) && (i &= Xg); + return i; + } + setObjProp(t, e, i, s) { + $g(t, `${qg + ey(i)}=`, this.enumerateField(e, i, s)); + } + enumerateObject(t, e) { + const i = e.constructor; + if (ni(i)) this.enumerateCCClass(t, e, i); else for (const i in e) { + if (!e.hasOwnProperty(i) || 95 === i.charCodeAt(0) && 95 === i.charCodeAt(1) && "__type__" !== i) continue; + const s = e[i]; + "object" == typeof s && s && s === e._iN$t || this.setObjProp(t, e, i, s); + } + } + instantiateObj(t) { + if (t instanceof m.ValueType) return si.getNewValueTypeCode(t); + if (t instanceof m.Asset) return this.getObjRef(t); + if (t._objFlags & jg) return null; + let e; + const i = t.constructor; + if (ni(i)) { + if (this.parent) if (this.parent instanceof m.Component) { + if (t instanceof m._BaseNode || t instanceof m.Component) return this.getObjRef(t); + } else if (this.parent instanceof m._BaseNode) if (t instanceof m._BaseNode) { + if (!t.isChildOf(this.parent)) return this.getObjRef(t); + } else if (t instanceof m.Component) { + var s; + if (!(null === (s = t.node) || void 0 === s ? void 0 : s.isChildOf(this.parent))) return this.getObjRef(t); + } + e = new Zg(qg, `new ${this.getFuncModule(i, !0)}()`); + } else if (i === Object) e = new Zg(qg, "{}"); else { + if (i) return this.getObjRef(t); + e = new Zg(qg, "Object.create(null)"); + } + const n = [ e ]; + t._iN$t = { + globalVar: "", + source: n + }; + this.objsToClear_iN$t.push(t); + this.enumerateObject(n, t); + return [ "(function(){", n, "return o;})();" ]; + } + } + function sy(t, e) { + if ("function" == typeof t) try { + t = t(); + } catch (t) { + return !1; + } + if (t === e) return !0; + if (t && e && "object" == typeof t && "object" == typeof e && t.constructor === e.constructor) if (t instanceof m.ValueType) { + if (t.equals(e)) return !0; + } else { + if (Array.isArray(t)) return 0 === t.length && 0 === e.length; + if (t.constructor === Object) return yt(t) && yt(e); + } + return !1; + } + let ny; + !function(t) { + t.TOUCH_START = "touch-start"; + t.TOUCH_MOVE = "touch-move"; + t.TOUCH_END = "touch-end"; + t.TOUCH_CANCEL = "touch-cancel"; + t.MOUSE_DOWN = "mouse-down"; + t.MOUSE_MOVE = "mouse-move"; + t.MOUSE_UP = "mouse-up"; + t.MOUSE_WHEEL = "mouse-wheel"; + t.MOUSE_ENTER = "mouse-enter"; + t.MOUSE_LEAVE = "mouse-leave"; + t.KEY_DOWN = "keydown"; + t.KEY_UP = "keyup"; + t.DEVICEMOTION = "devicemotion"; + t.TRANSFORM_CHANGED = "transform-changed"; + t.SCENE_CHANGED_FOR_PERSISTS = "scene-changed-for-persists"; + t.SIZE_CHANGED = "size-changed"; + t.ANCHOR_CHANGED = "anchor-changed"; + t.COLOR_CHANGED = "color-changed"; + t.CHILD_ADDED = "child-added"; + t.CHILD_REMOVED = "child-removed"; + t.PARENT_CHANGED = "parent-changed"; + t.NODE_DESTROYED = "node-destroyed"; + t.LAYER_CHANGED = "layer-changed"; + t.SIBLING_ORDER_CHANGED = "sibling-order-changed"; + t.ACTIVE_IN_HIERARCHY_CHANGED = "active-in-hierarchy-changed"; + t.COMPONENT_ADDED = "component-added"; + t.COMPONENT_REMOVED = "component-removed"; + }(ny || (ny = t("NodeEventType", {}))); + class ry { + get uiTransformComp() { + this._uiTransformComp || (this._uiTransformComp = this._node.getComponent("cc.UITransform")); + return this._uiTransformComp; + } + set uiTransformComp(t) { + this._uiTransformComp = t; + } + get uiComp() { + return this._uiComp; + } + set uiComp(t) { + this._uiComp && t ? N(12002) : this._uiComp = t; + } + get opacity() { + return this._opacity; + } + get localOpacity() { + return this._localOpacity; + } + set localOpacity(t) { + this._localOpacity = t; + this.colorDirty = !0; + } + constructor(t) { + this._uiComp = null; + this._opacity = 1; + this._localOpacity = 1; + this.colorDirty = !0; + this._uiTransformComp = null; + this._node = void 0; + this._node = t; + } + applyOpacity(t) { + this._opacity = this._localOpacity * t; + } + static markOpacityTree(t, e = !0) {} + } + let oy; + !function(t) { + t[t.LOCAL = 0] = "LOCAL"; + t[t.WORLD = 1] = "WORLD"; + }(oy || (oy = {})); + let ay; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.POSITION = 1] = "POSITION"; + t[t.ROTATION = 2] = "ROTATION"; + t[t.SCALE = 4] = "SCALE"; + t[t.RS = t.ROTATION | t.SCALE] = "RS"; + t[t.TRS = t.POSITION | t.ROTATION | t.SCALE] = "TRS"; + t[t.TRS_MASK = ~t.TRS] = "TRS_MASK"; + }(ay || (ay = {})); + m.internal.TransformBit = ay; + const ly = new Float32Array(jsb.createExternalArrayBuffer(80)); + const hy = function(t) { + qi.set(t, ly[0], ly[1], ly[2], ly[3], ly[4], ly[5], ly[6], ly[7], ly[8], ly[9], ly[10], ly[11], ly[12], ly[13], ly[14], ly[15]); + }; + co.Flags.Destroying; + jsb.BaseNode.prototype.createNode = null; + const cy = jsb.BaseNode; + m._BaseNode = cy; + Ul("cc.BaseNode")(cy); + const uy = Symbol("ReserveContentsForAllSyncablePrefab"); + const _y = t("Node", jsb.Node); + m.Node = _y; + const dy = _y; + dy.reserveContentsForAllSyncablePrefabTag = uy; + dy.EventType = ny; + dy.NodeSpace = oy; + dy.TransformDirtyBit = ay; + dy.TransformBit = ay; + const py = ay.TRS; + const my = jsb.Node.prototype; + const fy = t("TRANSFORM_ON", 1); + const gy = co.Flags.Destroying; + _y._setTempFloatArray(ly.buffer); + function yy(t) { + return t ? "string" == typeof t ? Jt(t) : t : null; + } + my.attr = function(t) { + Nt(this, t); + }; + my.getComponent = function(t) { + const e = yy(t); + return e ? dy._findComponent(this, e) : null; + }; + my.getComponents = function(t) { + const e = yy(t); + const i = []; + e && dy._findComponents(this, e, i); + return i; + }; + my.getComponentInChildren = function(t) { + const e = yy(t); + return e ? dy._findChildComponent(this._children, e) : null; + }; + my.getComponentsInChildren = function(t) { + const e = yy(t); + const i = []; + if (e) { + dy._findComponents(this, e, i); + dy._findChildComponents(this.children, e, i); + } + return i; + }; + my.addComponent = function(t) { + let e; + if ("string" == typeof t) { + e = Jt(t); + if (!e) { + m._RF.peek() && F(3808, t); + throw TypeError(G(3807, t)); + } + } else { + if (!t) throw TypeError(G(3804)); + e = t; + } + if ("function" != typeof e) throw TypeError(G(3809)); + if (!Vt(e, Qc)) throw TypeError(G(3810)); + const i = e._requireComponent; + i && !this.getComponent(i) && this.addComponent(i); + const s = new e; + s.node = this; + this._components.push(s); + this.emit(ny.COMPONENT_ADDED, s); + this._activeInHierarchy && m.director._nodeActivator.activateComp(s); + return s; + }; + my.removeComponent = function(t) { + if (!t) { + F(3813); + return; + } + let e = null; + e = t instanceof Qc ? t : this.getComponent(t); + e && e.destroy(); + }; + my.on = function(t, e, i, s = !1) { + switch (t) { + case ny.TRANSFORM_CHANGED: + this._eventMask |= fy; + if (!(1 & this._registeredNodeEventTypeMask)) { + this._registerOnTransformChanged(); + this._registeredNodeEventTypeMask |= 1; + } + break; + + case ny.PARENT_CHANGED: + if (!(2 & this._registeredNodeEventTypeMask)) { + this._registerOnParentChanged(); + this._registeredNodeEventTypeMask |= 2; + } + break; + + case ny.LAYER_CHANGED: + if (!(4 & this._registeredNodeEventTypeMask)) { + this._registerOnLayerChanged(); + this._registeredNodeEventTypeMask |= 4; + } + break; + + case ny.CHILD_REMOVED: + if (!(8 & this._registeredNodeEventTypeMask)) { + this._registerOnChildRemoved(); + this._registeredNodeEventTypeMask |= 8; + } + break; + + case ny.CHILD_ADDED: + if (!(16 & this._registeredNodeEventTypeMask)) { + this._registerOnChildAdded(); + this._registeredNodeEventTypeMask |= 16; + } + break; + + case ny.SIBLING_ORDER_CHANGED: + if (!(32 & this._registeredNodeEventTypeMask)) { + this._registerOnSiblingOrderChanged(); + this._registeredNodeEventTypeMask |= 32; + } + } + this._eventProcessor.on(t, e, i, s); + }; + my.off = function(t, e, i, s = !1) { + this._eventProcessor.off(t, e, i, s); + if (!this._eventProcessor.hasEventListener(t) && t === ny.TRANSFORM_CHANGED) this._eventMask &= ~fy; + }; + my.once = function(t, e, i, s) { + this._eventProcessor.once(t, e, i, s); + }; + my.emit = function(t, e, i, s, n, r) { + this._eventProcessor.emit(t, e, i, s, n, r); + }; + my.dispatchEvent = function(t) { + this._eventProcessor.dispatchEvent(t); + }; + my.hasEventListener = function(t, e, i) { + return this._eventProcessor.hasEventListener(t, e, i); + }; + my.targetOff = function(t) { + this._eventMask & fy && !this._eventProcessor.hasEventListener(ny.TRANSFORM_CHANGED) && (this._eventMask &= ~fy); + }; + my._removeComponent = function(t) { + if (t) { + if (!(this._objFlags & gy)) { + const e = this._components.indexOf(t); + if (-1 !== e) { + this._components.splice(e, 1); + this.emit(ny.COMPONENT_REMOVED, t); + } else t.node !== this && F(3815); + } + } else F(3814); + }; + my._registerIfAttached = void 0; + my._onTransformChanged = function(t) { + this.emit(ny.TRANSFORM_CHANGED, t); + }; + my._onParentChanged = function(t) { + this.emit(ny.PARENT_CHANGED, t); + }; + my._onReAttach = function() { + this._eventProcessor.reattach(); + }; + my._onEditorAttached = function(t) {}; + my._onRemovePersistRootNode = function() { + m.game.removePersistRootNode(this); + }; + my._onDestroyComponents = function() { + this._eventProcessor.destroy(); + const t = this._components; + for (let e = 0; e < t.length; ++e) t[e]._destroyImmediate(); + }; + my._onLayerChanged = function(t) { + this.emit(ny.LAYER_CHANGED, t); + }; + my._onChildRemoved = function(t) { + this.emit(ny.CHILD_REMOVED, t); + }; + my._onChildAdded = function(t) { + this.emit(ny.CHILD_ADDED, t); + }; + my._onNodeDestroyed = function() { + this.emit(ny.NODE_DESTROYED, this); + const t = this._children; + for (let e = 0; e < t.length; ++e) t[e]._destroyImmediate(); + }; + const by = my._onPreDestroy; + my._onPreDestroy = function() { + const t = by.call(this); + this.emit(ny.NODE_DESTROYED, this); + this._eventProcessor.destroy(); + const e = this._children; + for (let t = 0; t < e.length; ++t) e[t]._destroyImmediate(); + const i = this._components; + for (let t = 0; t < i.length; ++t) i[t]._destroyImmediate(); + return t; + }; + my.destroyAllChildren = function() { + const t = this._children; + for (let e = 0, i = t.length; e < i; ++e) t[e].destroy(); + }; + my._onSiblingOrderChanged = function() { + this.emit(ny.SIBLING_ORDER_CHANGED); + }; + my._onActivateNode = function(t) { + m.director._nodeActivator.activateNode(this, t); + }; + my._onPostActivated = function(t) { + if (t) { + this._eventProcessor.setEnabled(!0); + this.invalidateChildren(ay.TRS); + if (this._uiProps && this._uiProps.uiComp) { + this._uiProps.uiComp.setNodeDirty(); + this._uiProps.uiComp.setTextureDirty(); + this._uiProps.uiComp.markForUpdateRenderData(); + } + } else this._eventProcessor.setEnabled(!1); + }; + dy._findComponent = function(t, e) { + const i = e; + const s = t._components; + if (i._sealed) for (let t = 0; t < s.length; ++t) { + const i = s[t]; + if (i.constructor === e) return i; + } else for (let t = 0; t < s.length; ++t) { + const i = s[t]; + if (i instanceof e) return i; + } + return null; + }; + dy._findComponents = function(t, e, i) { + const s = e; + const n = t._components; + if (s._sealed) for (let t = 0; t < n.length; ++t) { + const s = n[t]; + s.constructor === e && i.push(s); + } else for (let t = 0; t < n.length; ++t) { + const s = n[t]; + s instanceof e && i.push(s); + } + }; + dy._findChildComponent = function(t, e) { + for (let i = 0; i < t.length; ++i) { + const s = t[i]; + let n = dy._findComponent(s, e); + if (n) return n; + const r = s.children; + if (r.length > 0) { + n = dy._findChildComponent(r, e); + if (n) return n; + } + } + return null; + }; + dy._findChildComponents = function(t, e, i) { + for (let s = 0; s < t.length; ++s) { + const n = t[s]; + dy._findComponents(n, e, i); + const r = n.children; + r.length > 0 && dy._findChildComponents(r, e, i); + } + }; + dy.isNode = function(t) { + return t instanceof jsb.Node && (t.constructor === jsb.Node || !(t instanceof m.Scene)); + }; + let Sy = new Ui; + my.setRTS = function(t, e, i) { + if (t) { + let e = Sy; + t instanceof Ui ? e = t : Ui.fromEuler(e, t.x, t.y, t.z); + ly[0] = 4; + ly[1] = e.x; + ly[2] = e.y; + ly[3] = e.z; + ly[4] = e.w; + this._lrot.set(e.x, e.y, e.z, e.w); + } else ly[0] = 0; + if (e) { + ly[5] = 3; + ly[6] = e.x; + ly[7] = e.y; + ly[8] = e.z; + this._lpos.set(e.x, e.y, e.z); + } else ly[5] = 0; + if (i) { + ly[9] = 3; + ly[10] = i.x; + ly[11] = i.y; + ly[12] = i.z; + this._lscale.set(i.x, i.y, i.z); + } else ly[9] = 0; + this._setRTS(); + }; + my.getPosition = function(t) { + return t ? Pi.set(t, this._lpos.x, this._lpos.y, this._lpos.z) : Pi.copy(new Pi, this._lpos); + }; + my.setPosition = function(t, e, i) { + if (void 0 === e && void 0 === i) { + ly[0] = 3; + const e = t; + this._lpos.x = ly[1] = e.x; + this._lpos.y = ly[2] = e.y; + this._lpos.z = ly[3] = e.z; + } else if (void 0 === i) { + ly[0] = 2; + this._lpos.x = ly[1] = t; + this._lpos.y = ly[2] = e; + } else { + ly[0] = 3; + this._lpos.x = ly[1] = t; + this._lpos.y = ly[2] = e; + this._lpos.z = ly[3] = i; + } + this._setPosition(); + }; + my.getRotation = function(t) { + const e = this._lrot; + return t ? Ui.set(t, e.x, e.y, e.z, e.w) : Ui.copy(new Ui, e); + }; + my.setRotation = function(t, e, i, s) { + if (void 0 === e || void 0 === i || void 0 === s) { + const e = t; + this._lrot.x = ly[0] = e.x; + this._lrot.y = ly[1] = e.y; + this._lrot.z = ly[2] = e.z; + this._lrot.w = ly[3] = e.w; + } else { + this._lrot.x = ly[0] = t; + this._lrot.y = ly[1] = e; + this._lrot.z = ly[2] = i; + this._lrot.w = ly[3] = s; + } + this._setRotation(); + }; + my.setRotationFromEuler = function(t, e, i) { + const s = void 0 === i ? this._euler.z : i; + if (void 0 === e) { + const e = t; + this._euler.x = ly[0] = e.x; + this._euler.y = ly[1] = e.y; + this._euler.z = ly[2] = e.z; + } else { + this._euler.x = ly[0] = t; + this._euler.y = ly[1] = e; + this._euler.z = ly[2] = s; + } + this._setRotationFromEuler(); + }; + my.getScale = function(t) { + return t ? Pi.set(t, this._lscale.x, this._lscale.y, this._lscale.z) : Pi.copy(new Pi, this._lscale); + }; + my.setScale = function(t, e, i) { + if (void 0 === e && void 0 === i) { + ly[0] = 3; + const e = t; + this._lscale.x = ly[1] = e.x; + this._lscale.y = ly[2] = e.y; + this._lscale.z = ly[3] = e.z; + } else if (void 0 === i) { + ly[0] = 2; + this._lscale.x = ly[1] = t; + this._lscale.y = ly[2] = e; + } else { + ly[0] = 3; + this._lscale.x = ly[1] = t; + this._lscale.y = ly[2] = e; + this._lscale.z = ly[3] = i; + } + this._setScale(); + }; + my.getWorldPosition = function(t) { + this._getWorldPosition(); + return (t = t || new Pi).set(ly[0], ly[1], ly[2]); + }; + my.getWorldRotation = function(t) { + this._getWorldRotation(); + return (t = t || new Ui).set(ly[0], ly[1], ly[2], ly[3]); + }; + my.getWorldScale = function(t) { + this._getWorldScale(); + return (t = t || new Pi).set(ly[0], ly[1], ly[2]); + }; + my.getWorldMatrix = function(t) { + this._getWorldMatrix(); + t = t || new qi; + hy(t); + return t; + }; + my.getEulerAngles = function(t) { + this._getEulerAngles(); + return (t = t || new Pi).set(ly[0], ly[1], ly[2]); + }; + my.getForward = function(t) { + this._getForward(); + return (t = t || new Pi).set(ly[0], ly[1], ly[2]); + }; + my.getUp = function(t) { + this._getUp(); + return (t = t || new Pi).set(ly[0], ly[1], ly[2]); + }; + my.getRight = function(t) { + this._getRight(); + return (t = t || new Pi).set(ly[0], ly[1], ly[2]); + }; + my.inverseTransformPoint = function(t, e) { + ly[0] = e.x; + ly[1] = e.y; + ly[2] = e.z; + this._inverseTransformPoint(); + t.x = ly[0]; + t.y = ly[1]; + t.z = ly[2]; + return t; + }; + my.getWorldRT = function(t) { + t = t || new qi; + this._getWorldRT(); + hy(t); + return t; + }; + my.getWorldRS = function(t) { + t = t || new qi; + this._getWorldRS(); + hy(t); + return t; + }; + Object.defineProperty(my, "position", { + configurable: !0, + enumerable: !0, + get() { + return this._lpos; + }, + set(t) { + this.setPosition(t); + } + }); + Object.defineProperty(my, "rotation", { + configurable: !0, + enumerable: !0, + get() { + return this._lrot; + }, + set(t) { + this.setRotation(t); + } + }); + Object.defineProperty(my, "scale", { + configurable: !0, + enumerable: !0, + get() { + return this._lscale; + }, + set(t) { + this.setScale(t); + } + }); + Object.defineProperty(my, "worldPosition", { + configurable: !0, + enumerable: !0, + get() { + return this.getWorldPosition(); + }, + set(t) { + this.setWorldPosition(t); + } + }); + Object.defineProperty(my, "worldRotation", { + configurable: !0, + enumerable: !0, + get() { + return this.getWorldRotation(); + }, + set(t) { + this.setWorldRotation(t); + } + }); + Object.defineProperty(my, "worldScale", { + configurable: !0, + enumerable: !0, + get() { + return this.getWorldScale(); + }, + set(t) { + this.setWorldScale(t); + } + }); + Object.defineProperty(my, "_pos", { + configurable: !0, + enumerable: !0, + get() { + return this.getWorldPosition(); + } + }); + Object.defineProperty(my, "_rot", { + configurable: !0, + enumerable: !0, + get() { + return this.getWorldRotation(); + } + }); + Object.defineProperty(my, "_scale", { + configurable: !0, + enumerable: !0, + get() { + return this.getWorldScale(); + } + }); + Object.defineProperty(my, "eulerAngles", { + configurable: !0, + enumerable: !0, + get() { + return this.getEulerAngles(); + }, + set(t) { + this.setRotationFromEuler(t.x, t.y, t.z); + } + }); + Object.defineProperty(my, "worldMatrix", { + configurable: !0, + enumerable: !0, + get() { + return this.getWorldMatrix(); + } + }); + Object.defineProperty(my, "_mat", { + configurable: !0, + enumerable: !0, + get() { + return this.getWorldMatrix(); + } + }); + Object.defineProperty(my, "activeInHierarchy", { + configurable: !0, + enumerable: !0, + get() { + return 0 != this._sharedUint8Arr[0]; + }, + set(t) { + this._sharedUint8Arr[0] = t ? 1 : 0; + } + }); + Object.defineProperty(my, "_activeInHierarchy", { + configurable: !0, + enumerable: !0, + get() { + return 0 != this._sharedUint8Arr[0]; + }, + set(t) { + this._sharedUint8Arr[0] = t ? 1 : 0; + } + }); + Object.defineProperty(my, "layer", { + configurable: !0, + enumerable: !0, + get() { + return this._sharedUint32Arr[1]; + }, + set(t) { + this._sharedUint32Arr[1] = t; + if (this._uiProps && this._uiProps.uiComp) { + this._uiProps.uiComp.setNodeDirty(); + this._uiProps.uiComp.markForUpdateRenderData(); + } + this.emit(ny.LAYER_CHANGED, t); + } + }); + Object.defineProperty(my, "_layer", { + configurable: !0, + enumerable: !0, + get() { + return this._sharedUint32Arr[1]; + }, + set(t) { + this._sharedUint32Arr[1] = t; + } + }); + Object.defineProperty(my, "_eventMask", { + configurable: !0, + enumerable: !0, + get() { + return this._sharedUint32Arr[0]; + }, + set(t) { + this._sharedUint32Arr[0] = t; + } + }); + Object.defineProperty(my, "_siblingIndex", { + configurable: !0, + enumerable: !0, + get() { + return this._sharedInt32Arr[0]; + }, + set(t) { + this._sharedInt32Arr[0] = t; + } + }); + my.getSiblingIndex = function() { + return this._sharedInt32Arr[0]; + }; + Object.defineProperty(my, "_dirtyFlags", { + configurable: !0, + enumerable: !0, + get() { + return this._sharedUint32Arr[2]; + }, + set(t) { + this._sharedUint32Arr[2] = t; + } + }); + Object.defineProperty(my, "_active", { + configurable: !0, + enumerable: !0, + get() { + return 0 != this._sharedUint8Arr[1]; + }, + set(t) { + this._sharedUint8Arr[1] = t ? 1 : 0; + } + }); + Object.defineProperty(my, "active", { + configurable: !0, + enumerable: !0, + get() { + return 0 != this._sharedUint8Arr[1]; + }, + set(t) { + this.setActive(!!t); + } + }); + Object.defineProperty(my, "_static", { + configurable: !0, + enumerable: !0, + get() { + return 0 != this._sharedUint8Arr[2]; + }, + set(t) { + this._sharedUint8Arr[2] = t ? 1 : 0; + } + }); + Object.defineProperty(my, "forward", { + configurable: !0, + enumerable: !0, + get() { + return this.getForward(); + }, + set(t) { + this.setForward(t); + } + }); + Object.defineProperty(my, "up", { + configurable: !0, + enumerable: !0, + get() { + return this.getUp(); + } + }); + Object.defineProperty(my, "right", { + configurable: !0, + enumerable: !0, + get() { + return this.getRight(); + } + }); + Object.defineProperty(my, "eventProcessor", { + configurable: !0, + enumerable: !0, + get() { + return this._eventProcessor; + } + }); + Object.defineProperty(my, "components", { + configurable: !0, + enumerable: !0, + get() { + return this._components; + } + }); + Object.defineProperty(my, "_parent", { + configurable: !0, + enumerable: !0, + get() { + this._parentRef = this._parentInternal; + return this._parentRef; + }, + set(t) { + this._parentRef = this._parentInternal = t; + } + }); + Object.defineProperty(my, "parent", { + configurable: !0, + enumerable: !0, + get() { + this._parentRef = this.getParent(); + return this._parentRef; + }, + set(t) { + this._parentRef = t; + this.setParent(t); + } + }); + Object.defineProperty(my, "children", { + configurable: !0, + enumerable: !0, + get() { + return this._children; + }, + set(t) { + this._children = t; + } + }); + Object.defineProperty(my, "scene", { + configurable: !0, + enumerable: !0, + get() { + return this._scene; + } + }); + my.rotate = function(t, e) { + ly[1] = t.x; + ly[2] = t.y; + ly[3] = t.z; + ly[4] = t.w; + if (e) { + ly[5] = e; + ly[0] = 5; + } else ly[0] = 4; + this._rotateForJS(); + const i = this._lrot; + i.x = ly[0]; + i.y = ly[1]; + i.z = ly[2]; + i.w = ly[3]; + }; + my.addChild = function(t) { + t.setParent(this); + }; + my.insertChild = function(t, e) { + t.parent = this; + t.setSiblingIndex(e); + }; + my[nu] = function(t, e) { + t.writeThis(); + const i = () => { + var t; + return !!(null === (t = this[io]) || void 0 === t ? void 0 : t.mountedRoot); + }; + const s = () => { + var t, e, s, n; + return (null === (t = this._prefab) || void 0 === t || null === (e = t.root) || void 0 === e || null === (s = e._prefab) || void 0 === s ? void 0 : s.instance) && ((null == this || null === (n = this._prefab) || void 0 === n ? void 0 : n.instance) || !i()); + }; + if ((() => !(e.customArguments[uy] || !s() || e.root === this))()) { + var n; + if ((null === (n = this._prefab) || void 0 === n ? void 0 : n.root) === this) { + t.writeProperty("_objFlags", this._objFlags); + t.writeProperty("_parent", this._parent); + t.writeProperty("_prefab", this._prefab); + e.customArguments.keepNodeUuid && t.writeProperty("_id", this._id); + t.writeProperty(io, this[io]); + } + } else t.writeThis(); + }; + my._onActiveNode = function(t) { + m.director._nodeActivator.activateNode(this, t); + }; + my._onBatchCreated = function(t) { + this.hasChangedFlags = py; + this._dirtyFlags |= py; + const e = this._children; + const i = e.length; + let s; + for (let n = 0; n < i; ++n) { + s = e[n]; + s._siblingIndex = n; + s._onBatchCreated(t); + } + !function(t) { + const e = t._lpos; + t.setPositionForJS(e.x, e.y, e.z); + const i = t._lscale; + t.setScaleForJS(i.x, i.y, i.z); + const s = t._lrot; + t.setRotationForJS(s.x, s.y, s.z, s.w); + const n = t._euler; + t.setRotationFromEulerForJS(n.x, n.y, n.z); + }(this); + }; + my._onSceneUpdated = function(t) { + this._scene = t; + }; + my._onLocalPositionUpdated = function(t, e, i) { + const s = this._lpos; + s.x = t; + s.y = e; + s.z = i; + }; + my._onLocalRotationUpdated = function(t, e, i, s) { + const n = this._lrot; + n.x = t; + n.y = e; + n.z = i; + n.w = s; + }; + my._onLocalScaleUpdated = function(t, e, i) { + const s = this._lscale; + s.x = t; + s.y = e; + s.z = i; + }; + my._onLocalPositionRotationScaleUpdated = function(t, e, i, s, n, r, o, a, l, h) { + const c = this._lpos; + c.x = t; + c.y = e; + c.z = i; + const u = this._lrot; + u.x = s; + u.y = n; + u.z = r; + u.w = o; + const _ = this._lscale; + _.x = a; + _.y = l; + _.z = h; + }; + my._instantiate = function(t, e) { + t || (t = m.instantiate._clone(this, this)); + t._prefab; + t._parent = null; + t._onBatchCreated(e); + return t; + }; + my._ctor = function(t) { + this.__nativeRefs = {}; + this._parentRef = null; + this.__jsb_ref_id = void 0; + this._iN$t = null; + this.__editorExtras__ = { + editorOnly: !0 + }; + this._components = []; + this._eventProcessor = new m.NodeEventProcessor(this); + this._uiProps = new ry(this); + const e = this._getSharedArrayBufferObject(); + this._sharedUint32Arr = new Uint32Array(e, 0, 3); + this._sharedInt32Arr = new Int32Array(e, 12, 1); + this._sharedUint8Arr = new Uint8Array(e, 16, 3); + this._sharedUint32Arr[1] = mm.Enum.DEFAULT; + this._scene = null; + this._prefab = null; + this._originalSceneId = ""; + this._registerListeners(); + this._children = []; + this._lpos = new Pi; + this._lrot = new Ui; + this._lscale = new Pi(1, 1, 1); + this._euler = new Pi; + this._registeredNodeEventTypeMask = 0; + this.on(ny.CHILD_ADDED, (t => { + this._children.push(t); + })); + this.on(ny.CHILD_REMOVED, (t => { + const e = this._children.indexOf(t); + e < 0 ? F(1633) : this._children.splice(e, 1); + })); + this._onSiblingIndexChanged = function(t) { + const e = this._parent._children; + t = -1 !== t ? t : e.length - 1; + const i = e.indexOf(this); + if (t !== i) { + e.splice(i, 1); + t < e.length ? e.splice(t, 0, this) : e.push(this); + } + }; + }; + const Ay = _y.prototype; + jl(Ay, "_persistNode", Object.getOwnPropertyDescriptor(Ay, "_persistNode")); + Yl(Ay, "_parent"); + Yl(Ay, "_children"); + Yl(Ay, "_active"); + Yl(Ay, "_components"); + Yl(Ay, "_prefab"); + Yl(Ay, "_lpos"); + Yl(Ay, "_lrot"); + Yl(Ay, "_lscale"); + Yl(Ay, "_layer"); + Yl(Ay, "_euler"); + const Ty = Object.getOwnPropertyDescriptor(Ay, "eulerAngles"); + Th(Pi)(Ay, "eulerAngles", Ty); + Ul("cc.Node")(_y); + si.Attr.setClassAttr(Vc, "target", "type", "Object"); + si.Attr.setClassAttr(Vc, "target", "ctor", _y); + let vy; + !function(t) { + t[t.VERTICAL = 0] = "VERTICAL"; + t[t.HORIZONTAL = 1] = "HORIZONTAL"; + }(vy || (vy = {})); + let Ey; + !function(t) { + t[t.ORTHO = 0] = "ORTHO"; + t[t.PERSPECTIVE = 1] = "PERSPECTIVE"; + }(Ey || (Ey = {})); + let Cy; + !function(t) { + t[t.F1_8 = 0] = "F1_8"; + t[t.F2_0 = 1] = "F2_0"; + t[t.F2_2 = 2] = "F2_2"; + t[t.F2_5 = 3] = "F2_5"; + t[t.F2_8 = 4] = "F2_8"; + t[t.F3_2 = 5] = "F3_2"; + t[t.F3_5 = 6] = "F3_5"; + t[t.F4_0 = 7] = "F4_0"; + t[t.F4_5 = 8] = "F4_5"; + t[t.F5_0 = 9] = "F5_0"; + t[t.F5_6 = 10] = "F5_6"; + t[t.F6_3 = 11] = "F6_3"; + t[t.F7_1 = 12] = "F7_1"; + t[t.F8_0 = 13] = "F8_0"; + t[t.F9_0 = 14] = "F9_0"; + t[t.F10_0 = 15] = "F10_0"; + t[t.F11_0 = 16] = "F11_0"; + t[t.F13_0 = 17] = "F13_0"; + t[t.F14_0 = 18] = "F14_0"; + t[t.F16_0 = 19] = "F16_0"; + t[t.F18_0 = 20] = "F18_0"; + t[t.F20_0 = 21] = "F20_0"; + t[t.F22_0 = 22] = "F22_0"; + }(Cy || (Cy = {})); + let xy; + !function(t) { + t[t.ISO100 = 0] = "ISO100"; + t[t.ISO200 = 1] = "ISO200"; + t[t.ISO400 = 2] = "ISO400"; + t[t.ISO800 = 3] = "ISO800"; + }(xy || (xy = {})); + let wy; + !function(t) { + t[t.D1 = 0] = "D1"; + t[t.D2 = 1] = "D2"; + t[t.D4 = 2] = "D4"; + t[t.D8 = 3] = "D8"; + t[t.D15 = 4] = "D15"; + t[t.D30 = 5] = "D30"; + t[t.D60 = 6] = "D60"; + t[t.D125 = 7] = "D125"; + t[t.D250 = 8] = "D250"; + t[t.D500 = 9] = "D500"; + t[t.D1000 = 10] = "D1000"; + t[t.D2000 = 11] = "D2000"; + t[t.D4000 = 12] = "D4000"; + }(wy || (wy = {})); + let Ry; + !function(t) { + t[t.DEFAULT = -1] = "DEFAULT"; + t[t.LEFT_EYE = 0] = "LEFT_EYE"; + t[t.RIGHT_EYE = 1] = "RIGHT_EYE"; + t[t.MAIN = 2] = "MAIN"; + }(Ry || (Ry = {})); + let Iy; + !function(t) { + t[t.NO_TRACKING = 0] = "NO_TRACKING"; + t[t.POSITION_AND_ROTATION = 1] = "POSITION_AND_ROTATION"; + t[t.POSITION = 2] = "POSITION"; + t[t.ROTATION = 3] = "ROTATION"; + }(Iy || (Iy = {})); + const My = en.STENCIL << 1; + const By = jsb.Camera; + const Dy = jsb.Camera.prototype; + Object.defineProperty(By, "standardExposureValue", { + configurable: !0, + enumerable: !0, + get: () => By.getStandardExposureValue() + }); + Object.defineProperty(By, "standardLightMeterScale", { + configurable: !0, + enumerable: !0, + get: () => By.getStandardLightMeterScale() + }); + Object.defineProperty(Dy, "matView", { + configurable: !0, + enumerable: !0, + get() { + this.getMatView(); + hy(this._matView); + return this._matView; + } + }); + Object.defineProperty(Dy, "matProj", { + configurable: !0, + enumerable: !0, + get() { + this.getMatProj(); + hy(this._matProj); + return this._matProj; + } + }); + Object.defineProperty(Dy, "matProjInv", { + configurable: !0, + enumerable: !0, + get() { + this.getMatProjInv(); + hy(this._matProjInv); + return this._matProjInv; + } + }); + Object.defineProperty(Dy, "matViewProj", { + configurable: !0, + enumerable: !0, + get() { + this.getMatViewProj(); + hy(this._matViewProj); + return this._matViewProj; + } + }); + Object.defineProperty(Dy, "matViewProjInv", { + configurable: !0, + enumerable: !0, + get() { + this.getMatViewProjInv(); + hy(this._matViewProjInv); + return this._matViewProjInv; + } + }); + const Py = Dy.initialize; + Dy.initialize = function() { + Py.apply(this, arguments); + this._matView = new qi; + this._matProj = new qi; + this._matProjInv = new qi; + this._matViewProj = new qi; + this._matViewProjInv = new qi; + }; + const Oy = Dy.screenPointToRay; + const Ny = Dy.screenToWorld; + const Ly = Dy.worldToScreen; + const Fy = Dy.worldMatrixToScreen; + Dy.screenPointToRay = function(t, e, i) { + ly[0] = e; + ly[1] = i; + Oy.call(this); + t.o.x = ly[0]; + t.o.y = ly[1]; + t.o.z = ly[2]; + t.d.x = ly[3]; + t.d.y = ly[4]; + t.d.z = ly[5]; + return t; + }; + Dy.screenToWorld = function(t, e) { + ly[0] = e.x; + ly[1] = e.y; + ly[2] = e.z; + Ny.call(this); + Pi.set(t, ly[0], ly[1], ly[2]); + return t; + }; + Dy.worldToScreen = function(t, e) { + ly[0] = e.x; + ly[1] = e.y; + ly[2] = e.z; + Ly.call(this); + Pi.set(t, ly[0], ly[1], ly[2]); + return t; + }; + Dy.worldMatrixToScreen = function(t, e, i, s) { + ly[0] = e.m00; + ly[1] = e.m01; + ly[2] = e.m02; + ly[3] = e.m03; + ly[4] = e.m04; + ly[5] = e.m05; + ly[6] = e.m06; + ly[7] = e.m07; + ly[8] = e.m08; + ly[9] = e.m09; + ly[10] = e.m10; + ly[11] = e.m11; + ly[12] = e.m12; + ly[13] = e.m13; + ly[14] = e.m14; + ly[15] = e.m15; + ly[16] = i; + ly[17] = s; + Fy.call(this); + hy(t); + return t; + }; + var Vy, ky, Uy, Gy, zy, Hy, jy, Xy, Wy, Yy, qy, Ky, Jy, Zy, Qy, $y, tb, eb, ib, sb, nb, rb, ob, ab, lb, hb, cb, ub, _b, db, pb, mb, fb, gb, yb, bb, Sb, Ab, Tb, vb, Eb, Cb, xb, wb, Rb, Ib, Mb, Bb, Db, Pb, Ob, Nb, Lb, Fb, Vb, kb, Ub, Gb, zb, Hb, jb, Xb, Wb, Yb, qb, Kb, Jb, Zb, Qb, $b, tS, eS; + const iS = new Pi; + const sS = oe(Ey); + const nS = oe(vy); + const rS = oe(Cy); + const oS = oe(wy); + const aS = oe(xy); + const lS = oe({ + SKYBOX: My | en.DEPTH_STENCIL, + SOLID_COLOR: en.ALL, + DEPTH_ONLY: en.DEPTH_STENCIL, + DONT_CLEAR: en.NONE + }); + let hS = (cS = (Vy = Ul("cc.Camera"), ky = sh(), Uy = $l(), Gy = ph(), zy = lh(), + Hy = Th(mm.BitMask), jy = ph(), Xy = lh(), Wy = Th(lS), Yy = ph(), qy = lh(), Ky = ph(), + Jy = lh(), Zy = ph(), Qy = lh(), $y = ph(), tb = lh(), eb = Th(sS), ib = ph(), sb = lh(), + nb = Th(nS), rb = ph(), ob = rh(), ab = lh(), lb = ph(), hb = rh(), cb = lh(), ub = ph(), + _b = rh(), db = lh(), pb = ph(), mb = lh(), fb = ph(), gb = lh(), yb = Th(rS), bb = ph(), + Sb = lh(), Ab = Th(oS), Tb = ph(), vb = lh(), Eb = Th(aS), Cb = ph(), xb = lh(), + wb = ph(), Rb = lh(), Ib = Th(Vg), Mb = ph(), Bb = lh(), Vy(Db = ky(Db = Uy(Db = Ql(Db = (Pb = (eS = tS = class t extends Qc { + constructor(...t) { + super(...t); + Ml(this, "_projection", Ob, this); + Ml(this, "_priority", Nb, this); + Ml(this, "_fov", Lb, this); + Ml(this, "_fovAxis", Fb, this); + Ml(this, "_orthoHeight", Vb, this); + Ml(this, "_near", kb, this); + Ml(this, "_far", Ub, this); + Ml(this, "_color", Gb, this); + Ml(this, "_depth", zb, this); + Ml(this, "_stencil", Hb, this); + Ml(this, "_clearFlags", jb, this); + Ml(this, "_rect", Xb, this); + Ml(this, "_aperture", Wb, this); + Ml(this, "_shutter", Yb, this); + Ml(this, "_iso", qb, this); + Ml(this, "_screenScale", Kb, this); + Ml(this, "_visibility", Jb, this); + Ml(this, "_targetTexture", Zb, this); + this._camera = null; + this._inEditorMode = !1; + this._flows = void 0; + Ml(this, "_cameraType", Qb, this); + Ml(this, "_trackingType", $b, this); + } + get camera() { + return this._camera; + } + get priority() { + return this._priority; + } + set priority(t) { + this._priority = t; + this._camera && (this._camera.priority = t); + } + get visibility() { + return this._visibility; + } + set visibility(t) { + this._visibility = t; + this._camera && (this._camera.visibility = t); + } + get clearFlags() { + return this._clearFlags; + } + set clearFlags(t) { + this._clearFlags = t; + this._camera && (this._camera.clearFlag = t); + } + get clearColor() { + return this._color; + } + set clearColor(t) { + this._color.set(t); + this._camera && (this._camera.clearColor = this._color); + } + get clearDepth() { + return this._depth; + } + set clearDepth(t) { + this._depth = t; + this._camera && (this._camera.clearDepth = t); + } + get clearStencil() { + return this._stencil; + } + set clearStencil(t) { + this._stencil = t; + this._camera && (this._camera.clearStencil = t); + } + get projection() { + return this._projection; + } + set projection(t) { + this._projection = t; + this._camera && (this._camera.projectionType = t); + } + get fovAxis() { + return this._fovAxis; + } + set fovAxis(t) { + if (t !== this._fovAxis) { + this._fovAxis = t; + if (this._camera) { + this._camera.fovAxis = t; + t === vy.VERTICAL ? this.fov = this._fov * this._camera.aspect : this.fov = this._fov / this._camera.aspect; + } + } + } + get fov() { + return this._fov; + } + set fov(t) { + this._fov = t; + this._camera && (this._camera.fov = mi(t)); + } + get orthoHeight() { + return this._orthoHeight; + } + set orthoHeight(t) { + this._orthoHeight = t; + this._camera && (this._camera.orthoHeight = t); + } + get near() { + return this._near; + } + set near(t) { + this._near = t; + this._camera && (this._camera.nearClip = t); + } + get far() { + return this._far; + } + set far(t) { + this._far = t; + this._camera && (this._camera.farClip = t); + } + get aperture() { + return this._aperture; + } + set aperture(t) { + this._aperture = t; + this._camera && (this._camera.aperture = t); + } + get shutter() { + return this._shutter; + } + set shutter(t) { + this._shutter = t; + this._camera && (this._camera.shutter = t); + } + get iso() { + return this._iso; + } + set iso(t) { + this._iso = t; + this._camera && (this._camera.iso = t); + } + get rect() { + return this._rect; + } + set rect(t) { + this._rect = t; + this._camera && this._camera.setViewportInOrientedSpace(t); + } + get targetTexture() { + return this._targetTexture; + } + set targetTexture(e) { + if (this._targetTexture === e) return; + const i = this._targetTexture; + this._targetTexture = e; + this._checkTargetTextureEvent(i); + this._updateTargetTexture(); + if (!e && this._camera) { + this._camera.changeTargetWindow(null); + this._camera.isWindowSize = !0; + } + this.node.emit(t.TARGET_TEXTURE_CHANGE, this); + } + get screenScale() { + return this._screenScale; + } + set screenScale(t) { + this._screenScale = t; + this._camera && (this._camera.screenScale = t); + } + get inEditorMode() { + return this._inEditorMode; + } + set inEditorMode(t) { + this._inEditorMode = t; + this._camera && this._camera.changeTargetWindow(t ? m.director.root && m.director.root.mainWindow : m.director.root && m.director.root.tempWindow); + } + get cameraType() { + return this._cameraType; + } + set cameraType(t) { + if (this._cameraType !== t) { + this._cameraType = t; + this.camera && (this.camera.cameraType = t); + } + } + get trackingType() { + return this._trackingType; + } + set trackingType(t) { + if (this._trackingType !== t) { + this._trackingType = t; + this.camera && (this.camera.trackingType = t); + } + } + onLoad() { + this._createCamera(); + } + onEnable() { + this.node.hasChangedFlags |= ay.POSITION; + this._camera && this._attachToScene(); + } + onDisable() { + this._camera && this._detachFromScene(); + } + onDestroy() { + if (this._camera) { + this._camera.destroy(); + this._camera = null; + } + this._targetTexture && this._targetTexture.off("resize"); + } + screenPointToRay(t, e, i) { + i || (i = ra.create()); + this._camera && this._camera.screenPointToRay(i, t, e); + return i; + } + worldToScreen(t, e) { + e || (e = new Pi); + this._camera && this._camera.worldToScreen(e, t); + return e; + } + screenToWorld(t, e) { + e || (e = this.node.getWorldPosition()); + this._camera && this._camera.screenToWorld(e, t); + return e; + } + convertToUINode(t, e, i) { + i || (i = new Pi); + if (!this._camera) return i; + this.worldToScreen(t, iS); + const s = e.getComponent("cc.UITransform"); + const n = m.view.getVisibleSize(); + const r = iS.x - .5 * this._camera.width; + const o = iS.y - .5 * this._camera.height; + iS.x = r / m.view.getScaleX() + .5 * n.width; + iS.y = o / m.view.getScaleY() + .5 * n.height; + s && s.convertToNodeSpaceAR(iS, i); + return i; + } + _createCamera() { + if (!this._camera) { + this._camera = m.director.root.createCamera(); + this._camera.initialize({ + name: this.node.name, + node: this.node, + projection: this._projection, + window: this._inEditorMode ? m.director.root && m.director.root.mainWindow : m.director.root && m.director.root.tempWindow, + priority: this._priority, + cameraType: this.cameraType, + trackingType: this.trackingType + }); + this._camera.setViewportInOrientedSpace(this._rect); + this._camera.fovAxis = this._fovAxis; + this._camera.fov = mi(this._fov); + this._camera.orthoHeight = this._orthoHeight; + this._camera.nearClip = this._near; + this._camera.farClip = this._far; + this._camera.clearColor = this._color; + this._camera.clearDepth = this._depth; + this._camera.clearStencil = this._stencil; + this._camera.clearFlag = this._clearFlags; + this._camera.visibility = this._visibility; + this._camera.aperture = this._aperture; + this._camera.shutter = this._shutter; + this._camera.iso = this._iso; + } + this._updateTargetTexture(); + } + _attachToScene() { + if (this.node.scene && this._camera) { + this._camera && this._camera.scene && this._camera.scene.removeCamera(this._camera); + this._getRenderScene().addCamera(this._camera); + } + } + _detachFromScene() { + this._camera && this._camera.scene && this._camera.scene.removeCamera(this._camera); + } + _checkTargetTextureEvent(t) { + t && t.off("resize"); + this._targetTexture && this._targetTexture.on("resize", (t => { + this._camera && this._camera.setFixedSize(t.width, t.height); + }), this); + } + _updateTargetTexture() { + if (this._camera && this._targetTexture) { + const t = this._targetTexture.window; + this._camera.changeTargetWindow(t); + this._camera.setFixedSize(t.width, t.height); + } + } + }, tS.ProjectionType = sS, tS.FOVAxis = nS, tS.ClearFlag = lS, tS.Aperture = rS, + tS.Shutter = oS, tS.ISO = aS, tS.TARGET_TEXTURE_CHANGE = "tex-change", eS), Ob = Bl(Pb.prototype, "_projection", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return sS.PERSPECTIVE; + } + }), Nb = Bl(Pb.prototype, "_priority", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Lb = Bl(Pb.prototype, "_fov", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 45; + } + }), Fb = Bl(Pb.prototype, "_fovAxis", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return nS.VERTICAL; + } + }), Vb = Bl(Pb.prototype, "_orthoHeight", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 10; + } + }), kb = Bl(Pb.prototype, "_near", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), Ub = Bl(Pb.prototype, "_far", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1e3; + } + }), Gb = Bl(Pb.prototype, "_color", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Bi("#333333"); + } + }), zb = Bl(Pb.prototype, "_depth", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), Hb = Bl(Pb.prototype, "_stencil", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), jb = Bl(Pb.prototype, "_clearFlags", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return lS.SOLID_COLOR; + } + }), Xb = Bl(Pb.prototype, "_rect", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new as(0, 0, 1, 1); + } + }), Wb = Bl(Pb.prototype, "_aperture", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return rS.F16_0; + } + }), Yb = Bl(Pb.prototype, "_shutter", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return oS.D125; + } + }), qb = Bl(Pb.prototype, "_iso", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return aS.ISO100; + } + }), Kb = Bl(Pb.prototype, "_screenScale", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), Jb = Bl(Pb.prototype, "_visibility", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return zf; + } + }), Zb = Bl(Pb.prototype, "_targetTexture", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Qb = Bl(Pb.prototype, "_cameraType", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Ry.DEFAULT; + } + }), $b = Bl(Pb.prototype, "_trackingType", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Iy.NO_TRACKING; + } + }), Bl(Pb.prototype, "priority", [ Gy, zy ], Object.getOwnPropertyDescriptor(Pb.prototype, "priority"), Pb.prototype), + Bl(Pb.prototype, "visibility", [ Hy, jy, Xy ], Object.getOwnPropertyDescriptor(Pb.prototype, "visibility"), Pb.prototype), + Bl(Pb.prototype, "clearFlags", [ Wy, Yy, qy ], Object.getOwnPropertyDescriptor(Pb.prototype, "clearFlags"), Pb.prototype), + Bl(Pb.prototype, "clearColor", [ Ky, Jy ], Object.getOwnPropertyDescriptor(Pb.prototype, "clearColor"), Pb.prototype), + Bl(Pb.prototype, "clearDepth", [ Zy, Qy ], Object.getOwnPropertyDescriptor(Pb.prototype, "clearDepth"), Pb.prototype), + Bl(Pb.prototype, "clearStencil", [ $y, tb ], Object.getOwnPropertyDescriptor(Pb.prototype, "clearStencil"), Pb.prototype), + Bl(Pb.prototype, "projection", [ eb, ib, sb ], Object.getOwnPropertyDescriptor(Pb.prototype, "projection"), Pb.prototype), + Bl(Pb.prototype, "fovAxis", [ nb, rb, ob, ab ], Object.getOwnPropertyDescriptor(Pb.prototype, "fovAxis"), Pb.prototype), + Bl(Pb.prototype, "fov", [ lb, hb, cb ], Object.getOwnPropertyDescriptor(Pb.prototype, "fov"), Pb.prototype), + Bl(Pb.prototype, "orthoHeight", [ ub, _b, db ], Object.getOwnPropertyDescriptor(Pb.prototype, "orthoHeight"), Pb.prototype), + Bl(Pb.prototype, "near", [ pb, mb ], Object.getOwnPropertyDescriptor(Pb.prototype, "near"), Pb.prototype), + Bl(Pb.prototype, "far", [ fb, gb ], Object.getOwnPropertyDescriptor(Pb.prototype, "far"), Pb.prototype), + Bl(Pb.prototype, "aperture", [ yb, bb, Sb ], Object.getOwnPropertyDescriptor(Pb.prototype, "aperture"), Pb.prototype), + Bl(Pb.prototype, "shutter", [ Ab, Tb, vb ], Object.getOwnPropertyDescriptor(Pb.prototype, "shutter"), Pb.prototype), + Bl(Pb.prototype, "iso", [ Eb, Cb, xb ], Object.getOwnPropertyDescriptor(Pb.prototype, "iso"), Pb.prototype), + Bl(Pb.prototype, "rect", [ wb, Rb ], Object.getOwnPropertyDescriptor(Pb.prototype, "rect"), Pb.prototype), + Bl(Pb.prototype, "targetTexture", [ Ib, Mb, Bb ], Object.getOwnPropertyDescriptor(Pb.prototype, "targetTexture"), Pb.prototype), + Pb)) || Db) || Db) || Db) || Db), t({ + Camera: cS, + CameraComponent: cS + }), cS); + var cS; + m.Camera = hS; + const uS = jsb.MaterialInstance; + const _S = jsb.MaterialInstance.prototype; + Object.defineProperty(_S, "parent", { + configurable: !0, + enumerable: !0, + get() { + return this._parent; + } + }); + Object.defineProperty(_S, "owner", { + configurable: !0, + enumerable: !0, + get() { + return this._owner; + } + }); + _S._ctor = function(t) { + jsb.Material.prototype._ctor.apply(this, arguments); + this._registerListeners(); + this._parent = t.parent; + this._owner = t.owner || null; + this._subModelIdx = t.subModelIdx || 0; + this._passes = this.getPasses(); + }; + _S._onRebuildPSO = function() { + this._owner && this._owner._onRebuildPSO(this._subModelIdx, this); + }; + var dS, pS, mS, fS, gS, yS, bS, SS, AS; + const TS = { + parent: null, + owner: null, + subModelIdx: 0 + }; + let vS = t("Renderer", (dS = Ul("cc.Renderer"), pS = Th(hm), mS = ph(), fS = ah(), + gS = Th([ hm ]), dS(yS = Hl(yS = (bS = (AS = class extends Qc { + constructor(...t) { + super(...t); + Ml(this, "_materials", SS, this); + this._materialInstances = []; + } + get sharedMaterial() { + return this.getMaterial(0); + } + get sharedMaterials() { + return this._materials; + } + set sharedMaterials(t) { + for (let e = 0; e < t.length; e++) t[e] !== this._materials[e] && this.setMaterial(t[e], e); + if (t.length < this._materials.length) { + for (let e = t.length; e < this._materials.length; e++) this.setMaterial(null, e); + this._materials.splice(t.length); + } + } + get material() { + return this.getMaterialInstance(0); + } + set material(t) { + (1 !== this._materials.length || this._materialInstances[0] || this._materials[0] !== t) && this.setMaterialInstance(t, 0); + } + get materials() { + for (let t = 0; t < this._materials.length; t++) this._materialInstances[t] = this.getMaterialInstance(t); + return this._materialInstances; + } + set materials(t) { + const e = t.length; + const i = this._materials.length; + for (let t = e; t < i; t++) this.setMaterialInstance(null, t); + this._materials.length = e; + this._materialInstances.length = e; + for (let i = 0; i < e; i++) this._materialInstances[i] != t[i] && this.setMaterialInstance(t[i], i); + } + getMaterial(t) { + return t < 0 || t >= this._materials.length ? null : this._materials[t]; + } + setMaterial(t, e) { + t && t instanceof uS && console.error("Can't set a material instance to a sharedMaterial slot"); + this._materials[e] = t; + const i = this._materialInstances[e]; + if (i) { + i.destroy(); + this._materialInstances[e] = null; + } + this._onMaterialModified(e, this._materials[e]); + } + getMaterialInstance(t) { + if (!this._materials[t]) return null; + if (!this._materialInstances[t]) { + TS.parent = this._materials[t]; + TS.owner = this; + TS.subModelIdx = t; + const e = new uS(TS); + TS.parent = null; + TS.owner = null; + TS.subModelIdx = 0; + this.setMaterialInstance(e, t); + } + return this._materialInstances[t]; + } + setMaterialInstance(t, e) { + if ("number" == typeof t) { + N(12007); + const i = t; + t = e; + e = i; + } + const i = this._materialInstances[e]; + if (t && t.parent) { + if (t !== i) { + this._materialInstances[e] = t; + this._onMaterialModified(e, t); + } + } else (t !== this._materials[e] || i) && this.setMaterial(t, e); + } + getRenderMaterial(t) { + return this._materialInstances[t] || this._materials[t]; + } + _onMaterialModified(t, e) {} + _onRebuildPSO(t, e) {} + _clearMaterials() {} + }, AS), Bl(bS.prototype, "sharedMaterials", [ pS, mS, fS ], Object.getOwnPropertyDescriptor(bS.prototype, "sharedMaterials"), bS.prototype), + SS = Bl(bS.prototype, "_materials", [ gS ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), bS)) || yS) || yS)); + var ES, CS, xS; + let wS = function(e) { + return t({ + ModelRenderer: e, + RenderableComponent: e + }), e; + }(Ul("cc.ModelRenderer")(ES = (CS = class extends vS { + constructor(...t) { + super(...t); + Ml(this, "_visFlags", xS, this); + this._models = []; + this._priority = 0; + } + get visibility() { + return this._visFlags; + } + set visibility(t) { + this._visFlags = t; + this._onVisibilityChange(t); + } + get priority() { + return this._priority; + } + set priority(t) { + if (t !== this._priority) { + this._priority = t; + this._updatePriority(); + } + } + _collectModels() { + return this._models; + } + onEnable() { + this._updatePriority(); + } + _attachToScene() {} + _detachFromScene() {} + _onVisibilityChange(t) {} + _updatePriority() { + if (this._models.length > 0) for (let t = 0; t < this._models.length; t++) this._models[t].priority = this._priority; + } + }, xS = Bl(CS.prototype, "_visFlags", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return mm.Enum.NONE; + } + }), CS)) || ES); + W(hS, "Camera", [ { + name: "CameraClearFlag", + newName: "ClearFlag" + } ]); + W(hS.prototype, "Camera.prototype", [ { + name: "color", + newName: "clearColor" + }, { + name: "depth", + newName: "clearDepth" + }, { + name: "stencil", + newName: "clearStencil" + } ]); + m.CameraComponent = hS; + ee.setClassAlias(hS, "cc.CameraComponent"); + m.RenderableComponent = wS; + ee.setClassAlias(wS, "cc.RenderableComponent"); + class RS { + constructor(t, e) { + this.type = void 0; + this.bubbles = void 0; + this.target = null; + this.currentTarget = null; + this.eventPhase = 0; + this.propagationStopped = !1; + this.propagationImmediateStopped = !1; + this.type = t; + this.bubbles = !!e; + } + unuse() { + this.type = RS.NO_TYPE; + this.target = null; + this.currentTarget = null; + this.eventPhase = RS.NONE; + this.propagationStopped = !1; + this.propagationImmediateStopped = !1; + } + reuse(t, e) { + this.type = t; + this.bubbles = e || !1; + } + isStopped() { + return this.propagationStopped || this.propagationImmediateStopped; + } + getCurrentTarget() { + return this.currentTarget; + } + getType() { + return this.type; + } + } + t("Event", RS); + RS.NO_TYPE = "no_type"; + RS.TOUCH = "touch"; + RS.MOUSE = "mouse"; + RS.KEYBOARD = "keyboard"; + RS.ACCELERATION = "acceleration"; + RS.NONE = 0; + RS.CAPTURING_PHASE = 1; + RS.AT_TARGET = 2; + RS.BUBBLING_PHASE = 3; + m.Event = RS; + let IS; + !function(t) { + t.TOUCH_START = "touch-start"; + t.TOUCH_MOVE = "touch-move"; + t.TOUCH_END = "touch-end"; + t.TOUCH_CANCEL = "touch-cancel"; + t.MOUSE_DOWN = "mouse-down"; + t.MOUSE_MOVE = "mouse-move"; + t.MOUSE_UP = "mouse-up"; + t.MOUSE_WHEEL = "mouse-wheel"; + t.MOUSE_ENTER = "mouse-enter"; + t.MOUSE_LEAVE = "mouse-leave"; + t.KEY_DOWN = "keydown"; + t.KEY_UP = "keyup"; + t.DEVICEMOTION = "devicemotion"; + t.TRANSFORM_CHANGED = "transform-changed"; + t.SCENE_CHANGED_FOR_PERSISTS = "scene-changed-for-persists"; + t.SIZE_CHANGED = "size-changed"; + t.ANCHOR_CHANGED = "anchor-changed"; + t.COLOR_CHANGED = "color-changed"; + t.CHILD_ADDED = "child-added"; + t.CHILD_REMOVED = "child-removed"; + t.PARENT_CHANGED = "parent-changed"; + t.NODE_DESTROYED = "node-destroyed"; + t.LAYER_CHANGED = "layer-changed"; + t.SIBLING_ORDER_CHANGED = "sibling-order-changed"; + }(IS || (IS = t("SystemEventType", {}))); + let MS; + !function(t) { + t.TOUCH_START = "touch-start"; + t.TOUCH_MOVE = "touch-move"; + t.TOUCH_END = "touch-end"; + t.TOUCH_CANCEL = "touch-cancel"; + t.MOUSE_DOWN = "mouse-down"; + t.MOUSE_MOVE = "mouse-move"; + t.MOUSE_UP = "mouse-up"; + t.MOUSE_WHEEL = "mouse-wheel"; + t.KEY_DOWN = "keydown"; + t.KEY_PRESSING = "key-pressing"; + t.KEY_UP = "keyup"; + t.DEVICEMOTION = "devicemotion"; + t.GAMEPAD_INPUT = "gamepad-input"; + t.GAMEPAD_CHANGE = "gamepad-change"; + t.HANDLE_INPUT = "handle-input"; + t.HANDLE_POSE_INPUT = "handle-pose-input"; + t.HMD_POSE_INPUT = "hmd-pose-input"; + }(MS || (MS = {})); + m.SystemEventType = IS; + class BS extends RS { + constructor(t, e) { + super(IS.DEVICEMOTION, e); + this.acc = void 0; + this.acc = t; + } + } + t("EventAcceleration", BS); + RS.EventAcceleration = BS; + class DS extends RS { + get isPressed() { + return this._isPressed; + } + constructor(t, e, i) { + if ("boolean" == typeof e) { + e = e ? IS.KEY_DOWN : IS.KEY_UP; + } + super(e, i); + this.keyCode = void 0; + this.rawEvent = void 0; + this._isPressed = void 0; + this._isPressed = e !== IS.KEY_UP; + if ("number" == typeof t) this.keyCode = t; else { + this.keyCode = t.keyCode; + this.rawEvent = t; + } + } + } + t("EventKeyboard", DS); + RS.EventKeyboard = DS; + class PS extends RS { + get eventType() { + return this._eventType; + } + constructor(t, e, i) { + super(t, e); + this.movementX = 0; + this.movementY = 0; + this.preventSwallow = !1; + this._eventType = void 0; + this._button = PS.BUTTON_MISSING; + this._x = 0; + this._y = 0; + this._prevX = 0; + this._prevY = 0; + this._scrollX = 0; + this._scrollY = 0; + this._eventType = t; + if (i) { + this._prevX = i.x; + this._prevY = i.y; + } + } + setScrollData(t, e) { + this._scrollX = t; + this._scrollY = e; + } + getScrollX() { + return this._scrollX; + } + getScrollY() { + return this._scrollY; + } + setLocation(t, e) { + this._x = t; + this._y = e; + } + getLocation(t) { + t || (t = new Qi); + Qi.set(t, this._x, this._y); + return t; + } + getLocationInView(t) { + t || (t = new Qi); + Qi.set(t, this._x, m.view._designResolutionSize.height - this._y); + return t; + } + getUILocation(t) { + t || (t = new Qi); + Qi.set(t, this._x, this._y); + m.view._convertToUISpace(t); + return t; + } + getPreviousLocation(t) { + t || (t = new Qi); + Qi.set(t, this._prevX, this._prevY); + return t; + } + getUIPreviousLocation(t) { + t || (t = new Qi); + Qi.set(t, this._prevX, this._prevY); + m.view._convertToUISpace(t); + return t; + } + getDelta(t) { + t || (t = new Qi); + Qi.set(t, this._x - this._prevX, this._y - this._prevY); + return t; + } + getDeltaX() { + return this._x - this._prevX; + } + getDeltaY() { + return this._y - this._prevY; + } + getUIDelta(t) { + t || (t = new Qi); + Qi.set(t, (this._x - this._prevX) / m.view.getScaleX(), (this._y - this._prevY) / m.view.getScaleY()); + return t; + } + getUIDeltaX() { + return (this._x - this._prevX) / m.view.getScaleX(); + } + getUIDeltaY() { + return (this._y - this._prevY) / m.view.getScaleY(); + } + setButton(t) { + this._button = t; + } + getButton() { + return this._button; + } + getLocationX() { + return this._x; + } + getLocationY() { + return this._y; + } + getUILocationX() { + const t = m.view.getViewportRect(); + return (this._x - t.x) / m.view.getScaleX(); + } + getUILocationY() { + const t = m.view.getViewportRect(); + return (this._y - t.y) / m.view.getScaleY(); + } + } + t("EventMouse", PS); + PS.BUTTON_MISSING = -1; + PS.BUTTON_LEFT = 0; + PS.BUTTON_RIGHT = 2; + PS.BUTTON_MIDDLE = 1; + PS.BUTTON_4 = 3; + PS.BUTTON_5 = 4; + PS.BUTTON_6 = 5; + PS.BUTTON_7 = 6; + PS.BUTTON_8 = 7; + RS.EventMouse = PS; + const OS = new Qi; + class NS extends RS { + constructor(t, e, i, s = []) { + super(i, e); + this.touch = null; + this.simulate = !1; + this.preventSwallow = !1; + this._eventCode = void 0; + this._touches = void 0; + this._allTouches = void 0; + this._eventCode = i; + this._touches = t || []; + this._allTouches = s; + } + getEventCode() { + return this._eventCode; + } + getTouches() { + return this._touches; + } + getAllTouches() { + return this._allTouches; + } + setLocation(t, e) { + this.touch && this.touch.setTouchInfo(this.touch.getID(), t, e); + } + getLocation(t) { + return this.touch ? this.touch.getLocation(t) : new Qi; + } + getUILocation(t) { + return this.touch ? this.touch.getUILocation(t) : new Qi; + } + getLocationInView(t) { + return this.touch ? this.touch.getLocationInView(t) : new Qi; + } + getPreviousLocation(t) { + return this.touch ? this.touch.getPreviousLocation(t) : new Qi; + } + getStartLocation(t) { + return this.touch ? this.touch.getStartLocation(t) : new Qi; + } + getUIStartLocation(t) { + return this.touch ? this.touch.getUIStartLocation(t) : new Qi; + } + getID() { + return this.touch ? this.touch.getID() : null; + } + getDelta(t) { + return this.touch ? this.touch.getDelta(t) : new Qi; + } + getUIDelta(t) { + return this.touch ? this.touch.getUIDelta(t) : new Qi; + } + getDeltaX() { + return this.touch ? this.touch.getDelta(OS).x : 0; + } + getDeltaY() { + return this.touch ? this.touch.getDelta(OS).y : 0; + } + getLocationX() { + return this.touch ? this.touch.getLocationX() : 0; + } + getLocationY() { + return this.touch ? this.touch.getLocationY() : 0; + } + } + t("EventTouch", NS); + NS.MAX_TOUCHES = 5; + RS.EventTouch = NS; + class LS extends RS { + constructor(t, e) { + super(t, !1); + this.gamepad = void 0; + this.gamepad = e; + } + } + t("EventGamepad", LS); + class FS extends RS { + constructor(t, e) { + super(t, !1); + this.handleInputDevice = void 0; + this.handleInputDevice = e; + } + } + t("EventHandle", FS); + class VS extends RS { + constructor(t, e) { + super(t, !1); + this.hmdInputDevice = void 0; + this.hmdInputDevice = e; + } + } + t("EventHMD", VS); + class kS { + constructor(t = 0, e = 0, i = 0, s = 0) { + this.x = void 0; + this.y = void 0; + this.z = void 0; + this.timestamp = void 0; + this.x = t; + this.y = e; + this.z = i; + this.timestamp = s; + } + } + t("Acceleration", kS); + let US; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.MOBILE_BACK = 6] = "MOBILE_BACK"; + t[t.BACKSPACE = 8] = "BACKSPACE"; + t[t.TAB = 9] = "TAB"; + t[t.ENTER = 13] = "ENTER"; + t[t.SHIFT_LEFT = 16] = "SHIFT_LEFT"; + t[t.CTRL_LEFT = 17] = "CTRL_LEFT"; + t[t.ALT_LEFT = 18] = "ALT_LEFT"; + t[t.PAUSE = 19] = "PAUSE"; + t[t.CAPS_LOCK = 20] = "CAPS_LOCK"; + t[t.ESCAPE = 27] = "ESCAPE"; + t[t.SPACE = 32] = "SPACE"; + t[t.PAGE_UP = 33] = "PAGE_UP"; + t[t.PAGE_DOWN = 34] = "PAGE_DOWN"; + t[t.END = 35] = "END"; + t[t.HOME = 36] = "HOME"; + t[t.ARROW_LEFT = 37] = "ARROW_LEFT"; + t[t.ARROW_UP = 38] = "ARROW_UP"; + t[t.ARROW_RIGHT = 39] = "ARROW_RIGHT"; + t[t.ARROW_DOWN = 40] = "ARROW_DOWN"; + t[t.INSERT = 45] = "INSERT"; + t[t.DELETE = 46] = "DELETE"; + t[t.DIGIT_0 = 48] = "DIGIT_0"; + t[t.DIGIT_1 = 49] = "DIGIT_1"; + t[t.DIGIT_2 = 50] = "DIGIT_2"; + t[t.DIGIT_3 = 51] = "DIGIT_3"; + t[t.DIGIT_4 = 52] = "DIGIT_4"; + t[t.DIGIT_5 = 53] = "DIGIT_5"; + t[t.DIGIT_6 = 54] = "DIGIT_6"; + t[t.DIGIT_7 = 55] = "DIGIT_7"; + t[t.DIGIT_8 = 56] = "DIGIT_8"; + t[t.DIGIT_9 = 57] = "DIGIT_9"; + t[t.KEY_A = 65] = "KEY_A"; + t[t.KEY_B = 66] = "KEY_B"; + t[t.KEY_C = 67] = "KEY_C"; + t[t.KEY_D = 68] = "KEY_D"; + t[t.KEY_E = 69] = "KEY_E"; + t[t.KEY_F = 70] = "KEY_F"; + t[t.KEY_G = 71] = "KEY_G"; + t[t.KEY_H = 72] = "KEY_H"; + t[t.KEY_I = 73] = "KEY_I"; + t[t.KEY_J = 74] = "KEY_J"; + t[t.KEY_K = 75] = "KEY_K"; + t[t.KEY_L = 76] = "KEY_L"; + t[t.KEY_M = 77] = "KEY_M"; + t[t.KEY_N = 78] = "KEY_N"; + t[t.KEY_O = 79] = "KEY_O"; + t[t.KEY_P = 80] = "KEY_P"; + t[t.KEY_Q = 81] = "KEY_Q"; + t[t.KEY_R = 82] = "KEY_R"; + t[t.KEY_S = 83] = "KEY_S"; + t[t.KEY_T = 84] = "KEY_T"; + t[t.KEY_U = 85] = "KEY_U"; + t[t.KEY_V = 86] = "KEY_V"; + t[t.KEY_W = 87] = "KEY_W"; + t[t.KEY_X = 88] = "KEY_X"; + t[t.KEY_Y = 89] = "KEY_Y"; + t[t.KEY_Z = 90] = "KEY_Z"; + t[t.NUM_0 = 96] = "NUM_0"; + t[t.NUM_1 = 97] = "NUM_1"; + t[t.NUM_2 = 98] = "NUM_2"; + t[t.NUM_3 = 99] = "NUM_3"; + t[t.NUM_4 = 100] = "NUM_4"; + t[t.NUM_5 = 101] = "NUM_5"; + t[t.NUM_6 = 102] = "NUM_6"; + t[t.NUM_7 = 103] = "NUM_7"; + t[t.NUM_8 = 104] = "NUM_8"; + t[t.NUM_9 = 105] = "NUM_9"; + t[t.NUM_MULTIPLY = 106] = "NUM_MULTIPLY"; + t[t.NUM_PLUS = 107] = "NUM_PLUS"; + t[t.NUM_SUBTRACT = 109] = "NUM_SUBTRACT"; + t[t.NUM_DECIMAL = 110] = "NUM_DECIMAL"; + t[t.NUM_DIVIDE = 111] = "NUM_DIVIDE"; + t[t.F1 = 112] = "F1"; + t[t.F2 = 113] = "F2"; + t[t.F3 = 114] = "F3"; + t[t.F4 = 115] = "F4"; + t[t.F5 = 116] = "F5"; + t[t.F6 = 117] = "F6"; + t[t.F7 = 118] = "F7"; + t[t.F8 = 119] = "F8"; + t[t.F9 = 120] = "F9"; + t[t.F10 = 121] = "F10"; + t[t.F11 = 122] = "F11"; + t[t.F12 = 123] = "F12"; + t[t.NUM_LOCK = 144] = "NUM_LOCK"; + t[t.SCROLL_LOCK = 145] = "SCROLL_LOCK"; + t[t.SEMICOLON = 186] = "SEMICOLON"; + t[t.EQUAL = 187] = "EQUAL"; + t[t.COMMA = 188] = "COMMA"; + t[t.DASH = 189] = "DASH"; + t[t.PERIOD = 190] = "PERIOD"; + t[t.SLASH = 191] = "SLASH"; + t[t.BACK_QUOTE = 192] = "BACK_QUOTE"; + t[t.BRACKET_LEFT = 219] = "BRACKET_LEFT"; + t[t.BACKSLASH = 220] = "BACKSLASH"; + t[t.BRACKET_RIGHT = 221] = "BRACKET_RIGHT"; + t[t.QUOTE = 222] = "QUOTE"; + t[t.SHIFT_RIGHT = 2e3] = "SHIFT_RIGHT"; + t[t.CTRL_RIGHT = 2001] = "CTRL_RIGHT"; + t[t.ALT_RIGHT = 2002] = "ALT_RIGHT"; + t[t.NUM_ENTER = 2003] = "NUM_ENTER"; + }(US || (US = t("KeyCode", {}))); + const GS = new Qi; + class zS { + get lastModified() { + return this._lastModified; + } + constructor(t, e, i = 0) { + this._point = new Qi; + this._prevPoint = new Qi; + this._lastModified = 0; + this._id = 0; + this._startPoint = new Qi; + this._startPointCaptured = !1; + this.setTouchInfo(i, t, e); + } + getLocation(t) { + t || (t = new Qi); + t.set(this._point.x, this._point.y); + return t; + } + getLocationX() { + return this._point.x; + } + getLocationY() { + return this._point.y; + } + getUILocation(t) { + t || (t = new Qi); + t.set(this._point.x, this._point.y); + m.view._convertToUISpace(t); + return t; + } + getUILocationX() { + const t = m.view.getViewportRect(); + return (this._point.x - t.x) / m.view.getScaleX(); + } + getUILocationY() { + const t = m.view.getViewportRect(); + return (this._point.y - t.y) / m.view.getScaleY(); + } + getPreviousLocation(t) { + t || (t = new Qi); + t.set(this._prevPoint.x, this._prevPoint.y); + return t; + } + getUIPreviousLocation(t) { + t || (t = new Qi); + t.set(this._prevPoint.x, this._prevPoint.y); + m.view._convertToUISpace(t); + return t; + } + getStartLocation(t) { + t || (t = new Qi); + t.set(this._startPoint.x, this._startPoint.y); + return t; + } + getUIStartLocation(t) { + t || (t = new Qi); + t.set(this._startPoint.x, this._startPoint.y); + m.view._convertToUISpace(t); + return t; + } + getDelta(t) { + t || (t = new Qi); + t.set(this._point); + t.subtract(this._prevPoint); + return t; + } + getUIDelta(t) { + t || (t = new Qi); + GS.set(this._point); + GS.subtract(this._prevPoint); + t.set(m.view.getScaleX(), m.view.getScaleY()); + Qi.divide(t, GS, t); + return t; + } + getLocationInView(t) { + t || (t = new Qi); + t.set(this._point.x, m.view._designResolutionSize.height - this._point.y); + return t; + } + getPreviousLocationInView(t) { + t || (t = new Qi); + t.set(this._prevPoint.x, m.view._designResolutionSize.height - this._prevPoint.y); + return t; + } + getStartLocationInView(t) { + t || (t = new Qi); + t.set(this._startPoint.x, m.view._designResolutionSize.height - this._startPoint.y); + return t; + } + getID() { + return this._id; + } + setTouchInfo(t = 0, e, i) { + this._prevPoint = this._point; + this._point = new Qi(e || 0, i || 0); + this._id = t; + if (!this._startPointCaptured) { + this._startPoint = new Qi(this._point); + this._startPointCaptured = !0; + } + } + setPoint(t, e) { + if ("object" == typeof t) { + this._point.x = t.x; + this._point.y = t.y; + } else { + this._point.x = t || 0; + this._point.y = e || 0; + } + this._lastModified = m.game.frameStartTime; + } + setPrevPoint(t, e) { + this._prevPoint = "object" == typeof t ? new Qi(t.x, t.y) : new Qi(t || 0, e || 0); + this._lastModified = m.game.frameStartTime; + } + } + t("Touch", zS); + m.Touch = zS; + const HS = new Array(16); + let jS = null; + const XS = new Qi; + const WS = [ ny.TOUCH_START, ny.TOUCH_MOVE, ny.TOUCH_END, ny.TOUCH_CANCEL ]; + const YS = [ ny.MOUSE_DOWN, ny.MOUSE_ENTER, ny.MOUSE_MOVE, ny.MOUSE_LEAVE, ny.MOUSE_UP, ny.MOUSE_WHEEL ]; + let qS; + !function(t) { + t[t.ADD_POINTER_EVENT_PROCESSOR = 0] = "ADD_POINTER_EVENT_PROCESSOR"; + t[t.REMOVE_POINTER_EVENT_PROCESSOR = 1] = "REMOVE_POINTER_EVENT_PROCESSOR"; + t[t.MARK_LIST_DIRTY = 2] = "MARK_LIST_DIRTY"; + }(qS || (qS = {})); + class KS { + get isEnabled() { + return this._isEnabled; + } + get node() { + return this._node; + } + constructor(t) { + this.claimedTouchIdList = []; + this.maskList = null; + this.cachedCameraPriority = 0; + this.previousMouseIn = !1; + this.bubblingTarget = null; + this.capturingTarget = null; + this.shouldHandleEventMouse = !1; + this.shouldHandleEventTouch = !1; + this._dispatchingTouch = null; + this._isEnabled = !1; + this._node = void 0; + this._node = t; + } + setEnabled(t, e = !1) { + if (this._isEnabled === t) return; + this._isEnabled = t; + const i = this.node.children; + t && this._attachMask(); + KS.callbacksInvoker.emit(qS.MARK_LIST_DIRTY); + if (e && i.length > 0) for (let e = 0; e < i.length; ++e) { + i[e]._eventProcessor.setEnabled(t, !0); + } + } + reattach() { + let t; + this.node.walk((e => { + t || (t = this._searchComponentsInParent(KS._maskComp)); + e.eventProcessor.maskList = t; + })); + } + destroy() { + jS === this._node && (jS = null); + this.capturingTarget && this.capturingTarget.clear(); + this.bubblingTarget && this.bubblingTarget.clear(); + KS.callbacksInvoker.emit(qS.REMOVE_POINTER_EVENT_PROCESSOR, this); + if (this._dispatchingTouch) { + const t = new NS([ this._dispatchingTouch ], !0, MS.TOUCH_CANCEL); + t.touch = this._dispatchingTouch; + this.dispatchEvent(t); + this._dispatchingTouch = null; + } + } + on(t, e, i, s) { + this._tryEmittingAddEvent(t); + let n; + if (s = !!s) { + var r; + n = null !== (r = this.capturingTarget) && void 0 !== r ? r : this.capturingTarget = this._newCallbacksInvoker(); + } else { + var o; + n = null !== (o = this.bubblingTarget) && void 0 !== o ? o : this.bubblingTarget = this._newCallbacksInvoker(); + } + n.on(t, e, i); + return e; + } + once(t, e, i, s) { + this._tryEmittingAddEvent(t); + let n; + if (s = !!s) { + var r; + n = null !== (r = this.capturingTarget) && void 0 !== r ? r : this.capturingTarget = this._newCallbacksInvoker(); + } else { + var o; + n = null !== (o = this.bubblingTarget) && void 0 !== o ? o : this.bubblingTarget = this._newCallbacksInvoker(); + } + n.on(t, e, i, !0); + return e; + } + off(t, e, i, s) { + var n; + let r; + r = (s = !!s) ? this.capturingTarget : this.bubblingTarget; + null === (n = r) || void 0 === n || n.off(t, e, i); + } + targetOff(t) { + var e, i; + null === (e = this.capturingTarget) || void 0 === e || e.removeAll(t); + null === (i = this.bubblingTarget) || void 0 === i || i.removeAll(t); + this.shouldHandleEventTouch && !this._hasTouchListeners() && (this.shouldHandleEventTouch = !1); + this.shouldHandleEventMouse && !this._hasMouseListeners() && (this.shouldHandleEventMouse = !1); + this._hasPointerListeners() || KS.callbacksInvoker.emit(qS.REMOVE_POINTER_EVENT_PROCESSOR, this); + } + emit(t, e, i, s, n, r) { + var o; + null === (o = this.bubblingTarget) || void 0 === o || o.emit(t, e, i, s, n, r); + } + dispatchEvent(t) { + const e = this.node; + let i; + let s = 0; + t.target = e; + HS.length = 0; + this.getCapturingTargets(t.type, HS); + t.eventPhase = 1; + for (s = HS.length - 1; s >= 0; --s) { + i = HS[s]; + if (i.eventProcessor.capturingTarget) { + t.currentTarget = i; + i.eventProcessor.capturingTarget.emit(t.type, t, HS); + if (t.propagationStopped) { + HS.length = 0; + return; + } + } + } + HS.length = 0; + t.eventPhase = 2; + t.currentTarget = e; + this.capturingTarget && this.capturingTarget.emit(t.type, t); + !t.propagationImmediateStopped && this.bubblingTarget && this.bubblingTarget.emit(t.type, t); + if (!t.propagationStopped && t.bubbles) { + this.getBubblingTargets(t.type, HS); + t.eventPhase = 3; + for (s = 0; s < HS.length; ++s) { + i = HS[s]; + if (i.eventProcessor.bubblingTarget) { + t.currentTarget = i; + i.eventProcessor.bubblingTarget.emit(t.type, t); + if (t.propagationStopped) { + HS.length = 0; + return; + } + } + } + } + HS.length = 0; + } + hasEventListener(t, e, i) { + let s = !1; + this.bubblingTarget && (s = this.bubblingTarget.hasEventListener(t, e, i)); + !s && this.capturingTarget && (s = this.capturingTarget.hasEventListener(t, e, i)); + return s; + } + getCapturingTargets(t, e) { + let i = this._node.parent; + for (;i; ) { + var s; + (null === (s = i.eventProcessor.capturingTarget) || void 0 === s ? void 0 : s.hasEventListener(t)) && e.push(i); + i = i.parent; + } + } + getBubblingTargets(t, e) { + let i = this._node.parent; + for (;i; ) { + var s; + (null === (s = i.eventProcessor.bubblingTarget) || void 0 === s ? void 0 : s.hasEventListener(t)) && e.push(i); + i = i.parent; + } + } + _searchComponentsInParent(t) { + const e = this.node; + if (t) { + let i = 0; + let s = []; + for (let n = e; n && _y.isNode(n); n = n.parent, ++i) { + const e = n.getComponent(t); + if (e) { + const t = { + index: i, + comp: e + }; + s ? s.push(t) : s = [ t ]; + } + } + return s.length > 0 ? s : null; + } + return null; + } + _attachMask() { + this.maskList = this._searchComponentsInParent(KS._maskComp); + } + _isTouchEvent(t) { + return -1 !== WS.indexOf(t); + } + _isMouseEvent(t) { + return -1 !== YS.indexOf(t); + } + _hasTouchListeners() { + for (let t = 0; t < WS.length; ++t) { + const e = WS[t]; + if (this.hasEventListener(e)) return !0; + } + return !1; + } + _hasMouseListeners() { + for (let t = 0; t < YS.length; ++t) { + const e = YS[t]; + if (this.hasEventListener(e)) return !0; + } + return !1; + } + _hasPointerListeners() { + return !!this._hasTouchListeners() || this._hasMouseListeners(); + } + _tryEmittingAddEvent(t) { + const e = this._isTouchEvent(t); + const i = this._isMouseEvent(t); + e ? this.shouldHandleEventTouch = !0 : i && (this.shouldHandleEventMouse = !0); + !e && !i || this._hasPointerListeners() || KS.callbacksInvoker.emit(qS.ADD_POINTER_EVENT_PROCESSOR, this); + } + _newCallbacksInvoker() { + const t = new Ao; + t._registerOffCallback((() => { + this.shouldHandleEventTouch && !this._hasTouchListeners() && (this.shouldHandleEventTouch = !1); + this.shouldHandleEventMouse && !this._hasMouseListeners() && (this.shouldHandleEventMouse = !1); + this._hasPointerListeners() || KS.callbacksInvoker.emit(qS.REMOVE_POINTER_EVENT_PROCESSOR, this); + })); + return t; + } + _handleEventMouse(t) { + switch (t.type) { + case MS.MOUSE_DOWN: + return this._handleMouseDown(t); + + case MS.MOUSE_MOVE: + return this._handleMouseMove(t); + + case MS.MOUSE_UP: + return this._handleMouseUp(t); + + case MS.MOUSE_WHEEL: + return this._handleMouseWheel(t); + + default: + return !1; + } + } + _handleMouseDown(t) { + const e = this._node; + if (!e || !e._uiProps.uiTransformComp) return !1; + t.getLocation(XS); + if (e._uiProps.uiTransformComp.hitTest(XS)) { + t.type = ny.MOUSE_DOWN; + t.bubbles = !0; + e.dispatchEvent(t); + t.propagationStopped = !0; + return !0; + } + return !1; + } + _handleMouseMove(t) { + const e = this._node; + if (!e || !e._uiProps.uiTransformComp) return !1; + t.getLocation(XS); + if (e._uiProps.uiTransformComp.hitTest(XS)) { + if (!this.previousMouseIn) { + if (jS && jS !== e) { + t.type = ny.MOUSE_LEAVE; + jS.dispatchEvent(t); + jS.eventProcessor.previousMouseIn = !1; + } + jS = e; + t.type = ny.MOUSE_ENTER; + e.dispatchEvent(t); + this.previousMouseIn = !0; + } + t.type = ny.MOUSE_MOVE; + t.bubbles = !0; + e.dispatchEvent(t); + t.propagationStopped = !0; + return !0; + } + if (this.previousMouseIn) { + t.type = ny.MOUSE_LEAVE; + e.dispatchEvent(t); + this.previousMouseIn = !1; + jS = null; + } + return !1; + } + _handleMouseUp(t) { + const e = this._node; + if (!e || !e._uiProps.uiTransformComp) return !1; + t.getLocation(XS); + if (e._uiProps.uiTransformComp.hitTest(XS)) { + t.type = ny.MOUSE_UP; + t.bubbles = !0; + e.dispatchEvent(t); + t.propagationStopped = !0; + return !0; + } + return !1; + } + _handleMouseWheel(t) { + const e = this._node; + if (!e || !e._uiProps.uiTransformComp) return !1; + t.getLocation(XS); + if (e._uiProps.uiTransformComp.hitTest(XS)) { + t.type = ny.MOUSE_WHEEL; + t.bubbles = !0; + e.dispatchEvent(t); + t.propagationStopped = !0; + return !0; + } + return !1; + } + _handleEventTouch(t) { + switch (t.type) { + case MS.TOUCH_START: + return this._handleTouchStart(t); + + case MS.TOUCH_MOVE: + return this._handleTouchMove(t); + + case MS.TOUCH_END: + return this._handleTouchEnd(t); + + case MS.TOUCH_CANCEL: + return this._handleTouchCancel(t); + + default: + return !1; + } + } + _handleTouchStart(t) { + const e = this.node; + if (!e || !e._uiProps.uiTransformComp) return !1; + t.getLocation(XS); + if (e._uiProps.uiTransformComp.hitTest(XS)) { + t.type = ny.TOUCH_START; + t.bubbles = !0; + this._dispatchingTouch = t.touch; + e.dispatchEvent(t); + return !0; + } + return !1; + } + _handleTouchMove(t) { + const e = this.node; + if (!e || !e._uiProps.uiTransformComp) return !1; + t.type = ny.TOUCH_MOVE; + t.bubbles = !0; + this._dispatchingTouch = t.touch; + e.dispatchEvent(t); + return !0; + } + _handleTouchEnd(t) { + const e = this.node; + if (e && e._uiProps.uiTransformComp) { + t.getLocation(XS); + e._uiProps.uiTransformComp.hitTest(XS) ? t.type = ny.TOUCH_END : t.type = ny.TOUCH_CANCEL; + t.bubbles = !0; + e.dispatchEvent(t); + this._dispatchingTouch = null; + } + } + _handleTouchCancel(t) { + const e = this.node; + if (e && e._uiProps.uiTransformComp) { + t.type = ny.TOUCH_CANCEL; + t.bubbles = !0; + e.dispatchEvent(t); + } + } + } + KS._maskComp = null; + KS.callbacksInvoker = new Ao; + m.NodeEventProcessor = KS; + function JS(t) { + const e = t._prefab; + if (!e) return; + if (!e.instance) return; + if (!e.asset) { + F(3701, t.name); + e.instance = void 0; + return; + } + const i = t._objFlags; + const s = t._parent; + const n = t._id; + const r = t._prefab; + t[io]; + m.game._isCloning = !0; + { + const i = e.asset.data; + i._iN$t = t; + m.instantiate._clone(i, i); + } + m.game._isCloning = !1; + t._objFlags = i; + t._parent = s; + t._id = n; + t._prefab && (t._prefab.instance = null == r ? void 0 : r.instance); + } + function ZS(t, e, i) { + var s; + if (!e) return; + if (!t) return; + let n = e; + const r = null === (s = t._prefab) || void 0 === s ? void 0 : s.instance; + if (!i && r) { + e[r.fileId] = {}; + n = e[r.fileId]; + } + const o = t._prefab; + o && (n[o.fileId] = t); + const a = t.components; + for (let t = 0; t < a.length; t++) { + const e = a[t]; + e.__prefab && (n[e.__prefab.fileId] = e); + } + for (let e = 0; e < t.children.length; e++) { + ZS(t.children[e], n, !1); + } + } + function QS(t, e) { + if (!t) return null; + let i = null; + let s = e; + for (let e = 0; e < t.length; e++) { + if (!s) return null; + s = s[t[e]]; + } + i = s; + return i; + } + function $S(t, e, i) { + if (e) for (let t = 0; t < e.length; t++) { + const s = e[t]; + if (s && s.targetInfo) { + const t = QS(s.targetInfo.localID, i); + if (!t) continue; + let e = i; + const n = s.targetInfo.localID; + if (n.length > 0) for (let t = 0; t < n.length - 1; t++) e = e[n[t]]; + if (s.nodes) for (let i = 0; i < s.nodes.length; i++) { + const n = s.nodes[i]; + if (n && !t._children.includes(n)) { + t._children.push(n); + n._parent = t; + ZS(n, e, !1); + n._siblingIndex = t._children.length - 1; + nA(n, !0); + } + } + } + } + } + function tA(t, e, i) { + if (e) for (let t = 0; t < e.length; t++) { + const s = e[t]; + if (s && s.targetInfo) { + const t = QS(s.targetInfo.localID, i); + if (!t) continue; + if (s.components) for (let e = 0; e < s.components.length; e++) { + const i = s.components[e]; + if (i) { + i.node = t; + t._components.push(i); + } + } + } + } + } + function eA(t, e, i) { + if (e) for (let t = 0; t < e.length; t++) { + const s = e[t]; + if (s) { + const t = QS(s.localID, i); + if (!t || !t.node) continue; + const e = t.node.components.indexOf(t); + e >= 0 && t.node._components.splice(e, 1); + } + } + } + function iA(t, e, i) { + if (e.length <= 0) return; + let s = null; + for (let t = 0; t < e.length; t++) { + const n = e[t]; + if (n && n.targetInfo) { + s = QS(n.targetInfo.localID, i); + if (!s) continue; + let t = s; + const e = n.propertyPath.slice(); + if (e.length > 0) { + const i = e.pop(); + if (!i) continue; + for (let i = 0; i < e.length; i++) { + t = t[e[i]]; + if (!t) break; + } + if (!t) continue; + if (Array.isArray(t)) if ("length" === i) t[i] = n.value; else { + const e = Number.parseInt(i); + Number.isInteger(e) && e < t.length && (t[i] = n.value); + } else t[i] instanceof ce ? t[i].set(n.value) : t[i] = n.value; + } + } + } + } + function sA(t) { + var e; + const i = null === (e = t._prefab) || void 0 === e ? void 0 : e.targetOverrides; + if (i) for (let t = 0; t < i.length; t++) { + var s, n; + const e = i[t]; + let a = e.source; + const l = e.sourceInfo; + if (l) { + var r, o; + const t = null === (r = e.source) || void 0 === r || null === (o = r._prefab) || void 0 === o ? void 0 : o.instance; + t && t.targetMap && (a = QS(l.localID, t.targetMap)); + } + if (!a) continue; + let h = null; + const c = e.targetInfo; + if (!c) continue; + const u = null === (s = e.target) || void 0 === s || null === (n = s._prefab) || void 0 === n ? void 0 : n.instance; + if (!u || !u.targetMap) continue; + h = QS(c.localID, u.targetMap); + if (!h) continue; + const _ = e.propertyPath.slice(); + let d = a; + if (_.length > 0) { + const t = _.pop(); + if (!t) return; + for (let t = 0; t < _.length; t++) { + d = d[_[t]]; + if (!d) break; + } + if (!d) continue; + d[t] = h; + } + } + } + function nA(t, e = !1) { + const i = t._prefab; + const s = null == i ? void 0 : i.instance; + if (s && !s.expanded) { + JS(t); + e && t && t.children && t.children.forEach((t => { + nA(t, !0); + })); + const i = {}; + s.targetMap = i; + ZS(t, i, !0); + $S(0, s.mountedChildren, i); + eA(0, s.removedComponents, i); + tA(0, s.mountedComponents, i); + iA(0, s.propertyOverrides, i); + s.expanded = !0; + } else e && t && t.children && t.children.forEach((t => { + nA(t, !0); + })); + } + function rA(t) { + const e = t._prefab; + e && e.nestedPrefabInstanceRoots && e.nestedPrefabInstanceRoots.forEach((t => { + nA(t); + })); + } + const oA = t("Scene", jsb.Scene); + m.Scene = oA; + const aA = oA.prototype; + Object.defineProperty(aA, "_globals", { + enumerable: !0, + configurable: !0, + get() { + return this.getSceneGlobals(); + }, + set(t) { + this._globalRef = t; + this.setSceneGlobals(t); + } + }); + Object.defineProperty(aA, "globals", { + enumerable: !0, + configurable: !0, + get() { + return this.getSceneGlobals(); + } + }); + Object.defineProperty(aA, "_renderScene", { + enumerable: !0, + configurable: !0, + get() { + this._renderSceneInternal || (this._renderSceneInternal = this.getRenderScene()); + return this._renderSceneInternal; + } + }); + Object.defineProperty(aA, "renderScene", { + enumerable: !0, + configurable: !0, + get() { + this._renderSceneInternal || (this._renderSceneInternal = this.getRenderScene()); + return this._renderSceneInternal; + } + }); + aA._ctor = function() { + _y.prototype._ctor.apply(this, arguments); + this._inited = !1; + this._renderSceneInternal = null; + this._globalRef = null; + this._prefabSyncedInLiveReload = !1; + }; + aA._onBatchCreated = function(t) { + this._parent && (this._siblingIndex = this._parent.children.indexOf(this)); + const e = this._children.length; + for (let i = 0; i < e; ++i) { + this.children[i]._siblingIndex = i; + this._children[i]._onBatchCreated(t); + } + }; + const lA = aA._load; + aA._load = function() { + this._scene = this; + if (!this._inited) { + rA(this); + sA(this); + this._onBatchCreated(_); + this._inited = !0; + } + dc(this); + lA.call(this); + }; + aA._activate = function(t) { + t = !1 !== t; + m.director._nodeActivator.activateNode(this, t); + this._globals.activate(); + this._renderScene && this._renderScene.activate(); + }; + const hA = oA.prototype; + Yl(hA, "autoReleaseAssets"); + Yl(hA, "_globals"); + Ul("cc.Scene")(oA); + const cA = new WeakMap; + const uA = new WeakSet; + const _A = new WeakSet; + function dA(t, e) { + let i; + i = su.safeFindClass; + const s = qu.pool.get(); + let n; + try { + n = o_(t, s, { + classFinder: i, + customEnv: e + }); + } catch (t) { + x(t); + qu.pool.put(s); + throw t; + } + n._uuid = e.__uuid__ || ""; + const r = s.uuidList; + const o = s.uuidObjList; + const a = s.uuidPropList; + const l = s.uuidTypeList || []; + const h = []; + for (let t = 0; t < r.length; t++) { + const e = r[t]; + h[t] = { + uuid: Wh(e), + owner: o[t], + prop: a[t], + type: ee.getClassById(l[t]) + }; + } + cA.set(n, h); + n._native && uA.add(n); + qu.pool.put(s); + return n; + } + var pA = new class { + constructor() { + this._depends = new Rh; + } + init() { + this._depends.clear(); + } + getNativeDep(t) { + const e = this._depends.get(t); + return e && e.nativeDep ? { + ...e.nativeDep + } : null; + } + getDeps(t) { + return this._depends.has(t) ? this._depends.get(t).deps : []; + } + getDepsRecursively(t) { + const e = Object.create(null); + const i = []; + this._descend(t, e, i); + return i; + } + remove(t) { + this._depends.remove(t); + } + parse(t, e) { + let i = null; + if (Array.isArray(e) || e.__type__ || e instanceof ou) { + if (this._depends.has(t)) return this._depends.get(t); + if (Array.isArray(e) && !function(t) { + const e = t[Gu]; + const i = e[e.length - 1]; + return "number" == typeof i && i < 0; + }(e)) i = { + deps: this._parseDepsFromJson(e) + }; else try { + const s = dA(e, { + __uuid__: t + }); + i = this._parseDepsFromAsset(s); + i.nativeDep && (i.nativeDep.uuid = t); + Dh.add(`${t}@import`, s); + } catch (e) { + Bh.remove(`${t}@import`); + i = { + deps: [] + }; + } + } else { + if (this._depends.has(t)) { + i = this._depends.get(t); + if (i.parsedFromExistAsset) return i; + } + i = this._parseDepsFromAsset(e); + } + this._depends.add(t, i); + return i; + } + _parseDepsFromAsset(t) { + const e = { + deps: [], + parsedFromExistAsset: !0 + }; + const i = cA.get(t); + se(i); + for (let t = 0, s = i.length; t < s; t++) e.deps.push(i[t].uuid); + uA.has(t) && (e.nativeDep = t._nativeDep); + return e; + } + _parseDepsFromJson(t) { + const e = h_(t); + e.forEach(((t, i) => e[i] = Wh(t))); + return e; + } + _descend(t, e, i) { + const s = this.getDeps(t); + for (let t = 0; t < s.length; t++) { + const n = s[t]; + if (!e[n]) { + e[n] = !0; + i.push(n); + this._descend(n, e, i); + } + } + } + }; + const mA = jsb.SimpleTexture; + mA.Filter = Qp; + mA.PixelFormat = Jp; + mA.WrapMode = Zp; + const fA = jsb.SimpleTexture.prototype; + const gA = fA.uploadData; + fA.uploadData = function(t, e = 0, i = 0) { + let s; + t instanceof HTMLCanvasElement ? s = t.data : t instanceof HTMLImageElement ? s = t._data : ArrayBuffer.isView(t) && (s = t.buffer); + gA.call(this, s, e, i); + }; + const yA = Ul("cc.SimpleTexture"); + fA._ctor = function() { + jsb.TextureBase.prototype._ctor.apply(this, arguments); + this._gfxTexture = null; + this._registerListeners(); + }; + const bA = fA.getGFXTexture; + fA.getGFXTexture = function() { + this._gfxTexture || (this._gfxTexture = bA.call(this)); + return this._gfxTexture; + }; + fA._onGFXTextureUpdated = function(t) { + this._gfxTexture = t; + }; + fA._onAfterAssignImage = function(t) { + if (pe.CLEANUP_IMAGE_CACHE) { + const e = pA.getDeps(this._uuid); + const i = e.indexOf(t._uuid); + if (-1 !== i) { + ot(e, i); + t.decRef(); + } + } + }; + yA(mA); + m.SimpleTexture = jsb.SimpleTexture; + const SA = jsb.TextureCube.prototype; + var AA; + !function(t) { + t[t.right = 0] = "right"; + t[t.left = 1] = "left"; + t[t.top = 2] = "top"; + t[t.bottom = 3] = "bottom"; + t[t.front = 4] = "front"; + t[t.back = 5] = "back"; + }(AA || (AA = {})); + var TA; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.AUTO = 1] = "AUTO"; + t[t.BAKED_CONVOLUTION_MAP = 2] = "BAKED_CONVOLUTION_MAP"; + }(TA || (TA = {})); + SA.createNode = null; + const vA = t("TextureCube", jsb.TextureCube); + vA.Filter = Qp; + vA.PixelFormat = Jp; + vA.WrapMode = Zp; + SA._ctor = function() { + jsb.SimpleTexture.prototype._ctor.apply(this, arguments); + this._mipmaps = null; + this._mipmapAtlas = null; + }; + Object.defineProperty(SA, "mipmaps", { + get() { + return this._mipmaps; + }, + set(t) { + this._mipmaps = t; + this.setMipmaps(t); + } + }); + Object.defineProperty(SA, "image", { + get() { + return 0 === this._mipmaps.length ? null : this._mipmaps[0]; + }, + set(t) { + this.mipmaps = t ? [ t ] : []; + } + }); + const EA = SA.onLoaded; + SA.onLoaded = function() { + this._mipmapMode === TA.BAKED_CONVOLUTION_MAP ? this.setMipmapAtlasForJS(this._mipmapAtlas) : this.setMipmapsForJS(this._mipmaps); + EA.apply(this); + }; + SA._serialize = function(t) { + return null; + }; + SA._deserialize = function(t, e) { + const i = t; + jsb.TextureBase.prototype._deserialize.call(this, i.base, e); + this.isRGBE = i.rgbe; + null != i.mipmapMode && (this._mipmapMode = i.mipmapMode); + if (this._mipmapMode === TA.BAKED_CONVOLUTION_MAP) { + const t = i.mipmapAtlas; + const s = i.mipmapLayout; + this._mipmapAtlas = { + atlas: {}, + layout: s + }; + this._mipmapAtlas.atlas = { + front: new jsb.ImageAsset, + back: new jsb.ImageAsset, + left: new jsb.ImageAsset, + right: new jsb.ImageAsset, + top: new jsb.ImageAsset, + bottom: new jsb.ImageAsset + }; + if (t) { + const i = ee.getClassId(jsb.ImageAsset); + e.result.push(this._mipmapAtlas.atlas, "front", t.front, i); + e.result.push(this._mipmapAtlas.atlas, "back", t.back, i); + e.result.push(this._mipmapAtlas.atlas, "left", t.left, i); + e.result.push(this._mipmapAtlas.atlas, "right", t.right, i); + e.result.push(this._mipmapAtlas.atlas, "top", t.top, i); + e.result.push(this._mipmapAtlas.atlas, "bottom", t.bottom, i); + } + } else { + this._mipmaps = new Array(i.mipmaps.length); + for (let t = 0; t < i.mipmaps.length; ++t) { + this._mipmaps[t] = { + front: new jsb.ImageAsset, + back: new jsb.ImageAsset, + left: new jsb.ImageAsset, + right: new jsb.ImageAsset, + top: new jsb.ImageAsset, + bottom: new jsb.ImageAsset + }; + const s = i.mipmaps[t]; + const n = ee.getClassId(jsb.ImageAsset); + e.result.push(this._mipmaps[t], "front", s.front, n); + e.result.push(this._mipmaps[t], "back", s.back, n); + e.result.push(this._mipmaps[t], "left", s.left, n); + e.result.push(this._mipmaps[t], "right", s.right, n); + e.result.push(this._mipmaps[t], "top", s.top, n); + e.result.push(this._mipmaps[t], "bottom", s.bottom, n); + } + } + }; + m.TextureCube = jsb.TextureCube; + const CA = vA.prototype; + Yl(CA, "isRGBE"); + Yl(CA, "_mipmaps"); + Yl(CA, "_mipmapMode"); + Yl(CA, "_mipmapAtlas"); + Ul("cc.TextureCube")(vA); + let xA; + !function(t) { + t[t.DEFAULT = 0] = "DEFAULT"; + t[t.SKINNING = 1] = "SKINNING"; + t[t.BAKED_SKINNING = 2] = "BAKED_SKINNING"; + t[t.BATCH_2D = 3] = "BATCH_2D"; + t[t.PARTICLE_BATCH = 4] = "PARTICLE_BATCH"; + t[t.LINE = 5] = "LINE"; + }(xA || (xA = {})); + const wA = jsb.Model; + const RA = wA.prototype; + RA._ctor = function() { + this._device = zo.gfxDevice; + }; + const IA = RA.createBoundingShape; + RA.createBoundingShape = function(t, e) { + t && e && IA.call(this, t, e); + }; + const MA = jsb.Ambient; + m.Ambient = MA; + let BA; + !function(t) { + t[t.DIRECTIONAL = 0] = "DIRECTIONAL"; + t[t.SPHERE = 1] = "SPHERE"; + t[t.SPOT = 2] = "SPOT"; + t[t.UNKNOWN = 3] = "UNKNOWN"; + }(BA || (BA = {})); + const DA = t => 4 * Math.PI * Math.PI * t * t; + const PA = jsb.Light; + m.Light = jsb.Light; + const OA = jsb.DirectionalLight; + m.DirectionalLight = jsb.DirectionalLight; + const NA = jsb.SpotLight; + m.SpotLight = jsb.SpotLight; + const LA = jsb.SphereLight; + m.SphereLight = jsb.SphereLight; + const FA = oe({ + LINEAR: 0, + EXP: 1, + EXP_SQUARED: 2, + LAYERED: 3 + }); + const VA = jsb.FogInfo; + const kA = jsb.Fog; + m.Fog = kA; + const UA = oe({ + Low_256x256: 256, + Medium_512x512: 512, + High_1024x1024: 1024, + Ultra_2048x2048: 2048 + }); + const GA = oe({ + Planar: 0, + ShadowMap: 1 + }); + const zA = oe({ + HARD: 0, + SOFT: 1, + SOFT_2X: 2 + }); + const HA = oe({ + LEVEL_1: 1, + LEVEL_2: 2, + LEVEL_3: 3, + LEVEL_4: 4 + }); + const jA = oe({ + NONE: 1, + RemoveDuplicates: 2, + DisableRotaitonFix: 3 + }); + const XA = oe({ + HEMISPHERE_DIFFUSE: 0, + AUTOGEN_HEMISPHERE_DIFFUSE_WITH_REFLECTION: 1, + DIFFUSEMAP_WITH_REFLECTION: 2 + }); + const WA = jsb.ShadowsInfo; + const YA = jsb.Shadow; + m.Shadows = YA; + const qA = jsb.Skybox; + m.Skybox = qA; + var KA = Object.freeze({ + __proto__: null, + get ModelType() { + return xA; + }, + Model: wA, + SubModel: Ig, + get CameraFOVAxis() { + return vy; + }, + get CameraProjection() { + return Ey; + }, + get CameraAperture() { + return Cy; + }, + get CameraISO() { + return xy; + }, + get CameraShutter() { + return wy; + }, + get CameraType() { + return Ry; + }, + get TrackingType() { + return Iy; + }, + SKYBOX_FLAG: My, + Camera: By, + Ambient: MA, + ColorTemperatureToRGB: function(t, e) { + e < 1e3 ? e = 1e3 : e > 15e3 && (e = 15e3); + const i = e * e; + const s = (.860117757 + .000154118254 * e + 1.28641212e-7 * i) / (1 + .000842420235 * e + 7.08145163e-7 * i); + const n = (.317398726 + 422806245e-13 * e + 4.20481691e-8 * i) / (1 - 289741816e-13 * e + 1.61456053e-7 * i); + const r = 2 * s - 8 * n + 4; + const o = 3 * s / r; + const a = 2 * n / r; + const l = 1 / a * o; + const h = 1 / a * (1 - o - a); + t.x = 3.2404542 * l - 1.5371385 + -.4985314 * h; + t.y = -.969266 * l + 1.8760108 + .041556 * h; + t.z = .0556434 * l - .2040259 + 1.0572252 * h; + }, + get LightType() { + return BA; + }, + nt2lm: DA, + Light: PA, + DirectionalLight: OA, + SpotLight: NA, + SphereLight: LA, + FogType: FA, + FogInfo: VA, + Fog: kA, + ShadowSize: UA, + ShadowType: GA, + PCFType: zA, + CSMLevel: HA, + CSMOptimizationMode: jA, + EnvironmentLightingType: XA, + ShadowsInfo: WA, + Shadows: YA, + Skybox: qA + }); + const JA = t("FogType", oe({ + LINEAR: 0, + EXP: 1, + EXP_SQUARED: 2, + LAYERED: 3 + })); + const ZA = t("ShadowSize", oe({ + Low_256x256: 256, + Medium_512x512: 512, + High_1024x1024: 1024, + Ultra_2048x2048: 2048 + })); + const QA = t("ShadowType", oe({ + Planar: 0, + ShadowMap: 1 + })); + const $A = t("AmbientInfo", jsb.AmbientInfo); + m.AmbientInfo = $A; + const tT = t("SkyboxInfo", jsb.SkyboxInfo); + m.SkyboxInfo = tT; + const eT = t("FogInfo", jsb.FogInfo); + m.FogInfo = eT; + eT.FogType = JA; + const iT = t("ShadowsInfo", jsb.ShadowsInfo); + m.ShadowsInfo = iT; + const sT = t("OctreeInfo", jsb.OctreeInfo); + m.OctreeInfo = sT; + const nT = t("SceneGlobals", jsb.SceneGlobals); + m.SceneGlobals = nT; + !function() { + const t = nT.prototype; + t._ctor = function() { + this._ambientRef = null; + this._shadowsRef = null; + this._skyboxRef = null; + this._fogRef = null; + this._octreeRef = null; + }; + Object.defineProperty(t, "ambient", { + enumerable: !0, + configurable: !0, + get() { + return this._ambientRef; + }, + set(t) { + this._ambientRef = t; + this.setAmbientInfo(t); + } + }); + Object.defineProperty(t, "shadows", { + enumerable: !0, + configurable: !0, + get() { + return this._shadowsRef; + }, + set(t) { + this._shadowsRef = t; + this.setShadowsInfo(t); + } + }); + Object.defineProperty(t, "_skybox", { + enumerable: !0, + configurable: !0, + get() { + return this._skyboxRef; + }, + set(t) { + this._skyboxRef = t; + this.setSkyboxInfo(t); + } + }); + Object.defineProperty(t, "skybox", { + enumerable: !0, + configurable: !0, + get() { + return this._skyboxRef; + }, + set(t) { + this._skyboxRef = t; + this.setSkyboxInfo(t); + } + }); + Object.defineProperty(t, "fog", { + enumerable: !0, + configurable: !0, + get() { + return this._fogRef; + }, + set(t) { + this._fogRef = t; + this.setFogInfo(t); + } + }); + Object.defineProperty(t, "octree", { + enumerable: !0, + configurable: !0, + get() { + return this._octreeRef; + }, + set(t) { + this._octreeRef = t; + this.setOctreeInfo(t); + } + }); + }(); + const rT = nT.prototype; + Yl(rT, "ambient"); + Yl(rT, "shadows"); + Yl(rT, "_skybox"); + Yl(rT, "fog"); + const oT = Object.getOwnPropertyDescriptor(rT, "skybox"); + Th(tT)(rT, "skybox", oT); + Yl(rT, "octree"); + Ul("cc.SceneGlobals")(nT); + const aT = sT.prototype; + Yl(aT, "_enabled"); + Yl(aT, "_minPos"); + Yl(aT, "_maxPos"); + Yl(aT, "_depth"); + const lT = Object.getOwnPropertyDescriptor(aT, "depth"); + Th(Oe)(aT, "depth", lT); + Ul("cc.OctreeInfo")(sT); + const hT = iT.prototype; + Yl(hT, "_enabled"); + Yl(hT, "_type"); + Yl(hT, "_normal"); + Yl(hT, "_distance"); + Yl(hT, "_shadowColor"); + Yl(hT, "_maxReceived"); + Yl(hT, "_size"); + const cT = Object.getOwnPropertyDescriptor(hT, "type"); + Th(QA)(hT, "type", cT); + const uT = Object.getOwnPropertyDescriptor(hT, "planeHeight"); + Th(Ne)(hT, "planeHeight", uT); + const _T = Object.getOwnPropertyDescriptor(hT, "maxReceived"); + Th(Oe)(hT, "maxReceived", _T); + const dT = Object.getOwnPropertyDescriptor(hT, "shadowMapSize"); + Th(ZA)(hT, "shadowMapSize", dT); + Ul("cc.ShadowsInfo")(iT); + const pT = eT.prototype; + Yl(pT, "_type"); + Yl(pT, "_fogColor"); + Yl(pT, "_enabled"); + Yl(pT, "_fogDensity"); + Yl(pT, "_fogStart"); + Yl(pT, "_fogEnd"); + Yl(pT, "_fogAtten"); + Yl(pT, "_fogTop"); + Yl(pT, "_fogRange"); + Yl(pT, "_accurate"); + const mT = Object.getOwnPropertyDescriptor(pT, "type"); + Th(JA)(pT, "type", mT); + const fT = Object.getOwnPropertyDescriptor(pT, "fogDensity"); + Th(Ne)(pT, "fogDensity", fT); + const gT = Object.getOwnPropertyDescriptor(pT, "fogStart"); + Th(Ne)(pT, "fogStart", gT); + const yT = Object.getOwnPropertyDescriptor(pT, "fogEnd"); + Th(Ne)(pT, "fogEnd", yT); + const bT = Object.getOwnPropertyDescriptor(pT, "fogAtten"); + Th(Ne)(pT, "fogAtten", bT); + const ST = Object.getOwnPropertyDescriptor(pT, "fogTop"); + Th(Ne)(pT, "fogTop", ST); + const AT = Object.getOwnPropertyDescriptor(pT, "fogRange"); + Th(Ne)(pT, "fogRange", AT); + Ul("cc.FogInfo")(eT); + const TT = tT.prototype; + Yl(TT, "_envLightingType"); + ql("_envmap")(TT, "_envmapHDR"); + Th(vA)(TT, "_envmapHDR"); + Yl(TT, "_envmapHDR"); + Th(vA)(TT, "_envmapLDR"); + Yl(TT, "_envmapLDR"); + Th(vA)(TT, "_diffuseMapHDR"); + Yl(TT, "_diffuseMapHDR"); + Th(vA)(TT, "_diffuseMapLDR"); + Yl(TT, "_diffuseMapLDR"); + Yl(TT, "_enabled"); + Yl(TT, "_useHDR"); + Th(hm)(TT, "_editableMaterial"); + Yl(TT, "_editableMaterial"); + Th(vA)(TT, "_reflectionHDR"); + Yl(TT, "_reflectionHDR"); + Th(vA)(TT, "_reflectionLDR"); + Yl(TT, "_reflectionLDR"); + const vT = Object.getOwnPropertyDescriptor(TT, "envLightingType"); + Th(XA)(TT, "envLightingType", vT); + const ET = Object.getOwnPropertyDescriptor(TT, "envmap"); + Th(vA)(TT, "envmap", ET); + const CT = Object.getOwnPropertyDescriptor(TT, "diffuseMap"); + Th(vA)(TT, "diffuseMap", CT); + const xT = Object.getOwnPropertyDescriptor(TT, "skyboxMaterial"); + Th(hm)(TT, "skyboxMaterial", xT); + Ul("cc.SkyboxInfo")(tT); + const wT = $A.prototype; + ql("_skyColor")(wT, "_skyColorHDR"); + Yl(wT, "_skyColorHDR"); + ql("_skyIllum")(wT, "_skyIllumHDR"); + Yl(wT, "_skyIllumHDR"); + ql("_groundAlbedo")(wT, "_groundAlbedoHDR"); + Yl(wT, "_groundAlbedoHDR"); + Yl(wT, "_skyColorLDR"); + Yl(wT, "_skyIllumLDR"); + Yl(wT, "_groundAlbedoLDR"); + const RT = Object.getOwnPropertyDescriptor(wT, "skyIllum"); + Th(Ne)(wT, "skyIllum", RT); + Ul("cc.AmbientInfo")($A); + et({ + SystemEventType: { + newName: "Input.EventType", + since: "3.3.0", + removed: !1 + } + }); + et({ + SystemEvent: { + newName: "Input", + since: "3.4.0", + removed: !1 + }, + systemEvent: { + newName: "input", + since: "3.4.0", + removed: !1 + } + }); + class IT { + constructor() { + this._intervalInSeconds = .2; + this._intervalId = void 0; + this._isEnabled = !1; + this._eventTarget = new vo; + this._didAccelerateFunc = void 0; + this._didAccelerateFunc = this._didAccelerate.bind(this); + } + _didAccelerate() { + const t = jsb.device.getDeviceMotionValue(); + let e = .1 * t[3]; + let i = .1 * t[4]; + const s = .1 * t[5]; + const n = Lo.orientation; + const r = e; + if (n === Oo.LANDSCAPE_RIGHT) { + e = -i; + i = r; + } else if (n === Oo.LANDSCAPE_LEFT) { + e = i; + i = -r; + } else if (n === Oo.PORTRAIT_UPSIDE_DOWN) { + e = -e; + i = -i; + } + if (Po.os === Ro.ANDROID || Po.os === Ro.OHOS) { + e = -e; + i = -i; + } + const o = performance.now(); + const a = new kS(e, i, s, o); + const l = new BS(a); + this._eventTarget.emit(MS.DEVICEMOTION, l); + } + start() { + this._intervalId && clearInterval(this._intervalId); + this._intervalId = setInterval(this._didAccelerateFunc, 1e3 * this._intervalInSeconds); + jsb.device.setAccelerometerInterval(this._intervalInSeconds); + jsb.device.setAccelerometerEnabled(!0); + this._isEnabled = !0; + } + stop() { + if (this._intervalId) { + clearInterval(this._intervalId); + this._intervalId = void 0; + } + jsb.device.setAccelerometerEnabled(!1); + this._isEnabled = !1; + } + setInterval(t) { + this._intervalInSeconds = t / 1e3; + jsb.device.setAccelerometerInterval(this._intervalInSeconds); + if (this._isEnabled) { + jsb.device.setAccelerometerEnabled(!1); + jsb.device.setAccelerometerEnabled(!0); + } + } + on(t, e, i) { + this._eventTarget.on(t, e, i); + } + } + class MT {} + class BT extends MT { + getValue() { + throw new Error("Method not implemented."); + } + } + class DT extends MT { + getValue() { + throw new Error("Method not implemented."); + } + } + class PT extends MT { + getValue() { + throw new Error("Method not implemented."); + } + } + class OT extends MT { + getValue() { + throw new Error("Method not implemented."); + } + } + class NT extends BT { + constructor(t) { + super(); + this.positive = void 0; + this.negative = void 0; + this.positive = t.positive; + this.negative = t.negative; + } + getValue() { + const t = this.positive.getValue(); + const e = this.negative.getValue(); + return Math.abs(t) > Math.abs(e) ? t : -e; + } + } + class LT extends DT { + constructor(t) { + super(); + this.up = void 0; + this.down = void 0; + this.left = void 0; + this.right = void 0; + this.xAxis = void 0; + this.yAxis = void 0; + this.up = t.up; + this.down = t.down; + this.left = t.left; + this.right = t.right; + this.xAxis = new NT({ + positive: this.right, + negative: this.left + }); + this.yAxis = new NT({ + positive: this.up, + negative: this.down + }); + } + getValue() { + return new Qi(this.xAxis.getValue(), this.yAxis.getValue()); + } + } + class FT extends BT { + getValue() { + return super.getValue(); + } + } + class VT extends LT {} + class kT extends LT {} + class UT extends OT { + getValue() { + return super.getValue(); + } + } + class GT extends PT { + getValue() { + return super.getValue(); + } + } + var zT; + !function(t) { + t[t.BUTTON_SOUTH = 0] = "BUTTON_SOUTH"; + t[t.BUTTON_EAST = 1] = "BUTTON_EAST"; + t[t.BUTTON_WEST = 2] = "BUTTON_WEST"; + t[t.BUTTON_NORTH = 3] = "BUTTON_NORTH"; + t[t.NS_MINUS = 4] = "NS_MINUS"; + t[t.NS_PLUS = 5] = "NS_PLUS"; + t[t.BUTTON_L1 = 6] = "BUTTON_L1"; + t[t.BUTTON_L2 = 7] = "BUTTON_L2"; + t[t.BUTTON_L3 = 8] = "BUTTON_L3"; + t[t.BUTTON_R1 = 9] = "BUTTON_R1"; + t[t.BUTTON_R2 = 10] = "BUTTON_R2"; + t[t.BUTTON_R3 = 11] = "BUTTON_R3"; + t[t.DPAD_UP = 12] = "DPAD_UP"; + t[t.DPAD_DOWN = 13] = "DPAD_DOWN"; + t[t.DPAD_LEFT = 14] = "DPAD_LEFT"; + t[t.DPAD_RIGHT = 15] = "DPAD_RIGHT"; + t[t.LEFT_STICK_UP = 16] = "LEFT_STICK_UP"; + t[t.LEFT_STICK_DOWN = 17] = "LEFT_STICK_DOWN"; + t[t.LEFT_STICK_LEFT = 18] = "LEFT_STICK_LEFT"; + t[t.LEFT_STICK_RIGHT = 19] = "LEFT_STICK_RIGHT"; + t[t.RIGHT_STICK_UP = 20] = "RIGHT_STICK_UP"; + t[t.RIGHT_STICK_DOWN = 21] = "RIGHT_STICK_DOWN"; + t[t.RIGHT_STICK_LEFT = 22] = "RIGHT_STICK_LEFT"; + t[t.RIGHT_STICK_RIGHT = 23] = "RIGHT_STICK_RIGHT"; + t[t.ROKID_MENU = 24] = "ROKID_MENU"; + t[t.ROKID_START = 25] = "ROKID_START"; + }(zT || (zT = {})); + const HT = { + 1: zT.BUTTON_EAST, + 2: zT.BUTTON_SOUTH, + 3: zT.BUTTON_NORTH, + 4: zT.BUTTON_WEST, + 5: zT.BUTTON_L1, + 6: zT.BUTTON_R1, + 7: zT.NS_MINUS, + 8: zT.NS_PLUS, + 9: zT.BUTTON_L3, + 10: zT.BUTTON_R3, + 11: zT.ROKID_MENU, + 12: zT.ROKID_START + }; + class jT { + get buttonNorth() { + return this._buttonNorth; + } + get buttonEast() { + return this._buttonEast; + } + get buttonWest() { + return this._buttonWest; + } + get buttonSouth() { + return this._buttonSouth; + } + get buttonL1() { + return this._buttonL1; + } + get buttonL2() { + return this._buttonL2; + } + get buttonL3() { + return this._buttonL3; + } + get buttonR1() { + return this._buttonR1; + } + get buttonR2() { + return this._buttonR2; + } + get buttonR3() { + return this._buttonR3; + } + get buttonShare() { + return this._buttonShare; + } + get buttonOptions() { + return this._buttonOptions; + } + get dpad() { + return this._dpad; + } + get leftStick() { + return this._leftStick; + } + get rightStick() { + return this._rightStick; + } + get buttonStart() { + return this._buttonStart; + } + get deviceId() { + return this._deviceId; + } + get connected() { + return this._connected; + } + constructor(t) { + this._deviceId = -1; + this._connected = !1; + this._nativeButtonState = { + [zT.BUTTON_SOUTH]: 0, + [zT.BUTTON_EAST]: 0, + [zT.BUTTON_WEST]: 0, + [zT.BUTTON_NORTH]: 0, + [zT.NS_MINUS]: 0, + [zT.NS_PLUS]: 0, + [zT.BUTTON_L1]: 0, + [zT.BUTTON_L2]: 0, + [zT.BUTTON_L3]: 0, + [zT.BUTTON_R1]: 0, + [zT.BUTTON_R2]: 0, + [zT.BUTTON_R3]: 0, + [zT.DPAD_UP]: 0, + [zT.DPAD_DOWN]: 0, + [zT.DPAD_LEFT]: 0, + [zT.DPAD_RIGHT]: 0, + [zT.LEFT_STICK_UP]: 0, + [zT.LEFT_STICK_DOWN]: 0, + [zT.LEFT_STICK_LEFT]: 0, + [zT.LEFT_STICK_RIGHT]: 0, + [zT.RIGHT_STICK_UP]: 0, + [zT.RIGHT_STICK_DOWN]: 0, + [zT.RIGHT_STICK_LEFT]: 0, + [zT.RIGHT_STICK_RIGHT]: 0, + [zT.ROKID_MENU]: 0, + [zT.ROKID_START]: 0 + }; + this._deviceId = t; + this._initInputSource(); + } + static _init() { + Po.hasFeature(Mo.EVENT_GAMEPAD) && jT._registerEvent(); + } + static _on(t, e, i) { + jT._eventTarget.on(t, e, i); + } + static _removeInputDevice(t) { + const e = jT.all.findIndex((e => e.deviceId === t)); + -1 !== e && ot(jT.all, e); + } + static _getInputDevice(t) { + return jT.all.find((e => e.deviceId === t)); + } + static _createInputDevice(t, e) { + const i = new jT(t); + i._connected = e; + jT.all.push(i); + return i; + } + static _getOrCreateInputDevice(t, e) { + let i = jT._getInputDevice(t); + i || (i = jT._createInputDevice(t, e)); + i._connected = e; + return i; + } + static _registerEvent() { + jsb.onControllerInput = t => { + for (let e = 0; e < t.length; ++e) { + const i = t[e]; + const s = jT._getOrCreateInputDevice(i.id, !0); + s._updateNativeButtonState(i); + jT._eventTarget.emit(MS.GAMEPAD_INPUT, new LS(MS.GAMEPAD_INPUT, s)); + } + }; + jsb.onControllerChange = t => { + for (let e = 0; e < t.length; ++e) { + const i = t[e]; + let s = jT._getInputDevice(i); + if (!s) { + s = jT._createInputDevice(i, !0); + jT._eventTarget.emit(MS.GAMEPAD_CHANGE, new LS(MS.GAMEPAD_CHANGE, s)); + } + } + const e = jT.all; + for (let i = 0; i < e.length; ++i) { + const s = e[i]; + if (!t.includes(s.deviceId)) { + jT._removeInputDevice(s.deviceId); + s._connected = !1; + jT._eventTarget.emit(MS.GAMEPAD_CHANGE, new LS(MS.GAMEPAD_CHANGE, s)); + } + } + }; + } + _axisToButtons(t) { + const e = Math.abs(t); + return t > 0 ? { + negative: 0, + positive: e + } : t < 0 ? { + negative: e, + positive: 0 + } : { + negative: 0, + positive: 0 + }; + } + _updateNativeButtonState(t) { + const {buttonInfoList: e, axisInfoList: i} = t; + for (let t = 0; t < e.length; ++t) { + const i = e[t]; + const s = HT[i.code]; + this._nativeButtonState[s] = i.isPressed ? 1 : 0; + } + for (let t = 0; t < i.length; ++t) { + const e = i[t]; + const {code: s, value: n} = e; + let r; + let o; + let a; + switch (s) { + case 1: + r = zT.DPAD_LEFT; + o = zT.DPAD_RIGHT; + a = this._axisToButtons(n); + break; + + case 2: + r = zT.DPAD_DOWN; + o = zT.DPAD_UP; + a = this._axisToButtons(n); + break; + + case 3: + r = zT.LEFT_STICK_LEFT; + o = zT.LEFT_STICK_RIGHT; + a = this._axisToButtons(n); + break; + + case 4: + r = zT.LEFT_STICK_DOWN; + o = zT.LEFT_STICK_UP; + a = this._axisToButtons(n); + break; + + case 5: + r = zT.RIGHT_STICK_LEFT; + o = zT.RIGHT_STICK_RIGHT; + a = this._axisToButtons(n); + break; + + case 6: + r = zT.RIGHT_STICK_DOWN; + o = zT.RIGHT_STICK_UP; + a = this._axisToButtons(n); + break; + + default: + 7 === s ? this._nativeButtonState[zT.BUTTON_L2] = n : 8 === s && (this._nativeButtonState[zT.BUTTON_R2] = n); + } + if (r && o && a) { + this._nativeButtonState[r] = a.negative; + this._nativeButtonState[o] = a.positive; + } + } + } + _initInputSource() { + this._buttonNorth = new FT; + this._buttonNorth.getValue = () => this._nativeButtonState[zT.BUTTON_NORTH]; + this._buttonEast = new FT; + this._buttonEast.getValue = () => this._nativeButtonState[zT.BUTTON_EAST]; + this._buttonWest = new FT; + this._buttonWest.getValue = () => this._nativeButtonState[zT.BUTTON_WEST]; + this._buttonSouth = new FT; + this._buttonSouth.getValue = () => this._nativeButtonState[zT.BUTTON_SOUTH]; + this._buttonL1 = new FT; + this._buttonL1.getValue = () => this._nativeButtonState[zT.BUTTON_L1]; + this._buttonL2 = new FT; + this._buttonL2.getValue = () => this._nativeButtonState[zT.BUTTON_L2]; + this._buttonL3 = new FT; + this._buttonL3.getValue = () => this._nativeButtonState[zT.BUTTON_L3]; + this._buttonR1 = new FT; + this._buttonR1.getValue = () => this._nativeButtonState[zT.BUTTON_R1]; + this._buttonR2 = new FT; + this._buttonR2.getValue = () => this._nativeButtonState[zT.BUTTON_R2]; + this._buttonR3 = new FT; + this._buttonR3.getValue = () => this._nativeButtonState[zT.BUTTON_R3]; + this._buttonShare = new FT; + this._buttonShare.getValue = () => this._nativeButtonState[zT.NS_MINUS]; + this._buttonOptions = new FT; + this._buttonOptions.getValue = () => this._nativeButtonState[zT.NS_PLUS] || this._nativeButtonState[zT.ROKID_MENU]; + const t = new FT; + t.getValue = () => this._nativeButtonState[zT.DPAD_UP]; + const e = new FT; + e.getValue = () => this._nativeButtonState[zT.DPAD_DOWN]; + const i = new FT; + i.getValue = () => this._nativeButtonState[zT.DPAD_LEFT]; + const s = new FT; + s.getValue = () => this._nativeButtonState[zT.DPAD_RIGHT]; + this._dpad = new VT({ + up: t, + down: e, + left: i, + right: s + }); + const n = new FT; + n.getValue = () => this._nativeButtonState[zT.LEFT_STICK_UP]; + const r = new FT; + r.getValue = () => this._nativeButtonState[zT.LEFT_STICK_DOWN]; + const o = new FT; + o.getValue = () => this._nativeButtonState[zT.LEFT_STICK_LEFT]; + const a = new FT; + a.getValue = () => this._nativeButtonState[zT.LEFT_STICK_RIGHT]; + this._leftStick = new kT({ + up: n, + down: r, + left: o, + right: a + }); + const l = new FT; + l.getValue = () => this._nativeButtonState[zT.RIGHT_STICK_UP]; + const h = new FT; + h.getValue = () => this._nativeButtonState[zT.RIGHT_STICK_DOWN]; + const c = new FT; + c.getValue = () => this._nativeButtonState[zT.RIGHT_STICK_LEFT]; + const u = new FT; + u.getValue = () => this._nativeButtonState[zT.RIGHT_STICK_RIGHT]; + this._rightStick = new kT({ + up: l, + down: h, + left: c, + right: u + }); + this._buttonStart = new FT; + this._buttonStart.getValue = () => this._nativeButtonState[zT.ROKID_START]; + } + } + jT.all = []; + jT._eventTarget = new vo; + var XT; + !function(t) { + t[t.BUTTON_EAST = 0] = "BUTTON_EAST"; + t[t.BUTTON_SOUTH = 1] = "BUTTON_SOUTH"; + t[t.BUTTON_WEST = 2] = "BUTTON_WEST"; + t[t.BUTTON_NORTH = 3] = "BUTTON_NORTH"; + t[t.BUTTON_TRIGGER_LEFT = 4] = "BUTTON_TRIGGER_LEFT"; + t[t.BUTTON_TRIGGER_RIGHT = 5] = "BUTTON_TRIGGER_RIGHT"; + t[t.TRIGGER_LEFT = 6] = "TRIGGER_LEFT"; + t[t.TRIGGER_RIGHT = 7] = "TRIGGER_RIGHT"; + t[t.GRIP_LEFT = 8] = "GRIP_LEFT"; + t[t.GRIP_RIGHT = 9] = "GRIP_RIGHT"; + t[t.BUTTON_LEFT_STICK = 10] = "BUTTON_LEFT_STICK"; + t[t.LEFT_STICK_UP = 11] = "LEFT_STICK_UP"; + t[t.LEFT_STICK_DOWN = 12] = "LEFT_STICK_DOWN"; + t[t.LEFT_STICK_LEFT = 13] = "LEFT_STICK_LEFT"; + t[t.LEFT_STICK_RIGHT = 14] = "LEFT_STICK_RIGHT"; + t[t.BUTTON_RIGHT_STICK = 15] = "BUTTON_RIGHT_STICK"; + t[t.RIGHT_STICK_UP = 16] = "RIGHT_STICK_UP"; + t[t.RIGHT_STICK_DOWN = 17] = "RIGHT_STICK_DOWN"; + t[t.RIGHT_STICK_LEFT = 18] = "RIGHT_STICK_LEFT"; + t[t.RIGHT_STICK_RIGHT = 19] = "RIGHT_STICK_RIGHT"; + }(XT || (XT = {})); + var WT; + !function(t) { + t[t.HAND_LEFT = 0] = "HAND_LEFT"; + t[t.HAND_RIGHT = 1] = "HAND_RIGHT"; + t[t.AIM_LEFT = 2] = "AIM_LEFT"; + t[t.AIM_RIGHT = 3] = "AIM_RIGHT"; + }(WT || (WT = {})); + const YT = { + 1: XT.BUTTON_EAST, + 2: XT.BUTTON_SOUTH, + 3: XT.BUTTON_NORTH, + 4: XT.BUTTON_WEST, + 9: XT.BUTTON_LEFT_STICK, + 10: XT.BUTTON_RIGHT_STICK, + 13: XT.BUTTON_TRIGGER_LEFT, + 14: XT.BUTTON_TRIGGER_RIGHT + }; + class qT { + get buttonNorth() { + return this._buttonNorth; + } + get buttonEast() { + return this._buttonEast; + } + get buttonWest() { + return this._buttonWest; + } + get buttonSouth() { + return this._buttonSouth; + } + get buttonTriggerLeft() { + return this._buttonTriggerLeft; + } + get buttonTriggerRight() { + return this._buttonTriggerRight; + } + get triggerLeft() { + return this._triggerLeft; + } + get triggerRight() { + return this._triggerRight; + } + get gripLeft() { + return this._gripLeft; + } + get gripRight() { + return this._gripRight; + } + get leftStick() { + return this._leftStick; + } + get rightStick() { + return this._rightStick; + } + get buttonLeftStick() { + return this._buttonLeftStick; + } + get buttonRightStick() { + return this._buttonRightStick; + } + get handLeftPosition() { + return this._handLeftPosition; + } + get handLeftOrientation() { + return this._handLeftOrientation; + } + get handRightPosition() { + return this._handRightPosition; + } + get handRightOrientation() { + return this._handRightOrientation; + } + get aimLeftPosition() { + return this._aimLeftPosition; + } + get aimLeftOrientation() { + return this._aimLeftOrientation; + } + get aimRightPosition() { + return this._aimRightPosition; + } + get aimRightOrientation() { + return this._aimRightOrientation; + } + constructor() { + this._eventTarget = new vo; + this._nativeButtonState = { + [XT.BUTTON_SOUTH]: 0, + [XT.BUTTON_EAST]: 0, + [XT.BUTTON_WEST]: 0, + [XT.BUTTON_NORTH]: 0, + [XT.BUTTON_TRIGGER_LEFT]: 0, + [XT.BUTTON_TRIGGER_RIGHT]: 0, + [XT.TRIGGER_LEFT]: 0, + [XT.TRIGGER_RIGHT]: 0, + [XT.GRIP_LEFT]: 0, + [XT.GRIP_RIGHT]: 0, + [XT.LEFT_STICK_UP]: 0, + [XT.LEFT_STICK_DOWN]: 0, + [XT.LEFT_STICK_LEFT]: 0, + [XT.LEFT_STICK_RIGHT]: 0, + [XT.RIGHT_STICK_UP]: 0, + [XT.RIGHT_STICK_DOWN]: 0, + [XT.RIGHT_STICK_LEFT]: 0, + [XT.RIGHT_STICK_RIGHT]: 0, + [XT.BUTTON_LEFT_STICK]: 0, + [XT.BUTTON_RIGHT_STICK]: 0 + }; + this._nativePoseState = { + [WT.HAND_LEFT]: { + position: Pi.ZERO, + orientation: Ui.IDENTITY + }, + [WT.HAND_RIGHT]: { + position: Pi.ZERO, + orientation: Ui.IDENTITY + }, + [WT.AIM_LEFT]: { + position: Pi.ZERO, + orientation: Ui.IDENTITY + }, + [WT.AIM_RIGHT]: { + position: Pi.ZERO, + orientation: Ui.IDENTITY + } + }; + this._initInputSource(); + this._registerEvent(); + } + _registerEvent() { + jsb.onHandleInput = t => { + for (let e = 0; e < t.length; ++e) { + const i = t[e]; + this._updateNativeButtonState(i); + this._eventTarget.emit(MS.HANDLE_INPUT, new FS(MS.HANDLE_INPUT, this)); + } + }; + jsb.onHandlePoseInput = t => { + for (let e = 0; e < t.length; ++e) { + const i = t[e]; + this._updateNativePoseState(i); + } + this._eventTarget.emit(MS.HANDLE_POSE_INPUT, new FS(MS.HANDLE_POSE_INPUT, this)); + }; + } + _on(t, e, i) { + this._eventTarget.on(t, e, i); + } + _axisToButtons(t) { + const e = Math.abs(t); + return t > 0 ? { + negative: 0, + positive: e + } : t < 0 ? { + negative: e, + positive: 0 + } : { + negative: 0, + positive: 0 + }; + } + _updateNativeButtonState(t) { + const {buttonInfoList: e, axisInfoList: i} = t; + for (let t = 0; t < e.length; ++t) { + const i = e[t]; + const s = YT[i.code]; + this._nativeButtonState[s] = i.isPressed ? 1 : 0; + } + for (let t = 0; t < i.length; ++t) { + const e = i[t]; + const {code: s, value: n} = e; + let r; + let o; + let a; + switch (s) { + case 3: + r = XT.LEFT_STICK_LEFT; + o = XT.LEFT_STICK_RIGHT; + a = this._axisToButtons(n); + break; + + case 4: + r = XT.LEFT_STICK_DOWN; + o = XT.LEFT_STICK_UP; + a = this._axisToButtons(n); + break; + + case 5: + r = XT.RIGHT_STICK_LEFT; + o = XT.RIGHT_STICK_RIGHT; + a = this._axisToButtons(n); + break; + + case 6: + r = XT.RIGHT_STICK_DOWN; + o = XT.RIGHT_STICK_UP; + a = this._axisToButtons(n); + break; + + default: + 7 === s ? this._nativeButtonState[XT.TRIGGER_LEFT] = n : 8 === s ? this._nativeButtonState[XT.TRIGGER_RIGHT] = n : 9 === s ? this._nativeButtonState[XT.GRIP_LEFT] = n : 10 === s && (this._nativeButtonState[XT.GRIP_RIGHT] = n); + } + if (r && o && a) { + this._nativeButtonState[r] = a.negative; + this._nativeButtonState[o] = a.positive; + } + } + } + _updateNativePoseState(t) { + switch (t.code) { + case 1: + this._nativePoseState[WT.HAND_LEFT] = { + position: new Pi(t.x, t.y, t.z), + orientation: new Ui(t.quaternionX, t.quaternionY, t.quaternionZ, t.quaternionW) + }; + break; + + case 2: + this._nativePoseState[WT.AIM_LEFT] = { + position: new Pi(t.x, t.y, t.z), + orientation: new Ui(t.quaternionX, t.quaternionY, t.quaternionZ, t.quaternionW) + }; + break; + + case 4: + this._nativePoseState[WT.HAND_RIGHT] = { + position: new Pi(t.x, t.y, t.z), + orientation: new Ui(t.quaternionX, t.quaternionY, t.quaternionZ, t.quaternionW) + }; + break; + + case 5: + this._nativePoseState[WT.AIM_RIGHT] = { + position: new Pi(t.x, t.y, t.z), + orientation: new Ui(t.quaternionX, t.quaternionY, t.quaternionZ, t.quaternionW) + }; + } + } + _initInputSource() { + this._buttonNorth = new FT; + this._buttonNorth.getValue = () => this._nativeButtonState[XT.BUTTON_NORTH]; + this._buttonEast = new FT; + this._buttonEast.getValue = () => this._nativeButtonState[XT.BUTTON_EAST]; + this._buttonWest = new FT; + this._buttonWest.getValue = () => this._nativeButtonState[XT.BUTTON_WEST]; + this._buttonSouth = new FT; + this._buttonSouth.getValue = () => this._nativeButtonState[XT.BUTTON_SOUTH]; + this._buttonTriggerLeft = new FT; + this._buttonTriggerLeft.getValue = () => this._nativeButtonState[XT.BUTTON_TRIGGER_LEFT]; + this._buttonTriggerRight = new FT; + this._buttonTriggerRight.getValue = () => this._nativeButtonState[XT.BUTTON_TRIGGER_RIGHT]; + this._triggerLeft = new FT; + this._triggerLeft.getValue = () => this._nativeButtonState[XT.TRIGGER_LEFT]; + this._triggerRight = new FT; + this._triggerRight.getValue = () => this._nativeButtonState[XT.TRIGGER_RIGHT]; + this._gripLeft = new FT; + this._gripLeft.getValue = () => this._nativeButtonState[XT.GRIP_LEFT]; + this._gripRight = new FT; + this._gripRight.getValue = () => this._nativeButtonState[XT.GRIP_RIGHT]; + this._buttonLeftStick = new FT; + this._buttonLeftStick.getValue = () => this._nativeButtonState[XT.BUTTON_LEFT_STICK]; + const t = new FT; + t.getValue = () => this._nativeButtonState[XT.LEFT_STICK_UP]; + const e = new FT; + e.getValue = () => this._nativeButtonState[XT.LEFT_STICK_DOWN]; + const i = new FT; + i.getValue = () => this._nativeButtonState[XT.LEFT_STICK_LEFT]; + const s = new FT; + s.getValue = () => this._nativeButtonState[XT.LEFT_STICK_RIGHT]; + this._leftStick = new kT({ + up: t, + down: e, + left: i, + right: s + }); + this._buttonRightStick = new FT; + this._buttonRightStick.getValue = () => this._nativeButtonState[XT.BUTTON_RIGHT_STICK]; + const n = new FT; + n.getValue = () => this._nativeButtonState[XT.RIGHT_STICK_UP]; + const r = new FT; + r.getValue = () => this._nativeButtonState[XT.RIGHT_STICK_DOWN]; + const o = new FT; + o.getValue = () => this._nativeButtonState[XT.RIGHT_STICK_LEFT]; + const a = new FT; + a.getValue = () => this._nativeButtonState[XT.RIGHT_STICK_RIGHT]; + this._rightStick = new kT({ + up: n, + down: r, + left: o, + right: a + }); + this._handLeftPosition = new GT; + this._handLeftPosition.getValue = () => this._nativePoseState[WT.HAND_LEFT].position; + this._handLeftOrientation = new UT; + this._handLeftOrientation.getValue = () => this._nativePoseState[WT.HAND_LEFT].orientation; + this._handRightPosition = new GT; + this._handRightPosition.getValue = () => this._nativePoseState[WT.HAND_RIGHT].position; + this._handRightOrientation = new UT; + this._handRightOrientation.getValue = () => this._nativePoseState[WT.HAND_RIGHT].orientation; + this._aimLeftPosition = new GT; + this._aimLeftPosition.getValue = () => this._nativePoseState[WT.AIM_LEFT].position; + this._aimLeftOrientation = new UT; + this._aimLeftOrientation.getValue = () => this._nativePoseState[WT.AIM_LEFT].orientation; + this._aimRightPosition = new GT; + this._aimRightPosition.getValue = () => this._nativePoseState[WT.AIM_RIGHT].position; + this._aimRightOrientation = new UT; + this._aimRightOrientation.getValue = () => this._nativePoseState[WT.AIM_RIGHT].orientation; + } + } + var KT; + !function(t) { + t[t.VIEW_LEFT = 0] = "VIEW_LEFT"; + t[t.VIEW_RIGHT = 1] = "VIEW_RIGHT"; + t[t.HEAD_MIDDLE = 2] = "HEAD_MIDDLE"; + }(KT || (KT = {})); + class JT { + get viewLeftPosition() { + return this._viewLeftPosition; + } + get viewLeftOrientation() { + return this._viewLeftOrientation; + } + get viewRightPosition() { + return this._viewRightPosition; + } + get viewRightOrientation() { + return this._viewRightOrientation; + } + get headMiddlePosition() { + return this._headMiddlePosition; + } + get headMiddleOrientation() { + return this._headMiddleOrientation; + } + constructor() { + this._eventTarget = new vo; + this._nativePoseState = { + [KT.VIEW_LEFT]: { + position: Pi.ZERO, + orientation: Ui.IDENTITY + }, + [KT.VIEW_RIGHT]: { + position: Pi.ZERO, + orientation: Ui.IDENTITY + }, + [KT.HEAD_MIDDLE]: { + position: Pi.ZERO, + orientation: Ui.IDENTITY + } + }; + this._initInputSource(); + this._registerEvent(); + } + _registerEvent() { + jsb.onHMDPoseInput = t => { + for (let e = 0; e < t.length; ++e) { + const i = t[e]; + this._updateNativePoseState(i); + } + this._eventTarget.emit(MS.HMD_POSE_INPUT, new VS(MS.HMD_POSE_INPUT, this)); + }; + } + _on(t, e, i) { + this._eventTarget.on(t, e, i); + } + _updateNativePoseState(t) { + switch (t.code) { + case 0: + this._nativePoseState[KT.VIEW_LEFT] = { + position: new Pi(t.x, t.y, t.z), + orientation: new Ui(t.quaternionX, t.quaternionY, t.quaternionZ, t.quaternionW) + }; + break; + + case 3: + this._nativePoseState[KT.VIEW_RIGHT] = { + position: new Pi(t.x, t.y, t.z), + orientation: new Ui(t.quaternionX, t.quaternionY, t.quaternionZ, t.quaternionW) + }; + break; + + case 6: + this._nativePoseState[KT.HEAD_MIDDLE] = { + position: new Pi(t.x, t.y, t.z), + orientation: new Ui(t.quaternionX, t.quaternionY, t.quaternionZ, t.quaternionW) + }; + } + } + _initInputSource() { + this._viewLeftPosition = new GT; + this._viewLeftPosition.getValue = () => this._nativePoseState[KT.VIEW_LEFT].position; + this._viewLeftOrientation = new UT; + this._viewLeftOrientation.getValue = () => this._nativePoseState[KT.VIEW_LEFT].orientation; + this._viewRightPosition = new GT; + this._viewRightPosition.getValue = () => this._nativePoseState[KT.VIEW_RIGHT].position; + this._viewRightOrientation = new UT; + this._viewRightOrientation.getValue = () => this._nativePoseState[KT.VIEW_RIGHT].orientation; + this._headMiddlePosition = new GT; + this._headMiddlePosition.getValue = () => this._nativePoseState[KT.HEAD_MIDDLE].position; + this._headMiddleOrientation = new UT; + this._headMiddleOrientation.getValue = () => this._nativePoseState[KT.HEAD_MIDDLE].orientation; + } + } + const ZT = { + 12: US.NUM_LOCK, + 10048: US.NUM_0, + 10049: US.NUM_1, + 10050: US.NUM_2, + 10051: US.NUM_3, + 10052: US.NUM_4, + 10053: US.NUM_5, + 10054: US.NUM_6, + 10055: US.NUM_7, + 10056: US.NUM_8, + 10057: US.NUM_9, + 20013: US.NUM_ENTER, + 20016: US.SHIFT_RIGHT, + 20017: US.CTRL_RIGHT, + 20018: US.ALT_RIGHT + }; + function QT(t) { + return ZT[t] || t; + } + class $T { + constructor() { + this._eventTarget = new vo; + this._keyStateMap = {}; + this._registerEvent(); + } + _registerEvent() { + jsb.onKeyDown = t => { + const e = QT(t.keyCode); + if (this._keyStateMap[e]) { + const e = this._getInputEvent(t, MS.KEY_PRESSING); + this._eventTarget.emit(MS.KEY_PRESSING, e); + } else { + const e = this._getInputEvent(t, MS.KEY_DOWN); + this._eventTarget.emit(MS.KEY_DOWN, e); + } + this._keyStateMap[e] = !0; + }; + jsb.onKeyUp = t => { + const e = QT(t.keyCode); + const i = this._getInputEvent(t, MS.KEY_UP); + this._keyStateMap[e] = !1; + this._eventTarget.emit(MS.KEY_UP, i); + }; + } + _getInputEvent(t, e) { + const i = QT(t.keyCode); + return new DS(i, e); + } + on(t, e, i) { + this._eventTarget.on(t, e, i); + } + } + class tv { + constructor() { + this._eventTarget = new vo; + this._preMousePos = new Qi; + this._isPressed = !1; + this._registerEvent(); + } + _getLocation(t) { + const e = Lo.windowSize; + const i = Lo.devicePixelRatio; + const s = t.x * i; + const n = e.height - t.y * i; + return new Qi(s, n); + } + _registerEvent() { + jsb.onMouseDown = this._createCallback(MS.MOUSE_DOWN); + jsb.onMouseMove = this._createCallback(MS.MOUSE_MOVE); + jsb.onMouseUp = this._createCallback(MS.MOUSE_UP); + jsb.onMouseWheel = this._handleMouseWheel.bind(this); + } + _createCallback(t) { + return e => { + const i = this._getLocation(e); + let s = e.button; + switch (t) { + case MS.MOUSE_DOWN: + this._isPressed = !0; + break; + + case MS.MOUSE_UP: + this._isPressed = !1; + break; + + case MS.MOUSE_MOVE: + this._isPressed || (s = PS.BUTTON_MISSING); + } + const n = new PS(t, !1, this._preMousePos); + n.setLocation(i.x, i.y); + n.setButton(s); + n.movementX = i.x - this._preMousePos.x; + n.movementY = this._preMousePos.y - i.y; + this._preMousePos.set(i.x, i.y); + this._eventTarget.emit(t, n); + }; + } + _handleMouseWheel(t) { + const e = MS.MOUSE_WHEEL; + const i = this._getLocation(t); + const s = t.button; + const n = new PS(e, !1, this._preMousePos); + n.setLocation(i.x, i.y); + n.setButton(s); + n.movementX = i.x - this._preMousePos.x; + n.movementY = this._preMousePos.y - i.y; + n.setScrollData(120 * t.wheelDeltaX, 120 * t.wheelDeltaY); + this._preMousePos.set(i.x, i.y); + this._eventTarget.emit(e, n); + } + on(t, e, i) { + this._eventTarget.on(t, e, i); + } + } + const ev = new Qi; + const iv = new class { + constructor() { + this._touchMap = void 0; + this._maxTouches = 8; + this._touchMap = new Map; + } + _cloneTouch(t) { + const e = t.getID(); + t.getStartLocation(ev); + const i = new zS(ev.x, ev.y, e); + t.getLocation(ev); + i.setPoint(ev.x, ev.y); + t.getPreviousLocation(ev); + i.setPrevPoint(ev); + return i; + } + _createTouch(t, e, i) { + if (this._touchMap.has(t)) { + console.log("Cannot create the same touch object."); + return; + } + if (this._checkTouchMapSizeMoreThanMax(t)) { + console.log("The touches is more than MAX_TOUCHES."); + return; + } + const s = new zS(e, i, t); + this._touchMap.set(t, s); + this._updateTouch(s, e, i); + return this._cloneTouch(s); + } + releaseTouch(t) { + this._touchMap.has(t) && this._touchMap.delete(t); + } + getTouch(t, e, i) { + let s = this._touchMap.get(t); + s ? this._updateTouch(s, e, i) : s = this._createTouch(t, e, i); + return s ? this._cloneTouch(s) : void 0; + } + getAllTouches() { + const t = []; + this._touchMap.forEach((e => { + if (e) { + const i = this._cloneTouch(e); + t.push(i); + } + })); + return t; + } + _updateTouch(t, e, i) { + t.getLocation(ev); + t.setPrevPoint(ev); + t.setPoint(e, i); + } + _checkTouchMapSizeMoreThanMax(t) { + if (this._touchMap.has(t)) return !1; + const e = pe.ENABLE_MULTI_TOUCH ? this._maxTouches : 1; + if (this._touchMap.size < e) return !1; + const i = performance.now(); + this._touchMap.forEach((t => { + if (i - t.lastModified > pe.TOUCH_TIMEOUT) { + console.log(`The touches is more than MAX_TOUCHES, release touch id ${t.getID()}.`); + this.releaseTouch(t.getID()); + } + })); + return e >= this._touchMap.size; + } + }; + class sv { + constructor() { + this._eventTarget = new vo; + this._registerEvent(); + } + _registerEvent() { + jsb.onTouchStart = this._createCallback(MS.TOUCH_START); + jsb.onTouchMove = this._createCallback(MS.TOUCH_MOVE); + jsb.onTouchEnd = this._createCallback(MS.TOUCH_END); + jsb.onTouchCancel = this._createCallback(MS.TOUCH_CANCEL); + } + _createCallback(t) { + return e => { + const i = []; + const s = e.length; + const n = Lo.windowSize; + for (let r = 0; r < s; ++r) { + const s = e[r]; + const o = s.identifier; + if (null === o) continue; + const a = this._getLocation(s, n); + const l = iv.getTouch(o, a.x, a.y); + if (l) { + t !== MS.TOUCH_END && t !== MS.TOUCH_CANCEL || iv.releaseTouch(o); + i.push(l); + } + } + if (i.length > 0) { + const e = new NS(i, !1, t, pe.ENABLE_MULTI_TOUCH ? iv.getAllTouches() : i); + this._eventTarget.emit(t, e); + } + }; + } + _getLocation(t, e) { + const i = Lo.devicePixelRatio; + const s = t.clientX * i; + const n = e.height - t.clientY * i; + return new Qi(s, n); + } + on(t, e, i) { + this._eventTarget.on(t, e, i); + } + } + let nv; + !function(t) { + t[t.GLOBAL = 0] = "GLOBAL"; + t[t.UI = 1] = "UI"; + }(nv || (nv = {})); + class rv { + constructor(t) { + this.priority = nv.GLOBAL; + this._inputEventTarget = void 0; + this._inputEventTarget = t; + } + dispatchEvent(t) { + this._inputEventTarget.emit(t.type, t); + return !0; + } + } + const ov = { + [MS.MOUSE_DOWN]: MS.TOUCH_START, + [MS.MOUSE_MOVE]: MS.TOUCH_MOVE, + [MS.MOUSE_UP]: MS.TOUCH_END + }; + class av { + constructor() { + this._dispatchImmediately = !1; + this._eventTarget = new vo; + this._touchInput = new sv; + this._mouseInput = new tv; + this._keyboardInput = new $T; + this._accelerometerInput = new IT; + this._handleInput = new qT; + this._hmdInput = new JT; + this._eventTouchList = []; + this._eventMouseList = []; + this._eventKeyboardList = []; + this._eventAccelerationList = []; + this._eventGamepadList = []; + this._eventHandleList = []; + this._eventHMDList = []; + this._needSimulateTouchMoveEvent = !1; + this._inputEventDispatcher = void 0; + this._eventDispatcherList = []; + this._registerEvent(); + this._inputEventDispatcher = new rv(this._eventTarget); + this._registerEventDispatcher(this._inputEventDispatcher); + jT._init(); + } + _dispatchMouseDownEvent(t) { + var e, i; + null === (e = (i = this._mouseInput).dispatchMouseDownEvent) || void 0 === e || e.call(i, t); + } + _dispatchMouseMoveEvent(t) { + var e, i; + null === (e = (i = this._mouseInput).dispatchMouseMoveEvent) || void 0 === e || e.call(i, t); + } + _dispatchMouseUpEvent(t) { + var e, i; + null === (e = (i = this._mouseInput).dispatchMouseUpEvent) || void 0 === e || e.call(i, t); + } + _dispatchMouseScrollEvent(t) { + var e, i; + null === (e = (i = this._mouseInput).dispatchScrollEvent) || void 0 === e || e.call(i, t); + } + _dispatchKeyboardDownEvent(t) { + var e, i; + null === (e = (i = this._keyboardInput).dispatchKeyboardDownEvent) || void 0 === e || e.call(i, t); + } + _dispatchKeyboardUpEvent(t) { + var e, i; + null === (e = (i = this._keyboardInput).dispatchKeyboardUpEvent) || void 0 === e || e.call(i, t); + } + on(t, e, i) { + this._eventTarget.on(t, e, i); + return e; + } + once(t, e, i) { + this._eventTarget.once(t, e, i); + return e; + } + off(t, e, i) { + this._eventTarget.off(t, e, i); + } + setAccelerometerEnabled(t) { + t ? this._accelerometerInput.start() : this._accelerometerInput.stop(); + } + setAccelerometerInterval(t) { + this._accelerometerInput.setInterval(t); + } + _simulateEventTouch(t) { + const e = ov[t.type]; + const i = iv.getTouch(0, t.getLocationX(), t.getLocationY()); + if (!i) return; + const s = [ i ]; + const n = new NS(s, !1, e, e === MS.TOUCH_END ? [] : s); + e === MS.TOUCH_END && iv.releaseTouch(0); + this._dispatchOrPushEventTouch(n, this._eventTouchList); + } + _registerEventDispatcher(t) { + this._eventDispatcherList.push(t); + this._eventDispatcherList.sort(((t, e) => e.priority - t.priority)); + } + _emitEvent(t) { + const e = this._eventDispatcherList.length; + for (let i = 0; i < e; ++i) { + if (!this._eventDispatcherList[i].dispatchEvent(t)) break; + } + } + _registerEvent() { + if (Vo.hasFeature(Vo.Feature.INPUT_TOUCH)) { + const t = this._eventTouchList; + this._touchInput.on(MS.TOUCH_START, (e => { + this._dispatchOrPushEventTouch(e, t); + })); + this._touchInput.on(MS.TOUCH_MOVE, (e => { + this._dispatchOrPushEventTouch(e, t); + })); + this._touchInput.on(MS.TOUCH_END, (e => { + this._dispatchOrPushEventTouch(e, t); + })); + this._touchInput.on(MS.TOUCH_CANCEL, (e => { + this._dispatchOrPushEventTouch(e, t); + })); + } + if (Vo.hasFeature(Vo.Feature.EVENT_MOUSE)) { + const t = this._eventMouseList; + this._mouseInput.on(MS.MOUSE_DOWN, (e => { + this._needSimulateTouchMoveEvent = !0; + this._simulateEventTouch(e); + this._dispatchOrPushEvent(e, t); + })); + this._mouseInput.on(MS.MOUSE_MOVE, (e => { + this._needSimulateTouchMoveEvent && this._simulateEventTouch(e); + this._dispatchOrPushEvent(e, t); + })); + this._mouseInput.on(MS.MOUSE_UP, (e => { + this._needSimulateTouchMoveEvent = !1; + this._simulateEventTouch(e); + this._dispatchOrPushEvent(e, t); + })); + this._mouseInput.on(MS.MOUSE_WHEEL, (e => { + this._dispatchOrPushEvent(e, t); + })); + } + if (Vo.hasFeature(Vo.Feature.EVENT_KEYBOARD)) { + const t = this._eventKeyboardList; + this._keyboardInput.on(MS.KEY_DOWN, (e => { + this._dispatchOrPushEvent(e, t); + })); + this._keyboardInput.on(MS.KEY_PRESSING, (e => { + this._dispatchOrPushEvent(e, t); + })); + this._keyboardInput.on(MS.KEY_UP, (e => { + this._dispatchOrPushEvent(e, t); + })); + } + if (Vo.hasFeature(Vo.Feature.EVENT_ACCELEROMETER)) { + const t = this._eventAccelerationList; + this._accelerometerInput.on(MS.DEVICEMOTION, (e => { + this._dispatchOrPushEvent(e, t); + })); + } + if (Vo.hasFeature(Vo.Feature.EVENT_GAMEPAD)) { + const t = this._eventGamepadList; + jT._on(MS.GAMEPAD_CHANGE, (e => { + this._dispatchOrPushEvent(e, t); + })); + jT._on(MS.GAMEPAD_INPUT, (e => { + this._dispatchOrPushEvent(e, t); + })); + } + if (Vo.hasFeature(Vo.Feature.EVENT_HANDLE)) { + const t = this._eventHandleList; + this._handleInput._on(MS.HANDLE_INPUT, (e => { + this._dispatchOrPushEvent(e, t); + })); + this._handleInput._on(MS.HANDLE_POSE_INPUT, (e => { + this._dispatchOrPushEvent(e, t); + })); + } + if (Vo.hasFeature(Vo.Feature.EVENT_HMD)) { + const t = this._eventHMDList; + this._hmdInput._on(MS.HMD_POSE_INPUT, (e => { + this._dispatchOrPushEvent(e, t); + })); + } + } + _clearEvents() { + this._eventMouseList.length = 0; + this._eventTouchList.length = 0; + this._eventKeyboardList.length = 0; + this._eventAccelerationList.length = 0; + this._eventGamepadList.length = 0; + this._eventHandleList.length = 0; + this._eventHMDList.length = 0; + } + _dispatchOrPushEvent(t, e) { + this._dispatchImmediately ? this._emitEvent(t) : e.push(t); + } + _dispatchOrPushEventTouch(t, e) { + if (this._dispatchImmediately) { + const e = t.getTouches(); + const i = e.length; + for (let s = 0; s < i; ++s) { + t.touch = e[s]; + t.propagationStopped = t.propagationImmediateStopped = !1; + this._emitEvent(t); + } + } else e.push(t); + } + _frameDispatchEvents() { + const t = this._eventMouseList; + for (let e = 0, i = t.length; e < i; ++e) { + const i = t[e]; + this._emitEvent(i); + } + const e = this._eventTouchList; + for (let t = 0, i = e.length; t < i; ++t) { + const i = e[t]; + const s = i.getTouches(); + const n = s.length; + for (let t = 0; t < n; ++t) { + i.touch = s[t]; + i.propagationStopped = i.propagationImmediateStopped = !1; + this._emitEvent(i); + } + } + const i = this._eventKeyboardList; + for (let t = 0, e = i.length; t < e; ++t) { + const e = i[t]; + this._emitEvent(e); + } + const s = this._eventAccelerationList; + for (let t = 0, e = s.length; t < e; ++t) { + const e = s[t]; + this._emitEvent(e); + } + const n = this._eventGamepadList; + for (let t = 0, e = n.length; t < e; ++t) { + const e = n[t]; + this._emitEvent(e); + } + const r = this._eventHandleList; + for (let t = 0, e = r.length; t < e; ++t) { + const e = r[t]; + this._emitEvent(e); + } + const o = this._eventHMDList; + for (let t = 0, e = o.length; t < e; ++t) { + const e = o[t]; + this._emitEvent(e); + } + this._clearEvents(); + } + } + t("Input", av); + av.EventType = MS; + const lv = t("input", new av); + class hv extends vo { + constructor() { + super(); + lv.on(MS.MOUSE_DOWN, (t => { + this.emit(IS.MOUSE_DOWN, t); + })); + lv.on(MS.MOUSE_MOVE, (t => { + this.emit(IS.MOUSE_MOVE, t); + })); + lv.on(MS.MOUSE_UP, (t => { + this.emit(IS.MOUSE_UP, t); + })); + lv.on(MS.MOUSE_WHEEL, (t => { + this.emit(IS.MOUSE_WHEEL, t); + })); + lv.on(MS.TOUCH_START, (t => { + this.emit(IS.TOUCH_START, t.touch, t); + })); + lv.on(MS.TOUCH_MOVE, (t => { + this.emit(IS.TOUCH_MOVE, t.touch, t); + })); + lv.on(MS.TOUCH_END, (t => { + this.emit(IS.TOUCH_END, t.touch, t); + })); + lv.on(MS.TOUCH_CANCEL, (t => { + this.emit(IS.TOUCH_CANCEL, t.touch, t); + })); + lv.on(MS.KEY_DOWN, (t => { + this.emit(IS.KEY_DOWN, t); + })); + lv.on(MS.KEY_PRESSING, (t => { + this.emit(IS.KEY_DOWN, t); + })); + lv.on(MS.KEY_UP, (t => { + this.emit(IS.KEY_UP, t); + })); + lv.on(MS.DEVICEMOTION, (t => { + this.emit(IS.DEVICEMOTION, t); + })); + } + setAccelerometerEnabled(t) { + lv.setAccelerometerEnabled(t); + } + setAccelerometerInterval(t) { + lv.setAccelerometerInterval(t); + } + on(t, e, i, s) { + super.on(t, e, i, s); + return e; + } + off(t, e, i) { + super.off(t, e, i); + } + } + t("SystemEvent", hv); + hv.EventType = IS; + m.SystemEvent = hv; + const cv = t("systemEvent", new hv); + m.systemEvent = cv; + W(IS, "Node.EventType", [ { + name: "POSITION_PART", + newName: "TRANSFORM_CHANGED" + }, { + name: "ROTATION_PART", + newName: "TRANSFORM_CHANGED" + }, { + name: "SCALE_PART", + newName: "TRANSFORM_CHANGED" + } ]); + W(RS, "Event", [ { + name: "ACCELERATION", + newName: "DEVICEMOTION", + target: hv.EventType, + targetName: "SystemEvent.EventType" + } ]); + q(RS, "Event", [ { + name: "TOUCH", + suggest: "please use SystemEvent.EventType.TOUCH_START, SystemEvent.EventType.TOUCH_MOVE, SystemEvent.EventType.TOUCH_END and SystemEvent.EventType.TOUCH_CANCEL instead" + }, { + name: "MOUSE", + suggest: "please use SystemEvent.EventType.MOUSE_DOWN, SystemEvent.EventType.MOUSE_MOVE, SystemEvent.EventType.MOUSE_UP, SystemEvent.EventType.MOUSE_WHEEL, Node.EventType.MOUSE_ENTER and Node.EventType.MOUSE_LEAVE instead" + }, { + name: "KEYBOARD", + suggest: "please use SystemEvent.EventType.KEY_DOWN and SystemEvent.EventType.KEY_UP instead" + } ]); + W(PS, "EventMouse", [ "DOWN", "UP", "MOVE" ].map((t => ({ + name: t, + newName: `MOUSE_${t}`, + target: hv.EventType, + targetName: "SystemEvent.EventType" + })))); + W(PS, "EventMouse", [ { + name: "SCROLL", + newName: "MOUSE_WHEEL", + target: hv.EventType, + targetName: "SystemEvent.EventType" + } ]); + q(PS.prototype, "EventMouse.prototype", [ { + name: "eventType", + suggest: "please use EventMouse.prototype.type instead" + } ]); + W(NS, "EventTouch", [ { + name: "BEGAN", + newName: "TOUCH_START", + target: hv.EventType, + targetName: "SystemEvent.EventType" + } ]); + W(NS, "EventTouch", [ { + name: "MOVED", + newName: "TOUCH_MOVE", + target: hv.EventType, + targetName: "SystemEvent.EventType" + } ]); + W(NS, "EventTouch", [ { + name: "ENDED", + newName: "TOUCH_END", + target: hv.EventType, + targetName: "SystemEvent.EventType" + } ]); + W(NS, "EventTouch", [ { + name: "CANCELLED", + newName: "TOUCH_CANCEL", + target: hv.EventType, + targetName: "SystemEvent.EventType" + } ]); + q(NS.prototype, "EventTouch.prototype", [ { + name: "getEventCode", + suggest: "please use EventTouch.prototype.type instead" + } ]); + W(NS.prototype, "EventTouch.prototype", [ { + name: "getUILocationInView", + newName: "getLocationInView", + target: NS, + targetName: "EventTouch" + } ]); + q(pe.KEY, "macro.KEY", [ "back", "menu", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "*", "+", "-", "/", ";", "=", ",", ".", "[", "]", "dpadLeft", "dpadRight", "dpadUp", "dpadDown", "dpadCenter" ].map((t => ({ + name: t + })))); + q(pe.KEY, "macro.KEY", [ { + name: "shift", + suggest: "please use KeyCode.SHIFT_LEFT instead" + } ]); + q(pe.KEY, "macro.KEY", [ { + name: "ctrl", + suggest: "please use KeyCode.CTRL_LEFT instead" + } ]); + q(pe.KEY, "macro.KEY", [ { + name: "alt", + suggest: "please use KeyCode.ALT_LEFT instead" + } ]); + q(pe, "macro", [ { + name: "KEY", + suggest: "please use KeyCode instead" + } ]); + var uv; + W(_y.prototype, "Node", [ { + name: "childrenCount", + newName: "children.length", + customGetter() { + return this.children.length; + } + } ]); + W(_y.prototype, "Node", [ { + name: "width", + targetName: "node.getComponent(UITransform)", + customGetter() { + return this._uiProps.uiTransformComp.width; + }, + customSetter(t) { + this._uiProps.uiTransformComp.width = t; + } + }, { + name: "height", + targetName: "node.getComponent(UITransform)", + customGetter() { + return this._uiProps.uiTransformComp.height; + }, + customSetter(t) { + this._uiProps.uiTransformComp.height = t; + } + }, { + name: "anchorX", + targetName: "node.getComponent(UITransform)", + customGetter() { + return this._uiProps.uiTransformComp.anchorX; + }, + customSetter(t) { + this._uiProps.uiTransformComp.anchorX = t; + } + }, { + name: "anchorY", + targetName: "node.getComponent(UITransform)", + customGetter() { + return this._uiProps.uiTransformComp.anchorY; + }, + customSetter(t) { + this._uiProps.uiTransformComp.anchorY = t; + } + }, { + name: "getAnchorPoint", + targetName: "node.getComponent(UITransform)", + customFunction(t) { + t || (t = new Qi); + t.set(this._uiProps.uiTransformComp.anchorPoint); + return t; + } + }, { + name: "setAnchorPoint", + targetName: "node.getComponent(UITransform)", + customFunction(t, e) { + this._uiProps.uiTransformComp.setAnchorPoint(t, e); + } + }, { + name: "getContentSize", + targetName: "node.getComponent(UITransform)", + customFunction(t) { + t || (t = new rs); + t.set(this._uiProps.uiTransformComp.contentSize); + return t; + } + }, { + name: "setContentSize", + targetName: "node.getComponent(UITransform)", + customFunction(t, e) { + "number" == typeof t ? this._uiProps.uiTransformComp.setContentSize(t, e) : this._uiProps.uiTransformComp.setContentSize(t); + } + } ]); + Y(nT.prototype, "SceneGlobals.prototype", [ { + name: "aspect" + }, { + name: "selfShadow" + }, { + name: "linear" + }, { + name: "packing" + }, { + name: "autoAdapt" + }, { + name: "fixedArea" + }, { + name: "pcf" + }, { + name: "bias" + }, { + name: "normalBias" + }, { + name: "near" + }, { + name: "far" + }, { + name: "shadowDistance" + }, { + name: "invisibleOcclusionRange" + }, { + name: "orthoSize" + }, { + name: "saturation" + } ]); + W(nT.prototype, "SceneGlobals.prototype", [ { + name: "distance", + newName: "planeHeight" + }, { + name: "normal", + newName: "planeDirection" + }, { + name: "size", + newName: "shadowMapSize" + } ]); + Y(_y.prototype, "Node.prototype", [ { + name: "addLayer" + }, { + name: "removeLayer" + } ]); + W(ry.prototype, "NodeUIProperties", [ { + name: "opacityDirty", + newName: "colorDirty" + } ]); + Y(mm, "Layers", [ { + name: "All" + }, { + name: "RaycastMask" + }, { + name: "check" + } ]); + W(mm, "Layers", [ { + name: "Default", + newName: "DEFAULT", + target: mm.Enum, + targetName: "Layers.Enum" + }, { + name: "Always", + newName: "ALWAYS", + target: mm.Enum, + targetName: "Layers.Enum" + }, { + name: "IgnoreRaycast", + newName: "IGNORE_RAYCAST", + target: mm.Enum, + targetName: "Layers.Enum" + }, { + name: "Gizmos", + newName: "GIZMOS", + target: mm.Enum, + targetName: "Layers.Enum" + }, { + name: "Editor", + newName: "EDITOR", + target: mm.Enum, + targetName: "Layers.Enum" + }, { + name: "UI", + newName: "UI_3D", + target: mm.Enum, + targetName: "Layers.Enum" + }, { + name: "UI2D", + newName: "UI_2D", + target: mm.Enum, + targetName: "Layers.Enum" + }, { + name: "SceneGizmo", + newName: "SCENE_GIZMO", + target: mm.Enum, + targetName: "Layers.Enum" + }, { + name: "makeInclusiveMask", + newName: "makeMaskInclude", + target: mm, + targetName: "Layers" + }, { + name: "makeExclusiveMask", + newName: "makeMaskExclude", + target: mm, + targetName: "Layers" + } ]); + Y(mm.Enum, "Layers.Enum", [ { + name: "ALWAYS" + } ]); + Y(mm.BitMask, "Layers.BitMask", [ { + name: "ALWAYS" + } ]); + const _v = co.Flags.HideInHierarchy; + const dv = co.Flags.DontSave; + let pv = t("PrivateNode", Ul("cc.PrivateNode")(uv = class extends _y { + constructor(t) { + super(t); + N(12003, this.name); + this.hideFlags |= dv | _v; + } + }) || uv); + W(IS, "SystemEventType", [ "MOUSE_ENTER", "MOUSE_LEAVE", "TRANSFORM_CHANGED", "SCENE_CHANGED_FOR_PERSISTS", "SIZE_CHANGED", "ANCHOR_CHANGED", "COLOR_CHANGED", "CHILD_ADDED", "CHILD_REMOVED", "PARENT_CHANGED", "NODE_DESTROYED", "LAYER_CHANGED", "SIBLING_ORDER_CHANGED" ].map((t => ({ + name: t, + target: _y.EventType, + targetName: "Node.EventType" + })))); + W(_y.EventType, "Node.EventType", [ { + name: "DEVICEMOTION", + target: hv.EventType, + targetName: "SystemEvent.EventType" + }, { + name: "KEY_DOWN", + target: hv.EventType, + targetName: "SystemEvent.EventType" + }, { + name: "KEY_UP", + target: hv.EventType, + targetName: "SystemEvent.EventType" + } ]); + m.PrivateNode = pv; + function mv(t, e) { + if (!e) { + const t = m.director.getScene(); + if (!t) return null; + e = t; + } + return e.getChildByPath(t); + } + m.find = mv; + const fv = te.fastRemoveAt; + const gv = co.Flags.IsStartCalled; + const yv = co.Flags.IsOnEnableCalled; + co.Flags.IsEditorOnEnableCalled; + function bv(t, e) { + const i = e.constructor._executionOrder; + const s = e._id; + let n = 0; + for (let e = t.length - 1, r = e >>> 1; n <= e; r = n + e >>> 1) { + const o = t[r]; + const a = o.constructor._executionOrder; + if (a > i) e = r - 1; else if (a < i) n = r + 1; else { + const t = o._id; + if (t > s) e = r - 1; else { + if (!(t < s)) return r; + n = r + 1; + } + } + } + return ~n; + } + function Sv(t, e) { + const i = t.array; + let s = t.i + 1; + for (;s < i.length; ) { + const n = i[s]; + if (n.node._activeInHierarchy) ++s; else { + t.removeAt(s); + e && (n._objFlags &= ~e); + } + } + } + class Av { + constructor(t) { + this._zero = void 0; + this._neg = void 0; + this._pos = void 0; + this._invoke = void 0; + const e = nt; + this._zero = new e([]); + this._neg = new e([]); + this._pos = new e([]); + this._invoke = t; + } + } + Av.stableRemoveInactive = Sv; + function Tv(t, e) { + return t.constructor._executionOrder - e.constructor._executionOrder; + } + class vv extends Av { + add(t) { + const e = t.constructor._executionOrder; + (0 === e ? this._zero : e < 0 ? this._neg : this._pos).array.push(t); + } + remove(t) { + const e = t.constructor._executionOrder; + (0 === e ? this._zero : e < 0 ? this._neg : this._pos).fastRemove(t); + } + cancelInactive(t) { + Sv(this._zero, t); + Sv(this._neg, t); + Sv(this._pos, t); + } + invoke() { + const t = this._neg; + if (t.array.length > 0) { + t.array.sort(Tv); + this._invoke(t); + t.array.length = 0; + } + this._invoke(this._zero); + this._zero.array.length = 0; + const e = this._pos; + if (e.array.length > 0) { + e.array.sort(Tv); + this._invoke(e); + e.array.length = 0; + } + } + } + class Ev extends Av { + add(t) { + const e = t.constructor._executionOrder; + if (0 === e) this._zero.array.push(t); else { + const i = e < 0 ? this._neg.array : this._pos.array; + const s = bv(i, t); + s < 0 && i.splice(~s, 0, t); + } + } + remove(t) { + const e = t.constructor._executionOrder; + if (0 === e) this._zero.fastRemove(t); else { + const i = e < 0 ? this._neg : this._pos; + const s = bv(i.array, t); + s >= 0 && i.removeAt(s); + } + } + invoke(t) { + this._neg.array.length > 0 && this._invoke(this._neg, t); + this._invoke(this._zero, t); + this._pos.array.length > 0 && this._invoke(this._pos, t); + } + } + function Cv(t, e, i) { + return (s, n) => { + try { + e(s, n); + } catch (e) { + m._throw(e); + const r = s.array; + i && (r[s.i]._objFlags |= i); + ++s.i; + for (;s.i < r.length; ++s.i) try { + t(r[s.i], n); + } catch (t) { + m._throw(t); + i && (r[s.i]._objFlags |= i); + } + } + }; + } + const xv = Cv((t => { + t.start(); + t._objFlags |= gv; + }), (t => { + const e = t.array; + for (t.i = 0; t.i < e.length; ++t.i) { + const i = e[t.i]; + i.start(); + i._objFlags |= gv; + } + }), gv); + const wv = Cv(((t, e) => { + t.update(e); + }), ((t, e) => { + const i = t.array; + for (t.i = 0; t.i < i.length; ++t.i) i[t.i].update(e); + })); + const Rv = Cv(((t, e) => { + t.lateUpdate(e); + }), ((t, e) => { + const i = t.array; + for (t.i = 0; t.i < i.length; ++t.i) i[t.i].lateUpdate(e); + })); + const Iv = t => { + const e = m.director._compScheduler; + const i = t.array; + for (t.i = 0; t.i < i.length; ++t.i) { + const s = i[t.i]; + if (s._enabled) { + s.onEnable(); + !s.node._activeInHierarchy || e._onEnabled(s); + } + } + }; + class Mv { + constructor() { + this._deferredComps = []; + this.unscheduleAll(); + } + unscheduleAll() { + this.startInvoker = new vv(xv); + this.updateInvoker = new Ev(wv); + this.lateUpdateInvoker = new Ev(Rv); + this._updating = !1; + } + _onEnabled(t) { + m.director.getScheduler().resumeTarget(t); + t._objFlags |= yv; + this._updating ? this._deferredComps.push(t) : this._scheduleImmediate(t); + } + _onDisabled(t) { + m.director.getScheduler().pauseTarget(t); + t._objFlags &= ~yv; + const e = this._deferredComps.indexOf(t); + if (e >= 0) fv(this._deferredComps, e); else { + !t.start || t._objFlags & gv || this.startInvoker.remove(t); + t.update && this.updateInvoker.remove(t); + t.lateUpdate && this.lateUpdateInvoker.remove(t); + } + } + enableComp(t, e) { + if (!(t._objFlags & yv)) { + if (t.onEnable) { + if (e) { + e.add(t); + return; + } + t.onEnable(); + if (!t.node._activeInHierarchy) return; + } + this._onEnabled(t); + } + } + disableComp(t) { + if (t._objFlags & yv) { + t.onDisable && t.onDisable(); + this._onDisabled(t); + } + } + startPhase() { + this._updating = !0; + this.startInvoker.invoke(); + this._startForNewComps(); + } + updatePhase(t) { + this.updateInvoker.invoke(t); + } + lateUpdatePhase(t) { + this.lateUpdateInvoker.invoke(t); + this._updating = !1; + this._startForNewComps(); + } + _startForNewComps() { + if (this._deferredComps.length > 0) { + this._deferredSchedule(); + this.startInvoker.invoke(); + } + } + _scheduleImmediate(t) { + "function" != typeof t.start || t._objFlags & gv || this.startInvoker.add(t); + "function" == typeof t.update && this.updateInvoker.add(t); + "function" == typeof t.lateUpdate && this.lateUpdateInvoker.add(t); + } + _deferredSchedule() { + const t = this._deferredComps; + for (let e = 0, i = t.length; e < i; e++) this._scheduleImmediate(t[e]); + t.length = 0; + } + } + const Bv = co.Flags.IsPreloadStarted; + const Dv = co.Flags.IsOnLoadStarted; + const Pv = co.Flags.IsOnLoadCalled; + const Ov = co.Flags.Deactivating; + class Nv extends Av { + add(t) { + this._zero.array.push(t); + } + remove(t) { + this._zero.fastRemove(t); + } + cancelInactive(t) { + Av.stableRemoveInactive(this._zero, t); + } + invoke() { + this._invoke(this._zero); + this._zero.array.length = 0; + } + } + const Lv = Cv((t => { + t.__preload(); + }), (t => { + const e = t.array; + for (t.i = 0; t.i < e.length; ++t.i) e[t.i].__preload(); + })); + const Fv = Cv((t => { + t.onLoad(); + t._objFlags |= Pv; + }), (t => { + const e = t.array; + for (t.i = 0; t.i < e.length; ++t.i) { + const i = e[t.i]; + i.onLoad(); + i._objFlags |= Pv; + } + }), Pv); + const Vv = new $t(4); + Vv.get = function() { + const t = this._get() || { + preload: new Nv(Lv), + onLoad: new vv(Fv), + onEnable: new vv(Iv) + }; + t.preload._zero.i = -1; + let e = t.onLoad; + e._zero.i = -1; + e._neg.i = -1; + e._pos.i = -1; + e = t.onEnable; + e._zero.i = -1; + e._neg.i = -1; + e._pos.i = -1; + return t; + }; + function kv(t, e, i) { + F(3817, t.name, i); + console.log("Corrupted component value:", e); + e ? t._removeComponent(e) : te.removeAt(t._components, i); + } + class Uv { + constructor() { + this.resetComp = void 0; + this.reset(); + } + reset() { + this._activatingStack = []; + } + activateNode(t, e) { + if (e) { + const e = Vv.get(); + this._activatingStack.push(e); + this._activateNodeRecursively(t, e.preload, e.onLoad, e.onEnable); + e.preload.invoke(); + e.onLoad.invoke(); + e.onEnable.invoke(); + this._activatingStack.pop(); + Vv.put(e); + } else { + this._deactivateNodeRecursively(t); + const e = this._activatingStack; + for (const t of e) { + t.preload.cancelInactive(Bv); + t.onLoad.cancelInactive(Dv); + t.onEnable.cancelInactive(); + } + } + t.emit(ny.ACTIVE_IN_HIERARCHY_CHANGED, t); + } + activateComp(t, e, i, s) { + if (po(t, !0)) { + if (!(t._objFlags & Bv)) { + t._objFlags |= Bv; + t.__preload && (e ? e.add(t) : t.__preload()); + } + if (!(t._objFlags & Dv)) { + t._objFlags |= Dv; + if (t.onLoad) if (i) i.add(t); else { + t.onLoad(); + t._objFlags |= Pv; + } else t._objFlags |= Pv; + } + if (t._enabled) { + ne(t.node, G(3823, t.uuid, t.name)); + if (!t.node._activeInHierarchy) return; + m.director._compScheduler.enableComp(t, s); + } + } + } + destroyComp(t) { + m.director._compScheduler.disableComp(t); + t.onDestroy && t._objFlags & Pv && t.onDestroy(); + } + _activateNodeRecursively(t, e, i, s) { + if (t._objFlags & Ov) { + F(3816, t.name); + return; + } + t._activeInHierarchy = !0; + let n = t._components.length; + for (let r = 0; r < n; ++r) { + const o = t._components[r]; + if (o instanceof m.Component) this.activateComp(o, e, i, s); else { + kv(t, o, r); + --r; + --n; + } + } + for (let n = 0, r = t._children.length; n < r; ++n) { + const r = t._children[n]; + r._active && this._activateNodeRecursively(r, e, i, s); + } + t._onPostActivated(!0); + } + _deactivateNodeRecursively(t) { + t._objFlags |= Ov; + t._activeInHierarchy = !1; + const e = t._components.length; + for (let i = 0; i < e; ++i) { + const e = t._components[i]; + if (e._enabled) { + m.director._compScheduler.disableComp(e); + if (t._activeInHierarchy) { + t._objFlags &= ~Ov; + return; + } + } + } + for (let e = 0, i = t._children.length; e < i; ++e) { + const i = t._children[e]; + if (i._activeInHierarchy) { + this._deactivateNodeRecursively(i); + if (t._activeInHierarchy) { + t._objFlags &= ~Ov; + return; + } + } + } + t._onPostActivated(!1); + t._objFlags &= ~Ov; + } + } + t("NodeActivator", Uv); + var Gv, zv, Hv, jv, Xv, Wv, Yv, qv, Kv, Jv, Zv, Qv, $v, tE, eE, iE, sE, nE, rE, oE, aE, lE, hE, cE, uE, _E, dE, pE, mE, fE, gE, yE, bE, SE, AE, TE, vE, EE, CE, xE, wE, RE, IE, ME, BE, DE, PE, OE, NE, LE, FE, VE, kE, UE, GE, zE, HE, jE, XE, WE, YE, qE, KE, JE, ZE; + let QE = Ul("cc.TargetInfo")(Gv = (zv = class { + constructor() { + Ml(this, "localID", Hv, this); + } + }, Hv = Bl(zv.prototype, "localID", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), zv)) || Gv; + let $E = (jv = Ul("cc.TargetOverrideInfo"), Xv = Th(co), Wv = Th(QE), Yv = Th(_y), + qv = Th(QE), jv(Kv = (Jv = class { + constructor() { + Ml(this, "source", Zv, this); + Ml(this, "sourceInfo", Qv, this); + Ml(this, "propertyPath", $v, this); + Ml(this, "target", tE, this); + Ml(this, "targetInfo", eE, this); + } + }, Zv = Bl(Jv.prototype, "source", [ Yl, Xv ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Qv = Bl(Jv.prototype, "sourceInfo", [ Yl, Wv ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), $v = Bl(Jv.prototype, "propertyPath", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), tE = Bl(Jv.prototype, "target", [ Yl, Yv ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), eE = Bl(Jv.prototype, "targetInfo", [ Yl, qv ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Jv)) || Kv); + let tC = Ul("cc.CompPrefabInfo")(iE = (sE = class { + constructor() { + Ml(this, "fileId", nE, this); + } + }, nE = Bl(sE.prototype, "fileId", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), sE)) || iE; + let eC = (rE = Ul("CCPropertyOverrideInfo"), oE = Th(QE), rE(aE = (lE = class { + constructor() { + Ml(this, "targetInfo", hE, this); + Ml(this, "propertyPath", cE, this); + Ml(this, "value", uE, this); + } + isTarget(t, e) {} + }, hE = Bl(lE.prototype, "targetInfo", [ Yl, oE ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), cE = Bl(lE.prototype, "propertyPath", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), uE = Bl(lE.prototype, "value", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), lE)) || aE); + let iC = (_E = Ul("cc.MountedChildrenInfo"), dE = Th(QE), pE = Th([ _y ]), _E(mE = (fE = class { + constructor() { + Ml(this, "targetInfo", gE, this); + Ml(this, "nodes", yE, this); + } + isTarget(t) {} + }, gE = Bl(fE.prototype, "targetInfo", [ Yl, dE ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), yE = Bl(fE.prototype, "nodes", [ Yl, pE ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), fE)) || mE); + let sC = (bE = Ul("cc.MountedComponentsInfo"), SE = Th(QE), AE = Th([ Qc ]), bE(TE = (vE = class { + constructor() { + Ml(this, "targetInfo", EE, this); + Ml(this, "components", CE, this); + } + isTarget(t) {} + }, EE = Bl(vE.prototype, "targetInfo", [ Yl, SE ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), CE = Bl(vE.prototype, "components", [ Yl, AE ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), vE)) || TE); + let nC = (xE = Ul("cc.PrefabInstance"), wE = Th(_y), RE = Th([ iC ]), IE = Th([ sC ]), + ME = Th([ eC ]), BE = Th([ QE ]), xE(DE = (PE = class { + constructor() { + Ml(this, "fileId", OE, this); + Ml(this, "prefabRootNode", NE, this); + Ml(this, "mountedChildren", LE, this); + Ml(this, "mountedComponents", FE, this); + Ml(this, "propertyOverrides", VE, this); + Ml(this, "removedComponents", kE, this); + this.targetMap = {}; + this.expanded = !1; + } + findPropertyOverride(t, e) {} + removePropertyOverride(t, e) {} + }, OE = Bl(PE.prototype, "fileId", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), NE = Bl(PE.prototype, "prefabRootNode", [ Yl, wE ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), LE = Bl(PE.prototype, "mountedChildren", [ Yl, RE ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), FE = Bl(PE.prototype, "mountedComponents", [ Yl, IE ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), VE = Bl(PE.prototype, "propertyOverrides", [ Yl, ME ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), kE = Bl(PE.prototype, "removedComponents", [ Yl, BE ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), PE)) || DE); + let rC = (UE = Ul("cc.PrefabInfo"), GE = Th(_y), zE = Th(nC), HE = Th([ $E ]), UE(jE = (XE = class { + constructor() { + Ml(this, "root", WE, this); + Ml(this, "asset", YE, this); + Ml(this, "fileId", qE, this); + Ml(this, "instance", KE, this); + Ml(this, "targetOverrides", JE, this); + Ml(this, "nestedPrefabInstanceRoots", ZE, this); + } + }, WE = Bl(XE.prototype, "root", [ Yl, GE ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), YE = Bl(XE.prototype, "asset", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), qE = Bl(XE.prototype, "fileId", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), KE = Bl(XE.prototype, "instance", [ Yl, zE ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), JE = Bl(XE.prototype, "targetOverrides", [ Yl, HE ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), ZE = Bl(XE.prototype, "nestedPrefabInstanceRoots", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), XE)) || jE); + m._PrefabInfo = rC; + var oC = Object.freeze({ + __proto__: null, + TargetInfo: QE, + TargetOverrideInfo: $E, + CompPrefabInfo: tC, + PropertyOverrideInfo: eC, + MountedChildrenInfo: iC, + MountedComponentsInfo: sC, + PrefabInstance: nC, + PrefabInfo: rC, + createNodeWithPrefab: JS, + generateTargetMap: ZS, + getTarget: QS, + applyMountedChildren: $S, + applyMountedComponents: tA, + applyRemovedComponents: eA, + applyPropertyOverrides: iA, + applyTargetOverrides: sA, + expandPrefabInstanceNode: nA, + expandNestedPrefabInstanceNode: rA, + applyNodeAndComponentId: function t(e, i) { + const {components: s, children: n} = e; + for (let t = 0; t < s.length; t++) { + var r; + const e = s[t]; + e._id = `${i}${null === (r = e.__prefab) || void 0 === r ? void 0 : r.fileId}`; + } + for (let e = 0; e < n.length; e++) { + var o; + const s = n[e]; + s._id = `${i}${null === (o = s._prefab) || void 0 === o ? void 0 : o.fileId}`; + t(s, i); + } + } + }); + var aC, lC, hC, cC, uC, _C, dC; + const pC = oe({ + AUTO: 0, + SINGLE_INSTANCE: 1, + MULTI_INSTANCE: 2 + }); + let mC = t("Prefab", Ul("cc.Prefab")(aC = (lC = (dC = _C = class extends gc { + constructor() { + super(); + Ml(this, "data", hC, this); + Ml(this, "optimizationPolicy", cC, this); + Ml(this, "persistent", uC, this); + this._createFunction = void 0; + this._instantiatedTimes = void 0; + this._createFunction = null; + this._instantiatedTimes = 0; + } + createNode(t) { + const e = m.instantiate(this); + e.name = this.name; + t(null, e); + } + compileCreateFunction() { + this._createFunction = function(t) { + const e = t instanceof m._BaseNode && t; + return new iy(t, e).result; + }(this.data); + } + _doInstantiate(t) { + this.data._prefab || N(3700); + this._createFunction || this.compileCreateFunction(); + return this._createFunction(t); + } + _instantiate() { + let t; + t = this.data._instantiate(); + ++this._instantiatedTimes; + return t; + } + initDefault(t) { + super.initDefault(t); + this.data = new _y; + this.data.name = "(Missing Node)"; + const e = new m._PrefabInfo; + e.asset = this; + e.root = this.data; + this.data._prefab = e; + } + validate() { + return !!this.data; + } + onLoaded() { + const t = this.data; + rA(t); + sA(t); + } + }, _C.OptimizationPolicy = pC, _C.OptimizationPolicyThreshold = 3, dC), hC = Bl(lC.prototype, "data", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), cC = Bl(lC.prototype, "optimizationPolicy", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return pC.AUTO; + } + }), uC = Bl(lC.prototype, "persistent", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), lC)) || aC); + ee.value(mC, "_utils", oC); + m.Prefab = mC; + Ct(m, "cc._Prefab", "Prefab"); + const fC = t("RenderingSubMesh", jsb.RenderingSubMesh); + const gC = fC.prototype; + gC._ctor = function(t, e, i, s = null, n = null) { + jsb.Asset.prototype._ctor.apply(this, arguments); + this._attributes = e; + this._vertexBuffers = t; + this._indexBuffer = s; + this._indirectBuffer = n; + }; + Object.defineProperty(gC, "geometricInfo", { + configurable: !0, + enumerable: !0, + get() { + let t = this.getGeometricInfo(); + if (!t.positions && !t.indices) { + t.positions = new Float32Array; + t.indices = new Uint8Array; + } + return t; + } + }); + Object.defineProperty(gC, "attributes", { + configurable: !0, + enumerable: !0, + get() { + this._attributes || (this._attributes = this.getAttributes()); + return this._attributes; + } + }); + Object.defineProperty(gC, "vertexBuffers", { + configurable: !0, + enumerable: !0, + get() { + this._vertexBuffers || (this._vertexBuffers = this.getVertexBuffers()); + return this._vertexBuffers; + } + }); + Object.defineProperty(gC, "indexBuffer", { + configurable: !0, + enumerable: !0, + get() { + this._indexBuffer || (this._indexBuffer = this.getIndexBuffer()); + return this._indexBuffer; + } + }); + Object.defineProperty(gC, "indirectBuffer", { + configurable: !0, + enumerable: !0, + get() { + this._indirectBuffer || (this._indirectBuffer = this.getIndexBuffer()); + return this._indirectBuffer; + } + }); + const yC = t("SceneAsset", jsb.SceneAsset); + m.SceneAsset = yC; + const bC = yC.prototype; + Object.defineProperty(bC, "scene", { + enumerable: !0, + configurable: !0, + get() { + this._scene || (this._scene = this.getScene()); + return this._scene; + }, + set(t) { + this._scene = t; + this.setScene(t); + } + }); + bC._ctor = function() { + jsb.Asset.prototype._ctor.apply(this, arguments); + this._scene = null; + }; + const SC = yC.prototype; + Yl(SC, "scene"); + Ul("cc.SceneAsset")(yC); + var AC, TC, vC; + let EC = t("TextAsset", Ul("cc.TextAsset")(AC = (TC = class extends gc { + constructor(...t) { + super(...t); + Ml(this, "text", vC, this); + } + toString() { + return this.text; + } + }, vC = Bl(TC.prototype, "text", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), TC)) || AC); + m.TextAsset = EC; + var CC, xC, wC; + let RC = t("JsonAsset", Ul("cc.JsonAsset")(CC = (xC = class extends gc { + constructor(...t) { + super(...t); + Ml(this, "json", wC, this); + } + }, wC = Bl(xC.prototype, "json", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), xC)) || CC); + m.JsonAsset = RC; + const IC = t("ImageAsset", jsb.ImageAsset); + const MC = [ ".png", ".jpg", ".jpeg", ".bmp", ".webp", ".pvr", ".pkm", ".astc" ]; + function BC(t) { + return !!(Vo.hasFeature(Vo.Feature.IMAGE_BITMAP) && t instanceof ImageBitmap); + } + const DC = IC.prototype; + DC._ctor = function(t) { + jsb.Asset.prototype._ctor.apply(this, arguments); + this._width = 0; + this._height = 0; + this._nativeData = { + _data: null, + width: 0, + height: 0, + format: 0, + _compressed: !1 + }; + void 0 !== t && this.reset(t); + }; + Object.defineProperty(DC, "_nativeAsset", { + configurable: !0, + enumerable: !0, + get() { + return this._nativeData; + }, + set(t) { + t instanceof HTMLElement || BC(t) || (t.format = t.format || this.format); + this.reset(t); + } + }); + Object.defineProperty(DC, "data", { + configurable: !0, + enumerable: !0, + get() { + return this._nativeData && (!0 !== (t = this._nativeData)._compressed && (t instanceof HTMLImageElement || t instanceof HTMLCanvasElement || BC(t))) ? this._nativeData : this._nativeData && this._nativeData._data; + var t; + } + }); + DC._setRawAsset = function(t, e = !0) { + this._native = !1 !== e ? t || "" : `/${t}`; + }; + DC.reset = function(t) { + this._nativeData = t; + t instanceof HTMLElement || (this.format = t.format); + this._syncDataToNative(); + }; + const PC = jsb.Asset.prototype.destroy; + DC.destroy = function() { + if (this.data && this.data instanceof HTMLImageElement) { + this.data.src = ""; + this._setRawAsset(""); + this.data.destroy(); + } else BC(this.data) && this.data.close && this.data.close(); + return PC.call(this); + }; + Object.defineProperty(DC, "width", { + configurable: !0, + enumerable: !0, + get() { + return this._nativeData.width || this._width; + } + }); + Object.defineProperty(DC, "height", { + configurable: !0, + enumerable: !0, + get() { + return this._nativeData.height || this._height; + } + }); + DC._syncDataToNative = function() { + const t = this._nativeData; + this._width = t.width; + this._height = t.height; + this.setWidth(this._width); + this.setHeight(this._height); + this.url = this.nativeUrl; + t instanceof HTMLCanvasElement ? this.setData(t._data.data) : t instanceof HTMLImageElement ? this.setData(t._data) : this.setData(this._nativeData._data); + }; + DC._serialize = function() { + if (EDITOR) { + let t; + this._native && (t = [ this._native ]); + if (!t) return ""; + const e = []; + for (const i of t) { + const t = i.split("@"); + const s = MC.indexOf(t[0]); + let n = s < 0 ? i : `${s}`; + t[1] && (n += `@${t[1]}`); + e.push(n); + } + return { + fmt: e.join("_"), + w: this.width, + h: this.height + }; + } + }; + DC._deserialize = function(t) { + let e = ""; + if ("string" == typeof t) e = t; else { + this._width = t.w; + this._height = t.h; + e = t.fmt; + } + const i = zo.gfxDevice; + const s = e.split("_"); + let n = Number.MAX_VALUE; + let r = this.format; + let o = ""; + const a = pe.SUPPORT_TEXTURE_FORMATS; + for (const t of s) { + const e = t.split("@"); + const s = parseInt(e[0], void 0); + const l = MC[s] || e[0]; + const h = a.indexOf(l); + if (-1 !== h && h < n) { + const t = e[1] ? parseInt(e[1]) : this.format; + if (!(".astc" !== l || i && i.getFormatFeatures(bs.ASTC_RGBA_4X4) & Is.SAMPLED_TEXTURE)) continue; + if (!(".pvr" !== l || i && i.getFormatFeatures(bs.PVRTC_RGBA4) & Is.SAMPLED_TEXTURE)) continue; + if (!(t !== Jp.RGB_ETC1 && t !== Jp.RGBA_ETC1 || i && i.getFormatFeatures(bs.ETC_RGB8) & Is.SAMPLED_TEXTURE)) continue; + if (!(t !== Jp.RGB_ETC2 && t !== Jp.RGBA_ETC2 || i && i.getFormatFeatures(bs.ETC2_RGB8) & Is.SAMPLED_TEXTURE)) continue; + if (".webp" === l && !Vo.hasFeature(Vo.Feature.WEBP)) continue; + n = h; + o = l; + r = t; + } + } + if (o) { + this._setRawAsset(o); + this.format = r; + } else N(3121); + }; + m.ImageAsset = jsb.ImageAsset; + const OC = IC.prototype; + vh(OC, "_nativeAsset", Object.getOwnPropertyDescriptor(OC, "_nativeAsset")); + Ul("cc.ImageAsset")(IC); + const NC = jsb.Texture2D.prototype; + NC.createNode = null; + const LC = t("Texture2D", jsb.Texture2D); + LC.Filter = Qp; + LC.PixelFormat = Jp; + LC.WrapMode = Zp; + NC._ctor = function() { + mA.prototype._ctor.apply(this, arguments); + this._mipmaps = []; + }; + NC._serialize = function(t) { + return EDITOR || TEST ? { + base: tm.prototype._serialize(t), + mipmaps: this._mipmaps.map((e => e && e._uuid ? t && t._compressUuid ? EditorExtends.UuidUtils.compressUuid(e._uuid, !0) : e._uuid : null)) + } : null; + }; + NC._deserialize = function(t, e) { + const i = t; + tm.prototype._deserialize.call(this, i.base); + this._mipmaps = new Array(i.mipmaps.length); + for (let t = 0; t < i.mipmaps.length; ++t) { + this._mipmaps[t] = new IC; + if (!i.mipmaps[t]) continue; + const s = i.mipmaps[t]; + e.result.push(this._mipmaps, `${t}`, s, ee.getClassId(IC)); + } + }; + const FC = NC.onLoaded; + NC.onLoaded = function() { + this.syncMipmapsForJS(this._mipmaps); + FC.call(this); + }; + Object.defineProperty(NC, "image", { + configurable: !0, + enumerable: !0, + get() { + return 0 === this._mipmaps.length ? null : this._mipmaps[0]; + }, + set(t) { + this.mipmaps = t ? [ t ] : []; + } + }); + Object.defineProperty(NC, "mipmaps", { + configurable: !0, + enumerable: !0, + get() { + return this._mipmaps; + }, + set(t) { + for (let e = 0, i = t.length; e < i; ++e) t[e]._syncDataToNative(); + this._mipmaps = t; + this.setMipmaps(t); + } + }); + m.Texture2D = jsb.Texture2D; + const VC = LC.prototype; + Th([ IC ])(VC, "_mipmaps"); + Ul("cc.Texture2D")(LC); + let kC, UC, GC; + const zC = 2; + const HC = 1; + const jC = 1, XC = 2, WC = 4, YC = 8; + class qC { + constructor(t, e) { + this.source = void 0; + this.target = void 0; + this.source = t; + this.target = e; + } + equals(t) { + return this.source === t.source && this.target === t.target; + } + } + class KC { + constructor(t) { + this.target = void 0; + this.target = t; + } + equals(t) { + return this.target === t.target; + } + } + kC = Symbol.iterator; + class JC { + constructor(t, e) { + this.iterator = void 0; + this.source = void 0; + this.iterator = t; + this.source = e; + } + [kC]() { + return this; + } + next() { + const t = this.iterator.next(); + return t.done ? { + value: void 0, + done: !0 + } : { + value: new qC(this.source, t.value.target), + done: !1 + }; + } + } + UC = Symbol.iterator; + class ZC { + constructor(t, e) { + this.iterator = void 0; + this.source = void 0; + this.iterator = t; + this.source = e; + } + [UC]() { + return this; + } + next() { + const t = this.iterator.next(); + return t.done ? { + value: void 0, + done: !0 + } : { + value: new qC(t.value.target, this.source), + done: !1 + }; + } + } + GC = Symbol.iterator; + class QC { + constructor(t, e) { + this.graph = void 0; + this.iterator = void 0; + this.graph = t; + this.iterator = e; + } + [GC]() { + return this; + } + next() { + const t = this.iterator.next(); + return t.done ? { + value: void 0, + done: !0 + } : { + value: this.graph.target(t.value), + done: !1 + }; + } + } + function $C(t, e) { + for (const i of t) i.target > e && --i.target; + } + function tx(t, e, i) { + const s = t.nullVertex(); + const n = i.split("/"); + if (0 === n.length) return e; + let r = e; + let o = 0; + if ("" === n[0]) { + r = s; + ++o; + } + for (let e = o; e !== n.length; ++e) { + const i = n[e]; + if ("" !== i && "." !== i) if (".." !== i) { + r = t.locateChild(r, i); + if (r === s) return s; + } else { + if (r === s) return s; + r = t.getParent(r); + } + } + return r; + } + class ex { + terminate(t, e) { + return !1; + } + } + function ix(t) { + const e = t.vertices().next(); + return e.done ? t.nullVertex() : e.value; + } + let sx; + !function(t) { + t[t.WHITE = 0] = "WHITE"; + t[t.GRAY = 1] = "GRAY"; + t[t.GREEN = 2] = "GREEN"; + t[t.RED = 3] = "RED"; + t[t.BLACK = 4] = "BLACK"; + }(sx || (sx = {})); + class nx { + constructor(t, e, i) { + this.v = void 0; + this.e = void 0; + this.iter = void 0; + this.v = t; + this.e = e; + this.iter = i; + } + } + function rx(t, e, i, s, n) { + let r = null; + let o = null; + const a = new Array; + s.put(e, sx.GRAY); + i.discoverVertex(e, t); + o = t.outEdges(e); + n.terminate(e, t) ? a.push(new nx(e, null, null)) : a.push(new nx(e, null, o)); + for (;a.length; ) { + const l = a.pop(); + e = l.v; + r = l.e; + o = l.iter; + null !== r && i.finishEdge(r, t); + if (o) for (let l = o.next(); !l.done; l = o.next()) { + const h = l.value; + const c = h.target; + i.examineEdge(h, t); + const u = s.get(c); + if (u === sx.WHITE) { + i.treeEdge(h, t); + r = h; + a.push(new nx(e, r, o)); + e = c; + s.put(e, sx.GRAY); + i.discoverVertex(e, t); + o = t.outEdges(e); + if (n.terminate(e, t)) break; + } else { + u === sx.GRAY ? i.backEdge(h, t) : i.forwardOrCrossEdge(h, t); + i.finishEdge(h, t); + } + } + s.put(e, sx.BLACK); + i.finishVertex(e, t); + } + } + const ox = 0, ax = 1, lx = 2, hx = 3; + const cx = 0, ux = 4; + const _x = 0; + const dx = 0, px = 1, mx = 3; + const fx = 0, gx = 1, yx = 2, bx = 4, Sx = 8, Ax = 16, Tx = 32, vx = 64, Ex = 256, Cx = 512, xx = 1024; + const wx = 0, Rx = 1; + const Ix = 0, Mx = 2; + class Bx { + constructor(t = "", e = Mx, i = wx, s = Us.LOAD, n = Gs.STORE, r = en.ALL, o = new gn) { + this.slotName = void 0; + this.accessType = void 0; + this.attachmentType = void 0; + this.loadOp = void 0; + this.storeOp = void 0; + this.clearFlags = void 0; + this.clearColor = void 0; + this.slotName = t; + this.accessType = e; + this.attachmentType = i; + this.loadOp = s; + this.storeOp = n; + this.clearFlags = r; + this.clearColor = o; + } + } + const Dx = 0; + class Px { + constructor() { + this.name = ""; + this.accessType = Ix; + this.clearFlags = en.NONE; + this.clearColor = new gn; + this.clearValueType = Dx; + } + } + class Ox { + constructor(t = null, e = 0) { + this.light = void 0; + this.level = void 0; + this.light = t; + this.level = e; + } + } + const Nx = 0, Lx = 1, Fx = 2, Vx = 3, kx = 4, Ux = 5, Gx = 7, zx = 8; + class Hx { + constructor(t = As.UNKNOWN) { + this.type = void 0; + this.count = 1; + this.type = t; + } + } + class jx { + constructor() { + this.descriptors = new Map; + this.uniformBlocks = new Map; + this.capacity = 0; + this.count = 0; + } + } + class Xx { + constructor() { + this.descriptorNames = []; + this.uniformBlockNames = []; + this.descriptors = []; + this.uniformBlocks = []; + this.capacity = 0; + this.count = 0; + } + } + class Wx { + constructor(t = ox, e = cx, i = Nx, s = ks.NONE) { + this.updateFrequency = void 0; + this.parameterType = void 0; + this.descriptorType = void 0; + this.visibility = void 0; + this.updateFrequency = t; + this.parameterType = e; + this.descriptorType = i; + this.visibility = s; + } + } + class Yx { + constructor() { + this.blocks = new Map; + } + } + class qx { + constructor() { + this.shaders = new Set; + } + } + const Kx = 0, Jx = 1; + class Zx { + constructor(t, e) { + this._outEdges = []; + this._inEdges = []; + this._id = void 0; + this._object = void 0; + this.id = t; + this.object = e; + this._id = t; + this._object = e; + } + } + class Qx { + constructor(t) { + this._names = void 0; + this.names = t; + this._names = t; + } + get(t) { + return this._names[t]; + } + } + class $x { + constructor(t) { + this._descriptors = void 0; + this.descriptors = t; + this._descriptors = t; + } + get(t) { + return this._descriptors[t]; + } + } + const tw = 0, ew = 1; + class iw { + constructor() { + this.directed_category = zC; + this.edge_parallel_category = HC; + this.traversal_category = jC | XC | WC | YC; + this.components = [ "Name", "Descriptors" ]; + this._vertices = []; + this._names = []; + this._descriptors = []; + } + nullVertex() { + return 4294967295; + } + edge(t, e) { + for (const i of this._vertices[t]._outEdges) if (e === i.target) return !0; + return !1; + } + source(t) { + return t.source; + } + target(t) { + return t.target; + } + outEdges(t) { + return new JC(this._vertices[t]._outEdges.values(), t); + } + outDegree(t) { + return this._vertices[t]._outEdges.length; + } + inEdges(t) { + return new ZC(this._vertices[t]._inEdges.values(), t); + } + inDegree(t) { + return this._vertices[t]._inEdges.length; + } + degree(t) { + return this.outDegree(t) + this.inDegree(t); + } + adjacentVertices(t) { + return new QC(this, this.outEdges(t)); + } + vertices() { + return this._vertices.keys(); + } + numVertices() { + return this._vertices.length; + } + clear() { + this._names.length = 0; + this._descriptors.length = 0; + this._vertices.length = 0; + } + addVertex(t, e, i, s, n = 4294967295) { + const r = new Zx(t, e); + const o = this._vertices.length; + this._vertices.push(r); + this._names.push(i); + this._descriptors.push(s); + 4294967295 !== n && this.addEdge(n, o); + return o; + } + clearVertex(t) { + const e = this._vertices[t]; + for (const i of e._outEdges) { + const e = this._vertices[i.target]; + for (let i = 0; i !== e._inEdges.length; ) e._inEdges[i].target === t ? e._inEdges.splice(i, 1) : ++i; + } + e._outEdges.length = 0; + for (const i of e._inEdges) { + const e = this._vertices[i.target]; + for (let i = 0; i !== e._outEdges.length; ) e._outEdges[i].target === t ? e._outEdges.splice(i, 1) : ++i; + } + e._inEdges.length = 0; + } + removeVertex(t) { + this._vertices.splice(t, 1); + this._names.splice(t, 1); + this._descriptors.splice(t, 1); + const e = this._vertices.length; + if (t !== e) for (let i = 0; i !== e; ++i) { + const e = this._vertices[i]; + $C(e._outEdges, t); + $C(e._inEdges, t); + } + } + addEdge(t, e) { + this._vertices[t]._outEdges.push(new KC(e)); + this._vertices[e]._inEdges.push(new KC(t)); + return new qC(t, e); + } + removeEdges(t, e) { + const i = this._vertices[t]; + for (let t = 0; t !== i._outEdges.length; ) i._outEdges[t].target === e ? i._outEdges.splice(t, 1) : ++t; + const s = this._vertices[e]; + for (let e = 0; e !== s._inEdges.length; ) s._inEdges[e].target === t ? s._inEdges.splice(e, 1) : ++e; + } + removeEdge(t) { + const e = t.source; + const i = t.target; + const s = this._vertices[e]; + for (let t = 0; t !== s._outEdges.length; ) { + if (s._outEdges[t].target === i) { + s._outEdges.splice(t, 1); + break; + } + ++t; + } + const n = this._vertices[i]; + for (let t = 0; t !== n._inEdges.length; ) { + if (n._inEdges[t].target === e) { + n._inEdges.splice(t, 1); + break; + } + ++t; + } + } + vertexName(t) { + return this._names[t]; + } + vertexNameMap() { + return new Qx(this._names); + } + get(t) { + switch (t) { + case "Name": + return new Qx(this._names); + + case "Descriptors": + return new $x(this._descriptors); + + default: + throw Error("property map not found"); + } + } + component(t, e) { + switch (t) { + case tw: + return this._names[e]; + + case ew: + return this._descriptors[e]; + + default: + throw Error("component not found"); + } + } + componentMap(t) { + switch (t) { + case tw: + return new Qx(this._names); + + case ew: + return new $x(this._descriptors); + + default: + throw Error("component map not found"); + } + } + getName(t) { + return this._names[t]; + } + getDescriptors(t) { + return this._descriptors[t]; + } + holds(t, e) { + return this._vertices[e]._id === t; + } + id(t) { + return this._vertices[t]._id; + } + object(t) { + return this._vertices[t]._object; + } + value(t, e) { + if (this._vertices[e]._id === t) return this._vertices[e]._object; + throw Error("value id not match"); + } + tryValue(t, e) { + return this._vertices[e]._id === t ? this._vertices[e]._object : null; + } + visitVertex(t, e) { + const i = this._vertices[e]; + switch (i._id) { + case Kx: + return t.renderStage(i._object); + + case Jx: + return t.renderPhase(i._object); + + default: + throw Error("polymorphic type not found"); + } + } + getRenderStage(t) { + if (this._vertices[t]._id === Kx) return this._vertices[t]._object; + throw Error("value id not match"); + } + getRenderPhase(t) { + if (this._vertices[t]._id === Jx) return this._vertices[t]._object; + throw Error("value id not match"); + } + tryGetRenderStage(t) { + return this._vertices[t]._id === Kx ? this._vertices[t]._object : null; + } + tryGetRenderPhase(t) { + return this._vertices[t]._id === Jx ? this._vertices[t]._object : null; + } + reference(t, e) { + for (const i of this._vertices[t]._outEdges) if (e === i.target) return !0; + return !1; + } + parent(t) { + return t.source; + } + child(t) { + return t.target; + } + parents(t) { + return new ZC(this._vertices[t]._inEdges.values(), t); + } + children(t) { + return new JC(this._vertices[t]._outEdges.values(), t); + } + numParents(t) { + return this._vertices[t]._inEdges.length; + } + numChildren(t) { + return this._vertices[t]._outEdges.length; + } + getParent(t) { + if (4294967295 === t) return 4294967295; + const e = this._vertices[t]._inEdges; + return 0 === e.length ? 4294967295 : e[0].target; + } + isAncestor(t, e) { + const i = 4294967295; + if (t === e) return !1; + if (t === i) return !0; + if (e === i) return !1; + for (let s = this.getParent(e); s !== i; ) { + if (t === s) return !0; + s = this.getParent(s); + } + return !1; + } + addReference(t, e) { + return this.addEdge(t, e); + } + removeReference(t) { + return this.removeEdge(t); + } + removeReferences(t, e) { + return this.removeEdges(t, e); + } + locateChild(t, e) { + if (4294967295 === t) { + for (const t of this._vertices.keys()) { + if (0 === this._vertices[t]._inEdges.length && this._names[t] === e) return t; + } + return 4294967295; + } + for (const i of this._vertices[t]._outEdges) { + const t = i.target; + if (e === this._names[t]) return t; + } + return 4294967295; + } + addressable(t) { + return 4294967295 !== tx(this, 4294967295, t); + } + locate(t) { + return tx(this, 4294967295, t); + } + locateRelative(t, e = 4294967295) { + return tx(this, e, t); + } + path(t) { + return function(t, e) { + if (e === t.nullVertex()) return ""; + const i = []; + for (;e !== t.nullVertex(); e = t.getParent(e)) i.push(t.vertexName(e)); + let s = ""; + for (let t = i.length; t-- > 0; ) { + s += "/"; + s += i[t]; + } + return s; + }(this, t); + } + } + class sw { + constructor() { + this.uniformBlockIndex = void 0; + this.blockMerged = void 0; + this.dbsToMerge = void 0; + this._layoutGraph = void 0; + this._layoutGraph = new iw; + this.uniformBlockIndex = new Map; + this.blockMerged = new Map; + this.dbsToMerge = new Map; + } + getLayoutBlock(t, e, i, s, n) { + const r = new Wx(t, e, i, s); + const o = JSON.stringify(r); + if (void 0 === n.blocks.get(o)) { + const t = new jx; + n.blocks.set(o, t); + this.uniformBlockIndex.set(t, r); + } + return n.blocks.get(o); + } + getLayoutBlockByKey(t, e) { + if (void 0 === e.blocks.get(t)) { + const i = new jx; + e.blocks.set(t, i); + const s = JSON.parse(t); + this.uniformBlockIndex.set(i, s); + } + return e.blocks.get(t); + } + getUniformBlock(t, e, i, s) { + if (void 0 === s.uniformBlocks.get(i)) { + const n = new Mn(t, e, i, [], 1); + s.uniformBlocks.set(i, n); + } + return s.uniformBlocks.get(i); + } + setUniform(t, e, i, s) { + const n = new In(e, i, s); + t.members.push(n); + } + setDescriptor(t, e, i) { + const s = new Hx(i); + t.descriptors.set(e, s); + } + merge(t) { + for (const i of t.blocks) { + const t = i[1]; + const s = new Map; + for (const e of t.descriptors) { + const i = e[1].type; + if (void 0 === s.get(i)) s.set(i, 1); else { + const t = s.get(i); + s.set(i, t + 1); + } + t.capacity++; + } + for (const i of s) { + const s = i[0]; + const n = i[1]; + if (n > 0) { + var e; + const i = new Hx(s); + i.count = n; + let r; + if (void 0 === this.blockMerged.get(t)) { + r = new Map; + this.blockMerged.set(t, r); + } + null === (e = this.blockMerged.get(t)) || void 0 === e || e.set(s, i); + } + } + } + } + mergeDBs(t, e) { + for (let i = 0; i < t.length; ++i) { + const s = t[i]; + for (const t of s.blocks) { + const i = t[0]; + const s = t[1]; + let n; + if (void 0 === this.blockMerged.get(s)) { + n = new Map; + this.blockMerged.set(s, n); + } else n = this.blockMerged.get(s); + if (n.size > 0) { + const t = this.getLayoutBlockByKey(i, e); + let r; + if (void 0 === this.blockMerged.get(t)) { + r = new Map; + this.blockMerged.set(t, r); + } else r = this.blockMerged.get(t); + for (const t of n) { + const e = t[0]; + const i = t[1]; + if (r.has(e)) { + const t = r.get(e); + void 0 !== t && (t.count = t.count > i.count ? t.count : i.count); + } else { + const t = new Hx(i.type); + t.count = i.count; + r.set(e, t); + } + } + t.capacity = s.capacity > t.capacity ? s.capacity : t.capacity; + } + } + } + } + sort(t) { + const e = new Map(Array.from(t.blocks).sort(((t, e) => String(t[0]).localeCompare(e[0])))); + t.blocks.clear(); + for (const i of e) t.blocks.set(i[0], i[1]); + } + addEffect(t, e) { + const i = t.shaders.length; + for (let n = 0; n !== i; ++n) { + var s; + const i = t.shaders[n]; + const r = new Yx; + for (let t = 0; t < i.blocks.length; ++t) { + const e = i.blocks[t]; + const s = this.getLayoutBlock(ox, ux, Nx, e.stageFlags, r); + const n = this.getUniformBlock(wm.MATERIAL, e.binding, e.name, s); + for (let t = 0; t < e.members.length; ++t) { + const i = e.members[t]; + n.members.push(i); + } + } + for (let t = 0; t < i.buffers.length; ++t) { + const e = i.buffers[t]; + const s = this.getLayoutBlock(ax, ux, Ux, e.stageFlags, r); + this.setDescriptor(s, e.name, As.UNKNOWN); + } + for (let t = 0; t < i.images.length; ++t) { + const e = i.images[t]; + const s = this.getLayoutBlock(ax, ux, Gx, e.stageFlags, r); + this.setDescriptor(s, e.name, e.type); + } + for (let t = 0; t < i.samplerTextures.length; ++t) { + const e = i.samplerTextures[t]; + const s = this.getLayoutBlock(ax, ux, Fx, e.stageFlags, r); + this.setDescriptor(s, e.name, e.type); + } + for (let t = 0; t < i.samplers.length; ++t) { + const e = i.samplers[t]; + const s = this.getLayoutBlock(ax, ux, Vx, e.stageFlags, r); + this.setDescriptor(s, e.name, As.SAMPLER); + } + for (let t = 0; t < i.textures.length; ++t) { + const e = i.textures[t]; + const s = this.getLayoutBlock(ax, ux, kx, e.stageFlags, r); + this.setDescriptor(s, e.name, e.type); + } + for (let t = 0; t < i.subpassInputs.length; ++t) { + const e = i.subpassInputs[t]; + const s = this.getLayoutBlock(ax, ux, zx, e.stageFlags, r); + this.setDescriptor(s, e.name, As.SUBPASS_INPUT); + } + const o = this.getLayoutBlock(ox, ux, Nx, ks.VERTEX, r); + const a = this.getLayoutBlock(ax, ux, Lx, ks.FRAGMENT, r); + const l = this.getLayoutBlock(ox, ux, Lx, ks.VERTEX, r); + const h = this.getLayoutBlock(ox, ux, Nx, ks.VERTEX | ks.COMPUTE, r); + const c = this.getLayoutBlock(ax, ux, Fx, ks.VERTEX, r); + const u = this.getLayoutBlock(ax, ux, Fx, ks.FRAGMENT, r); + const _ = this.getLayoutBlock(ax, ux, Fx, ks.COMPUTE, r); + for (let t = 0; t < i.builtins.locals.blocks.length; ++t) { + const e = i.builtins.locals.blocks[t].name; + if ("CCMorph" === e) { + const t = this.getUniformBlock(wm.LOCAL, nf.BINDING, "CCMorph", o); + this.setUniform(t, "cc_displacementWeights", As.FLOAT4, nf.MAX_MORPH_TARGET_COUNT / 4); + this.setUniform(t, "cc_displacementTextureInfo", As.FLOAT4, 1); + } else if ("CCSkinningTexture" === e) { + const t = this.getUniformBlock(wm.LOCAL, tf.BINDING, "CCSkinningTexture", o); + this.setUniform(t, "cc_jointTextureInfo", As.FLOAT4, 1); + } else if ("CCSkinningAnimation" === e) { + const t = this.getUniformBlock(wm.LOCAL, ef.BINDING, "CCSkinningAnimation", o); + this.setUniform(t, "cc_jointAnimInfo", As.FLOAT4, 1); + } else if ("CCSkinning" === e) { + const t = this.getUniformBlock(wm.LOCAL, sf.BINDING, "CCSkinning", o); + this.setUniform(t, "cc_joints", As.FLOAT4, 90); + } else if ("CCUILocal" === e) { + const t = this.getUniformBlock(wm.LOCAL, rf.BINDING, "CCUILocal", l); + this.setUniform(t, "cc_local_data", As.FLOAT4, 1); + } else if ("CCForwardLight" === e) { + const t = this.getUniformBlock(wm.LOCAL, Qm.BINDING, "CCForwardLight", a); + this.setUniform(t, "cc_lightPos", As.FLOAT4, Qm.LIGHTS_PER_PASS); + this.setUniform(t, "cc_lightColor", As.FLOAT4, Qm.LIGHTS_PER_PASS); + this.setUniform(t, "cc_lightSizeRangeAngle", As.FLOAT4, Qm.LIGHTS_PER_PASS); + this.setUniform(t, "cc_lightDir", As.FLOAT4, Qm.LIGHTS_PER_PASS); + } else if ("CCLocal" === e) { + const t = this.getUniformBlock(wm.LOCAL, Km.BINDING, "CCLocal", h); + this.setUniform(t, "cc_matWorld", As.MAT4, 1); + this.setUniform(t, "cc_matWorldIT", As.MAT4, 1); + this.setUniform(t, "cc_lightingMapUVParam", As.FLOAT4, 1); + } else if ("CCLocalBatched" === e) { + const t = this.getUniformBlock(wm.LOCAL, Zm.BINDING, "CCLocalBatched", h); + this.setUniform(t, "cc_matWorlds", As.MAT4, Zm.BATCHING_COUNT); + } else if ("CCWorldBound" === e) { + const t = this.getUniformBlock(wm.LOCAL, Jm.BINDING, "CCWorldBound", h); + this.setUniform(t, "cc_worldBoundCenter", As.FLOAT4, 1); + this.setUniform(t, "cc_worldBoundHalfExtents", As.FLOAT4, 1); + } + } + for (let t = 0; t < i.builtins.locals.samplerTextures.length; ++t) { + const e = i.builtins.locals.samplerTextures[t].name; + "cc_jointTexture" === e ? this.setDescriptor(c, "cc_jointTexture", As.SAMPLER2D) : "cc_PositionDisplacements" === e ? this.setDescriptor(c, "cc_PositionDisplacements", As.SAMPLER2D) : "cc_NormalDisplacements" === e ? this.setDescriptor(c, "cc_NormalDisplacements", As.SAMPLER2D) : "cc_TangentDisplacements" === e ? this.setDescriptor(c, "cc_TangentDisplacements", As.SAMPLER2D) : "cc_lightingMap" === e ? this.setDescriptor(u, "cc_lightingMap", As.SAMPLER2D) : "cc_spriteTexture" === e ? this.setDescriptor(u, "cc_spriteTexture", As.SAMPLER2D) : "cc_reflectionTexture" === e && this.setDescriptor(u, "cc_reflectionTexture", As.SAMPLER2D); + } + for (let t = 0; t < i.builtins.locals.images.length; ++t) { + "cc_reflectionStorage" === i.builtins.locals.images[t].name && this.setDescriptor(_, "cc_reflectionStorage", As.IMAGE2D); + } + const d = new qx; + d.shaders.add(i.name); + this._layoutGraph.addVertex(Jx, d, i.name, r, e); + this.merge(r); + this.sort(r); + const p = this._layoutGraph.getDescriptors(e); + void 0 === this.dbsToMerge.get(p) && this.dbsToMerge.set(p, []); + null === (s = this.dbsToMerge.get(p)) || void 0 === s || s.push(r); + } + } + addGlobal(t, e, i, s, n, r, o, a) { + const l = new Yx; + const h = this.getLayoutBlock(hx, ux, Nx, ks.ALL, l); + const c = this.getLayoutBlock(hx, ux, Fx, ks.FRAGMENT, l); + if (e) { + const t = this.getUniformBlock(wm.GLOBAL, Im.BINDING, "CCGlobal", h); + this.setUniform(t, "cc_time", As.FLOAT4, 1); + this.setUniform(t, "cc_screenSize", As.FLOAT4, 1); + this.setUniform(t, "cc_nativeSize", As.FLOAT4, 1); + this.setDescriptor(h, "CCGlobal", As.UNKNOWN); + } + if (i) { + const t = this.getUniformBlock(wm.GLOBAL, Mm.BINDING, "CCCamera", h); + this.setUniform(t, "cc_matView", As.MAT4, 1); + this.setUniform(t, "cc_matViewInv", As.MAT4, 1); + this.setUniform(t, "cc_matProj", As.MAT4, 1); + this.setUniform(t, "cc_matProjInv", As.MAT4, 1); + this.setUniform(t, "cc_matViewProj", As.MAT4, 1); + this.setUniform(t, "cc_matViewProjInv", As.MAT4, 1); + this.setUniform(t, "cc_cameraPos", As.FLOAT4, 1); + this.setUniform(t, "cc_surfaceTransform", As.FLOAT4, 1); + this.setUniform(t, "cc_screenScale", As.FLOAT4, 1); + this.setUniform(t, "cc_exposure", As.FLOAT4, 1); + this.setUniform(t, "cc_mainLitDir", As.FLOAT4, 1); + this.setUniform(t, "cc_mainLitColor", As.FLOAT4, 1); + this.setUniform(t, "cc_ambientSky", As.FLOAT4, 1); + this.setUniform(t, "cc_ambientGround", As.FLOAT4, 1); + this.setUniform(t, "cc_fogColor", As.FLOAT4, 1); + this.setUniform(t, "cc_fogBase", As.FLOAT4, 1); + this.setUniform(t, "cc_fogAdd", As.FLOAT4, 1); + this.setUniform(t, "cc_nearFar", As.FLOAT4, 1); + this.setUniform(t, "cc_viewPort", As.FLOAT4, 1); + this.setDescriptor(h, "CCCamera", As.UNKNOWN); + } + if (s) { + const t = this.getUniformBlock(wm.GLOBAL, Bm.BINDING, "CCShadow", h); + this.setUniform(t, "cc_matLightView", As.MAT4, 1); + this.setUniform(t, "cc_matLightViewProj", As.MAT4, 1); + this.setUniform(t, "cc_shadowInvProjDepthInfo", As.FLOAT4, 1); + this.setUniform(t, "cc_shadowProjDepthInfo", As.FLOAT4, 1); + this.setUniform(t, "cc_shadowProjInfo", As.FLOAT4, 1); + this.setUniform(t, "cc_shadowNFLSInfo", As.FLOAT4, 1); + this.setUniform(t, "cc_shadowWHPBInfo", As.FLOAT4, 1); + this.setUniform(t, "cc_shadowLPNNInfo", As.FLOAT4, 1); + this.setUniform(t, "cc_shadowColor", As.FLOAT4, 1); + this.setUniform(t, "cc_planarNDInfo", As.FLOAT4, 1); + this.setDescriptor(h, "CCShadow", As.UNKNOWN); + } + n && this.setDescriptor(c, "cc_shadowMap", As.SAMPLER2D); + r && this.setDescriptor(c, "cc_environment", As.SAMPLER_CUBE); + o && this.setDescriptor(c, "cc_diffuseMap", As.SAMPLER_CUBE); + a && this.setDescriptor(c, "cc_spotShadowMap", As.SAMPLER2D); + this.merge(l); + return this._layoutGraph.addVertex(Kx, fm.DEFAULT, t, l); + } + mergeDescriptors(t) { + const e = this._layoutGraph.getDescriptors(t); + const i = this.dbsToMerge.get(e); + if (void 0 !== i) { + this.mergeDBs(i, e); + this.sort(e); + } + } + addRenderStage(t, e) { + const i = new Yx; + return this._layoutGraph.addVertex(Kx, e, t, i); + } + addRenderPhase(t, e) { + const i = new Yx; + return this._layoutGraph.addVertex(Jx, new qx, t, i, e); + } + get layoutGraph() { + return this._layoutGraph; + } + } + class nw extends class { + initializeVertex(t, e) {} + startVertex(t, e) {} + discoverVertex(t, e) {} + examineEdge(t, e) {} + treeEdge(t, e) {} + backEdge(t, e) {} + forwardOrCrossEdge(t, e) {} + finishEdge(t, e) {} + finishVertex(t, e) {} + } { + constructor(...t) { + super(...t); + this._error = ""; + } + getFrequency(t, e) { + let i; + i = t.holds(Kx, e) ? hx : lx; + return i; + } + mergeDescriptors(t, e) { + for (const [n, r] of t.descriptors) { + const t = e.descriptors.get(n); + if (void 0 !== t) { + if (!(i = r, s = t, i.type === s.type && i.count === s.count)) return `Descriptor ${n} is inconsistent`; + } else e.descriptors.set(n, r); + } + var i, s; + return ""; + } + mergeParent(t, e, i) { + for (const [s, n] of e.blocks) { + let e = i.blocks.get(s); + if (void 0 === e) { + e = new jx; + i.blocks.set(s, e); + } + if (JSON.parse(s).updateFrequency > t) { + const t = this.mergeDescriptors(n, e); + if (t) return t; + } + } + return ""; + } + updateInfo(t, e) { + e.blocks.forEach(((e, i) => { + if (JSON.parse(i).updateFrequency >= t) { + e.count = function(t) { + let e = 0; + for (const [, i] of t.descriptors) e += i.count; + return e; + }(e); + e.capacity = e.count; + } + })); + } + backEdge(t, e) { + this._error = "Cycle detected in graph"; + } + finishEdge(t, e) { + if ("" !== this._error) return; + const i = e.source(t); + const s = e.target(t); + const n = e.getDescriptors(i); + const r = e.getDescriptors(s); + const o = this.getFrequency(e, s); + this.mergeParent(o, r, n); + } + finishVertex(t, e) { + if ("" !== this._error) return; + const i = this.getFrequency(e, t); + const s = e.getDescriptors(t); + this.updateInfo(i, s); + } + get error() { + return this._error; + } + } + function rw(t, e) { + t.descriptors.forEach(((t, i) => { + const s = i; + const n = t; + e.descriptorNames.push(s); + e.descriptors.push(n); + })); + t.uniformBlocks.forEach(((t, i) => { + const s = i; + const n = t; + e.uniformBlockNames.push(s); + e.uniformBlocks.push(n); + })); + e.count = t.count; + e.capacity = t.capacity; + } + function ow(t, e) { + for (const i of t.vertices()) { + const s = t.getDescriptors(i); + let n = 0; + t.id(i) === Kx && (n = e.addRenderStage(t.getName(i))); + if (t.id(i) === Jx) { + n = e.addRenderPhase(t.getName(i), t.getParent(i)); + const s = t.getRenderPhase(n); + for (const t of s.shaders) e.addShader(t, n); + } + s.blocks.forEach(((t, i) => { + const s = JSON.parse(i); + const r = t; + const o = new Xx; + rw(r, o); + r.capacity > 0 && e.addDescriptorBlock(n, s, o); + for (let t = 0; t < o.uniformBlockNames.length; ++t) e.addUniformBlock(n, s, o.uniformBlockNames[t], o.uniformBlocks[t]); + })); + } + } + var aw; + !function(t) { + t[t.GEOMETRY = 0] = "GEOMETRY"; + t[t.LIGHTING = 1] = "LIGHTING"; + t[t.POST = 2] = "POST"; + }(aw || (aw = {})); + class lw { + constructor(t) { + this.colors = void 0; + this.colors = new Array(t); + } + get(t) { + return this.colors[t]; + } + put(t, e) { + this.colors[t] = e; + } + } + function hw(t) { + const e = new sw; + const i = e.addGlobal("default", !0, !0, !0, !0, !0, !0, !0); + e.mergeDescriptors(i); + const s = e.addRenderStage("Geometry", aw.GEOMETRY); + const n = e.addRenderStage("Lighting", aw.LIGHTING); + const r = e.addRenderStage("Postprocess", aw.POST); + e.addRenderPhase("Queue", s); + const o = e.addRenderPhase("Queue", n); + e.addRenderPhase("Queue", r); + const a = e.layoutGraph.getDescriptors(o); + const l = e.getLayoutBlock(hx, ux, Fx, ks.FRAGMENT, a); + e.setDescriptor(l, "gbuffer_albedoMap", As.FLOAT4); + e.setDescriptor(l, "gbuffer_normalMap", As.FLOAT4); + e.setDescriptor(l, "gbuffer_emissiveMap", As.FLOAT4); + e.setDescriptor(l, "depth_stencil", As.FLOAT4); + const h = new nw; + const c = new lw(e.layoutGraph.numVertices()); + !function(t, e, i, s = null) { + if (null === (s = s || ix(t)) || 0 === t.numVertices()) return; + for (const s of t.vertices()) { + i.put(s, sx.WHITE); + e.initializeVertex(s, t); + } + const n = new ex; + if (s !== ix(t)) { + e.startVertex(s, t); + rx(t, s, e, i, n); + } + for (const s of t.vertices()) if (i.get(s) === sx.WHITE) { + e.startVertex(s, t); + rx(t, s, e, i, n); + } + }(e.layoutGraph, h, c); + e.mergeDescriptors(n); + const u = e.layoutGraph.getDescriptors(r); + const _ = e.getLayoutBlock(hx, ux, Fx, ks.FRAGMENT, u); + e.setDescriptor(_, "outputResultMap", As.FLOAT4); + e.merge(u); + e.mergeDescriptors(r); + h.error && console.log(h.error); + const d = t.layoutGraphBuilder; + d.clear(); + ow(e.layoutGraph, d); + } + const cw = t("Root", jsb.Root); + var uw; + !function(t) { + t[t.DIRECTIONAL = 0] = "DIRECTIONAL"; + t[t.SPHERE = 1] = "SPHERE"; + t[t.SPOT = 2] = "SPOT"; + t[t.UNKNOWN = 3] = "UNKNOWN"; + }(uw || (uw = {})); + const _w = cw.prototype; + _w._createBatcher2D = function() { + if (!this._batcher && m.internal.Batcher2D) { + this._batcher = new m.internal.Batcher2D(this); + if (!this._batcher.initialize()) { + this._batcher = null; + this.destroy(); + return; + } + this._batcher._nativeObj = this.getBatcher2D(); + } + }; + Object.defineProperty(_w, "batcher2D", { + configurable: !0, + enumerable: !0, + get() { + return this._batcher; + } + }); + Object.defineProperty(_w, "dataPoolManager", { + configurable: !0, + enumerable: !0, + get() { + return this._dataPoolMgr; + } + }); + Object.defineProperty(_w, "pipelineEvent", { + configurable: !0, + enumerable: !0, + get() { + return this._pipelineEvent; + } + }); + Object.defineProperty(_w, "debugView", { + configurable: !0, + enumerable: !0, + get() { + return this._debugView; + } + }); + class dw { + on(t, e, i, s) {} + once(t, e, i) {} + off(t, e, i) {} + emit(t, e, i, s, n, r) {} + targetOff(t) {} + removeAll(t) {} + hasEventListener(t, e, i) { + return !1; + } + } + _w._ctor = function(t) { + this._device = t; + this._dataPoolMgr = m.internal.DataPoolManager && new m.internal.DataPoolManager(t); + this._modelPools = new Map; + this._lightPools = new Map; + this._batcher = null; + this._pipelineEvent = new dw; + this._debugView = new Ng; + this.setDebugViewConfig(this._debugView._nativeConfig); + this._registerListeners(); + }; + _w.initialize = function(t) { + var e; + this._initialize(zo.swapchain); + const i = de.querySettings(_e.Category.ANIMATION, "customJointTextureLayouts") || []; + null === (e = this._dataPoolMgr) || void 0 === e || e.jointTexturePool.registerCustomTextureLayouts(i); + }; + _w.createModel = function(t) { + let e = this._modelPools.get(t); + if (!e) { + this._modelPools.set(t, new $r((() => new t), 10, (t => t.destroy()))); + e = this._modelPools.get(t); + } + const i = e.alloc(); + i.initialize(); + return i; + }; + _w.removeModel = function(t) { + const e = this._modelPools.get(t.constructor); + if (e) { + e.free(t); + t.destroy(); + t.scene && t.scene.removeModel(t); + } else N(1300, t.constructor.name); + }; + _w.createLight = function(t) { + let e = this._lightPools.get(t); + if (!e) { + this._lightPools.set(t, new $r((() => new t), 4, (t => t.destroy()))); + e = this._lightPools.get(t); + } + const i = e.alloc(); + i.initialize(); + return i; + }; + _w.destroyLight = function(t) { + if (t.scene) switch (t.type) { + case uw.DIRECTIONAL: + t.scene.removeDirectionalLight(t); + break; + + case uw.SPHERE: + t.scene.removeSphereLight(t); + break; + + case uw.SPOT: + t.scene.removeSpotLight(t); + } + t.destroy(); + }; + _w.recycleLight = function(t) { + const e = this._lightPools.get(t.constructor); + if (e) { + e.free(t); + if (t.scene) switch (t.type) { + case uw.DIRECTIONAL: + t.scene.removeDirectionalLight(t); + break; + + case uw.SPHERE: + t.scene.removeSphereLight(t); + break; + + case uw.SPOT: + t.scene.removeSpotLight(t); + } + } + }; + _w._onDirectorBeforeCommit = function() { + m.director.emit(m.Director.EVENT_BEFORE_COMMIT); + }; + const pw = _w.frameMove; + _w.frameMove = function(t) { + pw.call(this, t, m.director.getTotalFrames()); + }; + const mw = _w.setRenderPipeline; + _w.setRenderPipeline = function(t) { + let e; + if (this.usesCustomPipeline) { + const t = mw.call(this, null); + const e = this.customPipeline; + this.useDeferredPipeline ? hw(e) : function(t) { + const e = new sw; + { + const t = e.addGlobal("default", !0, !0, !0, !0, !0, !0, !0); + e.mergeDescriptors(t); + } + const i = t.layoutGraphBuilder; + i.clear(); + ow(e.layoutGraph, i); + }(e); + e.layoutGraphBuilder.compile(); + return t; + } + t || (t = new nr.ForwardPipeline).init(); + e = mw.call(this, t); + this._createBatcher2D(); + return e; + }; + _w.addBatch = function(t) { + console.error("The Draw Batch class is implemented differently in the native platform and does not support this interface."); + }; + _w.removeBatch = function(t) { + console.error("The Draw Batch class is implemented differently in the native platform and does not support this interface."); + }; + _w.removeBatches = function() { + console.error("The Draw Batch class is implemented differently in the native platform and does not support this interface."); + }; + class fw { + constructor() { + this._rafHandle = 0; + this._onTick = null; + this._targetFrameRate = 60; + this._isPlaying = !1; + this._updateCallback = void 0; + this._updateCallback = () => { + this._isPlaying && (this._rafHandle = requestAnimationFrame(this._updateCallback)); + this._onTick && this._onTick(); + }; + } + get targetFrameRate() { + return this._targetFrameRate; + } + set targetFrameRate(t) { + if (this._targetFrameRate !== t) { + ne(t > 0); + this._targetFrameRate = t; + jsb.setPreferredFramesPerSecond(this._targetFrameRate); + if (this._isPlaying) { + this.stop(); + this.start(); + } + } + } + set onTick(t) { + this._onTick = t; + } + get onTick() { + return this._onTick; + } + start() { + if (!this._isPlaying) { + this._rafHandle = requestAnimationFrame(this._updateCallback); + this._isPlaying = !0; + } + } + stop() { + if (this._isPlaying) { + cancelAnimationFrame(this._rafHandle); + this._rafHandle = 0; + this._isPlaying = !1; + } + } + } + class gw { + constructor() { + this.name = ""; + this.base = ""; + this.importBase = ""; + this.nativeBase = ""; + this.deps = null; + this.assetInfos = new Rh; + this.scenes = new Rh; + this.paths = new Rh; + } + init(t) { + (t => { + let e = t.uuids; + const i = t.paths; + const s = t.types; + const n = t.deps; + const r = t.paths = Object.create(null); + if (!1 === t.debug) { + for (let t = 0, i = e.length; t < i; t++) e[t] = Wh(e[t]); + for (const t in i) { + const e = i[t]; + const n = e[1]; + e[1] = s[n]; + } + } else { + const t = Object.create(null); + for (let i = 0, s = e.length; i < s; i++) { + const s = e[i]; + e[i] = t[s] = Wh(s); + } + e = t; + } + for (const t in i) { + const s = i[t]; + r[e[t]] = s; + } + const o = t.scenes; + for (const t in o) { + const i = o[t]; + o[t] = e[i]; + } + const a = t.packs; + for (const t in a) { + const i = a[t]; + for (let t = 0; t < i.length; ++t) i[t] = e[i[t]]; + } + const l = t.versions; + if (l) for (const t in l) { + const i = l[t]; + for (let t = 0; t < i.length; t += 2) { + const s = i[t]; + i[t] = e[s] || s; + } + } + const h = t.redirect; + if (h) for (let t = 0; t < h.length; t += 2) { + h[t] = e[h[t]]; + h[t + 1] = n[h[t + 1]]; + } + if (t.extensionMap) for (const i in t.extensionMap) Object.prototype.hasOwnProperty.call(t.extensionMap, i) && t.extensionMap[i].forEach(((s, n) => { + t.extensionMap[i][n] = e[s] || s; + })); + })(t); + this.importBase = t.importBase || ""; + this.nativeBase = t.nativeBase || ""; + this.base = t.base || ""; + this.name = t.name || ""; + this.deps = t.deps || []; + this._initUuid(t.uuids); + this._initPath(t.paths); + this._initScene(t.scenes); + this._initPackage(t.packs); + this._initVersion(t.versions); + this._initRedirect(t.redirect); + for (const e in t.extensionMap) Object.prototype.hasOwnProperty.call(t.extensionMap, e) && t.extensionMap[e].forEach((t => { + const i = this.assetInfos.get(t); + i && (i.extension = e); + })); + } + getInfoWithPath(t, e) { + if (!t) return null; + t = Zh(t); + const i = this.paths.get(t); + if (i) { + if (!e) return i[0]; + for (let t = 0, s = i.length; t < s; t++) { + const s = i[t]; + if (ee.isChildClassOf(s.ctor, e)) return s; + } + } + return null; + } + getDirWithPath(t, e, i) { + "/" === (t = Zh(t))[t.length - 1] && (t = t.slice(0, -1)); + const s = i || []; + this.paths.forEach(((i, n) => { + if (n.startsWith(t) && ((t, e) => { + if (t.length > e.length) return 47 === t.charCodeAt(e.length); + return !0; + })(n, t) || !t) for (let t = 0, n = i.length; t < n; t++) { + const n = i[t]; + e && !ee.isChildClassOf(n.ctor, e) || s.push(n); + } + })); + return s; + } + getAssetInfo(t) { + return this.assetInfos.get(t) || null; + } + getSceneInfo(t) { + t.endsWith(".scene") || (t += ".scene"); + "/" === t[0] || t.startsWith("db://") || (t = `/${t}`); + const e = this.scenes.find(((e, i) => i.endsWith(t))); + return e; + } + destroy() { + this.paths.destroy(); + this.scenes.destroy(); + this.assetInfos.destroy(); + } + _initUuid(t) { + if (t) { + this.assetInfos.clear(); + for (let e = 0, i = t.length; e < i; e++) { + const i = t[e]; + this.assetInfos.add(i, { + uuid: i + }); + } + } + } + _initPath(t) { + if (!t) return; + const e = this.paths; + e.clear(); + for (const i in t) { + const s = t[i]; + const n = s[0]; + const r = s[1]; + const o = 3 === s.length; + const a = this.assetInfos.get(i); + a.path = n; + a.ctor = ee.getClassById(r); + e.has(n) ? o ? e.get(n).push(a) : e.get(n).unshift(a) : e.add(n, [ a ]); + } + } + _initScene(t) { + if (!t) return; + const e = this.scenes; + e.clear(); + const i = this.assetInfos; + for (const s in t) { + const n = t[s]; + const r = i.get(n); + r.url = s; + e.add(s, r); + } + } + _initPackage(t) { + if (!t) return; + const e = this.assetInfos; + for (const i in t) { + const s = t[i]; + const n = { + uuid: i, + packedUuids: s, + ext: ".json" + }; + e.add(i, n); + for (let t = 0, i = s.length; t < i; t++) { + const r = s[t]; + const o = e.get(r); + const a = o.packs; + a ? 1 === i ? a.unshift(n) : a.push(n) : o.packs = [ n ]; + } + } + } + _initVersion(t) { + if (!t) return; + const e = this.assetInfos; + let i = t.import; + if (i) for (let t = 0, s = i.length; t < s; t += 2) { + const s = i[t]; + e.get(s).ver = i[t + 1]; + } + i = t.native; + if (i) for (let t = 0, s = i.length; t < s; t += 2) { + const s = i[t]; + e.get(s).nativeVer = i[t + 1]; + } + } + _initRedirect(t) { + if (!t) return; + const e = this.assetInfos; + for (let i = 0, s = t.length; i < s; i += 2) { + const s = t[i]; + e.get(s).redirect = t[i + 1]; + } + } + } + function yw(t, e) { + t._uuid && e.push(t._uuid); + } + function bw(t, e) { + const i = Object.getOwnPropertyNames(t); + for (let s = 0; s < i.length; s++) { + const n = i[s]; + if ("node" === n || "__eventTargets" === n) continue; + const r = t[n]; + if ("object" == typeof r && r) if (Array.isArray(r)) for (let t = 0; t < r.length; t++) { + const i = r[t]; + i instanceof gc && yw(i, e); + } else if (r.constructor && r.constructor !== Object) r instanceof gc && yw(r, e); else { + const t = Object.getOwnPropertyNames(r); + for (let i = 0; i < t.length; i++) { + const s = r[t[i]]; + s instanceof gc && yw(s, e); + } + } + } + } + function Sw(t, e) { + for (let i = 0; i < t._components.length; i++) bw(t._components[i], e); + for (let i = 0; i < t._children.length; i++) Sw(t._children[i], e); + } + function Aw(t, e, i, s) { + i.push(t._uuid); + const n = pA.getDeps(t._uuid); + for (let t = 0, r = n.length; t < r; t++) { + const r = Mh.get(n[t]); + if (!r) continue; + const o = r._uuid; + o in e ? e[o] += s : e[o] = r.refCount + s; + i.includes(o) || Aw(r, e, i, s); + } + } + const Tw = []; + var vw = new class { + constructor() { + this._persistNodeDeps = new Rh; + this._toDelete = new Rh; + this._eventListener = !1; + this._dontDestroyAssets = []; + } + addIgnoredAsset(t) { + this._dontDestroyAssets.push(t._uuid); + } + init() { + this._persistNodeDeps.clear(); + this._toDelete.clear(); + } + _addPersistNodeRef(t) { + const e = []; + Sw(t, e); + for (let t = 0, i = e.length; t < i; t++) { + const i = Mh.get(e[t]); + i && i.addRef(); + } + this._persistNodeDeps.add(t.uuid, e); + } + _removePersistNodeRef(t) { + if (!this._persistNodeDeps.has(t.uuid)) return; + const e = this._persistNodeDeps.get(t.uuid); + for (let t = 0, i = e.length; t < i; t++) { + const i = Mh.get(e[t]); + i && i.decRef(); + } + this._persistNodeDeps.remove(t.uuid); + } + _autoRelease(t, e, i) { + if (t) { + const i = pA.getDeps(t.uuid); + for (let e = 0, s = i.length; e < s; e++) { + const s = Mh.get(i[e]); + s && s.decRef(t.autoReleaseAssets); + } + const s = pA._depends.get(t.uuid); + if (s && s.persistDeps) { + const e = s.persistDeps; + for (let i = 0, s = e.length; i < s; i++) { + const s = Mh.get(e[i]); + s && s.decRef(t.autoReleaseAssets); + } + } + t.uuid !== e.uuid && pA.remove(t.uuid); + } + const s = pA._depends.get(e.uuid); + s && (s.persistDeps = []); + for (const t in i) { + const e = i[t]; + const n = this._persistNodeDeps.get(e.uuid); + for (const t of n) { + const e = Mh.get(t); + e && e.addRef(); + } + s && s.persistDeps.push(...n); + } + } + tryRelease(t, e = !1) { + if (t instanceof gc) if (e) this._free(t, e); else { + this._toDelete.add(t._uuid, t); + if (!this._eventListener) { + this._eventListener = !0; + Te(this._freeAssets.bind(this)); + } + } + } + _freeAssets() { + this._eventListener = !1; + this._toDelete.forEach((t => { + this._free(t); + })); + this._toDelete.clear(); + } + _free(t, e = !1) { + const i = t._uuid; + this._toDelete.remove(i); + if (!po(t, !0) || -1 !== this._dontDestroyAssets.indexOf(i)) return; + if (!e && t.refCount > 0 && function(t) { + const e = Object.create(null); + e[t._uuid] = t.refCount; + Aw(t, e, Tw, -1); + Tw.length = 0; + if (0 !== e[t._uuid]) return e[t._uuid]; + for (const t in e) 0 !== e[t] && Aw(Mh.get(t), e, Tw, 1); + Tw.length = 0; + return e[t._uuid]; + }(t) > 0) return; + Mh.remove(i); + const s = pA.getDeps(i); + for (let t = 0, e = s.length; t < e; t++) { + const e = Mh.get(s[t]); + if (e) { + e.decRef(!1); + this._free(e, !1); + } + } + t.destroy(); + pA.remove(i); + } + }; + let Ew = null; + function Cw(t, e) { + for (let i = 0, s = t.input.length; i < s; i++) { + const s = t.input[i]; + e && !s.isNative && s.content instanceof gc && s.content.decRef(!1); + s.recycle(); + } + t.input = null; + } + function xw(t, e) { + return e ? /\?/.test(t) ? `${t}&_t=${Date.now()}` : `${t}?_t=${Date.now()}` : t; + } + function ww(t, e, i, s, n = 0) { + t(n, ((r, o) => { + n++; + !r || n > e ? s && s(r, o) : setTimeout((() => { + ww(t, e, i, s, n); + }), i); + })); + } + function Rw(t, e, i, s, n) { + try { + const r = pA.parse(t, e); + for (let t = 0, e = r.deps.length; t < e; t++) { + const e = r.deps[t]; + if (!(e in i)) { + i[e] = !0; + s.push({ + uuid: e, + bundle: n && n.name + }); + } + } + if (r.nativeDep) { + n && (r.nativeDep.bundle = n.name); + s.push({ + ...r.nativeDep + }); + } + } catch (t) { + x(t.message, t.stack); + } + } + function Iw(t, e, i) { + if (e) { + i = void 0 !== i ? i : m.assetManager.cacheAsset; + Jh(e) || !i || e.isDefault || Mh.add(t, e); + } + } + function Mw(t, e, i) { + let s = 0; + const n = []; + const r = t.length; + 0 === r && i && i(n); + const o = t => { + t && n.push(t); + s++; + s === r && i && i(n); + }; + for (let i = 0; i < r; i++) e(t[i], o); + } + function Bw(t, e, i) { + let s = t; + let n = e; + let r = i; + if (void 0 === i) { + const i = "function" == typeof t; + if (e) { + r = e; + i || (n = null); + } else if (void 0 === e && i) { + r = t; + s = null; + n = null; + } + if (void 0 !== e && i) { + n = t; + s = null; + } + } + return { + options: s || Object.create(null), + onProgress: n, + onComplete: r + }; + } + function Dw(t, e, i) { + let s = t; + let n = e; + let r = i; + if (void 0 === i) { + const i = ee.isChildClassOf(t, gc); + if (e) { + r = e; + i && (n = null); + } else if (void 0 === e && !i) { + r = t; + n = null; + s = null; + } + if (void 0 !== e && !i) { + n = t; + s = null; + } + } + return { + type: s, + onProgress: n || Ew, + onComplete: r + }; + } + function Pw(t, e, i, s = {}) { + if (!i[e] || s[e]) return !1; + s[e] = !0; + let n = !1; + const r = pA.getDeps(e); + if (r) for (let e = 0, o = r.length; e < o; e++) { + const o = r[e]; + if (o === t || Pw(t, o, i, s)) { + n = !0; + break; + } + } + return n; + } + function Ow(t) { + return (e, i) => { + if (!t) return; + const s = []; + Array.isArray(i) ? i.forEach((t => t instanceof gc && s.push(t.addRef()))) : i instanceof gc && s.push(i.addRef()); + Te((() => { + s.forEach((t => t.decRef(!1))); + t(e, i); + })); + }; + } + class Nw { + constructor() { + this._config = new gw; + } + get config() { + return this._config; + } + get name() { + return this._config.name; + } + get deps() { + return this._config.deps; + } + get base() { + return this._config.base; + } + getInfoWithPath(t, e) { + return this._config.getInfoWithPath(t, e); + } + getDirWithPath(t, e, i) { + return this._config.getDirWithPath(t, e, i); + } + getAssetInfo(t) { + return this._config.getAssetInfo(t); + } + getSceneInfo(t) { + return this._config.getSceneInfo(t); + } + init(t) { + this._config.init(t); + Ph.add(t.name, this); + } + load(t, e, i, s) { + const {type: n, onProgress: r, onComplete: o} = Dw(e, i, s); + const a = { + __requestType__: Vh.PATH, + type: n, + bundle: this.name, + __outputAsArray__: Array.isArray(t) + }; + m.assetManager.loadAny(t, a, r, o); + } + preload(t, e, i, s) { + const {type: n, onProgress: r, onComplete: o} = Dw(e, i, s); + m.assetManager.preloadAny(t, { + __requestType__: Vh.PATH, + type: n, + bundle: this.name + }, r, o); + } + loadDir(t, e, i, s) { + const {type: n, onProgress: r, onComplete: o} = Dw(e, i, s); + m.assetManager.loadAny(t, { + __requestType__: Vh.DIR, + type: n, + bundle: this.name, + __outputAsArray__: !0 + }, r, o); + } + preloadDir(t, e, i, s) { + const {type: n, onProgress: r, onComplete: o} = Dw(e, i, s); + m.assetManager.preloadAny(t, { + __requestType__: Vh.DIR, + type: n, + bundle: this.name + }, r, o); + } + loadScene(t, e, i, s) { + const {options: n, onProgress: r, onComplete: o} = Bw(e, i, s); + n.preset = n.preset || "scene"; + n.bundle = this.name; + m.assetManager.loadAny({ + scene: t + }, n, r, ((t, e) => { + if (t) x(t.message, t.stack); else if (e.scene) { + const t = e.scene; + t._id = e._uuid; + t.name = e.name; + } else t = new Error(`The asset ${e._uuid} is not a scene`); + o && o(t, e); + })); + } + preloadScene(t, e, i, s) { + const {options: n, onProgress: r, onComplete: o} = Bw(e, i, s); + n.bundle = this.name; + m.assetManager.preloadAny({ + scene: t + }, n, r, (e => { + e && F(1210, t, e.message); + o && o(e); + })); + } + get(t, e) { + const i = this.getInfoWithPath(t, e); + return i && Mh.get(i.uuid) || null; + } + release(t, e) { + const i = this.get(t, e); + i && vw.tryRelease(i, !0); + } + releaseUnusedAssets() { + Mh.forEach((t => { + const e = this.getAssetInfo(t._uuid); + e && !e.redirect && vw.tryRelease(t); + })); + } + releaseAll() { + Mh.forEach((t => { + const e = this.getAssetInfo(t._uuid); + e && !e.redirect && vw.tryRelease(t, !0); + })); + } + _destroy() { + this._config.destroy(); + } + } + const Lw = t("resources", new Nw); + m.resources = Lw; + function Fw(t, e, i) { + const s = new Image; + "file:" !== window.location.protocol && (s.crossOrigin = "anonymous"); + function n() { + s.removeEventListener("load", n); + s.removeEventListener("error", r); + i && i(null, s); + } + function r() { + s.removeEventListener("load", n); + s.removeEventListener("error", r); + i && i(new Error(G(4930, t))); + } + s.addEventListener("load", n); + s.addEventListener("error", r); + s.src = t; + return s; + } + function Vw(t, e, i, s) { + const n = new XMLHttpRequest; + const r = `download failed: ${t}, status: `; + n.open("GET", t, !0); + void 0 !== e.xhrResponseType && (n.responseType = e.xhrResponseType); + void 0 !== e.xhrWithCredentials && (n.withCredentials = e.xhrWithCredentials); + void 0 !== e.xhrMimeType && n.overrideMimeType && n.overrideMimeType(e.xhrMimeType); + void 0 !== e.xhrTimeout && (n.timeout = e.xhrTimeout); + if (e.xhrHeader) for (const t in e.xhrHeader) n.setRequestHeader(t, e.xhrHeader[t]); + n.onload = () => { + 200 === n.status || 0 === n.status ? s && s(null, n.response) : s && s(new Error(`${r}${n.status}(no response)`)); + }; + i && (n.onprogress = t => { + t.lengthComputable && i(t.loaded, t.total); + }); + n.onerror = () => { + s && s(new Error(`${r}${n.status}(error)`)); + }; + n.ontimeout = () => { + s && s(new Error(`${r}${n.status}(time out)`)); + }; + n.onabort = () => { + s && s(new Error(`${r}${n.status}(abort)`)); + }; + n.send(null); + return n; + } + const kw = {}; + function Uw(t, e, i) { + if (kw[t]) { + i && i(null); + return null; + } + const s = document.createElement("script"); + "file:" !== window.location.protocol && (s.crossOrigin = "anonymous"); + s.async = e.scriptAsyncLoading || !1; + s.src = t; + function n() { + s.parentNode.removeChild(s); + s.removeEventListener("load", n, !1); + s.removeEventListener("error", r, !1); + kw[t] = !0; + i && i(null); + } + function r() { + s.parentNode.removeChild(s); + s.removeEventListener("load", n, !1); + s.removeEventListener("error", r, !1); + i && i(new Error(G(4928, t))); + } + s.addEventListener("load", n, !1); + s.addEventListener("error", r, !1); + document.body.appendChild(s); + return s; + } + const Gw = /^(?:\w+:\/\/|\.+\/).+/; + const zw = (t, e, i) => { + (Vo.hasFeature(Vo.Feature.IMAGE_BITMAP) && m.assetManager.allowImageBitmap ? Hw : Fw)(t, e, i); + }; + const Hw = (t, e, i) => { + e.xhrResponseType = "blob"; + Vw(t, e, e.onFileProgress, i); + }; + const jw = (t, e, i) => { + e.xhrResponseType = "json"; + Vw(t, e, e.onFileProgress, i); + }; + const Xw = (t, e, i) => { + e.xhrResponseType = "arraybuffer"; + Vw(t, e, e.onFileProgress, i); + }; + const Ww = (t, e, i) => { + jw(t, e, ((e, s) => { + if (e) { + i(e); + return; + } + const n = au(s); + Promise.all(n.chunks.map((i => new Promise(((s, n) => { + Xw(`${rc(t)}${i}`, {}, ((t, i) => { + e ? n(e) : s(new Uint8Array(i)); + })); + }))))).then((t => { + const e = new ou(n.document, t); + i(null, e); + })).catch((t => { + i(t); + })); + })); + }; + const Yw = (t, e, i) => { + Xw(t, e, ((t, e) => { + if (t) i(t); else try { + const t = lu(new Uint8Array(e)); + i(null, t); + } catch (t) { + i(t); + } + })); + }; + const qw = (t, e, i) => { + e.xhrResponseType = "text"; + Vw(t, e, e.onFileProgress, i); + }; + const Kw = (t, e, i) => { + const s = oc(t); + let n = t; + Gw.test(n) || (n = -1 !== Jw.remoteBundles.indexOf(s) ? `${Jw.remoteServerAddress}remote/${s}` : `assets/${s}`); + const r = e.version || Jw.bundleVers[s]; + let o = 0; + let a = null; + let l = null; + jw(`${n}/config.${r ? `${r}.` : ""}json`, e, ((t, e) => { + l = t; + a = e; + a && (a.base = `${n}/`); + 2 == ++o && i(l, a); + })); + Uw(`${n}/index.${r ? `${r}.` : ""}js`, e, (t => { + l = t; + 2 == ++o && i(t, a); + })); + }; + const Jw = new class { + constructor() { + this.maxConcurrency = 6; + this.maxRequestsPerFrame = 6; + this.maxRetryCount = 3; + this.appendTimeStamp = !1; + this.limited = !0; + this.retryInterval = 2e3; + this.bundleVers = null; + this.remoteBundles = []; + this.downloadDomImage = Fw; + this.downloadDomAudio = null; + this.downloadFile = Vw; + this.downloadScript = Uw; + this._downloaders = { + ".png": zw, + ".jpg": zw, + ".bmp": zw, + ".jpeg": zw, + ".gif": zw, + ".ico": zw, + ".tiff": zw, + ".webp": zw, + ".image": zw, + ".pvr": Xw, + ".pkm": Xw, + ".astc": Xw, + ".txt": qw, + ".xml": qw, + ".vsh": qw, + ".fsh": qw, + ".atlas": qw, + ".tmx": qw, + ".tsx": qw, + ".json": jw, + ".ExportJson": jw, + ".plist": qw, + ".ccon": Ww, + ".cconb": Yw, + ".fnt": qw, + ".binary": Xw, + ".bin": Xw, + ".dbbin": Xw, + ".skel": Xw, + ".js": Uw, + bundle: Kw, + default: qw + }; + this._downloading = new Rh; + this._queue = []; + this._queueDirty = !1; + this._totalNum = 0; + this._totalNumThisPeriod = 0; + this._lastDate = -1; + this._checkNextPeriod = !1; + this._remoteServerAddress = ""; + this._maxInterval = 1 / 30; + } + get remoteServerAddress() { + return this._remoteServerAddress; + } + init(t = "", e = {}, i = []) { + this._downloading.clear(); + this._queue.length = 0; + this._remoteServerAddress = t; + this.bundleVers = e; + this.remoteBundles = i; + } + register(t, e) { + "object" == typeof t ? ee.mixin(this._downloaders, t) : this._downloaders[t] = e; + } + download(t, e, i, s, n) { + const r = Bh.get(t); + if (r) { + n(null, r); + return; + } + const o = this._downloading.get(t); + if (o) { + o.push(n); + const e = this._queue.find((e => e.id === t)); + if (!e) return; + const i = s.priority || 0; + if (e.priority < i) { + e.priority = i; + this._queueDirty = !0; + } + return; + } + const a = void 0 !== s.maxRetryCount ? s.maxRetryCount : this.maxRetryCount; + const l = void 0 !== s.maxConcurrency ? s.maxConcurrency : this.maxConcurrency; + const h = void 0 !== s.maxRequestsPerFrame ? s.maxRequestsPerFrame : this.maxRequestsPerFrame; + const c = this._downloaders[i] || this._downloaders.default; + ww(((i, r) => { + 0 === i && this._downloading.add(t, [ n ]); + if (!this.limited) { + c(xw(e, this.appendTimeStamp), s, r); + return; + } + this._updateTime(); + const o = (t, e) => { + this._totalNum--; + this._handleQueueInNextFrame(l, h); + r(t, e); + }; + if (this._totalNum < l && this._totalNumThisPeriod < h) { + c(xw(e, this.appendTimeStamp), s, o); + this._totalNum++; + this._totalNumThisPeriod++; + } else { + this._queue.push({ + id: t, + priority: s.priority || 0, + url: e, + options: s, + done: o, + handler: c + }); + this._queueDirty = !0; + this._totalNum < l && this._handleQueueInNextFrame(l, h); + } + }), a, this.retryInterval, ((e, i) => { + e || Bh.add(t, i); + const s = this._downloading.remove(t); + for (let t = 0, n = s.length; t < n; t++) s[t](e, i); + })); + } + loadSubpackage(t, e) { + m.assetManager.loadBundle(t, null, e); + } + _updateTime() { + const t = performance.now(); + const e = m.game.deltaTime; + const i = e > this._maxInterval ? this._maxInterval : e; + if (t - this._lastDate > 1e3 * i) { + this._totalNumThisPeriod = 0; + this._lastDate = t; + } + } + _handleQueue(t, e) { + this._checkNextPeriod = !1; + this._updateTime(); + for (;this._queue.length > 0 && this._totalNum < t && this._totalNumThisPeriod < e; ) { + if (this._queueDirty) { + this._queue.sort(((t, e) => t.priority - e.priority)); + this._queueDirty = !1; + } + const t = this._queue.pop(); + if (!t) break; + this._totalNum++; + this._totalNumThisPeriod++; + t.handler(xw(t.url, this.appendTimeStamp), t.options, t.done); + } + this._handleQueueInNextFrame(t, e); + } + _handleQueueInNextFrame(t, e) { + if (!this._checkNextPeriod && this._queue.length > 0) { + Te(this._handleQueue.bind(this), t, e); + this._checkNextPeriod = !0; + } + } + }; + function Zw(t, e, i, s) { + let n = null; + let r = null; + try { + n = new IC; + n._nativeUrl = t; + n._nativeAsset = e; + } catch (t) { + r = t; + } + s(r, n); + } + function Qw(t, e, i, s) { + const n = new RC; + n.json = e; + s(null, n); + } + function $w(t, e, i, s) { + const n = new EC; + n.text = e; + s(null, n); + } + function tR(t, e, i, s) { + const n = new Ug; + n._nativeUrl = t; + n._nativeAsset = e; + s(null, n); + } + function eR(t, e, i, s) { + const n = new gc; + n._nativeUrl = t; + n._nativeAsset = e; + s(null, n); + } + function iR(t, i, s, n) { + let r = Ph.get(i.name); + if (!r) { + r = i.name === Uh.RESOURCES ? Lw : new Nw; + i.base = i.base || `${t}/`; + r.init(i); + } + e.import(`virtual:///prerequisite-imports/${r.name}`).then((() => { + n(null, r); + })).catch(n); + } + var sR = new class { + constructor() { + this._creating = new Rh; + this._producers = { + ".png": Zw, + ".jpg": Zw, + ".bmp": Zw, + ".jpeg": Zw, + ".gif": Zw, + ".ico": Zw, + ".tiff": Zw, + ".webp": Zw, + ".image": Zw, + ".pvr": Zw, + ".pkm": Zw, + ".txt": $w, + ".xml": $w, + ".vsh": $w, + ".fsh": $w, + ".atlas": $w, + ".tmx": $w, + ".tsx": $w, + ".fnt": $w, + ".json": Qw, + ".ExportJson": Qw, + ".binary": tR, + ".bin": tR, + ".dbbin": tR, + ".skel": tR, + bundle: iR, + default: eR + }; + } + register(t, e) { + "object" == typeof t ? ee.mixin(this._producers, t) : this._producers[t] = e; + } + create(t, e, i, s, n) { + const r = this._producers[i] || this._producers.default; + const o = Mh.get(t); + if (!s.reloadAsset && o) { + n(null, o); + return; + } + const a = this._creating.get(t); + if (a) a.push(n); else { + this._creating.add(t, [ n ]); + r(t, e, s, ((e, i) => { + if (!e && i instanceof gc) { + i._uuid = t; + Iw(t, i, s.cacheAsset); + } + const n = this._creating.remove(t); + for (let t = 0, s = n.length; t < s; t++) n[t](e, i); + })); + } + } + }; + var nR = new class { + constructor() { + this._loading = new Rh; + this._unpackers = { + ".json": this.unpackJson + }; + } + unpackJson(t, e, i, s) { + let n = ee.createMap(!0); + let r = null; + if (Array.isArray(e)) { + e = function(t, e, i) { + if (t[Nu] < 1) throw new Error(G(5304, t[Nu])); + n_(t, !0, e, null != i ? i : o_.reportMissingClass); + r_(t); + const s = new a_(t[Nu]); + const n = t[Fu]; + const r = t[Vu]; + const o = t[ku]; + const a = t[Uu]; + const l = t[Yu]; + for (let t = 0; t < l.length; ++t) l[t].unshift(s, n, r, o, a); + return l; + }(e); + e.length !== t.length && F(4915); + for (let i = 0; i < t.length; i++) n[`${t[i]}@import`] = e[i]; + } else { + const i = ee.getClassId(LC); + const s = ee.getClassId(IC); + if (e.type === i && e.data) { + const s = e.data; + s.length !== t.length && F(4915); + for (let e = 0; e < t.length; e++) n[`${t[e]}@import`] = l_(i, { + base: s[e][0], + mipmaps: s[e][1] + }); + } else if (e.type === s && e.data) { + const i = e.data; + i.length !== t.length && F(4915); + for (let e = 0; e < t.length; e++) n[`${t[e]}@import`] = i[e]; + } else { + r = new Error("unmatched type pack!"); + n = null; + } + } + s(r, n); + } + init() { + this._loading.clear(); + } + register(t, e) { + "object" == typeof t ? ee.mixin(this._unpackers, t) : this._unpackers[t] = e; + } + unpack(t, e, i, s, n) { + if (!e) { + n(new Error("package data is wrong!")); + return; + } + (0, this._unpackers[i])(t, e, s, n); + } + load(t, e, i) { + if (t.isNative || !t.info || !t.info.packs) { + Jw.download(t.id, t.url, t.ext, t.options, i); + return; + } + if (Bh.has(t.id)) { + i(null, Bh.get(t.id)); + return; + } + const s = t.info.packs; + let n = s.find((t => this._loading.has(t.uuid))); + if (n) { + this._loading.get(n.uuid).push({ + onComplete: i, + id: t.id + }); + return; + } + n = s[0]; + this._loading.add(n.uuid, [ { + onComplete: i, + id: t.id + } ]); + const r = Qh(n.uuid, { + ext: n.ext, + bundle: t.config.name + }); + Jw.download(n.uuid, r, n.ext, t.options, ((e, i) => { + Bh.remove(n.uuid); + e && x(e.message, e.stack); + this.unpack(n.packedUuids, i, n.ext, t.options, ((t, i) => { + if (!t) for (const t in i) Bh.add(t, i[t]); + const s = this._loading.remove(n.uuid); + for (let n = 0, r = s.length; n < r; n++) { + const r = s[n]; + if (e || t) { + r.onComplete(e || t); + continue; + } + const o = i[r.id]; + o ? r.onComplete(null, o) : r.onComplete(new Error("can not retrieve data from package")); + } + })); + })); + } + }; + function rR(t, e) { + let i = !1; + if (!t.progress) { + t.progress = { + finish: 0, + total: t.input.length, + canInvoke: !0 + }; + i = !0; + } + const {options: s, progress: n} = t; + const r = []; + const o = n.total; + const a = s.__exclude__ = s.__exclude__ || Object.create(null); + t.output = []; + Mw(t.input, ((s, l) => { + if (s.isNative || !Mh.has(s.uuid)) nR.load(s, t.options, ((h, c) => { + if (h) { + if (!t.isFinish) if (!m.assetManager.force || i) { + x(h.message, h.stack); + n.canInvoke = !1; + e(h); + } else { + t.output.push(s); + n.canInvoke && t.dispatch("progress", ++n.finish, n.total, s); + } + } else if (!t.isFinish) { + s.file = c; + t.output.push(s); + if (!s.isNative) { + a[s.uuid] = !0; + Rw(s.uuid, c, a, r, s.config); + n.total = o + r.length; + } + n.canInvoke && t.dispatch("progress", ++n.finish, n.total, s); + } + l(); + })); else { + const e = Mh.get(s.uuid); + s.content = e.addRef(); + t.output.push(s); + n.canInvoke && t.dispatch("progress", ++n.finish, n.total, s); + l(); + } + }), (() => { + if (t.isFinish) { + Cw(t, !0); + t.dispatch("error"); + } else if (r.length > 0) { + const o = Gh.create({ + input: r, + progress: n, + options: s, + onProgress: t.onProgress, + onError: Gh.prototype.recycle, + onComplete: s => { + if (!s) { + t.output.push(...o.output); + o.recycle(); + } + i && oR(t); + e(s); + } + }); + Nh.async(o); + } else { + i && oR(t); + e(); + } + })); + } + function oR(t) { + const e = t.output; + for (let t = 0, i = e.length; t < i; t++) e[t].content && e[t].content.decRef(!1); + } + class aR { + constructor() { + this._parser = null; + window.DOMParser && (this._parser = new DOMParser); + } + parse(t) { + return this._parseXML(t); + } + _parseXML(t) { + if (this._parser) return this._parser.parseFromString(t, "text/xml"); + throw new Error("Dom parser is not supported in this platform!"); + } + } + const lR = new class extends aR { + parse(t) { + const e = this._parseXML(t).documentElement; + if ("plist" !== e.tagName) { + N(5100); + return {}; + } + let i = null; + for (let t = 0, s = e.childNodes.length; t < s; t++) { + i = e.childNodes[t]; + if (1 === i.nodeType) break; + } + return this._parseNode(i); + } + _parseNode(t) { + let e = null; + const i = t.tagName; + if ("dict" === i) e = this._parseDict(t); else if ("array" === i) e = this._parseArray(t); else if ("string" === i) if (1 === t.childNodes.length) e = t.firstChild.nodeValue; else { + e = ""; + for (let i = 0; i < t.childNodes.length; i++) e += t.childNodes[i].nodeValue; + } else "false" === i ? e = !1 : "true" === i ? e = !0 : "real" === i ? e = parseFloat(t.firstChild.nodeValue) : "integer" === i && (e = parseInt(t.firstChild.nodeValue, 10)); + return e; + } + _parseArray(t) { + const e = []; + for (let i = 0, s = t.childNodes.length; i < s; i++) { + const s = t.childNodes[i]; + 1 === s.nodeType && e.push(this._parseNode(s)); + } + return e; + } + _parseDict(t) { + const e = {}; + let i = ""; + for (let s = 0, n = t.childNodes.length; s < n; s++) { + const n = t.childNodes[s]; + 1 === n.nodeType && ("key" === n.tagName ? i = n.firstChild.nodeValue : e[i] = this._parseNode(n)); + } + return e; + } + }; + function hR(t, e) { + return t[e] << 8 | t[e + 1]; + } + var cR = new class { + constructor() { + this._parsing = new Rh; + this._parsers = { + ".png": this.parseImage, + ".jpg": this.parseImage, + ".bmp": this.parseImage, + ".jpeg": this.parseImage, + ".gif": this.parseImage, + ".ico": this.parseImage, + ".tiff": this.parseImage, + ".webp": this.parseImage, + ".image": this.parseImage, + ".pvr": this.parsePVRTex, + ".pkm": this.parsePKMTex, + ".astc": this.parseASTCTex, + ".plist": this.parsePlist, + import: this.parseImport, + ".ccon": this.parseImport, + ".cconb": this.parseImport + }; + } + parseImage(t, e, i) { + t instanceof HTMLImageElement ? i(null, t) : createImageBitmap(t, { + premultiplyAlpha: "none" + }).then((t => { + i(null, t); + }), (t => { + i(t, null); + })); + } + parsePVRTex(t, e, i) { + let s = null; + let n = null; + try { + const e = t instanceof ArrayBuffer ? t : t.buffer; + const i = new Int32Array(e, 0, 13); + if (55727696 === i[0]) { + const t = i[7]; + const s = i[6]; + const r = i[12] + 52; + n = { + _data: new Uint8Array(e, r), + _compressed: !0, + width: t, + height: s, + format: 0 + }; + } else { + if (559044176 !== i[11]) throw new Error("Invalid magic number in PVR header"); + { + const t = i[0]; + const s = i[1]; + const r = i[2]; + n = { + _data: new Uint8Array(e, t), + _compressed: !0, + width: r, + height: s, + format: 0 + }; + } + } + } catch (t) { + s = t; + } + i(s, n); + } + parsePKMTex(t, e, i) { + let s = null; + let n = null; + try { + const e = t instanceof ArrayBuffer ? t : t.buffer; + const i = new Uint8Array(e); + const s = hR(i, 6); + if (0 !== s && 1 !== s && 3 !== s) throw new Error("Invalid magic number in ETC header"); + const r = hR(i, 12); + const o = hR(i, 14); + hR(i, 8); + hR(i, 10); + n = { + _data: new Uint8Array(e, 16), + _compressed: !0, + width: r, + height: o, + format: 0 + }; + } catch (t) { + s = t; + } + i(s, n); + } + parseASTCTex(t, e, i) { + let s = null; + let n = null; + try { + const e = t instanceof ArrayBuffer ? t : t.buffer; + const i = new Uint8Array(e); + if (1554098963 !== i[0] + (i[1] << 8) + (i[2] << 16) + (i[3] << 24)) throw new Error("Invalid magic number in ASTC header"); + const s = i[4]; + const r = i[5]; + const o = i[6]; + if ((s < 3 || s > 6 || r < 3 || r > 6 || o < 3 || o > 6) && (s < 4 || 7 === s || 9 === s || 11 === s || s > 12 || r < 4 || 7 === r || 9 === r || 11 === r || r > 12 || 1 !== o)) throw new Error("Invalid block number in ASTC header"); + const a = function(t, e) { + return 4 === t ? Jp.RGBA_ASTC_4x4 : 5 === t ? 4 === e ? Jp.RGBA_ASTC_5x4 : Jp.RGBA_ASTC_5x5 : 6 === t ? 5 === e ? Jp.RGBA_ASTC_6x5 : Jp.RGBA_ASTC_6x6 : 8 === t ? 5 === e ? Jp.RGBA_ASTC_8x5 : 6 === e ? Jp.RGBA_ASTC_8x6 : Jp.RGBA_ASTC_8x8 : 10 === t ? 5 === e ? Jp.RGBA_ASTC_10x5 : 6 === e ? Jp.RGBA_ASTC_10x6 : 8 === e ? Jp.RGBA_ASTC_10x8 : Jp.RGBA_ASTC_10x10 : 10 === e ? Jp.RGBA_ASTC_12x10 : Jp.RGBA_ASTC_12x12; + }(s, r); + const l = i[7] + (i[8] << 8) + (i[9] << 16); + const h = i[10] + (i[11] << 8) + (i[12] << 16); + i[13], i[14], i[15]; + n = { + _data: new Uint8Array(e, 16), + _compressed: !0, + width: l, + height: h, + format: a + }; + } catch (t) { + s = t; + } + i(s, n); + } + parsePlist(t, e, i) { + let s = null; + const n = lR.parse(t); + n || (s = new Error("parse failed")); + i(s, n); + } + parseImport(t, e, i) { + if (!t) { + i(new Error(`The json file of asset ${e.__uuid__} is empty or missing`)); + return; + } + let s = null; + let n = null; + try { + s = dA(t, e); + } catch (t) { + n = t; + } + i(n, s); + } + init() { + this._parsing.clear(); + } + register(t, e) { + "object" == typeof t ? ee.mixin(this._parsers, t) : this._parsers[t] = e; + } + parse(t, e, i, s, n) { + const r = Dh.get(t); + if (r) { + n(null, r); + return; + } + const o = this._parsing.get(t); + if (o) { + o.push(n); + return; + } + const a = this._parsers[i]; + if (a) { + this._parsing.add(t, [ n ]); + a(e, s, ((e, i) => { + e ? Bh.remove(t) : Jh(i) || Dh.add(t, i); + const s = this._parsing.remove(t); + for (let t = 0, n = s.length; t < n; t++) s[t](e, i); + })); + } else n(null, e); + } + }; + function uR(t, e) { + let i = !1; + if (!t.progress) { + t.progress = { + finish: 0, + total: t.input.length, + canInvoke: !0 + }; + i = !0; + } + const {options: s, progress: n} = t; + s.__exclude__ = s.__exclude__ || Object.create(null); + t.output = []; + Mw(t.input, ((r, o) => { + const a = Gh.create({ + input: r, + onProgress: t.onProgress, + options: s, + progress: n, + onComplete: (s, l) => { + if (s && !t.isFinish) if (!m.assetManager.force || i) { + x(s.message, s.stack); + n.canInvoke = !1; + e(s); + } else n.canInvoke && t.dispatch("progress", ++n.finish, n.total, r); + t.output.push(l); + a.recycle(); + o(null); + } + }); + _R.async(a); + }), (() => { + s.__exclude__ = null; + if (t.isFinish) { + Cw(t, !0); + t.dispatch("error"); + } else { + !function(t) { + const e = t.source; + if (t.options.__outputAsArray__ || 1 !== e.length) { + const i = t.output = []; + for (let t = 0, s = e.length; t < s; t++) i.push(e[t].content); + } else t.output = e[0].content; + }(t); + Cw(t, !0); + e(); + } + })); + } + const _R = new Ih("loadOneAsset", [ function(t, e) { + const i = t.output = t.input; + const {options: s, isNative: n, uuid: r, file: o} = i; + const {reloadAsset: a} = s; + o || !a && !n && Mh.has(r) ? e() : nR.load(i, t.options, ((t, s) => { + i.file = s; + e(t); + })); + }, function(t, e) { + const i = t.output = t.input; + const s = t.progress; + const n = t.options.__exclude__; + const {id: r, file: o, options: a} = i; + if (i.isNative) cR.parse(r, o, i.ext, a, ((n, o) => { + if (n) e(n); else { + i.content = o; + s.canInvoke && t.dispatch("progress", ++s.finish, s.total, i); + Bh.remove(r); + Dh.remove(r); + e(); + } + })); else { + const {uuid: l} = i; + if (l in n) { + const {finish: r, content: o, err: a, callbacks: h} = n[l]; + s.canInvoke && t.dispatch("progress", ++s.finish, s.total, i); + if (r || Pw(l, l, n)) { + o && o.addRef(); + i.content = o; + e(a); + } else h.push({ + done: e, + item: i + }); + } else if (!a.reloadAsset && Mh.has(l)) { + const n = Mh.get(l); + i.content = n.addRef(); + s.canInvoke && t.dispatch("progress", ++s.finish, s.total, i); + e(); + } else { + a.__uuid__ = l; + cR.parse(r, o, "import", a, ((i, s) => { + i ? e(i) : function(t, e, i) { + const {input: s, progress: n} = t; + const {uuid: r, id: o, options: a, config: l} = s; + const {cacheAsset: h} = a; + const c = []; + e.addRef && e.addRef(); + Rw(r, e, Object.create(null), c, l); + n.canInvoke && t.dispatch("progress", ++n.finish, n.total += c.length, s); + const u = t.options.__exclude__[r] = { + content: e, + finish: !1, + callbacks: [ { + done: i, + item: s + } ] + }; + const _ = Gh.create({ + input: c, + options: t.options, + onProgress: t.onProgress, + onError: Gh.prototype.recycle, + progress: n, + onComplete: t => { + e.decRef && e.decRef(!1); + u.finish = !0; + u.err = t; + if (!t) { + const t = Array.isArray(_.output) ? _.output : [ _.output ]; + const i = Object.create(null); + for (const e of t) e && (i[e instanceof gc ? `${e._uuid}@import` : `${r}@native`] = e); + !function(t, e, i) { + let s = !1; + const n = cA.get(e); + if (n) { + for (let t = 0, e = n.length; t < e; t++) { + const e = n[t]; + const r = i[`${e.uuid}@import`]; + if (r) e.owner[e.prop] = r.addRef(); else { + x(`The asset ${e.uuid} is missing!`); + if (e.type && e.type !== gc) { + const t = new e.type; + t.initDefault(e.uuid); + e.owner[e.prop] = t; + } + s = !0; + } + } + cA.delete(e); + } + if (uA.has(e)) { + if (i[`${t}@native`]) e._nativeAsset = i[`${t}@native`]; else { + s = !0; + console.error(`the native asset of ${t} is missing!`); + } + uA.delete(e); + } + }(r, e, i); + try { + if ("function" == typeof e.onLoaded && !_A.has(e) && !uA.has(e)) { + e.onLoaded(); + _A.add(e); + } + } catch (t) { + x(`The asset ${r} is invalid for some reason, detail message: ${t.message}, stack: ${t.stack}`); + } + Bh.remove(o); + Dh.remove(o); + Iw(r, e, h); + _.recycle(); + } + const i = u.callbacks; + for (let s = 0, n = i.length; s < n; s++) { + const n = i[s]; + e.addRef && e.addRef(); + n.item.content = e; + n.done(t); + } + i.length = 0; + } + }); + Oh.async(_); + }(t, s, e); + })); + } + } + } ]); + function dR(t, e) { + const i = t.options; + const s = Object.create(null); + const n = Object.create(null); + for (const t in i) switch (t) { + case Vh.PATH: + case Vh.UUID: + case Vh.DIR: + case Vh.SCENE: + case Vh.URL: + break; + + case "__requestType__": + case "__isNative__": + case "ext": + case "type": + case "__nativeName__": + case "audioLoadMode": + case "bundle": + s[t] = i[t]; + break; + + case "__exclude__": + case "__outputAsArray__": + n[t] = i[t]; + break; + + default: + s[t] = i[t]; + n[t] = i[t]; + } + t.options = n; + const r = Gh.create({ + input: t.input, + options: s + }); + let o = null; + try { + t.output = t.source = Lh.sync(r); + } catch (t) { + o = t; + for (let t = 0, e = r.output.length; t < e; t++) r.output[t].recycle(); + } + r.recycle(); + e(o); + } + class pR { + constructor() { + this.uuid = ""; + this.overrideUuid = ""; + this.url = ""; + this.ext = ".json"; + this.content = null; + this.file = null; + this.info = null; + this.config = null; + this.isNative = !1; + this.options = Object.create(null); + this._id = ""; + } + get id() { + this._id || (this._id = `${this.overrideUuid || this.uuid}@${this.isNative ? "native" : "import"}`); + return this._id; + } + static create() { + let t; + t = 0 !== pR._deadPool.length ? pR._deadPool.pop() : new pR; + return t; + } + recycle() { + if (pR._deadPool.length !== pR.MAX_DEAD_NUM) { + this._id = ""; + this.uuid = ""; + this.overrideUuid = ""; + this.url = ""; + this.ext = ".json"; + this.content = null; + this.file = null; + this.info = null; + this.config = null; + this.isNative = !1; + this.options = Object.create(null); + pR._deadPool.push(this); + } + } + } + pR.MAX_DEAD_NUM = 500; + pR._deadPool = []; + const mR = []; + function fR(t) { + var e; + const i = t.options; + const s = Array.isArray(t.input) ? t.input : [ t.input ]; + t.output = []; + for (let r = 0; r < s.length; r++) { + let o = s[r]; + let a = pR.create(); + let l = null; + let h = null; + if ("string" == typeof o) { + o = Object.create(null); + o[i.__requestType__ || Vh.UUID] = s[r]; + } + if ("object" == typeof o) { + ee.addon(o, i); + o.preset && ee.addon(o, kh[o.preset]); + const t = Object.keys(o); + for (let i = 0; i < t.length; ++i) { + const r = t[i]; + switch (r) { + case Vh.UUID: + { + var n; + const t = a.uuid = Wh(o.uuid); + if (!o.bundle) { + const e = Ph.find((e => !!e.getAssetInfo(t))); + o.bundle = e && e.name; + } + if (Ph.has(o.bundle)) { + l = Ph.get(o.bundle).config; + h = l.getAssetInfo(t); + if (h && h.redirect) { + if (!Ph.has(h.redirect)) throw new Error(`Please load bundle ${h.redirect} first`); + l = Ph.get(h.redirect).config; + h = l.getAssetInfo(t); + } + a.config = l; + a.info = h; + } + a.ext = o.ext || (null === (n = h) || void 0 === n ? void 0 : n.extension) || ".json"; + break; + } + + case "__requestType__": + case "ext": + case "bundle": + case "preset": + case "type": + break; + + case Vh.DIR: + if (Ph.has(o.bundle)) { + Ph.get(o.bundle).config.getDirWithPath(o.dir, o.type, mR); + for (const t of mR) s.push({ + uuid: t.uuid, + __isNative__: !1, + ext: t.extension || ".json", + bundle: o.bundle + }); + mR.length = 0; + } + a.recycle(); + a = null; + break; + + case Vh.PATH: + if (Ph.has(o.bundle)) { + l = Ph.get(o.bundle).config; + h = l.getInfoWithPath(o.path, o.type); + if (h && h.redirect) { + if (!Ph.has(h.redirect)) throw new Error(`you need to load bundle ${h.redirect} first`); + l = Ph.get(h.redirect).config; + h = l.getAssetInfo(h.uuid); + } + if (!h) { + a.recycle(); + throw new Error(`Bundle ${o.bundle} doesn't contain ${o.path}`); + } + a.config = l; + a.uuid = h.uuid; + a.info = h; + } + a.ext = o.ext || (null === (e = h) || void 0 === e ? void 0 : e.extension) || ".json"; + break; + + case Vh.SCENE: + if (!o.bundle) { + const t = Ph.find((t => !!t.getSceneInfo(o.scene))); + o.bundle = t && t.name; + } + if (Ph.has(o.bundle)) { + l = Ph.get(o.bundle).config; + h = l.getSceneInfo(o.scene); + if (h && h.redirect) { + if (!Ph.has(h.redirect)) throw new Error(`you need to load bundle ${h.redirect} first`); + l = Ph.get(h.redirect).config; + h = l.getAssetInfo(h.uuid); + } + if (!h) { + a.recycle(); + throw new Error(`Bundle ${l.name} doesn't contain scene ${o.scene}`); + } + a.config = l; + a.uuid = h.uuid; + a.info = h; + } + break; + + case "__isNative__": + a.isNative = o.__isNative__; + break; + + case Vh.URL: + a.url = o.url; + a.uuid = o.uuid || o.url; + a.ext = o.ext || nc(o.url); + a.isNative = void 0 === o.__isNative__ || o.__isNative__; + break; + + default: + a.options[r] = o[r]; + } + if (!a) break; + } + } + if (a) { + t.output.push(a); + if (!a.uuid && !a.url) throw new Error(`Can not parse this input:${JSON.stringify(o)}`); + } + } + return null; + } + function gR(t) { + const e = t.output = t.input; + for (let t = 0; t < e.length; t++) { + const s = e[t]; + if (Fh.has(s.uuid)) { + const t = Fh.get(s.uuid); + const e = Ph.find((e => !!e.getAssetInfo(t))); + if (e) { + var i; + s.overrideUuid = t; + let n = e.config; + let r = n.getAssetInfo(t); + if (r && r.redirect) { + if (!Ph.has(r.redirect)) throw new Error(`Please load bundle ${r.redirect} first`); + n = Ph.get(r.redirect).config; + r = n.getAssetInfo(t); + } + s.config = n; + s.info = r; + s.ext = s.isNative ? s.ext : (null === (i = r) || void 0 === i ? void 0 : i.extension) || ".json"; + } else N(16201, t, s.uuid); + } + } + } + function yR(t) { + const e = t.output = t.input; + for (let t = 0; t < e.length; t++) { + const i = e[t]; + if (i.url) continue; + let s = ""; + let n = ""; + const r = i.config; + n = i.isNative ? r && r.nativeBase ? r.base + r.nativeBase : m.assetManager.generalNativeBase : r && r.importBase ? r.base + r.importBase : m.assetManager.generalImportBase; + const o = i.overrideUuid || i.uuid; + let a = ""; + i.info && (a = i.isNative ? i.info.nativeVer ? `.${i.info.nativeVer}` : "" : i.info.ver ? `.${i.info.ver}` : ""); + s = ".ttf" === i.ext ? `${n}/${o.slice(0, 2)}/${o}${a}/${i.options.__nativeName__}` : `${n}/${o.slice(0, 2)}/${o}${a}${i.ext}`; + i.url = s; + } + return null; + } + class bR { + constructor() { + this.pipeline = Oh.append(dR).append(uR); + this.fetchPipeline = Nh.append(dR).append(rR); + this.transformPipeline = Lh.append(fR).append(gR).append(yR); + this.bundles = Ph; + this.assets = Mh; + this.assetsOverrideMap = Fh; + this.generalImportBase = ""; + this.generalNativeBase = ""; + this.dependUtil = pA; + this.force = false; + this.allowImageBitmap = !Vo.isMobile; + this.utils = $h; + this.downloader = Jw; + this.parser = cR; + this.packManager = nR; + this.cacheAsset = !0; + this.cacheManager = null; + this.presets = kh; + this.factory = sR; + this.preprocessPipe = dR; + this.fetchPipe = rR; + this.loadPipe = uR; + this.references = null; + this._releaseManager = vw; + this._files = Bh; + this._parsed = Dh; + this._parsePipeline = null; + this._projectBundles = []; + } + get main() { + return Ph.get(Uh.MAIN) || null; + } + get resources() { + return Ph.get(Uh.RESOURCES) || null; + } + init(t = {}) { + const e = t.server || de.querySettings(_e.Category.ASSETS, "server") || ""; + const i = t.bundleVers || de.querySettings(_e.Category.ASSETS, "bundleVers") || {}; + const s = t.remoteBundles || de.querySettings(_e.Category.ASSETS, "remoteBundles") || []; + this._files.clear(); + this._parsed.clear(); + this._releaseManager.init(); + this.assets.clear(); + this.bundles.clear(); + this.packManager.init(); + this.downloader.init(e, i, s); + this.parser.init(); + this.dependUtil.init(); + let n = t.importBase || de.querySettings(_e.Category.ASSETS, "importBase") || ""; + n && n.endsWith("/") && (n = n.substr(0, n.length - 1)); + let r = t.nativeBase || de.querySettings(_e.Category.ASSETS, "nativeBase") || ""; + r && r.endsWith("/") && (r = r.substr(0, r.length - 1)); + this.generalImportBase = n; + this.generalNativeBase = r; + this._projectBundles = de.querySettings(_e.Category.ASSETS, "projectBundles") || []; + const o = de.querySettings(_e.Category.ASSETS, "assetsOverrides") || {}; + for (const t in o) this.assetsOverrideMap.set(t, o[t]); + } + getBundle(t) { + return Ph.get(t) || null; + } + removeBundle(t) { + t._destroy(); + Ph.remove(t.name); + } + loadAny(t, e, i, s) { + const {options: n, onProgress: r, onComplete: o} = Bw(e, i, s); + n.preset = n.preset || "default"; + t = Array.isArray(t) ? t.slice() : t; + const a = Gh.create({ + input: t, + onProgress: r, + onComplete: Ow(o), + options: n + }); + Oh.async(a); + } + preloadAny(t, e, i, s) { + const {options: n, onProgress: r, onComplete: o} = Bw(e, i, s); + n.preset = n.preset || "preload"; + t = Array.isArray(t) ? t.slice() : t; + const a = Gh.create({ + input: t, + onProgress: r, + onComplete: Ow(o), + options: n + }); + Nh.async(a); + } + loadRemote(t, e, i) { + const {options: s, onComplete: n} = Bw(e, void 0, i); + if (s.reloadAsset || !this.assets.has(t)) { + s.__isNative__ = !0; + s.preset = s.preset || "remote"; + this.loadAny({ + url: t + }, s, null, ((e, i) => { + if (e) { + x(e.message, e.stack); + n && n(e, i); + } else sR.create(t, i, s.ext || nc(t), s, ((t, e) => { + n && n(t, e); + })); + })); + } else Ow(n)(null, this.assets.get(t)); + } + loadBundle(t, e, i) { + const {options: s, onComplete: n} = Bw(e, void 0, i); + const r = oc(t); + if (this.bundles.has(r)) Ow(n)(null, this.getBundle(r)); else { + s.preset = s.preset || "bundle"; + s.ext = "bundle"; + s.__isNative__ = !0; + this.loadAny({ + url: t + }, s, null, ((e, i) => { + if (e) { + x(e.message, e.stack); + n && n(e, i); + } else sR.create(t, i, "bundle", s, ((t, e) => { + n && n(t, e); + })); + })); + } + } + releaseAsset(t) { + vw.tryRelease(t, !0); + } + releaseUnusedAssets() { + Mh.forEach((t => { + vw.tryRelease(t); + })); + } + releaseAll() { + Mh.forEach((t => { + vw.tryRelease(t, !0); + })); + } + loadWithJson(t, e, i, s) { + throw new Error("Only valid in Editor"); + } + } + t("AssetManager", bR); + bR.Pipeline = Ih; + bR.Task = Gh; + bR.Cache = Rh; + bR.RequestItem = pR; + bR.Bundle = Nw; + bR.BuiltinBundleName = Uh; + var SR = t("assetManager", m.assetManager = new bR); + m.AssetManager = bR; + const AR = nr.RenderPipeline; + m.RenderPipeline = AR; + const TR = jsb.Texture2D; + const vR = jsb.ImageAsset; + const ER = jsb.BuiltinResMgr; + const CR = ER.prototype; + CR.init = function() { + this._resources = {}; + this._materialsToBeCompiled = []; + const t = this._resources; + const e = new Uint8Array(16); + for (let t = 0; t < 4; t++) { + e[0] = 0; + e[1] = 0; + e[2] = 0; + e[3] = 255; + } + const i = { + width: 2, + height: 2, + _data: e, + _compressed: !1, + format: TR.PixelFormat.RGBA8888 + }; + const s = new vR(i); + const n = new TR; + n._uuid = "black-texture"; + n.image = s; + t[n._uuid] = n; + if (m.SpriteFrame) { + const e = new m.SpriteFrame; + const i = s; + const n = new TR; + n.image = i; + e.texture = n; + e._uuid = "default-spriteframe"; + t[e._uuid] = e; + } + this.initBuiltinRes(); + }; + CR.get = function(t) { + return this._resources[t] || this.getAsset(t); + }; + CR.compileBuiltinMaterial = function() { + for (let t = 0; t < this._materialsToBeCompiled.length; ++t) { + const e = this._materialsToBeCompiled[t]; + for (let t = 0; t < e.passes.length; ++t) e.passes[t].tryCompile(); + } + this._materialsToBeCompiled.length = 0; + }; + CR.loadBuiltinAssets = function() { + const t = de.querySettings(_e.Category.ENGINE, "builtinAssets"); + if (!t) return Promise.resolve(); + const e = this._resources; + return new Promise(((i, s) => { + SR.loadBundle(Uh.INTERNAL, ((n, r) => { + n ? s(n) : SR.loadAny(t, ((t, n) => { + if (t) s(t); else { + n.forEach((t => { + e[t.name] = t; + t.nativeUrl; + vw.addIgnoredAsset(t); + this.addAsset(t.name, t); + t instanceof m.Material && this._materialsToBeCompiled.push(t); + })); + i(); + } + })); + })); + })); + }; + const xR = t("builtinResMgr", m.builtinResMgr = ER.getInstance()); + const wR = new class { + constructor() { + this._allRenderers = []; + this._dirtyRenderers = []; + this._dirtyVersion = 0; + } + addRenderer(t) { + if (-1 === t._internalId) { + t._internalId = this._allRenderers.length; + this._allRenderers.push(t); + } + } + removeRenderer(t) { + if (-1 !== t._internalId) { + w(this._allRenderers[t._internalId] === t); + const e = t._internalId; + this._allRenderers[this._allRenderers.length - 1]._internalId = e; + ee.array.fastRemoveAt(this._allRenderers, e); + t._internalId = -1; + if (t._dirtyVersion === this._dirtyVersion) { + ee.array.fastRemove(this._dirtyRenderers, t); + t._dirtyVersion = -1; + } + } + } + markDirtyRenderer(t) { + if (t._dirtyVersion !== this._dirtyVersion && -1 !== t._internalId) { + this._dirtyRenderers.push(t); + t._dirtyVersion = this._dirtyVersion; + } + } + updateAllDirtyRenderers() { + const t = this._dirtyRenderers.length; + const e = this._dirtyRenderers; + for (let i = 0; i < t; i++) { + w(-1 !== e[i]._internalId); + e[i].updateRenderer(); + } + this._dirtyRenderers.length = 0; + this._dirtyVersion++; + } + }; + class RR extends vo { + constructor() { + super(); + this._compScheduler = void 0; + this._nodeActivator = void 0; + this._invalid = void 0; + this._paused = void 0; + this._root = void 0; + this._loadingScene = void 0; + this._scene = void 0; + this._totalFrames = void 0; + this._scheduler = void 0; + this._systems = void 0; + this._persistRootNodes = {}; + this._invalid = !1; + this._paused = !1; + this._root = null; + this._loadingScene = ""; + this._scene = null; + this._totalFrames = 0; + this._scheduler = new Rg; + this._compScheduler = new Mv; + this._nodeActivator = new Uv; + this._systems = []; + } + calculateDeltaTime(t) {} + end() { + this.once(RR.EVENT_END_FRAME, (() => { + this.purgeDirector(); + })); + } + pause() { + this._paused || (this._paused = !0); + } + purgeDirector() { + this._scheduler.unscheduleAll(); + this._compScheduler.unscheduleAll(); + this._nodeActivator.reset(); + m.isValid(this._scene) && this._scene.destroy(); + this._scene = null; + this.stopAnimation(); + m.assetManager.releaseAll(); + } + reset() { + var t; + this.purgeDirector(); + for (const t in this._persistRootNodes) this.removePersistRootNode(this._persistRootNodes[t]); + null === (t = this.getScene()) || void 0 === t || t.destroy(); + this.emit(RR.EVENT_RESET); + this.startAnimation(); + } + runSceneImmediate(t, e, i) { + t instanceof yC && (t = t.scene); + k(t instanceof oA, 1216); + console.time("InitScene"); + t._load(); + console.timeEnd("InitScene"); + console.time("AttachPersist"); + const s = Object.keys(this._persistRootNodes).map((t => this._persistRootNodes[t])); + for (let e = 0; e < s.length; e++) { + const i = s[e]; + i.emit(_y.EventType.SCENE_CHANGED_FOR_PERSISTS, t.renderScene); + const n = t.uuid === i._originalSceneId && t.getChildByUuid(i.uuid); + if (n) { + const e = n.getSiblingIndex(); + i.hideFlags &= ~co.Flags.DontSave; + i.hideFlags |= co.Flags.DontSave & n.hideFlags; + n._destroyImmediate(); + t.insertChild(i, e); + } else { + i.hideFlags |= co.Flags.DontSave; + i.parent = t; + } + } + console.timeEnd("AttachPersist"); + const n = this._scene; + console.time("Destroy"); + m.isValid(n) && n.destroy(); + console.time("AutoRelease"); + m.assetManager._releaseManager._autoRelease(n, t, this._persistRootNodes); + console.timeEnd("AutoRelease"); + this._scene = null; + co._deferredDestroy(); + console.timeEnd("Destroy"); + e && e(); + this.emit(RR.EVENT_BEFORE_SCENE_LAUNCH, t); + this._scene = t; + console.time("Activate"); + t._activate(); + console.timeEnd("Activate"); + this._root && this._root.resetCumulativeTime(); + this.startAnimation(); + i && i(null, t); + this.emit(RR.EVENT_AFTER_SCENE_LAUNCH, t); + } + runScene(t, e, i) { + t instanceof yC && (t = t.scene); + k(t, 1205); + k(t instanceof oA, 1216); + t._load(); + this.once(RR.EVENT_END_FRAME, (() => { + this.runSceneImmediate(t, e, i); + })); + } + loadScene(t, e, i) { + if (this._loadingScene) { + N(1208, t, this._loadingScene); + return !1; + } + const s = m.assetManager.bundles.find((e => !!e.getSceneInfo(t))); + if (s) { + this.emit(RR.EVENT_BEFORE_SCENE_LOADING, t); + this._loadingScene = t; + console.time(`LoadScene ${t}`); + s.loadScene(t, ((s, n) => { + console.timeEnd(`LoadScene ${t}`); + this._loadingScene = ""; + if (s) { + x(s); + e && e(s); + } else this.runSceneImmediate(n, i, e); + })); + return !0; + } + F(1209, t); + return !1; + } + preloadScene(t, e, i) { + const s = m.assetManager.bundles.find((e => !!e.getSceneInfo(t))); + if (s) s.preloadScene(t, null, e, i); else { + const e = `Can not preload the scene "${t}" because it is not in the build settings.`; + i && i(new Error(e)); + x(`preloadScene: ${e}`); + } + } + resume() { + this._paused && (this._paused = !1); + } + get root() { + return this._root; + } + getScene() { + return this._scene; + } + getDeltaTime() { + return m.game.deltaTime; + } + getTotalTime() { + return m.game.totalTime; + } + getCurrentTime() { + return m.game.frameStartTime; + } + getTotalFrames() { + return this._totalFrames; + } + isPaused() { + return this._paused; + } + getScheduler() { + return this._scheduler; + } + setScheduler(t) { + if (this._scheduler !== t) { + this.unregisterSystem(this._scheduler); + this._scheduler = t; + this.registerSystem(Rg.ID, t, 200); + } + } + registerSystem(t, e, i) { + e.id = t; + e.priority = i; + this._systems.push(e); + this._systems.sort(Tg.sortByPriority); + } + unregisterSystem(t) { + ee.array.fastRemove(this._systems, t); + this._systems.sort(Tg.sortByPriority); + } + getSystem(t) { + return this._systems.find((e => e.id === t)); + } + getAnimationManager() { + return this.getSystem(m.AnimationManager.ID); + } + startAnimation() { + this._invalid = !1; + } + stopAnimation() { + this._invalid = !0; + } + mainLoop(t) { + let e; + e = m.game._calculateDT(t); + this.tick(e); + } + tick(t) { + if (!this._invalid) { + this.emit(RR.EVENT_BEGIN_FRAME); + lv._frameDispatchEvents(); + if (!this._paused) { + this.emit(RR.EVENT_BEFORE_UPDATE); + this._compScheduler.startPhase(); + this._compScheduler.updatePhase(t); + for (let e = 0; e < this._systems.length; ++e) this._systems[e].update(t); + this._compScheduler.lateUpdatePhase(t); + this.emit(RR.EVENT_AFTER_UPDATE); + co._deferredDestroy(); + for (let e = 0; e < this._systems.length; ++e) this._systems[e].postUpdate(t); + } + this.emit(RR.EVENT_BEFORE_DRAW); + wR.updateAllDirtyRenderers(); + this._root.frameMove(t); + this.emit(RR.EVENT_AFTER_DRAW); + _y.resetHasChangedFlags(); + _y.clearNodeArray(); + Zr.update(t); + this.emit(RR.EVENT_END_FRAME); + this._totalFrames++; + } + } + init() { + this._totalFrames = 0; + this._paused = !1; + this.registerSystem(Rg.ID, this._scheduler, 200); + this._root = new cw(zo.gfxDevice); + this._root.initialize({}); + for (let t = 0; t < this._systems.length; t++) this._systems[t].init(); + this.emit(RR.EVENT_INIT); + } + addPersistRootNode(t) { + if (!m.Node.isNode(t) || !t.uuid) { + N(3800); + return; + } + const e = t.uuid; + if (!this._persistRootNodes[e]) { + const i = this._scene; + if (m.isValid(i)) if (t.parent) { + if (!(t.parent instanceof oA)) { + N(3801); + return; + } + if (t.parent !== i) { + N(3802); + return; + } + t._originalSceneId = i.uuid; + } else { + t.parent = i; + t._originalSceneId = i.uuid; + } + this._persistRootNodes[e] = t; + t._persistNode = !0; + m.assetManager._releaseManager._addPersistNodeRef(t); + } + } + removePersistRootNode(t) { + const e = t.uuid || ""; + if (t === this._persistRootNodes[e]) { + delete this._persistRootNodes[e]; + t._persistNode = !1; + t._originalSceneId = ""; + m.assetManager._releaseManager._removePersistNodeRef(t); + } + } + isPersistRootNode(t) { + return !!t._persistNode; + } + } + t("Director", RR); + RR.EVENT_INIT = "director_init"; + RR.EVENT_RESET = "director_reset"; + RR.EVENT_BEFORE_SCENE_LOADING = "director_before_scene_loading"; + RR.EVENT_BEFORE_SCENE_LAUNCH = "director_before_scene_launch"; + RR.EVENT_AFTER_SCENE_LAUNCH = "director_after_scene_launch"; + RR.EVENT_BEFORE_UPDATE = "director_before_update"; + RR.EVENT_AFTER_UPDATE = "director_after_update"; + RR.EVENT_BEFORE_DRAW = "director_before_draw"; + RR.EVENT_AFTER_DRAW = "director_after_draw"; + RR.EVENT_BEFORE_COMMIT = "director_before_commit"; + RR.EVENT_BEFORE_PHYSICS = "director_before_physics"; + RR.EVENT_AFTER_PHYSICS = "director_after_physics"; + RR.EVENT_BEGIN_FRAME = "director_begin_frame"; + RR.EVENT_END_FRAME = "director_end_frame"; + RR.instance = void 0; + m.Director = RR; + const IR = t("director", RR.instance = m.director = new RR); + class MR extends vo { + constructor(...t) { + super(...t); + this.frame = null; + this.container = null; + this.canvas = null; + this.renderType = -1; + this.eventTargetOn = super.on; + this.eventTargetOnce = super.once; + this.config = {}; + this.onStart = null; + this.frameTime = 1e3 / 60; + this._isCloning = !1; + this._inited = !1; + this._engineInited = !1; + this._rendererInitialized = !1; + this._paused = !0; + this._frameRate = 60; + this._pacer = null; + this._initTime = 0; + this._startTime = 0; + this._deltaTime = 0; + this._shouldLoadLaunchScene = !0; + this.onPreBaseInitDelegate = new Eo; + this.onPostBaseInitDelegate = new Eo; + this.onPreInfrastructureInitDelegate = new Eo; + this.onPostInfrastructureInitDelegate = new Eo; + this.onPreSubsystemInitDelegate = new Eo; + this.onPostSubsystemInitDelegate = new Eo; + this.onPreProjectInitDelegate = new Eo; + this.onPostProjectInitDelegate = new Eo; + } + get inited() { + return this._inited; + } + get frameRate() { + return this._frameRate; + } + set frameRate(t) { + if ("number" != typeof t) { + t = parseInt(t, 10); + Number.isNaN(t) && (t = 60); + } + this._frameRate = t; + this.frameTime = 1e3 / t; + this._pacer && (this._pacer.targetFrameRate = this._frameRate); + } + get deltaTime() { + return this._deltaTime; + } + get totalTime() { + return performance.now() - this._initTime; + } + get frameStartTime() { + return this._startTime; + } + setFrameRate(t) { + this.frameRate = t; + } + getFrameRate() { + return this.frameRate; + } + step() { + IR.tick(this.frameTime / 1e3); + } + pause() { + var t; + if (!this._paused) { + this._paused = !0; + null === (t = this._pacer) || void 0 === t || t.stop(); + } + } + resume() { + var t; + if (this._paused) { + lv._clearEvents(); + this._paused = !1; + null === (t = this._pacer) || void 0 === t || t.start(); + } + } + isPaused() { + return this._paused; + } + restart() { + return new Promise((t => { + IR.once(RR.EVENT_END_FRAME, (() => t())); + })).then((() => { + IR.reset(); + m.Object._deferredDestroy(); + this.pause(); + this.resume(); + this._shouldLoadLaunchScene = !0; + Ag.instance.curTime = 0; + this._safeEmit(MR.EVENT_RESTART); + })); + } + end() { + Po.close(); + } + on(t, e, i, s) { + (this._engineInited && t === MR.EVENT_ENGINE_INITED || this._inited && t === MR.EVENT_GAME_INITED || this._rendererInitialized && t === MR.EVENT_RENDERER_INITED) && e.call(i); + return this.eventTargetOn(t, e, i, s); + } + once(t, e, i) { + return this._engineInited && t === MR.EVENT_ENGINE_INITED ? e.call(i) : this.eventTargetOnce(t, e, i); + } + init(t) { + this._compatibleWithOldParams(t); + return Promise.resolve().then((() => { + this.emit(MR.EVENT_PRE_BASE_INIT); + return this.onPreBaseInitDelegate.dispatch(); + })).then((() => { + console.time("Init Base"); + I(t.debugMode || U.NONE); + Vo.init(); + this._initEvents(); + })).then((() => de.init(t.settingsPath, t.overrideSettings))).then((() => { + console.timeEnd("Init Base"); + if (Vo.isXR) { + var t, e; + xr.entry = xr.XrEntry.getInstance(); + const i = null !== (t = de.querySettings(_e.Category.RENDERING, "msaa")) && void 0 !== t ? t : 1; + const s = null !== (e = de.querySettings(_e.Category.RENDERING, "renderingScale")) && void 0 !== e ? e : 1; + xr.entry.setMultisamplesRTT(i); + xr.entry.setRenderingScale(s); + } + this.emit(MR.EVENT_POST_BASE_INIT); + return this.onPostBaseInitDelegate.dispatch(); + })).then((() => { + this.emit(MR.EVENT_PRE_INFRASTRUCTURE_INIT); + return this.onPreInfrastructureInitDelegate.dispatch(); + })).then((() => { + console.time("Init Infrastructure"); + pe.init(); + const t = function() { + const t = document.createElement("div"); + return { + frame: document.documentElement, + canvas: window.__canvas, + container: t + }; + }(); + if (t) { + this.canvas = t.canvas; + this.frame = t.frame; + this.container = t.container; + } + Fo.init(); + _s.init(); + zo.init(this.canvas, Rm); + SR.init(); + xR.init(); + mm.init(); + this.initPacer(); + console.timeEnd("Init Infrastructure"); + })).then((() => { + this.emit(MR.EVENT_POST_INFRASTRUCTURE_INIT); + return this.onPostInfrastructureInitDelegate.dispatch(); + })).then((() => { + this.emit(MR.EVENT_PRE_SUBSYSTEM_INIT); + return this.onPreSubsystemInitDelegate.dispatch(); + })).then((() => { + console.time("Init SubSystem"); + IR.init(); + return xR.loadBuiltinAssets(); + })).then((() => { + console.timeEnd("Init SubSystem"); + this.emit(MR.EVENT_POST_SUBSYSTEM_INIT); + return this.onPostSubsystemInitDelegate.dispatch(); + })).then((() => { + E(`Cocos Creator v${f}`); + this.emit(MR.EVENT_ENGINE_INITED); + this._engineInited = !0; + })).then((() => { + this.emit(MR.EVENT_PRE_PROJECT_INIT); + return this.onPreProjectInitDelegate.dispatch(); + })).then((() => { + console.time("Init Project"); + const t = de.querySettings(_e.Category.PLUGINS, "jsList"); + let e = Promise.resolve(); + if (t) { + de.querySettings(_e.Category.PATH, "projectPath"); + t.forEach((t => { + e = e.then((() => function(t) { + if (window.oh) { + window.oh.loadModule(t); + return Promise.resolve(); + } + return i(260)(t); + }(`src/${t}`))); + })); + } + return e; + })).then((() => { + const t = de.querySettings(_e.Category.SCRIPTING, "scriptPackages"); + return t ? Promise.all(t.map((t => e.import(t)))) : Promise.resolve([]); + })).then((() => this._loadProjectBundles())).then((() => this._setupRenderPipeline())).then((() => this._loadPreloadAssets())).then((() => { + xR.compileBuiltinMaterial(); + return Ag.instance.init(); + })).then((() => { + console.timeEnd("Init Project"); + this.emit(MR.EVENT_POST_PROJECT_INIT); + return this.onPostProjectInitDelegate.dispatch(); + })).then((() => { + this._inited = !0; + this._safeEmit(MR.EVENT_GAME_INITED); + })); + } + _compatibleWithOldParams(t) { + const e = t.overrideSettings = t.overrideSettings || {}; + if ("showFPS" in t) { + e.profiling = e.profiling || {}; + e.profiling.showFPS = t.showFPS; + } + if ("frameRate" in t) { + e.screen = e.screen || {}; + e.screen.frameRate = t.frameRate; + } + if ("renderMode" in t) { + e.rendering = e.rendering || {}; + e.rendering.renderMode = t.renderMode; + } + if ("renderPipeline" in t) { + e.rendering = e.rendering || {}; + e.rendering.renderPipeline = t.renderPipeline; + } + if ("assetOptions" in t) { + e.assets = e.assets || {}; + Object.assign(e.assets, t.assetOptions); + } + if ("customJointTextureLayouts" in t) { + e.animation = e.animation || {}; + e.animation.customJointTextureLayouts = t.customJointTextureLayouts; + } + if ("physics" in t) { + e.physics = e.physics || {}; + Object.assign(e.physics, t.physics); + } + if ("orientation" in t) { + e.screen = e.screen || {}; + e.screen.orientation = t.orientation; + } + if ("exactFitScreen" in t) { + e.screen = e.screen || {}; + e.screen.exactFitScreen = t.exactFitScreen; + } + } + _loadPreloadAssets() { + const t = de.querySettings(_e.Category.ASSETS, "preloadAssets"); + return t ? Promise.all(t.map((t => new Promise(((e, i) => { + SR.loadAny(t, (t => { + t ? i(t) : e(); + })); + }))))) : Promise.resolve([]); + } + _loadProjectBundles() { + const t = de.querySettings(_e.Category.ASSETS, "preloadBundles"); + return t ? Promise.all(t.map((({bundle: t, version: e}) => new Promise(((i, s) => { + const n = {}; + e && (n.version = e); + SR.loadBundle(t, n, (t => { + t ? s(t) : i(); + })); + }))))) : Promise.resolve([]); + } + run(t) { + t && (this.onStart = t); + this._inited && this.resume(); + } + _calculateDT() { + const t = performance.now(); + this._deltaTime = t > this._startTime ? (t - this._startTime) / 1e3 : 0; + this._deltaTime > MR.DEBUG_DT_THRESHOLD && (this._deltaTime = this.frameTime / 1e3); + this._startTime = t; + return this._deltaTime; + } + _updateCallback() { + if (this._inited) if (Ag.instance.isFinished) if (this._shouldLoadLaunchScene) { + this._shouldLoadLaunchScene = !1; + const e = de.querySettings(_e.Category.LAUNCH, "launchScene"); + if (e) IR.loadScene(e, (() => { + var t; + console.log(`Success to load scene: ${e}`); + this._initTime = performance.now(); + IR.startAnimation(); + null === (t = this.onStart) || void 0 === t || t.call(this); + })); else { + var t; + this._initTime = performance.now(); + IR.startAnimation(); + null === (t = this.onStart) || void 0 === t || t.call(this); + } + } else IR.tick(this._calculateDT()); else Ag.instance.update(this._calculateDT()); + } + initPacer() { + var t; + const e = null !== (t = de.querySettings(_e.Category.SCREEN, "frameRate")) && void 0 !== t ? t : 60; + w("number" == typeof e); + this._pacer = new fw; + this._pacer.onTick = this._updateCallback.bind(this); + this.frameRate = e; + } + _initEvents() { + Po.on("show", this._onShow, this); + Po.on("hide", this._onHide, this); + } + _onHide() { + this.emit(MR.EVENT_HIDE); + this.pause(); + } + _onShow() { + this.emit(MR.EVENT_SHOW); + this.resume(); + } + addPersistRootNode(t) { + IR.addPersistRootNode(t); + } + removePersistRootNode(t) { + IR.removePersistRootNode(t); + } + isPersistRootNode(t) { + return IR.isPersistRootNode(t); + } + _setupRenderPipeline() { + const t = de.querySettings(_e.Category.RENDERING, "renderPipeline"); + return t ? new Promise(((e, i) => { + SR.loadAny(t, ((t, s) => !t && s instanceof AR ? e(s) : i(t))); + })).then((t => { + this._setRenderPipeline(t); + })).catch((e => { + C(e); + C(`Failed load render pipeline: ${t}, engine failed to initialize, will fallback to default pipeline`); + this._setRenderPipeline(); + })) : this._setRenderPipeline(); + } + _setRenderPipeline(t) { + IR.root.setRenderPipeline(t) || this._setRenderPipeline(); + this._rendererInitialized = !0; + this._safeEmit(MR.EVENT_RENDERER_INITED); + } + _safeEmit(t) { + this.emit(t); + } + } + t("Game", MR); + MR.EVENT_HIDE = "game_on_hide"; + MR.EVENT_SHOW = "game_on_show"; + MR.EVENT_LOW_MEMORY = "game_on_low_memory"; + MR.EVENT_GAME_INITED = "game_inited"; + MR.EVENT_ENGINE_INITED = "engine_inited"; + MR.EVENT_RENDERER_INITED = "renderer_inited"; + MR.EVENT_PRE_BASE_INIT = "pre_base_init"; + MR.EVENT_POST_BASE_INIT = "post_base_init"; + MR.EVENT_PRE_INFRASTRUCTURE_INIT = "pre_infrastructure_init"; + MR.EVENT_POST_INFRASTRUCTURE_INIT = "post_infrastructure_init"; + MR.EVENT_PRE_SUBSYSTEM_INIT = "pre_subsystem_init"; + MR.EVENT_POST_SUBSYSTEM_INIT = "post_subsystem_init"; + MR.EVENT_PRE_PROJECT_INIT = "pre_project_init"; + MR.EVENT_POST_PROJECT_INIT = "post_project_init"; + MR.EVENT_RESTART = "game_on_restart"; + MR.RENDER_TYPE_CANVAS = 0; + MR.RENDER_TYPE_WEBGL = 1; + MR.RENDER_TYPE_OPENGL = 2; + MR.RENDER_TYPE_HEADLESS = 3; + MR.DEBUG_DT_THRESHOLD = 1; + m.Game = MR; + const BR = t("game", m.game = new MR); + const DR = {}; + W(DR, "vmath", [ { + name: "vec2", + newName: "Vec2", + target: us, + targetName: "math" + }, { + name: "vec3", + newName: "Vec3", + target: us, + targetName: "math" + }, { + name: "vec4", + newName: "Vec4", + target: us, + targetName: "math" + }, { + name: "quat", + newName: "Quat", + target: us, + targetName: "math" + }, { + name: "mat3", + newName: "Mat3", + target: us, + targetName: "math" + }, { + name: "mat4", + newName: "Mat4", + target: us, + targetName: "math" + }, { + name: "color4", + newName: "Color", + target: us, + targetName: "math" + }, { + name: "rect", + newName: "Rect", + target: us, + targetName: "math" + }, { + name: "approx", + newName: "approx", + target: us, + targetName: "math" + }, { + name: "EPSILON", + newName: "EPSILON", + target: us, + targetName: "math" + }, { + name: "equals", + newName: "equals", + target: us, + targetName: "math" + }, { + name: "clamp", + newName: "clamp", + target: us, + targetName: "math" + }, { + name: "clamp01", + newName: "clamp01", + target: us, + targetName: "math" + }, { + name: "lerp", + newName: "lerp", + target: us, + targetName: "math" + }, { + name: "toRadian", + newName: "toRadian", + target: us, + targetName: "math" + }, { + name: "toDegree", + newName: "toDegree", + target: us, + targetName: "math" + }, { + name: "random", + newName: "random", + target: us, + targetName: "math" + }, { + name: "randomRange", + newName: "randomRange", + target: us, + targetName: "math" + }, { + name: "randomRangeInt", + newName: "randomRangeInt", + target: us, + targetName: "math" + }, { + name: "pseudoRandom", + newName: "pseudoRandom", + target: us, + targetName: "math" + }, { + name: "pseudoRandomRangeInt", + newName: "pseudoRandomRangeInt", + target: us, + targetName: "math" + }, { + name: "nextPow2", + newName: "nextPow2", + target: us, + targetName: "math" + }, { + name: "repeat", + newName: "repeat", + target: us, + targetName: "math" + }, { + name: "pingPong", + newName: "pingPong", + target: us, + targetName: "math" + }, { + name: "inverseLerp", + newName: "inverseLerp", + target: us, + targetName: "math" + } ]); + m.vmath = DR; + W(Rg.prototype, "Scheduler.prototype", [ { + name: "enableForTarget", + newName: "enableForTarget", + target: Rg, + targetName: "Scheduler" + } ]); + W(Rg, "Scheduler", [ { + name: "PRIORITY_SYSTEM", + newName: "System.Priority.SCHEDULER", + customGetter: () => Tg.Priority.SCHEDULER + } ]); + Y(Rg, "Scheduler", [ { + name: "PRIORITY_NON_SYSTEM", + suggest: "Use enum` System.Priority` instead" + } ]); + W(Ig.prototype, "SubModel.prototype", [ { + name: "subMeshData", + newName: "subMesh" + } ]); + Y(Ig.prototype, "SubModel.prototype", [ { + name: "getSubModel", + suggest: "Use `subModels[i]` instead" + }, { + name: "subModelNum", + suggest: "Use `subModels.length` instead" + } ]); + W(cw.prototype, "Root.prototype", [ { + name: "ui", + newName: "batcher2D" + } ]); + q(BR, "game", [ { + name: "collisionMatrix" + }, { + name: "groupList" + } ]); + q(RR.prototype, "director", [ { + name: "calculateDeltaTime" + }, { + name: "getDeltaTime", + suggest: "Use game.deltaTime instead" + }, { + name: "getTotalTime", + suggest: "Use game.totalTime instead" + }, { + name: "getCurrentTime", + suggest: "Use game.frameStartTime instead" + } ]); + Y(RR.prototype, "director", [ { + name: "setAnimationInterval", + suggest: "please use game.frameRate instead" + }, { + name: "getAnimationInterval", + suggest: "please use game.frameRate instead" + }, { + name: "getRunningScene", + suggest: "please use getScene instead" + }, { + name: "setDepthTest", + suggest: "please use camera API instead" + }, { + name: "setClearColor", + suggest: "please use camera API instead" + }, { + name: "getWinSize", + suggest: "please use view.getVisibleSize instead" + }, { + name: "getWinSizeInPixels" + }, { + name: "purgeCachedData", + suggest: "please use assetManager.releaseAll instead" + }, { + name: "convertToGL" + }, { + name: "convertToUI" + } ]); + et({ + replaceProperty: { + since: "3.6.0", + removed: !1 + }, + removeProperty: { + since: "3.6.0", + removed: !1 + }, + markAsWarning: { + since: "3.6.0", + removed: !1 + }, + setDefaultLogTimes: { + since: "3.6.0", + removed: !1 + } + }); + var PR, OR, NR, LR, FR, VR; + t("PrefabLink", (PR = Ul("cc.PrefabLink"), OR = Th(mC), NR = rh(), PR(LR = (FR = class extends Qc { + constructor(...t) { + super(...t); + Ml(this, "prefab", VR, this); + } + }, VR = Bl(FR.prototype, "prefab", [ OR, Yl, NR ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), FR)) || LR)); + const kR = new Pi; + function UR(t, e, i, s) { + s || (s = new Pi); + t.convertToUINode(e, i, s); + const n = i.position; + s.add(n); + return s; + } + function GR(t, e, i) { + i || (i = new Pi); + t.worldToScreen(e, i); + i.x /= m.view.getScaleX(); + i.y /= m.view.getScaleY(); + return i; + } + const zR = t("convertUtils", { + WorldNode3DToLocalNodeUI: UR, + WorldNode3DToWorldNodeUI: GR + }); + m.pipelineUtils = zR; + W(m.pipelineUtils, "cc.pipelineUtils", [ { + name: "WorldNode3DToLocalNodeUI", + newName: "convertToUINode", + targetName: "cc.Camera.prototype", + customFunction(...t) { + const e = t[0]; + const i = t[3] || kR; + e.convertToUINode(t[1], t[2], i); + i.add(t[2].position); + return t[3] || i.clone(); + } + } ]); + const HR = { + topLeft: m.v2(0, 0), + topRight: m.v2(0, 0), + top: m.v2(0, 0), + bottomLeft: m.v2(0, 0), + bottomRight: m.v2(0, 0), + bottom: m.v2(0, 0), + center: m.v2(0, 0), + left: m.v2(0, 0), + right: m.v2(0, 0), + width: 0, + height: 0, + init(t) { + const e = this.width = t.width; + const i = this.height = t.height; + const s = t.x; + const n = t.y; + const r = n + i; + const o = s + e; + this.topLeft.x = s; + this.topLeft.y = r; + this.topRight.x = o; + this.topRight.y = r; + this.top.x = s + e / 2; + this.top.y = r; + this.bottomLeft.x = s; + this.bottomLeft.y = n; + this.bottomRight.x = o; + this.bottomRight.y = n; + this.bottom.x = s + e / 2; + this.bottom.y = n; + this.center.x = s + e / 2; + this.center.y = n + i / 2; + this.left.x = s; + this.left.y = n + i / 2; + this.right.x = o; + this.right.y = n + i / 2; + } + }; + m.visibleRect = HR; + const jR = new rs; + const XR = { + [pe.ORIENTATION_AUTO]: Oo.AUTO, + [pe.ORIENTATION_LANDSCAPE]: Oo.LANDSCAPE, + [pe.ORIENTATION_PORTRAIT]: Oo.PORTRAIT + }; + class WR extends(To(Tg)){ + constructor() { + super(); + this._designResolutionSize = void 0; + this._scaleX = void 0; + this._scaleY = void 0; + this._viewportRect = void 0; + this._visibleRect = void 0; + this._autoFullScreen = void 0; + this._retinaEnabled = void 0; + this._resizeCallback = void 0; + this._resolutionPolicy = void 0; + this._rpExactFit = void 0; + this._rpShowAll = void 0; + this._rpNoBorder = void 0; + this._rpFixedHeight = void 0; + this._rpFixedWidth = void 0; + const t = YR; + const e = qR; + this._designResolutionSize = new rs(0, 0); + this._scaleX = 1; + this._scaleY = 1; + this._viewportRect = new as(0, 0, 0, 0); + this._visibleRect = new as(0, 0, 0, 0); + this._autoFullScreen = !1; + this._retinaEnabled = !1; + this._resizeCallback = null; + this._rpExactFit = new KR(t.EQUAL_TO_FRAME, e.EXACT_FIT); + this._rpShowAll = new KR(t.EQUAL_TO_FRAME, e.SHOW_ALL); + this._rpNoBorder = new KR(t.EQUAL_TO_FRAME, e.NO_BORDER); + this._rpFixedHeight = new KR(t.EQUAL_TO_FRAME, e.FIXED_HEIGHT); + this._rpFixedWidth = new KR(t.EQUAL_TO_FRAME, e.FIXED_WIDTH); + this._resolutionPolicy = this._rpShowAll; + } + init() { + const t = Fo.windowSize; + const e = t.width; + const i = t.height; + this._designResolutionSize.width = e; + this._designResolutionSize.height = i; + this._viewportRect.width = e; + this._viewportRect.height = i; + this._visibleRect.width = e; + this._visibleRect.height = i; + jR.width = this._visibleRect.width; + jR.height = this._visibleRect.height; + HR && HR.init(this._visibleRect); + { + this.resizeWithBrowserSize(!0); + const t = de.querySettings(_e.Category.SCREEN, "designResolution"); + t && this.setDesignResolutionSize(Number(t.width), Number(t.height), t.policy || KR.FIXED_HEIGHT); + } + Lo.on("window-resize", this._updateAdaptResult, this); + Lo.on("orientation-change", this._updateAdaptResult, this); + Lo.on("fullscreen-change", this._updateAdaptResult, this); + } + resizeWithBrowserSize(t) { + Lo.handleResizeEvent = t; + } + setResizeCallback(t) { + "function" != typeof t && null != t || (this._resizeCallback = t); + } + setOrientation(t) { + Lo.orientation = XR[t]; + } + adjustViewportMeta(t) {} + enableRetina(t) { + this._retinaEnabled = !!t; + } + isRetinaEnabled() { + return this._retinaEnabled; + } + enableAutoFullScreen(t) { + if (t !== this._autoFullScreen) { + this._autoFullScreen = t; + t && Fo.requestFullScreen().catch((t => {})); + } + } + isAutoFullScreenEnabled() { + return this._autoFullScreen; + } + setCanvasSize(t, e) { + Lo.resolutionScale = 1; + const i = Lo.devicePixelRatio; + const s = new rs(t * i, e * i); + Fo.windowSize = s; + } + getCanvasSize() { + return Fo.windowSize; + } + getFrameSize() { + const t = Lo.devicePixelRatio; + const e = Fo.windowSize; + e.width /= t; + e.height /= t; + return e; + } + setFrameSize(t, e) { + const i = Lo.devicePixelRatio; + Fo.windowSize = new rs(t * i, e * i); + } + getVisibleSize() { + return new rs(this._visibleRect.width, this._visibleRect.height); + } + getVisibleSizeInPixel() { + return new rs(this._visibleRect.width * this._scaleX, this._visibleRect.height * this._scaleY); + } + getVisibleOrigin() { + return new Qi(this._visibleRect.x, this._visibleRect.y); + } + getVisibleOriginInPixel() { + return new Qi(this._visibleRect.x * this._scaleX, this._visibleRect.y * this._scaleY); + } + getResolutionPolicy() { + return this._resolutionPolicy; + } + _updateResolutionPolicy(t) { + if (t instanceof KR) this._resolutionPolicy = t; else { + const e = KR; + t === e.EXACT_FIT && (this._resolutionPolicy = this._rpExactFit); + t === e.SHOW_ALL && (this._resolutionPolicy = this._rpShowAll); + t === e.NO_BORDER && (this._resolutionPolicy = this._rpNoBorder); + t === e.FIXED_HEIGHT && (this._resolutionPolicy = this._rpFixedHeight); + t === e.FIXED_WIDTH && (this._resolutionPolicy = this._rpFixedWidth); + } + } + setResolutionPolicy(t) { + this._updateResolutionPolicy(t); + const e = JR.getDesignResolutionSize(); + JR.setDesignResolutionSize(e.width, e.height, t); + } + setDesignResolutionSize(t, e, i) { + if (!(t > 0 && e > 0)) { + F(2200); + return; + } + this._updateResolutionPolicy(i); + const s = this._resolutionPolicy; + s && s.preApply(this); + this._designResolutionSize.width = t; + this._designResolutionSize.height = e; + const n = s.apply(this, this._designResolutionSize); + if (n.scale && 2 === n.scale.length) { + this._scaleX = n.scale[0]; + this._scaleY = n.scale[1]; + } + if (n.viewport) { + const t = this._viewportRect; + const e = this._visibleRect; + const i = n.viewport; + t.x = i.x; + t.y = i.y; + t.width = i.width; + t.height = i.height; + e.x = 0; + e.y = 0; + e.width = i.width / this._scaleX; + e.height = i.height / this._scaleY; + } + s.postApply(this); + jR.width = this._visibleRect.width; + jR.height = this._visibleRect.height; + HR && HR.init(this._visibleRect); + this.emit("design-resolution-changed"); + } + getDesignResolutionSize() { + return new rs(this._designResolutionSize.width, this._designResolutionSize.height); + } + setRealPixelResolution(t, e, i) { + this.setDesignResolutionSize(t, e, i); + } + getViewportRect() { + return this._viewportRect; + } + getScaleX() { + return this._scaleX; + } + getScaleY() { + return this._scaleY; + } + getDevicePixelRatio() { + return Lo.devicePixelRatio; + } + convertToLocationInView(t, e, i, s = new Qi) { + const n = Lo.devicePixelRatio * (t - i.left); + const r = Lo.devicePixelRatio * (i.top + i.height - e); + if (Lo.isFrameRotated) { + s.x = Fo.windowSize.width - r; + s.y = n; + } else { + s.x = n; + s.y = r; + } + return s; + } + _convertToUISpace(t) { + const e = this._viewportRect; + t.x = (t.x - e.x) / this._scaleX; + t.y = (t.y - e.y) / this._scaleY; + } + _updateAdaptResult() { + var t; + m.director.root.resize(Fo.windowSize.width, Fo.windowSize.height); + const e = this._designResolutionSize.width; + const i = this._designResolutionSize.height; + e > 0 && this.setDesignResolutionSize(e, i, this._resolutionPolicy); + this.emit("canvas-resize"); + null === (t = this._resizeCallback) || void 0 === t || t.call(this); + } + } + t("View", WR); + WR.instance = void 0; + class YR { + constructor() { + this.name = "ContainerStrategy"; + } + preApply(t) {} + apply(t, e) {} + postApply(t) {} + _setupCanvas() { + const t = m.game.canvas; + if (t) { + const e = Fo.windowSize; + t.width = e.width; + t.height = e.height; + } + } + } + YR.EQUAL_TO_FRAME = void 0; + YR.PROPORTION_TO_FRAME = void 0; + class qR { + constructor() { + this.name = "ContentStrategy"; + this._result = void 0; + this._result = { + scale: [ 1, 1 ], + viewport: null + }; + } + preApply(t) {} + apply(t, e) { + return { + scale: [ 1, 1 ] + }; + } + postApply(t) {} + _buildResult(t, e, i, s, n, r) { + Math.abs(t - i) < 2 && (i = t); + Math.abs(e - s) < 2 && (s = e); + const o = new as(Math.round((t - i) / 2), Math.round((e - s) / 2), i, s); + this._result.scale = [ n, r ]; + this._result.viewport = o; + return this._result; + } + } + qR.EXACT_FIT = void 0; + qR.SHOW_ALL = void 0; + qR.NO_BORDER = void 0; + qR.FIXED_HEIGHT = void 0; + qR.FIXED_WIDTH = void 0; + (() => { + YR.EQUAL_TO_FRAME = new class extends YR { + constructor(...t) { + super(...t); + this.name = "EqualToFrame"; + } + apply(t, e) { + Lo.isProportionalToFrame = !1; + this._setupCanvas(); + } + }; + YR.PROPORTION_TO_FRAME = new class extends YR { + constructor(...t) { + super(...t); + this.name = "ProportionalToFrame"; + } + apply(t, e) { + Lo.isProportionalToFrame = !0; + this._setupCanvas(); + } + }; + qR.EXACT_FIT = new class extends qR { + constructor(...t) { + super(...t); + this.name = "ExactFit"; + } + apply(t, e) { + const i = Fo.windowSize; + const s = i.width; + const n = i.height; + const r = s / e.width; + const o = n / e.height; + return this._buildResult(s, n, s, n, r, o); + } + }; + qR.SHOW_ALL = new class extends qR { + constructor(...t) { + super(...t); + this.name = "ShowAll"; + } + apply(t, e) { + const i = Fo.windowSize; + const s = i.width; + const n = i.height; + const r = e.width; + const o = e.height; + const a = s / r; + const l = n / o; + let h = 0; + let c; + let u; + if (a < l) { + h = a; + c = s; + u = o * h; + } else { + h = l; + c = r * h; + u = n; + } + return this._buildResult(s, n, c, u, h, h); + } + }; + qR.NO_BORDER = new class extends qR { + constructor(...t) { + super(...t); + this.name = "NoBorder"; + } + apply(t, e) { + const i = Fo.windowSize; + const s = i.width; + const n = i.height; + const r = e.width; + const o = e.height; + const a = s / r; + const l = n / o; + let h; + let c; + let u; + if (a < l) { + h = l; + c = r * h; + u = n; + } else { + h = a; + c = s; + u = o * h; + } + return this._buildResult(s, n, c, u, h, h); + } + }; + qR.FIXED_HEIGHT = new class extends qR { + constructor(...t) { + super(...t); + this.name = "FixedHeight"; + } + apply(t, e) { + const i = Fo.windowSize; + const s = i.width; + const n = i.height; + const r = n / e.height; + const o = s; + const a = n; + return this._buildResult(s, n, o, a, r, r); + } + }; + qR.FIXED_WIDTH = new class extends qR { + constructor(...t) { + super(...t); + this.name = "FixedWidth"; + } + apply(t, e) { + const i = Fo.windowSize; + const s = i.width; + const n = i.height; + const r = s / e.width; + const o = s; + const a = n; + return this._buildResult(s, n, o, a, r, r); + } + }; + })(); + class KR { + constructor(t, e) { + this.name = "ResolutionPolicy"; + this._containerStrategy = void 0; + this._contentStrategy = void 0; + this._containerStrategy = null; + this._contentStrategy = null; + this.setContainerStrategy(t); + this.setContentStrategy(e); + } + get canvasSize() { + return Fo.windowSize; + } + preApply(t) { + this._contentStrategy.preApply(t); + } + apply(t, e) { + this._containerStrategy.apply(t, e); + return this._contentStrategy.apply(t, e); + } + postApply(t) { + this._contentStrategy.postApply(t); + } + setContainerStrategy(t) { + t instanceof YR && (this._containerStrategy = t); + } + setContentStrategy(t) { + t instanceof qR && (this._contentStrategy = t); + } + } + t("ResolutionPolicy", KR); + KR.EXACT_FIT = 0; + KR.NO_BORDER = 1; + KR.SHOW_ALL = 2; + KR.FIXED_HEIGHT = 3; + KR.FIXED_WIDTH = 4; + KR.UNKNOWN = 5; + KR.ContainerStrategy = YR; + KR.ContentStrategy = qR; + m.ResolutionPolicy = KR; + const JR = t("view", WR.instance = m.view = new WR); + IR.registerSystem("view", JR, 0); + m.winSize = jR; + Y(WR.prototype, "View.prototype", [ { + name: "isAntiAliasEnabled", + suggest: "The API of Texture2d have been largely modified, no alternative" + }, { + name: "enableAntiAlias", + suggest: "The API of Texture2d have been largely modified, no alternative" + } ]); + q(WR.prototype, "View.prototype", [ { + name: "adjustViewportMeta" + }, { + name: "enableAutoFullScreen", + suggest: "use screen.requestFullScreen() instead." + }, { + name: "isAutoFullScreenEnabled" + }, { + name: "setCanvasSize", + suggest: "setting size in CSS pixels is not recommended, please use screen.windowSize instead." + }, { + name: "getCanvasSize", + suggest: "please use screen.windowSize instead." + }, { + name: "getFrameSize", + suggest: "getting size in CSS pixels is not recommended, please use screen.windowSize instead." + }, { + name: "setFrameSize", + suggest: "setting size in CSS pixels is not recommended, please use screen.windowSize instead." + }, { + name: "getDevicePixelRatio", + suggest: "use screen.devicePixelRatio instead." + }, { + name: "convertToLocationInView" + }, { + name: "enableRetina" + }, { + name: "isRetinaEnabled" + }, { + name: "setRealPixelResolution" + } ]); + q(m, "cc", [ { + name: "winSize", + suggest: "please use view.getVisibleSize() instead." + } ]); + q(Vo, "sys", [ { + name: "capabilities", + suggest: "please use sys.hasFeature() method instead." + } ]); + W(Vo, "sys", [ "UNKNOWN", "ENGLISH", "CHINESE", "FRENCH", "ITALIAN", "GERMAN", "SPANISH", "DUTCH", "RUSSIAN", "KOREAN", "JAPANESE", "HUNGARIAN", "PORTUGUESE", "ARABIC", "NORWEGIAN", "POLISH", "TURKISH", "UKRAINIAN", "ROMANIAN", "BULGARIAN" ].map((t => ({ + name: `LANGUAGE_${t}`, + newName: t, + target: Vo.Language, + targetName: "sys.Language" + })))); + W(Vo, "sys", [ "UNKNOWN", "IOS", "ANDROID", "WINDOWS", "LINUX", "OSX" ].map((t => ({ + name: `OS_${t}`, + newName: t, + target: Vo.OS, + targetName: "sys.OS" + })))); + W(Vo, "sys", [ "UNKNOWN", "WECHAT", "ANDROID", "IE", "EDGE", "QQ", "MOBILE_QQ", "UC", "UCBS", "BAIDU_APP", "BAIDU", "MAXTHON", "OPERA", "OUPENG", "MIUI", "FIREFOX", "SAFARI", "CHROME", "LIEBAO", "QZONE", "SOUGOU", "HUAWEI" ].map((t => ({ + name: `BROWSER_TYPE_${t}`, + newName: t, + target: Vo.BrowserType, + targetName: "sys.BrowserType" + })))); + W(Vo, "sys", [ { + name: "BROWSER_TYPE_360", + newName: "BROWSER_360", + target: Vo.BrowserType, + targetName: "sys.BrowserType" + } ]); + W(Vo, "sys", [ "UNKNOWN", "EDITOR_PAGE", "EDITOR_CORE", "MOBILE_BROWSER", "DESKTOP_BROWSER", "WIN32", "MACOS", "IOS", "ANDROID", "OHOS", "WECHAT_GAME", "BAIDU_MINI_GAME", "XIAOMI_QUICK_GAME", "ALIPAY_MINI_GAME", "BYTEDANCE_MINI_GAME", "OPPO_MINI_GAME", "VIVO_MINI_GAME", "HUAWEI_QUICK_GAME", "COCOSPLAY", "LINKSURE_MINI_GAME", "QTT_MINI_GAME" ].map((t => ({ + name: t, + target: Vo.Platform, + targetName: "sys.Platform" + })))); + W(Vo, "sys", [ { + name: "IPHONE", + newName: "IOS", + target: Vo.Platform, + targetName: "sys.Platform" + }, { + name: "IPAD", + newName: "IOS", + target: Vo.Platform, + targetName: "sys.Platform" + } ]); + Y(Vo, "sys", [ "LINUX", "BLACKBERRY", "NACL", "EMSCRIPTEN", "TIZEN", "WINRT", "WP8", "QQ_PLAY", "FB_PLAYABLE_ADS" ].map((t => ({ + name: t + })))); + W(Vo, "sys", [ { + name: "windowPixelResolution", + target: Fo, + targetName: "screen", + newName: "windowSize" + } ]); + q(Fo, "screen", [ { + name: "autoFullScreen", + suggest: "please use screen.requestFullScreen() instead." + }, { + name: "disableAutoFullScreen" + } ]); + const ZR = [ ".png", ".jpg", ".bmp", ".jpeg", ".gif", ".ico", ".tiff", ".webp", ".image", ".pvr", ".pkm", ".astc" ]; + const QR = [ ".mp3", ".ogg", ".wav", ".m4a" ]; + function $R() { + return !0; + } + const tI = { + transformURL(t) { + const e = qh(t); + if (!e) return t; + const i = Ph.find((t => !!t.getAssetInfo(e))); + if (!i) return t; + let s = ""; + const n = i.getAssetInfo(e); + s = t.startsWith(i.base + i.config.nativeBase) ? n.nativeVer || "" : n.ver || ""; + if (!s || -1 !== t.indexOf(s)) return t; + let r = !1; + ".ttf" === nc(t) && (r = !0); + if (r) { + const e = ac(t); + const i = oc(t); + t = `${e}.${s}/${i}`; + } else t = t.replace(/.*[/\\][0-9a-fA-F]{2}[/\\]([0-9a-fA-F-@]{8,})/, ((t, e) => `${t}.${s}`)); + return t; + } + }; + class eI { + constructor() { + this._autoReleaseSetting = Object.create(null); + this._parseLoadResArgs = Dw; + } + set onProgress(t) { + Ew = t; + } + get _cache() { + if (Mh instanceof Rh) return Mh._map; + { + const t = {}; + Mh.forEach(((e, i) => { + t[i] = e; + })); + return t; + } + } + load(t, e, i) { + if (void 0 === i && void 0 !== e) { + i = e; + e = null; + } + const s = Array.isArray(t) ? t : [ t ]; + for (let t = 0; t < s.length; t++) { + const e = s[t]; + if ("string" == typeof e) s[t] = { + url: e, + __isNative__: !0 + }; else { + if (e.type) { + e.ext = `.${e.type}`; + e.type = void 0; + } + e.url && (e.__isNative__ = !0); + } + } + const n = []; + const r = []; + SR.loadAny(s, null, ((t, i, s) => { + s.content && (ZR.includes(s.ext) ? n.push(s.content) : QR.includes(s.ext) && r.push(s.content)); + e && e(t, i, s); + }), ((t, e) => { + let o = null; + if (!t) { + e = Array.isArray(e) ? e : [ e ]; + for (let t = 0; t < e.length; t++) { + const i = e[t]; + if (!(i instanceof gc)) { + let o = i; + const a = s[t].url; + n.includes(o) ? sR.create(a, i, ".png", {}, ((i, s) => { + o = e[t] = s; + })) : r.includes(o) && sR.create(a, i, ".mp3", {}, ((i, s) => { + o = e[t] = s; + })); + Mh.add(a, o); + } + } + if (e.length > 1) { + const t = Object.create(null); + e.forEach((e => { + t[e._uuid] = e; + })); + o = { + isCompleted: $R, + _map: t + }; + } else o = e[0]; + } + i && i(t, o); + })); + } + getXMLHttpRequest() { + return new XMLHttpRequest; + } + getItem(t) { + return SR.assets.has(t) ? { + content: SR.assets.get(t) + } : null; + } + loadRes(t, e, i, s) { + const {type: n, onProgress: r, onComplete: o} = this._parseLoadResArgs(e, i, s); + const a = nc(t); + a && !Lw.getInfoWithPath(t, n) && (t = t.slice(0, -a.length)); + Lw.load(t, n, r, o); + } + loadResArray(t, e, i, s) { + const {type: n, onProgress: r, onComplete: o} = this._parseLoadResArgs(e, i, s); + t.forEach(((e, i) => { + const s = nc(e); + s && !Lw.getInfoWithPath(e, n) && (t[i] = e.slice(0, -s.length)); + })); + Lw.load(t, n, r, o); + } + loadResDir(t, e, i, s) { + const {type: n, onProgress: r, onComplete: o} = this._parseLoadResArgs(e, i, s); + Lw.loadDir(t, n, r, ((e, i) => { + let s = []; + if (!e) { + s = Lw.getDirWithPath(t, n).map((t => t.path)); + } + o && o(e, i, s); + })); + } + getRes(t, e) { + return Mh.has(t) ? Mh.get(t) : Lw.get(t, e); + } + getResCount() { + return Mh.count; + } + getDependsRecursively(t) { + if (!t) return []; + const e = "string" == typeof t ? t : t._uuid; + return pA.getDepsRecursively(e).concat([ e ]); + } + get md5Pipe() { + return tI; + } + get downloader() { + return Jw; + } + get loader() { + return SR.parser; + } + addDownloadHandlers(t) { + const e = Object.create(null); + for (const i in t) { + const s = t[i]; + e[`.${i}`] = (t, e, i) => { + s({ + url: t + }, i); + }; + } + Jw.register(e); + } + addLoadHandlers(t) { + const e = Object.create(null); + for (const i in t) { + const s = t[i]; + e[`.${i}`] = (t, e, i) => { + s({ + content: t + }, i); + }; + } + cR.register(e); + } + release(t) { + if (Array.isArray(t)) for (let e = 0; e < t.length; e++) { + let i = t[e]; + "string" == typeof i && (i = Mh.get(i)); + SR.releaseAsset(i); + } else if (t) { + "string" == typeof t && (t = Mh.get(t)); + SR.releaseAsset(t); + } + } + releaseAsset(t) { + SR.releaseAsset(t); + } + releaseRes(t, e) { + Lw.release(t, e); + } + releaseAll() { + SR.releaseAll(); + Mh.clear(); + } + removeItem(t) { + return !!Mh.remove(t); + } + setAutoRelease(t, e) { + "object" == typeof t && (t = t._uuid); + this._autoReleaseSetting[t] = !!e; + } + setAutoReleaseRecursively(t, e) { + "object" == typeof t && (t = t._uuid); + e = !!e; + this._autoReleaseSetting[t] = e; + const i = pA.getDepsRecursively(t); + for (let t = 0; t < i.length; t++) this._autoReleaseSetting[i[t]] = e; + } + isAutoRelease(t) { + "object" == typeof t && (t = t._uuid); + return !!this._autoReleaseSetting[t]; + } + } + t("CCLoader", eI); + const iI = t("loader", new eI); + const sI = t("AssetLibrary", { + init(t) { + t.importBase = t.libraryPath; + t.nativeBase = t.rawAssetsBase; + SR.init(t); + t.rawAssets && Lw.init({ + base: "", + deps: [], + scenes: {}, + redirect: [], + debug: !0, + packs: {}, + types: [], + versions: { + import: [], + native: [] + }, + name: Uh.RESOURCES, + importBase: t.importBase, + nativeBase: t.nativeBase, + paths: t.rawAssets.assets, + uuids: Object.keys(t.rawAssets.assets), + extensionMap: {} + }); + }, + loadAsset(t, e, i) { + SR.loadAny(t, e); + } + }); + const nI = t("url", {}); + W(nI, "url", [ { + name: "normalize", + target: SR.utils, + targetName: "assetManager.utils", + newName: "normalize" + }, { + name: "raw", + targetName: "Asset.prototype", + newName: "nativeUrl", + customFunction: t => t.startsWith("resources/") ? Qh({ + path: lc(t.substr(10)), + bundle: Uh.RESOURCES, + __isNative__: !0, + ext: nc(t) + }) : "" + } ]); + Y(sI, "AssetLibrary", [ { + name: "getLibUrlNoExt", + suggest: "AssetLibrary.getLibUrlNoExt was removed, if you want to transform url, please use assetManager.utils.getUrlWithUuid instead" + }, { + name: "queryAssetInfo", + suggest: "AssetLibrary.queryAssetInfo was removed" + } ]); + Y(iI, "loader", [ { + name: "releaseResDir", + suggest: "loader.releaseResDir was removed, please use assetManager.releaseAsset instead" + }, { + name: "flowInDeps", + suggest: "loader.flowInDeps was removed" + }, { + name: "assetLoader", + suggest: "loader.assetLoader was removed, assetLoader and md5Pipe were merged into assetManager.transformPipeline" + } ]); + W(m, "cc", [ { + name: "loader", + newName: "assetManager", + logTimes: 1, + customGetter: () => iI + }, { + name: "AssetLibrary", + newName: "assetManager", + logTimes: 1, + customGetter: () => sI + }, { + name: "Pipeline", + target: bR, + targetName: "AssetManager", + newName: "Pipeline", + logTimes: 1 + }, { + name: "url", + targetName: "assetManager", + newName: "utils", + logTimes: 1, + customGetter: () => nI + } ]); + Y(m, "cc", [ { + name: "LoadingItems", + suggest: G(1400, "LoadingItems", "AssetManager.Task") + } ]); + W(pe, "macro", [ { + name: "DOWNLOAD_MAX_CONCURRENT", + target: Jw, + targetName: "assetManager.downloader", + newName: "maxConcurrency" + } ]); + W(IR, "director", [ { + name: "_getSceneUuid", + targetName: "assetManager.main", + newName: "getSceneInfo", + customFunction: t => { + if (SR.main) { + var e; + return null === (e = SR.main.getSceneInfo(t)) || void 0 === e ? void 0 : e.uuid; + } + return ""; + } + } ]); + W(BR, "game", [ { + name: "_sceneInfos", + targetName: "assetManager.main", + newName: "getSceneInfo", + customGetter: () => { + const t = []; + SR.main && SR.main.config.scenes.forEach((e => { + t.push(e); + })); + return t; + } + } ]); + const rI = vw._autoRelease; + vw._autoRelease = function(t, e, i) { + rI.call(vw, t, e, i); + const s = iI._autoReleaseSetting; + const n = Object.keys(s); + for (let t = 0; t < n.length; t++) { + const e = n[t]; + if (!0 === s[e]) { + const t = Mh.get(e); + t && vw.tryRelease(t); + } + } + }; + function oI(t, e) { + t.x = e.x * e.x; + t.y = e.y * e.y; + t.z = e.z * e.z; + } + class aI {} + function lI(t, e, i, s = null, n = 0) { + const r = new hn; + const o = t.viewport; + const a = e; + const l = i; + r.x = o.x * a; + r.y = o.y * l; + r.width = o.width * a; + r.height = o.height * l; + if (s) switch (s.type) { + case BA.DIRECTIONAL: + { + const t = s; + if (t.shadowFixedArea || t.csmLevel === HA.LEVEL_1) { + r.x = 0; + r.y = 0; + r.width = a; + r.height = l; + } else { + r.x = n % 2 * .5 * a; + r.y = .5 * (1 - Math.floor(n / 2)) * l; + r.width = .5 * a; + r.height = .5 * l; + } + break; + } + + case BA.SPOT: + r.x = 0; + r.y = 0; + r.width = a; + r.height = l; + } + return r; + } + function hI(t, e, i, s, n, r, o) { + const a = e.device; + const l = t; + if (!e.containsResource(l)) { + const t = Xf(a) ? bs.R32F : bs.RGBA8; + e.addRenderTarget(l, t, r, o, _x); + e.addDepthStencil(`${l}Depth`, bs.DEPTH_STENCIL, r, o, _x); + } + const h = e.addRasterPass(r, o, "default", t); + h.addRasterView(l, new Bx("_", Mx, wx, Us.CLEAR, Gs.STORE, en.COLOR, new gn(1, 1, 1, i.clearColor.w))); + h.addRasterView(`${l}Depth`, new Bx("_", Mx, Rx, Us.CLEAR, Gs.DISCARD, en.DEPTH_STENCIL, new gn(i.clearDepth, i.clearStencil, 0, 0))); + const c = lI(i, r, o, s, n); + h.setViewport(new fn(c.x, c.y, c.width, c.height)); + h.addQueue(px).addSceneOfCamera(i, new Ox(s, n), Sx); + } + class cI { + constructor() { + this.shadowEnabled = !1; + this.mainLightShadowNames = new Array; + this.spotLightShadowNames = new Array; + } + } + function uI(t, e, i) { + const s = i; + const n = s.pipelineSceneData.shadows; + const r = i.pipelineSceneData.validPunctualLights; + const o = new cI; + const a = i.pipelineSceneData.shadows; + if (!n.enabled || n.type !== GA.ShadowMap) return o; + o.shadowEnabled = !0; + const l = []; + let h = 0; + let c = 0; + for (;h < n.maxReceived && c < r.length; ) { + const t = r[c]; + if (t.type === BA.SPOT) { + if (t.shadowEnabled) { + l.push(t); + h++; + } + } + c++; + } + const {mainLight: u} = e.scene; + const _ = a.size.x; + const d = a.size.y; + if (u && u.shadowEnabled) { + o.mainLightShadowNames[0] = `MainLightShadow${t}`; + if (u.shadowFixedArea) hI(o.mainLightShadowNames[0], i, e, u, 0, _, d); else { + const n = s.pipelineSceneData.csmSupported ? u.csmLevel : 1; + for (let s = 0; s < n; s++) { + o.mainLightShadowNames[s] = `MainLightShadow${t}`; + hI(o.mainLightShadowNames[s], i, e, u, s, _, d); + } + } + } + for (let s = 0; s < l.length; s++) { + const n = l[s]; + const r = `SpotLightShadow${s.toString()}${t}`; + o.spotLightShadowNames[s] = r; + hI(r, i, e, n, 0, _, d); + } + return o; + } + const _I = []; + function dI(t) { + _I.includes(t) || _I.push(t); + return _I.indexOf(t); + } + function pI(t, e) { + let i = Us.CLEAR; + t & en.COLOR || e !== wx || (i = t & My ? Us.DISCARD : Us.LOAD); + if ((t & en.DEPTH_STENCIL) !== en.DEPTH_STENCIL && e === Rx) { + t & en.DEPTH || (i = Us.LOAD); + t & en.STENCIL || (i = Us.LOAD); + } + return i; + } + t("ForwardPipelineBuilder", class extends aI { + setup(t, e) { + for (let i = 0; i < t.length; i++) { + const s = t[i]; + if (null === s.scene) continue; + gI(e, s); + const n = dI(s); + const r = `Camera${n}`; + const o = uI(r, s, e); + const a = s.window.width; + const l = s.window.height; + const h = `dsForwardPassColor${r}`; + const c = `dsForwardPassDS${r}`; + if (!e.containsResource(h)) { + e.addRenderTexture(h, bs.RGBA8, a, l, s.window); + e.addDepthStencil(c, bs.DEPTH_STENCIL, a, l, _x); + } + const u = e.addRasterPass(a, l, "default", `CameraForwardPass${n}`); + for (const t of o.mainLightShadowNames) if (e.containsResource(t)) { + const e = new Px; + u.addComputeView(t, e); + } + for (const t of o.spotLightShadowNames) if (e.containsResource(t)) { + const e = new Px; + u.addComputeView(t, e); + } + const _ = new Bx("_", Mx, wx, pI(s.clearFlag, wx), Gs.STORE, s.clearFlag, new gn(s.clearColor.x, s.clearColor.y, s.clearColor.z, s.clearColor.w)); + const d = new Bx("_", Mx, Rx, pI(s.clearFlag, Rx), Gs.STORE, s.clearFlag, new gn(s.clearDepth, s.clearStencil, 0, 0)); + u.addRasterView(h, _); + u.addRasterView(c, d); + u.addQueue(px).addSceneOfCamera(s, new Ox, gx | Ex | yx | Ex | Tx); + u.addQueue(mx).addSceneOfCamera(s, new Ox, bx | Ax | Cx | xx); + } + } + }); + let mI; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.FXAA = 1] = "FXAA"; + }(mI || (mI = t("AntiAliasing", {}))); + class fI { + constructor() { + this._deferredLightingMaterial = void 0; + this._deferredPostMaterial = void 0; + this._antiAliasing = mI.NONE; + this._deferredLightingMaterial = new hm; + this._deferredLightingMaterial.name = "builtin-deferred-material"; + this._deferredLightingMaterial.initialize({ + effectName: "pipeline/deferred-lighting", + defines: { + CC_RECEIVE_SHADOW: 1 + } + }); + for (let t = 0; t < this._deferredLightingMaterial.passes.length; ++t) this._deferredLightingMaterial.passes[t].tryCompile(); + this._deferredPostMaterial = new hm; + this._deferredPostMaterial.name = "builtin-post-process-material"; + pe.ENABLE_ANTIALIAS_FXAA && (this._antiAliasing = mI.FXAA); + this._deferredPostMaterial.initialize({ + effectName: "pipeline/post-process", + defines: { + ANTIALIAS_TYPE: this._antiAliasing + } + }); + for (let t = 0; t < this._deferredPostMaterial.passes.length; ++t) this._deferredPostMaterial.passes[t].tryCompile(); + } + } + function gI(t, e) { + const i = t.pipelineSceneData.validPunctualLights; + i.length = 0; + const s = ua.create(0, 0, 0, 1); + const {spotLights: n} = e.scene; + for (let t = 0; t < n.length; t++) { + const r = n[t]; + if (!r.baked) { + ua.set(s, r.position.x, r.position.y, r.position.z, r.range); + Za.sphereFrustum(s, e.frustum) && i.push(r); + } + } + const {sphereLights: r} = e.scene; + for (let t = 0; t < r.length; t++) { + const n = r[t]; + if (!n.baked) { + ua.set(s, n.position.x, n.position.y, n.position.z, n.range); + Za.sphereFrustum(s, e.frustum) && i.push(n); + } + } + } + t("DeferredPipelineBuilder", class extends aI { + constructor(...t) { + super(...t); + this._deferredData = new fI; + } + setup(t, e) { + for (let i = 0; i < t.length; ++i) { + const s = t[i]; + if (!s.scene) continue; + gI(e, s); + const n = dI(s); + const r = uI(`Camera${n}`, s, e); + const o = s.window.width; + const a = s.window.height; + const l = "dsDeferredPassColorCamera"; + const h = "deferredGbufferPassNormal"; + const c = "deferredGbufferPassEmissive"; + const u = "dsDeferredPassDSCamera"; + if (!e.containsResource(l)) { + const t = bs.RGBA16F; + e.addRenderTarget(l, t, o, a, _x); + e.addRenderTarget(h, t, o, a, _x); + e.addRenderTarget(c, t, o, a, _x); + e.addDepthStencil(u, bs.DEPTH_STENCIL, o, a, _x); + } + const _ = e.addRasterPass(o, a, "Geometry", `CameraGbufferPass${n}`); + const d = new gn(0, 0, 0, 0); + if (s.clearFlag & en.COLOR) if (e.pipelineSceneData.isHDR) oI(d, s.clearColor); else { + d.x = s.clearColor.x; + d.y = s.clearColor.y; + d.z = s.clearColor.z; + } + const p = new Bx("_", Mx, wx, Us.CLEAR, Gs.STORE, s.clearFlag, d); + const m = new Bx("_", Mx, wx, Us.CLEAR, Gs.STORE, s.clearFlag, new gn(0, 0, 0, 0)); + const f = new Bx("_", Mx, wx, Us.CLEAR, Gs.STORE, s.clearFlag, new gn(0, 0, 0, 0)); + const g = new Bx("_", Mx, Rx, Us.CLEAR, Gs.STORE, s.clearFlag, new gn(s.clearDepth, s.clearStencil, 0, 0)); + _.addRasterView(l, p); + _.addRasterView(h, m); + _.addRasterView(c, f); + _.addRasterView(u, g); + _.addQueue(px).addSceneOfCamera(s, new Ox, gx | yx); + const y = "deferredLightingPassRTName"; + const b = "deferredLightingPassDS"; + if (!e.containsResource(y)) { + e.addRenderTarget(y, bs.RGBA8, o, a, _x); + e.addDepthStencil(b, bs.DEPTH_STENCIL, o, a, _x); + } + const S = e.addRasterPass(o, a, "Lighting", `CameraLightingPass${n}`); + for (const t of r.mainLightShadowNames) if (e.containsResource(t)) { + const e = new Px; + S.addComputeView(t, e); + } + for (const t of r.spotLightShadowNames) if (e.containsResource(t)) { + const e = new Px; + S.addComputeView(t, e); + } + if (e.containsResource(l)) { + const t = new Px; + t.name = "gbuffer_albedoMap"; + S.addComputeView(l, t); + const e = new Px; + e.name = "gbuffer_normalMap"; + S.addComputeView(h, e); + const i = new Px; + i.name = "gbuffer_emissiveMap"; + S.addComputeView(c, i); + const s = new Px; + s.name = "depth_stencil"; + S.addComputeView(u, s); + } + const A = new gn(0, 0, 0, 0); + if (s.clearFlag & en.COLOR) { + A.x = s.clearColor.x; + A.y = s.clearColor.y; + A.z = s.clearColor.z; + } + A.w = 0; + const T = new Bx("_", Mx, wx, Us.CLEAR, Gs.STORE, s.clearFlag, A); + S.addRasterView(y, T); + S.addQueue(mx).addCameraQuad(s, this._deferredData._deferredLightingMaterial, vx); + S.addQueue(mx).addSceneOfCamera(s, new Ox, bx | Ex | Cx); + const v = `postprocessPassRTName${n}`; + const E = `postprocessPassDS${n}`; + if (!e.containsResource(v)) { + e.addRenderTexture(v, bs.RGBA8, o, a, s.window); + e.addDepthStencil(E, bs.DEPTH_STENCIL, o, a, _x); + } + const C = e.addRasterPass(o, a, "Postprocess", `CameraPostprocessPass${n}`); + if (e.containsResource(y)) { + const t = new Px; + t.name = "outputResultMap"; + C.addComputeView(y, t); + } + const x = new gn(0, 0, 0, s.clearColor.w); + if (s.clearFlag & en.COLOR) { + x.x = s.clearColor.x; + x.y = s.clearColor.y; + x.z = s.clearColor.z; + } + const w = new Bx("_", Mx, wx, pI(s.clearFlag, wx), Gs.STORE, s.clearFlag, x); + const R = new Bx("_", Mx, Rx, pI(s.clearFlag, Rx), Gs.STORE, s.clearFlag, new gn(s.clearDepth, s.clearStencil, 0, 0)); + C.addRasterView(v, w); + C.addRasterView(E, R); + C.addQueue(dx).addFullscreenQuad(this._deferredData._deferredPostMaterial, fx); + C.addQueue(mx).addSceneOfCamera(s, new Ox, Ax | xx); + } + } + }); + m.math = us; + m.geometry = Wp; + const yI = new qi; + function bI(t, e, i, s) { + const n = i.chunk; + const r = i.data; + const o = n.vb; + const a = i.vertexCount; + t.getWorldMatrix(yI); + let l = 0; + for (let t = 0; t < a; t++) { + const e = r[t]; + const i = e.x; + const n = e.y; + let a = yI.m03 * i + yI.m07 * n + yI.m15; + a = a ? Math.abs(1 / a) : 1; + o[l + 0] = (yI.m00 * i + yI.m04 * n + yI.m12) * a; + o[l + 1] = (yI.m01 * i + yI.m05 * n + yI.m13) * a; + o[l + 2] = (yI.m02 * i + yI.m06 * n + yI.m14) * a; + Bi.toArray(o, s, l + 5); + l += 9; + } + n.bufferId; + const h = n.vertexOffset; + const c = n.meshBuffer; + const u = n.meshBuffer.iData; + let _ = c.indexOffset; + for (let t = 0, e = a / 4; t < e; t++) { + const e = h + 4 * t; + u[_++] = e; + u[_++] = e + 1; + u[_++] = e + 2; + u[_++] = e + 1; + u[_++] = e + 3; + u[_++] = e + 2; + } + c.indexOffset += i.indexCount; + c.setDirty(); + } + const SI = {}; + class AI { + constructor(t, e) { + this._texture = void 0; + this._width = void 0; + this._height = void 0; + this._x = void 0; + this._y = void 0; + this._nexty = void 0; + this._innerTextureInfos = {}; + this._innerSpriteFrames = void 0; + this._count = void 0; + const i = new TI; + i.initWithSize(t, e); + this._texture = i; + this._width = t; + this._height = e; + this._x = 2; + this._y = 2; + this._nexty = 2; + this._innerTextureInfos = {}; + this._innerSpriteFrames = []; + this._count = 0; + } + insertSpriteFrame(t) { + const e = t.rect; + const i = t.texture; + const s = this._innerTextureInfos[i.getId()]; + let n = e.x; + let r = e.y; + if (s) { + n += s.x; + r += s.y; + } else { + const t = i.width; + const e = i.height; + if (this._x + t + 2 > this._width) { + this._x = 2; + this._y = this._nexty; + } + this._y + e + 2 > this._nexty && (this._nexty = this._y + e + 2); + if (this._nexty > this._height) return null; + if (m.internal.dynamicAtlasManager.textureBleeding) { + if (t <= 8 || e <= 8) { + this._texture.drawTextureAt(i.image, this._x - 1, this._y - 1); + this._texture.drawTextureAt(i.image, this._x - 1, this._y + 1); + this._texture.drawTextureAt(i.image, this._x + 1, this._y - 1); + this._texture.drawTextureAt(i.image, this._x + 1, this._y + 1); + } + this._texture.drawTextureAt(i.image, this._x - 1, this._y); + this._texture.drawTextureAt(i.image, this._x + 1, this._y); + this._texture.drawTextureAt(i.image, this._x, this._y - 1); + this._texture.drawTextureAt(i.image, this._x, this._y + 1); + } + this._texture.drawTextureAt(i.image, this._x, this._y); + this._innerTextureInfos[i.getId()] = { + x: this._x, + y: this._y, + texture: i + }; + this._count++; + n += this._x; + r += this._y; + this._x += t + 2; + } + const o = { + x: n, + y: r, + texture: this._texture + }; + this._innerSpriteFrames.push(t); + return o; + } + deleteInnerTexture(t) { + if (t && this._innerTextureInfos[t.getId()]) { + delete this._innerTextureInfos[t.getId()]; + this._count--; + } + } + isEmpty() { + return this._count <= 0; + } + reset() { + this._x = 2; + this._y = 2; + this._nexty = 2; + const t = this._innerSpriteFrames; + for (let e = 0, i = t.length; e < i; e++) { + const i = t[e]; + i.isValid && i._resetDynamicAtlasFrame(); + } + this._innerSpriteFrames.length = 0; + this._innerTextureInfos = {}; + } + destroy() { + this.reset(); + this._texture.destroy(); + } + } + class TI extends LC { + initWithSize(t, e, i = Jp.RGBA8888) { + this.reset({ + width: t, + height: e, + format: i + }); + } + drawTextureAt(t, e, i) { + const s = this.getGFXTexture(); + if (!t || !s) return; + const n = this._getGFXDevice(); + if (!n) { + console.warn("Unable to get device"); + return; + } + const r = new mn; + r.texOffset.x = e; + r.texOffset.y = i; + r.texExtent.width = t.width; + r.texExtent.height = t.height; + n.copyTexImagesToTexture([ t.data ], s, [ r ]); + } + } + class vI extends Tg { + constructor(...t) { + super(...t); + this._atlases = []; + this._atlasIndex = -1; + this._maxAtlasCount = 5; + this._textureSize = 2048; + this._maxFrameSize = 512; + this._textureBleeding = !0; + this._enabled = !1; + } + get enabled() { + return this._enabled; + } + set enabled(t) { + if (this._enabled !== t) { + if (t) { + this.reset(); + m.director.on(m.Director.EVENT_BEFORE_SCENE_LAUNCH, this.beforeSceneLoad, this); + } else { + this.reset(); + m.director.off(m.Director.EVENT_BEFORE_SCENE_LAUNCH, this.beforeSceneLoad, this); + } + this._enabled = t; + } + } + get maxAtlasCount() { + return this._maxAtlasCount; + } + set maxAtlasCount(t) { + this._maxAtlasCount = t; + } + get atlasCount() { + return this._atlases.length; + } + get textureBleeding() { + return this._textureBleeding; + } + set textureBleeding(t) { + this._textureBleeding = t; + } + get textureSize() { + return this._textureSize; + } + set textureSize(t) { + this._textureSize = t; + } + get maxFrameSize() { + return this._maxFrameSize; + } + set maxFrameSize(t) { + this._maxFrameSize = t; + } + newAtlas() { + let t = this._atlases[++this._atlasIndex]; + if (!t) { + t = new AI(this._textureSize, this._textureSize); + this._atlases.push(t); + } + return t; + } + beforeSceneLoad() { + this.reset(); + } + init() { + this.enabled = !pe.CLEANUP_IMAGE_CACHE; + } + insertSpriteFrame(t) { + if (!this._enabled || this._atlasIndex === this._maxAtlasCount || !t || t._original) return null; + if (!t.packable) return null; + const e = t.texture.getSamplerInfo(); + if (e.minFilter !== Qp.LINEAR || e.magFilter !== Qp.LINEAR || e.mipFilter !== Qp.NONE) return null; + let i = this._atlases[this._atlasIndex]; + i || (i = this.newAtlas()); + const s = i.insertSpriteFrame(t); + if (!s && this._atlasIndex !== this._maxAtlasCount) { + i = this.newAtlas(); + return i.insertSpriteFrame(t); + } + return s; + } + reset() { + for (let t = 0, e = this._atlases.length; t < e; t++) this._atlases[t].destroy(); + this._atlases.length = 0; + this._atlasIndex = -1; + } + deleteAtlasSpriteFrame(t) { + if (!t._original) return; + let e; + for (let i = this._atlases.length - 1; i >= 0; i--) { + e = this._atlases[i]; + ee.array.fastRemove(e._innerSpriteFrames, t); + } + const i = t._original._texture; + this.deleteAtlasTexture(i); + } + deleteAtlasTexture(t) { + if (t) for (let e = this._atlases.length - 1; e >= 0; e--) { + this._atlases[e].deleteInnerTexture(t); + if (this._atlases[e].isEmpty()) { + this._atlases[e].destroy(); + this._atlases.splice(e, 1); + this._atlasIndex--; + } + } + } + packToDynamicAtlas(t, e) { + if (this._enabled && e && !e._original && e.packable && e.texture && e.texture.width > 0 && e.texture.height > 0) { + const t = this.insertSpriteFrame(e); + t && e._setDynamicAtlasFrame(t); + } + } + } + vI.instance = void 0; + const EI = t("dynamicAtlasManager", vI.instance = new vI); + IR.registerSystem("dynamicAtlasManager", EI, 0); + m.internal.dynamicAtlasManager = EI; + const CI = { + [Ss.UNORM]: "Uint", + [Ss.SNORM]: "Int", + [Ss.UINT]: "Uint", + [Ss.INT]: "Int", + [Ss.UFLOAT]: "Float", + [Ss.FLOAT]: "Float", + default: "Uint" + }; + function xI(t) { + return `${CI[t.type] || CI.default}${t.size / t.count * 8}`; + } + function wI(t, e, i = bs.R32F, s = 0, n = 0) { + const r = ur[i]; + n || (n = r.size); + const o = `set${xI(r)}`; + const a = r.size / r.count; + const l = Math.floor(e.length / r.count); + const h = Vo.isLittleEndian; + for (let i = 0; i < l; ++i) { + const l = s + n * i; + for (let s = 0; s < r.count; ++s) { + const n = l + a * s; + t[o](n, e[r.count * i + s], h); + } + } + } + function RI(t, e = bs.R32F, i = 0, s = t.byteLength - i, n = 0, r = []) { + const o = ur[e]; + n || (n = o.size); + const a = `get${xI(o)}`; + const l = o.size / o.count; + const h = Math.floor(s / n); + const c = Vo.isLittleEndian; + for (let e = 0; e < h; ++e) { + const s = i + n * e; + for (let i = 0; i < o.count; ++i) { + const n = s + l * i; + r[o.count * e + i] = t[a](n, c); + } + } + return r; + } + function II(t, e, i = bs.R32F, s = 0, n = t.byteLength - s, r = 0, o) { + o || (o = new DataView(t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength))); + const a = ur[i]; + r || (r = a.size); + const l = `set${xI(a)}`; + const h = `get${xI(a)}`; + const c = a.size / a.count; + const u = Math.floor(n / r); + const _ = Vo.isLittleEndian; + for (let i = 0; i < u; ++i) { + const n = s + r * i; + for (let i = 0; i < a.count; ++i) { + const s = n + c * i; + const r = t[h](s, _); + o[l](s, e(r, i, t), _); + } + } + return o; + } + var MI; + !function(t) { + t[t.positions = cr.ATTR_POSITION] = "positions"; + t[t.normals = cr.ATTR_NORMAL] = "normals"; + t[t.uvs = cr.ATTR_TEX_COORD] = "uvs"; + t[t.colors = cr.ATTR_COLOR] = "colors"; + }(MI || (MI = {})); + const BI = jsb.MeshUtils; + const DI = BI.createMesh; + BI.createDynamicMesh; + m.MeshUtils = jsb.MeshUtils; + var PI = Object.freeze({ + __proto__: null, + find: mv, + toPPM: function(t, e, i) { + return `P3 ${e} ${i} 255\n${t.filter(((t, e) => e % 4 < 3)).toString()}\n`; + }, + readMesh: function(t, e = 0) { + const i = { + positions: [] + }; + const s = new DataView(t.data.buffer, t.data.byteOffset, t.data.byteLength); + const n = t.struct; + const r = n.primitives[e]; + for (const t of r.vertexBundelIndices) { + const e = n.vertexBundles[t]; + let r = e.view.offset; + const {length: o, stride: a} = e.view; + for (const t of e.attributes) { + const e = MI[t.name]; + e && (i[e] = (i[e] || []).concat(RI(s, t.format, r, o, a))); + r += ur[t.format].size; + } + } + const o = r.indexView; + i.indices = RI(s, bs[`R${8 * o.stride}UI`], o.offset, o.length); + return i; + }, + createMesh: DI, + MeshUtils: BI, + readBuffer: RI, + writeBuffer: wI, + mapBuffer: II + }); + t("utils", PI); + var OI, NI, LI; + const FI = new Pi; + const VI = new qi; + var kI; + !function(t) { + t[t.RECT = 0] = "RECT"; + t[t.POLYGON = 1] = "POLYGON"; + }(kI || (kI = {})); + const UI = [ { + u: 0, + v: 0 + }, { + u: 0, + v: 0 + }, { + u: 0, + v: 0 + }, { + u: 0, + v: 0 + } ]; + let GI = t("SpriteFrame", Ul("cc.SpriteFrame")(OI = (LI = NI = class t extends gc { + static createWithImage(e) { + const i = e instanceof IC ? e : new IC(e); + const s = new LC; + s.image = i; + const n = new t; + n.texture = s; + return n; + } + get insetTop() { + return this._capInsets[1]; + } + set insetTop(t) { + if (this._capInsets[1] !== t) { + this._capInsets[1] = t; + this._texture && this._calculateSlicedUV(); + } + } + get insetBottom() { + return this._capInsets[3]; + } + set insetBottom(t) { + if (this._capInsets[3] !== t) { + this._capInsets[3] = t; + this._texture && this._calculateSlicedUV(); + } + } + get insetLeft() { + return this._capInsets[0]; + } + set insetLeft(t) { + if (this._capInsets[0] !== t) { + this._capInsets[0] = t; + this._texture && this._calculateSlicedUV(); + } + } + get insetRight() { + return this._capInsets[2]; + } + set insetRight(t) { + if (this._capInsets[2] !== t) { + this._capInsets[2] = t; + this._texture && this._calculateSlicedUV(); + } + } + get rect() { + return this._rect; + } + set rect(t) { + if (!this._rect.equals(t)) { + this._rect.set(t); + this._texture && this._calculateUV(); + this._calcTrimmedBorder(); + } + } + get originalSize() { + return this._originalSize; + } + set originalSize(t) { + if (!this._originalSize.equals(t)) { + this._originalSize.set(t); + this._texture && this._calculateUV(); + this._calcTrimmedBorder(); + } + } + get offset() { + return this._offset; + } + set offset(t) { + this._offset.set(t); + this._calcTrimmedBorder(); + } + get rotated() { + return this._rotated; + } + set rotated(t) { + if (this._rotated !== t) { + this._rotated = t; + this._texture && this._calculateUV(); + } + } + get texture() { + return this._texture; + } + set texture(t) { + t ? t !== this._texture && this.reset({ + texture: t + }, !0) : N(3122, this.name); + } + get atlasUuid() { + return this._atlasUuid; + } + set atlasUuid(t) { + this._atlasUuid = t; + } + get width() { + return this._texture.width; + } + get height() { + return this._texture.height; + } + set _textureSource(t) { + if (window.Build) this._texture = t; else if (t) { + this._refreshTexture(t); + this._calculateUV(); + } + } + get flipUVX() { + return this._isFlipUVX; + } + set flipUVX(t) { + this._isFlipUVX = t; + this._calculateUV(); + } + get flipUVY() { + return this._isFlipUVY; + } + set flipUVY(t) { + this._isFlipUVY = t; + this._calculateUV(); + } + get packable() { + return this._packable; + } + set packable(t) { + this._packable = t; + } + get original() { + return this._original; + } + get pixelsToUnit() { + return this._pixelsToUnit; + } + get pivot() { + return this._pivot; + } + get mesh() { + return this._mesh; + } + get trimmedBorder() { + return this._trimmedBorder; + } + constructor() { + super(); + this.vertices = null; + this.uv = []; + this.unbiasUV = []; + this.uvSliced = []; + this._rect = new as; + this._trimmedBorder = new is; + this._offset = new Qi; + this._originalSize = new rs; + this._rotated = !1; + this._capInsets = [ 0, 0, 0, 0 ]; + this._atlasUuid = ""; + this._texture = void 0; + this._isFlipUVY = !1; + this._isFlipUVX = !1; + this._original = null; + this._packable = !0; + this._pixelsToUnit = 100; + this._pivot = new Qi(.5, .5); + this._meshType = kI.RECT; + this._extrude = 0; + this._customOutLine = []; + this._minPos = new Pi; + this._maxPos = new Pi; + } + textureLoaded() { + return !!this.texture; + } + isRotated() { + return this._rotated; + } + setRotated(t) { + this.rotated = t; + } + getRect(t) { + if (t) { + t.set(this._rect); + return t; + } + return this._rect.clone(); + } + setRect(t) { + this.rect = t; + } + getOriginalSize(t) { + if (t) { + t.set(this._originalSize); + return t; + } + return this._originalSize.clone(); + } + setOriginalSize(t) { + this.originalSize = t; + } + getOffset(t) { + if (t) { + t.set(this._offset); + return t; + } + return this._offset.clone(); + } + setOffset(t) { + this.offset = t; + } + getGFXTexture() { + return this._texture.getGFXTexture(); + } + getGFXSampler() { + return this._texture.getGFXSampler(); + } + getHash() { + return this._texture.getHash(); + } + getSamplerInfo() { + return this._texture.getSamplerInfo(); + } + reset(t, e = !1) { + let i = !1; + if (e) { + this._originalSize.set(0, 0); + this._rect.set(0, 0, 0, 0); + this._offset.set(0, 0); + this._capInsets = [ 0, 0, 0, 0 ]; + this._rotated = !1; + i = !0; + } + if (t) { + if (t.texture) { + this._rect.x = this._rect.y = 0; + this._rect.width = t.texture.width; + this._rect.height = t.texture.height; + this._refreshTexture(t.texture); + this.checkRect(this._texture); + } + t.originalSize && this._originalSize.set(t.originalSize); + t.rect && this._rect.set(t.rect); + t.offset && this._offset.set(t.offset); + void 0 !== t.borderTop && (this._capInsets[1] = t.borderTop); + void 0 !== t.borderBottom && (this._capInsets[3] = t.borderBottom); + void 0 !== t.borderLeft && (this._capInsets[0] = t.borderLeft); + void 0 !== t.borderRight && (this._capInsets[2] = t.borderRight); + void 0 !== t.isRotate && (this._rotated = !!t.isRotate); + void 0 !== t.isFlipUv && (this._isFlipUVY = !!t.isFlipUv); + i = !0; + } + i && this.texture && this._calculateUV(); + this._calcTrimmedBorder(); + } + checkRect(t) { + const e = this._rect; + let i = e.x; + let s = e.y; + if (this._rotated) { + i += e.height; + s += e.width; + } else { + i += e.width; + s += e.height; + } + if (i > t.width) { + F(3300, `${this.name}/${t.name}`, i, t.width); + return !1; + } + if (s > t.height) { + F(3301, `${this.name}/${t.name}`, s, t.height); + return !1; + } + return !0; + } + _calcTrimmedBorder() { + const t = this._originalSize.width; + const e = this._originalSize.height; + const i = .5 * (t - this._rect.width); + const s = .5 * (e - this._rect.height); + this._trimmedBorder.x = this._offset.x + i; + this._trimmedBorder.y = this._offset.x - i; + this._trimmedBorder.z = this._offset.y + s; + this._trimmedBorder.w = this._offset.y - s; + } + ensureMeshData() { + if (!this._mesh) { + this._initVertices(); + this._createMesh(); + } + } + destroy() { + this._packable && EI && EI.deleteAtlasSpriteFrame(this); + return super.destroy(); + } + _calculateSlicedUV() { + const e = this._rect; + const i = this.texture; + const s = i.width; + const n = i.height; + const r = this._capInsets[0]; + const o = this._capInsets[2]; + const a = e.width - r - o; + const l = this._capInsets[1]; + const h = this._capInsets[3]; + const c = e.height - l - h; + const u = this.uvSliced; + u.length = 0; + if (this._rotated) { + UI[0].u = e.x / s; + UI[1].u = (e.x + h) / s; + UI[2].u = (e.x + h + c) / s; + UI[3].u = (e.x + e.height) / s; + UI[3].v = e.y / n; + UI[2].v = (e.y + r) / n; + UI[1].v = (e.y + r + a) / n; + UI[0].v = (e.y + e.width) / n; + for (let t = 0; t < 4; ++t) { + const e = UI[t]; + for (let t = 0; t < 4; ++t) { + const i = UI[3 - t]; + u.push({ + u: e.u, + v: i.v + }); + } + } + } else { + UI[0].u = e.x / s; + UI[1].u = (e.x + r) / s; + UI[2].u = (e.x + r + a) / s; + UI[3].u = (e.x + e.width) / s; + UI[3].v = e.y / n; + UI[2].v = (e.y + l) / n; + UI[1].v = (e.y + l + c) / n; + UI[0].v = (e.y + e.height) / n; + for (let t = 0; t < 4; ++t) { + const e = UI[t]; + for (let t = 0; t < 4; ++t) { + const i = UI[t]; + u.push({ + u: i.u, + v: e.v + }); + } + } + } + this.emit(t.EVENT_UV_UPDATED, this); + } + _calculateUV() { + const t = this._rect; + const e = this.uv; + const i = this.unbiasUV; + const s = this.texture; + const n = s.width; + const r = s.height; + if (this._rotated) { + const s = 0 === n ? 0 : t.x / n; + const o = 0 === n ? 1 : (t.x + t.height) / n; + const a = 0 === r ? 0 : t.y / r; + const l = 0 === r ? 1 : (t.y + t.width) / r; + if (this._isFlipUVX && this._isFlipUVY) { + e[0] = o; + e[1] = l; + e[2] = o; + e[3] = a; + e[4] = s; + e[5] = l; + e[6] = s; + e[7] = a; + } else if (this._isFlipUVX) { + e[0] = o; + e[1] = a; + e[2] = o; + e[3] = l; + e[4] = s; + e[5] = a; + e[6] = s; + e[7] = l; + } else if (this._isFlipUVY) { + e[0] = s; + e[1] = l; + e[2] = s; + e[3] = a; + e[4] = o; + e[5] = l; + e[6] = o; + e[7] = a; + } else { + e[0] = s; + e[1] = a; + e[2] = s; + e[3] = l; + e[4] = o; + e[5] = a; + e[6] = o; + e[7] = l; + } + const h = 0 === n ? 0 : t.x / n; + const c = 0 === n ? 1 : (t.x + t.height) / n; + const u = 0 === r ? 0 : t.y / r; + const _ = 0 === r ? 1 : (t.y + t.width) / r; + if (this._isFlipUVX && this._isFlipUVY) { + i[0] = c; + i[1] = _; + i[2] = c; + i[3] = u; + i[4] = h; + i[5] = _; + i[6] = h; + i[7] = u; + } else if (this._isFlipUVX) { + i[0] = c; + i[1] = u; + i[2] = c; + i[3] = _; + i[4] = h; + i[5] = u; + i[6] = h; + i[7] = _; + } else if (this._isFlipUVY) { + i[0] = h; + i[1] = _; + i[2] = h; + i[3] = u; + i[4] = c; + i[5] = _; + i[6] = c; + i[7] = u; + } else { + i[0] = h; + i[1] = u; + i[2] = h; + i[3] = _; + i[4] = c; + i[5] = u; + i[6] = c; + i[7] = _; + } + } else { + const s = 0 === n ? 0 : t.x / n; + const o = 0 === n ? 1 : (t.x + t.width) / n; + const a = 0 === r ? 1 : (t.y + t.height) / r; + const l = 0 === r ? 0 : t.y / r; + if (this._isFlipUVX && this._isFlipUVY) { + e[0] = o; + e[1] = l; + e[2] = s; + e[3] = l; + e[4] = o; + e[5] = a; + e[6] = s; + e[7] = a; + } else if (this._isFlipUVX) { + e[0] = o; + e[1] = a; + e[2] = s; + e[3] = a; + e[4] = o; + e[5] = l; + e[6] = s; + e[7] = l; + } else if (this._isFlipUVY) { + e[0] = s; + e[1] = l; + e[2] = o; + e[3] = l; + e[4] = s; + e[5] = a; + e[6] = o; + e[7] = a; + } else { + e[0] = s; + e[1] = a; + e[2] = o; + e[3] = a; + e[4] = s; + e[5] = l; + e[6] = o; + e[7] = l; + } + const h = 0 === n ? 0 : t.x / n; + const c = 0 === n ? 1 : (t.x + t.width) / n; + const u = 0 === r ? 1 : (t.y + t.height) / r; + const _ = 0 === r ? 0 : t.y / r; + if (this._isFlipUVX && this._isFlipUVY) { + i[0] = c; + i[1] = _; + i[2] = h; + i[3] = _; + i[4] = c; + i[5] = u; + i[6] = h; + i[7] = u; + } else if (this._isFlipUVX) { + i[0] = c; + i[1] = u; + i[2] = h; + i[3] = u; + i[4] = c; + i[5] = _; + i[6] = h; + i[7] = _; + } else if (this._isFlipUVY) { + i[0] = h; + i[1] = _; + i[2] = c; + i[3] = _; + i[4] = h; + i[5] = u; + i[6] = c; + i[7] = u; + } else { + i[0] = h; + i[1] = u; + i[2] = c; + i[3] = u; + i[4] = h; + i[5] = _; + i[6] = c; + i[7] = _; + } + } + this._calculateSlicedUV(); + } + _setDynamicAtlasFrame(t) { + if (t) { + this._original = { + _texture: this._texture, + _x: this._rect.x, + _y: this._rect.y + }; + this._texture = t.texture; + this._rect.x = t.x; + this._rect.y = t.y; + this._calculateUV(); + } + } + _resetDynamicAtlasFrame() { + if (this._original) { + this._rect.x = this._original._x; + this._rect.y = this._original._y; + this._texture = this._original._texture; + this._original = null; + this._calculateUV(); + } + } + _checkPackable() { + const t = EI; + if (!t) return; + const e = this._texture; + if (!(e instanceof LC) || e.isCompressed) { + this._packable = !1; + return; + } + const i = this.width; + const s = this.height; + !e.image || i > t.maxFrameSize || s > t.maxFrameSize ? this._packable = !1 : e.image && e.image instanceof HTMLCanvasElement && (this._packable = !0); + } + _serialize(t) { + return null; + } + _deserialize(t, e) { + const i = t; + const s = i.rect; + s && (this._rect = new as(s.x, s.y, s.width, s.height)); + const n = i.offset; + i.offset && (this._offset = new Qi(n.x, n.y)); + const r = i.originalSize; + i.originalSize && (this._originalSize = new rs(r.width, r.height)); + this._rotated = !!i.rotated; + this._name = i.name; + this._packable = !!i.packable; + this._pixelsToUnit = i.pixelsToUnit; + const o = i.pivot; + o && (this._pivot = new Qi(o.x, o.y)); + this._meshType = i.meshType; + const a = i.capInsets; + if (a) { + this._capInsets[0] = a[0]; + this._capInsets[1] = a[1]; + this._capInsets[2] = a[2]; + this._capInsets[3] = a[3]; + } + const l = i.vertices; + if (l) { + this.vertices || (this.vertices = { + rawPosition: [], + positions: [], + indexes: l.indexes, + uv: l.uv, + nuv: l.nuv, + minPos: new Pi(l.minPos.x, l.minPos.y, l.minPos.z), + maxPos: new Pi(l.maxPos.x, l.maxPos.y, l.maxPos.z) + }); + this.vertices.rawPosition.length = 0; + const t = l.rawPosition; + for (let e = 0; e < t.length; e += 3) this.vertices.rawPosition.push(new Pi(t[e], t[e + 1], t[e + 2])); + this._updateMeshVertices(); + } + } + clone() { + const e = new t; + const i = this.vertices; + e.vertices = i ? { + rawPosition: i.rawPosition.slice(0), + positions: i.positions.slice(0), + indexes: i.indexes.slice(0), + uv: i.uv.slice(0), + nuv: i.nuv.slice(0), + minPos: i.minPos.clone(), + maxPos: i.minPos.clone() + } : null; + e.uv.splice(0, e.uv.length, ...this.uv); + e.unbiasUV.splice(0, e.unbiasUV.length, ...this.unbiasUV); + e.uvSliced.splice(0, e.uvSliced.length, ...this.uvSliced); + e._rect.set(this._rect); + e._offset.set(this._offset); + e._originalSize.set(this._originalSize); + e._rotated = this._rotated; + e._capInsets.splice(0, e._capInsets.length, ...this._capInsets); + e._atlasUuid = this._atlasUuid; + e._texture = this._texture; + e._isFlipUVX = this._isFlipUVX; + e._isFlipUVY = this._isFlipUVY; + e._pixelsToUnit = this._pixelsToUnit; + e._pivot.set(this._pivot); + e._meshType = this._meshType; + return e; + } + _refreshTexture(t) { + this._texture = t; + const e = this._texture; + const i = {}; + let s = !1; + if (0 === this._rect.width || 0 === this._rect.height || !this.checkRect(e)) { + i.rect = new as(0, 0, e.width, e.height); + s = !0; + } + if (0 === this._originalSize.width || 0 === this._originalSize.height || s) { + i.originalSize = new rs(e.width, e.height); + s = !0; + } + s && this.reset(i); + this._checkPackable(); + this._mesh && this._updateMesh(); + } + onLoaded() { + this._calcTrimmedBorder(); + } + initDefault(t) { + super.initDefault(t); + const e = new LC; + e.initDefault(); + this._refreshTexture(e); + this._calculateUV(); + } + validate() { + return this._texture && this._rect && 0 !== this._rect.width && 0 !== this._rect.height; + } + _initVertices() { + if (this.vertices) { + this.vertices.rawPosition.length = 0; + this.vertices.positions.length = 0; + this.vertices.indexes.length = 0; + this.vertices.uv.length = 0; + this.vertices.nuv.length = 0; + this.vertices.minPos.set(0, 0, 0); + this.vertices.maxPos.set(0, 0, 0); + } else this.vertices = { + rawPosition: [], + positions: [], + indexes: [], + uv: [], + nuv: [], + minPos: new Pi, + maxPos: new Pi + }; + if (this._meshType === kI.POLYGON) ; else { + const t = this.texture; + const e = t.width; + const i = t.height; + const s = this.rect; + const n = s.width; + const r = s.height; + const o = s.x; + const a = i - s.y - r; + const l = n / 2; + const h = r / 2; + const c = 0 === e ? 0 : o / e; + const u = 0 === e ? 1 : (o + n) / e; + const _ = 0 === i ? 1 : (a + r) / i; + const d = 0 === i ? 0 : s.y / i; + FI.set(-l, -h, 0); + this.vertices.rawPosition.push(FI.clone()); + this.vertices.uv.push(o); + this.vertices.uv.push(a + r); + this.vertices.nuv.push(c); + this.vertices.nuv.push(d); + this.vertices.minPos.set(FI); + FI.set(l, -h, 0); + this.vertices.rawPosition.push(FI.clone()); + this.vertices.uv.push(o + n); + this.vertices.uv.push(a + r); + this.vertices.nuv.push(u); + this.vertices.nuv.push(d); + FI.set(-l, h, 0); + this.vertices.rawPosition.push(FI.clone()); + this.vertices.uv.push(o); + this.vertices.uv.push(a); + this.vertices.nuv.push(c); + this.vertices.nuv.push(_); + FI.set(l, h, 0); + this.vertices.rawPosition.push(FI.clone()); + this.vertices.uv.push(o + n); + this.vertices.uv.push(a); + this.vertices.nuv.push(u); + this.vertices.nuv.push(_); + this.vertices.maxPos.set(FI); + this.vertices.indexes.push(0); + this.vertices.indexes.push(1); + this.vertices.indexes.push(2); + this.vertices.indexes.push(2); + this.vertices.indexes.push(1); + this.vertices.indexes.push(3); + } + this._updateMeshVertices(); + } + _updateMeshVertices() { + VI.identity(); + const t = 1 / this._pixelsToUnit; + const e = new Pi(t, t, 1); + VI.scale(e); + const i = -(this._pivot.x - .5) * this.rect.width * t; + const s = -(this._pivot.y - .5) * this.rect.height * t; + e.set(i, s, 0); + VI.translate(e); + const n = this.vertices; + for (let t = 0; t < n.rawPosition.length; t++) { + const i = n.rawPosition[t]; + Pi.transformMat4(e, i, VI); + Pi.toArray(n.positions, e, 3 * t); + } + Pi.transformMat4(this._minPos, n.minPos, VI); + Pi.transformMat4(this._maxPos, n.maxPos, VI); + } + _createMesh() { + this._mesh = DI({ + primitiveMode: Xs.TRIANGLE_LIST, + positions: this.vertices.positions, + uvs: this.vertices.nuv, + indices: this.vertices.indexes, + minPos: this._minPos, + maxPos: this._maxPos, + attributes: [ new Vn(cr.ATTR_POSITION, bs.RGB32F), new Vn(cr.ATTR_TEX_COORD, bs.RG32F) ] + }); + } + _updateMesh() { + this._mesh && this._mesh.destroy(); + this._initVertices(); + this._createMesh(); + } + }, NI.EVENT_UV_UPDATED = "uv_updated", NI.MeshType = kI, LI)) || OI); + m.SpriteFrame = GI; + var zI, HI, jI, XI; + let WI = t("SpriteAtlas", Ul("cc.SpriteAtlas")(zI = (HI = (XI = class extends gc { + constructor(...t) { + super(...t); + Ml(this, "spriteFrames", jI, this); + } + getTexture() { + const t = Object.keys(this.spriteFrames); + if (t.length > 0) { + const e = this.spriteFrames[t[0]]; + return e && e.texture; + } + return null; + } + getSpriteFrame(t) { + const e = this.spriteFrames[t]; + if (!e) return null; + e.name || (e.name = t); + return e; + } + getSpriteFrames() { + const t = []; + const e = this.spriteFrames; + for (const i of Object.keys(e)) t.push(e[i]); + return t; + } + _serialize(t) {} + _deserialize(t, e) { + const i = t; + this._name = i.name; + const s = i.spriteFrames; + this.spriteFrames = vt(); + for (let t = 0; t < s.length; t += 2) e.result.push(this.spriteFrames, s[t], s[t + 1], Qt(GI)); + } + }, XI), jI = Bl(HI.prototype, "spriteFrames", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return vt(); + } + }), HI)) || zI); + m.SpriteAtlas = WI; + var YI; + let qI = t("Font", Ul("cc.Font")(YI = class extends gc {}) || YI); + m.Font = qI; + var KI, JI, ZI, QI; + let $I = t("TTFFont", Ul("cc.TTFFont")(KI = (JI = (QI = class extends qI { + constructor(...t) { + super(...t); + Ml(this, "_fontFamily", ZI, this); + } + get _nativeAsset() { + return this._fontFamily; + } + set _nativeAsset(t) { + this._fontFamily = t || "Arial"; + } + get _nativeDep() { + return { + uuid: this._uuid, + __nativeName__: this._native, + ext: nc(this._native), + __isNative__: !0 + }; + } + initDefault(t) { + this._fontFamily = "Arial"; + super.initDefault(t); + } + }, QI), ZI = Bl(JI.prototype, "_fontFamily", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Bl(JI.prototype, "_nativeAsset", [ vh, Ah ], Object.getOwnPropertyDescriptor(JI.prototype, "_nativeAsset"), JI.prototype), + Bl(JI.prototype, "_nativeDep", [ vh ], Object.getOwnPropertyDescriptor(JI.prototype, "_nativeDep"), JI.prototype), + JI)) || KI); + m.TTFFont = $I; + var tM, eM, iM, sM, nM, rM, oM, aM, lM; + class hM { + constructor() { + this.u = 0; + this.v = 0; + this.w = 0; + this.h = 0; + this.offsetX = 0; + this.offsetY = 0; + this.textureID = 0; + this.valid = !1; + this.xAdvance = 0; + } + } + class cM { + constructor(t) { + this.letterDefinitions = {}; + this.texture = t; + } + addLetterDefinitions(t, e) { + this.letterDefinitions[t] = e; + } + cloneLetterDefinition() { + const t = {}; + for (const e of Object.keys(this.letterDefinitions)) { + const i = new hM; + Nt(i, this.letterDefinitions[e]); + t[e] = i; + } + return t; + } + getTexture() { + return this.texture; + } + getLetter(t) { + return this.letterDefinitions[t]; + } + getLetterDefinitionForChar(t, e) { + const i = t.charCodeAt(0); + let s; + s = this.letterDefinitions.hasOwnProperty(i) ? this.letterDefinitions[i] : null; + return s; + } + clear() { + this.letterDefinitions = {}; + } + } + let uM = t("BitmapFont", (tM = Ul("cc.BitmapFont"), eM = Th(GI), tM(iM = (sM = (lM = class extends qI { + constructor(...t) { + super(...t); + Ml(this, "fntDataStr", nM, this); + Ml(this, "spriteFrame", rM, this); + Ml(this, "fontSize", oM, this); + Ml(this, "fntConfig", aM, this); + } + onLoaded() { + const t = this.spriteFrame; + !this.fontDefDictionary && t && (this.fontDefDictionary = new cM(t.texture)); + const e = this.fntConfig; + if (!e) { + C("The fnt config is not exists!"); + return; + } + const i = e.fontDefDictionary; + for (const t in i) { + const e = new hM; + const s = i[t].rect; + e.offsetX = i[t].xOffset; + e.offsetY = i[t].yOffset; + e.w = s.width; + e.h = s.height; + e.u = s.x; + e.v = s.y; + e.textureID = 0; + e.valid = !0; + e.xAdvance = i[t].xAdvance; + this.fontDefDictionary.addLetterDefinitions(t, e); + } + } + }, lM), nM = Bl(sM.prototype, "fntDataStr", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), rM = Bl(sM.prototype, "spriteFrame", [ eM ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), oM = Bl(sM.prototype, "fontSize", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return -1; + } + }), aM = Bl(sM.prototype, "fntConfig", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), sM)) || iM)); + m.BitmapFont = uM; + var _M; + let dM = t("LabelAtlas", Ul("cc.LabelAtlas")(_M = class extends uM {}) || _M); + m.LabelAtlas = dM; + const pM = t("BASELINE_RATIO", .26); + const mM = t("MIDDLE_RATIO", (pM + 1) / 2 - pM); + function fM() { + return 0; + } + const gM = new $t(2); + gM.get = function() { + return this._get() || { + key: "", + value: 0, + prev: null, + next: null + }; + }; + const yM = new class { + constructor(t) { + this.count = 0; + this.limit = 0; + this.datas = {}; + this.limit = t; + } + moveToHead(t) { + t.next = this.head; + t.prev = null; + this.head && (this.head.prev = t); + this.head = t; + this.tail || (this.tail = t); + this.count++; + this.datas[t.key] = t; + } + put(t, e) { + const i = gM.get(); + i.key = t; + i.value = e; + if (this.count >= this.limit) { + const t = this.tail; + delete this.datas[t.key]; + this.count--; + this.tail = t.prev; + this.tail.next = null; + t.prev = null; + t.next = null; + gM.put(t); + } + this.moveToHead(i); + } + remove(t) { + t.prev ? t.prev.next = t.next : this.head = t.next; + t.next ? t.next.prev = t.prev : this.tail = t.prev; + delete this.datas[t.key]; + this.count--; + } + get(t) { + const e = this.datas[t]; + if (e) { + this.remove(e); + this.moveToHead(e); + return e.value; + } + return null; + } + clear() { + this.count = 0; + this.datas = {}; + this.head = null; + this.tail = null; + } + has(t) { + return !!this.datas[t]; + } + delete(t) { + const e = this.datas[t]; + this.remove(e); + } + }(100); + const bM = /([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûа-яА-ЯЁё]+|\S)/; + const SM = /^[!,.:;'}\]%\?>、‘“》?。,!]/; + const AM = /([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]+|\S)$/; + const TM = /[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]+$/; + const vM = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]/; + function EM(t) { + return /^[\u4E00-\u9FFF\u3400-\u4DFF]+$/.test(t) || /[\u3000-\u303F]|[\u3040-\u309F]|[\u30A0-\u30FF]|[\uFF00-\uFFEF]|[\u4E00-\u9FAF]|[\u2605-\u2606]|[\u2190-\u2195]|\u203B/g.test(t) || /^[\u1100-\u11FF]|[\u3130-\u318F]|[\uA960-\uA97F]|[\uAC00-\uD7AF]|[\uD7B0-\uD7FF]+$/.test(t); + } + function CM(t) { + const e = t.charCodeAt(0); + return e >= 9 && e <= 13 || 32 === e || 133 === e || 160 === e || 5760 === e || e >= 8192 && e <= 8202 || 8232 === e || 8233 === e || 8239 === e || 8287 === e || 12288 === e; + } + function xM(t, e, i) { + const s = `${i || t.font}🎮${e}`; + const n = yM.get(s); + if (null !== n) return n; + const r = t.measureText(e); + const o = r && r.width || 0; + yM.put(s, o); + return o; + } + function wM(t, e, i) { + let s = e; + let n = i; + const r = t[e]; + r >= "\udc00" && r <= "\udfff" && s--; + if (void 0 !== i) if (i - 1 !== e) { + const e = t[i - 1]; + e >= "\ud800" && e <= "\udbff" && n--; + } else r >= "\ud800" && r <= "\udbff" && n++; + return t.substring(s, n); + } + function RM(t) { + return vM.exec(t); + } + function IM(t) { + return TM.exec(t); + } + function MM(t, e, i, s) { + const n = []; + if (0 === t.length || i < 0) { + n.push(""); + return n; + } + let r = t; + for (;e > i && r.length > 1; ) { + let t = r.length * (i / e) | 0; + let o = wM(r, t); + let a = e - s(o); + let l = o; + let h = 0; + let c = 0; + const u = 100; + for (;a > i && c++ < u; ) { + t *= i / a; + t |= 0; + o = wM(r, t); + a = e - s(o); + } + c = 0; + for (;o && a <= i && c++ < u; ) { + const i = bM.exec(o); + h = i ? i[0].length : 1; + l = o; + t += h; + o = wM(r, t); + a = e - s(o); + } + t -= h; + if (0 === t) { + t = 1; + l = wM(r, 1); + } else if (1 === t && r[0] >= "\ud800" && r[0] <= "\udbff") { + t = 2; + l = wM(r, 2); + } + let _ = wM(r, 0, t); + let d; + if (SM.test(l || o)) { + d = AM.exec(_); + t -= d ? d[0].length : 0; + 0 === t && (t = 1); + l = wM(r, t); + _ = wM(r, 0, t); + } + if (vM.test(l)) { + d = TM.exec(_); + if (d && _ !== d[0]) { + t -= d[0].length; + l = wM(r, t); + _ = wM(r, 0, t); + } + } + if (0 === n.length) n.push(_); else { + _ = _.trim(); + _.length > 0 && n.push(_); + } + r = l || o; + e = s(r); + } + if (0 === n.length) n.push(r); else { + r = r.trim(); + r.length > 0 && n.push(r); + } + return n; + } + let BM; + class DM { + constructor() { + this.pool = []; + } + static getInstance() { + BM || (BM = new DM); + return BM; + } + get() { + let t = this.pool.pop(); + if (!t) { + const e = document.createElement("canvas"); + const i = e.getContext("2d"); + t = { + canvas: e, + context: i + }; + } + return t; + } + put(t) { + this.pool.length >= pe.MAX_LABEL_CANVAS_POOL_SIZE || this.pool.push(t); + } + } + t("CanvasPool", DM); + const PM = Bi.WHITE.clone(); + class OM { + constructor() { + this.u = 0; + this.v = 0; + this.w = 0; + this.h = 0; + this.texture = null; + this.offsetX = 0; + this.offsetY = 0; + this.valid = !1; + this.xAdvance = 0; + } + } + const NM = `rgba(255, 255, 255, ${(1 / 255).toFixed(3)})`; + class LM { + constructor(t, e) { + this.image = null; + this.labelInfo = void 0; + this.char = void 0; + this.data = null; + this.canvas = null; + this.context = null; + this.width = 0; + this.height = 0; + this.offsetY = 0; + this.hash = void 0; + this.char = t; + this.labelInfo = e; + this.hash = t.charCodeAt(0) + e.hash; + } + updateRenderData() { + this._updateProperties(); + this._updateTexture(); + } + destroy() { + this.image = null; + DM.getInstance().put(this.data); + } + _updateProperties() { + this.data = DM.getInstance().get(); + this.canvas = this.data.canvas; + this.context = this.data.context; + if (this.context) { + this.context.font = this.labelInfo.fontDesc; + const t = xM(this.context, this.char, this.labelInfo.fontDesc); + const e = 2 * this.labelInfo.margin + 2; + this.width = parseFloat(t.toFixed(2)) + e; + this.height = (1 + pM) * this.labelInfo.fontSize + e; + this.offsetY = -this.labelInfo.fontSize * pM / 2; + } + this.canvas.width !== this.width && (this.canvas.width = this.width); + this.canvas.height !== this.height && (this.canvas.height = this.height); + this.image || (this.image = new IC); + this.image.reset(this.canvas); + } + _updateTexture() { + if (!this.context || !this.canvas) return; + const t = this.context; + const e = this.labelInfo; + const i = this.canvas.width; + const s = this.canvas.height; + t.textAlign = "center"; + t.textBaseline = "alphabetic"; + t.clearRect(0, 0, i, s); + t.fillStyle = NM; + t.fillRect(0, 0, i, s); + t.font = e.fontDesc; + const n = e.fontSize; + const r = i / 2; + const o = s / 2 + n * mM + 0 * n; + const a = e.color; + t.lineJoin = "round"; + t.fillStyle = `rgba(${a.r}, ${a.g}, ${a.b}, 1)`; + if (e.isOutlined) { + const i = e.out || PM; + t.strokeStyle = `rgba(${i.r}, ${i.g}, ${i.b}, ${i.a / 255})`; + t.lineWidth = 2 * e.margin; + t.strokeText(this.char, r, o); + } + t.fillText(this.char, r, o); + } + } + class FM extends LC { + initWithSize(t, e, i = Jp.RGBA8888) { + this.reset({ + width: t, + height: e, + format: i + }); + } + drawTextureAt(t, e, i) { + const s = this.getGFXTexture(); + if (!t || !s) return; + const n = this._getGFXDevice(); + if (!n) { + console.warn("Unable to get device"); + return; + } + const r = new mn; + r.texOffset.x = e; + r.texOffset.y = i; + r.texExtent.width = t.width; + r.texExtent.height = t.height; + n.copyTexImagesToTexture([ t.data ], s, [ r ]); + } + } + class VM { + get width() { + return this._width; + } + get height() { + return this._height; + } + constructor(t, e) { + this._x = 0; + this._y = 0; + this._nextY = 0; + this._width = 0; + this._height = 0; + this._halfBleed = 0; + this._dirty = !1; + const i = new FM; + i.initWithSize(t, e); + this.fontDefDictionary = new cM(i); + this._halfBleed = 1; + this._width = t; + this._height = e; + IR.on(RR.EVENT_BEFORE_SCENE_LAUNCH, this.beforeSceneLoad, this); + } + insertLetterTexture(t) { + const e = t.image; + const i = IR.root.device; + if (!e || !this.fontDefDictionary || !i) return null; + const s = e.width; + const n = e.height; + if (this._x + s + 0 > this._width) { + this._x = 0; + this._y = this._nextY; + } + this._y + n > this._nextY && (this._nextY = this._y + n + 0); + if (this._nextY > this._height) { + N(12100); + return null; + } + this.fontDefDictionary.texture.drawTextureAt(e, this._x, this._y); + this._dirty = !0; + const r = new OM; + r.u = this._x + this._halfBleed; + r.v = this._y + this._halfBleed; + r.texture = this.fontDefDictionary.texture; + r.valid = !0; + r.w = t.width - 2; + r.h = t.height - 2; + r.xAdvance = r.w; + r.offsetY = t.offsetY; + this._x += s + 0; + this.fontDefDictionary.addLetterDefinitions(t.hash, r); + return r; + } + update() { + this._dirty && (this._dirty = !1); + } + reset() { + this._x = 0; + this._y = 0; + this._nextY = 0; + this.fontDefDictionary.clear(); + } + destroy() { + this.reset(); + if (this.fontDefDictionary) { + this.fontDefDictionary.texture.destroy(); + this.fontDefDictionary.texture = null; + } + } + getTexture() { + return this.fontDefDictionary.getTexture(); + } + beforeSceneLoad() { + this.clearAllCache(); + } + clearAllCache() { + this.destroy(); + const t = new FM; + t.initWithSize(this._width, this._height); + this.fontDefDictionary.texture = t; + } + getLetter(t) { + return this.fontDefDictionary.letterDefinitions[t]; + } + getLetterDefinitionForChar(t, e) { + const i = t.charCodeAt(0) + e.hash; + let s = this.fontDefDictionary.letterDefinitions[i]; + if (!s) { + const i = new LM(t, e); + i.updateRenderData(); + s = this.insertLetterTexture(i); + i.destroy(); + } + return s; + } + } + const kM = { + fontAtlas: null, + fontSize: 0, + lineHeight: 0, + hAlign: 0, + vAlign: 0, + hash: "", + fontFamily: "", + fontDesc: "Arial", + color: Bi.WHITE.clone(), + isOutlined: !1, + out: Bi.WHITE.clone(), + margin: 0 + }; + const UM = [ new Vn(cr.ATTR_POSITION, bs.RGB32F) ]; + const GM = [ new Vn(cr.ATTR_POSITION, bs.RGB32F), new Vn(cr.ATTR_COLOR, bs.RGBA32F) ]; + const zM = [ new Vn(cr.ATTR_POSITION, bs.RGB32F), new Vn(cr.ATTR_TEX_COORD, bs.RG32F), new Vn(cr.ATTR_COLOR, bs.RGBA32F) ]; + const HM = [ new Vn(cr.ATTR_POSITION, bs.RGB32F), new Vn(cr.ATTR_TEX_COORD, bs.RG32F), new Vn(cr.ATTR_COLOR, bs.RGBA8, !0) ]; + const jM = [ new Vn(cr.ATTR_POSITION, bs.RGB32F), new Vn(cr.ATTR_TEX_COORD, bs.RG32F), new Vn(cr.ATTR_COLOR, bs.RGBA32F), new Vn(cr.ATTR_COLOR2, bs.RGBA32F) ]; + const XM = [ new Vn(cr.ATTR_POSITION, bs.RGB32F), new Vn(cr.ATTR_TEX_COORD, bs.RG32F), new Vn(cr.ATTR_COLOR, bs.RGBA8, !0), new Vn(cr.ATTR_COLOR2, bs.RGBA8, !0) ]; + function WM(t) { + let e = 0; + for (let i = 0; i < t.length; i++) { + const s = t[i]; + e += ur[s.format].count; + } + return e; + } + function YM(t) { + let e = 0; + for (let i = 0; i < t.length; i++) { + const s = t[i]; + e += ur[s.format].size; + } + return e; + } + m.internal.vfmtPosUvColor = zM; + m.internal.vfmtPosUvTwoColor = jM; + m.internal.vfmtPosUvColor4B = HM; + m.internal.vfmtPosUvTwoColor4B = XM; + t("UIVertexFormat", Object.freeze({ + __proto__: null, + vfmt: UM, + vfmtPosColor: GM, + vfmtPosUvColor: zM, + vfmtPosUvColor4B: HM, + vfmtPosUvTwoColor: jM, + vfmtPosUvTwoColor4B: XM, + getComponentPerVertex: WM, + getAttributeStride: YM + })); + const qM = n2d.RenderDrawInfo; + n2d.Batcher2d; + const KM = n2d.UIMeshBuffer; + const JM = n2d.RenderEntity; + const ZM = n2d.UIModelProxy; + n2d.StencilManager; + let QM; + !function(t) { + t[t.byteOffset = 0] = "byteOffset"; + t[t.vertexOffset = 1] = "vertexOffset"; + t[t.indexOffset = 2] = "indexOffset"; + t[t.dirty = 3] = "dirty"; + t[t.count = 4] = "count"; + }(QM || (QM = {})); + class $M { + get attributes() { + return this._attributes; + } + get vertexFormatBytes() { + return this._vertexFormatBytes; + } + get byteOffset() { + return this._byteOffset; + } + set byteOffset(t) { + this._byteOffset = t; + this._sharedBuffer[QM.byteOffset] = t; + } + get vertexOffset() { + return this._vertexOffset; + } + set vertexOffset(t) { + this._vertexOffset = t; + this._sharedBuffer[QM.vertexOffset] = t; + } + get indexOffset() { + return this._indexOffset; + } + set indexOffset(t) { + this._indexOffset = t; + this._sharedBuffer[QM.indexOffset] = t; + } + get dirty() { + return this._dirty; + } + set dirty(t) { + this._dirty = t; + this._sharedBuffer[QM.dirty] = t ? 1 : 0; + } + get floatsPerVertex() { + return this._floatsPerVertex; + } + set floatsPerVertex(t) { + this._floatsPerVertex = t; + } + get vData() { + return this._vData; + } + set vData(t) { + this._vData = t; + this._nativeObj.vData = t; + } + get iData() { + return this._iData; + } + set iData(t) { + this._iData = t; + this._nativeObj.iData = t; + } + get useLinkedData() { + return this._useLinkedData; + } + set useLinkedData(t) { + this._useLinkedData !== t && (this._nativeObj.useLinkData = t); + this._useLinkedData = t; + } + get nativeObj() { + return this._nativeObj; + } + get sharedBuffer() { + return this._sharedBuffer; + } + initSharedBuffer() { + this._sharedBuffer = new Uint32Array(QM.count); + } + syncSharedBufferToNative() { + this._nativeObj.syncSharedBufferToNative(this._sharedBuffer); + } + constructor() { + this._byteOffset = 0; + this._vertexOffset = 0; + this._indexOffset = 0; + this._dirty = !1; + this._floatsPerVertex = 0; + this._vData = null; + this._iData = null; + this._useLinkedData = !1; + this._vertexFormatBytes = 0; + this._initVDataCount = 0; + this._initIDataCount = 0; + this._attributes = null; + this._iaPool = []; + this._iaInfo = null; + this._nextFreeIAHandle = 0; + this._nativeObj = new KM; + this.initSharedBuffer(); + this.syncSharedBufferToNative(); + } + initialize(t, e, i, s) { + this._initVDataCount = i; + this._initIDataCount = s; + this._attributes = e; + this.floatsPerVertex = YM(e) >> 2; + ne(this._initVDataCount / this._floatsPerVertex < 65536, G(9005)); + if (!this.vData || !this.iData) { + this.vData = new Float32Array(this._initVDataCount); + this.iData = new Uint16Array(this._initIDataCount); + } + this._iaPool.push(this.createNewIA(t)); + this._nativeObj.initialize(t, e, i, s); + } + reset() { + this._nextFreeIAHandle = 0; + this.dirty = !1; + } + destroy() { + this.reset(); + this._attributes = null; + this._iaInfo = null; + this.vData = null; + this.iData = null; + for (let t = 0; t < this._iaPool.length; ++t) { + const e = this._iaPool[t]; + e.vertexBuffers[0] && e.vertexBuffers[0].destroy(); + e.indexBuffer && e.indexBuffer.destroy(); + e.ia.destroy(); + } + this._iaPool.length = 0; + } + setDirty() { + this.dirty = !0; + } + request(t, e) { + N(9002); + return !1; + } + requireFreeIA(t) { + this._iaPool.length <= this._nextFreeIAHandle && this._iaPool.push(this.createNewIA(t)); + return this._iaPool[this._nextFreeIAHandle++].ia; + } + recycleIA(t) { + const e = this._iaPool; + for (let i = 0; i < this._nextFreeIAHandle; ++i) if (t === e[i].ia) { + const t = e[i]; + e[i] = e[--this._nextFreeIAHandle]; + e[this._nextFreeIAHandle] = t; + return; + } + } + checkCapacity(t, e) { + const i = (this.vertexOffset + t) * this._floatsPerVertex; + const s = this.indexOffset + e; + return !(i > this._initVDataCount || s > this._initIDataCount); + } + uploadBuffers() { + if (0 === this.byteOffset || !this._dirty) return; + const t = Vo.__isWebIOS14OrIPadOS14Env ? this._nextFreeIAHandle : 1; + const e = this.byteOffset; + const i = this.indexOffset; + for (let s = 0; s < t; ++s) { + const t = this._iaPool[s]; + const n = new Float32Array(this.vData.buffer, 0, e >> 2); + const r = new Uint16Array(this.iData.buffer, 0, i); + const o = t.vertexBuffers[0]; + e > o.size && o.resize(e); + o.update(n); + 2 * i > t.indexBuffer.size && t.indexBuffer.resize(2 * i); + t.indexBuffer.update(r); + } + this.dirty = !1; + } + createNewIA(t) { + let e; + let i; + let s; + if (Vo.__isWebIOS14OrIPadOS14Env || !this._iaPool[0]) { + const n = this._vertexFormatBytes = this._floatsPerVertex * Float32Array.BYTES_PER_ELEMENT; + const r = Uint16Array.BYTES_PER_ELEMENT; + const o = t.createBuffer(new An(Ts.VERTEX | Ts.TRANSFER_DST, Cs.HOST | Cs.DEVICE, n, n)); + s = t.createBuffer(new An(Ts.INDEX | Ts.TRANSFER_DST, Cs.HOST | Cs.DEVICE, r, r)); + i = [ o ]; + this._iaInfo = new Un(this._attributes, i, s); + e = t.createInputAssembler(this._iaInfo); + } else { + e = t.createInputAssembler(this._iaInfo); + i = this._iaInfo.vertexBuffers; + s = this._iaInfo.indexBuffer; + } + return { + ia: e, + vertexBuffers: i, + indexBuffer: s + }; + } + } + t("MeshBuffer", $M); + const tB = new $r((() => ({ + offset: 0, + length: 0 + })), 32); + class eB { + get ib() { + return this._ib; + } + constructor(t, e, i, s, n, r) { + this._ib = void 0; + this.vertexAccessor = t; + this.bufferId = e; + this.meshBuffer = i; + this.vertexOffset = s; + this.vb = n; + this.indexCount = r; + this._ib = new Uint16Array(r); + ne(i === t.getMeshBuffer(e)); + } + setIndexBuffer(t) { + ne(t.length === this.ib.length); + for (let e = 0; e < t.length; ++e) { + const i = t[e]; + this._ib[e] = this.vertexOffset + i; + } + } + } + class iB extends class { + get attributes() { + return this._attributes; + } + get vertexFormatBytes() { + return this._vertexFormatBytes; + } + get floatsPerVertex() { + return this._floatsPerVertex; + } + constructor(t, e) { + this._device = null; + this._attributes = null; + this._vertexFormatBytes = void 0; + this._floatsPerVertex = void 0; + this._buffers = []; + this._device = t; + this._attributes = e; + this._floatsPerVertex = YM(e) >> 2; + this._vertexFormatBytes = this._floatsPerVertex * Float32Array.BYTES_PER_ELEMENT; + } + initialize() {} + reset() {} + request(t = 4, e = 6) {} + appendBuffers(t, e) {} + uploadBuffers() {} + destroy() { + this._attributes.length = 0; + } + } { + get id() { + return this._id; + } + constructor(t, e, i, s) { + super(t, e); + this._freeLists = []; + this._vCount = 0; + this._iCount = 0; + this._id = 0; + this._vCount = i || Math.floor(1024 * pe.BATCHER2D_MEM_INCREMENT / this._vertexFormatBytes); + this._iCount = s || this._vCount * iB.IB_SCALE; + this._id = iB.generateID(); + this._allocateBuffer(); + } + destroy() { + for (let t = 0; t < this._buffers.length; ++t) { + this._buffers[t].destroy(); + const e = this._freeLists[t]; + for (let t = 0; t < e.length; ++t) tB.free(e[t]); + } + this._buffers.length = 0; + this._freeLists.length = 0; + super.destroy(); + } + reset() { + for (let t = 0; t < this._buffers.length; ++t) { + const e = this._buffers[t]; + e.indexOffset = 0; + e.reset(); + } + } + getVertexBuffer(t) { + return this._buffers[t].vData; + } + getIndexBuffer(t) { + return this._buffers[t].iData; + } + getMeshBuffer(t) { + return this._buffers[t]; + } + uploadBuffers() { + for (let t = 0; t < this._buffers.length; ++t) { + const e = this._freeLists[t][0]; + const i = this._buffers[t]; + (!e || e.length < i.vData.byteLength) && i.uploadBuffers(); + } + } + appendIndices(t, e) { + const i = this._buffers[t]; + if (e.length) { + i.iData.set(e, i.indexOffset); + i.indexOffset += e.length; + } + } + allocateChunk(t, e) { + const i = t * this.vertexFormatBytes; + let s = null; + let n; + let r = 0; + let o = -1; + let a = null; + for (let t = 0; t < this._buffers.length; ++t) { + s = this._buffers[t]; + n = this._freeLists[t]; + for (let e = 0; e < n.length; ++e) if (n[e].length >= i) { + a = n[e]; + r = t; + o = e; + break; + } + if (a) break; + } + if (!a) { + r = this._allocateBuffer(); + s = this._buffers[r]; + if (s && s.checkCapacity(t, e)) { + o = 0; + a = this._freeLists[r][o]; + } + } + if (a) { + const t = a.offset / this.vertexFormatBytes; + ne(Number.isInteger(t)); + const n = new Float32Array(s.vData.buffer, a.offset, i >> 2).fill(0); + this._allocateChunkFromEntry(r, o, a, i); + return new eB(this, r, s, t, n, e); + } + F(9004, i); + return null; + } + recycleChunk(t) { + const e = this._freeLists[t.bufferId]; + const i = this._buffers[t.bufferId]; + let s = t.vertexOffset * this.vertexFormatBytes; + let n = t.vb.byteLength; + if (0 === n) return; + let r = !1; + let o = 0; + let a = null; + let l = e[o]; + for (;l && l.offset < s; ) { + a = l; + l = e[++o]; + } + if (a) { + const t = s - (a.offset + a.length); + ne(t >= 0); + if (0 === t) { + a.length += n; + s = a.offset; + n = a.length; + if (l && l.offset - (s + n) == 0) { + a.length += l.length; + e.splice(o, 1); + tB.free(l); + l = null; + } + r = !0; + } + } + if (!r && l) { + const t = l.offset - (s + n); + ne(t >= 0); + if (0 === t) { + l.offset = s; + l.length += n; + } else { + const t = tB.alloc(); + t.offset = s; + t.length = n; + e.splice(o, 0, t); + } + r = !0; + } + if (r) s + n === i.byteOffset && (i.byteOffset = s); else { + const t = tB.alloc(); + t.offset = s; + t.length = n; + e.push(t); + } + } + _allocateChunkFromEntry(t, e, i, s) { + const n = i.length - s; + const r = i.offset + s; + const o = this._buffers[t]; + o.byteOffset < r && (o.byteOffset = r); + k(n >= 0, 9004, t, i.offset, i.length); + if (0 === n) { + this._freeLists[t].splice(e, 1); + tB.free(i); + } else { + i.offset += s; + i.length = n; + } + } + _allocateBuffer() { + k(this._buffers.length === this._freeLists.length, 9003); + const t = new $M; + const e = this._vCount * this._floatsPerVertex; + t.initialize(this._device, this._attributes, e, this._iCount); + this._buffers.push(t); + const i = tB.alloc(); + i.offset = 0; + i.length = t.vData.byteLength; + const s = [ i ]; + this._freeLists.push(s); + IR.root.batcher2D.syncMeshBuffersToNative(this.id, this._buffers); + return this._buffers.length - 1; + } + static generateID() { + return iB.ID_COUNT++; + } + } + iB.IB_SCALE = 4; + iB.ID_COUNT = 0; + let sB; + !function(t) { + t[t.DrawInfoType = 0] = "DrawInfoType"; + t[t.VertDirty = 1] = "VertDirty"; + t[t.IsMeshBuffer = 2] = "IsMeshBuffer"; + t[t.Stride = 3] = "Stride"; + t[t.Count = 4] = "Count"; + }(sB || (sB = {})); + let nB; + !function(t) { + t[t.BufferID = 0] = "BufferID"; + t[t.AccessorID = 1] = "AccessorID"; + t[t.Count = 2] = "Count"; + }(nB || (nB = {})); + let rB; + !function(t) { + t[t.VertexOffset = 0] = "VertexOffset"; + t[t.IndexOffset = 1] = "IndexOffset"; + t[t.VBCount = 2] = "VBCount"; + t[t.IBCount = 3] = "IBCount"; + t[t.DataHash = 4] = "DataHash"; + t[t.Count = 5] = "Count"; + }(rB || (rB = {})); + let oB; + !function(t) { + t[t.COMP = 0] = "COMP"; + t[t.MODEL = 1] = "MODEL"; + t[t.IA = 2] = "IA"; + t[t.SUB_NODE = 3] = "SUB_NODE"; + }(oB || (oB = {})); + class aB { + constructor(t) { + this._accId = -1; + this._bufferId = -1; + this._vertexOffset = 0; + this._indexOffset = 0; + this._vb = null; + this._ib = null; + this._vData = null; + this._iData = null; + this._vertDirty = !1; + this._vbCount = 0; + this._ibCount = 0; + this._dataHash = 0; + this._isMeshBuffer = !1; + this._material = null; + this._texture = null; + this._sampler = null; + this._stride = 0; + this._useLocal = !1; + this._model = null; + this._drawInfoType = oB.COMP; + this._subNode = null; + this._uint8SharedBuffer = void 0; + this._uint16SharedBuffer = void 0; + this._uint32SharedBuffer = void 0; + this.init(t); + const e = this._nativeObj.getAttrSharedBufferForJS(); + let i = 0; + this._uint8SharedBuffer = new Uint8Array(e, i, sB.Count); + i += sB.Count * Uint8Array.BYTES_PER_ELEMENT; + this._uint16SharedBuffer = new Uint16Array(e, i, nB.Count); + i += nB.Count * Uint16Array.BYTES_PER_ELEMENT; + this._uint32SharedBuffer = new Uint32Array(e, i, rB.Count); + } + get nativeObj() { + return this._nativeObj; + } + get render2dBuffer() { + return this._render2dBuffer; + } + init(t) { + t && (this._nativeObj = t); + this._nativeObj || (this._nativeObj = new qM); + } + clear() { + this._bufferId = 0; + this._vertexOffset = 0; + this._indexOffset = 0; + this._vertDirty = !1; + } + setAccId(t) { + this._accId !== t && (this._uint16SharedBuffer[nB.AccessorID] = t); + this._accId = t; + } + setBufferId(t) { + if (this._bufferId !== t) { + this._uint16SharedBuffer[nB.BufferID] = t; + this._nativeObj.changeMeshBuffer(); + } + this._bufferId = t; + } + setAccAndBuffer(t, e) { + if (this._accId !== t || this._bufferId !== e) { + this._uint16SharedBuffer[nB.AccessorID] = t; + this._uint16SharedBuffer[nB.BufferID] = e; + this._nativeObj.changeMeshBuffer(); + } + this._bufferId = e; + this._accId = t; + } + setVertexOffset(t) { + this._vertexOffset = t; + this._uint32SharedBuffer[rB.VertexOffset] = t; + } + setIndexOffset(t) { + this._indexOffset = t; + this._uint32SharedBuffer[rB.IndexOffset] = t; + } + setVB(t) { + this._nativeObj.vbBuffer = t; + } + setIB(t) { + this._nativeObj.ibBuffer = t; + } + setVData(t) { + this._nativeObj.vDataBuffer = t; + } + setIData(t) { + this._nativeObj.iDataBuffer = t; + } + setVBCount(t) { + this._uint32SharedBuffer[rB.VBCount] = t; + this._vbCount = t; + } + setIBCount(t) { + this._uint32SharedBuffer[rB.IBCount] = t; + } + setVertDirty(t) { + this._uint8SharedBuffer[sB.VertDirty] = t ? 1 : 0; + this._vertDirty = t; + } + setDataHash(t) { + this._uint32SharedBuffer[rB.DataHash] = t; + this._dataHash = t; + } + setIsMeshBuffer(t) { + this._uint8SharedBuffer[sB.IsMeshBuffer] = t ? 1 : 0; + this._isMeshBuffer = t; + } + setMaterial(t) { + this._material !== t && (this._nativeObj.material = t); + this._material = t; + } + setTexture(t) { + this._texture !== t && (this._nativeObj.texture = t); + this._texture = t; + } + setSampler(t) { + this._sampler !== t && (this._nativeObj.sampler = t); + this._sampler = t; + } + setModel(t) { + this._model !== t && (this._nativeObj.model = t); + } + setDrawInfoType(t) { + this._drawInfoType !== t && (this._uint8SharedBuffer[sB.DrawInfoType] = t); + this._drawInfoType = t; + } + setSubNode(t) { + this._subNode !== t && (this._nativeObj.subNode = t); + this._subNode = t; + } + setStride(t) { + this._uint8SharedBuffer[sB.Stride] = t; + this._stride = t; + } + initRender2dBuffer() { + this._render2dBuffer = new Float32Array(this._vbCount * this._stride); + this._nativeObj.setRender2dBufferToNative(this._render2dBuffer); + } + fillRender2dBuffer(t) { + { + const e = Math.min(this._vbCount, t.length); + let i = 0; + for (let s = 0; s < e; s++) { + const e = t[s]; + this._render2dBuffer[i] = e.x; + this._render2dBuffer[i + 1] = e.y; + this._render2dBuffer[i + 2] = e.z; + i += this._stride; + } + } + } + } + let lB; + !function(t) { + t[t.DISABLED = 0] = "DISABLED"; + t[t.CLEAR = 1] = "CLEAR"; + t[t.ENTER_LEVEL = 2] = "ENTER_LEVEL"; + t[t.ENABLED = 3] = "ENABLED"; + t[t.EXIT_LEVEL = 4] = "EXIT_LEVEL"; + t[t.CLEAR_INVERTED = 5] = "CLEAR_INVERTED"; + t[t.ENTER_LEVEL_INVERTED = 6] = "ENTER_LEVEL_INVERTED"; + }(lB || (lB = {})); + let hB; + !function(t) { + t[t.stencilTest = 0] = "stencilTest"; + t[t.func = 1] = "func"; + t[t.stencilMask = 2] = "stencilMask"; + t[t.writeMask = 3] = "writeMask"; + t[t.failOp = 4] = "failOp"; + t[t.zFailOp = 5] = "zFailOp"; + t[t.passOp = 6] = "passOp"; + t[t.ref = 7] = "ref"; + t[t.count = 8] = "count"; + }(hB || (hB = {})); + class cB { + constructor() { + this._maskStack = []; + this._stencilPattern = { + stencilTest: !0, + func: Os.ALWAYS, + stencilMask: 65535, + writeMask: 65535, + failOp: Ns.KEEP, + zFailOp: Ns.KEEP, + passOp: Ns.KEEP, + ref: 1 + }; + this._stage = lB.DISABLED; + this.stencilStateMap = new Map; + this.stencilStateMapWithDepth = new Map; + } + get stage() { + return this._stage; + } + set stage(t) { + this._stage = t; + } + get pattern() { + return this._stencilPattern; + } + pushMask(t) { + this._maskStack.push(t); + } + clear(t) { + return t.stencilStage !== lB.ENTER_LEVEL ? lB.CLEAR_INVERTED : lB.CLEAR; + } + enableMask() { + this.stage = lB.ENABLED; + } + exitMask() { + if (0 !== this._maskStack.length) { + this._maskStack.pop(); + 0 === this._maskStack.length ? this.stage = lB.DISABLED : this.stage = lB.ENABLED; + } + } + getWriteMask() { + return 1 << this._maskStack.length - 1; + } + getExitWriteMask() { + return 1 << this._maskStack.length; + } + getStencilRef() { + let t = 0; + for (let e = 0; e < this._maskStack.length; ++e) t += 1 << e; + return t; + } + getMaskStackSize() { + return this._maskStack.length; + } + reset() { + this._maskStack.length = 0; + this.stage = lB.DISABLED; + } + destroy() { + this.stencilStateMap.forEach(((t, e) => { + t.destroy(); + })); + this.stencilStateMap.clear(); + } + getStencilStage(t, e) { + let i = 0; + let s = !1; + let n = !1; + let r = Os.LESS; + let o = this.stencilStateMap; + if (e && e.passes[0]) { + const a = e.passes[0].depthStencilState; + let l = 0; + let h = 0; + a.depthTest && (l = 1); + a.depthWrite && (h = 1); + i = l | h << 1 | a.depthFunc << 2 | t << 6 | this._maskStack.length << 9; + s = a.depthTest; + n = a.depthWrite; + r = a.depthFunc; + o = this.stencilStateMapWithDepth; + } else i = t << 16 | this._maskStack.length; + if (o && o.has(i)) return o.get(i); + this.setStateFromStage(t); + const a = new wr(s, n, r, this._stencilPattern.stencilTest, this._stencilPattern.func, this._stencilPattern.stencilMask, this._stencilPattern.writeMask, this._stencilPattern.failOp, this._stencilPattern.zFailOp, this._stencilPattern.passOp, this._stencilPattern.ref, this._stencilPattern.stencilTest, this._stencilPattern.func, this._stencilPattern.stencilMask, this._stencilPattern.writeMask, this._stencilPattern.failOp, this._stencilPattern.zFailOp, this._stencilPattern.passOp, this._stencilPattern.ref); + o.set(i, a); + return a; + } + getStencilHash(t) { + return t << 8 | this._maskStack.length; + } + setStateFromStage(t) { + const e = this._stencilPattern; + if (t === lB.DISABLED) { + e.stencilTest = !1; + e.func = Os.ALWAYS; + e.failOp = Ns.KEEP; + e.stencilMask = e.writeMask = 65535; + e.ref = 1; + } else { + e.stencilTest = !0; + if (t === lB.ENABLED) { + e.func = Os.EQUAL; + e.failOp = Ns.KEEP; + e.stencilMask = e.ref = this.getStencilRef(); + e.writeMask = this.getWriteMask(); + } else if (t === lB.CLEAR) { + e.func = Os.NEVER; + e.failOp = Ns.ZERO; + e.writeMask = e.stencilMask = e.ref = this.getWriteMask(); + } else if (t === lB.CLEAR_INVERTED) { + e.func = Os.NEVER; + e.failOp = Ns.REPLACE; + e.writeMask = e.stencilMask = e.ref = this.getWriteMask(); + } else if (t === lB.ENTER_LEVEL) { + e.func = Os.NEVER; + e.failOp = Ns.REPLACE; + e.writeMask = e.stencilMask = e.ref = this.getWriteMask(); + } else if (t === lB.ENTER_LEVEL_INVERTED) { + e.func = Os.NEVER; + e.failOp = Ns.ZERO; + e.writeMask = e.stencilMask = e.ref = this.getWriteMask(); + } + } + } + } + t("StencilManager", cB); + cB.sharedManager = null; + cB.sharedManager = new cB; + let uB; + !function(t) { + t[t.STATIC = 0] = "STATIC"; + t[t.DYNAMIC = 1] = "DYNAMIC"; + t[t.CROSSED = 2] = "CROSSED"; + }(uB || (uB = {})); + let _B; + !function(t) { + t[t.localOpacity = 0] = "localOpacity"; + t[t.count = 1] = "count"; + }(_B || (_B = {})); + let dB; + !function(t) { + t[t.colorR = 0] = "colorR"; + t[t.colorG = 1] = "colorG"; + t[t.colorB = 2] = "colorB"; + t[t.colorA = 3] = "colorA"; + t[t.maskMode = 4] = "maskMode"; + t[t.count = 5] = "count"; + }(dB || (dB = {})); + let pB; + !function(t) { + t[t.colorDirty = 0] = "colorDirty"; + t[t.enabled = 1] = "enabled"; + t[t.useLocal = 2] = "useLocal"; + t[t.count = 3] = "count"; + }(pB || (pB = {})); + let mB; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.MASK = 1] = "MASK"; + t[t.MASK_INVERTED = 2] = "MASK_INVERTED"; + t[t.MASK_NODE = 3] = "MASK_NODE"; + t[t.MASK_NODE_INVERTED = 4] = "MASK_NODE_INVERTED"; + }(mB || (mB = {})); + class fB { + get nativeObj() { + return this._nativeObj; + } + get renderDrawInfoArr() { + return this._dynamicDrawInfoArr; + } + get renderEntityType() { + return this._renderEntityType; + } + get color() { + return this._color; + } + set color(t) { + this._color = t; + this._uint8SharedBuffer[dB.colorR] = t.r; + this._uint8SharedBuffer[dB.colorG] = t.g; + this._uint8SharedBuffer[dB.colorB] = t.b; + this._uint8SharedBuffer[dB.colorA] = t.a; + } + get localOpacity() { + return this._localOpacity; + } + set localOpacity(t) { + this._localOpacity = t; + this._floatSharedBuffer[_B.localOpacity] = t; + } + get colorDirty() { + return this._colorDirty; + } + set colorDirty(t) { + this._colorDirty = t; + this._boolSharedBuffer[pB.colorDirty] = t ? 1 : 0; + } + get enabled() { + return this._enabled; + } + set enabled(t) { + this._enabled = t; + this._boolSharedBuffer[pB.enabled] = t ? 1 : 0; + } + constructor(t) { + this._renderEntityType = uB.STATIC; + this._dynamicDrawInfoArr = []; + this._node = null; + this._renderTransform = null; + this._stencilStage = lB.DISABLED; + this._useLocal = !1; + this._maskMode = mB.NONE; + this._color = Bi.WHITE; + this._localOpacity = 255; + this._colorDirty = !0; + this._enabled = !1; + this._nativeObj || (this._nativeObj = new JM(t)); + this._renderEntityType = t; + this.initSharedBuffer(); + } + addDynamicRenderDrawInfo(t) { + if (t) { + this._dynamicDrawInfoArr.push(t); + this._nativeObj.addDynamicRenderDrawInfo(t.nativeObj); + } + } + removeDynamicRenderDrawInfo() { + this._dynamicDrawInfoArr.pop(); + this._nativeObj.removeDynamicRenderDrawInfo(); + } + clearDynamicRenderDrawInfos() { + this._dynamicDrawInfoArr.length = 0; + this._nativeObj.clearDynamicRenderDrawInfos(); + } + clearStaticRenderDrawInfos() { + this._nativeObj.clearStaticRenderDrawInfos(); + } + setDynamicRenderDrawInfo(t, e) { + if (t) if (this._dynamicDrawInfoArr.length < e + 1) { + this._dynamicDrawInfoArr.push(t); + this._nativeObj.addDynamicRenderDrawInfo(t.nativeObj); + } else { + this._dynamicDrawInfoArr[e] = t; + this._nativeObj.setDynamicRenderDrawInfo(t.nativeObj, e); + } + } + setMaskMode(t) { + this._uint8SharedBuffer[dB.maskMode] = t; + this._maskMode = t; + } + getStaticRenderDrawInfo() { + { + const t = this._nativeObj.getStaticRenderDrawInfo(this._nativeObj.staticDrawInfoSize++); + return new aB(t); + } + } + setNode(t) { + this._node !== t && (this._nativeObj.node = t); + this._node = t; + } + setRenderTransform(t) { + this._renderTransform !== t && (this._nativeObj.renderTransform = t); + this._renderTransform = t; + } + setStencilStage(t) { + this._stencilStage !== t && (this._nativeObj.stencilStage = t); + this._stencilStage = t; + } + setUseLocal(t) { + this._boolSharedBuffer[pB.useLocal] = t ? 1 : 0; + this._useLocal = t; + } + initSharedBuffer() { + { + const t = this._nativeObj.getEntitySharedBufferForJS(); + let e = 0; + this._floatSharedBuffer = new Float32Array(t, e, _B.count); + e += 4 * _B.count; + this._uint8SharedBuffer = new Uint8Array(t, e, dB.count); + e += 1 * dB.count; + this._boolSharedBuffer = new Uint8Array(t, e, pB.count); + } + } + } + const gB = YM(zM) >> 2; + const yB = new $r((() => ({ + x: 0, + y: 0, + z: 0, + u: 0, + v: 0, + color: Bi.WHITE.clone() + })), 128); + class bB { + get vertexCount() { + return this._vc; + } + get indexCount() { + return this._ic; + } + get stride() { + return this._floatStride << 2; + } + get floatStride() { + return this._floatStride; + } + get vertexFormat() { + return this._vertexFormat; + } + get drawInfoType() { + return this._drawInfoType; + } + set drawInfoType(t) { + this._drawInfoType = t; + this._renderDrawInfo && this._renderDrawInfo.setDrawInfoType(t); + } + get renderDrawInfo() { + return this._renderDrawInfo; + } + get material() { + return this._material; + } + set material(t) { + this._material = t; + this._renderDrawInfo && this._renderDrawInfo.setMaterial(t); + } + get dataHash() { + return this._dataHash; + } + set dataHash(t) { + this._dataHash = t; + this._renderDrawInfo && this._renderDrawInfo.setDataHash(t); + } + get multiOwner() { + return this._multiOwner; + } + set multiOwner(t) { + this._multiOwner = t; + } + get batcher() { + this._batcher || (this._batcher = IR.root.batcher2D); + return this._batcher; + } + constructor(t = zM) { + this.chunk = null; + this._renderDrawInfo = null; + this._material = null; + this._dataHash = 0; + this._isMeshBuffer = !1; + this._vc = 0; + this._ic = 0; + this._floatStride = 0; + this._vertexFormat = zM; + this._drawInfoType = oB.COMP; + this._multiOwner = !1; + this._batcher = null; + this._floatStride = t === zM ? gB : YM(t) >> 2; + this._vertexFormat = t; + } + isValid() { + return this._ic > 0 && this.chunk.vertexAccessor; + } + initRenderDrawInfo(t, e = oB.COMP) { + { + const i = t.renderEntity; + if (i.renderEntityType === uB.STATIC) { + if (!this._renderDrawInfo) { + const t = i.getStaticRenderDrawInfo(); + t && (this._renderDrawInfo = t); + } + } else if (!1 === this.multiOwner && !this._renderDrawInfo) { + this._renderDrawInfo = new aB; + i.addDynamicRenderDrawInfo(this._renderDrawInfo); + } + this.drawInfoType = e; + this.setRenderDrawInfoAttributes(); + } + } + removeRenderDrawInfo(t) { + { + const e = t.renderEntity; + e.renderEntityType === uB.DYNAMIC ? e.removeDynamicRenderDrawInfo() : e.renderEntityType === uB.STATIC && e.clearStaticRenderDrawInfos(); + } + } + setRenderDrawInfoAttributes() { + if (this._renderDrawInfo) { + if (this.chunk) { + this._renderDrawInfo.setBufferId(this.chunk.bufferId); + this._renderDrawInfo.setVertexOffset(this.chunk.vertexOffset); + this._renderDrawInfo.setVB(this.chunk.vb); + this._renderDrawInfo.setIB(this.chunk.ib); + if (this.chunk.meshBuffer) { + this._renderDrawInfo.setIndexOffset(this.chunk.meshBuffer.indexOffset); + this._renderDrawInfo.setVData(this.chunk.meshBuffer.vData.buffer); + this._renderDrawInfo.setIData(this.chunk.meshBuffer.iData.buffer); + } + } + this._renderDrawInfo.setVBCount(this._vc); + this._renderDrawInfo.setIBCount(this._ic); + this._renderDrawInfo.setDataHash(this.dataHash); + this._renderDrawInfo.setIsMeshBuffer(this._isMeshBuffer); + this._renderDrawInfo.setMaterial(this.material); + this._renderDrawInfo.setDrawInfoType(this._drawInfoType); + } + } + } + t("BaseRenderData", bB); + class SB extends bB { + static add(t = zM, e) { + const i = new SB(t, e); + if (!e) { + e = IR.root.batcher2D.switchBufferAccessor(i._vertexFormat); + } + i._accessor = e; + return i; + } + static remove(t) { + t.clear(); + t._accessor = null; + } + get dataLength() { + return this._data.length; + } + set dataLength(t) { + const e = this._data; + if (e.length !== t) { + const i = e.length; + let s = 0; + for (s = t; s < i; s++) yB.free(e[s]); + for (s = i; s < t; s++) e[s] = yB.alloc(); + e.length = t; + } + this.syncRender2dBuffer(); + } + get data() { + return this._data; + } + get vertDirty() { + return this._vertDirty; + } + set vertDirty(t) { + this._vertDirty = t; + this._renderDrawInfo && t && this._renderDrawInfo.setVertDirty(t); + } + get textureHash() { + return this._textureHash; + } + set textureHash(t) { + this._textureHash = t; + } + set frame(t) { + this._frame = t; + if (this._renderDrawInfo) if (this._frame) { + this._renderDrawInfo.setTexture(this._frame.getGFXTexture()); + this._renderDrawInfo.setSampler(this._frame.getGFXSampler()); + } else { + this._renderDrawInfo.setTexture(null); + this._renderDrawInfo.setSampler(null); + } + } + get frame() { + return this._frame; + } + get accessor() { + return this._accessor; + } + constructor(t = zM, e) { + super(t); + this._vertDirty = !0; + this._textureHash = 0; + this.indices = null; + this.layer = 0; + this.nodeDirty = !0; + this.passDirty = !0; + this.textureDirty = !0; + this.hashDirty = !0; + this._data = []; + this._pivotX = 0; + this._pivotY = 0; + this._width = 0; + this._height = 0; + this._frame = null; + this._accessor = null; + this.vertexRow = 1; + this.vertexCol = 1; + e || (e = this.batcher.switchBufferAccessor(this._vertexFormat)); + this._accessor = e; + } + resize(t, e) { + if (t !== this._vc || e !== this._ic || !this.chunk) { + this._vc = t; + this._ic = e; + if (this.chunk) { + this._accessor.recycleChunk(this.chunk); + this.chunk = null; + } + this.chunk = this._accessor.allocateChunk(t, e); + this.updateHash(); + if (!1 === this.multiOwner && this._renderDrawInfo) { + this._renderDrawInfo.setDrawInfoType(this._drawInfoType); + this._renderDrawInfo.setBufferId(this.chunk.bufferId); + this._renderDrawInfo.setVertexOffset(this.chunk.vertexOffset); + this._renderDrawInfo.setIndexOffset(this.chunk.meshBuffer.indexOffset); + this._renderDrawInfo.setVB(this.chunk.vb); + this._renderDrawInfo.setIB(this.chunk.ib); + this._renderDrawInfo.setVData(this.chunk.meshBuffer.vData.buffer); + this._renderDrawInfo.setIData(this.chunk.meshBuffer.iData.buffer); + this._renderDrawInfo.setVBCount(this._vc); + this._renderDrawInfo.setIBCount(this._ic); + } + } + } + setRenderDrawInfoAttributes() { + if (this._renderDrawInfo) { + this._renderDrawInfo.setAccId(this._accessor.id); + super.setRenderDrawInfoAttributes(); + this._renderDrawInfo.setTexture(this.frame ? this.frame.getGFXTexture() : null); + this._renderDrawInfo.setSampler(this.frame ? this.frame.getGFXSampler() : null); + } + } + fillDrawInfoAttributes(t) { + if (t) { + t.setDrawInfoType(this._drawInfoType); + t.setAccAndBuffer(this._accessor.id, this.chunk.bufferId); + t.setVertexOffset(this.chunk.vertexOffset); + t.setIndexOffset(this.chunk.meshBuffer.indexOffset); + t.setVB(this.chunk.vb); + t.setIB(this.chunk.ib); + t.setVData(this.chunk.meshBuffer.vData.buffer); + t.setIData(this.chunk.meshBuffer.iData.buffer); + t.setVBCount(this._vc); + t.setIBCount(this._ic); + t.setDataHash(this.dataHash); + t.setIsMeshBuffer(this._isMeshBuffer); + } + } + syncRender2dBuffer() { + if (!1 === this.multiOwner) { + if (!this._renderDrawInfo) return; + this.renderDrawInfo.setStride(this.floatStride); + this.renderDrawInfo.setVBCount(this.dataLength); + this.renderDrawInfo.initRender2dBuffer(); + } + } + resizeAndCopy(t, e) { + if (t === this._vc && e === this._ic && this.chunk) return; + this._vc = t; + this._ic = e; + const i = this.chunk; + this.chunk = this._accessor.allocateChunk(t, e); + if (i) { + this.chunk.vb.set(i.vb); + this._accessor.recycleChunk(i); + } + this.updateHash(); + } + getMeshBuffer() { + return this.chunk && this._accessor ? this._accessor.getMeshBuffer(this.chunk.bufferId) : null; + } + updateNode(t) { + this.layer = t.node.layer; + this.nodeDirty = !1; + this.hashDirty = !0; + } + updatePass(t) { + this.material = t.getRenderMaterial(0); + this.passDirty = !1; + this.hashDirty = !0; + } + updateTexture(t) { + this.frame = t; + this.textureHash = t.getHash(); + this.textureDirty = !1; + this.hashDirty = !0; + } + updateHash() { + const t = `${this.chunk ? this.chunk.bufferId : -1}${this.layer} ${this.textureHash}`; + this.dataHash = Ur(t, 666); + this.hashDirty = !1; + } + updateRenderData(t, e) { + if (this.passDirty) { + this.material = t.getRenderMaterial(0); + this.passDirty = !1; + this.hashDirty = !0; + this._renderDrawInfo && this._renderDrawInfo.setMaterial(this.material); + } + if (this.nodeDirty) { + const e = t.node.scene ? t._getRenderScene() : null; + this.layer = t.node.layer; + null !== e && (this.nodeDirty = !1); + this.hashDirty = !0; + } + if (this.textureDirty) { + this.frame = e; + this.textureHash = e.getHash(); + this.textureDirty = !1; + this.hashDirty = !0; + if (this._renderDrawInfo) { + this._renderDrawInfo.setTexture(this.frame ? this.frame.getGFXTexture() : null); + this._renderDrawInfo.setSampler(this.frame ? this.frame.getGFXSampler() : null); + } + } + if (this.hashDirty) { + this.updateHash(); + this._renderDrawInfo && this._renderDrawInfo.setDataHash(this.dataHash); + } + if (!1 === this.multiOwner) { + w(this._renderDrawInfo.render2dBuffer.length === this._floatStride * this._data.length, "Vertex count doesn't match."); + this._renderDrawInfo.fillRender2dBuffer(this._data); + } + } + updateSizeNPivot(t, e, i, s) { + if (t !== this._width || e !== this._height || i !== this._pivotX || s !== this._pivotY) { + this._width = t; + this._height = e; + this._pivotX = i; + this._pivotY = s; + this.vertDirty = !0; + } + } + clear() { + this.resize(0, 0); + this._data.length = 0; + this._pivotX = 0; + this._pivotY = 0; + this._width = 0; + this._height = 0; + this.indices = null; + this.vertDirty = !0; + this.material = null; + this.nodeDirty = !0; + this.passDirty = !0; + this.textureDirty = !0; + this.hashDirty = !0; + this.layer = 0; + this.frame = null; + this.textureHash = 0; + this.dataHash = 0; + this._renderDrawInfo && this._renderDrawInfo.clear(); + } + static createStaticVBAccessor(t, e, i) { + const s = IR.root.device; + return new iB(s, t, e, i); + } + } + t("RenderData", SB); + class AB extends bB { + static add(t = zM) { + const e = new AB; + e._floatStride = t === zM ? gB : YM(t) >> 2; + e._vertexFormat = t; + return e; + } + static remove(t) { + t.clear(); + } + set formatByte(t) {} + get formatByte() { + return this.stride; + } + get floatStride() { + return this._floatStride; + } + get vDataOffset() { + return this._byteLength >>> 2; + } + constructor(t = zM) { + super(t); + this._isMeshBuffer = !0; + this.vData = void 0; + this.iData = void 0; + this.vertexStart = 0; + this.vertexRange = 0; + this.indexStart = 0; + this.indexRange = 0; + this.lastFilledIndex = 0; + this.lastFilledVertex = 0; + this.frame = void 0; + this._byteLength = 0; + this._vertexBuffers = []; + this._indexBuffer = null; + this._iaPool = null; + this._iaInfo = null; + this.vData = new Float32Array(256 * this.stride); + this.iData = new Uint16Array(1536); + } + request(t, e) { + const i = this._byteLength + t * this.stride; + if (!this.reserve(t, e)) return !1; + this._vc += t; + this._ic += e; + this._byteLength = i; + this.vertexRange = this._vc; + this.indexRange = this._ic; + return !0; + } + reserve(t, e) { + const i = this._byteLength + t * this.stride; + const s = this.indexCount + e; + if (t + this.vertexCount > 65535) return !1; + let n = this.vData.byteLength; + let r = this.iData.length; + let o = this.vData.length; + let a = this.iData.length; + if (i > n || s > r) { + for (;n < i || r < s; ) { + o *= 2; + a *= 2; + n = 4 * o; + r = a; + } + this._reallocBuffer(o, a); + } + return !0; + } + resize(t, e) { + const i = t * this.stride; + ne(t >= 0 && e >= 0 && i <= this.vData.byteLength && e <= this.iData.length); + this._vc = t; + this._ic = e; + this._byteLength = i; + this.updateRange(0, t, 0, e); + } + updateRange(t, e, i, s) { + ne(e >= 0 && s >= 0 && e <= this._vc && s <= this._ic); + this.vertexStart = t; + this.indexStart = i; + this.vertexRange = e; + this.indexRange = s; + } + requestIA(t) { + this._initIAInfo(t); + const e = this._iaPool.add(); + e.firstIndex = this.indexStart; + e.indexCount = this.indexRange; + return e; + } + uploadBuffers() { + if (0 === this._byteLength || !this._vertexBuffers[0] || !this._indexBuffer) return; + const t = this._ic; + const e = new Float32Array(this.vData.buffer, 0, this._byteLength >> 2); + const i = new Uint16Array(this.iData.buffer, 0, t); + const s = this._vertexBuffers[0]; + this._byteLength > s.size && s.resize(this._byteLength); + s.update(e); + const n = t << 1; + n > this._indexBuffer.size && this._indexBuffer.resize(n); + this._indexBuffer.update(i); + } + freeIAPool() { + this._iaPool && this._iaPool.reset(); + } + reset() { + this._vc = 0; + this._ic = 0; + this._byteLength = 0; + this.vertexStart = 0; + this.vertexRange = 0; + this.indexStart = 0; + this.indexRange = 0; + this.lastFilledIndex = 0; + this.lastFilledVertex = 0; + this.material = null; + this.freeIAPool(); + } + clear() { + this.reset(); + this._iaPool && this._iaPool.destroy(); + if (this._vertexBuffers[0]) { + this._vertexBuffers[0].destroy(); + this._vertexBuffers = []; + } + this._iaInfo = null; + this.vData = new Float32Array(256 * this.stride); + this.iData = new Uint16Array(1536); + } + _initIAInfo(t) { + if (!this._iaInfo) { + const e = this.stride; + const i = this._vertexBuffers; + i.length || i.push(t.createBuffer(new An(Ts.VERTEX | Ts.TRANSFER_DST, Cs.DEVICE, e, e))); + const s = Uint16Array.BYTES_PER_ELEMENT; + this._indexBuffer || (this._indexBuffer = t.createBuffer(new An(Ts.INDEX | Ts.TRANSFER_DST, Cs.DEVICE, s, s))); + this._iaInfo = new Un(this._vertexFormat, i, this._indexBuffer); + this._iaPool = new to((() => t.createInputAssembler(this._iaInfo)), 1, (t => { + t.destroy(); + })); + } + } + _reallocBuffer(t, e) { + const i = this.vData; + this.vData = new Float32Array(t); + i && this.vData.set(i, 0); + const s = this.iData; + this.iData = new Uint16Array(e); + s && this.iData.set(s, 0); + } + setRenderDrawInfoAttributes() { + var t, e; + if (this._renderDrawInfo) { + this._renderDrawInfo.setVData(this.vData.buffer); + this._renderDrawInfo.setIData(this.iData.buffer); + this._renderDrawInfo.setVBCount(this._vc); + this._renderDrawInfo.setIBCount(this._ic); + this._renderDrawInfo.setVertexOffset(this.vertexStart); + this._renderDrawInfo.setIndexOffset(this.indexStart); + this._renderDrawInfo.setIsMeshBuffer(this._isMeshBuffer); + this._renderDrawInfo.setMaterial(this.material); + this._renderDrawInfo.setTexture(null === (t = this.frame) || void 0 === t ? void 0 : t.getGFXTexture()); + this._renderDrawInfo.setSampler(null === (e = this.frame) || void 0 === e ? void 0 : e.getGFXSampler()); + } + } + particleInitRenderDrawInfo(t) { + if (t.renderEntityType === uB.STATIC && !this._renderDrawInfo) { + const e = t.getStaticRenderDrawInfo(); + e && (this._renderDrawInfo = e); + } + } + } + t("MeshRenderData", AB); + new to((() => new AB), 32); + var TB, vB, EB, CB, xB, wB, RB, IB, MB, BB, DB, PB, OB, NB; + const LB = new Qi; + const FB = new Qi; + const VB = new Pi; + const kB = new qi; + const UB = new qi; + const GB = new qi; + const zB = new qi(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + const HB = new as; + let jB = function(e) { + return t({ + UITransform: e, + UITransformComponent: e + }), e; + }((TB = Ul("cc.UITransform"), vB = sh(), EB = zl(110), CB = $l(), xB = ph(), wB = lh(), + RB = ph(), IB = lh(), TB(MB = vB(MB = EB(MB = CB(MB = Hl(MB = Ql(MB = (BB = (NB = OB = class t extends Qc { + constructor(...t) { + super(...t); + this._priority = 0; + Ml(this, "_contentSize", DB, this); + Ml(this, "_anchorPoint", PB, this); + } + get contentSize() { + return this._contentSize; + } + set contentSize(t) { + if (!this._contentSize.equals(t)) { + this._contentSize.set(t); + this.node.emit(ny.SIZE_CHANGED); + this._markRenderDataDirty(); + } + } + get width() { + return this._contentSize.width; + } + set width(t) { + if (this._contentSize.width !== t) { + this._contentSize.width = t; + this.node.emit(ny.SIZE_CHANGED); + this._markRenderDataDirty(); + } + } + get height() { + return this._contentSize.height; + } + set height(t) { + if (this.contentSize.height !== t) { + this._contentSize.height = t; + this.node.emit(ny.SIZE_CHANGED); + this._markRenderDataDirty(); + } + } + get anchorPoint() { + return this._anchorPoint; + } + set anchorPoint(t) { + if (!this._anchorPoint.equals(t)) { + this._anchorPoint.set(t); + this.node.emit(ny.ANCHOR_CHANGED, this._anchorPoint); + this._markRenderDataDirty(); + } + } + get anchorX() { + return this._anchorPoint.x; + } + set anchorX(t) { + if (this._anchorPoint.x !== t) { + this._anchorPoint.x = t; + this.node.emit(ny.ANCHOR_CHANGED, this._anchorPoint); + this._markRenderDataDirty(); + } + } + get anchorY() { + return this._anchorPoint.y; + } + set anchorY(t) { + if (this._anchorPoint.y !== t) { + this._anchorPoint.y = t; + this.node.emit(ny.ANCHOR_CHANGED, this._anchorPoint); + this._markRenderDataDirty(); + } + } + get priority() { + return this._priority; + } + set priority(e) { + if (this._priority !== e) if (this.node.getComponent("cc.RenderRoot2D")) N(6706); else { + this._priority = e; + this.node.parent && t.insertChangeMap(this.node.parent); + } + } + get visibility() { + const t = IR.root.batcher2D.getFirstRenderCamera(this.node); + return t ? t.visibility : 0; + } + get cameraPriority() { + const t = IR.root.batcher2D.getFirstRenderCamera(this.node); + return t ? t.priority : 0; + } + __preload() { + this.node._uiProps.uiTransformComp = this; + } + onLoad() { + this.node.parent && t.insertChangeMap(this.node.parent); + } + onEnable() { + this.node.on(ny.PARENT_CHANGED, this._parentChanged, this); + this._markRenderDataDirty(); + } + onDisable() { + this.node.off(ny.PARENT_CHANGED, this._parentChanged, this); + } + onDestroy() { + this.node._uiProps.uiTransformComp = null; + } + setContentSize(t, e) { + const i = this._contentSize; + if (void 0 === e) { + if (ui(t.width, i.width, hi) && ui(t.height, i.height, hi)) return; + i.width = t.width; + i.height = t.height; + } else { + if (ui(t, i.width, hi) && ui(e, i.height, hi)) return; + i.width = t; + i.height = e; + } + this.node.emit(ny.SIZE_CHANGED); + this._markRenderDataDirty(); + } + setAnchorPoint(t, e) { + const i = this._anchorPoint; + if (void 0 === e) { + if (t.x === i.x && t.y === i.y) return; + i.x = t.x; + i.y = t.y; + } else { + if (t === i.x && e === i.y) return; + i.x = t; + i.y = e; + } + this.node.emit(ny.ANCHOR_CHANGED, this._anchorPoint); + this._markRenderDataDirty(); + } + isHit(t) { + const e = this._contentSize.width; + const i = this._contentSize.height; + const s = LB; + const n = FB; + const r = this._getRenderScene().cameras; + for (let o = 0; o < r.length; o++) { + const a = r[o]; + if (!(a.visibility & this.node.layer)) continue; + a.node.getWorldRT(kB); + const l = kB.m12; + const h = kB.m13; + const c = HR.center; + kB.m12 = c.x - (kB.m00 * l + kB.m04 * h); + kB.m13 = c.y - (kB.m01 * l + kB.m05 * h); + qi.invert(kB, kB); + Qi.transformMat4(s, t, kB); + this.node.getWorldMatrix(GB); + qi.invert(kB, GB); + if (qi.strictEquals(kB, zB)) continue; + Qi.transformMat4(n, s, kB); + n.x += this._anchorPoint.x * e; + n.y += this._anchorPoint.y * i; + let u = !1; + n.x >= 0 && n.y >= 0 && n.x <= e && n.y <= i && (u = this._maskTest(s)); + if (u) return !0; + } + return !1; + } + hitTest(t) { + const e = this._contentSize.width; + const i = this._contentSize.height; + const s = VB; + const n = LB; + const r = FB; + const o = this._getRenderScene().cameras; + for (let a = 0; a < o.length; a++) { + const l = o[a]; + if (!(l.visibility & this.node.layer) || l.window && !l.window.swapchain) continue; + Pi.set(s, t.x, t.y, 0); + l.screenToWorld(s, s); + Qi.set(n, s.x, s.y); + this.node.getWorldMatrix(GB); + qi.invert(kB, GB); + if (qi.strictEquals(kB, zB)) continue; + Qi.transformMat4(r, n, kB); + r.x += this._anchorPoint.x * e; + r.y += this._anchorPoint.y * i; + let h = !1; + r.x >= 0 && r.y >= 0 && r.x <= e && r.y <= i && (h = this._maskTest(n)); + if (h) return !0; + } + return !1; + } + _maskTest(t) { + var e, i; + const s = null === (e = this.node) || void 0 === e || null === (i = e.eventProcessor) || void 0 === i ? void 0 : i.maskList; + if (s) { + let e = this.node; + const i = s.length; + for (let n = 0, r = 0; e && r < i; ++n, e = e.parent) { + const i = s[r]; + if (n === i.index) { + if (e !== i.comp.node) { + s.length = r; + break; + } + { + const e = i.comp; + if (e && e._enabled && !e.isHit(t)) return !1; + r++; + } + } else if (n > i.index) { + s.length = r; + break; + } + } + } + return !0; + } + convertToNodeSpaceAR(t, e) { + this.node.getWorldMatrix(GB); + qi.invert(kB, GB); + e || (e = new Pi); + return Pi.transformMat4(e, t, kB); + } + convertToWorldSpaceAR(t, e) { + this.node.getWorldMatrix(GB); + e || (e = new Pi); + return Pi.transformMat4(e, t, GB); + } + getBoundingBox() { + qi.fromRTS(UB, this.node.getRotation(), this.node.getPosition(), this.node.getScale()); + const t = this._contentSize.width; + const e = this._contentSize.height; + const i = new as(-this._anchorPoint.x * t, -this._anchorPoint.y * e, t, e); + i.transformMat4(UB); + return i; + } + getBoundingBoxToWorld() { + if (this.node.parent) { + this.node.parent.getWorldMatrix(GB); + return this.getBoundingBoxTo(GB); + } + return this.getBoundingBox(); + } + getBoundingBoxTo(e) { + qi.fromRTS(UB, this.node.getRotation(), this.node.getPosition(), this.node.getScale()); + const i = this._contentSize.width; + const s = this._contentSize.height; + const n = new as(-this._anchorPoint.x * i, -this._anchorPoint.y * s, i, s); + qi.multiply(GB, e, UB); + n.transformMat4(GB); + if (!this.node.children) return n; + const r = this.node.children; + for (const i of r) if (i && i.active) { + const s = i.getComponent(t); + if (s) { + const t = s.getBoundingBoxTo(e); + t && as.union(n, n, t); + } + } + return n; + } + getComputeAABB(t) { + const e = this._contentSize.width; + const i = this._contentSize.height; + HB.set(-this._anchorPoint.x * e, -this._anchorPoint.y * i, e, i); + HB.transformMat4(this.node.worldMatrix); + const s = HB.x + .5 * HB.width; + const n = HB.y + .5 * HB.height; + const r = this.node.worldPosition.z; + const o = HB.width / 2; + const a = HB.height / 2; + if (null != t) { + hl.set(t, s, n, r, o, a, .001); + return t; + } + return new hl(s, n, r, o, a, .001); + } + _parentChanged(e) { + this.node.getComponent("cc.RenderRoot2D") || this.node.parent && t.insertChangeMap(this.node.parent); + } + _markRenderDataDirty() { + const t = this.node._uiProps.uiComp; + t && t.markForUpdateRenderData(); + } + static insertChangeMap(e) { + const i = e.uuid; + t.priorityChangeNodeMap.has(i) || t.priorityChangeNodeMap.set(i, e); + } + static _sortChildrenSibling(t) { + const e = t.children; + e && e.sort(((t, e) => { + const i = t._uiProps.uiTransformComp; + const s = e._uiProps.uiTransformComp; + const n = (i ? i._priority : 0) - (s ? s._priority : 0); + return 0 === n ? t.getSiblingIndex() - e.getSiblingIndex() : n; + })); + } + static _sortSiblings() { + t.priorityChangeNodeMap.forEach(((e, i) => { + t._sortChildrenSibling(e); + e._updateSiblingIndex(); + e.emit("childrenSiblingOrderChanged"); + })); + t.priorityChangeNodeMap.clear(); + } + static _cleanChangeMap() { + t.priorityChangeNodeMap.clear(); + } + }, OB.EventType = ny, OB.priorityChangeNodeMap = new Map, NB), Bl(BB.prototype, "contentSize", [ xB, wB ], Object.getOwnPropertyDescriptor(BB.prototype, "contentSize"), BB.prototype), + Bl(BB.prototype, "anchorPoint", [ RB, IB ], Object.getOwnPropertyDescriptor(BB.prototype, "anchorPoint"), BB.prototype), + DB = Bl(BB.prototype, "_contentSize", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new rs(100, 100); + } + }), PB = Bl(BB.prototype, "_anchorPoint", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Qi(.5, .5); + } + }), BB)) || MB) || MB) || MB) || MB) || MB) || MB)); + IR.on(RR.EVENT_AFTER_UPDATE, jB._sortSiblings); + IR.on(RR.EVENT_BEFORE_SCENE_LAUNCH, jB._cleanChangeMap); + var XB, WB, YB, qB, KB, JB, ZB, QB, $B, tD, eD, iD, sD, nD, rD, oD, aD, lD, hD; + he(Ls); + let cD; + !function(t) { + t[t.ADD_COLOR = 0] = "ADD_COLOR"; + t[t.ADD_COLOR_AND_TEXTURE = 1] = "ADD_COLOR_AND_TEXTURE"; + t[t.GRAYSCALE = 2] = "GRAYSCALE"; + t[t.USE_ALPHA_SEPARATED = 3] = "USE_ALPHA_SEPARATED"; + t[t.USE_ALPHA_SEPARATED_AND_GRAY = 4] = "USE_ALPHA_SEPARATED_AND_GRAY"; + }(cD || (cD = t("InstanceMaterialType", {}))); + let uD = function(e) { + return t({ + UIRenderer: e, + RenderComponent: e, + UIRenderable: e, + Renderable2D: e + }), e; + }((XB = Ul("cc.UIRenderer"), WB = Gl(jB), YB = rh(), qB = Th(hm), KB = ph(), JB = lh(), + ZB = ah(), QB = ph(), $B = lh(), tD = Th(hm), XB(eD = WB(eD = Ql(eD = (iD = (hD = lD = class t extends vS { + constructor() { + super(); + this._renderData = null; + Ml(this, "_materials", sD, this); + Ml(this, "_customMaterial", nD, this); + Ml(this, "_srcBlendFactor", rD, this); + Ml(this, "_dstBlendFactor", oD, this); + Ml(this, "_color", aD, this); + this._stencilStage = lB.DISABLED; + this._assembler = null; + this._postAssembler = null; + this._renderDataFlag = !0; + this._renderFlag = !0; + this._renderEntity = void 0; + this._instanceMaterialType = -1; + this._srcBlendFactorCache = Ls.SRC_ALPHA; + this._dstBlendFactorCache = Ls.ONE_MINUS_SRC_ALPHA; + this._dirtyVersion = -1; + this._internalId = -1; + this._useVertexOpacity = !1; + this._lastParent = null; + this._renderEntity = this.createRenderEntity(); + } + get sharedMaterials() { + return this._materials; + } + set sharedMaterials(t) { + for (let e = 0; e < t.length; e++) t[e] !== this._materials[e] && this.setMaterial(t[e], e); + if (t.length < this._materials.length) { + for (let e = t.length; e < this._materials.length; e++) this.setMaterial(null, e); + this._materials.splice(t.length); + } + } + get customMaterial() { + return this._customMaterial; + } + set customMaterial(t) { + this._customMaterial = t; + this.updateMaterial(); + } + get color() { + return this._color; + } + set color(t) { + if (!this._color.equals(t)) { + this._color.set(t); + this._updateColor(); + } + } + get renderData() { + return this._renderData; + } + get useVertexOpacity() { + return this._useVertexOpacity; + } + get stencilStage() { + return this._stencilStage; + } + set stencilStage(t) { + this._stencilStage = t; + this._renderEntity.setStencilStage(t); + } + get batcher() { + return IR.root.batcher2D; + } + get renderEntity() { + w(this._renderEntity, "this._renderEntity should not be invalid"); + return this._renderEntity; + } + onLoad() { + this._renderEntity.setNode(this.node); + } + __preload() { + this.node._uiProps.uiComp = this; + this._flushAssembler && this._flushAssembler(); + } + onEnable() { + this.node.on(ny.ANCHOR_CHANGED, this._nodeStateChange, this); + this.node.on(ny.SIZE_CHANGED, this._nodeStateChange, this); + this.node.on(ny.PARENT_CHANGED, this._colorDirty, this); + this.updateMaterial(); + this._colorDirty(); + wR.addRenderer(this); + this.markForUpdateRenderData(); + } + onRestore() { + this.updateMaterial(); + this.markForUpdateRenderData(); + } + onDisable() { + this.node.off(ny.ANCHOR_CHANGED, this._nodeStateChange, this); + this.node.off(ny.SIZE_CHANGED, this._nodeStateChange, this); + this.node.off(ny.PARENT_CHANGED, this._colorDirty, this); + wR.removeRenderer(this); + this._renderFlag = !1; + this._renderEntity.enabled = !1; + } + onDestroy() { + this._renderEntity.setNode(null); + this.node._uiProps.uiComp === this && (this.node._uiProps.uiComp = null); + this.destroyRenderData(); + if (this._materialInstances) for (let t = 0; t < this._materialInstances.length; t++) { + const e = this._materialInstances[t]; + e && e.destroy(); + } + } + markForUpdateRenderData(t = !0) { + if (t) { + const t = this.renderData; + t && (t.vertDirty = !0); + wR.markDirtyRenderer(this); + } + } + requestRenderData(t = oB.COMP) { + const e = SB.add(); + e.initRenderDrawInfo(this, t); + this._renderData = e; + return e; + } + destroyRenderData() { + if (this.renderData) { + this.renderData.removeRenderDrawInfo(this); + SB.remove(this.renderData); + this._renderData = null; + } + } + updateRenderer() { + this._assembler && this._assembler.updateRenderData(this); + this._renderFlag = this._canRender(); + this._renderEntity.enabled = this._renderFlag; + } + fillBuffers(t) { + this._renderFlag && this._render(t); + } + postUpdateAssembler(t) { + this._postAssembler && this._renderFlag && this._postRender(t); + } + _render(t) {} + _postRender(t) {} + _canRender() { + w(this.isValid, "this component should not be invalid!"); + return null !== this.getMaterial(0) && this._enabled && this._color.a > 0; + } + _postCanRender() {} + updateMaterial() { + if (this._customMaterial) { + this.setMaterial(this._customMaterial, 0); + return; + } + const t = this._updateBuiltinMaterial(); + this.setMaterial(t, 0); + this.stencilStage !== lB.ENTER_LEVEL && this.stencilStage !== lB.ENTER_LEVEL_INVERTED || this.getMaterialInstance(0).recompileShaders({ + USE_ALPHA_TEST: !0 + }); + this._updateBlendFunc(); + } + _updateColor() { + this.node._uiProps.colorDirty = !0; + this.setEntityColorDirty(!0); + this.setEntityColor(this._color); + this.setEntityOpacity(this.node._uiProps.localOpacity); + if (this._assembler) { + this._assembler.updateColor(this); + this._renderFlag = this._canRender(); + this.setEntityEnabled(this._renderFlag); + } + } + static setEntityColorDirtyRecursively(e, i) { + const s = e._uiProps.uiComp; + s && s.color && (s._renderEntity.colorDirty = i); + for (let s = 0; s < e.children.length; s++) t.setEntityColorDirtyRecursively(e.children[s], i); + } + setEntityColorDirty(e) { + t.setEntityColorDirtyRecursively(this.node, e); + } + setEntityColor(t) { + this._renderEntity.color = t; + } + setEntityOpacity(t) { + this._renderEntity.localOpacity = t; + } + setEntityEnabled(t) { + this._renderEntity.enabled = t; + } + _updateBlendFunc() { + let t = this.getRenderMaterial(0).passes[0].blendState.targets[0]; + this._dstBlendFactorCache = t.blendDst; + this._srcBlendFactorCache = t.blendSrc; + if (this._dstBlendFactorCache !== this._dstBlendFactor || this._srcBlendFactorCache !== this._srcBlendFactor) { + t = this.getMaterialInstance(0).passes[0].blendState.targets[0]; + t.blend = !0; + t.blendDstAlpha = Ls.ONE_MINUS_SRC_ALPHA; + t.blendDst = this._dstBlendFactor; + t.blendSrc = this._srcBlendFactor; + const e = this.getMaterialInstance(0).passes[0]; + e.blendState.setTarget(0, t); + e._updatePassHash(); + this._dstBlendFactorCache = this._dstBlendFactor; + this._srcBlendFactorCache = this._srcBlendFactor; + } + } + _nodeStateChange(e) { + this.renderData && this.markForUpdateRenderData(); + for (let e = 0; e < this.node.children.length; ++e) { + const i = this.node.children[e].getComponent(t); + i && i.markForUpdateRenderData(); + } + } + _colorDirty() { + this.node._uiProps.colorDirty = !0; + this.setEntityColorDirty(!0); + } + _onMaterialModified(t, e) { + if (this.renderData) { + this.markForUpdateRenderData(); + this.renderData.passDirty = !0; + } + super._onMaterialModified(t, e); + } + _updateBuiltinMaterial() { + let t; + switch (this._instanceMaterialType) { + case cD.ADD_COLOR: + t = xR.get("ui-base-material"); + break; + + case cD.GRAYSCALE: + t = xR.get("ui-sprite-gray-material"); + break; + + case cD.USE_ALPHA_SEPARATED: + t = xR.get("ui-sprite-alpha-sep-material"); + break; + + case cD.USE_ALPHA_SEPARATED_AND_GRAY: + t = xR.get("ui-sprite-gray-alpha-sep-material"); + break; + + default: + t = xR.get("ui-sprite-material"); + } + return t; + } + setNodeDirty() { + this.renderData && (this.renderData.nodeDirty = !0); + } + setTextureDirty() { + this.renderData && (this.renderData.textureDirty = !0); + } + createRenderEntity() { + return new fB(uB.STATIC); + } + }, lD.BlendState = Ls, lD.Assembler = null, lD.PostAssembler = null, hD), Bl(iD.prototype, "sharedMaterials", [ vh, YB ], Object.getOwnPropertyDescriptor(iD.prototype, "sharedMaterials"), iD.prototype), + Bl(iD.prototype, "customMaterial", [ qB, KB, JB, ZB, gh ], Object.getOwnPropertyDescriptor(iD.prototype, "customMaterial"), iD.prototype), + Bl(iD.prototype, "color", [ QB, $B ], Object.getOwnPropertyDescriptor(iD.prototype, "color"), iD.prototype), + sD = Bl(iD.prototype, "_materials", [ vh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), nD = Bl(iD.prototype, "_customMaterial", [ tD ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), rD = Bl(iD.prototype, "_srcBlendFactor", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Ls.SRC_ALPHA; + } + }), oD = Bl(iD.prototype, "_dstBlendFactor", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Ls.ONE_MINUS_SRC_ALPHA; + } + }), aD = Bl(iD.prototype, "_color", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Bi.WHITE.clone(); + } + }), iD)) || eD) || eD) || eD)); + m.internal.UIRenderer = uD; + var _D, dD, pD, mD, fD, gD, yD, bD, SD, AD, TD, vD, ED, CD, xD, wD, RD, ID, MD, BD, DD, PD, OD, ND, LD, FD, VD, kD, UD, GD, zD, HD, jD, XD, WD, YD, qD, KD, JD, ZD, QD, $D, tP, eP, iP, sP, nP, rP, oP, aP, lP, hP, cP, uP, _P, dP, pP, mP, fP, gP, yP, bP, SP, AP, TP, vP; + const EP = Bi.WHITE.clone(); + let CP; + !function(t) { + t[t.LEFT = 0] = "LEFT"; + t[t.CENTER = 1] = "CENTER"; + t[t.RIGHT = 2] = "RIGHT"; + }(CP || (CP = t("HorizontalTextAlignment", {}))); + he(CP); + let xP; + !function(t) { + t[t.TOP = 0] = "TOP"; + t[t.CENTER = 1] = "CENTER"; + t[t.BOTTOM = 2] = "BOTTOM"; + }(xP || (xP = t("VerticalTextAlignment", {}))); + he(xP); + let wP; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.CLAMP = 1] = "CLAMP"; + t[t.SHRINK = 2] = "SHRINK"; + t[t.RESIZE_HEIGHT = 3] = "RESIZE_HEIGHT"; + }(wP || (wP = t("Overflow", {}))); + he(wP); + let RP; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.BITMAP = 1] = "BITMAP"; + t[t.CHAR = 2] = "CHAR"; + }(RP || (RP = t("CacheMode", {}))); + he(RP); + let IP = function(e) { + return t({ + Label: e, + LabelComponent: e + }), e; + }((_D = Ul("cc.Label"), dD = sh(), pD = zl(110), mD = $l(), fD = ph(), gD = lh(), + yD = Th(CP), bD = ph(), SD = lh(), AD = Th(xP), TD = ph(), vD = lh(), ED = ph(), + CD = lh(), xD = ph(), wD = rh(), RD = lh(), ID = ph(), MD = lh(), BD = rh(), DD = ph(), + PD = lh(), OD = Th(wP), ND = ph(), LD = lh(), FD = ph(), VD = lh(), kD = Th(qI), + UD = ph(), GD = rh(), zD = lh(), HD = ph(), jD = lh(), XD = Th(RP), WD = ph(), YD = lh(), + qD = ph(), KD = lh(), JD = ph(), ZD = lh(), QD = ph(), $D = lh(), tP = rh(), eP = ph(), + iP = lh(), _D(sP = dD(sP = pD(sP = mD(sP = (nP = (vP = TP = class t extends uD { + get string() { + return this._string; + } + set string(t) { + t = null == t ? "" : t.toString(); + if (this._string !== t) { + this._string = t; + this.markForUpdateRenderData(); + } + } + get horizontalAlign() { + return this._horizontalAlign; + } + set horizontalAlign(t) { + if (this._horizontalAlign !== t) { + this._horizontalAlign = t; + this.markForUpdateRenderData(); + } + } + get verticalAlign() { + return this._verticalAlign; + } + set verticalAlign(t) { + if (this._verticalAlign !== t) { + this._verticalAlign = t; + this.markForUpdateRenderData(); + } + } + get actualFontSize() { + return this._actualFontSize; + } + set actualFontSize(t) { + this._actualFontSize = t; + } + get fontSize() { + return this._fontSize; + } + set fontSize(t) { + if (this._fontSize !== t) { + this._fontSize = t; + this.markForUpdateRenderData(); + } + } + get fontFamily() { + return this._fontFamily; + } + set fontFamily(t) { + if (this._fontFamily !== t) { + this._fontFamily = t; + this.markForUpdateRenderData(); + } + } + get lineHeight() { + return this._lineHeight; + } + set lineHeight(t) { + if (this._lineHeight !== t) { + this._lineHeight = t; + this.markForUpdateRenderData(); + } + } + get spacingX() { + return this._spacingX; + } + set spacingX(t) { + if (this._spacingX !== t) { + this._spacingX = t; + this.markForUpdateRenderData(); + } + } + get overflow() { + return this._overflow; + } + set overflow(t) { + if (this._overflow !== t) { + this._overflow = t; + this.markForUpdateRenderData(); + } + } + get enableWrapText() { + return this._enableWrapText; + } + set enableWrapText(t) { + if (this._enableWrapText !== t) { + this._enableWrapText = t; + this.markForUpdateRenderData(); + } + } + get font() { + return this._font; + } + set font(t) { + if (this._font !== t) { + this._isSystemFontUsed = !t; + this._font = t; + this.destroyRenderData(); + this._fontAtlas = null; + this.updateRenderData(!0); + } + } + get useSystemFont() { + return this._isSystemFontUsed; + } + set useSystemFont(t) { + if (this._isSystemFontUsed !== t) { + this.destroyRenderData(); + this._isSystemFontUsed = !!t; + t && (this.font = null); + this._flushAssembler(); + this.markForUpdateRenderData(); + } + } + get cacheMode() { + return this._cacheMode; + } + set cacheMode(t) { + if (this._cacheMode !== t) { + this._cacheMode !== RP.BITMAP || this._font instanceof uM || !this._ttfSpriteFrame || this._ttfSpriteFrame._resetDynamicAtlasFrame(); + this._cacheMode === RP.CHAR && (this._ttfSpriteFrame = null); + this._cacheMode = t; + this.updateRenderData(!0); + } + } + get isBold() { + return this._isBold; + } + set isBold(t) { + if (this._isBold !== t) { + this._isBold = t; + this.markForUpdateRenderData(); + } + } + get isItalic() { + return this._isItalic; + } + set isItalic(t) { + if (this._isItalic !== t) { + this._isItalic = t; + this.markForUpdateRenderData(); + } + } + get isUnderline() { + return this._isUnderline; + } + set isUnderline(t) { + if (this._isUnderline !== t) { + this._isUnderline = t; + this.markForUpdateRenderData(); + } + } + get underlineHeight() { + return this._underlineHeight; + } + set underlineHeight(t) { + if (this._underlineHeight !== t) { + this._underlineHeight = t; + this.markForUpdateRenderData(); + } + } + get spriteFrame() { + return this._texture; + } + get ttfSpriteFrame() { + return this._ttfSpriteFrame; + } + get assemblerData() { + return this._assemblerData; + } + get fontAtlas() { + return this._fontAtlas; + } + set fontAtlas(t) { + this._fontAtlas = t; + } + get _bmFontOriginalSize() { + return this._font instanceof uM ? this._font.fontSize : -1; + } + get contentWidth() { + return this._contentWidth; + } + set contentWidth(t) { + this._contentWidth = t; + } + constructor() { + super(); + Ml(this, "_string", rP, this); + Ml(this, "_horizontalAlign", oP, this); + Ml(this, "_verticalAlign", aP, this); + Ml(this, "_actualFontSize", lP, this); + Ml(this, "_fontSize", hP, this); + Ml(this, "_fontFamily", cP, this); + Ml(this, "_lineHeight", uP, this); + Ml(this, "_overflow", _P, this); + Ml(this, "_enableWrapText", dP, this); + Ml(this, "_font", pP, this); + Ml(this, "_isSystemFontUsed", mP, this); + Ml(this, "_spacingX", fP, this); + Ml(this, "_isItalic", gP, this); + Ml(this, "_isBold", yP, this); + Ml(this, "_isUnderline", bP, this); + Ml(this, "_underlineHeight", SP, this); + Ml(this, "_cacheMode", AP, this); + this._N$file = null; + this._texture = null; + this._ttfSpriteFrame = null; + this._userDefinedFont = null; + this._assemblerData = null; + this._fontAtlas = null; + this._letterTexture = null; + this._contentWidth = 0; + this._ttfSpriteFrame = null; + } + onEnable() { + super.onEnable(); + this._font || this._isSystemFontUsed || (this.useSystemFont = !0); + this._isSystemFontUsed && !this._fontFamily && (this.fontFamily = "Arial"); + this._applyFontTexture(); + } + onDestroy() { + this._assembler && this._assembler.resetAssemblerData && this._assembler.resetAssemblerData(this._assemblerData); + this._assemblerData = null; + if (this._ttfSpriteFrame) { + this._ttfSpriteFrame._resetDynamicAtlasFrame(); + const t = this._ttfSpriteFrame.texture; + this._ttfSpriteFrame.destroy(); + if (t) { + const e = t; + e.image && e.image.destroy(); + t.destroy(); + } + this._ttfSpriteFrame = null; + } + this._letterTexture = null; + super.onDestroy(); + } + updateRenderData(t = !1) { + if (t) { + this._flushAssembler(); + this.renderData && (this.renderData.vertDirty = !0); + this._applyFontTexture(); + } + this._assembler && this._assembler.updateRenderData(this); + } + _render(t) { + t.commitComp(this, this.renderData, this._texture, this._assembler, null); + } + _updateColor() { + super._updateColor(); + this.markForUpdateRenderData(); + } + setEntityColor(t) { + if (this._font instanceof uM) this._renderEntity.color = t; else { + EP.set(255, 255, 255, t.a); + this._renderEntity.color = EP; + } + } + _canRender() { + if (!super._canRender() || !this._string) return !1; + const t = this._font; + if (t && t instanceof uM) { + const e = t.spriteFrame; + if (!e || !e.texture) return !1; + } + return !0; + } + _flushAssembler() { + const e = t.Assembler.getAssembler(this); + if (this._assembler !== e) { + this.destroyRenderData(); + this._assembler = e; + } + if (!this.renderData && this._assembler && this._assembler.createData) { + this._renderData = this._assembler.createData(this); + this.renderData.material = this.material; + this._updateColor(); + } + } + _applyFontTexture() { + this.markForUpdateRenderData(); + const t = this._font; + if (t instanceof uM) { + const e = t.spriteFrame; + if (e && e.texture) { + this._texture = e; + this.renderData && (this.renderData.textureDirty = !0); + this.changeMaterialForDefine(); + this._assembler && this._assembler.updateRenderData(this); + } + } else { + if (this.cacheMode === RP.CHAR) { + this._letterTexture = this._assembler.getAssemblerData(); + this._texture = this._letterTexture; + } else if (!this._ttfSpriteFrame) { + this._ttfSpriteFrame = new GI; + this._assemblerData = this._assembler.getAssemblerData(); + const t = new IC(this._assemblerData.canvas); + const e = new LC; + e.image = t; + this._ttfSpriteFrame.texture = e; + } + this.cacheMode !== RP.CHAR && (this._texture = this._ttfSpriteFrame); + this.changeMaterialForDefine(); + } + } + changeMaterialForDefine() { + if (!this._texture) return; + let t = !1; + if (this.cacheMode !== RP.CHAR) { + const e = this._texture.texture; + if (e instanceof tm) { + const i = e.getPixelFormat(); + t = i === Jp.RGBA_ETC1 || i === Jp.RGB_A_PVRTC_4BPPV1 || i === Jp.RGB_A_PVRTC_2BPPV1; + } + } + this._instanceMaterialType = t ? cD.USE_ALPHA_SEPARATED : cD.ADD_COLOR_AND_TEXTURE; + this.updateMaterial(); + } + _updateBlendFunc() { + super._updateBlendFunc(); + } + }, TP.HorizontalAlign = CP, TP.VerticalAlign = xP, TP.Overflow = wP, TP.CacheMode = RP, + TP._canvasPool = DM.getInstance(), vP), Bl(nP.prototype, "string", [ fD, gD, fh ], Object.getOwnPropertyDescriptor(nP.prototype, "string"), nP.prototype), + Bl(nP.prototype, "horizontalAlign", [ yD, bD, SD ], Object.getOwnPropertyDescriptor(nP.prototype, "horizontalAlign"), nP.prototype), + Bl(nP.prototype, "verticalAlign", [ AD, TD, vD ], Object.getOwnPropertyDescriptor(nP.prototype, "verticalAlign"), nP.prototype), + Bl(nP.prototype, "fontSize", [ ED, CD ], Object.getOwnPropertyDescriptor(nP.prototype, "fontSize"), nP.prototype), + Bl(nP.prototype, "fontFamily", [ xD, wD, RD ], Object.getOwnPropertyDescriptor(nP.prototype, "fontFamily"), nP.prototype), + Bl(nP.prototype, "lineHeight", [ ID, MD ], Object.getOwnPropertyDescriptor(nP.prototype, "lineHeight"), nP.prototype), + Bl(nP.prototype, "spacingX", [ BD, DD, PD ], Object.getOwnPropertyDescriptor(nP.prototype, "spacingX"), nP.prototype), + Bl(nP.prototype, "overflow", [ OD, ND, LD ], Object.getOwnPropertyDescriptor(nP.prototype, "overflow"), nP.prototype), + Bl(nP.prototype, "enableWrapText", [ FD, VD ], Object.getOwnPropertyDescriptor(nP.prototype, "enableWrapText"), nP.prototype), + Bl(nP.prototype, "font", [ kD, UD, GD, zD ], Object.getOwnPropertyDescriptor(nP.prototype, "font"), nP.prototype), + Bl(nP.prototype, "useSystemFont", [ HD, jD ], Object.getOwnPropertyDescriptor(nP.prototype, "useSystemFont"), nP.prototype), + Bl(nP.prototype, "cacheMode", [ XD, WD, YD ], Object.getOwnPropertyDescriptor(nP.prototype, "cacheMode"), nP.prototype), + Bl(nP.prototype, "isBold", [ qD, KD ], Object.getOwnPropertyDescriptor(nP.prototype, "isBold"), nP.prototype), + Bl(nP.prototype, "isItalic", [ JD, ZD ], Object.getOwnPropertyDescriptor(nP.prototype, "isItalic"), nP.prototype), + Bl(nP.prototype, "isUnderline", [ QD, $D ], Object.getOwnPropertyDescriptor(nP.prototype, "isUnderline"), nP.prototype), + Bl(nP.prototype, "underlineHeight", [ tP, nh, eP, iP ], Object.getOwnPropertyDescriptor(nP.prototype, "underlineHeight"), nP.prototype), + rP = Bl(nP.prototype, "_string", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return "label"; + } + }), oP = Bl(nP.prototype, "_horizontalAlign", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return CP.CENTER; + } + }), aP = Bl(nP.prototype, "_verticalAlign", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return xP.CENTER; + } + }), lP = Bl(nP.prototype, "_actualFontSize", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), hP = Bl(nP.prototype, "_fontSize", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 40; + } + }), cP = Bl(nP.prototype, "_fontFamily", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return "Arial"; + } + }), uP = Bl(nP.prototype, "_lineHeight", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 40; + } + }), _P = Bl(nP.prototype, "_overflow", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return wP.NONE; + } + }), dP = Bl(nP.prototype, "_enableWrapText", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), pP = Bl(nP.prototype, "_font", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), mP = Bl(nP.prototype, "_isSystemFontUsed", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), fP = Bl(nP.prototype, "_spacingX", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), gP = Bl(nP.prototype, "_isItalic", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), yP = Bl(nP.prototype, "_isBold", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), bP = Bl(nP.prototype, "_isUnderline", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), SP = Bl(nP.prototype, "_underlineHeight", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 2; + } + }), AP = Bl(nP.prototype, "_cacheMode", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return RP.NONE; + } + }), nP)) || sP) || sP) || sP) || sP)); + m.Label = IP; + let MP = 0; + const BP = {}; + var DP = { + addStage(t) { + if (void 0 !== BP[t]) return; + const e = 1 << MP; + BP[t] = e; + MP += 1; + }, + stageID(t) { + const e = BP[t]; + return void 0 === e ? -1 : e; + }, + stageIDs(t) { + let e = 0; + for (const i of t) { + const t = BP[i]; + void 0 !== t && (e |= t); + } + return e; + } + }; + let PP; + !function(t) { + t[t.OPAQUE = 0] = "OPAQUE"; + t[t.TRANSPARENT = 1] = "TRANSPARENT"; + t[t.OVERLAY = 2] = "OVERLAY"; + }(PP || (PP = {})); + let OP; + !function(t) { + t[t.DEFAULT = 1] = "DEFAULT"; + t[t.FORWARD = 2] = "FORWARD"; + t[t.SHADOWCAST = 4] = "SHADOWCAST"; + }(OP || (OP = {})); + const NP = 4227858432; + const LP = 66060288; + const FP = 1044480; + const VP = { + [As.UNKNOWN]: (t, e, i = 0) => console.warn("illegal uniform handle"), + [As.INT]: (t, e, i = 0) => t[i], + [As.INT2]: (t, e, i = 0) => Qi.fromArray(e, t, i), + [As.INT3]: (t, e, i = 0) => Pi.fromArray(e, t, i), + [As.INT4]: (t, e, i = 0) => is.fromArray(e, t, i), + [As.FLOAT]: (t, e, i = 0) => t[i], + [As.FLOAT2]: (t, e, i = 0) => Qi.fromArray(e, t, i), + [As.FLOAT3]: (t, e, i = 0) => Pi.fromArray(e, t, i), + [As.FLOAT4]: (t, e, i = 0) => is.fromArray(e, t, i), + [As.MAT3]: (t, e, i = 0) => Fi.fromArray(e, t, i), + [As.MAT4]: (t, e, i = 0) => qi.fromArray(e, t, i) + }; + const kP = { + [As.UNKNOWN]: (t, e, i = 0) => console.warn("illegal uniform handle"), + [As.INT]: (t, e, i = 0) => t[i] = e, + [As.INT2]: (t, e, i = 0) => Qi.toArray(t, e, i), + [As.INT3]: (t, e, i = 0) => Pi.toArray(t, e, i), + [As.INT4]: (t, e, i = 0) => is.toArray(t, e, i), + [As.FLOAT]: (t, e, i = 0) => t[i] = e, + [As.FLOAT2]: (t, e, i = 0) => Qi.toArray(t, e, i), + [As.FLOAT3]: (t, e, i = 0) => Pi.toArray(t, e, i), + [As.FLOAT4]: (t, e, i = 0) => is.toArray(t, e, i), + [As.MAT3]: (t, e, i = 0) => Fi.toArray(t, e, i), + [As.MAT4]: (t, e, i = 0) => qi.toArray(t, e, i) + }; + const UP = [ Object.freeze([ 0 ]), Object.freeze([ 0, 0 ]), Object.freeze([ 0, 0, 0, 0 ]), Object.freeze([ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]) ]; + function GP(t) { + switch (t) { + case As.BOOL: + case As.INT: + case As.UINT: + case As.FLOAT: + return UP[0]; + + case As.BOOL2: + case As.INT2: + case As.UINT2: + case As.FLOAT2: + return UP[1]; + + case As.BOOL4: + case As.INT4: + case As.UINT4: + case As.FLOAT4: + return UP[2]; + + case As.MAT4: + return UP[3]; + + case As.SAMPLER2D: + return "default-texture"; + + case As.SAMPLER_CUBE: + return "default-cube-texture"; + + case As.SAMPLER2D_ARRAY: + return "default-array-texture"; + + case As.SAMPLER3D: + return "default-3d-texture"; + } + return UP[0]; + } + function zP(t) { + switch (t) { + case As.SAMPLER2D: + return "-texture"; + + case As.SAMPLER_CUBE: + return "-cube-texture"; + + case As.SAMPLER2D_ARRAY: + return "-array-texture"; + + case As.SAMPLER3D: + return "-3d-texture"; + + default: + return "-unknown"; + } + } + function HP(t, e) { + const i = Object.entries(e); + let s = !1; + for (let e = 0; e < i.length; e++) if (t[i[e][0]] !== i[e][1]) { + t[i[e][0]] = i[e][1]; + s = !0; + } + return s; + } + let jP; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.INSTANCING = 1] = "INSTANCING"; + t[t.VB_MERGING = 2] = "VB_MERGING"; + }(jP || (jP = {})); + const XP = jsb.Pass; + const WP = jsb.ProgramLib.getInstance(); + m.programLib = WP; + function YP(t) { + --t; + t |= t >> 16; + t |= t >> 8; + t |= t >> 4; + t |= t >> 2; + t |= t >> 1; + return ++t; + } + function qP(t, e) { + return Math.ceil(t / e) * e; + } + class KP { + constructor(t) { + this._device = void 0; + this._format = bs.UNKNOWN; + this._formatSize = 0; + this._chunks = []; + this._chunkCount = 0; + this._handles = []; + this._region0 = new mn; + this._region1 = new mn; + this._region2 = new mn; + this._roundUpFn = null; + this._bufferViewCtor = Uint8Array; + this._channels = 4; + this._alignment = 1; + this._device = t; + } + initialize(t) { + const e = ur[t.format]; + this._format = t.format; + this._formatSize = e.size; + this._channels = e.count; + this._bufferViewCtor = Ar(e); + this._roundUpFn = t.roundUpFn || null; + this._alignment = t.alignment || 1; + t.inOrderFree && (this.alloc = this._McDonaldAlloc); + } + destroy() { + for (let t = 0; t < this._chunkCount; ++t) { + this._chunks[t].texture.destroy(); + } + this._chunks.length = 0; + this._handles.length = 0; + } + alloc(t, e) { + t = qP(t, this._alignment); + let i = -1; + let s = -1; + if (void 0 !== e) { + i = e; + s = this._findAvailableSpace(t, i); + } + if (s < 0) for (let e = 0; e < this._chunkCount; ++e) { + i = e; + s = this._findAvailableSpace(t, i); + if (s >= 0) break; + } + if (s >= 0) { + const e = this._chunks[i]; + e.start += t; + const n = { + chunkIdx: i, + start: s, + end: s + t, + texture: e.texture + }; + this._handles.push(n); + return n; + } + const n = Math.sqrt(t / this._formatSize); + const r = this._roundUpFn && this._roundUpFn(n, this._formatSize) || Math.max(1024, YP(n)); + const o = this._chunks[this.createChunk(r)]; + o.start += t; + const a = { + chunkIdx: this._chunkCount - 1, + start: 0, + end: t, + texture: o.texture + }; + this._handles.push(a); + return a; + } + free(t) { + for (let e = 0; e < this._handles.length; ++e) if (this._handles[e] === t) { + this._chunks[t.chunkIdx].end = t.end; + this._handles.splice(e, 1); + return; + } + } + createChunk(t) { + const e = t * t * this._formatSize; + R(`TextureBufferPool: Allocate chunk ${this._chunkCount}, size: ${e}, format: ${this._format}`); + const i = { + texture: this._device.createTexture(new xn(xs.TEX2D, ws.SAMPLED | ws.TRANSFER_DST, this._format, t, t)), + size: e, + start: 0, + end: e + }; + this._chunks[this._chunkCount] = i; + return this._chunkCount++; + } + update(t, e) { + const i = []; + const s = []; + const n = t.start / this._formatSize; + let r = e.byteLength / this._formatSize; + let o = n % t.texture.width; + let a = Math.floor(n / t.texture.width); + let l = Math.min(t.texture.width - o, r); + let h = 0; + if (o > 0) { + this._region0.texOffset.x = o; + this._region0.texOffset.y = a; + this._region0.texExtent.width = l; + this._region0.texExtent.height = 1; + i.push(new this._bufferViewCtor(e, h * this._formatSize, l * this._channels)); + s.push(this._region0); + o = 0; + a += 1; + r -= l; + h += l; + } + if (r > 0) { + this._region1.texOffset.x = o; + this._region1.texOffset.y = a; + if (r > t.texture.width) { + this._region1.texExtent.width = t.texture.width; + this._region1.texExtent.height = Math.floor(r / t.texture.width); + l = this._region1.texExtent.width * this._region1.texExtent.height; + } else { + l = r; + this._region1.texExtent.width = l; + this._region1.texExtent.height = 1; + } + i.push(new this._bufferViewCtor(e, h * this._formatSize, l * this._channels)); + s.push(this._region1); + o = 0; + a += this._region1.texExtent.height; + r -= l; + h += l; + } + if (r > 0) { + this._region2.texOffset.x = o; + this._region2.texOffset.y = a; + this._region2.texExtent.width = r; + this._region2.texExtent.height = 1; + i.push(new this._bufferViewCtor(e, h * this._formatSize, r * this._channels)); + s.push(this._region2); + } + this._device.copyBuffersToTexture(i, t.texture, s); + } + _findAvailableSpace(t, e) { + const i = this._chunks[e]; + let s = !1; + let n = i.start; + if (n + t <= i.size) s = !0; else { + n = 0; + const r = this._handles.filter((t => t.chunkIdx === e)).sort(((t, e) => t.start - e.start)); + for (let e = 0; e < r.length; e++) { + const i = r[e]; + if (n + t <= i.start) { + s = !0; + break; + } + n = i.end; + } + !s && n + t <= i.size && (s = !0); + } + return s ? n : -1; + } + _McDonaldAlloc(t) { + t = qP(t, this._alignment); + for (let e = 0; e < this._chunkCount; ++e) { + const i = this._chunks[e]; + let s = !1; + let n = i.start; + if (n + t <= i.end) s = !0; else if (n > i.end) { + if (n + t <= i.size) s = !0; else if (t <= i.end) { + i.start = n = 0; + s = !0; + } + } else if (n === i.end) { + i.start = n = 0; + i.end = i.size; + t <= i.end && (s = !0); + } + if (s) { + i.start += t; + const s = { + chunkIdx: e, + start: n, + end: n + t, + texture: i.texture + }; + this._handles.push(s); + return s; + } + } + const e = Math.sqrt(t / this._formatSize); + const i = this._roundUpFn && this._roundUpFn(e, this._formatSize) || Math.max(1024, YP(e)); + const s = this._chunks[this.createChunk(i)]; + s.start += t; + const n = { + chunkIdx: this._chunkCount, + start: 0, + end: t, + texture: s.texture + }; + this._handles.push(n); + return n; + } + } + const JP = jsb.NativeBufferPool; + jsb.NativeObjectPool; + jsb.NativeBufferAllocator; + const ZP = (t, e) => { + for (let i = 0; i < t.length; ++i) if (t[i] === e) return !0; + return !1; + }; + var QP; + !function(t) { + t[t.UINT32 = 0] = "UINT32"; + t[t.FLOAT32 = 1] = "FLOAT32"; + t[t.NEVER = 2] = "NEVER"; + }(QP || (QP = {})); + class $P { + constructor(t, e, i, s, n = 8) { + this._dataType = void 0; + this._dataMembers = void 0; + this._elementCount = void 0; + this._entryBits = void 0; + this._stride = void 0; + this._entriesPerChunk = void 0; + this._entryMask = void 0; + this._chunkMask = void 0; + this._poolFlag = void 0; + this._arrayBuffers = []; + this._freeLists = []; + this._uint32BufferViews = []; + this._float32BufferViews = []; + this._hasUint32 = !1; + this._hasFloat32 = !1; + this._nativePool = void 0; + this._elementCount = s.COUNT; + this._entryBits = n; + this._dataType = e; + this._dataMembers = i; + this._stride = 4 * this._elementCount; + this._entriesPerChunk = 1 << n; + this._entryMask = this._entriesPerChunk - 1; + this._poolFlag = 1 << 30; + this._chunkMask = ~(this._entryMask | this._poolFlag); + this._nativePool = new JP(t, n, this._stride); + let r = QP.NEVER; + let o = !1; + let a = !1; + for (const t in e) { + o = this._hasFloat32; + a = this._hasUint32; + if (a && o) break; + r = e[t]; + o || r !== QP.FLOAT32 ? a || r !== QP.UINT32 || (this._hasUint32 = !0) : this._hasFloat32 = !0; + } + } + alloc() { + let t = 0; + for (;t < this._freeLists.length; t++) { + const e = this._freeLists[t]; + if (e.length) { + const i = e[e.length - 1]; + e.length--; + return (t << this._entryBits) + i + this._poolFlag; + } + } + const e = this._nativePool.allocateNewChunk(); + const i = []; + const s = []; + const n = []; + const r = this._hasFloat32; + const o = this._hasUint32; + for (let t = 0; t < this._entriesPerChunk; t++) { + r && i.push(new Float32Array(e, this._stride * t, this._elementCount)); + o && s.push(new Uint32Array(e, this._stride * t, this._elementCount)); + t && n.push(t); + } + o && this._uint32BufferViews.push(s); + r && this._float32BufferViews.push(i); + this._freeLists.push(n); + this._arrayBuffers.push(e); + return (t << this._entryBits) + this._poolFlag; + } + getBuffer(t) { + const e = (this._chunkMask & t) >> this._entryBits; + const i = this._entryMask & t; + const s = this._hasFloat32 ? this._float32BufferViews : this._uint32BufferViews; + if (!t || e < 0 || e >= s.length || i < 0 || i >= this._entriesPerChunk || ZP(this._freeLists[e], i)) { + console.warn("invalid buffer pool handle"); + return []; + } + return s[e][i]; + } + getTypedArray(t, e) { + const i = (this._chunkMask & t) >> this._entryBits; + const s = this._entryMask & t; + const n = this._dataType[e] === QP.UINT32 ? this._uint32BufferViews : this._float32BufferViews; + if (!t || i < 0 || i >= n.length || s < 0 || s >= this._entriesPerChunk || ZP(this._freeLists[i], s)) { + console.warn("invalid buffer pool handle"); + return []; + } + const r = e; + const o = n[i][s]; + const a = this._dataMembers[e]; + return o.subarray(r, r + a); + } + free(t) { + const e = (this._chunkMask & t) >> this._entryBits; + const i = this._entryMask & t; + if (!t || e < 0 || e >= this._freeLists.length || i < 0 || i >= this._entriesPerChunk || ZP(this._freeLists[e], i)) { + console.warn("invalid buffer pool handle"); + return; + } + (this._hasUint32 ? this._uint32BufferViews : this._float32BufferViews)[e][i].fill(0); + this._freeLists[e].push(i); + } + } + let tO; + !function(t) { + t[t.NODE = 0] = "NODE"; + t[t.PASS = 1] = "PASS"; + t[t.AABB = 2] = "AABB"; + t[t.RENDER2D = 3] = "RENDER2D"; + }(tO || (tO = {})); + let eO; + !function(t) { + t[t.POSITION = 0] = "POSITION"; + t[t.UV = 3] = "UV"; + t[t.COLOR = 5] = "COLOR"; + t[t.COUNT = 9] = "COUNT"; + }(eO || (eO = {})); + const iO = { + [eO.POSITION]: QP.FLOAT32, + [eO.UV]: QP.FLOAT32, + [eO.COLOR]: QP.UINT32, + [eO.COUNT]: QP.NEVER + }; + const sO = { + [eO.POSITION]: eO.UV - eO.POSITION, + [eO.UV]: eO.COLOR - eO.UV, + [eO.COLOR]: eO.COUNT - eO.COLOR, + [eO.COUNT]: 1 + }; + const nO = new $P(tO.RENDER2D, iO, sO, eO); + let rO; + !function(t) { + t[t.DIRTY_FLAG = 0] = "DIRTY_FLAG"; + t[t.LAYER = 1] = "LAYER"; + t[t.WORLD_SCALE = 2] = "WORLD_SCALE"; + t[t.WORLD_POSITION = 5] = "WORLD_POSITION"; + t[t.WORLD_ROTATION = 8] = "WORLD_ROTATION"; + t[t.WORLD_MATRIX = 12] = "WORLD_MATRIX"; + t[t.LOCAL_SCALE = 28] = "LOCAL_SCALE"; + t[t.LOCAL_POSITION = 31] = "LOCAL_POSITION"; + t[t.LOCAL_ROTATION = 34] = "LOCAL_ROTATION"; + t[t.COUNT = 38] = "COUNT"; + }(rO || (rO = {})); + const oO = { + [rO.DIRTY_FLAG]: QP.UINT32, + [rO.LAYER]: QP.UINT32, + [rO.WORLD_SCALE]: QP.FLOAT32, + [rO.WORLD_POSITION]: QP.FLOAT32, + [rO.WORLD_ROTATION]: QP.FLOAT32, + [rO.WORLD_MATRIX]: QP.FLOAT32, + [rO.LOCAL_SCALE]: QP.FLOAT32, + [rO.LOCAL_POSITION]: QP.FLOAT32, + [rO.LOCAL_ROTATION]: QP.FLOAT32, + [rO.COUNT]: QP.NEVER + }; + const aO = { + [rO.DIRTY_FLAG]: rO.LAYER - rO.DIRTY_FLAG, + [rO.LAYER]: rO.WORLD_SCALE - rO.LAYER, + [rO.WORLD_SCALE]: rO.WORLD_POSITION - rO.WORLD_SCALE, + [rO.WORLD_POSITION]: rO.WORLD_ROTATION - rO.WORLD_POSITION, + [rO.WORLD_ROTATION]: rO.WORLD_MATRIX - rO.WORLD_ROTATION, + [rO.WORLD_MATRIX]: rO.LOCAL_SCALE - rO.WORLD_MATRIX, + [rO.LOCAL_SCALE]: rO.LOCAL_POSITION - rO.LOCAL_SCALE, + [rO.LOCAL_POSITION]: rO.LOCAL_ROTATION - rO.LOCAL_POSITION, + [rO.LOCAL_ROTATION]: rO.COUNT - rO.LOCAL_ROTATION, + [rO.COUNT]: 1 + }; + const lO = new $P(tO.NODE, oO, aO, rO); + let hO; + !function(t) { + t[t.PRIORITY = 0] = "PRIORITY"; + t[t.STAGE = 1] = "STAGE"; + t[t.PHASE = 2] = "PHASE"; + t[t.PRIMITIVE = 3] = "PRIMITIVE"; + t[t.BATCHING_SCHEME = 4] = "BATCHING_SCHEME"; + t[t.DYNAMIC_STATE = 5] = "DYNAMIC_STATE"; + t[t.HASH = 6] = "HASH"; + t[t.COUNT = 7] = "COUNT"; + }(hO || (hO = {})); + const cO = { + [hO.PRIORITY]: QP.UINT32, + [hO.STAGE]: QP.UINT32, + [hO.PHASE]: QP.UINT32, + [hO.PRIMITIVE]: QP.UINT32, + [hO.BATCHING_SCHEME]: QP.UINT32, + [hO.DYNAMIC_STATE]: QP.UINT32, + [hO.HASH]: QP.UINT32, + [hO.COUNT]: QP.NEVER + }; + const uO = { + [hO.PRIORITY]: hO.STAGE - hO.PRIORITY, + [hO.STAGE]: hO.PHASE - hO.STAGE, + [hO.PHASE]: hO.PRIMITIVE - hO.PHASE, + [hO.PRIMITIVE]: hO.BATCHING_SCHEME - hO.PRIMITIVE, + [hO.BATCHING_SCHEME]: hO.DYNAMIC_STATE - hO.BATCHING_SCHEME, + [hO.DYNAMIC_STATE]: hO.HASH - hO.DYNAMIC_STATE, + [hO.HASH]: hO.COUNT - hO.HASH, + [hO.COUNT]: 1 + }; + const _O = new $P(tO.PASS, cO, uO, hO); + let dO; + !function(t) { + t[t.CENTER = 0] = "CENTER"; + t[t.HALFEXTENTS = 3] = "HALFEXTENTS"; + t[t.COUNT = 6] = "COUNT"; + }(dO || (dO = {})); + const pO = { + [dO.CENTER]: QP.FLOAT32, + [dO.HALFEXTENTS]: QP.FLOAT32, + [dO.COUNT]: QP.NEVER + }; + const mO = { + [dO.CENTER]: dO.HALFEXTENTS - dO.CENTER, + [dO.HALFEXTENTS]: dO.COUNT - dO.HALFEXTENTS, + [dO.COUNT]: 1 + }; + const fO = new $P(tO.AABB, pO, mO, dO); + const gO = jsb.RenderScene; + oe({ + Low_256x256: 256, + Medium_512x512: 512, + High_1024x1024: 1024, + Ultra_2048x2048: 2048 + }); + const yO = oe({ + Planar: 0, + ShadowMap: 1 + }); + oe({ + HARD: 0, + SOFT: 1, + SOFT_2X: 2, + SOFT_4X: 3 + }); + oe({ + LEVEL_1: 1, + LEVEL_2: 2, + LEVEL_3: 3, + LEVEL_4: 4 + }); + oe({ + NONE: 1, + RemoveDuplicates: 2, + DisableRotationFix: 3 + }); + const bO = yO.ShadowMap + 1; + class SO { + constructor() { + this.fixedSphere = new ua(0, 0, 0, .01); + this.maxReceived = 4; + this._matLight = new qi; + this._material = null; + this._instancingMaterial = null; + this._enabled = !1; + this._type = bO; + this._distance = 0; + this._normal = new Pi(0, 1, 0); + this._shadowColor = new Bi(0, 0, 0, 76); + this._size = new Qi(1024, 1024); + this._shadowMapDirty = !1; + } + get enabled() { + return this._enabled; + } + set enabled(t) { + this._enabled = t; + this.activate(); + } + get type() { + return this._type; + } + set type(t) { + this._type = this.enabled ? t : bO; + this.activate(); + } + get normal() { + return this._normal; + } + set normal(t) { + Pi.copy(this._normal, t); + } + get distance() { + return this._distance; + } + set distance(t) { + this._distance = t; + } + get shadowColor() { + return this._shadowColor; + } + set shadowColor(t) { + this._shadowColor = t; + } + get size() { + return this._size; + } + set size(t) { + this._size.set(t); + } + get shadowMapDirty() { + return this._shadowMapDirty; + } + set shadowMapDirty(t) { + this._shadowMapDirty = t; + } + get matLight() { + return this._matLight; + } + get material() { + return this._material; + } + get instancingMaterial() { + return this._instancingMaterial; + } + getPlanarShader(t) { + if (!this._material) { + this._material = new hm; + this._material.initialize({ + effectName: "pipeline/planar-shadow" + }); + } + const e = this._material.passes; + w(e.length > 0, "passes should not be empty!"); + return e.length > 0 ? e[0].getShaderVariant(t) : null; + } + getPlanarInstanceShader(t) { + if (!this._instancingMaterial) { + this._instancingMaterial = new hm; + this._instancingMaterial.initialize({ + effectName: "pipeline/planar-shadow", + defines: { + USE_INSTANCING: !0 + } + }); + } + const e = this._instancingMaterial.passes; + w(e.length > 0, "passes should not be empty!"); + return e.length > 0 ? e[0].getShaderVariant(t) : null; + } + initialize(t) { + this._enabled = t.enabled; + this._type = this.enabled ? t.type : bO; + this.normal = t.planeDirection; + this.distance = t.planeHeight; + this.shadowColor = t.shadowColor; + this.maxReceived = t.maxReceived; + if (t.shadowMapSize !== this._size.x) { + this.size.set(t.shadowMapSize, t.shadowMapSize); + this._shadowMapDirty = !0; + } + } + activate() { + if (this._enabled) if (this.type === yO.Planar) this._updatePlanarInfo(); else { + const t = m.director.root; + t.pipeline.macros.CC_SHADOW_TYPE = 2; + t.onGlobalPipelineStateChanged(); + } else { + const t = m.director.root; + t.pipeline.macros.CC_SHADOW_TYPE = 0; + t.onGlobalPipelineStateChanged(); + } + } + _updatePlanarInfo() { + if (!this._material) { + this._material = new hm; + this._material.initialize({ + effectName: "pipeline/planar-shadow" + }); + } + if (!this._instancingMaterial) { + this._instancingMaterial = new hm; + this._instancingMaterial.initialize({ + effectName: "pipeline/planar-shadow", + defines: { + USE_INSTANCING: !0 + } + }); + } + const t = m.director.root; + t.pipeline.macros.CC_SHADOW_TYPE = 1; + t.onGlobalPipelineStateChanged(); + } + destroy() { + this._material && this._material.destroy(); + this._instancingMaterial && this._instancingMaterial.destroy(); + this.fixedSphere.destroy(); + } + } + SO.MAX_FAR = 2e3; + SO.COEFFICIENT_OF_EXPANSION = 2 * Math.sqrt(3); + m.Shadows = SO; + Y(gO.prototype, "RenderScene.prototype", [ { + name: "raycastUI2DNode" + }, { + name: "raycastUINode" + } ]); + Y(gO.prototype, "RenderScene.prototype", [ { + name: "raycastAll", + suggest: "using intersect.rayModel in geometry" + }, { + name: "raycastAllModels", + suggest: "using intersect.rayModel in geometry" + }, { + name: "raycastSingleModel", + suggest: "using intersect.rayModel in geometry" + }, { + name: "raycastAllCanvas", + suggest: "using intersect.rayAABB in geometry" + }, { + name: "rayResultCanvas" + }, { + name: "rayResultModels" + }, { + name: "rayResultAll" + }, { + name: "rayResultSingleModel" + } ]); + const AO = {}; + Y(AO, "CameraVisFlags", [ { + name: "GENERAL" + } ]); + W(AO, "CameraVisFlags", [ { + name: "PROFILER", + newName: "PROFILER", + target: mm.BitMask, + targetName: "PROFILER" + }, { + name: "GIZMOS", + newName: "GIZMOS", + target: mm.BitMask, + targetName: "GIZMOS" + }, { + name: "EDITOR", + newName: "EDITOR", + target: mm.BitMask, + targetName: "EDITOR" + }, { + name: "UI", + newName: "UI", + target: mm.BitMask, + targetName: "UI_3D" + }, { + name: "UI2D", + newName: "UI2D", + target: mm.BitMask, + targetName: "UI_2D" + } ]); + m.CameraVisFlags = AO; + const TO = {}; + Y(TO, "VisibilityFlags", [ { + name: "GENERAL" + } ]); + W(TO, "VisibilityFlags", [ { + name: "ALWALS", + newName: "ALWALS", + target: mm.Enum, + targetName: "ALWALS" + }, { + name: "PROFILER", + newName: "PROFILER", + target: mm.Enum, + targetName: "PROFILER" + }, { + name: "GIZMOS", + newName: "GIZMOS", + target: mm.Enum, + targetName: "GIZMOS" + }, { + name: "EDITOR", + newName: "EDITOR", + target: mm.Enum, + targetName: "EDITOR" + }, { + name: "UI", + newName: "UI", + target: mm.Enum, + targetName: "UI_3D" + }, { + name: "UI2D", + newName: "UI2D", + target: mm.Enum, + targetName: "UI_2D" + } ]); + m.VisibilityFlags = TO; + W(XP.prototype, "Pass.prototype", [ { + name: "getBindingTypeFromHandle", + newName: "getDescriptorTypeFromHandle" + } ]); + Y(By.prototype, "Camera.prototype", [ { + name: "getSplitFrustum" + }, { + name: "setMatView" + }, { + name: "setMatViewInv" + }, { + name: "setMatProjInv" + }, { + name: "setMatViewProjInv" + }, { + name: "setMatProj" + }, { + name: "setMatViewProj" + }, { + name: "getMatViewInv" + } ]); + Y(SO.prototype, "Shadows.prototype", [ { + name: "aspect" + }, { + name: "selfShadow" + }, { + name: "linear" + }, { + name: "packing" + }, { + name: "autoAdapt" + }, { + name: "fixedArea" + }, { + name: "pcf" + }, { + name: "bias" + }, { + name: "normalBias" + }, { + name: "near" + }, { + name: "far" + }, { + name: "shadowDistance" + }, { + name: "invisibleOcclusionRange" + }, { + name: "orthoSize" + }, { + name: "saturation" + } ]); + Y(NA.prototype, "SpotLight.prototype", [ { + name: "aspect" + } ]); + const vO = DP.addStage; + var EO = Object.freeze({ + __proto__: null, + addStage: vO, + scene: KA, + createIA: function(t, e) { + if (!e.positions) { + console.error("The data must have positions field"); + return null; + } + const i = []; + const s = e.positions.length / 3; + for (let t = 0; t < s; ++t) { + i.push(e.positions[3 * t], e.positions[3 * t + 1], e.positions[3 * t + 2]); + e.normals && i.push(e.normals[3 * t], e.normals[3 * t + 1], e.normals[3 * t + 2]); + e.uvs && i.push(e.uvs[2 * t], e.uvs[2 * t + 1]); + e.colors && i.push(e.colors[3 * t], e.colors[3 * t + 1], e.colors[3 * t + 2]); + } + const n = []; + n.push(new Vn(cr.ATTR_POSITION, bs.RGB32F)); + e.normals && n.push(new Vn(cr.ATTR_NORMAL, bs.RGB32F)); + e.uvs && n.push(new Vn(cr.ATTR_TEX_COORD, bs.RG32F)); + e.colors && n.push(new Vn(cr.ATTR_COLOR, bs.RGB32F)); + const r = t.createBuffer(new An(Ts.VERTEX | Ts.TRANSFER_DST, Cs.DEVICE, 4 * i.length, 4 * i.length / s)); + r.update(new Float32Array(i)); + let o = null; + if (e.indices) { + o = t.createBuffer(new An(Ts.INDEX | Ts.TRANSFER_DST, Cs.DEVICE, 2 * e.indices.length, 2)); + o.update(new Uint16Array(e.indices)); + } + return t.createInputAssembler(new Un(n, [ r ], o)); + }, + get RenderQueue() { + return PP; + }, + get PassStage() { + return OP; + }, + genHandle: (t, e, i, s = 0) => e << 26 & NP | t << 20 & LP | i << 12 & FP | 4095 & s, + getTypeFromHandle: t => (t & NP) >>> 26, + getBindingFromHandle: t => (t & LP) >>> 20, + getCountFromHandle: t => (t & FP) >>> 12, + getOffsetFromHandle: t => 4095 & t, + customizeType: (t, e) => 67108863 & t | e << 26 & NP, + type2reader: VP, + type2writer: kP, + getDefaultFromType: GP, + getStringFromType: zP, + overrideMacros: HP, + get BatchingSchemes() { + return jP; + }, + Pass: XP, + getDeviceShaderVersion: function(t) { + switch (t.gfxAPI) { + case fs.GLES2: + case fs.WEBGL: + return "glsl1"; + + case fs.GLES3: + case fs.WEBGL2: + return "glsl3"; + + default: + return "glsl4"; + } + }, + programLib: WP, + nearestPOT: YP, + TextureBufferPool: KP, + MaterialInstance: uS, + PassInstance: class extends XP { + get parent() { + return this._parent; + } + constructor(t, e) { + super(t.root); + this._parent = void 0; + this._owner = void 0; + this._dontNotify = !1; + this._parent = t; + this._owner = e; + this._doInit(this._parent, !0); + for (let t = 0; t < this._shaderInfo.blocks.length; t++) { + const e = this._shaderInfo.blocks[t]; + const i = this._blocks[e.binding]; + const s = this._parent.blocks[e.binding]; + i.set(s); + } + this._rootBufferDirty = !0; + const i = this._parent; + for (let t = 0; t < this._shaderInfo.samplerTextures.length; t++) { + const e = this._shaderInfo.samplerTextures[t]; + for (let t = 0; t < e.count; t++) { + const s = i._descriptorSet.getSampler(e.binding, t); + const n = i._descriptorSet.getTexture(e.binding, t); + this._descriptorSet.bindSampler(e.binding, s, t); + this._descriptorSet.bindTexture(e.binding, n, t); + } + } + super.tryCompile(); + } + overridePipelineStates(t, e) { + this._bs.reset(); + this._rs.reset(); + this._dss.reset(); + XP.fillPipelineInfo(this, t); + XP.fillPipelineInfo(this, e); + this._onStateChange(); + } + tryCompile(t) { + if (t && !HP(this._defines, t)) return !1; + const e = super.tryCompile(); + this._onStateChange(); + return e; + } + beginChangeStatesSilently() { + this._dontNotify = !0; + } + endChangeStatesSilently() { + this._dontNotify = !1; + } + _syncBatchingScheme() { + this._defines.USE_BATCHING = this._defines.USE_INSTANCING = !1; + this._batchingScheme = jP.NONE; + } + _onStateChange() { + this._hash = XP.getPassHash(this); + this._owner.onPassStateChange(this._dontNotify); + } + }, + get PoolType() { + return tO; + }, + NULL_HANDLE: 0, + get Render2dView() { + return eO; + }, + Render2dPool: nO, + get NodeView() { + return rO; + }, + NodePool: lO, + get PassView() { + return hO; + }, + PassPool: _O, + get AABBView() { + return dO; + }, + AABBPool: fO, + RenderScene: gO, + CameraVisFlags: AO, + VisibilityFlags: TO + }); + t("renderer", EO); + let CO; + !function(t) { + t[t.BUTT = 0] = "BUTT"; + t[t.ROUND = 1] = "ROUND"; + t[t.SQUARE = 2] = "SQUARE"; + }(CO || (CO = {})); + he(CO); + let xO; + !function(t) { + t[t.BEVEL = 0] = "BEVEL"; + t[t.ROUND = 1] = "ROUND"; + t[t.MITER = 2] = "MITER"; + }(xO || (xO = {})); + he(xO); + let wO; + !function(t) { + t[t.PT_CORNER = 1] = "PT_CORNER"; + t[t.PT_LEFT = 2] = "PT_LEFT"; + t[t.PT_BEVEL = 4] = "PT_BEVEL"; + t[t.PT_INNERBEVEL = 8] = "PT_INNERBEVEL"; + }(wO || (wO = {})); + he(wO); + const RO = Math.PI; + const IO = Math.min; + const MO = Math.max; + const BO = Math.cos; + const DO = Math.sin; + const PO = Math.abs; + const OO = Math.sign; + const NO = .5522847493; + function LO(t, e, i, s, n) { + t.moveTo(e - s, i); + t.bezierCurveTo(e - s, i + n * NO, e - s * NO, i + n, e, i + n); + t.bezierCurveTo(e + s * NO, i + n, e + s, i + n * NO, e + s, i); + t.bezierCurveTo(e + s, i - n * NO, e + s * NO, i - n, e, i - n); + t.bezierCurveTo(e - s * NO, i - n, e - s, i - n * NO, e - s, i); + t.close(); + } + function FO(t, e, i, s, n, r, o, a, l, h, c) { + let u = 0; + let _ = 0; + let d = 0; + let p = 0; + let m = 0; + let f = 0; + let g = 0; + let y = 0; + let b = 0; + let S = 0; + let A = 0; + let T = 0; + let v = 0; + let E = 0; + let C = 0; + let x = 0; + if (!(h > 10)) { + u = .5 * (e + s); + _ = .5 * (i + n); + d = .5 * (s + r); + p = .5 * (n + o); + m = .5 * (r + a); + f = .5 * (o + l); + g = .5 * (u + d); + y = .5 * (_ + p); + v = a - e; + E = l - i; + C = PO((s - a) * E - (n - l) * v); + x = PO((r - a) * E - (o - l) * v); + if ((C + x) * (C + x) < t.tessTol * (v * v + E * E)) t.addPoint(a, l, 0 === c ? c | wO.PT_BEVEL : c); else { + b = .5 * (d + m); + S = .5 * (p + f); + A = .5 * (g + b); + T = .5 * (y + S); + FO(t, e, i, u, _, g, y, A, T, h + 1, 0); + FO(t, A, T, b, S, m, f, a, l, h + 1, c); + } + } + } + class VO extends Qi { + constructor(t, e) { + super(t, e); + this.dx = 0; + this.dy = 0; + this.dmx = 0; + this.dmy = 0; + this.flags = 0; + this.len = 0; + this.reset(); + } + reset() { + this.dx = 0; + this.dy = 0; + this.dmx = 0; + this.dmy = 0; + this.flags = 0; + this.len = 0; + } + } + class kO { + constructor() { + this.closed = !1; + this.bevel = 0; + this.complex = !0; + this.points = []; + this.reset(); + } + reset() { + this.closed = !1; + this.bevel = 0; + this.complex = !0; + this.points ? this.points.length = 0 : this.points = []; + } + } + class UO { + constructor(t) { + this.dataOffset = 0; + this.updatePathOffset = !1; + this.pathLength = 0; + this.pathOffset = 0; + this.paths = []; + this.tessTol = .25; + this.distTol = .01; + this.fillColor = Bi.WHITE.clone(); + this.lineCap = CO.BUTT; + this.strokeColor = Bi.BLACK.clone(); + this.lineJoin = xO.MITER; + this.lineWidth = 0; + this.pointsOffset = 0; + this._commandX = 0; + this._commandY = 0; + this._points = []; + this._renderDataList = []; + this._curPath = null; + this._comp = void 0; + this._comp = t; + } + moveTo(t, e) { + if (this.updatePathOffset) { + this.pathOffset = this.pathLength; + this.updatePathOffset = !1; + } + this._addPath(); + this.addPoint(t, e, wO.PT_CORNER); + this._commandX = t; + this._commandY = e; + } + lineTo(t, e) { + this.addPoint(t, e, wO.PT_CORNER); + this._commandX = t; + this._commandY = e; + } + bezierCurveTo(t, e, i, s, n, r) { + const o = this._curPath; + const a = o.points[o.points.length - 1]; + if (a) if (a.x !== t || a.y !== e || i !== n || s !== r) { + FO(this, a.x, a.y, t, e, i, s, n, r, 0, wO.PT_CORNER); + this._commandX = n; + this._commandY = r; + } else this.lineTo(n, r); + } + quadraticCurveTo(t, e, i, s) { + const n = this._commandX; + const r = this._commandY; + this.bezierCurveTo(n + 2 / 3 * (t - n), r + 2 / 3 * (e - r), i + 2 / 3 * (t - i), s + 2 / 3 * (e - s), i, s); + } + arc(t, e, i, s, n, r) { + !function(t, e, i, s, n, r, o) { + let a = 0; + let l = 0; + let h = 0; + let c = 0; + let u = 0; + let _ = 0; + let d = 0; + let p = 0; + let m = 0; + let f = 0; + let g = 0; + let y = 0; + let b = 0; + let S = 0; + let A = 0; + let T = 0; + l = r - n; + if (o = o || !1) if (PO(l) >= 2 * RO) l = 2 * RO; else for (;l < 0; ) l += 2 * RO; else if (PO(l) >= 2 * RO) l = 2 * -RO; else for (;l > 0; ) l -= 2 * RO; + T = 0 | MO(1, IO(PO(l) / (.5 * RO) + .5, 5)); + h = l / T / 2; + c = PO(4 / 3 * (1 - BO(h)) / DO(h)); + o || (c = -c); + for (A = 0; A <= T; A++) { + a = n + l * (A / T); + u = BO(a); + _ = DO(a); + d = e + u * s; + p = i + _ * s; + m = -_ * s * c; + f = u * s * c; + 0 === A ? t.moveTo(d, p) : t.bezierCurveTo(g + b, y + S, d - m, p - f, d, p); + g = d; + y = p; + b = m; + S = f; + } + }(this, t, e, i, s, n, r); + } + ellipse(t, e, i, s) { + LO(this, t, e, i, s); + this._curPath.complex = !1; + } + circle(t, e, i) { + LO(this, t, e, i, i); + this._curPath.complex = !1; + } + rect(t, e, i, s) { + this.moveTo(t, e); + this.lineTo(t + i, e); + this.lineTo(t + i, e + s); + this.lineTo(t, e + s); + this.close(); + this._curPath.complex = !1; + } + roundRect(t, e, i, s, n) { + !function(t, e, i, s, n, r) { + if (r < .1) t.rect(e, i, s, n); else { + const o = IO(r, .5 * PO(s)) * OO(s); + const a = IO(r, .5 * PO(n)) * OO(n); + t.moveTo(e, i + a); + t.lineTo(e, i + n - a); + t.bezierCurveTo(e, i + n - a * (1 - NO), e + o * (1 - NO), i + n, e + o, i + n); + t.lineTo(e + s - o, i + n); + t.bezierCurveTo(e + s - o * (1 - NO), i + n, e + s, i + n - a * (1 - NO), e + s, i + n - a); + t.lineTo(e + s, i + a); + t.bezierCurveTo(e + s, i + a * (1 - NO), e + s - o * (1 - NO), i, e + s - o, i); + t.lineTo(e + o, i); + t.bezierCurveTo(e + o * (1 - NO), i, e, i + a * (1 - NO), e, i + a); + t.close(); + } + }(this, t, e, i, s, n); + this._curPath.complex = !1; + } + clear() { + this.pathLength = 0; + this.pathOffset = 0; + this.pointsOffset = 0; + this.dataOffset = 0; + this._curPath = null; + this.paths.length = 0; + this._points.length = 0; + const t = this._renderDataList; + for (let e = 0, i = t.length; e < i; e++) { + const i = t[e]; + if (i) { + AB.remove(i); + i.removeRenderDrawInfo(this._comp); + } + } + this._renderDataList.length = 0; + } + close() { + this._curPath.closed = !0; + } + requestRenderData() { + const t = AB.add(); + this._renderDataList.push(t); + t.initRenderDrawInfo(this._comp, oB.MODEL); + this._comp._renderData = t; + this._comp._renderData.material = this._comp.getMaterialInstance(0); + return t; + } + getRenderDataList() { + 0 === this._renderDataList.length && this.requestRenderData(); + return this._renderDataList; + } + addPoint(t, e, i) { + const s = this._curPath; + if (!s) return; + const n = this._points; + const r = s.points; + let o = n[this.pointsOffset++]; + if (o) { + o.x = t; + o.y = e; + } else { + o = new VO(t, e); + n.push(o); + } + o.flags = i; + r.push(o); + } + _addPath() { + const t = this.pathLength; + let e = this.paths[t]; + if (e) e.reset(); else { + e = new kO; + this.paths.push(e); + } + this.pathLength++; + this._curPath = e; + return e; + } + } + var GO, zO, HO, jO, XO, WO, YO, qO, KO, JO, ZO, QO, $O, tN, eN, iN, sN, nN, rN, oN, aN, lN, hN; + const cN = GM.concat([ new Vn("a_dist", bs.R32F) ]); + const uN = WM(cN); + const _N = YM(cN); + let dN = function(e) { + return t({ + Graphics: e, + GraphicsComponent: e + }), e; + }((GO = Ul("cc.Graphics"), zO = sh(), HO = zl(110), jO = $l(), XO = lh(), WO = Th(xO), + YO = lh(), qO = Th(CO), KO = lh(), JO = lh(), ZO = lh(), QO = lh(), $O = rh(), GO(tN = zO(tN = HO(tN = jO(tN = (eN = (hN = lN = class t extends uD { + get lineWidth() { + return this._lineWidth; + } + set lineWidth(t) { + this._lineWidth = t; + this.impl && (this.impl.lineWidth = t); + } + get lineJoin() { + return this._lineJoin; + } + set lineJoin(t) { + this._lineJoin = t; + this.impl && (this.impl.lineJoin = t); + } + get lineCap() { + return this._lineCap; + } + set lineCap(t) { + this._lineCap = t; + this.impl && (this.impl.lineCap = t); + } + get strokeColor() { + return this._strokeColor; + } + set strokeColor(t) { + if (this.impl) { + this._strokeColor.set(t); + this.impl.strokeColor = this._strokeColor; + } + } + get fillColor() { + return this._fillColor; + } + set fillColor(t) { + if (this.impl) { + this._fillColor.set(t); + this.impl.fillColor = this._fillColor; + } + } + get miterLimit() { + return this._miterLimit; + } + set miterLimit(t) { + this._miterLimit = t; + } + get color() { + return this._color; + } + set color(t) { + this._color !== t && this._color.set(t); + } + get srcBlendFactor() { + return this._srcBlendFactor; + } + set srcBlendFactor(t) {} + get dstBlendFactor() { + return this._dstBlendFactor; + } + set dstBlendFactor(t) {} + get graphicsNativeProxy() { + return this._graphicsNativeProxy; + } + constructor() { + super(); + this.impl = null; + this.model = null; + Ml(this, "_lineWidth", iN, this); + Ml(this, "_strokeColor", sN, this); + Ml(this, "_lineJoin", nN, this); + Ml(this, "_lineCap", rN, this); + Ml(this, "_fillColor", oN, this); + Ml(this, "_miterLimit", aN, this); + this._isDrawing = !1; + this._isNeedUploadData = !0; + this._graphicsUseSubMeshes = []; + this._instanceMaterialType = cD.ADD_COLOR; + this.impl = new UO(this); + this._graphicsNativeProxy = new ZM; + } + onRestore() { + this.impl || this._flushAssembler(); + } + onLoad() { + super.onLoad(); + this._graphicsNativeProxy.initModel(this.node); + this.model = this._graphicsNativeProxy.getModel(); + this._flushAssembler(); + } + onEnable() { + super.onEnable(); + this._updateMtlForGraphics(); + } + onDestroy() { + this._sceneGetter = null; + this.graphicsNativeProxy.destroy(); + this.model = null; + if (this.impl) { + this._isDrawing = !1; + this.impl.clear(); + this.impl = null; + } + super.onDestroy(); + } + moveTo(t, e) { + this.impl && this.impl.moveTo(t, e); + } + lineTo(t, e) { + this.impl && this.impl.lineTo(t, e); + } + bezierCurveTo(t, e, i, s, n, r) { + this.impl && this.impl.bezierCurveTo(t, e, i, s, n, r); + } + quadraticCurveTo(t, e, i, s) { + this.impl && this.impl.quadraticCurveTo(t, e, i, s); + } + arc(t, e, i, s, n, r) { + this.impl && this.impl.arc(t, e, i, s, n, r); + } + ellipse(t, e, i, s) { + this.impl && this.impl.ellipse(t, e, i, s); + } + circle(t, e, i) { + this.impl && this.impl.circle(t, e, i); + } + rect(t, e, i, s) { + this.impl && this.impl.rect(t, e, i, s); + } + roundRect(t, e, i, s, n) { + this.impl && this.impl.roundRect(t, e, i, s, n); + } + fillRect(t, e, i, s) { + this.rect(t, e, i, s); + this.fill(); + } + clear() { + if (this.impl) { + this.impl.clear(); + this._isDrawing = !1; + this._graphicsNativeProxy.clear(); + this.markForUpdateRenderData(); + } + } + close() { + this.impl && this.impl.close(); + } + stroke() { + this._assembler || this._flushAssembler(); + this._isDrawing = !0; + this._isNeedUploadData = !0; + this._assembler.stroke(this); + } + fill() { + this._assembler || this._flushAssembler(); + this._isDrawing = !0; + this._isNeedUploadData = !0; + this._assembler.fill(this); + } + _updateMtlForGraphics() { + let t; + if (this._customMaterial) t = this.getMaterialInstance(0); else { + t = xR.get("ui-graphics-material"); + this.setMaterial(t, 0); + t = this.getMaterialInstance(0); + t.recompileShaders({ + USE_LOCAL: !0 + }); + } + } + activeSubModel(t) { + if (this.model) { + if (this.model.subModels.length <= t) { + const e = zo.gfxDevice; + const i = e.createBuffer(new An(Ts.VERTEX | Ts.TRANSFER_DST, Cs.DEVICE, 65535 * _N, _N)); + const s = e.createBuffer(new An(Ts.INDEX | Ts.TRANSFER_DST, Cs.DEVICE, 65535 * Uint16Array.BYTES_PER_ELEMENT * 2, Uint16Array.BYTES_PER_ELEMENT)); + const n = new fC([ i ], cN, Xs.TRIANGLE_LIST, s); + n.subMeshIdx = 0; + this.model.initSubModel(t, n, this.getMaterialInstance(0)); + this._graphicsUseSubMeshes.push(n); + } + } else N(4500, this.node.name); + } + _uploadData() { + const t = this.impl; + if (!t) return; + const e = t && t.getRenderDataList(); + if (e.length <= 0 || !this.model) return; + const i = this.model.subModels; + for (let t = 0; t < e.length; t++) { + const s = e[t]; + const n = i[t].inputAssembler; + if (s.lastFilledVertex === s.vertexStart) continue; + const r = new Float32Array(s.vData.buffer, 0, s.vertexStart * uN); + n.vertexBuffers[0].update(r); + n.vertexCount = s.vertexStart; + const o = new Uint16Array(s.iData.buffer, 0, s.indexStart); + n.indexBuffer.update(o); + n.indexCount = s.indexStart; + s.lastFilledVertex = s.vertexStart; + s.lastFilledIndex = s.indexStart; + } + this._isNeedUploadData = !1; + } + _render(t) { + if (this._isNeedUploadData) { + if (this.impl) { + const t = this.impl.getRenderDataList(); + const e = this.model.subModels.length; + if (t.length > e) for (let i = e; i < t.length; i++) this.activeSubModel(i); + } + this._uploadData(); + } + t.commitModel(this, this.model, this.getMaterialInstance(0)); + } + _flushAssembler() { + const e = t.Assembler.getAssembler(this); + this._assembler !== e && (this._assembler = e); + } + _canRender() { + return !!super._canRender() && this._isDrawing; + } + updateRenderer() { + super.updateRenderer(); + if (this._isNeedUploadData) { + if (this.impl) { + const t = this.impl.getRenderDataList(); + for (let e = 0; e < t.length; e++) t[e].setRenderDrawInfoAttributes(); + this._graphicsNativeProxy.activeSubModels(); + } + this._graphicsNativeProxy.uploadData(); + this._isNeedUploadData = !1; + } + } + createRenderEntity() { + return new fB(uB.DYNAMIC); + } + }, lN.LineJoin = xO, lN.LineCap = CO, hN), Bl(eN.prototype, "lineWidth", [ nh, XO ], Object.getOwnPropertyDescriptor(eN.prototype, "lineWidth"), eN.prototype), + Bl(eN.prototype, "lineJoin", [ WO, YO ], Object.getOwnPropertyDescriptor(eN.prototype, "lineJoin"), eN.prototype), + Bl(eN.prototype, "lineCap", [ qO, KO ], Object.getOwnPropertyDescriptor(eN.prototype, "lineCap"), eN.prototype), + Bl(eN.prototype, "strokeColor", [ JO ], Object.getOwnPropertyDescriptor(eN.prototype, "strokeColor"), eN.prototype), + Bl(eN.prototype, "fillColor", [ ZO ], Object.getOwnPropertyDescriptor(eN.prototype, "fillColor"), eN.prototype), + Bl(eN.prototype, "miterLimit", [ QO ], Object.getOwnPropertyDescriptor(eN.prototype, "miterLimit"), eN.prototype), + Bl(eN.prototype, "color", [ vh, $O ], Object.getOwnPropertyDescriptor(eN.prototype, "color"), eN.prototype), + iN = Bl(eN.prototype, "_lineWidth", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), sN = Bl(eN.prototype, "_strokeColor", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Bi.BLACK.clone(); + } + }), nN = Bl(eN.prototype, "_lineJoin", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return xO.MITER; + } + }), rN = Bl(eN.prototype, "_lineCap", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return CO.BUTT; + } + }), oN = Bl(eN.prototype, "_fillColor", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Bi.WHITE.clone(); + } + }), aN = Bl(eN.prototype, "_miterLimit", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 10; + } + }), eN)) || tN) || tN) || tN) || tN)); + m.Graphics = dN; + var pN, mN, fN, gN, yN, bN, SN, AN, TN, vN, EN, CN, xN, wN, RN, IN, MN, BN, DN, PN, ON, NN, LN, FN, VN, kN, UN, GN, zN, HN, jN, XN, WN, YN, qN, KN, JN, ZN, QN, $N, tL, eL, iL, sL, nL, rL; + let oL; + !function(t) { + t[t.SIMPLE = 0] = "SIMPLE"; + t[t.SLICED = 1] = "SLICED"; + t[t.TILED = 2] = "TILED"; + t[t.FILLED = 3] = "FILLED"; + }(oL || (oL = {})); + he(oL); + var aL; + !function(t) { + t[t.HORIZONTAL = 0] = "HORIZONTAL"; + t[t.VERTICAL = 1] = "VERTICAL"; + t[t.RADIAL = 2] = "RADIAL"; + }(aL || (aL = {})); + he(aL); + var lL; + !function(t) { + t[t.CUSTOM = 0] = "CUSTOM"; + t[t.TRIMMED = 1] = "TRIMMED"; + t[t.RAW = 2] = "RAW"; + }(lL || (lL = {})); + he(lL); + var hL; + !function(t) { + t.SPRITE_FRAME_CHANGED = "spriteframe-changed"; + }(hL || (hL = {})); + let cL = function(e) { + return t({ + Sprite: e, + SpriteComponent: e + }), e; + }((pN = Ul("cc.Sprite"), mN = sh(), fN = zl(110), gN = $l(), yN = Th(WI), bN = ph(), + SN = lh(), AN = Th(GI), TN = ph(), vN = lh(), EN = Th(oL), CN = ph(), xN = lh(), + wN = Th(aL), RN = ph(), IN = lh(), MN = ph(), BN = lh(), DN = hh(), PN = ph(), ON = lh(), + NN = hh(), LN = ph(), FN = lh(), VN = rh(), kN = ph(), UN = lh(), GN = ph(), zN = lh(), + HN = Th(lL), jN = ph(), XN = lh(), pN(WN = mN(WN = fN(WN = gN(WN = (YN = (rL = nL = class t extends uD { + constructor(...t) { + super(...t); + Ml(this, "_spriteFrame", qN, this); + Ml(this, "_type", KN, this); + Ml(this, "_fillType", JN, this); + Ml(this, "_sizeMode", ZN, this); + Ml(this, "_fillCenter", QN, this); + Ml(this, "_fillStart", $N, this); + Ml(this, "_fillRange", tL, this); + Ml(this, "_isTrimmedMode", eL, this); + Ml(this, "_useGrayscale", iL, this); + Ml(this, "_atlas", sL, this); + } + get spriteAtlas() { + return this._atlas; + } + set spriteAtlas(t) { + this._atlas !== t && (this._atlas = t); + } + get spriteFrame() { + return this._spriteFrame; + } + set spriteFrame(t) { + if (this._spriteFrame === t) return; + const e = this._spriteFrame; + this._spriteFrame = t; + this.markForUpdateRenderData(); + this._applySpriteFrame(e); + } + get type() { + return this._type; + } + set type(t) { + if (this._type !== t) { + this._type = t; + this._flushAssembler(); + } + } + get fillType() { + return this._fillType; + } + set fillType(t) { + this._fillType !== t && (t === aL.RADIAL || this._fillType === aL.RADIAL ? this.destroyRenderData() : this.renderData && this.markForUpdateRenderData(!0)); + this._fillType = t; + this._flushAssembler(); + } + get fillCenter() { + return this._fillCenter; + } + set fillCenter(t) { + this._fillCenter.x = t.x; + this._fillCenter.y = t.y; + this._type === oL.FILLED && this.renderData && this.markForUpdateRenderData(); + } + get fillStart() { + return this._fillStart; + } + set fillStart(t) { + this._fillStart = _i(t, 0, 1); + if (this._type === oL.FILLED && this.renderData) { + this.markForUpdateRenderData(); + this._updateUVs(); + } + } + get fillRange() { + return this._fillRange; + } + set fillRange(t) { + this._fillRange = _i(t, -1, 1); + if (this._type === oL.FILLED && this.renderData) { + this.markForUpdateRenderData(); + this._updateUVs(); + } + } + get trim() { + return this._isTrimmedMode; + } + set trim(t) { + if (this._isTrimmedMode !== t) { + this._isTrimmedMode = t; + this._type === oL.SIMPLE && this.renderData && this.markForUpdateRenderData(!0); + } + } + get grayscale() { + return this._useGrayscale; + } + set grayscale(t) { + if (this._useGrayscale !== t) { + this._useGrayscale = t; + this.changeMaterialForDefine(); + this.updateMaterial(); + } + } + get sizeMode() { + return this._sizeMode; + } + set sizeMode(t) { + if (this._sizeMode !== t) { + this._sizeMode = t; + t !== lL.CUSTOM && this._applySpriteSize(); + } + } + __preload() { + this.changeMaterialForDefine(); + super.__preload(); + } + onEnable() { + super.onEnable(); + this._activateMaterial(); + const t = this._spriteFrame; + if (t) { + this._updateUVs(); + this._type === oL.SLICED && t.on(GI.EVENT_UV_UPDATED, this._updateUVs, this); + } + } + onDisable() { + super.onDisable(); + this._spriteFrame && this._type === oL.SLICED && this._spriteFrame.off(GI.EVENT_UV_UPDATED, this._updateUVs, this); + } + onDestroy() { + super.onDestroy(); + } + changeSpriteFrameFromAtlas(t) { + if (!this._atlas) { + console.warn("SpriteAtlas is null."); + return; + } + const e = this._atlas.getSpriteFrame(t); + this.spriteFrame = e; + } + changeMaterialForDefine() { + let t; + const e = this._instanceMaterialType; + this._spriteFrame && (t = this._spriteFrame.texture); + let i = !1; + if (t instanceof tm) { + const e = t.getPixelFormat(); + i = e === Jp.RGBA_ETC1 || e === Jp.RGB_A_PVRTC_4BPPV1 || e === Jp.RGB_A_PVRTC_2BPPV1; + } + i && this.grayscale ? this._instanceMaterialType = cD.USE_ALPHA_SEPARATED_AND_GRAY : i ? this._instanceMaterialType = cD.USE_ALPHA_SEPARATED : this.grayscale ? this._instanceMaterialType = cD.GRAYSCALE : this._instanceMaterialType = cD.ADD_COLOR_AND_TEXTURE; + e !== this._instanceMaterialType && this.updateMaterial(); + } + _updateBuiltinMaterial() { + let t = super._updateBuiltinMaterial(); + if (this.spriteFrame && this.spriteFrame.texture instanceof Vg) { + const e = { + SAMPLE_FROM_RT: !0, + ...t.passes[0].defines + }; + const i = new hm; + i.initialize({ + effectAsset: t.effectAsset, + defines: e + }); + t = i; + } + return t; + } + _render(t) { + t.commitComp(this, this.renderData, this._spriteFrame, this._assembler, null); + } + _canRender() { + if (!super._canRender()) return !1; + const t = this._spriteFrame; + return !(!t || !t.texture); + } + _flushAssembler() { + const e = t.Assembler.getAssembler(this); + if (this._assembler !== e) { + this.destroyRenderData(); + this._assembler = e; + } + if (!this.renderData && this._assembler && this._assembler.createData) { + this._renderData = this._assembler.createData(this); + this.renderData.material = this.getRenderMaterial(0); + this.markForUpdateRenderData(); + this.spriteFrame && this._assembler.updateUVs(this); + this._updateColor(); + } + this._spriteFrame && (this._type === oL.SLICED ? this._spriteFrame.on(GI.EVENT_UV_UPDATED, this._updateUVs, this) : this._spriteFrame.off(GI.EVENT_UV_UPDATED, this._updateUVs, this)); + } + _applySpriteSize() { + if (this._spriteFrame) if (lL.RAW === this._sizeMode) { + const t = this._spriteFrame.originalSize; + this.node._uiProps.uiTransformComp.setContentSize(t); + } else if (lL.TRIMMED === this._sizeMode) { + const t = this._spriteFrame.rect; + this.node._uiProps.uiTransformComp.setContentSize(t.width, t.height); + } + } + _resized() {} + _activateMaterial() { + const t = this._spriteFrame; + const e = this.getRenderMaterial(0); + t && e && this.markForUpdateRenderData(); + this.renderData && (this.renderData.material = e); + } + _updateUVs() { + this._assembler && this._assembler.updateUVs(this); + } + _applySpriteFrame(t) { + const e = this._spriteFrame; + t && this._type === oL.SLICED && t.off(GI.EVENT_UV_UPDATED, this._updateUVs, this); + let i = !1; + if (e) { + t && t.texture === e.texture || (i = !0); + if (i) { + this.renderData && (this.renderData.textureDirty = !0); + this.changeMaterialForDefine(); + } + this._applySpriteSize(); + this._type === oL.SLICED && e.on(GI.EVENT_UV_UPDATED, this._updateUVs, this); + } + } + }, nL.FillType = aL, nL.Type = oL, nL.SizeMode = lL, nL.EventType = hL, rL), Bl(YN.prototype, "spriteAtlas", [ yN, bN, SN ], Object.getOwnPropertyDescriptor(YN.prototype, "spriteAtlas"), YN.prototype), + Bl(YN.prototype, "spriteFrame", [ AN, TN, vN ], Object.getOwnPropertyDescriptor(YN.prototype, "spriteFrame"), YN.prototype), + Bl(YN.prototype, "type", [ EN, CN, xN ], Object.getOwnPropertyDescriptor(YN.prototype, "type"), YN.prototype), + Bl(YN.prototype, "fillType", [ wN, RN, IN ], Object.getOwnPropertyDescriptor(YN.prototype, "fillType"), YN.prototype), + Bl(YN.prototype, "fillCenter", [ MN, BN ], Object.getOwnPropertyDescriptor(YN.prototype, "fillCenter"), YN.prototype), + Bl(YN.prototype, "fillStart", [ DN, PN, ON ], Object.getOwnPropertyDescriptor(YN.prototype, "fillStart"), YN.prototype), + Bl(YN.prototype, "fillRange", [ NN, LN, FN ], Object.getOwnPropertyDescriptor(YN.prototype, "fillRange"), YN.prototype), + Bl(YN.prototype, "trim", [ VN, kN, UN ], Object.getOwnPropertyDescriptor(YN.prototype, "trim"), YN.prototype), + Bl(YN.prototype, "grayscale", [ nh, GN, zN ], Object.getOwnPropertyDescriptor(YN.prototype, "grayscale"), YN.prototype), + Bl(YN.prototype, "sizeMode", [ HN, jN, XN ], Object.getOwnPropertyDescriptor(YN.prototype, "sizeMode"), YN.prototype), + qN = Bl(YN.prototype, "_spriteFrame", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), KN = Bl(YN.prototype, "_type", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return oL.SIMPLE; + } + }), JN = Bl(YN.prototype, "_fillType", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return aL.HORIZONTAL; + } + }), ZN = Bl(YN.prototype, "_sizeMode", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return lL.TRIMMED; + } + }), QN = Bl(YN.prototype, "_fillCenter", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Qi(0, 0); + } + }), $N = Bl(YN.prototype, "_fillStart", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), tL = Bl(YN.prototype, "_fillRange", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), eL = Bl(YN.prototype, "_isTrimmedMode", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), iL = Bl(YN.prototype, "_useGrayscale", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), sL = Bl(YN.prototype, "_atlas", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), YN)) || WN) || WN) || WN) || WN)); + m.Sprite = cL; + var uL, _L, dL, pL, mL, fL, gL, yL, bL, SL, AL, TL, vL, EL, CL, xL, wL, RL, IL; + const ML = new qi; + const BL = new Qi; + const DL = new qi; + const PL = []; + let OL; + !function(t) { + t[t.GRAPHICS_RECT = 0] = "GRAPHICS_RECT"; + t[t.GRAPHICS_ELLIPSE = 1] = "GRAPHICS_ELLIPSE"; + t[t.GRAPHICS_STENCIL = 2] = "GRAPHICS_STENCIL"; + t[t.SPRITE_STENCIL = 3] = "SPRITE_STENCIL"; + }(OL || (OL = {})); + he(OL); + let NL = function(e) { + return t({ + Mask: e, + MaskComponent: e + }), e; + }((uL = Ul("cc.Mask"), _L = sh(), dL = zl(110), pL = $l(), mL = Th(OL), fL = lh(), + gL = ph(), yL = lh(), bL = rh(), SL = rh(), AL = hh(), uL(TL = _L(TL = dL(TL = pL(TL = Ql(TL = (vL = (IL = RL = class extends Qc { + constructor(...t) { + super(...t); + Ml(this, "_type", EL, this); + Ml(this, "_inverted", CL, this); + Ml(this, "_segments", xL, this); + Ml(this, "_alphaThreshold", wL, this); + this._sprite = null; + this._graphics = null; + this._stencilStage = lB.DISABLED; + } + get type() { + return this._type; + } + set type(t) { + if (this._type !== t) { + this._type = t; + if (this._type !== OL.SPRITE_STENCIL) { + if (this._sprite) { + this.node.removeComponent(cL); + this._sprite._destroyImmediate(); + this._sprite = null; + } + this._changeRenderType(); + this._updateGraphics(); + this.subComp.renderEntity.setMaskMode(this._inverted ? mB.MASK_INVERTED : mB.MASK); + } else { + if (this._graphics) { + this._graphics.clear(); + this.node.removeComponent(dN); + this._graphics._destroyImmediate(); + this._graphics = null; + } + this._changeRenderType(); + this.subComp.renderEntity.setMaskMode(this._inverted ? mB.MASK_INVERTED : mB.MASK); + } + } + } + get inverted() { + return this._inverted; + } + set inverted(t) { + this._inverted = t; + this.subComp.stencilStage = this.inverted ? lB.ENTER_LEVEL_INVERTED : lB.ENTER_LEVEL; + this.subComp.renderEntity.setMaskMode(this._inverted ? mB.MASK_INVERTED : mB.MASK); + } + get segments() { + return this._segments; + } + set segments(t) { + if (this._segments !== t) { + this._segments = _i(t, 3, 1e4); + this._updateGraphics(); + } + } + get spriteFrame() { + return this._sprite ? this._sprite.spriteFrame : null; + } + set spriteFrame(t) { + this._sprite ? this._sprite.spriteFrame = t : console.error("please change type to sprite_stencil first"); + } + get alphaThreshold() { + return this._alphaThreshold; + } + set alphaThreshold(t) { + if (this._alphaThreshold !== t) { + this._alphaThreshold = t; + if (this.type === OL.SPRITE_STENCIL && this._sprite) { + this._sprite.getMaterialInstance(0).setProperty("alphaThreshold", this._alphaThreshold); + } + } + } + get subComp() { + return this._graphics || this._sprite; + } + onLoad() { + this._changeRenderType(); + this.subComp && this.subComp.renderEntity.setMaskMode(this._inverted ? mB.MASK_INVERTED : mB.MASK); + } + onEnable() { + this._changeRenderType(); + this._updateGraphics(); + this._enableRender(); + this.node.on(ny.ANCHOR_CHANGED, this._nodeStateChange, this); + this.node.on(ny.SIZE_CHANGED, this._nodeStateChange, this); + } + onRestore() { + this._changeRenderType(); + this._updateGraphics(); + } + onDisable() { + this._disableRender(); + this.node.off(ny.ANCHOR_CHANGED, this._nodeStateChange, this); + this.node.off(ny.SIZE_CHANGED, this._nodeStateChange, this); + } + onDestroy() { + this._removeMaskNode(); + } + isHit(t) { + const e = this.node._uiProps.uiTransformComp; + const i = e.contentSize; + const s = i.width; + const n = i.height; + const r = BL; + this.node.getWorldMatrix(ML); + qi.invert(DL, ML); + Qi.transformMat4(r, t, DL); + const o = e.anchorPoint; + r.x += o.x * s; + r.y += o.y * n; + let a = !1; + if (this.type === OL.GRAPHICS_RECT || this.type === OL.GRAPHICS_STENCIL || this.type === OL.SPRITE_STENCIL) a = r.x >= 0 && r.y >= 0 && r.x <= s && r.y <= n; else if (this.type === OL.GRAPHICS_ELLIPSE) { + const t = s / 2; + const e = n / 2; + const i = r.x - .5 * s; + const o = r.y - .5 * n; + a = i * i / (t * t) + o * o / (e * e) < 1; + } + this._inverted && (a = !a); + return a; + } + _nodeStateChange(t) { + this._updateGraphics(); + } + _changeRenderType() { + this._type !== OL.SPRITE_STENCIL ? this._createGraphics() : this._createSprite(); + } + _createSprite() { + if (!this._sprite) { + let t = this._sprite = this.node.getComponent(cL); + if (!t) { + const e = this.node; + t = this._sprite = e.addComponent(cL); + } + t.color = Bi.WHITE.clone(); + t.sizeMode = 0; + } + this._sprite.stencilStage = this.inverted ? lB.ENTER_LEVEL_INVERTED : lB.ENTER_LEVEL; + this._sprite.updateMaterial(); + } + _createGraphics() { + if (!this._graphics) { + let t = this._graphics = this.node.getComponent(dN); + if (!t) { + const e = this.node; + t = this._graphics = e.addComponent(dN); + } + t.lineWidth = 1; + const e = Bi.WHITE.clone(); + e.a = 0; + t.fillColor = e; + } + this._graphics.stencilStage = this.inverted ? lB.ENTER_LEVEL_INVERTED : lB.ENTER_LEVEL; + } + _updateGraphics() { + if (!this._graphics || this._type !== OL.GRAPHICS_RECT && this._type !== OL.GRAPHICS_ELLIPSE) return; + const t = this.node._uiProps.uiTransformComp; + const e = this._graphics; + e.clear(); + const i = t.contentSize; + const s = i.width; + const n = i.height; + const r = t.anchorPoint; + const o = -s * r.x; + const a = -n * r.y; + if (this._type === OL.GRAPHICS_RECT) e.rect(o, a, s, n); else if (this._type === OL.GRAPHICS_ELLIPSE) { + const t = function(t, e, i) { + PL.length = 0; + const s = 2 * Math.PI / i; + for (let n = 0; n < i; ++n) PL.push(new Pi(e.x * Math.cos(s * n) + t.x, e.y * Math.sin(s * n) + t.y, 0)); + return PL; + }(new Pi(o + s / 2, a + n / 2, 0), new Pi(s / 2, n / 2, 0), this._segments); + for (let i = 0; i < t.length; ++i) { + const s = t[i]; + 0 === i ? e.moveTo(s.x, s.y) : e.lineTo(s.x, s.y); + } + e.close(); + } + e.fill(); + } + _enableRender() { + this.subComp && (this.subComp.enabled = !0); + } + _disableRender() { + if (this.subComp) { + this.subComp.stencilStage = lB.DISABLED; + this.subComp.updateMaterial(); + this.node.activeInHierarchy && (this.subComp.enabled = !1); + } + } + _removeMaskNode() { + if (this._sprite) { + this._sprite.destroy(); + this._sprite = null; + } + if (this._graphics) { + this._graphics.destroy(); + this._graphics = null; + } + } + get customMaterial() { + N(9007); + return this.subComp ? this.subComp.customMaterial : null; + } + set customMaterial(t) { + N(9007); + this.subComp && (this.subComp.customMaterial = t); + } + get color() { + N(9007); + return this.subComp ? this.subComp.color : null; + } + set color(t) { + N(9007); + this.subComp && t && (this.subComp.color = t); + } + markForUpdateRenderData(t = !0) { + N(9007); + this.subComp && this.subComp.markForUpdateRenderData(t); + } + requestRenderData(t) { + N(9007); + } + destroyRenderData() { + N(9007); + } + updateRenderer() { + N(9007); + this.subComp && this.subComp.updateRenderer(); + } + fillBuffers(t) { + N(9007); + } + postUpdateAssembler(t) { + N(9007); + } + setNodeDirty() { + N(9007); + this.subComp && this.subComp.setNodeDirty(); + } + setTextureDirty() { + N(9007); + this.subComp && this.subComp.setTextureDirty(); + } + get sharedMaterial() { + N(9007); + return this.subComp ? this.subComp.sharedMaterial : null; + } + get sharedMaterials() { + N(9007); + return this.subComp ? this.subComp.sharedMaterials : null; + } + set sharedMaterials(t) { + N(9007); + this.subComp && t && (this.subComp.sharedMaterials = t); + } + get material() { + N(9007); + return this.subComp ? this.subComp.material : null; + } + set material(t) { + N(9007); + this.subComp && (this.subComp.material = t); + } + get materials() { + N(9007); + return this.subComp ? this.subComp.materials : [ null ]; + } + set materials(t) { + N(9007); + this.subComp && (this.subComp.materials = t); + } + getMaterial(t) { + N(9007); + return this.subComp ? this.subComp.getMaterial(t) : null; + } + setMaterial(t, e) { + N(9007); + this.subComp && this.subComp.setMaterial(t, e); + } + getMaterialInstance(t) { + N(9007); + return this.subComp ? this.subComp.getMaterialInstance(t) : null; + } + setMaterialInstance(t, e) { + N(9007); + this.subComp && this.subComp.setMaterialInstance(t, e); + } + getRenderMaterial(t) { + N(9007); + return this.subComp ? this.subComp.getRenderMaterial(t) : null; + } + }, RL.Type = OL, IL), Bl(vL.prototype, "type", [ mL, fL ], Object.getOwnPropertyDescriptor(vL.prototype, "type"), vL.prototype), + Bl(vL.prototype, "inverted", [ gL, yL ], Object.getOwnPropertyDescriptor(vL.prototype, "inverted"), vL.prototype), + Bl(vL.prototype, "segments", [ bL ], Object.getOwnPropertyDescriptor(vL.prototype, "segments"), vL.prototype), + Bl(vL.prototype, "alphaThreshold", [ SL, AL, dh ], Object.getOwnPropertyDescriptor(vL.prototype, "alphaThreshold"), vL.prototype), + EL = Bl(vL.prototype, "_type", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return OL.GRAPHICS_RECT; + } + }), CL = Bl(vL.prototype, "_inverted", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), xL = Bl(vL.prototype, "_segments", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 64; + } + }), wL = Bl(vL.prototype, "_alphaThreshold", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .1; + } + }), vL)) || TL) || TL) || TL) || TL) || TL)); + KS._maskComp = NL; + m.Mask = NL; + const LL = /^(click)(\s)*=|(param)(\s)*=/; + const FL = /(\s)*src(\s)*=|(\s)*height(\s)*=|(\s)*width(\s)*=|(\s)*align(\s)*=|(\s)*offset(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/; + class VL { + constructor() { + this._specialSymbolArray = []; + this._stack = []; + this._resultObjectArray = []; + this._specialSymbolArray.push([ /</g, "<" ]); + this._specialSymbolArray.push([ />/g, ">" ]); + this._specialSymbolArray.push([ /&/g, "&" ]); + this._specialSymbolArray.push([ /"/g, '"' ]); + this._specialSymbolArray.push([ /'/g, "'" ]); + } + parse(t) { + this._resultObjectArray.length = 0; + this._stack.length = 0; + let e = 0; + const i = t.length; + for (;e < i; ) { + let s = t.indexOf(">", e); + let n = -1; + if (s >= 0) { + n = t.lastIndexOf("<", s); + if (n < e - 1) { + n = t.indexOf("<", s + 1); + s = t.indexOf(">", n + 1); + } + } + if (n < 0) { + this._stack.pop(); + this._processResult(t.substring(e)); + e = i; + } else { + let i = t.substring(e, n); + const r = t.substring(n + 1, s); + "" === r && (i = t.substring(e, s + 1)); + this._processResult(i); + -1 === s ? s = n : "/" === t.charAt(n + 1) ? this._stack.pop() : this._addToStack(r); + e = s + 1; + } + } + return this._resultObjectArray; + } + _attributeToObject(t) { + t = t.trim(); + const e = {}; + let i = /^(color|size)(\s)*=/.exec(t); + let s = ""; + let n = 0; + let r = ""; + if (i) { + s = i[0]; + if ("" === (t = t.substring(s.length).trim())) return e; + n = t.indexOf(" "); + switch (s[0]) { + case "c": + e.color = n > -1 ? t.substring(0, n).trim() : t; + break; + + case "s": + e.size = parseInt(t); + } + if (n > -1) { + r = t.substring(n + 1).trim(); + e.event = this._processEventHandler(r); + } + return e; + } + i = /^(br(\s)*\/)/.exec(t); + if (i && i[0].length > 0) { + s = i[0].trim(); + if (s.startsWith("br") && "/" === s[s.length - 1]) { + e.isNewLine = !0; + this._resultObjectArray.push({ + text: "", + style: { + isNewLine: !0 + } + }); + return e; + } + } + i = /^(img(\s)*src(\s)*=[^>]+\/)/.exec(t); + let o = ""; + let a = -1; + if (i && i[0].length > 0) { + s = i[0].trim(); + if (s.startsWith("img") && "/" === s[s.length - 1]) { + i = FL.exec(t); + let r; + let l = !1; + for (;i; ) { + s = (t = t.substring(t.indexOf(i[0]))).substr(0, i[0].length); + const h = s.length; + s = s.replace(/[^a-zA-Z]/g, "").trim(); + s = s.toLowerCase(); + o = t.substring(h).trim(); + a = "src" === s ? this.getRightQuotationIndex(o) : -1; + n = o.indexOf(" ", a + 1 >= o.length ? -1 : a + 1); + r = n > -1 ? o.substr(0, n) : o; + t = o.substring(n).trim(); + r.endsWith("/") && (r = r.slice(0, -1)); + if ("src" === s) { + switch (r.charCodeAt(0)) { + case 34: + case 39: + l = !0; + r = r.slice(1, -1); + } + e.isImage = !0; + e.src = r; + } else if ("height" === s) e.imageHeight = parseInt(r); else if ("width" === s) e.imageWidth = parseInt(r); else if ("align" === s) { + switch (r.charCodeAt(0)) { + case 34: + case 39: + r = r.slice(1, -1); + } + e.imageAlign = r.toLowerCase(); + } else "offset" === s ? e.imageOffset = r : "click" === s && (e.event = this._processEventHandler(`${s}=${r}`)); + e.event && "param" === s && (e.event[s] = r.replace(/^"|"$/g, "")); + i = FL.exec(t); + } + l && e.isImage && this._resultObjectArray.push({ + text: "", + style: e + }); + return {}; + } + } + i = /^(outline(\s)*[^>]*)/.exec(t); + if (i) { + const r = { + color: "#ffffff", + width: 1 + }; + if (t = i[0].substring("outline".length).trim()) { + const a = /(\s)*color(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/; + i = a.exec(t); + let l; + for (;i; ) { + s = (t = t.substring(t.indexOf(i[0]))).substr(0, i[0].length); + o = t.substring(s.length).trim(); + n = o.indexOf(" "); + l = n > -1 ? o.substr(0, n) : o; + s = s.replace(/[^a-zA-Z]/g, "").trim(); + s = s.toLowerCase(); + t = o.substring(n).trim(); + "click" === s ? e.event = this._processEventHandler(`${s}=${l}`) : "color" === s ? r.color = l : "width" === s && (r.width = parseInt(l)); + e.event && "param" === s && (e.event[s] = l.replace(/^"|"$/g, "")); + i = a.exec(t); + } + } + e.outline = r; + } + i = /^(on|u|b|i)(\s)*/.exec(t); + if (i && i[0].length > 0) { + s = i[0]; + t = t.substring(s.length).trim(); + switch (s[0]) { + case "u": + e.underline = !0; + break; + + case "i": + e.italic = !0; + break; + + case "b": + e.bold = !0; + } + if ("" === t) return e; + e.event = this._processEventHandler(t); + } + return e; + } + getRightQuotationIndex(t) { + let e = -1; + let i = -1; + const s = t.indexOf("'"); + const n = t.indexOf('"'); + const r = n > -1 && (n < s || -1 === s); + if (s > -1 && (s < n || -1 === n)) { + e = s; + i = t.indexOf("'", e + 1 >= t.length ? -1 : e + 1); + } else if (r) { + e = n; + i = t.indexOf('"', e + 1 >= t.length ? -1 : e + 1); + } + return i; + } + _processEventHandler(t) { + const e = {}; + let i = 0; + let s = !1; + let n = LL.exec(t); + for (;n; ) { + let r = n[0]; + let o = ""; + s = !1; + if ('"' === (t = t.substring(r.length).trim()).charAt(0)) { + i = t.indexOf('"', 1); + if (i > -1) { + o = t.substring(1, i).trim(); + s = !0; + } + i++; + } else if ("'" === t.charAt(0)) { + i = t.indexOf("'", 1); + if (i > -1) { + o = t.substring(1, i).trim(); + s = !0; + } + i++; + } else { + const e = /(\S)+/.exec(t); + o = e ? e[0] : ""; + i = o.length; + } + if (s) { + r = r.substring(0, r.length - 1).trim(); + e[r] = o; + } + t = t.substring(i).trim(); + n = LL.exec(t); + } + return e; + } + _addToStack(t) { + const e = this._attributeToObject(t); + if (0 === this._stack.length) this._stack.push(e); else { + if (e.isNewLine || e.isImage) return; + const t = this._stack[this._stack.length - 1]; + for (const i in t) e[i] || (e[i] = t[i]); + this._stack.push(e); + } + } + _processResult(t) { + if (0 !== t.length) { + t = this._escapeSpecialSymbol(t); + this._stack.length > 0 ? this._resultObjectArray.push({ + text: t, + style: this._stack[this._stack.length - 1] + }) : this._resultObjectArray.push({ + text: t + }); + } + } + _escapeSpecialSymbol(t) { + for (const e of this._specialSymbolArray) { + const i = e[0]; + const s = e[1]; + t = t.replace(i, s); + } + return t; + } + } + t("HtmlTextParser", VL); + var kL, UL, GL, zL, HL, jL, XL, WL, YL, qL, KL, JL; + let ZL = function(e) { + return t({ + LabelOutline: e, + LabelOutlineComponent: e + }), e; + }((kL = Ul("cc.LabelOutline"), UL = sh(), GL = zl(110), zL = $l(), HL = Gl(IP), + jL = lh(), XL = lh(), kL(WL = UL(WL = GL(WL = zL(WL = HL(WL = Ql(WL = (YL = (JL = class extends Qc { + constructor(...t) { + super(...t); + Ml(this, "_color", qL, this); + Ml(this, "_width", KL, this); + } + get color() { + return this._color; + } + set color(t) { + if (this._color !== t) { + this._color.set(t); + this._updateRenderData(); + } + } + get width() { + return this._width; + } + set width(t) { + if (this._width !== t) { + this._width = t; + this._updateRenderData(); + } + } + onEnable() { + this._updateRenderData(); + } + onDisable() { + this._updateRenderData(); + } + _updateRenderData() { + const t = this.node.getComponent(IP); + t && t.updateRenderData(!0); + } + }, JL), qL = Bl(YL.prototype, "_color", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Bi(0, 0, 0, 255); + } + }), KL = Bl(YL.prototype, "_width", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 2; + } + }), Bl(YL.prototype, "color", [ jL ], Object.getOwnPropertyDescriptor(YL.prototype, "color"), YL.prototype), + Bl(YL.prototype, "width", [ XL ], Object.getOwnPropertyDescriptor(YL.prototype, "width"), YL.prototype), + YL)) || WL) || WL) || WL) || WL) || WL) || WL)); + m.LabelOutline = ZL; + et({ + RenderComponent: { + newName: "UIRenderer", + since: "1.2.0", + removed: !0 + }, + UITransformComponent: { + newName: "UITransform", + since: "1.2.0", + removed: !1 + }, + CanvasComponent: { + newName: "Canvas", + since: "1.2.0", + removed: !1 + } + }); + et({ + UIRenderable: { + newName: "UIRenderer", + since: "3.0.0", + removed: !0 + } + }); + et({ + Renderable2D: { + newName: "UIRenderer", + since: "3.6.0", + removed: !0 + } + }); + var QL; + let $L = t("RenderRoot2D", Ul("cc.RenderRoot2D")(QL = zl(100)(QL = $l()(QL = Gl(jB)(QL = Hl(QL = Ql(QL = class extends Qc { + onEnable() { + m.director.root.batcher2D.addScreen(this); + } + onDisable() { + m.director.root.batcher2D.removeScreen(this); + } + onDestroy() { + m.director.root.batcher2D.removeScreen(this); + } + }) || QL) || QL) || QL) || QL) || QL) || QL); + var tF, eF, iF, sF, nF, rF, oF, aF, lF, hF, cF, uF, _F; + const dF = new Pi; + const pF = oe({ + OVERLAY: 0, + INTERSPERSE: 1 + }); + let mF = function(e) { + return t({ + Canvas: e, + CanvasComponent: e + }), e; + }((tF = Ul("cc.Canvas"), eF = sh(), iF = zl(100), sF = $l(), nF = Th(hS), rF = lh(), + oF = lh(), aF = Th(hS), tF(lF = eF(lF = iF(lF = sF(lF = Ql(lF = Hl(lF = (hF = (_F = class extends $L { + get renderMode() { + return this._renderMode; + } + set renderMode(t) { + this._renderMode = t; + this._cameraComponent && (this._cameraComponent.priority = this._getViewPriority()); + } + get cameraComponent() { + return this._cameraComponent; + } + set cameraComponent(t) { + if (this._cameraComponent !== t) { + this._cameraComponent = t; + this._onResizeCamera(); + } + } + get alignCanvasWithScreen() { + return this._alignCanvasWithScreen; + } + set alignCanvasWithScreen(t) { + this._alignCanvasWithScreen = t; + this._onResizeCamera(); + } + constructor() { + super(); + Ml(this, "_cameraComponent", cF, this); + Ml(this, "_alignCanvasWithScreen", uF, this); + this._thisOnCameraResized = void 0; + this._fitDesignResolution = void 0; + this._pos = new Pi; + this._renderMode = pF.OVERLAY; + this._thisOnCameraResized = this._onResizeCamera.bind(this); + } + __preload() { + const t = this.getComponent("cc.Widget"); + t && t.updateAlignment(); + if (this._cameraComponent) { + this._cameraComponent._createCamera(); + this._cameraComponent.node.on(hS.TARGET_TEXTURE_CHANGE, this._thisOnCameraResized); + } + this._onResizeCamera(); + this.node.on(ny.TRANSFORM_CHANGED, this._thisOnCameraResized); + } + onEnable() { + super.onEnable(); + this._cameraComponent && this._cameraComponent.node.on(hS.TARGET_TEXTURE_CHANGE, this._thisOnCameraResized); + } + onDisable() { + super.onDisable(); + this._cameraComponent && this._cameraComponent.node.off(hS.TARGET_TEXTURE_CHANGE, this._thisOnCameraResized); + } + onDestroy() { + super.onDestroy(); + this.node.off(ny.TRANSFORM_CHANGED, this._thisOnCameraResized); + } + _onResizeCamera() { + if (this._cameraComponent && this._alignCanvasWithScreen) { + if (this._cameraComponent.targetTexture) this._cameraComponent.orthoHeight = HR.height / 2; else { + const t = Fo.windowSize; + this._cameraComponent.orthoHeight = t.height / JR.getScaleY() / 2; + } + this.node.getWorldPosition(dF); + this._cameraComponent.node.setWorldPosition(dF.x, dF.y, 1e3); + } + } + _getViewPriority() { + if (this._cameraComponent) { + var t; + let e = null === (t = this.cameraComponent) || void 0 === t ? void 0 : t.priority; + e = this._renderMode === pF.OVERLAY ? e | 1 << 30 : e & ~(1 << 30); + return e; + } + return 0; + } + }, _F), Bl(hF.prototype, "cameraComponent", [ nF, rF ], Object.getOwnPropertyDescriptor(hF.prototype, "cameraComponent"), hF.prototype), + Bl(hF.prototype, "alignCanvasWithScreen", [ oF ], Object.getOwnPropertyDescriptor(hF.prototype, "alignCanvasWithScreen"), hF.prototype), + cF = Bl(hF.prototype, "_cameraComponent", [ aF ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), uF = Bl(hF.prototype, "_alignCanvasWithScreen", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), hF)) || lF) || lF) || lF) || lF) || lF) || lF)); + m.Canvas = mF; + var fF; + Y(t("UIComponent", Ul("cc.UIComponent")(fF = Gl(jB)(fF = zl(110)(fF = Hl(fF = Ql(fF = class extends Qc { + constructor(...t) { + super(...t); + this._lastParent = null; + this.stencilStage = lB.DISABLED; + } + __preload() { + this.node._uiProps.uiComp = this; + } + onEnable() {} + onDisable() {} + onDestroy() { + this.node._uiProps.uiComp === this && (this.node._uiProps.uiComp = null); + } + postUpdateAssembler(t) {} + markForUpdateRenderData(t = !0) {} + setNodeDirty() {} + setTextureDirty() {} + }) || fF) || fF) || fF) || fF) || fF).prototype, "UIComponent", [ { + name: "_visibility" + }, { + name: "setVisibility" + } ]); + Y(uD.prototype, "Renderable2D.prototype", [ { + name: "srcBlendFactor" + }, { + name: "dstBlendFactor" + } ]); + W(mF.prototype, "Canvas.prototype", [ { + name: "camera", + newName: "cameraComponent.camera", + customGetter() { + return this._cameraComponent.camera; + } + }, { + name: "clearFlag", + newName: "cameraComponent.clearFlags", + customGetter() { + return this._cameraComponent ? this._cameraComponent.clearFlags : 0; + }, + customSetter(t) { + this._cameraComponent && (this._cameraComponent.clearFlags = t); + } + }, { + name: "color", + newName: "cameraComponent.clearColor", + customGetter() { + return this._cameraComponent ? this._cameraComponent.clearColor : Bi.BLACK; + }, + customSetter(t) { + this._cameraComponent && (this._cameraComponent.clearColor = t); + } + }, { + name: "priority", + newName: "cameraComponent.priority", + customGetter() { + return this._cameraComponent ? this._cameraComponent.priority : 0; + }, + customSetter(t) { + this._cameraComponent && (this._cameraComponent.priority = t); + } + }, { + name: "targetTexture", + newName: "cameraComponent.targetTexture", + customGetter() { + return this._cameraComponent ? this._cameraComponent.targetTexture : null; + }, + customSetter(t) { + this._cameraComponent && (this._cameraComponent.targetTexture = t); + } + }, { + name: "visibility", + newName: "cameraComponent.visibility", + customGetter() { + return this._cameraComponent ? this._cameraComponent.visibility : 0; + } + } ]); + q(jB.prototype, "UITransform.prototype", [ { + name: "priority", + suggest: "Please use setSiblingIndex to change index of the current node in its parent's children array." + } ]); + m.UITransformComponent = jB; + ee.setClassAlias(jB, "cc.UITransformComponent"); + ee.setClassAlias(uD, "cc.RenderComponent"); + m.CanvasComponent = mF; + ee.setClassAlias(mF, "cc.CanvasComponent"); + m.internal.Renderable2D = uD; + ee.setClassAlias(uD, "cc.Renderable2D"); + var gF, yF, bF, SF, AF, TF, vF, EF, CF, xF, wF, RF, IF, MF, BF; + var DF; + !function(t) { + t[t.SIMPLE = 0] = "SIMPLE"; + t[t.SLICED = 1] = "SLICED"; + t[t.TILED = 2] = "TILED"; + }(DF || (DF = {})); + t("SpriteRenderer", (gF = Ul("cc.SpriteRenderer"), yF = sh(), bF = zl(100), SF = $l(), + AF = Th(GI), TF = rh(), gF(vF = yF(vF = bF(vF = SF(vF = Ql(vF = (EF = (BF = class extends wS { + constructor(...t) { + super(...t); + Ml(this, "_spriteFrame", CF, this); + Ml(this, "_mode", xF, this); + Ml(this, "_color", wF, this); + Ml(this, "_flipX", RF, this); + Ml(this, "_flipY", IF, this); + Ml(this, "_size", MF, this); + this._model = null; + } + get spriteFrame() { + return this._spriteFrame; + } + set spriteFrame(t) { + if (this._spriteFrame === t) return; + this._spriteFrame; + this._spriteFrame = t; + if (this._spriteFrame) { + this._spriteFrame.ensureMeshData(); + this._spriteFrame.mesh.initialize(); + } + this._updateModels(); + this.enabledInHierarchy && this._attachToScene(); + } + get model() { + return this._model; + } + onLoad() { + if (this._spriteFrame) { + this._spriteFrame.mesh || this._spriteFrame.ensureMeshData(); + this._spriteFrame.mesh.initialize(); + } + this._updateModels(); + } + onRestore() { + this._updateModels(); + this.enabledInHierarchy && this._attachToScene(); + } + onEnable() { + this._model || this._updateModels(); + this._attachToScene(); + } + onDisable() { + this._model && this._detachFromScene(); + } + onDestroy() { + if (this._model) { + m.director.root.destroyModel(this._model); + this._model = null; + this._models.length = 0; + } + } + _updateModels() { + if (!this._spriteFrame) return; + const t = this._model; + if (t) { + t.destroy(); + t.initialize(); + t.node = t.transform = this.node; + } else this._createModel(); + if (this._model) { + const t = this._spriteFrame.mesh; + this._model.createBoundingShape(t.struct.minPosition, t.struct.maxPosition); + this._updateModelParams(); + this._onUpdateLocalDescriptorSet(); + } + } + _createModel() { + const t = this._model = m.director.root.createModel(wA); + t.visFlags = this.visibility; + t.node = t.transform = this.node; + this._models.length = 0; + this._models.push(this._model); + } + _updateModelParams() { + if (!this._spriteFrame || !this._model) return; + this._spriteFrame.ensureMeshData(); + const t = this._spriteFrame.mesh; + this.node.hasChangedFlags |= ay.POSITION; + this._model.transform.hasChangedFlags |= ay.POSITION; + const e = t ? t.renderingSubMeshes.length : 0; + const i = t.renderingSubMeshes; + if (i) for (let t = 0; t < e; ++t) { + let e = this.getRenderMaterial(t); + e && !e.isValid && (e = null); + const s = i[t]; + s && this._model.initSubModel(t, s, e || this._getBuiltinMaterial()); + } + this._model.enabled = !0; + } + _getBuiltinMaterial() { + return xR.get("missing-material"); + } + _onMaterialModified(t, e) { + super._onMaterialModified(t, e); + this._spriteFrame && this._model && this._model.inited && this._onRebuildPSO(t, e || this._getBuiltinMaterial()); + } + _onRebuildPSO(t, e) { + if (this._model && this._model.inited) { + this._model.setSubModelMaterial(t, e); + this._onUpdateLocalDescriptorSet(); + } + } + _onUpdateLocalDescriptorSet() { + if (!this._spriteFrame || !this._model || !this._model.inited) return; + const t = this._spriteFrame.getGFXTexture(); + const e = this._spriteFrame.getGFXSampler(); + const i = this._model.subModels; + const s = vm.SAMPLER_SPRITE; + for (let n = 0; n < i.length; n++) { + const {descriptorSet: r} = i[n]; + r.bindTexture(s, t); + r.bindSampler(s, e); + r.update(); + } + } + _attachToScene() { + if (!this.node.scene || !this._model) return; + const t = this._getRenderScene(); + null !== this._model.scene && this._detachFromScene(); + t.addModel(this._model); + } + _detachFromScene() { + this._model && this._model.scene && this._model.scene.removeModel(this._model); + } + }, BF), Bl(EF.prototype, "spriteFrame", [ AF ], Object.getOwnPropertyDescriptor(EF.prototype, "spriteFrame"), EF.prototype), + CF = Bl(EF.prototype, "_spriteFrame", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), xF = Bl(EF.prototype, "_mode", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return DF.SIMPLE; + } + }), wF = Bl(EF.prototype, "_color", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Bi.WHITE.clone(); + } + }), RF = Bl(EF.prototype, "_flipX", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), IF = Bl(EF.prototype, "_flipY", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), MF = Bl(EF.prototype, "_size", [ TF, Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Qi; + } + }), EF)) || vF) || vF) || vF) || vF) || vF)); + var PF, OF, NF, LF, FF, VF, kF, UF, GF, zF, HF, jF, XF, WF, YF, qF, KF, JF, ZF, QF, $F, tV, eV, iV, sV, nV, rV, oV, aV, lV, hV, cV, uV, _V, dV, pV, mV, fV, gV; + const yV = new VL; + const bV = "RICHTEXT_CHILD"; + const SV = "RICHTEXT_Image_CHILD"; + const AV = new $t((t => { + if (!m.isValid(t.node)) return !1; + { + const e = t.node.getComponent(ZL); + e && (e.width = 0); + } + return !0; + }), 20); + const TV = new $t((t => m.isValid(t.node)), 10); + function vV(t) { + return { + node: new _y(t), + comp: null, + lineCount: 0, + styleIndex: 0, + imageOffset: "", + clickParam: "", + clickHandler: "", + type: t + }; + } + function EV(t, e) { + let i; + t === bV ? i = AV._get() : t === SV && (i = TV._get()); + i = i || vV(t); + let s = i.node; + s || (s = new _y(t)); + s.hideFlags |= co.Flags.DontSave | co.Flags.HideInHierarchy; + if (t === SV) { + i.comp = s.getComponent(cL) || s.addComponent(cL); + i.comp.spriteFrame = e; + i.comp.type = cL.Type.SLICED; + i.comp.sizeMode = cL.SizeMode.CUSTOM; + } else { + i.comp = s.getComponent(IP) || s.addComponent(IP); + i.comp.string = e; + i.comp.horizontalAlign = CP.LEFT; + i.comp.verticalAlign = xP.TOP; + i.comp.underlineHeight = 2; + } + s.setPosition(0, 0, 0); + s._uiProps.uiTransformComp.setAnchorPoint(.5, .5); + i.node = s; + i.lineCount = 0; + i.styleIndex = 0; + i.imageOffset = ""; + i.clickParam = ""; + i.clickHandler = ""; + return i; + } + let CV = function(e) { + return t({ + RichText: e, + RichTextComponent: e + }), e; + }((PF = Ul("cc.RichText"), OF = sh(), NF = zl(110), LF = $l(), FF = lh(), VF = Th(CP), + kF = lh(), UF = Th(xP), GF = lh(), zF = lh(), HF = lh(), jF = Th(qI), XF = lh(), + WF = lh(), YF = ph(), qF = Th(RP), KF = lh(), JF = lh(), ZF = lh(), QF = Th(WI), + $F = lh(), tV = lh(), PF(eV = OF(eV = NF(eV = LF(eV = Ql(eV = (iV = (gV = fV = class extends Qc { + get string() { + return this._string; + } + set string(t) { + if (this._string !== t) { + this._string = t; + this._updateRichTextStatus(); + } + } + get horizontalAlign() { + return this._horizontalAlign; + } + set horizontalAlign(t) { + if (this.horizontalAlign !== t) { + this._horizontalAlign = t; + this._layoutDirty = !0; + this._updateRichTextStatus(); + } + } + get verticalAlign() { + return this._verticalAlign; + } + set verticalAlign(t) { + if (this._verticalAlign !== t) { + this._verticalAlign = t; + this._layoutDirty = !0; + this._updateRichTextStatus(); + } + } + get fontSize() { + return this._fontSize; + } + set fontSize(t) { + if (this._fontSize !== t) { + this._fontSize = t; + this._layoutDirty = !0; + this._updateRichTextStatus(); + } + } + get fontFamily() { + return this._fontFamily; + } + set fontFamily(t) { + if (this._fontFamily !== t) { + this._fontFamily = t; + this._layoutDirty = !0; + this._updateRichTextStatus(); + } + } + get font() { + return this._font; + } + set font(t) { + if (this._font !== t) { + this._font = t; + this._layoutDirty = !0; + if (this._font) { + this.useSystemFont = !1; + this._onTTFLoaded(); + } else this.useSystemFont = !0; + this._updateRichTextStatus(); + } + } + get useSystemFont() { + return this._isSystemFontUsed; + } + set useSystemFont(t) { + if (this._isSystemFontUsed !== t) { + this._isSystemFontUsed = t; + this._layoutDirty = !0; + this._updateRichTextStatus(); + } + } + get cacheMode() { + return this._cacheMode; + } + set cacheMode(t) { + if (this._cacheMode !== t) { + this._cacheMode = t; + this._updateRichTextStatus(); + } + } + get maxWidth() { + return this._maxWidth; + } + set maxWidth(t) { + if (this._maxWidth !== t) { + this._maxWidth = t; + this._layoutDirty = !0; + this._updateRichTextStatus(); + } + } + get lineHeight() { + return this._lineHeight; + } + set lineHeight(t) { + if (this._lineHeight !== t) { + this._lineHeight = t; + this._layoutDirty = !0; + this._updateRichTextStatus(); + } + } + get imageAtlas() { + return this._imageAtlas; + } + set imageAtlas(t) { + if (this._imageAtlas !== t) { + this._imageAtlas = t; + this._layoutDirty = !0; + this._updateRichTextStatus(); + } + } + get handleTouchEvent() { + return this._handleTouchEvent; + } + set handleTouchEvent(t) { + if (this._handleTouchEvent !== t) { + this._handleTouchEvent = t; + this.enabledInHierarchy && (this.handleTouchEvent ? this._addEventListeners() : this._removeEventListeners()); + } + } + constructor() { + super(); + Ml(this, "_lineHeight", sV, this); + Ml(this, "_string", nV, this); + Ml(this, "_horizontalAlign", rV, this); + Ml(this, "_verticalAlign", oV, this); + Ml(this, "_fontSize", aV, this); + Ml(this, "_maxWidth", lV, this); + Ml(this, "_fontFamily", hV, this); + Ml(this, "_font", cV, this); + Ml(this, "_isSystemFontUsed", uV, this); + Ml(this, "_userDefinedFont", _V, this); + Ml(this, "_cacheMode", dV, this); + Ml(this, "_imageAtlas", pV, this); + Ml(this, "_handleTouchEvent", mV, this); + this._textArray = []; + this._segments = []; + this._labelSegmentsCache = []; + this._linesWidth = []; + this._lineCount = 1; + this._labelWidth = 0; + this._labelHeight = 0; + this._layoutDirty = !0; + this._lineOffsetX = 0; + this._updateRichTextStatus = void 0; + this._labelChildrenNum = 0; + this._updateRichTextStatus = this._updateRichText; + } + onLoad() { + this.node.on(ny.LAYER_CHANGED, this._applyLayer, this); + } + onEnable() { + this.handleTouchEvent && this._addEventListeners(); + this._updateRichText(); + this._activateChildren(!0); + } + onDisable() { + this.handleTouchEvent && this._removeEventListeners(); + this._activateChildren(!1); + } + start() { + this._onTTFLoaded(); + this.node.on(ny.ANCHOR_CHANGED, this._updateRichTextPosition, this); + } + onRestore() {} + onDestroy() { + for (const t of this._segments) { + t.node.removeFromParent(); + t.type === bV ? AV.put(t) : t.type === SV && TV.put(t); + } + this.node.off(ny.ANCHOR_CHANGED, this._updateRichTextPosition, this); + this.node.off(ny.LAYER_CHANGED, this._applyLayer, this); + } + _addEventListeners() { + this.node.on(ny.TOUCH_END, this._onTouchEnded, this); + } + _removeEventListeners() { + this.node.off(ny.TOUCH_END, this._onTouchEnded, this); + } + _updateLabelSegmentTextAttributes() { + this._segments.forEach((t => { + this._applyTextAttribute(t); + })); + } + _createFontLabel(t) { + return EV(bV, t); + } + _createImage(t) { + return EV(SV, t); + } + _onTTFLoaded() { + if (this._font instanceof $I) { + this._layoutDirty = !0; + this._updateRichText(); + } else { + this._layoutDirty = !0; + this._updateRichText(); + } + } + SplitLongStringApproximatelyIn2048(t, e) { + const i = []; + if (this._calculateSize(e, t).x < 2048) i.push(t); else { + const s = t.split("\n"); + for (let t = 0; t < s.length; t++) { + if (this._calculateSize(e, s[t]).x < 2048) i.push(s[t]); else { + const n = this.splitLongStringOver2048(s[t], e); + i.push(...n); + } + } + } + return i; + } + splitLongStringOver2048(t, e) { + const i = []; + const s = t; + let n = 0; + let r = s.length / 2; + let o = s.substring(n, r); + let a = s.substring(r); + let l = this._calculateSize(e, o); + let h = this._calculateSize(e, a); + const c = 1 * this.maxWidth; + for (;l.x > c; ) { + r /= 2; + if (r < 1) { + r *= 2; + break; + } + o = o.substring(n, r); + a = s.substring(r); + l = this._calculateSize(e, o); + } + let u = 1e3; + let _ = 1; + for (;u && n < t.length; ) { + for (;u && l.x < c; ) { + const t = RM(a); + t && t.length > 0 && (_ = t[0].length); + r += _; + o = s.substring(n, r); + a = s.substring(r); + l = this._calculateSize(e, o); + u--; + } + for (;u && o.length >= 2 && l.x > c; ) { + r -= _; + o = s.substring(n, r); + l = this._calculateSize(e, o); + _ = 1; + u--; + } + if (o.length >= 2) { + const t = IM(o); + if (t && t.length > 0 && o !== t[0]) { + r -= t[0].length; + o = s.substring(n, r); + } + } + i.push(o); + n = r; + r += o.length; + o = s.substring(n, r); + a = s.substring(r); + h = this._calculateSize(e, a); + u--; + if (h.x < 2048) { + n = t.length; + r = t.length; + o = a; + i.push(o); + break; + } + l = this._calculateSize(e, o); + } + return i; + } + _measureText(t, e) { + const i = e => this._calculateSize(t, e).width; + return e ? i(e) : i; + } + _calculateSize(t, e) { + let i; + if (0 === this._labelSegmentsCache.length) { + i = this._createFontLabel(e); + this._labelSegmentsCache.push(i); + } else { + i = this._labelSegmentsCache[0]; + i.node.getComponent(IP).string = e; + } + i.styleIndex = t; + this._applyTextAttribute(i); + return i.node._uiProps.uiTransformComp.contentSize; + } + _onTouchEnded(t) { + const e = this.node.getComponents(Qc); + for (const i of this._segments) { + const s = i.clickHandler; + const n = i.clickParam; + if (s && this._containsTouchLocation(i, t.touch.getUILocation())) { + e.forEach((e => { + const i = e[s]; + e.enabledInHierarchy && i && i.call(e, t, n); + })); + t.propagationStopped = !0; + } + } + } + _containsTouchLocation(t, e) { + const i = t.node.getComponent(jB); + if (!i) return !1; + return i.getBoundingBoxToWorld().contains(e); + } + _resetState() { + const t = this.node.children; + for (let e = t.length - 1; e >= 0; e--) { + const i = t[e]; + if (i.name === bV || i.name === SV) { + w(i.parent === this.node); + i.parent = null; + const t = vV(i.name); + t.node = i; + if (i.name === bV) { + t.comp = i.getComponent(IP); + AV.put(t); + } else { + t.comp = i.getComponent(cL); + TV.put(t); + } + this._labelChildrenNum--; + } + } + this._segments.length = 0; + this._labelSegmentsCache.length = 0; + this._linesWidth.length = 0; + this._lineOffsetX = 0; + this._lineCount = 1; + this._labelWidth = 0; + this._labelHeight = 0; + this._layoutDirty = !0; + } + _activateChildren(t) { + for (let e = this.node.children.length - 1; e >= 0; e--) { + const i = this.node.children[e]; + i.name !== bV && i.name !== SV || (i.active = t); + } + } + _addLabelSegment(t, e) { + let i; + if (0 === this._labelSegmentsCache.length) i = this._createFontLabel(t); else { + i = this._labelSegmentsCache.pop(); + const e = i.node.getComponent(IP); + e && (e.string = t); + } + const s = i.comp; + s.verticalAlign !== this._verticalAlign && (s.verticalAlign = this._verticalAlign); + i.styleIndex = e; + i.lineCount = this._lineCount; + i.node._uiProps.uiTransformComp.setAnchorPoint(0, 0); + i.node.layer = this.node.layer; + this.node.insertChild(i.node, this._labelChildrenNum++); + this._applyTextAttribute(i); + this._segments.push(i); + return i; + } + _updateRichTextWithMaxWidth(t, e, i) { + let s = e; + let n; + if (this._lineOffsetX > 0 && s + this._lineOffsetX > this._maxWidth) { + let e = 0; + for (;this._lineOffsetX <= this._maxWidth; ) { + const n = this._getFirstWordLen(t, e, t.length); + const r = t.substr(e, n); + const o = this._measureText(i, r); + if (!(this._lineOffsetX + o <= this._maxWidth)) { + if (e > 0) { + const n = t.substr(0, e); + this._addLabelSegment(n, i); + t = t.substr(e, t.length); + s = this._measureText(i, t); + } + this._updateLineInfo(); + break; + } + this._lineOffsetX += o; + e += n; + } + } + if (s > this._maxWidth) { + const e = MM(t, s, this._maxWidth, this._measureText(i)); + for (let t = 0; t < e.length; ++t) { + const s = e[t]; + n = this._addLabelSegment(s, i); + const r = n.node._uiProps.uiTransformComp.contentSize; + this._lineOffsetX += r.width; + e.length > 1 && t < e.length - 1 && this._updateLineInfo(); + } + } else { + this._lineOffsetX += s; + this._addLabelSegment(t, i); + } + } + _isLastComponentCR(t) { + return t.length - 1 === t.lastIndexOf("\n"); + } + _updateLineInfo() { + this._linesWidth.push(this._lineOffsetX); + this._lineOffsetX = 0; + this._lineCount++; + } + _needsUpdateTextLayout(t) { + if (this._layoutDirty || !this._textArray || !t) return !0; + if (this._textArray.length !== t.length) return !0; + for (let e = 0; e < this._textArray.length; e++) { + const i = this._textArray[e]; + const s = t[e]; + if (i.text !== s.text) return !0; + { + const t = i.style; + const e = s.style; + if (t) { + if (e) { + if (!!e.outline != !!t.outline) return !0; + if (t.size !== e.size || t.italic !== e.italic || t.isImage !== e.isImage) return !0; + if (t.src !== e.src || t.imageAlign !== e.imageAlign || t.imageHeight !== e.imageHeight || t.imageWidth !== e.imageWidth || t.imageOffset !== e.imageOffset) return !0; + } else if (t.size || t.italic || t.isImage || t.outline) return !0; + } else if (e && (e.size || e.italic || e.isImage || e.outline)) return !0; + } + } + return !1; + } + _addRichTextImageElement(t) { + if (!t.style) return; + const e = t.style; + const i = e.src; + const s = this._imageAtlas && i && this._imageAtlas.getSpriteFrame(i); + if (s) { + const t = this._createImage(s); + t.comp; + switch (e.imageAlign) { + case "top": + t.node._uiProps.uiTransformComp.setAnchorPoint(0, 1); + break; + + case "center": + t.node._uiProps.uiTransformComp.setAnchorPoint(0, .5); + break; + + default: + t.node._uiProps.uiTransformComp.setAnchorPoint(0, 0); + } + e.imageOffset && (t.imageOffset = e.imageOffset); + t.node.layer = this.node.layer; + this.node.insertChild(t.node, this._labelChildrenNum++); + this._segments.push(t); + const i = s.rect.clone(); + let n = 1; + let r = i.width; + let o = i.height; + const a = e.imageWidth || 0; + const l = e.imageHeight || 0; + if (l > 0) { + n = l / o; + r *= n; + o *= n; + } else { + n = this._lineHeight / o; + r *= n; + o *= n; + } + a > 0 && (r = a); + if (this._maxWidth > 0) { + this._lineOffsetX + r > this._maxWidth && this._updateLineInfo(); + this._lineOffsetX += r; + } else { + this._lineOffsetX += r; + this._lineOffsetX > this._labelWidth && (this._labelWidth = this._lineOffsetX); + } + t.node._uiProps.uiTransformComp.setContentSize(r, o); + t.lineCount = this._lineCount; + t.clickHandler = ""; + t.clickParam = ""; + const h = e.event; + if (h) { + t.clickHandler = h.click; + t.clickParam = h.param; + } + } else N(4400); + } + _updateRichText() { + if (!this.enabledInHierarchy) return; + const t = yV.parse(this._string); + if (!this._needsUpdateTextLayout(t)) { + this._textArray = t.slice(); + this._updateLabelSegmentTextAttributes(); + return; + } + this._textArray = t.slice(); + this._resetState(); + let e = !1; + let i; + for (let t = 0; t < this._textArray.length; ++t) { + const s = this._textArray[t]; + let n = s.text; + if (void 0 === n) continue; + if ("" === n) { + if (s.style && s.style.isNewLine) { + this._updateLineInfo(); + continue; + } + if (s.style && s.style.isImage && this._imageAtlas) { + this._addRichTextImageElement(s); + continue; + } + } + n = this.SplitLongStringApproximatelyIn2048(n, t).join("\n"); + const r = n.split("\n"); + for (let s = 0; s < r.length; ++s) { + const o = r[s]; + if ("" !== o) { + e = !1; + if (this._maxWidth > 0) { + const e = this._measureText(t, o); + this._updateRichTextWithMaxWidth(o, e, t); + r.length > 1 && s < r.length - 1 && this._updateLineInfo(); + } else { + i = this._addLabelSegment(o, t); + this._lineOffsetX += i.node._uiProps.uiTransformComp.width; + this._lineOffsetX > this._labelWidth && (this._labelWidth = this._lineOffsetX); + r.length > 1 && s < r.length - 1 && this._updateLineInfo(); + } + } else { + if (this._isLastComponentCR(n) && s === r.length - 1) continue; + this._updateLineInfo(); + e = !0; + } + } + } + e || this._linesWidth.push(this._lineOffsetX); + this._maxWidth > 0 && (this._labelWidth = this._maxWidth); + this._labelHeight = (this._lineCount + pM) * this._lineHeight; + this.node._uiProps.uiTransformComp.setContentSize(this._labelWidth, this._labelHeight); + this._updateRichTextPosition(); + this._layoutDirty = !1; + } + _getFirstWordLen(t, e, i) { + let s = t.charAt(e); + if (EM(s) || CM(s)) return 1; + let n = 1; + for (let r = e + 1; r < i; ++r) { + s = t.charAt(r); + if (CM(s) || EM(s)) break; + n++; + } + return n; + } + _updateRichTextPosition() { + let t = 0; + let e = 1; + const i = this._lineCount; + const s = this.node._uiProps.uiTransformComp; + const n = s.anchorX; + const r = s.anchorY; + for (let s = 0; s < this._segments.length; ++s) { + const o = this._segments[s]; + const a = o.lineCount; + if (a > e) { + t = 0; + e = a; + } + let l = this._labelWidth * (.5 * this._horizontalAlign - n); + switch (this._horizontalAlign) { + case CP.LEFT: + break; + + case CP.CENTER: + l -= this._linesWidth[a - 1] / 2; + break; + + case CP.RIGHT: + l -= this._linesWidth[a - 1]; + } + const h = o.node.position; + o.node.setPosition(t + l, this._lineHeight * (i - a) - this._labelHeight * r, h.z); + a === e && (t += o.node._uiProps.uiTransformComp.width); + if (o.node.getComponent(cL)) { + const t = o.node.position.clone(); + const e = this._lineHeight; + const i = this._lineHeight * (1 + pM); + switch (o.node._uiProps.uiTransformComp.anchorY) { + case 1: + t.y += e + (i - e) / 2; + break; + + case .5: + t.y += i / 2; + break; + + default: + t.y += (i - e) / 2; + } + if (o.imageOffset) { + const e = o.imageOffset.split(","); + if (1 === e.length && e[0]) { + const i = parseFloat(e[0]); + Number.isInteger(i) && (t.y += i); + } else if (2 === e.length) { + const i = parseFloat(e[0]); + const s = parseFloat(e[1]); + Number.isInteger(i) && (t.x += i); + Number.isInteger(s) && (t.y += s); + } + } + o.node.position = t; + } + const c = o.node.getComponent(ZL); + if (c) { + const t = o.node.position.clone(); + t.y -= c.width; + o.node.position = t; + } + } + } + _convertLiteralColorValue(t) { + const e = t.toUpperCase(); + if (Bi[e]) { + return Bi[e]; + } + return (new Bi).fromHEX(t); + } + _applyTextAttribute(t) { + const e = t.node.getComponent(IP); + if (!e) return; + this._resetLabelState(e); + const i = t.styleIndex; + let s; + this._textArray[i] && (s = this._textArray[i].style); + if (s) { + e.color = this._convertLiteralColorValue(s.color || "white"); + e.isBold = !!s.bold; + e.isItalic = !!s.italic; + e.isUnderline = !!s.underline; + if (s.outline) { + let e = t.node.getComponent(ZL); + e || (e = t.node.addComponent(ZL)); + e.color = this._convertLiteralColorValue(s.outline.color); + e.width = s.outline.width; + } + e.fontSize = s.size || this._fontSize; + t.clickHandler = ""; + t.clickParam = ""; + const i = s.event; + if (i) { + t.clickHandler = i.click || ""; + t.clickParam = i.param || ""; + } + } + e.cacheMode = this._cacheMode; + this._font instanceof qI && !this._isSystemFontUsed ? e.font = this._font : e.fontFamily = this._fontFamily; + e.useSystemFont = this._isSystemFontUsed; + e.lineHeight = this._lineHeight; + e.updateRenderData(!0); + const n = e._assembler; + n && n.updateRenderData(e); + } + _applyLayer() { + for (const t of this._segments) t.node.layer = this.node.layer; + } + _resetLabelState(t) { + t.fontSize = this._fontSize; + t.color = Bi.WHITE; + t.isBold = !1; + t.isItalic = !1; + t.isUnderline = !1; + } + }, fV.HorizontalAlign = CP, fV.VerticalAlign = xP, gV), Bl(iV.prototype, "string", [ fh, FF ], Object.getOwnPropertyDescriptor(iV.prototype, "string"), iV.prototype), + Bl(iV.prototype, "horizontalAlign", [ VF, kF ], Object.getOwnPropertyDescriptor(iV.prototype, "horizontalAlign"), iV.prototype), + Bl(iV.prototype, "verticalAlign", [ UF, GF ], Object.getOwnPropertyDescriptor(iV.prototype, "verticalAlign"), iV.prototype), + Bl(iV.prototype, "fontSize", [ zF ], Object.getOwnPropertyDescriptor(iV.prototype, "fontSize"), iV.prototype), + Bl(iV.prototype, "fontFamily", [ HF ], Object.getOwnPropertyDescriptor(iV.prototype, "fontFamily"), iV.prototype), + Bl(iV.prototype, "font", [ jF, XF ], Object.getOwnPropertyDescriptor(iV.prototype, "font"), iV.prototype), + Bl(iV.prototype, "useSystemFont", [ WF, YF ], Object.getOwnPropertyDescriptor(iV.prototype, "useSystemFont"), iV.prototype), + Bl(iV.prototype, "cacheMode", [ qF, KF ], Object.getOwnPropertyDescriptor(iV.prototype, "cacheMode"), iV.prototype), + Bl(iV.prototype, "maxWidth", [ JF ], Object.getOwnPropertyDescriptor(iV.prototype, "maxWidth"), iV.prototype), + Bl(iV.prototype, "lineHeight", [ ZF ], Object.getOwnPropertyDescriptor(iV.prototype, "lineHeight"), iV.prototype), + Bl(iV.prototype, "imageAtlas", [ QF, $F ], Object.getOwnPropertyDescriptor(iV.prototype, "imageAtlas"), iV.prototype), + Bl(iV.prototype, "handleTouchEvent", [ tV ], Object.getOwnPropertyDescriptor(iV.prototype, "handleTouchEvent"), iV.prototype), + sV = Bl(iV.prototype, "_lineHeight", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 40; + } + }), nV = Bl(iV.prototype, "_string", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return "RichText"; + } + }), rV = Bl(iV.prototype, "_horizontalAlign", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return CP.LEFT; + } + }), oV = Bl(iV.prototype, "_verticalAlign", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return xP.TOP; + } + }), aV = Bl(iV.prototype, "_fontSize", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 40; + } + }), lV = Bl(iV.prototype, "_maxWidth", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), hV = Bl(iV.prototype, "_fontFamily", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return "Arial"; + } + }), cV = Bl(iV.prototype, "_font", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), uV = Bl(iV.prototype, "_isSystemFontUsed", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), _V = Bl(iV.prototype, "_userDefinedFont", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), dV = Bl(iV.prototype, "_cacheMode", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return RP.NONE; + } + }), pV = Bl(iV.prototype, "_imageAtlas", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), mV = Bl(iV.prototype, "_handleTouchEvent", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), iV)) || eV) || eV) || eV) || eV) || eV)); + m.RichText = CV; + var xV, wV; + let RV = function(e) { + return t({ + UIMeshRenderer: e, + UIModelComponent: e + }), e; + }(Ul("cc.UIMeshRenderer")(xV = sh()(xV = zl(110)(xV = $l()(xV = Ql(xV = (wV = class extends Qc { + constructor() { + super(); + this._modelComponent = null; + this.modelCount = 0; + this._dirtyVersion = -1; + this._internalId = -1; + this.stencilStage = lB.DISABLED; + this._renderData = null; + this._renderEntity = new fB(uB.DYNAMIC); + this._UIModelNativeProxy = new ZM; + } + get modelComponent() { + return this._modelComponent; + } + __preload() { + this.node._uiProps.uiComp = this; + } + onEnable() { + wR.addRenderer(this); + this.markForUpdateRenderData(); + } + onDisable() { + wR.removeRenderer(this); + this.renderEntity.enabled = this._canRender(); + } + onLoad() { + this.node._uiProps.uiTransformComp || this.node.addComponent("cc.UITransform"); + this._modelComponent = this.getComponent("cc.ModelRenderer"); + if (this._modelComponent) { + this._UIModelNativeProxy.attachNode(this.node); + this.renderEntity.setNode(this.node); + } else console.warn(`node '${this.node && this.node.name}' doesn't have any renderable component`); + } + onDestroy() { + this.renderEntity.setNode(null); + this.node._uiProps.uiComp === this && (this.node._uiProps.uiComp = null); + this._modelComponent = this.getComponent("cc.ModelRenderer"); + this._modelComponent && (this._modelComponent._sceneGetter = null); + } + _render(t) { + if (this._modelComponent) { + const e = this._modelComponent._collectModels(); + this._modelComponent._detachFromScene(); + for (let i = 0; i < e.length; i++) e[i].enabled && t.commitModel(this, e[i], this._modelComponent.material); + return !0; + } + return !1; + } + fillBuffers(t) { + this.enabled && this._render(t); + } + updateRenderer() { + this.renderEntity.enabled = this._canRender(); + if (this._modelComponent) { + const t = this._modelComponent._collectModels(); + this._modelComponent._detachFromScene(); + if (t.length !== this.modelCount) for (let e = this.modelCount; e < t.length; e++) { + this._uploadRenderData(e); + this._UIModelNativeProxy.updateModels(t[e]); + } + this.modelCount = t.length; + this._UIModelNativeProxy.attachDrawInfo(); + } + } + _uploadRenderData(t) { + { + const e = AB.add(); + e.initRenderDrawInfo(this, oB.MODEL); + this._renderData = e; + this._renderData.material = this._modelComponent.getMaterialInstance(t); + } + } + postUpdateAssembler(t) {} + update() { + if (this._modelComponent) { + this._modelComponent._collectModels().length !== this.modelCount && this.markForUpdateRenderData(); + } + this._fitUIRenderQueue(); + } + _fitUIRenderQueue() { + if (!this._modelComponent) return; + const t = this._modelComponent.sharedMaterials.length; + for (let e = 0; e < t; e++) { + const t = this._modelComponent.getMaterialInstance(e); + if (null == t) continue; + const i = t.passes; + const s = i.length; + for (let e = 0; e < s; e++) { + i[e]._priority = gm.MAX - 11; + t.recompileShaders({ + CC_FORCE_FORWARD_SHADING: !0 + }, e); + } + } + } + markForUpdateRenderData(t = !0) { + wR.markDirtyRenderer(this); + } + setNodeDirty() {} + setTextureDirty() {} + _canRender() { + return this.enabled && null !== this._modelComponent; + } + get renderEntity() { + w(this._renderEntity, "this._renderEntity should not be invalid"); + return this._renderEntity; + } + get renderData() { + return this._renderData; + } + }, wV)) || xV) || xV) || xV) || xV) || xV); + m.UIMeshRenderer = RV; + const IV = mm.Enum.NONE | mm.Enum.UI_3D; + class MV { + constructor() { + this.model = null; + this.texture = null; + this.sampler = null; + this.useLocalData = null; + this.isStatic = !1; + this.textureHash = 0; + this.samplerHash = 0; + this._passes = []; + this._shaders = []; + this._visFlags = IV; + this._inputAssembler = null; + this._descriptorSet = null; + } + get inputAssembler() { + return this._inputAssembler; + } + set inputAssembler(t) { + this._inputAssembler = t; + } + get descriptorSet() { + return this._descriptorSet; + } + set descriptorSet(t) { + this._descriptorSet = t; + } + get visFlags() { + return this._visFlags; + } + set visFlags(t) { + this._visFlags = t; + } + get passes() { + return this._passes; + } + get shaders() { + return this._shaders; + } + destroy(t) { + this._passes = []; + } + clear() { + this._inputAssembler = null; + this._descriptorSet = null; + this.texture = null; + this.sampler = null; + this.textureHash = 0; + this.samplerHash = 0; + this.model = null; + this.isStatic = !1; + this.useLocalData = null; + this.visFlags = IV; + } + fillPasses(t, e, i, s) { + if (t) { + const n = t.passes; + if (!n) return; + this._shaders.length = n.length; + for (let t = 0; t < n.length; t++) { + this._passes[t] || (this._passes[t] = new XP(m.director.root)); + const r = n[t]; + const o = this._passes[t]; + r.update(); + if (!e) { + e = r.depthStencilState; + i = 0; + } + o._initPassFromTarget(r, e, i); + this._shaders[t] = o.getShaderVariant(s); + } + } + } + } + var BV, DV, PV, OV, NV, LV, FV, VV; + let kV = function(e) { + return t({ + UIStaticBatch: e, + UIStaticBatchComponent: e + }), e; + }((BV = Ul("cc.UIStaticBatch"), DV = sh(), PV = $l(), OV = zl(110), NV = rh(), BV(LV = DV(LV = PV(LV = OV(LV = (FV = (VV = class extends uD { + constructor(...t) { + super(...t); + this._init = !1; + this._bufferAccessor = null; + this._dirty = !0; + this._uiDrawBatchList = []; + } + get color() { + return this._color; + } + set color(t) { + this._color !== t && this._color.set(t); + } + get drawBatchList() { + return this._uiDrawBatchList; + } + postUpdateAssembler(t) {} + markAsDirty() {} + _requireDrawBatch() { + const t = new MV; + t.isStatic = !0; + this._uiDrawBatchList.push(t); + return t; + } + _clearData() { + if (this._bufferAccessor) { + this._bufferAccessor.reset(); + const t = this._getBatcher(); + for (let e = 0; e < this._uiDrawBatchList.length; e++) { + this._uiDrawBatchList[e].destroy(t); + } + } + this._uiDrawBatchList.length = 0; + this._init = !1; + } + _getBatcher() { + if (IR.root && IR.root.batcher2D) return IR.root.batcher2D; + N(9301); + return null; + } + }, VV), Bl(FV.prototype, "color", [ vh, NV ], Object.getOwnPropertyDescriptor(FV.prototype, "color"), FV.prototype), + FV)) || LV) || LV) || LV) || LV)); + var UV, GV, zV, HV, jV, XV, WV, YV, qV, KV, JV, ZV, QV, $V; + let tk = t("LabelShadow", (UV = Ul("cc.LabelShadow"), GV = sh(), zV = zl(110), HV = $l(), + jV = Gl(IP), XV = lh(), WV = lh(), YV = lh(), UV(qV = GV(qV = zV(qV = HV(qV = jV(qV = Ql(qV = (KV = ($V = class extends Qc { + constructor(...t) { + super(...t); + Ml(this, "_color", JV, this); + Ml(this, "_offset", ZV, this); + Ml(this, "_blur", QV, this); + } + get color() { + return this._color; + } + set color(t) { + if (this._color !== t) { + this._color.set(t); + this._updateRenderData(); + } + } + get offset() { + return this._offset; + } + set offset(t) { + this._offset = t; + this._updateRenderData(); + } + get blur() { + return this._blur; + } + set blur(t) { + this._blur = t; + this._updateRenderData(); + } + onEnable() { + this._updateRenderData(); + } + onDisable() { + this._updateRenderData(); + } + _updateRenderData() { + const t = this.node.getComponent(IP); + t && t.updateRenderData(!0); + } + }, $V), JV = Bl(KV.prototype, "_color", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Bi(0, 0, 0, 255); + } + }), ZV = Bl(KV.prototype, "_offset", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Qi(2, 2); + } + }), QV = Bl(KV.prototype, "_blur", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 2; + } + }), Bl(KV.prototype, "color", [ XV ], Object.getOwnPropertyDescriptor(KV.prototype, "color"), KV.prototype), + Bl(KV.prototype, "offset", [ WV ], Object.getOwnPropertyDescriptor(KV.prototype, "offset"), KV.prototype), + Bl(KV.prototype, "blur", [ YV ], Object.getOwnPropertyDescriptor(KV.prototype, "blur"), KV.prototype), + KV)) || qV) || qV) || qV) || qV) || qV) || qV)); + var ek, ik, sk, nk, rk, ok, ak, lk, hk; + let ck = function(e) { + return t({ + UIOpacity: e, + UIOpacityComponent: e + }), e; + }((ek = Ul("cc.UIOpacity"), ik = sh(), sk = zl(110), nk = $l(), rk = lh(), ek(ok = ik(ok = sk(ok = nk(ok = Ql(ok = Hl(ok = (ak = (hk = class t extends Qc { + constructor(...t) { + super(...t); + Ml(this, "_opacity", lk, this); + } + get opacity() { + return this._opacity; + } + set opacity(t) { + if (this._opacity !== t) { + t = Ee(t, 0, 255); + this._opacity = t; + this.node._uiProps.localOpacity = t / 255; + this.setEntityLocalOpacityDirtyRecursively(!0); + } + } + setEntityLocalOpacityDirtyRecursively(e) { + t.setEntityLocalOpacityDirtyRecursively(this.node, e, 1); + } + static setEntityLocalOpacityDirtyRecursively(e, i, s) { + if (!e.isValid) return; + const n = e._uiProps.uiComp; + const r = e.getComponent(t); + let o = s; + if (n && n.color) { + n.renderEntity.colorDirty = i; + n.renderEntity.localOpacity = r ? o * r.opacity / 255 : o; + o = 1; + } else r && (o = o * r.opacity / 255); + for (let s = 0; s < e.children.length; s++) t.setEntityLocalOpacityDirtyRecursively(e.children[s], i || o < 1, o); + } + onEnable() { + this.node._uiProps.localOpacity = this._opacity / 255; + this.setEntityLocalOpacityDirtyRecursively(!0); + } + onDisable() { + this.node._uiProps.localOpacity = 1; + this.setEntityLocalOpacityDirtyRecursively(!0); + } + }, hk), Bl(ak.prototype, "opacity", [ nh, rk ], Object.getOwnPropertyDescriptor(ak.prototype, "opacity"), ak.prototype), + lk = Bl(ak.prototype, "_opacity", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 255; + } + }), ak)) || ok) || ok) || ok) || ok) || ok) || ok)); + m.MaskComponent = NL; + ee.setClassAlias(NL, "cc.MaskComponent"); + m.LabelComponent = IP; + ee.setClassAlias(IP, "cc.LabelComponent"); + m.LabelOutlineComponent = ZL; + ee.setClassAlias(ZL, "cc.LabelOutlineComponent"); + m.RichTextComponent = CV; + ee.setClassAlias(CV, "cc.RichTextComponent"); + m.SpriteComponent = cL; + ee.setClassAlias(cL, "cc.SpriteComponent"); + m.UIModelComponent = RV; + ee.setClassAlias(RV, "cc.UIModelComponent"); + m.GraphicsComponent = dN; + ee.setClassAlias(dN, "cc.GraphicsComponent"); + ee.setClassAlias(kV, "cc.UIStaticBatchComponent"); + ee.setClassAlias(ck, "cc.UIOpacityComponent"); + W(NL.prototype, "Mask", [ { + name: "graphics", + newName: "subComp", + target: NL.prototype, + targetName: "Mask" + } ]); + W(OL, "MaskType", [ { + name: "RECT", + newName: "GRAPHICS_RECT", + target: OL, + targetName: "MaskType" + }, { + name: "ELLIPSE", + newName: "GRAPHICS_ELLIPSE", + target: OL, + targetName: "MaskType" + }, { + name: "IMAGE_STENCIL", + newName: "SPRITE_STENCIL", + target: OL, + targetName: "MaskType" + } ]); + class uk { + constructor(t, e, i) { + this.i = void 0; + this.x = void 0; + this.y = void 0; + this.prev = null; + this.next = null; + this.z = 0; + this.prevZ = null; + this.nextZ = null; + this.steiner = !1; + this.i = t; + this.x = e; + this.y = i; + } + } + function _k(t, e, i, s, n) { + let r = 0; + let o = null; + if (n === function(t, e, i, s) { + let n = 0; + for (let r = e, o = i - s; r < i; r += s) { + n += (t[o] - t[r]) * (t[r + 1] + t[o + 1]); + o = r; + } + return n; + }(t, e, i, s) > 0) for (r = e; r < i; r += s) o = Mk(r, t[r], t[r + 1], o); else for (r = i - s; r >= e; r -= s) o = Mk(r, t[r], t[r + 1], o); + if (o && xk(o, o.next)) { + Bk(o); + o = o.next; + } + return o; + } + function dk(t, e = null) { + if (!t) return t; + e || (e = t); + let i = t; + let s = !1; + do { + s = !1; + if (i.steiner || !xk(i, i.next) && 0 !== Ck(i.prev, i, i.next)) i = i.next; else { + Bk(i); + i = e = i.prev; + if (i === i.next) return null; + s = !0; + } + } while (s || i !== e); + return e; + } + function pk(t, e, i, s, n, r, o = 0) { + if (!t) return; + !o && r && function(t, e, i, s) { + let n = t; + do { + null === n.z && (n.z = Ak(n.x, n.y, e, i, s)); + n.prevZ = n.prev; + n.nextZ = n.next; + n = n.next; + } while (n !== t); + n.prevZ.nextZ = null; + n.prevZ = null; + !function(t) { + let e = 0; + let i = null; + let s = null; + let n = null; + let r = null; + let o = 0; + let a = 0; + let l = 0; + let h = 1; + do { + i = t; + t = null; + r = null; + o = 0; + for (;i; ) { + o++; + s = i; + a = 0; + for (e = 0; e < h; e++) { + a++; + s = s.nextZ; + if (!s) break; + } + l = h; + for (;a > 0 || l > 0 && s; ) { + if (0 === a) { + n = s; + s = s.nextZ; + l--; + } else if (0 !== l && s) if (i.z <= s.z) { + n = i; + i = i.nextZ; + a--; + } else { + n = s; + s = s.nextZ; + l--; + } else { + n = i; + i = i.nextZ; + a--; + } + r ? r.nextZ = n : t = n; + n.prevZ = r; + r = n; + } + i = s; + } + r.nextZ = null; + h *= 2; + } while (o > 1); + }(n); + }(t, s, n, r); + let a = t; + let l = null; + let h = null; + for (;t.prev !== t.next; ) { + l = t.prev; + h = t.next; + if (r ? fk(t, s, n, r) : mk(t)) { + e.push(l.i / i); + e.push(t.i / i); + e.push(h.i / i); + Bk(t); + t = h.next; + a = h.next; + } else if ((t = h) === a) { + o ? 1 === o ? pk(t = gk(t, e, i), e, i, s, n, r, 2) : 2 === o && yk(t, e, i, s, n, r) : pk(dk(t), e, i, s, n, r, 1); + break; + } + } + } + function mk(t) { + const e = t.prev; + const i = t; + const s = t.next; + if (Ck(e, i, s) >= 0) return !1; + let n = t.next.next; + for (;n !== t.prev; ) { + if (vk(e.x, e.y, i.x, i.y, s.x, s.y, n.x, n.y) && Ck(n.prev, n, n.next) >= 0) return !1; + n = n.next; + } + return !0; + } + function fk(t, e, i, s) { + const n = t.prev; + const r = t; + const o = t.next; + if (Ck(n, r, o) >= 0) return !1; + const a = n.x < r.x ? n.x < o.x ? n.x : o.x : r.x < o.x ? r.x : o.x; + const l = n.y < r.y ? n.y < o.y ? n.y : o.y : r.y < o.y ? r.y : o.y; + const h = n.x > r.x ? n.x > o.x ? n.x : o.x : r.x > o.x ? r.x : o.x; + const c = n.y > r.y ? n.y > o.y ? n.y : o.y : r.y > o.y ? r.y : o.y; + const u = Ak(a, l, e, i, s); + const _ = Ak(h, c, e, i, s); + let d = t.nextZ; + for (;d && d.z <= _; ) { + if (d !== t.prev && d !== t.next && vk(n.x, n.y, r.x, r.y, o.x, o.y, d.x, d.y) && Ck(d.prev, d, d.next) >= 0) return !1; + d = d.nextZ; + } + d = t.prevZ; + for (;d && d.z >= u; ) { + if (d !== t.prev && d !== t.next && vk(n.x, n.y, r.x, r.y, o.x, o.y, d.x, d.y) && Ck(d.prev, d, d.next) >= 0) return !1; + d = d.prevZ; + } + return !0; + } + function gk(t, e, i) { + let s = t; + do { + const n = s.prev; + const r = s.next.next; + if (!xk(n, r) && wk(n, s, s.next, r) && Rk(n, r) && Rk(r, n)) { + e.push(n.i / i); + e.push(s.i / i); + e.push(r.i / i); + Bk(s); + Bk(s.next); + s = t = r; + } + s = s.next; + } while (s !== t); + return s; + } + function yk(t, e, i, s, n, r) { + let o = t; + do { + let t = o.next.next; + for (;t !== o.prev; ) { + if (o.i !== t.i && Ek(o, t)) { + let a = Ik(o, t); + o = dk(o, o.next); + a = dk(a, a.next); + pk(o, e, i, s, n, r); + pk(a, e, i, s, n, r); + return; + } + t = t.next; + } + o = o.next; + } while (o !== t); + } + function bk(t, e) { + return t.x - e.x; + } + function Sk(t, e) { + e = function(t, e) { + let i = e; + const s = t.x; + const n = t.y; + let r = -1 / 0; + let o = null; + do { + if (n <= i.y && n >= i.next.y) { + const t = i.x + (n - i.y) * (i.next.x - i.x) / (i.next.y - i.y); + if (t <= s && t > r) { + r = t; + if (t === s) { + if (n === i.y) return i; + if (n === i.next.y) return i.next; + } + o = i.x < i.next.x ? i : i.next; + } + } + i = i.next; + } while (i !== e); + if (!o) return null; + if (s === r) return o.prev; + const a = o; + const l = o.x; + const h = o.y; + let c = 1 / 0; + let u; + i = o.next; + for (;i !== a; ) { + if (s >= i.x && i.x >= l && vk(n < h ? s : r, n, l, h, n < h ? r : s, n, i.x, i.y)) { + u = Math.abs(n - i.y) / (s - i.x); + if ((u < c || u === c && i.x > o.x) && Rk(i, t)) { + o = i; + c = u; + } + } + i = i.next; + } + return o; + }(t, e); + if (e) { + const i = Ik(e, t); + dk(i, i.next); + } + } + function Ak(t, e, i, s, n) { + return (t = 1431655765 & ((t = 858993459 & ((t = 252645135 & ((t = 16711935 & ((t = 32767 * (t - i) / n) | t << 8)) | t << 4)) | t << 2)) | t << 1)) | (e = 1431655765 & ((e = 858993459 & ((e = 252645135 & ((e = 16711935 & ((e = 32767 * (e - s) / n) | e << 8)) | e << 4)) | e << 2)) | e << 1)) << 1; + } + function Tk(t) { + let e = t; + let i = t; + do { + e.x < i.x && (i = e); + e = e.next; + } while (e !== t); + return i; + } + function vk(t, e, i, s, n, r, o, a) { + return (n - o) * (e - a) - (t - o) * (r - a) >= 0 && (t - o) * (s - a) - (i - o) * (e - a) >= 0 && (i - o) * (r - a) - (n - o) * (s - a) >= 0; + } + function Ek(t, e) { + return t.next.i !== e.i && t.prev.i !== e.i && !function(t, e) { + let i = t; + do { + if (i.i !== t.i && i.next.i !== t.i && i.i !== e.i && i.next.i !== e.i && wk(i, i.next, t, e)) return !0; + i = i.next; + } while (i !== t); + return !1; + }(t, e) && Rk(t, e) && Rk(e, t) && function(t, e) { + let i = t; + let s = !1; + const n = (t.x + e.x) / 2; + const r = (t.y + e.y) / 2; + do { + i.y > r != i.next.y > r && n < (i.next.x - i.x) * (r - i.y) / (i.next.y - i.y) + i.x && (s = !s); + i = i.next; + } while (i !== t); + return s; + }(t, e); + } + function Ck(t, e, i) { + return (e.y - t.y) * (i.x - e.x) - (e.x - t.x) * (i.y - e.y); + } + function xk(t, e) { + return t.x === e.x && t.y === e.y; + } + function wk(t, e, i, s) { + return !!(xk(t, e) && xk(i, s) || xk(t, s) && xk(i, e)) || Ck(t, e, i) > 0 != Ck(t, e, s) > 0 && Ck(i, s, t) > 0 != Ck(i, s, e) > 0; + } + function Rk(t, e) { + return Ck(t.prev, t, t.next) < 0 ? Ck(t, e, t.next) >= 0 && Ck(t, t.prev, e) >= 0 : Ck(t, e, t.prev) < 0 || Ck(t, t.next, e) < 0; + } + function Ik(t, e) { + const i = new uk(t.i, t.x, t.y); + const s = new uk(e.i, e.x, e.y); + const n = t.next; + const r = e.prev; + t.next = e; + e.prev = t; + i.next = n; + n.prev = i; + s.next = i; + i.prev = s; + r.next = s; + s.prev = r; + return s; + } + function Mk(t, e, i, s) { + const n = new uk(t, e, i); + if (s) { + n.next = s.next; + n.prev = s; + s.next.prev = n; + s.next = n; + } else { + n.prev = n; + n.next = n; + } + return n; + } + function Bk(t) { + t.next.prev = t.prev; + t.prev.next = t.next; + t.prevZ && (t.prevZ.nextZ = t.nextZ); + t.nextZ && (t.nextZ.prevZ = t.prevZ); + } + function Dk(t, e, i) { + i = i || 3; + const s = e ? e.length : 0; + const n = s ? e[0] * i : t.length; + let r = _k(t, 0, n, i, !0); + const o = []; + if (!r) return o; + let a = 0; + let l = 0; + let h = 0; + let c = 0; + let u = 0; + let _ = 0; + let d = 0; + s && (r = function(t, e, i, s) { + const n = []; + let r = 0; + let o = 0; + let a = 0; + let l = 0; + let h = null; + for (r = 0, o = e.length; r < o; r++) { + a = e[r] * s; + l = r < o - 1 ? e[r + 1] * s : t.length; + h = _k(t, a, l, s, !1); + if (h) { + h === h.next && (h.steiner = !0); + n.push(Tk(h)); + } + } + n.sort(bk); + if (!i) return i; + for (r = 0; r < n.length; r++) { + Sk(n[r], i); + i = dk(i, i.next); + } + return i; + }(t, e, r, i)); + if (t.length > 80 * i) { + a = h = t[0]; + l = c = t[1]; + for (let e = i; e < n; e += i) { + u = t[e]; + _ = t[e + 1]; + u < a && (a = u); + _ < l && (l = _); + u > h && (h = u); + _ > c && (c = _); + } + d = Math.max(h - a, c - l); + } + pk(r, o, i, a, l, d); + return o; + } + const Pk = Math.PI; + const Ok = Math.min; + const Nk = Math.max; + const Lk = Math.ceil; + const Fk = Math.acos; + const Vk = Math.cos; + const kk = Math.sin; + const Uk = Math.atan2; + let Gk = null; + let zk = null; + const Hk = new Bi; + const jk = []; + for (let t = 0; t < 4; t++) jk.push(new Pi); + function Xk(t, e, i) { + return t < e ? e : t > i ? i : t; + } + const Wk = { + useModel: !0, + updateRenderData(t) { + t.renderData && (t.renderData.material = t.getMaterialInstance(0)); + }, + fillBuffers(t, e) {}, + renderIA(t, e) {}, + getRenderData(t, e) { + if (!zk) return null; + const i = zk.getRenderDataList(); + let s = i[zk.dataOffset]; + if (!s) return null; + let n = s; + const r = n ? n.vertexStart + e : 0; + if (r > 65535 || 3 * r > 131070) { + ++zk.dataOffset; + if (zk.dataOffset < i.length) s = i[zk.dataOffset]; else { + s = zk.requestRenderData(); + i[zk.dataOffset] = s; + } + n = s; + } + n && n.vertexCount < r && n.request(e, 3 * e); + return s; + }, + stroke(t) { + Bi.copy(Hk, t.strokeColor); + if (t.impl) { + this._flattenPaths(t.impl); + this._expandStroke(t); + t.impl.updatePathOffset = !0; + this.end(t); + } + }, + fill(t) { + Bi.copy(Hk, t.fillColor); + this._expandFill(t); + t.impl && (t.impl.updatePathOffset = !0); + this.end(t); + }, + end(t) { + t.markForUpdateRenderData(); + }, + _expandStroke(t) { + const e = .5 * t.lineWidth; + const i = t.lineCap; + const s = t.lineJoin; + const n = t.miterLimit; + zk = t.impl; + if (!zk) return; + const r = function(t, e, i) { + const s = 2 * Fk(t / (t + i)); + return Nk(2, Lk(e / s)); + }(e, Pk, zk.tessTol); + this._calculateJoins(zk, e, s, n); + const o = zk.paths; + let a = 0; + for (let t = zk.pathOffset, e = zk.pathLength; t < e; t++) { + const e = o[t]; + const n = e.points.length; + s === xO.ROUND ? a += 2 * (n + e.bevel * (r + 2) + 1) : a += 2 * (n + 5 * e.bevel + 1); + e.closed || (i === CO.ROUND ? a += 2 * (2 * r + 2) : a += 12); + } + const l = Gk = this.getRenderData(t, a); + if (!l) return; + const h = l.vData; + const c = l.iData; + for (let t = zk.pathOffset, n = zk.pathLength; t < n; t++) { + const n = o[t]; + const a = n.points; + const u = a.length; + const _ = l.vertexStart; + let d; + let p; + let m = 0; + let f = 0; + const g = n.closed; + if (g) { + d = a[u - 1]; + p = a[0]; + m = 0; + f = u; + } else { + d = a[0]; + p = a[1]; + m = 1; + f = u - 1; + } + p = p || d; + if (!g) { + const t = new VO(p.x, p.y); + t.subtract(d); + t.normalize(); + const s = t.x; + const n = t.y; + i === CO.BUTT ? this._buttCapStart(d, s, n, e, 0) : i === CO.SQUARE ? this._buttCapStart(d, s, n, e, e) : i === CO.ROUND && this._roundCapStart(d, s, n, e, r); + } + for (let t = m; t < f; ++t) { + if (s === xO.ROUND) this._roundJoin(d, p, e, e, r); else if (0 != (p.flags & (wO.PT_BEVEL | wO.PT_INNERBEVEL))) this._bevelJoin(d, p, e, e); else { + this._vSet(p.x + p.dmx * e, p.y + p.dmy * e, 1); + this._vSet(p.x - p.dmx * e, p.y - p.dmy * e, -1); + } + d = p; + p = a[t + 1]; + } + if (g) { + const t = 8 * _; + this._vSet(h[t], h[t + 1], 1); + this._vSet(h[t + 8], h[t + 8 + 1], -1); + } else { + const t = new VO(p.x, p.y); + t.subtract(d); + t.normalize(); + const s = t.x; + const n = t.y; + i === CO.BUTT ? this._buttCapEnd(p, s, n, e, 0) : i === CO.SQUARE ? this._buttCapEnd(p, s, n, e, e) : i === CO.ROUND && this._roundCapEnd(p, s, n, e, r); + } + let y = l.indexStart; + for (let t = _ + 2, e = l.vertexStart; t < e; t++) { + c[y++] = t - 2; + c[y++] = t - 1; + c[y++] = t; + } + l.indexStart = y; + } + Gk = null; + zk = null; + }, + _expandFill(t) { + zk = t.impl; + if (!zk) return; + const e = zk.paths; + let i = 0; + for (let t = zk.pathOffset, s = zk.pathLength; t < s; t++) { + i += e[t].points.length; + } + const s = Gk = this.getRenderData(t, i); + if (!s) return; + const n = s; + const r = n.vData; + const o = n.iData; + for (let t = zk.pathOffset, i = zk.pathLength; t < i; t++) { + const i = e[t]; + const a = i.points; + const l = a.length; + if (0 === l) continue; + const h = s.vertexStart; + for (let t = 0; t < l; ++t) this._vSet(a[t].x, a[t].y); + let c = s.indexStart; + if (i.complex) { + const t = []; + for (let e = h, i = s.vertexStart; e < i; e++) { + let i = 8 * e; + t.push(r[i++]); + t.push(r[i++]); + t.push(r[i++]); + } + const e = Dk(t, null, 3); + if (!e || 0 === e.length) continue; + for (let t = 0, i = e.length; t < i; t++) o[c++] = e[t] + h; + } else { + const t = h; + for (let e = h + 2, i = n.vertexStart; e < i; e++) { + o[c++] = t; + o[c++] = e - 1; + o[c++] = e; + } + } + n.indexStart = c; + } + Gk = null; + zk = null; + }, + _calculateJoins(t, e, i, s) { + let n = 0; + e > 0 && (n = 1 / e); + const r = t.paths; + for (let e = t.pathOffset, o = t.pathLength; e < o; e++) { + const t = r[e]; + const o = t.points; + const a = o.length; + let l = o[a - 1]; + let h = o[0]; + t.bevel = 0; + for (let e = 0; e < a; e++) { + let r = 0; + let a = 0; + let c = 0; + const u = l.dy; + const _ = -l.dx; + const d = h.dy; + const p = -h.dx; + h.dmx = .5 * (u + d); + h.dmy = .5 * (_ + p); + r = h.dmx * h.dmx + h.dmy * h.dmy; + if (r > 1e-6) { + let t = 1 / r; + t > 600 && (t = 600); + h.dmx *= t; + h.dmy *= t; + } + a = h.dx * l.dy - l.dx * h.dy; + a > 0 && (h.flags |= wO.PT_LEFT); + c = Nk(11, Ok(l.len, h.len) * n); + r * c * c < 1 && (h.flags |= wO.PT_INNERBEVEL); + h.flags & wO.PT_CORNER && (r * s * s < 1 || i === xO.BEVEL || i === xO.ROUND) && (h.flags |= wO.PT_BEVEL); + 0 != (h.flags & (wO.PT_BEVEL | wO.PT_INNERBEVEL)) && t.bevel++; + l = h; + h = o[e + 1]; + } + } + }, + _flattenPaths(t) { + const e = t.paths; + for (let i = t.pathOffset, s = t.pathLength; i < s; i++) { + const t = e[i]; + const s = t.points; + let n = s[s.length - 1]; + let r = s[0]; + if (s.length > 2 && n.equals(r)) { + t.closed = !0; + s.pop(); + n = s[s.length - 1]; + } + for (let t = 0, e = s.length; t < e; t++) { + const e = new VO(r.x, r.y); + e.subtract(n); + n.len = e.length(); + (e.x || e.y) && e.normalize(); + n.dx = e.x; + n.dy = e.y; + n = r; + r = s[t + 1]; + } + } + }, + _chooseBevel(t, e, i, s) { + const n = i.x; + const r = i.y; + let o = 0; + let a = 0; + let l = 0; + let h = 0; + if (0 !== t) { + o = n + e.dy * s; + a = r - e.dx * s; + l = n + i.dy * s; + h = r - i.dx * s; + } else { + o = l = n + i.dmx * s; + a = h = r + i.dmy * s; + } + return [ o, a, l, h ]; + }, + _buttCapStart(t, e, i, s, n) { + const r = t.x - e * n; + const o = t.y - i * n; + const a = i; + const l = -e; + this._vSet(r + a * s, o + l * s, 1); + this._vSet(r - a * s, o - l * s, -1); + }, + _buttCapEnd(t, e, i, s, n) { + const r = t.x + e * n; + const o = t.y + i * n; + const a = i; + const l = -e; + this._vSet(r + a * s, o + l * s, 1); + this._vSet(r - a * s, o - l * s, -1); + }, + _roundCapStart(t, e, i, s, n) { + const r = t.x; + const o = t.y; + const a = i; + const l = -e; + for (let t = 0; t < n; t++) { + const h = t / (n - 1) * Pk; + const c = Vk(h) * s; + const u = kk(h) * s; + this._vSet(r - a * c - e * u, o - l * c - i * u, 1); + this._vSet(r, o, 0); + } + this._vSet(r + a * s, o + l * s, 1); + this._vSet(r - a * s, o - l * s, -1); + }, + _roundCapEnd(t, e, i, s, n) { + const r = t.x; + const o = t.y; + const a = i; + const l = -e; + this._vSet(r + a * s, o + l * s, 1); + this._vSet(r - a * s, o - l * s, -1); + for (let t = 0; t < n; t++) { + const h = t / (n - 1) * Pk; + const c = Vk(h) * s; + const u = kk(h) * s; + this._vSet(r, o, 0); + this._vSet(r - a * c + e * u, o - l * c + i * u, 1); + } + }, + _roundJoin(t, e, i, s, n) { + const r = t.dy; + const o = -t.dx; + const a = e.dy; + const l = -e.dx; + const h = e.x; + const c = e.y; + if (0 != (e.flags & wO.PT_LEFT)) { + const u = this._chooseBevel(e.flags & wO.PT_INNERBEVEL, t, e, i); + const _ = u[0]; + const d = u[1]; + const p = u[2]; + const m = u[3]; + const f = Uk(-o, -r); + let g = Uk(-l, -a); + g > f && (g -= 2 * Pk); + this._vSet(_, d, 1); + this._vSet(h - r * s, e.y - o * s, -1); + const y = Xk(Lk((f - g) / Pk) * n, 2, n); + for (let t = 0; t < y; t++) { + const e = f + t / (y - 1) * (g - f); + const i = h + Vk(e) * s; + const n = c + kk(e) * s; + this._vSet(h, c, 0); + this._vSet(i, n, -1); + } + this._vSet(p, m, 1); + this._vSet(h - a * s, c - l * s, -1); + } else { + const u = this._chooseBevel(e.flags & wO.PT_INNERBEVEL, t, e, -s); + const _ = u[0]; + const d = u[1]; + const p = u[2]; + const m = u[3]; + const f = Uk(o, r); + let g = Uk(l, a); + g < f && (g += 2 * Pk); + this._vSet(h + r * s, c + o * s, 1); + this._vSet(_, d, -1); + const y = Xk(Lk((g - f) / Pk) * n, 2, n); + for (let t = 0; t < y; t++) { + const e = f + t / (y - 1) * (g - f); + const s = h + Vk(e) * i; + const n = c + kk(e) * i; + this._vSet(s, n, 1); + this._vSet(h, c, 0); + } + this._vSet(h + a * s, c + l * s, 1); + this._vSet(p, m, -1); + } + }, + _bevelJoin(t, e, i, s) { + let n = 0; + let r = 0; + let o = 0; + let a = 0; + let l = 0; + let h = 0; + let c = 0; + let u = 0; + const _ = t.dy; + const d = -t.dx; + const p = e.dy; + const m = -e.dx; + if (e.flags & wO.PT_LEFT) { + const n = this._chooseBevel(e.flags & wO.PT_INNERBEVEL, t, e, i); + l = n[0]; + h = n[1]; + c = n[2]; + u = n[3]; + this._vSet(l, h, 1); + this._vSet(e.x - _ * s, e.y - d * s, -1); + this._vSet(c, u, 1); + this._vSet(e.x - p * s, e.y - m * s, -1); + } else { + const l = this._chooseBevel(e.flags & wO.PT_INNERBEVEL, t, e, -s); + n = l[0]; + r = l[1]; + o = l[2]; + a = l[3]; + this._vSet(e.x + _ * i, e.y + d * i, 1); + this._vSet(n, r, -1); + this._vSet(e.x + p * i, e.y + m * i, 1); + this._vSet(o, a, -1); + } + }, + _vSet(t, e, i = 0) { + if (!Gk) return; + const s = Gk; + let n = 8 * s.vertexStart; + const r = s.vData; + r[n++] = t; + r[n++] = e; + r[n++] = 0; + Bi.toArray(r, Hk, n); + n += 4; + r[n++] = i; + s.vertexStart++; + } + }; + const Yk = t("graphicsAssembler", { + getAssembler: t => Wk + }); + dN.Assembler = Yk; + class qk { + constructor() { + this.char = ""; + this.valid = !0; + this.x = 0; + this.y = 0; + this.line = 0; + this.hash = ""; + } + } + const Kk = new as; + const Jk = new VM(64, 64); + const Zk = new cM(null); + let Qk = null; + let $k = null; + const tU = []; + const eU = []; + const iU = []; + const sU = []; + const nU = new rs; + const rU = new rs; + const oU = new Qi; + let aU = null; + let lU = 0; + let hU = 0; + let cU = 0; + let uU = 0; + let _U = 0; + let dU = 1; + let pU = null; + let mU = ""; + let fU = 0; + let gU = 0; + let yU = 0; + let bU = 0; + let SU = 0; + let AU = 0; + let TU = 0; + let vU = !1; + let EU = 0; + let CU = 0; + let xU = 0; + let wU; + const RU = { + updateRenderData(t) { + if (t.renderData && Qk !== t) { + if (t.renderData.vertDirty) { + Qk = t; + $k = Qk.node._uiProps.uiTransformComp; + this._updateFontFamily(t); + this._updateProperties(t); + this._updateLabelInfo(t); + this._updateContent(); + Qk.actualFontSize = fU; + $k.setContentSize(rU); + this.updateUVs(t); + this.updateColor(t); + Qk.renderData.vertDirty = !1; + Qk = null; + this._resetProperties(); + } + if (t.spriteFrame) { + t.renderData.updateRenderData(t, t.spriteFrame); + } + } + }, + updateUVs(t) { + const e = t.renderData; + const i = e.chunk.vb; + const s = e.vertexCount; + const n = e.data; + let r = 3; + for (let t = 0; t < s; t++) { + const e = n[t]; + i[r] = e.u; + i[r + 1] = e.v; + r += 9; + } + }, + updateColor(t) { + { + const e = t.renderData; + const i = e.vertexCount; + if (0 === i) return; + const s = e.chunk.vb; + const n = e.floatStride; + let r = 5; + const o = t.color; + const a = o.r / 255; + const l = o.g / 255; + const h = o.b / 255; + const c = o.a / 255; + for (let t = 0; t < i; t++) { + s[r] = a; + s[r + 1] = l; + s[r + 2] = h; + s[r + 3] = c; + r += n; + } + } + }, + _updateFontScale() { + dU = fU / gU; + }, + _updateFontFamily(t) { + const e = t.font; + pU = e.spriteFrame; + aU = e.fntConfig; + kM.fontAtlas = e.fontDefDictionary; + kM.fontAtlas || (t.cacheMode === RP.CHAR ? kM.fontAtlas = Jk : kM.fontAtlas = Zk); + EI.packToDynamicAtlas(t, pU); + }, + _updateLabelInfo(t) { + kM.hash = ""; + kM.margin = 0; + }, + _updateProperties(t) { + mU = t.string.toString(); + fU = t.fontSize; + gU = aU ? aU.fontSize : t.fontSize; + yU = t.horizontalAlign; + bU = t.verticalAlign; + SU = t.spacingX; + TU = t.overflow; + AU = t._lineHeight; + const e = $k.contentSize; + rU.width = e.width; + rU.height = e.height; + if (TU === wP.NONE) { + vU = !1; + rU.width += 2 * kM.margin; + rU.height += 2 * kM.margin; + } else if (TU === wP.RESIZE_HEIGHT) { + vU = !0; + rU.height += 2 * kM.margin; + } else vU = t.enableWrapText; + kM.lineHeight = AU; + kM.fontSize = fU; + this._setupBMFontOverflowMetrics(); + }, + _resetProperties() { + aU = null; + pU = null; + kM.hash = ""; + kM.margin = 0; + }, + _updateContent() { + this._updateFontScale(); + this._computeHorizontalKerningForText(); + this._alignText(); + }, + _computeHorizontalKerningForText() { + const t = mU; + const e = t.length; + const i = aU.kerningDict; + const s = tU; + if (!i) return; + let n = -1; + for (let r = 0; r < e; ++r) { + const o = t.charCodeAt(r); + const a = i[n << 16 | 65535 & o] || 0; + s[r] = r < e - 1 ? a : 0; + n = o; + } + }, + _multilineTextWrap(t) { + const e = mU.length; + let i = 0; + let s = 0; + let n = 0; + let r = 0; + let o = 0; + let a = 0; + let l = 0; + let h = null; + for (let c = 0; c < e; ) { + let u = mU.charAt(c); + if ("\n" === u) { + iU.push(o); + o = 0; + i++; + s = 0; + n -= AU * this._getFontScale() + 0; + this._recordPlaceholderInfo(c, u); + c++; + continue; + } + const _ = t(mU, c, e); + let d = a; + let p = l; + let m = o; + let f = s; + let g = !1; + for (let t = 0; t < _; ++t) { + const r = c + t; + u = mU.charAt(r); + if ("\r" === u) { + this._recordPlaceholderInfo(r, u); + continue; + } + h = kM.fontAtlas.getLetterDefinitionForChar(u, kM); + if (!h) { + this._recordPlaceholderInfo(r, u); + console.log(`Can't find letter definition in texture atlas ${aU.atlasName} for letter:${u}`); + continue; + } + const a = f + h.offsetX * dU - kM.margin; + if (vU && xU > 0 && s > 0 && a + h.w * dU > xU && !CM(u)) { + iU.push(o); + o = 0; + i++; + s = 0; + n -= AU * this._getFontScale() + 0; + g = !0; + break; + } + oU.x = a; + oU.y = n - h.offsetY * dU; + this._recordLetterInfo(oU, u, r, i); + r + 1 < tU.length && r < e - 1 && (f += tU[r + 1]); + f += h.xAdvance * dU + SU; + m = oU.x + h.w * dU; + d < oU.y && (d = oU.y); + p > oU.y - h.h * dU && (p = oU.y - h.h * dU); + } + if (!g) { + s = f; + o = m; + a < d && (a = d); + l > p && (l = p); + r < o && (r = o); + c += _; + } + } + iU.push(o); + lU = i + 1; + hU = lU * AU * this._getFontScale(); + lU > 1 && (hU += 0 * (lU - 1)); + rU.width = EU; + rU.height = CU; + EU <= 0 && (rU.width = parseFloat(r.toFixed(2)) + 2 * kM.margin); + CU <= 0 && (rU.height = parseFloat(hU.toFixed(2)) + 2 * kM.margin); + uU = rU.height; + _U = 0; + a > 0 && (uU = rU.height + a); + l < -hU && (_U = hU + l); + return !0; + }, + _getFirstCharLen: () => 1, + _getFontScale: () => TU === wP.SHRINK ? dU : 1, + _getFirstWordLen(t, e, i) { + let s = t.charAt(e); + if (EM(s) || "\n" === s || CM(s)) return 1; + let n = 1; + let r = kM.fontAtlas.getLetterDefinitionForChar(s, kM); + if (!r) return n; + let o = r.xAdvance * dU + SU; + let a = 0; + for (let l = e + 1; l < i; ++l) { + s = t.charAt(l); + r = kM.fontAtlas.getLetterDefinitionForChar(s, kM); + if (!r) break; + a = o + r.offsetX * dU; + if (a + r.w * dU > xU && !CM(s) && xU > 0) return n; + o += r.xAdvance * dU + SU; + if ("\n" === s || CM(s) || EM(s)) break; + n++; + } + return n; + }, + _multilineTextWrapByWord() { + return this._multilineTextWrap(this._getFirstWordLen); + }, + _multilineTextWrapByChar() { + return this._multilineTextWrap(this._getFirstCharLen); + }, + _recordPlaceholderInfo(t, e) { + if (t >= eU.length) { + const t = new qk; + eU.push(t); + } + eU[t].char = e; + eU[t].hash = `${e.charCodeAt(0)}${kM.hash}`; + eU[t].valid = !1; + }, + _recordLetterInfo(t, e, i, s) { + if (i >= eU.length) { + const t = new qk; + eU.push(t); + } + const n = `${e.charCodeAt(0)}${kM.hash}`; + eU[i].line = s; + eU[i].char = e; + eU[i].hash = n; + eU[i].valid = kM.fontAtlas.getLetter(n).valid; + eU[i].x = t.x; + eU[i].y = t.y; + }, + _alignText() { + hU = 0; + iU.length = 0; + this._multilineTextWrapByWord(); + this._computeAlignmentOffset(); + TU === wP.SHRINK && fU > 0 && this._isVerticalClamp() && this._shrinkLabelToContentSize(this._isVerticalClamp); + this._updateQuads() || TU === wP.SHRINK && this._shrinkLabelToContentSize(this._isHorizontalClamp); + }, + _scaleFontSizeDown(t) { + let e = !0; + if (!t) { + t = .1; + e = !1; + } + fU = t; + e && this._updateContent(); + }, + _shrinkLabelToContentSize(t) { + let e = 0; + let i = 0 | fU; + let s = 0; + for (;e < i; ) { + s = e + i + 1 >> 1; + const n = s; + if (n <= 0) break; + dU = n / gU; + this._multilineTextWrapByWord(); + this._computeAlignmentOffset(); + t() ? i = s - 1 : e = s; + } + e >= 0 && this._scaleFontSizeDown(e); + }, + _isVerticalClamp: () => hU > rU.height, + _isHorizontalClamp() { + let t = !1; + for (let e = 0, i = mU.length; e < i; ++e) { + const i = eU[e]; + if (i.valid) { + const e = kM.fontAtlas.getLetterDefinitionForChar(i.char, kM); + if (!e) continue; + const s = i.x + e.w * dU; + const n = i.line; + if (EU > 0) if (vU) { + if (iU[n] > rU.width && (s > rU.width || s < 0)) { + t = !0; + break; + } + } else if (s > rU.width) { + t = !0; + break; + } + } + } + return t; + }, + _isHorizontalClamped(t, e) { + const i = iU[e]; + const s = t > rU.width || t < 0; + return vU ? i > rU.width && s : s; + }, + _updateQuads() { + if (!Qk) return !1; + const t = pU ? pU.texture : kM.fontAtlas.getTexture(); + const e = Qk.renderData; + e.dataLength = 0; + e.resize(0, 0); + const i = $k.anchorPoint; + const s = rU; + const n = i.x * s.width; + const r = i.y * s.height; + let o = !0; + for (let e = 0, i = mU.length; e < i; ++e) { + const i = eU[e]; + if (!i.valid) continue; + const s = kM.fontAtlas.getLetter(i.hash); + if (!s) { + console.warn("Can't find letter in this bitmap-font"); + continue; + } + Kk.height = s.h; + Kk.width = s.w; + Kk.x = s.u; + Kk.y = s.v; + let a = i.y + cU; + if (CU > 0) { + if (a > uU) { + const t = a - uU; + Kk.y += t; + Kk.height -= t; + a -= t; + } + a - Kk.height * dU < _U && TU === wP.CLAMP && (Kk.height = a < _U ? 0 : (a - _U) / dU); + } + const l = i.line; + const h = i.x + s.w / 2 * dU + sU[l]; + if (EU > 0 && this._isHorizontalClamped(h, l)) if (TU === wP.CLAMP) Kk.width = 0; else if (TU === wP.SHRINK) { + if (rU.width > s.w) { + o = !1; + break; + } + Kk.width = 0; + } + if (Kk.height > 0 && Kk.width > 0) { + const e = this._determineRect(); + const s = i.x + sU[i.line]; + this.appendQuad(Qk, t, Kk, e, s - n, a - r, dU); + } + } + const a = e.indexCount; + this.createQuadIndices(a); + e.chunk.setIndexBuffer(wU); + return o; + }, + createQuadIndices(t) { + if (t % 6 != 0) { + console.error("illegal index count!"); + return; + } + const e = t / 6; + wU = null; + wU = new Uint16Array(t); + let i = 0; + for (let t = 0; t < e; t++) { + wU[i++] = 0 + 4 * t; + wU[i++] = 1 + 4 * t; + wU[i++] = 2 + 4 * t; + wU[i++] = 1 + 4 * t; + wU[i++] = 3 + 4 * t; + wU[i++] = 2 + 4 * t; + } + }, + appendQuad(t, e, i, s, n, r, o) {}, + _determineRect() { + const t = pU.isRotated(); + const e = pU.getOriginalSize(); + const i = pU.getRect(); + const s = pU.getOffset(); + const n = s.x + (e.width - i.width) / 2; + const r = s.y - (e.height - i.height) / 2; + if (t) { + const t = Kk.x; + Kk.x = i.x + i.height - Kk.y - Kk.height - r; + Kk.y = t + i.y - n; + Kk.y < 0 && (Kk.height += r); + } else { + Kk.x += i.x - n; + Kk.y += i.y + r; + } + return t; + }, + _computeAlignmentOffset() { + sU.length = 0; + switch (yU) { + case CP.LEFT: + for (let t = 0; t < lU; ++t) sU.push(0); + break; + + case CP.CENTER: + for (let t = 0, e = iU.length; t < e; t++) sU.push((rU.width - iU[t]) / 2); + break; + + case CP.RIGHT: + for (let t = 0, e = iU.length; t < e; t++) sU.push(rU.width - iU[t]); + } + cU = rU.height; + if (bU !== xP.TOP) { + const t = rU.height - hU + AU * this._getFontScale() - gU * dU; + bU === xP.BOTTOM ? cU -= t : cU -= t / 2; + } + }, + _setupBMFontOverflowMetrics() { + let t = rU.width; + let e = rU.height; + TU === wP.RESIZE_HEIGHT && (e = 0); + if (TU === wP.NONE) { + t = 0; + e = 0; + } + EU = t; + CU = e; + nU.width = t; + nU.height = e; + xU = t; + } + }; + const IU = new Bi(255, 255, 255, 255); + const MU = { + createData: t => t.requestRenderData(), + fillBuffers(t, e) { + const i = t.node; + IU.set(t.color); + IU.a = 255 * i._uiProps.opacity; + bI(i, 0, t.renderData, IU); + }, + appendQuad(t, e, i, s, n, r, o) { + const a = t.renderData; + if (!a) return; + const l = a.dataLength; + a.dataLength += 4; + a.resize(a.dataLength, a.dataLength / 2 * 3); + const h = a.data; + const c = e.width; + const u = e.height; + const _ = i.width; + const d = i.height; + let p = 0; + let m = 0; + let f = 0; + let g = 0; + if (s) { + p = i.x / c; + g = (i.x + d) / c; + m = (i.y + _) / u; + f = i.y / u; + h[l].u = p; + h[l].v = f; + h[l + 1].u = p; + h[l + 1].v = m; + h[l + 2].u = g; + h[l + 2].v = f; + h[l + 3].u = g; + h[l + 3].v = m; + } else { + p = i.x / c; + g = (i.x + _) / c; + m = (i.y + d) / u; + f = i.y / u; + h[l].u = p; + h[l].v = m; + h[l + 1].u = g; + h[l + 1].v = m; + h[l + 2].u = p; + h[l + 2].v = f; + h[l + 3].u = g; + h[l + 3].v = f; + } + h[l].x = n; + h[l].y = r - d * o; + h[l + 1].x = n + _ * o; + h[l + 1].y = r - d * o; + h[l + 2].x = n; + h[l + 2].y = r; + h[l + 3].x = n + _ * o; + h[l + 3].y = r; + } + }; + Ot(MU, RU); + let BU = null; + const DU = Nt(RU, { + getAssemblerData() { + BU || (BU = new VM(1024, 1024)); + return BU.getTexture(); + }, + _updateFontFamily(t) { + kM.fontAtlas = BU; + kM.fontFamily = this._getFontFamily(t); + const e = t.getComponent(ZL); + if (e && e.enabled) { + kM.isOutlined = !0; + kM.margin = e.width; + kM.out = e.color.clone(); + kM.out.a = e.color.a * t.color.a / 255; + } else { + kM.isOutlined = !1; + kM.margin = 0; + } + }, + _getFontFamily(t) { + let e = "Arial"; + t.useSystemFont ? e = t.fontFamily || "Arial" : t.font && (e = t.font._nativeAsset || "Arial"); + return e; + }, + _updateLabelInfo(t) { + kM.fontDesc = this._getFontDesc(); + kM.color = t.color; + kM.hash = function(t) { + const e = t.color.toHEX(); + let i = ""; + t.isOutlined && t.margin > 0 && (i = i + t.margin + t.out.toHEX()); + return "" + t.fontSize + t.fontFamily + e + i; + }(kM); + }, + _getFontDesc() { + let t = `${kM.fontSize.toString()}px `; + t += kM.fontFamily; + return t; + }, + _computeHorizontalKerningForText() {}, + _determineRect: t => !1 + }); + const PU = new Bi(255, 255, 255, 255); + const OU = { + createData: t => t.requestRenderData(), + fillBuffers(t, e) { + if (!t.renderData) return; + const i = t.node; + PU.a = 255 * i._uiProps.opacity; + bI(i, 0, t.renderData, PU); + }, + appendQuad: MU.appendQuad + }; + Ot(OU, DU); + const NU = IP.Overflow; + const LU = (1 / 255).toFixed(3); + let FU = null; + let VU = null; + let kU = null; + let UU = ""; + let GU = ""; + let zU = 0; + let HU = 0; + let jU = []; + const XU = new rs; + let WU = 0; + let YU = 0; + let qU = 0; + let KU = new Bi; + let JU = 1; + let ZU = ""; + let QU = NU.NONE; + let $U = !1; + let tG = null; + const eG = Bi.BLACK.clone(); + let iG = null; + const sG = Bi.BLACK.clone(); + const nG = new as; + const rG = rs.ZERO.clone(); + const oG = rs.ZERO.clone(); + const aG = Qi.ZERO.clone(); + const lG = Qi.ZERO.clone(); + let hG = 0; + let cG = 0; + let uG = !1; + let _G = !1; + let dG = !1; + const pG = [ "left", "center", "right" ]; + const mG = { + getAssemblerData: () => IP._canvasPool.get(), + resetAssemblerData(t) { + t && IP._canvasPool.put(t); + }, + updateRenderData(t) { + if (t.renderData) { + if (t.renderData.vertDirty) { + const e = t.node._uiProps.uiTransformComp; + this._updateFontFamily(t); + this._updateProperties(t, e); + this._calculateLabelFont(); + this._updateLabelDimensions(); + this._updateTexture(t); + this._calDynamicAtlas(t); + t.actualFontSize = zU; + e.setContentSize(XU); + this.updateVertexData(t); + this.updateUVs(t); + t.renderData.vertDirty = !1; + t.contentWidth = oG.width; + FU = null; + VU = null; + kU = null; + } + if (t.spriteFrame) { + t.renderData.updateRenderData(t, t.spriteFrame); + } + } + }, + updateVertexData(t) {}, + updateUVs(t) {}, + _updateFontFamily(t) { + ZU = t.useSystemFont ? t.fontFamily || "Arial" : t.font && t.font._nativeAsset || "Arial"; + }, + _updateProperties(t, e) { + const i = t.assemblerData; + if (i) { + FU = i.context; + VU = i.canvas; + kU = t.spriteFrame; + GU = t.string.toString(); + zU = t.fontSize; + HU = zU; + QU = t.overflow; + oG.width = XU.width = e.width; + oG.height = XU.height = e.height; + cG = t.underlineHeight; + WU = t.lineHeight; + YU = t.horizontalAlign; + qU = t.verticalAlign; + KU = t.color; + JU = t.node._uiProps.opacity; + uG = t.isBold; + _G = t.isItalic; + dG = t.isUnderline; + $U = QU !== NU.NONE && (QU === NU.RESIZE_HEIGHT || t.enableWrapText); + tG = ZL && t.getComponent(ZL); + tG = tG && tG.enabled && tG.width > 0 ? tG : null; + tG && eG.set(tG.color); + iG = tk && t.getComponent(tk); + iG = iG && iG.enabled ? iG : null; + iG && sG.set(iG.color); + this._updatePaddingRect(); + } + }, + _updatePaddingRect() { + let t = 0; + let e = 0; + let i = 0; + let s = 0; + let n = 0; + rG.width = rG.height = 0; + if (tG) { + n = tG.width; + t = e = i = s = n; + rG.width = rG.height = 2 * n; + } + if (iG) { + const r = iG.blur + n; + const o = iG.offset.x; + const a = iG.offset.y; + i = Math.max(i, -o + r); + s = Math.max(s, o + r); + t = Math.max(t, a + r); + e = Math.max(e, -a + r); + } + if (_G) { + const t = HU * Math.tan(.20943951); + s += t; + rG.width += t; + } + nG.x = i; + nG.y = t; + nG.width = i + s; + nG.height = t + e; + }, + _calculateFillTextStartPosition() { + let t = 0; + YU === CP.RIGHT ? t = XU.width - nG.width : YU === CP.CENTER && (t = (XU.width - nG.width) / 2); + const e = this._getLineHeight() * (jU.length - 1); + let i = zU * (1 - pM / 2); + if (qU !== xP.TOP) { + let t = e + nG.height + zU - XU.height; + if (qU === xP.BOTTOM) { + t += pM / 2 * zU; + i -= t; + } else i -= t / 2; + } + i += 0 * zU; + aG.set(t + nG.x, i + nG.y); + }, + _updateTexture(t) { + if (!FU || !VU) return; + FU.clearRect(0, 0, VU.width, VU.height); + FU.font = UU; + this._calculateFillTextStartPosition(); + const e = this._getLineHeight(); + FU.lineJoin = "round"; + if (tG) { + FU.fillStyle = `rgba(${eG.r}, ${eG.g}, ${eG.b}, ${LU})`; + FU.fillRect(0, 0, VU.width, VU.height); + } else if (t._srcBlendFactor === Ls.SRC_ALPHA) { + FU.fillStyle = `rgba(${KU.r}, ${KU.g}, ${KU.b}, ${LU})`; + FU.fillRect(0, 0, VU.width, VU.height); + } + FU.fillStyle = `rgb(${KU.r}, ${KU.g}, ${KU.b})`; + const i = aG.x; + let s = 0; + this._drawTextEffect(aG, e); + for (let t = 0; t < jU.length; ++t) { + s = aG.y + t * e; + tG && FU.strokeText(jU[t], i, s); + FU.fillText(jU[t], i, s); + } + iG && (FU.shadowColor = "transparent"); + this._uploadTexture(t); + }, + _uploadTexture(t) { + if (t.cacheMode === IP.CacheMode.BITMAP) { + const e = t.ttfSpriteFrame; + EI.deleteAtlasSpriteFrame(e); + e._resetDynamicAtlasFrame(); + } + if (kU && VU) { + let e; + e = kU instanceof GI ? kU.texture : kU; + if (0 !== VU.width && 0 !== VU.height) { + e.reset({ + width: VU.width, + height: VU.height, + mipmapLevel: 1 + }); + e.uploadData(VU); + e.setWrapMode(Zp.CLAMP_TO_EDGE, Zp.CLAMP_TO_EDGE); + if (kU instanceof GI) { + kU.rect = new as(0, 0, VU.width, VU.height); + kU._calculateUV(); + } + t.renderData && (t.renderData.textureDirty = !0); + m.director.root && m.director.root.batcher2D && m.director.root.batcher2D._releaseDescriptorSetCache(e.getGFXTexture(), e.getGFXSampler()); + } + } + }, + _calDynamicAtlas(t) { + if (t.cacheMode !== IP.CacheMode.BITMAP || !VU || VU.width <= 0 || VU.height <= 0) return; + const e = t.ttfSpriteFrame; + EI.packToDynamicAtlas(t, e); + }, + _setupOutline() { + FU.strokeStyle = `rgba(${eG.r}, ${eG.g}, ${eG.b}, ${eG.a / 255})`; + FU.lineWidth = 2 * tG.width; + }, + _setupShadow() { + FU.shadowColor = `rgba(${sG.r}, ${sG.g}, ${sG.b}, ${sG.a / 255})`; + FU.shadowBlur = iG.blur; + FU.shadowOffsetX = iG.offset.x; + FU.shadowOffsetY = -iG.offset.y; + }, + _drawTextEffect(t, e) { + if (!iG && !tG && !dG) return; + const i = jU.length > 1 && iG; + const s = this._measureText(FU, UU); + let n = 0; + let r = 0; + iG && this._setupShadow(); + tG && this._setupOutline(); + for (let o = 0; o < jU.length; ++o) { + n = t.x; + r = t.y + o * e; + if (i) { + tG && FU.strokeText(jU[o], n, r); + FU.fillText(jU[o], n, r); + } + if (dG) { + hG = s(jU[o]); + YU === CP.RIGHT ? lG.x = t.x - hG : YU === CP.CENTER ? lG.x = t.x - hG / 2 : lG.x = t.x; + lG.y = r + HU / 8; + FU.fillRect(lG.x, lG.y, hG, cG); + } + } + i && (FU.shadowColor = "transparent"); + }, + _updateLabelDimensions() { + XU.width = Math.min(XU.width, 2048); + XU.height = Math.min(XU.height, 2048); + let t = !1; + if (VU.width !== XU.width) { + VU.width = XU.width; + t = !0; + } + if (VU.height !== XU.height) { + VU.height = XU.height; + t = !0; + } + t && (FU.font = UU); + FU.textAlign = pG[YU]; + FU.textBaseline = "alphabetic"; + }, + _getFontDesc() { + let t = `${zU.toString()}px `; + t += ZU; + uG && (t = `bold ${t}`); + _G && (t = `italic ${t}`); + return t; + }, + _getLineHeight() { + let t = WU; + t = 0 === t ? zU : t * zU / HU; + return 0 | t; + }, + _calculateParagraphLength(t, e) { + const i = []; + for (const s of t) { + const t = xM(e, s, UU); + i.push(t); + } + return i; + }, + _measureText: (t, e) => i => xM(t, i, e), + _calculateShrinkFont(t) { + if (!FU) return; + const e = this._calculateParagraphLength(t, FU); + let i = 0; + let s = 0; + let n = 0; + if ($U) { + const e = oG.width; + const n = oG.height; + if (e < 0 || n < 0) return; + s = n + 1; + let r = []; + let o = 0; + let a = 0 | zU + 1; + let l = 0; + for (;o < a; ) { + l = o + a + 1 >> 1; + if (l <= 0) { + P(4003); + break; + } + zU = l; + UU = this._getFontDesc(); + FU.font = UU; + const h = this._getLineHeight(); + s = 0; + for (i = 0; i < t.length; ++i) { + const n = xM(FU, t[i], UU); + r = MM(t[i], n, e, this._measureText(FU, UU)); + s += r.length * h; + } + s > n ? a = l - 1 : o = l; + } + if (0 === o) P(4003); else { + zU = o; + UU = this._getFontDesc(); + FU.font = UU; + } + } else { + s = t.length * this._getLineHeight(); + for (i = 0; i < t.length; ++i) n < e[i] && (n = e[i]); + const r = (XU.width - nG.width) / n; + const o = XU.height / s; + zU = HU * Math.min(1, r, o) | 0; + UU = this._getFontDesc(); + FU.font = UU; + } + }, + _calculateWrapText(t) { + if (!$U || !FU) return; + jU = []; + const e = oG.width; + for (let i = 0; i < t.length; ++i) { + const s = xM(FU, t[i], UU); + const n = MM(t[i], s, e, this._measureText(FU, UU)); + jU = jU.concat(n); + } + }, + _calculateLabelFont() { + if (!FU) return; + const t = GU.split("\n"); + jU = t; + UU = this._getFontDesc(); + FU.font = UU; + switch (QU) { + case NU.NONE: + { + let e = 0; + let i = 0; + for (let i = 0; i < t.length; ++i) { + const s = xM(FU, t[i], UU); + e = e > s ? e : s; + } + i = (jU.length + pM) * this._getLineHeight(); + const s = parseFloat(e.toFixed(2)); + const n = parseFloat(i.toFixed(2)); + XU.width = s + nG.width; + XU.height = n + nG.height; + oG.width = s + rG.width; + oG.height = n + rG.height; + break; + } + + case NU.SHRINK: + this._calculateShrinkFont(t); + this._calculateWrapText(t); + break; + + case NU.CLAMP: + this._calculateWrapText(t); + break; + + case NU.RESIZE_HEIGHT: + { + this._calculateWrapText(t); + const e = (jU.length + pM) * this._getLineHeight(); + XU.height = e + nG.height; + oG.height = e + rG.height; + break; + } + } + } + }; + const fG = Bi.WHITE.clone(); + const gG = Uint16Array.from([ 0, 1, 2, 1, 3, 2 ]); + const yG = { + createData(t) { + const e = t.requestRenderData(); + e.dataLength = 4; + e.resize(4, 6); + const i = e.chunk.vb; + i[3] = i[21] = i[22] = i[31] = 0; + i[4] = i[12] = i[13] = i[30] = 1; + let s = 5; + for (let t = 0; t < 4; t++) { + Bi.toArray(i, fG, s); + s += 9; + } + e.vertexRow = 2; + e.vertexCol = 2; + e.chunk.setIndexBuffer(gG); + return e; + }, + fillBuffers(t, e) { + const i = t.renderData; + const s = i.chunk; + const n = i.data; + const r = t.node; + const o = s.vb; + const a = r.worldMatrix; + const l = i.floatStride; + let h = 0; + const c = n.length; + for (let t = 0; t < c; t++) { + const e = n[t]; + const i = e.x; + const s = e.y; + let r = a.m03 * i + a.m07 * s + a.m15; + r = r ? Math.abs(1 / r) : 1; + h = t * l; + o[h + 0] = (a.m00 * i + a.m04 * s + a.m12) * r; + o[h + 1] = (a.m01 * i + a.m05 * s + a.m13) * r; + o[h + 2] = (a.m02 * i + a.m06 * s + a.m14) * r; + } + const u = s.vertexOffset; + const _ = s.meshBuffer; + const d = s.meshBuffer.iData; + let p = _.indexOffset; + d[p++] = u; + d[p++] = u + 1; + d[p++] = u + 2; + d[p++] = u + 2; + d[p++] = u + 1; + d[p++] = u + 3; + _.indexOffset += 6; + }, + updateVertexData(t) { + const e = t.renderData; + if (!e) return; + const i = t.node._uiProps.uiTransformComp; + const s = i.width; + const n = i.height; + const r = i.anchorX * s; + const o = i.anchorY * n; + const a = e.data; + a[0].x = -r; + a[0].y = -o; + a[1].x = s - r; + a[1].y = -o; + a[2].x = -r; + a[2].y = n - o; + a[3].x = s - r; + a[3].y = n - o; + }, + updateUVs(t) { + const e = t.renderData; + if (!e || !t.ttfSpriteFrame) return; + const i = e.chunk.vb; + const s = t.ttfSpriteFrame.uv; + i[3] = s[0]; + i[4] = s[1]; + i[12] = s[2]; + i[13] = s[3]; + i[21] = s[4]; + i[22] = s[5]; + i[30] = s[6]; + i[31] = s[7]; + }, + updateColor(t) {} + }; + Ot(yG, mG); + const bG = t("labelAssembler", { + getAssembler(t) { + let e = yG; + t.font instanceof uM ? e = MU : t.cacheMode === IP.CacheMode.CHAR && (e = OU); + return e; + } + }); + IP.Assembler = bG; + const SG = cL.FillType; + const AG = new qi; + const TG = Uint16Array.from([ 0, 1, 2, 1, 3, 2 ]); + const vG = { + updateRenderData(t) { + const e = t.spriteFrame; + EI.packToDynamicAtlas(t, e); + const i = t.renderData; + if (i && e) { + if (!i.vertDirty) return; + let s = t.fillStart; + let n = t.fillRange; + if (n < 0) { + s += n; + n = -n; + } + n = s + n; + s = s > 1 ? 1 : s; + s = s < 0 ? 0 : s; + n = n > 1 ? 1 : n; + n = n < 0 ? 0 : n; + n -= s; + n = n < 0 ? 0 : n; + let r = s + n; + r = r > 1 ? 1 : r; + this.updateUVs(t, s, r); + this.updateVertexData(t, s, r); + i.updateRenderData(t, e); + } + }, + updateUVs(t, e, i) { + const s = t.spriteFrame; + const n = t.renderData.chunk.vb; + const r = s.width; + const o = s.height; + const a = s.rect; + let l = 0; + let h = 0; + let c = 0; + let u = 0; + let _ = 0; + let d = 0; + let p = 0; + let m = 0; + let f = 0; + let g = 0; + let y = 0; + let b = 0; + if (s.isRotated()) { + l = a.x / r; + h = (a.y + a.width) / o; + c = (a.x + a.height) / r; + u = a.y / o; + _ = p = l; + f = y = c; + m = b = h; + d = g = u; + } else { + l = a.x / r; + h = (a.y + a.height) / o; + c = (a.x + a.width) / r; + u = a.y / o; + _ = f = l; + p = y = c; + d = m = h; + g = b = u; + } + switch (t.fillType) { + case SG.HORIZONTAL: + n[3] = _ + (p - _) * e; + n[4] = d + (m - d) * e; + n[12] = _ + (p - _) * i; + n[13] = d + (m - d) * i; + n[21] = f + (y - f) * e; + n[22] = g + (b - g) * e; + n[30] = f + (y - f) * i; + n[31] = g + (b - g) * i; + break; + + case SG.VERTICAL: + n[3] = _ + (f - _) * e; + n[4] = d + (g - d) * e; + n[12] = p + (y - p) * e; + n[13] = m + (b - m) * e; + n[21] = _ + (f - _) * i; + n[22] = d + (g - d) * i; + n[30] = p + (y - p) * i; + n[31] = m + (b - m) * i; + break; + + default: + F(2626); + } + }, + updateVertexData(t, e, i) { + const s = t.renderData.data; + const n = t.node._uiProps.uiTransformComp; + const r = n.width; + const o = n.height; + const a = n.anchorX * r; + const l = n.anchorY * o; + let h = -a; + let c = -l; + let u = r - a; + let _ = o - l; + let d = 0; + let p = 0; + switch (t.fillType) { + case SG.HORIZONTAL: + d = h + (u - h) * e; + p = h + (u - h) * i; + h = d; + u = p; + break; + + case SG.VERTICAL: + d = c + (_ - c) * e; + p = c + (_ - c) * i; + c = d; + _ = p; + break; + + default: + F(2626); + } + s[0].x = h; + s[0].y = c; + s[1].x = u; + s[1].y = c; + s[2].x = h; + s[2].y = _; + s[3].x = u; + s[3].y = _; + }, + createData(t) { + const e = t.requestRenderData(); + e.dataLength = 4; + e.resize(4, 6); + e.vertexRow = 2; + e.vertexCol = 2; + e.chunk.setIndexBuffer(TG); + const i = e.data; + for (const t of i) t.z = 0; + return e; + }, + updateWorldVertexData(t, e) { + t.node.getWorldMatrix(AG); + const i = t.renderData.floatStride; + const s = t.renderData.data; + const n = e.vb; + let r = 0; + for (let t = 0; t < 4; t++) { + const e = s[t]; + const o = e.x; + const a = e.y; + let l = AG.m03 * o + AG.m07 * a + AG.m15; + l = l ? Math.abs(1 / l) : 1; + r = t * i; + n[r] = (AG.m00 * o + AG.m04 * a + AG.m12) * l; + n[r + 1] = (AG.m01 * o + AG.m05 * a + AG.m13) * l; + n[r + 2] = (AG.m02 * o + AG.m06 * a + AG.m14) * l; + } + }, + fillBuffers(t, e) { + const i = t.renderData; + const s = i.chunk; + if (t.node.hasChangedFlags || i.vertDirty) { + this.updateWorldVertexData(t, s); + i.vertDirty = !1; + } + s.bufferId; + const n = s.vertexOffset; + const r = s.meshBuffer; + const o = s.meshBuffer.iData; + let a = r.indexOffset; + o[a++] = n; + o[a++] = n + 1; + o[a++] = n + 2; + o[a++] = n + 2; + o[a++] = n + 1; + o[a++] = n + 3; + r.indexOffset += 6; + }, + updateColor(t) { + const e = t.renderData; + const i = e.chunk.vb; + const s = e.floatStride; + let n = 5; + const r = t.color; + const o = r.r / 255; + const a = r.g / 255; + const l = r.b / 255; + const h = t.node._uiProps.opacity; + for (let t = 0; t < 4; t++) { + i[n] = o; + i[n + 1] = a; + i[n + 2] = l; + i[n + 3] = h; + n += s; + } + } + }; + const EG = 2 * Math.PI; + const CG = 1e-6; + const xG = new qi; + const wG = [ new Qi, new Qi, new Qi, new Qi ]; + const RG = new Array(4); + const IG = new Array(8); + const MG = [ new Qi, new Qi, new Qi, new Qi ]; + const BG = [ new Qi, new Qi, new Qi, new Qi ]; + const DG = new Qi; + const PG = [ new Qi, new Qi, new Qi, new Qi ]; + let OG; + function NG(t, e, i, s, n, r, o) { + let a = Math.sin(r); + a = Math.abs(a) > CG ? a : 0; + let l = Math.cos(r); + l = Math.abs(l) > CG ? l : 0; + let h = 0; + let c = 0; + if (0 !== l) { + h = a / l; + if ((t - n.x) * l > 0) { + const e = n.y + h * (t - n.x); + o[0].x = t; + o[0].y = e; + } + if ((e - n.x) * l > 0) { + const t = n.y + h * (e - n.x); + o[2].x = e; + o[2].y = t; + } + } + if (0 !== a) { + c = l / a; + if ((s - n.y) * a > 0) { + const t = n.x + c * (s - n.y); + o[3].x = t; + o[3].y = s; + } + if ((i - n.y) * a > 0) { + const t = n.x + c * (i - n.y); + o[1].x = t; + o[1].y = i; + } + } + } + function LG(t, e) { + const i = e.x - t.x; + const s = e.y - t.y; + if (0 === i && 0 === s) return 0; + if (0 === i) return s > 0 ? .5 * Math.PI : 1.5 * Math.PI; + { + let t = Math.atan(s / i); + i < 0 && (t += Math.PI); + return t; + } + } + function FG(t, e, i, s, n) { + const r = RG; + const o = r[0]; + const a = r[1]; + const l = r[2]; + const h = r[3]; + t[e].x = i.x; + t[e].y = i.y; + t[e + 1].x = s.x; + t[e + 1].y = s.y; + t[e + 2].x = n.x; + t[e + 2].y = n.y; + let c = 0; + let u = 0; + c = (i.x - o) / (l - o); + u = (i.y - a) / (h - a); + VG(c, u, t, e); + c = (s.x - o) / (l - o); + u = (s.y - a) / (h - a); + VG(c, u, t, e + 1); + c = (n.x - o) / (l - o); + u = (n.y - a) / (h - a); + VG(c, u, t, e + 2); + } + function VG(t, e, i, s) { + const n = IG; + const r = n[0] + (n[2] - n[0]) * t; + const o = n[4] + (n[6] - n[4]) * t; + const a = n[1] + (n[3] - n[1]) * t; + const l = n[5] + (n[7] - n[5]) * t; + const h = i[s]; + h.u = r + (o - r) * e; + h.v = a + (l - a) * e; + } + const kG = { + useModel: !1, + createData: t => t.requestRenderData(), + updateRenderData(t) { + const e = t.spriteFrame; + EI.packToDynamicAtlas(t, e); + this.updateUVs(t); + const i = t.renderData; + if (i && e) { + if (!i.vertDirty) return; + const s = i.data; + let n = t.fillStart; + let r = t.fillRange; + if (r < 0) { + n += r; + r = -r; + } + for (;n >= 1; ) n -= 1; + for (;n < 0; ) n += 1; + n *= EG; + r *= EG; + const o = n + r; + !function(t) { + const e = t.node._uiProps.uiTransformComp; + const i = e.width; + const s = e.height; + const n = e.anchorX * i; + const r = e.anchorY * s; + const o = -n; + const a = -r; + const l = i - n; + const h = s - r; + const c = RG; + c[0] = o; + c[1] = a; + c[2] = l; + c[3] = h; + const u = t.fillCenter; + const _ = DG.x = Math.min(Math.max(0, u.x), 1) * (l - o) + o; + const d = DG.y = Math.min(Math.max(0, u.y), 1) * (h - a) + a; + wG[0].x = wG[3].x = o; + wG[1].x = wG[2].x = l; + wG[0].y = wG[1].y = a; + wG[2].y = wG[3].y = h; + for (const t of PG) Qi.set(t, 0, 0); + _ !== c[0] && Qi.set(PG[0], 3, 0); + _ !== c[2] && Qi.set(PG[2], 1, 2); + d !== c[1] && Qi.set(PG[1], 0, 1); + d !== c[3] && Qi.set(PG[3], 2, 3); + }(t); + !function(t) { + const e = t.width; + const i = t.height; + const s = t.getRect(); + let n = 0; + let r = 0; + let o = 0; + let a = 0; + const l = IG; + if (t.isRotated()) { + n = s.x / e; + r = (s.x + s.height) / e; + o = s.y / i; + a = (s.y + s.width) / i; + l[0] = l[2] = n; + l[4] = l[6] = r; + l[3] = l[7] = a; + l[1] = l[5] = o; + } else { + n = s.x / e; + r = (s.x + s.width) / e; + o = s.y / i; + a = (s.y + s.height) / i; + l[0] = l[4] = n; + l[2] = l[6] = r; + l[1] = l[3] = a; + l[5] = l[7] = o; + } + }(e); + NG(RG[0], RG[2], RG[1], RG[3], DG, n, MG); + NG(RG[0], RG[2], RG[1], RG[3], DG, n + r, BG); + let a = 0; + for (let t = 0; t < 4; ++t) { + const e = PG[t]; + if (!e) continue; + if (r >= EG) { + i.dataLength = a + 3; + FG(s, a, DG, wG[e.x], wG[e.y]); + a += 3; + continue; + } + let l = LG(DG, wG[e.x]); + let h = LG(DG, wG[e.y]); + h < l && (h += EG); + l -= EG; + h -= EG; + for (let r = 0; r < 3; ++r) { + if (l >= o) ; else if (l >= n) { + i.dataLength = a + 3; + FG(s, a, DG, wG[e.x], h >= o ? BG[t] : wG[e.y]); + a += 3; + } else if (h > n) if (h <= o) { + i.dataLength = a + 3; + FG(s, a, DG, MG[t], wG[e.y]); + a += 3; + } else { + i.dataLength = a + 3; + FG(s, a, DG, MG[t], BG[t]); + a += 3; + } + l += EG; + h += EG; + } + } + 0 === a && (i.dataLength = 0); + i.resize(a, a); + { + const e = i.indexCount; + this.createQuadIndices(e); + i.chunk.setIndexBuffer(OG); + this.updateWorldUVData(t); + t.renderEntity.colorDirty = !0; + } + i.updateRenderData(t, e); + } + }, + createQuadIndices(t) { + OG = null; + OG = new Uint16Array(t); + let e = 0; + for (let i = 0; i < t; i++) OG[e++] = i; + }, + fillBuffers(t, e) { + const i = t.node; + const s = t.renderData; + const n = s.chunk; + if (i.hasChangedFlags || s.vertDirty) { + this.updateWorldVertexAndUVData(t, n); + s.vertDirty = !1; + } + this.updateColorLate(t); + n.bufferId; + const r = n.vertexOffset; + const o = n.meshBuffer; + const a = n.meshBuffer.iData; + const l = o.indexOffset; + for (let t = 0; t < s.indexCount; t++) a[l + t] = r + t; + o.indexOffset += s.indexCount; + o.setDirty(); + }, + updateWorldUVData(t, e) { + const i = t.renderData; + const s = i.floatStride; + const n = i.data; + const r = i.chunk.vb; + for (let t = 0; t < n.length; t++) { + const e = t * s; + r[e + 3] = n[t].u; + r[e + 4] = n[t].v; + } + }, + updateWorldVertexAndUVData(t, e) { + t.node.getWorldMatrix(xG); + const i = t.renderData; + const s = i.floatStride; + const n = t.renderData.data; + const r = e.vb; + const o = i.vertexCount; + let a = 0; + for (let t = 0; t < o; t++) { + const e = n[t]; + const i = e.x; + const o = e.y; + let l = xG.m03 * i + xG.m07 * o + xG.m15; + l = l ? Math.abs(1 / l) : 1; + r[a + 0] = (xG.m00 * i + xG.m04 * o + xG.m12) * l; + r[a + 1] = (xG.m01 * i + xG.m05 * o + xG.m13) * l; + r[a + 2] = (xG.m02 * i + xG.m06 * o + xG.m14) * l; + r[a + 3] = e.u; + r[a + 4] = e.v; + a += s; + } + }, + updateUVs(t) { + t.renderData.vertDirty = !0; + t.markForUpdateRenderData(); + }, + updateColorLate(t) { + const e = t.renderData; + const i = e.chunk.vb; + const s = e.floatStride; + const n = e.vertexCount; + let r = 5; + const o = t.color; + const a = o.r / 255; + const l = o.g / 255; + const h = o.b / 255; + const c = t.node._uiProps.opacity; + for (let t = 0; t < n; t++) { + i[r] = a; + i[r + 1] = l; + i[r + 2] = h; + i[r + 3] = c; + r += s; + } + }, + updateColor(t) {} + }; + const UG = Uint16Array.from([ 0, 1, 2, 1, 3, 2 ]); + const GG = { + createData(t) { + const e = t.requestRenderData(); + e.dataLength = 4; + e.resize(4, 6); + e.vertexRow = 2; + e.vertexCol = 2; + e.chunk.setIndexBuffer(UG); + return e; + }, + updateRenderData(t) { + const e = t.spriteFrame; + EI.packToDynamicAtlas(t, e); + this.updateUVs(t); + const i = t.renderData; + if (i && e) { + i.vertDirty && this.updateVertexData(t); + i.updateRenderData(t, e); + } + }, + updateWorldVerts(t, e) { + const i = t.renderData; + const s = e.vb; + const n = i.data; + const r = t.node.worldMatrix; + const o = i.floatStride; + let a = 0; + const l = n.length; + for (let t = 0; t < l; t++) { + const e = n[t]; + const i = e.x; + const l = e.y; + let h = r.m03 * i + r.m07 * l + r.m15; + h = h ? Math.abs(1 / h) : 1; + a = t * o; + s[a + 0] = (r.m00 * i + r.m04 * l + r.m12) * h; + s[a + 1] = (r.m01 * i + r.m05 * l + r.m13) * h; + s[a + 2] = (r.m02 * i + r.m06 * l + r.m14) * h; + } + }, + fillBuffers(t, e) { + if (null === t) return; + const i = t.renderData; + const s = i.chunk; + if (t.node.hasChangedFlags || i.vertDirty) { + this.updateWorldVerts(t, s); + i.vertDirty = !1; + } + s.bufferId; + const n = s.vertexOffset; + const r = s.meshBuffer; + const o = s.meshBuffer.iData; + let a = r.indexOffset; + for (let t = 0; t < i.vertexRow - 1; t++) for (let e = 0; e < i.vertexCol - 1; e++) { + const s = n + t * i.vertexCol + e; + o[a++] = s; + o[a++] = s + 1; + o[a++] = s + i.vertexCol; + o[a++] = s + 1; + o[a++] = s + 1 + i.vertexCol; + o[a++] = s + i.vertexCol; + r.indexOffset += 6; + } + }, + updateVertexData(t) { + const e = t.renderData; + if (!e) return; + const i = t.node._uiProps.uiTransformComp; + const s = e.data; + const n = i.width; + const r = i.height; + const o = i.anchorX * n; + const a = i.anchorY * r; + let l = 0; + let h = 0; + let c = 0; + let u = 0; + if (t.trim) { + l = -o; + h = -a; + c = n - o; + u = r - a; + } else { + const e = t.spriteFrame; + const i = e.originalSize; + const s = n / i.width; + const _ = r / i.height; + const d = e.trimmedBorder; + l = d.x * s - o; + h = d.z * _ - a; + c = n + d.y * s - o; + u = r + d.w * _ - a; + } + s[0].x = l; + s[0].y = h; + s[1].x = c; + s[1].y = h; + s[2].x = l; + s[2].y = u; + s[3].x = c; + s[3].y = u; + e.vertDirty = !0; + }, + updateUVs(t) { + if (!t.spriteFrame) return; + const e = t.renderData.chunk.vb; + const i = t.spriteFrame.uv; + e[3] = i[0]; + e[4] = i[1]; + e[12] = i[2]; + e[13] = i[3]; + e[21] = i[4]; + e[22] = i[5]; + e[30] = i[6]; + e[31] = i[7]; + }, + updateColor(t) { + const e = t.renderData; + const i = e.chunk.vb; + let s = 5; + const n = t.color; + const r = n.r / 255; + const o = n.g / 255; + const a = n.b / 255; + const l = n.a / 255; + for (let t = 0; t < 4; t++, s += e.floatStride) { + i[s] = r; + i[s + 1] = o; + i[s + 2] = a; + i[s + 3] = l; + } + } + }; + const zG = new qi; + const HG = []; + for (let t = 0; t < 4; t++) HG.push({ + x: 0, + y: 0, + z: 0, + u: 0, + v: 0, + color: new Bi + }); + const jG = { + createData(t) { + const e = t.requestRenderData(); + e.dataLength = 16; + e.resize(16, 54); + e.vertexRow = 4; + e.vertexCol = 4; + this.QUAD_INDICES = new Uint16Array(54); + this.createQuadIndices(4, 4); + e.chunk.setIndexBuffer(this.QUAD_INDICES); + return e; + }, + createQuadIndices(t, e) { + let i = 0; + for (let s = 0; s < t - 1; s++) for (let t = 0; t < e - 1; t++) { + const n = s * e + t; + this.QUAD_INDICES[i++] = n; + this.QUAD_INDICES[i++] = n + 1; + this.QUAD_INDICES[i++] = n + e; + this.QUAD_INDICES[i++] = n + 1; + this.QUAD_INDICES[i++] = n + 1 + e; + this.QUAD_INDICES[i++] = n + e; + } + }, + updateRenderData(t) { + const e = t.spriteFrame; + EI.packToDynamicAtlas(t, e); + this.updateUVs(t); + const i = t.renderData; + if (i && e) { + i.vertDirty && this.updateVertexData(t); + i.updateRenderData(t, e); + } + }, + updateVertexData(t) { + const e = t.renderData; + const i = e.data; + const s = t.node._uiProps.uiTransformComp; + const n = s.width; + const r = s.height; + const o = s.anchorX * n; + const a = s.anchorY * r; + const l = t.spriteFrame; + const h = l.insetLeft; + const c = l.insetRight; + const u = l.insetTop; + const _ = l.insetBottom; + let d = n - h - c; + let p = r - u - _; + let m = n / (h + c); + let f = r / (u + _); + m = Number.isNaN(m) || m > 1 ? 1 : m; + f = Number.isNaN(f) || f > 1 ? 1 : f; + d = d < 0 ? 0 : d; + p = p < 0 ? 0 : p; + HG[0].x = -o; + HG[0].y = -a; + HG[1].x = h * m - o; + HG[1].y = _ * f - a; + HG[2].x = HG[1].x + d; + HG[2].y = HG[1].y + p; + HG[3].x = n - o; + HG[3].y = r - a; + for (let t = 0; t < e.vertexRow; t++) for (let s = 0; s < e.vertexCol; s++) { + const n = t * e.vertexCol + s; + if (n < e.dataLength && t < HG.length && s < HG.length) { + i[n].x = HG[s].x; + i[n].y = HG[t].y; + } + } + }, + fillBuffers(t, e) { + const i = t.renderData; + const s = i.chunk; + if (t.node.hasChangedFlags || i.vertDirty) { + this.updateWorldVertexData(t, s); + i.vertDirty = !1; + } + s.bufferId; + const n = s.vertexOffset; + const r = s.meshBuffer; + const o = s.meshBuffer.iData; + let a = r.indexOffset; + for (let t = 0; t < 3; ++t) for (let e = 0; e < 3; ++e) { + const i = n + 4 * t + e; + o[a++] = i; + o[a++] = i + 1; + o[a++] = i + 4; + o[a++] = i + 1; + o[a++] = i + 5; + o[a++] = i + 4; + } + r.indexOffset = a; + }, + updateWorldVertexData(t, e) { + t.node.getWorldMatrix(zG); + const i = t.renderData; + const s = i.floatStride; + const n = i.data; + const r = e.vb; + let o = 0; + for (let t = 0; t < 4; ++t) { + const e = n[4 * t]; + for (let i = 0; i < 4; ++i) { + const a = n[i].x; + const l = e.y; + let h = zG.m03 * a + zG.m07 * l + zG.m15; + h = h ? Math.abs(1 / h) : 1; + o = (4 * t + i) * s; + r[o + 0] = (zG.m00 * a + zG.m04 * l + zG.m12) * h; + r[o + 1] = (zG.m01 * a + zG.m05 * l + zG.m13) * h; + r[o + 2] = (zG.m02 * a + zG.m06 * l + zG.m14) * h; + } + } + }, + updateUVs(t) { + if (!t.spriteFrame) return; + const e = t.renderData; + const i = e.chunk.vb; + const s = e.floatStride; + const n = t.spriteFrame.uvSliced; + let r = 3; + for (let t = 0; t < 16; t++) { + i[r] = n[t].u; + i[r + 1] = n[t].v; + r += s; + } + }, + updateColor(t) { + const e = t.renderData; + const i = e.chunk.vb; + const s = e.floatStride; + let n = 5; + const r = t.color; + const o = r.r / 255; + const a = r.g / 255; + const l = r.b / 255; + const h = t.node._uiProps.opacity; + for (let t = 0; t < 16; t++) { + i[n] = o; + i[n + 1] = a; + i[n + 2] = l; + i[n + 3] = h; + n += s; + } + } + }; + const XG = new qi; + let WG; + let YG; + let qG; + let KG; + let JG; + let ZG; + let QG; + let $G = 0; + const tz = []; + let ez; + function iz(t) { + return t && (t.insetTop > 0 || t.insetBottom > 0 || t.insetLeft > 0 || t.insetRight > 0) ? 2 : 0; + } + const sz = { + createData: t => t.requestRenderData(), + updateRenderData(t) { + const e = t.renderData; + const i = t.spriteFrame; + if (!i || !e) return; + if (!e.vertDirty) return; + const s = t.node._uiProps.uiTransformComp; + const n = Math.abs(s.width); + const r = Math.abs(s.height); + const o = i.getRect(); + const a = i.insetLeft; + const l = i.insetRight; + const h = o.width - a - l; + const c = i.insetTop; + const u = i.insetBottom; + const _ = o.height - c - u; + let d = n - a - l; + let p = r - c - u; + d = d > 0 ? d : 0; + p = p > 0 ? p : 0; + const m = 0 === h ? d : d / h; + const f = 0 === _ ? p : p / _; + const g = iz(i); + const y = Math.ceil(f + g); + const b = Math.ceil(m + g); + e.dataLength = 2 * y * (2 * b); + this.updateVerts(t, d, p, y, b); + e.vertexCount !== y * b * 4 && (t.renderEntity.colorDirty = !0); + e.resize(y * b * 4, y * b * 6); + { + const i = e.indexCount; + this.createQuadIndices(i); + e.chunk.setIndexBuffer(ez); + this.updateWorldUVData(t); + } + e.updateRenderData(t, i); + }, + createQuadIndices(t) { + if (t % 6 != 0) { + console.error("illegal index count!"); + return; + } + const e = t / 6; + ez = null; + ez = new Uint16Array(t); + let i = 0; + for (let t = 0; t < e; t++) { + ez[i++] = 0 + 4 * t; + ez[i++] = 1 + 4 * t; + ez[i++] = 2 + 4 * t; + ez[i++] = 1 + 4 * t; + ez[i++] = 3 + 4 * t; + ez[i++] = 2 + 4 * t; + } + }, + updateUVs(t) { + t.renderData.vertDirty = !0; + t.markForUpdateRenderData(); + }, + fillBuffers(t, e) { + const i = t.node; + const s = t.renderData; + const n = s.chunk; + if (i.hasChangedFlags || s.vertDirty) { + this.updateWorldVertexAndUVData(t, n); + s.vertDirty = !1; + } + this.updateColorLate(t); + n.bufferId; + let r = n.vertexOffset; + const o = n.meshBuffer; + const a = n.meshBuffer.iData; + let l = o.indexOffset; + for (let t = 0; t < s.indexCount; t += 6) { + a[l++] = r; + a[l++] = r + 1; + a[l++] = r + 2; + a[l++] = r + 1; + a[l++] = r + 3; + a[l++] = r + 2; + r += 4; + o.indexOffset += 6; + } + o.setDirty(); + }, + updateWorldUVData(t) { + const e = t.renderData; + const i = e.floatStride; + const s = e.data; + const n = e.chunk.vb; + for (let t = 0; t < s.length; t++) { + const e = t * i; + n[e + 3] = s[t].u; + n[e + 4] = s[t].v; + } + }, + updateWorldVertexAndUVData(t, e) { + t.node.getWorldMatrix(XG); + const i = t.renderData; + const s = i.floatStride; + const n = i.data; + const r = e.vb; + const o = n.length; + for (let t = 0; t < o; t++) { + const e = n[t].x; + const i = n[t].y; + const o = n[t].z; + let a = XG.m03 * e + XG.m07 * i + XG.m11 * o + XG.m15; + a = a ? Math.abs(1 / a) : 1; + const l = t * s; + r[l] = (XG.m00 * e + XG.m04 * i + XG.m08 * o + XG.m12) * a; + r[l + 1] = (XG.m01 * e + XG.m05 * i + XG.m09 * o + XG.m13) * a; + r[l + 2] = (XG.m02 * e + XG.m06 * i + XG.m10 * o + XG.m14) * a; + } + this.updateWorldUVData(t); + }, + updateVerts(t, e, i, s, n) { + const r = t.node._uiProps.uiTransformComp; + const o = t.renderData.data; + const a = t.spriteFrame; + const l = a.rect; + const h = Math.abs(r.width); + const c = Math.abs(r.height); + const u = r.anchorX * h; + const _ = r.anchorY * c; + const d = a.insetLeft; + const p = a.insetRight; + const m = l.width - d - p; + const f = a.insetTop; + const g = a.insetBottom; + const y = l.height - f - g; + const b = r.width / (d + p) > 1 ? 1 : r.width / (d + p); + const S = r.height / (f + g) > 1 ? 1 : r.height / (f + g); + let A = 0; + let T = 0; + A = m > 0 ? Math.floor(1e3 * e) / 1e3 % m == 0 ? m : e % m : e; + T = y > 0 ? Math.floor(1e3 * i) / 1e3 % y == 0 ? y : i % y : i; + $G = Math.max(s + 1, n + 1); + for (let t = 0; t < $G; t++) tz.push({ + x: 0, + y: 0, + z: 0, + u: 0, + v: 0, + color: new Bi + }); + const v = iz(a); + if (0 === v) for (let t = 0; t < $G; t++) { + tz[t].x = t >= n ? h - u : t * m - u; + tz[t].y = t >= s ? c - _ : t * y - _; + } else for (let t = 0; t < $G; t++) { + 0 === t ? tz[t].x = -u : 1 === t ? tz[t].x = d * b - u : t > 1 && t < n - 1 ? tz[t].x = m > 0 ? d * b - u + m * (t - 1) : d + e - u : t === n - 1 ? tz[t].x = d * b - u + A + m * (t - 2) : t >= n && (tz[t].x = Math.min(d + e + p, h) - u); + 0 === t ? tz[t].y = -_ : 1 === t ? tz[t].y = g * S - _ : t > 1 && t < s - 1 ? tz[t].y = y > 0 ? g * S - _ + y * (t - 1) : g + i - _ : t === s - 1 ? tz[t].y = g * S - _ + T + y * (t - 2) : t >= s && (tz[t].y = Math.min(g + i + f, c) - _); + } + let E = 0; + let C = 0; + let x = 0; + let w = 0; + for (let t = 0; t < s; ++t) { + x = tz[t].y; + w = tz[t + 1].y; + for (let e = 0; e < n; ++e) { + E = tz[e].x; + C = tz[e + 1].x; + const i = 4 * (t * n + e); + o[i].x = E; + o[i].y = x; + o[i + 1].x = C; + o[i + 1].y = x; + o[i + 2].x = E; + o[i + 2].y = w; + o[i + 3].x = C; + o[i + 3].y = w; + } + } + const R = a.rotated; + a.uv; + const I = a.uvSliced; + WG = I[0]; + YG = I[1]; + qG = I[2]; + KG = I[3]; + JG = I[4]; + ZG = I[8]; + QG = I[12]; + let M = 0; + let B = 0; + const D = 0 === m ? e : e / m; + const P = 0 === y ? i : i / y; + const O = []; + const N = []; + for (let t = 0; t < s; ++t) { + if (i > y) { + B = i >= (v > 0 ? t : t + 1) * y ? 1 : P % 1; + } else B = P; + for (let i = 0; i < n; ++i) { + if (e > m) { + M = e >= (v > 0 ? i : i + 1) * m ? 1 : D % 1; + } else M = D; + if (R) { + if (0 === v) { + O[0] = JG.u; + O[1] = JG.u; + O[2] = JG.u + (ZG.u - JG.u) * B; + N[0] = YG.v; + N[1] = YG.v + (qG.v - YG.v) * M; + N[2] = YG.v; + } else { + if (0 === t) { + O[0] = WG.u; + O[1] = WG.u; + O[2] = JG.u; + } else if (t < s - 1) { + O[0] = JG.u; + O[1] = JG.u; + O[2] = JG.u + (ZG.u - JG.u) * B; + } else if (t === s - 1) { + O[0] = ZG.u; + O[1] = ZG.u; + O[2] = QG.u; + } + if (0 === i) { + N[0] = WG.v; + N[1] = YG.v; + N[2] = WG.v; + } else if (i < n - 1) { + N[0] = YG.v; + N[1] = YG.v + (qG.v - YG.v) * M; + N[2] = YG.v; + } else if (i === n - 1) { + N[0] = qG.v; + N[1] = KG.v; + N[2] = qG.v; + } + } + O[3] = O[2]; + N[3] = N[1]; + } else { + if (0 === v) { + O[0] = YG.u; + O[1] = YG.u + (qG.u - YG.u) * M; + O[2] = YG.u; + N[0] = JG.v; + N[1] = JG.v; + N[2] = JG.v + (ZG.v - JG.v) * B; + } else { + if (0 === i) { + O[0] = WG.u; + O[1] = YG.u; + O[2] = WG.u; + } else if (i < n - 1) { + O[0] = YG.u; + O[1] = YG.u + (qG.u - YG.u) * M; + O[2] = YG.u; + } else if (i === n - 1) { + O[0] = qG.u; + O[1] = KG.u; + O[2] = qG.u; + } + if (0 === t) { + N[0] = WG.v; + N[1] = WG.v; + N[2] = JG.v; + } else if (t < s - 1) { + N[0] = JG.v; + N[1] = JG.v; + N[2] = JG.v + (ZG.v - JG.v) * B; + } else if (t === s - 1) { + N[0] = ZG.v; + N[1] = ZG.v; + N[2] = QG.v; + } + } + O[3] = O[1]; + N[3] = N[2]; + } + const r = 4 * (t * n + i); + o[r].u = O[0]; + o[r].v = N[0]; + o[r + 1].u = O[1]; + o[r + 1].v = N[1]; + o[r + 2].u = O[2]; + o[r + 2].v = N[2]; + o[r + 3].u = O[3]; + o[r + 3].v = N[3]; + } + } + }, + updateColorLate(t) { + const e = t.renderData; + const i = e.chunk.vb; + const s = e.floatStride; + const n = e.vertexCount; + let r = 5; + const o = t.color; + const a = o.r / 255; + const l = o.g / 255; + const h = o.b / 255; + const c = t.node._uiProps.opacity; + for (let t = 0; t < n; t++) { + i[r] = a; + i[r + 1] = l; + i[r + 2] = h; + i[r + 3] = c; + r += s; + } + }, + updateColor(t) {} + }; + const nz = cL.Type; + const rz = cL.FillType; + const oz = t("spriteAssembler", { + getAssembler(t) { + let e = GG; + const i = t; + switch (i.type) { + case nz.SLICED: + e = jG; + break; + + case nz.TILED: + e = sz; + break; + + case nz.FILLED: + e = i.fillType === rz.RADIAL ? kG : vG; + } + return e; + } + }); + cL.Assembler = oz; + const az = [ av.EventType.MOUSE_DOWN, av.EventType.MOUSE_MOVE, av.EventType.MOUSE_UP, av.EventType.MOUSE_WHEEL ]; + const lz = [ av.EventType.TOUCH_START, av.EventType.TOUCH_MOVE, av.EventType.TOUCH_END, av.EventType.TOUCH_CANCEL ]; + new class { + constructor() { + this.priority = nv.UI; + this._isListDirty = !1; + this._inDispatchCount = 0; + this._pointerEventProcessorList = []; + this._processorListToAdd = []; + this._processorListToRemove = []; + lv._registerEventDispatcher(this); + KS.callbacksInvoker.on(qS.ADD_POINTER_EVENT_PROCESSOR, this.addPointerEventProcessor, this); + KS.callbacksInvoker.on(qS.REMOVE_POINTER_EVENT_PROCESSOR, this.removePointerEventProcessor, this); + KS.callbacksInvoker.on(qS.MARK_LIST_DIRTY, this._markListDirty, this); + } + dispatchEvent(t) { + const e = t.type; + return lz.includes(e) ? this.dispatchEventTouch(t) : !az.includes(e) || this.dispatchEventMouse(t); + } + addPointerEventProcessor(t) { + if (0 === this._inDispatchCount) { + if (!this._pointerEventProcessorList.includes(t)) { + this._pointerEventProcessorList.push(t); + this._isListDirty = !0; + } + } else this._processorListToAdd.includes(t) || this._processorListToAdd.push(t); + ee.array.remove(this._processorListToRemove, t); + } + removePointerEventProcessor(t) { + if (0 === this._inDispatchCount) { + ee.array.remove(this._pointerEventProcessorList, t); + this._isListDirty = !0; + } else this._processorListToRemove.includes(t) || this._processorListToRemove.push(t); + ee.array.remove(this._processorListToAdd, t); + } + dispatchEventMouse(t) { + this._inDispatchCount++; + this._sortPointerEventProcessorList(); + const e = this._pointerEventProcessorList; + const i = e.length; + let s = !0; + for (let n = 0; n < i; ++n) { + const i = e[n]; + if (i.isEnabled && i.shouldHandleEventMouse && i._handleEventMouse(t)) { + s = !1; + if (!t.preventSwallow) break; + t.preventSwallow = !1; + } + } + --this._inDispatchCount <= 0 && this._updatePointerEventProcessorList(); + return s; + } + dispatchEventTouch(t) { + this._inDispatchCount++; + this._sortPointerEventProcessorList(); + const e = this._pointerEventProcessorList; + const i = e.length; + const s = t.touch; + let n = !0; + for (let r = 0; r < i; ++r) { + const i = e[r]; + if (i.isEnabled && i.shouldHandleEventTouch) if (t.type === MS.TOUCH_START) { + if (i._handleEventTouch(t)) { + i.claimedTouchIdList.push(s.getID()); + n = !1; + if (!t.preventSwallow) break; + t.preventSwallow = !1; + } + } else if (i.claimedTouchIdList.length > 0) { + const e = i.claimedTouchIdList.indexOf(s.getID()); + if (-1 !== e) { + i._handleEventTouch(t); + t.type !== MS.TOUCH_END && t.type !== MS.TOUCH_CANCEL || ee.array.removeAt(i.claimedTouchIdList, e); + n = !1; + if (!t.preventSwallow) break; + t.preventSwallow = !1; + } + } + } + --this._inDispatchCount <= 0 && this._updatePointerEventProcessorList(); + return n; + } + _updatePointerEventProcessorList() { + const t = this._processorListToAdd; + const e = t.length; + for (let i = 0; i < e; ++i) this.addPointerEventProcessor(t[i]); + t.length = 0; + const i = this._processorListToRemove; + const s = i.length; + for (let t = 0; t < s; ++t) this.removePointerEventProcessor(i[t]); + i.length = 0; + } + _sortPointerEventProcessorList() { + if (!this._isListDirty) return; + const t = this._pointerEventProcessorList; + const e = t.length; + for (let i = 0; i < e; ++i) { + const e = t[i]; + const s = e.node; + if (s._uiProps) { + const t = s._uiProps.uiTransformComp; + e.cachedCameraPriority = t.cameraPriority; + } + } + t.sort(this._sortByPriority); + this._isListDirty = !1; + } + _sortByPriority(t, e) { + const i = t.node; + const s = e.node; + if (!(e && s && s.activeInHierarchy && s._uiProps.uiTransformComp)) return -1; + if (!(t && i && i.activeInHierarchy && i._uiProps.uiTransformComp)) return 1; + if (t.cachedCameraPriority !== e.cachedCameraPriority) return e.cachedCameraPriority - t.cachedCameraPriority; + let n = i; + let r = s; + let o = !1; + for (;(null === (a = n.parent) || void 0 === a ? void 0 : a._id) !== (null === (l = r.parent) || void 0 === l ? void 0 : l._id); ) { + var a, l, h, c, u, _; + n = null === (null === (h = n) || void 0 === h || null === (c = h.parent) || void 0 === c ? void 0 : c.parent) ? (o = !0) && s : n && n.parent; + r = null === (null === (u = r) || void 0 === u || null === (_ = u.parent) || void 0 === _ ? void 0 : _.parent) ? (o = !0) && i : r && r.parent; + } + if (n._id === r._id) { + if (n._id === s._id) return -1; + if (n._id === i._id) return 1; + } + const d = n ? n.getSiblingIndex() : 0; + const p = r ? r.getSiblingIndex() : 0; + return o ? d - p : p - d; + } + _markListDirty() { + this._isListDirty = !0; + } + }; + const hz = new Qn(null); + const cz = new qi; + class uz { + get nativeObj() { + return this._nativeObj; + } + get currBufferAccessor() { + if (this._staticVBBuffer) return this._staticVBBuffer; + this._staticVBBuffer = this.switchBufferAccessor(); + return this._staticVBBuffer; + } + get batches() { + return this._batches; + } + set currStaticRoot(t) { + this._currStaticRoot = t; + } + set currIsStatic(t) { + this._currIsStatic = t; + } + constructor(t) { + this.device = void 0; + this._screens = []; + this._staticVBBuffer = null; + this._bufferAccessors = new Map; + this._drawBatchPool = void 0; + this._batches = void 0; + this._currBID = -1; + this._indexStart = 0; + this._emptyMaterial = new hm; + this._currRenderData = null; + this._currMaterial = this._emptyMaterial; + this._currTexture = null; + this._currSampler = null; + this._currStaticRoot = null; + this._currComponent = null; + this._currTransform = null; + this._currTextureHash = 0; + this._currSamplerHash = 0; + this._currLayer = 0; + this._currDepthStencilStateStage = null; + this._currIsStatic = !1; + this._currHash = 0; + this._pOpacity = 1; + this._opacityDirty = 0; + this._descriptorSetCache = new dz; + this._meshDataArray = []; + this._maskClearModel = null; + this._maskClearMtl = null; + this._maskModelMesh = null; + this._root = t; + this.device = t.device; + this._batches = new eo(64); + this._drawBatchPool = new $r((() => new MV), 128, (t => t.destroy(this))); + } + initialize() { + return !0; + } + destroy() { + for (let t = 0; t < this._batches.length; t++) this._batches.array[t] && this._batches.array[t].destroy(this); + this._batches.destroy(); + this._bufferAccessors.forEach((t => { + t.destroy(); + })); + this._bufferAccessors.clear(); + this._drawBatchPool && this._drawBatchPool.destroy(); + this._descriptorSetCache.destroy(); + cB.sharedManager.destroy(); + if (this._maskClearModel && this._maskModelMesh) { + m.director.root.destroyModel(this._maskClearModel); + this._maskModelMesh.destroy(); + } + this._maskClearMtl && this._maskClearMtl.destroy(); + } + syncRootNodesToNative() { + { + const t = []; + for (const e of this._screens) t.push(e.node); + this._nativeObj.syncRootNodesToNative(t); + } + } + addScreen(t) { + this._screens.push(t); + this._screens.sort(this._screenSort); + this.syncRootNodesToNative(); + } + removeScreen(t) { + const e = this._screens.indexOf(t); + if (-1 !== e) { + this._screens.splice(e, 1); + this.syncRootNodesToNative(); + } + } + sortScreens() { + this._screens.sort(this._screenSort); + this.syncRootNodesToNative(); + } + getFirstRenderCamera(t) { + if (t.scene && t.scene.renderScene) { + const e = t.scene.renderScene.cameras; + for (let i = 0; i < e.length; i++) { + const s = e[i]; + if (s.visibility & t.layer) return s; + } + } + return null; + } + update() {} + uploadBuffers() { + this._nativeObj.uploadBuffers(); + } + reset() { + this._nativeObj.reset(); + } + switchBufferAccessor(t = zM) { + const e = t === zM ? 36 : YM(t); + if (!this._staticVBBuffer || this._staticVBBuffer.vertexFormatBytes !== e) { + let i = this._bufferAccessors.get(e); + if (!i) { + i = new iB(this.device, t); + this._bufferAccessors.set(e, i); + } + this._staticVBBuffer = i; + this._currBID = -1; + } + return this._staticVBBuffer; + } + registerBufferAccessor(t, e) { + this._bufferAccessors.set(t, e); + } + updateBuffer(t, e) { + const i = this.switchBufferAccessor(t); + if (this._currBID !== e) { + this._currBID = e; + this._indexStart = i.getMeshBuffer(e).indexOffset; + } + } + commitComp(t, e, i, s, n) { + let r = 0; + let o; + let a = -1; + if (e && e.chunk) { + if (!e.isValid()) return; + r = e.dataHash; + o = e.material; + a = e.chunk.bufferId; + } + t.stencilStage === lB.ENTER_LEVEL || t.stencilStage === lB.ENTER_LEVEL_INVERTED ? this._insertMaskBatch(t) : t.stencilStage = cB.sharedManager.stage; + const l = t.stencilStage; + if (this._currHash !== r || 0 === r || this._currMaterial !== o || this._currDepthStencilStateStage !== l) { + this.autoMergeBatches(this._currComponent); + e && !e._isMeshBuffer && this.updateBuffer(e.vertexFormat, a); + this._currRenderData = e; + this._currHash = e ? e.dataHash : 0; + this._currComponent = t; + this._currTransform = n; + this._currMaterial = t.getRenderMaterial(0); + this._currDepthStencilStateStage = l; + this._currLayer = t.node.layer; + if (i) { + this._currTexture = i.getGFXTexture(); + this._currSampler = i.getGFXSampler(); + this._currTextureHash = i.getHash(); + this._currSamplerHash = this._currSampler.hash; + } else { + this._currTexture = null; + this._currSampler = null; + this._currTextureHash = 0; + this._currSamplerHash = 0; + } + } + s.fillBuffers(t, this); + } + commitIA(t, e, i, s, n) { + if (this._currMaterial !== this._emptyMaterial) { + this.autoMergeBatches(this._currComponent); + this.resetRenderStates(); + } + let r; + let o = 0; + if (t) { + t.stencilStage = cB.sharedManager.stage; + r = null !== t.customMaterial ? cB.sharedManager.getStencilStage(t.stencilStage, s) : cB.sharedManager.getStencilStage(t.stencilStage); + o = cB.sharedManager.getStencilHash(t.stencilStage); + } + const a = this._currStaticRoot ? this._currStaticRoot._requireDrawBatch() : this._drawBatchPool.alloc(); + a.visFlags = t.node.layer; + a.inputAssembler = e; + a.useLocalData = n || null; + if (i) { + a.texture = i.getGFXTexture(); + a.sampler = i.getGFXSampler(); + a.textureHash = i.getHash(); + a.samplerHash = a.sampler.hash; + } + a.fillPasses(s || null, r, o, null); + this._batches.push(a); + } + commitModel(t, e, i) { + if (this._currMaterial !== this._emptyMaterial) { + this.autoMergeBatches(this._currComponent); + this.resetRenderStates(); + } + let s; + let n = 0; + if (i) { + t.stencilStage === lB.ENTER_LEVEL || t.stencilStage === lB.ENTER_LEVEL_INVERTED ? this._insertMaskBatch(t) : t.stencilStage = cB.sharedManager.stage; + s = cB.sharedManager.getStencilStage(t.stencilStage, i); + n = cB.sharedManager.getStencilHash(t.stencilStage); + } + const r = m.director.getTotalFrames(); + if (e) { + e.updateTransform(r); + e.updateUBOs(r); + } + for (let r = 0; r < e.subModels.length; r++) { + const o = this._drawBatchPool.alloc(); + const a = e.subModels[r]; + o.visFlags = t.node.layer; + o.model = e; + o.texture = null; + o.sampler = null; + o.useLocalData = null; + s || (s = null); + o.fillPasses(i, s, n, a.patches); + o.inputAssembler = a.inputAssembler; + o.model.visFlags = o.visFlags; + o.descriptorSet = a.descriptorSet; + this._batches.push(o); + } + } + setupStaticBatch(t, e) { + this.finishMergeBatches(); + this._staticVBBuffer = e; + this.currStaticRoot = t; + } + endStaticBatch() { + this.finishMergeBatches(); + this.currStaticRoot = null; + this._staticVBBuffer = null; + this.switchBufferAccessor(); + } + commitStaticBatch(t) { + this._batches.concat(t.drawBatchList); + this.finishMergeBatches(); + } + autoMergeBatches(t) { + const e = this._currMaterial; + if (!e) return; + let i; + const s = this._currRenderData; + const n = this._staticVBBuffer; + if (s && s._isMeshBuffer) { + i = s.requestIA(this.device); + -1 === this._meshDataArray.indexOf(s) && this._meshDataArray.push(s); + } else if (n) { + const t = this._currBID; + const e = n.getMeshBuffer(t); + if (!e) return; + const s = e.indexOffset - this._indexStart; + if (s <= 0) return; + ne(this._indexStart < e.indexOffset); + e.setDirty(); + i = e.requireFreeIA(this.device); + i.firstIndex = this._indexStart; + i.indexCount = s; + this._indexStart = e.indexOffset; + } + this._currBID = -1; + if (!i) return; + let r; + let o = 0; + if (t) { + r = null !== t.customMaterial ? cB.sharedManager.getStencilStage(t.stencilStage, e) : cB.sharedManager.getStencilStage(t.stencilStage); + o = cB.sharedManager.getStencilHash(t.stencilStage); + } + const a = this._currStaticRoot ? this._currStaticRoot._requireDrawBatch() : this._drawBatchPool.alloc(); + a.visFlags = this._currLayer; + a.texture = this._currTexture; + a.sampler = this._currSampler; + a.inputAssembler = i; + a.useLocalData = this._currTransform; + a.textureHash = this._currTextureHash; + a.samplerHash = this._currSamplerHash; + a.fillPasses(e, r, o, null); + this._batches.push(a); + } + forceMergeBatches(t, e, i) { + this._currMaterial = t; + if (e) { + this._currTexture = e.getGFXTexture(); + this._currSampler = e.getGFXSampler(); + this._currTextureHash = e.getHash(); + this._currSamplerHash = this._currSampler.hash; + } else { + this._currTexture = this._currSampler = null; + this._currTextureHash = this._currSamplerHash = 0; + } + this._currLayer = i.node.layer; + this.autoMergeBatches(i); + } + resetRenderStates() { + this._currMaterial = this._emptyMaterial; + this._currRenderData = null; + this._currTexture = null; + this._currComponent = null; + this._currTransform = null; + this._currTextureHash = 0; + this._currSamplerHash = 0; + this._currLayer = 0; + } + finishMergeBatches() { + this.autoMergeBatches(); + this.resetRenderStates(); + } + flushMaterial(t) { + this._currMaterial = t; + } + walk(t, e = 0) { + if (!t.activeInHierarchy) return; + const i = t.children; + const s = t._uiProps; + const n = s.uiComp; + const r = this._pOpacity; + let o = r; + const a = n && n.color ? n.color.a / 255 : 1; + this._pOpacity = o *= a * s.localOpacity; + s._opacity = o; + s.colorDirty && this._opacityDirty++; + n && n.enabledInHierarchy && n.fillBuffers(this); + if (this._opacityDirty && n && !n.useVertexOpacity && n.renderData && n.renderData.vertexCount > 0) { + !function(t, e) { + const i = t.vertexFormat; + const s = t.chunk.vb; + let n; + let r; + let o; + let a = 0; + for (let l = 0; l < i.length; ++l) { + n = i[l]; + r = ur[n.format]; + if (r.hasAlpha) { + o = t.floatStride; + if (r.size / r.count == 1) { + const t = ~~_i(Math.round(255 * e), 0, 255); + for (let e = a; e < s.length; e += o) s[e] = (4294967040 & s[e] | t) >>> 0; + } else if (r.size / r.count == 4) for (let t = a + 3; t < s.length; t += o) s[t] = e; + } + a += r.size >> 2; + } + }(n.renderData, o); + const t = n.renderData.getMeshBuffer(); + t && t.setDirty(); + } + if (i.length > 0 && !t._static) for (let t = 0; t < i.length; ++t) { + const s = i[t]; + this.walk(s, e); + } + if (s.colorDirty) { + this._opacityDirty--; + s.colorDirty = !1; + } + this._pOpacity = r; + if (n && n.enabledInHierarchy) { + n.postUpdateAssembler(this); + if ((n.stencilStage === lB.ENTER_LEVEL || n.stencilStage === lB.ENTER_LEVEL_INVERTED) && cB.sharedManager.getMaskStackSize() > 0) { + this.autoMergeBatches(this._currComponent); + this.resetRenderStates(); + cB.sharedManager.exitMask(); + } + } + e += 1; + } + _screenSort(t, e) { + return t.node.getSiblingIndex() - e.node.getSiblingIndex(); + } + _releaseDescriptorSetCache(t, e = null) { + this._nativeObj.releaseDescriptorSetCache(t, e); + } + _createClearModel() { + if (!this._maskClearModel) { + this._maskClearMtl = xR.get("default-clear-stencil"); + this._maskClearModel = m.director.root.createModel(wA); + const t = YM(UM); + const e = zo.gfxDevice; + const i = e.createBuffer(new An(Ts.VERTEX | Ts.TRANSFER_DST, Cs.DEVICE, 4 * t, t)); + const s = new Float32Array([ -1, -1, 0, 1, -1, 0, -1, 1, 0, 1, 1, 0 ]); + i.update(s); + const n = e.createBuffer(new An(Ts.INDEX | Ts.TRANSFER_DST, Cs.DEVICE, 6 * Uint16Array.BYTES_PER_ELEMENT, Uint16Array.BYTES_PER_ELEMENT)); + const r = new Uint16Array([ 0, 1, 2, 2, 1, 3 ]); + n.update(r); + this._maskModelMesh = new fC([ i ], UM, Xs.TRIANGLE_LIST, n); + this._maskModelMesh.subMeshIdx = 0; + this._maskClearModel.initSubModel(0, this._maskModelMesh, this._maskClearMtl); + } + } + _insertMaskBatch(t) { + this.autoMergeBatches(this._currComponent); + this.resetRenderStates(); + this._createClearModel(); + this._maskClearModel.node = this._maskClearModel.transform = t.node; + const e = cB.sharedManager; + e.pushMask(1); + const i = e.clear(t); + let s; + let n = 0; + const r = this._maskClearMtl; + if (r) { + s = e.getStencilStage(i, r); + n = e.getStencilHash(i); + } + const o = this._maskClearModel; + const a = m.director.getTotalFrames(); + if (o) { + o.updateTransform(a); + o.updateUBOs(a); + } + for (let e = 0; e < o.subModels.length; e++) { + const i = this._drawBatchPool.alloc(); + const a = o.subModels[e]; + i.visFlags = t.node.layer; + i.model = o; + i.texture = null; + i.sampler = null; + i.useLocalData = null; + s || (s = null); + i.fillPasses(r, s, n, a.patches); + i.inputAssembler = a.inputAssembler; + i.model.visFlags = i.visFlags; + i.descriptorSet = a.descriptorSet; + this._batches.push(i); + } + e.enableMask(); + } + syncMeshBuffersToNative(t, e) { + { + const i = []; + e.forEach((t => { + i.push(t.nativeObj); + })); + this._nativeObj.syncMeshBuffersToNative(t, i); + } + } + } + t("UI", uz); + class _z { + get descriptorSet() { + return this._descriptorSet; + } + constructor() { + this._descriptorSet = null; + this._transform = null; + this._textureHash = 0; + this._samplerHash = 0; + this._localBuffer = null; + this._transformUpdate = !0; + const t = zo.gfxDevice; + this._localData = new Float32Array(Km.COUNT); + this._localBuffer = t.createBuffer(new An(Ts.UNIFORM | Ts.TRANSFER_DST, Cs.HOST | Cs.DEVICE, Km.SIZE, Km.SIZE)); + } + initialize(t) { + const e = zo.gfxDevice; + this._transform = t.useLocalData; + this._textureHash = t.textureHash; + this._samplerHash = t.samplerHash; + hz.layout = t.passes[0].localSetLayout; + this._descriptorSet = e.createDescriptorSet(hz); + this._descriptorSet.bindBuffer(Km.BINDING, this._localBuffer); + const i = vm.SAMPLER_SPRITE; + this._descriptorSet.bindTexture(i, t.texture); + this._descriptorSet.bindSampler(i, t.sampler); + this._descriptorSet.update(); + this._transformUpdate = !0; + } + updateTransform(t) { + if (t !== this._transform) { + this._transform = t; + this._transformUpdate = !0; + this.uploadLocalData(); + } + } + equals(t, e, i) { + return this._transform === t && this._textureHash === e && this._samplerHash === i; + } + reset() { + this._transform = null; + this._textureHash = 0; + this._samplerHash = 0; + } + destroy() { + if (this._localBuffer) { + this._localBuffer.destroy(); + this._localBuffer = null; + } + if (this._descriptorSet) { + this._descriptorSet.destroy(); + this._descriptorSet = null; + } + this._localData = null; + } + isValid() { + return this._transform && this._transform.isValid; + } + uploadLocalData() { + const t = this._transform; + if (t.hasChangedFlags || t._dirtyFlags) { + t.updateWorldTransform(); + this._transformUpdate = !0; + } + if (this._transformUpdate) { + const e = t.worldMatrix; + qi.toArray(this._localData, e, Km.MAT_WORLD_OFFSET); + qi.inverseTranspose(cz, e); + qi.toArray(this._localData, cz, Km.MAT_WORLD_IT_OFFSET); + this._localBuffer.update(this._localData); + this._transformUpdate = !1; + } + } + } + class dz { + constructor() { + this._descriptorSetCache = new Map; + this._dsCacheHashByTexture = new Map; + this._localDescriptorSetCache = []; + this._localCachePool = void 0; + this._localCachePool = new $r((() => new _z), 16, (t => t.destroy())); + } + getDescriptorSet(t) { + m.director.root; + let e; + if (t.useLocalData) { + const e = this._localDescriptorSetCache; + for (let i = 0, s = e.length; i < s; i++) { + const s = e[i]; + if (s.equals(t.useLocalData, t.textureHash, t.samplerHash)) return s.descriptorSet; + } + const i = this._localCachePool.alloc(); + i.initialize(t); + this._localDescriptorSetCache.push(i); + return i.descriptorSet; + } + e = t.textureHash ^ t.samplerHash; + if (this._descriptorSetCache.has(e)) return this._descriptorSetCache.get(e); + { + hz.layout = t.passes[0].localSetLayout; + const i = zo.gfxDevice.createDescriptorSet(hz); + const s = vm.SAMPLER_SPRITE; + i.bindTexture(s, t.texture); + i.bindSampler(s, t.sampler); + i.update(); + this._descriptorSetCache.set(e, i); + this._dsCacheHashByTexture.set(t.textureHash, e); + return i; + } + } + update() { + const t = this._localDescriptorSetCache; + const e = []; + t.forEach((i => { + if (i.isValid()) i.uploadLocalData(); else { + i.reset(); + const s = t.indexOf(i); + e.push(s); + } + })); + for (let i = e.length - 1; i >= 0; i--) t.splice(e[i], 1); + } + reset() { + this._localDescriptorSetCache.forEach((t => { + this._localCachePool.free(t); + })); + this._localDescriptorSetCache.length = 0; + } + releaseDescriptorSetCache(t) { + const e = this._dsCacheHashByTexture.get(t); + if (e && this._descriptorSetCache.has(e)) { + this._descriptorSetCache.get(e).destroy(); + this._descriptorSetCache.delete(e); + this._dsCacheHashByTexture.delete(t); + } + } + destroy() { + this._descriptorSetCache.forEach(((t, e, i) => { + t.destroy(); + })); + this._descriptorSetCache.clear(); + this._dsCacheHashByTexture.clear(); + this._localDescriptorSetCache.length = 0; + this._localCachePool.destroy(); + } + } + m.internal.Batcher2D = uz; + t("UIDrawBatch", class extends MV {}); + q($M.prototype, "MeshBuffer", [ "byteStart", "vertexStart", "indicesStart", "request" ].map((t => ({ + name: t, + suggest: `please use meshBuffer.accessor.${t} instead` + })))); + W($M.prototype, "MeshBuffer", [ { + name: "indicesOffset", + newName: "indexOffset" + } ]); + Y($M.prototype, "MeshBuffer", [ { + name: "vertexBuffers" + }, { + name: "indexBuffer" + } ]); + W(uz.prototype, "Batcher2D", [ { + name: "currBufferBatch", + newName: "currBufferAccessor" + }, { + name: "acquireBufferBatch", + newName: "switchBufferAccessor" + } ]); + Y(AB.prototype, "MeshRenderData", [ { + name: "formatByte" + }, { + name: "byteStart" + }, { + name: "byteCount" + } ]); + W(AB.prototype, "MeshRenderData", [ { + name: "indicesStart", + newName: "indexStart" + } ]); + t("QuadRenderData", class extends AB { + constructor(t) { + super(t); + N(9006); + } + }); + let pz = null; + let mz = -1; + const fz = "BES bswy:->@123丁ぁᄁ"; + const gz = Object.create(null); + const yz = []; + const bz = 3e3; + const Sz = (() => { + let t; + return () => { + if (void 0 === t) if ("FontFace" in window) { + const e = /Gecko.*Firefox\/(\d+)/.exec(window.navigator.userAgent); + const i = /OS X.*Version\/10\..*Safari/.exec(window.navigator.userAgent) && /Apple/.exec(window.navigator.vendor); + t = e ? parseInt(e[1], 10) > 42 : !i; + } else t = !1; + return t; + }; + })(); + function Az() { + let t = !0; + const e = Date.now(); + for (let i = yz.length - 1; i >= 0; i--) { + const s = yz[i]; + const n = s.fontFamilyName; + if (e - s.startTime > bz) { + N(4933, n); + s.onComplete(null, n); + yz.splice(i, 1); + continue; + } + const r = s.refWidth; + const o = `40px ${n}`; + pz.font = o; + if (r !== xM(pz, fz, o)) { + yz.splice(i, 1); + s.onComplete(null, n); + } else t = !1; + } + if (t) { + clearInterval(mz); + mz = -1; + } + } + function Tz(t, e, i) { + const s = function(t) { + const e = t.lastIndexOf(".ttf"); + if (-1 === e) return t; + const i = t.lastIndexOf("/"); + let s; + s = -1 === i ? `${t.substring(0, e)}_LABEL` : `${t.substring(i + 1, e)}_LABEL`; + -1 !== s.indexOf(" ") && (s = `"${s}"`); + return s; + }(t); + if (gz[s]) { + i(null, s); + return; + } + if (!pz) { + const t = document.createElement("canvas"); + t.width = 100; + t.height = 100; + pz = t.getContext("2d"); + } + const n = xM(pz, fz, `40px ${s}`); + const r = document.createElement("style"); + r.type = "text/css"; + let o = ""; + Number.isNaN(s) ? o += `@font-face { font-family:${s}; src:` : o += `@font-face { font-family:"${s}"; src:`; + o += `url("${t}");`; + r.textContent = `${o}}`; + document.body.appendChild(r); + const a = document.createElement("div"); + const l = a.style; + l.fontFamily = s; + a.innerHTML = "."; + l.position = "absolute"; + l.left = "-100px"; + l.top = "-100px"; + document.body.appendChild(a); + if (Sz()) !function(t, e, i) { + const s = new Promise(((i, s) => { + const n = () => { + Date.now() - t >= bz ? s() : document.fonts.load(`40px ${e}`).then((t => { + t.length >= 1 ? i() : setTimeout(n, 100); + }), (() => { + s(); + })); + }; + n(); + })); + let n = null; + const r = new Promise(((t, e) => { + n = setTimeout(e, bz); + })); + Promise.race([ r, s ]).then((() => { + if (n) { + clearTimeout(n); + n = null; + } + i(null, e); + }), (() => { + N(4933, e); + i(null, e); + })); + }(Date.now(), s, i); else { + const t = { + fontFamilyName: s, + refWidth: n, + onComplete: i, + startTime: Date.now() + }; + yz.push(t); + -1 === mz && (mz = setInterval(Az, 100)); + } + gz[s] = r; + } + function vz(t, e, i, s) { + const n = new $I; + n._nativeUrl = t; + n._nativeAsset = e; + s(null, n); + } + Jw.register({ + ".font": Tz, + ".eot": Tz, + ".ttf": Tz, + ".woff": Tz, + ".svg": Tz, + ".ttc": Tz + }); + sR.register({ + ".font": vz, + ".eot": vz, + ".ttf": vz, + ".woff": vz, + ".svg": vz, + ".ttc": vz + }); + m.UI = { + MeshBuffer: $M, + spriteAssembler: oz, + graphicsAssembler: Yk, + labelAssembler: bG, + RenderData: SB, + MeshRenderData: AB + }; + const Ez = t("Mesh", jsb.Mesh); + const Cz = jsb.Mesh.IStruct.prototype; + Object.defineProperty(Cz, "minPosition", { + configurable: !0, + enumerable: !0, + get() { + const t = this.getMinPosition(); + t ? this._minPositionCache ? this._minPositionCache.set(t.x, t.y, t.z) : this._minPositionCache = new Pi(t.x, t.y, t.z) : this._minPositionCache = void 0; + return this._minPositionCache; + }, + set(t) { + this.setMinPosition(t); + } + }); + Object.defineProperty(Cz, "maxPosition", { + configurable: !0, + enumerable: !0, + get() { + const t = this.getMaxPosition(); + t ? this._maxPositionCache ? this._maxPositionCache.set(t.x, t.y, t.z) : this._maxPositionCache = new Pi(t.x, t.y, t.z) : this._maxPositionCache = void 0; + return this._maxPositionCache; + }, + set(t) { + this.setMaxPosition(t); + } + }); + const xz = jsb.Mesh.prototype; + xz.createNode = null; + const wz = xz.onLoaded; + xz._ctor = function() { + jsb.Asset.prototype._ctor.apply(this, arguments); + this._struct = { + vertexBundles: [], + primitives: [] + }; + this._minPosition = void 0; + this._maxPosition = void 0; + }; + Object.defineProperty(xz, "struct", { + configurable: !0, + enumerable: !0, + get() { + return this.getStruct(); + } + }); + Object.defineProperty(xz, "minPosition", { + configurable: !0, + enumerable: !0, + get() { + const t = this.getMinPosition(); + t ? this._minPosition ? this._minPosition.set(t.x, t.y, t.z) : this._minPosition = new Pi(t.x, t.y, t.z) : this._minPosition = void 0; + return this._minPosition; + } + }); + Object.defineProperty(xz, "maxPosition", { + configurable: !0, + enumerable: !0, + get() { + const t = this.getMaxPosition(); + t ? this._maxPosition ? this._maxPosition.set(t.x, t.y, t.z) : this._maxPosition = new Pi(t.x, t.y, t.z) : this._maxPosition = void 0; + return this._maxPosition; + } + }); + xz.onLoaded = function() { + null != this._struct && this.setStruct(this._struct); + this._struct = null; + wz.apply(this); + }; + m.Mesh = jsb.Mesh; + const Rz = Ez.prototype; + Yl(Rz, "_struct"); + Yl(Rz, "_hash"); + Yl(Rz, "_allowDataAccess"); + Ul("cc.Mesh")(Ez); + const Iz = jsb.MorphModel; + m.MorphModel = jsb.MorphModel; + var Mz, Bz, Dz, Pz, Oz, Nz, Lz, Fz, Vz, kz, Uz, Gz, zz, Hz, jz, Xz, Wz, Yz, qz, Kz, Jz, Zz, Qz, $z, tH, eH, iH, sH, nH, rH, oH, aH, lH, hH, cH, uH, _H, dH, pH, mH; + const fH = oe({ + OFF: 0, + ON: 1 + }); + const gH = oe({ + OFF: 0, + ON: 1 + }); + let yH = (Mz = Ul("cc.ModelLightmapSettings"), Bz = ql("_recieveShadow"), Mz(Dz = (Pz = class { + constructor() { + Ml(this, "texture", Oz, this); + Ml(this, "uvParam", Nz, this); + Ml(this, "_bakeable", Lz, this); + Ml(this, "_castShadow", Fz, this); + Ml(this, "_receiveShadow", Vz, this); + Ml(this, "_lightmapSize", kz, this); + } + get bakeable() { + return this._bakeable; + } + set bakeable(t) { + this._bakeable = t; + } + get castShadow() { + return this._castShadow; + } + set castShadow(t) { + this._castShadow = t; + } + get receiveShadow() { + return this._receiveShadow; + } + set receiveShadow(t) { + this._receiveShadow = t; + } + get lightmapSize() { + return this._lightmapSize; + } + set lightmapSize(t) { + this._lightmapSize = t; + } + }, Oz = Bl(Pz.prototype, "texture", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Nz = Bl(Pz.prototype, "uvParam", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new is; + } + }), Lz = Bl(Pz.prototype, "_bakeable", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Fz = Bl(Pz.prototype, "_castShadow", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Vz = Bl(Pz.prototype, "_receiveShadow", [ Bz ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), kz = Bl(Pz.prototype, "_lightmapSize", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 64; + } + }), Bl(Pz.prototype, "bakeable", [ nh ], Object.getOwnPropertyDescriptor(Pz.prototype, "bakeable"), Pz.prototype), + Bl(Pz.prototype, "castShadow", [ nh ], Object.getOwnPropertyDescriptor(Pz.prototype, "castShadow"), Pz.prototype), + Bl(Pz.prototype, "receiveShadow", [ nh ], Object.getOwnPropertyDescriptor(Pz.prototype, "receiveShadow"), Pz.prototype), + Bl(Pz.prototype, "lightmapSize", [ nh ], Object.getOwnPropertyDescriptor(Pz.prototype, "lightmapSize"), Pz.prototype), + Pz)) || Dz); + let bH = function(e) { + return t({ + MeshRenderer: e, + ModelComponent: e + }), e; + }((Uz = Ul("cc.MeshRenderer"), Gz = sh(), zz = zl(100), Hz = $l(), jz = Th(Ne), + Xz = lh(), Wz = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 0 + } + }), Yz = Th(Ne), qz = lh(), Kz = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 1 + } + }), Jz = Th(fH), Zz = lh(), Qz = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 2 + } + }), $z = Th(gH), tH = lh(), eH = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 3 + } + }), iH = Th(Ez), sH = lh(), nH = rh(), Uz(rH = Gz(rH = zz(rH = Hz(rH = Ql(rH = (oH = (mH = pH = class extends wS { + get shadowBias() { + return this._shadowBias; + } + set shadowBias(t) { + this._shadowBias = t; + this._updateShadowBias(); + this._onUpdateLocalShadowBias(); + } + get shadowNormalBias() { + return this._shadowNormalBias; + } + set shadowNormalBias(t) { + this._shadowNormalBias = t; + this._updateShadowNormalBias(); + this._onUpdateLocalShadowBias(); + } + get shadowCastingMode() { + return this._shadowCastingMode; + } + set shadowCastingMode(t) { + this._shadowCastingMode = t; + this._updateCastShadow(); + } + get receiveShadow() { + return this._shadowReceivingMode; + } + set receiveShadow(t) { + this._shadowReceivingMode = t; + this._updateReceiveShadow(); + } + get mesh() { + return this._mesh; + } + set mesh(t) { + const e = this._mesh; + const i = this._mesh = t; + null == i || i.initialize(); + this._initSubMeshShapesWeights(); + this._watchMorphInMesh(); + this._onMeshChanged(e); + this._updateModels(); + this.enabledInHierarchy && this._attachToScene(); + this._updateCastShadow(); + this._updateReceiveShadow(); + } + get model() { + return this._model; + } + get enableMorph() { + return this._enableMorph; + } + set enableMorph(t) { + this._enableMorph = t; + } + constructor() { + super(); + Ml(this, "lightmapSettings", aH, this); + Ml(this, "_mesh", lH, this); + Ml(this, "_shadowCastingMode", hH, this); + Ml(this, "_shadowReceivingMode", cH, this); + Ml(this, "_shadowBias", uH, this); + Ml(this, "_shadowNormalBias", _H, this); + this._subMeshShapesWeights = []; + this._modelType = void 0; + this._model = null; + this._morphInstance = null; + Ml(this, "_enableMorph", dH, this); + this._modelType = wA; + } + onLoad() { + this._mesh && this._mesh.initialize(); + this._validateShapeWeights() || this._initSubMeshShapesWeights(); + this._watchMorphInMesh(); + this._updateModels(); + this._updateCastShadow(); + this._updateReceiveShadow(); + this._updateShadowBias(); + this._updateShadowNormalBias(); + } + onRestore() { + this._updateModels(); + this.enabledInHierarchy && this._attachToScene(); + this._updateCastShadow(); + this._updateReceiveShadow(); + this._updateShadowBias(); + this._updateShadowNormalBias(); + } + onEnable() { + super.onEnable(); + this._model || this._updateModels(); + this._updateCastShadow(); + this._updateReceiveShadow(); + this._updateShadowBias(); + this._updateShadowNormalBias(); + this._onUpdateLocalShadowBias(); + this._attachToScene(); + } + onDisable() { + this._model && this._detachFromScene(); + } + onDestroy() { + if (this._model) { + m.director.root.destroyModel(this._model); + this._model = null; + this._models.length = 0; + } + this._morphInstance && this._morphInstance.destroy(); + } + onGeometryChanged() { + if (this._model && this._mesh) { + const t = this._mesh.struct; + this._model.createBoundingShape(t.minPosition, t.maxPosition); + this._model.updateWorldBound(); + this._model.onGeometryChanged(); + } + } + getWeight(t, e) { + const {_subMeshShapesWeights: i} = this; + ne(t < i.length); + const s = this._subMeshShapesWeights[t]; + ne(e < s.length); + return s[e]; + } + setWeights(t, e) { + const {_subMeshShapesWeights: i} = this; + if (e >= i.length) return; + if (i[e].length === t.length) { + i[e] = t.slice(0); + this._uploadSubMeshShapesWeights(e); + } + } + setWeight(t, e, i) { + const {_subMeshShapesWeights: s} = this; + if (e >= s.length) return; + const n = s[e]; + if (!(i >= n.length)) { + n[i] = t; + this._uploadSubMeshShapesWeights(e); + } + } + setInstancedAttribute(t, e) { + this.model && this.model._setInstancedAttribute(t, e); + } + _updateLightmap(t, e, i, s, n) { + this.lightmapSettings.texture = t; + this.lightmapSettings.uvParam.x = e; + this.lightmapSettings.uvParam.y = i; + this.lightmapSettings.uvParam.z = s; + this.lightmapSettings.uvParam.w = n; + this._onUpdateLightingmap(); + } + _updateModels() { + if (!this.enabledInHierarchy) return; + const t = this._model; + if (t) { + t.destroy(); + t.initialize(); + t.node = t.transform = this.node; + } else this._createModel(); + if (this._model) { + if (this._mesh) { + const t = this._mesh.struct; + this._model.createBoundingShape(t.minPosition, t.maxPosition); + } + this._model.initLightingmap(this.lightmapSettings.texture, this.lightmapSettings.uvParam); + this._updateModelParams(); + this._onUpdateLightingmap(); + this._onUpdateLocalShadowBias(); + } + } + _createModel() { + const t = !!this._morphInstance && this._modelType === wA ? Iz : this._modelType; + const e = this._model = m.director.root.createModel(t); + e.visFlags = this.visibility; + e.node = e.transform = this.node; + this._models.length = 0; + this._models.push(this._model); + this._morphInstance && e instanceof Iz && e.setMorphRendering(this._morphInstance); + } + _attachToScene() { + if (!this.node.scene || !this._model) return; + const t = this._getRenderScene(); + null !== this._model.scene && this._detachFromScene(); + t.addModel(this._model); + } + _detachFromScene() { + this._model && this._model.scene && this._model.scene.removeModel(this._model); + } + _updateModelParams() { + if (!this._mesh || !this._model) return; + this.node.hasChangedFlags |= ay.POSITION; + this._model.transform.hasChangedFlags |= ay.POSITION; + this._model.isDynamicBatching = this._isBatchingEnabled(); + const t = this._mesh ? this._mesh.renderingSubMeshes.length : 0; + const e = this._mesh.renderingSubMeshes; + if (e) for (let i = 0; i < t; ++i) { + let t = this.getRenderMaterial(i); + t && !t.isValid && (t = null); + const s = e[i]; + s && this._model.initSubModel(i, s, t || this._getBuiltinMaterial()); + } + this._model.enabled = !0; + } + _onUpdateLightingmap() { + null !== this.model && this.model.updateLightingmap(this.lightmapSettings.texture, this.lightmapSettings.uvParam); + this.setInstancedAttribute("a_lightingMapUVParam", [ this.lightmapSettings.uvParam.x, this.lightmapSettings.uvParam.y, this.lightmapSettings.uvParam.z, this.lightmapSettings.uvParam.w ]); + } + _onUpdateLocalShadowBias() { + null !== this.model && this.model.updateLocalShadowBias(); + this.setInstancedAttribute("a_localShadowBias", [ this._shadowBias, this._shadowNormalBias ]); + } + _onMaterialModified(t, e) { + this._model && this._model.inited && this._onRebuildPSO(t, e || this._getBuiltinMaterial()); + } + _onRebuildPSO(t, e) { + if (this._model && this._model.inited) { + this._model.isDynamicBatching = this._isBatchingEnabled(); + this._model.setSubModelMaterial(t, e); + this._onUpdateLightingmap(); + this._onUpdateLocalShadowBias(); + } + } + _onMeshChanged(t) {} + _clearMaterials() { + if (!this._model) return; + const t = this._model.subModels; + for (let e = 0; e < t.length; ++e) this._onMaterialModified(e, null); + } + _getBuiltinMaterial() { + return xR.get("missing-material"); + } + _onVisibilityChange(t) { + this._model && (this._model.visFlags = t); + } + _updateShadowBias() { + this._model && (this._model.shadowBias = this._shadowBias); + } + _updateShadowNormalBias() { + this._model && (this._model.shadowNormalBias = this._shadowNormalBias); + } + _updateCastShadow() { + if (this._model) if (this._shadowCastingMode === fH.OFF) this._model.castShadow = !1; else { + ne(this._shadowCastingMode === fH.ON, `ShadowCastingMode ${this._shadowCastingMode} is not supported.`); + this._model.castShadow = !0; + } + } + _updateReceiveShadow() { + this._model && (this._shadowReceivingMode === gH.OFF ? this._model.receiveShadow = !1 : this._model.receiveShadow = !0); + } + _isBatchingEnabled() { + for (let t = 0; t < this._materials.length; ++t) { + const e = this._materials[t]; + if (e) for (let t = 0; t < e.passes.length; ++t) { + if (e.passes[t].batchingScheme) return !0; + } + } + return !1; + } + _watchMorphInMesh() { + if (this._morphInstance) { + this._morphInstance.destroy(); + this._morphInstance = null; + } + if (!this._enableMorph) return; + if (!this._mesh || !this._mesh.struct.morph || !this._mesh.morphRendering) return; + this._morphInstance = this._mesh.morphRendering.createInstance(); + const t = this._mesh.struct.primitives.length; + for (let e = 0; e < t; ++e) this._uploadSubMeshShapesWeights(e); + this._model && this._model instanceof Iz && this._model.setMorphRendering(this._morphInstance); + } + _initSubMeshShapesWeights() { + const {_mesh: t} = this; + this._subMeshShapesWeights.length = 0; + if (!t) return; + const e = t.struct.morph; + if (!e) return; + const i = e.weights; + this._subMeshShapesWeights = e.subMeshMorphs.map((t => { + if (t) { + if (t.weights) return t.weights.slice(0); + if (i) { + ne(i.length === t.targets.length); + return i.slice(0); + } + return new Array(t.targets.length).fill(0); + } + return []; + })); + } + _validateShapeWeights() { + const {_mesh: t, _subMeshShapesWeights: e} = this; + if (!t || !t.struct.morph) return 0 === e.length; + const {morph: i} = t.struct; + return i.subMeshMorphs.length === e.length && e.every((({length: t}, e) => { + var s, n; + return (null !== (s = null === (n = i.subMeshMorphs[e]) || void 0 === n ? void 0 : n.targets.length) && void 0 !== s ? s : 0) === t; + })); + } + _uploadSubMeshShapesWeights(t) { + var e; + null === (e = this._morphInstance) || void 0 === e || e.setWeights(t, this._subMeshShapesWeights[t]); + } + }, pH.ShadowCastingMode = fH, pH.ShadowReceivingMode = gH, mH), aH = Bl(oH.prototype, "lightmapSettings", [ Yl, nh, gh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new yH; + } + }), lH = Bl(oH.prototype, "_mesh", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), hH = Bl(oH.prototype, "_shadowCastingMode", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return fH.OFF; + } + }), cH = Bl(oH.prototype, "_shadowReceivingMode", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return gH.ON; + } + }), uH = Bl(oH.prototype, "_shadowBias", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), _H = Bl(oH.prototype, "_shadowNormalBias", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Bl(oH.prototype, "shadowBias", [ jz, Xz, Wz, gh ], Object.getOwnPropertyDescriptor(oH.prototype, "shadowBias"), oH.prototype), + Bl(oH.prototype, "shadowNormalBias", [ Yz, qz, Kz, gh ], Object.getOwnPropertyDescriptor(oH.prototype, "shadowNormalBias"), oH.prototype), + Bl(oH.prototype, "shadowCastingMode", [ Jz, Zz, Qz, gh ], Object.getOwnPropertyDescriptor(oH.prototype, "shadowCastingMode"), oH.prototype), + Bl(oH.prototype, "receiveShadow", [ $z, tH, eH, gh ], Object.getOwnPropertyDescriptor(oH.prototype, "receiveShadow"), oH.prototype), + Bl(oH.prototype, "mesh", [ iH, sH ], Object.getOwnPropertyDescriptor(oH.prototype, "mesh"), oH.prototype), + Bl(oH.prototype, "enableMorph", [ nH, gh ], Object.getOwnPropertyDescriptor(oH.prototype, "enableMorph"), oH.prototype), + dH = Bl(oH.prototype, "_enableMorph", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), oH)) || rH) || rH) || rH) || rH) || rH)); + function SH(t, e) { + const i = t.sharedMaterials.length; + if (i !== e.sharedMaterials.length) return !1; + for (let s = 0; s < i; s++) if (t.getRenderMaterial(s) !== e.getRenderMaterial(s)) return !1; + return !0; + } + t("BatchingUtility", class { + static batchStaticModel(t, e) { + const i = t.getComponentsInChildren(bH); + if (i.length < 2) { + console.error("the number of static models to batch is less than 2,it needn't batch."); + return !1; + } + for (let t = 1; t < i.length; t++) { + if (!i[0].mesh.validateMergingMesh(i[t].mesh)) { + console.error(`the meshes of ${i[0].node.name} and ${i[t].node.name} can't be merged`); + return !1; + } + if (!SH(i[0], i[t])) { + console.error(`the materials of ${i[0].node.name} and ${i[t].node.name} can't be merged`); + return !1; + } + } + const s = new Ez; + const n = new qi; + const r = new qi; + t.getWorldMatrix(r); + qi.invert(r, r); + for (let t = 0; t < i.length; t++) { + const e = i[t]; + e.node.getWorldMatrix(n); + qi.multiply(n, r, n); + s.merge(i[t].mesh, n); + e.enabled = !1; + } + const o = e.addComponent(bH); + o.mesh = s; + o.sharedMaterials = i[0].sharedMaterials; + return !0; + } + static unbatchStaticModel(t, e) { + const i = t.getComponentsInChildren(bH); + for (let t = 0; t < i.length; t++) { + i[t].enabled = !0; + } + const s = e.getComponent(bH); + if (s) { + s.mesh && s.mesh.destroyRenderingMesh(); + s.destroy(); + } + return !0; + } + }); + W(Ez.prototype, "Mesh.prototype", [ { + name: "renderingMesh", + newName: "renderingSubMeshes" + } ]); + Y(Ez.prototype, "Mesh.prototype", [ { + name: "hasFlatBuffers" + }, { + name: "destroyFlatBuffers" + } ]); + const AH = t("Skeleton", jsb.Skeleton); + m.Skeleton = AH; + const TH = AH.prototype; + Object.defineProperty(TH, "bindposes", { + enumerable: !0, + configurable: !0, + get() { + return this._bindposes; + }, + set(t) { + this._bindposes = t; + this._setBindposes(t); + } + }); + TH._ctor = function() { + jsb.Asset.prototype._ctor.apply(this, arguments); + this._bindposes = []; + }; + TH.destroy = function() { + var t, e; + null === (t = null === (e = m.director.root) || void 0 === e ? void 0 : e.dataPoolManager) || void 0 === t || t.releaseSkeleton(this); + return gc.prototype.destroy.call(this); + }; + const vH = TH.onLoaded; + TH.onLoaded = function() { + this._setBindposes(this._bindposes); + vH.call(this); + }; + const EH = AH.prototype; + Th([ Fe ])(EH, "_joints"); + Th([ qi ])(EH, "_bindposes"); + Yl(EH, "_hash"); + Ul("cc.Skeleton")(AH); + Y(bH.prototype, "MeshRenderer.prototype", [ { + name: "enableDynamicBatching" + }, { + name: "recieveShadows" + } ]); + m.ModelComponent = bH; + ee.setClassAlias(bH, "cc.ModelComponent"); + var CH, xH, wH, RH, IH, MH, BH, DH, PH, OH, NH, LH, FH, VH, kH, UH, GH, zH, HH, jH, XH; + const WH = new Pi; + const YH = oe({ + LUMINOUS_FLUX: 0, + LUMINANCE: 1 + }); + let qH = Ul("cc.StaticLightSettings")(CH = (xH = class { + constructor() { + Ml(this, "_baked", wH, this); + Ml(this, "_editorOnly", RH, this); + Ml(this, "_bakeable", IH, this); + Ml(this, "_castShadow", MH, this); + } + get editorOnly() { + return this._editorOnly; + } + set editorOnly(t) { + this._editorOnly = t; + } + get baked() { + return this._baked; + } + set baked(t) { + this._baked = t; + } + get bakeable() { + return this._bakeable; + } + set bakeable(t) { + this._bakeable = t; + } + get castShadow() { + return this._castShadow; + } + set castShadow(t) { + this._castShadow = t; + } + }, wH = Bl(xH.prototype, "_baked", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), RH = Bl(xH.prototype, "_editorOnly", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), IH = Bl(xH.prototype, "_bakeable", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), MH = Bl(xH.prototype, "_castShadow", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Bl(xH.prototype, "editorOnly", [ nh ], Object.getOwnPropertyDescriptor(xH.prototype, "editorOnly"), xH.prototype), + Bl(xH.prototype, "bakeable", [ nh ], Object.getOwnPropertyDescriptor(xH.prototype, "bakeable"), xH.prototype), + Bl(xH.prototype, "castShadow", [ nh ], Object.getOwnPropertyDescriptor(xH.prototype, "castShadow"), xH.prototype), + xH)) || CH; + let KH = function(e) { + return t({ + Light: e, + LightComponent: e + }), e; + }((BH = Ul("cc.Light"), DH = lh(), PH = lh(), OH = hh(), NH = lh(), LH = Th(qH), + FH = ph(), BH(VH = (kH = (XH = jH = class extends Qc { + get color() { + return this._color; + } + set color(t) { + this._color = t; + if (this._light) { + WH.x = t.r / 255; + WH.y = t.g / 255; + WH.z = t.b / 255; + this._light.color = WH; + } + } + get useColorTemperature() { + return this._useColorTemperature; + } + set useColorTemperature(t) { + this._useColorTemperature = t; + this._light && (this._light.useColorTemperature = t); + } + get colorTemperature() { + return this._colorTemperature; + } + set colorTemperature(t) { + this._colorTemperature = t; + this._light && (this._light.colorTemperature = t); + } + get staticSettings() { + return this._staticSettings; + } + set staticSettings(t) { + this._staticSettings = t; + } + get type() { + return this._type; + } + get baked() { + return this.staticSettings.baked; + } + set baked(t) { + this.staticSettings.baked = t; + null !== this._light && (this._light.baked = t); + } + constructor() { + super(); + Ml(this, "_color", UH, this); + Ml(this, "_useColorTemperature", GH, this); + Ml(this, "_colorTemperature", zH, this); + Ml(this, "_staticSettings", HH, this); + this._type = BA.UNKNOWN; + this._lightType = void 0; + this._light = null; + this._lightType = PA; + } + onLoad() { + this._createLight(); + } + onEnable() { + this._attachToScene(); + } + onDisable() { + this._detachFromScene(); + } + onDestroy() { + this._destroyLight(); + } + _createLight() { + this._light || (this._light = m.director.root.createLight(this._lightType)); + this.color = this._color; + this.useColorTemperature = this._useColorTemperature; + this.colorTemperature = this._colorTemperature; + this._light.node = this.node; + this._light.baked = this.baked; + } + _destroyLight() { + if (this._light) { + m.director.root.recycleLight(this._light); + this._light = null; + } + } + _attachToScene() { + this._detachFromScene(); + if (this._light && !this._light.scene && this.node.scene) { + const t = this._getRenderScene(); + switch (this._type) { + case BA.DIRECTIONAL: + t.addDirectionalLight(this._light); + t.setMainLight(this._light); + break; + + case BA.SPHERE: + t.addSphereLight(this._light); + break; + + case BA.SPOT: + t.addSpotLight(this._light); + } + } + } + _detachFromScene() { + if (this._light && this._light.scene) { + const t = this._light.scene; + switch (this._type) { + case BA.DIRECTIONAL: + t.removeDirectionalLight(this._light); + t.unsetMainLight(this._light); + break; + + case BA.SPHERE: + t.removeSphereLight(this._light); + break; + + case BA.SPOT: + t.removeSpotLight(this._light); + } + } + } + }, jH.Type = BA, jH.PhotometricTerm = YH, XH), UH = Bl(kH.prototype, "_color", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Bi.WHITE.clone(); + } + }), GH = Bl(kH.prototype, "_useColorTemperature", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), zH = Bl(kH.prototype, "_colorTemperature", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 6550; + } + }), HH = Bl(kH.prototype, "_staticSettings", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new qH; + } + }), Bl(kH.prototype, "color", [ DH ], Object.getOwnPropertyDescriptor(kH.prototype, "color"), kH.prototype), + Bl(kH.prototype, "useColorTemperature", [ PH ], Object.getOwnPropertyDescriptor(kH.prototype, "useColorTemperature"), kH.prototype), + Bl(kH.prototype, "colorTemperature", [ dh, OH, NH ], Object.getOwnPropertyDescriptor(kH.prototype, "colorTemperature"), kH.prototype), + Bl(kH.prototype, "staticSettings", [ LH, FH ], Object.getOwnPropertyDescriptor(kH.prototype, "staticSettings"), kH.prototype), + kH)) || VH)); + var JH, ZH, QH, $H, tj, ej, ij, sj, nj, rj, oj, aj, lj, hj, cj, uj, _j, dj, pj, mj, fj, gj, yj, bj, Sj, Aj, Tj, vj, Ej, Cj, xj, wj, Rj, Ij, Mj, Bj, Dj, Pj, Oj, Nj, Lj, Fj, Vj, kj, Uj, Gj, zj, Hj, jj, Xj, Wj, Yj, qj, Kj, Jj, Zj, Qj, $j, tX, eX, iX, sX, nX, rX, oX, aX, lX, hX, cX, uX, _X, dX, pX, mX, fX, gX, yX, bX; + let SX = function(e) { + return t({ + DirectionalLight: e, + DirectionalLightComponent: e + }), e; + }((JH = Ul("cc.DirectionalLight"), ZH = sh(), QH = $l(), $H = ql("_illuminance"), + tj = lh(), ej = rh(), ij = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 1 + } + }), sj = Th(Le), nj = rh(), rj = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 5 + } + }), oj = Th(zA), aj = rh(), lj = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 6 + } + }), hj = Th(Ne), cj = rh(), uj = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 7 + } + }), _j = Th(Ne), dj = rh(), pj = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 8 + } + }), mj = hh(), fj = Th(Ne), gj = rh(), yj = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 9 + } + }), bj = lh(), Sj = hh(), Aj = Th(Ne), Tj = rh(), vj = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 10 + } + }), Ej = lh(), Cj = hh(), xj = Th(Ne), wj = rh(), Rj = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 11 + } + }), Ij = lh(), Mj = Th(HA), Bj = rh(), Dj = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 12 + } + }), Pj = lh(), Oj = Th(Le), Nj = rh(), Lj = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 13 + } + }), Fj = lh(), Vj = hh(), kj = Th(Ne), Uj = rh(), Gj = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 14 + } + }), zj = lh(), Hj = Th(jA), jj = rh(), Xj = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 15 + } + }), Wj = Th(Le), Yj = rh(), qj = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 16 + } + }), Kj = Th(Ne), Jj = rh(), Zj = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 17 + } + }), Qj = Th(Ne), $j = rh(), tX = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 18 + } + }), eX = Th(Ne), JH(iX = ZH(iX = QH(iX = Ql(iX = (sX = class extends KH { + get illuminance() { + return m.director.root.pipeline.pipelineSceneData.isHDR ? this._illuminanceHDR : this._illuminanceLDR; + } + set illuminance(t) { + if (m.director.root.pipeline.pipelineSceneData.isHDR) { + this._illuminanceHDR = t; + this._light && (this._light.illuminanceHDR = this._illuminanceHDR); + } else { + this._illuminanceLDR = t; + this._light && (this._light.illuminanceLDR = this._illuminanceLDR); + } + } + get shadowEnabled() { + return this._shadowEnabled; + } + set shadowEnabled(t) { + this._shadowEnabled = t; + this._light && (this._light.shadowEnabled = this._shadowEnabled); + } + get shadowPcf() { + return this._shadowPcf; + } + set shadowPcf(t) { + this._shadowPcf = t; + this._light && (this._light.shadowPcf = this._shadowPcf); + } + get shadowBias() { + return this._shadowBias; + } + set shadowBias(t) { + this._shadowBias = t; + this._light && (this._light.shadowBias = this._shadowBias); + } + get shadowNormalBias() { + return this._shadowNormalBias; + } + set shadowNormalBias(t) { + this._shadowNormalBias = t; + this._light && (this._light.shadowNormalBias = this._shadowNormalBias); + } + get shadowSaturation() { + return this._shadowSaturation; + } + set shadowSaturation(t) { + this._shadowSaturation = _i(t, 0, 1); + this._light && (this._light.shadowSaturation = this._shadowSaturation); + } + get shadowDistance() { + return this._shadowDistance; + } + set shadowDistance(t) { + this._shadowDistance = Math.min(t, YA.MAX_FAR); + this._shadowDistance / .1 < 10 && N(15003, this._shadowDistance); + if (this._light) { + this._light.shadowDistance = this._shadowDistance; + this._light.csmNeedUpdate = !0; + } + } + get shadowInvisibleOcclusionRange() { + return this._shadowInvisibleOcclusionRange; + } + set shadowInvisibleOcclusionRange(t) { + this._shadowInvisibleOcclusionRange = Math.min(t, YA.MAX_FAR); + this._light && (this._light.shadowInvisibleOcclusionRange = this._shadowInvisibleOcclusionRange); + } + get csmLevel() { + return this._csmLevel; + } + set csmLevel(t) { + this._csmLevel = t; + if (this._light) { + this._light.csmLevel = this._csmLevel; + this._light.csmNeedUpdate = !0; + } + } + get enableCSM() { + return this._csmLevel > HA.LEVEL_1; + } + set enableCSM(t) { + this._csmLevel = t ? HA.LEVEL_4 : HA.LEVEL_1; + if (this._light) { + this._light.csmLevel = this._csmLevel; + this._light.csmNeedUpdate = !0; + } + } + get csmLayerLambda() { + return this._csmLayerLambda; + } + set csmLayerLambda(t) { + this._csmLayerLambda = t; + if (this._light) { + this._light.csmLayerLambda = this._csmLayerLambda; + this._light.csmNeedUpdate = !0; + } + } + get csmOptimizationMode() { + return this._csmOptimizationMode; + } + set csmOptimizationMode(t) { + this._csmOptimizationMode = t; + this._light && (this._light.csmOptimizationMode = this._csmOptimizationMode); + } + get shadowFixedArea() { + return this._shadowFixedArea; + } + set shadowFixedArea(t) { + this._shadowFixedArea = t; + this._light && (this._light.shadowFixedArea = this._shadowFixedArea); + } + get shadowNear() { + return this._shadowNear; + } + set shadowNear(t) { + this._shadowNear = t; + this._light && (this._light.shadowNear = this._shadowNear); + } + get shadowFar() { + return this._shadowFar; + } + set shadowFar(t) { + this._shadowFar = Math.min(t, YA.MAX_FAR); + this._light && (this._light.shadowFar = this._shadowFar); + } + get shadowOrthoSize() { + return this._shadowOrthoSize; + } + set shadowOrthoSize(t) { + this._shadowOrthoSize = t; + this._light && (this._light.shadowOrthoSize = this._shadowOrthoSize); + } + constructor() { + super(); + Ml(this, "_illuminanceHDR", nX, this); + Ml(this, "_illuminanceLDR", rX, this); + Ml(this, "_shadowEnabled", oX, this); + Ml(this, "_shadowPcf", aX, this); + Ml(this, "_shadowBias", lX, this); + Ml(this, "_shadowNormalBias", hX, this); + Ml(this, "_shadowSaturation", cX, this); + Ml(this, "_shadowDistance", uX, this); + Ml(this, "_shadowInvisibleOcclusionRange", _X, this); + Ml(this, "_csmLevel", dX, this); + Ml(this, "_csmLayerLambda", pX, this); + Ml(this, "_csmOptimizationMode", mX, this); + Ml(this, "_shadowFixedArea", fX, this); + Ml(this, "_shadowNear", gX, this); + Ml(this, "_shadowFar", yX, this); + Ml(this, "_shadowOrthoSize", bX, this); + this._type = BA.DIRECTIONAL; + this._light = null; + this._lightType = OA; + } + _createLight() { + super._createLight(); + if (this._light) { + this._light.illuminanceHDR = this._illuminanceHDR; + this._light.illuminanceLDR = this._illuminanceLDR; + this._light.shadowEnabled = this._shadowEnabled; + this._light.shadowPcf = this._shadowPcf; + this._light.shadowBias = this._shadowBias; + this._light.shadowNormalBias = this._shadowNormalBias; + this._light.shadowSaturation = this._shadowSaturation; + this._light.shadowDistance = this._shadowDistance; + this._light.shadowInvisibleOcclusionRange = this._shadowInvisibleOcclusionRange; + this._light.shadowFixedArea = this._shadowFixedArea; + this._light.shadowNear = this._shadowNear; + this._light.shadowFar = this._shadowFar; + this._light.shadowOrthoSize = this._shadowOrthoSize; + this._light.csmLevel = this._csmLevel; + this._light.csmLayerLambda = this._csmLayerLambda; + this._light.csmOptimizationMode = this._csmOptimizationMode; + } + } + }, nX = Bl(sX.prototype, "_illuminanceHDR", [ jl, $H ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 65e3; + } + }), rX = Bl(sX.prototype, "_illuminanceLDR", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 65e3 * By.standardExposureValue; + } + }), oX = Bl(sX.prototype, "_shadowEnabled", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), aX = Bl(sX.prototype, "_shadowPcf", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return zA.HARD; + } + }), lX = Bl(sX.prototype, "_shadowBias", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1e-5; + } + }), hX = Bl(sX.prototype, "_shadowNormalBias", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), cX = Bl(sX.prototype, "_shadowSaturation", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), uX = Bl(sX.prototype, "_shadowDistance", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 50; + } + }), _X = Bl(sX.prototype, "_shadowInvisibleOcclusionRange", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 200; + } + }), dX = Bl(sX.prototype, "_csmLevel", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return HA.LEVEL_4; + } + }), pX = Bl(sX.prototype, "_csmLayerLambda", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .75; + } + }), mX = Bl(sX.prototype, "_csmOptimizationMode", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return jA.RemoveDuplicates; + } + }), fX = Bl(sX.prototype, "_shadowFixedArea", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), gX = Bl(sX.prototype, "_shadowNear", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .1; + } + }), yX = Bl(sX.prototype, "_shadowFar", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 10; + } + }), bX = Bl(sX.prototype, "_shadowOrthoSize", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 5; + } + }), Bl(sX.prototype, "illuminance", [ tj ], Object.getOwnPropertyDescriptor(sX.prototype, "illuminance"), sX.prototype), + Bl(sX.prototype, "shadowEnabled", [ ej, ij, nh, sj ], Object.getOwnPropertyDescriptor(sX.prototype, "shadowEnabled"), sX.prototype), + Bl(sX.prototype, "shadowPcf", [ nj, rj, nh, oj ], Object.getOwnPropertyDescriptor(sX.prototype, "shadowPcf"), sX.prototype), + Bl(sX.prototype, "shadowBias", [ aj, lj, nh, hj ], Object.getOwnPropertyDescriptor(sX.prototype, "shadowBias"), sX.prototype), + Bl(sX.prototype, "shadowNormalBias", [ cj, uj, nh, _j ], Object.getOwnPropertyDescriptor(sX.prototype, "shadowNormalBias"), sX.prototype), + Bl(sX.prototype, "shadowSaturation", [ dj, pj, nh, mj, dh, fj ], Object.getOwnPropertyDescriptor(sX.prototype, "shadowSaturation"), sX.prototype), + Bl(sX.prototype, "shadowDistance", [ gj, yj, nh, bj, Sj, dh, Aj ], Object.getOwnPropertyDescriptor(sX.prototype, "shadowDistance"), sX.prototype), + Bl(sX.prototype, "shadowInvisibleOcclusionRange", [ Tj, vj, nh, Ej, Cj, dh, xj ], Object.getOwnPropertyDescriptor(sX.prototype, "shadowInvisibleOcclusionRange"), sX.prototype), + Bl(sX.prototype, "csmLevel", [ wj, Rj, nh, Ij, dh, Mj ], Object.getOwnPropertyDescriptor(sX.prototype, "csmLevel"), sX.prototype), + Bl(sX.prototype, "enableCSM", [ Bj, Dj, nh, Pj, dh, Oj ], Object.getOwnPropertyDescriptor(sX.prototype, "enableCSM"), sX.prototype), + Bl(sX.prototype, "csmLayerLambda", [ Nj, Lj, nh, Fj, Vj, dh, kj ], Object.getOwnPropertyDescriptor(sX.prototype, "csmLayerLambda"), sX.prototype), + Bl(sX.prototype, "csmOptimizationMode", [ Uj, Gj, nh, zj, dh, Hj ], Object.getOwnPropertyDescriptor(sX.prototype, "csmOptimizationMode"), sX.prototype), + Bl(sX.prototype, "shadowFixedArea", [ jj, Xj, nh, Wj ], Object.getOwnPropertyDescriptor(sX.prototype, "shadowFixedArea"), sX.prototype), + Bl(sX.prototype, "shadowNear", [ Yj, qj, nh, Kj ], Object.getOwnPropertyDescriptor(sX.prototype, "shadowNear"), sX.prototype), + Bl(sX.prototype, "shadowFar", [ Jj, Zj, nh, Qj ], Object.getOwnPropertyDescriptor(sX.prototype, "shadowFar"), sX.prototype), + Bl(sX.prototype, "shadowOrthoSize", [ $j, tX, eX ], Object.getOwnPropertyDescriptor(sX.prototype, "shadowOrthoSize"), sX.prototype), + sX)) || iX) || iX) || iX) || iX)); + var AX, TX, vX, EX, CX, xX, wX, RX, IX, MX, BX, DX, PX, OX, NX, LX, FX, VX, kX, UX; + let GX = function(e) { + return t({ + SphereLight: e, + SphereLightComponent: e + }), e; + }((AX = Ul("cc.SphereLight"), TX = sh(), vX = $l(), EX = ql("_luminance"), CX = ph(), + xX = lh(), wX = ph(), RX = lh(), IX = Th(YH), MX = ph(), BX = lh(), DX = lh(), PX = lh(), + AX(OX = TX(OX = vX(OX = Ql(OX = (NX = class extends KH { + get luminousFlux() { + return m.director.root.pipeline.pipelineSceneData.isHDR ? this._luminanceHDR * DA(this._size) : this._luminanceLDR; + } + set luminousFlux(t) { + let e = 0; + if (m.director.root.pipeline.pipelineSceneData.isHDR) { + this._luminanceHDR = t / DA(this._size); + e = this._luminanceHDR; + } else { + this._luminanceLDR = t; + e = this._luminanceLDR; + } + this._light && (this._light.luminance = e); + } + get luminance() { + return m.director.root.pipeline.pipelineSceneData.isHDR ? this._luminanceHDR : this._luminanceLDR; + } + set luminance(t) { + if (m.director.root.pipeline.pipelineSceneData.isHDR) { + this._luminanceHDR = t; + this._light && (this._light.luminanceHDR = this._luminanceHDR); + } else { + this._luminanceLDR = t; + this._light && (this._light.luminanceLDR = this._luminanceLDR); + } + } + get term() { + return this._term; + } + set term(t) { + this._term = t; + } + get size() { + return this._size; + } + set size(t) { + this._size = t; + this._light && (this._light.size = t); + } + get range() { + return this._range; + } + set range(t) { + this._range = t; + this._light && (this._light.range = t); + } + constructor() { + super(); + Ml(this, "_size", LX, this); + Ml(this, "_luminanceHDR", FX, this); + Ml(this, "_luminanceLDR", VX, this); + Ml(this, "_term", kX, this); + Ml(this, "_range", UX, this); + this._type = BA.SPHERE; + this._light = null; + this._lightType = LA; + } + _createLight() { + super._createLight(); + this.size = this._size; + this.range = this._range; + if (this._light) { + this._light.luminanceHDR = this._luminanceHDR; + this._light.luminanceLDR = this._luminanceLDR; + } + } + }, LX = Bl(NX.prototype, "_size", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .15; + } + }), FX = Bl(NX.prototype, "_luminanceHDR", [ Yl, EX ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1700 / DA(.15); + } + }), VX = Bl(NX.prototype, "_luminanceLDR", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1700 / DA(.15) * By.standardExposureValue * By.standardLightMeterScale; + } + }), kX = Bl(NX.prototype, "_term", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return YH.LUMINOUS_FLUX; + } + }), UX = Bl(NX.prototype, "_range", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), Bl(NX.prototype, "luminousFlux", [ CX, xX ], Object.getOwnPropertyDescriptor(NX.prototype, "luminousFlux"), NX.prototype), + Bl(NX.prototype, "luminance", [ wX, RX ], Object.getOwnPropertyDescriptor(NX.prototype, "luminance"), NX.prototype), + Bl(NX.prototype, "term", [ IX, MX, BX ], Object.getOwnPropertyDescriptor(NX.prototype, "term"), NX.prototype), + Bl(NX.prototype, "size", [ DX ], Object.getOwnPropertyDescriptor(NX.prototype, "size"), NX.prototype), + Bl(NX.prototype, "range", [ PX ], Object.getOwnPropertyDescriptor(NX.prototype, "range"), NX.prototype), + NX)) || OX) || OX) || OX) || OX)); + var zX, HX, jX, XX, WX, YX, qX, KX, JX, ZX, QX, $X, tW, eW, iW, sW, nW, rW, oW, aW, lW, hW, cW, uW, _W, dW, pW, mW, fW, gW, yW, bW, SW, AW, TW, vW, EW, CW, xW; + let wW = function(e) { + return t({ + SpotLight: e, + SpotLightComponent: e + }), e; + }((zX = Ul("cc.SpotLight"), HX = sh(), jX = $l(), XX = ql("_luminance"), WX = lh(), + YX = ph(), qX = lh(), KX = ph(), JX = Th(YH), ZX = ph(), QX = lh(), $X = lh(), tW = lh(), + eW = hh(), iW = lh(), sW = rh(), nW = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 1 + } + }), rW = Th(Le), oW = rh(), aW = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 2 + } + }), lW = Th(zA), hW = rh(), cW = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 3 + } + }), uW = Th(Ne), _W = rh(), dW = jl({ + group: { + name: "DynamicShadowSettings", + displayOrder: 4 + } + }), pW = Th(Ne), zX(mW = HX(mW = jX(mW = Ql(mW = (fW = class extends KH { + get luminousFlux() { + return m.director.root.pipeline.pipelineSceneData.isHDR ? this._luminanceHDR * DA(this._size) : this._luminanceLDR; + } + set luminousFlux(t) { + let e = 0; + if (m.director.root.pipeline.pipelineSceneData.isHDR) { + this._luminanceHDR = t / DA(this._size); + e = this._luminanceHDR; + } else { + this._luminanceLDR = t; + e = this._luminanceLDR; + } + this._light && (this._light.luminance = e); + } + get luminance() { + return m.director.root.pipeline.pipelineSceneData.isHDR ? this._luminanceHDR : this._luminanceLDR; + } + set luminance(t) { + if (m.director.root.pipeline.pipelineSceneData.isHDR) { + this._luminanceHDR = t; + this._light && (this._light.luminanceHDR = this._luminanceHDR); + } else { + this._luminanceLDR = t; + this._light && (this._light.luminanceLDR = this._luminanceLDR); + } + } + get term() { + return this._term; + } + set term(t) { + this._term = t; + } + get size() { + return this._size; + } + set size(t) { + this._size = t; + this._light && (this._light.size = t); + } + get range() { + return this._range; + } + set range(t) { + this._range = t; + this._light && (this._light.range = t); + } + get spotAngle() { + return this._spotAngle; + } + set spotAngle(t) { + this._spotAngle = t; + this._light && (this._light.spotAngle = mi(t)); + } + get shadowEnabled() { + return this._shadowEnabled; + } + set shadowEnabled(t) { + this._shadowEnabled = t; + this._light && (this._light.shadowEnabled = t); + } + get shadowPcf() { + return this._shadowPcf; + } + set shadowPcf(t) { + this._shadowPcf = t; + this._light && (this._light.shadowPcf = t); + } + get shadowBias() { + return this._shadowBias; + } + set shadowBias(t) { + this._shadowBias = t; + this._light && (this._light.shadowBias = t); + } + get shadowNormalBias() { + return this._shadowNormalBias; + } + set shadowNormalBias(t) { + this._shadowNormalBias = t; + this._light && (this._light.shadowNormalBias = t); + } + constructor() { + super(); + Ml(this, "_size", gW, this); + Ml(this, "_luminanceHDR", yW, this); + Ml(this, "_luminanceLDR", bW, this); + Ml(this, "_term", SW, this); + Ml(this, "_range", AW, this); + Ml(this, "_spotAngle", TW, this); + Ml(this, "_shadowEnabled", vW, this); + Ml(this, "_shadowPcf", EW, this); + Ml(this, "_shadowBias", CW, this); + Ml(this, "_shadowNormalBias", xW, this); + this._type = BA.SPOT; + this._light = null; + this._lightType = NA; + } + _createLight() { + super._createLight(); + this.size = this._size; + this.range = this._range; + this.spotAngle = this._spotAngle; + if (this._light) { + this._light.luminanceHDR = this._luminanceHDR; + this._light.luminanceLDR = this._luminanceLDR; + this._light.shadowEnabled = this._shadowEnabled; + this._light.shadowPcf = this._shadowPcf; + this._light.shadowBias = this._shadowBias; + this._light.shadowNormalBias = this._shadowNormalBias; + } + } + }, gW = Bl(fW.prototype, "_size", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .15; + } + }), yW = Bl(fW.prototype, "_luminanceHDR", [ Yl, XX ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1700 / DA(.15); + } + }), bW = Bl(fW.prototype, "_luminanceLDR", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1700 / DA(.15) * By.standardExposureValue * By.standardLightMeterScale; + } + }), SW = Bl(fW.prototype, "_term", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return YH.LUMINOUS_FLUX; + } + }), AW = Bl(fW.prototype, "_range", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), TW = Bl(fW.prototype, "_spotAngle", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 60; + } + }), vW = Bl(fW.prototype, "_shadowEnabled", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), EW = Bl(fW.prototype, "_shadowPcf", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return zA.HARD; + } + }), CW = Bl(fW.prototype, "_shadowBias", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1e-5; + } + }), xW = Bl(fW.prototype, "_shadowNormalBias", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Bl(fW.prototype, "luminousFlux", [ WX, YX ], Object.getOwnPropertyDescriptor(fW.prototype, "luminousFlux"), fW.prototype), + Bl(fW.prototype, "luminance", [ qX, KX ], Object.getOwnPropertyDescriptor(fW.prototype, "luminance"), fW.prototype), + Bl(fW.prototype, "term", [ JX, ZX, QX ], Object.getOwnPropertyDescriptor(fW.prototype, "term"), fW.prototype), + Bl(fW.prototype, "size", [ $X ], Object.getOwnPropertyDescriptor(fW.prototype, "size"), fW.prototype), + Bl(fW.prototype, "range", [ tW ], Object.getOwnPropertyDescriptor(fW.prototype, "range"), fW.prototype), + Bl(fW.prototype, "spotAngle", [ dh, eW, iW ], Object.getOwnPropertyDescriptor(fW.prototype, "spotAngle"), fW.prototype), + Bl(fW.prototype, "shadowEnabled", [ sW, nW, nh, rW ], Object.getOwnPropertyDescriptor(fW.prototype, "shadowEnabled"), fW.prototype), + Bl(fW.prototype, "shadowPcf", [ oW, aW, nh, lW ], Object.getOwnPropertyDescriptor(fW.prototype, "shadowPcf"), fW.prototype), + Bl(fW.prototype, "shadowBias", [ hW, cW, nh, uW ], Object.getOwnPropertyDescriptor(fW.prototype, "shadowBias"), fW.prototype), + Bl(fW.prototype, "shadowNormalBias", [ _W, dW, nh, pW ], Object.getOwnPropertyDescriptor(fW.prototype, "shadowNormalBias"), fW.prototype), + fW)) || mW) || mW) || mW) || mW)); + m.LightComponent = KH; + ee.setClassAlias(KH, "cc.LightComponent"); + m.DirectionalLightComponent = SX; + ee.setClassAlias(SX, "cc.DirectionalLightComponent"); + m.SphereLightComponent = GX; + ee.setClassAlias(GX, "cc.SphereLightComponent"); + m.SpotLightComponent = wW; + ee.setClassAlias(wW, "cc.SpotLightComponent"); + W(wW.prototype, "SpotLight.prototype", [ { + name: "luminousPower", + newName: "luminousFlux", + customGetter() { + return this.luminousFlux; + }, + customSetter(t) { + this.luminousFlux = t; + } + } ]); + W(GX.prototype, "SphereLight.prototype", [ { + name: "luminousPower", + newName: "luminousFlux", + customGetter() { + return this.luminousFlux; + }, + customSetter(t) { + this.luminousFlux = t; + } + } ]); + W(KH.PhotometricTerm, "Light.PhotometricTerm", [ { + name: "LUMINOUS_POWER", + newName: "LUMINOUS_FLUX" + } ]); + const RW = jsb.SkinningModel; + m.SkinningModel = jsb.SkinningModel; + const IW = jsb.BakedSkinningModel; + m.BakedSkinningModel = jsb.BakedSkinningModel; + jsb.MorphModel; + const MW = IW.prototype; + MW._ctor = function() { + jsb.Model.prototype._ctor.call(this); + this.uploadedAnim = void 0; + this._dataPoolManager = m.director.root.dataPoolManager; + const t = new Float32Array(4); + const e = this._dataPoolManager.jointAnimationInfo.getData(); + this._jointsMedium = { + buffer: null, + jointTextureInfo: t, + animInfo: e, + texture: null, + boundsInfo: null + }; + this._skeleton = null; + this._mesh = null; + }; + const BW = MW.destroy; + MW.destroy = function() { + this.uploadedAnim = void 0; + this._jointsMedium.boundsInfo = null; + this._applyJointTexture(); + BW.call(this); + }; + const DW = MW.bindSkeleton; + MW.bindSkeleton = function(t = null, e = null, i = null) { + this._skeleton = t; + this._mesh = i; + if (!t || !e || !i) return; + this.transform = e; + const s = this._dataPoolManager; + this._jointsMedium.animInfo = s.jointAnimationInfo.getData(e.uuid); + const n = this._jointsMedium.animInfo; + this.syncAnimInfoForJS(n.buffer, n.data, n.dirtyForJSB); + DW.apply(this, arguments); + }; + MW.uploadAnimation = function(t) { + var e; + if (!this._skeleton || !this._mesh || this.uploadedAnim === t) return; + this.uploadedAnim = t; + this.setUploadedAnimForJS(!!t); + const i = this._dataPoolManager; + let s = null; + let n = null; + if (t) { + s = i.jointTexturePool.getSequencePoseTexture(this._skeleton, t, this._mesh, this.transform); + this._jointsMedium.boundsInfo = s && s.bounds.get(this._mesh.hash); + n = null; + } else { + s = i.jointTexturePool.getDefaultPoseTexture(this._skeleton, this._mesh, this.transform); + this._jointsMedium.boundsInfo = null; + n = s && s.bounds.get(this._mesh.hash)[0]; + } + this._applyJointTexture(s); + const {jointTextureInfo: r} = this._jointsMedium; + const o = null === (e = s) || void 0 === e ? void 0 : e.handle.texture; + this.syncDataForJS(this._jointsMedium.boundsInfo, n, r[0], r[1], r[2], r[3], o, this._jointsMedium.animInfo.data); + }; + MW._applyJointTexture = function(t = null) { + const e = this._jointsMedium.texture; + e && e !== t && this._dataPoolManager.jointTexturePool.releaseHandle(e); + this._jointsMedium.texture = t; + if (!t) return; + const {jointTextureInfo: i} = this._jointsMedium; + i[0] = t.handle.texture.width; + i[1] = this._skeleton.joints.length; + i[2] = t.pixelOffset + .1; + i[3] = 1 / i[0]; + }; + var PW, OW, NW, LW, FW, VW, kW, UW, GW, zW, HW, jW, XW, WW; + let YW = function(e) { + return t({ + SkinnedMeshRenderer: e, + SkinningModelComponent: e + }), e; + }((PW = Ul("cc.SkinnedMeshRenderer"), OW = sh(), NW = zl(100), LW = $l(), FW = Th(AH), + VW = Th(_y), kW = Th(AH), UW = Th(_y), GW = lh(), PW(zW = OW(zW = NW(zW = Ql(zW = LW(zW = (HW = (WW = class extends bH { + get skeleton() { + return this._skeleton; + } + set skeleton(t) { + if (t !== this._skeleton) { + this._skeleton = t; + this._update(); + } + } + get skinningRoot() { + return this._skinningRoot; + } + set skinningRoot(t) { + this._skinningRoot = t; + this._tryBindAnimation(); + t !== this._skinningRoot && this._update(); + } + get model() { + return this._model; + } + constructor() { + super(); + Ml(this, "_skeleton", jW, this); + Ml(this, "_skinningRoot", XW, this); + this._clip = null; + this.associatedAnimation = null; + this._modelType = IW; + } + onLoad() { + super.onLoad(); + this._tryBindAnimation(); + } + onDestroy() { + if (this.associatedAnimation) { + this.associatedAnimation.notifySkinnedMeshRemoved(this); + ne(null === this.associatedAnimation); + } + super.onDestroy(); + } + uploadAnimation(t) { + this._clip = t; + this.model && this.model.uploadAnimation && this.model.uploadAnimation(t); + } + setUseBakedAnimation(t = !0, e = !1) { + const i = t ? IW : RW; + if (e || this._modelType !== i) { + this._modelType = i; + if (this._model) { + m.director.root.destroyModel(this._model); + this._model = null; + this._models.length = 0; + this._updateModels(); + this._updateCastShadow(); + this._updateReceiveShadow(); + this.enabledInHierarchy && this._attachToScene(); + } + } + } + setMaterial(t, e) { + super.setMaterial(t, e); + this._modelType === RW && this.getMaterialInstance(e); + } + _updateModelParams() { + this._update(); + super._updateModelParams(); + } + _tryBindAnimation() { + const {_skinningRoot: t} = this; + if (!t) return; + let e = !1; + for (let i = this.node; i; i = i.parent) if (i === t) { + e = !0; + break; + } + if (!e) return; + const i = t.getComponent("cc.SkeletalAnimation"); + i ? i.notifySkinnedMeshAdded(this) : this.setUseBakedAnimation(!1); + } + _update() { + if (this.model) { + this.model.bindSkeleton(this._skeleton, this._skinningRoot, this._mesh); + this.model.uploadAnimation && this.model.uploadAnimation(this._clip); + } + } + }, WW), jW = Bl(HW.prototype, "_skeleton", [ FW ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), XW = Bl(HW.prototype, "_skinningRoot", [ VW ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Bl(HW.prototype, "skeleton", [ kW ], Object.getOwnPropertyDescriptor(HW.prototype, "skeleton"), HW.prototype), + Bl(HW.prototype, "skinningRoot", [ UW, GW ], Object.getOwnPropertyDescriptor(HW.prototype, "skinningRoot"), HW.prototype), + HW)) || zW) || zW) || zW) || zW) || zW)); + const qW = new qi; + function KW(t, e, i) { + qi.identity(i); + for (;t !== e; ) { + qi.fromRTS(qW, t.rotation, t.position, t.scale); + qi.multiply(i, qW, i); + t = t.parent; + } + return i; + } + var JW, ZW, QW, $W, tY, eY, iY, sY, nY, rY, oY, aY, lY, hY, cY, uY, _Y, dY, pY, mY, fY, gY, yY, bY, SY, AY, TY, vY, EY, CY, xY; + const wY = new Vn(cr.ATTR_BATCH_ID, bs.R32F); + const RY = new Vn(cr.ATTR_BATCH_UV, bs.RG32F); + const IY = ur[wY.format].size + ur[RY.format].size; + let MY = function(e) { + return t({ + SkinnedMeshUnit: e, + SkinningModelUnit: e + }), e; + }((JW = Ul("cc.SkinnedMeshUnit"), ZW = Th(Ez), QW = Th(AH), $W = Th(hm), tY = Th(YW), + JW(eY = (iY = (hY = class { + constructor() { + Ml(this, "mesh", sY, this); + Ml(this, "skeleton", nY, this); + Ml(this, "material", rY, this); + Ml(this, "_localTransform", oY, this); + Ml(this, "_offset", aY, this); + Ml(this, "_size", lY, this); + } + set offset(t) { + Qi.copy(this._offset, t); + } + get offset() { + return this._offset; + } + set size(t) { + Qi.copy(this._size, t); + } + get size() { + return this._size; + } + set copyFrom(t) { + if (t) { + this.mesh = t.mesh; + this.skeleton = t.skeleton; + this.material = t.getMaterial(0); + t.skinningRoot && KW(t.node, t.skinningRoot, this._localTransform); + } + } + get copyFrom() { + return null; + } + }, hY), sY = Bl(iY.prototype, "mesh", [ ZW ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), nY = Bl(iY.prototype, "skeleton", [ QW ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), rY = Bl(iY.prototype, "material", [ $W ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), oY = Bl(iY.prototype, "_localTransform", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new qi; + } + }), aY = Bl(iY.prototype, "_offset", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Qi(0, 0); + } + }), lY = Bl(iY.prototype, "_size", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Qi(1, 1); + } + }), Bl(iY.prototype, "offset", [ nh ], Object.getOwnPropertyDescriptor(iY.prototype, "offset"), iY.prototype), + Bl(iY.prototype, "size", [ nh ], Object.getOwnPropertyDescriptor(iY.prototype, "size"), iY.prototype), + Bl(iY.prototype, "copyFrom", [ tY ], Object.getOwnPropertyDescriptor(iY.prototype, "copyFrom"), iY.prototype), + iY)) || eY)); + const BY = new qi; + new qi; + const DY = new Pi; + let PY = function(e) { + return t({ + SkinnedMeshBatchRenderer: e, + BatchedSkinningModelComponent: e + }), e; + }((cY = Ul("cc.SkinnedMeshBatchRenderer"), uY = sh(), _Y = zl(100), dY = $l(), pY = lh(), + mY = Th([ Fe ]), fY = lh(), gY = Th([ MY ]), yY = lh(), bY = rh(), SY = rh(), cY(AY = uY(AY = _Y(AY = Ql(AY = dY(AY = (TY = (xY = class extends YW { + constructor(...t) { + super(...t); + Ml(this, "atlasSize", vY, this); + Ml(this, "batchableTextureNames", EY, this); + Ml(this, "units", CY, this); + this._textures = {}; + this._batchMaterial = null; + } + get mesh() { + return super.mesh; + } + set mesh(t) { + super.mesh = t; + } + get skeleton() { + return super.skeleton; + } + set skeleton(t) { + super.skeleton = t; + } + onLoad() { + super.onLoad(); + this.cook(); + } + onDestroy() { + for (const t in this._textures) this._textures[t].destroy(); + this._textures = {}; + if (this._mesh) { + this._mesh.destroy(); + this._mesh = null; + } + super.onDestroy(); + } + _onMaterialModified(t, e) { + this.cookMaterials(); + super._onMaterialModified(t, this.getMaterialInstance(t)); + } + cook() { + this.cookMaterials(); + this.cookSkeletons(); + this.cookMeshes(); + } + cookMaterials() { + this._batchMaterial || (this._batchMaterial = this.getMaterial(0)); + const t = this.getMaterialInstance(0); + if (!t || !this._batchMaterial || !this._batchMaterial.effectAsset) { + console.warn("incomplete batch material!"); + return; + } + t.copy(this._batchMaterial); + this.resizeAtlases(); + const e = t.effectAsset.techniques[t.technique]; + for (let i = 0; i < e.passes.length; i++) { + const s = e.passes[i]; + if (s.properties) for (const e in s.properties) if (s.properties[e].type >= As.SAMPLER1D) { + let s = null; + if (this.batchableTextureNames.find((t => t === e))) { + s = this._textures[e]; + s || (s = this.createTexture(e)); + this.cookTextures(s, e, i); + } else this.units.some((t => s = t.material && t.material.getProperty(e, i))); + s && t.setProperty(e, s, i); + } else { + const s = []; + for (let t = 0; t < this.units.length; t++) { + const n = this.units[t]; + n.material && s.push(n.material.getProperty(e.slice(0, -3), i)); + } + t.setProperty(e, s, i); + } + } + } + cookSkeletons() { + if (!this._skinningRoot) { + console.warn("no skinning root specified!"); + return; + } + const t = []; + const e = []; + for (let i = 0; i < this.units.length; i++) { + const s = this.units[i]; + if (!s || !s.skeleton) continue; + const n = s.skeleton; + qi.invert(BY, s._localTransform); + for (let i = 0; i < n.joints.length; i++) { + const s = n.joints[i]; + if (!(t.findIndex((t => t === s)) >= 0)) { + t.push(s); + e.push(qi.multiply(new qi, n.bindposes[i] || qi.IDENTITY, BY)); + } + } + } + const i = Array.from(Array(t.length).keys()).sort(((e, i) => t[e] > t[i] ? 1 : t[e] < t[i] ? -1 : 0)); + const s = new AH; + s.joints = t.map(((t, e, s) => s[i[e]])); + s.bindposes = e.map(((t, e, s) => s[i[e]])); + this._skeleton && this._skeleton.destroy(); + this.skeleton = s; + } + cookMeshes() { + let t = !1; + for (let e = 0; e < this.units.length; e++) { + if (this.units[e].mesh) { + t = !0; + break; + } + } + if (!t || !this._skinningRoot) return; + this._mesh ? this._mesh.destroyRenderingMesh() : this._mesh = new Ez; + let e = 0; + let i = bs.UNKNOWN; + let s = 0; + let n = bs.UNKNOWN; + let r = 0; + let o = bs.UNKNOWN; + let a = 0; + let l = bs.UNKNOWN; + let h = 0; + let c = bs.UNKNOWN; + const u = new Array(this.units.length); + const _ = this.units.length; + for (let t = 0; t < _; t++) { + const e = this.units[t]; + e && e.skeleton && (u[t] = e.skeleton.joints.map((t => this._skeleton.joints.findIndex((e => t === e))))); + } + for (let t = 0; t < _; t++) { + const _ = this.units[t]; + if (!_ || !_.mesh || !_.mesh.data) continue; + const d = this._createUnitMesh(t, _.mesh); + const p = new DataView(d.data.buffer); + qi.inverseTranspose(BY, _._localTransform); + const {offset: m} = _; + const {size: f} = _; + for (let g = 0; g < d.struct.vertexBundles.length; g++) { + const y = d.struct.vertexBundles[g]; + e = y.view.offset; + i = bs.UNKNOWN; + for (let t = 0; t < y.attributes.length; t++) { + const s = y.attributes[t]; + if (s.name === cr.ATTR_POSITION) { + i = s.format; + break; + } + e += ur[s.format].size; + } + if (i) { + const t = RI(p, i, e, y.view.length, y.view.stride); + for (let e = 0; e < t.length; e += 3) { + Pi.fromArray(DY, t, e); + Pi.transformMat4(DY, DY, _._localTransform); + Pi.toArray(t, DY, e); + } + wI(p, t, i, e, y.view.stride); + } + s = y.view.offset; + n = bs.UNKNOWN; + for (let t = 0; t < y.attributes.length; t++) { + const e = y.attributes[t]; + if (e.name === cr.ATTR_NORMAL) { + n = e.format; + break; + } + s += ur[e.format].size; + } + if (n) { + const t = RI(p, n, s, y.view.length, y.view.stride); + for (let e = 0; e < t.length; e += 3) { + Pi.fromArray(DY, t, e); + Pi.transformMat4Normal(DY, DY, BY); + Pi.toArray(t, DY, e); + } + wI(p, t, n, s, y.view.stride); + } + r = y.view.offset; + o = bs.UNKNOWN; + for (let t = 0; t < y.attributes.length; t++) { + const e = y.attributes[t]; + if (e.name === cr.ATTR_TANGENT) { + o = e.format; + break; + } + r += ur[e.format].size; + } + if (o) { + const t = RI(p, o, r, y.view.length, y.view.stride); + for (let e = 0; e < t.length; e += 3) { + Pi.fromArray(DY, t, e); + Pi.transformMat4Normal(DY, DY, BY); + Pi.toArray(t, DY, e); + } + wI(p, t, o, r, y.view.stride); + } + a = y.view.offset; + l = bs.UNKNOWN; + for (let t = 0; t < y.attributes.length; t++) { + const e = y.attributes[t]; + if (e.name === cr.ATTR_BATCH_UV) { + l = e.format; + break; + } + a += ur[e.format].size; + } + l && II(p, ((t, e) => { + var i; + const s = 0 === e ? "x" : "y"; + return (t = (i = t) - Math.floor(i)) * f[s] + m[s]; + }), l, a, y.view.length, y.view.stride, p); + const b = u[t]; + if (b) { + h = y.view.offset; + c = bs.UNKNOWN; + for (let t = 0; t < y.attributes.length; t++) { + const e = y.attributes[t]; + if (e.name === cr.ATTR_JOINTS) { + c = e.format; + break; + } + h += ur[e.format].size; + } + c && II(p, (t => b[t]), c, h, y.view.length, y.view.stride, p); + } + } + this._mesh.merge(d); + } + this._onMeshChanged(this._mesh); + this._updateModels(); + } + cookTextures(t, e, i) { + const s = []; + const n = []; + const r = []; + const o = []; + for (let t = 0; t < this.units.length; t++) { + const a = this.units[t]; + if (!a.material) continue; + const l = a.material.getProperty(e, i); + if (l && l.image && l.image.data) { + const t = new mn; + t.texOffset.x = a.offset.x * this.atlasSize; + t.texOffset.y = a.offset.y * this.atlasSize; + t.texExtent.width = a.size.x * this.atlasSize; + t.texExtent.height = a.size.y * this.atlasSize; + const {data: e} = l.image; + if (ArrayBuffer.isView(e)) { + r.push(e); + o.push(t); + } else { + s.push(e); + n.push(t); + } + } + } + const a = t.getGFXTexture(); + const {device: l} = m.director.root; + r.length > 0 && l.copyBuffersToTexture(r, a, o); + s.length > 0 && l.copyTexImagesToTexture(s, a, n); + } + createTexture(t) { + const e = new LC; + e.setFilters(Qp.LINEAR, Qp.LINEAR); + e.setMipFilter(Qp.NEAREST); + e.reset({ + width: this.atlasSize, + height: this.atlasSize, + format: Jp.RGBA8888 + }); + this._textures[t] = e; + return e; + } + resizeAtlases() { + for (const t in this._textures) { + this._textures[t].reset({ + width: this.atlasSize, + height: this.atlasSize, + format: Jp.RGBA8888 + }); + } + } + _createUnitMesh(t, e) { + const i = JSON.parse(JSON.stringify(e.struct)); + const s = {}; + for (let t = 0; t < e.struct.primitives.length; t++) { + const n = e.struct.primitives[t]; + let r = 0; + let o = bs.UNKNOWN; + let a = 0; + for (;a < n.vertexBundelIndices.length; a++) { + const t = e.struct.vertexBundles[n.vertexBundelIndices[a]]; + r = t.view.offset; + o = bs.UNKNOWN; + for (let e = 0; e < t.attributes.length; e++) { + const i = t.attributes[e]; + if (i.name === cr.ATTR_TEX_COORD) { + o = i.format; + break; + } + r += ur[i.format].size; + } + if (o) break; + } + if (void 0 !== s[a]) continue; + s[a] = [ o, r ]; + const l = i.vertexBundles[a]; + l.attributes.push(wY); + l.attributes.push(RY); + l.view.offset = 0; + l.view.length += l.view.count * IY; + l.view.stride += IY; + } + let n = 0; + for (let t = 0; t < i.vertexBundles.length; t++) n += i.vertexBundles[t].view.length; + for (let t = 0; t < i.primitives.length; t++) { + const e = i.primitives[t]; + if (e.indexView) { + e.indexView.offset = n; + n += e.indexView.length; + } + } + const r = new Uint8Array(n); + const o = e.data; + const a = new DataView(r.buffer); + const l = new DataView(o.buffer); + const {isLittleEndian: h} = m.sys; + for (const n in s) { + const c = i.vertexBundles[n]; + const u = e.struct.vertexBundles[n]; + const [_, d] = s[n]; + const p = RI(l, _, d, u.view.length, u.view.stride); + const m = u.view; + const f = c.view; + const g = m.stride; + const y = f.stride; + let b = m.offset; + let S = f.offset; + for (let e = 0; e < f.count; e++) { + const i = o.subarray(b, b + g); + r.set(i, S); + a.setFloat32(S + g, t); + a.setFloat32(S + g + 4, p[2 * e], h); + a.setFloat32(S + g + 8, p[2 * e + 1], h); + S += y; + b += g; + } + } + for (let t = 0; t < i.primitives.length; t++) { + const s = e.struct.primitives[t]; + const n = i.primitives[t]; + if (s.indexView && n.indexView) { + const t = s.indexView.stride; + const e = n.indexView.stride; + let i = s.indexView.offset; + let a = n.indexView.offset; + for (let s = 0; s < n.indexView.count; s++) { + const s = o.subarray(i, i + t); + r.set(s, a); + a += e; + i += t; + } + } + } + const c = new Ez; + c.reset({ + struct: i, + data: r + }); + return c; + } + }, xY), vY = Bl(TY.prototype, "atlasSize", [ Yl, pY ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1024; + } + }), EY = Bl(TY.prototype, "batchableTextureNames", [ mY, Yl, fY ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), CY = Bl(TY.prototype, "units", [ gY, Yl, yY ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), Bl(TY.prototype, "mesh", [ vh, bY ], Object.getOwnPropertyDescriptor(TY.prototype, "mesh"), TY.prototype), + Bl(TY.prototype, "skeleton", [ vh, SY ], Object.getOwnPropertyDescriptor(TY.prototype, "skeleton"), TY.prototype), + TY)) || AY) || AY) || AY) || AY) || AY)); + m.SkinningModelComponent = YW; + ee.setClassAlias(YW, "cc.SkinningModelComponent"); + m.SkinningModelUnit = MY; + ee.setClassAlias(MY, "cc.SkinningModelUnit"); + m.BatchedSkinningModelComponent = PY; + ee.setClassAlias(PY, "cc.BatchedSkinningModelComponent"); + m.utils = PI; + const OY = Symbol("CreateEval"); + var NY, LY, FY, VY, kY, UY; + Ul("cc.animation.EmbeddedPlayer")(NY = (LY = class extends Ch { + constructor(...t) { + super(...t); + Ml(this, "begin", FY, this); + Ml(this, "end", VY, this); + Ml(this, "reconciledSpeed", kY, this); + Ml(this, "playable", UY, this); + } + }, FY = Bl(LY.prototype, "begin", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), VY = Bl(LY.prototype, "end", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), kY = Bl(LY.prototype, "reconciledSpeed", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), UY = Bl(LY.prototype, "playable", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), LY)); + class GY {} + class zY { + constructor(t) { + this._randomAccess = t; + } + get randomAccess() { + return this._randomAccess; + } + setTime(t) {} + } + class HY { + constructor() { + this._isPlaying = !1; + this._isPaused = !1; + this._stepOnce = !1; + } + get isPlaying() { + return this._isPlaying; + } + get isPaused() { + return this._isPaused; + } + get isMotionless() { + return !this.isPlaying || this.isPaused; + } + play() { + if (this._isPlaying) if (this._isPaused) { + this._isPaused = !1; + this.onResume(); + } else this.onError(G(3912)); else { + this._isPlaying = !0; + this.onPlay(); + } + } + stop() { + if (this._isPlaying) { + this._isPlaying = !1; + this.onStop(); + this._isPaused = !1; + } + } + pause() { + if (this._isPlaying && !this._isPaused) { + this._isPaused = !0; + this.onPause(); + } + } + resume() { + if (this._isPlaying && this._isPaused) { + this._isPaused = !1; + this.onResume(); + } + } + step() { + this.pause(); + this._stepOnce = !0; + this._isPlaying || this.play(); + } + update(t) {} + onPlay() {} + onPause() {} + onResume() {} + onStop() {} + onError(t) {} + } + class jY { + constructor(t) { + this.weight = 0; + this._pose = void 0; + this._blendStateWriters = []; + this._pose = t; + } + destroy() { + for (let t = 0; t < this._blendStateWriters.length; ++t) this._pose.destroyWriter(this._blendStateWriters[t]); + this._blendStateWriters.length = 0; + } + createPoseWriter(t, e, i) { + const s = this._pose.createWriter(t, e, this, i); + this._blendStateWriters.push(s); + return s; + } + } + function XY() { + return m.director.getAnimationManager(); + } + let WY; + !function(t) { + t.PLAY = "play"; + t.STOP = "stop"; + t.PAUSE = "pause"; + t.RESUME = "resume"; + t.LASTFRAME = "lastframe"; + t.FINISHED = "finished"; + }(WY || (WY = {})); + he(WY); + class YY extends HY { + get clip() { + return this._clip; + } + get name() { + return this._name; + } + get length() { + return this.duration; + } + get wrapMode() { + return this._wrapMode; + } + set wrapMode(t) { + var e; + this._wrapMode = t; + this.time = 0; + t & Sl.Loop ? this.repeatCount = 1 / 0 : this.repeatCount = 1; + null === (e = this._clipEventEval) || void 0 === e || e.setWrapMode(t); + } + get repeatCount() { + return this._repeatCount; + } + set repeatCount(t) { + this._repeatCount = t; + const e = this._wrapMode & Sl.ShouldWrap; + const i = (this.wrapMode & Sl.Reverse) === Sl.Reverse; + this._useSimpleProcess = t === 1 / 0 && !e && !i; + } + get delay() { + return this._delay; + } + set delay(t) { + this._delayTime = this._delay = t; + } + get playbackRange() { + return this._playbackRange; + } + set playbackRange(t) { + ne(t.max > t.min); + this._playbackRange.min = Math.max(t.min, 0); + this._playbackRange.max = Math.min(t.max, this.duration); + this._playbackDuration = this._playbackRange.max - this._playbackRange.min; + this.setTime(0); + } + get speed() { + return this._speed; + } + set speed(t) { + var e; + this._speed = t; + null === (e = this._clipEmbeddedPlayerEval) || void 0 === e || e.notifyHostSpeedChanged(t); + } + get current() { + return this.getWrappedInfo(this.time).time; + } + get ratio() { + return 0 === this.duration ? 0 : this.current / this.duration; + } + get weight() { + return this._weight; + } + set weight(t) { + this._weight = t; + this._poseOutput && (this._poseOutput.weight = t); + } + constructor(t, e = "") { + super(); + this.duration = 1; + this.time = 0; + this.frameRate = 0; + this._targetNode = null; + this._curveLoaded = !1; + this._clip = void 0; + this._speed = 1; + this._useSimpleProcess = !1; + this._target = null; + this._wrapMode = Al.Normal; + this._repeatCount = 1; + this._delay = 0; + this._delayTime = 0; + this._currentFramePlayed = !1; + this._name = void 0; + this._lastIterations = NaN; + this._lastWrapInfo = null; + this._wrappedInfo = new Tl; + this._allowLastFrame = !1; + this._blendStateWriterHost = { + weight: 0 + }; + this._playbackDuration = 0; + this._invDuration = 1; + this._poseOutput = null; + this._weight = 1; + this._clipEval = void 0; + this._clipEventEval = void 0; + this._clipEmbeddedPlayerEval = void 0; + this._doNotCreateEval = !1; + this._clip = t; + this._name = e || t && t.name; + this._playbackRange = { + min: 0, + max: t.duration + }; + this._playbackDuration = t.duration; + t.duration || R(`Clip ${t.name} has zero duration.`); + } + get curveLoaded() { + return this._curveLoaded; + } + initialize(t, e, i) { + if (this._curveLoaded) return; + this._curveLoaded = !0; + if (this._poseOutput) { + this._poseOutput.destroy(); + this._poseOutput = null; + } + this._clipEval && (this._clipEval = void 0); + this._clipEventEval && (this._clipEventEval = void 0); + if (this._clipEmbeddedPlayerEval) { + this._clipEmbeddedPlayerEval.destroy(); + this._clipEmbeddedPlayerEval = void 0; + } + this._targetNode = t; + const s = this._clip; + this.duration = s.duration; + this._invDuration = 1 / this.duration; + this._speed = s.speed; + this.wrapMode = s.wrapMode; + this.frameRate = s.sample; + this._playbackRange.min = 0; + this._playbackRange.max = s.duration; + this._playbackDuration = s.duration; + (this.wrapMode & Sl.Loop) === Sl.Loop ? this.repeatCount = 1 / 0 : this.repeatCount = 1; + if (!this._doNotCreateEval) { + var n, r, o; + const a = null !== (n = null != e ? e : null === (r = XY()) || void 0 === r ? void 0 : r.blendState) && void 0 !== n ? n : null; + a && (this._poseOutput = new jY(a)); + this._clipEval = s.createEvaluator({ + target: t, + pose: null !== (o = this._poseOutput) && void 0 !== o ? o : void 0, + mask: i + }); + } + s.containsAnyEvent() && (this._clipEventEval = s.createEventEvaluator(this._targetNode)); + if (s.containsAnyEmbeddedPlayer()) { + this._clipEmbeddedPlayerEval = s.createEmbeddedPlayerEvaluator(this._targetNode); + this._clipEmbeddedPlayerEval.notifyHostSpeedChanged(this._speed); + } + } + destroy() { + this.isMotionless || XY().removeAnimation(this); + if (this._poseOutput) { + this._poseOutput.destroy(); + this._poseOutput = null; + } + this._clipEval = void 0; + } + emit(...t) { + XY().pushDelayEvent(this._emit, this, t); + } + on(t, e, i) { + return this._target && this._target.isValid ? this._target.on(t, e, i) : null; + } + once(t, e, i) { + return this._target && this._target.isValid ? this._target.once(t, e, i) : null; + } + off(t, e, i) { + this._target && this._target.isValid && this._target.off(t, e, i); + } + allowLastFrameEvent(t) { + this._allowLastFrame = t; + } + _setEventTarget(t) { + this._target = t; + } + setTime(t) { + this._currentFramePlayed = !1; + this.time = t || 0; + { + var e; + const i = this.getWrappedInfo(t, this._wrappedInfo); + null === (e = this._clipEventEval) || void 0 === e || e.ignore(i.ratio, i.direction); + } + } + update(t) { + if (this._delayTime > 0) { + this._delayTime -= t; + if (this._delayTime > 0) return; + } + this._currentFramePlayed ? this.time += t * this._speed : this._currentFramePlayed = !0; + this._process(); + } + sample() { + const t = this.getWrappedInfo(this.time, this._wrappedInfo); + this._sampleCurves(t.time); + this._sampleEvents(t); + this._sampleEmbeddedPlayers(t); + return t; + } + onPlay() { + var t; + this.setTime(this._getPlaybackStart()); + this._delayTime = this._delay; + this._onReplayOrResume(); + this.emit(WY.PLAY, this); + null === (t = this._clipEmbeddedPlayerEval) || void 0 === t || t.notifyHostPlay(this.current); + } + onStop() { + var t; + this.isPaused || this._onPauseOrStop(); + this.emit(WY.STOP, this); + null === (t = this._clipEmbeddedPlayerEval) || void 0 === t || t.notifyHostStop(); + } + onResume() { + var t; + this._onReplayOrResume(); + this.emit(WY.RESUME, this); + null === (t = this._clipEmbeddedPlayerEval) || void 0 === t || t.notifyHostPlay(this.current); + } + onPause() { + var t; + this._onPauseOrStop(); + this.emit(WY.PAUSE, this); + null === (t = this._clipEmbeddedPlayerEval) || void 0 === t || t.notifyHostPause(this.current); + } + _sampleCurves(t) { + const {_poseOutput: e, _clipEval: i} = this; + e && (e.weight = this.weight); + i && i.evaluate(t); + } + _process() { + this._useSimpleProcess ? this.simpleProcess() : this.process(); + } + process() { + const t = this.sample(); + if (this._allowLastFrame) { + let e; + e = this._lastWrapInfo ? this._lastWrapInfo : this._lastWrapInfo = new Tl(t); + this.repeatCount > 1 && (0 | t.iterations) > (0 | e.iterations) && this.emit(WY.LASTFRAME, this); + e.set(t); + } + if (t.stopped) { + this.stop(); + this.emit(WY.FINISHED, this); + } + } + simpleProcess() { + const t = this._playbackRange.min; + const e = this._playbackDuration; + let i = 0; + let s = 0; + if (0 !== e) { + i = this.time % e; + i < 0 && (i += e); + s = (t + i) * this._invDuration; + } + this._sampleCurves(t + i); + if (this._clipEventEval || this._clipEmbeddedPlayerEval) { + const t = this.getWrappedInfo(this.time, this._wrappedInfo); + this._sampleEvents(t); + this._sampleEmbeddedPlayers(t); + } + if (this._allowLastFrame) { + Number.isNaN(this._lastIterations) && (this._lastIterations = s); + (this.time > 0 && this._lastIterations > s || this.time < 0 && this._lastIterations < s) && this.emit(WY.LASTFRAME, this); + this._lastIterations = s; + } + } + _needReverse(t) { + const e = this.wrapMode; + let i = !1; + if ((e & Sl.PingPong) === Sl.PingPong) { + t - (0 | t) == 0 && t > 0 && (t -= 1); + 1 & t && (i = !i); + } + (e & Sl.Reverse) === Sl.Reverse && (i = !i); + return i; + } + getWrappedInfo(t, e) { + e = e || new Tl; + const {_playbackRange: {min: i}, _playbackDuration: s} = this; + const n = this.repeatCount; + if (0 === s) { + e.time = 0; + e.ratio = 0; + e.direction = 1; + e.stopped = !!Number.isFinite(n); + e.iterations = 0; + return e; + } + let r = !1; + let o = (t -= i) > 0 ? t / s : -t / s; + if (o >= n) { + o = n; + r = !0; + let e = n - (0 | n); + 0 === e && (e = 1); + t = e * s * (t > 0 ? 1 : -1); + } + if (t > s) { + const e = t % s; + t = 0 === e ? s : e; + } else t < 0 && 0 !== (t %= s) && (t += s); + let a = !1; + const l = this._wrapMode & Sl.ShouldWrap; + l && (a = this._needReverse(o)); + let h = a ? -1 : 1; + this.speed < 0 && (h *= -1); + l && a && (t = s - t); + e.time = i + t; + e.ratio = e.time / this.duration; + e.direction = h; + e.stopped = r; + e.iterations = o; + return e; + } + _getPlaybackStart() { + return this._playbackRange.min; + } + _sampleEvents(t) { + var e; + null === (e = this._clipEventEval) || void 0 === e || e.sample(t.ratio, t.direction, t.iterations); + } + _sampleEmbeddedPlayers(t) { + var e; + null === (e = this._clipEmbeddedPlayerEval) || void 0 === e || e.evaluate(t.time, Math.trunc(t.iterations)); + } + _emit(t, e) { + this._target && this._target.isValid && this._target.emit(t, t, e); + } + _onReplayOrResume() { + XY().addAnimation(this); + } + _onPauseOrStop() { + XY().removeAnimation(this); + } + } + t("AnimationState", YY); + m.AnimationState = YY; + var qY, KY, JY, ZY, QY; + Ul("cc.animation.EmbeddedAnimationClipPlayable")(qY = (KY = (QY = class extends GY { + constructor(...t) { + super(...t); + Ml(this, "path", JY, this); + Ml(this, "clip", ZY, this); + } + instantiate(t) { + const {clip: e, path: i} = this; + if (!e) return null; + const s = t.getChildByPath(i); + if (!s) { + F(3938, i, t.getPathInHierarchy(), e.name); + return null; + } + const n = new YY(e); + n.initialize(s); + return new $Y(n); + } + }, QY), JY = Bl(KY.prototype, "path", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), ZY = Bl(KY.prototype, "clip", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), KY)); + class $Y extends zY { + constructor(t) { + super(!0); + this._animationState = void 0; + this._animationState = t; + } + destroy() { + this._animationState.destroy(); + } + play() { + this._animationState.play(); + } + pause() { + this._animationState.pause(); + } + stop() { + this._animationState.stop(); + } + setSpeed(t) { + this._animationState.speed = t; + } + setTime(t) { + this._animationState.time = t; + } + } + var tq, eq, iq; + Ul("cc.animation.EmbeddedParticleSystemPlayable")(tq = (eq = class extends GY { + constructor(...t) { + super(...t); + Ml(this, "path", iq, this); + } + instantiate(t) { + const e = t.getChildByPath(this.path); + if (!e) { + C(`Hierarchy path ${this.path} does not exists.`); + return null; + } + const i = Jt("cc.ParticleSystem"); + if (!i) { + C("Particle system is required for embedded particle system player."); + return null; + } + const s = e.getComponent(i); + if (!s) { + C(`${this.path} does not includes a particle system component.`); + return null; + } + return new sq(s); + } + }, iq = Bl(eq.prototype, "path", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), eq)); + class sq extends zY { + constructor(t) { + super(!1); + this._particleSystem = void 0; + this._particleSystem = t; + } + destroy() {} + play() { + this._particleSystem.play(); + } + pause() { + this._particleSystem.stopEmitting(); + } + stop() { + this._particleSystem.stopEmitting(); + } + setSpeed(t) { + this._particleSystem.simulationSpeed = t; + } + } + var nq, rq, oq, aq, lq, hq, cq; + function uq(t) { + return "string" == typeof t || "number" == typeof t; + } + let _q = Ul("cc.animation.HierarchyPath")(nq = (rq = (aq = class { + constructor(t) { + Ml(this, "path", oq, this); + this.path = t || ""; + } + get(t) { + if (!(t instanceof _y)) { + N(3925); + return null; + } + const e = t.getChildByPath(this.path); + if (!e) { + N(3926, t.name, this.path); + return null; + } + return e; + } + }, aq), oq = Bl(rq.prototype, "path", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), rq)) || nq; + let dq = Ul("cc.animation.ComponentPath")(lq = (hq = class { + constructor(t) { + Ml(this, "component", cq, this); + this.component = t || ""; + } + get(t) { + if (!(t instanceof _y)) { + N(3927); + return null; + } + const e = t.getComponent(this.component); + if (!e) { + N(3928, t.name, this.component); + return null; + } + return e; + } + }, cq = Bl(hq.prototype, "component", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), hq)) || lq; + var pq, mq, fq, gq, yq, bq, Sq, Aq, Tq, vq, Eq, Cq, xq, wq, Rq, Iq, Mq, Bq, Dq, Pq; + const Oq = Symbol("NormalizedFollow"); + const Nq = Symbol("ConvertAsTrsPath"); + const Lq = Symbol("TrackBinding"); + let Fq = Ul("cc.animation.TrackPath")(pq = (mq = (gq = class t { + constructor() { + Ml(this, "_paths", fq, this); + } + get length() { + return this._paths.length; + } + toProperty(t) { + this._paths.push(t); + return this; + } + toElement(t) { + this._paths.push(t); + return this; + } + toHierarchy(t) { + this._paths.push(new _q(t)); + return this; + } + toComponent(t) { + const e = new dq("string" == typeof t ? t : ee.getClassName(t)); + this._paths.push(e); + return this; + } + toCustomized(t) { + this._paths.push(t); + return this; + } + append(...t) { + const e = this._paths.concat(...t.map((t => t._paths))); + this._paths = e; + return this; + } + isPropertyAt(t) { + return "string" == typeof this._paths[t]; + } + parsePropertyAt(t) { + return this._paths[t]; + } + isElementAt(t) { + return "number" == typeof this._paths[t]; + } + parseElementAt(t) { + return this._paths[t]; + } + isHierarchyAt(t) { + return this._paths[t] instanceof _q; + } + parseHierarchyAt(t) { + ne(this.isHierarchyAt(t)); + return this._paths[t].path; + } + isComponentAt(t) { + return this._paths[t] instanceof dq; + } + parseComponentAt(t) { + ne(this.isComponentAt(t)); + return this._paths[t].component; + } + slice(e, i) { + const s = new t; + s._paths = this._paths.slice(e, i); + return s; + } + trace(t, e, i) { + var s, n; + null !== (s = e) && void 0 !== s || (e = 0); + null !== (n = i) && void 0 !== n || (i = this._paths.length); + return this[Oq](t, e, i); + } + [Nq]() { + const {_paths: t} = this; + const e = t.length; + let i = 0; + let s = ""; + for (;i < e; ++i) { + const e = t[i]; + if (!(e instanceof _q)) break; + e.path && (s ? s += `/${e.path}` : s = e.path); + } + if (i === e) return null; + let n; + if (i !== e - 1) return null; + switch (t[i]) { + case "position": + case "scale": + case "rotation": + case "eulerAngles": + n = t[i]; + break; + + default: + return null; + } + return { + node: s, + property: n + }; + } + [Oq](t, e, i) { + const {_paths: s} = this; + let n = t; + for (let t = e; t < i; ++t) { + const e = s[t]; + if (uq(e)) { + if (!(e in n)) { + N(3929, e); + return null; + } + n = n[e]; + } else n = e.get(n); + if (null === n) break; + } + return n; + } + }, gq), fq = Bl(mq.prototype, "_paths", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), mq)) || pq; + let Vq = Ul("cc.animation.TrackBinding")(yq = Zl(yq = (bq = (vq = Tq = class { + constructor() { + Ml(this, "path", Sq, this); + Ml(this, "proxy", Aq, this); + } + parseTrsPath() { + return this.proxy ? null : this.path[Nq](); + } + createRuntimeBinding(t, e, i) { + const {path: s, proxy: n} = this; + const r = s.length; + const o = r - 1; + if (0 === r || !s.isPropertyAt(o) && !s.isElementAt(o) || n) { + if (n) { + const e = s[Oq](t, 0, r); + if (null === e) return null; + const i = n.forTarget(e); + const o = { + setValue: t => { + i.set(t); + } + }; + const a = i.get; + a && (o.getValue = () => a.call(i)); + return o; + } + F(3921); + return null; + } + { + const n = s.isPropertyAt(o) ? s.parsePropertyAt(o) : s.parseElementAt(o); + const l = s[Oq](t, 0, r - 1); + if (null === l) return null; + if (e && l instanceof _y && ("position" === (a = n) || "rotation" === a || "scale" === a || "eulerAngles" === a)) { + return e.createPoseWriter(l, n, i); + } + let h; + let c; + h = t => { + l[n] = t; + }; + c = () => l[n]; + return { + target: l, + setValue: h, + getValue: c + }; + } + var a; + } + isMaskedOff(t) { + const e = this.parseTrsPath(); + if (!e) return !1; + const i = t.joints[Symbol.iterator](); + for (let t = i.next(); !t.done; t = i.next()) { + const {value: i} = t; + if (i.path === e.node) return !i.enabled; + } + return !1; + } + }, Tq._animationFunctions = new WeakMap, vq), Sq = Bl(bq.prototype, "path", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Fq; + } + }), Aq = Bl(bq.prototype, "proxy", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), bq)) || yq) || yq; + let kq = Ul("cc.animation.Track")(Eq = (Cq = (wq = class { + constructor() { + Ml(this, "_binding", xq, this); + } + get path() { + return this._binding.path; + } + set path(t) { + this._binding.path = t; + } + get proxy() { + return this._binding.proxy; + } + set proxy(t) { + this._binding.proxy = t; + } + get [Lq]() { + return this._binding; + } + channels() { + return []; + } + range() { + const t = { + min: 1 / 0, + max: -1 / 0 + }; + for (const e of this.channels()) { + t.min = Math.min(t.min, e.curve.rangeMin); + t.max = Math.max(t.max, e.curve.rangeMax); + } + return t; + } + }, wq), xq = Bl(Cq.prototype, "_binding", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Vq; + } + }), Cq)) || Eq; + let Uq = Ul("cc.animation.Channel")(Rq = (Iq = class { + constructor(t) { + this.name = ""; + Ml(this, "_curve", Mq, this); + this._curve = t; + } + get curve() { + return this._curve; + } + }, Mq = Bl(Iq.prototype, "_curve", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), Iq)) || Rq; + let Gq = Ul("cc.animation.SingleChannelTrack")(Bq = (Dq = class extends kq { + constructor() { + super(); + Ml(this, "_channel", Pq, this); + this._channel = new Uq(this.createCurve()); + } + get channel() { + return this._channel; + } + channels() { + return [ this._channel ]; + } + createCurve() { + throw new Error("Not impl"); + } + [OY](t) { + const {curve: e} = this._channel; + return new zq(e); + } + }, Pq = Bl(Dq.prototype, "_channel", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), Dq)) || Bq; + class zq { + constructor(t) { + this._curve = t; + } + evaluate(t) { + return this._curve.evaluate(t); + } + } + var Hq, jq, Xq, Wq; + Ul("cc.animation.RealArrayTrack")(Hq = (jq = (Wq = class extends kq { + constructor(...t) { + super(...t); + Ml(this, "_channels", Xq, this); + } + get elementCount() { + return this._channels.length; + } + set elementCount(t) { + const {_channels: e} = this; + const i = e.length; + t < i ? this._channels.splice(t) : t > i && this._channels.push(...Array.from({ + length: t - i + }, (() => new Uq(new Od)))); + } + channels() { + return this._channels; + } + [OY]() { + return new Yq(this._channels.map((({curve: t}) => t))); + } + }, Wq), Xq = Bl(jq.prototype, "_channels", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), jq)); + class Yq { + constructor(t) { + this._curves = t; + this._result = new Array(t.length).fill(0); + } + evaluate(t, e) { + const {_result: i} = this; + const s = i.length; + for (let e = 0; e < s; ++e) i[e] = this._curves[e].evaluate(t); + return this._result; + } + } + var qq, Kq, Jq, Zq, Qq, $q; + let tK = Ul("cc.animation.UniformProxyFactory")(qq = (Kq = ($q = class { + constructor(t, e) { + Ml(this, "passIndex", Jq, this); + Ml(this, "uniformName", Zq, this); + Ml(this, "channelIndex", Qq, this); + this.passIndex = e || 0; + this.uniformName = t || ""; + } + forTarget(t) { + const e = t.passes[this.passIndex]; + const i = e.getHandle(this.uniformName); + if (!i) throw new Error(`Material "${t.name}" has no uniform "${this.uniformName}"`); + if (XP.getTypeFromHandle(i) < As.SAMPLER1D) { + const s = void 0 === this.channelIndex ? i : e.getHandle(this.uniformName, this.channelIndex, As.FLOAT); + if (!s) throw new Error(`Uniform "${this.uniformName} (in material ${t.name}) has no channel ${this.channelIndex}"`); + return function(t, e) { + for (const i of t.shaderInfo.blocks) for (const t of i.members) if (t.name === e) return t.count > 1; + return !1; + }(e, this.uniformName) ? { + set: t => { + e.setUniformArray(s, t); + } + } : { + set: t => { + e.setUniform(s, t); + } + }; + } + { + const t = XP.getBindingFromHandle(i); + const s = e.properties[this.uniformName]; + const n = s && s.value ? `${s.value}${zP(s.type)}` : GP(s.type); + let r = xR.get(n); + if (!r) { + C(`Illegal texture default value: ${n}.`); + r = xR.get("default-texture"); + } + return { + set: i => { + i || (i = r); + const s = i.getGFXTexture(); + if (s && s.width && s.height) { + e.bindTexture(t, s); + i instanceof tm && e.bindSampler(t, zo.gfxDevice.getSampler(i.getSamplerInfo())); + } + } + }; + } + } + }, $q), Jq = Bl(Kq.prototype, "passIndex", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Zq = Bl(Kq.prototype, "uniformName", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), Qq = Bl(Kq.prototype, "channelIndex", [ bh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() {} + }), Kq)) || qq; + var eK, iK, sK, nK, rK, oK, aK, lK, hK, cK; + let uK = Ul("cc.animation.MorphWeightValueProxy")(eK = (iK = (rK = class { + constructor() { + Ml(this, "subMeshIndex", sK, this); + Ml(this, "shapeIndex", nK, this); + } + forTarget(t) { + return { + set: e => { + t.setWeight(e, this.subMeshIndex, this.shapeIndex); + } + }; + } + }, rK), sK = Bl(iK.prototype, "subMeshIndex", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), nK = Bl(iK.prototype, "shapeIndex", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), iK)) || eK; + let _K = Ul("cc.animation.MorphWeightsValueProxy")(oK = (aK = (hK = class { + constructor() { + Ml(this, "subMeshIndex", lK, this); + } + forTarget(t) { + return { + set: e => { + t.setWeights(e, this.subMeshIndex); + } + }; + } + }, hK), lK = Bl(aK.prototype, "subMeshIndex", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), aK)) || oK; + let dK = Ul("cc.animation.MorphWeightsAllValueProxy")(cK = class { + forTarget(t) { + return { + set: e => { + var i, s; + const n = null !== (i = null === (s = t.mesh) || void 0 === s ? void 0 : s.struct.primitives.length) && void 0 !== i ? i : 0; + for (let i = 0; i < n; ++i) t.setWeights(e, i); + } + }; + } + }) || cK; + var pK, mK, fK, gK, yK; + function bK(t, e, i, s) { + var n, r, o, a, l; + let h = new e; + let c = new e; + let u = new e; + let _ = Ul(t)(n = (r = class { + constructor(t, i, s) { + Ml(this, "dataPoint", o, this); + Ml(this, "inTangent", a, this); + Ml(this, "outTangent", l, this); + this.dataPoint = t || new e; + this.inTangent = i || new e; + this.outTangent = s || new e; + } + lerp(t, e, n) { + const r = this.dataPoint; + const o = t.dataPoint; + c = i(c, this.inTangent, n); + u = i(u, t.outTangent, n); + const a = e * e * e; + const l = e * e; + const _ = a - 2 * l + e; + const d = -2 * a + 3 * l; + const p = a - l; + h = i(h, r, 2 * a - 3 * l + 1); + h = s(h, h, c, _); + h = s(h, h, o, d); + h = s(h, h, u, p); + return h; + } + getNoLerp() { + return this.dataPoint; + } + }, o = Bl(r.prototype, "dataPoint", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new e; + } + }), a = Bl(r.prototype, "inTangent", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new e; + } + }), l = Bl(r.prototype, "outTangent", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new e; + } + }), r)) || n; + if (e === Ui) { + const t = _.prototype.lerp; + _.prototype.lerp = function(e, i, s) { + const n = t.call(this, e, i, s); + Ui.normalize(n, n); + return n; + }; + } + return _; + } + const SK = bK("cc.CubicSplineVec2Value", Qi, Qi.multiplyScalar, Qi.scaleAndAdd); + const AK = bK("cc.CubicSplineVec3Value", Pi, Pi.multiplyScalar, Pi.scaleAndAdd); + const TK = bK("cc.CubicSplineVec4Value", is, is.multiplyScalar, is.scaleAndAdd); + const vK = bK("cc.CubicSplineQuatValue", Ui, Ui.multiplyScalar, Ui.scaleAndAdd); + let EK = Ul("cc.CubicSplineNumberValue")(pK = (mK = class { + constructor(t, e, i) { + Ml(this, "dataPoint", fK, this); + Ml(this, "inTangent", gK, this); + Ml(this, "outTangent", yK, this); + this.dataPoint = t; + this.inTangent = e; + this.outTangent = i; + } + lerp(t, e, i) { + const s = this.dataPoint; + const n = t.dataPoint; + const r = e * e * e; + const o = e * e; + return s * (2 * r - 3 * o + 1) + this.outTangent * i * (r - 2 * o + e) + n * (-2 * r + 3 * o) + t.inTangent * i * (r - o); + } + getNoLerp() { + return this.dataPoint; + } + }, fK = Bl(mK.prototype, "dataPoint", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), gK = Bl(mK.prototype, "inTangent", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), yK = Bl(mK.prototype, "outTangent", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), mK)) || pK; + var CK; + let xK = Ul("cc.animation.RealTrack")(CK = class extends Gq { + createCurve() { + return new Od; + } + }) || CK; + function wK(t) { + return 0 === t.keyFramesCount ? void 0 : t; + } + var RK, IK, MK, BK, DK; + const PK = [ "X", "Y", "Z", "W" ]; + let OK = Ul("cc.animation.VectorTrack")(RK = (IK = (DK = class extends kq { + constructor() { + super(); + Ml(this, "_channels", MK, this); + Ml(this, "_nComponents", BK, this); + this._channels = new Array(4); + for (let t = 0; t < this._channels.length; ++t) { + const e = new Uq(new Od); + e.name = PK[t]; + this._channels[t] = e; + } + } + get componentsCount() { + return this._nComponents; + } + set componentsCount(t) { + this._nComponents = t; + } + channels() { + return this._channels; + } + [OY]() { + switch (this._nComponents) { + default: + case 2: + return new NK(wK(this._channels[0].curve), wK(this._channels[1].curve)); + + case 3: + return new LK(wK(this._channels[0].curve), wK(this._channels[1].curve), wK(this._channels[2].curve)); + + case 4: + return new FK(wK(this._channels[0].curve), wK(this._channels[1].curve), wK(this._channels[2].curve), wK(this._channels[3].curve)); + } + } + }, DK), MK = Bl(IK.prototype, "_channels", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), BK = Bl(IK.prototype, "_nComponents", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 4; + } + }), IK)) || RK; + class NK { + constructor(t, e) { + this._result = new Qi; + this._x = t; + this._y = e; + } + evaluate(t, e) { + this._x && this._y || !e.getValue || Qi.copy(this._result, e.getValue()); + this._x && (this._result.x = this._x.evaluate(t)); + this._y && (this._result.y = this._y.evaluate(t)); + return this._result; + } + } + class LK { + constructor(t, e, i) { + this._result = new Pi; + this._x = t; + this._y = e; + this._z = i; + } + evaluate(t, e) { + this._x && this._y && this._z || !e.getValue || Pi.copy(this._result, e.getValue()); + this._x && (this._result.x = this._x.evaluate(t)); + this._y && (this._result.y = this._y.evaluate(t)); + this._z && (this._result.z = this._z.evaluate(t)); + return this._result; + } + } + class FK { + constructor(t, e, i, s) { + this._result = new is; + this._x = t; + this._y = e; + this._z = i; + this._w = s; + } + evaluate(t, e) { + this._x && this._y && this._z && this._w || !e.getValue || is.copy(this._result, e.getValue()); + this._x && (this._result.x = this._x.evaluate(t)); + this._y && (this._result.y = this._y.evaluate(t)); + this._z && (this._result.z = this._z.evaluate(t)); + this._w && (this._result.w = this._w.evaluate(t)); + return this._result; + } + } + var VK; + let kK = Ul("cc.animation.QuatTrack")(VK = class extends Gq { + createCurve() { + return new Sp; + } + [OY]() { + return new UK(this.channels()[0].curve); + } + }) || VK; + class UK { + constructor(t) { + this._result = new Ui; + this._curve = t; + } + evaluate(t) { + this._curve.evaluate(t, this._result); + return this._result; + } + } + var GK, zK, HK; + const jK = [ "Red", "Green", "Blue", "Alpha" ]; + let XK = Ul("cc.animation.ColorTrack")(GK = (zK = class extends kq { + constructor() { + super(); + Ml(this, "_channels", HK, this); + this._channels = new Array(4); + for (let t = 0; t < this._channels.length; ++t) { + const e = new Uq(new Od); + e.name = jK[t]; + this._channels[t] = e; + } + } + channels() { + return this._channels; + } + [OY]() { + return new WK(wK(this._channels[0].curve), wK(this._channels[1].curve), wK(this._channels[2].curve), wK(this._channels[3].curve)); + } + }, HK = Bl(zK.prototype, "_channels", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), zK)) || GK; + class WK { + constructor(t, e, i, s) { + this._result = new Bi; + this._x = t; + this._y = e; + this._z = i; + this._w = s; + } + evaluate(t, e) { + this._x && this._y && this._z && this._w || !e.getValue || Bi.copy(this._result, e.getValue()); + this._x && (this._result.r = this._x.evaluate(t)); + this._y && (this._result.g = this._y.evaluate(t)); + this._z && (this._result.b = this._z.evaluate(t)); + this._w && (this._result.a = this._w.evaluate(t)); + return this._result; + } + } + var YK, qK, KK; + const JK = [ "Width", "Height" ]; + let ZK = Ul("cc.animation.SizeTrack")(YK = (qK = class extends kq { + constructor() { + super(); + Ml(this, "_channels", KK, this); + this._channels = new Array(2); + for (let t = 0; t < this._channels.length; ++t) { + const e = new Uq(new Od); + e.name = JK[t]; + this._channels[t] = e; + } + } + channels() { + return this._channels; + } + [OY]() { + return new QK(wK(this._channels[0].curve), wK(this._channels[1].curve)); + } + }, KK = Bl(qK.prototype, "_channels", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), qK)) || YK; + class QK { + constructor(t, e) { + this._result = new rs; + this._width = t; + this._height = e; + } + evaluate(t, e) { + if ((!this._width || !this._height) && e.getValue) { + const t = e.getValue(); + this._result.x = t.x; + this._result.y = t.y; + } + this._width && (this._result.width = this._width.evaluate(t)); + this._height && (this._result.height = this._height.evaluate(t)); + return this._result; + } + } + var $K; + let tJ = Ul("cc.animation.ObjectTrack")($K = class extends Gq { + createCurve() { + return new Bp; + } + }) || $K; + const eJ = Symbol("[[Owner]]"); + function iJ(t, e) { + ne(t[eJ] === e); + } + function sJ(t, e) { + t[eJ] = e; + } + function nJ(t) { + t[eJ] = void 0; + } + let rJ; + !function(t) { + t[t.FLOAT = 0] = "FLOAT"; + t[t.BOOLEAN = 1] = "BOOLEAN"; + t[t.TRIGGER = 2] = "TRIGGER"; + t[t.INTEGER = 3] = "INTEGER"; + }(rJ || (rJ = {})); + let oJ; + !function(t) { + t[t.AFTER_CONSUMED = 0] = "AFTER_CONSUMED"; + t[t.NEXT_FRAME_OR_AFTER_CONSUMED = 1] = "NEXT_FRAME_OR_AFTER_CONSUMED"; + }(oJ || (oJ = {})); + class aJ { + constructor(t, e) { + this.type = void 0; + this.resetMode = oJ.AFTER_CONSUMED; + this._value = void 0; + this._refs = []; + this.type = t; + this._value = e; + } + get value() { + return this._value; + } + set value(t) { + this._value = t; + for (const {fn: e, thisArg: i, args: s} of this._refs) e.call(i, t, ...s); + } + bind(t, e, ...i) { + this._refs.push({ + fn: t, + thisArg: e, + args: i + }); + return this._value; + } + } + class lJ extends Error { + constructor(t) { + super(`${t} transition is invalid`); + this.name = "TransitionRejectError"; + } + } + class hJ extends Error { + constructor(t) { + super(`Graph variable ${t} is not defined`); + } + } + class cJ extends Error { + constructor(t, e, i) { + super(`Expect graph variable ${t} to have type '${e}' instead of received '${null != i ? i : typeof i}'`); + } + } + const uJ = Symbol("[[createEval]]"); + var _J, dJ, pJ, mJ, fJ, gJ, yJ; + const bJ = Symbol("[[Outgoing transitions]]"); + const SJ = Symbol("[[Incoming transitions]]"); + let AJ = Ul("cc.animation.State")(_J = (dJ = class extends Ch { + constructor() { + super(); + Ml(this, "name", pJ, this); + this[bJ] = []; + this[SJ] = []; + } + }, pJ = Bl(dJ.prototype, "name", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), dJ)) || _J; + let TJ = Ul("cc.animation.InteractiveState")(mJ = (fJ = (yJ = class extends AJ { + constructor(...t) { + super(...t); + Ml(this, "_components", gJ, this); + } + get components() { + return this._components; + } + addComponent(t) { + const e = new t; + this._components.push(e); + return e; + } + removeComponent(t) { + at(this._components, t); + } + instantiateComponents() { + return this._components.map((t => d_(t))); + } + }, yJ), gJ = Bl(fJ.prototype, "_components", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), fJ)) || mJ; + var vJ, EJ, CJ, xJ, wJ, RJ, IJ; + let MJ = Ul("cc.animation.Motion")(vJ = (EJ = (IJ = class t extends TJ { + constructor(...t) { + super(...t); + Ml(this, "motion", CJ, this); + Ml(this, "speed", xJ, this); + Ml(this, "speedMultiplier", wJ, this); + Ml(this, "speedMultiplierEnabled", RJ, this); + } + clone() { + var e, i; + const s = new t; + s.motion = null !== (e = null === (i = this.motion) || void 0 === i ? void 0 : i.clone()) && void 0 !== e ? e : null; + s.speed = this.speed; + s.speedMultiplier = this.speedMultiplier; + s.speedMultiplierEnabled = this.speedMultiplierEnabled; + return s; + } + }, IJ), CJ = Bl(EJ.prototype, "motion", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), xJ = Bl(EJ.prototype, "speed", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), wJ = Bl(EJ.prototype, "speedMultiplier", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), RJ = Bl(EJ.prototype, "speedMultiplierEnabled", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), EJ)) || vJ; + function BJ(t, e, i) { + re(t, e); + re(t, i); + if (e === i) return t; + const s = t[e]; + if (e < i) for (let s = e + 1; s <= i; ++s) t[s - 1] = t[s]; else for (let s = e; s !== i; --s) t[s] = t[s - 1]; + t[i] = s; + return t; + } + const DJ = Symbol("[[OnAfterDeserialized]]"); + var PJ, OJ, NJ, LJ, FJ, VJ, kJ, UJ, GJ, zJ, HJ, jJ, XJ, WJ, YJ, qJ, KJ, JJ, ZJ, QJ, $J, tZ, eZ, iZ, sZ, nZ, rZ, oZ, aZ, lZ, hZ, cZ, uZ, _Z, dZ, pZ, mZ, fZ, gZ, yZ, bZ, SZ, AZ, TZ, vZ, EZ, CZ, xZ, wZ, RZ, IZ, MZ, BZ; + let DZ = Ul("cc.animation.Transition")(PJ = (OJ = class extends Ch { + constructor(t, e, i) { + super(); + Ml(this, "from", NJ, this); + Ml(this, "to", LJ, this); + Ml(this, "conditions", FJ, this); + this[eJ] = void 0; + this.from = t; + this.to = e; + i && (this.conditions = i); + } + }, NJ = Bl(OJ.prototype, "from", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), LJ = Bl(OJ.prototype, "to", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), FJ = Bl(OJ.prototype, "conditions", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), OJ)) || PJ; + let PZ; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.CURRENT_STATE = 1] = "CURRENT_STATE"; + t[t.NEXT_STATE = 2] = "NEXT_STATE"; + t[t.CURRENT_STATE_THEN_NEXT_STATE = 3] = "CURRENT_STATE_THEN_NEXT_STATE"; + t[t.NEXT_STATE_THEN_CURRENT_STATE = 4] = "NEXT_STATE_THEN_CURRENT_STATE"; + }(PZ || (PZ = {})); + let OZ = Ul("cc.animation.AnimationTransition")(VJ = (kJ = (YJ = class extends DZ { + constructor(...t) { + super(...t); + Ml(this, "duration", UJ, this); + Ml(this, "relativeDuration", GJ, this); + Ml(this, "exitConditionEnabled", zJ, this); + Ml(this, "destinationStart", HJ, this); + Ml(this, "relativeDestinationStart", jJ, this); + Ml(this, "interruptionSource", XJ, this); + Ml(this, "_exitCondition", WJ, this); + } + get exitCondition() { + return this._exitCondition; + } + set exitCondition(t) { + ne(t >= 0); + this._exitCondition = t; + } + get interruptible() { + return this.interruptionSource !== PZ.NONE; + } + set interruptible(t) { + this.interruptionSource = t ? PZ.CURRENT_STATE_THEN_NEXT_STATE : PZ.NONE; + } + }, YJ), UJ = Bl(kJ.prototype, "duration", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .3; + } + }), GJ = Bl(kJ.prototype, "relativeDuration", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), zJ = Bl(kJ.prototype, "exitConditionEnabled", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), HJ = Bl(kJ.prototype, "destinationStart", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), jJ = Bl(kJ.prototype, "relativeDestinationStart", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), XJ = Bl(kJ.prototype, "interruptionSource", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return PZ.NONE; + } + }), WJ = Bl(kJ.prototype, "_exitCondition", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), kJ)) || VJ; + let NZ = Ul("cc.animation.EmptyState")(qJ = class extends AJ {}) || qJ; + let LZ = Ul("cc.animation.EmptyStateTransition")(KJ = (JJ = class extends DZ { + constructor(...t) { + super(...t); + Ml(this, "duration", ZJ, this); + Ml(this, "destinationStart", QJ, this); + Ml(this, "relativeDestinationStart", $J, this); + } + }, ZJ = Bl(JJ.prototype, "duration", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .3; + } + }), QJ = Bl(JJ.prototype, "destinationStart", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), $J = Bl(JJ.prototype, "relativeDestinationStart", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), JJ)) || KJ; + let FZ = Ul("cc.animation.StateMachine")(tZ = (eZ = (aZ = class t extends Ch { + __callOnAfterDeserializeRecursive() { + this[DJ](); + const t = this._states.length; + for (let e = 0; e < t; ++e) { + const t = this._states[e]; + t instanceof VZ && t.stateMachine.__callOnAfterDeserializeRecursive(); + } + } + constructor() { + super(); + Ml(this, "_states", iZ, this); + Ml(this, "_transitions", sZ, this); + Ml(this, "_entryState", nZ, this); + Ml(this, "_exitState", rZ, this); + Ml(this, "_anyState", oZ, this); + this._entryState = this._addState(new AJ); + this._entryState.name = "Entry"; + this._exitState = this._addState(new AJ); + this._exitState.name = "Exit"; + this._anyState = this._addState(new AJ); + this._anyState.name = "Any"; + } + [DJ]() { + this._states.forEach((t => sJ(t, this))); + this._transitions.forEach((t => { + t.from[bJ].push(t); + t.to[SJ].push(t); + })); + } + [uJ](t) { + throw new Error("Method not implemented."); + } + get entryState() { + return this._entryState; + } + get exitState() { + return this._exitState; + } + get anyState() { + return this._anyState; + } + states() { + return this._states; + } + transitions() { + return this._transitions; + } + getTransitionsBetween(t, e) { + iJ(t, this); + iJ(e, this); + return t[bJ].filter((t => t.to === e)); + } + getOutgoings(t) { + iJ(t, this); + return t[bJ]; + } + getIncomings(t) { + iJ(t, this); + return t[SJ]; + } + addMotion() { + return this._addState(new MJ); + } + addSubStateMachine() { + return this._addState(new VZ); + } + addEmpty() { + return this._addState(new NZ); + } + remove(t) { + iJ(t, this); + if (t !== this.entryState && t !== this.exitState && t !== this.anyState) { + this.eraseTransitionsIncludes(t); + at(this._states, t); + nJ(t); + } + } + connect(t, e, i) { + iJ(t, this); + iJ(e, this); + if (e === this.entryState) throw new lJ("to-entry"); + if (e === this.anyState) throw new lJ("to-any"); + if (t === this.exitState) throw new lJ("from-exit"); + const s = t instanceof MJ || t === this._anyState ? new OZ(t, e, i) : t instanceof NZ ? new LZ(t, e, i) : new DZ(t, e, i); + sJ(s, this); + this._transitions.push(s); + t[bJ].push(s); + e[SJ].push(s); + return s; + } + disconnect(t, e) { + iJ(t, this); + iJ(e, this); + const i = t[bJ]; + const s = e[SJ]; + const n = this._transitions; + const r = i.filter((t => t.to === e)); + const o = r.length; + for (let t = 0; t < o; ++t) { + const e = r[t]; + at(i, e); + ne(at(n, e)); + se(lt(s, (t => t === e))); + nJ(e); + } + } + removeTransition(t) { + ne(at(this._transitions, t)); + se(lt(t.from[bJ], (e => e === t))); + se(lt(t.to[SJ], (e => e === t))); + nJ(t); + } + eraseOutgoings(t) { + iJ(t, this); + const e = t[bJ]; + for (let t = 0; t < e.length; ++t) { + const i = e[t]; + const s = i.to; + ne(at(this._transitions, i)); + se(lt(s[SJ], (t => t === i))); + nJ(i); + } + e.length = 0; + } + eraseIncomings(t) { + iJ(t, this); + const e = t[SJ]; + for (let t = 0; t < e.length; ++t) { + const i = e[t]; + const s = i.from; + ne(at(this._transitions, i)); + se(lt(s[bJ], (t => t === i))); + nJ(i); + } + e.length = 0; + } + eraseTransitionsIncludes(t) { + this.eraseIncomings(t); + this.eraseOutgoings(t); + } + adjustTransitionPriority(t, e) { + const {from: i} = t; + if (0 === e) return; + const s = i[bJ]; + const n = s.indexOf(t); + ne(n >= 0); + BJ(s, n, _i(n + e, 0, s.length - 1)); + } + clone() { + const e = new t; + const i = new Map; + for (const t of this._states) switch (t) { + case this._entryState: + i.set(t, e._entryState); + break; + + case this._exitState: + i.set(t, e._exitState); + break; + + case this._anyState: + i.set(t, e._anyState); + break; + + default: + if (t instanceof MJ || t instanceof VZ) { + const s = t.clone(); + e._addState(s); + i.set(t, s); + } else ne(!1); + } + for (const t of this._transitions) { + const s = i.get(t.from); + const n = i.get(t.to); + ne(s && n); + const r = e.connect(s, n); + r.conditions = t.conditions.map((t => t.clone())); + if (r instanceof OZ) { + ne(t instanceof OZ); + r.duration = t.duration; + r.exitConditionEnabled = t.exitConditionEnabled; + r.exitCondition = t.exitCondition; + } + } + return e; + } + _addState(t) { + sJ(t, this); + this._states.push(t); + return t; + } + }, aZ), iZ = Bl(eZ.prototype, "_states", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), sZ = Bl(eZ.prototype, "_transitions", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), nZ = Bl(eZ.prototype, "_entryState", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), rZ = Bl(eZ.prototype, "_exitState", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), oZ = Bl(eZ.prototype, "_anyState", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), eZ)) || tZ; + let VZ = Ul("cc.animation.SubStateMachine")(lZ = (hZ = (uZ = class t extends TJ { + constructor(...t) { + super(...t); + Ml(this, "_stateMachine", cZ, this); + } + get stateMachine() { + return this._stateMachine; + } + clone() { + const e = new t; + e._stateMachine = this._stateMachine.clone(); + return e; + } + }, uZ), cZ = Bl(hZ.prototype, "_stateMachine", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new FZ; + } + }), hZ)) || lZ; + let kZ = Ul("cc.animation.Layer")(_Z = (dZ = class { + constructor() { + this[eJ] = void 0; + Ml(this, "_stateMachine", pZ, this); + Ml(this, "name", mZ, this); + Ml(this, "weight", fZ, this); + Ml(this, "mask", gZ, this); + this._stateMachine = new FZ; + } + get stateMachine() { + return this._stateMachine; + } + }, pZ = Bl(dZ.prototype, "_stateMachine", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), mZ = Bl(dZ.prototype, "name", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), fZ = Bl(dZ.prototype, "weight", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), gZ = Bl(dZ.prototype, "mask", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), dZ)) || _Z; + let UZ; + !function(t) { + t[t.override = 0] = "override"; + t[t.additive = 1] = "additive"; + }(UZ || (UZ = {})); + ne(0 == (0 | oJ.AFTER_CONSUMED << 1)); + let GZ = Ul("cc.animation.PlainVariable")(yZ = (bZ = (TZ = class { + constructor(t) { + Ml(this, "_type", SZ, this); + Ml(this, "_value", AZ, this); + if (void 0 !== t) { + this._type = t; + switch (t) { + default: + break; + + case rJ.FLOAT: + case rJ.INTEGER: + this._value = 0; + break; + + case rJ.BOOLEAN: + this._value = !1; + } + } + } + get type() { + return this._type; + } + get value() { + return this._value; + } + set value(t) { + switch (this._type) { + default: + break; + + case rJ.FLOAT: + ne("number" == typeof t); + break; + + case rJ.INTEGER: + ne(Number.isInteger(t)); + break; + + case rJ.BOOLEAN: + ne("boolean" == typeof t); + } + this._value = t; + } + }, TZ), SZ = Bl(bZ.prototype, "_type", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return rJ.FLOAT; + } + }), AZ = Bl(bZ.prototype, "_value", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), bZ)) || yZ; + let zZ = Ul("cc.animation.TriggerVariable")(vZ = (EZ = (xZ = class { + constructor() { + Ml(this, "_flags", CZ, this); + } + get type() { + return rJ.TRIGGER; + } + get value() { + return !!((1 & this._flags) >> 0); + } + set value(t) { + t ? this._flags |= 1 : this._flags &= -2; + } + get resetMode() { + return (6 & this._flags) >> 1; + } + set resetMode(t) { + this._flags &= -7; + this._flags |= t << 1; + } + }, xZ), CZ = Bl(EZ.prototype, "_flags", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), EZ)) || vZ; + let HZ = Ul("cc.animation.AnimationGraph")(wZ = (RZ = (BZ = class extends gc { + constructor() { + super(); + Ml(this, "_layers", IZ, this); + Ml(this, "_variables", MZ, this); + } + onLoaded() { + const {_layers: t} = this; + const e = t.length; + for (let i = 0; i < e; ++i) { + t[i].stateMachine.__callOnAfterDeserializeRecursive(); + } + } + get layers() { + return this._layers; + } + get variables() { + return Object.entries(this._variables); + } + addLayer() { + const t = new kZ; + this._layers.push(t); + return t; + } + removeLayer(t) { + te.removeAt(this._layers, t); + } + moveLayer(t, e) { + BJ(this._layers, t, e); + } + addBoolean(t, e = !1) { + const i = new GZ(rJ.BOOLEAN); + i.value = e; + this._variables[t] = i; + } + addFloat(t, e = 0) { + const i = new GZ(rJ.FLOAT); + i.value = e; + this._variables[t] = i; + } + addInteger(t, e = 0) { + const i = new GZ(rJ.INTEGER); + i.value = e; + this._variables[t] = i; + } + addTrigger(t, e = !1, i = oJ.AFTER_CONSUMED) { + const s = new zZ; + s.resetMode = i; + s.value = e; + this._variables[t] = s; + } + removeVariable(t) { + delete this._variables[t]; + } + getVariable(t) { + return this._variables[t]; + } + renameVariable(t, e) { + const {_variables: i} = this; + t in i && (e in i || (this._variables = Object.entries(i).reduce(((i, [s, n]) => { + i[s === t ? e : s] = n; + return i; + }), {}))); + } + }, BZ), IZ = Bl(RZ.prototype, "_layers", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), MZ = Bl(RZ.prototype, "_variables", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return {}; + } + }), RZ)) || wZ; + const jZ = Symbol("BakeNodeCurves"); + class XZ { + static getOrExtract(t) { + let e = XZ.pool.get(t); + if (!e || e.samples !== t.sample) { + e && m.director.root.dataPoolManager.releaseAnimationClip(t); + const i = Math.ceil(t.sample * t.duration) + 1; + const s = t.sample; + e = t[jZ](0, s, i); + XZ.pool.set(t, e); + } + return e; + } + static destroy(t) { + XZ.pool.delete(t); + } + } + t("SkelAnimDataHub", XZ); + XZ.pool = new Map; + class WZ { + constructor(t) { + this.ratios = void 0; + this._findRatio = void 0; + this.ratios = t; + let e; + let i; + let s = !0; + for (let n = 1, r = t.length; n < r; n++) { + e = t[n] - t[n - 1]; + if (1 === n) i = e; else if (Math.abs(e - i) > 1e-6) { + s = !1; + break; + } + } + this._findRatio = s ? JZ : vl; + } + sample(t) { + return this._findRatio(this.ratios, t); + } + } + t("RatioSampler", WZ); + m.RatioSampler = WZ; + class YZ { + static Bezier(t) { + return t; + } + constructor(t, e) { + this.types = void 0; + this.type = null; + this._values = []; + this._lerp = void 0; + this._duration = void 0; + this._array = void 0; + this._duration = e; + this._values = t.values; + const i = t => "string" == typeof t ? t : Array.isArray(t) ? t[0] === t[1] && t[2] === t[3] ? YZ.Linear : YZ.Bezier(t) : YZ.Linear; + if (void 0 !== t.easingMethod) this.type = i(t.easingMethod); else if (Array.isArray(t.easingMethods)) this.types = t.easingMethods.map(i); else if (void 0 !== t.easingMethods) { + this.types = new Array(this._values.length).fill(null); + for (const e of Object.keys(t.easingMethods)) this.types[e] = i(t.easingMethods[e]); + } else this.type = null; + const s = t.values[0]; + (void 0 === t.interpolate || t.interpolate) && (this._lerp = ZZ(s)); + void 0 !== t._arrayLength && (this._array = new Array(t._arrayLength)); + } + hasLerp() { + return !!this._lerp; + } + valueAt(t) { + if (void 0 === this._array) { + const e = this._values[t]; + return e && e.getNoLerp ? e.getNoLerp() : e; + } + for (let e = 0; e < this._array.length; ++e) this._array[e] = this._values[this._array.length * t + e]; + return this._array; + } + valueBetween(t, e, i, s, n) { + if (this._lerp) { + const r = this.types ? this.types[e] : this.type; + const o = n - i; + let a = (t - i) / o; + r && (a = KZ(a, r)); + if (void 0 === this._array) { + const t = this._values[e]; + const i = this._values[s]; + return this._lerp(t, i, a, o * this._duration); + } + for (let t = 0; t < this._array.length; ++t) { + const i = this._values[this._array.length * e + t]; + const n = this._values[this._array.length * s + t]; + this._array[t] = this._lerp(i, n, a, o * this._duration); + } + return this._array; + } + if (void 0 === this._array) return this.valueAt(e); + for (let t = 0; t < this._array.length; ++t) this._array[t] = this._values[this._array.length * e + t]; + return this._array; + } + empty() { + return 0 === this._values.length; + } + constant() { + return 1 === this._values.length; + } + } + t("AnimCurve", YZ); + YZ.Linear = null; + m.AnimCurve = YZ; + t("EventInfo", class { + constructor() { + this.events = []; + } + add(t, e) { + this.events.push({ + func: t || "", + params: e || [] + }); + } + }); + function qZ(t, e, i) { + let s = e.sample(i); + if (s < 0) { + s = ~s; + if (s <= 0) s = 0; else { + if (!(s >= e.ratios.length)) return t.valueBetween(i, s - 1, e.ratios[s - 1], s, e.ratios[s]); + s = e.ratios.length - 1; + } + } + return t.valueAt(s); + } + m.sampleAnimationCurve = qZ; + function KZ(t, e) { + if ("string" == typeof e) { + const i = Td[e]; + i ? t = i(t) : F(3906, e); + } else Array.isArray(e) && (t = rp(e, t)); + return t; + } + function JZ(t, e) { + const i = t.length - 1; + if (0 === i) return 0; + const s = t[0]; + if (e < s) return 0; + const n = t[i]; + if (e > n) return i; + const r = (e = (e - s) / (n - s)) / (1 / i); + const o = 0 | r; + const a = 1e-6; + return r - o < a ? o : o + 1 - r < a ? o + 1 : ~(o + 1); + } + const ZZ = (() => { + function t(t, e, i, s) { + return t.lerp(e, i, s); + } + return e => { + if (null !== e) { + if ("number" == typeof e) return pi; + if ("object" == typeof e && e.constructor) { + if (e instanceof Ui) return function() { + const t = new Ui; + return (e, i, s, n) => Ui.slerp(t, e, i, s); + }(); + if (e instanceof ce) return function(t) { + const e = new t; + return (i, s, n) => { + t.lerp(e, i, s, n); + return e; + }; + }(e.constructor); + if (e.constructor === Number) return pi; + if ("function" == typeof e.lerp) return t; + } + } + }; + })(); + var QZ, $Z, tQ, eQ, iQ, sQ, nQ; + let rQ = Ul("cc.animation.UntypedTrackChannel")(QZ = ($Z = class extends Uq { + constructor() { + super(new Od); + Ml(this, "property", tQ, this); + } + }, tQ = Bl($Z.prototype, "property", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), $Z)) || QZ; + let oQ = Ul("cc.animation.UntypedTrack")(eQ = (iQ = (nQ = class extends kq { + constructor(...t) { + super(...t); + Ml(this, "_channels", sQ, this); + } + channels() { + return this._channels; + } + [OY](t) { + if (!t.getValue) throw new Error(G(3930)); + const e = t => { + var e; + return null === (e = this._channels.find((e => e.property === t))) || void 0 === e ? void 0 : e.curve; + }; + const i = t.getValue(); + switch (!0) { + default: + throw new Error(G(3931)); + + case i instanceof Qi: + return new NK(e("x"), e("y")); + + case i instanceof Pi: + return new LK(e("x"), e("y"), e("z")); + + case i instanceof is: + return new FK(e("x"), e("y"), e("z"), e("w")); + + case i instanceof Bi: + return new WK(e("r"), e("g"), e("b"), e("a")); + + case i instanceof rs: + return new QK(e("width"), e("height")); + } + } + addChannel(t) { + const e = new rQ; + e.property = t; + this._channels.push(e); + return e; + } + upgrade(t) { + const e = (t, e) => { + const i = this.channels().find((e => e.property === t)); + if (i) { + e.name = i.name; + e.curve.assignSorted(Array.from(i.curve.times()), Array.from(i.curve.values())); + } + }; + const i = t(this.path, this.proxy); + switch (i) { + default: + case "size": + break; + + case "vec2": + case "vec3": + case "vec4": + { + const t = new OK; + t.path = this.path; + t.proxy = this.proxy; + t.componentsCount = "vec2" === i ? 2 : "vec3" === i ? 3 : 4; + const [s, n, r, o] = t.channels(); + switch (i) { + case "vec4": + e("w", o); + + case "vec3": + e("z", r); + + default: + e("x", s); + e("y", n); + } + return t; + } + + case "color": + { + const t = new XK; + const [i, s, n, r] = t.channels(); + e("r", i); + e("g", s); + e("b", n); + e("a", r); + e("x", i); + e("y", s); + e("z", n); + e("w", r); + return t; + } + } + return null; + } + }, nQ), sQ = Bl(iQ.prototype, "_channels", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), iQ)) || eQ; + class aQ { + constructor(t) { + this._keys = []; + this._curves = []; + this._commonTargets = []; + this._ratioSamplers = []; + this._runtimeCurves = void 0; + this._data = null; + this._duration = void 0; + this._duration = t; + } + get keys() { + return this._keys; + } + set keys(t) { + this._keys = t; + } + get curves() { + return this._curves; + } + set curves(t) { + this._curves = t; + delete this._runtimeCurves; + } + get commonTargets() { + return this._commonTargets; + } + set commonTargets(t) { + this._commonTargets = t; + } + get data() { + return this._data; + } + getPropertyCurves() { + this._runtimeCurves || this._createPropertyCurves(); + return this._runtimeCurves; + } + toTracks() { + const t = []; + const {keys: e, curves: i, commonTargets: s} = this; + const n = (t, e, i) => { + const s = new Fq; + for (const t of e) "string" == typeof t ? s.toProperty(t) : "number" == typeof t ? s.toElement(t) : t instanceof _q ? s.toHierarchy(t.path) : t instanceof dq ? s.toComponent(t.component) : s.toCustomized(t); + t.path = s; + t.proxy = i; + }; + const r = s.map((e => { + const i = new oQ; + n(i, e.modifiers, e.valueAdapter); + t.push(i); + return i; + })); + for (const s of i) { + var o; + const i = s.data; + const a = i.values; + if (0 === a.length) continue; + const l = i.keys < 0 ? [ 0 ] : e[i.keys]; + const h = a[0]; + const c = null === (o = i.interpolate) || void 0 === o || o; + ne("number" != typeof i._arrayLength || "number" == typeof h); + const u = new hQ(i, l.length); + const _ = t => { + n(t, s.modifiers, s.valueAdapter); + }; + let d; + if ("number" == typeof s.commonTarget) { + if (!a.every((t => "number" == typeof t))) { + N(3932); + continue; + } + if (s.valueAdapter || 1 !== s.modifiers.length || "string" != typeof s.modifiers[0]) { + N(3933); + continue; + } + const t = s.modifiers[0]; + const e = r[s.commonTarget]; + const {curve: i} = e.addChannel(t); + d = i; + } + const p = () => { + if ("number" == typeof h) { + if (!a.every((t => "number" == typeof t))) { + N(3934); + return; + } + let e; + if (d) e = d; else { + const i = new xK; + _(i); + t.push(i); + e = i.channel.curve; + } + const i = c ? xl.LINEAR : xl.CONSTANT; + e.assignSorted(l, a.map((t => ({ + value: t, + interpolationMode: i + })))); + u.convert(e); + return; + } + if ("object" == typeof h) switch (!0) { + default: + break; + + case lQ(a, Qi): + case lQ(a, Pi): + case lQ(a, is): + { + const e = h instanceof Qi ? 2 : h instanceof Pi ? 3 : 4; + const i = new OK; + _(i); + i.componentsCount = e; + const [{curve: s}, {curve: n}, {curve: r}, {curve: o}] = i.channels(); + const d = c ? xl.LINEAR : xl.CONSTANT; + const p = t => ({ + value: t, + interpolationMode: d + }); + switch (e) { + case 4: + o.assignSorted(l, a.map((t => p(t.w)))); + u.convert(o); + + case 3: + r.assignSorted(l, a.map((t => p(t.z)))); + u.convert(r); + + default: + s.assignSorted(l, a.map((t => p(t.x)))); + u.convert(s); + n.assignSorted(l, a.map((t => p(t.y)))); + u.convert(n); + } + t.push(i); + return; + } + + case lQ(a, Ui): + { + const e = new kK; + _(e); + const i = c ? gp.SLERP : gp.CONSTANT; + e.channel.curve.assignSorted(l, a.map((t => ({ + value: Ui.clone(t), + interpolationMode: i + })))); + u.convertQuatCurve(e.channel.curve); + t.push(e); + return; + } + + case lQ(a, Bi): + { + const e = new XK; + _(e); + const [{curve: i}, {curve: s}, {curve: n}, {curve: r}] = e.channels(); + const o = c ? xl.LINEAR : xl.CONSTANT; + const h = t => ({ + value: t, + interpolationMode: o + }); + i.assignSorted(l, a.map((t => h(t.r)))); + u.convert(i); + s.assignSorted(l, a.map((t => h(t.g)))); + u.convert(s); + n.assignSorted(l, a.map((t => h(t.b)))); + u.convert(n); + r.assignSorted(l, a.map((t => h(t.a)))); + u.convert(r); + t.push(e); + return; + } + + case lQ(a, rs): + { + const e = new ZK; + _(e); + const [{curve: i}, {curve: s}] = e.channels(); + const n = c ? xl.LINEAR : xl.CONSTANT; + const r = t => ({ + value: t, + interpolationMode: n + }); + i.assignSorted(l, a.map((t => r(t.width)))); + u.convert(i); + s.assignSorted(l, a.map((t => r(t.height)))); + u.convert(s); + t.push(e); + return; + } + + case lQ(a, EK): + { + ne(u.nil); + const e = new xK; + _(e); + const i = c ? xl.CUBIC : xl.CONSTANT; + e.channel.curve.assignSorted(l, a.map((t => ({ + value: t.dataPoint, + leftTangent: t.inTangent, + rightTangent: t.outTangent, + interpolationMode: i + })))); + t.push(e); + return; + } + + case lQ(a, SK): + case lQ(a, AK): + case lQ(a, TK): + { + ne(u.nil); + const e = h instanceof SK ? 2 : h instanceof AK ? 3 : 4; + const i = new OK; + _(i); + i.componentsCount = e; + const [s, n, r, o] = i.channels(); + const d = c ? xl.LINEAR : xl.CONSTANT; + const p = (t, e, i) => ({ + value: t, + leftTangent: e, + rightTangent: i, + interpolationMode: d + }); + switch (e) { + case 4: + o.curve.assignSorted(l, a.map((t => p(t.dataPoint.w, t.inTangent.w, t.outTangent.w)))); + + case 3: + r.curve.assignSorted(l, a.map((t => p(t.dataPoint.z, t.inTangent.z, t.outTangent.z)))); + + default: + s.curve.assignSorted(l, a.map((t => p(t.dataPoint.y, t.inTangent.y, t.outTangent.y)))); + n.curve.assignSorted(l, a.map((t => p(t.dataPoint.x, t.inTangent.x, t.outTangent.x)))); + } + t.push(i); + return; + } + + case a.every((t => t instanceof vK)): + N(3935); + } + const e = new tJ; + _(e); + e.channel.curve.assignSorted(l, a); + t.push(e); + }; + p(); + } + return t; + } + _createPropertyCurves() { + this._ratioSamplers = this._keys.map((t => new WZ(t.map((t => t / this._duration))))); + this._runtimeCurves = this._curves.map((t => ({ + curve: new YZ(t.data, this._duration), + modifiers: t.modifiers, + valueAdapter: t.valueAdapter, + sampler: this._ratioSamplers[t.data.keys], + commonTarget: t.commonTarget + }))); + } + } + function lQ(t, e) { + return t.every((t => t instanceof e)); + } + class hQ { + constructor(t, e) { + this._easingMethods = void 0; + const {easingMethods: i} = t; + Array.isArray(i) ? 0 === i.length && 0 !== e ? this._easingMethods = new Array(e).fill(null) : this._easingMethods = i : this._easingMethods = void 0 === i ? new Array(e).fill(t.easingMethod) : Array.from({ + length: e + }, ((t, e) => { + var s; + return null !== (s = i[e]) && void 0 !== s ? s : null; + })); + } + get nil() { + return !this._easingMethods || this._easingMethods.every((t => null == t)); + } + convert(t) { + const {_easingMethods: e} = this; + if (!e) return; + const i = t.keyFramesCount; + if (t.keyFramesCount < 2) return; + Array.isArray(e) && ne(i === e.length); + const s = i - 1; + for (let i = 0; i < s; ++i) { + const s = e[i]; + s && (Array.isArray(s) ? dQ(s, t.getKeyframeTime(i), t.getKeyframeValue(i), t.getKeyframeTime(i + 1), t.getKeyframeValue(i + 1)) : cQ(s, t, i)); + } + } + convertQuatCurve(t) { + const {_easingMethods: e} = this; + if (!e) return; + const i = t.keyFramesCount; + if (t.keyFramesCount < 2) return; + Array.isArray(e) && ne(i === e.length); + const s = i - 1; + for (let i = 0; i < s; ++i) { + const s = e[i]; + s && (Array.isArray(s) ? t.getKeyframeValue(i).easingMethod = s.slice() : uQ(s, t, i)); + } + } + } + function cQ(t, e, i) { + ne(i !== e.keyFramesCount - 1); + ne(t in _Q); + const s = e.getKeyframeValue(i); + const n = _Q[t]; + if (n === vd.CONSTANT) s.interpolationMode = xl.CONSTANT; else { + s.interpolationMode = xl.LINEAR; + s.easingMethod = n; + } + } + function uQ(t, e, i) { + ne(i !== e.keyFramesCount - 1); + ne(t in _Q); + const s = e.getKeyframeValue(i); + const n = _Q[t]; + s.easingMethod = n; + } + const _Q = { + constant: vd.CONSTANT, + linear: vd.LINEAR, + quadIn: vd.QUAD_IN, + quadOut: vd.QUAD_OUT, + quadInOut: vd.QUAD_IN_OUT, + quadOutIn: vd.QUAD_OUT_IN, + cubicIn: vd.CUBIC_IN, + cubicOut: vd.CUBIC_OUT, + cubicInOut: vd.CUBIC_IN_OUT, + cubicOutIn: vd.CUBIC_OUT_IN, + quartIn: vd.QUART_IN, + quartOut: vd.QUART_OUT, + quartInOut: vd.QUART_IN_OUT, + quartOutIn: vd.QUART_OUT_IN, + quintIn: vd.QUINT_IN, + quintOut: vd.QUINT_OUT, + quintInOut: vd.QUINT_IN_OUT, + quintOutIn: vd.QUINT_OUT_IN, + sineIn: vd.SINE_IN, + sineOut: vd.SINE_OUT, + sineInOut: vd.SINE_IN_OUT, + sineOutIn: vd.SINE_OUT_IN, + expoIn: vd.EXPO_IN, + expoOut: vd.EXPO_OUT, + expoInOut: vd.EXPO_IN_OUT, + expoOutIn: vd.EXPO_OUT_IN, + circIn: vd.CIRC_IN, + circOut: vd.CIRC_OUT, + circInOut: vd.CIRC_IN_OUT, + circOutIn: vd.CIRC_OUT_IN, + elasticIn: vd.ELASTIC_IN, + elasticOut: vd.ELASTIC_OUT, + elasticInOut: vd.ELASTIC_IN_OUT, + elasticOutIn: vd.ELASTIC_OUT_IN, + backIn: vd.BACK_IN, + backOut: vd.BACK_OUT, + backInOut: vd.BACK_IN_OUT, + backOutIn: vd.BACK_OUT_IN, + bounceIn: vd.BOUNCE_IN, + bounceOut: vd.BOUNCE_OUT, + bounceInOut: vd.BOUNCE_IN_OUT, + bounceOutIn: vd.BOUNCE_OUT_IN, + smooth: vd.SMOOTH, + fade: vd.FADE + }; + function dQ(t, e, i, s, n) { + const [r, o, a, l] = t; + const {value: h} = i; + const {value: c} = n; + const u = 3 * (s - e); + const _ = 3 * (c - h); + const d = r * u; + const p = o * _; + const m = (1 - a) * u; + const f = (1 - l) * _; + const g = 1 / 3; + const y = p / d; + const b = Math.sqrt(d * d + p * p) * g; + const S = f / m; + const A = Math.sqrt(m * m + f * f) * g; + i.interpolationMode = xl.CUBIC; + i.tangentWeightMode = (T = i.tangentWeightMode) === Rl.NONE ? Rl.RIGHT : T === Rl.LEFT ? Rl.BOTH : T; + var T; + i.rightTangent = y; + i.rightTangentWeight = b; + n.tangentWeightMode = function(t) { + return t === Rl.NONE ? Rl.LEFT : t === Rl.RIGHT ? Rl.BOTH : t; + }(n.tangentWeightMode); + n.leftTangent = S; + n.leftTangentWeight = A; + } + var pQ, mQ, fQ, gQ, yQ, bQ, SQ, AQ, TQ, vQ, EQ, CQ, xQ, wQ, RQ, IQ, MQ, BQ, DQ, PQ, OQ, NQ, LQ, FQ, VQ, kQ, UQ, GQ, zQ, HQ; + function jQ() { + throw new Error("split() only valid in Editor."); + } + Ul("cc.animation.ExoticAnimation")(pQ = (mQ = (gQ = class { + constructor() { + Ml(this, "_nodeAnimations", fQ, this); + } + createEvaluator(t) { + return new QQ(this._nodeAnimations, t); + } + addNodeAnimation(t) { + const e = new XQ(t); + this._nodeAnimations.push(e); + return e; + } + collectAnimatedJoints() { + return Array.from(new Set(this._nodeAnimations.map((({path: t}) => t)))); + } + split(t, e) { + return jQ(); + } + toHashString() { + return this._nodeAnimations.map((t => t.toHashString())).join("\n"); + } + }, gQ), fQ = Bl(mQ.prototype, "_nodeAnimations", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), mQ)); + let XQ = Ul("cc.animation.ExoticNodeAnimation")(yQ = (bQ = (EQ = class { + constructor(t) { + Ml(this, "_path", SQ, this); + Ml(this, "_position", AQ, this); + Ml(this, "_rotation", TQ, this); + Ml(this, "_scale", vQ, this); + this._path = t; + } + createPosition(t, e) { + this._position = new ZQ(t, new KQ(e)); + } + createRotation(t, e) { + this._rotation = new ZQ(t, new JQ(e)); + } + createScale(t, e) { + this._scale = new ZQ(t, new KQ(e)); + } + createEvaluator(t) { + return new $Q(this._path, this._position, this._rotation, this._scale, t); + } + split(t, e, i) { + return jQ(); + } + get path() { + return this._path; + } + toHashString() { + var t, e, i, s, n, r; + return `${this._path}\n${null !== (t = null === (e = this._position) || void 0 === e ? void 0 : e.toHashString()) && void 0 !== t ? t : ""}${null !== (i = null === (s = this._scale) || void 0 === s ? void 0 : s.toHashString()) && void 0 !== i ? i : ""}${null !== (n = null === (r = this._rotation) || void 0 === r ? void 0 : r.toHashString()) && void 0 !== n ? n : ""}`; + } + }, EQ), SQ = Bl(bQ.prototype, "_path", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), AQ = Bl(bQ.prototype, "_position", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), TQ = Bl(bQ.prototype, "_rotation", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), vQ = Bl(bQ.prototype, "_scale", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), bQ)) || yQ; + function WQ(t) { + return t.toPrecision(2); + } + function YQ(t) { + return t.map(WQ).join(" "); + } + let qQ = Ul("cc.animation.ExoticVectorLikeTrackValues")(CQ = (xQ = (IQ = class { + constructor(t) { + Ml(this, "_values", wQ, this); + Ml(this, "_isQuantized", RQ, this); + this._values = t; + this._isQuantized = !1; + } + get precision() { + return this._isQuantized ? this._values.originalPrecision : s$(this._values); + } + quantize(t) { + ne(!this._isQuantized); + this._values = function(t, e) { + const i = e$[e]; + const s = 1 << i.BYTES_PER_ELEMENT; + let n = Number.POSITIVE_INFINITY; + let r = Number.NEGATIVE_INFINITY; + t.forEach((t => { + n = Math.min(t, n); + r = Math.max(t, r); + })); + const o = r - n; + const a = i.from(t, (t => (t - n) / o * s)); + return new n$(s$(t), a, o, n); + }(this._values, t); + this._isQuantized = !0; + } + toHashString() { + const {_isQuantized: t, _values: e} = this; + return `${t} ${t ? e.toHashString() : YQ(e)}`; + } + }, IQ), wQ = Bl(xQ.prototype, "_values", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), RQ = Bl(xQ.prototype, "_isQuantized", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), xQ)) || CQ; + let KQ = Ul("cc.animation.ExoticVec3TrackValues")(MQ = class t extends qQ { + static imitate(e, i) { + const s = new t(e); + i._isQuantized && s.quantize(i._values.quantizationType); + return s; + } + get(t, e) { + const {_values: i, _isQuantized: s} = this; + s ? a$(i, t, e) : Pi.fromArray(e, i, 3 * t); + } + lerp(t, e, i, s, n, r) { + const {_values: o, _isQuantized: a} = this; + if (a) { + a$(o, t, s); + a$(o, e, n); + } else { + Pi.fromArray(s, o, 3 * t); + Pi.fromArray(n, o, 3 * e); + } + Pi.lerp(r, s, n, i); + } + }) || MQ; + let JQ = Ul("cc.animation.ExoticQuatTrackValues")(BQ = class t extends qQ { + static imitate(e, i) { + const s = new t(e); + i._isQuantized && s.quantize(i._values.quantizationType); + return s; + } + get(t, e) { + const {_values: i, _isQuantized: s} = this; + s ? l$(i, t, e) : Ui.fromArray(e, i, 4 * t); + } + lerp(t, e, i, s, n, r) { + const {_values: o, _isQuantized: a} = this; + if (a) { + l$(o, t, s); + l$(o, e, n); + } else { + Ui.fromArray(s, o, 4 * t); + Ui.fromArray(n, o, 4 * e); + } + Ui.slerp(r, s, n, i); + } + }) || BQ; + let ZQ = Ul("cc.animation.ExoticTrack")(DQ = (PQ = (LQ = class { + constructor(t, e) { + Ml(this, "times", OQ, this); + Ml(this, "values", NQ, this); + this.times = t; + this.values = e; + } + toHashString() { + const {times: t, values: e} = this; + return `times: ${YQ(t)}; values: ${e.toHashString()}`; + } + }, LQ), OQ = Bl(PQ.prototype, "times", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), NQ = Bl(PQ.prototype, "values", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), PQ)) || DQ; + class QQ { + constructor(t, e) { + this._nodeEvaluations = void 0; + this._nodeEvaluations = t.map((t => t.createEvaluator(e))); + } + evaluate(t) { + this._nodeEvaluations.forEach((e => { + e.evaluate(t); + })); + } + } + class $Q { + constructor(t, e, i, s, n) { + this._position = null; + this._rotation = null; + this._scale = null; + e && (this._position = o$(e.times, e.values, Pi, t, "position", n)); + i && (this._rotation = o$(i.times, i.values, Ui, t, "rotation", n)); + s && (this._scale = o$(s.times, s.values, Pi, t, "scale", n)); + } + evaluate(t) { + if (this._position) { + const e = this._position.evaluator.evaluate(t); + this._position.runtimeBinding.setValue(e); + } + if (this._rotation) { + const e = this._rotation.evaluator.evaluate(t); + this._rotation.runtimeBinding.setValue(e); + } + if (this._scale) { + const e = this._scale.evaluator.evaluate(t); + this._scale.runtimeBinding.setValue(e); + } + } + } + class t$ { + constructor(t, e, i) { + this._times = void 0; + this._inputSampleResultCache = { + just: !1, + index: -1, + nextIndex: -1, + ratio: 0 + }; + this._values = void 0; + this._prevValue = void 0; + this._nextValue = void 0; + this._resultValue = void 0; + this._times = t; + this._values = e; + this._prevValue = new i; + this._nextValue = new i; + this._resultValue = new i; + } + evaluate(t) { + const {_times: e, _values: i, _resultValue: s} = this; + if (0 === e.length) return s; + const n = function(t, e, i) { + const s = t.length; + ne(0 !== s); + const n = t[0]; + const r = t[s - 1]; + if (e < n) { + i.just = !0; + i.index = 0; + } else if (e > r) { + i.just = !0; + i.index = s - 1; + } else { + const n = vl(t, e); + if (n >= 0) { + i.just = !0; + i.index = n; + } else { + const r = ~n; + ne(0 !== r && r !== s && s > 1); + const o = r - 1; + const a = t[o]; + const l = t[r]; + const h = (e - t[o]) / (l - a); + i.just = !1; + i.index = o; + i.nextIndex = r; + i.ratio = h; + } + } + return i; + }(e, t, this._inputSampleResultCache); + n.just ? i.get(n.index, s) : i.lerp(n.index, n.nextIndex, n.ratio, this._prevValue, this._nextValue, s); + return s; + } + } + const e$ = { + uint8: Uint8Array, + uint16: Uint16Array + }; + var i$; + !function(t) { + t[t.FLOAT_32 = 0] = "FLOAT_32"; + t[t.FLOAT_64 = 1] = "FLOAT_64"; + }(i$ || (i$ = {})); + function s$(t) { + switch (t.BYTES_PER_ELEMENT) { + default: + ne(!1); + + case 4: + return i$.FLOAT_32; + + case 8: + return i$.FLOAT_64; + } + } + let n$ = Ul("cc.animation.QuantizedFloatArray")(FQ = (VQ = (HQ = class { + get quantizationType() { + switch (this.values.BYTES_PER_ELEMENT) { + default: + case 1: + return "uint8"; + + case 2: + return "uint16"; + } + } + constructor(t, e, i, s = 0) { + Ml(this, "originalPrecision", kQ, this); + Ml(this, "min", UQ, this); + Ml(this, "extent", GQ, this); + Ml(this, "values", zQ, this); + this.originalPrecision = t; + this.values = e; + this.extent = i; + this.min = s; + } + toHashString() { + const {originalPrecision: t, min: e, extent: i, values: s} = this; + return `${t} ${WQ(e)} ${WQ(i)} ${s.join(" ")}`; + } + }, HQ), kQ = Bl(VQ.prototype, "originalPrecision", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), UQ = Bl(VQ.prototype, "min", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), GQ = Bl(VQ.prototype, "extent", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), zQ = Bl(VQ.prototype, "values", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: null + }), VQ)) || FQ; + function r$(t, e) { + return t.values[e] / (1 << t.values.BYTES_PER_ELEMENT) * t.extent + t.min; + } + function o$(t, e, i, s, n, r) { + const o = new Vq; + o.path = (new Fq).toHierarchy(s).toProperty(n); + const a = r(o); + if (!a) return null; + return { + runtimeBinding: a, + evaluator: new t$(t, e, i) + }; + } + function a$(t, e, i) { + Pi.set(i, r$(t, 3 * e + 0), r$(t, 3 * e + 1), r$(t, 3 * e + 2)); + } + function l$(t, e, i) { + Ui.set(i, r$(t, 4 * e + 0), r$(t, 4 * e + 1), r$(t, 4 * e + 2), r$(t, 4 * e + 3)); + } + var h$, c$, u$, _$, d$, p$, m$, f$, g$, y$, b$, S$, A$, T$; + const v$ = Symbol("SearchForRootBonePath"); + const E$ = Symbol("ExoticAnimation"); + const C$ = Symbol("[[EmbeddedPlayerCount]]"); + const x$ = Symbol("[[GetEmbeddedPlayers]]"); + const w$ = Symbol("[[AddEmbeddedPlayer]]"); + const R$ = Symbol("[[RemoveEmbeddedPlayer]]"); + const I$ = Symbol("[[ClearEmbeddedPlayers]]"); + let M$ = t("AnimationClip", Ul("cc.AnimationClip")(h$ = (c$ = (T$ = A$ = class t extends gc { + constructor(...t) { + super(...t); + Ml(this, "sample", u$, this); + Ml(this, "speed", _$, this); + Ml(this, "wrapMode", d$, this); + Ml(this, "enableTrsBlending", p$, this); + Ml(this, "_duration", m$, this); + Ml(this, "_hash", f$, this); + this.frameRate = 0; + Ml(this, "_tracks", g$, this); + Ml(this, "_exoticAnimation", y$, this); + this._legacyData = void 0; + this._legacyDataDirty = !1; + Ml(this, "_events", b$, this); + Ml(this, "_embeddedPlayers", S$, this); + this._runtimeEvents = { + ratios: [], + eventGroups: [] + }; + } + static createWithSpriteFrames(e, i) { + const s = new t; + s.sample = i || s.sample; + s.duration = e.length / s.sample; + const n = 1 / s.sample; + const r = new tJ; + r.path = (new Fq).toComponent("cc.Sprite").toProperty("spriteFrame"); + r.channels()[0].curve.assignSorted(e.map(((t, e) => [ n * e, t ]))); + s.addTrack(r); + return s; + } + get duration() { + return this._duration; + } + set duration(t) { + this._duration = t; + } + get tracksCount() { + return this._tracks.length; + } + get tracks() { + return this._tracks; + } + get hash() { + var t, e; + if (this._hash) return this._hash; + const i = `Exotic:${null !== (t = null === (e = this._exoticAnimation) || void 0 === e ? void 0 : e.toHashString()) && void 0 !== t ? t : ""}`; + return this._hash = Ur(i, 666); + } + get events() { + return this._events; + } + set events(t) { + this._events = t; + const e = []; + const i = []; + const s = this.events.sort(((t, e) => t.frame - e.frame)); + const n = s.length; + for (let t = 0; t < n; ++t) { + const n = s[t]; + const r = n.frame / this._duration; + let o = e.findIndex((t => t === r)); + if (o < 0) { + o = e.length; + e.push(r); + i.push({ + events: [] + }); + } + i[o].events.push({ + functionName: n.func, + parameters: n.params + }); + } + this._runtimeEvents = { + ratios: e, + eventGroups: i + }; + } + get [E$]() { + return this._exoticAnimation; + } + set [E$](t) { + this._exoticAnimation = t; + } + onLoaded() { + this.frameRate = this.sample; + this.events = this._events; + } + range() { + const t = { + min: 1 / 0, + max: -1 / 0 + }; + const {_tracks: e} = this; + const i = e.length; + for (let s = 0; s < i; ++s) { + const i = e[s].range(); + t.min = Math.min(t.min, i.min); + t.max = Math.max(t.max, i.max); + } + return t; + } + getTrack(t) { + return this._tracks[t]; + } + addTrack(t) { + const e = this._tracks.length; + this._tracks.push(t); + return e; + } + removeTrack(t) { + this._tracks.splice(t, 1); + } + clearTracks() { + this._tracks.length = 0; + } + containsAnyEvent() { + return 0 !== this._events.length; + } + createEventEvaluator(t) { + return new k$(t, this._runtimeEvents.ratios, this._runtimeEvents.eventGroups, this.wrapMode); + } + containsAnyEmbeddedPlayer() { + return 0 !== this._embeddedPlayers.length; + } + createEmbeddedPlayerEvaluator(t) { + return new B$(this._embeddedPlayers, t); + } + createEvaluator(t) { + const {target: e} = t; + return this._createEvalWithBinder(e, (i => { + if (t.mask && i.isMaskedOff(t.mask)) return; + const s = i.createRuntimeBinding(e, this.enableTrsBlending ? t.pose : void 0, !1); + s || N(3937, this.name, t.target instanceof _y ? t.target.name : t.target); + return null != s ? s : void 0; + }), t.rootMotion); + } + destroy() { + var t; + (null === (t = m.director.root) || void 0 === t ? void 0 : t.dataPoolManager) && m.director.root.dataPoolManager.releaseAnimationClip(this); + XZ.destroy(this); + return super.destroy(); + } + [jZ](t, e, i) { + const s = 1 / e; + const n = this._collectAnimatedJoints(); + const r = n.length; + const o = {}; + for (let t = 0; t < r; ++t) { + o[n[t]] = { + transforms: Array.from({ + length: i + }, (() => new qi)) + }; + } + const a = n.reduce(((t, e) => { + t[e] = new O$; + return t; + }), {}); + for (const t in a) { + const e = a[t]; + const i = t.lastIndexOf("/"); + if (i >= 0) { + const s = t.substring(0, i); + const n = a[s]; + n && (e.parent = n); + } + } + const l = this._createEvalWithBinder(void 0, (t => { + const e = t.parseTrsPath(); + if (!e) return; + const i = a[e.node]; + return i ? V$(i, e.property) : void 0; + }), void 0); + for (let e = 0; e < i; ++e) { + const i = t + s * e; + l.evaluate(i); + for (let t = 0; t < r; ++t) { + const i = n[t]; + qi.copy(o[i].transforms[e], a[i].globalTransform); + } + for (let t = 0; t < r; ++t) { + const e = n[t]; + a[e].invalidate(); + } + } + return { + samples: e, + frames: i, + joints: o + }; + } + upgradeUntypedTracks(t) { + const e = []; + const i = []; + const {_tracks: s} = this; + const n = s.length; + for (let r = 0; r < n; ++r) { + const n = s[r]; + if (!(n instanceof oQ)) continue; + const o = n.upgrade(t); + if (o) { + e.push(o); + i.push(n); + } + } + const r = i.length; + for (let t = 0; t < r; ++t) te.remove(s, i[t]); + s.push(...e); + } + [v$]() { + return this._searchForRootBonePath(); + } + get keys() { + return this._getLegacyData().keys; + } + set keys(t) { + this._legacyDataDirty = !0; + this._getLegacyData().keys = t; + } + get curves() { + this._legacyDataDirty = !0; + return this._getLegacyData().curves; + } + set curves(t) { + this._getLegacyData().curves = t; + } + get commonTargets() { + return this._getLegacyData().commonTargets; + } + set commonTargets(t) { + this._legacyDataDirty = !0; + this._getLegacyData().commonTargets = t; + } + get data() { + return this._getLegacyData().data; + } + getPropertyCurves() { + return this._getLegacyData().getPropertyCurves(); + } + get eventGroups() { + return this._runtimeEvents.eventGroups; + } + updateEventDatas() { + this.events = this._events; + } + hasEvents() { + return 0 !== this.events.length; + } + syncLegacyData() { + if (this._legacyData) { + this._fromLegacy(this._legacyData); + this._legacyData = void 0; + } + } + get [C$]() { + return this._embeddedPlayers.length; + } + [x$]() { + return this._embeddedPlayers; + } + [w$](t) { + this._embeddedPlayers.push(t); + } + [R$](t) { + const e = this._embeddedPlayers.indexOf(t); + e >= 0 && this._embeddedPlayers.splice(e, 1); + } + [I$]() { + this._embeddedPlayers.length = 0; + } + _createEvalWithBinder(t, e, i) { + if (this._legacyDataDirty) { + this._legacyDataDirty = !1; + this.syncLegacyData(); + } + const s = []; + let n; + i && (n = this._createRootMotionEvaluation(t, i, s)); + const r = []; + let o; + const {_tracks: a} = this; + const l = a.length; + for (let t = 0; t < l; ++t) { + const i = a[t]; + if (s.includes(i)) continue; + if (Array.from(i.channels()).every((({curve: t}) => 0 === t.keyFramesCount))) continue; + const n = e(i[Lq]); + if (!n) continue; + const o = i[OY](n); + r.push({ + binding: n, + trackEval: o + }); + } + this._exoticAnimation && (o = this._exoticAnimation.createEvaluator(e)); + return new D$(r, o, n); + } + _createRootMotionEvaluation(t, e, i) { + if (!(t instanceof _y)) { + F(3920); + return; + } + const s = this._searchForRootBonePath(); + if (!s) { + N(3923); + return; + } + const n = t.getChildByPath(s); + if (!n) { + N(3924); + return; + } + const r = new P$; + const o = []; + const {_tracks: a} = this; + const l = a.length; + for (let t = 0; t < l; ++t) { + const e = a[t]; + const {[Lq]: n} = e; + const l = n.parseTrsPath(); + if (!l) continue; + if (l.node !== s) continue; + i.push(e); + const h = V$(r, l.property); + if (!h) continue; + const c = e[OY](h); + o.push({ + binding: h, + trackEval: c + }); + } + return new L$(n, this._duration, r, o); + } + _searchForRootBonePath() { + const t = this._tracks.map((t => { + const e = t[Lq].parseTrsPath(); + if (e) { + const t = e.node; + return { + path: t, + rank: t.split("/").length + }; + } + return { + path: "", + rank: 0 + }; + })); + t.sort(((t, e) => t.rank - e.rank)); + const e = t.findIndex((t => 0 !== t.rank)); + if (e < 0) return ""; + const i = t.length; + const s = t[e]; + let n = !0; + for (let r = e + 1; r < i; ++r) { + const e = t[r]; + if (e.rank !== s.rank) break; + if (e.path !== s.path) { + n = !1; + break; + } + } + return n ? s.path : ""; + } + _getLegacyData() { + this._legacyData || (this._legacyData = this._toLegacy()); + return this._legacyData; + } + _toLegacy() { + const t = new aQ(this._duration); + t.keys = []; + t.curves = []; + t.commonTargets = []; + return t; + } + _fromLegacy(t) { + const e = t.toTracks(); + const i = e.length; + for (let t = 0; t < i; ++t) this.addTrack(e[t]); + } + _collectAnimatedJoints() { + const t = new Set; + const {_tracks: e} = this; + const i = e.length; + for (let s = 0; s < i; ++s) { + const i = e[s][Lq].parseTrsPath(); + i && t.add(i.node); + } + if (this._exoticAnimation) { + const e = this._exoticAnimation.collectAnimatedJoints(); + const i = e.length; + for (let s = 0; s < i; ++s) t.add(e[s]); + } + return Array.from(t); + } + }, A$.WrapMode = Al, T$), u$ = Bl(c$.prototype, "sample", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 60; + } + }), _$ = Bl(c$.prototype, "speed", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), d$ = Bl(c$.prototype, "wrapMode", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Al.Normal; + } + }), p$ = Bl(c$.prototype, "enableTrsBlending", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), m$ = Bl(c$.prototype, "_duration", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), f$ = Bl(c$.prototype, "_hash", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), g$ = Bl(c$.prototype, "_tracks", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), y$ = Bl(c$.prototype, "_exoticAnimation", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), b$ = Bl(c$.prototype, "_events", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), S$ = Bl(c$.prototype, "_embeddedPlayers", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), c$)) || h$); + m.AnimationClip = M$; + class B$ { + constructor(t, e) { + this._embeddedPlayers = t; + this._embeddedPlayerEvaluationInfos = t.map((t => { + const {playable: i} = t; + if (!i) return null; + const s = i.instantiate(e); + return s ? { + instantiatedPlayer: s, + entered: !1, + hostPauseTime: 0, + lastIterations: 0 + } : null; + })); + } + destroy() { + const {_embeddedPlayerEvaluationInfos: t} = this; + const e = t.length; + for (let s = 0; s < e; ++s) { + var i; + null === (i = t[s]) || void 0 === i || i.instantiatedPlayer.destroy(); + } + this._embeddedPlayerEvaluationInfos.length = 0; + } + evaluate(t, e) { + ne(Number.isInteger(e)); + const {_embeddedPlayers: i, _embeddedPlayerEvaluationInfos: s} = this; + const n = i.length; + for (let r = 0; r < n; ++r) { + const n = s[r]; + if (!n) continue; + const {entered: o, instantiatedPlayer: a, lastIterations: l} = n; + const {begin: h, end: c} = i[r]; + if (t >= h && t <= c) if (o) { + if (e !== l) { + a.stop(); + a.play(); + n.entered = !0; + } + } else { + a.play(); + n.entered = !0; + } else if (o) { + a.stop(); + n.entered = !1; + } + n.lastIterations = e; + if (n.entered) { + const e = t - h; + n.instantiatedPlayer.setTime(e); + } + } + } + notifyHostSpeedChanged(t) { + const {_embeddedPlayers: e, _embeddedPlayerEvaluationInfos: i} = this; + const s = e.length; + for (let n = 0; n < s; ++n) { + const s = i[n]; + if (!s) continue; + const {instantiatedPlayer: r} = s; + const {reconciledSpeed: o} = e[n]; + o && r.setSpeed(t); + } + } + notifyHostPlay(t) { + const {_embeddedPlayers: e, _embeddedPlayerEvaluationInfos: i} = this; + const s = e.length; + for (let n = 0; n < s; ++n) { + const s = i[n]; + if (!s) continue; + const {begin: r, end: o} = e[n]; + const {instantiatedPlayer: a, entered: l} = s; + if (l) { + const {hostPauseTime: e} = s; + if (a.randomAccess || ui(e, t, 1e-5)) { + const e = _i(t, r, o); + a.play(); + a.setTime(e - r); + } else a.stop(); + } + } + } + notifyHostPause(t) { + const {_embeddedPlayers: e, _embeddedPlayerEvaluationInfos: i} = this; + const s = e.length; + for (let e = 0; e < s; ++e) { + const s = i[e]; + if (!s) continue; + const {instantiatedPlayer: n, entered: r} = s; + if (r) { + n.pause(); + s.hostPauseTime = t; + } + } + } + notifyHostStop() { + const {_embeddedPlayers: t, _embeddedPlayerEvaluationInfos: e} = this; + const i = t.length; + for (let t = 0; t < i; ++t) { + const i = e[t]; + if (!i) continue; + const {instantiatedPlayer: s, entered: n} = i; + if (n) { + i.entered = !1; + s.stop(); + } + } + } + } + class D$ { + constructor(t, e, i) { + this._exoticAnimationEvaluator = void 0; + this._trackEvalStatues = []; + this._rootMotionEvaluation = void 0; + this._trackEvalStatues = t; + this._exoticAnimationEvaluator = e; + this._rootMotionEvaluation = i; + } + evaluate(t) { + const {_trackEvalStatues: e, _exoticAnimationEvaluator: i} = this; + const s = e.length; + for (let i = 0; i < s; ++i) { + const {trackEval: s, binding: n} = e[i]; + const r = s.evaluate(t, n); + n.setValue(r); + } + i && i.evaluate(t); + } + evaluateRootMotion(t, e) { + const {_rootMotionEvaluation: i} = this; + i && i.evaluate(t, e); + } + } + class P$ { + constructor() { + this.position = new Pi; + this.scale = new Pi(1, 1, 1); + this.rotation = new Ui; + this.eulerAngles = new Pi; + } + getTransform(t) { + qi.fromRTS(t, this.rotation, this.position, this.scale); + } + } + class O$ extends P$ { + constructor(...t) { + super(...t); + this.parent = null; + this._dirty = !0; + this._transform = new qi; + } + get globalTransform() { + const t = this._transform; + if (this._dirty) { + this._dirty = !1; + qi.fromRTS(t, this.rotation, this.position, this.scale); + this.parent && qi.multiply(t, this.parent.globalTransform, t); + } + return this._transform; + } + invalidate() { + this._dirty = !0; + } + } + const N$ = new qi; + class L$ { + constructor(t, e, i, s) { + this._initialTransformCache = new qi; + this._clipEndTransformCache = new qi; + this._startTransformCache = new qi; + this._endTransformCache = new qi; + this._motionTransformCache = new qi; + this._translationMotionCache = new Pi; + this._rotationMotionCache = new Ui; + this._scaleMotionCache = new Pi; + this._rootBone = t; + this._duration = e; + this._boneTransform = i; + this._trackEvalStatuses = s; + } + evaluate(t, e) { + const i = this._calcMotionTransform(t, e, this._motionTransformCache); + const {_translationMotionCache: s, _rotationMotionCache: n, _scaleMotionCache: r, _rootBone: o} = this; + qi.toRTS(i, n, s, r); + Pi.add(s, s, o.position); + o.setPosition(s); + Ui.multiply(n, n, o.rotation); + o.setRotation(n); + Pi.multiply(r, r, o.scale); + o.setScale(r); + } + _calcMotionTransform(t, e, i) { + const {_duration: s} = this; + const n = s - t; + ne(n >= 0); + const r = this._evaluateAt(t, this._startTransformCache); + if (e < n) { + const s = this._evaluateAt(t + e, this._endTransformCache); + F$(i, r, s); + } else { + qi.identity(i); + const t = (t, e) => { + F$(N$, t, e); + qi.multiply(i, i, N$); + }; + const o = e - n; + const a = Math.floor(o / s); + const l = o - a * s; + const h = this._evaluateAt(0, this._initialTransformCache); + const c = this._evaluateAt(s, this._clipEndTransformCache); + const u = this._evaluateAt(l, this._endTransformCache); + t(r, c); + F$(N$, h, c); + for (let t = 0; t < a; ++t) qi.multiply(i, i, N$); + t(h, u); + } + return i; + } + _evaluateAt(t, e) { + const {_trackEvalStatuses: i} = this; + const s = i.length; + for (let e = 0; e < s; ++e) { + const {trackEval: s, binding: n} = i[e]; + const r = s.evaluate(t, n); + n.setValue(r); + } + this._boneTransform.getTransform(e); + return e; + } + } + function F$(t, e, i) { + qi.invert(t, e); + qi.multiply(t, i, t); + } + function V$(t, e) { + switch (e) { + default: + return; + + case "position": + return { + setValue(e) { + Pi.copy(t.position, e); + } + }; + + case "rotation": + return { + setValue(e) { + Ui.copy(t.rotation, e); + } + }; + + case "scale": + return { + setValue(e) { + Pi.copy(t.scale, e); + } + }; + + case "eulerAngles": + return { + setValue(e) { + Pi.copy(t.eulerAngles, e); + } + }; + } + } + class k$ { + constructor(t, e, i, s) { + this._lastFrameIndex = -1; + this._lastIterations = 0; + this._lastDirection = 0; + this._ignoreIndex = -1; + this._sampled = !1; + this._targetNode = t; + this._ratios = e; + this._eventGroups = i; + this._wrapMode = s; + } + setWrapMode(t) { + this._wrapMode = t; + } + ignore(t, e) { + this._ignoreIndex = -1; + this._sampled = !1; + let i = G$(t, this._ratios); + if (i < 0) { + i = ~i - 1; + e < 0 && (i += 1); + this._ignoreIndex = i; + } + } + sample(t, e, i) { + const s = this._eventGroups.length; + let n = G$(t, this._ratios); + if (n < 0) { + n = ~n - 1; + e < 0 && (n += 1); + } + this._ignoreIndex !== n && (this._ignoreIndex = -1); + if (!this._sampled) { + this._sampled = !0; + this._doFire(n, !1); + this._lastFrameIndex = n; + this._lastIterations = i; + this._lastDirection = e; + return; + } + const r = this._wrapMode; + const o = U$(i); + let a = U$(this._lastIterations); + let l = this._lastFrameIndex; + const h = this._lastDirection; + const c = -1 !== a && o !== a; + if (l === n && c && 1 === s) this._doFire(0, !1); else if (l !== n || c) { + e = h; + do { + if (l !== n) { + if (-1 === e && 0 === l && n > 0) { + (r & Sl.PingPong) === Sl.PingPong ? e *= -1 : l = s; + a++; + } else if (1 === e && l === s - 1 && n < s - 1) { + (r & Sl.PingPong) === Sl.PingPong ? e *= -1 : l = -1; + a++; + } + if (l === n) break; + if (a > o) break; + } + l += e; + this._doFire(l, !0); + } while (l !== n && l > -1 && l < s); + } + this._lastFrameIndex = n; + this._lastIterations = i; + this._lastDirection = e; + } + _doFire(t, e) { + e ? XY().pushDelayEvent(this._checkAndFire, this, [ t ]) : this._checkAndFire(t); + } + _checkAndFire(t) { + if (!this._targetNode || !this._targetNode.isValid) return; + const {_eventGroups: e} = this; + if (t < 0 || t >= e.length || this._ignoreIndex === t) return; + const i = e[t]; + const s = this._targetNode.components; + const n = i.events.length; + for (let t = 0; t < n; ++t) { + const e = i.events[t]; + const {functionName: n} = e; + const r = s.length; + for (let t = 0; t < r; ++t) { + const i = s[t]; + const r = i[n]; + "function" == typeof r && r.apply(i, e.parameters); + } + } + } + } + function U$(t) { + t - (0 | t) == 0 && (t -= 1); + return 0 | t; + } + function G$(t, e) { + return vl(e, t); + } + const z$ = j$; + const H$ = j$; + function j$(...t) {} + var X$, W$, Y$, q$, K$, J$; + X$ = Ul("cc.animation.ClipMotion"), W$ = Th(M$), X$(Y$ = (q$ = (J$ = class t extends Ch { + constructor(...t) { + super(...t); + Ml(this, "clip", K$, this); + } + [uJ](t) { + if (!this.clip) return null; + return new Z$(t, this.clip); + } + clone() { + const e = new t; + e.clip = this.clip; + return e; + } + }, J$), K$ = Bl(q$.prototype, "clip", [ W$ ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), q$)); + class Z$ { + constructor(t, e) { + this.duration = e.duration / e.speed; + this._state = new YY(e); + this._state.initialize(t.node, t.blendBuffer, t.mask); + } + getClipStatuses(t) { + let e = !1; + return { + next: () => { + if (e) return { + done: !0, + value: void 0 + }; + e = !0; + return { + done: !1, + value: { + __DEBUG_ID__: this.__DEBUG__ID__, + clip: this._state.clip, + weight: t + } + }; + } + }; + } + get progress() { + return this._state.time / this.duration; + } + sample(t, e) { + if (0 === e) return; + const i = this._state.duration * t; + this._state.time = i; + this._state.weight = e; + this._state.sample(); + this._state.weight = 0; + } + } + var Q$, $$, t0, e0, i0, s0, n0, r0, o0, a0; + let l0 = Ul("cc.animation.BindableNumber")(Q$ = ($$ = (i0 = class t { + constructor(t = 0) { + Ml(this, "variable", t0, this); + Ml(this, "value", e0, this); + this.value = t; + } + clone() { + const e = new t; + e.value = this.value; + e.variable = this.variable; + return e; + } + }, i0), t0 = Bl($$.prototype, "variable", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), e0 = Bl($$.prototype, "value", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), $$)) || Q$; + let h0 = Ul("cc.animation.BindableBoolean")(s0 = (n0 = (a0 = class t { + constructor(t = !1) { + Ml(this, "variable", r0, this); + Ml(this, "value", o0, this); + this.value = t; + } + clone() { + const e = new t; + e.value = this.value; + e.variable = this.variable; + return e; + } + }, a0), r0 = Bl(n0.prototype, "variable", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), o0 = Bl(n0.prototype, "value", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), n0)) || s0; + function c0(t, e, i, s, n, ...r) { + const {variable: o, value: a} = e; + if (!o) return a; + const l = t.getVar(o); + if (!_0(l, o)) return a; + if (l.type !== i) throw new cJ(o, "number"); + return l.bind(s, n, ...r); + } + function u0(t, e, i, s, n, ...r) { + const {variable: o, value: a} = e; + if (!o) return a; + const l = t.getVar(o); + if (!_0(l, o)) return a; + if (i !== rJ.FLOAT && i !== rJ.INTEGER) throw new cJ(o, "number or integer"); + return l.bind(s, n, ...r); + } + function _0(t, e) { + if (t) return !0; + throw new hJ(e); + } + var d0, p0, m0, f0, g0, y0, b0; + let S0 = Ul("cc.animation.AnimationBlendItem")(d0 = (p0 = (f0 = class t { + constructor() { + Ml(this, "motion", m0, this); + } + clone() { + const e = new t; + this._assign(e); + return e; + } + _assign(t) { + var e, i; + t.motion = null !== (e = null === (i = this.motion) || void 0 === i ? void 0 : i.clone()) && void 0 !== e ? e : null; + return t; + } + }, f0), m0 = Bl(p0.prototype, "motion", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), p0)) || d0; + let A0 = Ul("cc.animation.AnimationBlend")(g0 = (y0 = class extends Ch { + constructor(...t) { + super(...t); + Ml(this, "name", b0, this); + } + }, b0 = Bl(y0.prototype, "name", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), y0)) || g0; + class T0 { + constructor(t, e, i, s) { + this._childEvaluators = i.map((e => { + var i, s; + return null !== (i = null === (s = e.motion) || void 0 === s ? void 0 : s[uJ](t)) && void 0 !== i ? i : null; + })); + this._weights = new Array(this._childEvaluators.length).fill(0); + this._inputs = [ ...s ]; + } + get childCount() { + return this._weights.length; + } + getChildWeight(t) { + return this._weights[t]; + } + getChildMotionEval(t) { + return this._childEvaluators[t]; + } + get duration() { + let t = 0; + for (let s = 0; s < this._childEvaluators.length; ++s) { + var e, i; + t += (null !== (e = null === (i = this._childEvaluators[s]) || void 0 === i ? void 0 : i.duration) && void 0 !== e ? e : 0) * this._weights[s]; + } + return t; + } + getClipStatuses(t) { + const {_childEvaluators: e, _weights: i} = this; + const s = e.length; + let n = 0; + let r; + return { + next() { + for (;;) { + if (r) { + const t = r.next(); + if (!t.done) return t; + } + if (n >= s) return { + done: !0, + value: void 0 + }; + { + const s = e[n]; + r = null == s ? void 0 : s.getClipStatuses(t * i[n]); + ++n; + } + } + } + }; + } + sample(t, e) { + for (let s = 0; s < this._childEvaluators.length; ++s) { + var i; + null === (i = this._childEvaluators[s]) || void 0 === i || i.sample(t, e * this._weights[s]); + } + } + setInput(t, e) { + this._inputs[e] = t; + this.doEval(); + } + doEval() { + this.eval(this._weights, this._inputs); + } + eval(t, e) {} + } + var v0, E0, C0, x0, w0, R0, I0, M0, B0, D0; + let P0 = Ul("cc.animation.AnimationBlend1DItem")(v0 = (E0 = (x0 = class t extends S0 { + constructor(...t) { + super(...t); + Ml(this, "threshold", C0, this); + } + clone() { + const e = new t; + this._assign(e); + return e; + } + _assign(t) { + super._assign(t); + t.threshold = this.threshold; + return t; + } + }, x0), C0 = Bl(E0.prototype, "threshold", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), E0)) || v0; + Ul("cc.animation.AnimationBlend1D")(w0 = (R0 = (D0 = B0 = class t extends A0 { + constructor(...t) { + super(...t); + Ml(this, "_items", I0, this); + Ml(this, "param", M0, this); + } + get items() { + return this._items; + } + set items(t) { + this._items = Array.from(t).sort((({threshold: t}, {threshold: e}) => t - e)); + } + clone() { + const e = new t; + e._items = this._items.map((t => t.clone())); + e.param = this.param.clone(); + return e; + } + [uJ](t) { + const e = new O0(t, this, this._items, this._items.map((({threshold: t}) => t)), 0); + const i = c0(t, this.param, rJ.FLOAT, e.setInput, e, 0); + e.setInput(i, 0); + return e; + } + }, B0.Item = P0, D0), I0 = Bl(R0.prototype, "_items", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), M0 = Bl(R0.prototype, "param", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new l0; + } + }), R0)); + class O0 extends T0 { + constructor(t, e, i, s, n) { + super(t, e, i, [ n ]); + this._thresholds = s; + this.doEval(); + } + eval(t, [e]) { + !function(t, e, i) { + t.fill(0); + if (0 === e.length) ; else if (i <= e[0]) t[0] = 1; else if (i >= e[e.length - 1]) t[t.length - 1] = 1; else { + let s = 0; + for (let t = 1; t < e.length; ++t) if (e[t] > i) { + s = t; + break; + } + const n = e[s - 1]; + const r = e[s]; + const o = r - n; + t[s - 1] = (r - i) / o; + t[s] = (i - n) / o; + } + }(t, this._thresholds, e); + } + } + const N0 = (() => { + const t = new Qi; + const e = { + wA: 0, + wB: 0 + }; + return function(i, s, n) { + ne(i.length === s.length); + if (0 === s.length) return; + if (1 === s.length) { + i[0] = 1; + return; + } + if (Qi.strictEquals(n, Qi.ZERO)) { + const t = s.findIndex((t => Qi.strictEquals(t, Qi.ZERO))); + t >= 0 ? i[t] = 1 : i.fill(1 / s.length); + return; + } + let r = -1; + let o = -1; + let a = -1; + let l = Number.NEGATIVE_INFINITY; + let h = Number.NEGATIVE_INFINITY; + const {x: c, y: u} = n; + for (let e = 0; e < s.length; ++e) { + const i = s[e]; + if (Qi.equals(i, Qi.ZERO)) { + a = e; + continue; + } + const _ = Qi.normalize(t, i); + const d = Qi.dot(_, n); + if (_.x * u - _.y * c > 0) { + if (d >= h) { + h = d; + r = e; + } + } else if (d >= l) { + l = d; + o = e; + } + } + let _ = 0; + if (r < 0 || o < 0) _ = 1; else { + const {wA: t, wB: a} = function(t, e, i, s) { + const n = Qi.cross(t, e); + if (n) { + s.wA = Qi.cross(i, e) / n; + s.wB = Qi.cross(i, t) / -n; + } else { + s.wA = 0; + s.wB = 0; + } + return s; + }(s[r], s[o], n, e); + let l = 0; + let h = 0; + const c = t + a; + if (c > 1) { + l = t / c; + h = a / c; + } else if (c < 0) { + l = 0; + h = 0; + _ = 1; + } else { + l = t; + h = a; + _ = 1 - c; + } + i[r] = l; + i[o] = h; + } + if (_ > 0) if (a >= 0) i[a] = _; else { + const t = _ / i.length; + for (let e = 0; e < i.length; ++e) i[e] += t; + } + }; + })(); + function L0(t, e, i, s) { + t.fill(0); + const n = new Qi(0, 0); + const r = new Qi(0, 0); + let o = 0; + const a = e.length; + for (let l = 0; l < a; ++l) { + let h = Number.MAX_VALUE; + let c = !1; + for (let t = 0; t < a; ++t) { + if (l === t) continue; + s(e[l], e[t], i, n, r); + const o = 1 - Qi.dot(n, r) / Qi.lengthSqr(r); + if (o < 0) { + c = !0; + break; + } + h = Math.min(h, o); + } + if (!c) { + t[l] = h; + o += h; + } + } + o > 0 && t.forEach(((e, i) => t[i] = e / o)); + } + const F0 = (t, e, i, s, n) => { + Qi.subtract(s, i, t); + Qi.subtract(n, e, t); + }; + const V0 = (() => { + const t = new Pi(0, 0, 0); + const e = new Pi(0, 0, 0); + const i = new Pi(0, 0, 0); + const s = new Pi(0, 0, 0); + const n = new Pi(0, 0, 0); + const r = new Pi(0, 0, 0); + return (o, a, l, h, c) => { + let u = 0; + let _ = 0; + let d = 2; + Pi.set(i, l.x, l.y, 0); + if (Qi.equals(o, Qi.ZERO)) { + u = Qi.angle(l, a); + _ = 0; + d = 1; + } else if (Qi.equals(a, Qi.ZERO)) { + u = Qi.angle(l, o); + _ = u; + d = 1; + } else { + u = Qi.angle(o, a); + if (u <= 0) _ = 0; else if (Qi.equals(l, Qi.ZERO)) _ = u; else { + Pi.set(s, o.x, o.y, 0); + Pi.set(n, a.x, a.y, 0); + Pi.set(r, l.x, l.y, 0); + Pi.cross(t, s, n); + Pi.projectOnPlane(i, r, t); + _ = Pi.angle(s, i); + u < .99 * Math.PI && Pi.dot(Pi.cross(e, s, i), t) < 0 && (_ = -_); + } + } + const p = Qi.len(o); + const m = Qi.len(a); + const f = (m + p) / 2; + Qi.set(c, (m - p) / f, u * d); + Qi.set(h, (Pi.len(i) - p) / f, _ * d); + }; + })(); + var k0, U0, G0, z0, H0, j0, X0, W0, Y0, q0, K0, J0; + var Z0; + !function(t) { + t[t.SIMPLE_DIRECTIONAL = 0] = "SIMPLE_DIRECTIONAL"; + t[t.FREEFORM_CARTESIAN = 1] = "FREEFORM_CARTESIAN"; + t[t.FREEFORM_DIRECTIONAL = 2] = "FREEFORM_DIRECTIONAL"; + }(Z0 || (Z0 = {})); + he(Z0); + let Q0 = Ul("cc.animation.AnimationBlend2DItem")(k0 = (U0 = (z0 = class t extends S0 { + constructor(...t) { + super(...t); + Ml(this, "threshold", G0, this); + } + clone() { + const e = new t; + this._assign(e); + return e; + } + _assign(t) { + super._assign(t); + Qi.copy(t.threshold, this.threshold); + return t; + } + }, z0), G0 = Bl(U0.prototype, "threshold", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Qi; + } + }), U0)) || k0; + Ul("cc.animation.AnimationBlend2D")(H0 = (j0 = (J0 = K0 = class t extends A0 { + constructor(...t) { + super(...t); + Ml(this, "algorithm", X0, this); + Ml(this, "_items", W0, this); + Ml(this, "paramX", Y0, this); + Ml(this, "paramY", q0, this); + } + get items() { + return this._items; + } + set items(t) { + this._items = Array.from(t); + } + clone() { + const e = new t; + e._items = this._items.map((t => { + var e; + return null !== (e = null == t ? void 0 : t.clone()) && void 0 !== e ? e : null; + })); + e.paramX = this.paramX.clone(); + e.paramY = this.paramY.clone(); + return e; + } + [uJ](t) { + const e = new $0(t, this, this._items, this._items.map((({threshold: t}) => t)), this.algorithm, [ 0, 0 ]); + const i = c0(t, this.paramX, rJ.FLOAT, e.setInput, e, 0); + const s = c0(t, this.paramY, rJ.FLOAT, e.setInput, e, 1); + e.setInput(i, 0); + e.setInput(s, 1); + return e; + } + }, K0.Algorithm = Z0, K0.Item = Q0, J0), X0 = Bl(j0.prototype, "algorithm", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Z0.SIMPLE_DIRECTIONAL; + } + }), W0 = Bl(j0.prototype, "_items", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), Y0 = Bl(j0.prototype, "paramX", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new l0; + } + }), q0 = Bl(j0.prototype, "paramY", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new l0; + } + }), j0)); + class $0 extends T0 { + constructor(t, e, i, s, n, r) { + super(t, e, i, r); + this._thresholds = void 0; + this._algorithm = void 0; + this._value = new Qi; + this._thresholds = s; + this._algorithm = n; + this.doEval(); + } + eval(t, [e, i]) { + Qi.set(this._value, e, i); + t.fill(0); + switch (this._algorithm) { + case Z0.SIMPLE_DIRECTIONAL: + N0(t, this._thresholds, this._value); + break; + + case Z0.FREEFORM_CARTESIAN: + !function(t, e, i) { + L0(t, e, i, F0); + }(t, this._thresholds, this._value); + break; + + case Z0.FREEFORM_DIRECTIONAL: + !function(t, e, i) { + L0(t, e, i, V0); + }(t, this._thresholds, this._value); + } + } + } + var t1, e1, i1, s1, n1, r1, o1, a1, l1; + let h1 = Ul("cc.animation.AnimationBlendDirectItem")(t1 = (e1 = (s1 = class t extends S0 { + constructor(...t) { + super(...t); + Ml(this, "weight", i1, this); + } + clone() { + const e = new t; + this._assign(e); + return e; + } + _assign(t) { + super._assign(t); + t.weight = this.weight; + return t; + } + }, s1), i1 = Bl(e1.prototype, "weight", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), e1)) || t1; + Ul("cc.animation.AnimationBlendDirect")(n1 = (r1 = (l1 = a1 = class t extends A0 { + constructor(...t) { + super(...t); + Ml(this, "_items", o1, this); + } + get items() { + return this._items; + } + set items(t) { + this._items = Array.from(t); + } + clone() { + const e = new t; + e._items = this._items.map((t => { + var e; + return null !== (e = null == t ? void 0 : t.clone()) && void 0 !== e ? e : null; + })); + return e; + } + [uJ](t) { + return new c1(t, this, this._items, this._items.map((({weight: t}) => t))); + } + }, a1.Item = h1, l1), o1 = Bl(r1.prototype, "_items", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), r1)); + class c1 extends T0 { + constructor(...t) { + super(...t); + this.doEval(); + } + eval(t, e) { + const i = t.length; + for (let s = 0; s < i; ++s) t[s] = e[s]; + } + } + var u1, _1, d1, p1, m1, f1, g1, y1; + Ul("cc.animation.AnimationMask")(u1 = (_1 = (p1 = class extends gc { + constructor(...t) { + super(...t); + Ml(this, "_jointMasks", d1, this); + } + get joints() { + return this._jointMasks; + } + set joints(t) { + this.clear(); + for (const e of t) this.addJoint(e.path, e.enabled); + } + addJoint(t, e) { + this.removeJoint(t); + const i = new b1; + i.path = t; + i.enabled = e; + this._jointMasks.push(i); + } + removeJoint(t) { + lt(this._jointMasks, (({path: e}) => e === t)); + } + clear() { + this._jointMasks.length = 0; + } + filterDisabledNodes(t) { + const {_jointMasks: e} = this; + const i = e.length; + const s = new Set; + for (let n = 0; n < i; ++n) { + const {path: i, enabled: r} = e[n]; + if (r) continue; + const o = t.getChildByPath(i); + o && s.add(o); + } + return s; + } + }, p1), d1 = Bl(_1.prototype, "_jointMasks", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), Bl(_1.prototype, "joints", [ nh ], Object.getOwnPropertyDescriptor(_1.prototype, "joints"), _1.prototype), + _1)); + let b1 = Ul("cc.JointMask")(m1 = (f1 = class { + constructor() { + Ml(this, "path", g1, this); + Ml(this, "enabled", y1, this); + } + }, g1 = Bl(f1.prototype, "path", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), y1 = Bl(f1.prototype, "enabled", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), f1)) || m1; + var S1, A1, T1, v1, E1, C1, x1, w1, R1, I1, M1, B1, D1, P1, O1, N1, L1; + var F1; + !function(t) { + t[t.EQUAL_TO = 0] = "EQUAL_TO"; + t[t.NOT_EQUAL_TO = 1] = "NOT_EQUAL_TO"; + t[t.LESS_THAN = 2] = "LESS_THAN"; + t[t.LESS_THAN_OR_EQUAL_TO = 3] = "LESS_THAN_OR_EQUAL_TO"; + t[t.GREATER_THAN = 4] = "GREATER_THAN"; + t[t.GREATER_THAN_OR_EQUAL_TO = 5] = "GREATER_THAN_OR_EQUAL_TO"; + }(F1 || (F1 = {})); + Ul("cc.animation.BinaryCondition")(S1 = (A1 = (x1 = C1 = class t { + constructor() { + Ml(this, "operator", T1, this); + Ml(this, "lhs", v1, this); + Ml(this, "rhs", E1, this); + } + clone() { + const e = new t; + e.operator = this.operator; + e.lhs = this.lhs.clone(); + e.rhs = this.rhs.clone(); + return e; + } + [uJ](t) { + const {operator: e, lhs: i, rhs: s} = this; + const n = new V1(e, 0, 0); + const r = u0(t, i, rJ.FLOAT, n.setLhs, n); + const o = u0(t, s, rJ.FLOAT, n.setRhs, n); + n.reset(r, o); + return n; + } + }, C1.Operator = F1, x1), T1 = Bl(A1.prototype, "operator", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return F1.EQUAL_TO; + } + }), v1 = Bl(A1.prototype, "lhs", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new l0; + } + }), E1 = Bl(A1.prototype, "rhs", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new l0; + } + }), A1)); + class V1 { + constructor(t, e, i) { + this._operator = t; + this._lhs = e; + this._rhs = i; + this._eval(); + } + reset(t, e) { + this._lhs = t; + this._rhs = e; + this._eval(); + } + setLhs(t) { + this._lhs = t; + this._eval(); + } + setRhs(t) { + this._rhs = t; + this._eval(); + } + eval() { + return this._result; + } + _eval() { + const {_lhs: t, _rhs: e} = this; + switch (this._operator) { + default: + case F1.EQUAL_TO: + this._result = t === e; + break; + + case F1.NOT_EQUAL_TO: + this._result = t !== e; + break; + + case F1.LESS_THAN: + this._result = t < e; + break; + + case F1.LESS_THAN_OR_EQUAL_TO: + this._result = t <= e; + break; + + case F1.GREATER_THAN: + this._result = t > e; + break; + + case F1.GREATER_THAN_OR_EQUAL_TO: + this._result = t >= e; + } + } + } + var k1; + !function(t) { + t[t.TRUTHY = 0] = "TRUTHY"; + t[t.FALSY = 1] = "FALSY"; + }(k1 || (k1 = {})); + Ul("cc.animation.UnaryCondition")(w1 = (R1 = (D1 = B1 = class t { + constructor() { + Ml(this, "operator", I1, this); + Ml(this, "operand", M1, this); + } + clone() { + const e = new t; + e.operator = this.operator; + e.operand = this.operand.clone(); + return e; + } + [uJ](t) { + const {operator: e, operand: i} = this; + const s = new U1(e, !1); + const n = c0(t, i, rJ.BOOLEAN, s.setOperand, s); + s.reset(n); + return s; + } + }, B1.Operator = k1, D1), I1 = Bl(R1.prototype, "operator", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return k1.TRUTHY; + } + }), M1 = Bl(R1.prototype, "operand", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new h0; + } + }), R1)); + class U1 { + constructor(t, e) { + this._operator = t; + this._operand = e; + this._eval(); + } + reset(t) { + this.setOperand(t); + } + setOperand(t) { + this._operand = t; + this._eval(); + } + eval() { + return this._result; + } + _eval() { + const {_operand: t} = this; + switch (this._operator) { + default: + case k1.TRUTHY: + this._result = !!t; + break; + + case k1.FALSY: + this._result = !t; + } + } + } + let G1 = Ul("cc.animation.TriggerCondition")(P1 = (O1 = (L1 = class t { + constructor() { + Ml(this, "trigger", N1, this); + } + clone() { + const e = new t; + e.trigger = this.trigger; + return e; + } + [uJ](t) { + const e = new z1(!1); + const i = t.getVar(this.trigger); + if (_0(i, this.trigger)) { + !function(t, e) { + if (t !== rJ.TRIGGER) throw new cJ(e, "trigger"); + }(i.type, this.trigger); + e.setTrigger(i.bind(e.setTrigger, e)); + } + return e; + } + }, L1), N1 = Bl(O1.prototype, "trigger", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), O1)) || P1; + class z1 { + constructor(t) { + this._triggered = !1; + this._triggered = t; + } + setTrigger(t) { + this._triggered = t; + } + eval() { + return this._triggered; + } + } + class H1 { + constructor() { + this._nodeBlendStates = new Map; + } + createWriter(t, e, i, s) { + const n = this.ref(t, e); + return new j1(t, e, n, i, s); + } + destroyWriter(t) { + const e = t; + this.deRef(e.node, e.property); + } + ref(t, e) { + let i = this._nodeBlendStates.get(t); + if (!i) { + i = this.createNodeBlendState(); + this._nodeBlendStates.set(t, i); + } + return i.refProperty(t, e); + } + deRef(t, e) { + const i = this._nodeBlendStates.get(t); + if (i) { + i.deRefProperty(e); + i.empty && this._nodeBlendStates.delete(t); + } + } + apply() { + this._nodeBlendStates.forEach(((t, e) => { + t.apply(e); + })); + } + } + class j1 { + constructor(t, e, i, s, n) { + this._node = t; + this._property = e; + this._propertyBlendState = i; + this._host = s; + this._constants = n; + } + get node() { + return this._node; + } + get property() { + return this._property; + } + getValue() { + return this._node[this._property]; + } + setValue(t) { + const {_propertyBlendState: e, _host: i} = this; + const s = i.weight; + e.blend(t, s); + } + } + var X1; + !function(t) { + t[t.POSITION = 1] = "POSITION"; + t[t.ROTATION = 2] = "ROTATION"; + t[t.SCALE = 4] = "SCALE"; + t[t.EULER_ANGLES = 8] = "EULER_ANGLES"; + }(X1 || (X1 = {})); + const W1 = X1.POSITION | X1.ROTATION | X1.SCALE | X1.EULER_ANGLES; + class Y1 { + constructor() { + this.refCount = 0; + this.accumulatedWeight = 0; + this.result = new Pi; + } + blend(t, e) { + this.accumulatedWeight = s2(this.result, this.result, this.accumulatedWeight, t, e); + } + reset() { + this.accumulatedWeight = 0; + Pi.zero(this.result); + } + } + class q1 { + constructor() { + this.refCount = 0; + this.accumulatedWeight = 0; + this.result = new Ui; + } + blend(t, e) { + this.accumulatedWeight = n2(this.result, this.result, this.accumulatedWeight, t, e); + } + reset() { + this.accumulatedWeight = 0; + Ui.identity(this.result); + } + } + class K1 { + constructor() { + this._transformApplyFlags = 0; + this._properties = {}; + } + get empty() { + const {_properties: t} = this; + return !(t.position || t.rotation || t.eulerAngles || t.scale); + } + refProperty(t, e) { + var i, s; + const {_properties: n} = this; + let r; + switch (e) { + default: + case "position": + case "scale": + case "eulerAngles": + r = null !== (i = n[e]) && void 0 !== i ? i : n[e] = this._createVec3BlendState(t[e]); + break; + + case "rotation": + r = null !== (s = n[e]) && void 0 !== s ? s : n[e] = this._createQuatBlendState(t.rotation); + } + ++r.refCount; + return r; + } + deRefProperty(t) { + const {_properties: e} = this; + const i = e[t]; + if (i) { + --i.refCount; + i.refCount > 0 || delete e[t]; + } + } + apply(t) { + const {_transformApplyFlags: e, _properties: {position: i, scale: s, rotation: n, eulerAngles: r}} = this; + if (!e) return; + let o; + let a; + let l; + i && e & X1.POSITION && (o = i.result); + s && e & X1.SCALE && (a = s.result); + r && e & X1.EULER_ANGLES && (l = r.result); + n && e & X1.ROTATION && (l = n.result); + (l || o || a) && t.setRTS(l, o, a); + this._transformApplyFlags = 0; + } + } + class J1 extends K1 { + apply(t) { + const {_properties: {position: e, scale: i, rotation: s, eulerAngles: n}} = this; + if (e && e.accumulatedWeight) { + this._transformApplyFlags |= X1.POSITION; + e.accumulatedWeight < 1 && e.blend(t.position, 1 - e.accumulatedWeight); + } + if (i && i.accumulatedWeight) { + this._transformApplyFlags |= X1.SCALE; + i.accumulatedWeight < 1 && i.blend(t.scale, 1 - i.accumulatedWeight); + } + if (n && n.accumulatedWeight) { + this._transformApplyFlags |= X1.EULER_ANGLES; + n.accumulatedWeight < 1 && n.blend(t.eulerAngles, 1 - n.accumulatedWeight); + } + if (s && s.accumulatedWeight) { + this._transformApplyFlags |= X1.ROTATION; + s.accumulatedWeight < 1 && s.blend(t.rotation, 1 - s.accumulatedWeight); + } + super.apply(t); + null == e || e.reset(); + null == i || i.reset(); + null == s || s.reset(); + null == n || n.reset(); + } + _createVec3BlendState(t) { + return new Y1; + } + _createQuatBlendState(t) { + return new q1; + } + } + class Z1 extends H1 { + createNodeBlendState() { + return new J1; + } + } + class Q1 { + constructor(t) { + this.refCount = 0; + this.result = new Pi; + this._defaultValue = new Pi; + this._clipBlendResult = new Pi; + this._accumulatedWeight = 0; + Pi.copy(this._defaultValue, t); + Pi.copy(this.result, t); + } + blend(t, e) { + this._accumulatedWeight = s2(this._clipBlendResult, this._clipBlendResult, this._accumulatedWeight, t, e); + } + commitLayerChange(t) { + const {result: e, _clipBlendResult: i, _accumulatedWeight: s} = this; + s < 1 && this.blend(this._defaultValue, 1 - s); + Pi.lerp(e, e, i, t); + Pi.zero(this._clipBlendResult); + this._accumulatedWeight = 0; + } + reset() { + Pi.copy(this.result, this._defaultValue); + } + } + class $1 { + constructor(t) { + this.refCount = 0; + this.result = new Ui; + this._defaultValue = new Ui; + this._clipBlendResult = new Ui; + this._accumulatedWeight = 0; + Ui.copy(this._defaultValue, t); + Ui.copy(this.result, t); + } + blend(t, e) { + this._accumulatedWeight = n2(this._clipBlendResult, this._clipBlendResult, this._accumulatedWeight, t, e); + } + commitLayerChange(t) { + const {result: e, _clipBlendResult: i, _accumulatedWeight: s} = this; + s < 1 && this.blend(this._defaultValue, 1 - s); + Ui.slerp(e, e, i, t); + Ui.identity(this._clipBlendResult); + this._accumulatedWeight = 0; + } + reset() { + Ui.copy(this.result, this._defaultValue); + } + } + class t2 extends K1 { + constructor(...t) { + super(...t); + this._layerMask = -1 >>> 0; + } + setLayerMask(t) { + this._layerMask &= ~(1 << t); + } + commitLayerChanges(t, e) { + if (!(this._layerMask & 1 << t)) return; + const {_properties: {position: i, scale: s, rotation: n, eulerAngles: r}} = this; + i && i.commitLayerChange(e); + s && s.commitLayerChange(e); + n && n.commitLayerChange(e); + r && r.commitLayerChange(e); + } + apply(t) { + this._transformApplyFlags = W1; + super.apply(t); + const {_properties: {position: e, scale: i, rotation: s, eulerAngles: n}} = this; + null == e || e.reset(); + null == i || i.reset(); + null == s || s.reset(); + null == n || n.reset(); + } + _createVec3BlendState(t) { + return new Q1(t); + } + _createQuatBlendState(t) { + return new $1(t); + } + } + class e2 extends H1 { + setMask(t, e) { + i2(t); + this._nodeBlendStates.forEach(((i, s) => { + e.has(s) && i.setLayerMask(t); + })); + } + commitLayerChanges(t, e) { + i2(t); + this._nodeBlendStates.forEach(((i, s) => { + i.commitLayerChanges(t, e); + })); + } + createNodeBlendState() { + return new t2; + } + } + function i2(t) { + ne(t < 32); + } + function s2(t, e, i, s, n) { + const r = i + n; + if (1 !== n || i) { + if (r) { + const e = n / r; + Pi.lerp(t, t, s, e); + } + } else Pi.copy(t, s); + return r; + } + function n2(t, e, i, s, n) { + const r = i + n; + if (1 !== n || i) { + if (r) { + const i = n / r; + Ui.slerp(t, e, s, i); + } + } else Ui.copy(t, s); + return r; + } + var r2; + let o2 = Ul("cc.animation.StateMachineComponent")(r2 = class { + onMotionStateEnter(t, e) {} + onMotionStateExit(t, e) {} + onMotionStateUpdate(t, e) {} + onStateMachineEnter(t) {} + onStateMachineExit(t) {} + }) || r2; + class a2 { + constructor(t, e, i) { + this._blendBuffer = new e2; + this._currentTransitionCache = { + duration: 0, + time: 0 + }; + this._varInstances = {}; + this._hasAutoTrigger = !1; + if (t.layers.length >= 32) throw new Error(`Max layer count exceeds. Allowed: 32, actual: ${t.layers.length}`); + for (const [e, i] of t.variables) { + const t = this._varInstances[e] = new aJ(i.type, i.value); + if (i.type === rJ.TRIGGER) { + const {resetMode: e} = i; + t.resetMode = e; + e === oJ.NEXT_FRAME_OR_AFTER_CONSUMED && (this._hasAutoTrigger = !0); + } + } + const s = { + controller: i, + blendBuffer: this._blendBuffer, + node: e, + getVar: t => this._varInstances[t], + triggerResetFn: t => { + this.setValue(t, !1); + } + }; + const n = (this._layerEvaluations = t.layers.map((t => { + var e; + return new l2(t, { + ...s, + mask: null !== (e = t.mask) && void 0 !== e ? e : void 0 + }); + }))).length; + for (let e = 0; e < n; ++e) { + const i = t.layers[e].mask; + if (i) { + const t = i.filterDisabledNodes(s.node); + this._blendBuffer.setMask(e, t); + } + } + } + update(t) { + const {_blendBuffer: e, _layerEvaluations: i} = this; + const s = i.length; + for (let n = 0; n < s; ++n) { + const s = i[n]; + s.update(t); + e.commitLayerChanges(n, s.weight * s.passthroughWeight); + } + if (this._hasAutoTrigger) { + const {_varInstances: t} = this; + for (const e in t) { + const i = t[e]; + i.type === rJ.TRIGGER && i.resetMode === oJ.NEXT_FRAME_OR_AFTER_CONSUMED && (i.value = !1); + } + } + this._blendBuffer.apply(); + } + getVariables() { + return Object.entries(this._varInstances); + } + getCurrentStateStatus(t) { + return this._layerEvaluations[t].getCurrentStateStatus(); + } + getCurrentClipStatuses(t) { + return this._layerEvaluations[t].getCurrentClipStatuses(); + } + getCurrentTransition(t) { + const {_layerEvaluations: e, _currentTransitionCache: i} = this; + return e[t].getCurrentTransition(i) ? i : null; + } + getNextStateStatus(t) { + return this._layerEvaluations[t].getNextStateStatus(); + } + getNextClipStatuses(t) { + se(this.getCurrentTransition(t), "!!this.getCurrentTransition(layer)"); + return this._layerEvaluations[t].getNextClipStatuses(); + } + getValue(t) { + const e = this._varInstances[t]; + return e ? e.value : void 0; + } + setValue(t, e) { + const i = this._varInstances[t]; + i && (i.value = e); + } + getLayerWeight(t) { + return this._layerEvaluations[t].weight; + } + setLayerWeight(t, e) { + this._layerEvaluations[t].weight = e; + } + } + class l2 { + constructor(t, e) { + this.passthroughWeight = 1; + this._nodes = []; + this._topLevelEntry = void 0; + this._topLevelExit = void 0; + this._currentNode = void 0; + this._currentTransitionToNode = null; + this._currentTransitionPath = []; + this._transitionProgress = 0; + this._fromWeight = 0; + this._toWeight = 0; + this._fromUpdated = !1; + this._toUpdated = !1; + this._transitionSnapshot = new v2; + this.name = t.name; + this._controller = e.controller; + this.weight = t.weight; + const {entry: i, exit: s} = this._addStateMachine(t.stateMachine, null, { + ...e + }, t.name); + this._topLevelEntry = i; + this._topLevelExit = s; + this._currentNode = i; + this._resetTrigger = e.triggerResetFn; + } + get exited() { + return this._currentNode === this._topLevelExit; + } + update(t) { + if (!this.exited) { + this._fromWeight = 1; + this._toWeight = 0; + this._eval(t); + this._sample(); + } + } + getCurrentStateStatus() { + const {_currentNode: t} = this; + return t.kind === p2.animation ? t.getFromPortStatus() : t.kind === p2.transitionSnapshot ? t.first.getFromPortStatus() : null; + } + getCurrentClipStatuses() { + const {_currentNode: t} = this; + return t.kind === p2.animation ? t.getClipStatuses(this._fromWeight) : t.kind === p2.transitionSnapshot ? t.first.getClipStatuses(this._fromWeight) : u2; + } + getCurrentTransition(t) { + const {_currentTransitionPath: e} = this; + if (0 !== e.length) { + if (e[e.length - 1].to.kind !== p2.animation) return !1; + const {duration: i, normalizedDuration: s} = e[0]; + const n = t.duration = s ? i * (this._currentNode.kind === p2.animation ? this._currentNode.duration : this._currentNode.kind === p2.transitionSnapshot ? this._currentNode.first.duration : 0) : i; + t.time = this._transitionProgress * n; + return !0; + } + return !1; + } + getNextStateStatus() { + ne(this._currentTransitionToNode && this._currentTransitionToNode.kind !== p2.empty, "There is no transition currently in layer."); + return this._currentTransitionToNode.getToPortStatus(); + } + getNextClipStatuses() { + var t; + const {_currentTransitionPath: e} = this; + const i = e.length; + ne(i > 0, "There is no transition currently in layer."); + const s = e[i - 1].to; + ne(s.kind === p2.animation); + return null !== (t = s.getClipStatuses(this._toWeight)) && void 0 !== t ? t : u2; + } + _addStateMachine(t, e, i, s) { + const n = Array.from(t.states()); + let r; + let o; + let a; + const l = n.map((e => { + if (e instanceof MJ) return new g2(e, i); + if (e === t.entryState) return r = new S2(e, p2.entry, e.name); + if (e === t.exitState) return a = new S2(e, p2.exit, e.name); + if (e === t.anyState) return o = new S2(e, p2.any, e.name); + if (e instanceof NZ) return new A2(e); + ne(e instanceof VZ); + return null; + })); + se(r, "Entry node is missing"); + se(a, "Exit node is missing"); + se(o, "Any node is missing"); + const h = { + components: null, + parent: e, + entry: r, + exit: a, + any: o + }; + for (let t = 0; t < n.length; ++t) { + const e = l[t]; + e && (e.stateMachine = h); + } + const c = n.map((t => { + if (t instanceof VZ) { + const e = this._addStateMachine(t.stateMachine, h, i, `${s}/${t.name}`); + e.components = new f2(t); + return e; + } + return null; + })); + for (const t of l) t && (t.__DEBUG_ID__ = `${t.name}(from ${s})`); + for (let e = 0; e < n.length; ++e) { + const s = n[e]; + const r = t.getOutgoings(s); + const o = []; + let a; + if (s instanceof VZ) { + const t = c[e]; + se(t); + a = t.exit; + } else { + const t = l[e]; + se(t); + a = t; + } + for (const t of r) { + const e = t.to; + const s = n.findIndex((e => e === t.to)); + s < 0 && ne(!1, "Bad animation data"); + let r; + if (e instanceof VZ) { + const t = c[s]; + se(t); + r = t.entry; + } else { + const t = l[s]; + se(t); + r = t; + } + const a = { + conditions: t.conditions.map((t => t[uJ](i))), + to: r, + triggers: void 0, + duration: 0, + normalizedDuration: !1, + destinationStart: 0, + relativeDestinationStart: !1, + exitCondition: 0, + exitConditionEnabled: !1, + interruption: PZ.NONE + }; + if (t instanceof OZ) { + a.duration = t.duration; + a.normalizedDuration = t.relativeDuration; + a.exitConditionEnabled = t.exitConditionEnabled; + a.exitCondition = t.exitCondition; + a.destinationStart = t.destinationStart; + a.relativeDestinationStart = t.relativeDestinationStart; + a.interruption = t.interruptionSource; + } else if (t instanceof LZ) { + a.duration = t.duration; + a.destinationStart = t.destinationStart; + a.relativeDestinationStart = t.relativeDestinationStart; + } + a.conditions.forEach(((e, i) => { + const s = t.conditions[i]; + if (s instanceof G1 && s.trigger) { + var n; + (null !== (n = a.triggers) && void 0 !== n ? n : a.triggers = []).push(s.trigger); + } + })); + o.push(a); + } + a.outgoingTransitions = o; + } + return h; + } + _eval(t) { + ne(!this.exited); + H$(`[Layer ${this.name}]: UpdateStart ${t}s`); + if (this._continueDanglingTransition()) return 0; + let e = t; + for (let t = !0, i = 0; t || e > 0; ) { + t = !1; + if (100 === i) { + N(14e3, 100); + break; + } + ++i; + if (this._currentTransitionPath.length > 0) { + const i = this._detectInterruption(e, d2); + if (i) { + e -= i.requires; + if (this._interrupt(i)) break; + t = !0; + continue; + } + e -= this._updateCurrentTransition(e); + if (this._currentNode.kind === p2.exit) break; + 0 === this._currentTransitionPath.length && (t = !0); + continue; + } + const {_currentNode: s} = this; + const n = this._matchCurrentNodeTransition(e); + if (n) { + const {transition: i, requires: r} = n; + z$(`[SubStateMachine ${this.name}]: CurrentNodeUpdate: ${s.name}`); + e -= r; + if (s.kind === p2.animation) { + s.updateFromPort(r); + this._fromUpdated = !0; + } + if (this._switchTo(i)) break; + t = !0; + } else { + z$(`[SubStateMachine ${this.name}]: CurrentNodeUpdate: ${s.name}`); + if (s.kind === p2.animation) { + s.updateFromPort(e); + this._fromUpdated = !0; + e = 0; + } else e = 0; + } + } + z$(`[SubStateMachine ${this.name}]: UpdateEnd`); + if (this._fromUpdated && this._currentNode.kind === p2.animation) { + this._fromUpdated = !1; + this._currentNode.triggerFromPortUpdate(this._controller); + } + if (this._currentTransitionToNode && this._toUpdated && this._currentTransitionToNode.kind === p2.animation) { + this._toUpdated = !1; + this._currentTransitionToNode.triggerToPortUpdate(this._controller); + } + return e; + } + _sample() { + const {_currentNode: t, _currentTransitionToNode: e, _fromWeight: i, _toWeight: s} = this; + if (t.kind === p2.empty) { + this.passthroughWeight = s; + e && e.kind === p2.animation && e.sampleToPort(1); + } else if (e && e.kind === p2.empty) { + this.passthroughWeight = i; + this._sampleSource(1); + } else { + this.passthroughWeight = 1; + this._sampleSource(i); + e && e.kind === p2.animation && e.sampleToPort(s); + } + } + _sampleSource(t) { + const {_currentNode: e} = this; + e.kind === p2.animation ? e.sampleFromPort(t) : e.kind === p2.transitionSnapshot && e.sample(t); + } + _matchCurrentNodeTransition(t) { + const e = this._currentNode; + const i = _2.reset(); + this._matchTransition(e, e, t, null, i); + if (i.hasZeroCost()) return i; + if (e.kind === p2.animation) { + this._matchAnyScoped(e, t, i); + if (i.hasZeroCost()) return i; + } + return i.isValid() ? i : null; + } + _matchAnyScoped(t, e, i) { + let s = !1; + for (let n = t.stateMachine; null !== n; n = n.parent) { + this._matchTransition(n.any, t, e, null, i) && (s = !0); + if (i.hasZeroCost()) break; + } + return s; + } + _matchTransition(t, e, i, s, n) { + ne(t === e || t.kind === p2.any); + const {outgoingTransitions: r} = t; + const o = r.length; + let a = !1; + for (let l = 0; l < o; ++l) { + const o = r[l]; + if (o === s) continue; + const {conditions: h} = o; + const c = h.length; + if (0 === c) { + if (t.kind === p2.entry || t.kind === p2.exit) { + n.set(o, 0); + a = !0; + break; + } + if (!o.exitConditionEnabled) continue; + } + let u = 0; + if (e.kind === p2.animation && o.exitConditionEnabled) { + const t = e.duration * o.exitCondition; + u = Math.max(t - e.fromPortTime, 0); + if (u > i || u >= n.requires) continue; + } + let _ = !0; + for (let t = 0; t < c; ++t) { + if (!h[t].eval()) { + _ = !1; + break; + } + } + if (_) { + if (0 === u) { + n.set(o, 0); + a = !0; + break; + } + ne(u <= n.requires); + n.set(o, u); + a = !0; + } + } + return a; + } + _switchTo(t) { + const {_currentTransitionPath: e} = this; + this._consumeTransition(t); + e.push(t); + const i = this._matchTransitionPathUntilMotion(); + if (i) { + this._doTransitionToMotion(i); + return !1; + } + return !0; + } + _continueDanglingTransition() { + const {_currentTransitionPath: t} = this; + const e = t.length; + if (0 === e) return !1; + const i = t[e - 1].to; + if (i.kind !== p2.animation && i.kind !== p2.empty) { + const t = this._matchTransitionPathUntilMotion(); + if (t) { + this._doTransitionToMotion(t); + return !1; + } + return !0; + } + return !1; + } + _matchTransitionPathUntilMotion() { + const {_currentTransitionPath: t} = this; + const e = t.length; + ne(0 !== e); + let i = t[e - 1].to; + for (;i.kind !== p2.animation && i.kind !== p2.empty; ) { + const e = _2.reset(); + this._matchTransition(i, i, 0, null, e); + if (!e.transition) break; + const s = e.transition; + this._consumeTransition(s); + t.push(s); + i = s.to; + } + return i.kind === p2.animation || i.kind === p2.empty ? i : null; + } + _consumeTransition(t) { + const {to: e} = t; + e.kind === p2.entry && this._callEnterMethods(e); + } + _resetTriggersAlongThePath() { + const {_currentTransitionPath: t} = this; + const e = t.length; + for (let i = 0; i < e; ++i) { + const e = t[i]; + this._resetTriggersOnTransition(e); + } + } + _doTransitionToMotion(t) { + const {_currentTransitionPath: e} = this; + ne(0 !== e.length); + this._resetTriggersAlongThePath(); + this._transitionProgress = 0; + this._currentTransitionToNode = t; + this._toUpdated = !1; + if (t.kind === p2.animation) { + const {destinationStart: i, relativeDestinationStart: s} = e[0]; + const n = s ? i : 0 === t.duration ? 0 : i / t.duration; + t.resetToPort(n); + } + this._callEnterMethods(t); + } + _updateCurrentTransition(t) { + var e; + const {_currentTransitionPath: i, _currentTransitionToNode: s} = this; + se(i.length > 0); + se(s); + const n = i[0]; + const {duration: r, normalizedDuration: o} = n; + const a = this._currentNode; + const l = s; + let h = 0; + let c = 0; + if (r <= 0) { + h = 0; + c = 1; + } else { + ne(a.kind === p2.animation || a.kind === p2.empty || a.kind === p2.transitionSnapshot); + const {_transitionProgress: e} = this; + const i = a.kind === p2.empty ? r : o ? r * (a.kind === p2.animation ? a.duration : a.first.duration) : r; + const s = e * i; + const n = i - s; + ne(n >= 0); + h = Math.min(n, t); + c = this._transitionProgress = (s + h) / i; + ne(c >= 0 && c <= 1); + } + const u = null !== (e = null == l ? void 0 : l.name) && void 0 !== e ? e : ""; + this._fromWeight = 1 - c; + this._toWeight = c; + const _ = 0 !== h; + const d = 1 === c; + if (a.kind === p2.animation && _) { + H$(`Update ${a.name}`); + a.updateFromPort(h); + this._fromUpdated = !0; + } + if (l.kind === p2.animation && _) { + H$(`Update ${l.name}`); + l.updateToPort(h); + this._toUpdated = !0; + } + if (d) { + z$(`[SubStateMachine ${this.name}]: Transition finished: ${a.name} -> ${u}.`); + this._finishCurrentTransition(); + } + return h; + } + _finishCurrentTransition() { + const {_currentTransitionPath: t, _currentTransitionToNode: e} = this; + se(t.length > 0); + se(e); + const i = this._currentNode; + const s = e; + this._callExitMethods(i); + const {_currentTransitionPath: n} = this; + const r = n.length; + for (let t = 0; t < r; ++t) { + const {to: e} = n[t]; + e.kind === p2.exit && this._callExitMethods(e); + } + this._fromUpdated = this._toUpdated; + this._toUpdated = !1; + this._dropCurrentTransition(); + this._currentNode = s; + i.kind === p2.transitionSnapshot && i.clear(); + } + _dropCurrentTransition() { + const {_currentTransitionToNode: t} = this; + se(t); + t.kind === p2.animation && t.finishTransition(); + this._currentTransitionToNode = null; + this._currentTransitionPath.length = 0; + this._fromWeight = 1; + this._toWeight = 0; + } + _detectInterruption(t, e) { + const {_currentTransitionPath: i, _currentNode: s, _currentTransitionToNode: n} = this; + if (s.kind !== p2.animation && s.kind !== p2.transitionSnapshot) return null; + if (!n || n.kind !== p2.animation) return null; + ne(0 !== i.length); + const r = i[0]; + const {interruption: o} = r; + if (o === PZ.NONE) return null; + const a = _2.reset(); + let l = null; + const h = s.kind === p2.animation ? s : s.first; + let c = this._matchAnyScoped(h, t, a); + c && (l = h); + a.hasZeroCost(); + const u = o === PZ.CURRENT_STATE || o === PZ.CURRENT_STATE_THEN_NEXT_STATE ? h2(s) : n; + c = this._matchTransition(u, u, t, r, a); + c && (l = u); + a.hasZeroCost(); + const _ = o === PZ.NEXT_STATE_THEN_CURRENT_STATE ? h2(s) : o === PZ.CURRENT_STATE_THEN_NEXT_STATE ? n : null; + if (_) { + c = this._matchTransition(_, _, t, r, a); + c && (l = _); + a.hasZeroCost(); + } + if (_2.transition) { + se(l); + return e.set(l, _2.transition, _2.requires); + } + return null; + } + _interrupt({from: t, transition: e, requires: i}) { + const {_currentNode: s} = this; + ne(s.kind === p2.animation || s.kind === p2.transitionSnapshot); + if (s.kind === p2.animation) { + s.updateFromPort(i); + this._fromUpdated = !0; + const {_transitionSnapshot: t} = this; + ne(t.empty); + t.enqueue(s, 1); + } + this._takeCurrentTransitionSnapshot(t); + this._dropCurrentTransition(); + this._currentNode = this._transitionSnapshot; + return this._switchTo(e); + } + _takeCurrentTransitionSnapshot(t) { + const {_currentTransitionPath: e, _currentTransitionToNode: i, _transitionSnapshot: s} = this; + ne(0 !== e.length); + ne(i && i.kind === p2.animation); + const n = e[0]; + const {duration: r, normalizedDuration: o} = n; + const a = t; + let l = 0; + if (r <= 0) l = 1; else { + const {_transitionProgress: t} = this; + const e = o ? r * a.duration : r; + const i = t * e; + ne(e - i >= 0); + l = i / e; + ne(l >= 0 && l <= 1); + } + s.enqueue(i, l); + } + _resetTriggersOnTransition(t) { + const {triggers: e} = t; + if (e) { + const t = e.length; + for (let i = 0; i < t; ++i) { + const t = e[i]; + this._resetTrigger(t); + } + } + } + _resetTrigger(t) { + const {_triggerReset: e} = this; + e(t); + } + _callEnterMethods(t) { + var e; + const {_controller: i} = this; + switch (t.kind) { + default: + break; + + case p2.animation: + t.components.callMotionStateEnterMethods(i, t.getToPortStatus()); + break; + + case p2.entry: + null === (e = t.stateMachine.components) || void 0 === e || e.callStateMachineEnterMethods(i); + } + } + _callExitMethods(t) { + var e; + const {_controller: i} = this; + switch (t.kind) { + default: + break; + + case p2.animation: + t.components.callMotionStateExitMethods(i, t.getFromPortStatus()); + break; + + case p2.exit: + null === (e = t.stateMachine.components) || void 0 === e || e.callStateMachineExitMethods(i); + } + } + } + function h2(t) { + return t.kind === p2.animation ? t : t.first; + } + const c2 = Object.freeze({ + next: (...t) => ({ + done: !0, + value: void 0 + }) + }); + const u2 = Object.freeze({ + [Symbol.iterator]: () => c2 + }); + const _2 = new class { + constructor() { + this.transition = null; + this.requires = 1 / 0; + } + hasZeroCost() { + return 0 === this.requires; + } + isValid() { + return null !== this.transition; + } + set(t, e) { + this.transition = t; + this.requires = e; + return this; + } + reset() { + this.requires = 1 / 0; + this.transition = null; + return this; + } + }; + const d2 = new class { + constructor() { + this.transition = null; + this.requires = 0; + this.from = null; + } + set(t, e, i) { + this.from = t; + this.transition = e; + this.requires = i; + return this; + } + }; + var p2; + !function(t) { + t[t.entry = 0] = "entry"; + t[t.exit = 1] = "exit"; + t[t.any = 2] = "any"; + t[t.animation = 3] = "animation"; + t[t.empty = 4] = "empty"; + t[t.transitionSnapshot = 5] = "transitionSnapshot"; + }(p2 || (p2 = {})); + class m2 { + constructor(t) { + this.name = void 0; + this.outgoingTransitions = []; + this.name = t.name; + } + } + class f2 { + constructor(t) { + this._components = t.instantiateComponents(); + } + callMotionStateEnterMethods(t, e) { + this._callMotionStateCallbackIfNonDefault("onMotionStateEnter", t, e); + } + callMotionStateUpdateMethods(t, e) { + this._callMotionStateCallbackIfNonDefault("onMotionStateUpdate", t, e); + } + callMotionStateExitMethods(t, e) { + this._callMotionStateCallbackIfNonDefault("onMotionStateExit", t, e); + } + callStateMachineEnterMethods(t) { + this._callStateMachineCallbackIfNonDefault("onStateMachineEnter", t); + } + callStateMachineExitMethods(t) { + this._callStateMachineCallbackIfNonDefault("onStateMachineExit", t); + } + _callMotionStateCallbackIfNonDefault(t, e, i) { + const {_components: s} = this; + const n = s.length; + for (let r = 0; r < n; ++r) { + const n = s[r]; + n[t] !== o2.prototype[t] && n[t](e, i); + } + } + _callStateMachineCallbackIfNonDefault(t, e) { + const {_components: i} = this; + const s = i.length; + for (let n = 0; n < s; ++n) { + const s = i[n]; + s[t] !== o2.prototype[t] && s[t](e); + } + } + } + class g2 extends m2 { + constructor(t, e) { + var i, s; + super(t); + this.kind = p2.animation; + this._source = null; + this._baseSpeed = 1; + this._speed = 1; + this._fromPort = { + progress: 0, + statusCache: { + progress: 0 + } + }; + this._toPort = { + progress: 0, + statusCache: { + progress: 0 + } + }; + this._baseSpeed = t.speed; + this._setSpeedMultiplier(1); + if (t.speedMultiplierEnabled && t.speedMultiplier) { + const i = t.speedMultiplier; + const s = e.getVar(i); + if (_0(s, i)) { + !function(t, e, i) { + if (t !== e) throw new cJ(i, "number"); + }(s.type, rJ.FLOAT, i); + s.bind(this._setSpeedMultiplier, this); + const t = s.value; + this._setSpeedMultiplier(t); + } + } + const n = { + ...e + }; + const r = null !== (i = null === (s = t.motion) || void 0 === s ? void 0 : s[uJ](n)) && void 0 !== i ? i : null; + r && Object.defineProperty(r, "__DEBUG_ID__", { + value: this.name + }); + this._source = r; + this.components = new f2(t); + } + get duration() { + var t, e; + return null !== (t = null === (e = this._source) || void 0 === e ? void 0 : e.duration) && void 0 !== t ? t : 0; + } + get fromPortTime() { + return this._fromPort.progress * this.duration; + } + updateFromPort(t) { + this._fromPort.progress = y2(this._fromPort.progress, this.duration, t * this._speed); + } + updateToPort(t) { + ne(!Number.isNaN(this._toPort.progress)); + this._toPort.progress = y2(this._toPort.progress, this.duration, t * this._speed); + } + triggerFromPortUpdate(t) { + this.components.callMotionStateUpdateMethods(t, this.getFromPortStatus()); + } + triggerToPortUpdate(t) { + this.components.callMotionStateUpdateMethods(t, this.getToPortStatus()); + } + getFromPortStatus() { + const {statusCache: t} = this._fromPort; + t.__DEBUG_ID__ = this.name; + t.progress = b2(this._fromPort.progress); + return t; + } + getToPortStatus() { + ne(!Number.isNaN(this._toPort.progress)); + const {statusCache: t} = this._toPort; + t.__DEBUG_ID__ = this.name; + t.progress = b2(this._toPort.progress); + return t; + } + resetToPort(t) { + this._toPort.progress = t; + } + finishTransition() { + this._fromPort.progress = this._toPort.progress; + this._toPort.progress = Number.NaN; + } + sampleFromPort(t) { + var e; + null === (e = this._source) || void 0 === e || e.sample(this._fromPort.progress, t); + } + sampleToPort(t) { + var e; + ne(!Number.isNaN(this._toPort.progress)); + null === (e = this._source) || void 0 === e || e.sample(this._toPort.progress, t); + } + getClipStatuses(t) { + const {_source: e} = this; + return e ? { + [Symbol.iterator]: () => e.getClipStatuses(t) + } : u2; + } + _setSpeedMultiplier(t) { + this._speed = this._baseSpeed * t; + } + } + function y2(t, e, i) { + if (0 === e) return 0; + return t + i / e; + } + function b2(t) { + const e = t - Math.trunc(t); + return e >= 0 ? e : 1 + e; + } + class S2 extends m2 { + constructor(t, e, i) { + super(t); + this.kind = void 0; + this.kind = e; + } + } + class A2 extends m2 { + constructor(t) { + super(t); + this.kind = p2.empty; + } + } + class T2 { + constructor(t, e) { + this.motion = t; + this.weight = e; + } + } + class v2 extends m2 { + constructor() { + super({ + name: "[[TransitionSnapshotEval]]" + }); + this.kind = p2.transitionSnapshot; + this._queue = []; + } + get empty() { + return 0 === this._queue.length; + } + get first() { + const {_queue: t} = this; + ne(t.length > 0); + return t[0].motion; + } + sample(t) { + const {_queue: e} = this; + const i = e.length; + for (let s = 0; s < i; ++s) { + const {motion: i, weight: n} = e[s]; + i.sampleFromPort(n * t); + } + } + clear() { + this._queue.length = 0; + } + enqueue(t, e) { + const {_queue: i} = this; + const s = i.length; + const n = 1 - e; + for (let t = 0; t < s; ++t) i[t].weight *= n; + i.push(new T2(t, e)); + } + } + var E2, C2, x2, w2, R2, I2, M2; + let B2 = (E2 = Ul("cc.animation.AnimationController"), C2 = $l(), x2 = jl(HZ), E2(w2 = C2(w2 = (R2 = (M2 = class extends Qc { + constructor(...t) { + super(...t); + Ml(this, "graph", I2, this); + this._graphEval = null; + } + __preload() { + this.graph && (this._graphEval = new a2(this.graph, this.node, this)); + } + update(t) { + var e; + null === (e = this._graphEval) || void 0 === e || e.update(t); + } + getVariables() { + const {_graphEval: t} = this; + se(t); + return t.getVariables(); + } + setValue(t, e) { + const {_graphEval: i} = this; + se(i); + i.setValue(t, e); + } + getValue(t) { + const {_graphEval: e} = this; + se(e); + return e.getValue(t); + } + getCurrentStateStatus(t) { + const {_graphEval: e} = this; + se(e); + return e.getCurrentStateStatus(t); + } + getCurrentClipStatuses(t) { + const {_graphEval: e} = this; + se(e); + return e.getCurrentClipStatuses(t); + } + getCurrentTransition(t) { + const {_graphEval: e} = this; + se(e); + return e.getCurrentTransition(t); + } + getNextStateStatus(t) { + const {_graphEval: e} = this; + se(e); + return e.getNextStateStatus(t); + } + getNextClipStatuses(t) { + const {_graphEval: e} = this; + se(e); + return e.getNextClipStatuses(t); + } + getLayerWeight(t) { + const {_graphEval: e} = this; + se(e); + return e.getLayerWeight(t); + } + setLayerWeight(t, e) { + const {_graphEval: i} = this; + se(i); + return i.setLayerWeight(t, e); + } + }, M2), I2 = Bl(R2.prototype, "graph", [ x2 ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), R2)) || w2) || w2); + var D2 = Object.freeze({ + __proto__: null, + UniformProxyFactory: tK, + MorphWeightValueProxy: uK, + MorphWeightsValueProxy: _K, + MorphWeightsAllValueProxy: dK, + Track: kq, + TrackPath: Fq, + RealTrack: xK, + VectorTrack: OK, + QuatTrack: kK, + ColorTrack: XK, + SizeTrack: ZK, + ObjectTrack: tJ, + isPropertyPath: uq, + isCustomPath: function(t, e) { + return t instanceof e; + }, + HierarchyPath: _q, + ComponentPath: dq, + CubicSplineVec2Value: SK, + CubicSplineVec3Value: AK, + CubicSplineVec4Value: TK, + CubicSplineQuatValue: vK, + CubicSplineNumberValue: EK, + AnimationController: B2, + get VariableType() { + return rJ; + }, + StateMachineComponent: o2 + }); + t("animation", D2); + const P2 = []; + const O2 = new Map; + function N2(t, e) { + let i = 0; + let s = qi.IDENTITY; + for (;t; ) { + if (t.stamp === e || t.stamp + 1 === e && !t.node.hasChangedFlags) { + s = t.world; + t.stamp = e; + break; + } + t.stamp = e; + P2[i++] = t; + t = t.parent; + } + for (;i > 0; ) { + t = P2[--i]; + P2[i] = null; + const e = t.node; + qi.fromRTS(t.local, e.rotation, e.position, e.scale); + s = qi.multiply(t.world, s, t.local); + } + return s; + } + function L2(t, e) { + let i = null; + let s = 0; + for (;t !== e; ) { + const e = t.uuid; + if (O2.has(e)) { + i = O2.get(e); + break; + } + i = { + node: t, + local: new qi, + world: new qi, + stamp: -1, + parent: null + }; + O2.set(e, i); + P2[s++] = i; + t = t.parent; + i = null; + } + let n; + for (;s > 0; ) { + n = P2[--s]; + P2[s] = null; + n.parent = i; + i = n; + } + return i; + } + function F2(t) { + let e = O2.get(t.uuid) || null; + for (;e; ) { + O2.delete(e.node.uuid); + e = e.parent; + } + } + var V2, k2, U2; + let G2 = t("AnimationManager", Ul(V2 = (U2 = k2 = class extends Tg { + constructor(...t) { + super(...t); + this._anims = new nt([]); + this._crossFades = new nt([]); + this._delayEvents = []; + this._blendStateBuffer = new Z1; + this._sockets = []; + } + get blendState() { + return this._blendStateBuffer; + } + addCrossFade(t) { + -1 === this._crossFades.array.indexOf(t) && this._crossFades.push(t); + } + removeCrossFade(t) { + const e = this._crossFades.array.indexOf(t); + e >= 0 ? this._crossFades.fastRemoveAt(e) : F(3907); + } + update(t) { + const {_delayEvents: e, _crossFades: i, _sockets: s} = this; + { + const e = i.array; + for (i.i = 0; i.i < e.length; ++i.i) { + e[i.i].update(t); + } + } + const n = this._anims; + const r = n.array; + for (n.i = 0; n.i < r.length; ++n.i) { + const e = r[n.i]; + e.isMotionless || e.update(t); + } + this._blendStateBuffer.apply(); + const o = m.director.getTotalFrames(); + for (let t = 0, e = s.length; t < e; t++) { + const {target: e, transform: i} = s[t]; + e.matrix = N2(i, o); + } + for (let t = 0, i = e.length; t < i; t++) { + const i = e[t]; + i.fn.apply(i.thisArg, i.args); + } + e.length = 0; + } + destruct() {} + addAnimation(t) { + -1 === this._anims.array.indexOf(t) && this._anims.push(t); + } + removeAnimation(t) { + const e = this._anims.array.indexOf(t); + e >= 0 ? this._anims.fastRemoveAt(e) : F(3907); + } + pushDelayEvent(t, e, i) { + this._delayEvents.push({ + fn: t, + thisArg: e, + args: i + }); + } + addSockets(t, e) { + for (let i = 0; i < e.length; ++i) { + const s = e[i]; + if (this._sockets.find((t => t.target === s.target))) continue; + const n = t.getChildByPath(s.path); + const r = s.target && n && L2(n, t); + r && this._sockets.push({ + target: s.target, + transform: r + }); + } + } + removeSockets(t, e) { + for (let t = 0; t < e.length; ++t) { + const i = e[t]; + for (let t = 0; t < this._sockets.length; ++t) { + const e = this._sockets[t]; + if (e.target === i.target) { + F2(e.transform.node); + this._sockets[t] = this._sockets[this._sockets.length - 1]; + this._sockets.length--; + break; + } + } + } + } + }, k2.ID = "animation", U2)) || V2); + IR.on(RR.EVENT_INIT, (() => { + const t = new G2; + IR.registerSystem(G2.ID, t, Tg.Priority.HIGH); + })); + m.AnimationManager = G2; + class z2 extends HY { + constructor(t) { + super(); + this._managedStates = []; + this._fadings = []; + this._scheduled = !1; + this._scheduler = null != t ? t : XY(); + } + update(t) { + if (this.isMotionless) return; + const e = this._managedStates; + const i = this._fadings; + if (1 === e.length && 1 === i.length) { + const t = e[0].state; + t && (t.weight = 1); + } else this._calculateWeights(t); + 1 === e.length && 1 === i.length && this._unscheduleThis(); + } + crossFade(t, e) { + var i; + 0 === this._managedStates.length && (e = 0); + 0 === e && this.clear(); + let s = this._managedStates.find((e => e.state === t)); + if (s) (null === (i = s.state) || void 0 === i ? void 0 : i.isMotionless) && s.state.play(); else { + s = { + state: t, + reference: 0 + }; + t && t.play(); + this._managedStates.push(s); + } + ++s.reference; + this._fadings.unshift({ + easeDuration: e, + easeTime: 0, + target: s + }); + this.isMotionless || this._scheduleThis(); + } + clear() { + for (let t = 0; t < this._managedStates.length; ++t) { + const e = this._managedStates[t].state; + e && e.stop(); + } + this._managedStates.length = 0; + this._fadings.length = 0; + } + onPlay() { + super.onPlay(); + this._scheduleThis(); + } + onPause() { + super.onPause(); + for (let t = 0; t < this._managedStates.length; ++t) { + const e = this._managedStates[t].state; + e && e.pause(); + } + this._unscheduleThis(); + } + onResume() { + super.onResume(); + for (let t = 0; t < this._managedStates.length; ++t) { + const e = this._managedStates[t].state; + e && e.resume(); + } + this._scheduleThis(); + } + onStop() { + super.onStop(); + this.clear(); + } + _calculateWeights(t) { + const e = this._managedStates; + const i = this._fadings; + for (let t = 0; t < e.length; ++t) { + const i = e[t].state; + i && (i.weight = 0); + } + let s = 1; + let n = i.length; + for (let e = 0; e < i.length; ++e) { + const r = i[e]; + r.easeTime += t; + const o = 0 === r.easeDuration ? 1 : di(r.easeTime / r.easeDuration); + const a = o * s; + s *= 1 - o; + r.target.state && (r.target.state.weight += a); + if (r.easeTime >= r.easeDuration) { + n = e + 1; + r.easeTime = r.easeDuration; + break; + } + } + if (n !== i.length) { + for (let t = n; t < i.length; ++t) { + const e = i[t]; + --e.target.reference; + if (e.target.reference <= 0) { + e.target.state && e.target.state.stop(); + at(this._managedStates, e.target); + } + } + i.splice(n); + } + } + _scheduleThis() { + if (!this._scheduled) { + this._scheduler.addCrossFade(this); + this._scheduled = !0; + } + } + _unscheduleThis() { + if (this._scheduled) { + this._scheduler.removeCrossFade(this); + this._scheduled = !1; + } + } + } + var H2, j2, X2, W2, Y2, q2, K2, J2, Z2, Q2, $2, t3, e3, i3, s3, n3, r3; + let o3 = function(e) { + return t({ + Animation: e, + AnimationComponent: e + }), e; + }((H2 = Ul("cc.Animation"), j2 = sh(), X2 = zl(99), W2 = $l(), Y2 = Th([ M$ ]), + q2 = lh(), K2 = Th(M$), J2 = lh(), Z2 = lh(), Q2 = Th([ M$ ]), H2($2 = j2($2 = X2($2 = Ql($2 = W2($2 = (t3 = (r3 = n3 = class extends(To(Qc)){ + constructor(...t) { + super(...t); + Ml(this, "playOnLoad", e3, this); + this._crossFade = new z2; + this._nameToState = vt(!0); + Ml(this, "_clips", i3, this); + Ml(this, "_defaultClip", s3, this); + this._hasBeenPlayed = !1; + } + get clips() { + return this._clips; + } + set clips(t) { + this._crossFade && this._crossFade.clear(); + for (const t of this._clips) t && this._removeStateOfAutomaticClip(t); + for (const e of t) e && this.createState(e); + const e = t.find((t => a3(t, this._defaultClip))); + this._defaultClip = e || null; + this._clips = t; + } + get defaultClip() { + return this._defaultClip; + } + set defaultClip(t) { + this._defaultClip = t; + if (!t) return; + if (!(this._clips.findIndex((e => a3(e, t))) >= 0)) { + this._clips.push(t); + this.createState(t); + } + } + onLoad() { + this.clips = this._clips; + for (const t in this._nameToState) { + this._nameToState[t].initialize(this.node); + } + } + start() { + this.playOnLoad && !this._hasBeenPlayed && this._defaultClip && this.crossFade(this._defaultClip.name, 0); + } + onEnable() { + this._crossFade.resume(); + } + onDisable() { + this._crossFade.pause(); + } + onDestroy() { + this._crossFade.stop(); + for (const t in this._nameToState) { + this._nameToState[t].destroy(); + } + this._nameToState = vt(!0); + } + play(t) { + this._hasBeenPlayed = !0; + if (!t) { + if (!this._defaultClip) return; + t = this._defaultClip.name; + } + this.crossFade(t, 0); + } + crossFade(t, e = .3) { + this._hasBeenPlayed = !0; + const i = this._nameToState[t]; + i && this.doPlayOrCrossFade(i, e); + } + pause() { + this._crossFade.pause(); + } + resume() { + this._crossFade.resume(); + } + stop() { + this._crossFade.stop(); + } + getState(t) { + const e = this._nameToState[t]; + e && !e.curveLoaded && e.initialize(this.node); + return e || null; + } + createState(t, e) { + e = e || t.name; + this.removeState(e); + return this._doCreateState(t, e); + } + removeState(t) { + const e = this._nameToState[t]; + if (e) { + e.allowLastFrameEvent(!1); + e.stop(); + delete this._nameToState[t]; + } + } + addClip(t, e) { + ht(this._clips, t) || this._clips.push(t); + return this.createState(t, e); + } + removeClip(t, e) { + let i; + for (const e in this._nameToState) { + const s = this._nameToState[e]; + if (s.clip === t) { + i = s; + break; + } + } + if (t === this._defaultClip) { + if (!e) { + N(3902); + return; + } + this._defaultClip = null; + } + if (i && i.isPlaying) { + if (!e) { + N(3903); + return; + } + i.stop(); + } + this._clips = this._clips.filter((e => e !== t)); + i && delete this._nameToState[i.name]; + } + on(t, e, i, s) { + const n = super.on(t, e, i, s); + t === WY.LASTFRAME && this._syncAllowLastFrameEvent(); + return n; + } + once(t, e, i) { + const s = super.once(t, e, i); + t === WY.LASTFRAME && this._syncAllowLastFrameEvent(); + return s; + } + off(t, e, i) { + super.off(t, e, i); + t === WY.LASTFRAME && this._syncDisallowLastFrameEvent(); + } + _createState(t, e) { + return new YY(t, e); + } + _doCreateState(t, e) { + const i = this._createState(t, e); + i._setEventTarget(this); + i.allowLastFrameEvent(this.hasEventListener(WY.LASTFRAME)); + this.node && i.initialize(this.node); + this._nameToState[i.name] = i; + return i; + } + doPlayOrCrossFade(t, e) { + this._crossFade.play(); + this._crossFade.crossFade(t, e); + } + _removeStateOfAutomaticClip(t) { + for (const e in this._nameToState) { + const i = this._nameToState[e]; + if (a3(t, i.clip)) { + i.stop(); + delete this._nameToState[e]; + } + } + } + _syncAllowLastFrameEvent() { + if (this.hasEventListener(WY.LASTFRAME)) for (const t in this._nameToState) this._nameToState[t].allowLastFrameEvent(!0); + } + _syncDisallowLastFrameEvent() { + if (!this.hasEventListener(WY.LASTFRAME)) for (const t in this._nameToState) this._nameToState[t].allowLastFrameEvent(!1); + } + }, n3.EventType = WY, r3), Bl(t3.prototype, "clips", [ Y2, q2 ], Object.getOwnPropertyDescriptor(t3.prototype, "clips"), t3.prototype), + Bl(t3.prototype, "defaultClip", [ K2, J2 ], Object.getOwnPropertyDescriptor(t3.prototype, "defaultClip"), t3.prototype), + e3 = Bl(t3.prototype, "playOnLoad", [ Yl, Z2 ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), i3 = Bl(t3.prototype, "_clips", [ Q2 ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), s3 = Bl(t3.prototype, "_defaultClip", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), t3)) || $2) || $2) || $2) || $2) || $2)); + function a3(t, e) { + return t === e || !!t && !!e && t._uuid === e._uuid && t._uuid; + } + m.Animation = o3; + m.AnimationComponent = o3; + ee.setClassAlias(o3, "cc.AnimationComponent"); + m.easing = Td; + let l3; + !function(t) { + t.PLAYED = "play"; + t.PAUSED = "pause"; + t.STOPPED = "stop"; + t.SEEKED = "seeked"; + t.ENDED = "ended"; + t.INTERRUPTION_BEGIN = "interruptionBegin"; + t.INTERRUPTION_END = "interruptionEnd"; + t.USER_GESTURE = "on_gesture"; + }(l3 || (l3 = {})); + let h3; + !function(t) { + t[t.DOM_AUDIO = 0] = "DOM_AUDIO"; + t[t.WEB_AUDIO = 1] = "WEB_AUDIO"; + t[t.MINIGAME_AUDIO = 2] = "MINIGAME_AUDIO"; + t[t.NATIVE_AUDIO = 3] = "NATIVE_AUDIO"; + t[t.UNKNOWN_AUDIO = 4] = "UNKNOWN_AUDIO"; + }(h3 || (h3 = {})); + let c3; + !function(t) { + t[t.INIT = 0] = "INIT"; + t[t.PLAYING = 1] = "PLAYING"; + t[t.PAUSED = 2] = "PAUSED"; + t[t.STOPPED = 3] = "STOPPED"; + t[t.INTERRUPTED = 4] = "INTERRUPTED"; + }(c3 || (c3 = {})); + class u3 { + constructor(...t) { + this._bufferView = void 0; + this._normalizeFactor = 1; + if (2 === t.length) { + this._bufferView = t[0]; + this._normalizeFactor = t[1]; + } else { + const e = t[0]; + const i = t[1]; + const s = t[2]; + this._bufferView = new i(e); + this._normalizeFactor = s; + } + } + get length() { + return this._bufferView.length; + } + getData(t) { + return this._bufferView[t] * this._normalizeFactor; + } + } + t("AudioPCMDataView", u3); + let _3 = 0; + function d3(t, e) { + if (!e.invoking) { + e.invoking = !0; + e.func.call(t, ...e.args).then((() => { + e.invoking = !1; + t._operationQueue.shift(); + t._eventTarget.emit(e.id.toString()); + const i = t._operationQueue[0]; + i && d3(t, i); + })).catch((t => {})); + } + } + function p3(t, e, i) { + const s = i.value; + i.value = function(...t) { + return new Promise((e => { + const i = _3++; + const n = this; + n._operationQueue.push({ + id: i, + func: s, + args: t, + invoking: !1 + }); + n._eventTarget.once(i.toString(), e); + d3(n, n._operationQueue[0]); + })); + }; + } + var m3, f3, g3; + const y3 = {}; + const b3 = jsb.AudioEngine; + const S3 = -1; + var A3; + !function(t) { + t[t.UNKNOWN = 0] = "UNKNOWN"; + t[t.SIGNED_8 = 1] = "SIGNED_8"; + t[t.UNSIGNED_8 = 2] = "UNSIGNED_8"; + t[t.SIGNED_16 = 3] = "SIGNED_16"; + t[t.UNSIGNED_16 = 4] = "UNSIGNED_16"; + t[t.SIGNED_32 = 5] = "SIGNED_32"; + t[t.UNSIGNED_32 = 6] = "UNSIGNED_32"; + t[t.FLOAT_32 = 7] = "FLOAT_32"; + t[t.FLOAT_64 = 8] = "FLOAT_64"; + }(A3 || (A3 = {})); + const T3 = { + [A3.UNKNOWN]: void 0, + [A3.SIGNED_8]: { + ctor: Int8Array, + maxValue: 127 + }, + [A3.UNSIGNED_8]: { + ctor: Uint8Array, + maxValue: 255 + }, + [A3.SIGNED_16]: { + ctor: Int16Array, + maxValue: 32767 + }, + [A3.UNSIGNED_16]: { + ctor: Uint16Array, + maxValue: 65535 + }, + [A3.SIGNED_32]: { + ctor: Int32Array, + maxValue: 2147483647 + }, + [A3.UNSIGNED_32]: { + ctor: Uint32Array, + maxValue: 4294967295 + }, + [A3.FLOAT_32]: { + ctor: Float32Array, + maxValue: 1 + }, + [A3.FLOAT_64]: { + ctor: Float64Array, + maxValue: 1 + } + }; + class v3 { + get onPlay() { + return this._onPlayCb; + } + set onPlay(t) { + this._onPlayCb = t; + } + get onEnd() { + return this._onEndCb; + } + set onEnd(t) { + this._onEndCb = t; + } + constructor(t, e) { + this._id = S3; + this._url = void 0; + this._volume = void 0; + this._onPlayCb = void 0; + this._onEndCb = void 0; + this._url = t; + this._volume = e; + } + play() { + var t; + this._id = jsb.AudioEngine.play2d(this._url, !1, this._volume); + jsb.AudioEngine.setFinishCallback(this._id, (() => { + var t; + null === (t = this.onEnd) || void 0 === t || t.call(this); + })); + null === (t = this.onPlay) || void 0 === t || t.call(this); + } + stop() { + this._id !== S3 && jsb.AudioEngine.stop(this._id); + } + } + let E3 = (m3 = (g3 = f3 = class t { + constructor(t) { + this._url = void 0; + this._id = S3; + this._state = c3.INIT; + this._pcmHeader = void 0; + this._eventTarget = new vo; + this._operationQueue = []; + this._cachedState = { + duration: 1, + loop: !1, + currentTime: 0, + volume: 1 + }; + this._url = t; + this._pcmHeader = null; + Po.on("hide", this._onHide, this); + Po.on("show", this._onShow, this); + } + destroy() { + Po.on("hide", this._onHide, this); + Po.on("show", this._onShow, this); + --y3[this._url] <= 0 && b3.uncache(this._url); + } + _onHide() { + this._state === c3.PLAYING && this.pause().then((() => { + this._state = c3.INTERRUPTED; + this._eventTarget.emit(l3.INTERRUPTION_BEGIN); + })).catch((t => {})); + } + _onShow() { + this._state === c3.INTERRUPTED && this.play().then((() => { + this._eventTarget.emit(l3.INTERRUPTION_END); + })).catch((t => {})); + } + static load(e) { + return new Promise(((i, s) => { + t.loadNative(e).then((e => { + i(new t(e)); + })).catch((t => s(t))); + })); + } + static loadNative(t) { + return new Promise(((e, i) => { + if (Po.platform === Io.WIN32) { + b3.preload(t, (t => { + console.debug("somehow preload success on windows"); + })); + e(t); + } else b3.preload(t, (s => { + s ? e(t) : i(new Error("load audio failed")); + })); + })); + } + static loadOneShotAudio(e, i) { + return new Promise(((s, n) => { + t.loadNative(e).then((t => { + s(new v3(t, i)); + })).catch(n); + })); + } + get _isValid() { + return this._id !== S3; + } + get src() { + return this._url; + } + get type() { + return h3.NATIVE_AUDIO; + } + get state() { + return this._state; + } + get loop() { + return this._isValid ? b3.isLoop(this._id) : this._cachedState.loop; + } + set loop(t) { + this._isValid && b3.setLoop(this._id, t); + this._cachedState.loop = t; + } + get volume() { + return this._isValid ? b3.getVolume(this._id) : this._cachedState.volume; + } + set volume(t) { + t = di(t); + this._isValid && b3.setVolume(this._id, t); + this._cachedState.volume = t; + } + get duration() { + return this._isValid ? b3.getDuration(this._id) : this._cachedState.duration; + } + get currentTime() { + return this._isValid ? b3.getCurrentTime(this._id) : this._cachedState.currentTime; + } + get sampleRate() { + null === this._pcmHeader && (this._pcmHeader = jsb.AudioEngine.getPCMHeader(this._url)); + return this._pcmHeader.sampleRate; + } + getPCMData(t) { + const e = b3.getOriginalPCMBuffer(this._url, t); + null === this._pcmHeader && (this._pcmHeader = jsb.AudioEngine.getPCMHeader(this._url)); + const i = T3[this._pcmHeader.audioFormat]; + if (e && i) return new u3(e, i.ctor, 1 / i.maxValue); + } + seek(t) { + return new Promise((e => { + this._isValid && b3.setCurrentTime(this._id, t); + this._cachedState.currentTime = t; + return e(); + })); + } + play() { + return new Promise((t => { + if (this._isValid) { + if (this._state === c3.PAUSED || this._state === c3.INTERRUPTED) b3.resume(this._id); else if (this._state === c3.PLAYING) { + b3.pause(this._id); + b3.setCurrentTime(this._id, 0); + b3.resume(this._id); + } + } else { + this._id = b3.play2d(this._url, this._cachedState.loop, this._cachedState.volume); + if (this._isValid) { + if (0 !== this._cachedState.currentTime) { + b3.setCurrentTime(this._id, this._cachedState.currentTime); + this._cachedState.currentTime = 0; + } + b3.setFinishCallback(this._id, (() => { + this._cachedState.currentTime = 0; + this._id = S3; + this._state = c3.INIT; + this._eventTarget.emit(l3.ENDED); + })); + } + } + this._state = c3.PLAYING; + t(); + })); + } + pause() { + return new Promise((t => { + this._isValid && b3.pause(this._id); + this._state = c3.PAUSED; + t(); + })); + } + stop() { + return new Promise((t => { + this._isValid && b3.stop(this._id); + this._state = c3.STOPPED; + this._id = S3; + this._cachedState.currentTime = 0; + t(); + })); + } + onInterruptionBegin(t) { + this._eventTarget.on(l3.INTERRUPTION_BEGIN, t); + } + offInterruptionBegin(t) { + this._eventTarget.off(l3.INTERRUPTION_BEGIN, t); + } + onInterruptionEnd(t) { + this._eventTarget.on(l3.INTERRUPTION_END, t); + } + offInterruptionEnd(t) { + this._eventTarget.off(l3.INTERRUPTION_END, t); + } + onEnded(t) { + this._eventTarget.on(l3.ENDED, t); + } + offEnded(t) { + this._eventTarget.off(l3.ENDED, t); + } + }, f3.maxAudioChannel = b3.getMaxAudioInstance(), g3), Bl(m3.prototype, "seek", [ p3 ], Object.getOwnPropertyDescriptor(m3.prototype, "seek"), m3.prototype), + Bl(m3.prototype, "play", [ p3 ], Object.getOwnPropertyDescriptor(m3.prototype, "play"), m3.prototype), + Bl(m3.prototype, "pause", [ p3 ], Object.getOwnPropertyDescriptor(m3.prototype, "pause"), m3.prototype), + Bl(m3.prototype, "stop", [ p3 ], Object.getOwnPropertyDescriptor(m3.prototype, "stop"), m3.prototype), + m3); + m.AudioPlayer = E3; + var C3, x3, w3, R3, I3; + let M3 = t("AudioClip", Ul("cc.AudioClip")(C3 = (x3 = (I3 = R3 = class extends gc { + constructor(...t) { + super(...t); + Ml(this, "_duration", w3, this); + this._loadMode = h3.UNKNOWN_AUDIO; + this._meta = null; + this._player = null; + } + destroy() { + var t; + const e = super.destroy(); + null === (t = this._player) || void 0 === t || t.destroy(); + this._player = null; + this._meta && (this._meta.player = null); + return e; + } + set _nativeAsset(t) { + this._meta = t; + if (t) { + this._loadMode = t.type; + this._player = t.player; + } else { + this._meta = null; + this._loadMode = h3.UNKNOWN_AUDIO; + this._duration = 0; + } + } + get _nativeAsset() { + return this._meta; + } + get _nativeDep() { + return { + uuid: this._uuid, + audioLoadMode: this.loadMode, + ext: this._native, + __isNative__: !0 + }; + } + get loadMode() { + return this._loadMode; + } + validate() { + return !!this._meta; + } + getDuration() { + return this._duration ? this._duration : this._meta ? this._meta.duration : 0; + } + get state() { + return this._player ? this._player.state : c3.INIT; + } + getCurrentTime() { + return this._player ? this._player.currentTime : 0; + } + getVolume() { + return this._player ? this._player.volume : 0; + } + getLoop() { + return !!this._player && this._player.loop; + } + setCurrentTime(t) { + var e; + null === (e = this._player) || void 0 === e || e.seek(t).catch((t => {})); + } + setVolume(t) { + this._player && (this._player.volume = t); + } + setLoop(t) { + this._player && (this._player.loop = t); + } + play() { + var t; + null === (t = this._player) || void 0 === t || t.play().catch((t => {})); + } + pause() { + var t; + null === (t = this._player) || void 0 === t || t.pause().catch((t => {})); + } + stop() { + var t; + null === (t = this._player) || void 0 === t || t.stop().catch((t => {})); + } + playOneShot(t = 1) { + this._nativeAsset && E3.loadOneShotAudio(this._nativeAsset.url, t).then((t => { + t.play(); + })).catch((t => {})); + } + }, R3.AudioType = h3, I3), w3 = Bl(x3.prototype, "_duration", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Bl(x3.prototype, "_nativeDep", [ vh ], Object.getOwnPropertyDescriptor(x3.prototype, "_nativeDep"), x3.prototype), + x3)) || C3); + m.AudioClip = M3; + function B3(t, e, i) { + E3.load(t, { + audioLoadMode: e.audioLoadMode + }).then((e => { + const s = { + player: e, + url: t, + duration: e.duration, + type: e.type + }; + i(null, s); + })).catch((t => { + i(t); + })); + } + function D3(t, e, i, s) { + const n = new M3; + n._nativeUrl = t; + n._nativeAsset = e; + n._duration = e.duration; + s(null, n); + } + Jw.register({ + ".mp3": B3, + ".ogg": B3, + ".wav": B3, + ".m4a": B3 + }); + sR.register({ + ".mp3": D3, + ".ogg": D3, + ".wav": D3, + ".m4a": D3 + }); + const P3 = new class { + constructor() { + this._oneShotAudioInfoList = []; + this._audioPlayerInfoList = []; + } + _findIndex(t, e) { + return t.findIndex((t => t.audio === e)); + } + _tryAddPlaying(t, e) { + const i = this._findIndex(t, e); + if (i > -1) { + t[i].playTime = performance.now(); + return !1; + } + t.push({ + audio: e, + playTime: performance.now() + }); + return !0; + } + addPlaying(t) { + if (t instanceof E3) { + if (this._tryAddPlaying(this._audioPlayerInfoList, t)) return; + } else this._tryAddPlaying(this._oneShotAudioInfoList, t); + } + _tryRemovePlaying(t, e) { + const i = this._findIndex(t, e); + if (-1 === i) return !1; + ot(t, i); + return !0; + } + removePlaying(t) { + if (t instanceof E3) { + if (this._tryRemovePlaying(this._audioPlayerInfoList, t)) return; + } else this._tryRemovePlaying(this._oneShotAudioInfoList, t); + } + discardOnePlayingIfNeeded() { + if (this._audioPlayerInfoList.length + this._oneShotAudioInfoList.length < E3.maxAudioChannel) return; + let t; + this._oneShotAudioInfoList.length > 0 ? this._oneShotAudioInfoList.forEach((e => { + (!t || e.playTime < t.playTime) && (t = e); + })) : this._audioPlayerInfoList.forEach((e => { + (!t || e.playTime < t.playTime) && (t = e); + })); + if (t) { + t.audio.stop(); + this.removePlaying(t.audio); + } + } + }; + var O3, N3, L3, F3, V3, k3, U3, G3, z3, H3, j3, X3, W3, Y3, q3, K3, J3, Z3; + const Q3 = "audiosource-loaded"; + var $3; + !function(t) { + t.STARTED = "started"; + t.ENDED = "ended"; + }($3 || ($3 = {})); + let t5 = function(e) { + return t({ + AudioSource: e, + AudioSourceComponent: e + }), e; + }((O3 = Ul("cc.AudioSource"), N3 = sh(), L3 = $l(), F3 = Th(M3), V3 = Th(M3), k3 = lh(), + U3 = lh(), G3 = lh(), z3 = hh(), H3 = lh(), O3(j3 = N3(j3 = L3(j3 = (X3 = (Z3 = J3 = class t extends Qc { + constructor(...t) { + super(...t); + Ml(this, "_clip", W3, this); + this._player = null; + Ml(this, "_loop", Y3, this); + Ml(this, "_playOnAwake", q3, this); + Ml(this, "_volume", K3, this); + this._cachedCurrentTime = 0; + this._operationsBeforeLoading = []; + this._isLoaded = !1; + this._lastSetClip = null; + } + static get maxAudioChannel() { + return E3.maxAudioChannel; + } + set clip(t) { + if (t !== this._clip) { + this._clip = t; + this._syncPlayer(); + } + } + get clip() { + return this._clip; + } + _syncPlayer() { + const t = this._clip; + this._isLoaded = !1; + if (this._lastSetClip !== t) if (t) if (t._nativeAsset) { + this._lastSetClip = t; + this._operationsBeforeLoading.length = 0; + E3.load(t._nativeAsset.url, { + audioLoadMode: t.loadMode + }).then((e => { + var i; + if (this._lastSetClip === t) { + this._isLoaded = !0; + if (this._player) { + P3.removePlaying(this._player); + this._player.offEnded(); + this._player.offInterruptionBegin(); + this._player.offInterruptionEnd(); + this._player.destroy(); + } + this._player = e; + e.onEnded((() => { + var t; + P3.removePlaying(e); + null === (t = this.node) || void 0 === t || t.emit($3.ENDED, this); + })); + e.onInterruptionBegin((() => { + P3.removePlaying(e); + })); + e.onInterruptionEnd((() => { + P3.addPlaying(e); + })); + this._syncStates(); + null === (i = this.node) || void 0 === i || i.emit(Q3); + } else e.destroy(); + })).catch((t => {})); + } else console.error("Invalid audio clip"); else this._lastSetClip = null; + } + set loop(t) { + this._loop = t; + this._player && (this._player.loop = t); + } + get loop() { + return this._loop; + } + set playOnAwake(t) { + this._playOnAwake = t; + } + get playOnAwake() { + return this._playOnAwake; + } + set volume(t) { + if (Number.isNaN(t)) console.warn("illegal audio volume!"); else { + t = _i(t, 0, 1); + if (this._player) { + this._player.volume = t; + this._volume = this._player.volume; + } else this._volume = t; + } + } + get volume() { + return this._volume; + } + onLoad() { + this._syncPlayer(); + } + onEnable() { + this._playOnAwake && !this.playing && this.play(); + } + onDisable() { + const t = this._getRootNode(); + (null == t ? void 0 : t._persistNode) || this.pause(); + } + onDestroy() { + var t; + this.stop(); + null === (t = this._player) || void 0 === t || t.destroy(); + this._player = null; + } + getPCMData(t) { + return new Promise((e => { + if (0 === t || 1 === t) if (this._player) e(this._player.getPCMData(t)); else { + var i; + null === (i = this.node) || void 0 === i || i.once(Q3, (() => { + var i; + e(null === (i = this._player) || void 0 === i ? void 0 : i.getPCMData(t)); + })); + } else { + console.warn("Only support channel index 0 or 1 to get buffer"); + e(void 0); + } + })); + } + getSampleRate() { + return new Promise((t => { + if (this._player) t(this._player.sampleRate); else { + var e; + null === (e = this.node) || void 0 === e || e.once(Q3, (() => { + t(this._player.sampleRate); + })); + } + })); + } + _getRootNode() { + var t, e; + let i = this.node; + let s = null === (t = i) || void 0 === t || null === (e = t.parent) || void 0 === e ? void 0 : e.parent; + for (;s; ) { + var n, r, o; + i = null === (n = i) || void 0 === n ? void 0 : n.parent; + s = null === (r = i) || void 0 === r || null === (o = r.parent) || void 0 === o ? void 0 : o.parent; + } + return i; + } + play() { + var t; + if (!this._isLoaded && this.clip) { + this._operationsBeforeLoading.push("play"); + return; + } + P3.discardOnePlayingIfNeeded(); + if (this.state === c3.PLAYING) { + var e; + null === (e = this._player) || void 0 === e || e.stop().catch((t => {})); + } + const i = this._player; + null === (t = this._player) || void 0 === t || t.play().then((() => { + var t; + P3.addPlaying(i); + null === (t = this.node) || void 0 === t || t.emit($3.STARTED, this); + })).catch((t => {})); + } + pause() { + var t; + if (!this._isLoaded && this.clip) { + this._operationsBeforeLoading.push("pause"); + return; + } + const e = this._player; + null === (t = this._player) || void 0 === t || t.pause().then((() => { + P3.removePlaying(e); + })).catch((t => {})); + } + stop() { + var t; + if (!this._isLoaded && this.clip) { + this._operationsBeforeLoading.push("stop"); + return; + } + const e = this._player; + null === (t = this._player) || void 0 === t || t.stop().then((() => { + P3.removePlaying(e); + })).catch((t => {})); + } + playOneShot(t, e = 1) { + t._nativeAsset ? E3.loadOneShotAudio(t._nativeAsset.url, this._volume * e, { + audioLoadMode: t.loadMode + }).then((t => { + P3.discardOnePlayingIfNeeded(); + t.onPlay = () => { + P3.addPlaying(t); + }; + t.onEnd = () => { + P3.removePlaying(t); + }; + t.play(); + })).catch((t => {})) : console.error("Invalid audio clip"); + } + _syncStates() { + this._player && this._player.seek(this._cachedCurrentTime).then((() => { + if (this._player) { + this._player.loop = this._loop; + this._player.volume = this._volume; + this._operationsBeforeLoading.forEach((t => { + var e; + null === (e = this[t]) || void 0 === e || e.call(this); + })); + this._operationsBeforeLoading.length = 0; + } + })).catch((t => {})); + } + set currentTime(t) { + var e; + if (Number.isNaN(t)) console.warn("illegal audio time!"); else { + t = _i(t, 0, this.duration); + this._cachedCurrentTime = t; + null === (e = this._player) || void 0 === e || e.seek(this._cachedCurrentTime).catch((t => {})); + } + } + get currentTime() { + return this._player ? this._player.currentTime : this._cachedCurrentTime; + } + get duration() { + var t, e; + return null !== (t = null === (e = this._clip) || void 0 === e ? void 0 : e.getDuration()) && void 0 !== t ? t : this._player ? this._player.duration : 0; + } + get state() { + return this._player ? this._player.state : c3.INIT; + } + get playing() { + return this.state === t.AudioState.PLAYING; + } + }, J3.AudioState = c3, J3.EventType = $3, Z3), W3 = Bl(X3.prototype, "_clip", [ F3 ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Y3 = Bl(X3.prototype, "_loop", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), q3 = Bl(X3.prototype, "_playOnAwake", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), K3 = Bl(X3.prototype, "_volume", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), Bl(X3.prototype, "clip", [ V3, k3 ], Object.getOwnPropertyDescriptor(X3.prototype, "clip"), X3.prototype), + Bl(X3.prototype, "loop", [ U3 ], Object.getOwnPropertyDescriptor(X3.prototype, "loop"), X3.prototype), + Bl(X3.prototype, "playOnAwake", [ G3 ], Object.getOwnPropertyDescriptor(X3.prototype, "playOnAwake"), X3.prototype), + Bl(X3.prototype, "volume", [ z3, H3 ], Object.getOwnPropertyDescriptor(X3.prototype, "volume"), X3.prototype), + X3)) || j3) || j3) || j3)); + W(M3, "AudioClip", [ { + name: "PlayingState", + newName: "AudioState", + target: t5, + targetName: "AudioSource" + } ]); + q(M3.prototype, "AudioClip.prototype", [ "state", "play", "pause", "stop", "playOneShot", "setCurrentTime", "setVolume", "setLoop", "getCurrentTime", "getVolume", "getLoop" ].map((t => ({ + name: t, + suggest: `please use AudioSource.prototype.${t} instead` + })))); + m.AudioSourceComponent = t5; + ee.setClassAlias(t5, "cc.AudioSourceComponent"); + m.log = E; + m.warn = C; + m.error = x; + m.assert = w; + m._throw = M; + m.logID = P; + m.warnID = N; + m.errorID = F; + m.assertID = k; + m.debug = j; + m.path = { + join: sc, + extname: nc, + mainFileName: rc, + basename: oc, + dirname: ac, + changeExtname: lc, + changeBasename: hc, + _normalize: cc, + stripSep: uc, + get sep() { + return _c(); + } + }; + class e5 { + constructor(t) { + this.poolHandlerComp = void 0; + this._pool = void 0; + this.poolHandlerComp = t; + this._pool = []; + } + size() { + return this._pool.length; + } + clear() { + const t = this._pool.length; + for (let e = 0; e < t; ++e) this._pool[e].destroy(); + this._pool.length = 0; + } + put(t) { + if (t && -1 === this._pool.indexOf(t)) { + t.removeFromParent(); + const e = this.poolHandlerComp ? t.getComponent(this.poolHandlerComp) : null; + e && e.unuse && e.unuse(); + this._pool.push(t); + } + } + get(...t) { + const e = this._pool.length - 1; + if (e < 0) return null; + { + const t = this._pool[e]; + this._pool.length = e; + const i = this.poolHandlerComp ? t.getComponent(this.poolHandlerComp) : null; + i && i.reuse && i.reuse(arguments); + return t; + } + } + } + t("NodePool", e5); + m.NodePool = e5; + var i5, s5; + const n5 = null !== (i5 = globalThis.jsb) && void 0 !== i5 ? i5 : {}; + { + Object.defineProperty(n5, "reflection", { + get() { + if (void 0 !== n5.__bridge) return n5.__bridge; + !globalThis.JavascriptJavaBridge || Vo.os !== Vo.OS.ANDROID && Vo.os !== Vo.OS.OHOS ? !globalThis.JavaScriptObjCBridge || Vo.os !== Vo.OS.IOS && Vo.os !== Vo.OS.OSX ? n5.__bridge = null : n5.__bridge = new globalThis.JavaScriptObjCBridge : n5.__bridge = new globalThis.JavascriptJavaBridge; + return n5.__bridge; + }, + enumerable: !0, + configurable: !0, + set(t) { + n5.__bridge = t; + } + }); + Object.defineProperty(n5, "bridge", { + get() { + if (void 0 !== n5.__ccbridge) return n5.__ccbridge; + window.ScriptNativeBridge && Vo.os === Vo.OS.ANDROID || Vo.os === Vo.OS.IOS || Vo.os === Vo.OS.OSX || Vo.os === Vo.OS.OHOS ? n5.__ccbridge = new ScriptNativeBridge : n5.__ccbridge = null; + return n5.__ccbridge; + }, + enumerable: !0, + configurable: !0, + set(t) { + n5.__ccbridge = t; + } + }); + const t = { + eventMap: new Map, + addNativeEventListener(t, e) { + this.eventMap.get(t) || this.eventMap.set(t, []); + const i = this.eventMap.get(t); + i.find(e) || i.push(e); + }, + dispatchEventToNative(t, e) { + n5.bridge.sendToNative(t, e); + }, + removeAllListenersForEvent(t) { + return this.eventMap.delete(t); + }, + removeNativeEventListener(t, e) { + const i = this.eventMap.get(t); + if (!i) return !1; + for (let t = 0, s = i.length; t < s; t++) if (i[t] === e) { + i.splice(t, 1); + return !0; + } + return !0; + }, + removeAllListeners() { + this.eventMap.clear(); + }, + triggerEvent(t, e) { + const i = this.eventMap.get(t); + i ? i.map((t => t.call(null, e))) : console.error(`${t} does not exist`); + } + }; + Object.defineProperty(n5, "jsbBridgeWrapper", { + get() { + if (void 0 !== n5.__JsbBridgeWrapper) return n5.__JsbBridgeWrapper; + if (window.ScriptNativeBridge && Vo.os === Vo.OS.ANDROID || Vo.os === Vo.OS.IOS || Vo.os === Vo.OS.OSX || Vo.os === Vo.OS.OHOS) { + n5.__JsbBridgeWrapper = t; + n5.bridge.onNative = (t, e) => { + console.log(`Trigger event: ${t} with argeter: ${e}`); + n5.__JsbBridgeWrapper.triggerEvent(t, e); + }; + } else n5.__JsbBridgeWrapper = null; + return n5.__JsbBridgeWrapper; + }, + enumerable: !0, + configurable: !0, + set(t) { + n5.__JsbBridgeWrapper = t; + } + }); + const e = n5.saveImageData; + n5.saveImageData = (t, i, s, n) => new Promise(((r, o) => { + e(t, i, s, n, (t => { + t ? r() : o(); + })); + })); + } + t("native", { + DownloaderHints: n5.DownloaderHints, + Downloader: n5.Downloader, + zipUtils: n5.zipUtils, + fileUtils: n5.fileUtils, + DebugRenderer: n5.DebugRenderer, + copyTextToClipboard: null === (s5 = n5.copyTextToClipboard) || void 0 === s5 ? void 0 : s5.bind(n5), + garbageCollect: n5.garbageCollect, + reflection: n5.reflection, + bridge: n5.bridge, + jsbBridgeWrapper: n5.jsbBridgeWrapper, + AssetsManager: n5.AssetsManager, + EventAssetsManager: n5.EventAssetsManager, + Manifest: n5.Manifest, + saveImageData: n5.saveImageData + }); + m.renderer = EO; + var r5 = o5 = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function(t, e) { + t.__proto__ = e; + } || function(t, e) { + for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]); + }; + var o5; + let a5 = {}; + a5 || (a5 = {}); + !function(t) { + var e = function() { + function e(i) { + this._clock = new t.WorldClock; + this._events = []; + this._objects = []; + this._eventManager = null; + this._eventManager = i; + console.info("DragonBones: " + e.VERSION + "\nWebsite: http://dragonbones.com/\nSource and Demo: https://github.com/DragonBones/"); + } + e.prototype.advanceTime = function(e) { + if (this._objects.length > 0) { + for (var i = 0, s = this._objects; i < s.length; i++) { + s[i].returnToPool(); + } + this._objects.length = 0; + } + this._clock.advanceTime(e); + if (this._events.length > 0) { + for (var n = 0; n < this._events.length; ++n) { + var r = this._events[n]; + var o = r.armature; + if (null !== o._armatureData) { + o.eventDispatcher.dispatchDBEvent(r.type, r); + r.type === t.EventObject.SOUND_EVENT && this._eventManager.dispatchDBEvent(r.type, r); + } + this.bufferObject(r); + } + this._events.length = 0; + } + }; + e.prototype.bufferEvent = function(t) { + this._events.indexOf(t) < 0 && this._events.push(t); + }; + e.prototype.bufferObject = function(t) { + this._objects.indexOf(t) < 0 && this._objects.push(t); + }; + Object.defineProperty(e.prototype, "clock", { + get: function() { + return this._clock; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(e.prototype, "eventManager", { + get: function() { + return this._eventManager; + }, + enumerable: !0, + configurable: !0 + }); + e.VERSION = "5.6.300"; + e.yDown = !1; + e.debug = !1; + e.debugDraw = !1; + e.webAssembly = !1; + return e; + }(); + t.DragonBones = e; + }(a5 || (a5 = {})); + console.warn || (console.warn = function() {}); + console.assert || (console.assert = function() {}); + Date.now || (Date.now = function() { + return (new Date).getTime(); + }); + r5 = function(t, e) { + function i() { + this.constructor = t; + } + for (var s in e) e.hasOwnProperty(s) && (t[s] = e[s]); + i.prototype = e.prototype, t.prototype = new i; + }; + !function(t) { + var e = function() { + function t() { + this.hashCode = t._hashCode++; + this._isInPool = !1; + } + t._returnObject = function(e) { + var i = String(e.constructor); + var s = i in t._maxCountMap ? t._maxCountMap[i] : t._defaultMaxCount; + var n = t._poolsMap[i] = t._poolsMap[i] || []; + if (n.length < s) if (e._isInPool) console.warn("The object is already in the pool."); else { + e._isInPool = !0; + n.push(e); + } + }; + t.toString = function() { + throw new Error; + }; + t.setMaxCount = function(e, i) { + (i < 0 || i != i) && (i = 0); + if (null !== e) { + null !== (n = (s = String(e)) in t._poolsMap ? t._poolsMap[s] : null) && n.length > i && (n.length = i); + t._maxCountMap[s] = i; + } else { + t._defaultMaxCount = i; + for (var s in t._poolsMap) { + var n; + (n = t._poolsMap[s]).length > i && (n.length = i); + s in t._maxCountMap && (t._maxCountMap[s] = i); + } + } + }; + t.clearPool = function(e) { + void 0 === e && (e = null); + if (null !== e) { + var i = String(e); + null !== (n = i in t._poolsMap ? t._poolsMap[i] : null) && n.length > 0 && (n.length = 0); + } else for (var s in t._poolsMap) { + var n; + (n = t._poolsMap[s]).length = 0; + } + }; + t.borrowObject = function(e) { + var i = String(e); + var s = i in t._poolsMap ? t._poolsMap[i] : null; + if (null !== s && s.length > 0) { + var n = s.pop(); + n._isInPool = !1; + return n; + } + var r = new e; + r._onClear(); + return r; + }; + t.prototype.returnToPool = function() { + this._onClear(); + t._returnObject(this); + }; + t._hashCode = 0; + t._defaultMaxCount = 3e3; + t._maxCountMap = {}; + t._poolsMap = {}; + return t; + }(); + t.BaseObject = e; + }(a5 || (a5 = {})); + !function(t) { + var e = function() { + function t(t, e, i, s, n, r) { + void 0 === t && (t = 1); + void 0 === e && (e = 0); + void 0 === i && (i = 0); + void 0 === s && (s = 1); + void 0 === n && (n = 0); + void 0 === r && (r = 0); + this.a = t; + this.b = e; + this.c = i; + this.d = s; + this.tx = n; + this.ty = r; + } + t.prototype.toString = function() { + return "[object dragonBones.Matrix] a:" + this.a + " b:" + this.b + " c:" + this.c + " d:" + this.d + " tx:" + this.tx + " ty:" + this.ty; + }; + t.prototype.copyFrom = function(t) { + this.a = t.a; + this.b = t.b; + this.c = t.c; + this.d = t.d; + this.tx = t.tx; + this.ty = t.ty; + return this; + }; + t.prototype.copyFromArray = function(t, e) { + void 0 === e && (e = 0); + this.a = t[e]; + this.b = t[e + 1]; + this.c = t[e + 2]; + this.d = t[e + 3]; + this.tx = t[e + 4]; + this.ty = t[e + 5]; + return this; + }; + t.prototype.identity = function() { + this.a = this.d = 1; + this.b = this.c = 0; + this.tx = this.ty = 0; + return this; + }; + t.prototype.concat = function(t) { + var e = this.a * t.a; + var i = 0; + var s = 0; + var n = this.d * t.d; + var r = this.tx * t.a + t.tx; + var o = this.ty * t.d + t.ty; + if (0 !== this.b || 0 !== this.c) { + e += this.b * t.c; + i += this.b * t.d; + s += this.c * t.a; + n += this.c * t.b; + } + if (0 !== t.b || 0 !== t.c) { + i += this.a * t.b; + s += this.d * t.c; + r += this.ty * t.c; + o += this.tx * t.b; + } + this.a = e; + this.b = i; + this.c = s; + this.d = n; + this.tx = r; + this.ty = o; + return this; + }; + t.prototype.invert = function() { + var t = this.a; + var e = this.b; + var i = this.c; + var s = this.d; + var n = this.tx; + var r = this.ty; + if (0 === e && 0 === i) { + this.b = this.c = 0; + if (0 === t || 0 === s) this.a = this.b = this.tx = this.ty = 0; else { + t = this.a = 1 / t; + s = this.d = 1 / s; + this.tx = -t * n; + this.ty = -s * r; + } + return this; + } + var o = t * s - e * i; + if (0 === o) { + this.a = this.d = 1; + this.b = this.c = 0; + this.tx = this.ty = 0; + return this; + } + o = 1 / o; + var a = this.a = s * o; + e = this.b = -e * o; + i = this.c = -i * o; + s = this.d = t * o; + this.tx = -(a * n + i * r); + this.ty = -(e * n + s * r); + return this; + }; + t.prototype.transformPoint = function(t, e, i, s) { + void 0 === s && (s = !1); + i.x = this.a * t + this.c * e; + i.y = this.b * t + this.d * e; + if (!s) { + i.x += this.tx; + i.y += this.ty; + } + }; + t.prototype.transformRectangle = function(t, e) { + void 0 === e && (e = !1); + var i = this.a; + var s = this.b; + var n = this.c; + var r = this.d; + var o = e ? 0 : this.tx; + var a = e ? 0 : this.ty; + var l = t.x; + var h = t.y; + var c = l + t.width; + var u = h + t.height; + var _ = i * l + n * h + o; + var d = s * l + r * h + a; + var p = i * c + n * h + o; + var m = s * c + r * h + a; + var f = i * c + n * u + o; + var g = s * c + r * u + a; + var y = i * l + n * u + o; + var b = s * l + r * u + a; + var S = 0; + if (_ > p) { + S = _; + _ = p; + p = S; + } + if (f > y) { + S = f; + f = y; + y = S; + } + t.x = Math.floor(_ < f ? _ : f); + t.width = Math.ceil((p > y ? p : y) - t.x); + if (d > m) { + S = d; + d = m; + m = S; + } + if (g > b) { + S = g; + g = b; + b = S; + } + t.y = Math.floor(d < g ? d : g); + t.height = Math.ceil((m > b ? m : b) - t.y); + }; + return t; + }(); + t.Matrix = e; + }(a5 || (a5 = {})); + !function(t) { + var e = function() { + function t(t, e, i, s, n, r) { + void 0 === t && (t = 0); + void 0 === e && (e = 0); + void 0 === i && (i = 0); + void 0 === s && (s = 0); + void 0 === n && (n = 1); + void 0 === r && (r = 1); + this.x = t; + this.y = e; + this.skew = i; + this.rotation = s; + this.scaleX = n; + this.scaleY = r; + } + t.normalizeRadian = function(t) { + t = (t + Math.PI) % (2 * Math.PI); + return t += t > 0 ? -Math.PI : Math.PI; + }; + t.prototype.toString = function() { + return "[object dragonBones.Transform] x:" + this.x + " y:" + this.y + " skewX:" + 180 * this.skew / Math.PI + " skewY:" + 180 * this.rotation / Math.PI + " scaleX:" + this.scaleX + " scaleY:" + this.scaleY; + }; + t.prototype.copyFrom = function(t) { + this.x = t.x; + this.y = t.y; + this.skew = t.skew; + this.rotation = t.rotation; + this.scaleX = t.scaleX; + this.scaleY = t.scaleY; + return this; + }; + t.prototype.identity = function() { + this.x = this.y = 0; + this.skew = this.rotation = 0; + this.scaleX = this.scaleY = 1; + return this; + }; + t.prototype.add = function(t) { + this.x += t.x; + this.y += t.y; + this.skew += t.skew; + this.rotation += t.rotation; + this.scaleX *= t.scaleX; + this.scaleY *= t.scaleY; + return this; + }; + t.prototype.minus = function(t) { + this.x -= t.x; + this.y -= t.y; + this.skew -= t.skew; + this.rotation -= t.rotation; + this.scaleX /= t.scaleX; + this.scaleY /= t.scaleY; + return this; + }; + t.prototype.fromMatrix = function(e) { + var i = this.scaleX, s = this.scaleY; + var n = t.PI_Q; + this.x = e.tx; + this.y = e.ty; + this.rotation = Math.atan(e.b / e.a); + var r = Math.atan(-e.c / e.d); + this.scaleX = this.rotation > -n && this.rotation < n ? e.a / Math.cos(this.rotation) : e.b / Math.sin(this.rotation); + this.scaleY = r > -n && r < n ? e.d / Math.cos(r) : -e.c / Math.sin(r); + if (i >= 0 && this.scaleX < 0) { + this.scaleX = -this.scaleX; + this.rotation = this.rotation - Math.PI; + } + if (s >= 0 && this.scaleY < 0) { + this.scaleY = -this.scaleY; + r -= Math.PI; + } + this.skew = r - this.rotation; + return this; + }; + t.prototype.toMatrix = function(t) { + if (0 === this.rotation) { + t.a = 1; + t.b = 0; + } else { + t.a = Math.cos(this.rotation); + t.b = Math.sin(this.rotation); + } + if (0 === this.skew) { + t.c = -t.b; + t.d = t.a; + } else { + t.c = -Math.sin(this.skew + this.rotation); + t.d = Math.cos(this.skew + this.rotation); + } + if (1 !== this.scaleX) { + t.a *= this.scaleX; + t.b *= this.scaleX; + } + if (1 !== this.scaleY) { + t.c *= this.scaleY; + t.d *= this.scaleY; + } + t.tx = this.x; + t.ty = this.y; + return this; + }; + t.PI = Math.PI; + t.PI_D = 2 * Math.PI; + t.PI_H = Math.PI / 2; + t.PI_Q = Math.PI / 4; + t.RAD_DEG = 180 / Math.PI; + t.DEG_RAD = Math.PI / 180; + return t; + }(); + t.Transform = e; + }(a5 || (a5 = {})); + !function(t) { + var e = function() { + function t(t, e, i, s, n, r, o, a) { + void 0 === t && (t = 1); + void 0 === e && (e = 1); + void 0 === i && (i = 1); + void 0 === s && (s = 1); + void 0 === n && (n = 0); + void 0 === r && (r = 0); + void 0 === o && (o = 0); + void 0 === a && (a = 0); + this.alphaMultiplier = t; + this.redMultiplier = e; + this.greenMultiplier = i; + this.blueMultiplier = s; + this.alphaOffset = n; + this.redOffset = r; + this.greenOffset = o; + this.blueOffset = a; + } + t.prototype.copyFrom = function(t) { + this.alphaMultiplier = t.alphaMultiplier; + this.redMultiplier = t.redMultiplier; + this.greenMultiplier = t.greenMultiplier; + this.blueMultiplier = t.blueMultiplier; + this.alphaOffset = t.alphaOffset; + this.redOffset = t.redOffset; + this.greenOffset = t.greenOffset; + this.blueOffset = t.blueOffset; + }; + t.prototype.identity = function() { + this.alphaMultiplier = this.redMultiplier = this.greenMultiplier = this.blueMultiplier = 1; + this.alphaOffset = this.redOffset = this.greenOffset = this.blueOffset = 0; + }; + return t; + }(); + t.ColorTransform = e; + }(a5 || (a5 = {})); + !function(t) { + var e = function() { + function t(t, e) { + void 0 === t && (t = 0); + void 0 === e && (e = 0); + this.x = t; + this.y = e; + } + t.prototype.copyFrom = function(t) { + this.x = t.x; + this.y = t.y; + }; + t.prototype.clear = function() { + this.x = this.y = 0; + }; + return t; + }(); + t.Point = e; + }(a5 || (a5 = {})); + !function(t) { + var e = function() { + function t(t, e, i, s) { + void 0 === t && (t = 0); + void 0 === e && (e = 0); + void 0 === i && (i = 0); + void 0 === s && (s = 0); + this.x = t; + this.y = e; + this.width = i; + this.height = s; + } + t.prototype.copyFrom = function(t) { + this.x = t.x; + this.y = t.y; + this.width = t.width; + this.height = t.height; + }; + t.prototype.clear = function() { + this.x = this.y = 0; + this.width = this.height = 0; + }; + return t; + }(); + t.Rectangle = e; + }(a5 || (a5 = {})); + !function(t) { + var e = function(t) { + r5(e, t); + function e() { + var e = null !== t && t.apply(this, arguments) || this; + e.ints = []; + e.floats = []; + e.strings = []; + return e; + } + e.toString = function() { + return "[class dragonBones.UserData]"; + }; + e.prototype._onClear = function() { + this.ints.length = 0; + this.floats.length = 0; + this.strings.length = 0; + }; + e.prototype.addInt = function(t) { + this.ints.push(t); + }; + e.prototype.addFloat = function(t) { + this.floats.push(t); + }; + e.prototype.addString = function(t) { + this.strings.push(t); + }; + e.prototype.getInt = function(t) { + void 0 === t && (t = 0); + return t >= 0 && t < this.ints.length ? this.ints[t] : 0; + }; + e.prototype.getFloat = function(t) { + void 0 === t && (t = 0); + return t >= 0 && t < this.floats.length ? this.floats[t] : 0; + }; + e.prototype.getString = function(t) { + void 0 === t && (t = 0); + return t >= 0 && t < this.strings.length ? this.strings[t] : ""; + }; + return e; + }(t.BaseObject); + t.UserData = e; + var i = function(t) { + r5(e, t); + function e() { + var e = null !== t && t.apply(this, arguments) || this; + e.data = null; + return e; + } + e.toString = function() { + return "[class dragonBones.ActionData]"; + }; + e.prototype._onClear = function() { + null !== this.data && this.data.returnToPool(); + this.type = 0; + this.name = ""; + this.bone = null; + this.slot = null; + this.data = null; + }; + return e; + }(t.BaseObject); + t.ActionData = i; + }(a5 || (a5 = {})); + !function(t) { + var e = function(t) { + r5(e, t); + function e() { + var e = null !== t && t.apply(this, arguments) || this; + e.frameIndices = []; + e.cachedFrames = []; + e.armatureNames = []; + e.armatures = {}; + e.userData = null; + return e; + } + e.toString = function() { + return "[class dragonBones.DragonBonesData]"; + }; + e.prototype._onClear = function() { + for (var t in this.armatures) { + this.armatures[t].returnToPool(); + delete this.armatures[t]; + } + null !== this.userData && this.userData.returnToPool(); + this.autoSearch = !1; + this.frameRate = 0; + this.version = ""; + this.name = ""; + this.stage = null; + this.frameIndices.length = 0; + this.cachedFrames.length = 0; + this.armatureNames.length = 0; + this.binary = null; + this.intArray = null; + this.floatArray = null; + this.frameIntArray = null; + this.frameFloatArray = null; + this.frameArray = null; + this.timelineArray = null; + this.userData = null; + }; + e.prototype.addArmature = function(t) { + if (t.name in this.armatures) console.warn("Same armature: " + t.name); else { + t.parent = this; + this.armatures[t.name] = t; + this.armatureNames.push(t.name); + } + }; + e.prototype.getArmature = function(t) { + return t in this.armatures ? this.armatures[t] : null; + }; + e.prototype.dispose = function() { + console.warn("已废弃"); + this.returnToPool(); + }; + return e; + }(t.BaseObject); + t.DragonBonesData = e; + }(a5 || (a5 = {})); + !function(t) { + var e = function(e) { + r5(i, e); + function i() { + var i = null !== e && e.apply(this, arguments) || this; + i.aabb = new t.Rectangle; + i.animationNames = []; + i.sortedBones = []; + i.sortedSlots = []; + i.defaultActions = []; + i.actions = []; + i.bones = {}; + i.slots = {}; + i.constraints = {}; + i.skins = {}; + i.animations = {}; + i.canvas = null; + i.userData = null; + return i; + } + i.toString = function() { + return "[class dragonBones.ArmatureData]"; + }; + i.prototype._onClear = function() { + for (var t = 0, e = this.defaultActions; t < e.length; t++) { + e[t].returnToPool(); + } + for (var i = 0, s = this.actions; i < s.length; i++) { + s[i].returnToPool(); + } + for (var n in this.bones) { + this.bones[n].returnToPool(); + delete this.bones[n]; + } + for (var n in this.slots) { + this.slots[n].returnToPool(); + delete this.slots[n]; + } + for (var n in this.constraints) { + this.constraints[n].returnToPool(); + delete this.constraints[n]; + } + for (var n in this.skins) { + this.skins[n].returnToPool(); + delete this.skins[n]; + } + for (var n in this.animations) { + this.animations[n].returnToPool(); + delete this.animations[n]; + } + null !== this.canvas && this.canvas.returnToPool(); + null !== this.userData && this.userData.returnToPool(); + this.type = 0; + this.frameRate = 0; + this.cacheFrameRate = 0; + this.scale = 1; + this.name = ""; + this.aabb.clear(); + this.animationNames.length = 0; + this.sortedBones.length = 0; + this.sortedSlots.length = 0; + this.defaultActions.length = 0; + this.actions.length = 0; + this.defaultSkin = null; + this.defaultAnimation = null; + this.canvas = null; + this.userData = null; + this.parent = null; + }; + i.prototype.sortBones = function() { + var t = this.sortedBones.length; + if (!(t <= 0)) { + var e = this.sortedBones.concat(); + var i = 0; + var s = 0; + this.sortedBones.length = 0; + for (;s < t; ) { + var n = e[i++]; + i >= t && (i = 0); + if (!(this.sortedBones.indexOf(n) >= 0)) { + var r = !1; + for (var o in this.constraints) { + var a = this.constraints[o]; + if (a.root === n && this.sortedBones.indexOf(a.target) < 0) { + r = !0; + break; + } + } + if (!(r || null !== n.parent && this.sortedBones.indexOf(n.parent) < 0)) { + this.sortedBones.push(n); + s++; + } + } + } + } + }; + i.prototype.cacheFrames = function(t) { + if (!(this.cacheFrameRate > 0)) { + this.cacheFrameRate = t; + for (var e in this.animations) this.animations[e].cacheFrames(this.cacheFrameRate); + } + }; + i.prototype.setCacheFrame = function(t, e) { + var i = this.parent.cachedFrames; + var s = i.length; + i.length += 10; + i[s] = t.a; + i[s + 1] = t.b; + i[s + 2] = t.c; + i[s + 3] = t.d; + i[s + 4] = t.tx; + i[s + 5] = t.ty; + i[s + 6] = e.rotation; + i[s + 7] = e.skew; + i[s + 8] = e.scaleX; + i[s + 9] = e.scaleY; + return s; + }; + i.prototype.getCacheFrame = function(t, e, i) { + var s = this.parent.cachedFrames; + t.a = s[i]; + t.b = s[i + 1]; + t.c = s[i + 2]; + t.d = s[i + 3]; + t.tx = s[i + 4]; + t.ty = s[i + 5]; + e.rotation = s[i + 6]; + e.skew = s[i + 7]; + e.scaleX = s[i + 8]; + e.scaleY = s[i + 9]; + e.x = t.tx; + e.y = t.ty; + }; + i.prototype.addBone = function(t) { + if (t.name in this.bones) console.warn("Same bone: " + t.name); else { + this.bones[t.name] = t; + this.sortedBones.push(t); + } + }; + i.prototype.addSlot = function(t) { + if (t.name in this.slots) console.warn("Same slot: " + t.name); else { + this.slots[t.name] = t; + this.sortedSlots.push(t); + } + }; + i.prototype.addConstraint = function(t) { + t.name in this.constraints ? console.warn("Same constraint: " + t.name) : this.constraints[t.name] = t; + }; + i.prototype.addSkin = function(t) { + if (t.name in this.skins) console.warn("Same skin: " + t.name); else { + t.parent = this; + this.skins[t.name] = t; + null === this.defaultSkin && (this.defaultSkin = t); + "default" === t.name && (this.defaultSkin = t); + } + }; + i.prototype.addAnimation = function(t) { + if (t.name in this.animations) console.warn("Same animation: " + t.name); else { + t.parent = this; + this.animations[t.name] = t; + this.animationNames.push(t.name); + null === this.defaultAnimation && (this.defaultAnimation = t); + } + }; + i.prototype.addAction = function(t, e) { + e ? this.defaultActions.push(t) : this.actions.push(t); + }; + i.prototype.getBone = function(t) { + return t in this.bones ? this.bones[t] : null; + }; + i.prototype.getSlot = function(t) { + return t in this.slots ? this.slots[t] : null; + }; + i.prototype.getConstraint = function(t) { + return t in this.constraints ? this.constraints[t] : null; + }; + i.prototype.getSkin = function(t) { + return t in this.skins ? this.skins[t] : null; + }; + i.prototype.getMesh = function(t, e, i) { + var s = this.getSkin(t); + return null === s ? null : s.getDisplay(e, i); + }; + i.prototype.getAnimation = function(t) { + return t in this.animations ? this.animations[t] : null; + }; + return i; + }(t.BaseObject); + t.ArmatureData = e; + var i = function(e) { + r5(i, e); + function i() { + var i = null !== e && e.apply(this, arguments) || this; + i.transform = new t.Transform; + i.userData = null; + return i; + } + i.toString = function() { + return "[class dragonBones.BoneData]"; + }; + i.prototype._onClear = function() { + null !== this.userData && this.userData.returnToPool(); + this.inheritTranslation = !1; + this.inheritRotation = !1; + this.inheritScale = !1; + this.inheritReflection = !1; + this.type = 0; + this.length = 0; + this.name = ""; + this.transform.identity(); + this.userData = null; + this.parent = null; + }; + return i; + }(t.BaseObject); + t.BoneData = i; + var s = function(t) { + r5(e, t); + function e() { + var e = null !== t && t.apply(this, arguments) || this; + e.vertices = []; + return e; + } + e.toString = function() { + return "[class dragonBones.SurfaceData]"; + }; + e.prototype._onClear = function() { + t.prototype._onClear.call(this); + this.type = 1; + this.segmentX = 0; + this.segmentY = 0; + this.vertices.length = 0; + }; + return e; + }(i); + t.SurfaceData = s; + var n = function(e) { + r5(i, e); + function i() { + var t = null !== e && e.apply(this, arguments) || this; + t.color = null; + t.userData = null; + return t; + } + i.createColor = function() { + return new t.ColorTransform; + }; + i.toString = function() { + return "[class dragonBones.SlotData]"; + }; + i.prototype._onClear = function() { + null !== this.userData && this.userData.returnToPool(); + this.blendMode = 0; + this.displayIndex = 0; + this.zOrder = 0; + this.name = ""; + this.color = null; + this.userData = null; + this.parent = null; + }; + i.DEFAULT_COLOR = new t.ColorTransform; + return i; + }(t.BaseObject); + t.SlotData = n; + }(a5 || (a5 = {})); + !function(t) { + var e = function(t) { + r5(e, t); + function e() { + return null !== t && t.apply(this, arguments) || this; + } + e.prototype._onClear = function() { + this.order = 0; + this.name = ""; + this.type = 0; + this.target = null; + this.root = null; + this.bone = null; + }; + return e; + }(t.BaseObject); + t.ConstraintData = e; + var i = function(t) { + r5(e, t); + function e() { + return null !== t && t.apply(this, arguments) || this; + } + e.toString = function() { + return "[class dragonBones.IKConstraintData]"; + }; + e.prototype._onClear = function() { + t.prototype._onClear.call(this); + this.scaleEnabled = !1; + this.bendPositive = !1; + this.weight = 1; + }; + return e; + }(e); + t.IKConstraintData = i; + var s = function(t) { + r5(e, t); + function e() { + var e = null !== t && t.apply(this, arguments) || this; + e.bones = []; + return e; + } + e.toString = function() { + return "[class dragonBones.PathConstraintData]"; + }; + e.prototype._onClear = function() { + t.prototype._onClear.call(this); + this.pathSlot = null; + this.pathDisplayData = null; + this.bones.length = 0; + this.positionMode = 0; + this.spacingMode = 1; + this.rotateMode = 1; + this.position = 0; + this.spacing = 0; + this.rotateOffset = 0; + this.rotateMix = 0; + this.translateMix = 0; + }; + e.prototype.AddBone = function(t) { + this.bones.push(t); + }; + return e; + }(e); + t.PathConstraintData = s; + }(a5 || (a5 = {})); + !function(t) { + var e = function(t) { + r5(e, t); + function e() { + return null !== t && t.apply(this, arguments) || this; + } + e.toString = function() { + return "[class dragonBones.CanvasData]"; + }; + e.prototype._onClear = function() { + this.hasBackground = !1; + this.color = 0; + this.x = 0; + this.y = 0; + this.width = 0; + this.height = 0; + }; + return e; + }(t.BaseObject); + t.CanvasData = e; + }(a5 || (a5 = {})); + !function(t) { + var e = function(t) { + r5(e, t); + function e() { + var e = null !== t && t.apply(this, arguments) || this; + e.displays = {}; + return e; + } + e.toString = function() { + return "[class dragonBones.SkinData]"; + }; + e.prototype._onClear = function() { + for (var t in this.displays) { + for (var e = 0, i = this.displays[t]; e < i.length; e++) { + var s = i[e]; + null !== s && s.returnToPool(); + } + delete this.displays[t]; + } + this.name = ""; + this.parent = null; + }; + e.prototype.addDisplay = function(t, e) { + t in this.displays || (this.displays[t] = []); + null !== e && (e.parent = this); + this.displays[t].push(e); + }; + e.prototype.getDisplay = function(t, e) { + var i = this.getDisplays(t); + if (null !== i) for (var s = 0, n = i; s < n.length; s++) { + var r = n[s]; + if (null !== r && r.name === e) return r; + } + return null; + }; + e.prototype.getDisplays = function(t) { + return t in this.displays ? this.displays[t] : null; + }; + return e; + }(t.BaseObject); + t.SkinData = e; + }(a5 || (a5 = {})); + !function(t) { + var e = function() { + function t() { + this.weight = null; + } + t.prototype.clear = function() { + this.isShared || null === this.weight || this.weight.returnToPool(); + this.isShared = !1; + this.inheritDeform = !1; + this.offset = 0; + this.data = null; + this.weight = null; + }; + t.prototype.shareFrom = function(t) { + this.isShared = !0; + this.offset = t.offset; + this.weight = t.weight; + }; + return t; + }(); + t.VerticesData = e; + var i = function(e) { + r5(i, e); + function i() { + var i = null !== e && e.apply(this, arguments) || this; + i.transform = new t.Transform; + return i; + } + i.prototype._onClear = function() { + this.name = ""; + this.path = ""; + this.transform.identity(); + this.parent = null; + }; + return i; + }(t.BaseObject); + t.DisplayData = i; + var s = function(e) { + r5(i, e); + function i() { + var i = null !== e && e.apply(this, arguments) || this; + i.pivot = new t.Point; + return i; + } + i.toString = function() { + return "[class dragonBones.ImageDisplayData]"; + }; + i.prototype._onClear = function() { + e.prototype._onClear.call(this); + this.type = 0; + this.pivot.clear(); + this.texture = null; + }; + return i; + }(i); + t.ImageDisplayData = s; + var n = function(t) { + r5(e, t); + function e() { + var e = null !== t && t.apply(this, arguments) || this; + e.actions = []; + return e; + } + e.toString = function() { + return "[class dragonBones.ArmatureDisplayData]"; + }; + e.prototype._onClear = function() { + t.prototype._onClear.call(this); + for (var e = 0, i = this.actions; e < i.length; e++) { + i[e].returnToPool(); + } + this.type = 1; + this.inheritAnimation = !1; + this.actions.length = 0; + this.armature = null; + }; + e.prototype.addAction = function(t) { + this.actions.push(t); + }; + return e; + }(i); + t.ArmatureDisplayData = n; + var r = function(t) { + r5(i, t); + function i() { + var i = null !== t && t.apply(this, arguments) || this; + i.vertices = new e; + return i; + } + i.toString = function() { + return "[class dragonBones.MeshDisplayData]"; + }; + i.prototype._onClear = function() { + t.prototype._onClear.call(this); + this.type = 2; + this.vertices.clear(); + this.texture = null; + }; + return i; + }(i); + t.MeshDisplayData = r; + var o = function(t) { + r5(e, t); + function e() { + var e = null !== t && t.apply(this, arguments) || this; + e.boundingBox = null; + return e; + } + e.toString = function() { + return "[class dragonBones.BoundingBoxDisplayData]"; + }; + e.prototype._onClear = function() { + t.prototype._onClear.call(this); + null !== this.boundingBox && this.boundingBox.returnToPool(); + this.type = 3; + this.boundingBox = null; + }; + return e; + }(i); + t.BoundingBoxDisplayData = o; + var a = function(t) { + r5(i, t); + function i() { + var i = null !== t && t.apply(this, arguments) || this; + i.vertices = new e; + i.curveLengths = []; + return i; + } + i.toString = function() { + return "[class dragonBones.PathDisplayData]"; + }; + i.prototype._onClear = function() { + t.prototype._onClear.call(this); + this.type = 4; + this.closed = !1; + this.constantSpeed = !1; + this.vertices.clear(); + this.curveLengths.length = 0; + }; + return i; + }(i); + t.PathDisplayData = a; + var l = function(t) { + r5(e, t); + function e() { + var e = null !== t && t.apply(this, arguments) || this; + e.bones = []; + return e; + } + e.toString = function() { + return "[class dragonBones.WeightData]"; + }; + e.prototype._onClear = function() { + this.count = 0; + this.offset = 0; + this.bones.length = 0; + }; + e.prototype.addBone = function(t) { + this.bones.push(t); + }; + return e; + }(t.BaseObject); + t.WeightData = l; + }(a5 || (a5 = {})); + !function(t) { + var e = function(t) { + r5(e, t); + function e() { + return null !== t && t.apply(this, arguments) || this; + } + e.prototype._onClear = function() { + this.color = 0; + this.width = 0; + this.height = 0; + }; + return e; + }(t.BaseObject); + t.BoundingBoxData = e; + var i = function(t) { + r5(e, t); + function e() { + return null !== t && t.apply(this, arguments) || this; + } + e.toString = function() { + return "[class dragonBones.RectangleBoundingBoxData]"; + }; + e._computeOutCode = function(t, e, i, s, n, r) { + var o = 0; + t < i ? o |= 1 : t > n && (o |= 2); + e < s ? o |= 4 : e > r && (o |= 8); + return o; + }; + e.rectangleIntersectsSegment = function(t, i, s, n, r, o, a, l, h, c, u) { + void 0 === h && (h = null); + void 0 === c && (c = null); + void 0 === u && (u = null); + var _ = t > r && t < a && i > o && i < l; + var d = s > r && s < a && n > o && n < l; + if (_ && d) return -1; + var p = 0; + var m = e._computeOutCode(t, i, r, o, a, l); + var f = e._computeOutCode(s, n, r, o, a, l); + for (;;) { + if (0 == (m | f)) { + p = 2; + break; + } + if (0 != (m & f)) break; + var g = 0; + var y = 0; + var b = 0; + var S = 0 !== m ? m : f; + if (0 != (4 & S)) { + g = t + (s - t) * (o - i) / (n - i); + y = o; + null !== u && (b = .5 * -Math.PI); + } else if (0 != (8 & S)) { + g = t + (s - t) * (l - i) / (n - i); + y = l; + null !== u && (b = .5 * Math.PI); + } else if (0 != (2 & S)) { + y = i + (n - i) * (a - t) / (s - t); + g = a; + null !== u && (b = 0); + } else if (0 != (1 & S)) { + y = i + (n - i) * (r - t) / (s - t); + g = r; + null !== u && (b = Math.PI); + } + if (S === m) { + t = g; + i = y; + m = e._computeOutCode(t, i, r, o, a, l); + null !== u && (u.x = b); + } else { + s = g; + n = y; + f = e._computeOutCode(s, n, r, o, a, l); + null !== u && (u.y = b); + } + } + if (p) if (_) { + p = 2; + if (null !== h) { + h.x = s; + h.y = n; + } + if (null !== c) { + c.x = s; + c.y = s; + } + null !== u && (u.x = u.y + Math.PI); + } else if (d) { + p = 1; + if (null !== h) { + h.x = t; + h.y = i; + } + if (null !== c) { + c.x = t; + c.y = i; + } + null !== u && (u.y = u.x + Math.PI); + } else { + p = 3; + if (null !== h) { + h.x = t; + h.y = i; + } + if (null !== c) { + c.x = s; + c.y = n; + } + } + return p; + }; + e.prototype._onClear = function() { + t.prototype._onClear.call(this); + this.type = 0; + }; + e.prototype.containsPoint = function(t, e) { + var i = .5 * this.width; + if (t >= -i && t <= i) { + var s = .5 * this.height; + if (e >= -s && e <= s) return !0; + } + return !1; + }; + e.prototype.intersectsSegment = function(t, i, s, n, r, o, a) { + void 0 === r && (r = null); + void 0 === o && (o = null); + void 0 === a && (a = null); + var l = .5 * this.width; + var h = .5 * this.height; + return e.rectangleIntersectsSegment(t, i, s, n, -l, -h, l, h, r, o, a); + }; + return e; + }(e); + t.RectangleBoundingBoxData = i; + var s = function(t) { + r5(e, t); + function e() { + return null !== t && t.apply(this, arguments) || this; + } + e.toString = function() { + return "[class dragonBones.EllipseData]"; + }; + e.ellipseIntersectsSegment = function(t, e, i, s, n, r, o, a, l, h, c) { + void 0 === l && (l = null); + void 0 === h && (h = null); + void 0 === c && (c = null); + var u = o / a; + var _ = u * u; + var d = i - t; + var p = (s *= u) - (e *= u); + var m = Math.sqrt(d * d + p * p); + var f = d / m; + var g = p / m; + var y = (n - t) * f + (r - e) * g; + var b = o * o; + var S = b - (t * t + e * e) + y * y; + var A = 0; + if (S >= 0) { + var T = Math.sqrt(S); + var v = y - T; + var E = y + T; + var C = v < 0 ? -1 : v <= m ? 0 : 1; + var x = E < 0 ? -1 : E <= m ? 0 : 1; + var w = C * x; + if (w < 0) return -1; + if (0 === w) if (-1 === C) { + A = 2; + i = t + E * f; + s = (e + E * g) / u; + if (null !== l) { + l.x = i; + l.y = s; + } + if (null !== h) { + h.x = i; + h.y = s; + } + if (null !== c) { + c.x = Math.atan2(s / b * _, i / b); + c.y = c.x + Math.PI; + } + } else if (1 === x) { + A = 1; + t += v * f; + e = (e + v * g) / u; + if (null !== l) { + l.x = t; + l.y = e; + } + if (null !== h) { + h.x = t; + h.y = e; + } + if (null !== c) { + c.x = Math.atan2(e / b * _, t / b); + c.y = c.x + Math.PI; + } + } else { + A = 3; + if (null !== l) { + l.x = t + v * f; + l.y = (e + v * g) / u; + null !== c && (c.x = Math.atan2(l.y / b * _, l.x / b)); + } + if (null !== h) { + h.x = t + E * f; + h.y = (e + E * g) / u; + null !== c && (c.y = Math.atan2(h.y / b * _, h.x / b)); + } + } + } + return A; + }; + e.prototype._onClear = function() { + t.prototype._onClear.call(this); + this.type = 1; + }; + e.prototype.containsPoint = function(t, e) { + var i = .5 * this.width; + if (t >= -i && t <= i) { + var s = .5 * this.height; + if (e >= -s && e <= s) { + e *= i / s; + return Math.sqrt(t * t + e * e) <= i; + } + } + return !1; + }; + e.prototype.intersectsSegment = function(t, i, s, n, r, o, a) { + void 0 === r && (r = null); + void 0 === o && (o = null); + void 0 === a && (a = null); + return e.ellipseIntersectsSegment(t, i, s, n, 0, 0, .5 * this.width, .5 * this.height, r, o, a); + }; + return e; + }(e); + t.EllipseBoundingBoxData = s; + var n = function(t) { + r5(e, t); + function e() { + var e = null !== t && t.apply(this, arguments) || this; + e.vertices = []; + return e; + } + e.toString = function() { + return "[class dragonBones.PolygonBoundingBoxData]"; + }; + e.polygonIntersectsSegment = function(t, e, i, s, n, r, o, a) { + void 0 === r && (r = null); + void 0 === o && (o = null); + void 0 === a && (a = null); + t === i && (t = i + 1e-6); + e === s && (e = s + 1e-6); + var l = n.length; + var h = t - i; + var c = e - s; + var u = t * s - e * i; + var _ = 0; + var d = n[l - 2]; + var p = n[l - 1]; + var m = 0; + var f = 0; + var g = 0; + var y = 0; + var b = 0; + var S = 0; + for (var A = 0; A < l; A += 2) { + var T = n[A]; + var v = n[A + 1]; + d === T && (d = T + 1e-4); + p === v && (p = v + 1e-4); + var E = d - T; + var C = p - v; + var x = d * v - p * T; + var w = h * C - c * E; + var R = (u * E - h * x) / w; + if ((R >= d && R <= T || R >= T && R <= d) && (0 === h || R >= t && R <= i || R >= i && R <= t)) { + var I = (u * C - c * x) / w; + if ((I >= p && I <= v || I >= v && I <= p) && (0 === c || I >= e && I <= s || I >= s && I <= e)) { + if (null === o) { + g = R; + y = I; + b = R; + S = I; + _++; + if (null !== a) { + a.x = Math.atan2(v - p, T - d) - .5 * Math.PI; + a.y = a.x; + } + break; + } + var M = R - t; + M < 0 && (M = -M); + if (0 === _) { + m = M; + f = M; + g = R; + y = I; + b = R; + S = I; + if (null !== a) { + a.x = Math.atan2(v - p, T - d) - .5 * Math.PI; + a.y = a.x; + } + } else { + if (M < m) { + m = M; + g = R; + y = I; + null !== a && (a.x = Math.atan2(v - p, T - d) - .5 * Math.PI); + } + if (M > f) { + f = M; + b = R; + S = I; + null !== a && (a.y = Math.atan2(v - p, T - d) - .5 * Math.PI); + } + } + _++; + } + } + d = T; + p = v; + } + if (1 === _) { + if (null !== r) { + r.x = g; + r.y = y; + } + if (null !== o) { + o.x = g; + o.y = y; + } + null !== a && (a.y = a.x + Math.PI); + } else if (_ > 1) { + _++; + if (null !== r) { + r.x = g; + r.y = y; + } + if (null !== o) { + o.x = b; + o.y = S; + } + } + return _; + }; + e.prototype._onClear = function() { + t.prototype._onClear.call(this); + this.type = 2; + this.x = 0; + this.y = 0; + this.vertices.length = 0; + }; + e.prototype.containsPoint = function(t, e) { + var i = !1; + if (t >= this.x && t <= this.width && e >= this.y && e <= this.height) for (var s = 0, n = this.vertices.length, r = n - 2; s < n; s += 2) { + var o = this.vertices[r + 1]; + var a = this.vertices[s + 1]; + if (a < e && o >= e || o < e && a >= e) { + var l = this.vertices[r]; + var h = this.vertices[s]; + (e - a) * (l - h) / (o - a) + h < t && (i = !i); + } + r = s; + } + return i; + }; + e.prototype.intersectsSegment = function(t, s, n, r, o, a, l) { + void 0 === o && (o = null); + void 0 === a && (a = null); + void 0 === l && (l = null); + var h = 0; + 0 !== i.rectangleIntersectsSegment(t, s, n, r, this.x, this.y, this.x + this.width, this.y + this.height, null, null, null) && (h = e.polygonIntersectsSegment(t, s, n, r, this.vertices, o, a, l)); + return h; + }; + return e; + }(e); + t.PolygonBoundingBoxData = n; + }(a5 || (a5 = {})); + !function(t) { + var e = function(t) { + r5(e, t); + function e() { + var e = null !== t && t.apply(this, arguments) || this; + e.cachedFrames = []; + e.boneTimelines = {}; + e.surfaceTimelines = {}; + e.slotTimelines = {}; + e.constraintTimelines = {}; + e.animationTimelines = {}; + e.boneCachedFrameIndices = {}; + e.slotCachedFrameIndices = {}; + e.actionTimeline = null; + e.zOrderTimeline = null; + return e; + } + e.toString = function() { + return "[class dragonBones.AnimationData]"; + }; + e.prototype._onClear = function() { + for (var t in this.boneTimelines) { + for (var e = 0, i = this.boneTimelines[t]; e < i.length; e++) { + i[e].returnToPool(); + } + delete this.boneTimelines[t]; + } + for (var t in this.surfaceTimelines) { + for (var s = 0, n = this.surfaceTimelines[t]; s < n.length; s++) { + n[s].returnToPool(); + } + delete this.surfaceTimelines[t]; + } + for (var t in this.slotTimelines) { + for (var r = 0, o = this.slotTimelines[t]; r < o.length; r++) { + o[r].returnToPool(); + } + delete this.slotTimelines[t]; + } + for (var t in this.constraintTimelines) { + for (var a = 0, l = this.constraintTimelines[t]; a < l.length; a++) { + l[a].returnToPool(); + } + delete this.constraintTimelines[t]; + } + for (var t in this.animationTimelines) { + for (var h = 0, c = this.animationTimelines[t]; h < c.length; h++) { + c[h].returnToPool(); + } + delete this.animationTimelines[t]; + } + for (var t in this.boneCachedFrameIndices) delete this.boneCachedFrameIndices[t]; + for (var t in this.slotCachedFrameIndices) delete this.slotCachedFrameIndices[t]; + null !== this.actionTimeline && this.actionTimeline.returnToPool(); + null !== this.zOrderTimeline && this.zOrderTimeline.returnToPool(); + this.frameIntOffset = 0; + this.frameFloatOffset = 0; + this.frameOffset = 0; + this.frameCount = 0; + this.playTimes = 0; + this.duration = 0; + this.scale = 1; + this.fadeInTime = 0; + this.cacheFrameRate = 0; + this.name = ""; + this.cachedFrames.length = 0; + this.actionTimeline = null; + this.zOrderTimeline = null; + this.parent = null; + }; + e.prototype.cacheFrames = function(t) { + if (!(this.cacheFrameRate > 0)) { + this.cacheFrameRate = Math.max(Math.ceil(t * this.scale), 1); + var e = Math.ceil(this.cacheFrameRate * this.duration) + 1; + this.cachedFrames.length = e; + for (var i = 0, s = this.cacheFrames.length; i < s; ++i) this.cachedFrames[i] = !1; + for (var n = 0, r = this.parent.sortedBones; n < r.length; n++) { + var o = r[n]; + for (i = 0, s = (c = new Array(e)).length; i < s; ++i) c[i] = -1; + this.boneCachedFrameIndices[o.name] = c; + } + for (var a = 0, l = this.parent.sortedSlots; a < l.length; a++) { + var h = l[a]; + var c; + for (i = 0, s = (c = new Array(e)).length; i < s; ++i) c[i] = -1; + this.slotCachedFrameIndices[h.name] = c; + } + } + }; + e.prototype.addBoneTimeline = function(t, e) { + var i = t.name in this.boneTimelines ? this.boneTimelines[t.name] : this.boneTimelines[t.name] = []; + i.indexOf(e) < 0 && i.push(e); + }; + e.prototype.addSurfaceTimeline = function(t, e) { + var i = t.name in this.surfaceTimelines ? this.surfaceTimelines[t.name] : this.surfaceTimelines[t.name] = []; + i.indexOf(e) < 0 && i.push(e); + }; + e.prototype.addSlotTimeline = function(t, e) { + var i = t.name in this.slotTimelines ? this.slotTimelines[t.name] : this.slotTimelines[t.name] = []; + i.indexOf(e) < 0 && i.push(e); + }; + e.prototype.addConstraintTimeline = function(t, e) { + var i = t.name in this.constraintTimelines ? this.constraintTimelines[t.name] : this.constraintTimelines[t.name] = []; + i.indexOf(e) < 0 && i.push(e); + }; + e.prototype.addAnimationTimeline = function(t, e) { + var i = t in this.animationTimelines ? this.animationTimelines[t] : this.animationTimelines[t] = []; + i.indexOf(e) < 0 && i.push(e); + }; + e.prototype.getBoneTimelines = function(t) { + return t in this.boneTimelines ? this.boneTimelines[t] : null; + }; + e.prototype.getSurfaceTimelines = function(t) { + return t in this.surfaceTimelines ? this.surfaceTimelines[t] : null; + }; + e.prototype.getSlotTimelines = function(t) { + return t in this.slotTimelines ? this.slotTimelines[t] : null; + }; + e.prototype.getConstraintTimelines = function(t) { + return t in this.constraintTimelines ? this.constraintTimelines[t] : null; + }; + e.prototype.getAnimationTimelines = function(t) { + return t in this.animationTimelines ? this.animationTimelines[t] : null; + }; + e.prototype.getBoneCachedFrameIndices = function(t) { + return t in this.boneCachedFrameIndices ? this.boneCachedFrameIndices[t] : null; + }; + e.prototype.getSlotCachedFrameIndices = function(t) { + return t in this.slotCachedFrameIndices ? this.slotCachedFrameIndices[t] : null; + }; + return e; + }(t.BaseObject); + t.AnimationData = e; + var i = function(t) { + r5(e, t); + function e() { + return null !== t && t.apply(this, arguments) || this; + } + e.toString = function() { + return "[class dragonBones.TimelineData]"; + }; + e.prototype._onClear = function() { + this.type = 10; + this.offset = 0; + this.frameIndicesOffset = -1; + }; + return e; + }(t.BaseObject); + t.TimelineData = i; + }(a5 || (a5 = {})); + !function(t) { + var e = function(t) { + r5(e, t); + function e() { + var e = null !== t && t.apply(this, arguments) || this; + e.boneMask = []; + return e; + } + e.toString = function() { + return "[class dragonBones.AnimationConfig]"; + }; + e.prototype._onClear = function() { + this.pauseFadeOut = !0; + this.fadeOutMode = 4; + this.fadeOutTweenType = 1; + this.fadeOutTime = -1; + this.actionEnabled = !0; + this.additiveBlending = !1; + this.displayControl = !0; + this.pauseFadeIn = !0; + this.resetToPose = !0; + this.fadeInTweenType = 1; + this.playTimes = -1; + this.layer = 0; + this.position = 0; + this.duration = -1; + this.timeScale = -100; + this.weight = 1; + this.fadeInTime = -1; + this.autoFadeOutTime = -1; + this.name = ""; + this.animation = ""; + this.group = ""; + this.boneMask.length = 0; + }; + e.prototype.clear = function() { + this._onClear(); + }; + e.prototype.copyFrom = function(t) { + this.pauseFadeOut = t.pauseFadeOut; + this.fadeOutMode = t.fadeOutMode; + this.autoFadeOutTime = t.autoFadeOutTime; + this.fadeOutTweenType = t.fadeOutTweenType; + this.actionEnabled = t.actionEnabled; + this.additiveBlending = t.additiveBlending; + this.displayControl = t.displayControl; + this.pauseFadeIn = t.pauseFadeIn; + this.resetToPose = t.resetToPose; + this.playTimes = t.playTimes; + this.layer = t.layer; + this.position = t.position; + this.duration = t.duration; + this.timeScale = t.timeScale; + this.fadeInTime = t.fadeInTime; + this.fadeOutTime = t.fadeOutTime; + this.fadeInTweenType = t.fadeInTweenType; + this.weight = t.weight; + this.name = t.name; + this.animation = t.animation; + this.group = t.group; + this.boneMask.length = t.boneMask.length; + for (var e = 0, i = this.boneMask.length; e < i; ++e) this.boneMask[e] = t.boneMask[e]; + }; + e.prototype.containsBoneMask = function(t) { + return 0 === this.boneMask.length || this.boneMask.indexOf(t) >= 0; + }; + e.prototype.addBoneMask = function(t, e, i) { + void 0 === i && (i = !0); + var s = t.getBone(e); + if (null !== s) { + this.boneMask.indexOf(e) < 0 && this.boneMask.push(e); + if (i) for (var n = 0, r = t.getBones(); n < r.length; n++) { + var o = r[n]; + this.boneMask.indexOf(o.name) < 0 && s.contains(o) && this.boneMask.push(o.name); + } + } + }; + e.prototype.removeBoneMask = function(t, e, i) { + void 0 === i && (i = !0); + var s = this.boneMask.indexOf(e); + s >= 0 && this.boneMask.splice(s, 1); + if (i) { + var n = t.getBone(e); + if (null !== n) if (this.boneMask.length > 0) for (var r = 0, o = t.getBones(); r < o.length; r++) { + var a = o[r]; + var l = this.boneMask.indexOf(a.name); + l >= 0 && n.contains(a) && this.boneMask.splice(l, 1); + } else for (var h = 0, c = t.getBones(); h < c.length; h++) { + (a = c[h]) !== n && (n.contains(a) || this.boneMask.push(a.name)); + } + } + }; + return e; + }(t.BaseObject); + t.AnimationConfig = e; + }(a5 || (a5 = {})); + !function(t) { + var e = function(t) { + r5(e, t); + function e() { + var e = null !== t && t.apply(this, arguments) || this; + e.textures = {}; + return e; + } + e.prototype._onClear = function() { + for (var t in this.textures) { + this.textures[t].returnToPool(); + delete this.textures[t]; + } + this.autoSearch = !1; + this.width = 0; + this.height = 0; + this.scale = 1; + this.name = ""; + this.imagePath = ""; + }; + e.prototype.copyFrom = function(t) { + this.autoSearch = t.autoSearch; + this.scale = t.scale; + this.width = t.width; + this.height = t.height; + this.name = t.name; + this.imagePath = t.imagePath; + for (var e in this.textures) { + this.textures[e].returnToPool(); + delete this.textures[e]; + } + for (var e in t.textures) { + var i = this.createTexture(); + i.copyFrom(t.textures[e]); + this.textures[e] = i; + } + }; + e.prototype.addTexture = function(t) { + if (t.name in this.textures) console.warn("Same texture: " + t.name); else { + t.parent = this; + this.textures[t.name] = t; + } + }; + e.prototype.getTexture = function(t) { + return t in this.textures ? this.textures[t] : null; + }; + return e; + }(t.BaseObject); + t.TextureAtlasData = e; + var i = function(e) { + r5(i, e); + function i() { + var i = null !== e && e.apply(this, arguments) || this; + i.region = new t.Rectangle; + i.frame = null; + return i; + } + i.createRectangle = function() { + return new t.Rectangle; + }; + i.prototype._onClear = function() { + this.rotated = !1; + this.name = ""; + this.region.clear(); + this.parent = null; + this.frame = null; + }; + i.prototype.copyFrom = function(t) { + this.rotated = t.rotated; + this.name = t.name; + this.region.copyFrom(t.region); + this.parent = t.parent; + null === this.frame && null !== t.frame ? this.frame = i.createRectangle() : null !== this.frame && null === t.frame && (this.frame = null); + null !== this.frame && null !== t.frame && this.frame.copyFrom(t.frame); + }; + return i; + }(t.BaseObject); + t.TextureData = i; + }(a5 || (a5 = {})); + !function(t) { + var e = function(t) { + r5(e, t); + function e() { + var e = null !== t && t.apply(this, arguments) || this; + e.vertices = []; + e.bones = []; + return e; + } + e.toString = function() { + return "[class dragonBones.DeformVertices]"; + }; + e.prototype._onClear = function() { + this.verticesDirty = !1; + this.vertices.length = 0; + this.bones.length = 0; + this.verticesData = null; + }; + e.prototype.init = function(t, e) { + this.verticesData = t; + if (null !== this.verticesData) { + var i = 0; + i = null !== this.verticesData.weight ? 2 * this.verticesData.weight.count : 2 * this.verticesData.data.intArray[this.verticesData.offset + 0]; + this.verticesDirty = !0; + this.vertices.length = i; + this.bones.length = 0; + for (var s = 0, n = this.vertices.length; s < n; ++s) this.vertices[s] = 0; + if (null !== this.verticesData.weight) for (s = 0, n = this.verticesData.weight.bones.length; s < n; ++s) { + var r = e.getBone(this.verticesData.weight.bones[s].name); + this.bones.push(r); + } + } else { + this.verticesDirty = !1; + this.vertices.length = 0; + this.bones.length = 0; + this.verticesData = null; + } + }; + e.prototype.isBonesUpdate = function() { + for (var t = 0, e = this.bones; t < e.length; t++) { + var i = e[t]; + if (null !== i && i._childrenTransformDirty) return !0; + } + return !1; + }; + return e; + }(t.BaseObject); + t.DeformVertices = e; + }(a5 || (a5 = {})); + !function(t) { + var e = function(e) { + r5(i, e); + function i() { + var t = null !== e && e.apply(this, arguments) || this; + t._bones = []; + t._slots = []; + t._constraints = []; + t._actions = []; + t._animation = null; + t._proxy = null; + t._replaceTextureAtlasData = null; + t._clock = null; + return t; + } + i.toString = function() { + return "[class dragonBones.Armature]"; + }; + i._onSortSlots = function(t, e) { + return t._zOrder > e._zOrder ? 1 : -1; + }; + i.prototype._onClear = function() { + null !== this._clock && this._clock.remove(this); + for (var t = 0, e = this._bones; t < e.length; t++) { + e[t].returnToPool(); + } + for (var i = 0, s = this._slots; i < s.length; i++) { + s[i].returnToPool(); + } + for (var n = 0, r = this._constraints; n < r.length; n++) { + r[n].returnToPool(); + } + for (var o = 0, a = this._actions; o < a.length; o++) { + a[o].returnToPool(); + } + null !== this._animation && this._animation.returnToPool(); + null !== this._proxy && this._proxy.dbClear(); + null !== this._replaceTextureAtlasData && this._replaceTextureAtlasData.returnToPool(); + this.inheritAnimation = !0; + this.userData = null; + this._lockUpdate = !1; + this._slotsDirty = !0; + this._zOrderDirty = !1; + this._flipX = !1; + this._flipY = !1; + this._cacheFrameIndex = -1; + this._bones.length = 0; + this._slots.length = 0; + this._constraints.length = 0; + this._actions.length = 0; + this._armatureData = null; + this._animation = null; + this._proxy = null; + this._display = null; + this._replaceTextureAtlasData = null; + this._replacedTexture = null; + this._dragonBones = null; + this._clock = null; + this._parent = null; + }; + i.prototype._sortZOrder = function(t, e) { + var i = this._armatureData.sortedSlots; + var s = null === t; + if (this._zOrderDirty || !s) { + for (var n = 0, r = i.length; n < r; ++n) { + var o = s ? n : t[e + n]; + if (!(o < 0 || o >= r)) { + var a = i[o]; + var l = this.getSlot(a.name); + null !== l && l._setZorder(n); + } + } + this._slotsDirty = !0; + this._zOrderDirty = !s; + } + }; + i.prototype._addBone = function(t) { + this._bones.indexOf(t) < 0 && this._bones.push(t); + }; + i.prototype._addSlot = function(t) { + this._slots.indexOf(t) < 0 && this._slots.push(t); + }; + i.prototype._addConstraint = function(t) { + this._constraints.indexOf(t) < 0 && this._constraints.push(t); + }; + i.prototype._bufferAction = function(t, e) { + this._actions.indexOf(t) < 0 && (e ? this._actions.push(t) : this._actions.unshift(t)); + }; + i.prototype.dispose = function() { + if (null !== this._armatureData) { + this._lockUpdate = !0; + this._dragonBones.bufferObject(this); + } + }; + i.prototype.init = function(e, i, s, n) { + if (null === this._armatureData) { + this._armatureData = e; + this._animation = t.BaseObject.borrowObject(t.Animation); + this._proxy = i; + this._display = s; + this._dragonBones = n; + this._proxy.dbInit(this); + this._animation.init(this); + this._animation.animations = this._armatureData.animations; + } + }; + i.prototype.advanceTime = function(t) { + if (!this._lockUpdate) if (null !== this._armatureData) if (null !== this._armatureData.parent) { + var e = this._cacheFrameIndex; + this._animation.advanceTime(t); + if (this._slotsDirty) { + this._slotsDirty = !1; + this._slots.sort(i._onSortSlots); + } + if (this._cacheFrameIndex < 0 || this._cacheFrameIndex !== e) { + var s = 0, n = 0; + for (s = 0, n = this._bones.length; s < n; ++s) this._bones[s].update(this._cacheFrameIndex); + for (s = 0, n = this._slots.length; s < n; ++s) this._slots[s].update(this._cacheFrameIndex); + } + if (this._actions.length > 0) { + this._lockUpdate = !0; + for (var r = 0, o = this._actions; r < o.length; r++) { + var a = o[r]; + var l = a.actionData; + if (null !== l && 0 === l.type) if (null !== a.slot) { + null !== (_ = a.slot.childArmature) && _.animation.fadeIn(l.name); + } else if (null !== a.bone) for (var h = 0, c = this.getSlots(); h < c.length; h++) { + var u = c[h]; + if (u.parent === a.bone) { + var _; + null !== (_ = u.childArmature) && _.animation.fadeIn(l.name); + } + } else this._animation.fadeIn(l.name); + a.returnToPool(); + } + this._actions.length = 0; + this._lockUpdate = !1; + } + this._proxy.dbUpdate(); + } else console.warn("The armature data has been disposed.\nPlease make sure dispose armature before call factory.clear()."); else console.warn("The armature has been disposed."); + }; + i.prototype.invalidUpdate = function(t, e) { + void 0 === t && (t = null); + void 0 === e && (e = !1); + if (null !== t && t.length > 0) { + if (null !== (o = this.getBone(t))) { + o.invalidUpdate(); + if (e) for (var i = 0, s = this._slots; i < s.length; i++) { + (h = s[i]).parent === o && h.invalidUpdate(); + } + } + } else { + for (var n = 0, r = this._bones; n < r.length; n++) { + var o; + (o = r[n]).invalidUpdate(); + } + if (e) for (var a = 0, l = this._slots; a < l.length; a++) { + var h; + (h = l[a]).invalidUpdate(); + } + } + }; + i.prototype.containsPoint = function(t, e) { + for (var i = 0, s = this._slots; i < s.length; i++) { + var n = s[i]; + if (n.containsPoint(t, e)) return n; + } + return null; + }; + i.prototype.intersectsSegment = function(t, e, i, s, n, r, o) { + void 0 === n && (n = null); + void 0 === r && (r = null); + void 0 === o && (o = null); + var a = t === i; + var l = 0; + var h = 0; + var c = 0; + var u = 0; + var _ = 0; + var d = 0; + var p = 0; + var m = 0; + var f = null; + var g = null; + for (var y = 0, b = this._slots; y < b.length; y++) { + var S = b[y]; + if (S.intersectsSegment(t, e, i, s, n, r, o) > 0) { + if (null === n && null === r) { + f = S; + break; + } + if (null !== n) { + (A = a ? n.y - e : n.x - t) < 0 && (A = -A); + if (null === f || A < l) { + l = A; + c = n.x; + u = n.y; + f = S; + o && (p = o.x); + } + } + if (null !== r) { + var A; + (A = r.x - t) < 0 && (A = -A); + if (null === g || A > h) { + h = A; + _ = r.x; + d = r.y; + g = S; + null !== o && (m = o.y); + } + } + } + } + if (null !== f && null !== n) { + n.x = c; + n.y = u; + null !== o && (o.x = p); + } + if (null !== g && null !== r) { + r.x = _; + r.y = d; + null !== o && (o.y = m); + } + return f; + }; + i.prototype.getBone = function(t) { + for (var e = 0, i = this._bones; e < i.length; e++) { + var s = i[e]; + if (s.name === t) return s; + } + return null; + }; + i.prototype.getBoneByDisplay = function(t) { + var e = this.getSlotByDisplay(t); + return null !== e ? e.parent : null; + }; + i.prototype.getSlot = function(t) { + for (var e = 0, i = this._slots; e < i.length; e++) { + var s = i[e]; + if (s.name === t) return s; + } + return null; + }; + i.prototype.getSlotByDisplay = function(t) { + if (null !== t) for (var e = 0, i = this._slots; e < i.length; e++) { + var s = i[e]; + if (s.display === t) return s; + } + return null; + }; + i.prototype.getBones = function() { + return this._bones; + }; + i.prototype.getSlots = function() { + return this._slots; + }; + Object.defineProperty(i.prototype, "flipX", { + get: function() { + return this._flipX; + }, + set: function(t) { + if (this._flipX !== t) { + this._flipX = t; + this.invalidUpdate(); + } + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "flipY", { + get: function() { + return this._flipY; + }, + set: function(t) { + if (this._flipY !== t) { + this._flipY = t; + this.invalidUpdate(); + } + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "cacheFrameRate", { + get: function() { + return this._armatureData.cacheFrameRate; + }, + set: function(t) { + if (this._armatureData.cacheFrameRate !== t) { + this._armatureData.cacheFrames(t); + for (var e = 0, i = this._slots; e < i.length; e++) { + var s = i[e].childArmature; + null !== s && (s.cacheFrameRate = t); + } + } + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "name", { + get: function() { + return this._armatureData.name; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "armatureData", { + get: function() { + return this._armatureData; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "animation", { + get: function() { + return this._animation; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "proxy", { + get: function() { + return this._proxy; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "eventDispatcher", { + get: function() { + return this._proxy; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "display", { + get: function() { + return this._display; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "replacedTexture", { + get: function() { + return this._replacedTexture; + }, + set: function(t) { + if (this._replacedTexture !== t) { + if (null !== this._replaceTextureAtlasData) { + this._replaceTextureAtlasData.returnToPool(); + this._replaceTextureAtlasData = null; + } + this._replacedTexture = t; + for (var e = 0, i = this._slots; e < i.length; e++) { + var s = i[e]; + s.invalidUpdate(); + s.update(-1); + } + } + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "clock", { + get: function() { + return this._clock; + }, + set: function(t) { + if (this._clock !== t) { + null !== this._clock && this._clock.remove(this); + this._clock = t; + this._clock && this._clock.add(this); + for (var e = 0, i = this._slots; e < i.length; e++) { + var s = i[e].childArmature; + null !== s && (s.clock = this._clock); + } + } + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "parent", { + get: function() { + return this._parent; + }, + enumerable: !0, + configurable: !0 + }); + i.prototype.replaceTexture = function(t) { + this.replacedTexture = t; + }; + i.prototype.hasEventListener = function(t) { + return this._proxy.hasDBEventListener(t); + }; + i.prototype.addEventListener = function(t, e, i) { + this._proxy.addDBEventListener(t, e, i); + }; + i.prototype.removeEventListener = function(t, e, i) { + this._proxy.removeDBEventListener(t, e, i); + }; + i.prototype.enableAnimationCache = function(t) { + console.warn("Deprecated."); + this.cacheFrameRate = t; + }; + i.prototype.getDisplay = function() { + return this._display; + }; + return i; + }(t.BaseObject); + t.Armature = e; + }(a5 || (a5 = {})); + !function(t) { + var e = function(e) { + r5(i, e); + function i() { + var i = null !== e && e.apply(this, arguments) || this; + i.globalTransformMatrix = new t.Matrix; + i.global = new t.Transform; + i.offset = new t.Transform; + return i; + } + i.prototype._onClear = function() { + this.globalTransformMatrix.identity(); + this.global.identity(); + this.offset.identity(); + this.origin = null; + this.userData = null; + this._globalDirty = !1; + this._armature = null; + }; + i.prototype.updateGlobalTransform = function() { + if (this._globalDirty) { + this._globalDirty = !1; + this.global.fromMatrix(this.globalTransformMatrix); + } + }; + Object.defineProperty(i.prototype, "armature", { + get: function() { + return this._armature; + }, + enumerable: !0, + configurable: !0 + }); + i._helpMatrix = new t.Matrix; + i._helpTransform = new t.Transform; + i._helpPoint = new t.Point; + return i; + }(t.BaseObject); + t.TransformObject = e; + }(a5 || (a5 = {})); + !function(t) { + var e = function(e) { + r5(i, e); + function i() { + var i = null !== e && e.apply(this, arguments) || this; + i.animationPose = new t.Transform; + i._blendState = new t.BlendState; + return i; + } + i.toString = function() { + return "[class dragonBones.Bone]"; + }; + i.prototype._onClear = function() { + e.prototype._onClear.call(this); + this.offsetMode = 1; + this.animationPose.identity(); + this._transformDirty = !1; + this._childrenTransformDirty = !1; + this._localDirty = !0; + this._hasConstraint = !1; + this._visible = !0; + this._cachedFrameIndex = -1; + this._blendState.clear(); + this._boneData = null; + this._parent = null; + this._cachedFrameIndices = null; + }; + i.prototype._updateGlobalTransformMatrix = function(e) { + var i = this._boneData; + var s = this.global; + var n = this.globalTransformMatrix; + var r = this.origin; + var o = this.offset; + var a = this.animationPose; + var l = this._parent; + var h = this._armature.flipX; + var c = this._armature.flipY === t.DragonBones.yDown; + var u = null !== l; + var _ = 0; + if (1 === this.offsetMode) if (null !== r) { + s.x = r.x + o.x + a.x; + s.scaleX = r.scaleX * o.scaleX * a.scaleX; + s.scaleY = r.scaleY * o.scaleY * a.scaleY; + if (t.DragonBones.yDown) { + s.y = r.y + o.y + a.y; + s.skew = r.skew + o.skew + a.skew; + s.rotation = r.rotation + o.rotation + a.rotation; + } else { + s.y = r.y - o.y + a.y; + s.skew = r.skew - o.skew + a.skew; + s.rotation = r.rotation - o.rotation + a.rotation; + } + } else { + s.copyFrom(o); + if (!t.DragonBones.yDown) { + s.y = -s.y; + s.skew = -s.skew; + s.rotation = -s.rotation; + } + s.add(a); + } else if (0 === this.offsetMode) null !== r ? s.copyFrom(r).add(a) : s.copyFrom(a); else { + u = !1; + s.copyFrom(o); + if (!t.DragonBones.yDown) { + s.y = -s.y; + s.skew = -s.skew; + s.rotation = -s.rotation; + } + } + if (u) { + var d = 0 === l._boneData.type ? l.globalTransformMatrix : l._getGlobalTransformMatrix(s.x, s.y); + if (i.inheritScale) { + if (!i.inheritRotation) { + l.updateGlobalTransform(); + _ = h && c ? s.rotation - (l.global.rotation + Math.PI) : h ? s.rotation + l.global.rotation + Math.PI : c ? s.rotation + l.global.rotation : s.rotation - l.global.rotation; + s.rotation = _; + } + s.toMatrix(n); + n.concat(d); + if (i.inheritTranslation) { + s.x = n.tx; + s.y = n.ty; + } else { + n.tx = s.x; + n.ty = s.y; + } + e ? s.fromMatrix(n) : this._globalDirty = !0; + } else { + if (i.inheritTranslation) { + var p = s.x; + var m = s.y; + s.x = d.a * p + d.c * m + d.tx; + s.y = d.b * p + d.d * m + d.ty; + } else { + h && (s.x = -s.x); + c && (s.y = -s.y); + } + if (i.inheritRotation) { + l.updateGlobalTransform(); + _ = l.global.scaleX < 0 ? s.rotation + l.global.rotation + Math.PI : s.rotation + l.global.rotation; + if (d.a * d.d - d.b * d.c < 0) { + _ -= 2 * s.rotation; + (h !== c || i.inheritReflection) && (s.skew += Math.PI); + t.DragonBones.yDown || (s.skew = -s.skew); + } + s.rotation = _; + } else if (h || c) { + if (h && c) _ = s.rotation + Math.PI; else { + _ = h ? Math.PI - s.rotation : -s.rotation; + s.skew += Math.PI; + } + s.rotation = _; + } + s.toMatrix(n); + } + } else { + if (h || c) { + h && (s.x = -s.x); + c && (s.y = -s.y); + if (h && c) _ = s.rotation + Math.PI; else { + _ = h ? Math.PI - s.rotation : -s.rotation; + s.skew += Math.PI; + } + s.rotation = _; + } + s.toMatrix(n); + } + }; + i.prototype.init = function(t, e) { + if (null === this._boneData) { + this._boneData = t; + this._armature = e; + null !== this._boneData.parent && (this._parent = this._armature.getBone(this._boneData.parent.name)); + this._armature._addBone(this); + this.origin = this._boneData.transform; + } + }; + i.prototype.update = function(t) { + this._blendState.dirty = !1; + if (t >= 0 && null !== this._cachedFrameIndices) { + var e = this._cachedFrameIndices[t]; + if (e >= 0 && this._cachedFrameIndex === e) this._transformDirty = !1; else if (e >= 0) { + this._transformDirty = !0; + this._cachedFrameIndex = e; + } else { + if (this._hasConstraint) for (var i = 0, s = this._armature._constraints; i < s.length; i++) { + (o = s[i])._root === this && o.update(); + } + if (this._transformDirty || null !== this._parent && this._parent._childrenTransformDirty) { + this._transformDirty = !0; + this._cachedFrameIndex = -1; + } else if (this._cachedFrameIndex >= 0) { + this._transformDirty = !1; + this._cachedFrameIndices[t] = this._cachedFrameIndex; + } else { + this._transformDirty = !0; + this._cachedFrameIndex = -1; + } + } + } else { + if (this._hasConstraint) for (var n = 0, r = this._armature._constraints; n < r.length; n++) { + var o; + (o = r[n])._root === this && o.update(); + } + if (this._transformDirty || null !== this._parent && this._parent._childrenTransformDirty) { + t = -1; + this._transformDirty = !0; + this._cachedFrameIndex = -1; + } + } + if (this._transformDirty) { + this._transformDirty = !1; + this._childrenTransformDirty = !0; + if (this._cachedFrameIndex < 0) { + var a = t >= 0; + this._localDirty && this._updateGlobalTransformMatrix(a); + a && null !== this._cachedFrameIndices && (this._cachedFrameIndex = this._cachedFrameIndices[t] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global)); + } else this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); + } else this._childrenTransformDirty && (this._childrenTransformDirty = !1); + this._localDirty = !0; + }; + i.prototype.updateByConstraint = function() { + if (this._localDirty) { + this._localDirty = !1; + (this._transformDirty || null !== this._parent && this._parent._childrenTransformDirty) && this._updateGlobalTransformMatrix(!0); + this._transformDirty = !0; + } + }; + i.prototype.invalidUpdate = function() { + this._transformDirty = !0; + }; + i.prototype.contains = function(t) { + if (t === this) return !1; + var e = t; + for (;e !== this && null !== e; ) e = e.parent; + return e === this; + }; + Object.defineProperty(i.prototype, "boneData", { + get: function() { + return this._boneData; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "visible", { + get: function() { + return this._visible; + }, + set: function(t) { + if (this._visible !== t) { + this._visible = t; + for (var e = 0, i = this._armature.getSlots(); e < i.length; e++) { + var s = i[e]; + s.parent === this && s._updateVisible(); + } + } + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "name", { + get: function() { + return this._boneData.name; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "parent", { + get: function() { + return this._parent; + }, + enumerable: !0, + configurable: !0 + }); + i.prototype.getBones = function() { + console.warn("Deprecated."); + var t = new Array; + for (var e = 0, i = this._armature.getBones(); e < i.length; e++) { + var s = i[e]; + s.parent === this && t.push(s); + } + return t; + }; + i.prototype.getSlots = function() { + console.warn("Deprecated."); + var t = new Array; + for (var e = 0, i = this._armature.getSlots(); e < i.length; e++) { + var s = i[e]; + s.parent === this && t.push(s); + } + return t; + }; + Object.defineProperty(i.prototype, "slot", { + get: function() { + console.warn("Deprecated."); + for (var t = 0, e = this._armature.getSlots(); t < e.length; t++) { + var i = e[t]; + if (i.parent === this) return i; + } + return null; + }, + enumerable: !0, + configurable: !0 + }); + return i; + }(t.TransformObject); + t.Bone = e; + }(a5 || (a5 = {})); + !function(t) { + var e = function(t) { + r5(e, t); + function e() { + var e = null !== t && t.apply(this, arguments) || this; + e._vertices = []; + e._deformVertices = []; + e._hullCache = []; + e._matrixCahce = []; + return e; + } + e.toString = function() { + return "[class dragonBones.Surface]"; + }; + e.prototype._onClear = function() { + t.prototype._onClear.call(this); + this._dX = 0; + this._dY = 0; + this._k = 0; + this._kX = 0; + this._kY = 0; + this._vertices.length = 0; + this._deformVertices.length = 0; + this._matrixCahce.length = 0; + this._hullCache.length = 0; + }; + e.prototype._getAffineTransform = function(t, e, i, s, n, r, o, a, l, h, c, u, _) { + var d = o - n; + var p = a - r; + var m = l - n; + var f = h - r; + c.rotation = Math.atan2(p, d); + c.skew = Math.atan2(f, m) - .5 * Math.PI - c.rotation; + _ && (c.rotation += Math.PI); + c.scaleX = Math.sqrt(d * d + p * p) / i; + c.scaleY = Math.sqrt(m * m + f * f) / s; + c.toMatrix(u); + c.x = u.tx = n - (u.a * t + u.c * e); + c.y = u.ty = r - (u.b * t + u.d * e); + }; + e.prototype._updateVertices = function() { + var t = this._boneData.vertices; + var e = this._vertices; + var i = this._deformVertices; + if (null !== this._parent) if (1 === this._parent._boneData.type) for (var s = 0, n = t.length; s < n; s += 2) { + var r = t[s] + i[s]; + var o = t[s + 1] + i[s]; + var a = this._parent._getGlobalTransformMatrix(r, o); + e[s] = a.a * r + a.c * o + a.tx; + e[s + 1] = a.b * r + a.d * o + a.ty; + } else { + var l = this._parent.globalTransformMatrix; + for (s = 0, n = t.length; s < n; s += 2) { + r = t[s] + i[s]; + o = t[s + 1] + i[s + 1]; + e[s] = l.a * r + l.c * o + l.tx; + e[s + 1] = l.b * r + l.d * o + l.ty; + } + } else for (s = 0, n = t.length; s < n; s += 2) { + e[s] = t[s] + i[s]; + e[s + 1] = t[s + 1] + i[s + 1]; + } + }; + e.prototype._updateGlobalTransformMatrix = function(t) { + var e = 2 * this._boneData.segmentX; + var i = this._vertices.length - 2; + var s = this._vertices[0]; + var n = this._vertices[1]; + var r = this._vertices[e]; + var o = this._vertices[e + 1]; + var a = this._vertices[i]; + var l = this._vertices[i + 1]; + var h = this._vertices[i - e]; + var c = this._vertices[i - e + 1]; + var u = s + .5 * (a - s); + var _ = n + .5 * (l - n); + var d = u + .5 * (r + .5 * (h - r) - u); + var p = _ + .5 * (o + .5 * (c - o) - _); + var m = r + .5 * (a - r); + var f = o + .5 * (l - o); + var g = h + .5 * (a - h); + var y = c + .5 * (l - c); + this._globalDirty = !1; + this._getAffineTransform(0, 0, 200, 200, d, p, m, f, g, y, this.global, this.globalTransformMatrix, !1); + }; + e.prototype._getGlobalTransformMatrix = function(t, i) { + var s = 1e3; + if (t < -s || s < t || i < -s || s < i) return this.globalTransformMatrix; + var n = !1; + var r = 200; + var o = this._boneData; + var a = o.segmentX; + var l = o.segmentY; + var h = 2 * o.segmentX; + var c = this._dX; + var u = this._dY; + var _ = Math.floor((t + r) / c); + var d = Math.floor((i + r) / u); + var p = 0; + var m = _ * c - r; + var f = d * u - r; + var g = this._matrixCahce; + var y = e._helpMatrix; + if (t < -r) { + if (i < -r || i >= r) return this.globalTransformMatrix; + p = 7 * (2 * (a * (l + 1) + 2 * a + l + d) + ((n = i > this._kX * (t + r) + f) ? 1 : 0)); + if (this._matrixCahce[p] > 0) y.copyFromArray(g, p + 1); else { + var b = d * (h + 2); + var S = this._hullCache[4]; + var A = this._hullCache[5]; + var T = this._hullCache[2] - (l - d) * S; + var v = this._hullCache[3] - (l - d) * A; + var E = this._vertices; + n ? this._getAffineTransform(-r, f + u, 800, u, E[b + h + 2], E[b + h + 3], T + S, v + A, E[b], E[b + 1], e._helpTransform, y, !0) : this._getAffineTransform(-s, f, 800, u, T, v, E[b], E[b + 1], T + S, v + A, e._helpTransform, y, !1); + g[p] = 1; + g[p + 1] = y.a; + g[p + 2] = y.b; + g[p + 3] = y.c; + g[p + 4] = y.d; + g[p + 5] = y.tx; + g[p + 6] = y.ty; + } + } else if (t >= r) { + if (i < -r || i >= r) return this.globalTransformMatrix; + p = 7 * (2 * (a * (l + 1) + a + d) + ((n = i > this._kX * (t - s) + f) ? 1 : 0)); + if (this._matrixCahce[p] > 0) y.copyFromArray(g, p + 1); else { + b = (d + 1) * (h + 2) - 2; + S = this._hullCache[4]; + A = this._hullCache[5]; + T = this._hullCache[0] + d * S; + v = this._hullCache[1] + d * A; + E = this._vertices; + n ? this._getAffineTransform(s, f + u, 800, u, T + S, v + A, E[b + h + 2], E[b + h + 3], T, v, e._helpTransform, y, !0) : this._getAffineTransform(r, f, 800, u, E[b], E[b + 1], T, v, E[b + h + 2], E[b + h + 3], e._helpTransform, y, !1); + g[p] = 1; + g[p + 1] = y.a; + g[p + 2] = y.b; + g[p + 3] = y.c; + g[p + 4] = y.d; + g[p + 5] = y.tx; + g[p + 6] = y.ty; + } + } else if (i < -r) { + if (t < -r || t >= r) return this.globalTransformMatrix; + p = 7 * (a * (l + 1) + 2 * _ + ((n = i > this._kY * (t - m - c) - s) ? 1 : 0)); + if (this._matrixCahce[p] > 0) y.copyFromArray(g, p + 1); else { + b = 2 * _; + S = this._hullCache[10]; + A = this._hullCache[11]; + T = this._hullCache[8] + _ * S; + v = this._hullCache[9] + _ * A; + E = this._vertices; + n ? this._getAffineTransform(m + c, -r, c, 800, E[b + 2], E[b + 3], E[b], E[b + 1], T + S, v + A, e._helpTransform, y, !0) : this._getAffineTransform(m, -s, c, 800, T, v, T + S, v + A, E[b], E[b + 1], e._helpTransform, y, !1); + g[p] = 1; + g[p + 1] = y.a; + g[p + 2] = y.b; + g[p + 3] = y.c; + g[p + 4] = y.d; + g[p + 5] = y.tx; + g[p + 6] = y.ty; + } + } else if (i >= r) { + if (t < -r || t >= r) return this.globalTransformMatrix; + p = 7 * (2 * (a * (l + 1) + a + l + d) + ((n = i > this._kY * (t - m - c) + r) ? 1 : 0)); + if (this._matrixCahce[p] > 0) y.copyFromArray(g, p + 1); else { + b = l * (h + 2) + 2 * _; + S = this._hullCache[10]; + A = this._hullCache[11]; + T = this._hullCache[6] - (a - _) * S; + v = this._hullCache[7] - (a - _) * A; + E = this._vertices; + n ? this._getAffineTransform(m + c, s, c, 800, T + S, v + A, T, v, E[b + 2], E[b + 3], e._helpTransform, y, !0) : this._getAffineTransform(m, r, c, 800, E[b], E[b + 1], E[b + 2], E[b + 3], T, v, e._helpTransform, y, !1); + g[p] = 1; + g[p + 1] = y.a; + g[p + 2] = y.b; + g[p + 3] = y.c; + g[p + 4] = y.d; + g[p + 5] = y.tx; + g[p + 6] = y.ty; + } + } else { + p = 7 * (2 * (a * d + _) + ((n = i > this._k * (t - m - c) + f) ? 1 : 0)); + if (this._matrixCahce[p] > 0) y.copyFromArray(g, p + 1); else { + b = 2 * _ + d * (h + 2); + E = this._vertices; + n ? this._getAffineTransform(m + c, f + u, c, u, E[b + h + 4], E[b + h + 5], E[b + h + 2], E[b + h + 3], E[b + 2], E[b + 3], e._helpTransform, y, !0) : this._getAffineTransform(m, f, c, u, E[b], E[b + 1], E[b + 2], E[b + 3], E[b + h + 2], E[b + h + 3], e._helpTransform, y, !1); + g[p] = 1; + g[p + 1] = y.a; + g[p + 2] = y.b; + g[p + 3] = y.c; + g[p + 4] = y.d; + g[p + 5] = y.tx; + g[p + 6] = y.ty; + } + } + return y; + }; + e.prototype.init = function(e, i) { + if (null === this._boneData) { + t.prototype.init.call(this, e, i); + var s = e.segmentX; + var n = e.segmentY; + var r = e.vertices.length; + this._dX = 400 / s; + this._dY = 400 / n; + this._k = -this._dY / this._dX; + this._kX = -this._dY / 800; + this._kY = -800 / this._dX; + this._vertices.length = r; + this._deformVertices.length = r; + this._matrixCahce.length = 2 * (s * n + 2 * s + 2 * n) * 7; + this._hullCache.length = 10; + for (var o = 0; o < r; ++o) this._deformVertices[o] = 0; + } + }; + e.prototype.update = function(t) { + this._blendState.dirty = !1; + if (t >= 0 && null !== this._cachedFrameIndices) { + var i = this._cachedFrameIndices[t]; + if (i >= 0 && this._cachedFrameIndex === i) this._transformDirty = !1; else if (i >= 0) { + this._transformDirty = !0; + this._cachedFrameIndex = i; + } else { + if (this._hasConstraint) for (var s = 0, n = this._armature._constraints; s < n.length; s++) { + (a = n[s])._root === this && a.update(); + } + if (this._transformDirty || null !== this._parent && this._parent._childrenTransformDirty) { + this._transformDirty = !0; + this._cachedFrameIndex = -1; + } else if (this._cachedFrameIndex >= 0) { + this._transformDirty = !1; + this._cachedFrameIndices[t] = this._cachedFrameIndex; + } else { + this._transformDirty = !0; + this._cachedFrameIndex = -1; + } + } + } else { + if (this._hasConstraint) for (var r = 0, o = this._armature._constraints; r < o.length; r++) { + var a; + (a = o[r])._root === this && a.update(); + } + if (this._transformDirty || null !== this._parent && this._parent._childrenTransformDirty) { + t = -1; + this._transformDirty = !0; + this._cachedFrameIndex = -1; + } + } + if (this._transformDirty) { + this._transformDirty = !1; + this._childrenTransformDirty = !0; + for (var l = 0, h = this._matrixCahce.length; l < h; l += 7) this._matrixCahce[l] = -1; + this._updateVertices(); + if (this._cachedFrameIndex < 0) { + var c = t >= 0; + this._localDirty && this._updateGlobalTransformMatrix(c); + c && null !== this._cachedFrameIndices && (this._cachedFrameIndex = this._cachedFrameIndices[t] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global)); + } else this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); + var u = 2 * this.global.x; + var _ = 2 * this.global.y; + var d = e._helpPoint; + this.globalTransformMatrix.transformPoint(1e3, -200, d); + this._hullCache[0] = d.x; + this._hullCache[1] = d.y; + this._hullCache[2] = u - d.x; + this._hullCache[3] = _ - d.y; + this.globalTransformMatrix.transformPoint(0, this._dY, d, !0); + this._hullCache[4] = d.x; + this._hullCache[5] = d.y; + this.globalTransformMatrix.transformPoint(200, 1e3, d); + this._hullCache[6] = d.x; + this._hullCache[7] = d.y; + this._hullCache[8] = u - d.x; + this._hullCache[9] = _ - d.y; + this.globalTransformMatrix.transformPoint(this._dX, 0, d, !0); + this._hullCache[10] = d.x; + this._hullCache[11] = d.y; + } else this._childrenTransformDirty && (this._childrenTransformDirty = !1); + this._localDirty = !0; + }; + return e; + }(t.Bone); + t.Surface = e; + }(a5 || (a5 = {})); + !function(t) { + var e = function(e) { + r5(i, e); + function i() { + var i = null !== e && e.apply(this, arguments) || this; + i._localMatrix = new t.Matrix; + i._colorTransform = new t.ColorTransform; + i._displayDatas = []; + i._displayList = []; + i._deformVertices = null; + i._rawDisplay = null; + i._meshDisplay = null; + return i; + } + i.prototype._onClear = function() { + e.prototype._onClear.call(this); + var i = []; + for (var s = 0, n = this._displayList; s < n.length; s++) { + null !== (a = n[s]) && a !== this._rawDisplay && a !== this._meshDisplay && i.indexOf(a) < 0 && i.push(a); + } + for (var r = 0, o = i; r < o.length; r++) { + var a; + (a = o[r]) instanceof t.Armature ? a.dispose() : this._disposeDisplay(a, !0); + } + null !== this._deformVertices && this._deformVertices.returnToPool(); + null !== this._meshDisplay && this._meshDisplay !== this._rawDisplay && this._disposeDisplay(this._meshDisplay, !1); + null !== this._rawDisplay && this._disposeDisplay(this._rawDisplay, !1); + this.displayController = null; + this._displayDirty = !1; + this._zOrderDirty = !1; + this._blendModeDirty = !1; + this._colorDirty = !1; + this._transformDirty = !1; + this._visible = !0; + this._blendMode = 0; + this._displayIndex = -1; + this._animationDisplayIndex = -1; + this._zOrder = 0; + this._cachedFrameIndex = -1; + this._pivotX = 0; + this._pivotY = 0; + this._localMatrix.identity(); + this._colorTransform.identity(); + this._displayList.length = 0; + this._displayDatas.length = 0; + this._slotData = null; + this._rawDisplayDatas = null; + this._displayData = null; + this._boundingBoxData = null; + this._textureData = null; + this._deformVertices = null; + this._rawDisplay = null; + this._meshDisplay = null; + this._display = null; + this._childArmature = null; + this._parent = null; + this._cachedFrameIndices = null; + }; + i.prototype._getDefaultRawDisplayData = function(t) { + var e = this._armature._armatureData.defaultSkin; + if (null !== e) { + var i = e.getDisplays(this._slotData.name); + if (null !== i) return t < i.length ? i[t] : null; + } + return null; + }; + i.prototype._updateDisplayData = function() { + var e = this._displayData; + var s = null !== this._deformVertices ? this._deformVertices.verticesData : null; + var n = this._textureData; + var r = null; + var o = null; + this._displayData = null; + this._boundingBoxData = null; + this._textureData = null; + if (this._displayIndex >= 0) { + null !== this._rawDisplayDatas && (r = this._displayIndex < this._rawDisplayDatas.length ? this._rawDisplayDatas[this._displayIndex] : null); + null === r && (r = this._getDefaultRawDisplayData(this._displayIndex)); + this._displayIndex < this._displayDatas.length && (this._displayData = this._displayDatas[this._displayIndex]); + } + if (null !== this._displayData) { + 2 === this._displayData.type || 4 === this._displayData.type ? o = this._displayData.vertices : null !== r && (2 === r.type || 4 === r.type) && (o = r.vertices); + 3 === this._displayData.type ? this._boundingBoxData = this._displayData.boundingBox : null !== r && 3 === r.type && (this._boundingBoxData = r.boundingBox); + (0 === this._displayData.type || 2 === this._displayData.type) && (this._textureData = this._displayData.texture); + } + if (this._displayData !== e || o !== s || this._textureData !== n) { + if (null === o && null !== this._textureData) { + var a = this._displayData; + var l = this._textureData.parent.scale * this._armature._armatureData.scale; + var h = this._textureData.frame; + this._pivotX = a.pivot.x; + this._pivotY = a.pivot.y; + var c = null !== h ? h : this._textureData.region; + var u = c.width; + var _ = c.height; + if (this._textureData.rotated && null === h) { + u = c.height; + _ = c.width; + } + this._pivotX *= u * l; + this._pivotY *= _ * l; + if (null !== h) { + this._pivotX += h.x * l; + this._pivotY += h.y * l; + } + if (null !== this._displayData && null !== r && this._displayData !== r) { + r.transform.toMatrix(i._helpMatrix); + i._helpMatrix.invert(); + i._helpMatrix.transformPoint(0, 0, i._helpPoint); + this._pivotX -= i._helpPoint.x; + this._pivotY -= i._helpPoint.y; + this._displayData.transform.toMatrix(i._helpMatrix); + i._helpMatrix.invert(); + i._helpMatrix.transformPoint(0, 0, i._helpPoint); + this._pivotX += i._helpPoint.x; + this._pivotY += i._helpPoint.y; + } + t.DragonBones.yDown || (this._pivotY = (this._textureData.rotated ? this._textureData.region.width : this._textureData.region.height) * l - this._pivotY); + } else { + this._pivotX = 0; + this._pivotY = 0; + } + null !== r ? this.origin = r.transform : null !== this._displayData ? this.origin = this._displayData.transform : this.origin = null; + if (o !== s) { + null === this._deformVertices && (this._deformVertices = t.BaseObject.borrowObject(t.DeformVertices)); + this._deformVertices.init(o, this._armature); + } else null !== this._deformVertices && this._textureData !== n && (this._deformVertices.verticesDirty = !0); + this._displayDirty = !0; + this._transformDirty = !0; + } + }; + i.prototype._updateDisplay = function() { + var e = null !== this._display ? this._display : this._rawDisplay; + var i = this._childArmature; + if (this._displayIndex >= 0 && this._displayIndex < this._displayList.length) { + this._display = this._displayList[this._displayIndex]; + if (null !== this._display && this._display instanceof t.Armature) { + this._childArmature = this._display; + this._display = this._childArmature.display; + } else this._childArmature = null; + } else { + this._display = null; + this._childArmature = null; + } + var s = null !== this._display ? this._display : this._rawDisplay; + if (s !== e) { + this._onUpdateDisplay(); + this._replaceDisplay(e); + this._transformDirty = !0; + this._visibleDirty = !0; + this._blendModeDirty = !0; + this._colorDirty = !0; + } + s !== this._rawDisplay && s !== this._meshDisplay || this._updateFrame(); + if (this._childArmature !== i) { + if (null !== i) { + i._parent = null; + i.clock = null; + i.inheritAnimation && i.animation.reset(); + } + if (null !== this._childArmature) { + this._childArmature._parent = this; + this._childArmature.clock = this._armature.clock; + if (this._childArmature.inheritAnimation) { + if (0 === this._childArmature.cacheFrameRate) { + var n = this._armature.cacheFrameRate; + 0 !== n && (this._childArmature.cacheFrameRate = n); + } + var r = null; + if (null !== this._displayData && 1 === this._displayData.type) r = this._displayData.actions; else if (this._displayIndex >= 0 && null !== this._rawDisplayDatas) { + var o = this._displayIndex < this._rawDisplayDatas.length ? this._rawDisplayDatas[this._displayIndex] : null; + null === o && (o = this._getDefaultRawDisplayData(this._displayIndex)); + null !== o && 1 === o.type && (r = o.actions); + } + if (null !== r && r.length > 0) for (var a = 0, l = r; a < l.length; a++) { + var h = l[a]; + var c = t.BaseObject.borrowObject(t.EventObject); + t.EventObject.actionDataToInstance(h, c, this._armature); + c.slot = this; + this._armature._bufferAction(c, !1); + } else this._childArmature.animation.play(); + } + } + } + }; + i.prototype._updateGlobalTransformMatrix = function(t) { + var e = 0 === this._parent._boneData.type ? this._parent.globalTransformMatrix : this._parent._getGlobalTransformMatrix(this.global.x, this.global.y); + this.globalTransformMatrix.copyFrom(this._localMatrix); + this.globalTransformMatrix.concat(e); + t ? this.global.fromMatrix(this.globalTransformMatrix) : this._globalDirty = !0; + }; + i.prototype._setDisplayIndex = function(t, e) { + void 0 === e && (e = !1); + if (e) { + if (this._animationDisplayIndex === t) return !1; + this._animationDisplayIndex = t; + } + if (this._displayIndex === t) return !1; + this._displayIndex = t; + this._displayDirty = !0; + this._updateDisplayData(); + return this._displayDirty; + }; + i.prototype._setZorder = function(t) { + this._zOrder; + this._zOrder = t; + this._zOrderDirty = !0; + return this._zOrderDirty; + }; + i.prototype._setColor = function(t) { + this._colorTransform.copyFrom(t); + this._colorDirty = !0; + return this._colorDirty; + }; + i.prototype._setDisplayList = function(e) { + if (null !== e && e.length > 0) { + this._displayList.length !== e.length && (this._displayList.length = e.length); + for (var i = 0, s = e.length; i < s; ++i) { + var n = e[i]; + null !== n && n !== this._rawDisplay && n !== this._meshDisplay && !(n instanceof t.Armature) && this._displayList.indexOf(n) < 0 && this._initDisplay(n, !0); + this._displayList[i] = n; + } + } else this._displayList.length > 0 && (this._displayList.length = 0); + this._displayIndex >= 0 && this._displayIndex < this._displayList.length ? this._displayDirty = this._display !== this._displayList[this._displayIndex] : this._displayDirty = null !== this._display; + this._updateDisplayData(); + return this._displayDirty; + }; + i.prototype.init = function(t, e, i, s) { + if (null === this._slotData) { + this._slotData = t; + this._isFromCache = !1; + this._visibleDirty = !0; + this._blendModeDirty = !0; + this._colorDirty = !0; + this._blendMode = this._slotData.blendMode; + this._zOrder = this._slotData.zOrder; + this._colorTransform.copyFrom(this._slotData.color); + this._rawDisplay = i; + this._meshDisplay = s; + this._armature = e; + var n = this._armature.getBone(this._slotData.parent.name); + null !== n && (this._parent = n); + this._armature._addSlot(this); + this._initDisplay(this._rawDisplay, !1); + this._rawDisplay !== this._meshDisplay && this._initDisplay(this._meshDisplay, !1); + this._onUpdateDisplay(); + this._addDisplay(); + } + }; + i.prototype.update = function(t) { + this._isFromCache = !1; + if (this._displayDirty) { + this._displayDirty = !1; + this._updateDisplay(); + this._transformDirty && (null !== this.origin ? this.global.copyFrom(this.origin).add(this.offset).toMatrix(this._localMatrix) : this.global.copyFrom(this.offset).toMatrix(this._localMatrix)); + } + if (this._zOrderDirty) { + this._zOrderDirty = !1; + this._updateZOrder(); + } + if (t >= 0 && null !== this._cachedFrameIndices) { + var e = this._cachedFrameIndices[t]; + if (e >= 0 && this._cachedFrameIndex === e) this._transformDirty = !1; else if (e >= 0) { + this._transformDirty = !0; + this._cachedFrameIndex = e; + } else if (this._transformDirty || this._parent._childrenTransformDirty) { + this._transformDirty = !0; + this._cachedFrameIndex = -1; + } else if (this._cachedFrameIndex >= 0) { + this._transformDirty = !1; + this._cachedFrameIndices[t] = this._cachedFrameIndex; + } else { + this._transformDirty = !0; + this._cachedFrameIndex = -1; + } + } else if (this._transformDirty || this._parent._childrenTransformDirty) { + t = -1; + this._transformDirty = !0; + this._cachedFrameIndex = -1; + } + if (null !== this._display) { + if (this._visibleDirty) { + this._visibleDirty = !1; + this._updateVisible(); + } + if (this._blendModeDirty) { + this._blendModeDirty = !1; + this._updateBlendMode(); + } + if (this._colorDirty) { + this._colorDirty = !1; + this._updateColor(); + } + if (null !== this._deformVertices && null !== this._deformVertices.verticesData && this._display === this._meshDisplay) { + var i = null !== this._deformVertices.verticesData.weight; + var s = 0 !== this._parent._boneData.type; + if (this._deformVertices.verticesDirty || i && this._deformVertices.isBonesUpdate() || s && this._parent._childrenTransformDirty) { + this._deformVertices.verticesDirty = !1; + this._updateMesh(); + } + if (i || s) return; + } + if (this._transformDirty) { + this._transformDirty = !1; + if (this._cachedFrameIndex < 0) { + var n = t >= 0; + this._updateGlobalTransformMatrix(n); + n && null !== this._cachedFrameIndices && (this._cachedFrameIndex = this._cachedFrameIndices[t] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global)); + } else { + this._isFromCache = !0; + this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); + } + this._updateTransform(); + } + } + }; + i.prototype.updateTransformAndMatrix = function() { + if (this._transformDirty) { + this._transformDirty = !1; + this._updateGlobalTransformMatrix(!1); + } + }; + i.prototype.replaceDisplayData = function(t, e) { + void 0 === e && (e = -1); + e < 0 && (e = this._displayIndex < 0 ? 0 : this._displayIndex); + if (this._displayDatas.length <= e) { + this._displayDatas.length = e + 1; + for (var i = 0, s = this._displayDatas.length; i < s; ++i) this._displayDatas[i] || (this._displayDatas[i] = null); + } + this._displayDatas[e] = t; + }; + i.prototype.containsPoint = function(t, e) { + if (null === this._boundingBoxData) return !1; + this.updateTransformAndMatrix(); + i._helpMatrix.copyFrom(this.globalTransformMatrix); + i._helpMatrix.invert(); + i._helpMatrix.transformPoint(t, e, i._helpPoint); + return this._boundingBoxData.containsPoint(i._helpPoint.x, i._helpPoint.y); + }; + i.prototype.intersectsSegment = function(t, e, s, n, r, o, a) { + void 0 === r && (r = null); + void 0 === o && (o = null); + void 0 === a && (a = null); + if (null === this._boundingBoxData) return 0; + this.updateTransformAndMatrix(); + i._helpMatrix.copyFrom(this.globalTransformMatrix); + i._helpMatrix.invert(); + i._helpMatrix.transformPoint(t, e, i._helpPoint); + t = i._helpPoint.x; + e = i._helpPoint.y; + i._helpMatrix.transformPoint(s, n, i._helpPoint); + s = i._helpPoint.x; + n = i._helpPoint.y; + var l = this._boundingBoxData.intersectsSegment(t, e, s, n, r, o, a); + if (l > 0) { + if (1 === l || 2 === l) if (null !== r) { + this.globalTransformMatrix.transformPoint(r.x, r.y, r); + if (null !== o) { + o.x = r.x; + o.y = r.y; + } + } else null !== o && this.globalTransformMatrix.transformPoint(o.x, o.y, o); else { + null !== r && this.globalTransformMatrix.transformPoint(r.x, r.y, r); + null !== o && this.globalTransformMatrix.transformPoint(o.x, o.y, o); + } + if (null !== a) { + this.globalTransformMatrix.transformPoint(Math.cos(a.x), Math.sin(a.x), i._helpPoint, !0); + a.x = Math.atan2(i._helpPoint.y, i._helpPoint.x); + this.globalTransformMatrix.transformPoint(Math.cos(a.y), Math.sin(a.y), i._helpPoint, !0); + a.y = Math.atan2(i._helpPoint.y, i._helpPoint.x); + } + } + return l; + }; + i.prototype.invalidUpdate = function() { + this._displayDirty = !0; + this._transformDirty = !0; + }; + Object.defineProperty(i.prototype, "visible", { + get: function() { + return this._visible; + }, + set: function(t) { + if (this._visible !== t) { + this._visible = t; + this._updateVisible(); + } + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "displayIndex", { + get: function() { + return this._displayIndex; + }, + set: function(t) { + this._setDisplayIndex(t) && this.update(-1); + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "name", { + get: function() { + return this._slotData.name; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "displayList", { + get: function() { + return this._displayList.concat(); + }, + set: function(e) { + var i = this._displayList.concat(); + var s = new Array; + this._setDisplayList(e) && this.update(-1); + for (var n = 0, r = i; n < r.length; n++) { + null !== (l = r[n]) && l !== this._rawDisplay && l !== this._meshDisplay && this._displayList.indexOf(l) < 0 && s.indexOf(l) < 0 && s.push(l); + } + for (var o = 0, a = s; o < a.length; o++) { + var l; + (l = a[o]) instanceof t.Armature || this._disposeDisplay(l, !0); + } + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "slotData", { + get: function() { + return this._slotData; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "rawDisplayDatas", { + get: function() { + return this._rawDisplayDatas; + }, + set: function(t) { + if (this._rawDisplayDatas !== t) { + this._displayDirty = !0; + this._rawDisplayDatas = t; + if (null !== this._rawDisplayDatas) { + this._displayDatas.length = this._rawDisplayDatas.length; + for (var e = 0, i = this._displayDatas.length; e < i; ++e) { + var s = this._rawDisplayDatas[e]; + null === s && (s = this._getDefaultRawDisplayData(e)); + this._displayDatas[e] = s; + } + } else this._displayDatas.length = 0; + } + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "displayData", { + get: function() { + return this._displayData; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "boundingBoxData", { + get: function() { + return this._boundingBoxData; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "rawDisplay", { + get: function() { + return this._rawDisplay; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "meshDisplay", { + get: function() { + return this._meshDisplay; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "display", { + get: function() { + return this._display; + }, + set: function(t) { + if (this._display !== t) { + var e = this._displayList.length; + this._displayIndex < 0 && 0 === e && (this._displayIndex = 0); + if (!(this._displayIndex < 0)) { + var i = this.displayList; + e <= this._displayIndex && (i.length = this._displayIndex + 1); + i[this._displayIndex] = t; + this.displayList = i; + } + } + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "childArmature", { + get: function() { + return this._childArmature; + }, + set: function(t) { + this._childArmature !== t && (this.display = t); + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "parent", { + get: function() { + return this._parent; + }, + enumerable: !0, + configurable: !0 + }); + i.prototype.getDisplay = function() { + return this._display; + }; + i.prototype.setDisplay = function(t) { + this.display = t; + }; + return i; + }(t.TransformObject); + t.Slot = e; + }(a5 || (a5 = {})); + !function(t) { + var e = function(e) { + r5(i, e); + function i() { + return null !== e && e.apply(this, arguments) || this; + } + i.prototype._onClear = function() { + this._armature = null; + this._target = null; + this._root = null; + this._bone = null; + }; + Object.defineProperty(i.prototype, "name", { + get: function() { + return this._constraintData.name; + }, + enumerable: !0, + configurable: !0 + }); + i._helpMatrix = new t.Matrix; + i._helpTransform = new t.Transform; + i._helpPoint = new t.Point; + return i; + }(t.BaseObject); + t.Constraint = e; + var i = function(e) { + r5(i, e); + function i() { + return null !== e && e.apply(this, arguments) || this; + } + i.toString = function() { + return "[class dragonBones.IKConstraint]"; + }; + i.prototype._onClear = function() { + e.prototype._onClear.call(this); + this._scaleEnabled = !1; + this._bendPositive = !1; + this._weight = 1; + this._constraintData = null; + }; + i.prototype._computeA = function() { + var e = this._target.global; + var i = this._root.global; + var s = this._root.globalTransformMatrix; + var n = Math.atan2(e.y - i.y, e.x - i.x); + i.scaleX < 0 && (n += Math.PI); + i.rotation += t.Transform.normalizeRadian(n - i.rotation) * this._weight; + i.toMatrix(s); + }; + i.prototype._computeB = function() { + var e = this._bone._boneData.length; + var i = this._root; + var s = this._target.global; + var n = i.global; + var r = this._bone.global; + var o = this._bone.globalTransformMatrix; + var a = o.a * e; + var l = o.b * e; + var h = a * a + l * l; + var c = Math.sqrt(h); + var u = r.x - n.x; + var _ = r.y - n.y; + var d = u * u + _ * _; + var p = Math.sqrt(d); + var m = r.rotation; + var f = n.rotation; + var g = Math.atan2(_, u); + var y = (u = s.x - n.x) * u + (_ = s.y - n.y) * _; + var b = Math.sqrt(y); + var S = 0; + if (c + p <= b || b + c <= p || b + p <= c) { + S = Math.atan2(s.y - n.y, s.x - n.x); + c + p <= b || p < c && (S += Math.PI); + } else { + var A = (d - h + y) / (2 * y); + var T = Math.sqrt(d - A * A * y) / b; + var v = n.x + u * A; + var E = n.y + _ * A; + var C = -_ * T; + var x = u * T; + var w = !1; + var R = i.parent; + if (null !== R) { + var I = R.globalTransformMatrix; + w = I.a * I.d - I.b * I.c < 0; + } + if (w !== this._bendPositive) { + r.x = v - C; + r.y = E - x; + } else { + r.x = v + C; + r.y = E + x; + } + S = Math.atan2(r.y - n.y, r.x - n.x); + } + var M = t.Transform.normalizeRadian(S - g); + n.rotation = f + M * this._weight; + n.toMatrix(i.globalTransformMatrix); + var B = g + M * this._weight; + r.x = n.x + Math.cos(B) * p; + r.y = n.y + Math.sin(B) * p; + var D = Math.atan2(s.y - r.y, s.x - r.x); + r.scaleX < 0 && (D += Math.PI); + r.rotation = n.rotation + m - f + t.Transform.normalizeRadian(D - M - m) * this._weight; + r.toMatrix(o); + }; + i.prototype.init = function(t, e) { + if (null === this._constraintData) { + this._constraintData = t; + this._armature = e; + this._target = this._armature.getBone(this._constraintData.target.name); + this._root = this._armature.getBone(this._constraintData.root.name); + this._bone = null !== this._constraintData.bone ? this._armature.getBone(this._constraintData.bone.name) : null; + var i = this._constraintData; + this._scaleEnabled = i.scaleEnabled; + this._bendPositive = i.bendPositive; + this._weight = i.weight; + this._root._hasConstraint = !0; + } + }; + i.prototype.update = function() { + this._root.updateByConstraint(); + if (null !== this._bone) { + this._bone.updateByConstraint(); + this._computeB(); + } else this._computeA(); + }; + i.prototype.invalidUpdate = function() { + this._root.invalidUpdate(); + null !== this._bone && this._bone.invalidUpdate(); + }; + return i; + }(e); + t.IKConstraint = i; + var s = function(e) { + r5(i, e); + function i() { + var t = null !== e && e.apply(this, arguments) || this; + t._bones = []; + t._spaces = []; + t._positions = []; + t._curves = []; + t._boneLengths = []; + t._pathGlobalVertices = []; + t._segments = [ 10 ]; + return t; + } + i.toString = function() { + return "[class dragonBones.PathConstraint]"; + }; + i.prototype._onClear = function() { + e.prototype._onClear.call(this); + this.dirty = !1; + this.pathOffset = 0; + this.position = 0; + this.spacing = 0; + this.rotateOffset = 0; + this.rotateMix = 1; + this.translateMix = 1; + this._pathSlot = null; + this._bones.length = 0; + this._spaces.length = 0; + this._positions.length = 0; + this._curves.length = 0; + this._boneLengths.length = 0; + this._pathGlobalVertices.length = 0; + }; + i.prototype._updatePathVertices = function(t) { + var e = this._armature; + var i = e.armatureData.parent; + var s = e.armatureData.scale; + var n = i.intArray; + var r = i.floatArray; + var o = t.offset; + var a = n[o + 0]; + var l = n[o + 2]; + this._pathGlobalVertices.length = 2 * a; + var h = t.weight; + if (null !== h) { + var c = this._pathSlot._deformVertices.bones; + var u = h.bones.length; + var _ = h.offset; + var d = n[_ + 1]; + var p = _ + 2 + u; + E = 0; + for (var m = 0; E < a; E++) { + var f = 0, g = 0; + for (var y = 0, b = n[p++]; y < b; y++) { + var S = c[n[p++]]; + if (null !== S) { + S.updateByConstraint(); + v = S.globalTransformMatrix; + var A = r[d++]; + x = r[d++] * s; + w = r[d++] * s; + f += (v.a * x + v.c * w + v.tx) * A; + g += (v.b * x + v.d * w + v.ty) * A; + } + } + this._pathGlobalVertices[m++] = f; + this._pathGlobalVertices[m++] = g; + } + } else { + var T = this._pathSlot.parent; + T.updateByConstraint(); + var v = T.globalTransformMatrix; + for (var E = 0, C = l; E < a; E += 2) { + var x = r[C++] * s; + var w = r[C++] * s; + var R = v.a * x + v.c * w + v.tx; + var I = v.b * x + v.d * w + v.ty; + this._pathGlobalVertices[E] = R; + this._pathGlobalVertices[E + 1] = I; + } + } + }; + i.prototype._computeVertices = function(t, e, i, s) { + for (var n = i, r = t; n < e; n += 2) { + s[n] = this._pathGlobalVertices[r++]; + s[n + 1] = this._pathGlobalVertices[r++]; + } + }; + i.prototype._computeBezierCurve = function(t, e, i, s, n) { + var r = this._armature.armatureData.parent.intArray[t.vertices.offset + 0]; + var o = this._positions; + var a = this._spaces; + var l = t.closed; + var h = Array(); + var c = 2 * r; + var u = c / 6; + var _ = -1; + var d = this.position; + o.length = 3 * e + 2; + var p = 0; + if (t.constantSpeed) { + if (l) { + c += 2; + h.length = r; + this._computeVertices(2, c - 4, 0, h); + this._computeVertices(0, 2, c - 4, h); + h[c - 2] = h[0]; + h[c - 1] = h[1]; + } else { + u--; + c -= 4; + h.length = c; + this._computeVertices(2, c, 0, h); + } + var m = new Array(u); + p = 0; + var f = h[0], g = h[1], y = 0, b = 0, S = 0, A = 0, T = 0, v = 0; + var E, C, x, w, R, I, M, B; + z = 0; + for (var D = 2; z < u; z++, D += 6) { + y = h[D]; + b = h[D + 1]; + S = h[D + 2]; + A = h[D + 3]; + R = 2 * (E = .1875 * (f - 2 * y + S)) + (x = .09375 * (3 * (y - S) - f + (T = h[D + 4]))); + I = 2 * (C = .1875 * (g - 2 * b + A)) + (w = .09375 * (3 * (b - A) - g + (v = h[D + 5]))); + M = .75 * (y - f) + E + .16666667 * x; + B = .75 * (b - g) + C + .16666667 * w; + p += Math.sqrt(M * M + B * B); + M += R; + B += I; + R += x; + I += w; + p += Math.sqrt(M * M + B * B); + M += R; + B += I; + p += Math.sqrt(M * M + B * B); + M += R + x; + B += I + w; + p += Math.sqrt(M * M + B * B); + m[z] = p; + f = T; + g = v; + } + s && (d *= p); + if (n) for (z = 0; z < e; z++) a[z] *= p; + var P = this._segments; + var O = 0; + z = 0, H = 0, j = 0; + for (var N = 0; z < e; z++, H += 3) { + var L = d += a[z]; + if (l) { + (L %= p) < 0 && (L += p); + j = 0; + } else { + if (L < 0) continue; + if (L > p) continue; + } + for (;;j++) { + var F = m[j]; + if (!(L > F)) { + if (0 === j) L /= F; else { + L = (L - (U = m[j - 1])) / (F - U); + } + break; + } + } + if (j !== _) { + _ = j; + var V = 6 * j; + f = h[V]; + g = h[V + 1]; + y = h[V + 2]; + b = h[V + 3]; + S = h[V + 4]; + A = h[V + 5]; + R = 2 * (E = .03 * (f - 2 * y + S)) + (x = .006 * (3 * (y - S) - f + (T = h[V + 6]))); + I = 2 * (C = .03 * (g - 2 * b + A)) + (w = .006 * (3 * (b - A) - g + (v = h[V + 7]))); + M = .3 * (y - f) + E + .16666667 * x; + B = .3 * (b - g) + C + .16666667 * w; + O = Math.sqrt(M * M + B * B); + P[0] = O; + for (V = 1; V < 8; V++) { + M += R; + B += I; + R += x; + I += w; + O += Math.sqrt(M * M + B * B); + P[V] = O; + } + M += R; + B += I; + O += Math.sqrt(M * M + B * B); + P[8] = O; + M += R + x; + B += I + w; + O += Math.sqrt(M * M + B * B); + P[9] = O; + N = 0; + } + L *= O; + for (;;N++) { + var k = P[N]; + if (!(L > k)) { + if (0 === N) L /= k; else { + var U; + L = N + (L - (U = P[N - 1])) / (k - U); + } + break; + } + } + this.addCurvePosition(.1 * L, f, g, y, b, S, A, T, v, o, H, i); + } + } else { + var G = t.curveLengths; + p = G[u -= l ? 1 : 2]; + s && (d *= p); + if (n) for (var z = 0; z < e; z++) a[z] *= p; + h.length = 8; + for (var z = 0, H = 0, j = 0; z < e; z++, H += 3) { + d += a[z]; + if (l) { + (d %= p) < 0 && (d += p); + j = 0; + } else { + if (d < 0) continue; + if (d > p) continue; + } + var X = 0; + for (;;j++) { + var W = G[j]; + if (!(d > W)) { + if (0 === j) X = d / W; else { + var Y = G[j - 1]; + X = (d - Y) / (W - Y); + } + break; + } + } + if (j !== _) { + _ = j; + if (l && j === u) { + this._computeVertices(c - 4, 4, 0, h); + this._computeVertices(0, 4, 4, h); + } else this._computeVertices(6 * j + 2, 8, 0, h); + } + this.addCurvePosition(X, h[0], h[1], h[2], h[3], h[4], h[5], h[6], h[7], o, H, i); + } + } + }; + i.prototype.addCurvePosition = function(t, e, i, s, n, r, o, a, l, h, c, u) { + if (0 !== t) if (1 !== t) { + var _ = 1 - t; + var d = _ * _; + var p = t * t; + var m = d * _; + var f = d * t * 3; + var g = _ * p * 3; + var y = t * p; + var b = m * e + f * s + g * r + y * a; + var S = m * i + f * n + g * o + y * l; + h[c] = b; + h[c + 1] = S; + h[c + 2] = u ? Math.atan2(S - (m * i + f * n + g * o), b - (m * e + f * s + g * r)) : 0; + } else { + h[c] = a; + h[c + 1] = l; + h[c + 2] = 0; + } else { + h[c] = e; + h[c + 1] = i; + h[c + 2] = 0; + } + }; + i.prototype.init = function(t, e) { + this._constraintData = t; + this._armature = e; + var i = t; + this.pathOffset = i.pathDisplayData.vertices.offset; + this.position = i.position; + this.spacing = i.spacing; + this.rotateOffset = i.rotateOffset; + this.rotateMix = i.rotateMix; + this.translateMix = i.translateMix; + this._root = this._armature.getBone(i.root.name); + this._target = this._armature.getBone(i.target.name); + this._pathSlot = this._armature.getSlot(i.pathSlot.name); + for (var s = 0, n = i.bones.length; s < n; s++) { + var r = this._armature.getBone(i.bones[s].name); + null !== r && this._bones.push(r); + } + 2 === i.rotateMode && (this._boneLengths.length = this._bones.length); + this._root._hasConstraint = !0; + }; + i.prototype.update = function() { + var e = this._pathSlot; + if (null !== e._deformVertices && null !== e._deformVertices.verticesData && e._deformVertices.verticesData.offset === this.pathOffset) { + var i = this._constraintData; + var s = e._displayData; + var n = !1; + var r = e._deformVertices; + if (this._root._childrenTransformDirty) { + this._updatePathVertices(s.vertices); + n = !0; + } else if (null !== r && (r.verticesDirty || r.isBonesUpdate())) { + this._updatePathVertices(s.vertices); + r.verticesDirty = !1; + n = !0; + } + if (n || this.dirty) { + var o = i.positionMode; + var a = i.spacingMode; + var l = i.rotateMode; + var h = this._bones; + var c = 0 === a; + var u = 2 === l; + var _ = 0 === l; + var d = h.length; + var p = _ ? d : d + 1; + var m = this.spacing; + var f = this._spaces; + f.length = p; + if (u || c) { + f[0] = 0; + for (var g = 0, y = p - 1; g < y; g++) { + (B = h[g]).updateByConstraint(); + var b = B._boneData.length; + var S = b * (D = B.globalTransformMatrix).a; + var A = b * D.b; + var T = Math.sqrt(S * S + A * A); + u && (this._boneLengths[g] = T); + f[g + 1] = (b + m) * T / b; + } + } else for (g = 0; g < p; g++) f[g] = m; + this._computeBezierCurve(s, p, _, 1 === o, 2 === a); + var v = this._positions; + var E = this.rotateOffset; + var C = v[0], x = v[1]; + var w; + if (0 === E) w = 1 === l; else { + w = !1; + if (null !== (B = e.parent)) { + E *= (D = B.globalTransformMatrix).a * D.d - D.b * D.c > 0 ? t.Transform.DEG_RAD : -t.Transform.DEG_RAD; + } + } + var R = this.rotateMix; + var I = this.translateMix; + g = 0; + for (var M = 3; g < d; g++, M += 3) { + var B; + (B = h[g]).updateByConstraint(); + var D; + (D = B.globalTransformMatrix).tx += (C - D.tx) * I; + D.ty += (x - D.ty) * I; + var P = (S = v[M]) - C, O = (A = v[M + 1]) - x; + if (u) { + var N = this._boneLengths[g]; + var L = (Math.sqrt(P * P + O * O) / N - 1) * R + 1; + D.a *= L; + D.b *= L; + } + C = S; + x = A; + if (R > 0) { + var F = D.a, V = D.b, k = D.c, U = D.d, G = void 0, z = void 0, H = void 0; + G = _ ? v[M - 1] : Math.atan2(O, P); + G -= Math.atan2(V, F); + if (w) { + z = Math.cos(G); + H = Math.sin(G); + var j = B._boneData.length; + C += (j * (z * F - H * V) - P) * R; + x += (j * (H * F + z * V) - O) * R; + } else G += E; + G > t.Transform.PI ? G -= t.Transform.PI_D : G < -t.Transform.PI && (G += t.Transform.PI_D); + G *= R; + z = Math.cos(G); + H = Math.sin(G); + D.a = z * F - H * V; + D.b = H * F + z * V; + D.c = z * k - H * U; + D.d = H * k + z * U; + } + B.global.fromMatrix(D); + } + this.dirty = !1; + } + } + }; + i.prototype.invalidUpdate = function() {}; + return i; + }(e); + t.PathConstraint = s; + }(a5 || (a5 = {})); + !function(t) { + var e = function() { + function t(t) { + void 0 === t && (t = 0); + this.time = 0; + this.timeScale = 1; + this._systemTime = 0; + this._animatebles = []; + this._clock = null; + this.time = t; + this._systemTime = .001 * (new Date).getTime(); + } + t.prototype.advanceTime = function(t) { + t != t && (t = 0); + var e = .001 * Date.now(); + t < 0 && (t = e - this._systemTime); + this._systemTime = e; + 1 !== this.timeScale && (t *= this.timeScale); + if (0 !== t) { + t < 0 ? this.time -= t : this.time += t; + var i = 0, s = 0, n = this._animatebles.length; + for (;i < n; ++i) { + var r = this._animatebles[i]; + if (null !== r) { + if (s > 0) { + this._animatebles[i - s] = r; + this._animatebles[i] = null; + } + r.advanceTime(t); + } else s++; + } + if (s > 0) { + n = this._animatebles.length; + for (;i < n; ++i) { + var o = this._animatebles[i]; + null !== o ? this._animatebles[i - s] = o : s++; + } + this._animatebles.length -= s; + } + } + }; + t.prototype.contains = function(t) { + if (t === this) return !1; + var e = t; + for (;e !== this && null !== e; ) e = e.clock; + return e === this; + }; + t.prototype.add = function(t) { + if (this._animatebles.indexOf(t) < 0) { + this._animatebles.push(t); + t.clock = this; + } + }; + t.prototype.remove = function(t) { + var e = this._animatebles.indexOf(t); + if (e >= 0) { + this._animatebles[e] = null; + t.clock = null; + } + }; + t.prototype.clear = function() { + for (var t = 0, e = this._animatebles; t < e.length; t++) { + var i = e[t]; + null !== i && (i.clock = null); + } + }; + Object.defineProperty(t.prototype, "clock", { + get: function() { + return this._clock; + }, + set: function(t) { + if (this._clock !== t) { + null !== this._clock && this._clock.remove(this); + this._clock = t; + null !== this._clock && this._clock.add(this); + } + }, + enumerable: !0, + configurable: !0 + }); + t.clock = new t; + return t; + }(); + t.WorldClock = e; + }(a5 || (a5 = {})); + !function(t) { + var e = function(e) { + r5(i, e); + function i() { + var t = null !== e && e.apply(this, arguments) || this; + t._animationNames = []; + t._animationStates = []; + t._animations = {}; + t._animationConfig = null; + return t; + } + i.toString = function() { + return "[class dragonBones.Animation]"; + }; + i.prototype._onClear = function() { + for (var t = 0, e = this._animationStates; t < e.length; t++) { + e[t].returnToPool(); + } + for (var i in this._animations) delete this._animations[i]; + null !== this._animationConfig && this._animationConfig.returnToPool(); + this.timeScale = 1; + this._lockUpdate = !1; + this._animationDirty = !1; + this._inheritTimeScale = 1; + this._animationNames.length = 0; + this._animationStates.length = 0; + this._armature = null; + this._animationConfig = null; + this._lastAnimationState = null; + }; + i.prototype._fadeOut = function(t) { + switch (t.fadeOutMode) { + case 1: + for (var e = 0, i = this._animationStates; e < i.length; e++) { + null === (h = i[e])._parent && (h.layer === t.layer && h.fadeOut(t.fadeOutTime, t.pauseFadeOut)); + } + break; + + case 2: + for (var s = 0, n = this._animationStates; s < n.length; s++) { + null === (h = n[s])._parent && (h.group === t.group && h.fadeOut(t.fadeOutTime, t.pauseFadeOut)); + } + break; + + case 3: + for (var r = 0, o = this._animationStates; r < o.length; r++) { + null === (h = o[r])._parent && (h.layer === t.layer && h.group === t.group && h.fadeOut(t.fadeOutTime, t.pauseFadeOut)); + } + break; + + case 4: + for (var a = 0, l = this._animationStates; a < l.length; a++) { + var h; + null === (h = l[a])._parent && h.fadeOut(t.fadeOutTime, t.pauseFadeOut); + } + } + }; + i.prototype.init = function(e) { + if (null === this._armature) { + this._armature = e; + this._animationConfig = t.BaseObject.borrowObject(t.AnimationConfig); + } + }; + i.prototype.advanceTime = function(t) { + t < 0 && (t = -t); + this._armature.inheritAnimation && null !== this._armature._parent ? this._inheritTimeScale = this._armature._parent._armature.animation._inheritTimeScale * this.timeScale : this._inheritTimeScale = this.timeScale; + 1 !== this._inheritTimeScale && (t *= this._inheritTimeScale); + var e = this._animationStates.length; + if (1 === e) { + if ((p = this._animationStates[0])._fadeState > 0 && p._subFadeState > 0) { + this._armature._dragonBones.bufferObject(p); + this._animationStates.length = 0; + this._lastAnimationState = null; + } else { + var i = p._animationData; + var s = i.cacheFrameRate; + if (this._animationDirty && s > 0) { + this._animationDirty = !1; + for (var n = 0, r = this._armature.getBones(); n < r.length; n++) { + var o = r[n]; + o._cachedFrameIndices = i.getBoneCachedFrameIndices(o.name); + } + for (var a = 0, l = this._armature.getSlots(); a < l.length; a++) { + var h = l[a]; + var c = h.rawDisplayDatas; + if (null !== c && c.length > 0) { + var u = c[0]; + if (null !== u && u.parent === this._armature.armatureData.defaultSkin) { + h._cachedFrameIndices = i.getSlotCachedFrameIndices(h.name); + continue; + } + } + h._cachedFrameIndices = null; + } + } + p.advanceTime(t, s); + } + } else if (e > 1) { + for (var _ = 0, d = 0; _ < e; ++_) { + var p; + if ((p = this._animationStates[_])._fadeState > 0 && p._subFadeState > 0) { + d++; + this._armature._dragonBones.bufferObject(p); + this._animationDirty = !0; + this._lastAnimationState === p && (this._lastAnimationState = null); + } else { + d > 0 && (this._animationStates[_ - d] = p); + p.advanceTime(t, 0); + } + if (_ === e - 1 && d > 0) { + this._animationStates.length -= d; + null === this._lastAnimationState && this._animationStates.length > 0 && (this._lastAnimationState = this._animationStates[this._animationStates.length - 1]); + } + } + this._armature._cacheFrameIndex = -1; + } else this._armature._cacheFrameIndex = -1; + }; + i.prototype.reset = function() { + for (var t = 0, e = this._animationStates; t < e.length; t++) { + e[t].returnToPool(); + } + this._animationDirty = !1; + this._animationConfig.clear(); + this._animationStates.length = 0; + this._lastAnimationState = null; + }; + i.prototype.stop = function(t) { + void 0 === t && (t = null); + if (null !== t) { + null !== (s = this.getState(t)) && s.stop(); + } else for (var e = 0, i = this._animationStates; e < i.length; e++) { + var s; + (s = i[e]).stop(); + } + }; + i.prototype.playConfig = function(e) { + var i = e.animation; + if (!(i in this._animations)) { + console.warn("Non-existent animation.\n", "DragonBones name: " + this._armature.armatureData.parent.name, "Armature name: " + this._armature.name, "Animation name: " + i); + return null; + } + var s = this._animations[i]; + if (5 === e.fadeOutMode) for (var n = 0, r = this._animationStates; n < r.length; n++) { + var o = r[n]; + if (o._animationData === s) return o; + } + 0 === this._animationStates.length ? e.fadeInTime = 0 : e.fadeInTime < 0 && (e.fadeInTime = s.fadeInTime); + e.fadeOutTime < 0 && (e.fadeOutTime = e.fadeInTime); + e.timeScale <= -100 && (e.timeScale = 1 / s.scale); + if (s.frameCount > 1) { + if (e.position < 0) { + e.position %= s.duration; + e.position = s.duration - e.position; + } else e.position === s.duration ? e.position -= 1e-6 : e.position > s.duration && (e.position %= s.duration); + e.duration > 0 && e.position + e.duration > s.duration && (e.duration = s.duration - e.position); + e.playTimes < 0 && (e.playTimes = s.playTimes); + } else { + e.playTimes = 1; + e.position = 0; + e.duration > 0 && (e.duration = 0); + } + 0 === e.duration && (e.duration = -1); + this._fadeOut(e); + var a = t.BaseObject.borrowObject(t.AnimationState); + a.init(this._armature, s, e); + this._animationDirty = !0; + this._armature._cacheFrameIndex = -1; + if (this._animationStates.length > 0) { + var l = !1; + for (var h = 0, c = this._animationStates.length; h < c; ++h) { + if (a.layer > this._animationStates[h].layer) { + l = !0; + this._animationStates.splice(h, 0, a); + break; + } + if (h !== c - 1 && a.layer > this._animationStates[h + 1].layer) { + l = !0; + this._animationStates.splice(h + 1, 0, a); + break; + } + } + l || this._animationStates.push(a); + } else this._animationStates.push(a); + for (var u = 0, _ = this._armature.getSlots(); u < _.length; u++) { + var d = _[u].childArmature; + null !== d && d.inheritAnimation && d.animation.hasAnimation(i) && null === d.animation.getState(i) && d.animation.fadeIn(i); + } + var p = !1; + for (var m in s.animationTimelines) { + if (!this._lockUpdate) { + p = !0; + this._lockUpdate = !0; + } + var f = this.fadeIn(m, e.fadeInTime, 1, a.layer, null, 0); + if (null !== f) { + f.resetToPose = !1; + f._parent = a; + f.stop(); + } + } + p && (this._lockUpdate = !1); + if (!this._lockUpdate) { + e.fadeInTime <= 0 && this._armature.advanceTime(0); + this._lastAnimationState = a; + } + return a; + }; + i.prototype.play = function(t, e) { + void 0 === t && (t = null); + void 0 === e && (e = -1); + this._animationConfig.clear(); + this._animationConfig.resetToPose = !0; + this._animationConfig.playTimes = e; + this._animationConfig.fadeInTime = 0; + this._animationConfig.animation = null !== t ? t : ""; + if (null !== t && t.length > 0) this.playConfig(this._animationConfig); else if (null === this._lastAnimationState) { + var i = this._armature.armatureData.defaultAnimation; + if (null !== i) { + this._animationConfig.animation = i.name; + this.playConfig(this._animationConfig); + } + } else if (this._lastAnimationState.isPlaying || this._lastAnimationState.isCompleted) { + this._animationConfig.animation = this._lastAnimationState.name; + this.playConfig(this._animationConfig); + } else this._lastAnimationState.play(); + return this._lastAnimationState; + }; + i.prototype.fadeIn = function(t, e, i, s, n, r) { + void 0 === e && (e = -1); + void 0 === i && (i = -1); + void 0 === s && (s = 0); + void 0 === n && (n = null); + void 0 === r && (r = 3); + this._animationConfig.clear(); + this._animationConfig.fadeOutMode = r; + this._animationConfig.playTimes = i; + this._animationConfig.layer = s; + this._animationConfig.fadeInTime = e; + this._animationConfig.animation = t; + this._animationConfig.group = null !== n ? n : ""; + return this.playConfig(this._animationConfig); + }; + i.prototype.gotoAndPlayByTime = function(t, e, i) { + void 0 === e && (e = 0); + void 0 === i && (i = -1); + this._animationConfig.clear(); + this._animationConfig.resetToPose = !0; + this._animationConfig.playTimes = i; + this._animationConfig.position = e; + this._animationConfig.fadeInTime = 0; + this._animationConfig.animation = t; + return this.playConfig(this._animationConfig); + }; + i.prototype.gotoAndPlayByFrame = function(t, e, i) { + void 0 === e && (e = 0); + void 0 === i && (i = -1); + this._animationConfig.clear(); + this._animationConfig.resetToPose = !0; + this._animationConfig.playTimes = i; + this._animationConfig.fadeInTime = 0; + this._animationConfig.animation = t; + var s = t in this._animations ? this._animations[t] : null; + null !== s && (this._animationConfig.position = s.duration * e / s.frameCount); + return this.playConfig(this._animationConfig); + }; + i.prototype.gotoAndPlayByProgress = function(t, e, i) { + void 0 === e && (e = 0); + void 0 === i && (i = -1); + this._animationConfig.clear(); + this._animationConfig.resetToPose = !0; + this._animationConfig.playTimes = i; + this._animationConfig.fadeInTime = 0; + this._animationConfig.animation = t; + var s = t in this._animations ? this._animations[t] : null; + null !== s && (this._animationConfig.position = s.duration * (e > 0 ? e : 0)); + return this.playConfig(this._animationConfig); + }; + i.prototype.gotoAndStopByTime = function(t, e) { + void 0 === e && (e = 0); + var i = this.gotoAndPlayByTime(t, e, 1); + null !== i && i.stop(); + return i; + }; + i.prototype.gotoAndStopByFrame = function(t, e) { + void 0 === e && (e = 0); + var i = this.gotoAndPlayByFrame(t, e, 1); + null !== i && i.stop(); + return i; + }; + i.prototype.gotoAndStopByProgress = function(t, e) { + void 0 === e && (e = 0); + var i = this.gotoAndPlayByProgress(t, e, 1); + null !== i && i.stop(); + return i; + }; + i.prototype.getState = function(t) { + var e = this._animationStates.length; + for (;e--; ) { + var i = this._animationStates[e]; + if (i.name === t) return i; + } + return null; + }; + i.prototype.hasAnimation = function(t) { + return t in this._animations; + }; + i.prototype.getStates = function() { + return this._animationStates; + }; + Object.defineProperty(i.prototype, "isPlaying", { + get: function() { + for (var t = 0, e = this._animationStates; t < e.length; t++) { + if (e[t].isPlaying) return !0; + } + return !1; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "isCompleted", { + get: function() { + for (var t = 0, e = this._animationStates; t < e.length; t++) { + if (!e[t].isCompleted) return !1; + } + return this._animationStates.length > 0; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "lastAnimationName", { + get: function() { + return null !== this._lastAnimationState ? this._lastAnimationState.name : ""; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "animationNames", { + get: function() { + return this._animationNames; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "animations", { + get: function() { + return this._animations; + }, + set: function(t) { + if (this._animations !== t) { + this._animationNames.length = 0; + for (var e in this._animations) delete this._animations[e]; + for (var e in t) { + this._animationNames.push(e); + this._animations[e] = t[e]; + } + } + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "animationConfig", { + get: function() { + this._animationConfig.clear(); + return this._animationConfig; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "lastAnimationState", { + get: function() { + return this._lastAnimationState; + }, + enumerable: !0, + configurable: !0 + }); + i.prototype.gotoAndPlay = function(t, e, i, s, n, r, o, a, l) { + void 0 === e && (e = -1); + void 0 === i && (i = -1); + void 0 === s && (s = -1); + void 0 === n && (n = 0); + void 0 === r && (r = null); + void 0 === o && (o = 3); + console.warn("Deprecated."); + this._animationConfig.clear(); + this._animationConfig.resetToPose = !0; + this._animationConfig.fadeOutMode = o; + this._animationConfig.playTimes = s; + this._animationConfig.layer = n; + this._animationConfig.fadeInTime = e; + this._animationConfig.animation = t; + this._animationConfig.group = null !== r ? r : ""; + var h = this._animations[t]; + h && i > 0 && (this._animationConfig.timeScale = h.duration / i); + return this.playConfig(this._animationConfig); + }; + i.prototype.gotoAndStop = function(t, e) { + void 0 === e && (e = 0); + console.warn("Deprecated."); + return this.gotoAndStopByTime(t, e); + }; + Object.defineProperty(i.prototype, "animationList", { + get: function() { + console.warn("Deprecated."); + return this._animationNames; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(i.prototype, "animationDataList", { + get: function() { + console.warn("Deprecated."); + var t = []; + for (var e = 0, i = this._animationNames.length; e < i; ++e) t.push(this._animations[this._animationNames[e]]); + return t; + }, + enumerable: !0, + configurable: !0 + }); + return i; + }(t.BaseObject); + t.Animation = e; + }(a5 || (a5 = {})); + !function(t) { + var e = function(e) { + r5(n, e); + function n() { + var t = null !== e && e.apply(this, arguments) || this; + t._blendState = new s; + t._boneMask = []; + t._boneTimelines = []; + t._surfaceTimelines = []; + t._slotTimelines = []; + t._constraintTimelines = []; + t._animationTimelines = []; + t._poseTimelines = []; + t._bonePoses = {}; + t._actionTimeline = null; + t._zOrderTimeline = null; + t._parent = null; + return t; + } + n.toString = function() { + return "[class dragonBones.AnimationState]"; + }; + n.prototype._onClear = function() { + for (var t = 0, e = this._boneTimelines; t < e.length; t++) { + e[t].returnToPool(); + } + for (var i = 0, s = this._surfaceTimelines; i < s.length; i++) { + s[i].returnToPool(); + } + for (var n = 0, r = this._slotTimelines; n < r.length; n++) { + r[n].returnToPool(); + } + for (var o = 0, a = this._constraintTimelines; o < a.length; o++) { + a[o].returnToPool(); + } + for (var l = 0, h = this._animationTimelines; l < h.length; l++) { + h[l].returnToPool(); + } + for (var c in this._bonePoses) { + this._bonePoses[c].returnToPool(); + delete this._bonePoses[c]; + } + null !== this._actionTimeline && this._actionTimeline.returnToPool(); + null !== this._zOrderTimeline && this._zOrderTimeline.returnToPool(); + this.actionEnabled = !1; + this.additiveBlending = !1; + this.displayControl = !1; + this.resetToPose = !1; + this.playTimes = 1; + this.layer = 0; + this.timeScale = 1; + this.weight = 1; + this.autoFadeOutTime = 0; + this.fadeTotalTime = 0; + this.name = ""; + this.group = ""; + this._timelineDirty = 2; + this._playheadState = 0; + this._fadeState = -1; + this._subFadeState = -1; + this._position = 0; + this._duration = 0; + this._fadeTime = 0; + this._time = 0; + this._fadeProgress = 0; + this._weightResult = 0; + this._blendState.clear(); + this._boneMask.length = 0; + this._boneTimelines.length = 0; + this._surfaceTimelines.length = 0; + this._slotTimelines.length = 0; + this._constraintTimelines.length = 0; + this._animationTimelines.length = 0; + this._poseTimelines.length = 0; + this._animationData = null; + this._armature = null; + this._actionTimeline = null; + this._zOrderTimeline = null; + this._parent = null; + }; + n.prototype._updateTimelines = function() { + for (var e = 0, i = this._armature._constraints; e < i.length; e++) { + var s = i[e]; + if (null !== (h = this._animationData.getConstraintTimelines(s.name))) for (var n = 0, r = h; n < r.length; n++) { + if (30 === (_ = r[n]).type) { + (d = t.BaseObject.borrowObject(t.IKConstraintTimelineState)).constraint = s; + d.init(this._armature, this, _); + this._constraintTimelines.push(d); + } + } else if (this.resetToPose) { + (d = t.BaseObject.borrowObject(t.IKConstraintTimelineState)).constraint = s; + d.init(this._armature, this, null); + this._constraintTimelines.push(d); + this._poseTimelines.push(d); + } + } + for (var o = 0, a = this._armature.animation.getStates(); o < a.length; o++) { + var l = a[o]; + if (l._parent === this) { + var h; + if (null !== (h = this._animationData.getAnimationTimelines(l.name))) for (var c = 0, u = h; c < u.length; c++) { + var _; + if (40 === (_ = u[c]).type) { + var d; + (d = t.BaseObject.borrowObject(t.AnimationTimelineState)).animationState = l; + d.init(this._armature, this, _); + this._animationTimelines.push(d); + } + } + } + } + }; + n.prototype._updateBoneAndSlotTimelines = function() { + var e = {}; + for (var s = 0, n = this._boneTimelines; s < n.length; s++) { + (l = (y = n[s]).bone.name) in e || (e[l] = []); + e[l].push(y); + } + for (var r = 0, o = this._armature.getBones(); r < o.length; r++) { + var a = o[r]; + var l = a.name; + if (this.containsBoneMask(l)) if (l in e) delete e[l]; else if (0 === a._boneData.type) { + var h = this._animationData.getBoneTimelines(l); + var c = l in this._bonePoses ? this._bonePoses[l] : this._bonePoses[l] = t.BaseObject.borrowObject(i); + if (null !== h) for (var u = 0, _ = h; u < _.length; u++) { + switch ((B = _[u]).type) { + case 10: + (y = t.BaseObject.borrowObject(t.BoneAllTimelineState)).bone = a; + y.bonePose = c; + y.init(this._armature, this, B); + this._boneTimelines.push(y); + break; + + case 11: + (y = t.BaseObject.borrowObject(t.BoneTranslateTimelineState)).bone = a; + y.bonePose = c; + y.init(this._armature, this, B); + this._boneTimelines.push(y); + break; + + case 12: + (y = t.BaseObject.borrowObject(t.BoneRotateTimelineState)).bone = a; + y.bonePose = c; + y.init(this._armature, this, B); + this._boneTimelines.push(y); + break; + + case 13: + (y = t.BaseObject.borrowObject(t.BoneScaleTimelineState)).bone = a; + y.bonePose = c; + y.init(this._armature, this, B); + this._boneTimelines.push(y); + } + } else if (this.resetToPose) { + (y = t.BaseObject.borrowObject(t.BoneAllTimelineState)).bone = a; + y.bonePose = c; + y.init(this._armature, this, null); + this._boneTimelines.push(y); + this._poseTimelines.push(y); + } + } else if (1 === a._boneData.type) { + if (null !== (h = this._animationData.getSurfaceTimelines(l))) for (var d = 0, p = h; d < p.length; d++) { + if (50 === (B = p[d]).type) { + (y = t.BaseObject.borrowObject(t.SurfaceTimelineState)).surface = a; + y.init(this._armature, this, B); + this._surfaceTimelines.push(y); + } + } else if (this.resetToPose) { + (y = t.BaseObject.borrowObject(t.SurfaceTimelineState)).surface = a; + y.init(this._armature, this, null); + this._surfaceTimelines.push(y); + this._poseTimelines.push(y); + } + } + } + for (var m in e) for (var f = 0, g = e[m]; f < g.length; f++) { + var y = g[f]; + this._boneTimelines.splice(this._boneTimelines.indexOf(y), 1); + y.returnToPool(); + } + var b = {}; + var S = []; + for (var A = 0, T = this._slotTimelines; A < T.length; A++) { + (l = (y = T[A]).slot.name) in b || (b[l] = []); + b[l].push(y); + } + for (var v = 0, E = this._armature.getSlots(); v < E.length; v++) { + var C = E[v]; + var x = C.parent.name; + if (this.containsBoneMask(x)) { + l = C.name; + h = this._animationData.getSlotTimelines(l); + if (l in b) delete b[l]; else { + var w = !1; + var R = !1; + S.length = 0; + if (null !== h) for (var I = 0, M = h; I < M.length; I++) { + var B; + switch ((B = M[I]).type) { + case 20: + (y = t.BaseObject.borrowObject(t.SlotDislayTimelineState)).slot = C; + y.init(this._armature, this, B); + this._slotTimelines.push(y); + w = !0; + break; + + case 21: + (y = t.BaseObject.borrowObject(t.SlotColorTimelineState)).slot = C; + y.init(this._armature, this, B); + this._slotTimelines.push(y); + R = !0; + break; + + case 22: + (y = t.BaseObject.borrowObject(t.DeformTimelineState)).slot = C; + y.init(this._armature, this, B); + this._slotTimelines.push(y); + S.push(y.vertexOffset); + } + } + if (this.resetToPose) { + if (!w) { + (y = t.BaseObject.borrowObject(t.SlotDislayTimelineState)).slot = C; + y.init(this._armature, this, null); + this._slotTimelines.push(y); + this._poseTimelines.push(y); + } + if (!R) { + (y = t.BaseObject.borrowObject(t.SlotColorTimelineState)).slot = C; + y.init(this._armature, this, null); + this._slotTimelines.push(y); + this._poseTimelines.push(y); + } + if (null !== C.rawDisplayDatas) for (var D = 0, P = C.rawDisplayDatas; D < P.length; D++) { + var O = P[D]; + if (null !== O && 2 === O.type) { + var N = O.vertices.offset; + if (S.indexOf(N) < 0) { + (y = t.BaseObject.borrowObject(t.DeformTimelineState)).vertexOffset = N; + y.slot = C; + y.init(this._armature, this, null); + this._slotTimelines.push(y); + this._poseTimelines.push(y); + } + } + } + } + } + } + } + for (var m in b) for (var L = 0, F = b[m]; L < F.length; L++) { + y = F[L]; + this._slotTimelines.splice(this._slotTimelines.indexOf(y), 1); + y.returnToPool(); + } + }; + n.prototype._advanceFadeTime = function(e) { + var i = this._fadeState > 0; + if (this._subFadeState < 0) { + this._subFadeState = 0; + var s = i ? t.EventObject.FADE_OUT : t.EventObject.FADE_IN; + if (this._armature.eventDispatcher.hasDBEventListener(s)) { + (n = t.BaseObject.borrowObject(t.EventObject)).type = s; + n.armature = this._armature; + n.animationState = this; + this._armature._dragonBones.bufferEvent(n); + } + } + e < 0 && (e = -e); + this._fadeTime += e; + if (this._fadeTime >= this.fadeTotalTime) { + this._subFadeState = 1; + this._fadeProgress = i ? 0 : 1; + } else this._fadeTime > 0 ? this._fadeProgress = i ? 1 - this._fadeTime / this.fadeTotalTime : this._fadeTime / this.fadeTotalTime : this._fadeProgress = i ? 1 : 0; + if (this._subFadeState > 0) { + if (!i) { + this._playheadState |= 1; + this._fadeState = 0; + } + s = i ? t.EventObject.FADE_OUT_COMPLETE : t.EventObject.FADE_IN_COMPLETE; + if (this._armature.eventDispatcher.hasDBEventListener(s)) { + var n; + (n = t.BaseObject.borrowObject(t.EventObject)).type = s; + n.armature = this._armature; + n.animationState = this; + this._armature._dragonBones.bufferEvent(n); + } + } + }; + n.prototype.init = function(e, i, s) { + if (null === this._armature) { + this._armature = e; + this._animationData = i; + this.resetToPose = s.resetToPose; + this.additiveBlending = s.additiveBlending; + this.displayControl = s.displayControl; + this.actionEnabled = s.actionEnabled; + this.layer = s.layer; + this.playTimes = s.playTimes; + this.timeScale = s.timeScale; + this.fadeTotalTime = s.fadeInTime; + this.autoFadeOutTime = s.autoFadeOutTime; + this.weight = s.weight; + this.name = s.name.length > 0 ? s.name : s.animation; + this.group = s.group; + s.pauseFadeIn ? this._playheadState = 2 : this._playheadState = 3; + if (s.duration < 0) { + this._position = 0; + this._duration = this._animationData.duration; + 0 !== s.position ? this.timeScale >= 0 ? this._time = s.position : this._time = s.position - this._duration : this._time = 0; + } else { + this._position = s.position; + this._duration = s.duration; + this._time = 0; + } + this.timeScale < 0 && 0 === this._time && (this._time = -1e-6); + this.fadeTotalTime <= 0 && (this._fadeProgress = .999999); + if (s.boneMask.length > 0) { + this._boneMask.length = s.boneMask.length; + for (var n = 0, r = this._boneMask.length; n < r; ++n) this._boneMask[n] = s.boneMask[n]; + } + this._actionTimeline = t.BaseObject.borrowObject(t.ActionTimelineState); + this._actionTimeline.init(this._armature, this, this._animationData.actionTimeline); + this._actionTimeline.currentTime = this._time; + this._actionTimeline.currentTime < 0 && (this._actionTimeline.currentTime = this._duration - this._actionTimeline.currentTime); + if (null !== this._animationData.zOrderTimeline) { + this._zOrderTimeline = t.BaseObject.borrowObject(t.ZOrderTimelineState); + this._zOrderTimeline.init(this._armature, this, this._animationData.zOrderTimeline); + } + } + }; + n.prototype.advanceTime = function(e, i) { + this._blendState.dirty = !1; + 0 === this._fadeState && 0 === this._subFadeState || this._advanceFadeTime(e); + if (3 === this._playheadState) { + 1 !== this.timeScale && (e *= this.timeScale); + this._time += e; + } + if (0 !== this._timelineDirty) { + 2 === this._timelineDirty && this._updateTimelines(); + this._timelineDirty = 0; + this._updateBoneAndSlotTimelines(); + } + if (0 !== this.weight) { + var s = 0 === this._fadeState && i > 0; + var n = !0; + var r = !0; + var o = this._time; + this._weightResult = this.weight * this._fadeProgress; + null !== this._parent && (this._weightResult *= this._parent._weightResult / this._parent._fadeProgress); + this._actionTimeline.playState <= 0 && this._actionTimeline.update(o); + if (s) { + var a = 2 * i; + this._actionTimeline.currentTime = Math.floor(this._actionTimeline.currentTime * a) / a; + } + null !== this._zOrderTimeline && this._zOrderTimeline.playState <= 0 && this._zOrderTimeline.update(o); + if (s) { + var l = Math.floor(this._actionTimeline.currentTime * i); + if (this._armature._cacheFrameIndex === l) { + n = !1; + r = !1; + } else { + this._armature._cacheFrameIndex = l; + this._animationData.cachedFrames[l] ? r = !1 : this._animationData.cachedFrames[l] = !0; + } + } + if (n) { + if (r) for (var h = 0, c = this._boneTimelines.length; h < c; ++h) { + (m = this._boneTimelines[h]).playState <= 0 && m.update(o); + if (h === c - 1 || m.bone !== this._boneTimelines[h + 1].bone) { + 0 !== (u = m.bone._blendState.update(this._weightResult, this.layer)) && m.blend(u); + } + } + for (h = 0, c = this._surfaceTimelines.length; h < c; ++h) { + var u = (m = this._surfaceTimelines[h]).surface._blendState.update(this._weightResult, this.layer); + m.playState <= 0 && m.update(o); + 0 !== u && m.blend(u); + } + if (this.displayControl) for (h = 0, c = this._slotTimelines.length; h < c; ++h) { + var _ = (m = this._slotTimelines[h]).slot.displayController; + null !== _ && _ !== this.name && _ !== this.group || m.playState <= 0 && m.update(o); + } + for (h = 0, c = this._constraintTimelines.length; h < c; ++h) { + (m = this._constraintTimelines[h]).playState <= 0 && m.update(o); + } + for (h = 0, c = this._animationTimelines.length; h < c; ++h) { + u = (m = this._animationTimelines[h]).animationState._blendState.update(this._weightResult, this.layer); + m.playState <= 0 && m.update(o); + 0 !== u && m.blend(u); + } + } + if (0 === this._fadeState) { + if (this._subFadeState > 0) { + this._subFadeState = 0; + if (this._poseTimelines.length > 0) { + for (var d = 0, p = this._poseTimelines; d < p.length; d++) { + var m; + (m = p[d]) instanceof t.BoneTimelineState ? this._boneTimelines.splice(this._boneTimelines.indexOf(m), 1) : m instanceof t.SurfaceTimelineState ? this._surfaceTimelines.splice(this._surfaceTimelines.indexOf(m), 1) : m instanceof t.SlotTimelineState ? this._slotTimelines.splice(this._slotTimelines.indexOf(m), 1) : m instanceof t.ConstraintTimelineState && this._constraintTimelines.splice(this._constraintTimelines.indexOf(m), 1); + m.returnToPool(); + } + this._poseTimelines.length = 0; + } + } + this._actionTimeline.playState > 0 && this.autoFadeOutTime >= 0 && this.fadeOut(this.autoFadeOutTime); + } + } + }; + n.prototype.play = function() { + this._playheadState = 3; + }; + n.prototype.stop = function() { + this._playheadState &= 1; + }; + n.prototype.fadeOut = function(t, e) { + void 0 === e && (e = !0); + t < 0 && (t = 0); + e && (this._playheadState &= 2); + if (this._fadeState > 0) { + if (t > this.fadeTotalTime - this._fadeTime) return; + } else { + this._fadeState = 1; + this._subFadeState = -1; + (t <= 0 || this._fadeProgress <= 0) && (this._fadeProgress = 1e-6); + for (var i = 0, s = this._boneTimelines; i < s.length; i++) { + (_ = s[i]).fadeOut(); + } + for (var n = 0, r = this._surfaceTimelines; n < r.length; n++) { + (_ = r[n]).fadeOut(); + } + for (var o = 0, a = this._slotTimelines; o < a.length; o++) { + (_ = a[o]).fadeOut(); + } + for (var l = 0, h = this._constraintTimelines; l < h.length; l++) { + (_ = h[l]).fadeOut(); + } + for (var c = 0, u = this._animationTimelines; c < u.length; c++) { + var _; + (_ = u[c]).animationState.fadeOut(t, e); + _.fadeOut(); + } + } + this.displayControl = !1; + this.fadeTotalTime = this._fadeProgress > 1e-6 ? t / this._fadeProgress : 0; + this._fadeTime = this.fadeTotalTime * (1 - this._fadeProgress); + }; + n.prototype.containsBoneMask = function(t) { + return 0 === this._boneMask.length || this._boneMask.indexOf(t) >= 0; + }; + n.prototype.addBoneMask = function(t, e) { + void 0 === e && (e = !0); + var i = this._armature.getBone(t); + if (null !== i) { + this._boneMask.indexOf(t) < 0 && this._boneMask.push(t); + if (e) for (var s = 0, n = this._armature.getBones(); s < n.length; s++) { + var r = n[s]; + this._boneMask.indexOf(r.name) < 0 && i.contains(r) && this._boneMask.push(r.name); + } + this._timelineDirty = 1; + } + }; + n.prototype.removeBoneMask = function(t, e) { + void 0 === e && (e = !0); + var i = this._boneMask.indexOf(t); + i >= 0 && this._boneMask.splice(i, 1); + if (e) { + var s = this._armature.getBone(t); + if (null !== s) { + var n = this._armature.getBones(); + if (this._boneMask.length > 0) for (var r = 0, o = n; r < o.length; r++) { + var a = o[r]; + var l = this._boneMask.indexOf(a.name); + l >= 0 && s.contains(a) && this._boneMask.splice(l, 1); + } else for (var h = 0, c = n; h < c.length; h++) { + (a = c[h]) !== s && (s.contains(a) || this._boneMask.push(a.name)); + } + } + } + this._timelineDirty = 1; + }; + n.prototype.removeAllBoneMask = function() { + this._boneMask.length = 0; + this._timelineDirty = 1; + }; + Object.defineProperty(n.prototype, "isFadeIn", { + get: function() { + return this._fadeState < 0; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(n.prototype, "isFadeOut", { + get: function() { + return this._fadeState > 0; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(n.prototype, "isFadeComplete", { + get: function() { + return 0 === this._fadeState; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(n.prototype, "isPlaying", { + get: function() { + return 0 != (2 & this._playheadState) && this._actionTimeline.playState <= 0; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(n.prototype, "isCompleted", { + get: function() { + return this._actionTimeline.playState > 0; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(n.prototype, "currentPlayTimes", { + get: function() { + return this._actionTimeline.currentPlayTimes; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(n.prototype, "totalTime", { + get: function() { + return this._duration; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(n.prototype, "currentTime", { + get: function() { + return this._actionTimeline.currentTime; + }, + set: function(t) { + var e = this._actionTimeline.currentPlayTimes - (this._actionTimeline.playState > 0 ? 1 : 0); + (t < 0 || this._duration < t) && (t = t % this._duration + e * this._duration) < 0 && (t += this._duration); + this.playTimes > 0 && e === this.playTimes - 1 && t === this._duration && (t = this._duration - 1e-6); + if (this._time !== t) { + this._time = t; + this._actionTimeline.setCurrentTime(this._time); + null !== this._zOrderTimeline && (this._zOrderTimeline.playState = -1); + for (var i = 0, s = this._boneTimelines; i < s.length; i++) { + s[i].playState = -1; + } + for (var n = 0, r = this._slotTimelines; n < r.length; n++) { + r[n].playState = -1; + } + } + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(n.prototype, "animationData", { + get: function() { + return this._animationData; + }, + enumerable: !0, + configurable: !0 + }); + return n; + }(t.BaseObject); + t.AnimationState = e; + var i = function(e) { + r5(i, e); + function i() { + var i = null !== e && e.apply(this, arguments) || this; + i.current = new t.Transform; + i.delta = new t.Transform; + i.result = new t.Transform; + return i; + } + i.toString = function() { + return "[class dragonBones.BonePose]"; + }; + i.prototype._onClear = function() { + this.current.identity(); + this.delta.identity(); + this.result.identity(); + }; + return i; + }(t.BaseObject); + t.BonePose = i; + var s = function() { + function t() {} + t.prototype.update = function(t, e) { + if (this.dirty) { + if (!(this.leftWeight > 0)) return 0; + if (this.layer !== e) { + if (this.layerWeight >= this.leftWeight) { + this.leftWeight = 0; + return 0; + } + this.layer = e; + this.leftWeight -= this.layerWeight; + this.layerWeight = 0; + } + t *= this.leftWeight; + this.layerWeight += t; + this.blendWeight = t; + return 2; + } + this.dirty = !0; + this.layer = e; + this.layerWeight = t; + this.leftWeight = 1; + this.blendWeight = t; + return 1; + }; + t.prototype.clear = function() { + this.dirty = !1; + this.layer = 0; + this.leftWeight = 0; + this.layerWeight = 0; + this.blendWeight = 0; + }; + return t; + }(); + t.BlendState = s; + }(a5 || (a5 = {})); + !function(t) { + var e = function(t) { + r5(e, t); + function e() { + return null !== t && t.apply(this, arguments) || this; + } + e.prototype._onClear = function() { + this.playState = -1; + this.currentPlayTimes = -1; + this.currentTime = -1; + this._tweenState = 0; + this._frameRate = 0; + this._frameValueOffset = 0; + this._frameCount = 0; + this._frameOffset = 0; + this._frameIndex = -1; + this._frameRateR = 0; + this._position = 0; + this._duration = 0; + this._timeScale = 1; + this._timeOffset = 0; + this._dragonBonesData = null; + this._animationData = null; + this._timelineData = null; + this._armature = null; + this._animationState = null; + this._actionTimeline = null; + this._frameArray = null; + this._frameIntArray = null; + this._frameFloatArray = null; + this._timelineArray = null; + this._frameIndices = null; + }; + e.prototype._setCurrentTime = function(t) { + var e = this.playState; + var i = this.currentPlayTimes; + var s = this.currentTime; + if (null !== this._actionTimeline && this._frameCount <= 1) { + this.playState = this._actionTimeline.playState >= 0 ? 1 : -1; + this.currentPlayTimes = 1; + this.currentTime = this._actionTimeline.currentTime; + } else if (null === this._actionTimeline || 1 !== this._timeScale || 0 !== this._timeOffset) { + var n = this._animationState.playTimes; + var r = n * this._duration; + t *= this._timeScale; + 0 !== this._timeOffset && (t += this._timeOffset * this._animationData.duration); + if (n > 0 && (t >= r || t <= -r)) { + this.playState <= 0 && 3 === this._animationState._playheadState && (this.playState = 1); + this.currentPlayTimes = n; + this.currentTime = t < 0 ? 0 : this._duration + 1e-6; + } else { + 0 !== this.playState && 3 === this._animationState._playheadState && (this.playState = 0); + if (t < 0) { + t = -t; + this.currentPlayTimes = Math.floor(t / this._duration); + this.currentTime = this._duration - t % this._duration; + } else { + this.currentPlayTimes = Math.floor(t / this._duration); + this.currentTime = t % this._duration; + } + } + this.currentTime += this._position; + } else { + this.playState = this._actionTimeline.playState; + this.currentPlayTimes = this._actionTimeline.currentPlayTimes; + this.currentTime = this._actionTimeline.currentTime; + } + if (this.currentPlayTimes === i && this.currentTime === s) return !1; + (e < 0 && this.playState !== e || this.playState <= 0 && this.currentPlayTimes !== i) && (this._frameIndex = -1); + return !0; + }; + e.prototype.init = function(t, e, i) { + this._armature = t; + this._animationState = e; + this._timelineData = i; + this._actionTimeline = this._animationState._actionTimeline; + this === this._actionTimeline && (this._actionTimeline = null); + this._animationData = this._animationState._animationData; + this._frameRate = this._animationData.parent.frameRate; + this._frameRateR = 1 / this._frameRate; + this._position = this._animationState._position; + this._duration = this._animationState._duration; + this._dragonBonesData = this._animationData.parent.parent; + if (null !== this._timelineData) { + this._frameIntArray = this._dragonBonesData.frameIntArray; + this._frameFloatArray = this._dragonBonesData.frameFloatArray; + this._frameArray = this._dragonBonesData.frameArray; + this._timelineArray = this._dragonBonesData.timelineArray; + this._frameIndices = this._dragonBonesData.frameIndices; + this._frameCount = this._timelineArray[this._timelineData.offset + 2]; + this._frameValueOffset = this._timelineArray[this._timelineData.offset + 4]; + this._timeScale = 100 / this._timelineArray[this._timelineData.offset + 0]; + this._timeOffset = .01 * this._timelineArray[this._timelineData.offset + 1]; + } + }; + e.prototype.fadeOut = function() {}; + e.prototype.update = function(t) { + if (this._setCurrentTime(t)) { + if (this._frameCount > 1) { + var e = Math.floor(this.currentTime * this._frameRate); + var i = this._frameIndices[this._timelineData.frameIndicesOffset + e]; + if (this._frameIndex !== i) { + this._frameIndex = i; + this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 + this._frameIndex]; + this._onArriveAtFrame(); + } + } else if (this._frameIndex < 0) { + this._frameIndex = 0; + null !== this._timelineData && (this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5]); + this._onArriveAtFrame(); + } + 0 !== this._tweenState && this._onUpdateFrame(); + } + }; + return e; + }(t.BaseObject); + t.TimelineState = e; + var i = function(t) { + r5(e, t); + function e() { + return null !== t && t.apply(this, arguments) || this; + } + e._getEasingValue = function(t, e, i) { + var s = e; + switch (t) { + case 3: + s = Math.pow(e, 2); + break; + + case 4: + s = 1 - Math.pow(1 - e, 2); + break; + + case 5: + s = .5 * (1 - Math.cos(e * Math.PI)); + } + return (s - e) * i + e; + }; + e._getEasingCurveValue = function(t, e, i, s) { + if (t <= 0) return 0; + if (t >= 1) return 1; + var n = i + 1; + var r = Math.floor(t * n); + var o = 0 === r ? 0 : e[s + r - 1]; + return 1e-4 * (o + ((r === n - 1 ? 1e4 : e[s + r]) - o) * (t * n - r)); + }; + e.prototype._onClear = function() { + t.prototype._onClear.call(this); + this._tweenType = 0; + this._curveCount = 0; + this._framePosition = 0; + this._frameDurationR = 0; + this._tweenProgress = 0; + this._tweenEasing = 0; + }; + e.prototype._onArriveAtFrame = function() { + if (this._frameCount > 1 && (this._frameIndex !== this._frameCount - 1 || 0 === this._animationState.playTimes || this._animationState.currentPlayTimes < this._animationState.playTimes - 1)) { + this._tweenType = this._frameArray[this._frameOffset + 1]; + this._tweenState = 0 === this._tweenType ? 1 : 2; + 2 === this._tweenType ? this._curveCount = this._frameArray[this._frameOffset + 2] : 0 !== this._tweenType && 1 !== this._tweenType && (this._tweenEasing = .01 * this._frameArray[this._frameOffset + 2]); + this._framePosition = this._frameArray[this._frameOffset] * this._frameRateR; + if (this._frameIndex === this._frameCount - 1) this._frameDurationR = 1 / (this._animationData.duration - this._framePosition); else { + var t = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 + this._frameIndex + 1]; + var e = this._frameArray[t] * this._frameRateR - this._framePosition; + this._frameDurationR = e > 0 ? 1 / e : 0; + } + } else this._tweenState = 1; + }; + e.prototype._onUpdateFrame = function() { + if (2 === this._tweenState) { + this._tweenProgress = (this.currentTime - this._framePosition) * this._frameDurationR; + 2 === this._tweenType ? this._tweenProgress = e._getEasingCurveValue(this._tweenProgress, this._frameArray, this._curveCount, this._frameOffset + 3) : 1 !== this._tweenType && (this._tweenProgress = e._getEasingValue(this._tweenType, this._tweenProgress, this._tweenEasing)); + } else this._tweenProgress = 0; + }; + return e; + }(e); + t.TweenTimelineState = i; + var s = function(t) { + r5(e, t); + function e() { + return null !== t && t.apply(this, arguments) || this; + } + e.prototype._onClear = function() { + t.prototype._onClear.call(this); + this.bone = null; + this.bonePose = null; + }; + e.prototype.blend = function(t) { + var e = this.bone._blendState.blendWeight; + var i = this.bone.animationPose; + var s = this.bonePose.result; + if (2 === t) { + i.x += s.x * e; + i.y += s.y * e; + i.rotation += s.rotation * e; + i.skew += s.skew * e; + i.scaleX += (s.scaleX - 1) * e; + i.scaleY += (s.scaleY - 1) * e; + } else if (1 !== e) { + i.x = s.x * e; + i.y = s.y * e; + i.rotation = s.rotation * e; + i.skew = s.skew * e; + i.scaleX = (s.scaleX - 1) * e + 1; + i.scaleY = (s.scaleY - 1) * e + 1; + } else { + i.x = s.x; + i.y = s.y; + i.rotation = s.rotation; + i.skew = s.skew; + i.scaleX = s.scaleX; + i.scaleY = s.scaleY; + } + 0 === this._animationState._fadeState && 0 === this._animationState._subFadeState || (this.bone._transformDirty = !0); + }; + return e; + }(i); + t.BoneTimelineState = s; + var n = function(t) { + r5(e, t); + function e() { + return null !== t && t.apply(this, arguments) || this; + } + e.prototype._onClear = function() { + t.prototype._onClear.call(this); + this.slot = null; + }; + return e; + }(i); + t.SlotTimelineState = n; + var r = function(t) { + r5(e, t); + function e() { + return null !== t && t.apply(this, arguments) || this; + } + e.prototype._onClear = function() { + t.prototype._onClear.call(this); + this.constraint = null; + }; + return e; + }(i); + t.ConstraintTimelineState = r; + }(a5 || (a5 = {})); + !function(t) { + var e = function(e) { + r5(i, e); + function i() { + return null !== e && e.apply(this, arguments) || this; + } + i.toString = function() { + return "[class dragonBones.ActionTimelineState]"; + }; + i.prototype._onCrossFrame = function(e) { + var i = this._armature.eventDispatcher; + if (this._animationState.actionEnabled) { + var s = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 + e]; + var n = this._frameArray[s + 1]; + var r = this._animationData.parent.actions; + for (var o = 0; o < n; ++o) { + var a = r[this._frameArray[s + 2 + o]]; + if (0 === a.type) { + (h = t.BaseObject.borrowObject(t.EventObject)).time = this._frameArray[s] / this._frameRate; + h.animationState = this._animationState; + t.EventObject.actionDataToInstance(a, h, this._armature); + this._armature._bufferAction(h, !0); + } else { + var l = 10 === a.type ? t.EventObject.FRAME_EVENT : t.EventObject.SOUND_EVENT; + if (11 === a.type || i.hasDBEventListener(l)) { + var h; + (h = t.BaseObject.borrowObject(t.EventObject)).time = this._frameArray[s] / this._frameRate; + h.animationState = this._animationState; + t.EventObject.actionDataToInstance(a, h, this._armature); + this._armature._dragonBones.bufferEvent(h); + } + } + } + } + }; + i.prototype._onArriveAtFrame = function() {}; + i.prototype._onUpdateFrame = function() {}; + i.prototype.update = function(e) { + var i = this.playState; + var s = this.currentPlayTimes; + var n = this.currentTime; + if (this._setCurrentTime(e)) { + var r = this._armature.eventDispatcher; + if (i < 0) { + if (this.playState === i) return; + this._animationState.displayControl && this._animationState.resetToPose && this._armature._sortZOrder(null, 0); + s = this.currentPlayTimes; + if (r.hasDBEventListener(t.EventObject.START)) { + var o = t.BaseObject.borrowObject(t.EventObject); + o.type = t.EventObject.START; + o.armature = this._armature; + o.animationState = this._animationState; + this._armature._dragonBones.bufferEvent(o); + } + } + var a = this._animationState.timeScale < 0; + var l = null; + var h = null; + if (this.currentPlayTimes !== s) { + if (r.hasDBEventListener(t.EventObject.LOOP_COMPLETE)) { + (l = t.BaseObject.borrowObject(t.EventObject)).type = t.EventObject.LOOP_COMPLETE; + l.armature = this._armature; + l.animationState = this._animationState; + } + if (this.playState > 0 && r.hasDBEventListener(t.EventObject.COMPLETE)) { + (h = t.BaseObject.borrowObject(t.EventObject)).type = t.EventObject.COMPLETE; + h.armature = this._armature; + h.animationState = this._animationState; + } + } + if (this._frameCount > 1) { + var c = this._timelineData; + var u = Math.floor(this.currentTime * this._frameRate); + var _ = this._frameIndices[c.frameIndicesOffset + u]; + if (this._frameIndex !== _) { + var d = this._frameIndex; + this._frameIndex = _; + if (null !== this._timelineArray) { + this._frameOffset = this._animationData.frameOffset + this._timelineArray[c.offset + 5 + this._frameIndex]; + if (a) { + if (d < 0) { + var p = Math.floor(n * this._frameRate); + d = this._frameIndices[c.frameIndicesOffset + p]; + this.currentPlayTimes === s && d === _ && (d = -1); + } + for (;d >= 0; ) { + var m = this._animationData.frameOffset + this._timelineArray[c.offset + 5 + d]; + var f = this._frameArray[m] / this._frameRate; + this._position <= f && f <= this._position + this._duration && this._onCrossFrame(d); + if (null !== l && 0 === d) { + this._armature._dragonBones.bufferEvent(l); + l = null; + } + d > 0 ? d-- : d = this._frameCount - 1; + if (d === _) break; + } + } else { + if (d < 0) { + p = Math.floor(n * this._frameRate); + d = this._frameIndices[c.frameIndicesOffset + p]; + m = this._animationData.frameOffset + this._timelineArray[c.offset + 5 + d]; + f = this._frameArray[m] / this._frameRate; + this.currentPlayTimes === s && (n <= f ? d > 0 ? d-- : d = this._frameCount - 1 : d === _ && (d = -1)); + } + for (;d >= 0; ) { + d < this._frameCount - 1 ? d++ : d = 0; + m = this._animationData.frameOffset + this._timelineArray[c.offset + 5 + d]; + f = this._frameArray[m] / this._frameRate; + this._position <= f && f <= this._position + this._duration && this._onCrossFrame(d); + if (null !== l && 0 === d) { + this._armature._dragonBones.bufferEvent(l); + l = null; + } + if (d === _) break; + } + } + } + } + } else if (this._frameIndex < 0) { + this._frameIndex = 0; + if (null !== this._timelineData) { + this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5]; + f = this._frameArray[this._frameOffset] / this._frameRate; + if (this.currentPlayTimes === s) n <= f && this._onCrossFrame(this._frameIndex); else if (this._position <= f) { + if (!a && null !== l) { + this._armature._dragonBones.bufferEvent(l); + l = null; + } + this._onCrossFrame(this._frameIndex); + } + } + } + null !== l && this._armature._dragonBones.bufferEvent(l); + null !== h && this._armature._dragonBones.bufferEvent(h); + } + }; + i.prototype.setCurrentTime = function(t) { + this._setCurrentTime(t); + this._frameIndex = -1; + }; + return i; + }(t.TimelineState); + t.ActionTimelineState = e; + var i = function(t) { + r5(e, t); + function e() { + return null !== t && t.apply(this, arguments) || this; + } + e.toString = function() { + return "[class dragonBones.ZOrderTimelineState]"; + }; + e.prototype._onArriveAtFrame = function() { + if (this.playState >= 0) { + this._frameArray[this._frameOffset + 1] > 0 ? this._armature._sortZOrder(this._frameArray, this._frameOffset + 2) : this._armature._sortZOrder(null, 0); + } + }; + e.prototype._onUpdateFrame = function() {}; + return e; + }(t.TimelineState); + t.ZOrderTimelineState = i; + var s = function(e) { + r5(i, e); + function i() { + return null !== e && e.apply(this, arguments) || this; + } + i.toString = function() { + return "[class dragonBones.BoneAllTimelineState]"; + }; + i.prototype._onArriveAtFrame = function() { + e.prototype._onArriveAtFrame.call(this); + if (null !== this._timelineData) { + var t = this._animationData.frameFloatOffset + this._frameValueOffset + 6 * this._frameIndex; + var i = this._armature._armatureData.scale; + var s = this._frameFloatArray; + var n = this.bonePose.current; + var r = this.bonePose.delta; + n.x = s[t++] * i; + n.y = s[t++] * i; + n.rotation = s[t++]; + n.skew = s[t++]; + n.scaleX = s[t++]; + n.scaleY = s[t++]; + if (2 === this._tweenState) { + this._frameIndex === this._frameCount - 1 && (t = this._animationData.frameFloatOffset + this._frameValueOffset); + r.x = s[t++] * i - n.x; + r.y = s[t++] * i - n.y; + r.rotation = s[t++] - n.rotation; + r.skew = s[t++] - n.skew; + r.scaleX = s[t++] - n.scaleX; + r.scaleY = s[t++] - n.scaleY; + } else { + r.x = 0; + r.y = 0; + r.rotation = 0; + r.skew = 0; + r.scaleX = 0; + r.scaleY = 0; + } + } else { + n = this.bonePose.current; + r = this.bonePose.delta; + n.x = 0; + n.y = 0; + n.rotation = 0; + n.skew = 0; + n.scaleX = 1; + n.scaleY = 1; + r.x = 0; + r.y = 0; + r.rotation = 0; + r.skew = 0; + r.scaleX = 0; + r.scaleY = 0; + } + }; + i.prototype._onUpdateFrame = function() { + e.prototype._onUpdateFrame.call(this); + var t = this.bonePose.current; + var i = this.bonePose.delta; + var s = this.bonePose.result; + this.bone._transformDirty = !0; + 2 !== this._tweenState && (this._tweenState = 0); + s.x = t.x + i.x * this._tweenProgress; + s.y = t.y + i.y * this._tweenProgress; + s.rotation = t.rotation + i.rotation * this._tweenProgress; + s.skew = t.skew + i.skew * this._tweenProgress; + s.scaleX = t.scaleX + i.scaleX * this._tweenProgress; + s.scaleY = t.scaleY + i.scaleY * this._tweenProgress; + }; + i.prototype.fadeOut = function() { + var e = this.bonePose.result; + e.rotation = t.Transform.normalizeRadian(e.rotation); + e.skew = t.Transform.normalizeRadian(e.skew); + }; + return i; + }(t.BoneTimelineState); + t.BoneAllTimelineState = s; + var n = function(t) { + r5(e, t); + function e() { + return null !== t && t.apply(this, arguments) || this; + } + e.toString = function() { + return "[class dragonBones.BoneTranslateTimelineState]"; + }; + e.prototype._onArriveAtFrame = function() { + t.prototype._onArriveAtFrame.call(this); + if (null !== this._timelineData) { + var e = this._animationData.frameFloatOffset + this._frameValueOffset + 2 * this._frameIndex; + var i = this._armature._armatureData.scale; + var s = this._frameFloatArray; + var n = this.bonePose.current; + var r = this.bonePose.delta; + n.x = s[e++] * i; + n.y = s[e++] * i; + if (2 === this._tweenState) { + this._frameIndex === this._frameCount - 1 && (e = this._animationData.frameFloatOffset + this._frameValueOffset); + r.x = s[e++] * i - n.x; + r.y = s[e++] * i - n.y; + } else { + r.x = 0; + r.y = 0; + } + } else { + n = this.bonePose.current; + r = this.bonePose.delta; + n.x = 0; + n.y = 0; + r.x = 0; + r.y = 0; + } + }; + e.prototype._onUpdateFrame = function() { + t.prototype._onUpdateFrame.call(this); + var e = this.bonePose.current; + var i = this.bonePose.delta; + var s = this.bonePose.result; + this.bone._transformDirty = !0; + 2 !== this._tweenState && (this._tweenState = 0); + s.x = e.x + i.x * this._tweenProgress; + s.y = e.y + i.y * this._tweenProgress; + }; + return e; + }(t.BoneTimelineState); + t.BoneTranslateTimelineState = n; + var r = function(e) { + r5(i, e); + function i() { + return null !== e && e.apply(this, arguments) || this; + } + i.toString = function() { + return "[class dragonBones.BoneRotateTimelineState]"; + }; + i.prototype._onArriveAtFrame = function() { + e.prototype._onArriveAtFrame.call(this); + if (null !== this._timelineData) { + var i = this._animationData.frameFloatOffset + this._frameValueOffset + 2 * this._frameIndex; + var s = this._frameFloatArray; + var n = this.bonePose.current; + var r = this.bonePose.delta; + n.rotation = s[i++]; + n.skew = s[i++]; + if (2 === this._tweenState) { + if (this._frameIndex === this._frameCount - 1) { + i = this._animationData.frameFloatOffset + this._frameValueOffset; + r.rotation = t.Transform.normalizeRadian(s[i++] - n.rotation); + } else r.rotation = s[i++] - n.rotation; + r.skew = s[i++] - n.skew; + } else { + r.rotation = 0; + r.skew = 0; + } + } else { + n = this.bonePose.current; + r = this.bonePose.delta; + n.rotation = 0; + n.skew = 0; + r.rotation = 0; + r.skew = 0; + } + }; + i.prototype._onUpdateFrame = function() { + e.prototype._onUpdateFrame.call(this); + var t = this.bonePose.current; + var i = this.bonePose.delta; + var s = this.bonePose.result; + this.bone._transformDirty = !0; + 2 !== this._tweenState && (this._tweenState = 0); + s.rotation = t.rotation + i.rotation * this._tweenProgress; + s.skew = t.skew + i.skew * this._tweenProgress; + }; + i.prototype.fadeOut = function() { + var e = this.bonePose.result; + e.rotation = t.Transform.normalizeRadian(e.rotation); + e.skew = t.Transform.normalizeRadian(e.skew); + }; + return i; + }(t.BoneTimelineState); + t.BoneRotateTimelineState = r; + var o = function(t) { + r5(e, t); + function e() { + return null !== t && t.apply(this, arguments) || this; + } + e.toString = function() { + return "[class dragonBones.BoneScaleTimelineState]"; + }; + e.prototype._onArriveAtFrame = function() { + t.prototype._onArriveAtFrame.call(this); + if (null !== this._timelineData) { + var e = this._animationData.frameFloatOffset + this._frameValueOffset + 2 * this._frameIndex; + var i = this._frameFloatArray; + var s = this.bonePose.current; + var n = this.bonePose.delta; + s.scaleX = i[e++]; + s.scaleY = i[e++]; + if (2 === this._tweenState) { + this._frameIndex === this._frameCount - 1 && (e = this._animationData.frameFloatOffset + this._frameValueOffset); + n.scaleX = i[e++] - s.scaleX; + n.scaleY = i[e++] - s.scaleY; + } else { + n.scaleX = 0; + n.scaleY = 0; + } + } else { + s = this.bonePose.current; + n = this.bonePose.delta; + s.scaleX = 1; + s.scaleY = 1; + n.scaleX = 0; + n.scaleY = 0; + } + }; + e.prototype._onUpdateFrame = function() { + t.prototype._onUpdateFrame.call(this); + var e = this.bonePose.current; + var i = this.bonePose.delta; + var s = this.bonePose.result; + this.bone._transformDirty = !0; + 2 !== this._tweenState && (this._tweenState = 0); + s.scaleX = e.scaleX + i.scaleX * this._tweenProgress; + s.scaleY = e.scaleY + i.scaleY * this._tweenProgress; + }; + return e; + }(t.BoneTimelineState); + t.BoneScaleTimelineState = o; + var a = function(t) { + r5(e, t); + function e() { + var e = null !== t && t.apply(this, arguments) || this; + e._current = []; + e._delta = []; + e._result = []; + return e; + } + e.toString = function() { + return "[class dragonBones.SurfaceTimelineState]"; + }; + e.prototype._onClear = function() { + t.prototype._onClear.call(this); + this.surface = null; + this._frameFloatOffset = 0; + this._valueCount = 0; + this._deformCount = 0; + this._valueOffset = 0; + this._current.length = 0; + this._delta.length = 0; + this._result.length = 0; + }; + e.prototype._onArriveAtFrame = function() { + t.prototype._onArriveAtFrame.call(this); + if (null !== this._timelineData) { + var e = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * this._valueCount; + var i = this._armature._armatureData.scale; + var s = this._frameFloatArray; + if (2 === this._tweenState) { + var n = e + this._valueCount; + this._frameIndex === this._frameCount - 1 && (n = this._animationData.frameFloatOffset + this._frameValueOffset); + for (var r = 0; r < this._valueCount; ++r) this._delta[r] = s[n + r] * i - (this._current[r] = s[e + r] * i); + } else for (r = 0; r < this._valueCount; ++r) this._current[r] = s[e + r] * i; + } else for (r = 0; r < this._valueCount; ++r) this._current[r] = 0; + }; + e.prototype._onUpdateFrame = function() { + t.prototype._onUpdateFrame.call(this); + this.surface._transformDirty = !0; + 2 !== this._tweenState && (this._tweenState = 0); + for (var e = 0; e < this._valueCount; ++e) this._result[e] = this._current[e] + this._delta[e] * this._tweenProgress; + }; + e.prototype.init = function(e, i, s) { + t.prototype.init.call(this, e, i, s); + if (null !== this._timelineData) { + var n = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3]; + this._deformCount = this._frameIntArray[n + 1]; + this._valueCount = this._frameIntArray[n + 2]; + this._valueOffset = this._frameIntArray[n + 3]; + this._frameFloatOffset = this._frameIntArray[n + 4] + this._animationData.frameFloatOffset; + } else { + this._deformCount = this.surface._deformVertices.length; + this._valueCount = this._deformCount; + this._valueOffset = 0; + this._frameFloatOffset = 0; + } + this._current.length = this._valueCount; + this._delta.length = this._valueCount; + this._result.length = this._valueCount; + for (var r = 0; r < this._valueCount; ++r) this._delta[r] = 0; + }; + e.prototype.blend = function(t) { + var e = this.surface._blendState.blendWeight; + var i = this.surface._deformVertices; + for (var s = 0; s < this._deformCount; ++s) { + var n = 0; + n = s < this._valueOffset ? this._frameFloatArray[this._frameFloatOffset + s] : s < this._valueOffset + this._valueCount ? this._result[s - this._valueOffset] : this._frameFloatArray[this._frameFloatOffset + s - this._valueCount]; + 2 === t ? i[s] += n * e : i[s] = 1 !== e ? n * e : n; + } + 0 === this._animationState._fadeState && 0 === this._animationState._subFadeState || (this.surface._transformDirty = !0); + }; + return e; + }(t.TweenTimelineState); + t.SurfaceTimelineState = a; + var l = function(t) { + r5(e, t); + function e() { + return null !== t && t.apply(this, arguments) || this; + } + e.toString = function() { + return "[class dragonBones.SlotDislayTimelineState]"; + }; + e.prototype._onArriveAtFrame = function() { + if (this.playState >= 0) { + var t = null !== this._timelineData ? this._frameArray[this._frameOffset + 1] : this.slot._slotData.displayIndex; + this.slot.displayIndex !== t && this.slot._setDisplayIndex(t, !0); + } + }; + return e; + }(t.SlotTimelineState); + t.SlotDislayTimelineState = l; + var h = function(t) { + r5(e, t); + function e() { + var e = null !== t && t.apply(this, arguments) || this; + e._current = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; + e._delta = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; + e._result = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; + return e; + } + e.toString = function() { + return "[class dragonBones.SlotColorTimelineState]"; + }; + e.prototype._onClear = function() { + t.prototype._onClear.call(this); + this._dirty = !1; + }; + e.prototype._onArriveAtFrame = function() { + t.prototype._onArriveAtFrame.call(this); + if (null !== this._timelineData) { + var e = this._dragonBonesData.intArray; + var i = this._frameIntArray; + var s = this._animationData.frameIntOffset + this._frameValueOffset + 1 * this._frameIndex; + var n = i[s]; + n < 0 && (n += 65536); + this._current[0] = e[n++]; + this._current[1] = e[n++]; + this._current[2] = e[n++]; + this._current[3] = e[n++]; + this._current[4] = e[n++]; + this._current[5] = e[n++]; + this._current[6] = e[n++]; + this._current[7] = e[n++]; + if (2 === this._tweenState) { + (n = this._frameIndex === this._frameCount - 1 ? i[this._animationData.frameIntOffset + this._frameValueOffset] : i[s + 1]) < 0 && (n += 65536); + this._delta[0] = e[n++] - this._current[0]; + this._delta[1] = e[n++] - this._current[1]; + this._delta[2] = e[n++] - this._current[2]; + this._delta[3] = e[n++] - this._current[3]; + this._delta[4] = e[n++] - this._current[4]; + this._delta[5] = e[n++] - this._current[5]; + this._delta[6] = e[n++] - this._current[6]; + this._delta[7] = e[n++] - this._current[7]; + } + } else { + var r = this.slot._slotData.color; + this._current[0] = 100 * r.alphaMultiplier; + this._current[1] = 100 * r.redMultiplier; + this._current[2] = 100 * r.greenMultiplier; + this._current[3] = 100 * r.blueMultiplier; + this._current[4] = r.alphaOffset; + this._current[5] = r.redOffset; + this._current[6] = r.greenOffset; + this._current[7] = r.blueOffset; + } + }; + e.prototype._onUpdateFrame = function() { + t.prototype._onUpdateFrame.call(this); + this._dirty = !0; + 2 !== this._tweenState && (this._tweenState = 0); + this._result[0] = .01 * (this._current[0] + this._delta[0] * this._tweenProgress); + this._result[1] = .01 * (this._current[1] + this._delta[1] * this._tweenProgress); + this._result[2] = .01 * (this._current[2] + this._delta[2] * this._tweenProgress); + this._result[3] = .01 * (this._current[3] + this._delta[3] * this._tweenProgress); + this._result[4] = this._current[4] + this._delta[4] * this._tweenProgress; + this._result[5] = this._current[5] + this._delta[5] * this._tweenProgress; + this._result[6] = this._current[6] + this._delta[6] * this._tweenProgress; + this._result[7] = this._current[7] + this._delta[7] * this._tweenProgress; + }; + e.prototype.fadeOut = function() { + this._tweenState = 0; + this._dirty = !1; + }; + e.prototype.update = function(e) { + t.prototype.update.call(this, e); + if (0 !== this._tweenState || this._dirty) { + var i = this.slot._colorTransform; + if (0 !== this._animationState._fadeState || 0 !== this._animationState._subFadeState) { + if (i.alphaMultiplier !== this._result[0] || i.redMultiplier !== this._result[1] || i.greenMultiplier !== this._result[2] || i.blueMultiplier !== this._result[3] || i.alphaOffset !== this._result[4] || i.redOffset !== this._result[5] || i.greenOffset !== this._result[6] || i.blueOffset !== this._result[7]) { + var s = Math.pow(this._animationState._fadeProgress, 4); + i.alphaMultiplier += (this._result[0] - i.alphaMultiplier) * s; + i.redMultiplier += (this._result[1] - i.redMultiplier) * s; + i.greenMultiplier += (this._result[2] - i.greenMultiplier) * s; + i.blueMultiplier += (this._result[3] - i.blueMultiplier) * s; + i.alphaOffset += (this._result[4] - i.alphaOffset) * s; + i.redOffset += (this._result[5] - i.redOffset) * s; + i.greenOffset += (this._result[6] - i.greenOffset) * s; + i.blueOffset += (this._result[7] - i.blueOffset) * s; + this.slot._colorDirty = !0; + } + } else if (this._dirty) { + this._dirty = !1; + if (i.alphaMultiplier !== this._result[0] || i.redMultiplier !== this._result[1] || i.greenMultiplier !== this._result[2] || i.blueMultiplier !== this._result[3] || i.alphaOffset !== this._result[4] || i.redOffset !== this._result[5] || i.greenOffset !== this._result[6] || i.blueOffset !== this._result[7]) { + i.alphaMultiplier = this._result[0]; + i.redMultiplier = this._result[1]; + i.greenMultiplier = this._result[2]; + i.blueMultiplier = this._result[3]; + i.alphaOffset = this._result[4]; + i.redOffset = this._result[5]; + i.greenOffset = this._result[6]; + i.blueOffset = this._result[7]; + this.slot._colorDirty = !0; + } + } + } + }; + return e; + }(t.SlotTimelineState); + t.SlotColorTimelineState = h; + var c = function(t) { + r5(e, t); + function e() { + var e = null !== t && t.apply(this, arguments) || this; + e._current = []; + e._delta = []; + e._result = []; + return e; + } + e.toString = function() { + return "[class dragonBones.DeformTimelineState]"; + }; + e.prototype._onClear = function() { + t.prototype._onClear.call(this); + this.vertexOffset = 0; + this._dirty = !1; + this._frameFloatOffset = 0; + this._valueCount = 0; + this._deformCount = 0; + this._valueOffset = 0; + this._current.length = 0; + this._delta.length = 0; + this._result.length = 0; + }; + e.prototype._onArriveAtFrame = function() { + t.prototype._onArriveAtFrame.call(this); + if (null !== this._timelineData) { + var e = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * this._valueCount; + var i = this._armature._armatureData.scale; + var s = this._frameFloatArray; + if (2 === this._tweenState) { + var n = e + this._valueCount; + this._frameIndex === this._frameCount - 1 && (n = this._animationData.frameFloatOffset + this._frameValueOffset); + for (var r = 0; r < this._valueCount; ++r) this._delta[r] = s[n + r] * i - (this._current[r] = s[e + r] * i); + } else for (r = 0; r < this._valueCount; ++r) this._current[r] = s[e + r] * i; + } else for (r = 0; r < this._valueCount; ++r) this._current[r] = 0; + }; + e.prototype._onUpdateFrame = function() { + t.prototype._onUpdateFrame.call(this); + this._dirty = !0; + 2 !== this._tweenState && (this._tweenState = 0); + for (var e = 0; e < this._valueCount; ++e) this._result[e] = this._current[e] + this._delta[e] * this._tweenProgress; + }; + e.prototype.init = function(e, i, s) { + t.prototype.init.call(this, e, i, s); + if (null !== this._timelineData) { + var n = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3]; + this.vertexOffset = this._frameIntArray[n + 0]; + this.vertexOffset < 0 && (this.vertexOffset += 65536); + this._deformCount = this._frameIntArray[n + 1]; + this._valueCount = this._frameIntArray[n + 2]; + this._valueOffset = this._frameIntArray[n + 3]; + this._frameFloatOffset = this._frameIntArray[n + 4] + this._animationData.frameFloatOffset; + } else { + var r = this.slot._deformVertices; + this._deformCount = null !== r ? r.vertices.length : 0; + this._valueCount = this._deformCount; + this._valueOffset = 0; + this._frameFloatOffset = 0; + } + this._current.length = this._valueCount; + this._delta.length = this._valueCount; + this._result.length = this._valueCount; + for (var o = 0; o < this._valueCount; ++o) this._delta[o] = 0; + }; + e.prototype.fadeOut = function() { + this._tweenState = 0; + this._dirty = !1; + }; + e.prototype.update = function(e) { + var i = this.slot._deformVertices; + if (null !== i && null !== i.verticesData && i.verticesData.offset === this.vertexOffset) { + t.prototype.update.call(this, e); + if (0 !== this._tweenState || this._dirty) { + var s = i.vertices; + if (0 !== this._animationState._fadeState || 0 !== this._animationState._subFadeState) { + var n = Math.pow(this._animationState._fadeProgress, 2); + for (var r = 0; r < this._deformCount; ++r) r < this._valueOffset ? s[r] += (this._frameFloatArray[this._frameFloatOffset + r] - s[r]) * n : r < this._valueOffset + this._valueCount ? s[r] += (this._result[r - this._valueOffset] - s[r]) * n : s[r] += (this._frameFloatArray[this._frameFloatOffset + r - this._valueCount] - s[r]) * n; + i.verticesDirty = !0; + } else if (this._dirty) { + this._dirty = !1; + for (r = 0; r < this._deformCount; ++r) r < this._valueOffset ? s[r] = this._frameFloatArray[this._frameFloatOffset + r] : r < this._valueOffset + this._valueCount ? s[r] = this._result[r - this._valueOffset] : s[r] = this._frameFloatArray[this._frameFloatOffset + r - this._valueCount]; + i.verticesDirty = !0; + } + } + } + }; + return e; + }(t.SlotTimelineState); + t.DeformTimelineState = c; + var u = function(t) { + r5(e, t); + function e() { + return null !== t && t.apply(this, arguments) || this; + } + e.toString = function() { + return "[class dragonBones.IKConstraintTimelineState]"; + }; + e.prototype._onClear = function() { + t.prototype._onClear.call(this); + this._current = 0; + this._delta = 0; + }; + e.prototype._onArriveAtFrame = function() { + t.prototype._onArriveAtFrame.call(this); + var e = this.constraint; + if (null !== this._timelineData) { + var i = this._animationData.frameIntOffset + this._frameValueOffset + 2 * this._frameIndex; + var s = this._frameIntArray; + var n = 0 !== s[i++]; + this._current = .01 * s[i++]; + if (2 === this._tweenState) { + this._frameIndex === this._frameCount - 1 && (i = this._animationData.frameIntOffset + this._frameValueOffset); + this._delta = .01 * s[i + 1] - this._current; + } else this._delta = 0; + e._bendPositive = n; + } else { + var r = e._constraintData; + this._current = r.weight; + this._delta = 0; + e._bendPositive = r.bendPositive; + } + e.invalidUpdate(); + }; + e.prototype._onUpdateFrame = function() { + t.prototype._onUpdateFrame.call(this); + 2 !== this._tweenState && (this._tweenState = 0); + var e = this.constraint; + e._weight = this._current + this._delta * this._tweenProgress; + e.invalidUpdate(); + }; + return e; + }(t.ConstraintTimelineState); + t.IKConstraintTimelineState = u; + var _ = function(t) { + r5(e, t); + function e() { + var e = null !== t && t.apply(this, arguments) || this; + e._floats = [ 0, 0, 0, 0, 0, 0 ]; + return e; + } + e.toString = function() { + return "[class dragonBones.AnimationTimelineState]"; + }; + e.prototype._onClear = function() { + t.prototype._onClear.call(this); + this.animationState = null; + }; + e.prototype._onArriveAtFrame = function() { + t.prototype._onArriveAtFrame.call(this); + if (null !== this._timelineData) { + var e = this._animationData.frameIntOffset + this._frameValueOffset + 2 * this._frameIndex; + var i = 1 / this.animationState._animationData.parent.frameRate; + var s = this._frameIntArray; + this._floats[0] = s[e++] * i; + this._floats[3] = .01 * s[e++]; + if (2 === this._tweenState) { + this._frameIndex === this._frameCount - 1 && (e = this._animationData.frameIntOffset + this._frameValueOffset); + this._floats[1] = s[e++] * i - this._floats[0]; + this._floats[4] = .01 * s[e++] - this._floats[3]; + } else { + this._floats[1] = 0; + this._floats[4] = 0; + } + } + }; + e.prototype._onUpdateFrame = function() { + t.prototype._onUpdateFrame.call(this); + 2 !== this._tweenState && (this._tweenState = 0); + this._floats[0] >= 0 && (this._floats[2] = this._floats[0] + this._floats[1] * this._tweenProgress); + this._floats[5] = this._floats[3] + this._floats[4] * this._tweenProgress; + }; + e.prototype.blend = function(t) { + var e = this.animationState; + var i = e._blendState.blendWeight; + if (2 === t) { + e.weight += this._floats[5] * i; + e.currentTime += this._floats[2] * i; + } else { + e.weight = this._floats[5] * i; + e.currentTime = this._floats[2] * i; + } + }; + return e; + }(t.TweenTimelineState); + t.AnimationTimelineState = _; + }(a5 || (a5 = {})); + !function(t) { + var e = function(t) { + r5(e, t); + function e() { + return null !== t && t.apply(this, arguments) || this; + } + e.actionDataToInstance = function(t, i, s) { + 0 === t.type ? i.type = e.FRAME_EVENT : i.type = 10 === t.type ? e.FRAME_EVENT : e.SOUND_EVENT; + i.name = t.name; + i.armature = s; + i.actionData = t; + i.data = t.data; + null !== t.bone && (i.bone = s.getBone(t.bone.name)); + null !== t.slot && (i.slot = s.getSlot(t.slot.name)); + }; + e.toString = function() { + return "[class dragonBones.EventObject]"; + }; + e.prototype._onClear = function() { + this.time = 0; + this.type = ""; + this.name = ""; + this.armature = null; + this.bone = null; + this.slot = null; + this.animationState = null; + this.actionData = null; + this.data = null; + }; + e.START = "start"; + e.LOOP_COMPLETE = "loopComplete"; + e.COMPLETE = "complete"; + e.FADE_IN = "fadeIn"; + e.FADE_IN_COMPLETE = "fadeInComplete"; + e.FADE_OUT = "fadeOut"; + e.FADE_OUT_COMPLETE = "fadeOutComplete"; + e.FRAME_EVENT = "frameEvent"; + e.SOUND_EVENT = "soundEvent"; + return e; + }(t.BaseObject); + t.EventObject = e; + }(a5 || (a5 = {})); + !function(t) { + var e = function() { + function e() {} + e._getArmatureType = function(t) { + switch (t.toLowerCase()) { + case "stage": + return 2; + + case "armature": + default: + return 0; + + case "movieclip": + return 1; + } + }; + e._getBoneType = function(t) { + switch (t.toLowerCase()) { + case "bone": + default: + return 0; + + case "surface": + return 1; + } + }; + e._getDisplayType = function(t) { + switch (t.toLowerCase()) { + case "image": + default: + return 0; + + case "mesh": + return 2; + + case "armature": + return 1; + + case "boundingbox": + return 3; + + case "path": + return 4; + } + }; + e._getBoundingBoxType = function(t) { + switch (t.toLowerCase()) { + case "rectangle": + default: + return 0; + + case "ellipse": + return 1; + + case "polygon": + return 2; + } + }; + e._getActionType = function(t) { + switch (t.toLowerCase()) { + case "play": + default: + return 0; + + case "frame": + return 10; + + case "sound": + return 11; + } + }; + e._getBlendMode = function(t) { + switch (t.toLowerCase()) { + case "normal": + default: + return 0; + + case "add": + return 1; + + case "alpha": + return 2; + + case "darken": + return 3; + + case "difference": + return 4; + + case "erase": + return 5; + + case "hardlight": + return 6; + + case "invert": + return 7; + + case "layer": + return 8; + + case "lighten": + return 9; + + case "multiply": + return 10; + + case "overlay": + return 11; + + case "screen": + return 12; + + case "subtract": + return 13; + } + }; + e._getPositionMode = function(t) { + switch (t.toLocaleLowerCase()) { + case "percent": + default: + return 1; + + case "fixed": + return 0; + } + }; + e._getSpacingMode = function(t) { + switch (t.toLocaleLowerCase()) { + case "length": + default: + return 0; + + case "percent": + return 2; + + case "fixed": + return 1; + } + }; + e._getRotateMode = function(t) { + switch (t.toLocaleLowerCase()) { + case "tangent": + default: + return 0; + + case "chain": + return 1; + + case "chainscale": + return 2; + } + }; + e.parseDragonBonesData = function(e) { + console.warn("Deprecated."); + return e instanceof ArrayBuffer ? t.BinaryDataParser.getInstance().parseDragonBonesData(e) : t.ObjectDataParser.getInstance().parseDragonBonesData(e); + }; + e.parseTextureAtlasData = function(i, s) { + void 0 === s && (s = 1); + console.warn("已废弃"); + var n = {}; + var r = i[e.SUB_TEXTURE]; + for (var o = 0, a = r.length; o < a; o++) { + var l = r[o]; + var h = l[e.NAME]; + var c = new t.Rectangle; + var u = null; + c.x = l[e.X] / s; + c.y = l[e.Y] / s; + c.width = l[e.WIDTH] / s; + c.height = l[e.HEIGHT] / s; + if (e.FRAME_WIDTH in l) { + (u = new t.Rectangle).x = l[e.FRAME_X] / s; + u.y = l[e.FRAME_Y] / s; + u.width = l[e.FRAME_WIDTH] / s; + u.height = l[e.FRAME_HEIGHT] / s; + } + n[h] = { + region: c, + frame: u, + rotated: !1 + }; + } + return n; + }; + e.DATA_VERSION_2_3 = "2.3"; + e.DATA_VERSION_3_0 = "3.0"; + e.DATA_VERSION_4_0 = "4.0"; + e.DATA_VERSION_4_5 = "4.5"; + e.DATA_VERSION_5_0 = "5.0"; + e.DATA_VERSION_5_5 = "5.5"; + e.DATA_VERSION = e.DATA_VERSION_5_5; + e.DATA_VERSIONS = [ e.DATA_VERSION_4_0, e.DATA_VERSION_4_5, e.DATA_VERSION_5_0, e.DATA_VERSION_5_5 ]; + e.TEXTURE_ATLAS = "textureAtlas"; + e.SUB_TEXTURE = "SubTexture"; + e.FORMAT = "format"; + e.IMAGE_PATH = "imagePath"; + e.WIDTH = "width"; + e.HEIGHT = "height"; + e.ROTATED = "rotated"; + e.FRAME_X = "frameX"; + e.FRAME_Y = "frameY"; + e.FRAME_WIDTH = "frameWidth"; + e.FRAME_HEIGHT = "frameHeight"; + e.DRADON_BONES = "dragonBones"; + e.USER_DATA = "userData"; + e.ARMATURE = "armature"; + e.BONE = "bone"; + e.SURFACE = "surface"; + e.SLOT = "slot"; + e.CONSTRAINT = "constraint"; + e.IK = "ik"; + e.PATH_CONSTRAINT = "path"; + e.SKIN = "skin"; + e.DISPLAY = "display"; + e.ANIMATION = "animation"; + e.Z_ORDER = "zOrder"; + e.FFD = "ffd"; + e.FRAME = "frame"; + e.TRANSLATE_FRAME = "translateFrame"; + e.ROTATE_FRAME = "rotateFrame"; + e.SCALE_FRAME = "scaleFrame"; + e.DISPLAY_FRAME = "displayFrame"; + e.COLOR_FRAME = "colorFrame"; + e.DEFAULT_ACTIONS = "defaultActions"; + e.ACTIONS = "actions"; + e.EVENTS = "events"; + e.INTS = "ints"; + e.FLOATS = "floats"; + e.STRINGS = "strings"; + e.CANVAS = "canvas"; + e.TRANSFORM = "transform"; + e.PIVOT = "pivot"; + e.AABB = "aabb"; + e.COLOR = "color"; + e.VERSION = "version"; + e.COMPATIBLE_VERSION = "compatibleVersion"; + e.FRAME_RATE = "frameRate"; + e.TYPE = "type"; + e.SUB_TYPE = "subType"; + e.NAME = "name"; + e.PARENT = "parent"; + e.TARGET = "target"; + e.STAGE = "stage"; + e.SHARE = "share"; + e.PATH = "path"; + e.LENGTH = "length"; + e.DISPLAY_INDEX = "displayIndex"; + e.BLEND_MODE = "blendMode"; + e.INHERIT_TRANSLATION = "inheritTranslation"; + e.INHERIT_ROTATION = "inheritRotation"; + e.INHERIT_SCALE = "inheritScale"; + e.INHERIT_REFLECTION = "inheritReflection"; + e.INHERIT_ANIMATION = "inheritAnimation"; + e.INHERIT_DEFORM = "inheritDeform"; + e.SEGMENT_X = "segmentX"; + e.SEGMENT_Y = "segmentY"; + e.BEND_POSITIVE = "bendPositive"; + e.CHAIN = "chain"; + e.WEIGHT = "weight"; + e.FADE_IN_TIME = "fadeInTime"; + e.PLAY_TIMES = "playTimes"; + e.SCALE = "scale"; + e.OFFSET = "offset"; + e.POSITION = "position"; + e.DURATION = "duration"; + e.TWEEN_EASING = "tweenEasing"; + e.TWEEN_ROTATE = "tweenRotate"; + e.TWEEN_SCALE = "tweenScale"; + e.CLOCK_WISE = "clockwise"; + e.CURVE = "curve"; + e.SOUND = "sound"; + e.EVENT = "event"; + e.ACTION = "action"; + e.X = "x"; + e.Y = "y"; + e.SKEW_X = "skX"; + e.SKEW_Y = "skY"; + e.SCALE_X = "scX"; + e.SCALE_Y = "scY"; + e.VALUE = "value"; + e.ROTATE = "rotate"; + e.SKEW = "skew"; + e.ALPHA_OFFSET = "aO"; + e.RED_OFFSET = "rO"; + e.GREEN_OFFSET = "gO"; + e.BLUE_OFFSET = "bO"; + e.ALPHA_MULTIPLIER = "aM"; + e.RED_MULTIPLIER = "rM"; + e.GREEN_MULTIPLIER = "gM"; + e.BLUE_MULTIPLIER = "bM"; + e.UVS = "uvs"; + e.VERTICES = "vertices"; + e.TRIANGLES = "triangles"; + e.WEIGHTS = "weights"; + e.SLOT_POSE = "slotPose"; + e.BONE_POSE = "bonePose"; + e.GLUE_WEIGHTS = "glueWeights"; + e.GLUE_MESHES = "glueMeshes"; + e.BONES = "bones"; + e.POSITION_MODE = "positionMode"; + e.SPACING_MODE = "spacingMode"; + e.ROTATE_MODE = "rotateMode"; + e.SPACING = "spacing"; + e.ROTATE_OFFSET = "rotateOffset"; + e.ROTATE_MIX = "rotateMix"; + e.TRANSLATE_MIX = "translateMix"; + e.TARGET_DISPLAY = "targetDisplay"; + e.CLOSED = "closed"; + e.CONSTANT_SPEED = "constantSpeed"; + e.VERTEX_COUNT = "vertexCount"; + e.LENGTHS = "lengths"; + e.GOTO_AND_PLAY = "gotoAndPlay"; + e.DEFAULT_NAME = "default"; + return e; + }(); + t.DataParser = e; + }(a5 || (a5 = {})); + !function(t) { + var e = function(e) { + r5(s, e); + function s() { + var i = null !== e && e.apply(this, arguments) || this; + i._rawTextureAtlasIndex = 0; + i._rawBones = []; + i._data = null; + i._armature = null; + i._bone = null; + i._surface = null; + i._slot = null; + i._skin = null; + i._mesh = null; + i._animation = null; + i._timeline = null; + i._rawTextureAtlases = null; + i._defaultColorOffset = -1; + i._prevClockwise = 0; + i._prevRotation = 0; + i._helpMatrixA = new t.Matrix; + i._helpMatrixB = new t.Matrix; + i._helpTransform = new t.Transform; + i._helpColorTransform = new t.ColorTransform; + i._helpPoint = new t.Point; + i._helpArray = []; + i._intArray = []; + i._floatArray = []; + i._frameIntArray = []; + i._frameFloatArray = []; + i._frameArray = []; + i._timelineArray = []; + i._cacheRawMeshes = []; + i._cacheMeshes = []; + i._actionFrames = []; + i._weightSlotPose = {}; + i._weightBonePoses = {}; + i._cacheBones = {}; + i._slotChildActions = {}; + return i; + } + s._getBoolean = function(t, e, i) { + if (e in t) { + var s = t[e]; + var n = typeof s; + if ("boolean" === n) return s; + if ("string" !== n) return !!s; + switch (s) { + case "0": + case "NaN": + case "": + case "false": + case "null": + case "undefined": + return !1; + + default: + return !0; + } + } + return i; + }; + s._getNumber = function(t, e, i) { + if (e in t) { + var s = t[e]; + return null === s || "NaN" === s ? i : +s || 0; + } + return i; + }; + s._getString = function(e, i, s) { + if (i in e) { + var n = e[i]; + if ("string" === typeof n) { + if (t.DragonBones.webAssembly) for (var r = 0, o = n.length; r < o; ++r) if (n.charCodeAt(r) > 255) return encodeURI(n); + return n; + } + return String(n); + } + return s; + }; + s.prototype._getCurvePoint = function(t, e, i, s, n, r, o, a, l, h) { + var c = 1 - l; + var u = c * c; + var _ = l * l; + var d = c * u; + var p = 3 * l * u; + var m = 3 * c * _; + var f = l * _; + h.x = d * t + p * i + m * n + f * o; + h.y = d * e + p * s + m * r + f * a; + }; + s.prototype._samplingEasingCurve = function(t, e) { + var i = t.length; + var s = -2; + for (var n = 0, r = e.length; n < r; ++n) { + var o = (n + 1) / (r + 1); + for (;(s + 6 < i ? t[s + 6] : 1) < o; ) s += 6; + var a = s >= 0 && s + 6 < i; + var l = a ? t[s] : 0; + var h = a ? t[s + 1] : 0; + var c = t[s + 2]; + var u = t[s + 3]; + var _ = t[s + 4]; + var d = t[s + 5]; + var p = a ? t[s + 6] : 1; + var m = a ? t[s + 7] : 1; + var f = 0; + var g = 1; + for (;g - f > 1e-4; ) { + var y = .5 * (g + f); + this._getCurvePoint(l, h, c, u, _, d, p, m, y, this._helpPoint); + o - this._helpPoint.x > 0 ? f = y : g = y; + } + e[n] = this._helpPoint.y; + } + }; + s.prototype._parseActionDataInFrame = function(e, i, s, n) { + t.DataParser.EVENT in e && this._mergeActionFrame(e[t.DataParser.EVENT], i, 10, s, n); + t.DataParser.SOUND in e && this._mergeActionFrame(e[t.DataParser.SOUND], i, 11, s, n); + t.DataParser.ACTION in e && this._mergeActionFrame(e[t.DataParser.ACTION], i, 0, s, n); + t.DataParser.EVENTS in e && this._mergeActionFrame(e[t.DataParser.EVENTS], i, 10, s, n); + t.DataParser.ACTIONS in e && this._mergeActionFrame(e[t.DataParser.ACTIONS], i, 0, s, n); + }; + s.prototype._mergeActionFrame = function(e, s, n, r, o) { + var a = t.DragonBones.webAssembly ? this._armature.actions.size() : this._armature.actions.length; + var l = this._parseActionData(e, n, r, o); + var h = 0; + var c = null; + for (var u = 0, _ = l; u < _.length; u++) { + var d = _[u]; + this._armature.addAction(d, !1); + } + if (0 === this._actionFrames.length) { + (c = new i).frameStart = 0; + this._actionFrames.push(c); + c = null; + } + for (var p = 0, m = this._actionFrames; p < m.length; p++) { + var f = m[p]; + if (f.frameStart === s) { + c = f; + break; + } + if (f.frameStart > s) break; + h++; + } + if (null === c) { + (c = new i).frameStart = s; + this._actionFrames.splice(h + 1, 0, c); + } + for (var g = 0; g < l.length; ++g) c.actions.push(a + g); + }; + s.prototype._parseArmature = function(e, i) { + var n = t.BaseObject.borrowObject(t.ArmatureData); + n.name = s._getString(e, t.DataParser.NAME, ""); + n.frameRate = s._getNumber(e, t.DataParser.FRAME_RATE, this._data.frameRate); + n.scale = i; + t.DataParser.TYPE in e && "string" == typeof e[t.DataParser.TYPE] ? n.type = t.DataParser._getArmatureType(e[t.DataParser.TYPE]) : n.type = s._getNumber(e, t.DataParser.TYPE, 0); + 0 === n.frameRate && (n.frameRate = 24); + this._armature = n; + if (t.DataParser.CANVAS in e) { + var r = e[t.DataParser.CANVAS]; + var o = t.BaseObject.borrowObject(t.CanvasData); + t.DataParser.COLOR in r ? o.hasBackground = !0 : o.hasBackground = !1; + o.color = s._getNumber(r, t.DataParser.COLOR, 0); + o.x = s._getNumber(r, t.DataParser.X, 0) * n.scale; + o.y = s._getNumber(r, t.DataParser.Y, 0) * n.scale; + o.width = s._getNumber(r, t.DataParser.WIDTH, 0) * n.scale; + o.height = s._getNumber(r, t.DataParser.HEIGHT, 0) * n.scale; + n.canvas = o; + } + if (t.DataParser.AABB in e) { + var a = e[t.DataParser.AABB]; + n.aabb.x = s._getNumber(a, t.DataParser.X, 0) * n.scale; + n.aabb.y = s._getNumber(a, t.DataParser.Y, 0) * n.scale; + n.aabb.width = s._getNumber(a, t.DataParser.WIDTH, 0) * n.scale; + n.aabb.height = s._getNumber(a, t.DataParser.HEIGHT, 0) * n.scale; + } + if (t.DataParser.BONE in e) { + for (var l = 0, h = e[t.DataParser.BONE]; l < h.length; l++) { + var c = h[l]; + var u = s._getString(c, t.DataParser.PARENT, ""); + var _ = this._parseBone(c); + if (u.length > 0) { + var d = n.getBone(u); + if (null !== d) _.parent = d; else { + u in this._cacheBones || (this._cacheBones[u] = []); + this._cacheBones[u].push(_); + } + } + if (_.name in this._cacheBones) { + for (var p = 0, m = this._cacheBones[_.name]; p < m.length; p++) { + m[p].parent = _; + } + delete this._cacheBones[_.name]; + } + n.addBone(_); + this._rawBones.push(_); + } + } + if (t.DataParser.IK in e) { + for (var f = 0, g = e[t.DataParser.IK]; f < g.length; f++) { + var y = g[f]; + (I = this._parseIKConstraint(y)) && n.addConstraint(I); + } + } + n.sortBones(); + if (t.DataParser.SLOT in e) { + var b = 0; + for (var S = 0, A = e[t.DataParser.SLOT]; S < A.length; S++) { + var T = A[S]; + n.addSlot(this._parseSlot(T, b++)); + } + } + if (t.DataParser.SKIN in e) { + for (var v = 0, E = e[t.DataParser.SKIN]; v < E.length; v++) { + var C = E[v]; + n.addSkin(this._parseSkin(C)); + } + } + if (t.DataParser.PATH_CONSTRAINT in e) { + for (var x = 0, w = e[t.DataParser.PATH_CONSTRAINT]; x < w.length; x++) { + var R = w[x]; + var I; + (I = this._parsePathConstraint(R)) && n.addConstraint(I); + } + } + for (var M = 0, B = this._cacheRawMeshes.length; M < B; ++M) { + var D = this._cacheRawMeshes[M]; + t.DataParser.GLUE_WEIGHTS in D && t.DataParser.GLUE_MESHES in D && this._parseMeshGlue(D, this._cacheMeshes[M]); + } + for (M = 0, B = this._cacheRawMeshes.length; M < B; ++M) { + var P = this._cacheRawMeshes[M]; + var O = s._getString(P, t.DataParser.SHARE, ""); + if (0 !== O.length) { + var N = s._getString(P, t.DataParser.SKIN, t.DataParser.DEFAULT_NAME); + 0 === N.length && (N = t.DataParser.DEFAULT_NAME); + var L = n.getMesh(N, "", O); + if (null !== L) { + this._cacheMeshes[M].vertices.shareFrom(L.vertices); + } + } + } + if (t.DataParser.ANIMATION in e) { + for (var F = 0, V = e[t.DataParser.ANIMATION]; F < V.length; F++) { + var k = V[F]; + var U = this._parseAnimation(k); + n.addAnimation(U); + } + } + if (t.DataParser.DEFAULT_ACTIONS in e) { + for (var G = 0, z = this._parseActionData(e[t.DataParser.DEFAULT_ACTIONS], 0, null, null); G < z.length; G++) { + var H = z[G]; + n.addAction(H, !0); + if (0 === H.type) { + null !== (U = n.getAnimation(H.name)) && (n.defaultAnimation = U); + } + } + } + if (t.DataParser.ACTIONS in e) { + for (var j = 0, X = this._parseActionData(e[t.DataParser.ACTIONS], 0, null, null); j < X.length; j++) { + H = X[j]; + n.addAction(H, !1); + } + } + this._rawBones.length = 0; + this._cacheRawMeshes.length = 0; + this._cacheMeshes.length = 0; + this._armature = null; + for (var W in this._weightSlotPose) delete this._weightSlotPose[W]; + for (var W in this._weightBonePoses) delete this._weightBonePoses[W]; + for (var W in this._cacheBones) delete this._cacheBones[W]; + for (var W in this._slotChildActions) delete this._slotChildActions[W]; + return n; + }; + s.prototype._parseBone = function(e) { + var i = this._armature.scale; + if (0 === (t.DataParser.TYPE in e && "string" == typeof e[t.DataParser.TYPE] ? t.DataParser._getBoneType(e[t.DataParser.TYPE]) : s._getNumber(e, t.DataParser.TYPE, 0))) { + var n = t.BaseObject.borrowObject(t.BoneData); + n.inheritTranslation = s._getBoolean(e, t.DataParser.INHERIT_TRANSLATION, !0); + n.inheritRotation = s._getBoolean(e, t.DataParser.INHERIT_ROTATION, !0); + n.inheritScale = s._getBoolean(e, t.DataParser.INHERIT_SCALE, !0); + n.inheritReflection = s._getBoolean(e, t.DataParser.INHERIT_REFLECTION, !0); + n.length = s._getNumber(e, t.DataParser.LENGTH, 0) * i; + n.name = s._getString(e, t.DataParser.NAME, ""); + t.DataParser.TRANSFORM in e && this._parseTransform(e[t.DataParser.TRANSFORM], n.transform, i); + return n; + } + var r = t.BaseObject.borrowObject(t.SurfaceData); + r.name = s._getString(e, t.DataParser.NAME, ""); + r.segmentX = s._getNumber(e, t.DataParser.SEGMENT_X, 0); + r.segmentY = s._getNumber(e, t.DataParser.SEGMENT_Y, 0); + r.vertices.length = (r.segmentX + 1) * (r.segmentY + 1) * 2; + if (t.DataParser.VERTICES in e) { + var o = e[t.DataParser.VERTICES]; + for (var a = 0, l = r.vertices.length; a < l; ++a) a < o.length ? r.vertices[a] = o[a] * i : r.vertices[a] = 0; + } + return r; + }; + s.prototype._parseIKConstraint = function(e) { + var i = this._armature.getBone(s._getString(e, t.DataParser.BONE, "")); + if (null === i) return null; + var n = this._armature.getBone(s._getString(e, t.DataParser.TARGET, "")); + if (null === n) return null; + var r = t.BaseObject.borrowObject(t.IKConstraintData); + r.scaleEnabled = s._getBoolean(e, t.DataParser.SCALE, !1); + r.bendPositive = s._getBoolean(e, t.DataParser.BEND_POSITIVE, !0); + r.weight = s._getNumber(e, t.DataParser.WEIGHT, 1); + r.name = s._getString(e, t.DataParser.NAME, ""); + r.type = 0; + r.target = n; + if (s._getNumber(e, t.DataParser.CHAIN, 0) > 0 && null !== i.parent) { + r.root = i.parent; + r.bone = i; + } else { + r.root = i; + r.bone = null; + } + return r; + }; + s.prototype._parsePathConstraint = function(e) { + var i = this._armature.getSlot(s._getString(e, t.DataParser.TARGET, "")); + if (null === i) return null; + var n = this._armature.defaultSkin; + if (null === n) return null; + var r = n.getDisplay(i.name, s._getString(e, t.DataParser.TARGET_DISPLAY, i.name)); + if (null === r || !(r instanceof t.PathDisplayData)) return null; + var o = e[t.DataParser.BONES]; + if (null === o || 0 === o.length) return null; + var a = t.BaseObject.borrowObject(t.PathConstraintData); + a.name = s._getString(e, t.DataParser.NAME, ""); + a.type = 1; + a.pathSlot = i; + a.pathDisplayData = r; + a.target = i.parent; + a.positionMode = t.DataParser._getPositionMode(s._getString(e, t.DataParser.POSITION_MODE, "")); + a.spacingMode = t.DataParser._getSpacingMode(s._getString(e, t.DataParser.SPACING_MODE, "")); + a.rotateMode = t.DataParser._getRotateMode(s._getString(e, t.DataParser.ROTATE_MODE, "")); + a.position = s._getNumber(e, t.DataParser.POSITION, 0); + a.spacing = s._getNumber(e, t.DataParser.SPACING, 0); + a.rotateOffset = s._getNumber(e, t.DataParser.ROTATE_OFFSET, 0); + a.rotateMix = s._getNumber(e, t.DataParser.ROTATE_MIX, 1); + a.translateMix = s._getNumber(e, t.DataParser.TRANSLATE_MIX, 1); + for (var l = 0, h = o; l < h.length; l++) { + var c = h[l]; + var u = this._armature.getBone(c); + if (null !== u) { + a.AddBone(u); + null === a.root && (a.root = u); + } + } + return a; + }; + s.prototype._parseSlot = function(e, i) { + var n = t.BaseObject.borrowObject(t.SlotData); + n.displayIndex = s._getNumber(e, t.DataParser.DISPLAY_INDEX, 0); + n.zOrder = i; + n.name = s._getString(e, t.DataParser.NAME, ""); + n.parent = this._armature.getBone(s._getString(e, t.DataParser.PARENT, "")); + t.DataParser.BLEND_MODE in e && "string" == typeof e[t.DataParser.BLEND_MODE] ? n.blendMode = t.DataParser._getBlendMode(e[t.DataParser.BLEND_MODE]) : n.blendMode = s._getNumber(e, t.DataParser.BLEND_MODE, 0); + if (t.DataParser.COLOR in e) { + n.color = t.SlotData.createColor(); + this._parseColorTransform(e[t.DataParser.COLOR], n.color); + } else n.color = t.SlotData.DEFAULT_COLOR; + t.DataParser.ACTIONS in e && (this._slotChildActions[n.name] = this._parseActionData(e[t.DataParser.ACTIONS], 0, null, null)); + return n; + }; + s.prototype._parseSkin = function(e) { + var i = t.BaseObject.borrowObject(t.SkinData); + i.name = s._getString(e, t.DataParser.NAME, t.DataParser.DEFAULT_NAME); + 0 === i.name.length && (i.name = t.DataParser.DEFAULT_NAME); + if (t.DataParser.SLOT in e) { + var n = e[t.DataParser.SLOT]; + this._skin = i; + for (var r = 0, o = n; r < o.length; r++) { + var a = o[r]; + var l = s._getString(a, t.DataParser.NAME, ""); + var h = this._armature.getSlot(l); + if (null !== h) { + this._slot = h; + if (t.DataParser.DISPLAY in a) { + for (var c = 0, u = a[t.DataParser.DISPLAY]; c < u.length; c++) { + var _ = u[c]; + _ ? i.addDisplay(l, this._parseDisplay(_)) : i.addDisplay(l, null); + } + } + this._slot = null; + } + } + this._skin = null; + } + return i; + }; + s.prototype._parseDisplay = function(e) { + var i = s._getString(e, t.DataParser.NAME, ""); + var n = s._getString(e, t.DataParser.PATH, ""); + var r = 0; + var o = null; + switch (r = t.DataParser.TYPE in e && "string" == typeof e[t.DataParser.TYPE] ? t.DataParser._getDisplayType(e[t.DataParser.TYPE]) : s._getNumber(e, t.DataParser.TYPE, r)) { + case 0: + var a = o = t.BaseObject.borrowObject(t.ImageDisplayData); + a.name = i; + a.path = n.length > 0 ? n : i; + this._parsePivot(e, a); + break; + + case 1: + var l = o = t.BaseObject.borrowObject(t.ArmatureDisplayData); + l.name = i; + l.path = n.length > 0 ? n : i; + l.inheritAnimation = !0; + if (t.DataParser.ACTIONS in e) { + for (var h = 0, c = this._parseActionData(e[t.DataParser.ACTIONS], 0, null, null); h < c.length; h++) { + var u = c[h]; + l.addAction(u); + } + } else if (this._slot.name in this._slotChildActions) { + var _ = this._skin.getDisplays(this._slot.name); + if (null === _ ? 0 === this._slot.displayIndex : this._slot.displayIndex === _.length) { + for (var d = 0, p = this._slotChildActions[this._slot.name]; d < p.length; d++) { + u = p[d]; + l.addAction(u); + } + delete this._slotChildActions[this._slot.name]; + } + } + break; + + case 2: + var m = o = t.BaseObject.borrowObject(t.MeshDisplayData); + m.vertices.inheritDeform = s._getBoolean(e, t.DataParser.INHERIT_DEFORM, !0); + m.name = i; + m.path = n.length > 0 ? n : i; + m.vertices.data = this._data; + if (t.DataParser.SHARE in e) { + this._cacheRawMeshes.push(e); + this._cacheMeshes.push(m); + } else this._parseMesh(e, m); + if (t.DataParser.GLUE_WEIGHTS in e && t.DataParser.GLUE_MESHES in e) { + this._cacheRawMeshes.push(e); + this._cacheMeshes.push(m); + } + break; + + case 3: + var f = this._parseBoundingBox(e); + if (null !== f) { + var g = o = t.BaseObject.borrowObject(t.BoundingBoxDisplayData); + g.name = i; + g.path = n.length > 0 ? n : i; + g.boundingBox = f; + } + break; + + case 4: + var y = e[t.DataParser.LENGTHS]; + var b = o = t.BaseObject.borrowObject(t.PathDisplayData); + b.closed = s._getBoolean(e, t.DataParser.CLOSED, !1); + b.constantSpeed = s._getBoolean(e, t.DataParser.CONSTANT_SPEED, !1); + b.name = i; + b.path = n.length > 0 ? n : i; + b.vertices.data = this._data; + b.curveLengths.length = y.length; + for (var S = 0, A = y.length; S < A; ++S) b.curveLengths[S] = y[S]; + this._parsePath(e, b); + } + null !== o && t.DataParser.TRANSFORM in e && this._parseTransform(e[t.DataParser.TRANSFORM], o.transform, this._armature.scale); + return o; + }; + s.prototype._parsePath = function(e, i) { + var n = e[t.DataParser.VERTICES]; + var r = s._getNumber(e, t.DataParser.VERTEX_COUNT, 0); + var o = this._floatArray.length; + var a = this._intArray.length; + i.vertices.offset = a; + this._intArray.length += 2; + this._intArray[a + 0] = r; + this._intArray[a + 2] = o; + if (t.DataParser.WEIGHTS in e) { + var l = e[t.DataParser.WEIGHTS]; + var h = e[t.DataParser.BONES]; + var c = h.length; + var u = Math.floor(l.length - r) / 2; + var _ = this._intArray.length; + var d = this._floatArray.length; + var p = this._armature.sortedBones; + var m = t.BaseObject.borrowObject(t.WeightData); + m.count = u; + m.offset = _; + this._intArray.length += 2 + c + r + u; + this._intArray[_ + 0] = c; + this._intArray[_ + 1] = d; + for (R = 0; R < c; R++) { + var f = h[R]; + var g = this._rawBones[f]; + m.addBone(g); + this._intArray[_ + 2 + R] = p.indexOf(g); + } + this._floatArray.length += 3 * u; + R = 0; + for (var y = 0, b = 0, S = _ + 2 + c, A = d; R < u; R++) { + var T = l[y++]; + this._intArray[S++] = T; + for (var v = 0; v < T; v++) { + var E = l[y++]; + var C = l[y++]; + var x = n[b++]; + var w = n[b++]; + this._intArray[S++] = h.indexOf(E); + this._floatArray[A++] = C; + this._floatArray[A++] = x; + this._floatArray[A++] = w; + } + } + i.vertices.weight = m; + } else { + this._floatArray.length += n.length; + for (var R = 0, I = n.length; R < I; ++R) this._floatArray[o + R] = n[R]; + } + }; + s.prototype._parsePivot = function(e, i) { + if (t.DataParser.PIVOT in e) { + var n = e[t.DataParser.PIVOT]; + i.pivot.x = s._getNumber(n, t.DataParser.X, 0); + i.pivot.y = s._getNumber(n, t.DataParser.Y, 0); + } else { + i.pivot.x = .5; + i.pivot.y = .5; + } + }; + s.prototype._parseMesh = function(e, i) { + var s = e[t.DataParser.VERTICES]; + var n = e[t.DataParser.UVS]; + var r = e[t.DataParser.TRIANGLES]; + var o = Math.floor(s.length / 2); + var a = Math.floor(r.length / 3); + var l = this._floatArray.length; + var h = l + 2 * o; + var c = this._intArray.length; + var u = this._skin.name + "_" + this._slot.name + "_" + i.name; + i.vertices.offset = c; + this._intArray.length += 4 + 3 * a; + this._intArray[c + 0] = o; + this._intArray[c + 1] = a; + this._intArray[c + 2] = l; + for (var _ = 0, d = 3 * a; _ < d; ++_) this._intArray[c + 4 + _] = r[_]; + this._floatArray.length += 2 * o + 2 * o; + for (_ = 0, d = 2 * o; _ < d; ++_) { + this._floatArray[l + _] = s[_]; + this._floatArray[h + _] = n[_]; + } + if (t.DataParser.WEIGHTS in e) { + var p = e[t.DataParser.WEIGHTS]; + var m = e[t.DataParser.SLOT_POSE]; + var f = e[t.DataParser.BONE_POSE]; + var g = this._armature.sortedBones; + var y = new Array; + var b = Math.floor(f.length / 7); + var S = this._floatArray.length; + var A = Math.floor(p.length - o) / 2; + var T = this._intArray.length; + var v = t.BaseObject.borrowObject(t.WeightData); + v.count = A; + v.offset = T; + y.length = b; + this._intArray.length += 2 + b + o + A; + this._intArray[T + 1] = S; + for (_ = 0; _ < b; ++_) { + var E = f[7 * _]; + var C = this._rawBones[E]; + v.addBone(C); + y[_] = E; + this._intArray[T + 2 + _] = g.indexOf(C); + } + this._floatArray.length += 3 * A; + this._helpMatrixA.copyFromArray(m, 0); + _ = 0; + for (var x = 0, w = T + 2 + b, R = S; _ < o; ++_) { + var I = 2 * _; + var M = this._intArray[w++] = p[x++]; + var B = this._floatArray[l + I]; + var D = this._floatArray[l + I + 1]; + this._helpMatrixA.transformPoint(B, D, this._helpPoint); + B = this._helpPoint.x; + D = this._helpPoint.y; + for (var P = 0; P < M; ++P) { + E = p[x++]; + var O = y.indexOf(E); + this._helpMatrixB.copyFromArray(f, 7 * O + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(B, D, this._helpPoint); + this._intArray[w++] = O; + this._floatArray[R++] = p[x++]; + this._floatArray[R++] = this._helpPoint.x; + this._floatArray[R++] = this._helpPoint.y; + } + } + i.vertices.weight = v; + this._weightSlotPose[u] = m; + this._weightBonePoses[u] = f; + } + }; + s.prototype._parseMeshGlue = function(t, e) {}; + s.prototype._parseBoundingBox = function(e) { + var i = null; + var n = 0; + switch (n = t.DataParser.SUB_TYPE in e && "string" == typeof e[t.DataParser.SUB_TYPE] ? t.DataParser._getBoundingBoxType(e[t.DataParser.SUB_TYPE]) : s._getNumber(e, t.DataParser.SUB_TYPE, n)) { + case 0: + i = t.BaseObject.borrowObject(t.RectangleBoundingBoxData); + break; + + case 1: + i = t.BaseObject.borrowObject(t.EllipseBoundingBoxData); + break; + + case 2: + i = this._parsePolygonBoundingBox(e); + } + if (null !== i) { + i.color = s._getNumber(e, t.DataParser.COLOR, 0); + if (0 === i.type || 1 === i.type) { + i.width = s._getNumber(e, t.DataParser.WIDTH, 0); + i.height = s._getNumber(e, t.DataParser.HEIGHT, 0); + } + } + return i; + }; + s.prototype._parsePolygonBoundingBox = function(e) { + var i = t.BaseObject.borrowObject(t.PolygonBoundingBoxData); + if (t.DataParser.VERTICES in e) { + var s = this._armature.scale; + var n = e[t.DataParser.VERTICES]; + var r = i.vertices; + t.DragonBones.webAssembly ? r.resize(n.length, 0) : r.length = n.length; + for (var o = 0, a = n.length; o < a; o += 2) { + var l = n[o] * s; + var h = n[o + 1] * s; + if (t.DragonBones.webAssembly) { + r.set(o, l); + r.set(o + 1, h); + } else { + r[o] = l; + r[o + 1] = h; + } + if (0 === o) { + i.x = l; + i.y = h; + i.width = l; + i.height = h; + } else { + l < i.x ? i.x = l : l > i.width && (i.width = l); + h < i.y ? i.y = h : h > i.height && (i.height = h); + } + } + i.width -= i.x; + i.height -= i.y; + } else console.warn("Data error.\n Please reexport DragonBones Data to fixed the bug."); + return i; + }; + s.prototype._parseAnimation = function(e) { + var i = t.BaseObject.borrowObject(t.AnimationData); + i.frameCount = Math.max(s._getNumber(e, t.DataParser.DURATION, 1), 1); + i.playTimes = s._getNumber(e, t.DataParser.PLAY_TIMES, 1); + i.duration = i.frameCount / this._armature.frameRate; + i.fadeInTime = s._getNumber(e, t.DataParser.FADE_IN_TIME, 0); + i.scale = s._getNumber(e, t.DataParser.SCALE, 1); + i.name = s._getString(e, t.DataParser.NAME, t.DataParser.DEFAULT_NAME); + 0 === i.name.length && (i.name = t.DataParser.DEFAULT_NAME); + i.frameIntOffset = this._frameIntArray.length; + i.frameFloatOffset = this._frameFloatArray.length; + i.frameOffset = this._frameArray.length; + this._animation = i; + if (t.DataParser.FRAME in e) { + var n = e[t.DataParser.FRAME]; + var r = n.length; + if (r > 0) for (var o = 0, a = 0; o < r; ++o) { + var l = n[o]; + this._parseActionDataInFrame(l, a, null, null); + a += s._getNumber(l, t.DataParser.DURATION, 1); + } + } + t.DataParser.Z_ORDER in e && (this._animation.zOrderTimeline = this._parseTimeline(e[t.DataParser.Z_ORDER], null, t.DataParser.FRAME, 1, !1, !1, 0, this._parseZOrderFrame)); + if (t.DataParser.BONE in e) { + for (var h = 0, c = e[t.DataParser.BONE]; h < c.length; h++) { + var u = c[h]; + this._parseBoneTimeline(u); + } + } + if (t.DataParser.SURFACE in e) { + for (var _ = 0, d = e[t.DataParser.SURFACE]; _ < d.length; _++) { + u = d[_]; + var p = s._getString(u, t.DataParser.NAME, ""); + this._surface = this._armature.getBone(p); + if (null !== this._surface) { + null !== (I = this._parseTimeline(u, null, t.DataParser.FRAME, 50, !1, !0, 0, this._parseSurfaceFrame)) && this._animation.addSurfaceTimeline(this._surface, I); + this._surface = null; + } + } + } + if (t.DataParser.SLOT in e) { + for (var m = 0, f = e[t.DataParser.SLOT]; m < f.length; m++) { + u = f[m]; + this._parseSlotTimeline(u); + } + } + if (t.DataParser.FFD in e) { + for (var g = 0, y = e[t.DataParser.FFD]; g < y.length; g++) { + u = y[g]; + var b = s._getString(u, t.DataParser.SKIN, t.DataParser.DEFAULT_NAME); + var S = s._getString(u, t.DataParser.SLOT, ""); + var A = s._getString(u, t.DataParser.NAME, ""); + 0 === b.length && (b = t.DataParser.DEFAULT_NAME); + this._slot = this._armature.getSlot(S); + this._mesh = this._armature.getMesh(b, S, A); + if (null !== this._slot && null !== this._mesh) { + null !== (I = this._parseTimeline(u, null, t.DataParser.FRAME, 22, !1, !0, 0, this._parseSlotFFDFrame)) && this._animation.addSlotTimeline(this._slot, I); + this._slot = null; + this._mesh = null; + } + } + } + if (t.DataParser.IK in e) { + for (var T = 0, v = e[t.DataParser.IK]; T < v.length; T++) { + u = v[T]; + var E = s._getString(u, t.DataParser.NAME, ""); + var C = this._armature.getConstraint(E); + if (null !== C) { + null !== (I = this._parseTimeline(u, null, t.DataParser.FRAME, 30, !0, !1, 2, this._parseIKConstraintFrame)) && this._animation.addConstraintTimeline(C, I); + } + } + } + if (t.DataParser.ANIMATION in e) { + for (var x = 0, w = e[t.DataParser.ANIMATION]; x < w.length; x++) { + u = w[x]; + var R = s._getString(u, t.DataParser.NAME, ""); + var I; + null !== (I = this._parseTimeline(u, null, t.DataParser.FRAME, 40, !0, !1, 2, this._parseAnimationFrame)) && this._animation.addAnimationTimeline(R, I); + } + } + if (this._actionFrames.length > 0) { + this._animation.actionTimeline = this._parseTimeline(null, this._actionFrames, "", 0, !1, !1, 0, this._parseActionFrame); + this._actionFrames.length = 0; + } + this._animation = null; + return i; + }; + s.prototype._parseTimeline = function(e, n, r, o, a, l, h, c) { + null !== e && r.length > 0 && r in e && (n = e[r]); + if (null === n) return null; + var u = n.length; + if (0 === u) return null; + var _ = this._frameIntArray.length; + var d = this._frameFloatArray.length; + var p = t.BaseObject.borrowObject(t.TimelineData); + var m = this._timelineArray.length; + this._timelineArray.length += 5 + u; + if (null !== e) { + this._timelineArray[m + 0] = Math.round(100 * s._getNumber(e, t.DataParser.SCALE, 1)); + this._timelineArray[m + 1] = Math.round(100 * s._getNumber(e, t.DataParser.OFFSET, 0)); + } else { + this._timelineArray[m + 0] = 100; + this._timelineArray[m + 1] = 0; + } + this._timelineArray[m + 2] = u; + this._timelineArray[m + 3] = h; + this._timelineArray[m + 4] = a ? _ - this._animation.frameIntOffset : l ? d - this._animation.frameFloatOffset : 0; + this._timeline = p; + p.type = o; + p.offset = m; + if (1 === u) { + p.frameIndicesOffset = -1; + this._timelineArray[m + 5 + 0] = c.call(this, n[0], 0, 0) - this._animation.frameOffset; + } else { + var f = this._animation.frameCount + 1; + var g = this._data.frameIndices; + var y = 0; + if (t.DragonBones.webAssembly) { + y = g.size(); + g.resize(y + f, 0); + } else { + y = g.length; + g.length += f; + } + p.frameIndicesOffset = y; + for (var b = 0, S = 0, A = 0, T = 0; b < f; ++b) { + if (A + T <= b && S < u) { + var v = n[S]; + A = b; + T = S === u - 1 ? this._animation.frameCount - A : v instanceof i ? this._actionFrames[S + 1].frameStart - A : s._getNumber(v, t.DataParser.DURATION, 1); + this._timelineArray[m + 5 + S] = c.call(this, v, A, T) - this._animation.frameOffset; + S++; + } + t.DragonBones.webAssembly ? g.set(y + b, S - 1) : g[y + b] = S - 1; + } + } + this._timeline = null; + return p; + }; + s.prototype._parseBoneTimeline = function(e) { + var i = this._armature.getBone(s._getString(e, t.DataParser.NAME, "")); + if (null !== i) { + this._bone = i; + this._slot = this._armature.getSlot(this._bone.name); + if (t.DataParser.TRANSLATE_FRAME in e) { + null !== (n = this._parseTimeline(e, null, t.DataParser.TRANSLATE_FRAME, 11, !1, !0, 2, this._parseBoneTranslateFrame)) && this._animation.addBoneTimeline(i, n); + } + if (t.DataParser.ROTATE_FRAME in e) { + null !== (n = this._parseTimeline(e, null, t.DataParser.ROTATE_FRAME, 12, !1, !0, 2, this._parseBoneRotateFrame)) && this._animation.addBoneTimeline(i, n); + } + if (t.DataParser.SCALE_FRAME in e) { + null !== (n = this._parseTimeline(e, null, t.DataParser.SCALE_FRAME, 13, !1, !0, 2, this._parseBoneScaleFrame)) && this._animation.addBoneTimeline(i, n); + } + if (t.DataParser.FRAME in e) { + var n; + null !== (n = this._parseTimeline(e, null, t.DataParser.FRAME, 10, !1, !0, 6, this._parseBoneAllFrame)) && this._animation.addBoneTimeline(i, n); + } + this._bone = null; + this._slot = null; + } + }; + s.prototype._parseSlotTimeline = function(e) { + var i = this._armature.getSlot(s._getString(e, t.DataParser.NAME, "")); + if (null !== i) { + this._slot = i; + var n = null; + null !== (n = t.DataParser.DISPLAY_FRAME in e ? this._parseTimeline(e, null, t.DataParser.DISPLAY_FRAME, 20, !1, !1, 0, this._parseSlotDisplayFrame) : this._parseTimeline(e, null, t.DataParser.FRAME, 20, !1, !1, 0, this._parseSlotDisplayFrame)) && this._animation.addSlotTimeline(i, n); + var r = null; + null !== (r = t.DataParser.COLOR_FRAME in e ? this._parseTimeline(e, null, t.DataParser.COLOR_FRAME, 21, !0, !1, 1, this._parseSlotColorFrame) : this._parseTimeline(e, null, t.DataParser.FRAME, 21, !0, !1, 1, this._parseSlotColorFrame)) && this._animation.addSlotTimeline(i, r); + this._slot = null; + } + }; + s.prototype._parseFrame = function(t, e, i) { + var s = this._frameArray.length; + this._frameArray.length += 1; + this._frameArray[s + 0] = e; + return s; + }; + s.prototype._parseTweenFrame = function(e, i, n) { + var r = this._parseFrame(e, i, n); + if (n > 0) if (t.DataParser.CURVE in e) { + var o = n + 1; + this._helpArray.length = o; + this._samplingEasingCurve(e[t.DataParser.CURVE], this._helpArray); + this._frameArray.length += 2 + this._helpArray.length; + this._frameArray[r + 1] = 2; + this._frameArray[r + 2] = o; + for (var a = 0; a < o; ++a) this._frameArray[r + 3 + a] = Math.round(1e4 * this._helpArray[a]); + } else { + var l = -2; + t.DataParser.TWEEN_EASING in e && (l = s._getNumber(e, t.DataParser.TWEEN_EASING, -2)); + if (-2 === l) { + this._frameArray.length += 1; + this._frameArray[r + 1] = 0; + } else if (0 === l) { + this._frameArray.length += 1; + this._frameArray[r + 1] = 1; + } else if (l < 0) { + this._frameArray.length += 2; + this._frameArray[r + 1] = 3; + this._frameArray[r + 2] = Math.round(100 * -l); + } else if (l <= 1) { + this._frameArray.length += 2; + this._frameArray[r + 1] = 4; + this._frameArray[r + 2] = Math.round(100 * l); + } else { + this._frameArray.length += 2; + this._frameArray[r + 1] = 5; + this._frameArray[r + 2] = Math.round(100 * l - 100); + } + } else { + this._frameArray.length += 1; + this._frameArray[r + 1] = 0; + } + return r; + }; + s.prototype._parseActionFrame = function(t, e, i) { + var s = this._frameArray.length; + var n = t.actions.length; + this._frameArray.length += 2 + n; + this._frameArray[s + 0] = e; + this._frameArray[s + 0 + 1] = n; + for (var r = 0; r < n; ++r) this._frameArray[s + 0 + 2 + r] = t.actions[r]; + return s; + }; + s.prototype._parseZOrderFrame = function(e, i, s) { + var n = this._parseFrame(e, i, s); + if (t.DataParser.Z_ORDER in e) { + var r = e[t.DataParser.Z_ORDER]; + if (r.length > 0) { + var o = this._armature.sortedSlots.length; + var a = new Array(o - r.length / 2); + var l = new Array(o); + for (var h = 0; h < a.length; ++h) a[h] = 0; + for (var c = 0; c < o; ++c) l[c] = -1; + var u = 0; + var _ = 0; + for (var d = 0, p = r.length; d < p; d += 2) { + var m = r[d]; + var f = r[d + 1]; + for (;u !== m; ) a[_++] = u++; + l[u + f] = u++; + } + for (;u < o; ) a[_++] = u++; + this._frameArray.length += 1 + o; + this._frameArray[n + 1] = o; + var g = o; + for (;g--; ) -1 === l[g] ? this._frameArray[n + 2 + g] = a[--_] || 0 : this._frameArray[n + 2 + g] = l[g] || 0; + return n; + } + } + this._frameArray.length += 1; + this._frameArray[n + 1] = 0; + return n; + }; + s.prototype._parseBoneAllFrame = function(e, i, n) { + this._helpTransform.identity(); + t.DataParser.TRANSFORM in e && this._parseTransform(e[t.DataParser.TRANSFORM], this._helpTransform, 1); + var r = this._helpTransform.rotation; + if (0 !== i) if (0 === this._prevClockwise) r = this._prevRotation + t.Transform.normalizeRadian(r - this._prevRotation); else { + (this._prevClockwise > 0 ? r >= this._prevRotation : r <= this._prevRotation) && (this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1); + r = this._prevRotation + r - this._prevRotation + t.Transform.PI_D * this._prevClockwise; + } + this._prevClockwise = s._getNumber(e, t.DataParser.TWEEN_ROTATE, 0); + this._prevRotation = r; + var o = this._parseTweenFrame(e, i, n); + var a = this._frameFloatArray.length; + this._frameFloatArray.length += 6; + this._frameFloatArray[a++] = this._helpTransform.x; + this._frameFloatArray[a++] = this._helpTransform.y; + this._frameFloatArray[a++] = r; + this._frameFloatArray[a++] = this._helpTransform.skew; + this._frameFloatArray[a++] = this._helpTransform.scaleX; + this._frameFloatArray[a++] = this._helpTransform.scaleY; + this._parseActionDataInFrame(e, i, this._bone, this._slot); + return o; + }; + s.prototype._parseBoneTranslateFrame = function(e, i, n) { + var r = this._parseTweenFrame(e, i, n); + var o = this._frameFloatArray.length; + this._frameFloatArray.length += 2; + this._frameFloatArray[o++] = s._getNumber(e, t.DataParser.X, 0); + this._frameFloatArray[o++] = s._getNumber(e, t.DataParser.Y, 0); + return r; + }; + s.prototype._parseBoneRotateFrame = function(e, i, n) { + var r = s._getNumber(e, t.DataParser.ROTATE, 0) * t.Transform.DEG_RAD; + if (0 !== i) if (0 === this._prevClockwise) r = this._prevRotation + t.Transform.normalizeRadian(r - this._prevRotation); else { + (this._prevClockwise > 0 ? r >= this._prevRotation : r <= this._prevRotation) && (this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1); + r = this._prevRotation + r - this._prevRotation + t.Transform.PI_D * this._prevClockwise; + } + this._prevClockwise = s._getNumber(e, t.DataParser.CLOCK_WISE, 0); + this._prevRotation = r; + var o = this._parseTweenFrame(e, i, n); + var a = this._frameFloatArray.length; + this._frameFloatArray.length += 2; + this._frameFloatArray[a++] = r; + this._frameFloatArray[a++] = s._getNumber(e, t.DataParser.SKEW, 0) * t.Transform.DEG_RAD; + return o; + }; + s.prototype._parseBoneScaleFrame = function(e, i, n) { + var r = this._parseTweenFrame(e, i, n); + var o = this._frameFloatArray.length; + this._frameFloatArray.length += 2; + this._frameFloatArray[o++] = s._getNumber(e, t.DataParser.X, 1); + this._frameFloatArray[o++] = s._getNumber(e, t.DataParser.Y, 1); + return r; + }; + s.prototype._parseSurfaceFrame = function(e, i, n) { + var r = this._frameFloatArray.length; + var o = this._parseTweenFrame(e, i, n); + var a = e[t.DataParser.VERTICES]; + var l = s._getNumber(e, t.DataParser.OFFSET, 0); + var h = this._surface.vertices.length / 2; + var c = 0; + var u = 0; + this._frameFloatArray.length += 2 * h; + for (var _ = 0; _ < 2 * h; _ += 2) { + c = _ < l || _ - l >= a.length ? 0 : a[_ - l]; + u = _ + 1 < l || _ + 1 - l >= a.length ? 0 : a[_ + 1 - l]; + this._frameFloatArray[r + _] = c; + this._frameFloatArray[r + _ + 1] = u; + } + if (0 === i) { + var d = this._frameIntArray.length; + this._frameIntArray.length += 5; + this._frameIntArray[d + 0] = 0; + this._frameIntArray[d + 1] = this._frameFloatArray.length - r; + this._frameIntArray[d + 2] = this._frameFloatArray.length - r; + this._frameIntArray[d + 3] = 0; + this._frameIntArray[d + 4] = r - this._animation.frameFloatOffset; + this._timelineArray[this._timeline.offset + 3] = d - this._animation.frameIntOffset; + } + return o; + }; + s.prototype._parseSlotDisplayFrame = function(e, i, n) { + var r = this._parseFrame(e, i, n); + this._frameArray.length += 1; + t.DataParser.VALUE in e ? this._frameArray[r + 1] = s._getNumber(e, t.DataParser.VALUE, 0) : this._frameArray[r + 1] = s._getNumber(e, t.DataParser.DISPLAY_INDEX, 0); + this._parseActionDataInFrame(e, i, this._slot.parent, this._slot); + return r; + }; + s.prototype._parseSlotColorFrame = function(e, i, s) { + var n = this._parseTweenFrame(e, i, s); + var r = -1; + if (t.DataParser.VALUE in e || t.DataParser.COLOR in e) { + var o = t.DataParser.VALUE in e ? e[t.DataParser.VALUE] : e[t.DataParser.COLOR]; + for (var a in o) { + this._parseColorTransform(o, this._helpColorTransform); + r = this._intArray.length; + this._intArray.length += 8; + this._intArray[r++] = Math.round(100 * this._helpColorTransform.alphaMultiplier); + this._intArray[r++] = Math.round(100 * this._helpColorTransform.redMultiplier); + this._intArray[r++] = Math.round(100 * this._helpColorTransform.greenMultiplier); + this._intArray[r++] = Math.round(100 * this._helpColorTransform.blueMultiplier); + this._intArray[r++] = Math.round(this._helpColorTransform.alphaOffset); + this._intArray[r++] = Math.round(this._helpColorTransform.redOffset); + this._intArray[r++] = Math.round(this._helpColorTransform.greenOffset); + this._intArray[r++] = Math.round(this._helpColorTransform.blueOffset); + r -= 8; + break; + } + } + if (r < 0) { + if (this._defaultColorOffset < 0) { + this._defaultColorOffset = r = this._intArray.length; + this._intArray.length += 8; + this._intArray[r++] = 100; + this._intArray[r++] = 100; + this._intArray[r++] = 100; + this._intArray[r++] = 100; + this._intArray[r++] = 0; + this._intArray[r++] = 0; + this._intArray[r++] = 0; + this._intArray[r++] = 0; + } + r = this._defaultColorOffset; + } + var l = this._frameIntArray.length; + this._frameIntArray.length += 1; + this._frameIntArray[l] = r; + return n; + }; + s.prototype._parseSlotFFDFrame = function(e, i, n) { + var r = this._frameFloatArray.length; + var o = this._parseTweenFrame(e, i, n); + var a = t.DataParser.VERTICES in e ? e[t.DataParser.VERTICES] : null; + var l = s._getNumber(e, t.DataParser.OFFSET, 0); + var h = this._intArray[this._mesh.vertices.offset + 0]; + var c = this._mesh.parent.name + "_" + this._slot.name + "_" + this._mesh.name; + var u = this._mesh.vertices.weight; + var _ = 0; + var d = 0; + var p = 0; + var m = 0; + if (null !== u) { + var f = this._weightSlotPose[c]; + this._helpMatrixA.copyFromArray(f, 0); + this._frameFloatArray.length += 2 * u.count; + p = u.offset + 2 + u.bones.length; + } else this._frameFloatArray.length += 2 * h; + for (var g = 0; g < 2 * h; g += 2) { + if (null === a) { + _ = 0; + d = 0; + } else { + _ = g < l || g - l >= a.length ? 0 : a[g - l]; + d = g + 1 < l || g + 1 - l >= a.length ? 0 : a[g + 1 - l]; + } + if (null !== u) { + var y = this._weightBonePoses[c]; + var b = this._intArray[p++]; + this._helpMatrixA.transformPoint(_, d, this._helpPoint, !0); + _ = this._helpPoint.x; + d = this._helpPoint.y; + for (var S = 0; S < b; ++S) { + var A = this._intArray[p++]; + this._helpMatrixB.copyFromArray(y, 7 * A + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(_, d, this._helpPoint, !0); + this._frameFloatArray[r + m++] = this._helpPoint.x; + this._frameFloatArray[r + m++] = this._helpPoint.y; + } + } else { + this._frameFloatArray[r + g] = _; + this._frameFloatArray[r + g + 1] = d; + } + } + if (0 === i) { + var T = this._frameIntArray.length; + this._frameIntArray.length += 5; + this._frameIntArray[T + 0] = this._mesh.vertices.offset; + this._frameIntArray[T + 1] = this._frameFloatArray.length - r; + this._frameIntArray[T + 2] = this._frameFloatArray.length - r; + this._frameIntArray[T + 3] = 0; + this._frameIntArray[T + 4] = r - this._animation.frameFloatOffset; + this._timelineArray[this._timeline.offset + 3] = T - this._animation.frameIntOffset; + } + return o; + }; + s.prototype._parseIKConstraintFrame = function(e, i, n) { + var r = this._parseTweenFrame(e, i, n); + var o = this._frameIntArray.length; + this._frameIntArray.length += 2; + this._frameIntArray[o++] = s._getBoolean(e, t.DataParser.BEND_POSITIVE, !0) ? 1 : 0; + this._frameIntArray[o++] = Math.round(100 * s._getNumber(e, t.DataParser.WEIGHT, 1)); + return r; + }; + s.prototype._parseAnimationFrame = function(e, i, n) { + var r = this._parseTweenFrame(e, i, n); + var o = this._frameIntArray.length; + this._frameIntArray.length += 2; + this._frameIntArray[o++] = s._getNumber(e, t.DataParser.VALUE, 0); + this._frameIntArray[o++] = Math.round(100 * s._getNumber(e, t.DataParser.WEIGHT, 1)); + return r; + }; + s.prototype._parseActionData = function(e, i, n, r) { + var o = new Array; + if ("string" == typeof e) { + (c = t.BaseObject.borrowObject(t.ActionData)).type = i; + c.name = e; + c.bone = n; + c.slot = r; + o.push(c); + } else if (e instanceof Array) for (var a = 0, l = e; a < l.length; a++) { + var h = l[a]; + var c = t.BaseObject.borrowObject(t.ActionData); + if (t.DataParser.GOTO_AND_PLAY in h) { + c.type = 0; + c.name = s._getString(h, t.DataParser.GOTO_AND_PLAY, ""); + } else { + t.DataParser.TYPE in h && "string" == typeof h[t.DataParser.TYPE] ? c.type = t.DataParser._getActionType(h[t.DataParser.TYPE]) : c.type = s._getNumber(h, t.DataParser.TYPE, i); + c.name = s._getString(h, t.DataParser.NAME, ""); + } + if (t.DataParser.BONE in h) { + var u = s._getString(h, t.DataParser.BONE, ""); + c.bone = this._armature.getBone(u); + } else c.bone = n; + if (t.DataParser.SLOT in h) { + var _ = s._getString(h, t.DataParser.SLOT, ""); + c.slot = this._armature.getSlot(_); + } else c.slot = r; + var d = null; + if (t.DataParser.INTS in h) { + null === d && (d = t.BaseObject.borrowObject(t.UserData)); + for (var p = 0, m = h[t.DataParser.INTS]; p < m.length; p++) { + var f = m[p]; + d.addInt(f); + } + } + if (t.DataParser.FLOATS in h) { + null === d && (d = t.BaseObject.borrowObject(t.UserData)); + for (var g = 0, y = h[t.DataParser.FLOATS]; g < y.length; g++) { + f = y[g]; + d.addFloat(f); + } + } + if (t.DataParser.STRINGS in h) { + null === d && (d = t.BaseObject.borrowObject(t.UserData)); + for (var b = 0, S = h[t.DataParser.STRINGS]; b < S.length; b++) { + f = S[b]; + d.addString(f); + } + } + c.data = d; + o.push(c); + } + return o; + }; + s.prototype._parseTransform = function(e, i, n) { + i.x = s._getNumber(e, t.DataParser.X, 0) * n; + i.y = s._getNumber(e, t.DataParser.Y, 0) * n; + if (t.DataParser.ROTATE in e || t.DataParser.SKEW in e) { + i.rotation = t.Transform.normalizeRadian(s._getNumber(e, t.DataParser.ROTATE, 0) * t.Transform.DEG_RAD); + i.skew = t.Transform.normalizeRadian(s._getNumber(e, t.DataParser.SKEW, 0) * t.Transform.DEG_RAD); + } else if (t.DataParser.SKEW_X in e || t.DataParser.SKEW_Y in e) { + i.rotation = t.Transform.normalizeRadian(s._getNumber(e, t.DataParser.SKEW_Y, 0) * t.Transform.DEG_RAD); + i.skew = t.Transform.normalizeRadian(s._getNumber(e, t.DataParser.SKEW_X, 0) * t.Transform.DEG_RAD) - i.rotation; + } + i.scaleX = s._getNumber(e, t.DataParser.SCALE_X, 1); + i.scaleY = s._getNumber(e, t.DataParser.SCALE_Y, 1); + }; + s.prototype._parseColorTransform = function(e, i) { + i.alphaMultiplier = .01 * s._getNumber(e, t.DataParser.ALPHA_MULTIPLIER, 100); + i.redMultiplier = .01 * s._getNumber(e, t.DataParser.RED_MULTIPLIER, 100); + i.greenMultiplier = .01 * s._getNumber(e, t.DataParser.GREEN_MULTIPLIER, 100); + i.blueMultiplier = .01 * s._getNumber(e, t.DataParser.BLUE_MULTIPLIER, 100); + i.alphaOffset = s._getNumber(e, t.DataParser.ALPHA_OFFSET, 0); + i.redOffset = s._getNumber(e, t.DataParser.RED_OFFSET, 0); + i.greenOffset = s._getNumber(e, t.DataParser.GREEN_OFFSET, 0); + i.blueOffset = s._getNumber(e, t.DataParser.BLUE_OFFSET, 0); + }; + s.prototype._parseArray = function(t) { + this._intArray.length = 0; + this._floatArray.length = 0; + this._frameIntArray.length = 0; + this._frameFloatArray.length = 0; + this._frameArray.length = 0; + this._timelineArray.length = 0; + }; + s.prototype._modifyArray = function() { + this._intArray.length % Int16Array.BYTES_PER_ELEMENT != 0 && this._intArray.push(0); + this._frameIntArray.length % Int16Array.BYTES_PER_ELEMENT != 0 && this._frameIntArray.push(0); + this._frameArray.length % Int16Array.BYTES_PER_ELEMENT != 0 && this._frameArray.push(0); + this._timelineArray.length % Uint16Array.BYTES_PER_ELEMENT != 0 && this._timelineArray.push(0); + var e = this._intArray.length * Int16Array.BYTES_PER_ELEMENT; + var i = this._floatArray.length * Float32Array.BYTES_PER_ELEMENT; + var s = this._frameIntArray.length * Int16Array.BYTES_PER_ELEMENT; + var n = this._frameFloatArray.length * Float32Array.BYTES_PER_ELEMENT; + var r = this._frameArray.length * Int16Array.BYTES_PER_ELEMENT; + var o = this._timelineArray.length * Uint16Array.BYTES_PER_ELEMENT; + var a = e + i + s + n + r + o; + if (t.DragonBones.webAssembly) { + var l = t.webAssemblyModule.HEAP16.buffer; + var h = t.webAssemblyModule._malloc(a); + var c = new Int16Array(l, h, this._intArray.length); + var u = new Float32Array(l, h + e, this._floatArray.length); + var _ = new Int16Array(l, h + e + i, this._frameIntArray.length); + var d = new Float32Array(l, h + e + i + s, this._frameFloatArray.length); + var p = new Int16Array(l, h + e + i + s + n, this._frameArray.length); + var m = new Uint16Array(l, h + e + i + s + n + r, this._timelineArray.length); + for (var f = 0, g = this._intArray.length; f < g; ++f) c[f] = this._intArray[f]; + for (f = 0, g = this._floatArray.length; f < g; ++f) u[f] = this._floatArray[f]; + for (f = 0, g = this._frameIntArray.length; f < g; ++f) _[f] = this._frameIntArray[f]; + for (f = 0, g = this._frameFloatArray.length; f < g; ++f) d[f] = this._frameFloatArray[f]; + for (f = 0, g = this._frameArray.length; f < g; ++f) p[f] = this._frameArray[f]; + for (f = 0, g = this._timelineArray.length; f < g; ++f) m[f] = this._timelineArray[f]; + t.webAssemblyModule.setDataBinary(this._data, h, e, i, s, n, r, o); + } else { + var y = new ArrayBuffer(a); + c = new Int16Array(y, 0, this._intArray.length); + u = new Float32Array(y, e, this._floatArray.length); + _ = new Int16Array(y, e + i, this._frameIntArray.length); + d = new Float32Array(y, e + i + s, this._frameFloatArray.length); + p = new Int16Array(y, e + i + s + n, this._frameArray.length); + m = new Uint16Array(y, e + i + s + n + r, this._timelineArray.length); + for (f = 0, g = this._intArray.length; f < g; ++f) c[f] = this._intArray[f]; + for (f = 0, g = this._floatArray.length; f < g; ++f) u[f] = this._floatArray[f]; + for (f = 0, g = this._frameIntArray.length; f < g; ++f) _[f] = this._frameIntArray[f]; + for (f = 0, g = this._frameFloatArray.length; f < g; ++f) d[f] = this._frameFloatArray[f]; + for (f = 0, g = this._frameArray.length; f < g; ++f) p[f] = this._frameArray[f]; + for (f = 0, g = this._timelineArray.length; f < g; ++f) m[f] = this._timelineArray[f]; + this._data.binary = y; + this._data.intArray = c; + this._data.floatArray = u; + this._data.frameIntArray = _; + this._data.frameFloatArray = d; + this._data.frameArray = p; + this._data.timelineArray = m; + } + this._defaultColorOffset = -1; + }; + s.prototype.parseDragonBonesData = function(e, i) { + void 0 === i && (i = 1); + console.assert(null != e, "Data error."); + var n = s._getString(e, t.DataParser.VERSION, ""); + var r = s._getString(e, t.DataParser.COMPATIBLE_VERSION, ""); + if (t.DataParser.DATA_VERSIONS.indexOf(n) >= 0 || t.DataParser.DATA_VERSIONS.indexOf(r) >= 0) { + var o = t.BaseObject.borrowObject(t.DragonBonesData); + o.version = n; + o.name = s._getString(e, t.DataParser.NAME, ""); + o.frameRate = s._getNumber(e, t.DataParser.FRAME_RATE, 24); + 0 === o.frameRate && (o.frameRate = 24); + if (t.DataParser.ARMATURE in e) { + this._data = o; + this._parseArray(e); + for (var a = 0, l = e[t.DataParser.ARMATURE]; a < l.length; a++) { + var h = l[a]; + o.addArmature(this._parseArmature(h, i)); + } + this._data.binary || this._modifyArray(); + t.DataParser.STAGE in e ? o.stage = o.getArmature(s._getString(e, t.DataParser.STAGE, "")) : o.armatureNames.length > 0 && (o.stage = o.getArmature(o.armatureNames[0])); + this._data = null; + } + t.DataParser.TEXTURE_ATLAS in e && (this._rawTextureAtlases = e[t.DataParser.TEXTURE_ATLAS]); + return o; + } + console.assert(!1, "Nonsupport data version: " + n + "\nPlease convert DragonBones data to support version.\nRead more: https://github.com/DragonBones/Tools/"); + return null; + }; + s.prototype.parseTextureAtlasData = function(e, i, n) { + void 0 === n && (n = 1); + console.assert(void 0 !== e); + if (null === e) { + if (null === this._rawTextureAtlases || 0 === this._rawTextureAtlases.length) return !1; + var r = this._rawTextureAtlases[this._rawTextureAtlasIndex++]; + this.parseTextureAtlasData(r, i, n); + if (this._rawTextureAtlasIndex >= this._rawTextureAtlases.length) { + this._rawTextureAtlasIndex = 0; + this._rawTextureAtlases = null; + } + return !0; + } + i.width = s._getNumber(e, t.DataParser.WIDTH, 0); + i.height = s._getNumber(e, t.DataParser.HEIGHT, 0); + i.scale = 1 === n ? 1 / s._getNumber(e, t.DataParser.SCALE, 1) : n; + i.name = s._getString(e, t.DataParser.NAME, ""); + i.imagePath = s._getString(e, t.DataParser.IMAGE_PATH, ""); + if (t.DataParser.SUB_TEXTURE in e) { + var o = e[t.DataParser.SUB_TEXTURE]; + for (var a = 0, l = o.length; a < l; ++a) { + var h = o[a]; + var c = i.createTexture(); + c.rotated = s._getBoolean(h, t.DataParser.ROTATED, !1); + c.name = s._getString(h, t.DataParser.NAME, ""); + c.region.x = s._getNumber(h, t.DataParser.X, 0); + c.region.y = s._getNumber(h, t.DataParser.Y, 0); + c.region.width = s._getNumber(h, t.DataParser.WIDTH, 0); + c.region.height = s._getNumber(h, t.DataParser.HEIGHT, 0); + var u = s._getNumber(h, t.DataParser.FRAME_WIDTH, -1); + var _ = s._getNumber(h, t.DataParser.FRAME_HEIGHT, -1); + if (u > 0 && _ > 0) { + c.frame = t.TextureData.createRectangle(); + c.frame.x = s._getNumber(h, t.DataParser.FRAME_X, 0); + c.frame.y = s._getNumber(h, t.DataParser.FRAME_Y, 0); + c.frame.width = u; + c.frame.height = _; + } + i.addTexture(c); + } + } + return !0; + }; + s.getInstance = function() { + null === s._objectDataParserInstance && (s._objectDataParserInstance = new s); + return s._objectDataParserInstance; + }; + s._objectDataParserInstance = null; + return s; + }(t.DataParser); + t.ObjectDataParser = e; + var i = function() { + this.frameStart = 0; + this.actions = []; + }; + t.ActionFrame = i; + }(a5 || (a5 = {})); + !function(t) { + var e = function(e) { + r5(i, e); + function i() { + return null !== e && e.apply(this, arguments) || this; + } + i.prototype._inRange = function(t, e, i) { + return e <= t && t <= i; + }; + i.prototype._decodeUTF8 = function(t) { + var e = 0; + var i = ""; + var s; + var n = 0; + var r = 0; + var o = 0; + var a = 0; + for (;t.length > e; ) { + var l = t[e++]; + if (-1 === l) s = 0 !== r ? 65533 : -1; else if (0 === r) if (this._inRange(l, 0, 127)) s = l; else { + if (this._inRange(l, 194, 223)) { + r = 1; + a = 128; + n = l - 192; + } else if (this._inRange(l, 224, 239)) { + r = 2; + a = 2048; + n = l - 224; + } else if (this._inRange(l, 240, 244)) { + r = 3; + a = 65536; + n = l - 240; + } + n *= Math.pow(64, r); + s = null; + } else if (this._inRange(l, 128, 191)) { + o += 1; + n += (l - 128) * Math.pow(64, r - o); + if (o !== r) s = null; else { + var h = n; + var c = a; + n = 0; + r = 0; + o = 0; + a = 0; + s = this._inRange(h, c, 1114111) && !this._inRange(h, 55296, 57343) ? h : l; + } + } else { + n = 0; + r = 0; + o = 0; + a = 0; + e--; + s = l; + } + if (null !== s && -1 !== s) if (s <= 65535) s > 0 && (i += String.fromCharCode(s)); else { + s -= 65536; + i += String.fromCharCode(55296 + (s >> 10 & 1023)); + i += String.fromCharCode(56320 + (1023 & s)); + } + } + return i; + }; + i.prototype._getUTF16Key = function(t) { + for (var e = 0, i = t.length; e < i; ++e) if (t.charCodeAt(e) > 255) return encodeURI(t); + return t; + }; + i.prototype._parseBinaryTimeline = function(e, i, s) { + void 0 === s && (s = null); + var n = null !== s ? s : t.BaseObject.borrowObject(t.TimelineData); + n.type = e; + n.offset = i; + this._timeline = n; + var r = this._timelineArrayBuffer[n.offset + 2]; + if (1 === r) n.frameIndicesOffset = -1; else { + var o = 0; + var a = this._animation.frameCount + 1; + var l = this._data.frameIndices; + if (t.DragonBones.webAssembly) { + o = l.size(); + l.resize(o + a, 0); + } else { + o = l.length; + l.length += a; + } + n.frameIndicesOffset = o; + for (var h = 0, c = 0, u = 0, _ = 0; h < a; ++h) { + if (u + _ <= h && c < r) { + u = this._frameArrayBuffer[this._animation.frameOffset + this._timelineArrayBuffer[n.offset + 5 + c]]; + _ = c === r - 1 ? this._animation.frameCount - u : this._frameArrayBuffer[this._animation.frameOffset + this._timelineArrayBuffer[n.offset + 5 + c + 1]] - u; + c++; + } + t.DragonBones.webAssembly ? l.set(o + h, c - 1) : l[o + h] = c - 1; + } + } + this._timeline = null; + return n; + }; + i.prototype._parseVertices = function(e, i) { + i.offset = e[t.DataParser.OFFSET]; + var s = this._intArrayBuffer[i.offset + 3]; + if (s >= 0) { + var n = t.BaseObject.borrowObject(t.WeightData); + var r = this._intArrayBuffer[i.offset + 0]; + var o = this._intArrayBuffer[s + 0]; + n.offset = s; + for (var a = 0; a < o; ++a) { + var l = this._intArrayBuffer[s + 2 + a]; + n.addBone(this._rawBones[l]); + } + var h = s + 2 + o; + var c = 0; + a = 0; + for (var u = r; a < u; ++a) { + var _ = this._intArrayBuffer[h++]; + c += _; + h += _; + } + n.count = c; + i.weight = n; + } + }; + i.prototype._parseMesh = function(t, e) { + this._parseVertices(t, e.vertices); + }; + i.prototype._parsePath = function(t, e) { + this._parseVertices(t, e.vertices); + }; + i.prototype._parseAnimation = function(e) { + var i = t.BaseObject.borrowObject(t.AnimationData); + i.frameCount = Math.max(t.ObjectDataParser._getNumber(e, t.DataParser.DURATION, 1), 1); + i.playTimes = t.ObjectDataParser._getNumber(e, t.DataParser.PLAY_TIMES, 1); + i.duration = i.frameCount / this._armature.frameRate; + i.fadeInTime = t.ObjectDataParser._getNumber(e, t.DataParser.FADE_IN_TIME, 0); + i.scale = t.ObjectDataParser._getNumber(e, t.DataParser.SCALE, 1); + i.name = t.ObjectDataParser._getString(e, t.DataParser.NAME, t.DataParser.DEFAULT_NAME); + 0 === i.name.length && (i.name = t.DataParser.DEFAULT_NAME); + var s = e[t.DataParser.OFFSET]; + i.frameIntOffset = s[0]; + i.frameFloatOffset = s[1]; + i.frameOffset = s[2]; + this._animation = i; + t.DataParser.ACTION in e && (i.actionTimeline = this._parseBinaryTimeline(0, e[t.DataParser.ACTION])); + t.DataParser.Z_ORDER in e && (i.zOrderTimeline = this._parseBinaryTimeline(1, e[t.DataParser.Z_ORDER])); + if (t.DataParser.BONE in e) { + var n = e[t.DataParser.BONE]; + for (var r in n) { + var o = n[r]; + t.DragonBones.webAssembly && (r = this._getUTF16Key(r)); + var a = this._armature.getBone(r); + if (null !== a) for (var l = 0, h = o.length; l < h; l += 2) { + var c = o[l]; + var u = o[l + 1]; + var _ = this._parseBinaryTimeline(c, u); + this._animation.addBoneTimeline(a, _); + } + } + } + if (t.DataParser.SURFACE in e) { + n = e[t.DataParser.SURFACE]; + for (var r in n) { + o = n[r]; + t.DragonBones.webAssembly && (r = this._getUTF16Key(r)); + var d = this._armature.getBone(r); + if (null !== d) for (l = 0, h = o.length; l < h; l += 2) { + c = o[l]; + u = o[l + 1]; + _ = this._parseBinaryTimeline(c, u); + this._animation.addSurfaceTimeline(d, _); + } + } + } + if (t.DataParser.SLOT in e) { + n = e[t.DataParser.SLOT]; + for (var r in n) { + o = n[r]; + t.DragonBones.webAssembly && (r = this._getUTF16Key(r)); + var p = this._armature.getSlot(r); + if (null !== p) for (l = 0, h = o.length; l < h; l += 2) { + c = o[l]; + u = o[l + 1]; + _ = this._parseBinaryTimeline(c, u); + this._animation.addSlotTimeline(p, _); + } + } + } + if (t.DataParser.CONSTRAINT in e) { + n = e[t.DataParser.CONSTRAINT]; + for (var r in n) { + o = n[r]; + t.DragonBones.webAssembly && (r = this._getUTF16Key(r)); + var m = this._armature.getConstraint(r); + if (null !== m) for (l = 0, h = o.length; l < h; l += 2) { + c = o[l]; + u = o[l + 1]; + _ = this._parseBinaryTimeline(c, u); + this._animation.addConstraintTimeline(m, _); + } + } + } + if (t.DataParser.ANIMATION in e) { + n = e[t.DataParser.ANIMATION]; + for (var r in n) { + o = n[r]; + t.DragonBones.webAssembly && (r = this._getUTF16Key(r)); + for (l = 0, h = o.length; l < h; l += 2) { + c = o[l]; + u = o[l + 1]; + _ = this._parseBinaryTimeline(c, u); + this._animation.addAnimationTimeline(r, _); + } + } + } + this._animation = null; + return i; + }; + i.prototype._parseArray = function(e) { + var i = e[t.DataParser.OFFSET]; + var s = i[1]; + var n = i[3]; + var r = i[5]; + var o = i[7]; + var a = i[9]; + var l = i[11]; + var h = new Int16Array(this._binary, this._binaryOffset + i[0], s / Int16Array.BYTES_PER_ELEMENT); + var c = new Float32Array(this._binary, this._binaryOffset + i[2], n / Float32Array.BYTES_PER_ELEMENT); + var u = new Int16Array(this._binary, this._binaryOffset + i[4], r / Int16Array.BYTES_PER_ELEMENT); + var _ = new Float32Array(this._binary, this._binaryOffset + i[6], o / Float32Array.BYTES_PER_ELEMENT); + var d = new Int16Array(this._binary, this._binaryOffset + i[8], a / Int16Array.BYTES_PER_ELEMENT); + var p = new Uint16Array(this._binary, this._binaryOffset + i[10], l / Uint16Array.BYTES_PER_ELEMENT); + if (t.DragonBones.webAssembly) { + var m = s + n + r + o + a + l; + var f = t.webAssemblyModule._malloc(m); + var g = new Uint8Array(this._binary, this._binaryOffset, m / Uint8Array.BYTES_PER_ELEMENT); + var y = new Uint8Array(t.webAssemblyModule.HEAP16.buffer, f, g.length); + for (var b = 0, S = g.length; b < S; ++b) y[b] = g[b]; + t.webAssemblyModule.setDataBinary(this._data, f, s, n, r, o, a, l); + this._intArrayBuffer = h; + this._floatArrayBuffer = c; + this._frameIntArrayBuffer = u; + this._frameFloatArrayBuffer = _; + this._frameArrayBuffer = d; + this._timelineArrayBuffer = p; + } else { + this._data.binary = this._binary; + this._data.intArray = this._intArrayBuffer = h; + this._data.floatArray = this._floatArrayBuffer = c; + this._data.frameIntArray = this._frameIntArrayBuffer = u; + this._data.frameFloatArray = this._frameFloatArrayBuffer = _; + this._data.frameArray = this._frameArrayBuffer = d; + this._data.timelineArray = this._timelineArrayBuffer = p; + } + }; + i.prototype.parseDragonBonesData = function(t, i) { + void 0 === i && (i = 1); + console.assert(null != t && t instanceof ArrayBuffer, "Data error."); + var s = new Uint8Array(t, 0, 8); + if (s[0] !== "D".charCodeAt(0) || s[1] !== "B".charCodeAt(0) || s[2] !== "D".charCodeAt(0) || s[3] !== "T".charCodeAt(0)) { + console.assert(!1, "Nonsupport data."); + return null; + } + var n = new Uint32Array(t, 8, 1)[0]; + var r = new Uint8Array(t, 12, n); + var o = this._decodeUTF8(r); + var a = JSON.parse(o); + this._binaryOffset = 12 + n; + this._binary = t; + return e.prototype.parseDragonBonesData.call(this, a, i); + }; + i.getInstance = function() { + null === i._binaryDataParserInstance && (i._binaryDataParserInstance = new i); + return i._binaryDataParserInstance; + }; + i._binaryDataParserInstance = null; + return i; + }(t.ObjectDataParser); + t.BinaryDataParser = e; + }(a5 || (a5 = {})); + !function(t) { + var e = function() { + function e(i) { + void 0 === i && (i = null); + this.autoSearch = !1; + this._dragonBonesDataMap = {}; + this._textureAtlasDataMap = {}; + this._dragonBones = null; + this._dataParser = null; + null === e._objectParser && (e._objectParser = new t.ObjectDataParser); + null === e._binaryParser && (e._binaryParser = new t.BinaryDataParser); + this._dataParser = null !== i ? i : e._objectParser; + } + e.prototype._isSupportMesh = function() { + return !0; + }; + e.prototype._getTextureData = function(t, e) { + if (t in this._textureAtlasDataMap) for (var i = 0, s = this._textureAtlasDataMap[t]; i < s.length; i++) { + if (null !== (l = (a = s[i]).getTexture(e))) return l; + } + if (this.autoSearch) for (var n in this._textureAtlasDataMap) for (var r = 0, o = this._textureAtlasDataMap[n]; r < o.length; r++) { + var a; + if ((a = o[r]).autoSearch) { + var l; + if (null !== (l = a.getTexture(e))) return l; + } + } + return null; + }; + e.prototype._fillBuildArmaturePackage = function(t, e, i, s, n) { + var r = null; + var o = null; + e.length > 0 && e in this._dragonBonesDataMap && (o = (r = this._dragonBonesDataMap[e]).getArmature(i)); + if (null === o && (0 === e.length || this.autoSearch)) for (var a in this._dragonBonesDataMap) { + r = this._dragonBonesDataMap[a]; + if ((0 === e.length || r.autoSearch) && null !== (o = r.getArmature(i))) { + e = a; + break; + } + } + if (null !== o) { + t.dataName = e; + t.textureAtlasName = n; + t.data = r; + t.armature = o; + t.skin = null; + if (s.length > 0) { + t.skin = o.getSkin(s); + if (null === t.skin && this.autoSearch) for (var a in this._dragonBonesDataMap) { + var l = this._dragonBonesDataMap[a].getArmature(s); + if (null !== l) { + t.skin = l.defaultSkin; + break; + } + } + } + null === t.skin && (t.skin = o.defaultSkin); + return !0; + } + return !1; + }; + e.prototype._buildBones = function(e, i) { + for (var s = 0, n = e.armature.sortedBones; s < n.length; s++) { + var r = n[s]; + t.BaseObject.borrowObject(0 === r.type ? t.Bone : t.Surface).init(r, i); + } + }; + e.prototype._buildSlots = function(e, i) { + var s = e.skin; + var n = e.armature.defaultSkin; + if (null !== s && null !== n) { + var r = {}; + for (var o in n.displays) { + var a = n.getDisplays(o); + r[o] = a; + } + if (s !== n) for (var o in s.displays) { + a = s.getDisplays(o); + r[o] = a; + } + for (var l = 0, h = e.armature.sortedSlots; l < h.length; l++) { + var c = h[l]; + var u = c.name in r ? r[c.name] : null; + var _ = this._buildSlot(e, c, i); + _.rawDisplayDatas = u; + if (null !== u) { + var d = new Array; + for (var p = 0, m = t.DragonBones.webAssembly ? u.size() : u.length; p < m; ++p) { + var f = t.DragonBones.webAssembly ? u.get(p) : u[p]; + null !== f ? d.push(this._getSlotDisplay(e, f, null, _)) : d.push(null); + } + _._setDisplayList(d); + } + _._setDisplayIndex(c.displayIndex, !0); + } + } + }; + e.prototype._buildConstraints = function(e, i) { + var s = e.armature.constraints; + for (var n in s) { + var r = s[n]; + switch (r.type) { + case 0: + var o = t.BaseObject.borrowObject(t.IKConstraint); + o.init(r, i); + i._addConstraint(o); + break; + + case 1: + var a = t.BaseObject.borrowObject(t.PathConstraint); + a.init(r, i); + i._addConstraint(a); + break; + + default: + var l = t.BaseObject.borrowObject(t.IKConstraint); + l.init(r, i); + i._addConstraint(l); + } + } + }; + e.prototype._buildChildArmature = function(t, e, i) { + return this.buildArmature(i.path, null !== t ? t.dataName : "", "", null !== t ? t.textureAtlasName : ""); + }; + e.prototype._getSlotDisplay = function(e, i, s, n) { + var r = null !== e ? e.dataName : i.parent.parent.parent.name; + var o = null; + switch (i.type) { + case 0: + var a = i; + null !== e && e.textureAtlasName.length > 0 && (a.texture = this._getTextureData(e.textureAtlasName, i.path)); + null === a.texture && (a.texture = this._getTextureData(r, i.path)); + o = null !== s && 2 === s.type && this._isSupportMesh() ? n.meshDisplay : n.rawDisplay; + break; + + case 2: + var l = i; + null !== e && e.textureAtlasName.length > 0 && (l.texture = this._getTextureData(e.textureAtlasName, l.path)); + null === l.texture && (l.texture = this._getTextureData(r, l.path)); + o = this._isSupportMesh() ? n.meshDisplay : n.rawDisplay; + break; + + case 1: + var h = i; + var c = this._buildChildArmature(e, n, i); + if (null !== c) { + c.inheritAnimation = h.inheritAnimation; + if (!c.inheritAnimation) { + var u = h.actions.length > 0 ? h.actions : c.armatureData.defaultActions; + if (u.length > 0) for (var _ = 0, d = u; _ < d.length; _++) { + var p = d[_]; + var m = t.BaseObject.borrowObject(t.EventObject); + t.EventObject.actionDataToInstance(p, m, n.armature); + m.slot = n; + n.armature._bufferAction(m, !1); + } else c.animation.play(); + } + h.armature = c.armatureData; + } + o = c; + } + return o; + }; + e.prototype.parseDragonBonesData = function(t, i, s) { + void 0 === i && (i = null); + void 0 === s && (s = 1); + var n = t instanceof ArrayBuffer ? e._binaryParser : this._dataParser; + var r = n.parseDragonBonesData(t, s); + for (;;) { + var o = this._buildTextureAtlasData(null, null); + if (!n.parseTextureAtlasData(null, o, s)) { + o.returnToPool(); + break; + } + this.addTextureAtlasData(o, i); + } + null !== r && this.addDragonBonesData(r, i); + return r; + }; + e.prototype.parseTextureAtlasData = function(t, e, i, s) { + void 0 === i && (i = null); + void 0 === s && (s = 1); + var n = this._buildTextureAtlasData(null, null); + this._dataParser.parseTextureAtlasData(t, n, s); + this._buildTextureAtlasData(n, e || null); + this.addTextureAtlasData(n, i); + return n; + }; + e.prototype.updateTextureAtlasData = function(t, e) { + var i = this.getTextureAtlasData(t); + if (null !== i) for (var s = 0, n = i.length; s < n; ++s) s < e.length && this._buildTextureAtlasData(i[s], e[s]); + }; + e.prototype.getDragonBonesData = function(t) { + return t in this._dragonBonesDataMap ? this._dragonBonesDataMap[t] : null; + }; + e.prototype.addDragonBonesData = function(t, e) { + void 0 === e && (e = null); + if ((e = null !== e ? e : t.name) in this._dragonBonesDataMap) { + if (this._dragonBonesDataMap[e] === t) return; + console.warn("Can not add same name data: " + e); + } else this._dragonBonesDataMap[e] = t; + }; + e.prototype.removeDragonBonesData = function(t, e) { + void 0 === e && (e = !0); + if (t in this._dragonBonesDataMap) { + e && this._dragonBones.bufferObject(this._dragonBonesDataMap[t]); + delete this._dragonBonesDataMap[t]; + } + }; + e.prototype.getTextureAtlasData = function(t) { + return t in this._textureAtlasDataMap ? this._textureAtlasDataMap[t] : null; + }; + e.prototype.addTextureAtlasData = function(t, e) { + void 0 === e && (e = null); + var i = (e = null !== e ? e : t.name) in this._textureAtlasDataMap ? this._textureAtlasDataMap[e] : this._textureAtlasDataMap[e] = []; + i.indexOf(t) < 0 && i.push(t); + }; + e.prototype.removeTextureAtlasData = function(t, e) { + void 0 === e && (e = !0); + if (t in this._textureAtlasDataMap) { + var i = this._textureAtlasDataMap[t]; + if (e) for (var s = 0, n = i; s < n.length; s++) { + var r = n[s]; + this._dragonBones.bufferObject(r); + } + delete this._textureAtlasDataMap[t]; + } + }; + e.prototype.getArmatureData = function(t, e) { + void 0 === e && (e = ""); + var s = new i; + return this._fillBuildArmaturePackage(s, e, t, "", "") ? s.armature : null; + }; + e.prototype.clear = function(t) { + void 0 === t && (t = !0); + for (var e in this._dragonBonesDataMap) { + t && this._dragonBones.bufferObject(this._dragonBonesDataMap[e]); + delete this._dragonBonesDataMap[e]; + } + for (var e in this._textureAtlasDataMap) { + if (t) { + for (var i = 0, s = this._textureAtlasDataMap[e]; i < s.length; i++) { + var n = s[i]; + this._dragonBones.bufferObject(n); + } + } + delete this._textureAtlasDataMap[e]; + } + }; + e.prototype.buildArmature = function(t, e, s, n) { + void 0 === e && (e = ""); + void 0 === s && (s = ""); + void 0 === n && (n = ""); + var r = new i; + if (!this._fillBuildArmaturePackage(r, e || "", t, s || "", n || "")) { + console.warn("No armature data: " + t + ", " + (null !== e ? e : "")); + return null; + } + var o = this._buildArmature(r); + this._buildBones(r, o); + this._buildSlots(r, o); + this._buildConstraints(r, o); + o.invalidUpdate(null, !0); + o.advanceTime(0); + return o; + }; + e.prototype.replaceDisplay = function(e, i, s) { + void 0 === s && (s = -1); + s < 0 && (s = e.displayIndex); + s < 0 && (s = 0); + e.replaceDisplayData(i, s); + var n = e.displayList; + if (n.length <= s) { + n.length = s + 1; + for (var r = 0, o = n.length; r < o; ++r) n[r] || (n[r] = null); + } + if (null !== i) { + var a = e.rawDisplayDatas; + var l = null; + a && (t.DragonBones.webAssembly ? s < a.size() && (l = a.get(s)) : s < a.length && (l = a[s])); + n[s] = this._getSlotDisplay(null, i, l, e); + } else n[s] = null; + e.displayList = n; + }; + e.prototype.replaceSlotDisplay = function(t, e, i, s, n, r) { + void 0 === r && (r = -1); + var o = this.getArmatureData(e, t || ""); + if (!o || !o.defaultSkin) return !1; + var a = o.defaultSkin.getDisplay(i, s); + if (!a) return !1; + this.replaceDisplay(n, a, r); + return !0; + }; + e.prototype.replaceSlotDisplayList = function(e, i, s, n) { + var r = this.getArmatureData(i, e || ""); + if (!r || !r.defaultSkin) return !1; + var o = r.defaultSkin.getDisplays(s); + if (!o) return !1; + var a = 0; + for (var l = 0, h = t.DragonBones.webAssembly ? o.size() : o.length; l < h; ++l) { + var c = t.DragonBones.webAssembly ? o.get(l) : o[l]; + this.replaceDisplay(n, c, a++); + } + return !0; + }; + e.prototype.replaceSkin = function(e, i, s, n) { + void 0 === s && (s = !1); + void 0 === n && (n = null); + var r = !1; + var o = i.parent.defaultSkin; + for (var a = 0, l = e.getSlots(); a < l.length; a++) { + var h = l[a]; + if (!(null !== n && n.indexOf(h.name) >= 0)) { + var c = i.getDisplays(h.name); + if (!c) { + null !== o && i !== o && (c = o.getDisplays(h.name)); + if (!c) { + if (s) { + h.rawDisplayDatas = null; + h.displayList = []; + } + continue; + } + } + var u = t.DragonBones.webAssembly ? c.size() : c.length; + var _ = h.displayList; + _.length = u; + for (var d = 0, p = u; d < p; ++d) { + var m = t.DragonBones.webAssembly ? c.get(d) : c[d]; + _[d] = null !== m ? this._getSlotDisplay(null, m, null, h) : null; + } + r = !0; + h.rawDisplayDatas = c; + h.displayList = _; + } + } + return r; + }; + e.prototype.replaceAnimation = function(e, i, s) { + void 0 === s && (s = !0); + var n = i.defaultSkin; + if (null === n) return !1; + if (s) e.animation.animations = i.animations; else { + var r = e.animation.animations; + var o = {}; + for (var a in r) o[a] = r[a]; + for (var a in i.animations) o[a] = i.animations[a]; + e.animation.animations = o; + } + for (var l = 0, h = e.getSlots(); l < h.length; l++) { + var c = h[l]; + var u = 0; + for (var _ = 0, d = c.displayList; _ < d.length; _++) { + var p = d[_]; + if (p instanceof t.Armature) { + var m = n.getDisplays(c.name); + if (null !== m && u < (t.DragonBones.webAssembly ? m.size() : m.length)) { + var f = t.DragonBones.webAssembly ? m.get(u) : m[u]; + if (null !== f && 1 === f.type) { + var g = this.getArmatureData(f.path, f.parent.parent.parent.name); + g && this.replaceAnimation(p, g, s); + } + } + } + u++; + } + } + return !0; + }; + e.prototype.getAllDragonBonesData = function() { + return this._dragonBonesDataMap; + }; + e.prototype.getAllTextureAtlasData = function() { + return this._textureAtlasDataMap; + }; + Object.defineProperty(e.prototype, "clock", { + get: function() { + return this._dragonBones.clock; + }, + enumerable: !0, + configurable: !0 + }); + Object.defineProperty(e.prototype, "dragonBones", { + get: function() { + return this._dragonBones; + }, + enumerable: !0, + configurable: !0 + }); + e.prototype.changeSkin = function(t, e, i) { + void 0 === i && (i = null); + return this.replaceSkin(t, e, !1, i); + }; + e.prototype.copyAnimationsToArmature = function(t, e, i, s, n) { + void 0 === s && (s = ""); + void 0 === n && (n = !0); + var r = this.getArmatureData(e, s); + return !!r && this.replaceAnimation(t, r, n); + }; + e._objectParser = null; + e._binaryParser = null; + return e; + }(); + t.BaseFactory = e; + var i = function() { + this.dataName = ""; + this.textureAtlasName = ""; + this.skin = null; + }; + t.BuildArmaturePackage = i; + }(a5 || (a5 = {})); + !function(t) { + t.BinaryOffset = { + WeigthBoneCount: 0, + WeigthFloatOffset: 1, + WeigthBoneIndices: 2, + MeshVertexCount: 0, + MeshTriangleCount: 1, + MeshFloatOffset: 2, + MeshWeightOffset: 3, + MeshVertexIndices: 4, + TimelineScale: 0, + TimelineOffset: 1, + TimelineKeyFrameCount: 2, + TimelineFrameValueCount: 3, + TimelineFrameValueOffset: 4, + TimelineFrameOffset: 5, + FramePosition: 0, + FrameTweenType: 1, + FrameTweenEasingOrCurveSampleCount: 2, + FrameCurveSamples: 3, + DeformMeshOffset: 0, + DeformCount: 1, + DeformValueCount: 2, + DeformValueOffset: 3, + DeformFloatOffset: 4 + }; + t.ArmatureType = { + Armature: 0, + MovieClip: 1, + Stage: 2 + }; + t.BoneType = { + Bone: 0, + Surface: 1 + }; + t.DisplayType = { + Image: 0, + Armature: 1, + Mesh: 2, + BoundingBox: 3 + }; + t.BoundingBoxType = { + Rectangle: 0, + Ellipse: 1, + Polygon: 2 + }; + t.ActionType = { + Play: 0, + Stop: 1, + GotoAndPlay: 2, + GotoAndStop: 3, + FadeIn: 4, + FadeOut: 5, + Frame: 10, + Sound: 11 + }; + t.BlendMode = { + Normal: 0, + Add: 1, + Alpha: 2, + Darken: 3, + Difference: 4, + Erase: 5, + HardLight: 6, + Invert: 7, + Layer: 8, + Lighten: 9, + Multiply: 10, + Overlay: 11, + Screen: 12, + Subtract: 13 + }; + t.TweenType = { + None: 0, + Line: 1, + Curve: 2, + QuadIn: 3, + QuadOut: 4, + QuadInOut: 5 + }; + t.TimelineType = { + Action: 0, + ZOrder: 1, + BoneAll: 10, + BoneTranslate: 11, + BoneRotate: 12, + BoneScale: 13, + Surface: 50, + SlotDisplay: 20, + SlotColor: 21, + SlotFFD: 22, + IKConstraint: 30, + AnimationTime: 40, + AnimationWeight: 41 + }; + }(a5 || (a5 = {})); + const l5 = a5.DragonBones; + const h5 = a5.BaseObject; + const c5 = a5.Matrix; + a5.Transform; + a5.ColorTransform; + a5.Point; + a5.Rectangle; + a5.UserData; + a5.ActionData; + a5.DragonBonesData; + a5.ArmatureData; + a5.BoneData; + a5.SurfaceData; + a5.SlotData; + a5.ConstraintData; + a5.IKConstraintData; + a5.PathConstraintData; + a5.CanvasData; + a5.SkinData; + a5.VerticesData; + const u5 = a5.DisplayData; + a5.ImageDisplayData; + a5.ArmatureDisplayData; + a5.MeshDisplayData; + a5.BoundingBoxDisplayData; + a5.PathDisplayData; + a5.WeightData; + a5.BoundingBoxData; + a5.RectangleBoundingBoxData; + a5.EllipseBoundingBoxData; + a5.PolygonBoundingBoxData; + a5.AnimationData; + a5.TimelineData; + a5.AnimationConfig; + const _5 = a5.TextureAtlasData; + const d5 = a5.TextureData; + a5.DeformVertices; + const p5 = a5.Armature; + a5.TransformObject; + a5.Bone; + a5.Surface; + const m5 = a5.Slot; + a5.Constraint; + a5.IKConstraint; + a5.PathConstraint; + a5.WorldClock; + const f5 = a5.Animation; + a5.AnimationState; + a5.BonePose; + a5.BlendState; + a5.TimelineState; + a5.TweenTimelineState; + a5.BoneTimelineState; + a5.SlotTimelineState; + a5.ConstraintTimelineState; + a5.ActionTimelineState; + a5.ZOrderTimelineState; + a5.BoneAllTimelineState; + a5.BoneTranslateTimelineState; + a5.BoneRotateTimelineState; + a5.BoneScaleTimelineState; + a5.SurfaceTimelineState; + a5.SlotDislayTimelineState; + a5.SlotColorTimelineState; + a5.DeformTimelineState; + a5.IKConstraintTimelineState; + a5.AnimationTimelineState; + const g5 = a5.EventObject; + a5.DataParser; + a5.ObjectDataParser; + a5.ActionFrame; + a5.BinaryDataParser; + const y5 = a5.BaseFactory; + a5.BuildArmaturePackage; + const b5 = a5.BinaryOffset; + a5.ArmatureType; + const S5 = a5.BoneType; + a5.DisplayType; + a5.BoundingBoxType; + a5.ActionType; + a5.BlendMode; + a5.TweenType; + a5.TimelineType; + var A5, T5, v5; + let E5 = Ul("dragonBones.CCTextureAtlasData")(A5 = (T5 = class extends _5 { + constructor(...t) { + super(...t); + this._renderTexture = null; + } + get renderTexture() { + return this._renderTexture; + } + set renderTexture(t) { + this._renderTexture = t; + if (t) for (const e in this.textures) { + const i = this.textures[e]; + if (!i.spriteFrame) { + let e = null; + if (i.rotated) e = new as(i.region.x, i.region.y, i.region.height, i.region.width); else { + e = new as(i.region.x, i.region.y, i.region.width, i.region.height); + i.spriteFrame = new GI; + i.spriteFrame.texture = t; + i.spriteFrame.rect = e; + } + } + } else for (const t in this.textures) { + this.textures[t].spriteFrame = null; + } + } + static toString() { + return "[class dragonBones.CCTextureAtlasData]"; + } + createTexture() { + return h5.borrowObject(C5); + } + _onClear() { + super._onClear(); + this.renderTexture = null; + } + }, T5)) || A5; + let C5 = Ul("dragonBones.CCTextureData")(v5 = class extends d5 { + constructor(...t) { + super(...t); + this.spriteFrame = null; + } + static toString() { + return "[class dragonBones.CCTextureData]"; + } + _onClear() { + super._onClear(); + this.spriteFrame = null; + } + }) || v5; + var x5, w5; + let R5 = Ul("dragonBones.CCSlot")(x5 = (w5 = class extends m5 { + static toString() { + return "[class dragonBones.CCSlot]"; + } + constructor() { + super(); + this._localVertices = void 0; + this._indices = void 0; + this._matrix = void 0; + this._worldMatrix = void 0; + this._worldMatrixDirty = void 0; + this._color = void 0; + this._localVertices = []; + this._indices = []; + this._matrix = new qi; + this._worldMatrix = new qi; + this._worldMatrixDirty = !0; + this._visible = !1; + this._color = new Bi; + } + getTexture() { + if (this._textureData) { + return this._textureData.spriteFrame.texture; + } + return null; + } + calculWorldMatrix() { + const t = this._armature._parent; + t ? this._mulMat(this._worldMatrix, t._worldMatrix, this._matrix) : qi.copy(this._worldMatrix, this._matrix); + this._worldMatrixDirty = !1; + } + _onClear() { + super._onClear(); + this._localVertices.length = 0; + this._indices.length = 0; + qi.identity(this._matrix); + qi.identity(this._worldMatrix); + this._worldMatrixDirty = !0; + this._color = new Bi; + this._visible = !1; + } + _onUpdateDisplay() {} + _initDisplay(t) {} + _addDisplay() { + this._visible = !0; + } + _replaceDisplay(t) {} + _removeDisplay() { + this._visible = !1; + } + _disposeDisplay(t) {} + _updateVisible() { + this._visible = this.parent.visible; + } + _updateGlueMesh() {} + _updateZOrder() {} + _updateBlendMode() { + if (this._childArmature) { + const t = this._childArmature.getSlots(); + for (let e = 0, i = t.length; e < i; e++) { + const i = t[e]; + i._blendMode = this._blendMode; + i._updateBlendMode(); + } + } + } + _updateColor() { + const t = this._color; + t.r = 255 * this._colorTransform.redMultiplier; + t.g = 255 * this._colorTransform.greenMultiplier; + t.b = 255 * this._colorTransform.blueMultiplier; + t.a = 255 * this._colorTransform.alphaMultiplier; + } + _updateFrame() { + this._indices.length = 0; + const t = this._indices; + const e = this._localVertices; + let i = 0; + let s = 0; + const n = this._textureData; + if (!this._display || this._displayIndex < 0 || !n || !n.spriteFrame) return; + const r = n.spriteFrame.texture; + const o = r.width; + const a = r.height; + const l = n.region; + if (0 === o || 0 === a) { + console.error(`SpriteFrame ${n.spriteFrame.name} incorrect size ${o} x ${a}`); + return; + } + const h = null !== this._deformVertices && this._display === this._meshDisplay ? this._deformVertices.verticesData : null; + if (h) { + const n = h.data; + const r = n.intArray; + const c = n.floatArray; + const u = r[h.offset + b5.MeshVertexCount]; + const _ = r[h.offset + b5.MeshTriangleCount]; + let d = r[h.offset + b5.MeshFloatOffset]; + d < 0 && (d += 65536); + const p = d + 2 * u; + const m = this._armature._armatureData.scale; + for (let t = 0, i = 2 * u; t < i; t += 2) { + e[s++] = c[d + t] * m; + e[s++] = -c[d + t + 1] * m; + if (h.rotated) { + e[s++] = (l.x + (1 - c[p + t]) * l.width) / o; + e[s++] = (l.y + c[p + t + 1] * l.height) / a; + } else { + e[s++] = (l.x + c[p + t] * l.width) / o; + e[s++] = (l.y + c[p + t + 1] * l.height) / a; + } + } + for (let e = 0; e < 3 * _; ++e) t[i++] = r[h.offset + b5.MeshVertexIndices + e]; + e.length = s; + t.length = i; + !!h.weight && this._identityTransform(); + } else { + const i = l.x / o; + const n = (l.y + l.height) / a; + const r = (l.x + l.width) / o; + const h = l.y / a; + e[s++] = 0; + e[s++] = 0; + e[s++] = i; + e[s++] = n; + e[s++] = l.width; + e[s++] = 0; + e[s++] = r; + e[s++] = n; + e[s++] = 0; + e[s++] = l.height; + e[s++] = i; + e[s++] = h; + e[s++] = l.width; + e[s++] = l.height; + e[s++] = r; + e[s++] = h; + t[0] = 0; + t[1] = 1; + t[2] = 2; + t[3] = 1; + t[4] = 3; + t[5] = 2; + e.length = s; + t.length = 6; + } + this._visibleDirty = !0; + this._blendModeDirty = !0; + this._colorDirty = !0; + } + _updateMesh() { + const t = this._armature._armatureData.scale; + const e = this._deformVertices.vertices; + const i = this._deformVertices.bones; + const s = this._deformVertices.verticesData; + const n = s.weight; + const r = e.length > 0 && s.inheritDeform; + const o = this._localVertices; + if (n) { + const a = s.data; + const l = a.intArray; + const h = a.floatArray; + const c = l[s.offset + b5.MeshVertexCount]; + let u = l[n.offset + b5.WeigthFloatOffset]; + u < 0 && (u += 65536); + for (let s = 0, a = n.offset + b5.WeigthBoneIndices + i.length, _ = u, d = 0, p = 0; s < c; s++, + p += 4) { + const s = l[a++]; + let n = 0; + let c = 0; + for (let o = 0; o < s; ++o) { + const s = i[l[a++]]; + if (null !== s) { + const i = s.globalTransformMatrix; + const o = h[_++]; + let a = h[_++] * t; + let l = h[_++] * t; + if (r) { + a += e[d++]; + l += e[d++]; + } + n += (i.a * a + i.c * l + i.tx) * o; + c += (i.b * a + i.d * l + i.ty) * o; + } + } + o[p] = n; + o[p + 1] = -c; + } + } else if (r) { + const i = this._parent._boneData.type !== S5.Bone; + const n = s.data; + const r = n.intArray; + const a = n.floatArray; + const l = r[s.offset + b5.MeshVertexCount]; + let h = r[s.offset + b5.MeshFloatOffset]; + h < 0 && (h += 65536); + for (let s = 0, n = l, r = 0; s < n; s++, r += 4) { + const n = a[h + 2 * s] * t + e[2 * s]; + const l = a[h + 2 * s + 1] * t + e[2 * s + 1]; + if (i) { + const t = this._parent._getGlobalTransformMatrix(n, l); + o[r] = t.a * n + t.c * l + t.tx; + o[r + 1] = -t.b * n + t.d * l + t.ty; + } else { + o[r] = n; + o[r + 1] = -l; + } + } + } + n && this._identityTransform(); + } + _identityTransform() { + const t = this._matrix; + t.m00 = 1; + t.m01 = 0; + t.m04 = -0; + t.m05 = -1; + t.m12 = 0; + t.m13 = 0; + this._worldMatrixDirty = !0; + } + _updateTransform() { + const t = this._matrix; + t.m00 = this.globalTransformMatrix.a; + t.m01 = this.globalTransformMatrix.b; + t.m04 = -this.globalTransformMatrix.c; + t.m05 = -this.globalTransformMatrix.d; + if (this._childArmature) { + t.m12 = this.globalTransformMatrix.tx; + t.m13 = this.globalTransformMatrix.ty; + } else { + t.m12 = this.globalTransformMatrix.tx - (this.globalTransformMatrix.a * this._pivotX - this.globalTransformMatrix.c * this._pivotY); + t.m13 = this.globalTransformMatrix.ty - (this.globalTransformMatrix.b * this._pivotX - this.globalTransformMatrix.d * this._pivotY); + } + this._worldMatrixDirty = !0; + } + updateWorldMatrix() { + if (!this._armature) return; + const t = this._armature._parent; + t && t.updateWorldMatrix(); + if (this._worldMatrixDirty) { + this.calculWorldMatrix(); + const t = this.childArmature; + if (!t) return; + const e = t.getSlots(); + for (let t = 0, i = e.length; t < i; t++) { + const i = e[t]; + i && (i._worldMatrixDirty = !0); + } + } + } + _mulMat(t, e, i) { + const s = e.m00; + const n = e.m01; + const r = e.m04; + const o = e.m05; + const a = e.m12; + const l = e.m13; + const h = i.m00; + const c = i.m01; + const u = i.m04; + const _ = i.m05; + const d = i.m12; + const p = i.m13; + if (0 !== n || 0 !== r) { + t.m00 = h * s + c * r; + t.m01 = h * n + c * o; + t.m04 = u * s + _ * r; + t.m05 = u * n + _ * o; + t.m12 = s * d + r * p + a; + t.m13 = n * d + o * p + l; + } else { + t.m00 = h * s; + t.m01 = c * o; + t.m04 = u * s; + t.m05 = _ * o; + t.m12 = s * d + a; + t.m13 = o * p + l; + } + } + }, w5)) || x5; + var I5, M5; + let B5 = Ul("dragonBones.CCArmatureDisplay")(I5 = (M5 = class extends u5 { + get node() { + return this; + } + constructor() { + super(); + this.shouldAdvanced = !1; + this._ccNode = null; + this._ccComponent = null; + this._eventTarget = void 0; + this._armature = null; + this._eventTarget = new vo; + } + hasEvent(t) { + console.warn("Method not implemented."); + return !1; + } + addEvent(t, e, i) { + console.warn("Method not implemented."); + } + removeEvent(t, e, i) { + console.warn("Method not implemented."); + } + setEventTarget(t) { + this._eventTarget = t; + } + getRootDisplay() { + let t = this._armature._parent; + if (!t) return this; + let e; + for (;t; ) { + e = t; + t = t._armature._parent; + } + return e._armature.display; + } + convertToRootSpace(t) { + const e = this._armature._parent; + if (!e) return t; + e.updateWorldMatrix(); + const i = e._worldMatrix; + const s = new Pi(0, 0); + s.x = t.x * i.m00 + t.y * i.m04 + i.m12; + s.y = t.x * i.m01 + t.y * i.m05 + i.m13; + return s; + } + convertToWorldSpace(t) { + var e; + const i = this.convertToRootSpace(t); + const s = this.getRootNode(); + return null == s || null === (e = s._uiProps.uiTransformComp) || void 0 === e ? void 0 : e.convertToWorldSpaceAR(i); + } + getRootNode() { + const t = this.getRootDisplay(); + return t && t._ccNode; + } + dbInit(t) { + this._armature = t; + } + dbClear() { + this._armature = null; + } + dbUpdate() { + this._ccComponent && this._ccComponent.markForUpdateRenderData(); + } + advanceTimeBySelf(t) { + this.shouldAdvanced = !!t; + } + hasDBEventListener(t) { + return this._eventTarget.hasEventListener(t); + } + addDBEventListener(t, e, i) { + this._eventTarget.on(t, e, i); + } + removeDBEventListener(t, e, i) { + this._eventTarget.off(t, e, i); + } + dispatchDBEvent(t, e) { + this._eventTarget.emit(t, e); + } + }, M5)) || I5; + var D5, P5, O5; + let N5 = Ul("CCFactory")(D5 = (O5 = P5 = class t extends y5 { + static getInstance() { + t._factory || (t._factory = new t); + return t._factory; + } + constructor() { + super(); + this.id = void 0; + this.uuid = void 0; + this._slots = void 0; + const t = new B5; + this._dragonBones = new l5(t); + if (IR.getScheduler()) { + BR.on(MR.EVENT_RESTART, this.onRestart, this); + this.initUpdate(); + } + this.id = this.uuid = "CCFactory"; + } + onRestart() { + t._factory = null; + } + initUpdate(t) { + Rg.enableForTarget(this); + IR.getScheduler().scheduleUpdate(this, Tg.Priority.HIGH, !1); + } + update(t) { + this._dragonBones.advanceTime(t); + } + getDragonBonesDataByRawData(t) { + return (t instanceof ArrayBuffer ? y5._binaryParser : this._dataParser).parseDragonBonesData(t, 1); + } + buildArmatureDisplay(t, e, i, s) { + const n = this.buildArmature(t, e, i, s); + return n ? n._display : null; + } + createArmatureNode(t, e, i) { + let s = (i = i || new _y).getComponent("dragonBones.ArmatureDisplay"); + s || (s = i.addComponent("dragonBones.ArmatureDisplay")); + i.name = e; + s._armatureName = e; + s._dragonAsset = t.dragonAsset; + s._dragonAtlasAsset = t.dragonAtlasAsset; + s._init(); + return s; + } + _buildTextureAtlasData(t, e) { + t ? t.renderTexture = e : t = h5.borrowObject(E5); + return t; + } + _sortSlots() { + const t = this._slots; + const e = []; + for (let i = 0, s = t.length; i < s; i++) { + const s = t[i]; + const n = s._zOrder; + let r = !1; + for (let t = e.length - 1; t >= 0; t--) if (n >= e[t]._zOrder) { + e.splice(t + 1, 0, s); + r = !0; + break; + } + r || e.unshift(s); + } + this._slots = e; + } + _buildArmature(t) { + const e = h5.borrowObject(p5); + e._skinData = t.skin; + e._animation = h5.borrowObject(f5); + e._animation._armature = e; + e._animation.animations = t.armature.animations; + e._isChildArmature = !1; + const i = new B5; + e.init(t.armature, i, i, this._dragonBones); + return e; + } + _buildSlot(t, e, i) { + const s = h5.borrowObject(R5); + const n = s; + s.init(e, i, n, n); + return s; + } + getDragonBonesDataByUUID(t) { + for (const e in this._dragonBonesDataMap) if (-1 !== e.indexOf(t)) return this._dragonBonesDataMap[e]; + return null; + } + removeDragonBonesDataByUUID(t, e) { + void 0 === e && (e = !0); + for (const i in this._dragonBonesDataMap) if (-1 !== i.indexOf(t)) { + e && this._dragonBones.bufferObject(this._dragonBonesDataMap[i]); + delete this._dragonBonesDataMap[i]; + } + } + }, P5._factory = null, O5)) || D5; + const L5 = 1 / 60; + const F5 = []; + const V5 = []; + let k5 = 0; + let U5 = 0; + let G5 = 0; + let z5 = null; + let H5 = null; + let j5 = 0; + let X5 = 0; + let W5 = 0; + let Y5 = 0; + let q5 = 0; + let K5; + let J5; + class Z5 { + constructor() { + this.maxVertexCount = 0; + this.maxIndexCount = 0; + this._privateMode = !1; + this._inited = !1; + this._invalid = !0; + this._enableCacheAttachedInfo = !1; + this.frames = []; + this.totalTime = 0; + this.isCompleted = !1; + this._frameIdx = -1; + this._armatureInfo = null; + this._animationName = null; + this._tempSegments = null; + this._tempColors = null; + this._tempBoneInfos = null; + } + init(t, e) { + this._inited = !0; + this._armatureInfo = t; + this._animationName = e; + } + clear() { + this._inited = !1; + for (let t = 0, e = this.frames.length; t < e; t++) { + this.frames[t].segments.length = 0; + } + this.invalidAllFrame(); + } + begin() { + if (!this._invalid) return; + const t = this._armatureInfo; + const e = t.curAnimationCache; + e && e !== this && (this._privateMode ? e.invalidAllFrame() : e.updateToFrame()); + t.armature.animation.play(this._animationName, 1); + t.curAnimationCache = this; + this._invalid = !1; + this._frameIdx = -1; + this.totalTime = 0; + this.isCompleted = !1; + } + end() { + if (!this._needToUpdate()) { + this._armatureInfo.curAnimationCache = null; + this.frames.length = this._frameIdx + 1; + this.isCompleted = !0; + } + } + _needToUpdate(t) { + return !this._armatureInfo.armature.animation.isCompleted && this.totalTime < 30 && (void 0 === t || this._frameIdx < t); + } + updateToFrame(t) { + if (!this._inited) return; + this.begin(); + if (!this._needToUpdate(t)) return; + const e = this._armatureInfo.armature; + do { + e.advanceTime(L5); + this._frameIdx++; + this.updateFrame(e, this._frameIdx); + this.totalTime += L5; + } while (this._needToUpdate(t)); + this.end(); + } + isInited() { + return this._inited; + } + isInvalid() { + return this._invalid; + } + invalidAllFrame() { + this.isCompleted = !1; + this._invalid = !0; + } + updateAllFrame() { + this.invalidAllFrame(); + this.updateToFrame(); + } + enableCacheAttachedInfo() { + if (!this._enableCacheAttachedInfo) { + this._enableCacheAttachedInfo = !0; + this.invalidAllFrame(); + } + } + updateFrame(t, e) { + G5 = 0; + k5 = 0; + U5 = 0; + z5 = null; + H5 = null; + j5 = 0; + X5 = 0; + W5 = 0; + Y5 = 0; + q5 = 0; + this.frames[e] = this.frames[e] || { + segments: [], + colors: [], + boneInfos: [], + vertices: null, + uintVert: null, + indices: null + }; + const i = this.frames[e]; + const s = this._tempSegments = i.segments; + const n = this._tempColors = i.colors; + const r = this._tempBoneInfos = i.boneInfos; + this._traverseArmature(t, 1); + Y5 > 0 && (n[Y5 - 1].vfOffset = G5); + n.length = Y5; + r.length = k5; + const o = W5 - 1; + if (o >= 0) if (X5 > 0) { + const t = s[o]; + t.indexCount = X5; + t.vfCount = 9 * j5; + t.vertexCount = j5; + s.length = W5; + } else s.length = W5 - 1; + if (0 === s.length) return; + let a = i.vertices; + const l = G5 / 5; + const h = 9 * l; + (!a || a.length < G5) && (a = i.vertices = new Float32Array(h)); + let c; + for (let t = 0, e = 0; t < h; ) { + a[t] = F5[e++]; + a[t + 1] = F5[e++]; + a[t + 3] = F5[e++]; + a[t + 4] = F5[e++]; + c = F5[e++]; + a[t + 5] = (255 & c) / 255; + a[t + 6] = (c >> 8 & 255) / 255; + a[t + 7] = (c >> 16 & 255) / 255; + a[t + 8] = (c >> 24 & 255) / 255; + t += 9; + } + let u = i.indices; + (!u || u.length < U5) && (u = i.indices = new Uint16Array(U5)); + for (let t = 0; t < U5; t++) u[t] = V5[t]; + i.vertices = a; + i.indices = u; + this.maxVertexCount = l > this.maxVertexCount ? l : this.maxVertexCount; + this.maxIndexCount = u.length > this.maxIndexCount ? u.length : this.maxIndexCount; + } + _traverseArmature(t, e) { + const i = this._tempColors; + const s = this._tempSegments; + const n = this._tempBoneInfos; + const r = t._slots; + let o; + let a; + let l; + let h; + let c; + let u; + let _; + let d; + let p; + const m = t._bones; + if (this._enableCacheAttachedInfo) for (let t = 0, e = m.length; t < e; t++, k5++) { + const e = m[t]; + let i = n[k5]; + i || (i = n[k5] = { + globalTransformMatrix: new c5 + }); + const s = e.globalTransformMatrix; + i.globalTransformMatrix.copyFrom(s); + } + for (let t = 0, n = r.length; t < n; t++) { + l = r[t]; + if (l._visible && l._displayData) { + l.updateWorldMatrix(); + c = l._color; + if (l.childArmature) this._traverseArmature(l.childArmature, e * c.a / 255); else { + _ = l.getTexture(); + if (_) { + if (z5 !== _.nativeUrl || H5 !== l._blendMode) { + z5 = _.nativeUrl; + H5 = l._blendMode; + d = W5 - 1; + if (d >= 0) if (X5 > 0) { + p = s[d]; + p.indexCount = X5; + p.vertexCount = j5; + p.vfCount = 9 * j5; + } else W5--; + s[W5] = { + tex: _, + blendMode: l._blendMode, + indexCount: 0, + vertexCount: 0, + vfCount: 0 + }; + W5++; + X5 = 0; + j5 = 0; + } + u = (c.a * e << 24 >>> 0) + (c.b << 16) + (c.g << 8) + c.r; + if (q5 !== u) { + q5 = u; + Y5 > 0 && (i[Y5 - 1].vfOffset = G5); + i[Y5++] = { + r: c.r, + g: c.g, + b: c.b, + a: c.a * e, + vfOffset: 0 + }; + } + o = l._localVertices; + a = l._indices; + h = l._worldMatrix; + for (let t = 0, e = o.length; t < e; ) { + K5 = o[t++]; + J5 = o[t++]; + F5[G5++] = K5 * h.m00 + J5 * h.m04 + h.m12; + F5[G5++] = K5 * h.m01 + J5 * h.m05 + h.m13; + F5[G5++] = o[t++]; + F5[G5++] = o[t++]; + F5[G5++] = u; + } + for (let t = 0, e = a.length; t < e; t++) V5[U5++] = j5 + a[t]; + X5 += a.length; + j5 += o.length / 4; + } + } + } + } + } + } + class Q5 { + constructor() { + this._privateMode = !1; + this._animationPool = {}; + this._armatureCache = {}; + } + enablePrivateMode() { + this._privateMode = !0; + } + dispose() { + for (const t in this._armatureCache) { + const e = this._armatureCache[t]; + if (e) { + const t = e.armature; + t && t.dispose(); + } + } + this._armatureCache = {}; + this._animationPool = {}; + } + _removeArmature(t) { + const e = this._armatureCache[t]; + const i = e.animationsCache; + for (const e in i) { + const s = i[e]; + if (s) { + this._animationPool[`${t}#${e}`] = s; + s.clear(); + } + } + const s = e.armature; + s && s.dispose(); + delete this._armatureCache[t]; + } + resetArmature(t) { + for (const e in this._armatureCache) -1 !== e.indexOf(t) && this._removeArmature(e); + } + getArmatureCache(t, e, i) { + const s = this._armatureCache[e]; + let n; + if (s) n = s.armature; else { + const s = N5.getInstance().buildArmatureDisplay(t, e, "", i); + if (!s || !s._armature) return null; + n = s._armature; + if (!Q5.canCache(n)) { + n.dispose(); + return null; + } + this._armatureCache[e] = { + armature: n, + animationsCache: {}, + curAnimationCache: null + }; + } + return n; + } + getAnimationCache(t, e) { + const i = this._armatureCache[t]; + if (!i) return null; + return i.animationsCache[e]; + } + initAnimationCache(t, e) { + if (!e) return null; + const i = this._armatureCache[t]; + const s = i && i.armature; + if (!s) return null; + if (!s.animation.hasAnimation(e)) return null; + const n = i.animationsCache; + let r = n[e]; + if (!r) { + const s = `${t}#${e}`; + r = this._animationPool[s]; + if (r) delete this._animationPool[s]; else { + r = new Z5; + r._privateMode = this._privateMode; + } + r.init(i, e); + n[e] = r; + } + return r; + } + invalidAnimationCache(t) { + const e = this._armatureCache[t]; + if (!(e && e.armature)) return; + const i = e.animationsCache; + for (const t in i) { + i[t].invalidAllFrame(); + } + } + updateAnimationCache(t, e) { + if (e) { + const i = this.initAnimationCache(t, e); + if (!i) return; + i.updateAllFrame(); + } else { + const e = this._armatureCache[t]; + if (!(e && e.armature)) return; + const i = e.animationsCache; + for (const t in i) { + i[t].updateAllFrame(); + } + } + } + static canCache(t) { + const e = t._slots; + for (let t = 0, i = e.length; t < i; t++) { + if (e[t].childArmature) return !1; + } + return !0; + } + } + Q5.FrameTime = L5; + Q5.sharedCache = new Q5; + var $5, t4, e4, i4; + let s4 = Ul("dragonBones.DragonBonesAsset")($5 = (t4 = (i4 = class extends gc { + constructor(...t) { + super(...t); + Ml(this, "_dragonBonesJson", e4, this); + this._factory = null; + this._dragonBonesJsonData = void 0; + this._armaturesEnum = null; + } + get dragonBonesJson() { + return this._dragonBonesJson; + } + set dragonBonesJson(t) { + this._dragonBonesJson = t; + this._dragonBonesJsonData = JSON.parse(t); + this.reset(); + } + constructctor() { + this.reset(); + } + createNode(t) { + const e = new _y(this.name); + e.addComponent("dragonBones.ArmatureDisplay").dragonAsset = this; + return t(null, e); + } + reset() { + this._clear(); + } + init(t, e) { + this._factory = t || N5.getInstance(); + !this._dragonBonesJsonData && this.dragonBonesJson && (this._dragonBonesJsonData = JSON.parse(this.dragonBonesJson)); + let i = null; + i = this._dragonBonesJsonData ? this._dragonBonesJsonData : this._nativeAsset; + if (!this._uuid) { + const t = this._factory.getDragonBonesDataByRawData(i); + t ? this._uuid = t.name : console.warn("dragonbones name is empty"); + } + const s = `${this._uuid}#${e}`; + if (this._factory.getDragonBonesData(s)) return s; + this._factory.parseDragonBonesData(i instanceof ArrayBuffer ? i : i.buffer instanceof ArrayBuffer ? i.buffer : i, s); + return s; + } + getArmatureEnum() { + if (this._armaturesEnum) return this._armaturesEnum; + this.init(); + const t = this._factory.getDragonBonesDataByUUID(this._uuid); + if (t) { + const e = t.armatureNames; + const i = {}; + for (let t = 0; t < e.length; t++) { + i[e[t]] = t; + } + return this._armaturesEnum = oe(i); + } + return null; + } + getAnimsEnum(t) { + this.init(); + const e = this._factory.getDragonBonesDataByUUID(this._uuid); + if (e) { + const i = e.getArmature(t); + if (!i) return null; + const s = { + "": 0 + }; + const n = i.animations; + let r = 0; + for (const t in n) if (n.hasOwnProperty(t)) { + s[t] = r + 1; + r++; + } + return oe(s); + } + return null; + } + destroy() { + this._clear(); + return super.destroy(); + } + _clear() { + if (this._factory) { + Q5.sharedCache.resetArmature(this._uuid); + this._factory.removeDragonBonesDataByUUID(this._uuid, !0); + } + } + }, i4), e4 = Bl(t4.prototype, "_dragonBonesJson", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), t4)) || $5; + m.internal.DragonBonesAsset = s4; + var n4, r4, o4, a4, l4, h4, c4, u4, _4; + let d4 = (n4 = Ul("dragonBones.DragonBonesAtlasAsset"), r4 = Th(LC), n4(o4 = (a4 = (_4 = class extends gc { + constructor() { + super(); + Ml(this, "_atlasJson", l4, this); + Ml(this, "_texture", h4, this); + Ml(this, "_atlasJsonData", c4, this); + this._factory = null; + Ml(this, "_textureAtlasData", u4, this); + this._clear(); + } + get atlasJson() { + return this._atlasJson; + } + set atlasJson(t) { + this._atlasJson = t; + this._atlasJsonData = JSON.parse(this.atlasJson); + this._clear(); + } + get texture() { + return this._texture; + } + set texture(t) { + this._texture = t; + this._clear(); + } + createNode(t) { + const e = new _y(this.name); + e.addComponent("dragonBones.ArmatureDisplay").dragonAtlasAsset = this; + return t(null, e); + } + init(t) { + this._factory = t; + this._atlasJsonData || (this._atlasJsonData = JSON.parse(this.atlasJson)); + const e = this._atlasJsonData; + this._uuid = this._uuid || e.name; + this._textureAtlasData ? t.addTextureAtlasData(this._textureAtlasData, this._uuid) : this._textureAtlasData = t.parseTextureAtlasData(e, this.texture, this._uuid); + } + destroy() { + this._clear(); + return super.destroy(); + } + _clear() {} + }, _4), l4 = Bl(a4.prototype, "_atlasJson", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), h4 = Bl(a4.prototype, "_texture", [ Yl, r4 ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), c4 = Bl(a4.prototype, "_atlasJsonData", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return {}; + } + }), u4 = Bl(a4.prototype, "_textureAtlasData", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), a4)) || o4); + m.internal.DragonBonesAtlasAsset = d4; + var p4; + const m4 = new qi; + let f4 = Ul("dragonBones.AttachUtil")(p4 = class { + constructor() { + this._inited = !1; + this._armature = null; + this._armatureNode = null; + this._armatureDisplay = null; + } + init(t) { + this._inited = !0; + this._armature = t._armature; + this._armatureNode = t.node; + this._armatureDisplay = t; + } + reset() { + this._inited = !1; + this._armature = null; + this._armatureNode = null; + this._armatureDisplay = null; + } + _syncAttachedNode() { + if (!this._inited) return; + this._armatureNode.worldMatrix; + let t = null; + const e = this._armatureDisplay.isAnimationCached(); + if (e && this._armatureDisplay) { + t = this._armatureDisplay._curFrame && this._armatureDisplay._curFrame.boneInfos; + if (!t) return; + } + const i = this._armatureDisplay.sockets; + const s = this._armatureDisplay.socketNodes; + const n = (t, e) => { + const i = m4; + i.m00 = e.a; + i.m01 = e.b; + i.m04 = -e.c; + i.m05 = -e.d; + i.m12 = e.tx; + i.m13 = e.ty; + t.matrix = m4; + }; + const r = this._armature.getBones(); + for (let o = i.length - 1; o >= 0; o--) { + const a = i[o]; + const l = a.target; + if (!l) continue; + if (!l.isValid) { + s.delete(a.path); + i.splice(o, 1); + continue; + } + const h = e ? t[a.boneIndex] : r[a.boneIndex]; + h && n(l, h.globalTransformMatrix); + } + } + }) || p4; + class g4 extends Tg { + constructor() { + super(); + this._armatures = new Set; + } + static getInstance() { + if (!g4._instance) { + g4._instance = new g4; + IR.registerSystem(g4.ID, g4._instance, Tg.Priority.HIGH); + } + return g4._instance; + } + add(t) { + t && (this._armatures.has(t) || this._armatures.add(t)); + } + remove(t) { + t && this._armatures.has(t) && this._armatures.delete(t); + } + postUpdate(t) { + this._armatures && this._armatures.forEach((e => { + e.updateAnimation(t); + })); + } + prepareRenderData() { + this._armatures && this._armatures.forEach((t => { + t.markForUpdateRenderData(); + })); + } + } + g4.ID = "ARMATURE"; + g4._instance = void 0; + m.internal.ArmatureSystem = g4; + var y4, b4, S4, A4, T4, v4, E4, C4, x4, w4, R4, I4, M4, B4, D4, P4, O4, N4, L4, F4, V4, k4, U4, G4, z4, H4, j4, X4, W4, Y4, q4, K4, J4, Z4, Q4, $4, t8, e8, i8, s8, n8, r8, o8, a8, l8, h8, c8, u8, _8, d8; + var p8; + !function(t) { + t[t.default = -1] = "default"; + }(p8 || (p8 = {})); + he(p8); + var m8; + !function(t) { + t[t[""] = 0] = ""; + }(m8 || (m8 = {})); + he(m8); + var f8; + !function(t) { + t[t.REALTIME = 0] = "REALTIME"; + }(f8 || (f8 = {})); + he(m8); + let g8; + !function(t) { + t[t.REALTIME = 0] = "REALTIME"; + t[t.SHARED_CACHE = 1] = "SHARED_CACHE"; + t[t.PRIVATE_CACHE = 2] = "PRIVATE_CACHE"; + }(g8 || (g8 = {})); + he(g8); + function y8(t, e, i) { + si.Attr.setClassAttr(t, e, "type", "Enum"); + si.Attr.setClassAttr(t, e, "enumList", oe.getList(i)); + } + let b8 = (y4 = Ul("dragonBones.ArmatureDisplay.DragonBoneSocket"), b4 = Th(_y), + y4(S4 = (A4 = (E4 = class { + constructor(t = "", e = null) { + Ml(this, "path", T4, this); + Ml(this, "target", v4, this); + this.boneIndex = null; + this.path = t; + this.target = e; + } + }, E4), T4 = Bl(A4.prototype, "path", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), v4 = Bl(A4.prototype, "target", [ b4, nh, Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), A4)) || S4); + Wt(b8, "dragonBones.ArmatureDisplay.DragonBoneSocket"); + let S8 = (C4 = Ul("dragonBones.ArmatureDisplay"), x4 = sh(), w4 = $l(), R4 = Th(s4), + I4 = lh(), M4 = Th(d4), B4 = lh(), D4 = rh(), P4 = rh(), O4 = ah(), N4 = Th(p8), + L4 = lh(), F4 = Th(m8), V4 = ah(), k4 = lh(), U4 = ah(), G4 = lh(), z4 = lh(), H4 = lh(), + j4 = lh(), X4 = lh(), W4 = Th([ b8 ]), Y4 = lh(), q4 = Th(hm), K4 = ph(), J4 = ah(), + C4(Z4 = x4(Z4 = w4(Z4 = Ql(Z4 = (Q4 = (d8 = _8 = class t extends uD { + get dragonAsset() { + return this._dragonAsset; + } + set dragonAsset(t) { + this._dragonAsset = t; + this.destroyRenderData(); + this._refresh(); + } + get dragonAtlasAsset() { + return this._dragonAtlasAsset; + } + set dragonAtlasAsset(t) { + this._dragonAtlasAsset = t; + this._parseDragonAtlasAsset(); + this._refresh(); + } + get armatureName() { + return this._armatureName; + } + set armatureName(t) { + this._armatureName = t; + const e = this.getAnimationNames(this._armatureName); + (!this.animationName || e.indexOf(this.animationName) < 0) && (this.animationName = ""); + this._armature && !this.isAnimationCached() && this._factory._dragonBones.clock.remove(this._armature); + this._refresh(); + this._armature && !this.isAnimationCached() && this._factory._dragonBones.clock.add(this._armature); + } + get animationName() { + return this._animationName; + } + set animationName(t) { + this._animationName = t; + } + get _defaultArmatureIndex() { + return this._defaultArmatureIndexValue; + } + set _defaultArmatureIndex(t) { + this._defaultArmatureIndexValue = t; + let e = ""; + if (this.dragonAsset) { + let t; + this.dragonAsset && (t = this.dragonAsset.getArmatureEnum()); + if (!t) { + F(7400, this.name); + return; + } + e = t[this._defaultArmatureIndex]; + } + void 0 !== e ? this.armatureName = e : F(7401, this.name); + this.markForUpdateRenderData(); + } + get _animationIndex() { + return this._animationIndexValue; + } + set _animationIndex(t) { + this._animationIndexValue = t; + if (0 === this._animationIndex) { + this.animationName = ""; + return; + } + let e; + this.dragonAsset && (e = this.dragonAsset.getAnimsEnum(this.armatureName)); + if (!e) return; + const i = e[this._animationIndex]; + void 0 !== i ? this.playAnimation(i, this.playTimes) : F(7402, this.name); + } + get _defaultCacheMode() { + return this._defaultCacheModeValue; + } + set _defaultCacheMode(t) { + this._defaultCacheModeValue = t; + if (this._defaultCacheMode === g8.REALTIME || !this._armature || Q5.canCache(this._armature)) this.setAnimationCacheMode(this._defaultCacheMode); else { + this._defaultCacheMode = g8.REALTIME; + console.warn("Animation cache mode doesn't support skeletal nesting"); + } + } + get timeScale() { + return this._timeScale; + } + set timeScale(t) { + this._timeScale = t; + this._armature && !this.isAnimationCached() && (this._armature.animation.timeScale = this.timeScale); + } + get debugBones() { + return this._debugBones; + } + set debugBones(t) { + this._debugBones = t; + this._updateDebugDraw(); + } + get sockets() { + return this._sockets; + } + set sockets(t) { + this._verifySockets(t); + this._sockets = t; + this._updateSocketBindings(); + t.length > 0 && this._frameCache && this._frameCache.enableCacheAttachedInfo(); + } + get socketNodes() { + return this._socketNodes; + } + get drawList() { + return this._drawList; + } + requestDrawInfo(t) { + this._drawInfoList[t] || (this._drawInfoList[t] = new aB); + return this._drawInfoList[t]; + } + constructor() { + super(); + Ml(this, "playTimes", $4, this); + Ml(this, "premultipliedAlpha", t8, this); + this._armature = null; + this.attachUtil = void 0; + Ml(this, "_defaultArmatureIndexValue", e8, this); + Ml(this, "_dragonAsset", i8, this); + Ml(this, "_dragonAtlasAsset", s8, this); + Ml(this, "_armatureName", n8, this); + Ml(this, "_animationName", r8, this); + Ml(this, "_animationIndexValue", o8, this); + this._preCacheMode = -1; + this._cacheMode = g8.REALTIME; + Ml(this, "_defaultCacheModeValue", a8, this); + Ml(this, "_timeScale", l8, this); + Ml(this, "_playTimes", h8, this); + Ml(this, "_debugBones", c8, this); + this._debugDraw = null; + this._armatureKey = ""; + this._accTime = 0; + this._playCount = 0; + this._frameCache = null; + this._curFrame = null; + this._playing = !1; + this._armatureCache = null; + this._eventTarget = void 0; + this._factory = null; + this._displayProxy = null; + this._drawIdx = 0; + this._drawList = new to((() => ({ + material: null, + texture: null, + indexOffset: 0, + indexCount: 0 + })), 1); + this.maxVertexCount = 0; + this.maxIndexCount = 0; + this._materialCache = {}; + this._enumArmatures = oe({}); + this._enumAnimations = oe({}); + this._socketNodes = new Map; + this._cachedSockets = new Map; + Ml(this, "_sockets", u8, this); + this._inited = void 0; + this._drawInfoList = []; + this._cacheModeEnum = void 0; + this._eventTarget = new vo; + this._inited = !1; + this.attachUtil = new f4; + this.initFactory(); + y8(this, "_animationIndex", this._enumAnimations); + y8(this, "_defaultArmatureIndex", this._enumArmatures); + this._useVertexOpacity = !0; + } + initFactory() { + this._factory = N5.getInstance(); + } + onLoad() { + super.onLoad(); + const t = this.node.children; + for (let e = 0, i = t.length; e < i; e++) { + const i = t[e]; + 0 === (i.name && i.name.search("CHILD_ARMATURE-")) && i.destroy(); + } + } + _requestDrawData(t, e, i, s) { + const n = this._drawList.add(); + n.material = t; + n.texture = e; + n.indexOffset = i; + n.indexCount = s; + return n; + } + destroyRenderData() { + this._drawList.reset(); + super.destroyRenderData(); + } + getMaterialForBlend(t, e) { + const i = `${t}/${e}`; + let s = this._materialCache[i]; + if (s) return s; + const n = this.getMaterial(0); + s = new uS({ + parent: n, + subModelIdx: 0, + owner: this + }); + s.recompileShaders({ + USE_LOCAL: !0 + }, 0); + this._materialCache[i] = s; + s.overridePipelineStates({ + blendState: { + targets: [ { + blendSrc: t, + blendDst: e + } ] + } + }); + return s; + } + get customMaterial() { + return this._customMaterial; + } + set customMaterial(t) { + this._customMaterial = t; + this._cleanMaterialCache(); + this.setMaterial(this._customMaterial, 0); + this.markForUpdateRenderData(); + } + _render(t) { + if (this.renderData && this._drawList) { + const e = this.renderData; + const i = e.chunk; + const s = i.vertexAccessor; + const n = e.getMeshBuffer(); + const r = n.indexOffset; + s.appendIndices(i.bufferId, e.indices); + for (let e = 0; e < this._drawList.length; e++) { + this._drawIdx = e; + const i = this._drawList.data[e]; + if (i.texture) { + const e = n.requireFreeIA(t.device); + e.firstIndex = r + i.indexOffset; + e.indexCount = i.indexCount; + t.commitIA(this, e, i.texture, i.material, this.node); + } + } + } + } + __preload() { + super.__preload(); + this._init(); + } + _init() { + this._cacheMode = this._defaultCacheMode; + if (this._inited) return; + this._inited = !0; + this._parseDragonAtlasAsset(); + this._refresh(); + const t = this.node.children; + for (let e = 0, i = t.length; e < i; e++) { + const i = t[e]; + i && "DEBUG_DRAW_NODE" === i.name && i.destroy(); + } + this._updateDebugDraw(); + this._indexBoneSockets(); + this._updateSocketBindings(); + } + getArmatureKey() { + return this._armatureKey; + } + setAnimationCacheMode(t) { + if (this._preCacheMode !== t) { + this._cacheMode = t; + this._buildArmature(); + this._armature && !this.isAnimationCached() && this._factory._dragonBones.clock.add(this._armature); + this._updateSocketBindings(); + this.markForUpdateRenderData(); + } + } + isAnimationCached() { + return this._cacheMode !== g8.REALTIME; + } + onEnable() { + super.onEnable(); + this._armature && !this.isAnimationCached() && this._factory._dragonBones.clock.add(this._armature); + this._flushAssembler(); + g4.getInstance().add(this); + } + onDisable() { + super.onDisable(); + this._armature && !this.isAnimationCached() && this._factory._dragonBones.clock.remove(this._armature); + g4.getInstance().remove(this); + } + _emitCacheCompleteEvent() { + this._eventTarget.emit(g5.LOOP_COMPLETE); + this._eventTarget.emit(g5.COMPLETE); + } + updateAnimation(t) { + if (!this.isAnimationCached()) return; + if (!this._frameCache) return; + this.markForUpdateRenderData(); + const e = this._frameCache; + if (!e.isInited()) return; + const i = e.frames; + if (!this._playing) { + if (e.isInvalid()) { + e.updateToFrame(); + this._curFrame = i[i.length - 1]; + if (this.renderData && (this.renderData.vertexCount < e.maxVertexCount || this.renderData.indexCount < e.maxIndexCount)) { + this.maxVertexCount = e.maxVertexCount > this.maxVertexCount ? e.maxVertexCount : this.maxVertexCount; + this.maxIndexCount = e.maxIndexCount > this.maxIndexCount ? e.maxIndexCount : this.maxIndexCount; + this.renderData.resize(this.maxVertexCount, this.maxIndexCount); + (!this.renderData.indices || this.maxIndexCount > this.renderData.indices.length) && (this.renderData.indices = new Uint16Array(this.maxIndexCount)); + } + } + return; + } + const s = Q5.FrameTime; + 0 === this._accTime && 0 === this._playCount && this._eventTarget.emit(g5.START); + this._accTime += t * this.timeScale * 1; + let n = Math.floor(this._accTime / s); + if (!e.isCompleted) { + e.updateToFrame(n); + if (this.renderData && (this.renderData.vertexCount < e.maxVertexCount || this.renderData.indexCount < e.maxIndexCount)) { + this.maxVertexCount = e.maxVertexCount > this.maxVertexCount ? e.maxVertexCount : this.maxVertexCount; + this.maxIndexCount = e.maxIndexCount > this.maxIndexCount ? e.maxIndexCount : this.maxIndexCount; + this.renderData.resize(this.maxVertexCount, this.maxIndexCount); + (!this.renderData.indices || this.maxIndexCount > this.renderData.indices.length) && (this.renderData.indices = new Uint16Array(this.maxIndexCount)); + } + } + if (e.isCompleted && n >= i.length) { + this._playCount++; + if (this.playTimes > 0 && this._playCount >= this.playTimes) { + this._curFrame = i[i.length - 1]; + this._accTime = 0; + this._playing = !1; + this._playCount = 0; + this._emitCacheCompleteEvent(); + this.attachUtil._syncAttachedNode(); + return; + } + this._accTime = 0; + n = 0; + this._emitCacheCompleteEvent(); + } + this._curFrame = i[n]; + this.attachUtil._syncAttachedNode(); + } + onDestroy() { + this._materialInstances = this._materialInstances.filter((t => !!t)); + this._inited = !1; + if (this._cacheMode === g8.PRIVATE_CACHE) { + this._armatureCache.dispose(); + this._armatureCache = null; + this._armature = null; + } else if (this._cacheMode === g8.SHARED_CACHE) { + this._armatureCache = null; + this._armature = null; + } else if (this._armature) { + this._armature.dispose(); + this._armature = null; + } + this._drawList.destroy(); + super.onDestroy(); + } + _updateDebugDraw() { + if (this.debugBones) { + if (!this._debugDraw) { + const t = new _y("DEBUG_DRAW_NODE"); + t.hideFlags |= co.Flags.DontSave | co.Flags.HideInHierarchy; + const e = t.addComponent(dN); + e.lineWidth = 1; + e.strokeColor = new Bi(255, 0, 0, 255); + this._debugDraw = e; + } + this._debugDraw.node.parent = this.node; + } else this._debugDraw && (this._debugDraw.node.parent = null); + this.markForUpdateRenderData(); + } + _buildArmature() { + if (!this.dragonAsset || !this.dragonAtlasAsset || !this.armatureName) return; + if (this._armature) { + this._preCacheMode === g8.PRIVATE_CACHE ? this._armatureCache.dispose() : this._preCacheMode === g8.REALTIME && this._armature.dispose(); + this._armatureCache = null; + this._armature = null; + this._displayProxy = null; + this._frameCache = null; + this._curFrame = null; + this._playing = !1; + this._preCacheMode = -1; + } + if (this._cacheMode === g8.SHARED_CACHE) this._armatureCache = Q5.sharedCache; else if (this._cacheMode === g8.PRIVATE_CACHE) { + this._armatureCache = new Q5; + this._armatureCache.enablePrivateMode(); + } + const t = this.dragonAtlasAsset._uuid; + this._armatureKey = this.dragonAsset.init(this._factory, t); + if (this.isAnimationCached()) { + this._armature = this._armatureCache.getArmatureCache(this.armatureName, this._armatureKey, t); + this._armature || (this._cacheMode = g8.REALTIME); + } + this._preCacheMode = this._cacheMode; + if (this._cacheMode === g8.REALTIME) { + this._displayProxy = this._factory.buildArmatureDisplay(this.armatureName, this._armatureKey, "", t); + if (!this._displayProxy) return; + this._displayProxy._ccNode = this.node; + this._displayProxy._ccComponent = this; + this._displayProxy.setEventTarget(this._eventTarget); + this._armature = this._displayProxy._armature; + this._armature.animation.timeScale = this.timeScale; + } + this._cacheMode !== g8.REALTIME && this.debugBones && console.warn("Debug bones is invalid in cached mode"); + if (this._armature) { + const t = this._armature.armatureData.aabb; + this.node._uiProps.uiTransformComp.setContentSize(t.width, t.height); + } + this.attachUtil.init(this); + this.animationName && this.playAnimation(this.animationName, this.playTimes); + this._flushAssembler(); + } + querySockets() { + if (!this._armature) return []; + 0 === this._cachedSockets.size && this._indexBoneSockets(); + return Array.from(this._cachedSockets.keys()).sort(); + } + querySocketPathByName(t) { + const e = []; + for (const i of this._cachedSockets.keys()) i.endsWith(t) && e.push(i); + return e; + } + _parseDragonAtlasAsset() { + this.dragonAtlasAsset && this.dragonAtlasAsset.init(this._factory); + } + _refresh() { + this._buildArmature(); + this._indexBoneSockets(); + this.markForUpdateRenderData(); + } + _updateCacheModeEnum() { + this._cacheModeEnum = oe({}); + this._armature ? Object.assign(this._cacheModeEnum, g8) : Object.assign(this._cacheModeEnum, f8); + y8(this, "_defaultCacheMode", this._cacheModeEnum); + } + _updateAnimEnum() { + let t; + t = this.dragonAsset ? this.dragonAsset.getAnimsEnum(this.armatureName) : m8; + this._enumAnimations = oe({}); + Object.assign(this._enumAnimations, t || m8); + oe.update(this._enumAnimations); + y8(this, "_animationIndex", this._enumAnimations); + } + _updateArmatureEnum() { + let t; + t = this.dragonAsset ? this.dragonAsset.getArmatureEnum() : p8; + this._enumArmatures = oe({}); + Object.assign(this._enumArmatures, t || p8); + oe.update(this._enumArmatures); + y8(this, "_defaultArmatureIndex", this._enumArmatures); + } + _indexBoneSockets() { + if (!this._armature) return; + this._cachedSockets.clear(); + const t = this._cachedSockets; + const e = (t, i, s) => { + if (s.has(t)) return s.get(t); + const n = i[t]; + if (!n.parent) { + s.set(t, n.name); + n.path = n.name; + return n.name; + } + const r = `${e(n.parent._boneIndex, i, s)}/${n.name}`; + s.set(t, r); + n.path = r; + return r; + }; + const i = (s, n) => { + const r = n.getBones(); + const o = new Map; + for (let t = 0; t < r.length; t++) r[t]._boneIndex = t; + for (let t = 0; t < r.length; t++) e(t, r, o); + for (const e of o.keys()) t.set(`${s}${o.get(e)}`, e); + const a = n.getSlots(); + for (let t = 0; t < a.length; t++) a[t].childArmature && i(a[t].name, a[t].childArmature); + }; + i("", this._armature); + } + playAnimation(t, e) { + this.playTimes = void 0 === e ? -1 : e; + this.animationName = t; + if (this.isAnimationCached()) { + let e = this._armatureCache.getAnimationCache(this._armatureKey, t); + e || (e = this._armatureCache.initAnimationCache(this._armatureKey, t)); + if (e) { + this._accTime = 0; + this._playCount = 0; + this._frameCache = e; + this._sockets.length > 0 && this._frameCache.enableCacheAttachedInfo(); + this._frameCache.updateToFrame(0); + this._playing = !0; + this._curFrame = this._frameCache.frames[0]; + } + } else if (this._armature) return this._armature.animation.play(t, this.playTimes); + this.markForUpdateRenderData(); + return null; + } + updateAnimationCache(t) { + this.isAnimationCached() && this._armatureCache.updateAnimationCache(this._armatureKey, t); + } + invalidAnimationCache() { + this.isAnimationCached() && this._armatureCache.invalidAnimationCache(this._armatureKey); + } + getArmatureNames() { + const t = this._factory.getDragonBonesData(this._armatureKey); + return t && t.armatureNames || []; + } + getAnimationNames(t) { + const e = []; + const i = this._factory.getDragonBonesData(this._armatureKey); + if (i) { + const s = i.getArmature(t); + if (s) for (const t in s.animations) s.animations.hasOwnProperty(t) && e.push(t); + } + return e; + } + on(t, e, i) { + this.addEventListener(t, e, i); + } + off(t, e, i) { + this.removeEventListener(t, e, i); + } + once(t, e, i) { + this._eventTarget.once(t, e, i); + } + addEventListener(t, e, i) { + this._eventTarget.on(t, e, i); + } + removeEventListener(t, e, i) { + this._eventTarget.off(t, e, i); + } + buildArmature(t, e) { + return this._factory.createArmatureNode(this, t, e); + } + armature() { + return this._armature; + } + _flushAssembler() { + const e = t.Assembler.getAssembler(this); + this._assembler !== e && (this._assembler = e); + if (this._armature && this._assembler) { + this._renderData = this._assembler.createData(this); + if (this.renderData) { + this.maxVertexCount = this.renderData.vertexCount; + this.maxIndexCount = this.renderData.indexCount; + } + this.markForUpdateRenderData(); + this._updateColor(); + } + } + _updateSocketBindings() { + if (this._armature) { + this._socketNodes.clear(); + for (let t = 0, e = this._sockets.length; t < e; t++) { + const e = this._sockets[t]; + if (e.path && e.target) { + const t = this._cachedSockets.get(e.path); + if (!t) { + console.error(`Skeleton data does not contain path ${e.path}`); + continue; + } + e.boneIndex = t; + this._socketNodes.set(e.path, e.target); + } + } + } + } + _verifySockets(t) { + for (let e = 0, i = t.length; e < i; e++) { + const i = t[e].target; + !i || i.parent && i.parent === this.node || console.error(`Target node ${i.name} is expected to be a direct child of ${this.node.name}`); + } + } + _cleanMaterialCache() { + for (const t in this._materialCache) this._materialCache[t].destroy(); + this._materialCache = {}; + } + createRenderEntity() { + const t = new fB(uB.DYNAMIC); + t.setUseLocal(!0); + return t; + } + markForUpdateRenderData(t = !0) { + super.markForUpdateRenderData(t); + this._debugDraw && this._debugDraw.markForUpdateRenderData(t); + } + }, _8.AnimationCacheMode = g8, d8), Bl(Q4.prototype, "dragonAsset", [ nh, R4, I4 ], Object.getOwnPropertyDescriptor(Q4.prototype, "dragonAsset"), Q4.prototype), + Bl(Q4.prototype, "dragonAtlasAsset", [ nh, M4, B4 ], Object.getOwnPropertyDescriptor(Q4.prototype, "dragonAtlasAsset"), Q4.prototype), + Bl(Q4.prototype, "armatureName", [ D4 ], Object.getOwnPropertyDescriptor(Q4.prototype, "armatureName"), Q4.prototype), + Bl(Q4.prototype, "animationName", [ P4 ], Object.getOwnPropertyDescriptor(Q4.prototype, "animationName"), Q4.prototype), + Bl(Q4.prototype, "_defaultArmatureIndex", [ O4, nh, N4, L4 ], Object.getOwnPropertyDescriptor(Q4.prototype, "_defaultArmatureIndex"), Q4.prototype), + Bl(Q4.prototype, "_animationIndex", [ nh, F4, V4, k4 ], Object.getOwnPropertyDescriptor(Q4.prototype, "_animationIndex"), Q4.prototype), + Bl(Q4.prototype, "_defaultCacheMode", [ nh, U4, G4 ], Object.getOwnPropertyDescriptor(Q4.prototype, "_defaultCacheMode"), Q4.prototype), + Bl(Q4.prototype, "timeScale", [ nh, z4, Yl ], Object.getOwnPropertyDescriptor(Q4.prototype, "timeScale"), Q4.prototype), + $4 = Bl(Q4.prototype, "playTimes", [ H4, nh, Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return -1; + } + }), t8 = Bl(Q4.prototype, "premultipliedAlpha", [ Yl, nh, j4 ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Bl(Q4.prototype, "debugBones", [ X4, nh ], Object.getOwnPropertyDescriptor(Q4.prototype, "debugBones"), Q4.prototype), + Bl(Q4.prototype, "sockets", [ W4, Y4 ], Object.getOwnPropertyDescriptor(Q4.prototype, "sockets"), Q4.prototype), + e8 = Bl(Q4.prototype, "_defaultArmatureIndexValue", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return p8.default; + } + }), i8 = Bl(Q4.prototype, "_dragonAsset", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), s8 = Bl(Q4.prototype, "_dragonAtlasAsset", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), n8 = Bl(Q4.prototype, "_armatureName", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), r8 = Bl(Q4.prototype, "_animationName", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), o8 = Bl(Q4.prototype, "_animationIndexValue", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), a8 = Bl(Q4.prototype, "_defaultCacheModeValue", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return g8.REALTIME; + } + }), l8 = Bl(Q4.prototype, "_timeScale", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), h8 = Bl(Q4.prototype, "_playTimes", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return -1; + } + }), c8 = Bl(Q4.prototype, "_debugBones", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), u8 = Bl(Q4.prototype, "_sockets", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), Bl(Q4.prototype, "customMaterial", [ vh, q4, K4, J4 ], Object.getOwnPropertyDescriptor(Q4.prototype, "customMaterial"), Q4.prototype), + Q4)) || Z4) || Z4) || Z4) || Z4); + m.internal.ArmatureDisplay = S8; + const A8 = new Bi(255, 0, 0, 255); + const T8 = new Bi(0, 0, 255, 255); + const v8 = new Bi(0, 255, 0, 255); + let E8; + let C8; + let x8; + let w8; + let R8; + let I8; + let M8; + let B8; + let D8; + let P8; + let O8; + let N8 = 0; + let L8 = 0; + let F8 = 0; + let V8 = 0; + let k8 = 0; + let U8 = 0; + let G8 = 0; + let z8 = 0; + let H8 = 0; + let j8; + let X8; + const W8 = new Float32Array(4); + let Y8; + let q8; + let K8; + let J8; + let Z8; + let Q8; + let $8; + const t6 = new qi; + let e6 = null; + let i6 = null; + function s6(t, e) { + if (!t) return null; + let i; + let s; + switch (e) { + case 1: + i = R8 ? Ls.ONE : Ls.SRC_ALPHA; + s = Ls.ONE; + break; + + case 10: + i = Ls.DST_COLOR; + s = Ls.ONE_MINUS_SRC_ALPHA; + break; + + case 12: + i = Ls.ONE; + s = Ls.ONE_MINUS_SRC_COLOR; + break; + + default: + i = R8 ? Ls.ONE : Ls.SRC_ALPHA; + s = Ls.ONE_MINUS_SRC_ALPHA; + } + return O8.getMaterialForBlend(i, s); + } + function n6(t, e) { + const i = t.a * e * w8; + const s = R8 ? i / 255 : 1; + const n = t.r * E8 * s / 255; + const r = t.g * C8 * s / 255; + const o = t.b * x8 * s / 255; + W8[0] = n; + W8[1] = r; + W8[2] = o; + W8[3] = R8 ? 1 : i / 255; + } + let r6 = null; + const o6 = { + accessor: r6, + vCount: 32767, + ensureAccessor() { + if (!r6) { + const t = IR.root.device; + const e = IR.root.batcher2D; + const i = zM; + this.accessor = r6 = new iB(t, i, this.vCount); + e.registerBufferAccessor(Number.parseInt("DRAGONBONES", 36), r6); + } + return this.accessor; + }, + createData(t) { + let e = t.renderData; + if (!e) { + this.ensureAccessor(); + const i = t._armature._slots; + let s = 0; + let n = 0; + for (let t = 0; t < i.length; ++t) { + const e = i[t]; + s += e._localVertices.length / 4; + n += e._indices.length; + } + e = SB.add(zM, this.accessor); + e.resize(s, n); + e.indices && n === e.indices.length || (e.indices = new Uint16Array(n)); + } + return e; + }, + updateRenderData(t, e) { + O8 = t; + t._armature && function(t, e) { + const i = t._armature; + if (!i) return; + I8 = !0; + R8 = t.premultipliedAlpha; + t.drawList.reset(); + O8 = t; + P8 = t.node; + M8 = t.renderData; + O8 = t; + Y8 = 0; + e6 = null; + const s = t.color; + E8 = s.r / 255; + C8 = s.g / 255; + x8 = s.b / 255; + w8 = t.node._uiProps.opacity; + 4294967295 !== s._val && (Y8 |= 1); + let n; + N8 = 0; + F8 = 0; + V8 = 0; + k8 = 0; + U8 = 0; + H8 = 0; + G8 = O8.maxVertexCount; + z8 = O8.maxIndexCount; + if (t.isAnimationCached()) !function(t, e) { + if (!t) return; + const i = t.segments; + if (0 === i.length) return; + let s = null; + const n = t.vertices; + const r = t.indices; + let o = 0; + let a = 0; + let l = 0; + let h = 0; + if (e) { + q8 = e.m00; + Z8 = e.m01; + K8 = e.m04; + Q8 = e.m05; + J8 = e.m12; + $8 = e.m13; + } + let c = 0; + const u = t.colors; + let _ = u[c++]; + let d = _.vfOffset; + n6(_, 1); + const p = M8; + const m = p.chunk.vb; + const f = p.indices; + for (let t = 0, g = i.length; t < g; t++) { + const g = i[t]; + s = s6(g.tex, g.blendMode); + if (!s) continue; + e6 || (e6 = s); + if (I8 || s.hash !== e6.hash || g.tex && g.tex !== i6) { + I8 = !1; + const t = U8 - H8; + if (t > 0) { + O8._requestDrawData(e6, i6, H8, t); + H8 = U8; + } + e6 = s; + i6 = g.tex; + } + L8 = g.vertexCount; + k8 = g.indexCount; + o = p.chunk.vertexOffset; + for (let t = U8, e = U8 + k8; t < e; t++) f[t] = o + F8 + r[l++]; + h = g.vfCount; + const y = n.subarray(a, h); + m.set(y, a); + let b = 0; + if (e) for (let t = 0, e = L8; t < e; t++) { + j8 = m[b]; + X8 = m[b + 1]; + m[b] = j8 * q8 + X8 * K8 + J8; + m[b + 1] = j8 * Z8 + X8 * Q8 + $8; + b += 9; + } + if (1 & Y8) { + let t = a / 9 * 5; + for (let e = a, i = a + h; e < i; e += 9, t += 5) { + if (t >= d) { + _ = u[c++]; + n6(_, 1); + d = _.vfOffset; + } + m.set(W8, e + 5); + } + } + a += h; + F8 += L8; + U8 += k8; + L8 = 0; + k8 = 0; + } + const g = U8 - H8; + i6 && g > 0 && O8._requestDrawData(e6, i6, H8, g); + }(t._curFrame, n); else { + a6(i, 1, n); + const e = t._debugDraw; + if (t.debugBones && e) { + e.clear(); + e.lineWidth = 5; + e.strokeColor = A8; + e.fillColor = T8; + const t = i.getBones(); + for (let i = 0, s = t.length; i < s; i++) { + const s = t[i]; + const n = Math.max(s.boneData.length, 5); + const r = s.globalTransformMatrix.tx; + const o = s.globalTransformMatrix.ty; + const a = r + s.globalTransformMatrix.a * n; + const l = o + s.globalTransformMatrix.b * n; + e.moveTo(r, o); + e.lineTo(a, l); + e.stroke(); + e.circle(r, o, 2 * Math.PI); + e.fill(); + 0 === i && (e.fillColor = v8); + } + } + } + r6.getMeshBuffer(M8.chunk.bufferId).setDirty(); + t.attachUtil._syncAttachedNode(); + P8 = void 0; + O8 = void 0; + }(t); + }, + updateColor(t) { + if (t) { + O8 = t; + O8.markForUpdateRenderData(); + } + } + }; + function a6(t, e, i) { + const s = M8; + D8 = s.chunk.vb; + B8 = s.indices; + const n = t._slots; + let r; + let o; + let a; + let l; + let h; + let c = 0; + for (let t = 0, c = n.length; t < c; t++) { + h = n[t]; + l = h._color; + if (!h._visible || !h._displayData) continue; + i ? h._mulMat(h._worldMatrix, i, h._matrix) : qi.copy(h._worldMatrix, h._matrix); + if (h.childArmature) { + a6(h.childArmature, l.a / 255, h._worldMatrix); + continue; + } + r = s6(h.getTexture(), h._blendMode); + if (!r) continue; + e6 || (e6 = r); + const c = h.getTexture(); + if (I8 || r.hash !== e6.hash || c && i6 !== c) { + I8 = !1; + const t = U8 - H8; + if (t > 0) { + O8._requestDrawData(e6, i6, H8, t); + H8 = U8; + } + i6 = c; + e6 = r; + } + n6(l, e); + t6.set(h._worldMatrix); + o = h._localVertices; + L8 = o.length / 4; + N8 = 9 * L8; + a = h._indices; + k8 = a.length; + let u = !1; + if (F8 + L8 > G8) { + G8 = F8 + L8; + u = !0; + } + if (U8 + k8 > z8) { + z8 = U8 + k8; + u = !0; + } + if (u) { + const t = B8; + const e = s.chunk.vertexOffset; + s.resizeAndCopy(G8, z8 > s.indexCount ? z8 : s.indexCount); + D8 = s.chunk.vb; + z8 > B8.length && (B8 = s.indices = new Uint16Array(z8)); + const i = s.chunk.vertexOffset - e; + for (let e = 0; e < U8; ++e) B8[e] = t[e] + i; + } + q8 = t6.m00; + K8 = t6.m04; + J8 = t6.m12; + Z8 = t6.m01; + Q8 = t6.m05; + $8 = t6.m13; + for (let t = 0, e = o.length, i = V8; t < e; i += 9) { + j8 = o[t++]; + X8 = o[t++]; + D8[i] = j8 * q8 + X8 * K8 + J8; + D8[i + 1] = j8 * Z8 + X8 * Q8 + $8; + D8[i + 3] = o[t++]; + D8[i + 4] = o[t++]; + D8.set(W8, i + 5); + } + const _ = s.chunk.vertexOffset; + for (let t = 0, e = a.length, i = U8; t < e; t++, i++) B8[i] = F8 + a[t] + _; + V8 += N8; + F8 += L8; + U8 += k8; + L8 = 0; + k8 = 0; + } + c = U8 - H8; + if (i6 && c > 0) { + O8._requestDrawData(e6, i6, H8, c); + H8 = U8; + } + O8.maxIndexCount < z8 && (O8.maxIndexCount = z8); + O8.maxVertexCount < G8 && (O8.maxVertexCount = G8); + } + m.internal.DragonBonesAssembler = o6; + const l6 = { + getAssembler: () => o6 + }; + S8.Assembler = l6; + let h6; + !function(t) { + t[t.FFD = 0] = "FFD"; + t[t.AdjustColor = 10] = "AdjustColor"; + t[t.BevelFilter = 11] = "BevelFilter"; + t[t.BlurFilter = 12] = "BlurFilter"; + t[t.DropShadowFilter = 13] = "DropShadowFilter"; + t[t.GlowFilter = 14] = "GlowFilter"; + t[t.GradientBevelFilter = 15] = "GradientBevelFilter"; + t[t.GradientGlowFilter = 16] = "GradientGlowFilter"; + }(h6 || (h6 = {})); + let c6; + !function(t) { + t[t.Frame = 0] = "Frame"; + t[t.Sound = 1] = "Sound"; + }(c6 || (c6 = {})); + let u6; + !function(t) { + t[t.None = 0] = "None"; + t[t.SameLayer = 1] = "SameLayer"; + t[t.SameGroup = 2] = "SameGroup"; + t[t.SameLayerAndGroup = 3] = "SameLayerAndGroup"; + t[t.All = 4] = "All"; + }(u6 || (u6 = {})); + const _6 = window.dragonBones; + const d6 = _6.Slot; + const p6 = _6.Matrix; + const m6 = _6.BaseObject; + const f6 = _6.BoundingBoxData; + const g6 = _6.PolygonBoundingBoxData; + const y6 = _6.Transform; + const b6 = _6.Animation; + const S6 = _6.TextureData; + const A6 = _6.CCTextureData; + const T6 = _6.BaseFactory; + const v6 = _6.CCFactory; + const E6 = _6.WorldClock; + const C6 = _6.TextureAtlasData; + const x6 = _6.CCArmatureDisplay; + const w6 = _6.AnimationState; + const R6 = _6.BoneData; + const I6 = _6.EllipseBoundingBoxData; + const M6 = _6.ArmatureData; + const B6 = _6.CCTextureAtlasData; + const D6 = _6.TransformObject; + const P6 = _6.CCSlot; + const O6 = _6.Armature; + const N6 = _6.Bone; + const L6 = _6.RectangleBoundingBoxData; + const F6 = _6.ArmatureCacheMgr; + const V6 = _6.SkinData; + const k6 = _6.EventObject; + const U6 = _6.SlotData; + const G6 = _6.DragonBonesData; + const z6 = _6.AnimationData; + const H6 = _6.CCArmatureCacheDisplay; + t("dragonBones", Object.freeze({ + __proto__: null, + DragonBonesAsset: s4, + DragonBonesAtlasAsset: d4, + timeScale: 1, + get AnimationCacheMode() { + return g8; + }, + DragonBoneSocket: b8, + ArmatureDisplay: S8, + AttachUtil: f4, + simpleDragonBoneAssembler: l6, + get ExtensionType() { + return h6; + }, + get EventType() { + return c6; + }, + get AnimationFadeOutMode() { + return u6; + }, + Slot: d6, + Matrix: p6, + BaseObject: m6, + BoundingBoxData: f6, + PolygonBoundingBoxData: g6, + Transform: y6, + Animation: b6, + TextureData: S6, + CCTextureData: A6, + BaseFactory: T6, + CCFactory: v6, + WorldClock: E6, + TextureAtlasData: C6, + CCArmatureDisplay: x6, + AnimationState: w6, + BoneData: R6, + EllipseBoundingBoxData: I6, + ArmatureData: M6, + CCTextureAtlasData: B6, + TransformObject: D6, + CCSlot: P6, + Armature: O6, + Bone: N6, + RectangleBoundingBoxData: L6, + ArmatureCacheMgr: F6, + SkinData: V6, + EventObject: k6, + SlotData: U6, + DragonBonesData: G6, + AnimationData: z6, + CCArmatureCacheDisplay: H6 + })); + class j6 extends Dr { + constructor(...t) { + super(...t); + this._gpuDescriptorSet = null; + } + get gpuDescriptorSet() { + return this._gpuDescriptorSet; + } + initialize(t) { + this._layout = t.layout; + const {bindings: e, descriptorIndices: i, descriptorCount: s} = t.layout.gpuDescriptorSetLayout; + this._buffers = Array(s).fill(null); + this._textures = Array(s).fill(null); + this._samplers = Array(s).fill(null); + const n = []; + this._gpuDescriptorSet = { + gpuDescriptors: n, + descriptorIndices: i + }; + for (let t = 0; t < e.length; ++t) { + const i = e[t]; + for (let t = 0; t < i.count; t++) n.push({ + type: i.descriptorType, + gpuBuffer: null, + gpuTexture: null, + gpuSampler: null + }); + } + } + destroy() { + this._layout = null; + this._gpuDescriptorSet = null; + } + update() { + if (this._isDirty && this._gpuDescriptorSet) { + const t = this._gpuDescriptorSet.gpuDescriptors; + for (let e = 0; e < t.length; ++e) if (t[e].type & _r) { + const i = this._buffers[e]; + i && (t[e].gpuBuffer = i.gpuBuffer || i.gpuBufferView); + } else if (t[e].type & dr) { + this._textures[e] && (t[e].gpuTexture = this._textures[e].gpuTexture); + this._samplers[e] && (t[e].gpuSampler = this._samplers[e].gpuSampler); + } + this._isDirty = !1; + } + } + } + let X6; + !function(t) { + t[t.RGBA16F_EXT = 34842] = "RGBA16F_EXT"; + t[t.RGB16F_EXT = 34843] = "RGB16F_EXT"; + t[t.RGBA32F_EXT = 34836] = "RGBA32F_EXT"; + t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT = 33297] = "FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT"; + t[t.UNSIGNED_NORMALIZED_EXT = 35863] = "UNSIGNED_NORMALIZED_EXT"; + t[t.UNSIGNED_INT_24_8_WEBGL = 34042] = "UNSIGNED_INT_24_8_WEBGL"; + t[t.HALF_FLOAT_OES = 36193] = "HALF_FLOAT_OES"; + t[t.SRGB_EXT = 35904] = "SRGB_EXT"; + t[t.SRGB_ALPHA_EXT = 35906] = "SRGB_ALPHA_EXT"; + t[t.SRGB8_ALPHA8_EXT = 35907] = "SRGB8_ALPHA8_EXT"; + t[t.COMPRESSED_RGB_S3TC_DXT1_EXT = 33776] = "COMPRESSED_RGB_S3TC_DXT1_EXT"; + t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT = 33777] = "COMPRESSED_RGBA_S3TC_DXT1_EXT"; + t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT = 33778] = "COMPRESSED_RGBA_S3TC_DXT3_EXT"; + t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT = 33779] = "COMPRESSED_RGBA_S3TC_DXT5_EXT"; + t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT = 35916] = "COMPRESSED_SRGB_S3TC_DXT1_EXT"; + t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = 35917] = "COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT"; + t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT = 35918] = "COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT"; + t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = 35919] = "COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT"; + t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 35840] = "COMPRESSED_RGB_PVRTC_4BPPV1_IMG"; + t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 35841] = "COMPRESSED_RGB_PVRTC_2BPPV1_IMG"; + t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 35842] = "COMPRESSED_RGBA_PVRTC_4BPPV1_IMG"; + t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 35843] = "COMPRESSED_RGBA_PVRTC_2BPPV1_IMG"; + t[t.COMPRESSED_RGB_ETC1_WEBGL = 36196] = "COMPRESSED_RGB_ETC1_WEBGL"; + t[t.COMPRESSED_R11_EAC = 37488] = "COMPRESSED_R11_EAC"; + t[t.COMPRESSED_SIGNED_R11_EAC = 37489] = "COMPRESSED_SIGNED_R11_EAC"; + t[t.COMPRESSED_RG11_EAC = 37490] = "COMPRESSED_RG11_EAC"; + t[t.COMPRESSED_SIGNED_RG11_EAC = 37491] = "COMPRESSED_SIGNED_RG11_EAC"; + t[t.COMPRESSED_RGB8_ETC2 = 37492] = "COMPRESSED_RGB8_ETC2"; + t[t.COMPRESSED_SRGB8_ETC2 = 37493] = "COMPRESSED_SRGB8_ETC2"; + t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 37494] = "COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2"; + t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 37495] = "COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2"; + t[t.COMPRESSED_RGBA8_ETC2_EAC = 37496] = "COMPRESSED_RGBA8_ETC2_EAC"; + t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 37497] = "COMPRESSED_SRGB8_ALPHA8_ETC2_EAC"; + t[t.COMPRESSED_RGBA_ASTC_4x4_KHR = 37808] = "COMPRESSED_RGBA_ASTC_4x4_KHR"; + t[t.COMPRESSED_RGBA_ASTC_5x4_KHR = 37809] = "COMPRESSED_RGBA_ASTC_5x4_KHR"; + t[t.COMPRESSED_RGBA_ASTC_5x5_KHR = 37810] = "COMPRESSED_RGBA_ASTC_5x5_KHR"; + t[t.COMPRESSED_RGBA_ASTC_6x5_KHR = 37811] = "COMPRESSED_RGBA_ASTC_6x5_KHR"; + t[t.COMPRESSED_RGBA_ASTC_6x6_KHR = 37812] = "COMPRESSED_RGBA_ASTC_6x6_KHR"; + t[t.COMPRESSED_RGBA_ASTC_8x5_KHR = 37813] = "COMPRESSED_RGBA_ASTC_8x5_KHR"; + t[t.COMPRESSED_RGBA_ASTC_8x6_KHR = 37814] = "COMPRESSED_RGBA_ASTC_8x6_KHR"; + t[t.COMPRESSED_RGBA_ASTC_8x8_KHR = 37815] = "COMPRESSED_RGBA_ASTC_8x8_KHR"; + t[t.COMPRESSED_RGBA_ASTC_10x5_KHR = 37816] = "COMPRESSED_RGBA_ASTC_10x5_KHR"; + t[t.COMPRESSED_RGBA_ASTC_10x6_KHR = 37817] = "COMPRESSED_RGBA_ASTC_10x6_KHR"; + t[t.COMPRESSED_RGBA_ASTC_10x8_KHR = 37818] = "COMPRESSED_RGBA_ASTC_10x8_KHR"; + t[t.COMPRESSED_RGBA_ASTC_10x10_KHR = 37819] = "COMPRESSED_RGBA_ASTC_10x10_KHR"; + t[t.COMPRESSED_RGBA_ASTC_12x10_KHR = 37820] = "COMPRESSED_RGBA_ASTC_12x10_KHR"; + t[t.COMPRESSED_RGBA_ASTC_12x12_KHR = 37821] = "COMPRESSED_RGBA_ASTC_12x12_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 37840] = "COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 37841] = "COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 37842] = "COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 37843] = "COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 37844] = "COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 37845] = "COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 37846] = "COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 37847] = "COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 37848] = "COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 37849] = "COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 37850] = "COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 37851] = "COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 37852] = "COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 37853] = "COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR"; + }(X6 || (X6 = {})); + class W6 { + static get instance() { + return W6._instance; + } + static setInstance(t) { + W6._instance = t; + } + } + W6._instance = null; + function Y6(t, e) { + switch (t) { + case bs.R8: + return e.UNSIGNED_BYTE; + + case bs.R8SN: + return e.BYTE; + + case bs.R8UI: + return e.UNSIGNED_BYTE; + + case bs.R8I: + return e.BYTE; + + case bs.R16F: + return X6.HALF_FLOAT_OES; + + case bs.R16UI: + return e.UNSIGNED_SHORT; + + case bs.R16I: + return e.SHORT; + + case bs.R32F: + return e.FLOAT; + + case bs.R32UI: + return e.UNSIGNED_INT; + + case bs.R32I: + return e.INT; + + case bs.RG8: + return e.UNSIGNED_BYTE; + + case bs.RG8SN: + return e.BYTE; + + case bs.RG8UI: + return e.UNSIGNED_BYTE; + + case bs.RG8I: + return e.BYTE; + + case bs.RG16F: + return X6.HALF_FLOAT_OES; + + case bs.RG16UI: + return e.UNSIGNED_SHORT; + + case bs.RG16I: + return e.SHORT; + + case bs.RG32F: + return e.FLOAT; + + case bs.RG32UI: + return e.UNSIGNED_INT; + + case bs.RG32I: + return e.INT; + + case bs.RGB8: + case bs.SRGB8: + return e.UNSIGNED_BYTE; + + case bs.RGB8SN: + return e.BYTE; + + case bs.RGB8UI: + return e.UNSIGNED_BYTE; + + case bs.RGB8I: + return e.BYTE; + + case bs.RGB16F: + return X6.HALF_FLOAT_OES; + + case bs.RGB16UI: + return e.UNSIGNED_SHORT; + + case bs.RGB16I: + return e.SHORT; + + case bs.RGB32F: + return e.FLOAT; + + case bs.RGB32UI: + return e.UNSIGNED_INT; + + case bs.RGB32I: + return e.INT; + + case bs.BGRA8: + case bs.RGBA8: + case bs.SRGB8_A8: + return e.UNSIGNED_BYTE; + + case bs.RGBA8SN: + return e.BYTE; + + case bs.RGBA8UI: + return e.UNSIGNED_BYTE; + + case bs.RGBA8I: + return e.BYTE; + + case bs.RGBA16F: + return X6.HALF_FLOAT_OES; + + case bs.RGBA16UI: + return e.UNSIGNED_SHORT; + + case bs.RGBA16I: + return e.SHORT; + + case bs.RGBA32F: + return e.FLOAT; + + case bs.RGBA32UI: + return e.UNSIGNED_INT; + + case bs.RGBA32I: + return e.INT; + + case bs.R5G6B5: + return e.UNSIGNED_SHORT_5_6_5; + + case bs.R11G11B10F: + return e.FLOAT; + + case bs.RGB5A1: + return e.UNSIGNED_SHORT_5_5_5_1; + + case bs.RGBA4: + return e.UNSIGNED_SHORT_4_4_4_4; + + case bs.RGB10A2: + return e.UNSIGNED_BYTE; + + case bs.RGB10A2UI: + return e.UNSIGNED_INT; + + case bs.RGB9E5: + return e.UNSIGNED_BYTE; + + case bs.DEPTH: + return e.UNSIGNED_INT; + + case bs.DEPTH_STENCIL: + return X6.UNSIGNED_INT_24_8_WEBGL; + + case bs.BC1: + case bs.BC1_SRGB: + case bs.BC2: + case bs.BC2_SRGB: + case bs.BC3: + case bs.BC3_SRGB: + case bs.BC4: + return e.UNSIGNED_BYTE; + + case bs.BC4_SNORM: + return e.BYTE; + + case bs.BC5: + return e.UNSIGNED_BYTE; + + case bs.BC5_SNORM: + return e.BYTE; + + case bs.BC6H_SF16: + case bs.BC6H_UF16: + return e.FLOAT; + + case bs.BC7: + case bs.BC7_SRGB: + case bs.ETC_RGB8: + case bs.ETC2_RGB8: + case bs.ETC2_SRGB8: + case bs.ETC2_RGB8_A1: + case bs.ETC2_SRGB8_A1: + case bs.EAC_R11: + return e.UNSIGNED_BYTE; + + case bs.EAC_R11SN: + return e.BYTE; + + case bs.EAC_RG11: + return e.UNSIGNED_BYTE; + + case bs.EAC_RG11SN: + return e.BYTE; + + case bs.PVRTC_RGB2: + case bs.PVRTC_RGBA2: + case bs.PVRTC_RGB4: + case bs.PVRTC_RGBA4: + case bs.PVRTC2_2BPP: + case bs.PVRTC2_4BPP: + case bs.ASTC_RGBA_4X4: + case bs.ASTC_RGBA_5X4: + case bs.ASTC_RGBA_5X5: + case bs.ASTC_RGBA_6X5: + case bs.ASTC_RGBA_6X6: + case bs.ASTC_RGBA_8X5: + case bs.ASTC_RGBA_8X6: + case bs.ASTC_RGBA_8X8: + case bs.ASTC_RGBA_10X5: + case bs.ASTC_RGBA_10X6: + case bs.ASTC_RGBA_10X8: + case bs.ASTC_RGBA_10X10: + case bs.ASTC_RGBA_12X10: + case bs.ASTC_RGBA_12X12: + case bs.ASTC_SRGBA_4X4: + case bs.ASTC_SRGBA_5X4: + case bs.ASTC_SRGBA_5X5: + case bs.ASTC_SRGBA_6X5: + case bs.ASTC_SRGBA_6X6: + case bs.ASTC_SRGBA_8X5: + case bs.ASTC_SRGBA_8X6: + case bs.ASTC_SRGBA_8X8: + case bs.ASTC_SRGBA_10X5: + case bs.ASTC_SRGBA_10X6: + case bs.ASTC_SRGBA_10X8: + case bs.ASTC_SRGBA_10X10: + case bs.ASTC_SRGBA_12X10: + case bs.ASTC_SRGBA_12X12: + default: + return e.UNSIGNED_BYTE; + } + } + function q6(t, e) { + switch (t) { + case As.BOOL: + return e.BOOL; + + case As.BOOL2: + return e.BOOL_VEC2; + + case As.BOOL3: + return e.BOOL_VEC3; + + case As.BOOL4: + return e.BOOL_VEC4; + + case As.INT: + return e.INT; + + case As.INT2: + return e.INT_VEC2; + + case As.INT3: + return e.INT_VEC3; + + case As.INT4: + return e.INT_VEC4; + + case As.UINT: + return e.UNSIGNED_INT; + + case As.FLOAT: + return e.FLOAT; + + case As.FLOAT2: + return e.FLOAT_VEC2; + + case As.FLOAT3: + return e.FLOAT_VEC3; + + case As.FLOAT4: + return e.FLOAT_VEC4; + + case As.MAT2: + return e.FLOAT_MAT2; + + case As.MAT3: + return e.FLOAT_MAT3; + + case As.MAT4: + return e.FLOAT_MAT4; + + case As.SAMPLER2D: + return e.SAMPLER_2D; + + case As.SAMPLER_CUBE: + return e.SAMPLER_CUBE; + + default: + console.error("Unsupported GLType, convert to GL type failed."); + return As.UNKNOWN; + } + } + function K6(t) { + switch (t) { + case As.BOOL: + case As.BOOL2: + case As.BOOL3: + case As.BOOL4: + case As.INT: + case As.INT2: + case As.INT3: + case As.INT4: + case As.UINT: + return Int32Array; + + case As.FLOAT: + case As.FLOAT2: + case As.FLOAT3: + case As.FLOAT4: + case As.MAT2: + case As.MAT3: + case As.MAT4: + return Float32Array; + + default: + console.error("Unsupported GLType, convert to TypedArrayConstructor failed."); + return Float32Array; + } + } + function J6(t, e) { + switch (t) { + case e.BOOL: + return As.BOOL; + + case e.BOOL_VEC2: + return As.BOOL2; + + case e.BOOL_VEC3: + return As.BOOL3; + + case e.BOOL_VEC4: + return As.BOOL4; + + case e.INT: + return As.INT; + + case e.INT_VEC2: + return As.INT2; + + case e.INT_VEC3: + return As.INT3; + + case e.INT_VEC4: + return As.INT4; + + case e.UNSIGNED_INT: + return As.UINT; + + case e.FLOAT: + return As.FLOAT; + + case e.FLOAT_VEC2: + return As.FLOAT2; + + case e.FLOAT_VEC3: + return As.FLOAT3; + + case e.FLOAT_VEC4: + return As.FLOAT4; + + case e.FLOAT_MAT2: + return As.MAT2; + + case e.FLOAT_MAT3: + return As.MAT3; + + case e.FLOAT_MAT4: + return As.MAT4; + + case e.SAMPLER_2D: + return As.SAMPLER2D; + + case e.SAMPLER_CUBE: + return As.SAMPLER_CUBE; + + default: + console.error("Unsupported GLType, convert to Type failed."); + return As.UNKNOWN; + } + } + function Z6(t, e) { + switch (t) { + case e.BOOL: + return 4; + + case e.BOOL_VEC2: + return 8; + + case e.BOOL_VEC3: + return 12; + + case e.BOOL_VEC4: + return 16; + + case e.INT: + return 4; + + case e.INT_VEC2: + return 8; + + case e.INT_VEC3: + return 12; + + case e.INT_VEC4: + return 16; + + case e.UNSIGNED_INT: + case e.FLOAT: + return 4; + + case e.FLOAT_VEC2: + return 8; + + case e.FLOAT_VEC3: + return 12; + + case e.FLOAT_VEC4: + case e.FLOAT_MAT2: + return 16; + + case e.FLOAT_MAT3: + return 36; + + case e.FLOAT_MAT4: + return 64; + + case e.SAMPLER_2D: + case e.SAMPLER_CUBE: + return 4; + + default: + console.error("Unsupported GLType, get type failed."); + return 0; + } + } + function Q6(t, e) { + switch (t) { + case e.FLOAT_MAT2: + return 2; + + case e.FLOAT_MAT3: + return 3; + + case e.FLOAT_MAT4: + return 4; + + default: + return 1; + } + } + const $6 = [ 512, 513, 514, 515, 516, 517, 518, 519 ]; + const t7 = [ 0, 7680, 7681, 7682, 7683, 5386, 34055, 34056 ]; + const e7 = [ 32774, 32778, 32779, 32775, 32776 ]; + const i7 = [ 0, 1, 770, 772, 771, 773, 768, 774, 769, 775, 776, 32769, 32770, 32771, 32772 ]; + let s7; + !function(t) { + t[t.BEGIN_RENDER_PASS = 0] = "BEGIN_RENDER_PASS"; + t[t.END_RENDER_PASS = 1] = "END_RENDER_PASS"; + t[t.BIND_STATES = 2] = "BIND_STATES"; + t[t.DRAW = 3] = "DRAW"; + t[t.UPDATE_BUFFER = 4] = "UPDATE_BUFFER"; + t[t.COPY_BUFFER_TO_TEXTURE = 5] = "COPY_BUFFER_TO_TEXTURE"; + t[t.COUNT = 6] = "COUNT"; + }(s7 || (s7 = {})); + class n7 { + constructor(t) { + this.cmdType = void 0; + this.refCount = 0; + this.cmdType = t; + } + } + class r7 extends n7 { + constructor() { + super(s7.BEGIN_RENDER_PASS); + this.gpuRenderPass = null; + this.gpuFramebuffer = null; + this.renderArea = new hn; + this.clearFlag = en.NONE; + this.clearColors = []; + this.clearDepth = 1; + this.clearStencil = 0; + } + clear() { + this.gpuFramebuffer = null; + this.clearColors.length = 0; + } + } + class o7 extends n7 { + constructor() { + super(s7.BIND_STATES); + this.gpuPipelineState = null; + this.gpuInputAssembler = null; + this.gpuDescriptorSets = []; + this.dynamicOffsets = []; + this.dynamicStates = new lr; + } + clear() { + this.gpuPipelineState = null; + this.gpuDescriptorSets.length = 0; + this.gpuInputAssembler = null; + this.dynamicOffsets.length = 0; + } + } + class a7 extends n7 { + constructor() { + super(s7.DRAW); + this.drawInfo = new vn; + } + clear() {} + } + class l7 extends n7 { + constructor() { + super(s7.UPDATE_BUFFER); + this.gpuBuffer = null; + this.buffer = null; + this.offset = 0; + this.size = 0; + } + clear() { + this.gpuBuffer = null; + this.buffer = null; + } + } + class h7 extends n7 { + constructor() { + super(s7.COPY_BUFFER_TO_TEXTURE); + this.gpuTexture = null; + this.buffers = []; + this.regions = []; + } + clear() { + this.gpuTexture = null; + this.buffers.length = 0; + this.regions.length = 0; + } + } + class c7 { + constructor() { + this.cmds = new eo(1); + this.beginRenderPassCmds = new eo(1); + this.bindStatesCmds = new eo(1); + this.drawCmds = new eo(1); + this.updateBufferCmds = new eo(1); + this.copyBufferToTextureCmds = new eo(1); + } + clearCmds(t) { + if (this.beginRenderPassCmds.length) { + t.beginRenderPassCmdPool.freeCmds(this.beginRenderPassCmds); + this.beginRenderPassCmds.clear(); + } + if (this.bindStatesCmds.length) { + t.bindStatesCmdPool.freeCmds(this.bindStatesCmds); + this.bindStatesCmds.clear(); + } + if (this.drawCmds.length) { + t.drawCmdPool.freeCmds(this.drawCmds); + this.drawCmds.clear(); + } + if (this.updateBufferCmds.length) { + t.updateBufferCmdPool.freeCmds(this.updateBufferCmds); + this.updateBufferCmds.clear(); + } + if (this.copyBufferToTextureCmds.length) { + t.copyBufferToTextureCmdPool.freeCmds(this.copyBufferToTextureCmds); + this.copyBufferToTextureCmds.clear(); + } + this.cmds.clear(); + } + } + function u7(t, e, i, s, n) { + if (e.usage & Ts.UNIFORM) ArrayBuffer.isView(i) ? e.vf32.set(i, s / Float32Array.BYTES_PER_ELEMENT) : e.vf32.set(new Float32Array(i), s / Float32Array.BYTES_PER_ELEMENT); else if (e.usage & Ts.INDIRECT) { + e.indirects.clearDraws(); + const t = i.drawInfos; + for (let i = 0; i < t.length; ++i) e.indirects.setDrawInfo(s + i, t[i]); + } else { + const r = i; + const {gl: o} = t; + const a = t.stateCache; + switch (e.glTarget) { + case o.ARRAY_BUFFER: + if (t.extensions.useVAO && a.glVAO) { + t.extensions.OES_vertex_array_object.bindVertexArrayOES(null); + a.glVAO = null; + } + d7.gpuInputAssembler = null; + if (t.stateCache.glArrayBuffer !== e.glBuffer) { + o.bindBuffer(o.ARRAY_BUFFER, e.glBuffer); + t.stateCache.glArrayBuffer = e.glBuffer; + } + break; + + case o.ELEMENT_ARRAY_BUFFER: + if (t.extensions.useVAO && a.glVAO) { + t.extensions.OES_vertex_array_object.bindVertexArrayOES(null); + a.glVAO = null; + } + d7.gpuInputAssembler = null; + if (t.stateCache.glElementArrayBuffer !== e.glBuffer) { + o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, e.glBuffer); + t.stateCache.glElementArrayBuffer = e.glBuffer; + } + break; + + default: + console.error("Unsupported BufferType, update buffer failed."); + return; + } + n === r.byteLength ? o.bufferSubData(e.glTarget, s, r) : o.bufferSubData(e.glTarget, s, r.slice(0, n)); + } + } + function _7(t, e) { + const {gl: i} = t; + e.glFormat = e.glInternalFmt = function(t, e) { + switch (t) { + case bs.A8: + return e.ALPHA; + + case bs.L8: + return e.LUMINANCE; + + case bs.LA8: + return e.LUMINANCE_ALPHA; + + case bs.RGB8: + case bs.RGB16F: + case bs.RGB32F: + return e.RGB; + + case bs.BGRA8: + case bs.RGBA8: + case bs.SRGB8_A8: + case bs.RGBA16F: + case bs.RGBA32F: + return e.RGBA; + + case bs.R5G6B5: + return e.RGB; + + case bs.RGB5A1: + case bs.RGBA4: + return e.RGBA; + + case bs.DEPTH: + return e.DEPTH_COMPONENT; + + case bs.DEPTH_STENCIL: + return e.DEPTH_STENCIL; + + case bs.BC1: + return X6.COMPRESSED_RGB_S3TC_DXT1_EXT; + + case bs.BC1_ALPHA: + return X6.COMPRESSED_RGBA_S3TC_DXT1_EXT; + + case bs.BC1_SRGB: + return X6.COMPRESSED_SRGB_S3TC_DXT1_EXT; + + case bs.BC1_SRGB_ALPHA: + return X6.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; + + case bs.BC2: + return X6.COMPRESSED_RGBA_S3TC_DXT3_EXT; + + case bs.BC2_SRGB: + return X6.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; + + case bs.BC3: + return X6.COMPRESSED_RGBA_S3TC_DXT5_EXT; + + case bs.BC3_SRGB: + return X6.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; + + case bs.ETC_RGB8: + return X6.COMPRESSED_RGB_ETC1_WEBGL; + + case bs.ETC2_RGB8: + return X6.COMPRESSED_RGB8_ETC2; + + case bs.ETC2_SRGB8: + return X6.COMPRESSED_SRGB8_ETC2; + + case bs.ETC2_RGB8_A1: + return X6.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; + + case bs.ETC2_SRGB8_A1: + return X6.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2; + + case bs.ETC2_RGBA8: + return X6.COMPRESSED_RGBA8_ETC2_EAC; + + case bs.ETC2_SRGB8_A8: + return X6.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC; + + case bs.EAC_R11: + return X6.COMPRESSED_R11_EAC; + + case bs.EAC_R11SN: + return X6.COMPRESSED_SIGNED_R11_EAC; + + case bs.EAC_RG11: + return X6.COMPRESSED_RG11_EAC; + + case bs.EAC_RG11SN: + return X6.COMPRESSED_SIGNED_RG11_EAC; + + case bs.PVRTC_RGB2: + return X6.COMPRESSED_RGB_PVRTC_2BPPV1_IMG; + + case bs.PVRTC_RGBA2: + return X6.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; + + case bs.PVRTC_RGB4: + return X6.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; + + case bs.PVRTC_RGBA4: + return X6.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; + + case bs.ASTC_RGBA_4X4: + return X6.COMPRESSED_RGBA_ASTC_4x4_KHR; + + case bs.ASTC_RGBA_5X4: + return X6.COMPRESSED_RGBA_ASTC_5x4_KHR; + + case bs.ASTC_RGBA_5X5: + return X6.COMPRESSED_RGBA_ASTC_5x5_KHR; + + case bs.ASTC_RGBA_6X5: + return X6.COMPRESSED_RGBA_ASTC_6x5_KHR; + + case bs.ASTC_RGBA_6X6: + return X6.COMPRESSED_RGBA_ASTC_6x6_KHR; + + case bs.ASTC_RGBA_8X5: + return X6.COMPRESSED_RGBA_ASTC_8x5_KHR; + + case bs.ASTC_RGBA_8X6: + return X6.COMPRESSED_RGBA_ASTC_8x6_KHR; + + case bs.ASTC_RGBA_8X8: + return X6.COMPRESSED_RGBA_ASTC_8x8_KHR; + + case bs.ASTC_RGBA_10X5: + return X6.COMPRESSED_RGBA_ASTC_10x5_KHR; + + case bs.ASTC_RGBA_10X6: + return X6.COMPRESSED_RGBA_ASTC_10x6_KHR; + + case bs.ASTC_RGBA_10X8: + return X6.COMPRESSED_RGBA_ASTC_10x8_KHR; + + case bs.ASTC_RGBA_10X10: + return X6.COMPRESSED_RGBA_ASTC_10x10_KHR; + + case bs.ASTC_RGBA_12X10: + return X6.COMPRESSED_RGBA_ASTC_12x10_KHR; + + case bs.ASTC_RGBA_12X12: + return X6.COMPRESSED_RGBA_ASTC_12x12_KHR; + + case bs.ASTC_SRGBA_4X4: + return X6.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR; + + case bs.ASTC_SRGBA_5X4: + return X6.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR; + + case bs.ASTC_SRGBA_5X5: + return X6.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR; + + case bs.ASTC_SRGBA_6X5: + return X6.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR; + + case bs.ASTC_SRGBA_6X6: + return X6.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR; + + case bs.ASTC_SRGBA_8X5: + return X6.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR; + + case bs.ASTC_SRGBA_8X6: + return X6.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR; + + case bs.ASTC_SRGBA_8X8: + return X6.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR; + + case bs.ASTC_SRGBA_10X5: + return X6.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR; + + case bs.ASTC_SRGBA_10X6: + return X6.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR; + + case bs.ASTC_SRGBA_10X8: + return X6.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR; + + case bs.ASTC_SRGBA_10X10: + return X6.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR; + + case bs.ASTC_SRGBA_12X10: + return X6.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR; + + case bs.ASTC_SRGBA_12X12: + return X6.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR; + + default: + console.error("Unsupported Format, convert to WebGL format failed."); + return e.RGBA; + } + }(e.format, i); + e.glType = Y6(e.format, i); + let s = e.width; + let n = e.height; + switch (e.type) { + case xs.TEX2D: + { + e.glTarget = i.TEXTURE_2D; + if (e.isSwapchainTexture) break; + const r = Math.max(s, n); + r > t.capabilities.maxTextureSize && F(9100, r, t.capabilities.maxTextureSize); + if (t.textureExclusive[e.format] || t.extensions.WEBGL_depth_texture || !ur[e.format].hasDepth) { + e.glTexture = i.createTexture(); + if (e.size > 0) { + const r = t.stateCache.glTexUnits[t.stateCache.texUnit]; + if (r.glTexture !== e.glTexture) { + i.bindTexture(i.TEXTURE_2D, e.glTexture); + r.glTexture = e.glTexture; + } + if (ur[e.format].isCompressed) for (let t = 0; t < e.mipLevel; ++t) { + const r = gr(e.format, s, n, 1); + const o = new Uint8Array(r); + i.compressedTexImage2D(i.TEXTURE_2D, t, e.glInternalFmt, s, n, 0, o); + s = Math.max(1, s >> 1); + n = Math.max(1, n >> 1); + } else for (let t = 0; t < e.mipLevel; ++t) { + i.texImage2D(i.TEXTURE_2D, t, e.glInternalFmt, s, n, 0, e.glFormat, e.glType, null); + s = Math.max(1, s >> 1); + n = Math.max(1, n >> 1); + } + if (e.isPowerOf2) { + e.glWrapS = i.REPEAT; + e.glWrapT = i.REPEAT; + } else { + e.glWrapS = i.CLAMP_TO_EDGE; + e.glWrapT = i.CLAMP_TO_EDGE; + } + e.glMinFilter = i.LINEAR; + e.glMagFilter = i.LINEAR; + i.texParameteri(e.glTarget, i.TEXTURE_WRAP_S, e.glWrapS); + i.texParameteri(e.glTarget, i.TEXTURE_WRAP_T, e.glWrapT); + i.texParameteri(e.glTarget, i.TEXTURE_MIN_FILTER, e.glMinFilter); + i.texParameteri(e.glTarget, i.TEXTURE_MAG_FILTER, e.glMagFilter); + } + } else { + e.glInternalFmt = function(t, e) { + switch (t) { + case bs.R5G6B5: + return e.RGB565; + + case bs.RGB5A1: + return e.RGB5_A1; + + case bs.RGBA4: + return e.RGBA4; + + case bs.RGBA16F: + return X6.RGBA16F_EXT; + + case bs.RGBA32F: + return X6.RGBA32F_EXT; + + case bs.SRGB8_A8: + return X6.SRGB8_ALPHA8_EXT; + + case bs.DEPTH: + return e.DEPTH_COMPONENT16; + + case bs.DEPTH_STENCIL: + return e.DEPTH_STENCIL; + + default: + console.error("Unsupported Format, convert to WebGL internal format failed."); + return e.RGBA; + } + }(e.format, i); + e.glRenderbuffer = i.createRenderbuffer(); + if (e.size > 0) { + if (t.stateCache.glRenderbuffer !== e.glRenderbuffer) { + i.bindRenderbuffer(i.RENDERBUFFER, e.glRenderbuffer); + t.stateCache.glRenderbuffer = e.glRenderbuffer; + } + i.renderbufferStorage(i.RENDERBUFFER, e.glInternalFmt, s, n); + } + } + break; + } + + case xs.CUBE: + { + e.glTarget = i.TEXTURE_CUBE_MAP; + const r = Math.max(s, n); + r > t.capabilities.maxCubeMapTextureSize && F(9100, r, t.capabilities.maxTextureSize); + e.glTexture = i.createTexture(); + if (e.size > 0) { + const r = t.stateCache.glTexUnits[t.stateCache.texUnit]; + if (r.glTexture !== e.glTexture) { + i.bindTexture(i.TEXTURE_CUBE_MAP, e.glTexture); + r.glTexture = e.glTexture; + } + if (ur[e.format].isCompressed) for (let t = 0; t < 6; ++t) { + s = e.width; + n = e.height; + for (let r = 0; r < e.mipLevel; ++r) { + const o = gr(e.format, s, n, 1); + const a = new Uint8Array(o); + i.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + t, r, e.glInternalFmt, s, n, 0, a); + s = Math.max(1, s >> 1); + n = Math.max(1, n >> 1); + } + } else for (let t = 0; t < 6; ++t) { + s = e.width; + n = e.height; + for (let r = 0; r < e.mipLevel; ++r) { + i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + t, r, e.glInternalFmt, s, n, 0, e.glFormat, e.glType, null); + s = Math.max(1, s >> 1); + n = Math.max(1, n >> 1); + } + } + if (e.isPowerOf2) { + e.glWrapS = i.REPEAT; + e.glWrapT = i.REPEAT; + } else { + e.glWrapS = i.CLAMP_TO_EDGE; + e.glWrapT = i.CLAMP_TO_EDGE; + } + e.glMinFilter = i.LINEAR; + e.glMagFilter = i.LINEAR; + i.texParameteri(e.glTarget, i.TEXTURE_WRAP_S, e.glWrapS); + i.texParameteri(e.glTarget, i.TEXTURE_WRAP_T, e.glWrapT); + i.texParameteri(e.glTarget, i.TEXTURE_MIN_FILTER, e.glMinFilter); + i.texParameteri(e.glTarget, i.TEXTURE_MAG_FILTER, e.glMagFilter); + } + break; + } + + default: + console.error("Unsupported TextureType, create texture failed."); + e.type = xs.TEX2D; + e.glTarget = i.TEXTURE_2D; + } + } + const d7 = { + gpuPipelineState: null, + gpuInputAssembler: null, + glPrimitive: 0 + }; + const p7 = new hn; + function m7(t, e, i, s, n, r, o) { + const {gl: a} = t; + const l = t.stateCache; + let h = 0; + if (i) { + p7.x = s.x << i.lodLevel; + p7.y = s.y << i.lodLevel; + p7.width = s.width << i.lodLevel; + p7.height = s.height << i.lodLevel; + } + if (i && e) { + if (l.glFramebuffer !== i.glFramebuffer) { + a.bindFramebuffer(a.FRAMEBUFFER, i.glFramebuffer); + l.glFramebuffer = i.glFramebuffer; + } + if (l.viewport.left !== p7.x || l.viewport.top !== p7.y || l.viewport.width !== p7.width || l.viewport.height !== p7.height) { + a.viewport(p7.x, p7.y, p7.width, p7.height); + l.viewport.left = p7.x; + l.viewport.top = p7.y; + l.viewport.width = p7.width; + l.viewport.height = p7.height; + } + if (l.scissorRect.x !== p7.x || l.scissorRect.y !== p7.y || l.scissorRect.width !== p7.width || l.scissorRect.height !== p7.height) { + a.scissor(p7.x, p7.y, p7.width, p7.height); + l.scissorRect.x = p7.x; + l.scissorRect.y = p7.y; + l.scissorRect.width = p7.width; + l.scissorRect.height = p7.height; + } + let s = n.length; + t.extensions.WEBGL_draw_buffers || (s = 1); + for (let t = 0; t < s; ++t) { + const i = e.colorAttachments[t]; + if (i.format !== bs.UNKNOWN) switch (i.loadOp) { + case Us.LOAD: + break; + + case Us.CLEAR: + { + l.bs.targets[0].blendColorMask !== Vs.ALL && a.colorMask(!0, !0, !0, !0); + const t = n[0]; + a.clearColor(t.x, t.y, t.z, t.w); + h |= a.COLOR_BUFFER_BIT; + break; + } + + case Us.DISCARD: + } + } + if (e.depthStencilAttachment && e.depthStencilAttachment.format !== bs.UNKNOWN) { + switch (e.depthStencilAttachment.depthLoadOp) { + case Us.LOAD: + break; + + case Us.CLEAR: + l.dss.depthWrite || a.depthMask(!0); + a.clearDepth(r); + h |= a.DEPTH_BUFFER_BIT; + + case Us.DISCARD: + } + if (ur[e.depthStencilAttachment.format].hasStencil) switch (e.depthStencilAttachment.stencilLoadOp) { + case Us.LOAD: + break; + + case Us.CLEAR: + l.dss.stencilWriteMaskFront || a.stencilMaskSeparate(a.FRONT, 65535); + l.dss.stencilWriteMaskBack || a.stencilMaskSeparate(a.BACK, 65535); + a.clearStencil(o); + h |= a.STENCIL_BUFFER_BIT; + + case Us.DISCARD: + } + } + h && a.clear(h); + if (h & a.COLOR_BUFFER_BIT) { + const t = l.bs.targets[0].blendColorMask; + if (t !== Vs.ALL) { + const e = (t & Vs.R) !== Vs.NONE; + const i = (t & Vs.G) !== Vs.NONE; + const s = (t & Vs.B) !== Vs.NONE; + const n = (t & Vs.A) !== Vs.NONE; + a.colorMask(e, i, s, n); + } + } + h & a.DEPTH_BUFFER_BIT && !l.dss.depthWrite && a.depthMask(!1); + if (h & a.STENCIL_BUFFER_BIT) { + l.dss.stencilWriteMaskFront || a.stencilMaskSeparate(a.FRONT, 0); + l.dss.stencilWriteMaskBack || a.stencilMaskSeparate(a.BACK, 0); + } + } + } + function f7(t, e, i, s, n, r) { + const {gl: o} = t; + const a = t.stateCache; + const l = e && e.gpuShader; + let h = !1; + let c; + let u; + let _; + if (e && d7.gpuPipelineState !== e) { + d7.gpuPipelineState = e; + d7.glPrimitive = e.glPrimitive; + if (e.gpuShader) { + const {glProgram: t} = e.gpuShader; + if (a.glProgram !== t) { + o.useProgram(t); + a.glProgram = t; + h = !0; + } + } + const {rs: t} = e; + if (t) { + if (a.rs.cullMode !== t.cullMode) { + switch (t.cullMode) { + case qs.NONE: + o.disable(o.CULL_FACE); + break; + + case qs.FRONT: + o.enable(o.CULL_FACE); + o.cullFace(o.FRONT); + break; + + case qs.BACK: + o.enable(o.CULL_FACE); + o.cullFace(o.BACK); + } + a.rs.cullMode = t.cullMode; + } + const e = t.isFrontFaceCCW; + if (a.rs.isFrontFaceCCW !== e) { + o.frontFace(e ? o.CCW : o.CW); + a.rs.isFrontFaceCCW = e; + } + if (a.rs.depthBias !== t.depthBias || a.rs.depthBiasSlop !== t.depthBiasSlop) { + o.polygonOffset(t.depthBias, t.depthBiasSlop); + a.rs.depthBias = t.depthBias; + a.rs.depthBiasSlop = t.depthBiasSlop; + } + if (a.rs.lineWidth !== t.lineWidth) { + o.lineWidth(t.lineWidth); + a.rs.lineWidth = t.lineWidth; + } + } + const {dss: i} = e; + if (i) { + if (a.dss.depthTest !== i.depthTest) { + i.depthTest ? o.enable(o.DEPTH_TEST) : o.disable(o.DEPTH_TEST); + a.dss.depthTest = i.depthTest; + } + if (a.dss.depthWrite !== i.depthWrite) { + o.depthMask(i.depthWrite); + a.dss.depthWrite = i.depthWrite; + } + if (a.dss.depthFunc !== i.depthFunc) { + o.depthFunc($6[i.depthFunc]); + a.dss.depthFunc = i.depthFunc; + } + if (a.dss.stencilTestFront !== i.stencilTestFront || a.dss.stencilTestBack !== i.stencilTestBack) { + i.stencilTestFront || i.stencilTestBack ? o.enable(o.STENCIL_TEST) : o.disable(o.STENCIL_TEST); + a.dss.stencilTestFront = i.stencilTestFront; + a.dss.stencilTestBack = i.stencilTestBack; + } + if (a.dss.stencilFuncFront !== i.stencilFuncFront || a.dss.stencilRefFront !== i.stencilRefFront || a.dss.stencilReadMaskFront !== i.stencilReadMaskFront) { + o.stencilFuncSeparate(o.FRONT, $6[i.stencilFuncFront], i.stencilRefFront, i.stencilReadMaskFront); + a.dss.stencilFuncFront = i.stencilFuncFront; + a.dss.stencilRefFront = i.stencilRefFront; + a.dss.stencilReadMaskFront = i.stencilReadMaskFront; + } + if (a.dss.stencilFailOpFront !== i.stencilFailOpFront || a.dss.stencilZFailOpFront !== i.stencilZFailOpFront || a.dss.stencilPassOpFront !== i.stencilPassOpFront) { + o.stencilOpSeparate(o.FRONT, t7[i.stencilFailOpFront], t7[i.stencilZFailOpFront], t7[i.stencilPassOpFront]); + a.dss.stencilFailOpFront = i.stencilFailOpFront; + a.dss.stencilZFailOpFront = i.stencilZFailOpFront; + a.dss.stencilPassOpFront = i.stencilPassOpFront; + } + if (a.dss.stencilWriteMaskFront !== i.stencilWriteMaskFront) { + o.stencilMaskSeparate(o.FRONT, i.stencilWriteMaskFront); + a.dss.stencilWriteMaskFront = i.stencilWriteMaskFront; + } + if (a.dss.stencilFuncBack !== i.stencilFuncBack || a.dss.stencilRefBack !== i.stencilRefBack || a.dss.stencilReadMaskBack !== i.stencilReadMaskBack) { + o.stencilFuncSeparate(o.BACK, $6[i.stencilFuncBack], i.stencilRefBack, i.stencilReadMaskBack); + a.dss.stencilFuncBack = i.stencilFuncBack; + a.dss.stencilRefBack = i.stencilRefBack; + a.dss.stencilReadMaskBack = i.stencilReadMaskBack; + } + if (a.dss.stencilFailOpBack !== i.stencilFailOpBack || a.dss.stencilZFailOpBack !== i.stencilZFailOpBack || a.dss.stencilPassOpBack !== i.stencilPassOpBack) { + o.stencilOpSeparate(o.BACK, t7[i.stencilFailOpBack], t7[i.stencilZFailOpBack], t7[i.stencilPassOpBack]); + a.dss.stencilFailOpBack = i.stencilFailOpBack; + a.dss.stencilZFailOpBack = i.stencilZFailOpBack; + a.dss.stencilPassOpBack = i.stencilPassOpBack; + } + if (a.dss.stencilWriteMaskBack !== i.stencilWriteMaskBack) { + o.stencilMaskSeparate(o.BACK, i.stencilWriteMaskBack); + a.dss.stencilWriteMaskBack = i.stencilWriteMaskBack; + } + } + const {bs: s} = e; + if (s) { + if (a.bs.isA2C !== s.isA2C) { + s.isA2C ? o.enable(o.SAMPLE_ALPHA_TO_COVERAGE) : o.disable(o.SAMPLE_ALPHA_TO_COVERAGE); + a.bs.isA2C = s.isA2C; + } + if (a.bs.blendColor.x !== s.blendColor.x || a.bs.blendColor.y !== s.blendColor.y || a.bs.blendColor.z !== s.blendColor.z || a.bs.blendColor.w !== s.blendColor.w) { + o.blendColor(s.blendColor.x, s.blendColor.y, s.blendColor.z, s.blendColor.w); + a.bs.blendColor.x = s.blendColor.x; + a.bs.blendColor.y = s.blendColor.y; + a.bs.blendColor.z = s.blendColor.z; + a.bs.blendColor.w = s.blendColor.w; + } + const t = s.targets[0]; + const e = a.bs.targets[0]; + if (e.blend !== t.blend) { + t.blend ? o.enable(o.BLEND) : o.disable(o.BLEND); + e.blend = t.blend; + } + if (e.blendEq !== t.blendEq || e.blendAlphaEq !== t.blendAlphaEq) { + o.blendEquationSeparate(e7[t.blendEq], e7[t.blendAlphaEq]); + e.blendEq = t.blendEq; + e.blendAlphaEq = t.blendAlphaEq; + } + if (e.blendSrc !== t.blendSrc || e.blendDst !== t.blendDst || e.blendSrcAlpha !== t.blendSrcAlpha || e.blendDstAlpha !== t.blendDstAlpha) { + o.blendFuncSeparate(i7[t.blendSrc], i7[t.blendDst], i7[t.blendSrcAlpha], i7[t.blendDstAlpha]); + e.blendSrc = t.blendSrc; + e.blendDst = t.blendDst; + e.blendSrcAlpha = t.blendSrcAlpha; + e.blendDstAlpha = t.blendDstAlpha; + } + if (e.blendColorMask !== t.blendColorMask) { + o.colorMask((t.blendColorMask & Vs.R) !== Vs.NONE, (t.blendColorMask & Vs.G) !== Vs.NONE, (t.blendColorMask & Vs.B) !== Vs.NONE, (t.blendColorMask & Vs.A) !== Vs.NONE); + e.blendColorMask = t.blendColorMask; + } + } + } + if (e && e.gpuPipelineLayout && l) { + const i = l.glBlocks.length; + const {dynamicOffsetIndices: r} = e.gpuPipelineLayout; + for (let t = 0; t < i; t++) { + const e = l.glBlocks[t]; + const i = s[e.set]; + const a = i && i.descriptorIndices[e.binding]; + const h = a >= 0 && i.gpuDescriptors[a]; + let c = null; + let u = 0; + if (h && h.gpuBuffer) { + const {gpuBuffer: t} = h; + const i = r[e.set]; + const s = i && i[e.binding]; + s >= 0 && (u = n[s]); + if ("vf32" in t) c = t.vf32; else { + u += t.offset; + c = t.gpuBuffer.vf32; + } + u >>= 2; + } + if (!c) { + x(`Buffer binding '${e.name}' at set ${e.set} binding ${e.binding} is not bounded`); + continue; + } + const _ = e.glActiveUniforms.length; + for (let t = 0; t < _; t++) { + const i = e.glActiveUniforms[t]; + switch (i.glType) { + case o.BOOL: + case o.INT: + for (let t = 0; t < i.array.length; ++t) { + const e = i.offset + u + t; + if (c[e] !== i.array[t]) { + for (let s = t, n = e; s < i.array.length; ++s, ++n) i.array[s] = c[n]; + o.uniform1iv(i.glLoc, i.array); + break; + } + } + break; + + case o.BOOL_VEC2: + case o.INT_VEC2: + for (let t = 0; t < i.array.length; ++t) { + const e = i.offset + u + t; + if (c[e] !== i.array[t]) { + for (let s = t, n = e; s < i.array.length; ++s, ++n) i.array[s] = c[n]; + o.uniform2iv(i.glLoc, i.array); + break; + } + } + break; + + case o.BOOL_VEC3: + case o.INT_VEC3: + for (let t = 0; t < i.array.length; ++t) { + const e = i.offset + u + t; + if (c[e] !== i.array[t]) { + for (let s = t, n = e; s < i.array.length; ++s, ++n) i.array[s] = c[n]; + o.uniform3iv(i.glLoc, i.array); + break; + } + } + break; + + case o.BOOL_VEC4: + case o.INT_VEC4: + for (let t = 0; t < i.array.length; ++t) { + const e = i.offset + u + t; + if (c[e] !== i.array[t]) { + for (let s = t, n = e; s < i.array.length; ++s, ++n) i.array[s] = c[n]; + o.uniform4iv(i.glLoc, i.array); + break; + } + } + break; + + case o.FLOAT: + for (let t = 0; t < i.array.length; ++t) { + const e = i.offset + u + t; + if (c[e] !== i.array[t]) { + for (let s = t, n = e; s < i.array.length; ++s, ++n) i.array[s] = c[n]; + o.uniform1fv(i.glLoc, i.array); + break; + } + } + break; + + case o.FLOAT_VEC2: + for (let t = 0; t < i.array.length; ++t) { + const e = i.offset + u + t; + if (c[e] !== i.array[t]) { + for (let s = t, n = e; s < i.array.length; ++s, ++n) i.array[s] = c[n]; + o.uniform2fv(i.glLoc, i.array); + break; + } + } + break; + + case o.FLOAT_VEC3: + for (let t = 0; t < i.array.length; ++t) { + const e = i.offset + u + t; + if (c[e] !== i.array[t]) { + for (let s = t, n = e; s < i.array.length; ++s, ++n) i.array[s] = c[n]; + o.uniform3fv(i.glLoc, i.array); + break; + } + } + break; + + case o.FLOAT_VEC4: + for (let t = 0; t < i.array.length; ++t) { + const e = i.offset + u + t; + if (c[e] !== i.array[t]) { + for (let s = t, n = e; s < i.array.length; ++s, ++n) i.array[s] = c[n]; + o.uniform4fv(i.glLoc, i.array); + break; + } + } + break; + + case o.FLOAT_MAT2: + for (let t = 0; t < i.array.length; ++t) { + const e = i.offset + u + t; + if (c[e] !== i.array[t]) { + for (let s = t, n = e; s < i.array.length; ++s, ++n) i.array[s] = c[n]; + o.uniformMatrix2fv(i.glLoc, !1, i.array); + break; + } + } + break; + + case o.FLOAT_MAT3: + for (let t = 0; t < i.array.length; ++t) { + const e = i.offset + u + t; + if (c[e] !== i.array[t]) { + for (let s = t, n = e; s < i.array.length; ++s, ++n) i.array[s] = c[n]; + o.uniformMatrix3fv(i.glLoc, !1, i.array); + break; + } + } + break; + + case o.FLOAT_MAT4: + for (let t = 0; t < i.array.length; ++t) { + const e = i.offset + u + t; + if (c[e] !== i.array[t]) { + for (let s = t, n = e; s < i.array.length; ++s, ++n) i.array[s] = c[n]; + o.uniformMatrix4fv(i.glLoc, !1, i.array); + break; + } + } + } + } + } + const h = l.glSamplerTextures.length; + for (let e = 0; e < h; e++) { + const i = l.glSamplerTextures[e]; + const n = s[i.set]; + let r = n && n.descriptorIndices[i.binding]; + let h = r >= 0 && n.gpuDescriptors[r]; + const d = i.units.length; + for (let e = 0; e < d; e++) { + const s = i.units[e]; + if (h && h.gpuSampler) { + if (h.gpuTexture && h.gpuTexture.size > 0) { + const {gpuTexture: e} = h; + const i = a.glTexUnits[s]; + if (i.glTexture !== e.glTexture) { + if (a.texUnit !== s) { + o.activeTexture(o.TEXTURE0 + s); + a.texUnit = s; + } + e.glTexture ? o.bindTexture(e.glTarget, e.glTexture) : o.bindTexture(e.glTarget, t.nullTex2D.gpuTexture.glTexture); + i.glTexture = e.glTexture; + } + const {gpuSampler: n} = h; + if (e.isPowerOf2) { + c = n.glWrapS; + u = n.glWrapT; + } else { + c = o.CLAMP_TO_EDGE; + u = o.CLAMP_TO_EDGE; + } + _ = e.isPowerOf2 ? e.mipLevel <= 1 && (n.glMinFilter === o.LINEAR_MIPMAP_NEAREST || n.glMinFilter === o.LINEAR_MIPMAP_LINEAR) ? o.LINEAR : n.glMinFilter : n.glMinFilter === o.LINEAR || n.glMinFilter === o.LINEAR_MIPMAP_NEAREST || n.glMinFilter === o.LINEAR_MIPMAP_LINEAR ? o.LINEAR : o.NEAREST; + if (e.glWrapS !== c) { + if (a.texUnit !== s) { + o.activeTexture(o.TEXTURE0 + s); + a.texUnit = s; + } + o.texParameteri(e.glTarget, o.TEXTURE_WRAP_S, c); + e.glWrapS = c; + } + if (e.glWrapT !== u) { + if (a.texUnit !== s) { + o.activeTexture(o.TEXTURE0 + s); + a.texUnit = s; + } + o.texParameteri(e.glTarget, o.TEXTURE_WRAP_T, u); + e.glWrapT = u; + } + if (e.glMinFilter !== _) { + if (a.texUnit !== s) { + o.activeTexture(o.TEXTURE0 + s); + a.texUnit = s; + } + o.texParameteri(e.glTarget, o.TEXTURE_MIN_FILTER, _); + e.glMinFilter = _; + } + if (e.glMagFilter !== n.glMagFilter) { + if (a.texUnit !== s) { + o.activeTexture(o.TEXTURE0 + s); + a.texUnit = s; + } + o.texParameteri(e.glTarget, o.TEXTURE_MAG_FILTER, n.glMagFilter); + e.glMagFilter = n.glMagFilter; + } + } + h = n.gpuDescriptors[++r]; + } else x(`Sampler binding '${i.name}' at set ${i.set} binding ${i.binding} index ${e} is not bounded`); + } + } + } + if (i && l && (h || d7.gpuInputAssembler !== i)) { + d7.gpuInputAssembler = i; + const e = t.extensions.ANGLE_instanced_arrays; + if (t.extensions.useVAO) { + const s = t.extensions.OES_vertex_array_object; + let n = i.glVAOs.get(l.glProgram); + if (!n) { + n = s.createVertexArrayOES(); + i.glVAOs.set(l.glProgram, n); + s.bindVertexArrayOES(n); + o.bindBuffer(o.ARRAY_BUFFER, null); + o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, null); + a.glArrayBuffer = null; + a.glElementArrayBuffer = null; + let t; + const r = l.glInputs.length; + for (let s = 0; s < r; s++) { + const n = l.glInputs[s]; + t = null; + const r = i.glAttribs.length; + for (let e = 0; e < r; e++) { + const s = i.glAttribs[e]; + if (s.name === n.name) { + t = s; + break; + } + } + if (t) { + if (a.glArrayBuffer !== t.glBuffer) { + o.bindBuffer(o.ARRAY_BUFFER, t.glBuffer); + a.glArrayBuffer = t.glBuffer; + } + for (let i = 0; i < t.componentCount; ++i) { + const s = n.glLoc + i; + const r = t.offset + t.size * i; + o.enableVertexAttribArray(s); + a.glCurrentAttribLocs[s] = !0; + o.vertexAttribPointer(s, t.count, t.glType, t.isNormalized, t.stride, r); + e && e.vertexAttribDivisorANGLE(s, t.isInstanced ? 1 : 0); + } + } + } + const h = i.gpuIndexBuffer; + h && o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, h.glBuffer); + s.bindVertexArrayOES(null); + o.bindBuffer(o.ARRAY_BUFFER, null); + o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, null); + a.glArrayBuffer = null; + a.glElementArrayBuffer = null; + } + if (a.glVAO !== n) { + s.bindVertexArrayOES(n); + a.glVAO = n; + } + } else { + for (let e = 0; e < t.capabilities.maxVertexAttributes; ++e) a.glCurrentAttribLocs[e] = !1; + const s = l.glInputs.length; + for (let t = 0; t < s; t++) { + const s = l.glInputs[t]; + let n = null; + const r = i.glAttribs.length; + for (let t = 0; t < r; t++) { + const e = i.glAttribs[t]; + if (e.name === s.name) { + n = e; + break; + } + } + if (n) { + if (a.glArrayBuffer !== n.glBuffer) { + o.bindBuffer(o.ARRAY_BUFFER, n.glBuffer); + a.glArrayBuffer = n.glBuffer; + } + for (let t = 0; t < n.componentCount; ++t) { + const i = s.glLoc + t; + const r = n.offset + n.size * t; + if (!a.glEnabledAttribLocs[i] && i >= 0) { + o.enableVertexAttribArray(i); + a.glEnabledAttribLocs[i] = !0; + } + a.glCurrentAttribLocs[i] = !0; + o.vertexAttribPointer(i, n.count, n.glType, n.isNormalized, n.stride, r); + e && e.vertexAttribDivisorANGLE(i, n.isInstanced ? 1 : 0); + } + } + } + const n = i.gpuIndexBuffer; + if (n && a.glElementArrayBuffer !== n.glBuffer) { + o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, n.glBuffer); + a.glElementArrayBuffer = n.glBuffer; + } + for (let e = 0; e < t.capabilities.maxVertexAttributes; ++e) if (a.glEnabledAttribLocs[e] !== a.glCurrentAttribLocs[e]) { + o.disableVertexAttribArray(e); + a.glEnabledAttribLocs[e] = !1; + } + } + } + if (e && e.dynamicStates.length) { + const t = e.dynamicStates.length; + for (let i = 0; i < t; i++) { + switch (e.dynamicStates[i]) { + case Ks.LINE_WIDTH: + if (a.rs.lineWidth !== r.lineWidth) { + o.lineWidth(r.lineWidth); + a.rs.lineWidth = r.lineWidth; + } + break; + + case Ks.DEPTH_BIAS: + if (a.rs.depthBias !== r.depthBiasConstant || a.rs.depthBiasSlop !== r.depthBiasSlope) { + o.polygonOffset(r.depthBiasConstant, r.depthBiasSlope); + a.rs.depthBias = r.depthBiasConstant; + a.rs.depthBiasSlop = r.depthBiasSlope; + } + break; + + case Ks.BLEND_CONSTANTS: + { + const t = r.blendConstant; + if (a.bs.blendColor.x !== t.x || a.bs.blendColor.y !== t.y || a.bs.blendColor.z !== t.z || a.bs.blendColor.w !== t.w) { + o.blendColor(t.x, t.y, t.z, t.w); + a.bs.blendColor.copy(t); + } + break; + } + + case Ks.STENCIL_WRITE_MASK: + { + const t = r.stencilStatesFront; + const e = r.stencilStatesBack; + if (a.dss.stencilWriteMaskFront !== t.writeMask) { + o.stencilMaskSeparate(o.FRONT, t.writeMask); + a.dss.stencilWriteMaskFront = t.writeMask; + } + if (a.dss.stencilWriteMaskBack !== e.writeMask) { + o.stencilMaskSeparate(o.BACK, e.writeMask); + a.dss.stencilWriteMaskBack = e.writeMask; + } + break; + } + + case Ks.STENCIL_COMPARE_MASK: + { + const t = r.stencilStatesFront; + const e = r.stencilStatesBack; + if (a.dss.stencilRefFront !== t.reference || a.dss.stencilReadMaskFront !== t.compareMask) { + o.stencilFuncSeparate(o.FRONT, $6[a.dss.stencilFuncFront], t.reference, t.compareMask); + a.dss.stencilRefFront = t.reference; + a.dss.stencilReadMaskFront = t.compareMask; + } + if (a.dss.stencilRefBack !== e.reference || a.dss.stencilReadMaskBack !== e.compareMask) { + o.stencilFuncSeparate(o.BACK, $6[a.dss.stencilFuncBack], e.reference, e.compareMask); + a.dss.stencilRefBack = e.reference; + a.dss.stencilReadMaskBack = e.compareMask; + } + break; + } + } + } + } + } + function g7(t, e) { + const {gl: i} = t; + const {ANGLE_instanced_arrays: s, WEBGL_multi_draw: n} = t.extensions; + const {gpuInputAssembler: r, glPrimitive: o} = d7; + if (r) { + const t = r.gpuIndexBuffer; + if (r.gpuIndirectBuffer) { + const e = r.gpuIndirectBuffer.indirects; + if (e.drawByIndex) { + for (let i = 0; i < e.drawCount; i++) e.byteOffsets[i] = e.offsets[i] * t.stride; + if (n) e.instancedDraw ? n.multiDrawElementsInstancedWEBGL(o, e.counts, 0, r.glIndexType, e.byteOffsets, 0, e.instances, 0, e.drawCount) : n.multiDrawElementsWEBGL(o, e.counts, 0, r.glIndexType, e.byteOffsets, 0, e.drawCount); else for (let t = 0; t < e.drawCount; t++) e.instances[t] && s ? s.drawElementsInstancedANGLE(o, e.counts[t], r.glIndexType, e.byteOffsets[t], e.instances[t]) : i.drawElements(o, e.counts[t], r.glIndexType, e.byteOffsets[t]); + } else if (n) e.instancedDraw ? n.multiDrawArraysInstancedWEBGL(o, e.offsets, 0, e.counts, 0, e.instances, 0, e.drawCount) : n.multiDrawArraysWEBGL(o, e.offsets, 0, e.counts, 0, e.drawCount); else for (let t = 0; t < e.drawCount; t++) e.instances[t] && s ? s.drawArraysInstancedANGLE(o, e.offsets[t], e.counts[t], e.instances[t]) : i.drawArrays(o, e.offsets[t], e.counts[t]); + } else if (e.instanceCount && s) if (t) { + if (e.indexCount > 0) { + const i = e.firstIndex * t.stride; + s.drawElementsInstancedANGLE(o, e.indexCount, r.glIndexType, i, e.instanceCount); + } + } else e.vertexCount > 0 && s.drawArraysInstancedANGLE(o, e.firstVertex, e.vertexCount, e.instanceCount); else if (t) { + if (e.indexCount > 0) { + const s = e.firstIndex * t.stride; + i.drawElements(o, e.indexCount, r.glIndexType, s); + } + } else e.vertexCount > 0 && i.drawArrays(o, e.firstVertex, e.vertexCount); + } + } + const y7 = new Array(s7.COUNT); + function b7(t, e) { + y7.fill(0); + for (let i = 0; i < e.cmds.length; ++i) { + const s = e.cmds.array[i]; + const n = y7[s]++; + switch (s) { + case s7.BEGIN_RENDER_PASS: + { + const i = e.beginRenderPassCmds.array[n]; + m7(t, i.gpuRenderPass, i.gpuFramebuffer, i.renderArea, i.clearColors, i.clearDepth, i.clearStencil); + break; + } + + case s7.BIND_STATES: + { + const i = e.bindStatesCmds.array[n]; + f7(t, i.gpuPipelineState, i.gpuInputAssembler, i.gpuDescriptorSets, i.dynamicOffsets, i.dynamicStates); + break; + } + + case s7.DRAW: + g7(t, e.drawCmds.array[n].drawInfo); + break; + + case s7.UPDATE_BUFFER: + { + const i = e.updateBufferCmds.array[n]; + u7(t, i.gpuBuffer, i.buffer, i.offset, i.size); + break; + } + + case s7.COPY_BUFFER_TO_TEXTURE: + { + const i = e.copyBufferToTextureCmds.array[n]; + T7(t, i.buffers, i.gpuTexture, i.regions); + break; + } + } + } + } + let S7 = new Uint8Array(1); + function A7(t, e, i, s, n) { + const r = Tr(e).height; + const o = gr(e, n.width, n.height, n.depth); + const a = gr(e, s.width, 1, 1); + const l = gr(e, s.width, s.height, 1); + const h = gr(e, n.width, 1, 1); + const c = Ar(ur[e]); + S7.byteLength < o && (S7 = new Uint8Array(o)); + let u = 0; + let _ = i; + for (let e = 0; e < n.depth; e++) { + _ = i + l * e; + for (let e = 0; e < n.height; e += r) { + S7.subarray(u, u + h).set(new Uint8Array(t.buffer, t.byteOffset + _, h)); + u += h; + _ += a; + } + } + return new c(S7.buffer); + } + function T7(t, e, i, s) { + const {gl: n} = t; + const r = t.stateCache.glTexUnits[t.stateCache.texUnit]; + if (r.glTexture !== i.glTexture) { + n.bindTexture(i.glTarget, i.glTexture); + r.glTexture = i.glTexture; + } + let o = 0; + let a = 0; + const l = ur[i.format]; + const h = Ar(l); + const {isCompressed: c} = l; + const u = Tr(i.format); + const _ = new cn; + const d = new ln; + const p = new cn; + switch (i.glTarget) { + case n.TEXTURE_2D: + for (let r = 0; r < s.length; r++) { + const a = s[r]; + const l = a.texSubres.mipLevel; + d.x = 0 === a.texOffset.x ? 0 : vr(a.texOffset.x, u.width); + d.y = 0 === a.texOffset.y ? 0 : vr(a.texOffset.y, u.height); + _.width = a.texExtent.width < u.width ? a.texExtent.width : vr(a.texExtent.width, u.width); + _.height = a.texExtent.height < u.height ? a.texExtent.width : vr(a.texExtent.height, u.height); + p.width = a.buffStride > 0 ? a.buffStride : _.width; + p.height = a.buffTexHeight > 0 ? a.buffTexHeight : _.height; + const m = a.texExtent.width + d.x === i.width >> l ? a.texExtent.width : _.width; + const f = a.texExtent.height + d.y === i.height >> l ? a.texExtent.height : _.height; + let g; + const y = e[o++]; + g = p.width === _.width && p.height === _.height ? new h(y.buffer, y.byteOffset + a.buffOffset) : A7(y, i.format, a.buffOffset, p, _); + c ? i.glInternalFmt === X6.COMPRESSED_RGB_ETC1_WEBGL || t.extensions.noCompressedTexSubImage2D ? n.compressedTexImage2D(n.TEXTURE_2D, l, i.glInternalFmt, m, f, 0, g) : n.compressedTexSubImage2D(n.TEXTURE_2D, l, d.x, d.y, m, f, i.glFormat, g) : n.texSubImage2D(n.TEXTURE_2D, l, d.x, d.y, m, f, i.glFormat, i.glType, g); + } + break; + + case n.TEXTURE_CUBE_MAP: + for (let r = 0; r < s.length; r++) { + const l = s[r]; + const m = l.texSubres.mipLevel; + d.x = 0 === l.texOffset.x ? 0 : vr(l.texOffset.x, u.width); + d.y = 0 === l.texOffset.y ? 0 : vr(l.texOffset.y, u.height); + _.width = l.texExtent.width < u.width ? l.texExtent.width : vr(l.texExtent.width, u.width); + _.height = l.texExtent.height < u.height ? l.texExtent.width : vr(l.texExtent.height, u.height); + p.width = l.buffStride > 0 ? l.buffStride : _.width; + p.height = l.buffTexHeight > 0 ? l.buffTexHeight : _.height; + const f = l.texExtent.width + d.x === i.width >> m ? l.texExtent.width : _.width; + const g = l.texExtent.height + d.y === i.height >> m ? l.texExtent.height : _.height; + const y = l.texSubres.baseArrayLayer + l.texSubres.layerCount; + for (a = l.texSubres.baseArrayLayer; a < y; ++a) { + let s; + const r = e[o++]; + s = p.width === _.width && p.height === _.height ? new h(r.buffer, r.byteOffset + l.buffOffset) : A7(r, i.format, l.buffOffset, p, _); + c ? i.glInternalFmt === X6.COMPRESSED_RGB_ETC1_WEBGL || t.extensions.noCompressedTexSubImage2D ? n.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + a, m, i.glInternalFmt, f, g, 0, s) : n.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + a, m, d.x, d.y, f, g, i.glFormat, s) : n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + a, m, d.x, d.y, f, g, i.glFormat, i.glType, s); + } + } + break; + + default: + console.error("Unsupported GL texture type, copy buffer to texture failed."); + } + i.flags & Rs.GEN_MIPMAP && n.generateMipmap(i.glTarget); + } + class v7 { + constructor() { + this.counts = void 0; + this.offsets = void 0; + this.instances = void 0; + this.drawCount = 0; + this.drawByIndex = !1; + this.instancedDraw = !1; + this.byteOffsets = void 0; + this._capacity = 4; + this.counts = new Int32Array(this._capacity); + this.offsets = new Int32Array(this._capacity); + this.instances = new Int32Array(this._capacity); + this.byteOffsets = new Int32Array(this._capacity); + } + clearDraws() { + this.drawCount = 0; + this.drawByIndex = !1; + this.instancedDraw = !1; + } + setDrawInfo(t, e) { + this._ensureCapacity(t); + this.drawByIndex = e.indexCount > 0; + this.instancedDraw = !!e.instanceCount; + this.drawCount = Math.max(t + 1, this.drawCount); + if (this.drawByIndex) { + this.counts[t] = e.indexCount; + this.offsets[t] = e.firstIndex; + } else { + this.counts[t] = e.vertexCount; + this.offsets[t] = e.firstVertex; + } + this.instances[t] = Math.max(1, e.instanceCount); + } + _ensureCapacity(t) { + if (this._capacity > t) return; + this._capacity = l(t); + const e = new Int32Array(this._capacity); + const i = new Int32Array(this._capacity); + const s = new Int32Array(this._capacity); + this.byteOffsets = new Int32Array(this._capacity); + e.set(this.counts); + i.set(this.offsets); + s.set(this.instances); + this.counts = e; + this.offsets = i; + this.instances = s; + } + } + class E7 extends Pr { + constructor(...t) { + super(...t); + this._gpuBuffer = null; + this._gpuBufferView = null; + this._uniformBuffer = null; + } + get gpuBuffer() { + return this._gpuBuffer; + } + get gpuBufferView() { + return this._gpuBufferView; + } + initialize(t) { + if ("buffer" in t) { + this._isBufferView = !0; + const e = t.buffer; + this._usage = e.usage; + this._memUsage = e.memUsage; + this._size = this._stride = t.range; + this._count = 1; + this._flags = e.flags; + this._gpuBufferView = { + gpuBuffer: e.gpuBuffer, + offset: t.offset, + range: t.range + }; + } else { + this._usage = t.usage; + this._memUsage = t.memUsage; + this._size = t.size; + this._stride = Math.max(t.stride || this._size, 1); + this._count = this._size / this._stride; + this._flags = t.flags; + this._usage & Ts.UNIFORM && this._size > 0 && (this._uniformBuffer = new Uint8Array(this._size)); + this._gpuBuffer = { + usage: this._usage, + memUsage: this._memUsage, + size: this._size, + stride: this._stride, + buffer: null, + vf32: null, + indirects: new v7, + glTarget: 0, + glBuffer: null + }; + this._usage & Ts.UNIFORM && (this._gpuBuffer.buffer = this._uniformBuffer); + !function(t, e) { + const {gl: i} = t; + const s = t.stateCache; + const n = e.memUsage & Cs.HOST ? i.DYNAMIC_DRAW : i.STATIC_DRAW; + if (e.usage & Ts.VERTEX) { + e.glTarget = i.ARRAY_BUFFER; + const r = i.createBuffer(); + if (r) { + e.glBuffer = r; + if (e.size > 0) { + if (t.extensions.useVAO && s.glVAO) { + t.extensions.OES_vertex_array_object.bindVertexArrayOES(null); + s.glVAO = null; + } + d7.gpuInputAssembler = null; + if (t.stateCache.glArrayBuffer !== e.glBuffer) { + i.bindBuffer(i.ARRAY_BUFFER, e.glBuffer); + t.stateCache.glArrayBuffer = e.glBuffer; + } + i.bufferData(i.ARRAY_BUFFER, e.size, n); + i.bindBuffer(i.ARRAY_BUFFER, null); + t.stateCache.glArrayBuffer = null; + } + } + } else if (e.usage & Ts.INDEX) { + e.glTarget = i.ELEMENT_ARRAY_BUFFER; + const r = i.createBuffer(); + if (r) { + e.glBuffer = r; + if (e.size > 0) { + if (t.extensions.useVAO && s.glVAO) { + t.extensions.OES_vertex_array_object.bindVertexArrayOES(null); + s.glVAO = null; + } + d7.gpuInputAssembler = null; + if (t.stateCache.glElementArrayBuffer !== e.glBuffer) { + i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, e.glBuffer); + t.stateCache.glElementArrayBuffer = e.glBuffer; + } + i.bufferData(i.ELEMENT_ARRAY_BUFFER, e.size, n); + i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, null); + t.stateCache.glElementArrayBuffer = null; + } + } + } else if (e.usage & Ts.UNIFORM) { + e.glTarget = i.NONE; + e.buffer && (e.vf32 = new Float32Array(e.buffer.buffer)); + } else if (e.usage & Ts.INDIRECT) e.glTarget = i.NONE; else if (e.usage & Ts.TRANSFER_DST) e.glTarget = i.NONE; else if (e.usage & Ts.TRANSFER_SRC) e.glTarget = i.NONE; else { + console.error("Unsupported BufferType, create buffer failed."); + e.glTarget = i.NONE; + } + }(W6.instance, this._gpuBuffer); + W6.instance.memoryStatus.bufferSize += this._size; + } + } + destroy() { + if (this._gpuBuffer) { + !function(t, e) { + const {gl: i} = t; + const s = t.stateCache; + if (e.glBuffer) { + switch (e.glTarget) { + case i.ARRAY_BUFFER: + if (t.extensions.useVAO && s.glVAO) { + t.extensions.OES_vertex_array_object.bindVertexArrayOES(null); + t.stateCache.glVAO = null; + } + d7.gpuInputAssembler = null; + i.bindBuffer(i.ARRAY_BUFFER, null); + t.stateCache.glArrayBuffer = null; + break; + + case i.ELEMENT_ARRAY_BUFFER: + if (t.extensions.useVAO && s.glVAO) { + t.extensions.OES_vertex_array_object.bindVertexArrayOES(null); + t.stateCache.glVAO = null; + } + d7.gpuInputAssembler = null; + i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, null); + t.stateCache.glElementArrayBuffer = null; + } + i.deleteBuffer(e.glBuffer); + e.glBuffer = null; + } + }(W6.instance, this._gpuBuffer); + W6.instance.memoryStatus.bufferSize -= this._size; + this._gpuBuffer = null; + } + this._gpuBufferView && (this._gpuBufferView = null); + } + resize(t) { + if (this._isBufferView) { + console.warn("cannot resize buffer views!"); + return; + } + const e = this._size; + if (e !== t) { + this._size = t; + this._count = this._size / this._stride; + this._uniformBuffer && (this._uniformBuffer = new Uint8Array(t)); + if (this._gpuBuffer) { + this._uniformBuffer && (this._gpuBuffer.buffer = this._uniformBuffer); + this._gpuBuffer.size = t; + if (t > 0) { + !function(t, e) { + const {gl: i} = t; + const s = t.stateCache; + const n = e.memUsage & Cs.HOST ? i.DYNAMIC_DRAW : i.STATIC_DRAW; + if (e.usage & Ts.VERTEX) { + if (t.extensions.useVAO && s.glVAO) { + t.extensions.OES_vertex_array_object.bindVertexArrayOES(null); + s.glVAO = null; + } + d7.gpuInputAssembler = null; + t.stateCache.glArrayBuffer !== e.glBuffer && i.bindBuffer(i.ARRAY_BUFFER, e.glBuffer); + e.buffer ? i.bufferData(i.ARRAY_BUFFER, e.buffer, n) : i.bufferData(i.ARRAY_BUFFER, e.size, n); + i.bindBuffer(i.ARRAY_BUFFER, null); + t.stateCache.glArrayBuffer = null; + } else if (e.usage & Ts.INDEX) { + if (t.extensions.useVAO && s.glVAO) { + t.extensions.OES_vertex_array_object.bindVertexArrayOES(null); + s.glVAO = null; + } + d7.gpuInputAssembler = null; + t.stateCache.glElementArrayBuffer !== e.glBuffer && i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, e.glBuffer); + e.buffer ? i.bufferData(i.ELEMENT_ARRAY_BUFFER, e.buffer, n) : i.bufferData(i.ELEMENT_ARRAY_BUFFER, e.size, n); + i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, null); + t.stateCache.glElementArrayBuffer = null; + } else if (e.usage & Ts.UNIFORM) e.buffer && (e.vf32 = new Float32Array(e.buffer.buffer)); else if (e.usage & Ts.INDIRECT || e.usage & Ts.TRANSFER_DST || e.usage & Ts.TRANSFER_SRC) e.glTarget = i.NONE; else { + console.error("Unsupported BufferType, create buffer failed."); + e.glTarget = i.NONE; + } + }(W6.instance, this._gpuBuffer); + W6.instance.memoryStatus.bufferSize -= e; + W6.instance.memoryStatus.bufferSize += t; + } + } + } + } + update(t, e) { + if (this._isBufferView) { + console.warn("cannot update through buffer views!"); + return; + } + let i; + i = void 0 !== e ? e : this._usage & Ts.INDIRECT ? 0 : t.byteLength; + u7(W6.instance, this._gpuBuffer, t, 0, i); + } + } + class C7 { + constructor(t, e) { + this._frees = void 0; + this._freeIdx = 0; + this._freeCmds = void 0; + this._frees = new Array(e); + this._freeCmds = new eo(e); + for (let i = 0; i < e; ++i) this._frees[i] = new t; + this._freeIdx = e - 1; + } + alloc(t) { + if (this._freeIdx < 0) { + const e = 2 * this._frees.length; + const i = this._frees; + this._frees = new Array(e); + const s = e - i.length; + for (let e = 0; e < s; ++e) this._frees[e] = new t; + for (let t = s, n = 0; t < e; ++t, ++n) this._frees[t] = i[n]; + this._freeIdx += s; + } + const e = this._frees[this._freeIdx]; + this._frees[this._freeIdx--] = null; + ++e.refCount; + return e; + } + free(t) { + 0 == --t.refCount && this._freeCmds.push(t); + } + freeCmds(t) { + for (let e = 0; e < t.length; ++e) 0 == --t.array[e].refCount && this._freeCmds.push(t.array[e]); + } + release() { + for (let t = 0; t < this._freeCmds.length; ++t) { + const e = this._freeCmds.array[t]; + e.clear(); + this._frees[++this._freeIdx] = e; + } + this._freeCmds.clear(); + } + } + class x7 { + constructor() { + this.beginRenderPassCmdPool = void 0; + this.bindStatesCmdPool = void 0; + this.drawCmdPool = void 0; + this.updateBufferCmdPool = void 0; + this.copyBufferToTextureCmdPool = void 0; + this.beginRenderPassCmdPool = new C7(r7, 1); + this.bindStatesCmdPool = new C7(o7, 1); + this.drawCmdPool = new C7(a7, 1); + this.updateBufferCmdPool = new C7(l7, 1); + this.copyBufferToTextureCmdPool = new C7(h7, 1); + } + clearCmds(t) { + if (t.beginRenderPassCmds.length) { + this.beginRenderPassCmdPool.freeCmds(t.beginRenderPassCmds); + t.beginRenderPassCmds.clear(); + } + if (t.bindStatesCmds.length) { + this.bindStatesCmdPool.freeCmds(t.bindStatesCmds); + t.bindStatesCmds.clear(); + } + if (t.drawCmds.length) { + this.drawCmdPool.freeCmds(t.drawCmds); + t.drawCmds.clear(); + } + if (t.updateBufferCmds.length) { + this.updateBufferCmdPool.freeCmds(t.updateBufferCmds); + t.updateBufferCmds.clear(); + } + if (t.copyBufferToTextureCmds.length) { + this.copyBufferToTextureCmdPool.freeCmds(t.copyBufferToTextureCmds); + t.copyBufferToTextureCmds.clear(); + } + t.cmds.clear(); + } + releaseCmds() { + this.beginRenderPassCmdPool.release(); + this.bindStatesCmdPool.release(); + this.drawCmdPool.release(); + this.updateBufferCmdPool.release(); + this.copyBufferToTextureCmdPool.release(); + } + } + class w7 extends Or { + constructor(...t) { + super(...t); + this.cmdPackage = new c7; + this._cmdAllocator = new x7; + this._isInRenderPass = !1; + this._curGPUPipelineState = null; + this._curGPUInputAssembler = null; + this._curGPUDescriptorSets = []; + this._curDynamicOffsets = Array(8).fill(0); + this._curDynamicStates = new lr; + this._isStateInvalied = !1; + } + initialize(t) { + this._type = t.type; + this._queue = t.queue; + const e = W6.instance.bindingMappings.blockOffsets.length; + for (let t = 0; t < e; t++) this._curGPUDescriptorSets.push(null); + } + destroy() { + this._cmdAllocator.clearCmds(this.cmdPackage); + } + begin(t, e = 0, i) { + this._cmdAllocator.clearCmds(this.cmdPackage); + this._curGPUPipelineState = null; + this._curGPUInputAssembler = null; + this._curGPUDescriptorSets.length = 0; + this._numDrawCalls = 0; + this._numInstances = 0; + this._numTris = 0; + } + end() { + this._isStateInvalied && this.bindStates(); + this._isInRenderPass = !1; + } + beginRenderPass(t, e, i, s, n, r) { + const o = this._cmdAllocator.beginRenderPassCmdPool.alloc(r7); + o.gpuRenderPass = t.gpuRenderPass; + o.gpuFramebuffer = e.gpuFramebuffer; + o.renderArea.copy(i); + o.clearColors.length = s.length; + for (let t = 0; t < s.length; ++t) o.clearColors[t] = s[t]; + o.clearDepth = n; + o.clearStencil = r; + this.cmdPackage.beginRenderPassCmds.push(o); + this.cmdPackage.cmds.push(s7.BEGIN_RENDER_PASS); + this._isInRenderPass = !0; + } + endRenderPass() { + this._isInRenderPass = !1; + } + bindPipelineState(t) { + const e = t.gpuPipelineState; + if (e !== this._curGPUPipelineState) { + this._curGPUPipelineState = e; + this._isStateInvalied = !0; + } + } + bindDescriptorSet(t, e, i) { + const s = e.gpuDescriptorSet; + if (s !== this._curGPUDescriptorSets[t]) { + this._curGPUDescriptorSets[t] = s; + this._isStateInvalied = !0; + } + if (i) { + var n; + const e = null === (n = this._curGPUPipelineState) || void 0 === n ? void 0 : n.gpuPipelineLayout; + if (e) { + const s = this._curDynamicOffsets; + const n = e.dynamicOffsetOffsets[t]; + for (let t = 0; t < i.length; t++) s[n + t] = i[t]; + this._isStateInvalied = !0; + } + } + } + bindInputAssembler(t) { + const e = t.gpuInputAssembler; + this._curGPUInputAssembler = e; + this._isStateInvalied = !0; + } + setViewport(t) { + const e = this._curDynamicStates.viewport; + if (e.left !== t.left || e.top !== t.top || e.width !== t.width || e.height !== t.height || e.minDepth !== t.minDepth || e.maxDepth !== t.maxDepth) { + e.left = t.left; + e.top = t.top; + e.width = t.width; + e.height = t.height; + e.minDepth = t.minDepth; + e.maxDepth = t.maxDepth; + this._isStateInvalied = !0; + } + } + setScissor(t) { + const e = this._curDynamicStates.scissor; + if (e.x !== t.x || e.y !== t.y || e.width !== t.width || e.height !== t.height) { + e.x = t.x; + e.y = t.y; + e.width = t.width; + e.height = t.height; + this._isStateInvalied = !0; + } + } + setLineWidth(t) { + if (this._curDynamicStates.lineWidth !== t) { + this._curDynamicStates.lineWidth = t; + this._isStateInvalied = !0; + } + } + setDepthBias(t, e, i) { + const s = this._curDynamicStates; + if (s.depthBiasConstant !== t || s.depthBiasClamp !== e || s.depthBiasSlope !== i) { + s.depthBiasConstant = t; + s.depthBiasClamp = e; + s.depthBiasSlope = i; + this._isStateInvalied = !0; + } + } + setBlendConstants(t) { + const e = this._curDynamicStates.blendConstant; + if (e.x !== t.x || e.y !== t.y || e.z !== t.z || e.w !== t.w) { + e.copy(t); + this._isStateInvalied = !0; + } + } + setDepthBound(t, e) { + const i = this._curDynamicStates; + if (i.depthMinBounds !== t || i.depthMaxBounds !== e) { + i.depthMinBounds = t; + i.depthMaxBounds = e; + this._isStateInvalied = !0; + } + } + setStencilWriteMask(t, e) { + const i = this._curDynamicStates.stencilStatesFront; + const s = this._curDynamicStates.stencilStatesBack; + if (t & Js.FRONT && i.writeMask !== e) { + i.writeMask = e; + this._isStateInvalied = !0; + } + if (t & Js.BACK && s.writeMask !== e) { + s.writeMask = e; + this._isStateInvalied = !0; + } + } + setStencilCompareMask(t, e, i) { + const s = this._curDynamicStates.stencilStatesFront; + const n = this._curDynamicStates.stencilStatesBack; + if (t & Js.FRONT && (s.compareMask !== i || s.reference !== e)) { + s.reference = e; + s.compareMask = i; + this._isStateInvalied = !0; + } + if (t & Js.BACK && (n.compareMask !== i || n.reference !== e)) { + n.reference = e; + n.compareMask = i; + this._isStateInvalied = !0; + } + } + draw(t) { + if (this._type === tn.PRIMARY && this._isInRenderPass || this._type === tn.SECONDARY) { + this._isStateInvalied && this.bindStates(); + const e = "drawInfo" in t ? t.drawInfo : t; + const i = this._cmdAllocator.drawCmdPool.alloc(a7); + i.drawInfo.copy(e); + this.cmdPackage.drawCmds.push(i); + this.cmdPackage.cmds.push(s7.DRAW); + ++this._numDrawCalls; + this._numInstances += e.instanceCount; + const s = e.indexCount || e.vertexCount; + if (this._curGPUPipelineState) { + switch (this._curGPUPipelineState.glPrimitive) { + case 4: + this._numTris += s / 3 * Math.max(e.instanceCount, 1); + break; + + case 5: + case 6: + this._numTris += (s - 2) * Math.max(e.instanceCount, 1); + } + } + } else console.error("Command 'draw' must be recorded inside a render pass."); + } + updateBuffer(t, e, i) { + if (this._type === tn.PRIMARY && !this._isInRenderPass || this._type === tn.SECONDARY) { + const s = t.gpuBuffer; + if (s) { + const n = this._cmdAllocator.updateBufferCmdPool.alloc(l7); + let r = 0; + let o = null; + if (t.usage & Ts.INDIRECT) o = e; else { + r = void 0 !== i ? i : e.byteLength; + o = e; + } + n.gpuBuffer = s; + n.buffer = o; + n.offset = 0; + n.size = r; + this.cmdPackage.updateBufferCmds.push(n); + this.cmdPackage.cmds.push(s7.UPDATE_BUFFER); + } + } else console.error("Command 'updateBuffer' must be recorded outside a render pass."); + } + copyBuffersToTexture(t, e, i) { + if (this._type === tn.PRIMARY && !this._isInRenderPass || this._type === tn.SECONDARY) { + const s = e.gpuTexture; + if (s) { + const e = this._cmdAllocator.copyBufferToTextureCmdPool.alloc(h7); + if (e) { + e.gpuTexture = s; + e.regions = i; + e.buffers = t; + this.cmdPackage.copyBufferToTextureCmds.push(e); + this.cmdPackage.cmds.push(s7.COPY_BUFFER_TO_TEXTURE); + } + } + } else console.error("Command 'copyBufferToTexture' must be recorded outside a render pass."); + } + execute(t, e) { + for (let i = 0; i < e; ++i) { + const e = t[i]; + for (let t = 0; t < e.cmdPackage.beginRenderPassCmds.length; ++t) { + const i = e.cmdPackage.beginRenderPassCmds.array[t]; + ++i.refCount; + this.cmdPackage.beginRenderPassCmds.push(i); + } + for (let t = 0; t < e.cmdPackage.bindStatesCmds.length; ++t) { + const i = e.cmdPackage.bindStatesCmds.array[t]; + ++i.refCount; + this.cmdPackage.bindStatesCmds.push(i); + } + for (let t = 0; t < e.cmdPackage.drawCmds.length; ++t) { + const i = e.cmdPackage.drawCmds.array[t]; + ++i.refCount; + this.cmdPackage.drawCmds.push(i); + } + for (let t = 0; t < e.cmdPackage.updateBufferCmds.length; ++t) { + const i = e.cmdPackage.updateBufferCmds.array[t]; + ++i.refCount; + this.cmdPackage.updateBufferCmds.push(i); + } + for (let t = 0; t < e.cmdPackage.copyBufferToTextureCmds.length; ++t) { + const i = e.cmdPackage.copyBufferToTextureCmds.array[t]; + ++i.refCount; + this.cmdPackage.copyBufferToTextureCmds.push(i); + } + this.cmdPackage.cmds.concat(e.cmdPackage.cmds.array); + this._numDrawCalls += e._numDrawCalls; + this._numInstances += e._numInstances; + this._numTris += e._numTris; + } + } + pipelineBarrier(t, e, i, s, n) {} + bindStates() { + const t = this._cmdAllocator.bindStatesCmdPool.alloc(o7); + if (t) { + t.gpuPipelineState = this._curGPUPipelineState; + Array.prototype.push.apply(t.gpuDescriptorSets, this._curGPUDescriptorSets); + Array.prototype.push.apply(t.dynamicOffsets, this._curDynamicOffsets); + t.gpuInputAssembler = this._curGPUInputAssembler; + t.dynamicStates.copy(this._curDynamicStates); + this.cmdPackage.bindStatesCmds.push(t); + this.cmdPackage.cmds.push(s7.BIND_STATES); + this._isStateInvalied = !1; + } + } + } + class R7 extends Fr { + constructor(...t) { + super(...t); + this._gpuFramebuffer = null; + } + get gpuFramebuffer() { + return this._gpuFramebuffer; + } + initialize(t) { + this._renderPass = t.renderPass; + this._colorTextures = t.colorTextures || []; + this._depthStencilTexture = t.depthStencilTexture || null; + let e = 0; + const i = []; + for (let s = 0; s < t.colorTextures.length; ++s) { + const n = t.colorTextures[s]; + if (n) { + i.push(n.gpuTexture); + e = n.lodLevel; + } + } + let s = null; + if (t.depthStencilTexture) { + s = t.depthStencilTexture.gpuTexture; + e = t.depthStencilTexture.lodLevel; + } + let n = Number.MAX_SAFE_INTEGER; + let r = Number.MAX_SAFE_INTEGER; + this._gpuFramebuffer = { + gpuRenderPass: t.renderPass.gpuRenderPass, + gpuColorTextures: i, + gpuDepthStencilTexture: s, + glFramebuffer: null, + isOffscreen: !0, + get width() { + return this.isOffscreen ? n : this.gpuColorTextures[0].width; + }, + set width(t) { + n = t; + }, + get height() { + return this.isOffscreen ? r : this.gpuColorTextures[0].height; + }, + set height(t) { + r = t; + }, + lodLevel: e + }; + !function(t, e) { + for (let t = 0; t < e.gpuColorTextures.length; ++t) if (e.gpuColorTextures[t].isSwapchainTexture) { + e.isOffscreen = !1; + return; + } + const {gl: i} = t; + const s = []; + const n = i.createFramebuffer(); + if (n) { + e.glFramebuffer = n; + t.stateCache.glFramebuffer !== e.glFramebuffer && i.bindFramebuffer(i.FRAMEBUFFER, e.glFramebuffer); + for (let t = 0; t < e.gpuColorTextures.length; ++t) { + const n = e.gpuColorTextures[t]; + if (n) { + n.glTexture ? i.framebufferTexture2D(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0 + t, n.glTarget, n.glTexture, 0) : i.framebufferRenderbuffer(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0 + t, i.RENDERBUFFER, n.glRenderbuffer); + s.push(i.COLOR_ATTACHMENT0 + t); + e.width = Math.min(e.width, n.width); + e.height = Math.min(e.height, n.height); + } + } + const r = e.gpuDepthStencilTexture; + if (r) { + const t = ur[r.format].hasStencil ? i.DEPTH_STENCIL_ATTACHMENT : i.DEPTH_ATTACHMENT; + r.glTexture ? i.framebufferTexture2D(i.FRAMEBUFFER, t, r.glTarget, r.glTexture, 0) : i.framebufferRenderbuffer(i.FRAMEBUFFER, t, i.RENDERBUFFER, r.glRenderbuffer); + e.width = Math.min(e.width, r.width); + e.height = Math.min(e.height, r.height); + } + t.extensions.WEBGL_draw_buffers && t.extensions.WEBGL_draw_buffers.drawBuffersWEBGL(s); + const o = i.checkFramebufferStatus(i.FRAMEBUFFER); + if (o !== i.FRAMEBUFFER_COMPLETE) switch (o) { + case i.FRAMEBUFFER_INCOMPLETE_ATTACHMENT: + console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_ATTACHMENT"); + break; + + case i.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: + console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT"); + break; + + case i.FRAMEBUFFER_INCOMPLETE_DIMENSIONS: + console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_DIMENSIONS"); + break; + + case i.FRAMEBUFFER_UNSUPPORTED: + console.error("glCheckFramebufferStatus() - FRAMEBUFFER_UNSUPPORTED"); + } + t.stateCache.glFramebuffer !== e.glFramebuffer && i.bindFramebuffer(i.FRAMEBUFFER, t.stateCache.glFramebuffer); + } + }(W6.instance, this._gpuFramebuffer); + } + destroy() { + if (this._gpuFramebuffer) { + !function(t, e) { + if (e.glFramebuffer) { + t.gl.deleteFramebuffer(e.glFramebuffer); + if (t.stateCache.glFramebuffer === e.glFramebuffer) { + t.gl.bindFramebuffer(t.gl.FRAMEBUFFER, null); + t.stateCache.glFramebuffer = null; + } + e.glFramebuffer = null; + } + }(W6.instance, this._gpuFramebuffer); + this._gpuFramebuffer = null; + } + } + } + class I7 extends Gr { + constructor(...t) { + super(...t); + this._gpuInputAssembler = null; + } + get gpuInputAssembler() { + return this._gpuInputAssembler; + } + initialize(t) { + if (0 === t.vertexBuffers.length) { + console.error("InputAssemblerInfo.vertexBuffers is null."); + return; + } + this._attributes = t.attributes; + this._attributesHash = this.computeAttributesHash(); + this._vertexBuffers = t.vertexBuffers; + if (t.indexBuffer) { + this._indexBuffer = t.indexBuffer; + this._drawInfo.indexCount = this._indexBuffer.size / this._indexBuffer.stride; + this._drawInfo.firstIndex = 0; + } else { + const t = this._vertexBuffers[0]; + this._drawInfo.vertexCount = t.size / t.stride; + this._drawInfo.firstVertex = 0; + this._drawInfo.vertexOffset = 0; + } + this._drawInfo.instanceCount = 0; + this._drawInfo.firstInstance = 0; + this._indirectBuffer = t.indirectBuffer || null; + const e = new Array(t.vertexBuffers.length); + for (let i = 0; i < t.vertexBuffers.length; ++i) { + const s = t.vertexBuffers[i]; + s.gpuBuffer && (e[i] = s.gpuBuffer); + } + let i = null; + let s = 0; + if (t.indexBuffer) { + i = t.indexBuffer.gpuBuffer; + if (i) switch (i.stride) { + case 1: + s = 5121; + break; + + case 2: + s = 5123; + break; + + case 4: + s = 5125; + break; + + default: + console.error("Error index buffer stride."); + } + } + let n = null; + t.indirectBuffer && (n = t.indirectBuffer.gpuBuffer); + this._gpuInputAssembler = { + attributes: t.attributes, + gpuVertexBuffers: e, + gpuIndexBuffer: i, + gpuIndirectBuffer: n, + glAttribs: [], + glIndexType: s, + glVAOs: new Map + }; + !function(t, e) { + const {gl: i} = t; + e.glAttribs = new Array(e.attributes.length); + const s = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; + for (let t = 0; t < e.attributes.length; ++t) { + const n = e.attributes[t]; + const r = void 0 !== n.stream ? n.stream : 0; + const o = e.gpuVertexBuffers[r]; + const a = Y6(n.format, i); + const {size: l} = ur[n.format]; + e.glAttribs[t] = { + name: n.name, + glBuffer: o.glBuffer, + glType: a, + size: l, + count: ur[n.format].count, + stride: o.stride, + componentCount: Q6(a, i), + isNormalized: void 0 !== n.isNormalized && n.isNormalized, + isInstanced: void 0 !== n.isInstanced && n.isInstanced, + offset: s[r] + }; + s[r] += l; + } + }(W6.instance, this._gpuInputAssembler); + } + destroy() { + const t = W6.instance; + this._gpuInputAssembler && t.extensions.useVAO && function(t, e) { + const i = e.glVAOs.values(); + let s = i.next(); + const n = t.extensions.OES_vertex_array_object; + let r = t.stateCache.glVAO; + for (;!s.done; ) { + n.deleteVertexArrayOES(s.value); + if (r === s.value) { + n.bindVertexArrayOES(null); + r = null; + } + s = i.next(); + } + t.stateCache.glVAO = r; + e.glVAOs.clear(); + }(t, this._gpuInputAssembler); + this._gpuInputAssembler = null; + } + } + class M7 extends zr { + constructor(...t) { + super(...t); + this._gpuDescriptorSetLayout = null; + } + get gpuDescriptorSetLayout() { + return this._gpuDescriptorSetLayout; + } + initialize(t) { + Array.prototype.push.apply(this._bindings, t.bindings); + let e = 0; + let i = -1; + const s = []; + for (let t = 0; t < this._bindings.length; t++) { + const n = this._bindings[t]; + s.push(e); + e += n.count; + n.binding > i && (i = n.binding); + } + this._bindingIndices = Array(i + 1).fill(-1); + const n = this._descriptorIndices = Array(i + 1).fill(-1); + for (let t = 0; t < this._bindings.length; t++) { + const e = this._bindings[t]; + this._bindingIndices[e.binding] = t; + n[e.binding] = s[t]; + } + const r = []; + for (let t = 0; t < this._bindings.length; t++) { + const e = this._bindings[t]; + if (e.descriptorType & pr) for (let t = 0; t < e.count; t++) r.push(e.binding); + } + this._gpuDescriptorSetLayout = { + bindings: this._bindings, + dynamicBindings: r, + descriptorIndices: n, + descriptorCount: e + }; + } + destroy() { + this._bindings.length = 0; + } + } + class B7 extends Hr { + constructor(...t) { + super(...t); + this._gpuPipelineLayout = null; + } + get gpuPipelineLayout() { + return this._gpuPipelineLayout; + } + initialize(t) { + Array.prototype.push.apply(this._setLayouts, t.setLayouts); + const e = []; + const i = []; + let s = 0; + const n = []; + for (let t = 0; t < this._setLayouts.length; t++) { + const r = this._setLayouts[t]; + const o = r.gpuDescriptorSetLayout.dynamicBindings; + const a = Array(r.bindingIndices.length).fill(-1); + for (let t = 0; t < o.length; t++) { + const e = o[t]; + a[e] < 0 && (a[e] = s + t); + } + i.push(r.gpuDescriptorSetLayout); + e.push(a); + n.push(s); + s += o.length; + } + this._gpuPipelineLayout = { + gpuSetLayouts: i, + dynamicOffsetIndices: e, + dynamicOffsetCount: s, + dynamicOffsetOffsets: n + }; + } + destroy() { + this._setLayouts.length = 0; + } + } + const D7 = [ 0, 1, 3, 2, 0, 0, 0, 4, 5, 6, 0, 0, 0, 0 ]; + class P7 extends Mr { + constructor(...t) { + super(...t); + this._gpuPipelineState = null; + } + get gpuPipelineState() { + return this._gpuPipelineState; + } + initialize(t) { + this._primitive = t.primitive; + this._shader = t.shader; + this._pipelineLayout = t.pipelineLayout; + const e = this._bs; + if (t.blendState) { + const i = t.blendState; + const {targets: s} = i; + s && s.forEach(((t, i) => { + e.setTarget(i, t); + })); + void 0 !== i.isA2C && (e.isA2C = i.isA2C); + void 0 !== i.isIndepend && (e.isIndepend = i.isIndepend); + void 0 !== i.blendColor && (e.blendColor = i.blendColor); + } + Object.assign(this._rs, t.rasterizerState); + Object.assign(this._dss, t.depthStencilState); + this._is = t.inputState; + this._renderPass = t.renderPass; + this._dynamicStates = t.dynamicStates; + const i = []; + for (let t = 0; t < 31; t++) this._dynamicStates & 1 << t && i.push(1 << t); + this._gpuPipelineState = { + glPrimitive: D7[t.primitive], + gpuShader: t.shader.gpuShader, + gpuPipelineLayout: t.pipelineLayout.gpuPipelineLayout, + rs: t.rasterizerState, + dss: t.depthStencilState, + bs: t.blendState, + gpuRenderPass: t.renderPass.gpuRenderPass, + dynamicStates: i + }; + } + destroy() { + this._gpuPipelineState = null; + } + } + class O7 extends w7 { + beginRenderPass(t, e, i, s, n, r) { + m7(W6.instance, t.gpuRenderPass, e.gpuFramebuffer, i, s, n, r); + this._isInRenderPass = !0; + } + draw(t) { + if (this._isInRenderPass) { + this._isStateInvalied && this.bindStates(); + const e = "drawInfo" in t ? t.drawInfo : t; + g7(W6.instance, e); + ++this._numDrawCalls; + this._numInstances += e.instanceCount; + const i = e.indexCount || e.vertexCount; + if (this._curGPUPipelineState) { + switch (this._curGPUPipelineState.glPrimitive) { + case 4: + this._numTris += i / 3 * Math.max(e.instanceCount, 1); + break; + + case 5: + case 6: + this._numTris += (i - 2) * Math.max(e.instanceCount, 1); + } + } + } else console.error("Command 'draw' must be recorded inside a render pass."); + } + setViewport(t) { + const {stateCache: e, gl: i} = W6.instance; + if (e.viewport.left !== t.left || e.viewport.top !== t.top || e.viewport.width !== t.width || e.viewport.height !== t.height) { + i.viewport(t.left, t.top, t.width, t.height); + e.viewport.left = t.left; + e.viewport.top = t.top; + e.viewport.width = t.width; + e.viewport.height = t.height; + } + } + setScissor(t) { + const {stateCache: e, gl: i} = W6.instance; + if (e.scissorRect.x !== t.x || e.scissorRect.y !== t.y || e.scissorRect.width !== t.width || e.scissorRect.height !== t.height) { + i.scissor(t.x, t.y, t.width, t.height); + e.scissorRect.x = t.x; + e.scissorRect.y = t.y; + e.scissorRect.width = t.width; + e.scissorRect.height = t.height; + } + } + updateBuffer(t, e, i) { + if (this._isInRenderPass) console.error("Command 'updateBuffer' must be recorded outside a render pass."); else { + const s = t.gpuBuffer; + if (s) { + let n; + n = void 0 !== i ? i : t.usage & Ts.INDIRECT ? 0 : e.byteLength; + u7(W6.instance, s, e, 0, n); + } + } + } + copyBuffersToTexture(t, e, i) { + if (this._isInRenderPass) console.error("Command 'copyBufferToTexture' must be recorded outside a render pass."); else { + const s = e.gpuTexture; + s && T7(W6.instance, t, s, i); + } + } + execute(t, e) { + for (let i = 0; i < e; ++i) { + const e = t[i]; + b7(W6.instance, e.cmdPackage); + this._numDrawCalls += e._numDrawCalls; + this._numInstances += e._numInstances; + this._numTris += e._numTris; + } + } + bindStates() { + f7(W6.instance, this._curGPUPipelineState, this._curGPUInputAssembler, this._curGPUDescriptorSets, this._curDynamicOffsets, this._curDynamicStates); + this._isStateInvalied = !1; + } + } + class N7 extends jr { + constructor(...t) { + super(...t); + this.numDrawCalls = 0; + this.numInstances = 0; + this.numTris = 0; + } + initialize(t) { + this._type = t.type; + } + destroy() {} + submit(t) { + const e = t.length; + for (let i = 0; i < e; i++) { + const e = t[i]; + this.numDrawCalls += e.numDrawCalls; + this.numInstances += e.numInstances; + this.numTris += e.numTris; + } + } + clear() { + this.numDrawCalls = 0; + this.numInstances = 0; + this.numTris = 0; + } + } + class L7 extends Xr { + constructor(...t) { + super(...t); + this._gpuRenderPass = null; + } + get gpuRenderPass() { + return this._gpuRenderPass; + } + initialize(t) { + this._colorInfos = t.colorAttachments; + this._depthStencilInfo = t.depthStencilAttachment; + this._subpasses = t.subpasses; + this._gpuRenderPass = { + colorAttachments: this._colorInfos, + depthStencilAttachment: this._depthStencilInfo + }; + this._hash = this.computeHash(); + } + destroy() { + this._gpuRenderPass = null; + } + } + const F7 = [ 10497, 33648, 33071, 33071 ]; + class V7 extends qr { + get gpuSampler() { + return this._gpuSampler; + } + constructor(t, e) { + super(t, e); + this._gpuSampler = null; + let i = 0; + let s = 0; + const n = this._info.minFilter; + const r = this._info.magFilter; + const o = this._info.mipFilter; + i = n === Ds.LINEAR || n === Ds.ANISOTROPIC ? o === Ds.LINEAR || o === Ds.ANISOTROPIC ? 9987 : o === Ds.POINT ? 9985 : 9729 : o === Ds.LINEAR || o === Ds.ANISOTROPIC ? 9986 : o === Ds.POINT ? 9984 : 9728; + s = r === Ds.LINEAR || r === Ds.ANISOTROPIC ? 9729 : 9728; + const a = F7[this._info.addressU]; + const l = F7[this._info.addressV]; + const h = F7[this._info.addressW]; + this._gpuSampler = { + glMinFilter: i, + glMagFilter: s, + glWrapS: a, + glWrapT: l, + glWrapR: h + }; + } + } + class k7 extends Wr { + constructor(...t) { + super(...t); + this._gpuShader = null; + } + get gpuShader() { + null === this._gpuShader.glProgram && function(t, e) { + const {gl: i} = t; + for (let t = 0; t < e.gpuStages.length; t++) { + const s = e.gpuStages[t]; + let n = 0; + let r = ""; + let o = 1; + switch (s.type) { + case ks.VERTEX: + r = "VertexShader"; + n = i.VERTEX_SHADER; + break; + + case ks.FRAGMENT: + r = "FragmentShader"; + n = i.FRAGMENT_SHADER; + break; + + default: + console.error("Unsupported ShaderType."); + return; + } + const a = i.createShader(n); + if (a) { + s.glShader = a; + i.shaderSource(s.glShader, s.source); + i.compileShader(s.glShader); + if (!i.getShaderParameter(s.glShader, i.COMPILE_STATUS)) { + console.error(`${r} in '${e.name}' compilation failed.`); + console.error("Shader source dump:", s.source.replace(/^|\n/g, (() => `\n${o++} `))); + console.error(i.getShaderInfoLog(s.glShader)); + for (let s = 0; s < e.gpuStages.length; s++) { + const s = e.gpuStages[t]; + if (s.glShader) { + i.deleteShader(s.glShader); + s.glShader = null; + } + } + return; + } + } + } + const s = i.createProgram(); + if (!s) return; + e.glProgram = s; + for (let t = 0; t < e.gpuStages.length; t++) { + const s = e.gpuStages[t]; + i.attachShader(e.glProgram, s.glShader); + } + i.linkProgram(e.glProgram); + if (t.extensions.destroyShadersImmediately) for (let t = 0; t < e.gpuStages.length; t++) { + const s = e.gpuStages[t]; + if (s.glShader) { + i.detachShader(e.glProgram, s.glShader); + i.deleteShader(s.glShader); + s.glShader = null; + } + } + if (!i.getProgramParameter(e.glProgram, i.LINK_STATUS)) { + console.error(`Failed to link shader '${e.name}'.`); + console.error(i.getProgramInfoLog(e.glProgram)); + return; + } + R(`Shader '${e.name}' compilation succeeded.`); + const n = i.getProgramParameter(e.glProgram, i.ACTIVE_ATTRIBUTES); + e.glInputs = new Array(n); + for (let t = 0; t < n; ++t) { + const s = i.getActiveAttrib(e.glProgram, t); + if (s) { + let n; + const r = s.name.indexOf("["); + n = -1 !== r ? s.name.substr(0, r) : s.name; + const o = i.getAttribLocation(e.glProgram, n); + const a = J6(s.type, i); + const l = Z6(s.type, i); + e.glInputs[t] = { + binding: o, + name: n, + type: a, + stride: l, + count: s.size, + size: l * s.size, + glType: s.type, + glLoc: o + }; + } + } + if (e.blocks.length > 0) { + e.glBlocks = new Array(e.blocks.length); + for (let t = 0; t < e.blocks.length; ++t) { + const s = e.blocks[t]; + const n = { + set: s.set, + binding: s.binding, + name: s.name, + size: 0, + glUniforms: new Array(s.members.length), + glActiveUniforms: [] + }; + e.glBlocks[t] = n; + for (let t = 0; t < s.members.length; ++t) { + const e = s.members[t]; + const r = q6(e.type, i); + const o = Z6(r, i); + const a = o * e.count; + n.glUniforms[t] = { + binding: -1, + name: e.name, + type: e.type, + stride: o, + count: e.count, + size: a, + offset: 0, + glType: r, + glLoc: null, + array: null + }; + } + } + } + for (let t = 0; t < e.subpassInputs.length; ++t) { + const i = e.subpassInputs[t]; + e.samplerTextures.push(new Bn(i.set, i.binding, i.name, As.SAMPLER2D, i.count)); + } + if (e.samplerTextures.length > 0) { + e.glSamplerTextures = new Array(e.samplerTextures.length); + for (let t = 0; t < e.samplerTextures.length; ++t) { + const s = e.samplerTextures[t]; + e.glSamplerTextures[t] = { + set: s.set, + binding: s.binding, + name: s.name, + type: s.type, + count: s.count, + units: [], + glUnits: null, + glType: q6(s.type, i), + glLoc: null + }; + } + } + const r = i.getProgramParameter(e.glProgram, i.ACTIVE_UNIFORMS); + for (let s = 0; s < r; ++s) { + const n = i.getActiveUniform(e.glProgram, s); + if (n && n.type !== i.SAMPLER_2D && n.type !== i.SAMPLER_CUBE) { + const s = i.getUniformLocation(e.glProgram, n.name); + if (t.extensions.isLocationActive(s)) { + let t; + const i = n.name.indexOf("["); + t = -1 !== i ? n.name.substr(0, i) : n.name; + for (let i = 0; i < e.glBlocks.length; i++) { + const r = e.glBlocks[i]; + for (let e = 0; e < r.glUniforms.length; e++) { + const i = r.glUniforms[e]; + if (i.name === t) { + i.glLoc = s; + i.count = n.size; + i.size = i.stride * i.count; + i.array = new (K6(i.type))(i.size / 4); + r.glActiveUniforms.push(i); + break; + } + } + } + } + } + } + for (let t = 0; t < e.glBlocks.length; t++) { + const i = e.glBlocks[t]; + for (let t = 0; t < i.glUniforms.length; t++) { + const e = i.glUniforms[t]; + e.offset = i.size / 4; + i.size += e.size; + } + } + const o = []; + const a = []; + const {bindingMappings: l} = t; + const {texUnitCacheMap: h} = t.stateCache; + let c = 0; + for (let t = 0; t < e.blocks.length; ++t) e.blocks[t].set === l.flexibleSet && c++; + let u = 0; + for (let s = 0; s < e.samplerTextures.length; ++s) { + const n = e.samplerTextures[s]; + const r = i.getUniformLocation(e.glProgram, n.name); + if (t.extensions.isLocationActive(r)) { + o.push(e.glSamplerTextures[s]); + a.push(r); + } + if (void 0 === h[n.name]) { + let e = n.binding + l.samplerTextureOffsets[n.set] + u; + n.set === l.flexibleSet && (e -= c); + h[n.name] = e % t.capabilities.maxTextureUnits; + u += n.count - 1; + } + } + if (o.length) { + const s = []; + for (let e = 0; e < o.length; ++e) { + const i = o[e]; + let n = h[i.name]; + if (void 0 !== n) { + i.glLoc = a[e]; + for (let e = 0; e < i.count; ++e) { + for (;s[n]; ) n = (n + 1) % t.capabilities.maxTextureUnits; + i.units.push(n); + s[n] = !0; + } + } + } + let n = 0; + for (let e = 0; e < o.length; ++e) { + const i = o[e]; + if (!t.extensions.isLocationActive(i.glLoc)) { + i.glLoc = a[e]; + for (let e = 0; e < i.count; ++e) { + for (;s[n]; ) n = (n + 1) % t.capabilities.maxTextureUnits; + void 0 === h[i.name] && (h[i.name] = n); + i.units.push(n); + s[n] = !0; + } + } + } + t.stateCache.glProgram !== e.glProgram && i.useProgram(e.glProgram); + for (let t = 0; t < o.length; t++) { + const e = o[t]; + e.glUnits = new Int32Array(e.units); + i.uniform1iv(e.glLoc, e.glUnits); + } + t.stateCache.glProgram !== e.glProgram && i.useProgram(t.stateCache.glProgram); + } + for (let t = 0; t < e.glBlocks.length; ) if (e.glBlocks[t].glActiveUniforms.length) t++; else { + e.glBlocks[t] = e.glBlocks[e.glBlocks.length - 1]; + e.glBlocks.length--; + } + e.glSamplerTextures = o; + }(W6.instance, this._gpuShader); + return this._gpuShader; + } + initialize(t) { + this._name = t.name; + this._stages = t.stages; + this._attributes = t.attributes; + this._blocks = t.blocks; + this._samplers = t.samplers; + this._gpuShader = { + name: t.name, + blocks: t.blocks.slice(), + samplerTextures: t.samplerTextures.slice(), + subpassInputs: t.subpassInputs.slice(), + gpuStages: new Array(t.stages.length), + glProgram: null, + glInputs: [], + glUniforms: [], + glBlocks: [], + glSamplerTextures: [] + }; + for (let e = 0; e < t.stages.length; ++e) { + const i = t.stages[e]; + this._gpuShader.gpuStages[e] = { + type: i.stage, + source: i.source, + glShader: null + }; + } + } + destroy() { + if (this._gpuShader) { + !function(t, e) { + if (e.glProgram) { + const {gl: i} = t; + if (!t.extensions.destroyShadersImmediately) for (let t = 0; t < e.gpuStages.length; t++) { + const s = e.gpuStages[t]; + if (s.glShader) { + i.detachShader(e.glProgram, s.glShader); + i.deleteShader(s.glShader); + s.glShader = null; + } + } + i.deleteProgram(e.glProgram); + if (t.stateCache.glProgram === e.glProgram) { + t.gl.useProgram(null); + t.stateCache.glProgram = null; + } + e.glProgram = null; + } + }(W6.instance, this._gpuShader); + this._gpuShader = null; + } + } + } + class U7 { + constructor() { + this.glArrayBuffer = null; + this.glElementArrayBuffer = null; + this.glVAO = null; + this.texUnit = 0; + this.glTexUnits = []; + this.glRenderbuffer = null; + this.glFramebuffer = null; + this.viewport = new fn; + this.scissorRect = new hn(0, 0, 0, 0); + this.rs = new Cr; + this.dss = new wr; + this.bs = new Ir; + this.glProgram = null; + this.glEnabledAttribLocs = []; + this.glCurrentAttribLocs = []; + this.texUnitCacheMap = {}; + } + initialize(t, e) { + for (let e = 0; e < t; ++e) this.glTexUnits.push({ + glTexture: null + }); + this.glEnabledAttribLocs.length = e; + this.glEnabledAttribLocs.fill(!1); + this.glCurrentAttribLocs.length = e; + this.glCurrentAttribLocs.fill(!1); + } + } + class G7 extends Yr { + constructor(...t) { + super(...t); + this._gpuTexture = null; + this._lodLevel = 0; + } + get gpuTexture() { + return this._gpuTexture; + } + get lodLevel() { + return this._lodLevel; + } + initialize(t, e) { + let i = t; + const s = t; + if ("texture" in t) { + i = s.texture.info; + this._isTextureView = !0; + } + this._info.copy(i); + this._isPowerOf2 = fr(this._info.width) && fr(this._info.height); + this._size = yr(this._info.format, this.width, this.height, this.depth, this._info.levelCount) * this._info.layerCount; + if (this._isTextureView) { + this._viewInfo.copy(s); + this._lodLevel = s.baseLevel; + this._gpuTexture = s.texture._gpuTexture; + } else { + this._gpuTexture = { + type: i.type, + format: i.format, + usage: i.usage, + width: i.width, + height: i.height, + depth: i.depth, + size: this._size, + arrayLayer: i.layerCount, + mipLevel: i.levelCount, + samples: i.samples, + flags: i.flags, + isPowerOf2: this._isPowerOf2, + glTarget: 0, + glInternalFmt: 0, + glFormat: 0, + glType: 0, + glUsage: 0, + glTexture: null, + glRenderbuffer: null, + glWrapS: 0, + glWrapT: 0, + glMinFilter: 0, + glMagFilter: 0, + isSwapchainTexture: e || !1 + }; + _7(W6.instance, this._gpuTexture); + W6.instance.memoryStatus.textureSize += this._size; + this._viewInfo.texture = this; + this._viewInfo.type = t.type; + this._viewInfo.format = t.format; + this._viewInfo.baseLevel = 0; + this._viewInfo.levelCount = t.levelCount; + this._viewInfo.baseLayer = 0; + this._viewInfo.layerCount = t.layerCount; + } + } + destroy() { + if (!this._isTextureView && this._gpuTexture) { + !function(t, e) { + const {gl: i} = t; + if (e.glTexture) { + const s = t.stateCache.glTexUnits; + let n = t.stateCache.texUnit; + i.deleteTexture(e.glTexture); + for (let t = 0; t < s.length; t++) if (s[t].glTexture === e.glTexture) { + i.activeTexture(i.TEXTURE0 + t); + n = t; + i.bindTexture(e.glTarget, null); + s[t].glTexture = null; + } + t.stateCache.texUnit = n; + e.glTexture = null; + } + if (e.glRenderbuffer) { + let s = t.stateCache.glRenderbuffer; + i.deleteRenderbuffer(e.glRenderbuffer); + if (s === e.glRenderbuffer) { + i.bindRenderbuffer(i.RENDERBUFFER, null); + s = null; + } + e.glRenderbuffer = null; + } + }(W6.instance, this._gpuTexture); + W6.instance.memoryStatus.textureSize -= this._size; + this._gpuTexture = null; + } + } + resize(t, e) { + if (this._info.width === t && this._info.height === e) return; + this._info.levelCount === G7.getLevelCount(this._info.width, this._info.height) ? this._info.levelCount = G7.getLevelCount(t, e) : this._info.levelCount > 1 && (this._info.levelCount = Math.min(this._info.levelCount, G7.getLevelCount(t, e))); + const i = this._size; + this._info.width = t; + this._info.height = e; + this._size = yr(this._info.format, this.width, this.height, this.depth, this._info.levelCount) * this._info.layerCount; + if (!this._isTextureView && this._gpuTexture) { + this._gpuTexture.width = t; + this._gpuTexture.height = e; + this._gpuTexture.size = this._size; + !function(t, e) { + if (!e.size) return; + const {gl: i} = t; + let s = e.width; + let n = e.height; + switch (e.type) { + case xs.TEX2D: + { + e.glTarget = i.TEXTURE_2D; + const r = Math.max(s, n); + r > t.capabilities.maxTextureSize && F(9100, r, t.capabilities.maxTextureSize); + if (e.glRenderbuffer) { + if (t.stateCache.glRenderbuffer !== e.glRenderbuffer) { + i.bindRenderbuffer(i.RENDERBUFFER, e.glRenderbuffer); + t.stateCache.glRenderbuffer = e.glRenderbuffer; + } + i.renderbufferStorage(i.RENDERBUFFER, e.glInternalFmt, s, n); + } else if (e.glTexture) { + const r = t.stateCache.glTexUnits[t.stateCache.texUnit]; + if (r.glTexture !== e.glTexture) { + i.bindTexture(i.TEXTURE_2D, e.glTexture); + r.glTexture = e.glTexture; + } + if (ur[e.format].isCompressed) for (let t = 0; t < e.mipLevel; ++t) { + const r = gr(e.format, s, n, 1); + const o = new Uint8Array(r); + i.compressedTexImage2D(i.TEXTURE_2D, t, e.glInternalFmt, s, n, 0, o); + s = Math.max(1, s >> 1); + n = Math.max(1, n >> 1); + } else for (let t = 0; t < e.mipLevel; ++t) { + i.texImage2D(i.TEXTURE_2D, t, e.glInternalFmt, s, n, 0, e.glFormat, e.glType, null); + s = Math.max(1, s >> 1); + n = Math.max(1, n >> 1); + } + } + break; + } + + case xs.CUBE: + { + e.glTarget = i.TEXTURE_CUBE_MAP; + const r = Math.max(s, n); + r > t.capabilities.maxCubeMapTextureSize && F(9100, r, t.capabilities.maxTextureSize); + const o = t.stateCache.glTexUnits[t.stateCache.texUnit]; + if (o.glTexture !== e.glTexture) { + i.bindTexture(i.TEXTURE_CUBE_MAP, e.glTexture); + o.glTexture = e.glTexture; + } + if (ur[e.format].isCompressed) for (let t = 0; t < 6; ++t) { + s = e.width; + n = e.height; + for (let r = 0; r < e.mipLevel; ++r) { + const o = gr(e.format, s, n, 1); + const a = new Uint8Array(o); + i.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + t, r, e.glInternalFmt, s, n, 0, a); + s = Math.max(1, s >> 1); + n = Math.max(1, n >> 1); + } + } else for (let t = 0; t < 6; ++t) { + s = e.width; + n = e.height; + for (let r = 0; r < e.mipLevel; ++r) { + i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + t, r, e.glInternalFmt, s, n, 0, e.glFormat, e.glType, null); + s = Math.max(1, s >> 1); + n = Math.max(1, n >> 1); + } + } + break; + } + + default: + console.error("Unsupported TextureType, create texture failed."); + e.type = xs.TEX2D; + e.glTarget = i.TEXTURE_2D; + } + }(W6.instance, this._gpuTexture); + W6.instance.memoryStatus.textureSize -= i; + W6.instance.memoryStatus.textureSize += this._size; + } + } + initAsSwapchainTexture(t) { + const e = new xn; + e.format = t.format; + e.usage = ur[t.format].hasDepth ? ws.DEPTH_STENCIL_ATTACHMENT : ws.COLOR_ATTACHMENT; + e.width = t.width; + e.height = t.height; + this.initialize(e, !0); + } + } + const z7 = "webglcontextlost"; + function H7(t, e) { + const i = [ "", "WEBKIT_", "MOZ_" ]; + for (let s = 0; s < i.length; ++s) { + const n = t.getExtension(i[s] + e); + if (n) return n; + } + return null; + } + function j7(t) { + const e = { + EXT_texture_filter_anisotropic: H7(t, "EXT_texture_filter_anisotropic"), + EXT_blend_minmax: H7(t, "EXT_blend_minmax"), + EXT_frag_depth: H7(t, "EXT_frag_depth"), + EXT_shader_texture_lod: H7(t, "EXT_shader_texture_lod"), + EXT_sRGB: H7(t, "EXT_sRGB"), + OES_vertex_array_object: H7(t, "OES_vertex_array_object"), + EXT_color_buffer_half_float: H7(t, "EXT_color_buffer_half_float"), + WEBGL_color_buffer_float: H7(t, "WEBGL_color_buffer_float"), + WEBGL_compressed_texture_etc1: H7(t, "WEBGL_compressed_texture_etc1"), + WEBGL_compressed_texture_etc: H7(t, "WEBGL_compressed_texture_etc"), + WEBGL_compressed_texture_pvrtc: H7(t, "WEBGL_compressed_texture_pvrtc"), + WEBGL_compressed_texture_s3tc: H7(t, "WEBGL_compressed_texture_s3tc"), + WEBGL_compressed_texture_s3tc_srgb: H7(t, "WEBGL_compressed_texture_s3tc_srgb"), + WEBGL_debug_shaders: H7(t, "WEBGL_debug_shaders"), + WEBGL_draw_buffers: H7(t, "WEBGL_draw_buffers"), + WEBGL_lose_context: H7(t, "WEBGL_lose_context"), + WEBGL_depth_texture: H7(t, "WEBGL_depth_texture"), + OES_texture_half_float: H7(t, "OES_texture_half_float"), + OES_texture_half_float_linear: H7(t, "OES_texture_half_float_linear"), + OES_texture_float: H7(t, "OES_texture_float"), + OES_texture_float_linear: H7(t, "OES_texture_float_linear"), + OES_standard_derivatives: H7(t, "OES_standard_derivatives"), + OES_element_index_uint: H7(t, "OES_element_index_uint"), + ANGLE_instanced_arrays: H7(t, "ANGLE_instanced_arrays"), + WEBGL_debug_renderer_info: H7(t, "WEBGL_debug_renderer_info"), + WEBGL_multi_draw: null, + WEBGL_compressed_texture_astc: null, + destroyShadersImmediately: !0, + noCompressedTexSubImage2D: !1, + isLocationActive: t => !!t, + useVAO: !1 + }; + Po.os === Ro.IOS && 14 === Po.osMainVersion && Po.isBrowser || (e.WEBGL_compressed_texture_astc = H7(t, "WEBGL_compressed_texture_astc")); + Po.os !== Ro.ANDROID && Po.os !== Ro.IOS && (e.WEBGL_multi_draw = H7(t, "WEBGL_multi_draw")); + Po.browserType === Co.UC && (e.ANGLE_instanced_arrays = null); + Po.os === Ro.IOS && Po.osMainVersion <= 10 && (e.destroyShadersImmediately = !1); + e.OES_vertex_array_object && (e.useVAO = !0); + return e; + } + class X7 extends Lr { + constructor(...t) { + super(...t); + this.stateCache = new U7; + this.cmdAllocator = new x7; + this.nullTex2D = null; + this.nullTexCube = null; + this._canvas = null; + this._webGLContextLostHandler = null; + this._extensions = null; + } + get extensions() { + return this._extensions; + } + initialize(t) { + this._canvas = t.windowHandle; + this._webGLContextLostHandler = this._onWebGLContextLost.bind(this); + this._canvas.addEventListener(z7, this._onWebGLContextLost); + const e = W6.instance.gl; + this.stateCache.initialize(W6.instance.capabilities.maxTextureUnits, W6.instance.capabilities.maxVertexAttributes); + this._extensions = j7(e); + !function(t) { + t.activeTexture(t.TEXTURE0); + t.pixelStorei(t.PACK_ALIGNMENT, 1); + t.pixelStorei(t.UNPACK_ALIGNMENT, 1); + t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL, !1); + t.bindFramebuffer(t.FRAMEBUFFER, null); + t.enable(t.SCISSOR_TEST); + t.enable(t.CULL_FACE); + t.cullFace(t.BACK); + t.frontFace(t.CCW); + t.disable(t.POLYGON_OFFSET_FILL); + t.polygonOffset(0, 0); + t.enable(t.DEPTH_TEST); + t.depthMask(!0); + t.depthFunc(t.LESS); + t.depthRange(0, 1); + t.stencilFuncSeparate(t.FRONT, t.ALWAYS, 1, 65535); + t.stencilOpSeparate(t.FRONT, t.KEEP, t.KEEP, t.KEEP); + t.stencilMaskSeparate(t.FRONT, 65535); + t.stencilFuncSeparate(t.BACK, t.ALWAYS, 1, 65535); + t.stencilOpSeparate(t.BACK, t.KEEP, t.KEEP, t.KEEP); + t.stencilMaskSeparate(t.BACK, 65535); + t.disable(t.STENCIL_TEST); + t.disable(t.SAMPLE_ALPHA_TO_COVERAGE); + t.disable(t.BLEND); + t.blendEquationSeparate(t.FUNC_ADD, t.FUNC_ADD); + t.blendFuncSeparate(t.ONE, t.ZERO, t.ONE, t.ZERO); + t.colorMask(!0, !0, !0, !0); + t.blendColor(0, 0, 0, 0); + }(e); + const i = bs.RGBA8; + let s = bs.DEPTH_STENCIL; + let n = e.getParameter(e.DEPTH_BITS); + const r = e.getParameter(e.STENCIL_BITS); + n && r ? s = bs.DEPTH_STENCIL : n && (s = bs.DEPTH); + this._colorTexture = new G7; + this._colorTexture.initAsSwapchainTexture({ + swapchain: this, + format: i, + width: t.width, + height: t.height + }); + this._depthStencilTexture = new G7; + this._depthStencilTexture.initAsSwapchainTexture({ + swapchain: this, + format: s, + width: t.width, + height: t.height + }); + this.nullTex2D = W6.instance.createTexture(new xn(xs.TEX2D, ws.SAMPLED, bs.RGBA8, 2, 2, Rs.GEN_MIPMAP)); + this.nullTexCube = W6.instance.createTexture(new xn(xs.CUBE, ws.SAMPLED, bs.RGBA8, 2, 2, Rs.GEN_MIPMAP, 6)); + const o = new mn; + o.texExtent.width = 2; + o.texExtent.height = 2; + const a = new Uint8Array(this.nullTex2D.size); + a.fill(0); + W6.instance.copyBuffersToTexture([ a ], this.nullTex2D, [ o ]); + o.texSubres.layerCount = 6; + W6.instance.copyBuffersToTexture([ a, a, a, a, a, a ], this.nullTexCube, [ o ]); + } + destroy() { + if (this._canvas && this._webGLContextLostHandler) { + this._canvas.removeEventListener(z7, this._webGLContextLostHandler); + this._webGLContextLostHandler = null; + } + if (this.nullTex2D) { + this.nullTex2D.destroy(); + this.nullTex2D = null; + } + if (this.nullTexCube) { + this.nullTexCube.destroy(); + this.nullTexCube = null; + } + this._extensions = null; + this._canvas = null; + } + resize(t, e, i) { + if (this._colorTexture.width !== t || this._colorTexture.height !== e) { + R(`Resizing swapchain: ${t}x${e}`); + this._canvas.width = t; + this._canvas.height = e; + this._colorTexture.resize(t, e); + this._depthStencilTexture.resize(t, e); + } + } + _onWebGLContextLost(t) { + N(11e3); + C(t); + } + } + class W7 extends hr { + get info() { + return this._info; + } + get hash() { + return this._hash; + } + constructor(t, e) { + super(ps.BUFFER_BARRIER); + this._info = new qn; + this._hash = 0; + this._info.copy(t); + this._hash = e; + } + static computeHash(t) { + let e = `${t.prevAccesses} ${t.nextAccesses}`; + e += t.type; + e += t.offset; + e += t.size; + e += t.discardContents; + e += t.srcQueue ? t.srcQueue.type : 0; + e += t.dstQueue ? t.dstQueue.type : 0; + return Ur(e, 666); + } + } + class Y7 extends Nr { + constructor(...t) { + super(...t); + this._swapchain = null; + this._context = null; + this._bindingMappings = null; + this._textureExclusive = new Array(bs.COUNT); + } + get gl() { + return this._context; + } + get extensions() { + return this._swapchain.extensions; + } + get stateCache() { + return this._swapchain.stateCache; + } + get nullTex2D() { + return this._swapchain.nullTex2D; + } + get nullTexCube() { + return this._swapchain.nullTexCube; + } + get textureExclusive() { + return this._textureExclusive; + } + get bindingMappings() { + return this._bindingMappings; + } + initialize(t) { + W6.setInstance(this); + this._gfxAPI = fs.WEBGL; + const e = this._bindingMappingInfo = t.bindingMappingInfo; + const i = []; + const s = []; + const n = e.setIndices[0]; + i[n] = 0; + s[n] = 0; + for (let t = 1; t < e.setIndices.length; ++t) { + const n = e.setIndices[t]; + const r = e.setIndices[t - 1]; + i[n] = e.maxBlockCounts[r] + i[r]; + s[n] = e.maxSamplerTextureCounts[r] + s[r]; + } + for (let t = 0; t < e.setIndices.length; ++t) { + const i = e.setIndices[t]; + s[i] -= e.maxBlockCounts[i]; + } + this._bindingMappings = { + blockOffsets: i, + samplerTextureOffsets: s, + flexibleSet: e.setIndices[e.setIndices.length - 1] + }; + const r = this._context = function(t) { + let e = null; + try { + const i = { + alpha: pe.ENABLE_TRANSPARENT_CANVAS, + antialias: pe.ENABLE_WEBGL_ANTIALIAS, + depth: !0, + stencil: !0, + premultipliedAlpha: !1, + preserveDrawingBuffer: !1, + powerPreference: "default", + failIfMajorPerformanceCaveat: !1 + }; + e = t.getContext("webgl", i); + } catch (t) { + return null; + } + return e; + }(Nr.canvas); + if (!r) { + console.error("This device does not support WebGL."); + return !1; + } + this._queue = this.createQueue(new ir(Qs.GRAPHICS)); + this._cmdBuff = this.createCommandBuffer(new er(this._queue)); + this._caps.maxVertexAttributes = r.getParameter(r.MAX_VERTEX_ATTRIBS); + this._caps.maxVertexUniformVectors = r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS); + this._caps.maxFragmentUniformVectors = r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS); + this._caps.maxTextureUnits = r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS); + this._caps.maxVertexTextureUnits = r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS); + this._caps.maxTextureSize = r.getParameter(r.MAX_TEXTURE_SIZE); + this._caps.maxCubeMapTextureSize = r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE); + this._caps.maxUniformBufferBindings = 16; + const o = r.getSupportedExtensions(); + let a = ""; + if (o) for (const t of o) a += `${t} `; + const l = j7(r); + if (l.WEBGL_debug_renderer_info) { + this._renderer = r.getParameter(l.WEBGL_debug_renderer_info.UNMASKED_RENDERER_WEBGL); + this._vendor = r.getParameter(l.WEBGL_debug_renderer_info.UNMASKED_VENDOR_WEBGL); + } else { + this._renderer = r.getParameter(r.RENDERER); + this._vendor = r.getParameter(r.VENDOR); + } + const h = r.getParameter(r.VERSION); + this._features.fill(!1); + this.initFormatFeatures(l); + l.EXT_blend_minmax && (this._features[ys.BLEND_MINMAX] = !0); + l.OES_element_index_uint && (this._features[ys.ELEMENT_INDEX_UINT] = !0); + l.ANGLE_instanced_arrays && (this._features[ys.INSTANCED_ARRAYS] = !0); + l.WEBGL_draw_buffers && (this._features[ys.MULTIPLE_RENDER_TARGETS] = !0); + let c = ""; + this.getFormatFeatures(bs.ETC_RGB8) && (c += "etc1 "); + this.getFormatFeatures(bs.ETC2_RGB8) && (c += "etc2 "); + this.getFormatFeatures(bs.BC1) && (c += "dxt "); + this.getFormatFeatures(bs.PVRTC_RGB2) && (c += "pvrtc "); + this.getFormatFeatures(bs.ASTC_RGBA_4X4) && (c += "astc "); + R("WebGL device initialized."); + R(`RENDERER: ${this._renderer}`); + R(`VENDOR: ${this._vendor}`); + R(`VERSION: ${h}`); + R(`COMPRESSED_FORMAT: ${c}`); + R(`EXTENSIONS: ${a}`); + return !0; + } + destroy() { + if (this._queue) { + this._queue.destroy(); + this._queue = null; + } + if (this._cmdBuff) { + this._cmdBuff.destroy(); + this._cmdBuff = null; + } + this._swapchain = null; + } + flushCommands(t) {} + acquire(t) {} + present() { + const t = this._queue; + this._numDrawCalls = t.numDrawCalls; + this._numInstances = t.numInstances; + this._numTris = t.numTris; + t.clear(); + } + initFormatFeatures(t) { + this._formatFeatures.fill(Is.NONE); + this._textureExclusive.fill(!0); + const e = Is.RENDER_TARGET | Is.SAMPLED_TEXTURE | Is.LINEAR_FILTER; + this._formatFeatures[bs.RGB8] = e; + this._formatFeatures[bs.R5G6B5] = e; + this._textureExclusive[bs.R5G6B5] = !1; + this._formatFeatures[bs.RGBA8] = e; + this._formatFeatures[bs.RGBA4] = e; + this._textureExclusive[bs.RGBA4] = !1; + this._formatFeatures[bs.RGB5A1] = e; + this._textureExclusive[bs.RGB5A1] = !1; + this._formatFeatures[bs.DEPTH] = Is.RENDER_TARGET; + this._textureExclusive[bs.DEPTH] = !1; + this._formatFeatures[bs.DEPTH_STENCIL] = Is.RENDER_TARGET; + this._textureExclusive[bs.DEPTH_STENCIL] = !1; + this._formatFeatures[bs.R8I] |= Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.RG8I] |= Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.RGB8I] |= Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.RGBA8I] |= Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.R8UI] |= Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.RG8UI] |= Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.RGB8UI] |= Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.RGBA8UI] |= Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.R8I] |= Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.RG8I] |= Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.RGB8I] |= Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.RGBA8I] |= Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.R8UI] |= Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.RG8UI] |= Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.RGB8UI] |= Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.RGBA8UI] |= Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.R32F] |= Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.RG32F] |= Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.RGB32F] |= Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.RGBA32F] |= Is.VERTEX_ATTRIBUTE; + if (t.EXT_sRGB) { + this._formatFeatures[bs.SRGB8] = e; + this._formatFeatures[bs.SRGB8_A8] = e; + this._textureExclusive[bs.SRGB8_A8] = !1; + } + if (t.WEBGL_depth_texture) { + this._formatFeatures[bs.DEPTH] |= e; + this._formatFeatures[bs.DEPTH_STENCIL] |= e; + } + if (t.WEBGL_color_buffer_float) { + this._formatFeatures[bs.RGB32F] |= Is.RENDER_TARGET; + this._formatFeatures[bs.RGBA32F] |= Is.RENDER_TARGET; + this._textureExclusive[bs.RGB32F] = !1; + this._textureExclusive[bs.RGBA32F] = !1; + } + if (t.EXT_color_buffer_half_float) { + this._formatFeatures[bs.RGB16F] |= Is.RENDER_TARGET; + this._formatFeatures[bs.RGBA16F] |= Is.RENDER_TARGET; + this._textureExclusive[bs.RGB16F] = !1; + this._textureExclusive[bs.RGBA16F] = !1; + } + if (t.OES_texture_float) { + this._formatFeatures[bs.RGB32F] |= Is.RENDER_TARGET | Is.SAMPLED_TEXTURE; + this._formatFeatures[bs.RGBA32F] |= Is.RENDER_TARGET | Is.SAMPLED_TEXTURE; + } + if (t.OES_texture_half_float) { + this._formatFeatures[bs.RGB16F] |= Is.RENDER_TARGET | Is.SAMPLED_TEXTURE; + this._formatFeatures[bs.RGBA16F] |= Is.RENDER_TARGET | Is.SAMPLED_TEXTURE; + } + if (t.OES_texture_float_linear) { + this._formatFeatures[bs.RGB32F] |= Is.LINEAR_FILTER; + this._formatFeatures[bs.RGBA32F] |= Is.LINEAR_FILTER; + } + if (t.OES_texture_half_float_linear) { + this._formatFeatures[bs.RGB16F] |= Is.LINEAR_FILTER; + this._formatFeatures[bs.RGBA16F] |= Is.LINEAR_FILTER; + } + const i = Is.SAMPLED_TEXTURE | Is.LINEAR_FILTER; + t.WEBGL_compressed_texture_etc1 && (this._formatFeatures[bs.ETC_RGB8] = i); + if (t.WEBGL_compressed_texture_etc) { + this._formatFeatures[bs.ETC2_RGB8] = i; + this._formatFeatures[bs.ETC2_RGBA8] = i; + this._formatFeatures[bs.ETC2_SRGB8] = i; + this._formatFeatures[bs.ETC2_SRGB8_A8] = i; + this._formatFeatures[bs.ETC2_RGB8_A1] = i; + this._formatFeatures[bs.ETC2_SRGB8_A1] = i; + } + if (t.WEBGL_compressed_texture_s3tc) { + this._formatFeatures[bs.BC1] = i; + this._formatFeatures[bs.BC1_ALPHA] = i; + this._formatFeatures[bs.BC1_SRGB] = i; + this._formatFeatures[bs.BC1_SRGB_ALPHA] = i; + this._formatFeatures[bs.BC2] = i; + this._formatFeatures[bs.BC2_SRGB] = i; + this._formatFeatures[bs.BC3] = i; + this._formatFeatures[bs.BC3_SRGB] = i; + } + if (t.WEBGL_compressed_texture_pvrtc) { + this._formatFeatures[bs.PVRTC_RGB2] |= i; + this._formatFeatures[bs.PVRTC_RGBA2] |= i; + this._formatFeatures[bs.PVRTC_RGB4] |= i; + this._formatFeatures[bs.PVRTC_RGBA4] |= i; + } + if (t.WEBGL_compressed_texture_astc) { + this._formatFeatures[bs.ASTC_RGBA_4X4] |= i; + this._formatFeatures[bs.ASTC_RGBA_5X4] |= i; + this._formatFeatures[bs.ASTC_RGBA_5X5] |= i; + this._formatFeatures[bs.ASTC_RGBA_6X5] |= i; + this._formatFeatures[bs.ASTC_RGBA_6X6] |= i; + this._formatFeatures[bs.ASTC_RGBA_8X5] |= i; + this._formatFeatures[bs.ASTC_RGBA_8X6] |= i; + this._formatFeatures[bs.ASTC_RGBA_8X8] |= i; + this._formatFeatures[bs.ASTC_RGBA_10X5] |= i; + this._formatFeatures[bs.ASTC_RGBA_10X6] |= i; + this._formatFeatures[bs.ASTC_RGBA_10X8] |= i; + this._formatFeatures[bs.ASTC_RGBA_10X10] |= i; + this._formatFeatures[bs.ASTC_RGBA_12X10] |= i; + this._formatFeatures[bs.ASTC_RGBA_12X12] |= i; + this._formatFeatures[bs.ASTC_SRGBA_4X4] |= i; + this._formatFeatures[bs.ASTC_SRGBA_5X4] |= i; + this._formatFeatures[bs.ASTC_SRGBA_5X5] |= i; + this._formatFeatures[bs.ASTC_SRGBA_6X5] |= i; + this._formatFeatures[bs.ASTC_SRGBA_6X6] |= i; + this._formatFeatures[bs.ASTC_SRGBA_8X5] |= i; + this._formatFeatures[bs.ASTC_SRGBA_8X6] |= i; + this._formatFeatures[bs.ASTC_SRGBA_8X8] |= i; + this._formatFeatures[bs.ASTC_SRGBA_10X5] |= i; + this._formatFeatures[bs.ASTC_SRGBA_10X6] |= i; + this._formatFeatures[bs.ASTC_SRGBA_10X8] |= i; + this._formatFeatures[bs.ASTC_SRGBA_10X10] |= i; + this._formatFeatures[bs.ASTC_SRGBA_12X10] |= i; + this._formatFeatures[bs.ASTC_SRGBA_12X12] |= i; + } + } + createCommandBuffer(t) { + const e = new (t.type === tn.PRIMARY ? O7 : w7); + e.initialize(t); + return e; + } + createSwapchain(t) { + const e = new X7; + this._swapchain = e; + e.initialize(t); + return e; + } + createBuffer(t) { + const e = new E7; + e.initialize(t); + return e; + } + createTexture(t) { + const e = new G7; + e.initialize(t); + return e; + } + createDescriptorSet(t) { + const e = new j6; + e.initialize(t); + return e; + } + createShader(t) { + const e = new k7; + e.initialize(t); + return e; + } + createInputAssembler(t) { + const e = new I7; + e.initialize(t); + return e; + } + createRenderPass(t) { + const e = new L7; + e.initialize(t); + return e; + } + createFramebuffer(t) { + const e = new R7; + e.initialize(t); + return e; + } + createDescriptorSetLayout(t) { + const e = new M7; + e.initialize(t); + return e; + } + createPipelineLayout(t) { + const e = new B7; + e.initialize(t); + return e; + } + createPipelineState(t) { + const e = new P7; + e.initialize(t); + return e; + } + createQueue(t) { + const e = new N7; + e.initialize(t); + return e; + } + getSampler(t) { + const e = qr.computeHash(t); + this._samplers.has(e) || this._samplers.set(e, new V7(t, e)); + return this._samplers.get(e); + } + getSwapchains() { + return [ this._swapchain ]; + } + getGeneralBarrier(t) { + const e = Kr.computeHash(t); + this._generalBarrierss.has(e) || this._generalBarrierss.set(e, new Kr(t, e)); + return this._generalBarrierss.get(e); + } + getTextureBarrier(t) { + const e = Jr.computeHash(t); + this._textureBarriers.has(e) || this._textureBarriers.set(e, new Jr(t, e)); + return this._textureBarriers.get(e); + } + getBufferBarrier(t) { + const e = W7.computeHash(t); + this._bufferBarriers.has(e) || this._bufferBarriers.set(e, new W7(t, e)); + return this._bufferBarriers.get(e); + } + copyBuffersToTexture(t, e, i) { + T7(this, t, e.gpuTexture, i); + } + copyTextureToBuffers(t, e, i) { + !function(t, e, i, s) { + const {gl: n} = t; + const r = t.stateCache; + const o = n.createFramebuffer(); + n.bindFramebuffer(n.FRAMEBUFFER, o); + let a = 0; + let l = 0; + let h = 1; + let c = 1; + if (e.glTarget === n.TEXTURE_2D) for (let t = 0; t < s.length; t++) { + const r = s[t]; + n.framebufferTexture2D(n.FRAMEBUFFER, n.COLOR_ATTACHMENT0, e.glTarget, e.glTexture, r.texSubres.mipLevel); + a = r.texOffset.x; + l = r.texOffset.y; + h = r.texExtent.width; + c = r.texExtent.height; + n.readPixels(a, l, h, c, e.glFormat, e.glType, i[t]); + } else console.error("Unsupported GL texture type, copy texture to buffers failed."); + n.bindFramebuffer(n.FRAMEBUFFER, null); + r.glFramebuffer = null; + n.deleteFramebuffer(o); + }(this, t.gpuTexture, e, i); + } + copyTexImagesToTexture(t, e, i) { + !function(t, e, i, s) { + const {gl: n} = t; + const r = t.stateCache.glTexUnits[t.stateCache.texUnit]; + if (r.glTexture !== i.glTexture) { + n.bindTexture(i.glTarget, i.glTexture); + r.glTexture = i.glTexture; + } + let o = 0; + let a = 0; + switch (i.glTarget) { + case n.TEXTURE_2D: + for (let t = 0; t < s.length; t++) { + const r = s[t]; + n.texSubImage2D(n.TEXTURE_2D, r.texSubres.mipLevel, r.texOffset.x, r.texOffset.y, i.glFormat, i.glType, e[o++]); + } + break; + + case n.TEXTURE_CUBE_MAP: + for (let t = 0; t < s.length; t++) { + const r = s[t]; + const l = r.texSubres.baseArrayLayer + r.texSubres.layerCount; + for (a = r.texSubres.baseArrayLayer; a < l; ++a) n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + a, r.texSubres.mipLevel, r.texOffset.x, r.texOffset.y, i.glFormat, i.glType, e[o++]); + } + break; + + default: + console.error("Unsupported GL texture type, copy buffer to texture failed."); + } + i.flags & Rs.GEN_MIPMAP && i.isPowerOf2 && n.generateMipmap(i.glTarget); + }(this, t, e.gpuTexture, i); + } + } + t("WebGLDevice", Y7); + m.WebGLDevice = Y7; + class q7 extends Dr { + constructor(...t) { + super(...t); + this._gpuDescriptorSet = null; + } + get gpuDescriptorSet() { + return this._gpuDescriptorSet; + } + initialize(t) { + this._layout = t.layout; + const {bindings: e, descriptorIndices: i, descriptorCount: s} = t.layout.gpuDescriptorSetLayout; + this._buffers = Array(s).fill(null); + this._textures = Array(s).fill(null); + this._samplers = Array(s).fill(null); + const n = []; + this._gpuDescriptorSet = { + gpuDescriptors: n, + descriptorIndices: i + }; + for (let t = 0; t < e.length; ++t) { + const i = e[t]; + for (let t = 0; t < i.count; t++) n.push({ + type: i.descriptorType, + gpuBuffer: null, + gpuTextureView: null, + gpuSampler: null + }); + } + } + destroy() { + this._layout = null; + this._gpuDescriptorSet = null; + } + update() { + if (this._isDirty && this._gpuDescriptorSet) { + const t = this._gpuDescriptorSet.gpuDescriptors; + for (let e = 0; e < t.length; ++e) if (t[e].type & _r) this._buffers[e] && (t[e].gpuBuffer = this._buffers[e].gpuBuffer); else if (t[e].type & dr) { + this._textures[e] && (t[e].gpuTextureView = this._textures[e].gpuTextureView); + this._samplers[e] && (t[e].gpuSampler = this._samplers[e].gpuSampler); + } + this._isDirty = !1; + } + } + } + let K7; + !function(t) { + t[t.COMPRESSED_RGB_S3TC_DXT1_EXT = 33776] = "COMPRESSED_RGB_S3TC_DXT1_EXT"; + t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT = 33777] = "COMPRESSED_RGBA_S3TC_DXT1_EXT"; + t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT = 33778] = "COMPRESSED_RGBA_S3TC_DXT3_EXT"; + t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT = 33779] = "COMPRESSED_RGBA_S3TC_DXT5_EXT"; + t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT = 35916] = "COMPRESSED_SRGB_S3TC_DXT1_EXT"; + t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = 35917] = "COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT"; + t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT = 35918] = "COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT"; + t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = 35919] = "COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT"; + t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 35840] = "COMPRESSED_RGB_PVRTC_4BPPV1_IMG"; + t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 35841] = "COMPRESSED_RGB_PVRTC_2BPPV1_IMG"; + t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 35842] = "COMPRESSED_RGBA_PVRTC_4BPPV1_IMG"; + t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 35843] = "COMPRESSED_RGBA_PVRTC_2BPPV1_IMG"; + t[t.COMPRESSED_RGB_ETC1_WEBGL = 36196] = "COMPRESSED_RGB_ETC1_WEBGL"; + t[t.COMPRESSED_R11_EAC = 37488] = "COMPRESSED_R11_EAC"; + t[t.COMPRESSED_SIGNED_R11_EAC = 37489] = "COMPRESSED_SIGNED_R11_EAC"; + t[t.COMPRESSED_RG11_EAC = 37490] = "COMPRESSED_RG11_EAC"; + t[t.COMPRESSED_SIGNED_RG11_EAC = 37491] = "COMPRESSED_SIGNED_RG11_EAC"; + t[t.COMPRESSED_RGB8_ETC2 = 37492] = "COMPRESSED_RGB8_ETC2"; + t[t.COMPRESSED_SRGB8_ETC2 = 37493] = "COMPRESSED_SRGB8_ETC2"; + t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 37494] = "COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2"; + t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 37495] = "COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2"; + t[t.COMPRESSED_RGBA8_ETC2_EAC = 37496] = "COMPRESSED_RGBA8_ETC2_EAC"; + t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 37497] = "COMPRESSED_SRGB8_ALPHA8_ETC2_EAC"; + t[t.COMPRESSED_RGBA_ASTC_4x4_KHR = 37808] = "COMPRESSED_RGBA_ASTC_4x4_KHR"; + t[t.COMPRESSED_RGBA_ASTC_5x4_KHR = 37809] = "COMPRESSED_RGBA_ASTC_5x4_KHR"; + t[t.COMPRESSED_RGBA_ASTC_5x5_KHR = 37810] = "COMPRESSED_RGBA_ASTC_5x5_KHR"; + t[t.COMPRESSED_RGBA_ASTC_6x5_KHR = 37811] = "COMPRESSED_RGBA_ASTC_6x5_KHR"; + t[t.COMPRESSED_RGBA_ASTC_6x6_KHR = 37812] = "COMPRESSED_RGBA_ASTC_6x6_KHR"; + t[t.COMPRESSED_RGBA_ASTC_8x5_KHR = 37813] = "COMPRESSED_RGBA_ASTC_8x5_KHR"; + t[t.COMPRESSED_RGBA_ASTC_8x6_KHR = 37814] = "COMPRESSED_RGBA_ASTC_8x6_KHR"; + t[t.COMPRESSED_RGBA_ASTC_8x8_KHR = 37815] = "COMPRESSED_RGBA_ASTC_8x8_KHR"; + t[t.COMPRESSED_RGBA_ASTC_10x5_KHR = 37816] = "COMPRESSED_RGBA_ASTC_10x5_KHR"; + t[t.COMPRESSED_RGBA_ASTC_10x6_KHR = 37817] = "COMPRESSED_RGBA_ASTC_10x6_KHR"; + t[t.COMPRESSED_RGBA_ASTC_10x8_KHR = 37818] = "COMPRESSED_RGBA_ASTC_10x8_KHR"; + t[t.COMPRESSED_RGBA_ASTC_10x10_KHR = 37819] = "COMPRESSED_RGBA_ASTC_10x10_KHR"; + t[t.COMPRESSED_RGBA_ASTC_12x10_KHR = 37820] = "COMPRESSED_RGBA_ASTC_12x10_KHR"; + t[t.COMPRESSED_RGBA_ASTC_12x12_KHR = 37821] = "COMPRESSED_RGBA_ASTC_12x12_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 37840] = "COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 37841] = "COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 37842] = "COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 37843] = "COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 37844] = "COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 37845] = "COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 37846] = "COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 37847] = "COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 37848] = "COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 37849] = "COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 37850] = "COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 37851] = "COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 37852] = "COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR"; + t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 37853] = "COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR"; + }(K7 || (K7 = {})); + class J7 { + static get instance() { + return J7._instance; + } + static setInstance(t) { + J7._instance = t; + } + } + J7._instance = null; + const Z7 = [ 10497, 33648, 33071, 33071 ]; + const Q7 = new Float32Array(4); + function $7(t, e) { + switch (t) { + case bs.R8: + return e.UNSIGNED_BYTE; + + case bs.R8SN: + return e.BYTE; + + case bs.R8UI: + return e.UNSIGNED_BYTE; + + case bs.R8I: + return e.BYTE; + + case bs.R16F: + return e.HALF_FLOAT; + + case bs.R16UI: + return e.UNSIGNED_SHORT; + + case bs.R16I: + return e.SHORT; + + case bs.R32F: + return e.FLOAT; + + case bs.R32UI: + return e.UNSIGNED_INT; + + case bs.R32I: + return e.INT; + + case bs.RG8: + return e.UNSIGNED_BYTE; + + case bs.RG8SN: + return e.BYTE; + + case bs.RG8UI: + return e.UNSIGNED_BYTE; + + case bs.RG8I: + return e.BYTE; + + case bs.RG16F: + return e.HALF_FLOAT; + + case bs.RG16UI: + return e.UNSIGNED_SHORT; + + case bs.RG16I: + return e.SHORT; + + case bs.RG32F: + return e.FLOAT; + + case bs.RG32UI: + return e.UNSIGNED_INT; + + case bs.RG32I: + return e.INT; + + case bs.RGB8: + case bs.SRGB8: + return e.UNSIGNED_BYTE; + + case bs.RGB8SN: + return e.BYTE; + + case bs.RGB8UI: + return e.UNSIGNED_BYTE; + + case bs.RGB8I: + return e.BYTE; + + case bs.RGB16F: + return e.HALF_FLOAT; + + case bs.RGB16UI: + return e.UNSIGNED_SHORT; + + case bs.RGB16I: + return e.SHORT; + + case bs.RGB32F: + return e.FLOAT; + + case bs.RGB32UI: + return e.UNSIGNED_INT; + + case bs.RGB32I: + return e.INT; + + case bs.BGRA8: + case bs.RGBA8: + case bs.SRGB8_A8: + return e.UNSIGNED_BYTE; + + case bs.RGBA8SN: + return e.BYTE; + + case bs.RGBA8UI: + return e.UNSIGNED_BYTE; + + case bs.RGBA8I: + return e.BYTE; + + case bs.RGBA16F: + return e.HALF_FLOAT; + + case bs.RGBA16UI: + return e.UNSIGNED_SHORT; + + case bs.RGBA16I: + return e.SHORT; + + case bs.RGBA32F: + return e.FLOAT; + + case bs.RGBA32UI: + return e.UNSIGNED_INT; + + case bs.RGBA32I: + return e.INT; + + case bs.R5G6B5: + return e.UNSIGNED_SHORT_5_6_5; + + case bs.R11G11B10F: + return e.UNSIGNED_INT_10F_11F_11F_REV; + + case bs.RGB5A1: + return e.UNSIGNED_SHORT_5_5_5_1; + + case bs.RGBA4: + return e.UNSIGNED_SHORT_4_4_4_4; + + case bs.RGB10A2: + case bs.RGB10A2UI: + return e.UNSIGNED_INT_2_10_10_10_REV; + + case bs.RGB9E5: + case bs.DEPTH: + return e.FLOAT; + + case bs.DEPTH_STENCIL: + return e.UNSIGNED_INT_24_8; + + case bs.BC1: + case bs.BC1_SRGB: + case bs.BC2: + case bs.BC2_SRGB: + case bs.BC3: + case bs.BC3_SRGB: + case bs.BC4: + return e.UNSIGNED_BYTE; + + case bs.BC4_SNORM: + return e.BYTE; + + case bs.BC5: + return e.UNSIGNED_BYTE; + + case bs.BC5_SNORM: + return e.BYTE; + + case bs.BC6H_SF16: + case bs.BC6H_UF16: + return e.FLOAT; + + case bs.BC7: + case bs.BC7_SRGB: + case bs.ETC_RGB8: + case bs.ETC2_RGB8: + case bs.ETC2_SRGB8: + case bs.ETC2_RGB8_A1: + case bs.ETC2_SRGB8_A1: + case bs.EAC_R11: + return e.UNSIGNED_BYTE; + + case bs.EAC_R11SN: + return e.BYTE; + + case bs.EAC_RG11: + return e.UNSIGNED_BYTE; + + case bs.EAC_RG11SN: + return e.BYTE; + + case bs.PVRTC_RGB2: + case bs.PVRTC_RGBA2: + case bs.PVRTC_RGB4: + case bs.PVRTC_RGBA4: + case bs.PVRTC2_2BPP: + case bs.PVRTC2_4BPP: + case bs.ASTC_RGBA_4X4: + case bs.ASTC_RGBA_5X4: + case bs.ASTC_RGBA_5X5: + case bs.ASTC_RGBA_6X5: + case bs.ASTC_RGBA_6X6: + case bs.ASTC_RGBA_8X5: + case bs.ASTC_RGBA_8X6: + case bs.ASTC_RGBA_8X8: + case bs.ASTC_RGBA_10X5: + case bs.ASTC_RGBA_10X6: + case bs.ASTC_RGBA_10X8: + case bs.ASTC_RGBA_10X10: + case bs.ASTC_RGBA_12X10: + case bs.ASTC_RGBA_12X12: + case bs.ASTC_SRGBA_4X4: + case bs.ASTC_SRGBA_5X4: + case bs.ASTC_SRGBA_5X5: + case bs.ASTC_SRGBA_6X5: + case bs.ASTC_SRGBA_6X6: + case bs.ASTC_SRGBA_8X5: + case bs.ASTC_SRGBA_8X6: + case bs.ASTC_SRGBA_8X8: + case bs.ASTC_SRGBA_10X5: + case bs.ASTC_SRGBA_10X6: + case bs.ASTC_SRGBA_10X8: + case bs.ASTC_SRGBA_10X10: + case bs.ASTC_SRGBA_12X10: + case bs.ASTC_SRGBA_12X12: + default: + return e.UNSIGNED_BYTE; + } + } + function t9(t, e) { + switch (t) { + case As.BOOL: + return e.BOOL; + + case As.BOOL2: + return e.BOOL_VEC2; + + case As.BOOL3: + return e.BOOL_VEC3; + + case As.BOOL4: + return e.BOOL_VEC4; + + case As.INT: + return e.INT; + + case As.INT2: + return e.INT_VEC2; + + case As.INT3: + return e.INT_VEC3; + + case As.INT4: + return e.INT_VEC4; + + case As.UINT: + return e.UNSIGNED_INT; + + case As.FLOAT: + return e.FLOAT; + + case As.FLOAT2: + return e.FLOAT_VEC2; + + case As.FLOAT3: + return e.FLOAT_VEC3; + + case As.FLOAT4: + return e.FLOAT_VEC4; + + case As.MAT2: + return e.FLOAT_MAT2; + + case As.MAT2X3: + return e.FLOAT_MAT2x3; + + case As.MAT2X4: + return e.FLOAT_MAT2x4; + + case As.MAT3X2: + return e.FLOAT_MAT3x2; + + case As.MAT3: + return e.FLOAT_MAT3; + + case As.MAT3X4: + return e.FLOAT_MAT3x4; + + case As.MAT4X2: + return e.FLOAT_MAT4x2; + + case As.MAT4X3: + return e.FLOAT_MAT4x3; + + case As.MAT4: + return e.FLOAT_MAT4; + + case As.SAMPLER2D: + return e.SAMPLER_2D; + + case As.SAMPLER2D_ARRAY: + return e.SAMPLER_2D_ARRAY; + + case As.SAMPLER3D: + return e.SAMPLER_3D; + + case As.SAMPLER_CUBE: + return e.SAMPLER_CUBE; + + default: + console.error("Unsupported GLType, convert to GL type failed."); + return As.UNKNOWN; + } + } + function e9(t, e) { + switch (t) { + case e.BOOL: + return As.BOOL; + + case e.BOOL_VEC2: + return As.BOOL2; + + case e.BOOL_VEC3: + return As.BOOL3; + + case e.BOOL_VEC4: + return As.BOOL4; + + case e.INT: + return As.INT; + + case e.INT_VEC2: + return As.INT2; + + case e.INT_VEC3: + return As.INT3; + + case e.INT_VEC4: + return As.INT4; + + case e.UNSIGNED_INT: + return As.UINT; + + case e.UNSIGNED_INT_VEC2: + return As.UINT2; + + case e.UNSIGNED_INT_VEC3: + return As.UINT3; + + case e.UNSIGNED_INT_VEC4: + return As.UINT4; + + case e.FLOAT: + return As.FLOAT; + + case e.FLOAT_VEC2: + return As.FLOAT2; + + case e.FLOAT_VEC3: + return As.FLOAT3; + + case e.FLOAT_VEC4: + return As.FLOAT4; + + case e.FLOAT_MAT2: + return As.MAT2; + + case e.FLOAT_MAT2x3: + return As.MAT2X3; + + case e.FLOAT_MAT2x4: + return As.MAT2X4; + + case e.FLOAT_MAT3x2: + return As.MAT3X2; + + case e.FLOAT_MAT3: + return As.MAT3; + + case e.FLOAT_MAT3x4: + return As.MAT3X4; + + case e.FLOAT_MAT4x2: + return As.MAT4X2; + + case e.FLOAT_MAT4x3: + return As.MAT4X3; + + case e.FLOAT_MAT4: + return As.MAT4; + + case e.SAMPLER_2D: + return As.SAMPLER2D; + + case e.SAMPLER_2D_ARRAY: + return As.SAMPLER2D_ARRAY; + + case e.SAMPLER_3D: + return As.SAMPLER3D; + + case e.SAMPLER_CUBE: + return As.SAMPLER_CUBE; + + default: + console.error("Unsupported GLType, convert to Type failed."); + return As.UNKNOWN; + } + } + function i9(t, e) { + switch (t) { + case e.BOOL: + return 4; + + case e.BOOL_VEC2: + return 8; + + case e.BOOL_VEC3: + return 12; + + case e.BOOL_VEC4: + return 16; + + case e.INT: + return 4; + + case e.INT_VEC2: + return 8; + + case e.INT_VEC3: + return 12; + + case e.INT_VEC4: + return 16; + + case e.UNSIGNED_INT: + return 4; + + case e.UNSIGNED_INT_VEC2: + return 8; + + case e.UNSIGNED_INT_VEC3: + return 12; + + case e.UNSIGNED_INT_VEC4: + return 16; + + case e.FLOAT: + return 4; + + case e.FLOAT_VEC2: + return 8; + + case e.FLOAT_VEC3: + return 12; + + case e.FLOAT_VEC4: + case e.FLOAT_MAT2: + return 16; + + case e.FLOAT_MAT2x3: + return 24; + + case e.FLOAT_MAT2x4: + return 32; + + case e.FLOAT_MAT3x2: + return 24; + + case e.FLOAT_MAT3: + return 36; + + case e.FLOAT_MAT3x4: + return 48; + + case e.FLOAT_MAT4x2: + return 32; + + case e.FLOAT_MAT4x3: + return 48; + + case e.FLOAT_MAT4: + return 64; + + case e.SAMPLER_2D: + case e.SAMPLER_2D_ARRAY: + case e.SAMPLER_2D_ARRAY_SHADOW: + case e.SAMPLER_3D: + case e.SAMPLER_CUBE: + case e.INT_SAMPLER_2D: + case e.INT_SAMPLER_2D_ARRAY: + case e.INT_SAMPLER_3D: + case e.INT_SAMPLER_CUBE: + case e.UNSIGNED_INT_SAMPLER_2D: + case e.UNSIGNED_INT_SAMPLER_2D_ARRAY: + case e.UNSIGNED_INT_SAMPLER_3D: + case e.UNSIGNED_INT_SAMPLER_CUBE: + return 4; + + default: + console.error("Unsupported GLType, get type failed."); + return 0; + } + } + function s9(t, e) { + switch (t) { + case e.FLOAT_MAT2: + case e.FLOAT_MAT2x3: + case e.FLOAT_MAT2x4: + return 2; + + case e.FLOAT_MAT3x2: + case e.FLOAT_MAT3: + case e.FLOAT_MAT3x4: + return 3; + + case e.FLOAT_MAT4x2: + case e.FLOAT_MAT4x3: + case e.FLOAT_MAT4: + return 4; + + default: + return 1; + } + } + const n9 = [ 512, 513, 514, 515, 516, 517, 518, 519 ]; + const r9 = [ 0, 7680, 7681, 7682, 7683, 5386, 34055, 34056 ]; + const o9 = [ 32774, 32778, 32779, 32775, 32776 ]; + const a9 = [ 0, 1, 770, 772, 771, 773, 768, 774, 769, 775, 776, 32769, 32770, 32771, 32772 ]; + let l9; + !function(t) { + t[t.BEGIN_RENDER_PASS = 0] = "BEGIN_RENDER_PASS"; + t[t.END_RENDER_PASS = 1] = "END_RENDER_PASS"; + t[t.BIND_STATES = 2] = "BIND_STATES"; + t[t.DRAW = 3] = "DRAW"; + t[t.UPDATE_BUFFER = 4] = "UPDATE_BUFFER"; + t[t.COPY_BUFFER_TO_TEXTURE = 5] = "COPY_BUFFER_TO_TEXTURE"; + t[t.COUNT = 6] = "COUNT"; + }(l9 || (l9 = {})); + class h9 { + constructor(t) { + this.cmdType = void 0; + this.refCount = 0; + this.cmdType = t; + } + } + class c9 extends h9 { + constructor() { + super(l9.BEGIN_RENDER_PASS); + this.gpuRenderPass = null; + this.gpuFramebuffer = null; + this.renderArea = new hn; + this.clearColors = []; + this.clearDepth = 1; + this.clearStencil = 0; + } + clear() { + this.gpuFramebuffer = null; + this.clearColors.length = 0; + } + } + class u9 extends h9 { + constructor() { + super(l9.BIND_STATES); + this.gpuPipelineState = null; + this.gpuInputAssembler = null; + this.gpuDescriptorSets = []; + this.dynamicOffsets = []; + this.dynamicStates = new lr; + } + clear() { + this.gpuPipelineState = null; + this.gpuInputAssembler = null; + this.gpuDescriptorSets.length = 0; + this.dynamicOffsets.length = 0; + } + } + class _9 extends h9 { + constructor() { + super(l9.DRAW); + this.drawInfo = new vn; + } + clear() {} + } + class d9 extends h9 { + constructor() { + super(l9.UPDATE_BUFFER); + this.gpuBuffer = null; + this.buffer = null; + this.offset = 0; + this.size = 0; + } + clear() { + this.gpuBuffer = null; + this.buffer = null; + } + } + class p9 extends h9 { + constructor() { + super(l9.COPY_BUFFER_TO_TEXTURE); + this.gpuTexture = null; + this.buffers = []; + this.regions = []; + } + clear() { + this.gpuTexture = null; + this.buffers.length = 0; + this.regions.length = 0; + } + } + class m9 { + constructor() { + this.cmds = new eo(1); + this.beginRenderPassCmds = new eo(1); + this.bindStatesCmds = new eo(1); + this.drawCmds = new eo(1); + this.updateBufferCmds = new eo(1); + this.copyBufferToTextureCmds = new eo(1); + } + clearCmds(t) { + if (this.beginRenderPassCmds.length) { + t.beginRenderPassCmdPool.freeCmds(this.beginRenderPassCmds); + this.beginRenderPassCmds.clear(); + } + if (this.bindStatesCmds.length) { + t.bindStatesCmdPool.freeCmds(this.bindStatesCmds); + this.bindStatesCmds.clear(); + } + if (this.drawCmds.length) { + t.drawCmdPool.freeCmds(this.drawCmds); + this.drawCmds.clear(); + } + if (this.updateBufferCmds.length) { + t.updateBufferCmdPool.freeCmds(this.updateBufferCmds); + this.updateBufferCmds.clear(); + } + if (this.copyBufferToTextureCmds.length) { + t.copyBufferToTextureCmdPool.freeCmds(this.copyBufferToTextureCmds); + this.copyBufferToTextureCmds.clear(); + } + this.cmds.clear(); + } + } + function f9(t, e, i, s, n) { + if (e.usage & Ts.INDIRECT) { + e.indirects.clearDraws(); + const t = i.drawInfos; + for (let i = 0; i < t.length; ++i) e.indirects.setDrawInfo(s + i, t[i]); + } else { + const r = i; + const {gl: o} = t; + const a = t.stateCache; + switch (e.glTarget) { + case o.ARRAY_BUFFER: + if (t.extensions.useVAO && a.glVAO) { + o.bindVertexArray(null); + a.glVAO = null; + } + b9.gpuInputAssembler = null; + if (a.glArrayBuffer !== e.glBuffer) { + o.bindBuffer(o.ARRAY_BUFFER, e.glBuffer); + a.glArrayBuffer = e.glBuffer; + } + n === r.byteLength ? o.bufferSubData(e.glTarget, s, r) : o.bufferSubData(e.glTarget, s, r.slice(0, n)); + break; + + case o.ELEMENT_ARRAY_BUFFER: + if (t.extensions.useVAO && a.glVAO) { + o.bindVertexArray(null); + a.glVAO = null; + } + b9.gpuInputAssembler = null; + if (a.glElementArrayBuffer !== e.glBuffer) { + o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, e.glBuffer); + a.glElementArrayBuffer = e.glBuffer; + } + n === r.byteLength ? o.bufferSubData(e.glTarget, s, r) : o.bufferSubData(e.glTarget, s, r.slice(0, n)); + break; + + case o.UNIFORM_BUFFER: + if (a.glUniformBuffer !== e.glBuffer) { + o.bindBuffer(o.UNIFORM_BUFFER, e.glBuffer); + a.glUniformBuffer = e.glBuffer; + } + n === r.byteLength ? o.bufferSubData(e.glTarget, s, r) : o.bufferSubData(e.glTarget, s, new Float32Array(r, 0, n / 4)); + break; + + default: + console.error("Unsupported BufferType, update buffer failed."); + } + } + } + function g9(t, e) { + const {gl: i} = t; + e.glInternalFmt = function(t, e) { + switch (t) { + case bs.A8: + return e.ALPHA; + + case bs.L8: + return e.LUMINANCE; + + case bs.LA8: + return e.LUMINANCE_ALPHA; + + case bs.R8: + return e.R8; + + case bs.R8SN: + return e.R8_SNORM; + + case bs.R8UI: + return e.R8UI; + + case bs.R8I: + return e.R8I; + + case bs.RG8: + return e.RG8; + + case bs.RG8SN: + return e.RG8_SNORM; + + case bs.RG8UI: + return e.RG8UI; + + case bs.RG8I: + return e.RG8I; + + case bs.RGB8: + return e.RGB8; + + case bs.RGB8SN: + return e.RGB8_SNORM; + + case bs.RGB8UI: + return e.RGB8UI; + + case bs.RGB8I: + return e.RGB8I; + + case bs.BGRA8: + case bs.RGBA8: + return e.RGBA8; + + case bs.RGBA8SN: + return e.RGBA8_SNORM; + + case bs.RGBA8UI: + return e.RGBA8UI; + + case bs.RGBA8I: + return e.RGBA8I; + + case bs.R16I: + return e.R16I; + + case bs.R16UI: + return e.R16UI; + + case bs.R16F: + return e.R16F; + + case bs.RG16I: + return e.RG16I; + + case bs.RG16UI: + return e.RG16UI; + + case bs.RG16F: + return e.RG16F; + + case bs.RGB16I: + return e.RGB16I; + + case bs.RGB16UI: + return e.RGB16UI; + + case bs.RGB16F: + return e.RGB16F; + + case bs.RGBA16I: + return e.RGBA16I; + + case bs.RGBA16UI: + return e.RGBA16UI; + + case bs.RGBA16F: + return e.RGBA16F; + + case bs.R32I: + return e.R32I; + + case bs.R32UI: + return e.R32UI; + + case bs.R32F: + return e.R32F; + + case bs.RG32I: + return e.RG32I; + + case bs.RG32UI: + return e.RG32UI; + + case bs.RG32F: + return e.RG32F; + + case bs.RGB32I: + return e.RGB32I; + + case bs.RGB32UI: + return e.RGB32UI; + + case bs.RGB32F: + return e.RGB32F; + + case bs.RGBA32I: + return e.RGBA32I; + + case bs.RGBA32UI: + return e.RGBA32UI; + + case bs.RGBA32F: + return e.RGBA32F; + + case bs.R5G6B5: + return e.RGB565; + + case bs.RGB5A1: + return e.RGB5_A1; + + case bs.RGBA4: + return e.RGBA4; + + case bs.SRGB8: + return e.SRGB8; + + case bs.SRGB8_A8: + return e.SRGB8_ALPHA8; + + case bs.RGB10A2: + return e.RGB10_A2; + + case bs.RGB10A2UI: + return e.RGB10_A2UI; + + case bs.R11G11B10F: + return e.R11F_G11F_B10F; + + case bs.DEPTH: + return e.DEPTH_COMPONENT32F; + + case bs.DEPTH_STENCIL: + return e.DEPTH24_STENCIL8; + + case bs.BC1: + return K7.COMPRESSED_RGB_S3TC_DXT1_EXT; + + case bs.BC1_ALPHA: + return K7.COMPRESSED_RGBA_S3TC_DXT1_EXT; + + case bs.BC1_SRGB: + return K7.COMPRESSED_SRGB_S3TC_DXT1_EXT; + + case bs.BC1_SRGB_ALPHA: + return K7.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; + + case bs.BC2: + return K7.COMPRESSED_RGBA_S3TC_DXT3_EXT; + + case bs.BC2_SRGB: + return K7.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; + + case bs.BC3: + return K7.COMPRESSED_RGBA_S3TC_DXT5_EXT; + + case bs.BC3_SRGB: + return K7.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; + + case bs.ETC_RGB8: + return K7.COMPRESSED_RGB_ETC1_WEBGL; + + case bs.ETC2_RGB8: + return K7.COMPRESSED_RGB8_ETC2; + + case bs.ETC2_SRGB8: + return K7.COMPRESSED_SRGB8_ETC2; + + case bs.ETC2_RGB8_A1: + return K7.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; + + case bs.ETC2_SRGB8_A1: + return K7.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2; + + case bs.ETC2_RGBA8: + return K7.COMPRESSED_RGBA8_ETC2_EAC; + + case bs.ETC2_SRGB8_A8: + return K7.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC; + + case bs.EAC_R11: + return K7.COMPRESSED_R11_EAC; + + case bs.EAC_R11SN: + return K7.COMPRESSED_SIGNED_R11_EAC; + + case bs.EAC_RG11: + return K7.COMPRESSED_RG11_EAC; + + case bs.EAC_RG11SN: + return K7.COMPRESSED_SIGNED_RG11_EAC; + + case bs.PVRTC_RGB2: + return K7.COMPRESSED_RGB_PVRTC_2BPPV1_IMG; + + case bs.PVRTC_RGBA2: + return K7.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; + + case bs.PVRTC_RGB4: + return K7.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; + + case bs.PVRTC_RGBA4: + return K7.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; + + case bs.ASTC_RGBA_4X4: + return K7.COMPRESSED_RGBA_ASTC_4x4_KHR; + + case bs.ASTC_RGBA_5X4: + return K7.COMPRESSED_RGBA_ASTC_5x4_KHR; + + case bs.ASTC_RGBA_5X5: + return K7.COMPRESSED_RGBA_ASTC_5x5_KHR; + + case bs.ASTC_RGBA_6X5: + return K7.COMPRESSED_RGBA_ASTC_6x5_KHR; + + case bs.ASTC_RGBA_6X6: + return K7.COMPRESSED_RGBA_ASTC_6x6_KHR; + + case bs.ASTC_RGBA_8X5: + return K7.COMPRESSED_RGBA_ASTC_8x5_KHR; + + case bs.ASTC_RGBA_8X6: + return K7.COMPRESSED_RGBA_ASTC_8x6_KHR; + + case bs.ASTC_RGBA_8X8: + return K7.COMPRESSED_RGBA_ASTC_8x8_KHR; + + case bs.ASTC_RGBA_10X5: + return K7.COMPRESSED_RGBA_ASTC_10x5_KHR; + + case bs.ASTC_RGBA_10X6: + return K7.COMPRESSED_RGBA_ASTC_10x6_KHR; + + case bs.ASTC_RGBA_10X8: + return K7.COMPRESSED_RGBA_ASTC_10x8_KHR; + + case bs.ASTC_RGBA_10X10: + return K7.COMPRESSED_RGBA_ASTC_10x10_KHR; + + case bs.ASTC_RGBA_12X10: + return K7.COMPRESSED_RGBA_ASTC_12x10_KHR; + + case bs.ASTC_RGBA_12X12: + return K7.COMPRESSED_RGBA_ASTC_12x12_KHR; + + case bs.ASTC_SRGBA_4X4: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR; + + case bs.ASTC_SRGBA_5X4: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR; + + case bs.ASTC_SRGBA_5X5: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR; + + case bs.ASTC_SRGBA_6X5: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR; + + case bs.ASTC_SRGBA_6X6: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR; + + case bs.ASTC_SRGBA_8X5: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR; + + case bs.ASTC_SRGBA_8X6: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR; + + case bs.ASTC_SRGBA_8X8: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR; + + case bs.ASTC_SRGBA_10X5: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR; + + case bs.ASTC_SRGBA_10X6: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR; + + case bs.ASTC_SRGBA_10X8: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR; + + case bs.ASTC_SRGBA_10X10: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR; + + case bs.ASTC_SRGBA_12X10: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR; + + case bs.ASTC_SRGBA_12X12: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR; + + default: + console.error("Unsupported Format, convert to WebGL internal format failed."); + return e.RGBA; + } + }(e.format, i); + e.glFormat = function(t, e) { + switch (t) { + case bs.A8: + return e.ALPHA; + + case bs.L8: + return e.LUMINANCE; + + case bs.LA8: + return e.LUMINANCE_ALPHA; + + case bs.R8: + case bs.R8SN: + case bs.R8UI: + case bs.R8I: + return e.RED; + + case bs.RG8: + case bs.RG8SN: + case bs.RG8UI: + case bs.RG8I: + return e.RG; + + case bs.RGB8: + case bs.RGB8SN: + case bs.RGB8UI: + case bs.RGB8I: + return e.RGB; + + case bs.BGRA8: + case bs.RGBA8: + case bs.RGBA8SN: + case bs.RGBA8UI: + case bs.RGBA8I: + return e.RGBA; + + case bs.R16UI: + case bs.R16I: + case bs.R16F: + return e.RED; + + case bs.RG16UI: + case bs.RG16I: + case bs.RG16F: + return e.RG; + + case bs.RGB16UI: + case bs.RGB16I: + case bs.RGB16F: + return e.RGB; + + case bs.RGBA16UI: + case bs.RGBA16I: + case bs.RGBA16F: + return e.RGBA; + + case bs.R32UI: + case bs.R32I: + case bs.R32F: + return e.RED; + + case bs.RG32UI: + case bs.RG32I: + case bs.RG32F: + return e.RG; + + case bs.RGB32UI: + case bs.RGB32I: + case bs.RGB32F: + return e.RGB; + + case bs.RGBA32UI: + case bs.RGBA32I: + case bs.RGBA32F: + case bs.RGB10A2: + return e.RGBA; + + case bs.R11G11B10F: + case bs.R5G6B5: + return e.RGB; + + case bs.RGB5A1: + case bs.RGBA4: + return e.RGBA; + + case bs.SRGB8: + return e.RGB; + + case bs.SRGB8_A8: + return e.RGBA; + + case bs.DEPTH: + return e.DEPTH_COMPONENT; + + case bs.DEPTH_STENCIL: + return e.DEPTH_STENCIL; + + case bs.BC1: + return K7.COMPRESSED_RGB_S3TC_DXT1_EXT; + + case bs.BC1_ALPHA: + return K7.COMPRESSED_RGBA_S3TC_DXT1_EXT; + + case bs.BC1_SRGB: + return K7.COMPRESSED_SRGB_S3TC_DXT1_EXT; + + case bs.BC1_SRGB_ALPHA: + return K7.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; + + case bs.BC2: + return K7.COMPRESSED_RGBA_S3TC_DXT3_EXT; + + case bs.BC2_SRGB: + return K7.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; + + case bs.BC3: + return K7.COMPRESSED_RGBA_S3TC_DXT5_EXT; + + case bs.BC3_SRGB: + return K7.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; + + case bs.ETC_RGB8: + return K7.COMPRESSED_RGB_ETC1_WEBGL; + + case bs.ETC2_RGB8: + return K7.COMPRESSED_RGB8_ETC2; + + case bs.ETC2_SRGB8: + return K7.COMPRESSED_SRGB8_ETC2; + + case bs.ETC2_RGB8_A1: + return K7.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; + + case bs.ETC2_SRGB8_A1: + return K7.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2; + + case bs.ETC2_RGBA8: + return K7.COMPRESSED_RGBA8_ETC2_EAC; + + case bs.ETC2_SRGB8_A8: + return K7.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC; + + case bs.EAC_R11: + return K7.COMPRESSED_R11_EAC; + + case bs.EAC_R11SN: + return K7.COMPRESSED_SIGNED_R11_EAC; + + case bs.EAC_RG11: + return K7.COMPRESSED_RG11_EAC; + + case bs.EAC_RG11SN: + return K7.COMPRESSED_SIGNED_RG11_EAC; + + case bs.PVRTC_RGB2: + return K7.COMPRESSED_RGB_PVRTC_2BPPV1_IMG; + + case bs.PVRTC_RGBA2: + return K7.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; + + case bs.PVRTC_RGB4: + return K7.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; + + case bs.PVRTC_RGBA4: + return K7.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; + + case bs.ASTC_RGBA_4X4: + return K7.COMPRESSED_RGBA_ASTC_4x4_KHR; + + case bs.ASTC_RGBA_5X4: + return K7.COMPRESSED_RGBA_ASTC_5x4_KHR; + + case bs.ASTC_RGBA_5X5: + return K7.COMPRESSED_RGBA_ASTC_5x5_KHR; + + case bs.ASTC_RGBA_6X5: + return K7.COMPRESSED_RGBA_ASTC_6x5_KHR; + + case bs.ASTC_RGBA_6X6: + return K7.COMPRESSED_RGBA_ASTC_6x6_KHR; + + case bs.ASTC_RGBA_8X5: + return K7.COMPRESSED_RGBA_ASTC_8x5_KHR; + + case bs.ASTC_RGBA_8X6: + return K7.COMPRESSED_RGBA_ASTC_8x6_KHR; + + case bs.ASTC_RGBA_8X8: + return K7.COMPRESSED_RGBA_ASTC_8x8_KHR; + + case bs.ASTC_RGBA_10X5: + return K7.COMPRESSED_RGBA_ASTC_10x5_KHR; + + case bs.ASTC_RGBA_10X6: + return K7.COMPRESSED_RGBA_ASTC_10x6_KHR; + + case bs.ASTC_RGBA_10X8: + return K7.COMPRESSED_RGBA_ASTC_10x8_KHR; + + case bs.ASTC_RGBA_10X10: + return K7.COMPRESSED_RGBA_ASTC_10x10_KHR; + + case bs.ASTC_RGBA_12X10: + return K7.COMPRESSED_RGBA_ASTC_12x10_KHR; + + case bs.ASTC_RGBA_12X12: + return K7.COMPRESSED_RGBA_ASTC_12x12_KHR; + + case bs.ASTC_SRGBA_4X4: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR; + + case bs.ASTC_SRGBA_5X4: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR; + + case bs.ASTC_SRGBA_5X5: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR; + + case bs.ASTC_SRGBA_6X5: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR; + + case bs.ASTC_SRGBA_6X6: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR; + + case bs.ASTC_SRGBA_8X5: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR; + + case bs.ASTC_SRGBA_8X6: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR; + + case bs.ASTC_SRGBA_8X8: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR; + + case bs.ASTC_SRGBA_10X5: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR; + + case bs.ASTC_SRGBA_10X6: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR; + + case bs.ASTC_SRGBA_10X8: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR; + + case bs.ASTC_SRGBA_10X10: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR; + + case bs.ASTC_SRGBA_12X10: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR; + + case bs.ASTC_SRGBA_12X12: + return K7.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR; + + default: + console.error("Unsupported Format, convert to WebGL format failed."); + return e.RGBA; + } + }(e.format, i); + e.glType = $7(e.format, i); + let s = e.width; + let n = e.height; + switch (e.type) { + case xs.TEX2D: + { + e.glTarget = i.TEXTURE_2D; + if (e.isSwapchainTexture) break; + const r = Math.max(s, n); + r > t.capabilities.maxTextureSize && F(9100, r, t.capabilities.maxTextureSize); + if (e.samples === Ms.ONE) { + e.glTexture = i.createTexture(); + if (e.size > 0) { + const r = t.stateCache.glTexUnits[t.stateCache.texUnit]; + if (r.glTexture !== e.glTexture) { + i.bindTexture(i.TEXTURE_2D, e.glTexture); + r.glTexture = e.glTexture; + } + if (ur[e.format].isCompressed) for (let t = 0; t < e.mipLevel; ++t) { + const r = gr(e.format, s, n, 1); + const o = new Uint8Array(r); + i.compressedTexImage2D(i.TEXTURE_2D, t, e.glInternalFmt, s, n, 0, o); + s = Math.max(1, s >> 1); + n = Math.max(1, n >> 1); + } else i.texStorage2D(i.TEXTURE_2D, e.mipLevel, e.glInternalFmt, s, n); + } + } else { + e.glRenderbuffer = i.createRenderbuffer(); + if (e.size > 0) { + if (t.stateCache.glRenderbuffer !== e.glRenderbuffer) { + i.bindRenderbuffer(i.RENDERBUFFER, e.glRenderbuffer); + t.stateCache.glRenderbuffer = e.glRenderbuffer; + } + i.renderbufferStorageMultisample(i.RENDERBUFFER, e.samples, e.glInternalFmt, e.width, e.height); + } + } + break; + } + + case xs.CUBE: + { + e.glTarget = i.TEXTURE_CUBE_MAP; + const r = Math.max(s, n); + r > t.capabilities.maxCubeMapTextureSize && F(9100, r, t.capabilities.maxTextureSize); + e.glTexture = i.createTexture(); + if (e.size > 0) { + const r = t.stateCache.glTexUnits[t.stateCache.texUnit]; + if (r.glTexture !== e.glTexture) { + i.bindTexture(i.TEXTURE_CUBE_MAP, e.glTexture); + r.glTexture = e.glTexture; + } + if (ur[e.format].isCompressed) for (let t = 0; t < e.mipLevel; ++t) { + const r = gr(e.format, s, n, 1); + const o = new Uint8Array(r); + for (let r = 0; r < 6; ++r) i.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + r, t, e.glInternalFmt, s, n, 0, o); + s = Math.max(1, s >> 1); + n = Math.max(1, n >> 1); + } else i.texStorage2D(i.TEXTURE_CUBE_MAP, e.mipLevel, e.glInternalFmt, s, n); + } + break; + } + + default: + console.error("Unsupported TextureType, create texture failed."); + e.type = xs.TEX2D; + e.glTarget = i.TEXTURE_2D; + } + } + function y9(t, e) { + const {gl: i} = t; + if (e.glTexture) { + const s = t.stateCache.glTexUnits; + let n = t.stateCache.texUnit; + i.deleteTexture(e.glTexture); + for (let t = 0; t < s.length; ++t) if (s[t].glTexture === e.glTexture) { + i.activeTexture(i.TEXTURE0 + t); + n = t; + i.bindTexture(e.glTarget, null); + s[t].glTexture = null; + } + t.stateCache.texUnit = n; + e.glTexture = null; + } + if (e.glRenderbuffer) { + let s = t.stateCache.glRenderbuffer; + i.deleteRenderbuffer(e.glRenderbuffer); + if (s === e.glRenderbuffer) { + i.bindRenderbuffer(i.RENDERBUFFER, null); + s = null; + } + e.glRenderbuffer = null; + } + } + const b9 = { + gpuPipelineState: null, + gpuInputAssembler: null, + glPrimitive: 0, + invalidateAttachments: [] + }; + function S9(t, e, i, s, n, r, o) { + const {gl: a} = t; + const l = t.stateCache; + let h = 0; + if (i && e) { + if (l.glFramebuffer !== i.glFramebuffer) { + a.bindFramebuffer(a.FRAMEBUFFER, i.glFramebuffer); + l.glFramebuffer = i.glFramebuffer; + } + if (l.viewport.left !== s.x || l.viewport.top !== s.y || l.viewport.width !== s.width || l.viewport.height !== s.height) { + a.viewport(s.x, s.y, s.width, s.height); + l.viewport.left = s.x; + l.viewport.top = s.y; + l.viewport.width = s.width; + l.viewport.height = s.height; + } + if (l.scissorRect.x !== s.x || l.scissorRect.y !== s.y || l.scissorRect.width !== s.width || l.scissorRect.height !== s.height) { + a.scissor(s.x, s.y, s.width, s.height); + l.scissorRect.x = s.x; + l.scissorRect.y = s.y; + l.scissorRect.width = s.width; + l.scissorRect.height = s.height; + } + b9.invalidateAttachments.length = 0; + for (let t = 0; t < n.length; ++t) { + const s = e.colorAttachments[t]; + if (s.format !== bs.UNKNOWN) switch (s.loadOp) { + case Us.LOAD: + break; + + case Us.CLEAR: + l.bs.targets[0].blendColorMask !== Vs.ALL && a.colorMask(!0, !0, !0, !0); + if (i.isOffscreen) { + Q7[0] = n[t].x; + Q7[1] = n[t].y; + Q7[2] = n[t].z; + Q7[3] = n[t].w; + a.clearBufferfv(a.COLOR, t, Q7); + } else { + const t = n[0]; + a.clearColor(t.x, t.y, t.z, t.w); + h |= a.COLOR_BUFFER_BIT; + } + break; + + case Us.DISCARD: + b9.invalidateAttachments.push(a.COLOR_ATTACHMENT0 + t); + } + } + if (e.depthStencilAttachment && e.depthStencilAttachment.format !== bs.UNKNOWN) { + switch (e.depthStencilAttachment.depthLoadOp) { + case Us.LOAD: + break; + + case Us.CLEAR: + l.dss.depthWrite || a.depthMask(!0); + a.clearDepth(r); + h |= a.DEPTH_BUFFER_BIT; + break; + + case Us.DISCARD: + b9.invalidateAttachments.push(a.DEPTH_ATTACHMENT); + } + if (ur[e.depthStencilAttachment.format].hasStencil) switch (e.depthStencilAttachment.stencilLoadOp) { + case Us.LOAD: + break; + + case Us.CLEAR: + l.dss.stencilWriteMaskFront || a.stencilMaskSeparate(a.FRONT, 65535); + l.dss.stencilWriteMaskBack || a.stencilMaskSeparate(a.BACK, 65535); + a.clearStencil(o); + h |= a.STENCIL_BUFFER_BIT; + break; + + case Us.DISCARD: + b9.invalidateAttachments.push(a.STENCIL_ATTACHMENT); + } + } + i.glFramebuffer && b9.invalidateAttachments.length && a.invalidateFramebuffer(a.FRAMEBUFFER, b9.invalidateAttachments); + h && a.clear(h); + if (h & a.COLOR_BUFFER_BIT) { + const t = l.bs.targets[0].blendColorMask; + if (t !== Vs.ALL) { + const e = (t & Vs.R) !== Vs.NONE; + const i = (t & Vs.G) !== Vs.NONE; + const s = (t & Vs.B) !== Vs.NONE; + const n = (t & Vs.A) !== Vs.NONE; + a.colorMask(e, i, s, n); + } + } + h & a.DEPTH_BUFFER_BIT && !l.dss.depthWrite && a.depthMask(!1); + if (h & a.STENCIL_BUFFER_BIT) { + l.dss.stencilWriteMaskFront || a.stencilMaskSeparate(a.FRONT, 0); + l.dss.stencilWriteMaskBack || a.stencilMaskSeparate(a.BACK, 0); + } + } + } + function A9(t, e, i, s, n, r) { + const {gl: o} = t; + const a = t.stateCache; + const l = e && e.gpuShader; + let h = !1; + if (e && b9.gpuPipelineState !== e) { + b9.gpuPipelineState = e; + b9.glPrimitive = e.glPrimitive; + if (l) { + const {glProgram: t} = l; + if (a.glProgram !== t) { + o.useProgram(t); + a.glProgram = t; + h = !0; + } + } + const {rs: i} = e; + if (i) { + if (a.rs.cullMode !== i.cullMode) { + switch (i.cullMode) { + case qs.NONE: + o.disable(o.CULL_FACE); + break; + + case qs.FRONT: + o.enable(o.CULL_FACE); + o.cullFace(o.FRONT); + break; + + case qs.BACK: + o.enable(o.CULL_FACE); + o.cullFace(o.BACK); + } + t.stateCache.rs.cullMode = i.cullMode; + } + const e = i.isFrontFaceCCW; + if (t.stateCache.rs.isFrontFaceCCW !== e) { + o.frontFace(e ? o.CCW : o.CW); + t.stateCache.rs.isFrontFaceCCW = e; + } + if (t.stateCache.rs.depthBias !== i.depthBias || t.stateCache.rs.depthBiasSlop !== i.depthBiasSlop) { + o.polygonOffset(i.depthBias, i.depthBiasSlop); + t.stateCache.rs.depthBias = i.depthBias; + t.stateCache.rs.depthBiasSlop = i.depthBiasSlop; + } + if (t.stateCache.rs.lineWidth !== i.lineWidth) { + o.lineWidth(i.lineWidth); + t.stateCache.rs.lineWidth = i.lineWidth; + } + } + const {dss: s} = e; + if (s) { + if (a.dss.depthTest !== s.depthTest) { + s.depthTest ? o.enable(o.DEPTH_TEST) : o.disable(o.DEPTH_TEST); + a.dss.depthTest = s.depthTest; + } + if (a.dss.depthWrite !== s.depthWrite) { + o.depthMask(s.depthWrite); + a.dss.depthWrite = s.depthWrite; + } + if (a.dss.depthFunc !== s.depthFunc) { + o.depthFunc(n9[s.depthFunc]); + a.dss.depthFunc = s.depthFunc; + } + if (a.dss.stencilTestFront !== s.stencilTestFront || a.dss.stencilTestBack !== s.stencilTestBack) { + s.stencilTestFront || s.stencilTestBack ? o.enable(o.STENCIL_TEST) : o.disable(o.STENCIL_TEST); + a.dss.stencilTestFront = s.stencilTestFront; + a.dss.stencilTestBack = s.stencilTestBack; + } + if (a.dss.stencilFuncFront !== s.stencilFuncFront || a.dss.stencilRefFront !== s.stencilRefFront || a.dss.stencilReadMaskFront !== s.stencilReadMaskFront) { + o.stencilFuncSeparate(o.FRONT, n9[s.stencilFuncFront], s.stencilRefFront, s.stencilReadMaskFront); + a.dss.stencilFuncFront = s.stencilFuncFront; + a.dss.stencilRefFront = s.stencilRefFront; + a.dss.stencilReadMaskFront = s.stencilReadMaskFront; + } + if (a.dss.stencilFailOpFront !== s.stencilFailOpFront || a.dss.stencilZFailOpFront !== s.stencilZFailOpFront || a.dss.stencilPassOpFront !== s.stencilPassOpFront) { + o.stencilOpSeparate(o.FRONT, r9[s.stencilFailOpFront], r9[s.stencilZFailOpFront], r9[s.stencilPassOpFront]); + a.dss.stencilFailOpFront = s.stencilFailOpFront; + a.dss.stencilZFailOpFront = s.stencilZFailOpFront; + a.dss.stencilPassOpFront = s.stencilPassOpFront; + } + if (a.dss.stencilWriteMaskFront !== s.stencilWriteMaskFront) { + o.stencilMaskSeparate(o.FRONT, s.stencilWriteMaskFront); + a.dss.stencilWriteMaskFront = s.stencilWriteMaskFront; + } + if (a.dss.stencilFuncBack !== s.stencilFuncBack || a.dss.stencilRefBack !== s.stencilRefBack || a.dss.stencilReadMaskBack !== s.stencilReadMaskBack) { + o.stencilFuncSeparate(o.BACK, n9[s.stencilFuncBack], s.stencilRefBack, s.stencilReadMaskBack); + a.dss.stencilFuncBack = s.stencilFuncBack; + a.dss.stencilRefBack = s.stencilRefBack; + a.dss.stencilReadMaskBack = s.stencilReadMaskBack; + } + if (a.dss.stencilFailOpBack !== s.stencilFailOpBack || a.dss.stencilZFailOpBack !== s.stencilZFailOpBack || a.dss.stencilPassOpBack !== s.stencilPassOpBack) { + o.stencilOpSeparate(o.BACK, r9[s.stencilFailOpBack], r9[s.stencilZFailOpBack], r9[s.stencilPassOpBack]); + a.dss.stencilFailOpBack = s.stencilFailOpBack; + a.dss.stencilZFailOpBack = s.stencilZFailOpBack; + a.dss.stencilPassOpBack = s.stencilPassOpBack; + } + if (a.dss.stencilWriteMaskBack !== s.stencilWriteMaskBack) { + o.stencilMaskSeparate(o.BACK, s.stencilWriteMaskBack); + a.dss.stencilWriteMaskBack = s.stencilWriteMaskBack; + } + } + const {bs: n} = e; + if (n) { + if (a.bs.isA2C !== n.isA2C) { + n.isA2C ? o.enable(o.SAMPLE_ALPHA_TO_COVERAGE) : o.disable(o.SAMPLE_ALPHA_TO_COVERAGE); + a.bs.isA2C = n.isA2C; + } + if (a.bs.blendColor.x !== n.blendColor.x || a.bs.blendColor.y !== n.blendColor.y || a.bs.blendColor.z !== n.blendColor.z || a.bs.blendColor.w !== n.blendColor.w) { + o.blendColor(n.blendColor.x, n.blendColor.y, n.blendColor.z, n.blendColor.w); + a.bs.blendColor.x = n.blendColor.x; + a.bs.blendColor.y = n.blendColor.y; + a.bs.blendColor.z = n.blendColor.z; + a.bs.blendColor.w = n.blendColor.w; + } + const t = n.targets[0]; + const e = a.bs.targets[0]; + if (e.blend !== t.blend) { + t.blend ? o.enable(o.BLEND) : o.disable(o.BLEND); + e.blend = t.blend; + } + if (e.blendEq !== t.blendEq || e.blendAlphaEq !== t.blendAlphaEq) { + o.blendEquationSeparate(o9[t.blendEq], o9[t.blendAlphaEq]); + e.blendEq = t.blendEq; + e.blendAlphaEq = t.blendAlphaEq; + } + if (e.blendSrc !== t.blendSrc || e.blendDst !== t.blendDst || e.blendSrcAlpha !== t.blendSrcAlpha || e.blendDstAlpha !== t.blendDstAlpha) { + o.blendFuncSeparate(a9[t.blendSrc], a9[t.blendDst], a9[t.blendSrcAlpha], a9[t.blendDstAlpha]); + e.blendSrc = t.blendSrc; + e.blendDst = t.blendDst; + e.blendSrcAlpha = t.blendSrcAlpha; + e.blendDstAlpha = t.blendDstAlpha; + } + if (e.blendColorMask !== t.blendColorMask) { + o.colorMask((t.blendColorMask & Vs.R) !== Vs.NONE, (t.blendColorMask & Vs.G) !== Vs.NONE, (t.blendColorMask & Vs.B) !== Vs.NONE, (t.blendColorMask & Vs.A) !== Vs.NONE); + e.blendColorMask = t.blendColorMask; + } + } + } + if (e && e.gpuPipelineLayout && l) { + const i = l.glBlocks.length; + const {dynamicOffsetIndices: r} = e.gpuPipelineLayout; + for (let t = 0; t < i; t++) { + const e = l.glBlocks[t]; + const i = s[e.set]; + const h = i && i.descriptorIndices[e.binding]; + const c = h >= 0 && i.gpuDescriptors[h]; + if (!c || !c.gpuBuffer) { + x(`Buffer binding '${e.name}' at set ${e.set} binding ${e.binding} is not bounded`); + continue; + } + const u = r[e.set]; + const _ = u && u[e.binding]; + let d = c.gpuBuffer.glOffset; + _ >= 0 && (d += n[_]); + if (a.glBindUBOs[e.glBinding] !== c.gpuBuffer.glBuffer || a.glBindUBOOffsets[e.glBinding] !== d) { + d ? o.bindBufferRange(o.UNIFORM_BUFFER, e.glBinding, c.gpuBuffer.glBuffer, d, c.gpuBuffer.size) : o.bindBufferBase(o.UNIFORM_BUFFER, e.glBinding, c.gpuBuffer.glBuffer); + a.glUniformBuffer = a.glBindUBOs[e.glBinding] = c.gpuBuffer.glBuffer; + a.glBindUBOOffsets[e.glBinding] = d; + } + } + const h = l.glSamplerTextures.length; + for (let e = 0; e < h; e++) { + const i = l.glSamplerTextures[e]; + const n = s[i.set]; + let r = n && n.descriptorIndices[i.binding]; + let h = r >= 0 && n.gpuDescriptors[r]; + for (let e = 0; e < i.units.length; e++) { + const s = i.units[e]; + const l = a.glTexUnits[s]; + if (!(h && h.gpuTextureView && h.gpuTextureView.gpuTexture && h.gpuSampler)) { + x(`Sampler binding '${i.name}' at set ${i.set} binding ${i.binding} index ${e} is not bounded`); + continue; + } + const c = h.gpuTextureView; + const u = c.gpuTexture; + const _ = c.baseLevel; + const d = _ + c.levelCount; + if (u.size > 0) { + if (l.glTexture !== u.glTexture) { + if (a.texUnit !== s) { + o.activeTexture(o.TEXTURE0 + s); + a.texUnit = s; + } + u.glTexture ? o.bindTexture(u.glTarget, u.glTexture) : o.bindTexture(u.glTarget, t.nullTex2D.gpuTexture.glTexture); + l.glTexture = u.glTexture; + } + const {gpuSampler: e} = h; + const i = e.getGLSampler(t, _, d); + if (a.glSamplerUnits[s] !== i) { + o.bindSampler(s, i); + a.glSamplerUnits[s] = i; + } + } + h = n.gpuDescriptors[++r]; + } + } + } + if (i && l && (h || b9.gpuInputAssembler !== i)) { + b9.gpuInputAssembler = i; + if (t.extensions.useVAO) { + let t = i.glVAOs.get(l.glProgram); + if (!t) { + t = o.createVertexArray(); + i.glVAOs.set(l.glProgram, t); + o.bindVertexArray(t); + o.bindBuffer(o.ARRAY_BUFFER, null); + o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, null); + a.glArrayBuffer = null; + a.glElementArrayBuffer = null; + let e; + for (let t = 0; t < l.glInputs.length; t++) { + const s = l.glInputs[t]; + e = null; + for (let t = 0; t < i.glAttribs.length; t++) { + const n = i.glAttribs[t]; + if (n.name === s.name) { + e = n; + break; + } + } + if (e) { + if (a.glArrayBuffer !== e.glBuffer) { + o.bindBuffer(o.ARRAY_BUFFER, e.glBuffer); + a.glArrayBuffer = e.glBuffer; + } + for (let t = 0; t < e.componentCount; ++t) { + const i = s.glLoc + t; + const n = e.offset + e.size * t; + o.enableVertexAttribArray(i); + a.glCurrentAttribLocs[i] = !0; + o.vertexAttribPointer(i, e.count, e.glType, e.isNormalized, e.stride, n); + o.vertexAttribDivisor(i, e.isInstanced ? 1 : 0); + } + } + } + const s = i.gpuIndexBuffer; + s && o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, s.glBuffer); + o.bindVertexArray(null); + o.bindBuffer(o.ARRAY_BUFFER, null); + o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, null); + a.glArrayBuffer = null; + a.glElementArrayBuffer = null; + } + if (a.glVAO !== t) { + o.bindVertexArray(t); + a.glVAO = t; + } + } else { + for (let e = 0; e < t.capabilities.maxVertexAttributes; ++e) a.glCurrentAttribLocs[e] = !1; + for (let t = 0; t < l.glInputs.length; t++) { + const e = l.glInputs[t]; + let s = null; + for (let t = 0; t < i.glAttribs.length; t++) { + const n = i.glAttribs[t]; + if (n.name === e.name) { + s = n; + break; + } + } + if (s) { + if (a.glArrayBuffer !== s.glBuffer) { + o.bindBuffer(o.ARRAY_BUFFER, s.glBuffer); + a.glArrayBuffer = s.glBuffer; + } + for (let t = 0; t < s.componentCount; ++t) { + const i = e.glLoc + t; + const n = s.offset + s.size * t; + if (!a.glEnabledAttribLocs[i] && i >= 0) { + o.enableVertexAttribArray(i); + a.glEnabledAttribLocs[i] = !0; + } + a.glCurrentAttribLocs[i] = !0; + o.vertexAttribPointer(i, s.count, s.glType, s.isNormalized, s.stride, n); + o.vertexAttribDivisor(i, s.isInstanced ? 1 : 0); + } + } + } + const e = i.gpuIndexBuffer; + if (e && a.glElementArrayBuffer !== e.glBuffer) { + o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, e.glBuffer); + a.glElementArrayBuffer = e.glBuffer; + } + for (let e = 0; e < t.capabilities.maxVertexAttributes; ++e) if (a.glEnabledAttribLocs[e] !== a.glCurrentAttribLocs[e]) { + o.disableVertexAttribArray(e); + a.glEnabledAttribLocs[e] = !1; + } + } + } + if (e && e.dynamicStates.length) { + const t = e.dynamicStates.length; + for (let i = 0; i < t; i++) { + switch (e.dynamicStates[i]) { + case Ks.LINE_WIDTH: + if (a.rs.lineWidth !== r.lineWidth) { + o.lineWidth(r.lineWidth); + a.rs.lineWidth = r.lineWidth; + } + break; + + case Ks.DEPTH_BIAS: + if (a.rs.depthBias !== r.depthBiasConstant || a.rs.depthBiasSlop !== r.depthBiasSlope) { + o.polygonOffset(r.depthBiasConstant, r.depthBiasSlope); + a.rs.depthBias = r.depthBiasConstant; + a.rs.depthBiasSlop = r.depthBiasSlope; + } + break; + + case Ks.BLEND_CONSTANTS: + { + const t = r.blendConstant; + if (a.bs.blendColor.x !== t.x || a.bs.blendColor.y !== t.y || a.bs.blendColor.z !== t.z || a.bs.blendColor.w !== t.w) { + o.blendColor(t.x, t.y, t.z, t.w); + a.bs.blendColor.copy(t); + } + break; + } + + case Ks.STENCIL_WRITE_MASK: + { + const t = r.stencilStatesFront; + const e = r.stencilStatesBack; + if (a.dss.stencilWriteMaskFront !== t.writeMask) { + o.stencilMaskSeparate(o.FRONT, t.writeMask); + a.dss.stencilWriteMaskFront = t.writeMask; + } + if (a.dss.stencilWriteMaskBack !== e.writeMask) { + o.stencilMaskSeparate(o.BACK, e.writeMask); + a.dss.stencilWriteMaskBack = e.writeMask; + } + break; + } + + case Ks.STENCIL_COMPARE_MASK: + { + const t = r.stencilStatesFront; + const e = r.stencilStatesBack; + if (a.dss.stencilRefFront !== t.reference || a.dss.stencilReadMaskFront !== t.compareMask) { + o.stencilFuncSeparate(o.FRONT, n9[a.dss.stencilFuncFront], t.reference, t.compareMask); + a.dss.stencilRefFront = t.reference; + a.dss.stencilReadMaskFront = t.compareMask; + } + if (a.dss.stencilRefBack !== e.reference || a.dss.stencilReadMaskBack !== e.compareMask) { + o.stencilFuncSeparate(o.BACK, n9[a.dss.stencilFuncBack], e.reference, e.compareMask); + a.dss.stencilRefBack = e.reference; + a.dss.stencilReadMaskBack = e.compareMask; + } + break; + } + } + } + } + } + function T9(t, e) { + const {gl: i} = t; + const {gpuInputAssembler: s, glPrimitive: n} = b9; + const r = t.extensions.WEBGL_multi_draw; + if (s) { + const t = s.gpuIndexBuffer; + if (s.gpuIndirectBuffer) { + const {indirects: e} = s.gpuIndirectBuffer; + if (e.drawByIndex) { + for (let i = 0; i < e.drawCount; i++) e.byteOffsets[i] = e.offsets[i] * t.stride; + if (r) e.instancedDraw ? r.multiDrawElementsInstancedWEBGL(n, e.counts, 0, s.glIndexType, e.byteOffsets, 0, e.instances, 0, e.drawCount) : r.multiDrawElementsWEBGL(n, e.counts, 0, s.glIndexType, e.byteOffsets, 0, e.drawCount); else for (let t = 0; t < e.drawCount; t++) e.instances[t] ? i.drawElementsInstanced(n, e.counts[t], s.glIndexType, e.byteOffsets[t], e.instances[t]) : i.drawElements(n, e.counts[t], s.glIndexType, e.byteOffsets[t]); + } else if (r) e.instancedDraw ? r.multiDrawArraysInstancedWEBGL(n, e.offsets, 0, e.counts, 0, e.instances, 0, e.drawCount) : r.multiDrawArraysWEBGL(n, e.offsets, 0, e.counts, 0, e.drawCount); else for (let t = 0; t < e.drawCount; t++) e.instances[t] ? i.drawArraysInstanced(n, e.offsets[t], e.counts[t], e.instances[t]) : i.drawArrays(n, e.offsets[t], e.counts[t]); + } else if (e.instanceCount) if (t) { + if (e.indexCount > 0) { + const r = e.firstIndex * t.stride; + i.drawElementsInstanced(n, e.indexCount, s.glIndexType, r, e.instanceCount); + } + } else e.vertexCount > 0 && i.drawArraysInstanced(n, e.firstVertex, e.vertexCount, e.instanceCount); else if (t) { + if (e.indexCount > 0) { + const r = e.firstIndex * t.stride; + i.drawElements(n, e.indexCount, s.glIndexType, r); + } + } else e.vertexCount > 0 && i.drawArrays(n, e.firstVertex, e.vertexCount); + } + } + const v9 = new Array(l9.COUNT); + function E9(t, e) { + v9.fill(0); + for (let i = 0; i < e.cmds.length; ++i) { + const s = e.cmds.array[i]; + const n = v9[s]++; + switch (s) { + case l9.BEGIN_RENDER_PASS: + { + const i = e.beginRenderPassCmds.array[n]; + S9(t, i.gpuRenderPass, i.gpuFramebuffer, i.renderArea, i.clearColors, i.clearDepth, i.clearStencil); + break; + } + + case l9.BIND_STATES: + { + const i = e.bindStatesCmds.array[n]; + A9(t, i.gpuPipelineState, i.gpuInputAssembler, i.gpuDescriptorSets, i.dynamicOffsets, i.dynamicStates); + break; + } + + case l9.DRAW: + T9(t, e.drawCmds.array[n].drawInfo); + break; + + case l9.UPDATE_BUFFER: + { + const i = e.updateBufferCmds.array[n]; + f9(t, i.gpuBuffer, i.buffer, i.offset, i.size); + break; + } + + case l9.COPY_BUFFER_TO_TEXTURE: + { + const i = e.copyBufferToTextureCmds.array[n]; + w9(t, i.buffers, i.gpuTexture, i.regions); + break; + } + } + } + } + let C9 = new Uint8Array(1); + function x9(t, e, i, s, n) { + const r = Tr(e).height; + const o = gr(e, n.width, n.height, n.depth); + const a = gr(e, s.width, 1, 1); + const l = gr(e, s.width, s.height, 1); + const h = gr(e, n.width, 1, 1); + const c = Ar(ur[e]); + C9.byteLength < o && (C9 = new Uint8Array(o)); + let u = 0; + let _ = i; + for (let e = 0; e < n.depth; e++) { + _ = i + l * e; + for (let e = 0; e < n.height; e += r) { + C9.subarray(u, u + h).set(new Uint8Array(t.buffer, t.byteOffset + _, h)); + u += h; + _ += a; + } + } + return new c(C9.buffer); + } + function w9(t, e, i, s) { + const {gl: n} = t; + const r = t.stateCache.glTexUnits[t.stateCache.texUnit]; + if (r.glTexture !== i.glTexture) { + n.bindTexture(i.glTarget, i.glTexture); + r.glTexture = i.glTexture; + } + let o = 0; + let a = 0; + const l = ur[i.format]; + const h = Ar(l); + const {isCompressed: c} = l; + const u = Tr(i.format); + const _ = new cn; + const d = new ln; + const p = new cn; + switch (i.glTarget) { + case n.TEXTURE_2D: + for (let t = 0; t < s.length; t++) { + const r = s[t]; + const a = r.texSubres.mipLevel; + d.x = 0 === r.texOffset.x ? 0 : vr(r.texOffset.x, u.width); + d.y = 0 === r.texOffset.y ? 0 : vr(r.texOffset.y, u.height); + _.width = r.texExtent.width < u.width ? r.texExtent.width : vr(r.texExtent.width, u.width); + _.height = r.texExtent.height < u.height ? r.texExtent.width : vr(r.texExtent.height, u.height); + p.width = r.buffStride > 0 ? r.buffStride : _.width; + p.height = r.buffTexHeight > 0 ? r.buffTexHeight : _.height; + const l = r.texExtent.width + d.x === i.width >> a ? r.texExtent.width : _.width; + const m = r.texExtent.height + d.y === i.height >> a ? r.texExtent.height : _.height; + let f; + const g = e[o++]; + f = p.width === _.width && p.height === _.height ? new h(g.buffer, g.byteOffset + r.buffOffset) : x9(g, i.format, r.buffOffset, p, _); + c ? i.glInternalFmt !== K7.COMPRESSED_RGB_ETC1_WEBGL ? n.compressedTexSubImage2D(n.TEXTURE_2D, a, d.x, d.y, l, m, i.glFormat, f) : n.compressedTexImage2D(n.TEXTURE_2D, a, i.glInternalFmt, l, m, 0, f) : n.texSubImage2D(n.TEXTURE_2D, a, d.x, d.y, l, m, i.glFormat, i.glType, f); + } + break; + + case n.TEXTURE_2D_ARRAY: + for (let t = 0; t < s.length; t++) { + const r = s[t]; + const l = r.texSubres.mipLevel; + d.x = 0 === r.texOffset.x ? 0 : vr(r.texOffset.x, u.width); + d.y = 0 === r.texOffset.y ? 0 : vr(r.texOffset.y, u.height); + _.width = r.texExtent.width < u.width ? r.texExtent.width : vr(r.texExtent.width, u.width); + _.height = r.texExtent.height < u.height ? r.texExtent.width : vr(r.texExtent.height, u.height); + _.depth = 1; + p.width = r.buffStride > 0 ? r.buffStride : _.width; + p.height = r.buffTexHeight > 0 ? r.buffTexHeight : _.height; + const m = r.texExtent.width + d.x === i.width >> l ? r.texExtent.width : _.width; + const f = r.texExtent.height + d.y === i.height >> l ? r.texExtent.height : _.height; + const g = r.texSubres.baseArrayLayer + r.texSubres.layerCount; + for (a = r.texSubres.baseArrayLayer; a < g; ++a) { + d.z = a; + let t; + const s = e[o++]; + t = p.width === _.width && p.height === _.height ? new h(s.buffer, s.byteOffset + r.buffOffset) : x9(s, i.format, r.buffOffset, p, _); + c ? i.glInternalFmt !== K7.COMPRESSED_RGB_ETC1_WEBGL ? n.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY, l, d.x, d.y, d.z, m, f, _.depth, i.glFormat, t) : n.compressedTexImage3D(n.TEXTURE_2D_ARRAY, l, i.glInternalFmt, m, f, _.depth, 0, t) : n.texSubImage3D(n.TEXTURE_2D_ARRAY, l, d.x, d.y, d.z, m, f, _.depth, i.glFormat, i.glType, t); + } + } + break; + + case n.TEXTURE_3D: + for (let t = 0; t < s.length; t++) { + const r = s[t]; + const a = r.texSubres.mipLevel; + d.x = 0 === r.texOffset.x ? 0 : vr(r.texOffset.x, u.width); + d.y = 0 === r.texOffset.y ? 0 : vr(r.texOffset.y, u.height); + d.z = r.texOffset.z; + _.width = r.texExtent.width < u.width ? r.texExtent.width : vr(r.texExtent.width, u.width); + _.height = r.texExtent.height < u.height ? r.texExtent.width : vr(r.texExtent.height, u.height); + _.depth = r.texExtent.depth; + p.width = r.buffStride > 0 ? r.buffStride : _.width; + p.height = r.buffTexHeight > 0 ? r.buffTexHeight : _.height; + const l = r.texExtent.width + d.x === i.width >> a ? r.texExtent.width : _.width; + const m = r.texExtent.height + d.y === i.height >> a ? r.texExtent.height : _.height; + let f; + const g = e[o++]; + f = p.width === _.width && p.height === _.height ? new h(g.buffer, g.byteOffset + r.buffOffset) : x9(g, i.format, r.buffOffset, p, _); + c ? i.glInternalFmt !== K7.COMPRESSED_RGB_ETC1_WEBGL ? n.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY, a, d.x, d.y, d.z, l, m, _.depth, i.glFormat, f) : n.compressedTexImage3D(n.TEXTURE_2D_ARRAY, a, i.glInternalFmt, l, m, _.depth, 0, f) : n.texSubImage3D(n.TEXTURE_2D_ARRAY, a, d.x, d.y, d.z, l, m, _.depth, i.glFormat, i.glType, f); + } + break; + + case n.TEXTURE_CUBE_MAP: + for (let t = 0; t < s.length; t++) { + const r = s[t]; + const l = r.texSubres.mipLevel; + d.x = 0 === r.texOffset.x ? 0 : vr(r.texOffset.x, u.width); + d.y = 0 === r.texOffset.y ? 0 : vr(r.texOffset.y, u.height); + _.width = r.texExtent.width < u.width ? r.texExtent.width : vr(r.texExtent.width, u.width); + _.height = r.texExtent.height < u.height ? r.texExtent.width : vr(r.texExtent.height, u.height); + p.width = r.buffStride > 0 ? r.buffStride : _.width; + p.height = r.buffTexHeight > 0 ? r.buffTexHeight : _.height; + const m = r.texExtent.width + d.x === i.width >> l ? r.texExtent.width : _.width; + const f = r.texExtent.height + d.y === i.height >> l ? r.texExtent.height : _.height; + const g = r.texSubres.baseArrayLayer + r.texSubres.layerCount; + for (a = r.texSubres.baseArrayLayer; a < g; ++a) { + let t; + const s = e[o++]; + t = p.width === _.width && p.height === _.height ? new h(s.buffer, s.byteOffset + r.buffOffset) : x9(s, i.format, r.buffOffset, p, _); + c ? i.glInternalFmt !== K7.COMPRESSED_RGB_ETC1_WEBGL ? n.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + a, l, d.x, d.y, m, f, i.glFormat, t) : n.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + a, l, i.glInternalFmt, m, f, 0, t) : n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + a, l, d.x, d.y, m, f, i.glFormat, i.glType, t); + } + } + break; + + default: + console.error("Unsupported GL texture type, copy buffer to texture failed."); + } + i.flags & Rs.GEN_MIPMAP && n.generateMipmap(i.glTarget); + } + class R9 { + constructor() { + this.counts = void 0; + this.offsets = void 0; + this.instances = void 0; + this.drawCount = 0; + this.drawByIndex = !1; + this.instancedDraw = !1; + this.byteOffsets = void 0; + this._capacity = 4; + this.counts = new Int32Array(this._capacity); + this.offsets = new Int32Array(this._capacity); + this.instances = new Int32Array(this._capacity); + this.byteOffsets = new Int32Array(this._capacity); + } + clearDraws() { + this.drawCount = 0; + this.drawByIndex = !1; + this.instancedDraw = !1; + } + setDrawInfo(t, e) { + this._ensureCapacity(t); + this.drawByIndex = e.indexCount > 0; + this.instancedDraw = !!e.instanceCount; + this.drawCount = Math.max(t + 1, this.drawCount); + if (this.drawByIndex) { + this.counts[t] = e.indexCount; + this.offsets[t] = e.firstIndex; + } else { + this.counts[t] = e.vertexCount; + this.offsets[t] = e.firstVertex; + } + this.instances[t] = Math.max(1, e.instanceCount); + } + _ensureCapacity(t) { + if (this._capacity > t) return; + this._capacity = l(t); + const e = new Int32Array(this._capacity); + const i = new Int32Array(this._capacity); + const s = new Int32Array(this._capacity); + this.byteOffsets = new Int32Array(this._capacity); + e.set(this.counts); + i.set(this.offsets); + s.set(this.instances); + this.counts = e; + this.offsets = i; + this.instances = s; + } + } + class I9 extends Pr { + constructor(...t) { + super(...t); + this._gpuBuffer = null; + } + get gpuBuffer() { + return this._gpuBuffer; + } + initialize(t) { + if ("buffer" in t) { + this._isBufferView = !0; + const e = t.buffer; + this._usage = e.usage; + this._memUsage = e.memUsage; + this._size = this._stride = t.range; + this._count = 1; + this._flags = e.flags; + this._gpuBuffer = { + usage: this._usage, + memUsage: this._memUsage, + size: this._size, + stride: this._stride, + buffer: null, + indirects: e.gpuBuffer.indirects, + glTarget: e.gpuBuffer.glTarget, + glBuffer: e.gpuBuffer.glBuffer, + glOffset: t.offset + }; + } else { + this._usage = t.usage; + this._memUsage = t.memUsage; + this._size = t.size; + this._stride = Math.max(t.stride || this._size, 1); + this._count = this._size / this._stride; + this._flags = t.flags; + this._gpuBuffer = { + usage: this._usage, + memUsage: this._memUsage, + size: this._size, + stride: this._stride, + buffer: null, + indirects: new R9, + glTarget: 0, + glBuffer: null, + glOffset: 0 + }; + !function(t, e) { + const {gl: i} = t; + const s = t.stateCache; + const n = e.memUsage & Cs.HOST ? i.DYNAMIC_DRAW : i.STATIC_DRAW; + if (e.usage & Ts.VERTEX) { + e.glTarget = i.ARRAY_BUFFER; + const r = i.createBuffer(); + if (r) { + e.glBuffer = r; + if (e.size > 0) { + if (t.extensions.useVAO && s.glVAO) { + i.bindVertexArray(null); + s.glVAO = null; + } + b9.gpuInputAssembler = null; + if (t.stateCache.glArrayBuffer !== e.glBuffer) { + i.bindBuffer(i.ARRAY_BUFFER, e.glBuffer); + t.stateCache.glArrayBuffer = e.glBuffer; + } + i.bufferData(i.ARRAY_BUFFER, e.size, n); + i.bindBuffer(i.ARRAY_BUFFER, null); + t.stateCache.glArrayBuffer = null; + } + } + } else if (e.usage & Ts.INDEX) { + e.glTarget = i.ELEMENT_ARRAY_BUFFER; + const r = i.createBuffer(); + if (r) { + e.glBuffer = r; + if (e.size > 0) { + if (t.extensions.useVAO && s.glVAO) { + i.bindVertexArray(null); + s.glVAO = null; + } + b9.gpuInputAssembler = null; + if (t.stateCache.glElementArrayBuffer !== e.glBuffer) { + i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, e.glBuffer); + t.stateCache.glElementArrayBuffer = e.glBuffer; + } + i.bufferData(i.ELEMENT_ARRAY_BUFFER, e.size, n); + i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, null); + t.stateCache.glElementArrayBuffer = null; + } + } + } else if (e.usage & Ts.UNIFORM) { + e.glTarget = i.UNIFORM_BUFFER; + const s = i.createBuffer(); + if (s && e.size > 0) { + e.glBuffer = s; + if (t.stateCache.glUniformBuffer !== e.glBuffer) { + i.bindBuffer(i.UNIFORM_BUFFER, e.glBuffer); + t.stateCache.glUniformBuffer = e.glBuffer; + } + i.bufferData(i.UNIFORM_BUFFER, e.size, n); + i.bindBuffer(i.UNIFORM_BUFFER, null); + t.stateCache.glUniformBuffer = null; + } + } else if (e.usage & Ts.INDIRECT) e.glTarget = i.NONE; else if (e.usage & Ts.TRANSFER_DST) e.glTarget = i.NONE; else if (e.usage & Ts.TRANSFER_SRC) e.glTarget = i.NONE; else { + console.error("Unsupported BufferType, create buffer failed."); + e.glTarget = i.NONE; + } + }(J7.instance, this._gpuBuffer); + J7.instance.memoryStatus.bufferSize += this._size; + } + } + destroy() { + if (this._gpuBuffer) { + if (!this._isBufferView) { + !function(t, e) { + const {gl: i} = t; + const s = t.stateCache; + if (e.glBuffer) { + switch (e.glTarget) { + case i.ARRAY_BUFFER: + if (t.extensions.useVAO && s.glVAO) { + i.bindVertexArray(null); + t.stateCache.glVAO = null; + } + b9.gpuInputAssembler = null; + i.bindBuffer(i.ARRAY_BUFFER, null); + t.stateCache.glArrayBuffer = null; + break; + + case i.ELEMENT_ARRAY_BUFFER: + if (t.extensions.useVAO && s.glVAO) { + i.bindVertexArray(null); + t.stateCache.glVAO = null; + } + b9.gpuInputAssembler = null; + i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, null); + t.stateCache.glElementArrayBuffer = null; + break; + + case i.UNIFORM_BUFFER: + i.bindBuffer(i.UNIFORM_BUFFER, null); + t.stateCache.glUniformBuffer = null; + } + i.deleteBuffer(e.glBuffer); + e.glBuffer = null; + } + }(J7.instance, this._gpuBuffer); + J7.instance.memoryStatus.bufferSize -= this._size; + } + this._gpuBuffer = null; + } + } + resize(t) { + if (this._isBufferView) { + console.warn("cannot resize buffer views!"); + return; + } + const e = this._size; + if (e !== t) { + this._size = t; + this._count = this._size / this._stride; + if (this._gpuBuffer) { + this._gpuBuffer.size = t; + if (t > 0) { + !function(t, e) { + const {gl: i} = t; + const s = t.stateCache; + const n = e.memUsage & Cs.HOST ? i.DYNAMIC_DRAW : i.STATIC_DRAW; + if (e.usage & Ts.VERTEX) { + if (t.extensions.useVAO && s.glVAO) { + i.bindVertexArray(null); + s.glVAO = null; + } + b9.gpuInputAssembler = null; + s.glArrayBuffer !== e.glBuffer && i.bindBuffer(i.ARRAY_BUFFER, e.glBuffer); + e.buffer ? i.bufferData(i.ARRAY_BUFFER, e.buffer, n) : i.bufferData(i.ARRAY_BUFFER, e.size, n); + i.bindBuffer(i.ARRAY_BUFFER, null); + s.glArrayBuffer = null; + } else if (e.usage & Ts.INDEX) { + if (t.extensions.useVAO && s.glVAO) { + i.bindVertexArray(null); + s.glVAO = null; + } + b9.gpuInputAssembler = null; + t.stateCache.glElementArrayBuffer !== e.glBuffer && i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, e.glBuffer); + e.buffer ? i.bufferData(i.ELEMENT_ARRAY_BUFFER, e.buffer, n) : i.bufferData(i.ELEMENT_ARRAY_BUFFER, e.size, n); + i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, null); + t.stateCache.glElementArrayBuffer = null; + } else if (e.usage & Ts.UNIFORM) { + t.stateCache.glUniformBuffer !== e.glBuffer && i.bindBuffer(i.UNIFORM_BUFFER, e.glBuffer); + i.bufferData(i.UNIFORM_BUFFER, e.size, n); + i.bindBuffer(i.UNIFORM_BUFFER, null); + t.stateCache.glUniformBuffer = null; + } else if (e.usage & Ts.INDIRECT || e.usage & Ts.TRANSFER_DST || e.usage & Ts.TRANSFER_SRC) e.glTarget = i.NONE; else { + console.error("Unsupported BufferType, create buffer failed."); + e.glTarget = i.NONE; + } + }(J7.instance, this._gpuBuffer); + J7.instance.memoryStatus.bufferSize -= e; + J7.instance.memoryStatus.bufferSize += t; + } + } + } + } + update(t, e) { + if (this._isBufferView) { + console.warn("cannot update through buffer views!"); + return; + } + let i; + i = void 0 !== e ? e : this._usage & Ts.INDIRECT ? 0 : t.byteLength; + f9(J7.instance, this._gpuBuffer, t, 0, i); + } + } + class M9 { + constructor(t, e) { + this._frees = void 0; + this._freeIdx = 0; + this._freeCmds = void 0; + this._frees = new Array(e); + this._freeCmds = new eo(e); + for (let i = 0; i < e; ++i) this._frees[i] = new t; + this._freeIdx = e - 1; + } + alloc(t) { + if (this._freeIdx < 0) { + const e = 2 * this._frees.length; + const i = this._frees; + this._frees = new Array(e); + const s = e - i.length; + for (let e = 0; e < s; ++e) this._frees[e] = new t; + for (let t = s, n = 0; t < e; ++t, ++n) this._frees[t] = i[n]; + this._freeIdx += s; + } + const e = this._frees[this._freeIdx]; + this._frees[this._freeIdx--] = null; + ++e.refCount; + return e; + } + free(t) { + 0 == --t.refCount && this._freeCmds.push(t); + } + freeCmds(t) { + for (let e = 0; e < t.length; ++e) 0 == --t.array[e].refCount && this._freeCmds.push(t.array[e]); + } + release() { + for (let t = 0; t < this._freeCmds.length; ++t) { + const e = this._freeCmds.array[t]; + e.clear(); + this._frees[++this._freeIdx] = e; + } + this._freeCmds.clear(); + } + } + class B9 { + constructor() { + this.beginRenderPassCmdPool = void 0; + this.bindStatesCmdPool = void 0; + this.drawCmdPool = void 0; + this.updateBufferCmdPool = void 0; + this.copyBufferToTextureCmdPool = void 0; + this.beginRenderPassCmdPool = new M9(c9, 1); + this.bindStatesCmdPool = new M9(u9, 1); + this.drawCmdPool = new M9(_9, 1); + this.updateBufferCmdPool = new M9(d9, 1); + this.copyBufferToTextureCmdPool = new M9(p9, 1); + } + clearCmds(t) { + if (t.beginRenderPassCmds.length) { + this.beginRenderPassCmdPool.freeCmds(t.beginRenderPassCmds); + t.beginRenderPassCmds.clear(); + } + if (t.bindStatesCmds.length) { + this.bindStatesCmdPool.freeCmds(t.bindStatesCmds); + t.bindStatesCmds.clear(); + } + if (t.drawCmds.length) { + this.drawCmdPool.freeCmds(t.drawCmds); + t.drawCmds.clear(); + } + if (t.updateBufferCmds.length) { + this.updateBufferCmdPool.freeCmds(t.updateBufferCmds); + t.updateBufferCmds.clear(); + } + if (t.copyBufferToTextureCmds.length) { + this.copyBufferToTextureCmdPool.freeCmds(t.copyBufferToTextureCmds); + t.copyBufferToTextureCmds.clear(); + } + t.cmds.clear(); + } + releaseCmds() { + this.beginRenderPassCmdPool.release(); + this.bindStatesCmdPool.release(); + this.drawCmdPool.release(); + this.updateBufferCmdPool.release(); + this.copyBufferToTextureCmdPool.release(); + } + } + class D9 extends Or { + constructor(...t) { + super(...t); + this.cmdPackage = new m9; + this._cmdAllocator = new B9; + this._isInRenderPass = !1; + this._curGPUPipelineState = null; + this._curGPUDescriptorSets = []; + this._curGPUInputAssembler = null; + this._curDynamicOffsets = Array(8).fill(0); + this._curDynamicStates = new lr; + this._isStateInvalied = !1; + } + initialize(t) { + this._type = t.type; + this._queue = t.queue; + const e = J7.instance.bindingMappings.blockOffsets.length; + for (let t = 0; t < e; t++) this._curGPUDescriptorSets.push(null); + } + destroy() { + this._cmdAllocator.clearCmds(this.cmdPackage); + } + begin(t, e = 0, i) { + this._cmdAllocator.clearCmds(this.cmdPackage); + this._curGPUPipelineState = null; + this._curGPUInputAssembler = null; + this._curGPUDescriptorSets.length = 0; + this._numDrawCalls = 0; + this._numInstances = 0; + this._numTris = 0; + } + end() { + this._isStateInvalied && this.bindStates(); + this._isInRenderPass = !1; + } + beginRenderPass(t, e, i, s, n, r) { + const o = this._cmdAllocator.beginRenderPassCmdPool.alloc(c9); + o.gpuRenderPass = t.gpuRenderPass; + o.gpuFramebuffer = e.gpuFramebuffer; + o.renderArea.copy(i); + for (let t = 0; t < s.length; ++t) o.clearColors[t] = s[t]; + o.clearDepth = n; + o.clearStencil = r; + this.cmdPackage.beginRenderPassCmds.push(o); + this.cmdPackage.cmds.push(l9.BEGIN_RENDER_PASS); + this._isInRenderPass = !0; + } + endRenderPass() { + this._isInRenderPass = !1; + } + bindPipelineState(t) { + const e = t.gpuPipelineState; + if (e !== this._curGPUPipelineState) { + this._curGPUPipelineState = e; + this._isStateInvalied = !0; + } + } + bindDescriptorSet(t, e, i) { + const s = e.gpuDescriptorSet; + if (s !== this._curGPUDescriptorSets[t]) { + this._curGPUDescriptorSets[t] = s; + this._isStateInvalied = !0; + } + if (i) { + var n; + const e = null === (n = this._curGPUPipelineState) || void 0 === n ? void 0 : n.gpuPipelineLayout; + if (e) { + const s = this._curDynamicOffsets; + const n = e.dynamicOffsetOffsets[t]; + for (let t = 0; t < i.length; t++) s[n + t] = i[t]; + this._isStateInvalied = !0; + } + } + } + bindInputAssembler(t) { + const e = t.gpuInputAssembler; + this._curGPUInputAssembler = e; + this._isStateInvalied = !0; + } + setViewport(t) { + const e = this._curDynamicStates.viewport; + if (e.left !== t.left || e.top !== t.top || e.width !== t.width || e.height !== t.height || e.minDepth !== t.minDepth || e.maxDepth !== t.maxDepth) { + e.left = t.left; + e.top = t.top; + e.width = t.width; + e.height = t.height; + e.minDepth = t.minDepth; + e.maxDepth = t.maxDepth; + this._isStateInvalied = !0; + } + } + setScissor(t) { + const e = this._curDynamicStates.scissor; + if (e.x !== t.x || e.y !== t.y || e.width !== t.width || e.height !== t.height) { + e.x = t.x; + e.y = t.y; + e.width = t.width; + e.height = t.height; + this._isStateInvalied = !0; + } + } + setLineWidth(t) { + if (this._curDynamicStates.lineWidth !== t) { + this._curDynamicStates.lineWidth = t; + this._isStateInvalied = !0; + } + } + setDepthBias(t, e, i) { + const s = this._curDynamicStates; + if (s.depthBiasConstant !== t || s.depthBiasClamp !== e || s.depthBiasSlope !== i) { + s.depthBiasConstant = t; + s.depthBiasClamp = e; + s.depthBiasSlope = i; + this._isStateInvalied = !0; + } + } + setBlendConstants(t) { + const e = this._curDynamicStates.blendConstant; + if (e.x !== t.x || e.y !== t.y || e.z !== t.z || e.w !== t.w) { + e.copy(t); + this._isStateInvalied = !0; + } + } + setDepthBound(t, e) { + const i = this._curDynamicStates; + if (i.depthMinBounds !== t || i.depthMaxBounds !== e) { + i.depthMinBounds = t; + i.depthMaxBounds = e; + this._isStateInvalied = !0; + } + } + setStencilWriteMask(t, e) { + const i = this._curDynamicStates.stencilStatesFront; + const s = this._curDynamicStates.stencilStatesBack; + if (t & Js.FRONT && i.writeMask !== e) { + i.writeMask = e; + this._isStateInvalied = !0; + } + if (t & Js.BACK && s.writeMask !== e) { + s.writeMask = e; + this._isStateInvalied = !0; + } + } + setStencilCompareMask(t, e, i) { + const s = this._curDynamicStates.stencilStatesFront; + const n = this._curDynamicStates.stencilStatesBack; + if (t & Js.FRONT && (s.compareMask !== i || s.reference !== e)) { + s.reference = e; + s.compareMask = i; + this._isStateInvalied = !0; + } + if (t & Js.BACK && (n.compareMask !== i || n.reference !== e)) { + n.reference = e; + n.compareMask = i; + this._isStateInvalied = !0; + } + } + draw(t) { + if (this._type === tn.PRIMARY && this._isInRenderPass || this._type === tn.SECONDARY) { + this._isStateInvalied && this.bindStates(); + const e = "drawInfo" in t ? t.drawInfo : t; + const i = this._cmdAllocator.drawCmdPool.alloc(_9); + i.drawInfo.copy(e); + this.cmdPackage.drawCmds.push(i); + this.cmdPackage.cmds.push(l9.DRAW); + ++this._numDrawCalls; + this._numInstances += e.instanceCount; + const s = e.indexCount || e.vertexCount; + if (this._curGPUPipelineState) { + switch (this._curGPUPipelineState.glPrimitive) { + case 4: + this._numTris += s / 3 * Math.max(e.instanceCount, 1); + break; + + case 5: + case 6: + this._numTris += (s - 2) * Math.max(e.instanceCount, 1); + } + } + } else console.error("Command 'draw' must be recorded inside a render pass."); + } + updateBuffer(t, e, i) { + if (this._type === tn.PRIMARY && !this._isInRenderPass || this._type === tn.SECONDARY) { + const s = t.gpuBuffer; + if (s) { + const n = this._cmdAllocator.updateBufferCmdPool.alloc(d9); + let r = 0; + let o = null; + if (t.usage & Ts.INDIRECT) o = e; else { + r = void 0 !== i ? i : e.byteLength; + o = e; + } + n.gpuBuffer = s; + n.buffer = o; + n.offset = 0; + n.size = r; + this.cmdPackage.updateBufferCmds.push(n); + this.cmdPackage.cmds.push(l9.UPDATE_BUFFER); + } + } else console.error("Command 'updateBuffer' must be recorded outside a render pass."); + } + copyBuffersToTexture(t, e, i) { + if (this._type === tn.PRIMARY && !this._isInRenderPass || this._type === tn.SECONDARY) { + const s = e.gpuTexture; + if (s) { + const e = this._cmdAllocator.copyBufferToTextureCmdPool.alloc(p9); + e.gpuTexture = s; + e.regions = i; + e.buffers = t; + this.cmdPackage.copyBufferToTextureCmds.push(e); + this.cmdPackage.cmds.push(l9.COPY_BUFFER_TO_TEXTURE); + } + } else console.error("Command 'copyBufferToTexture' must be recorded outside a render pass."); + } + execute(t, e) { + for (let i = 0; i < e; ++i) { + const e = t[i]; + for (let t = 0; t < e.cmdPackage.beginRenderPassCmds.length; ++t) { + const i = e.cmdPackage.beginRenderPassCmds.array[t]; + ++i.refCount; + this.cmdPackage.beginRenderPassCmds.push(i); + } + for (let t = 0; t < e.cmdPackage.bindStatesCmds.length; ++t) { + const i = e.cmdPackage.bindStatesCmds.array[t]; + ++i.refCount; + this.cmdPackage.bindStatesCmds.push(i); + } + for (let t = 0; t < e.cmdPackage.drawCmds.length; ++t) { + const i = e.cmdPackage.drawCmds.array[t]; + ++i.refCount; + this.cmdPackage.drawCmds.push(i); + } + for (let t = 0; t < e.cmdPackage.updateBufferCmds.length; ++t) { + const i = e.cmdPackage.updateBufferCmds.array[t]; + ++i.refCount; + this.cmdPackage.updateBufferCmds.push(i); + } + for (let t = 0; t < e.cmdPackage.copyBufferToTextureCmds.length; ++t) { + const i = e.cmdPackage.copyBufferToTextureCmds.array[t]; + ++i.refCount; + this.cmdPackage.copyBufferToTextureCmds.push(i); + } + this.cmdPackage.cmds.concat(e.cmdPackage.cmds.array); + this._numDrawCalls += e._numDrawCalls; + this._numInstances += e._numInstances; + this._numTris += e._numTris; + } + } + pipelineBarrier(t, e, i, s, n) {} + bindStates() { + const t = this._cmdAllocator.bindStatesCmdPool.alloc(u9); + t.gpuPipelineState = this._curGPUPipelineState; + Array.prototype.push.apply(t.gpuDescriptorSets, this._curGPUDescriptorSets); + Array.prototype.push.apply(t.dynamicOffsets, this._curDynamicOffsets); + t.gpuInputAssembler = this._curGPUInputAssembler; + t.dynamicStates = this._curDynamicStates; + this.cmdPackage.bindStatesCmds.push(t); + this.cmdPackage.cmds.push(l9.BIND_STATES); + this._isStateInvalied = !1; + } + } + class P9 extends Fr { + constructor(...t) { + super(...t); + this._gpuFramebuffer = null; + } + get gpuFramebuffer() { + return this._gpuFramebuffer; + } + initialize(t) { + this._renderPass = t.renderPass; + this._colorTextures = t.colorTextures || []; + this._depthStencilTexture = t.depthStencilTexture || null; + const e = []; + for (let i = 0; i < t.colorTextures.length; i++) { + const s = t.colorTextures[i]; + s && e.push(s.gpuTextureView); + } + let i = null; + t.depthStencilTexture && (i = t.depthStencilTexture.gpuTextureView); + let s = Number.MAX_SAFE_INTEGER; + this._gpuFramebuffer = { + gpuRenderPass: t.renderPass.gpuRenderPass, + gpuColorViews: e, + gpuDepthStencilView: i, + glFramebuffer: null, + isOffscreen: !0, + get width() { + return this.isOffscreen ? s : this.gpuColorViews.length > 0 ? this.gpuColorViews[0].gpuTexture.width : this.gpuDepthStencilView.gpuTexture.width; + }, + set width(t) { + s = t; + }, + get height() { + return this.isOffscreen ? s : this.gpuColorViews.length > 0 ? this.gpuColorViews[0].gpuTexture.height : this.gpuDepthStencilView.gpuTexture.height; + }, + set height(t) {} + }; + !function(t, e) { + for (let t = 0; t < e.gpuColorViews.length; ++t) if (e.gpuColorViews[t].gpuTexture.isSwapchainTexture) { + e.isOffscreen = !1; + return; + } + const {gl: i} = t; + const s = []; + const n = i.createFramebuffer(); + if (n) { + e.glFramebuffer = n; + t.stateCache.glFramebuffer !== e.glFramebuffer && i.bindFramebuffer(i.FRAMEBUFFER, e.glFramebuffer); + for (let t = 0; t < e.gpuColorViews.length; ++t) { + const n = e.gpuColorViews[t]; + const r = n.gpuTexture; + if (r) { + r.glTexture ? i.framebufferTexture2D(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0 + t, r.glTarget, r.glTexture, n.baseLevel) : i.framebufferRenderbuffer(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0 + t, i.RENDERBUFFER, r.glRenderbuffer); + s.push(i.COLOR_ATTACHMENT0 + t); + e.width = Math.min(e.width, r.width >> n.baseLevel); + e.height = Math.min(e.height, r.height >> n.baseLevel); + } + } + const r = e.gpuDepthStencilView; + if (r) { + const t = r.gpuTexture; + const s = ur[t.format].hasStencil ? i.DEPTH_STENCIL_ATTACHMENT : i.DEPTH_ATTACHMENT; + t.glTexture ? i.framebufferTexture2D(i.FRAMEBUFFER, s, t.glTarget, t.glTexture, e.gpuDepthStencilView.baseLevel) : i.framebufferRenderbuffer(i.FRAMEBUFFER, s, i.RENDERBUFFER, t.glRenderbuffer); + e.width = Math.min(e.width, t.width >> r.baseLevel); + e.height = Math.min(e.height, t.height >> r.baseLevel); + } + i.drawBuffers(s); + const o = i.checkFramebufferStatus(i.FRAMEBUFFER); + if (o !== i.FRAMEBUFFER_COMPLETE) switch (o) { + case i.FRAMEBUFFER_INCOMPLETE_ATTACHMENT: + console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_ATTACHMENT"); + break; + + case i.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: + console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT"); + break; + + case i.FRAMEBUFFER_INCOMPLETE_DIMENSIONS: + console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_DIMENSIONS"); + break; + + case i.FRAMEBUFFER_UNSUPPORTED: + console.error("glCheckFramebufferStatus() - FRAMEBUFFER_UNSUPPORTED"); + } + t.stateCache.glFramebuffer !== e.glFramebuffer && i.bindFramebuffer(i.FRAMEBUFFER, t.stateCache.glFramebuffer); + } + }(J7.instance, this._gpuFramebuffer); + } + destroy() { + if (this._gpuFramebuffer) { + !function(t, e) { + if (e.glFramebuffer) { + t.gl.deleteFramebuffer(e.glFramebuffer); + if (t.stateCache.glFramebuffer === e.glFramebuffer) { + t.gl.bindFramebuffer(t.gl.FRAMEBUFFER, null); + t.stateCache.glFramebuffer = null; + } + e.glFramebuffer = null; + } + }(J7.instance, this._gpuFramebuffer); + this._gpuFramebuffer = null; + } + } + } + class O9 extends Gr { + constructor(...t) { + super(...t); + this._gpuInputAssembler = null; + } + get gpuInputAssembler() { + return this._gpuInputAssembler; + } + initialize(t) { + if (0 === t.vertexBuffers.length) { + console.error("InputAssemblerInfo.vertexBuffers is null."); + return; + } + this._attributes = t.attributes; + this._attributesHash = this.computeAttributesHash(); + this._vertexBuffers = t.vertexBuffers; + if (t.indexBuffer) { + this._indexBuffer = t.indexBuffer; + this._drawInfo.indexCount = this._indexBuffer.size / this._indexBuffer.stride; + this._drawInfo.firstIndex = 0; + } else { + const t = this._vertexBuffers[0]; + this._drawInfo.vertexCount = t.size / t.stride; + this._drawInfo.firstVertex = 0; + this._drawInfo.vertexOffset = 0; + } + this._drawInfo.instanceCount = 0; + this._drawInfo.firstInstance = 0; + this._indirectBuffer = t.indirectBuffer || null; + const e = new Array(t.vertexBuffers.length); + for (let i = 0; i < t.vertexBuffers.length; ++i) { + const s = t.vertexBuffers[i]; + s.gpuBuffer && (e[i] = s.gpuBuffer); + } + let i = null; + let s = 0; + if (t.indexBuffer) { + i = t.indexBuffer.gpuBuffer; + if (i) switch (i.stride) { + case 1: + s = 5121; + break; + + case 2: + s = 5123; + break; + + case 4: + s = 5125; + break; + + default: + console.error("Illegal index buffer stride."); + } + } + let n = null; + t.indirectBuffer && (n = t.indirectBuffer.gpuBuffer); + this._gpuInputAssembler = { + attributes: t.attributes, + gpuVertexBuffers: e, + gpuIndexBuffer: i, + gpuIndirectBuffer: n, + glAttribs: [], + glIndexType: s, + glVAOs: new Map + }; + !function(t, e) { + const {gl: i} = t; + e.glAttribs = new Array(e.attributes.length); + const s = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; + for (let t = 0; t < e.attributes.length; ++t) { + const n = e.attributes[t]; + const r = void 0 !== n.stream ? n.stream : 0; + const o = e.gpuVertexBuffers[r]; + const a = $7(n.format, i); + const {size: l} = ur[n.format]; + e.glAttribs[t] = { + name: n.name, + glBuffer: o.glBuffer, + glType: a, + size: l, + count: ur[n.format].count, + stride: o.stride, + componentCount: s9(a, i), + isNormalized: void 0 !== n.isNormalized && n.isNormalized, + isInstanced: void 0 !== n.isInstanced && n.isInstanced, + offset: s[r] + }; + s[r] += l; + } + }(J7.instance, this._gpuInputAssembler); + } + destroy() { + const t = J7.instance; + this._gpuInputAssembler && t.extensions.useVAO && function(t, e) { + const i = e.glVAOs.values(); + let s = i.next(); + const {gl: n} = t; + let r = t.stateCache.glVAO; + for (;!s.done; ) { + n.deleteVertexArray(s.value); + if (r === s.value) { + n.bindVertexArray(null); + r = null; + } + s = i.next(); + } + t.stateCache.glVAO = r; + e.glVAOs.clear(); + }(t, this._gpuInputAssembler); + this._gpuInputAssembler = null; + } + } + class N9 extends zr { + constructor(...t) { + super(...t); + this._gpuDescriptorSetLayout = null; + } + get gpuDescriptorSetLayout() { + return this._gpuDescriptorSetLayout; + } + initialize(t) { + Array.prototype.push.apply(this._bindings, t.bindings); + let e = 0; + let i = -1; + const s = []; + for (let t = 0; t < this._bindings.length; t++) { + const n = this._bindings[t]; + s.push(e); + e += n.count; + n.binding > i && (i = n.binding); + } + this._bindingIndices = Array(i + 1).fill(-1); + const n = this._descriptorIndices = Array(i + 1).fill(-1); + for (let t = 0; t < this._bindings.length; t++) { + const e = this._bindings[t]; + this._bindingIndices[e.binding] = t; + n[e.binding] = s[t]; + } + const r = []; + for (let t = 0; t < this._bindings.length; t++) { + const e = this._bindings[t]; + if (e.descriptorType & pr) for (let t = 0; t < e.count; t++) r.push(e.binding); + } + this._gpuDescriptorSetLayout = { + bindings: this._bindings, + dynamicBindings: r, + descriptorIndices: n, + descriptorCount: e + }; + } + destroy() { + this._bindings.length = 0; + } + } + class L9 extends Hr { + constructor(...t) { + super(...t); + this._gpuPipelineLayout = null; + } + get gpuPipelineLayout() { + return this._gpuPipelineLayout; + } + initialize(t) { + Array.prototype.push.apply(this._setLayouts, t.setLayouts); + const e = []; + const i = []; + let s = 0; + const n = []; + for (let t = 0; t < this._setLayouts.length; t++) { + const r = this._setLayouts[t]; + const o = r.gpuDescriptorSetLayout.dynamicBindings; + const a = Array(r.bindingIndices.length).fill(-1); + for (let t = 0; t < o.length; t++) { + const e = o[t]; + a[e] < 0 && (a[e] = s + t); + } + i.push(r.gpuDescriptorSetLayout); + e.push(a); + n.push(s); + s += o.length; + } + this._gpuPipelineLayout = { + gpuSetLayouts: i, + dynamicOffsetIndices: e, + dynamicOffsetCount: s, + dynamicOffsetOffsets: n + }; + } + destroy() { + this._setLayouts.length = 0; + } + } + const F9 = [ 0, 1, 3, 2, 0, 0, 0, 4, 5, 6, 0, 0, 0, 0 ]; + class V9 extends Mr { + constructor(...t) { + super(...t); + this._gpuPipelineState = null; + } + get gpuPipelineState() { + return this._gpuPipelineState; + } + initialize(t) { + this._primitive = t.primitive; + this._shader = t.shader; + this._pipelineLayout = t.pipelineLayout; + const e = this._bs; + if (t.blendState) { + const i = t.blendState; + const {targets: s} = i; + s && s.forEach(((t, i) => { + e.setTarget(i, t); + })); + void 0 !== i.isA2C && (e.isA2C = i.isA2C); + void 0 !== i.isIndepend && (e.isIndepend = i.isIndepend); + void 0 !== i.blendColor && (e.blendColor = i.blendColor); + } + Object.assign(this._rs, t.rasterizerState); + Object.assign(this._dss, t.depthStencilState); + this._is = t.inputState; + this._renderPass = t.renderPass; + this._dynamicStates = t.dynamicStates; + const i = []; + for (let t = 0; t < 31; t++) this._dynamicStates & 1 << t && i.push(1 << t); + this._gpuPipelineState = { + glPrimitive: F9[t.primitive], + gpuShader: t.shader.gpuShader, + gpuPipelineLayout: t.pipelineLayout.gpuPipelineLayout, + rs: t.rasterizerState, + dss: t.depthStencilState, + bs: t.blendState, + gpuRenderPass: t.renderPass.gpuRenderPass, + dynamicStates: i + }; + } + destroy() { + this._gpuPipelineState = null; + } + } + class k9 extends D9 { + beginRenderPass(t, e, i, s, n, r) { + S9(J7.instance, t.gpuRenderPass, e.gpuFramebuffer, i, s, n, r); + this._isInRenderPass = !0; + } + draw(t) { + if (this._isInRenderPass) { + this._isStateInvalied && this.bindStates(); + const e = "drawInfo" in t ? t.drawInfo : t; + T9(J7.instance, e); + ++this._numDrawCalls; + this._numInstances += e.instanceCount; + const i = e.indexCount || e.vertexCount; + if (this._curGPUPipelineState) { + switch (this._curGPUPipelineState.glPrimitive) { + case 4: + this._numTris += i / 3 * Math.max(e.instanceCount, 1); + break; + + case 5: + case 6: + this._numTris += (i - 2) * Math.max(e.instanceCount, 1); + } + } + } else console.error("Command 'draw' must be recorded inside a render pass."); + } + setViewport(t) { + const {stateCache: e, gl: i} = J7.instance; + if (e.viewport.left !== t.left || e.viewport.top !== t.top || e.viewport.width !== t.width || e.viewport.height !== t.height) { + i.viewport(t.left, t.top, t.width, t.height); + e.viewport.left = t.left; + e.viewport.top = t.top; + e.viewport.width = t.width; + e.viewport.height = t.height; + } + } + setScissor(t) { + const {stateCache: e, gl: i} = J7.instance; + if (e.scissorRect.x !== t.x || e.scissorRect.y !== t.y || e.scissorRect.width !== t.width || e.scissorRect.height !== t.height) { + i.scissor(t.x, t.y, t.width, t.height); + e.scissorRect.x = t.x; + e.scissorRect.y = t.y; + e.scissorRect.width = t.width; + e.scissorRect.height = t.height; + } + } + updateBuffer(t, e, i) { + if (this._isInRenderPass) console.error("Command 'updateBuffer' must be recorded outside a render pass."); else { + const s = t.gpuBuffer; + if (s) { + let n; + n = void 0 !== i ? i : t.usage & Ts.INDIRECT ? 0 : e.byteLength; + f9(J7.instance, s, e, 0, n); + } + } + } + copyBuffersToTexture(t, e, i) { + if (this._isInRenderPass) console.error("Command 'copyBufferToTexture' must be recorded outside a render pass."); else { + const s = e.gpuTexture; + s && w9(J7.instance, t, s, i); + } + } + execute(t, e) { + for (let i = 0; i < e; ++i) { + const e = t[i]; + E9(J7.instance, e.cmdPackage); + this._numDrawCalls += e._numDrawCalls; + this._numInstances += e._numInstances; + this._numTris += e._numTris; + } + } + bindStates() { + A9(J7.instance, this._curGPUPipelineState, this._curGPUInputAssembler, this._curGPUDescriptorSets, this._curDynamicOffsets, this._curDynamicStates); + this._isStateInvalied = !1; + } + } + class U9 extends jr { + constructor(...t) { + super(...t); + this.numDrawCalls = 0; + this.numInstances = 0; + this.numTris = 0; + } + initialize(t) { + this._type = t.type; + } + destroy() {} + submit(t) { + for (let e = 0; e < t.length; e++) { + const i = t[e]; + this.numDrawCalls += i.numDrawCalls; + this.numInstances += i.numInstances; + this.numTris += i.numTris; + } + } + clear() { + this.numDrawCalls = 0; + this.numInstances = 0; + this.numTris = 0; + } + } + class G9 extends Xr { + constructor(...t) { + super(...t); + this._gpuRenderPass = null; + } + get gpuRenderPass() { + return this._gpuRenderPass; + } + initialize(t) { + this._colorInfos = t.colorAttachments; + this._depthStencilInfo = t.depthStencilAttachment; + this._subpasses = t.subpasses; + this._gpuRenderPass = { + colorAttachments: this._colorInfos, + depthStencilAttachment: this._depthStencilInfo + }; + this._hash = this.computeHash(); + } + destroy() { + this._gpuRenderPass = null; + } + } + class z9 extends qr { + get gpuSampler() { + return this._gpuSampler; + } + constructor(t, e) { + super(t, e); + this._gpuSampler = null; + this._gpuSampler = { + glSamplers: new Map, + minFilter: this._info.minFilter, + magFilter: this._info.magFilter, + mipFilter: this._info.mipFilter, + addressU: this._info.addressU, + addressV: this._info.addressV, + addressW: this._info.addressW, + glMinFilter: 0, + glMagFilter: 0, + glWrapS: 0, + glWrapT: 0, + glWrapR: 0, + getGLSampler(t, e, i) { + const {gl: s} = t; + const n = e << 16 | i; + if (!this.glSamplers.has(n)) { + const t = s.createSampler(); + if (t) { + this.glSamplers.set(n, t); + s.samplerParameteri(t, s.TEXTURE_MIN_FILTER, this.glMinFilter); + s.samplerParameteri(t, s.TEXTURE_MAG_FILTER, this.glMagFilter); + s.samplerParameteri(t, s.TEXTURE_WRAP_S, this.glWrapS); + s.samplerParameteri(t, s.TEXTURE_WRAP_T, this.glWrapT); + s.samplerParameteri(t, s.TEXTURE_WRAP_R, this.glWrapR); + s.samplerParameterf(t, s.TEXTURE_MIN_LOD, e); + s.samplerParameterf(t, s.TEXTURE_MAX_LOD, i); + } + } + return this.glSamplers.get(n); + } + }; + !function(t, e) { + const {gl: i} = t; + e.minFilter === Ds.LINEAR || e.minFilter === Ds.ANISOTROPIC ? e.mipFilter === Ds.LINEAR || e.mipFilter === Ds.ANISOTROPIC ? e.glMinFilter = i.LINEAR_MIPMAP_LINEAR : e.mipFilter === Ds.POINT ? e.glMinFilter = i.LINEAR_MIPMAP_NEAREST : e.glMinFilter = i.LINEAR : e.mipFilter === Ds.LINEAR || e.mipFilter === Ds.ANISOTROPIC ? e.glMinFilter = i.NEAREST_MIPMAP_LINEAR : e.mipFilter === Ds.POINT ? e.glMinFilter = i.NEAREST_MIPMAP_NEAREST : e.glMinFilter = i.NEAREST; + e.magFilter === Ds.LINEAR || e.magFilter === Ds.ANISOTROPIC ? e.glMagFilter = i.LINEAR : e.glMagFilter = i.NEAREST; + e.glWrapS = Z7[e.addressU]; + e.glWrapT = Z7[e.addressV]; + e.glWrapR = Z7[e.addressW]; + }(J7.instance, this._gpuSampler); + } + destroy() { + if (this._gpuSampler) { + !function(t, e) { + const {gl: i} = t; + const s = e.glSamplers.values().next(); + for (;!s.done; ) { + i.deleteSampler(s.value); + const e = t.stateCache.glSamplerUnits; + for (let t = 0; t < e.length; ++t) if (e[t] === s.value) { + i.bindSampler(t, null); + e[t] = null; + } + } + e.glSamplers.clear(); + }(J7.instance, this._gpuSampler); + this._gpuSampler = null; + } + } + } + class H9 extends Wr { + constructor(...t) { + super(...t); + this._gpuShader = null; + } + get gpuShader() { + null === this._gpuShader.glProgram && function(t, e) { + const {gl: i} = t; + for (let t = 0; t < e.gpuStages.length; t++) { + const s = e.gpuStages[t]; + let n = 0; + let r = ""; + let o = 1; + switch (s.type) { + case ks.VERTEX: + r = "VertexShader"; + n = i.VERTEX_SHADER; + break; + + case ks.FRAGMENT: + r = "FragmentShader"; + n = i.FRAGMENT_SHADER; + break; + + default: + console.error("Unsupported ShaderType."); + return; + } + const a = i.createShader(n); + if (a) { + s.glShader = a; + i.shaderSource(s.glShader, `#version 300 es\n${s.source}`); + i.compileShader(s.glShader); + if (!i.getShaderParameter(s.glShader, i.COMPILE_STATUS)) { + console.error(`${r} in '${e.name}' compilation failed.`); + console.error("Shader source dump:", s.source.replace(/^|\n/g, (() => `\n${o++} `))); + console.error(i.getShaderInfoLog(s.glShader)); + for (let s = 0; s < e.gpuStages.length; s++) { + const s = e.gpuStages[t]; + if (s.glShader) { + i.deleteShader(s.glShader); + s.glShader = null; + } + } + return; + } + } + } + const s = i.createProgram(); + if (!s) return; + e.glProgram = s; + for (let t = 0; t < e.gpuStages.length; t++) { + const s = e.gpuStages[t]; + i.attachShader(e.glProgram, s.glShader); + } + i.linkProgram(e.glProgram); + for (let t = 0; t < e.gpuStages.length; t++) { + const s = e.gpuStages[t]; + if (s.glShader) { + i.detachShader(e.glProgram, s.glShader); + i.deleteShader(s.glShader); + s.glShader = null; + } + } + if (!i.getProgramParameter(e.glProgram, i.LINK_STATUS)) { + console.error(`Failed to link shader '${e.name}'.`); + console.error(i.getProgramInfoLog(e.glProgram)); + return; + } + R(`Shader '${e.name}' compilation succeeded.`); + const n = i.getProgramParameter(e.glProgram, i.ACTIVE_ATTRIBUTES); + e.glInputs = new Array(n); + for (let t = 0; t < n; ++t) { + const s = i.getActiveAttrib(e.glProgram, t); + if (s) { + let n; + const r = s.name.indexOf("["); + n = -1 !== r ? s.name.substr(0, r) : s.name; + const o = i.getAttribLocation(e.glProgram, n); + const a = e9(s.type, i); + const l = i9(s.type, i); + e.glInputs[t] = { + name: n, + type: a, + stride: l, + count: s.size, + size: l * s.size, + glType: s.type, + glLoc: o + }; + } + } + const r = i.getProgramParameter(e.glProgram, i.ACTIVE_UNIFORM_BLOCKS); + let o; + let a; + let l; + let h; + if (r) { + e.glBlocks = new Array(r); + for (let s = 0; s < r; ++s) { + o = i.getActiveUniformBlockName(e.glProgram, s); + const n = o.indexOf("["); + -1 !== n && (o = o.substr(0, n)); + h = null; + for (let t = 0; t < e.blocks.length; t++) if (e.blocks[t].name === o) { + h = e.blocks[t]; + break; + } + if (h) { + a = s; + l = i.getActiveUniformBlockParameter(e.glProgram, a, i.UNIFORM_BLOCK_DATA_SIZE); + const n = h.binding + (t.bindingMappings.blockOffsets[h.set] || 0); + i.uniformBlockBinding(e.glProgram, a, n); + e.glBlocks[s] = { + set: h.set, + binding: h.binding, + idx: a, + name: o, + size: l, + glBinding: n + }; + } else x(`Block '${o}' does not bound`); + } + } + for (let t = 0; t < e.subpassInputs.length; ++t) { + const i = e.subpassInputs[t]; + e.samplerTextures.push(new Bn(i.set, i.binding, i.name, As.SAMPLER2D, i.count)); + } + if (e.samplerTextures.length > 0) { + e.glSamplerTextures = new Array(e.samplerTextures.length); + for (let t = 0; t < e.samplerTextures.length; ++t) { + const s = e.samplerTextures[t]; + e.glSamplerTextures[t] = { + set: s.set, + binding: s.binding, + name: s.name, + type: s.type, + count: s.count, + units: [], + glUnits: null, + glType: t9(s.type, i), + glLoc: null + }; + } + } + const c = []; + const u = []; + const _ = t.stateCache.texUnitCacheMap; + let d = 0; + for (let i = 0; i < e.blocks.length; ++i) e.blocks[i].set === t.bindingMappings.flexibleSet && d++; + let p = 0; + for (let s = 0; s < e.samplerTextures.length; ++s) { + const n = e.samplerTextures[s]; + const r = i.getUniformLocation(e.glProgram, n.name); + if (r && -1 !== r.id) { + c.push(e.glSamplerTextures[s]); + u.push(r); + } + if (void 0 === _[n.name]) { + let e = n.binding + t.bindingMappings.samplerTextureOffsets[n.set] + p; + n.set === t.bindingMappings.flexibleSet && (e -= d); + _[n.name] = e % t.capabilities.maxTextureUnits; + p += n.count - 1; + } + } + if (c.length) { + const s = []; + for (let e = 0; e < c.length; ++e) { + const i = c[e]; + let n = _[i.name]; + if (void 0 !== n) { + i.glLoc = u[e]; + for (let e = 0; e < i.count; ++e) { + for (;s[n]; ) n = (n + 1) % t.capabilities.maxTextureUnits; + i.units.push(n); + s[n] = !0; + } + } + } + let n = 0; + for (let e = 0; e < c.length; ++e) { + const i = c[e]; + if (!i.glLoc) { + i.glLoc = u[e]; + for (;s[n]; ) n++; + for (let e = 0; e < i.count; ++e) { + for (;s[n]; ) n = (n + 1) % t.capabilities.maxTextureUnits; + void 0 === _[i.name] && (_[i.name] = n); + i.units.push(n); + s[n] = !0; + } + } + } + t.stateCache.glProgram !== e.glProgram && i.useProgram(e.glProgram); + for (let t = 0; t < c.length; t++) { + const e = c[t]; + e.glUnits = new Int32Array(e.units); + i.uniform1iv(e.glLoc, e.glUnits); + } + t.stateCache.glProgram !== e.glProgram && i.useProgram(t.stateCache.glProgram); + } + e.glSamplerTextures = c; + }(J7.instance, this._gpuShader); + return this._gpuShader; + } + initialize(t) { + this._name = t.name; + this._stages = t.stages; + this._attributes = t.attributes; + this._blocks = t.blocks; + this._samplers = t.samplers; + this._gpuShader = { + name: t.name, + blocks: t.blocks.slice(), + samplerTextures: t.samplerTextures.slice(), + subpassInputs: t.subpassInputs.slice(), + gpuStages: new Array(t.stages.length), + glProgram: null, + glInputs: [], + glUniforms: [], + glBlocks: [], + glSamplerTextures: [] + }; + for (let e = 0; e < t.stages.length; ++e) { + const i = t.stages[e]; + this._gpuShader.gpuStages[e] = { + type: i.stage, + source: i.source, + glShader: null + }; + } + } + destroy() { + if (this._gpuShader) { + !function(t, e) { + if (e.glProgram) { + t.gl.deleteProgram(e.glProgram); + if (t.stateCache.glProgram === e.glProgram) { + t.gl.useProgram(null); + t.stateCache.glProgram = null; + } + e.glProgram = null; + } + }(J7.instance, this._gpuShader); + this._gpuShader = null; + } + } + } + class j9 { + constructor() { + this.glArrayBuffer = null; + this.glElementArrayBuffer = null; + this.glUniformBuffer = null; + this.glBindUBOs = []; + this.glBindUBOOffsets = []; + this.glVAO = null; + this.texUnit = 0; + this.glTexUnits = []; + this.glSamplerUnits = []; + this.glRenderbuffer = null; + this.glFramebuffer = null; + this.glReadFramebuffer = null; + this.viewport = new fn; + this.scissorRect = new hn(0, 0, 0, 0); + this.rs = new Cr; + this.dss = new wr; + this.bs = new Ir; + this.glProgram = null; + this.glEnabledAttribLocs = []; + this.glCurrentAttribLocs = []; + this.texUnitCacheMap = {}; + } + initialize(t, e, i) { + for (let e = 0; e < t; ++e) this.glTexUnits.push({ + glTexture: null + }); + this.glSamplerUnits.length = t; + this.glSamplerUnits.fill(null); + this.glBindUBOs.length = e; + this.glBindUBOs.fill(null); + this.glBindUBOOffsets.length = e; + this.glBindUBOOffsets.fill(0); + this.glEnabledAttribLocs.length = i; + this.glEnabledAttribLocs.fill(!1); + this.glCurrentAttribLocs.length = i; + this.glCurrentAttribLocs.fill(!1); + } + } + class X9 extends Yr { + constructor(...t) { + super(...t); + this._gpuTexture = null; + this._gpuTextureView = null; + } + get gpuTexture() { + return this._gpuTexture; + } + get gpuTextureView() { + return this._gpuTextureView; + } + initialize(t, e) { + let i = t; + const s = t; + if ("texture" in t) { + i = s.texture.info; + this._isTextureView = !0; + } + this._info.copy(i); + this._isPowerOf2 = fr(this._info.width) && fr(this._info.height); + this._size = yr(this._info.format, this.width, this.height, this.depth, this._info.levelCount) * this._info.layerCount; + if (this._isTextureView) { + var n; + this._viewInfo.copy(s); + this._gpuTexture = s.texture._gpuTexture; + if ((null === (n = this._gpuTexture) || void 0 === n ? void 0 : n.format) !== i.format) { + console.log("GPU memory alias is not supported"); + return; + } + this._gpuTextureView = { + gpuTexture: this._gpuTexture, + type: s.type, + format: s.format, + baseLevel: s.baseLevel, + levelCount: s.levelCount + }; + } else { + this._gpuTexture = { + type: i.type, + format: i.format, + usage: i.usage, + width: i.width, + height: i.height, + depth: i.depth, + size: this._size, + arrayLayer: i.layerCount, + mipLevel: i.levelCount, + samples: i.samples, + flags: i.flags, + isPowerOf2: this._isPowerOf2, + glTarget: 0, + glInternalFmt: 0, + glFormat: 0, + glType: 0, + glUsage: 0, + glTexture: null, + glRenderbuffer: null, + glWrapS: 0, + glWrapT: 0, + glMinFilter: 0, + glMagFilter: 0, + isSwapchainTexture: e || !1 + }; + g9(J7.instance, this._gpuTexture); + J7.instance.memoryStatus.textureSize += this._size; + this._viewInfo.texture = this; + this._viewInfo.type = t.type; + this._viewInfo.format = t.format; + this._viewInfo.baseLevel = 0; + this._viewInfo.levelCount = t.levelCount; + this._viewInfo.baseLayer = 0; + this._viewInfo.layerCount = t.layerCount; + this._gpuTextureView = { + gpuTexture: this._gpuTexture, + type: this._viewInfo.type, + format: this._viewInfo.format, + baseLevel: this._viewInfo.baseLevel, + levelCount: this._viewInfo.levelCount + }; + } + } + destroy() { + if (!this._isTextureView && this._gpuTexture) { + y9(J7.instance, this._gpuTexture); + J7.instance.memoryStatus.textureSize -= this._size; + this._gpuTexture = null; + } + } + resize(t, e) { + if (this._info.width === t && this._info.height === e) return; + this._info.levelCount === X9.getLevelCount(this._info.width, this._info.height) ? this._info.levelCount = X9.getLevelCount(t, e) : this._info.levelCount > 1 && (this._info.levelCount = Math.min(this._info.levelCount, X9.getLevelCount(t, e))); + const i = this._size; + this._info.width = t; + this._info.height = e; + this._size = yr(this._info.format, this.width, this.height, this.depth, this._info.levelCount) * this._info.layerCount; + if (!this._isTextureView && this._gpuTexture) { + this._gpuTexture.width = t; + this._gpuTexture.height = e; + this._gpuTexture.size = this._size; + !function(t, e) { + if (!e.size) return; + const {gl: i} = t; + let s = e.width; + let n = e.height; + switch (e.type) { + case xs.TEX2D: + { + e.glTarget = i.TEXTURE_2D; + const r = Math.max(s, n); + r > t.capabilities.maxTextureSize && F(9100, r, t.capabilities.maxTextureSize); + if (e.samples === Ms.ONE) { + const r = t.stateCache.glTexUnits[t.stateCache.texUnit]; + if (r.glTexture !== e.glTexture) { + i.bindTexture(i.TEXTURE_2D, e.glTexture); + r.glTexture = e.glTexture; + } + if (ur[e.format].isCompressed) for (let t = 0; t < e.mipLevel; ++t) { + const r = gr(e.format, s, n, 1); + const o = new Uint8Array(r); + i.compressedTexImage2D(i.TEXTURE_2D, t, e.glInternalFmt, s, n, 0, o); + s = Math.max(1, s >> 1); + n = Math.max(1, n >> 1); + } else { + y9(t, e); + g9(t, e); + } + } else if (e.glRenderbuffer) { + if (t.stateCache.glRenderbuffer !== e.glRenderbuffer) { + i.bindRenderbuffer(i.RENDERBUFFER, e.glRenderbuffer); + t.stateCache.glRenderbuffer = e.glRenderbuffer; + } + i.renderbufferStorageMultisample(i.RENDERBUFFER, e.samples, e.glInternalFmt, e.width, e.height); + } + break; + } + + case xs.CUBE: + { + e.type = xs.CUBE; + e.glTarget = i.TEXTURE_CUBE_MAP; + const r = Math.max(s, n); + r > t.capabilities.maxCubeMapTextureSize && F(9100, r, t.capabilities.maxTextureSize); + const o = t.stateCache.glTexUnits[t.stateCache.texUnit]; + if (o.glTexture !== e.glTexture) { + i.bindTexture(i.TEXTURE_CUBE_MAP, e.glTexture); + o.glTexture = e.glTexture; + } + if (ur[e.format].isCompressed) for (let t = 0; t < 6; ++t) { + s = e.width; + n = e.height; + for (let r = 0; r < e.mipLevel; ++r) { + const o = gr(e.format, s, n, 1); + const a = new Uint8Array(o); + i.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + t, r, e.glInternalFmt, s, n, 0, a); + s = Math.max(1, s >> 1); + n = Math.max(1, n >> 1); + } + } else { + y9(t, e); + g9(t, e); + } + break; + } + + default: + console.error("Unsupported TextureType, create texture failed."); + e.type = xs.TEX2D; + e.glTarget = i.TEXTURE_2D; + } + }(J7.instance, this._gpuTexture); + J7.instance.memoryStatus.textureSize -= i; + J7.instance.memoryStatus.textureSize += this._size; + } + } + initAsSwapchainTexture(t) { + const e = new xn; + e.format = t.format; + e.usage = ur[t.format].hasDepth ? ws.DEPTH_STENCIL_ATTACHMENT : ws.COLOR_ATTACHMENT; + e.width = t.width; + e.height = t.height; + this.initialize(e, !0); + } + } + const W9 = "webglcontextlost"; + function Y9(t, e) { + const i = [ "", "WEBKIT_", "MOZ_" ]; + for (let s = 0; s < i.length; ++s) { + const n = t.getExtension(i[s] + e); + if (n) return n; + } + return null; + } + function q9(t) { + const e = { + EXT_texture_filter_anisotropic: Y9(t, "EXT_texture_filter_anisotropic"), + EXT_color_buffer_half_float: Y9(t, "EXT_color_buffer_half_float"), + EXT_color_buffer_float: Y9(t, "EXT_color_buffer_float"), + WEBGL_compressed_texture_etc1: Y9(t, "WEBGL_compressed_texture_etc1"), + WEBGL_compressed_texture_etc: Y9(t, "WEBGL_compressed_texture_etc"), + WEBGL_compressed_texture_pvrtc: Y9(t, "WEBGL_compressed_texture_pvrtc"), + WEBGL_compressed_texture_astc: Y9(t, "WEBGL_compressed_texture_astc"), + WEBGL_compressed_texture_s3tc: Y9(t, "WEBGL_compressed_texture_s3tc"), + WEBGL_compressed_texture_s3tc_srgb: Y9(t, "WEBGL_compressed_texture_s3tc_srgb"), + WEBGL_debug_shaders: Y9(t, "WEBGL_debug_shaders"), + WEBGL_lose_context: Y9(t, "WEBGL_lose_context"), + WEBGL_debug_renderer_info: Y9(t, "WEBGL_debug_renderer_info"), + OES_texture_half_float_linear: Y9(t, "OES_texture_half_float_linear"), + OES_texture_float_linear: Y9(t, "OES_texture_float_linear"), + WEBGL_multi_draw: null, + useVAO: !0 + }; + Po.os !== Ro.ANDROID && Po.os !== Ro.IOS && (e.WEBGL_multi_draw = Y9(t, "WEBGL_multi_draw")); + return e; + } + class K9 extends Lr { + constructor(...t) { + super(...t); + this.stateCache = new j9; + this.nullTex2D = null; + this.nullTexCube = null; + this._canvas = null; + this._webGL2ContextLostHandler = null; + this._extensions = null; + } + get extensions() { + return this._extensions; + } + initialize(t) { + this._canvas = t.windowHandle; + this._webGL2ContextLostHandler = this._onWebGLContextLost.bind(this); + this._canvas.addEventListener(W9, this._onWebGLContextLost); + const e = J7.instance.gl; + this.stateCache.initialize(J7.instance.capabilities.maxTextureUnits, J7.instance.capabilities.maxUniformBufferBindings, J7.instance.capabilities.maxVertexAttributes); + this._extensions = q9(e); + !function(t) { + t.activeTexture(t.TEXTURE0); + t.pixelStorei(t.PACK_ALIGNMENT, 1); + t.pixelStorei(t.UNPACK_ALIGNMENT, 1); + t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL, !1); + t.bindFramebuffer(t.FRAMEBUFFER, null); + t.enable(t.SCISSOR_TEST); + t.enable(t.CULL_FACE); + t.cullFace(t.BACK); + t.frontFace(t.CCW); + t.polygonOffset(0, 0); + t.enable(t.DEPTH_TEST); + t.depthMask(!0); + t.depthFunc(t.LESS); + t.stencilFuncSeparate(t.FRONT, t.ALWAYS, 1, 65535); + t.stencilOpSeparate(t.FRONT, t.KEEP, t.KEEP, t.KEEP); + t.stencilMaskSeparate(t.FRONT, 65535); + t.stencilFuncSeparate(t.BACK, t.ALWAYS, 1, 65535); + t.stencilOpSeparate(t.BACK, t.KEEP, t.KEEP, t.KEEP); + t.stencilMaskSeparate(t.BACK, 65535); + t.disable(t.STENCIL_TEST); + t.disable(t.SAMPLE_ALPHA_TO_COVERAGE); + t.disable(t.BLEND); + t.blendEquationSeparate(t.FUNC_ADD, t.FUNC_ADD); + t.blendFuncSeparate(t.ONE, t.ZERO, t.ONE, t.ZERO); + t.colorMask(!0, !0, !0, !0); + t.blendColor(0, 0, 0, 0); + }(e); + const i = bs.RGBA8; + let s = bs.DEPTH_STENCIL; + const n = e.getParameter(e.DEPTH_BITS); + const r = e.getParameter(e.STENCIL_BITS); + n && r ? s = bs.DEPTH_STENCIL : n && (s = bs.DEPTH); + this._colorTexture = new X9; + this._colorTexture.initAsSwapchainTexture({ + swapchain: this, + format: i, + width: t.width, + height: t.height + }); + this._depthStencilTexture = new X9; + this._depthStencilTexture.initAsSwapchainTexture({ + swapchain: this, + format: s, + width: t.width, + height: t.height + }); + this.nullTex2D = J7.instance.createTexture(new xn(xs.TEX2D, ws.SAMPLED, bs.RGBA8, 2, 2, Rs.NONE)); + this.nullTexCube = J7.instance.createTexture(new xn(xs.CUBE, ws.SAMPLED, bs.RGBA8, 2, 2, Rs.NONE, 6)); + const o = new mn; + o.texExtent.width = 2; + o.texExtent.height = 2; + const a = new Uint8Array(this.nullTex2D.size); + a.fill(0); + J7.instance.copyBuffersToTexture([ a ], this.nullTex2D, [ o ]); + o.texSubres.layerCount = 6; + J7.instance.copyBuffersToTexture([ a, a, a, a, a, a ], this.nullTexCube, [ o ]); + } + destroy() { + if (this._canvas && this._webGL2ContextLostHandler) { + this._canvas.removeEventListener(W9, this._webGL2ContextLostHandler); + this._webGL2ContextLostHandler = null; + } + if (this.nullTex2D) { + this.nullTex2D.destroy(); + this.nullTex2D = null; + } + if (this.nullTexCube) { + this.nullTexCube.destroy(); + this.nullTexCube = null; + } + this._extensions = null; + this._canvas = null; + } + resize(t, e, i) { + if (this._colorTexture.width !== t || this._colorTexture.height !== e) { + R(`Resizing swapchain: ${t}x${e}`); + this._canvas.width = t; + this._canvas.height = e; + this._colorTexture.resize(t, e); + this._depthStencilTexture.resize(t, e); + } + } + _onWebGLContextLost(t) { + N(11e3); + C(t); + } + } + class J9 extends Nr { + constructor(...t) { + super(...t); + this._swapchain = null; + this._context = null; + this._bindingMappings = null; + this._textureExclusive = new Array(bs.COUNT); + } + get gl() { + return this._context; + } + get extensions() { + return this._swapchain.extensions; + } + get stateCache() { + return this._swapchain.stateCache; + } + get nullTex2D() { + return this._swapchain.nullTex2D; + } + get nullTexCube() { + return this._swapchain.nullTexCube; + } + get textureExclusive() { + return this._textureExclusive; + } + get bindingMappings() { + return this._bindingMappings; + } + initialize(t) { + J7.setInstance(this); + this._gfxAPI = fs.WEBGL2; + const e = this._bindingMappingInfo = t.bindingMappingInfo; + const i = []; + const s = []; + const n = e.setIndices[0]; + i[n] = 0; + s[n] = 0; + for (let t = 1; t < e.setIndices.length; ++t) { + const n = e.setIndices[t]; + const r = e.setIndices[t - 1]; + i[n] = e.maxBlockCounts[r] + i[r]; + s[n] = e.maxSamplerTextureCounts[r] + s[r]; + } + for (let t = 0; t < e.setIndices.length; ++t) { + const i = e.setIndices[t]; + s[i] -= e.maxBlockCounts[i]; + } + this._bindingMappings = { + blockOffsets: i, + samplerTextureOffsets: s, + flexibleSet: e.setIndices[e.setIndices.length - 1] + }; + const r = this._context = function(t) { + let e = null; + try { + const i = { + alpha: pe.ENABLE_TRANSPARENT_CANVAS, + antialias: pe.ENABLE_WEBGL_ANTIALIAS, + depth: !0, + stencil: !0, + premultipliedAlpha: !1, + preserveDrawingBuffer: !1, + powerPreference: "default", + failIfMajorPerformanceCaveat: !1 + }; + e = t.getContext("webgl2", i); + } catch (t) { + return null; + } + return e; + }(Nr.canvas); + if (!r) { + console.error("This device does not support WebGL."); + return !1; + } + this._queue = this.createQueue(new ir(Qs.GRAPHICS)); + this._cmdBuff = this.createCommandBuffer(new er(this._queue)); + this._caps.maxVertexAttributes = r.getParameter(r.MAX_VERTEX_ATTRIBS); + this._caps.maxVertexUniformVectors = r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS); + this._caps.maxFragmentUniformVectors = r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS); + this._caps.maxTextureUnits = r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS); + this._caps.maxVertexTextureUnits = r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS); + this._caps.maxUniformBufferBindings = r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS); + this._caps.maxUniformBlockSize = r.getParameter(r.MAX_UNIFORM_BLOCK_SIZE); + this._caps.maxTextureSize = r.getParameter(r.MAX_TEXTURE_SIZE); + this._caps.maxCubeMapTextureSize = r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE); + this._caps.uboOffsetAlignment = r.getParameter(r.UNIFORM_BUFFER_OFFSET_ALIGNMENT); + const o = r.getSupportedExtensions(); + let a = ""; + if (o) for (const t of o) a += `${t} `; + const l = q9(r); + if (l.WEBGL_debug_renderer_info) { + this._renderer = r.getParameter(l.WEBGL_debug_renderer_info.UNMASKED_RENDERER_WEBGL); + this._vendor = r.getParameter(l.WEBGL_debug_renderer_info.UNMASKED_VENDOR_WEBGL); + } else { + this._renderer = r.getParameter(r.RENDERER); + this._vendor = r.getParameter(r.VENDOR); + } + const h = r.getParameter(r.VERSION); + this._features.fill(!1); + this.initFormatFeatures(l); + this._features[ys.ELEMENT_INDEX_UINT] = !0; + this._features[ys.INSTANCED_ARRAYS] = !0; + this._features[ys.MULTIPLE_RENDER_TARGETS] = !0; + this._features[ys.BLEND_MINMAX] = !0; + let c = ""; + this.getFormatFeatures(bs.ETC_RGB8) && (c += "etc1 "); + this.getFormatFeatures(bs.ETC2_RGB8) && (c += "etc2 "); + this.getFormatFeatures(bs.BC1) && (c += "dxt "); + this.getFormatFeatures(bs.PVRTC_RGB2) && (c += "pvrtc "); + this.getFormatFeatures(bs.ASTC_RGBA_4X4) && (c += "astc "); + R("WebGL2 device initialized."); + R(`RENDERER: ${this._renderer}`); + R(`VENDOR: ${this._vendor}`); + R(`VERSION: ${h}`); + R(`COMPRESSED_FORMAT: ${c}`); + R(`EXTENSIONS: ${a}`); + return !0; + } + destroy() { + if (this._queue) { + this._queue.destroy(); + this._queue = null; + } + if (this._cmdBuff) { + this._cmdBuff.destroy(); + this._cmdBuff = null; + } + const t = this._samplers.values(); + let e = t.next(); + for (;!e.done; ) { + e.value.destroy(); + e = t.next(); + } + this._swapchain = null; + } + flushCommands(t) {} + acquire(t) {} + present() { + const t = this._queue; + this._numDrawCalls = t.numDrawCalls; + this._numInstances = t.numInstances; + this._numTris = t.numTris; + t.clear(); + } + initFormatFeatures(t) { + this._formatFeatures.fill(Is.NONE); + this._textureExclusive.fill(!0); + let e = Is.RENDER_TARGET | Is.SAMPLED_TEXTURE | Is.STORAGE_TEXTURE | Is.LINEAR_FILTER | Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.R8] = e; + this._formatFeatures[bs.RG8] = e; + this._formatFeatures[bs.RGB8] = e; + this._formatFeatures[bs.RGBA8] = e; + e = Is.RENDER_TARGET | Is.SAMPLED_TEXTURE | Is.STORAGE_TEXTURE | Is.LINEAR_FILTER; + this._formatFeatures[bs.R8SN] = e; + this._formatFeatures[bs.RG8SN] = e; + this._formatFeatures[bs.RGB8SN] = e; + this._formatFeatures[bs.RGBA8SN] = e; + this._formatFeatures[bs.R5G6B5] = e; + this._formatFeatures[bs.RGBA4] = e; + this._formatFeatures[bs.RGB5A1] = e; + this._formatFeatures[bs.RGB10A2] = e; + this._formatFeatures[bs.SRGB8] = e; + this._formatFeatures[bs.SRGB8_A8] = e; + this._formatFeatures[bs.R11G11B10F] = e; + this._formatFeatures[bs.RGB9E5] = e; + this._formatFeatures[bs.DEPTH] = e; + this._formatFeatures[bs.DEPTH_STENCIL] = e; + this._formatFeatures[bs.RGB10A2UI] = Is.RENDER_TARGET | Is.STORAGE_TEXTURE | Is.SAMPLED_TEXTURE | Is.LINEAR_FILTER; + e = Is.RENDER_TARGET | Is.SAMPLED_TEXTURE | Is.STORAGE_TEXTURE | Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.R16F] = e; + this._formatFeatures[bs.RG16F] = e; + this._formatFeatures[bs.RGB16F] = e; + this._formatFeatures[bs.RGBA16F] = e; + e = Is.STORAGE_TEXTURE | Is.SAMPLED_TEXTURE | Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.R32F] = e; + this._formatFeatures[bs.RG32F] = e; + this._formatFeatures[bs.RGB32F] = e; + this._formatFeatures[bs.RGBA32F] = e; + this._formatFeatures[bs.RGB10A2UI] = Is.RENDER_TARGET | Is.STORAGE_TEXTURE | Is.SAMPLED_TEXTURE | Is.LINEAR_FILTER; + e = Is.RENDER_TARGET | Is.STORAGE_TEXTURE | Is.SAMPLED_TEXTURE | Is.LINEAR_FILTER | Is.VERTEX_ATTRIBUTE; + this._formatFeatures[bs.R8I] = e; + this._formatFeatures[bs.R8UI] = e; + this._formatFeatures[bs.R16I] = e; + this._formatFeatures[bs.R16UI] = e; + this._formatFeatures[bs.R32I] = e; + this._formatFeatures[bs.R32UI] = e; + this._formatFeatures[bs.RG8I] = e; + this._formatFeatures[bs.RG8UI] = e; + this._formatFeatures[bs.RG16I] = e; + this._formatFeatures[bs.RG16UI] = e; + this._formatFeatures[bs.RG32I] = e; + this._formatFeatures[bs.RG32UI] = e; + this._formatFeatures[bs.RGB8I] = e; + this._formatFeatures[bs.RGB8UI] = e; + this._formatFeatures[bs.RGB16I] = e; + this._formatFeatures[bs.RGB16UI] = e; + this._formatFeatures[bs.RGB32I] = e; + this._formatFeatures[bs.RGB32UI] = e; + this._formatFeatures[bs.RGBA8I] = e; + this._formatFeatures[bs.RGBA8UI] = e; + this._formatFeatures[bs.RGBA16I] = e; + this._formatFeatures[bs.RGBA16UI] = e; + this._formatFeatures[bs.RGBA32I] = e; + this._formatFeatures[bs.RGBA32UI] = e; + this._textureExclusive[bs.R8] = !1; + this._textureExclusive[bs.RG8] = !1; + this._textureExclusive[bs.RGB8] = !1; + this._textureExclusive[bs.R5G6B5] = !1; + this._textureExclusive[bs.RGBA4] = !1; + this._textureExclusive[bs.RGB5A1] = !1; + this._textureExclusive[bs.RGBA8] = !1; + this._textureExclusive[bs.RGB10A2] = !1; + this._textureExclusive[bs.RGB10A2UI] = !1; + this._textureExclusive[bs.SRGB8_A8] = !1; + this._textureExclusive[bs.R8I] = !1; + this._textureExclusive[bs.R8UI] = !1; + this._textureExclusive[bs.R16I] = !1; + this._textureExclusive[bs.R16UI] = !1; + this._textureExclusive[bs.R32I] = !1; + this._textureExclusive[bs.R32UI] = !1; + this._textureExclusive[bs.RG8I] = !1; + this._textureExclusive[bs.RG8UI] = !1; + this._textureExclusive[bs.RG16I] = !1; + this._textureExclusive[bs.RG16UI] = !1; + this._textureExclusive[bs.RG32I] = !1; + this._textureExclusive[bs.RG32UI] = !1; + this._textureExclusive[bs.RGBA8I] = !1; + this._textureExclusive[bs.RGBA8UI] = !1; + this._textureExclusive[bs.RGBA16I] = !1; + this._textureExclusive[bs.RGBA16UI] = !1; + this._textureExclusive[bs.RGBA32I] = !1; + this._textureExclusive[bs.RGBA32UI] = !1; + this._textureExclusive[bs.DEPTH] = !1; + this._textureExclusive[bs.DEPTH_STENCIL] = !1; + if (t.EXT_color_buffer_float) { + this._formatFeatures[bs.R32F] |= Is.RENDER_TARGET; + this._formatFeatures[bs.RG32F] |= Is.RENDER_TARGET; + this._formatFeatures[bs.RGBA32F] |= Is.RENDER_TARGET; + this._textureExclusive[bs.R32F] = !1; + this._textureExclusive[bs.RG32F] = !1; + this._textureExclusive[bs.RGBA32F] = !1; + } + if (t.EXT_color_buffer_half_float) { + this._textureExclusive[bs.R16F] = !1; + this._textureExclusive[bs.RG16F] = !1; + this._textureExclusive[bs.RGBA16F] = !1; + } + if (t.OES_texture_float_linear) { + this._formatFeatures[bs.RGB32F] |= Is.LINEAR_FILTER; + this._formatFeatures[bs.RGBA32F] |= Is.LINEAR_FILTER; + this._formatFeatures[bs.R32F] |= Is.LINEAR_FILTER; + this._formatFeatures[bs.RG32F] |= Is.LINEAR_FILTER; + } + if (t.OES_texture_half_float_linear) { + this._formatFeatures[bs.RGB16F] |= Is.LINEAR_FILTER; + this._formatFeatures[bs.RGBA16F] |= Is.LINEAR_FILTER; + this._formatFeatures[bs.R16F] |= Is.LINEAR_FILTER; + this._formatFeatures[bs.RG16F] |= Is.LINEAR_FILTER; + } + const i = Is.SAMPLED_TEXTURE | Is.LINEAR_FILTER; + t.WEBGL_compressed_texture_etc1 && (this._formatFeatures[bs.ETC_RGB8] = i); + if (t.WEBGL_compressed_texture_etc) { + this._formatFeatures[bs.ETC2_RGB8] = i; + this._formatFeatures[bs.ETC2_RGBA8] = i; + this._formatFeatures[bs.ETC2_SRGB8] = i; + this._formatFeatures[bs.ETC2_SRGB8_A8] = i; + this._formatFeatures[bs.ETC2_RGB8_A1] = i; + this._formatFeatures[bs.ETC2_SRGB8_A1] = i; + } + if (t.WEBGL_compressed_texture_s3tc) { + this._formatFeatures[bs.BC1] = i; + this._formatFeatures[bs.BC1_ALPHA] = i; + this._formatFeatures[bs.BC1_SRGB] = i; + this._formatFeatures[bs.BC1_SRGB_ALPHA] = i; + this._formatFeatures[bs.BC2] = i; + this._formatFeatures[bs.BC2_SRGB] = i; + this._formatFeatures[bs.BC3] = i; + this._formatFeatures[bs.BC3_SRGB] = i; + } + if (t.WEBGL_compressed_texture_pvrtc) { + this._formatFeatures[bs.PVRTC_RGB2] = i; + this._formatFeatures[bs.PVRTC_RGBA2] = i; + this._formatFeatures[bs.PVRTC_RGB4] = i; + this._formatFeatures[bs.PVRTC_RGBA4] = i; + } + if (t.WEBGL_compressed_texture_astc) { + this._formatFeatures[bs.ASTC_RGBA_4X4] = i; + this._formatFeatures[bs.ASTC_RGBA_5X4] = i; + this._formatFeatures[bs.ASTC_RGBA_5X5] = i; + this._formatFeatures[bs.ASTC_RGBA_6X5] = i; + this._formatFeatures[bs.ASTC_RGBA_6X6] = i; + this._formatFeatures[bs.ASTC_RGBA_8X5] = i; + this._formatFeatures[bs.ASTC_RGBA_8X6] = i; + this._formatFeatures[bs.ASTC_RGBA_8X8] = i; + this._formatFeatures[bs.ASTC_RGBA_10X5] = i; + this._formatFeatures[bs.ASTC_RGBA_10X6] = i; + this._formatFeatures[bs.ASTC_RGBA_10X8] = i; + this._formatFeatures[bs.ASTC_RGBA_10X10] = i; + this._formatFeatures[bs.ASTC_RGBA_12X10] = i; + this._formatFeatures[bs.ASTC_RGBA_12X12] = i; + this._formatFeatures[bs.ASTC_SRGBA_4X4] = i; + this._formatFeatures[bs.ASTC_SRGBA_5X4] = i; + this._formatFeatures[bs.ASTC_SRGBA_5X5] = i; + this._formatFeatures[bs.ASTC_SRGBA_6X5] = i; + this._formatFeatures[bs.ASTC_SRGBA_6X6] = i; + this._formatFeatures[bs.ASTC_SRGBA_8X5] = i; + this._formatFeatures[bs.ASTC_SRGBA_8X6] = i; + this._formatFeatures[bs.ASTC_SRGBA_8X8] = i; + this._formatFeatures[bs.ASTC_SRGBA_10X5] = i; + this._formatFeatures[bs.ASTC_SRGBA_10X6] = i; + this._formatFeatures[bs.ASTC_SRGBA_10X8] = i; + this._formatFeatures[bs.ASTC_SRGBA_10X10] = i; + this._formatFeatures[bs.ASTC_SRGBA_12X10] = i; + this._formatFeatures[bs.ASTC_SRGBA_12X12] = i; + } + } + createCommandBuffer(t) { + const e = new (t.type === tn.PRIMARY ? k9 : D9); + e.initialize(t); + return e; + } + createSwapchain(t) { + const e = new K9; + this._swapchain = e; + e.initialize(t); + return e; + } + createBuffer(t) { + const e = new I9; + e.initialize(t); + return e; + } + createTexture(t) { + const e = new X9; + e.initialize(t); + return e; + } + createDescriptorSet(t) { + const e = new q7; + e.initialize(t); + return e; + } + createShader(t) { + const e = new H9; + e.initialize(t); + return e; + } + createInputAssembler(t) { + const e = new O9; + e.initialize(t); + return e; + } + createRenderPass(t) { + const e = new G9; + e.initialize(t); + return e; + } + createFramebuffer(t) { + const e = new P9; + e.initialize(t); + return e; + } + createDescriptorSetLayout(t) { + const e = new N9; + e.initialize(t); + return e; + } + createPipelineLayout(t) { + const e = new L9; + e.initialize(t); + return e; + } + createPipelineState(t) { + const e = new V9; + e.initialize(t); + return e; + } + createQueue(t) { + const e = new U9; + e.initialize(t); + return e; + } + getSampler(t) { + const e = qr.computeHash(t); + this._samplers.has(e) || this._samplers.set(e, new z9(t, e)); + return this._samplers.get(e); + } + getSwapchains() { + return [ this._swapchain ]; + } + getGeneralBarrier(t) { + const e = Kr.computeHash(t); + this._generalBarrierss.has(e) || this._generalBarrierss.set(e, new Kr(t, e)); + return this._generalBarrierss.get(e); + } + getTextureBarrier(t) { + const e = Jr.computeHash(t); + this._textureBarriers.has(e) || this._textureBarriers.set(e, new Jr(t, e)); + return this._textureBarriers.get(e); + } + getBufferBarrier(t) { + const e = W7.computeHash(t); + this._bufferBarriers.has(e) || this._bufferBarriers.set(e, new W7(t, e)); + return this._bufferBarriers.get(e); + } + copyBuffersToTexture(t, e, i) { + w9(this, t, e.gpuTexture, i); + } + copyTextureToBuffers(t, e, i) { + !function(t, e, i, s) { + const {gl: n} = t; + const r = t.stateCache; + const o = n.createFramebuffer(); + n.bindFramebuffer(n.FRAMEBUFFER, o); + let a = 0; + let l = 0; + let h = 1; + let c = 1; + if (e.glTarget === n.TEXTURE_2D) for (let t = 0; t < s.length; t++) { + const r = s[t]; + n.framebufferTexture2D(n.FRAMEBUFFER, n.COLOR_ATTACHMENT0, e.glTarget, e.glTexture, r.texSubres.mipLevel); + a = r.texOffset.x; + l = r.texOffset.y; + h = r.texExtent.width; + c = r.texExtent.height; + n.readPixels(a, l, h, c, e.glFormat, e.glType, i[t]); + } else console.error("Unsupported GL texture type, copy texture to buffers failed."); + n.bindFramebuffer(n.FRAMEBUFFER, null); + r.glFramebuffer = null; + n.deleteFramebuffer(o); + }(this, t.gpuTexture, e, i); + } + copyTexImagesToTexture(t, e, i) { + !function(t, e, i, s) { + const {gl: n} = t; + const r = t.stateCache.glTexUnits[t.stateCache.texUnit]; + if (r.glTexture !== i.glTexture) { + n.bindTexture(i.glTarget, i.glTexture); + r.glTexture = i.glTexture; + } + let o = 0; + let a = 0; + switch (i.glTarget) { + case n.TEXTURE_2D: + for (let t = 0; t < s.length; t++) { + const r = s[t]; + n.texSubImage2D(n.TEXTURE_2D, r.texSubres.mipLevel, r.texOffset.x, r.texOffset.y, i.glFormat, i.glType, e[o++]); + } + break; + + case n.TEXTURE_CUBE_MAP: + for (let t = 0; t < s.length; t++) { + const r = s[t]; + const l = r.texSubres.baseArrayLayer + r.texSubres.layerCount; + for (a = r.texSubres.baseArrayLayer; a < l; ++a) n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + a, r.texSubres.mipLevel, r.texOffset.x, r.texOffset.y, i.glFormat, i.glType, e[o++]); + } + break; + + default: + console.error("Unsupported GL texture type, copy buffer to texture failed."); + } + i.flags & Rs.GEN_MIPMAP && n.generateMipmap(i.glTarget); + }(this, t, e.gpuTexture, i); + } + } + t("WebGL2Device", J9); + m.WebGL2Device = J9; + function Z9(t, e, i, s) { + const n = (s.x - i.x) * (t.y - i.y) - (s.y - i.y) * (t.x - i.x); + const r = (e.x - t.x) * (t.y - i.y) - (e.y - t.y) * (t.x - i.x); + const o = (s.y - i.y) * (e.x - t.x) - (s.x - i.x) * (e.y - t.y); + if (0 !== o) { + const t = n / o; + const e = r / o; + if (t >= 0 && t <= 1 && e >= 0 && e <= 1) return !0; + } + return !1; + } + const Q9 = new Qi; + const $9 = new Qi; + const ttt = new Qi; + const ett = new Qi; + function itt(t, e, i) { + const s = i.length; + for (let n = 0; n < s; ++n) { + if (Z9(t, e, i[n], i[(n + 1) % s])) return !0; + } + return !1; + } + function stt(t, e) { + let i = !1; + const s = t.x; + const n = t.y; + const r = e.length; + for (let t = 0, o = r - 1; t < r; o = t++) { + const r = e[t].x; + const a = e[t].y; + const l = e[o].x; + const h = e[o].y; + a > n != h > n && s < (l - r) * (n - a) / (h - a) + r && (i = !i); + } + return i; + } + function ntt(t, e, i, s) { + let n = i.x - e.x; + let r = i.y - e.y; + const o = n * n + r * r; + const a = ((t.x - e.x) * n + (t.y - e.y) * r) / o; + let l; + l = s ? o ? a < 0 ? e : a > 1 ? i : Q9.set(e.x + a * n, e.y + a * r) : e : Q9.set(e.x + a * n, e.y + a * r); + n = t.x - l.x; + r = t.y - l.y; + return Math.sqrt(n * n + r * r); + } + class rtt {} + t("Intersection2D", rtt); + rtt.lineLine = Z9; + rtt.lineRect = function(t, e, i) { + const s = Q9.set(i.x, i.y); + const n = $9.set(i.x, i.yMax); + const r = ttt.set(i.xMax, i.yMax); + const o = ett.set(i.xMax, i.y); + return !!Z9(t, e, s, n) || (!!Z9(t, e, n, r) || (!!Z9(t, e, r, o) || !!Z9(t, e, o, s))); + }; + rtt.linePolygon = itt; + rtt.rectRect = function(t, e) { + const i = t.x; + const s = t.y; + const n = t.x + t.width; + const r = t.y + t.height; + const o = e.x; + const a = e.y; + const l = e.x + e.width; + const h = e.y + e.height; + return i <= l && n >= o && s <= h && r >= a; + }; + rtt.rectPolygon = function(t, e) { + const i = Q9.set(t.x, t.y); + const s = $9.set(t.x, t.yMax); + const n = ttt.set(t.xMax, t.yMax); + const r = ett.set(t.xMax, t.y); + if (itt(i, s, e)) return !0; + if (itt(s, n, e)) return !0; + if (itt(n, r, e)) return !0; + if (itt(r, i, e)) return !0; + for (let i = 0, s = e.length; i < s; ++i) if (t.contains(e[i])) return !0; + return !!stt(i, e) || (!!stt(s, e) || (!!stt(n, e) || !!stt(r, e))); + }; + rtt.rectCircle = function(t, e, i) { + const s = e.x; + const n = e.y; + const r = t.x; + const o = t.y; + const a = t.width; + const l = t.height; + let h = s; + let c = n; + s < r ? h = r : s > r + a && (h = r + a); + n < o ? c = o : n > o + l && (c = o + l); + const u = s - h; + const _ = n - c; + return Math.sqrt(u * u + _ * _) <= i; + }; + rtt.polygonPolygon = function(t, e) { + let i; + let s; + for (i = 0, s = t.length; i < s; ++i) { + if (itt(t[i], t[(i + 1) % s], e)) return !0; + } + for (i = 0, s = e.length; i < s; ++i) if (stt(e[i], t)) return !0; + for (i = 0, s = t.length; i < s; ++i) if (stt(t[i], e)) return !0; + return !1; + }; + rtt.circleCircle = function(t, e, i, s) { + return Qi.distance(t, i) < e + s; + }; + rtt.polygonCircle = function(t, e, i) { + const s = e; + if (stt(s, t)) return !0; + for (let e = 0, n = t.length; e < n; e++) { + if (ntt(s, 0 === e ? t[t.length - 1] : t[e - 1], t[e], !0) < i) return !0; + } + return !1; + }; + rtt.pointInPolygon = stt; + rtt.pointLineDistance = ntt; + var ott, att, ltt, htt, ctt, utt, _tt, dtt, ptt, mtt, ftt, gtt, ytt, btt, Stt; + let Att = function(e) { + return t({ + Billboard: e, + BillboardComponent: e + }), e; + }((ott = Ul("cc.Billboard"), att = sh(), ltt = $l(), htt = Th(LC), ctt = Th(LC), + utt = lh(), _tt = lh(), dtt = lh(), ptt = lh(), ott(mtt = att(mtt = ltt(mtt = Ql(mtt = (ftt = class extends Qc { + get texture() { + return this._texture; + } + set texture(t) { + this._texture = t; + this._material && this._material.setProperty("mainTexture", t); + } + get height() { + return this._height; + } + set height(t) { + this._height = t; + if (this._material) { + this._uniform.y = t; + this._material.setProperty("cc_size_rotation", this._uniform); + } + } + get width() { + return this._width; + } + set width(t) { + this._width = t; + if (this._material) { + this._uniform.x = t; + this._material.setProperty("cc_size_rotation", this._uniform); + } + } + get rotation() { + return Math.round(100 * fi(this._rotation)) / 100; + } + set rotation(t) { + this._rotation = mi(t); + if (this._material) { + this._uniform.z = this._rotation; + this._material.setProperty("cc_size_rotation", this._uniform); + } + } + constructor() { + super(); + Ml(this, "_texture", gtt, this); + Ml(this, "_height", ytt, this); + Ml(this, "_width", btt, this); + Ml(this, "_rotation", Stt, this); + this._model = null; + this._mesh = null; + this._material = null; + this._uniform = new is(1, 1, 0, 0); + } + onLoad() { + this.createModel(); + } + onEnable() { + this.attachToScene(); + this._model.enabled = !0; + this.width = this._width; + this.height = this._height; + this.rotation = this.rotation; + this.texture = this.texture; + } + onDisable() { + this.detachFromScene(); + } + attachToScene() { + if (this._model && this.node && this.node.scene) { + this._model.scene && this.detachFromScene(); + this._getRenderScene().addModel(this._model); + } + } + detachFromScene() { + this._model && this._model.scene && this._model.scene.removeModel(this._model); + } + createModel() { + this._mesh = DI({ + primitiveMode: Xs.TRIANGLE_LIST, + positions: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], + uvs: [ 0, 0, 1, 0, 0, 1, 1, 1 ], + colors: [ Bi.WHITE.r, Bi.WHITE.g, Bi.WHITE.b, Bi.WHITE.a, Bi.WHITE.r, Bi.WHITE.g, Bi.WHITE.b, Bi.WHITE.a, Bi.WHITE.r, Bi.WHITE.g, Bi.WHITE.b, Bi.WHITE.a, Bi.WHITE.r, Bi.WHITE.g, Bi.WHITE.b, Bi.WHITE.a ], + attributes: [ new Vn(cr.ATTR_POSITION, bs.RGB32F), new Vn(cr.ATTR_TEX_COORD, bs.RG32F), new Vn(cr.ATTR_COLOR, bs.RGBA8UI, !0) ], + indices: [ 0, 1, 2, 1, 2, 3 ] + }, void 0, { + calculateBounds: !1 + }); + const t = this._model = m.director.root.createModel(wA, this.node); + t.node = t.transform = this.node; + if (null == this._material) { + this._material = new hm; + this._material.copy(xR.get("default-billboard-material")); + } + t.initSubModel(0, this._mesh.renderingSubMeshes[0], this._material); + } + }, gtt = Bl(ftt.prototype, "_texture", [ htt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Bl(ftt.prototype, "texture", [ ctt, utt ], Object.getOwnPropertyDescriptor(ftt.prototype, "texture"), ftt.prototype), + ytt = Bl(ftt.prototype, "_height", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Bl(ftt.prototype, "height", [ _tt ], Object.getOwnPropertyDescriptor(ftt.prototype, "height"), ftt.prototype), + btt = Bl(ftt.prototype, "_width", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Bl(ftt.prototype, "width", [ dtt ], Object.getOwnPropertyDescriptor(ftt.prototype, "width"), ftt.prototype), + Stt = Bl(ftt.prototype, "_rotation", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Bl(ftt.prototype, "rotation", [ ptt ], Object.getOwnPropertyDescriptor(ftt.prototype, "rotation"), ftt.prototype), + ftt)) || mtt) || mtt) || mtt) || mtt)); + const Ttt = [ new Vn(cr.ATTR_POSITION, bs.RGB32F), new Vn(cr.ATTR_TEX_COORD, bs.RGBA32F), new Vn(cr.ATTR_TEX_COORD1, bs.RGB32F), new Vn(cr.ATTR_COLOR, bs.RGBA8, !0) ]; + const vtt = new Pi; + const Ett = new Pi; + class Ctt extends wA { + constructor() { + super(); + this._capacity = void 0; + this._vertSize = 0; + this._vBuffer = null; + this._vertAttrsFloatCount = 0; + this._vdataF32 = null; + this._vdataUint32 = null; + this._iaInfo = void 0; + this._iaInfoBuffer = void 0; + this._subMeshData = null; + this._vertCount = 0; + this._indexCount = 0; + this._material = null; + this._registerListeners(); + this.type = xA.LINE; + this._capacity = 100; + this._iaInfo = new Cn([ new vn ]); + this._iaInfoBuffer = this._device.createBuffer(new An(Ts.INDIRECT, Cs.DEVICE, mr, mr)); + } + setCapacity(t) { + this._capacity = t; + this.createBuffer(); + } + createBuffer() { + this._vertSize = 0; + for (const t of Ttt) { + t.offset = this._vertSize; + this._vertSize += ur[t.format].size; + } + this._vertAttrsFloatCount = this._vertSize / 4; + this._vBuffer = this.createSubMeshData(); + this._vdataF32 = new Float32Array(this._vBuffer); + this._vdataUint32 = new Uint32Array(this._vBuffer); + } + updateMaterial(t) { + this._material = t; + super.setSubModelMaterial(0, t); + } + createSubMeshData() { + this._subMeshData && this.destroySubMeshData(); + this._vertCount = 2; + this._indexCount = 6; + const t = this._device.createBuffer(new An(Ts.VERTEX | Ts.TRANSFER_DST, Cs.DEVICE, this._vertSize * this._capacity * this._vertCount, this._vertSize)); + const e = new ArrayBuffer(this._vertSize * this._capacity * this._vertCount); + t.update(e); + const i = new Uint16Array((this._capacity - 1) * this._indexCount); + let s = 0; + for (let t = 0; t < this._capacity - 1; ++t) { + const e = 2 * t; + i[s++] = e; + i[s++] = e + 1; + i[s++] = e + 2; + i[s++] = e + 3; + i[s++] = e + 2; + i[s++] = e + 1; + } + const n = this._device.createBuffer(new An(Ts.INDEX | Ts.TRANSFER_DST, Cs.DEVICE, (this._capacity - 1) * this._indexCount * Uint16Array.BYTES_PER_ELEMENT, Uint16Array.BYTES_PER_ELEMENT)); + n.update(i); + this._iaInfo.drawInfos[0].vertexCount = this._capacity * this._vertCount; + this._iaInfo.drawInfos[0].indexCount = (this._capacity - 1) * this._indexCount; + this._iaInfoBuffer.update(this._iaInfo); + this._subMeshData = new fC([ t ], Ttt, Xs.TRIANGLE_LIST, n, this._iaInfoBuffer); + this.initSubModel(0, this._subMeshData, this._material); + return e; + } + addLineVertexData(t, e, i) { + if (t.length > 1) { + let s = 0; + Pi.subtract(vtt, t[1], t[0]); + this._vdataF32[s++] = t[0].x; + this._vdataF32[s++] = t[0].y; + this._vdataF32[s++] = t[0].z; + this._vdataF32[s++] = 0; + this._vdataF32[s++] = e.evaluate(0, 1); + this._vdataF32[s++] = 0; + this._vdataF32[s++] = 0; + this._vdataF32[s++] = vtt.x; + this._vdataF32[s++] = vtt.y; + this._vdataF32[s++] = vtt.z; + this._vdataUint32[s++] = i.evaluate(0, 1)._val; + this._vdataF32[s++] = t[0].x; + this._vdataF32[s++] = t[0].y; + this._vdataF32[s++] = t[0].z; + this._vdataF32[s++] = 1; + this._vdataF32[s++] = e.evaluate(0, 1); + this._vdataF32[s++] = 0; + this._vdataF32[s++] = 1; + this._vdataF32[s++] = vtt.x; + this._vdataF32[s++] = vtt.y; + this._vdataF32[s++] = vtt.z; + this._vdataUint32[s++] = i.evaluate(0, 1)._val; + for (let n = 1; n < t.length - 1; n++) { + Pi.subtract(vtt, t[n - 1], t[n]); + Pi.subtract(Ett, t[n + 1], t[n]); + Pi.subtract(Ett, Ett, vtt); + const r = n / t.length; + this._vdataF32[s++] = t[n].x; + this._vdataF32[s++] = t[n].y; + this._vdataF32[s++] = t[n].z; + this._vdataF32[s++] = 0; + this._vdataF32[s++] = e.evaluate(r, 1); + this._vdataF32[s++] = r; + this._vdataF32[s++] = 0; + this._vdataF32[s++] = Ett.x; + this._vdataF32[s++] = Ett.y; + this._vdataF32[s++] = Ett.z; + this._vdataUint32[s++] = i.evaluate(r, 1)._val; + this._vdataF32[s++] = t[n].x; + this._vdataF32[s++] = t[n].y; + this._vdataF32[s++] = t[n].z; + this._vdataF32[s++] = 1; + this._vdataF32[s++] = e.evaluate(r, 1); + this._vdataF32[s++] = r; + this._vdataF32[s++] = 1; + this._vdataF32[s++] = Ett.x; + this._vdataF32[s++] = Ett.y; + this._vdataF32[s++] = Ett.z; + this._vdataUint32[s++] = i.evaluate(r, 1)._val; + } + Pi.subtract(vtt, t[t.length - 1], t[t.length - 2]); + this._vdataF32[s++] = t[t.length - 1].x; + this._vdataF32[s++] = t[t.length - 1].y; + this._vdataF32[s++] = t[t.length - 1].z; + this._vdataF32[s++] = 0; + this._vdataF32[s++] = e.evaluate(1, 1); + this._vdataF32[s++] = 1; + this._vdataF32[s++] = 0; + this._vdataF32[s++] = vtt.x; + this._vdataF32[s++] = vtt.y; + this._vdataF32[s++] = vtt.z; + this._vdataUint32[s++] = i.evaluate(1, 1)._val; + this._vdataF32[s++] = t[t.length - 1].x; + this._vdataF32[s++] = t[t.length - 1].y; + this._vdataF32[s++] = t[t.length - 1].z; + this._vdataF32[s++] = 1; + this._vdataF32[s++] = e.evaluate(1, 1); + this._vdataF32[s++] = 1; + this._vdataF32[s++] = 1; + this._vdataF32[s++] = vtt.x; + this._vdataF32[s++] = vtt.y; + this._vdataF32[s++] = vtt.z; + this._vdataUint32[s++] = i.evaluate(1, 1)._val; + } + this.updateIA(Math.max(0, t.length - 1)); + } + updateIA(t) { + this._subModels[0].inputAssembler.vertexBuffers[0].update(this._vdataF32); + this._iaInfo.drawInfos[0].firstIndex = 0; + this._iaInfo.drawInfos[0].indexCount = this._indexCount * t; + this._iaInfoBuffer.update(this._iaInfo); + } + destroySubMeshData() { + if (this._subMeshData) { + this._subMeshData.destroy(); + this._subMeshData = null; + } + } + } + var xtt, wtt, Rtt; + const Itt = si.Attr.setClassAttr; + const Mtt = [ [ "mode", "constant", "multiplier" ], [ "mode", "spline", "multiplier" ], [ "mode", "splineMin", "splineMax", "multiplier" ], [ "mode", "constantMin", "constantMax", "multiplier" ] ]; + const Btt = oe({ + Constant: 0, + Curve: 1, + TwoCurves: 2, + TwoConstants: 3 + }); + let Dtt = t("CurveRange", Ul("cc.CurveRange")(xtt = (Rtt = wtt = class { + get curve() { + var t; + return null !== (t = this._curve) && void 0 !== t ? t : this._curve = new Op(this.spline); + } + set curve(t) { + this._curve = t; + this.spline = t._internalCurve; + } + get curveMin() { + var t; + return null !== (t = this._curveMin) && void 0 !== t ? t : this._curveMin = new Op(this.splineMin); + } + set curveMin(t) { + this._curveMin = t; + this.splineMin = t._internalCurve; + } + get curveMax() { + var t; + return null !== (t = this._curveMax) && void 0 !== t ? t : this._curveMax = new Op(this.splineMax); + } + set curveMax(t) { + this._curveMax = t; + this.splineMax = t._internalCurve; + } + constructor() { + this.mode = Btt.Constant; + this.spline = Fp(); + this.splineMin = Fp(); + this.splineMax = Fp(); + this.constant = 0; + this.constantMin = 0; + this.constantMax = 0; + this.multiplier = 1; + } + evaluate(t, e) { + switch (this.mode) { + default: + case Btt.Constant: + return this.constant; + + case Btt.Curve: + return this.spline.evaluate(t) * this.multiplier; + + case Btt.TwoCurves: + return pi(this.splineMin.evaluate(t), this.splineMax.evaluate(t), e) * this.multiplier; + + case Btt.TwoConstants: + return pi(this.constantMin, this.constantMax, e); + } + } + getMax() { + switch (this.mode) { + default: + case Btt.Constant: + return this.constant; + + case Btt.Curve: + return this.multiplier; + + case Btt.TwoConstants: + return this.constantMax; + + case Btt.TwoCurves: + return this.multiplier; + } + } + _onBeforeSerialize(t) { + return Mtt[this.mode]; + } + }, wtt.Mode = Btt, Rtt)) || xtt); + si.fastDefine("cc.CurveRange", Dtt, { + multiplier: 1, + constantMax: 0, + constantMin: 0, + constant: 0, + mode: Btt.Constant, + splineMax: Object.freeze(Fp()), + splineMin: Object.freeze(Fp()), + spline: Object.freeze(Fp()) + }); + Itt(Dtt, "multiplier", "visible", !0); + Itt(Dtt, "constantMax", "visible", !0); + Itt(Dtt, "constantMin", "visible", !0); + Itt(Dtt, "constant", "visible", !0); + Itt(Dtt, "mode", "type", "Enum"); + Itt(Dtt, "mode", "enumList", oe.getList(Btt)); + Itt(Dtt, "mode", "visible", !0); + Itt(Dtt, "splineMax", "type", "Object"); + Itt(Dtt, "splineMax", "ctor", Od); + Itt(Dtt, "splineMax", "visible", !0); + Itt(Dtt, "splineMin", "type", "Object"); + Itt(Dtt, "splineMin", "ctor", Od); + Itt(Dtt, "splineMin", "visible", !0); + Itt(Dtt, "spline", "type", "Object"); + Itt(Dtt, "spline", "ctor", Od); + Itt(Dtt, "spline", "visible", !0); + function Ptt(t, e, i) { + switch (t.mode) { + case Btt.Constant: + return t.constant; + + case Btt.Curve: + return t.spline.evaluate(e) * t.multiplier; + + case Btt.TwoCurves: + return 0 === i ? t.splineMin.evaluate(e) * t.multiplier : t.splineMax.evaluate(e) * t.multiplier; + + case Btt.TwoConstants: + return 0 === i ? t.constantMin : t.constantMax; + + default: + return 0; + } + } + function Ott(t) { + switch (t.mode) { + case Btt.TwoConstants: + case Btt.TwoCurves: + return 2; + + default: + return 1; + } + } + function Ntt(t, e, i, s) { + if (null === t || i !== t.width || s !== t.height) { + t && t.destroy(); + t = function(t, e, i) { + const s = new IC({ + width: e, + height: i, + _data: t, + _compressed: !1, + format: Jp.RGBA32F + }); + const n = new LC; + n.setFilters(Qp.NEAREST, Qp.NEAREST); + n.setMipFilter(Qp.NONE); + n.setWrapMode(Zp.CLAMP_TO_EDGE, Zp.CLAMP_TO_EDGE, Zp.CLAMP_TO_EDGE); + n.image = s; + return n; + }(e, i, s); + } else t.uploadData(e); + return t; + } + function Ltt(t, e, i, s, n, r, o) { + const a = Math.max(Ott(s), Ott(n), Ott(r)); + const l = i * a * 4; + null !== e && e.length === l || (e = new Float32Array(i * a * 4)); + const h = [ s, n, r ]; + const c = 1 / (i - 1); + for (let t = 0; t < a; t++) for (let s = 0; s < 3; s++) { + const n = h[s]; + let r = 0; + let a = 0; + for (let l = 0; l < i; l++) { + const h = Ptt(n, c * l, t); + if (o) a = h; else { + r += h; + a = r / (l + 1); + } + e[4 * (t * i + l) + s] = a; + } + } + return { + texture: Ntt(t, e, i, a), + texdata: e + }; + } + const Ftt = oe({ + Blend: 0, + Fixed: 1 + }); + class Vtt { + constructor() { + this.color = Bi.WHITE.clone(); + this.time = 0; + } + } + t("ColorKey", Vtt); + si.fastDefine("cc.ColorKey", Vtt, { + color: Bi.WHITE.clone(), + time: 0 + }); + si.Attr.setClassAttr(Vtt, "color", "visible", !0); + si.Attr.setClassAttr(Vtt, "time", "visible", !0); + class ktt { + constructor() { + this.alpha = 1; + this.time = 0; + } + } + t("AlphaKey", ktt); + si.fastDefine("cc.AlphaKey", ktt, { + alpha: 1, + time: 0 + }); + si.Attr.setClassAttr(ktt, "alpha", "visible", !0); + si.Attr.setClassAttr(ktt, "time", "visible", !0); + class Utt { + constructor() { + this.colorKeys = new Array; + this.alphaKeys = new Array; + this.mode = Ftt.Blend; + this._color = void 0; + this._color = Bi.WHITE.clone(); + } + setKeys(t, e) { + this.colorKeys = t; + this.alphaKeys = e; + } + sortKeys() { + this.colorKeys.length > 1 && this.colorKeys.sort(((t, e) => t.time - e.time)); + this.alphaKeys.length > 1 && this.alphaKeys.sort(((t, e) => t.time - e.time)); + } + evaluate(t) { + this.getRGB(t); + this._color._set_a_unsafe(this.getAlpha(t)); + return this._color; + } + randomColor() { + const t = this.colorKeys[Math.trunc(Math.random() * this.colorKeys.length)]; + const e = this.alphaKeys[Math.trunc(Math.random() * this.alphaKeys.length)]; + this._color.set(t.color); + this._color._set_a_unsafe(e.alpha); + return this._color; + } + getRGB(t) { + if (this.colorKeys.length > 1) { + t = Ei(t, 1); + for (let e = 1; e < this.colorKeys.length; ++e) { + const i = this.colorKeys[e - 1].time; + const s = this.colorKeys[e].time; + if (t >= i && t < s) { + if (this.mode === Ftt.Fixed) return this.colorKeys[e].color; + const n = (t - i) / (s - i); + Bi.lerp(this._color, this.colorKeys[e - 1].color, this.colorKeys[e].color, n); + return this._color; + } + } + const e = this.colorKeys.length - 1; + t < this.colorKeys[0].time ? Bi.lerp(this._color, Bi.BLACK, this.colorKeys[0].color, t / this.colorKeys[0].time) : t > this.colorKeys[e].time && Bi.lerp(this._color, this.colorKeys[e].color, Bi.BLACK, (t - this.colorKeys[e].time) / (1 - this.colorKeys[e].time)); + return this._color; + } + if (1 === this.colorKeys.length) { + this._color.set(this.colorKeys[0].color); + return this._color; + } + this._color.set(Bi.WHITE); + return this._color; + } + getAlpha(t) { + if (this.alphaKeys.length > 1) { + t = Ei(t, 1); + for (let e = 1; e < this.alphaKeys.length; ++e) { + const i = this.alphaKeys[e - 1].time; + const s = this.alphaKeys[e].time; + if (t >= i && t < s) { + if (this.mode === Ftt.Fixed) return this.alphaKeys[e].alpha; + const n = (t - i) / (s - i); + return pi(this.alphaKeys[e - 1].alpha, this.alphaKeys[e].alpha, n); + } + } + const e = this.alphaKeys.length - 1; + return t < this.alphaKeys[0].time ? pi(0, this.alphaKeys[0].alpha, t / this.alphaKeys[0].time) : t > this.alphaKeys[e].time ? pi(this.alphaKeys[e].alpha, 0, (t - this.alphaKeys[e].time) / (1 - this.alphaKeys[e].time)) : 255; + } + return 1 === this.alphaKeys.length ? this.alphaKeys[0].alpha : 255; + } + } + t("Gradient", Utt); + Utt.Mode = Ftt; + si.fastDefine("cc.Gradient", Utt, { + colorKeys: [], + alphaKeys: [], + mode: Ftt.Blend + }); + si.Attr.setClassAttr(Utt, "colorKeys", "visible", !0); + si.Attr.setClassAttr(Utt, "alphaKeys", "visible", !0); + si.Attr.setClassAttr(Utt, "mode", "visible", !0); + var Gtt, ztt, Htt, jtt, Xtt, Wtt, Ytt, qtt, Ktt, Jtt, Ztt, Qtt, $tt, tet, eet, iet, set; + const net = oe({ + Color: 0, + Gradient: 1, + TwoColors: 2, + TwoGradients: 3, + RandomColor: 4 + }); + let ret = t("GradientRange", (Gtt = Ul("cc.GradientRange"), ztt = Th(net), Htt = Th(Utt), + jtt = Th(Utt), Xtt = Th(Utt), Wtt = Th(net), Gtt(Ytt = (qtt = (set = iet = class { + constructor() { + Ml(this, "color", Ktt, this); + Ml(this, "colorMin", Jtt, this); + Ml(this, "colorMax", Ztt, this); + Ml(this, "gradient", Qtt, this); + Ml(this, "gradientMin", $tt, this); + Ml(this, "gradientMax", tet, this); + Ml(this, "_mode", eet, this); + this._color = Bi.WHITE.clone(); + } + get mode() { + return this._mode; + } + set mode(t) { + this._mode = t; + } + evaluate(t, e) { + switch (this._mode) { + case net.Color: + return this.color; + + case net.TwoColors: + Bi.lerp(this._color, this.colorMin, this.colorMax, e); + return this._color; + + case net.RandomColor: + return this.gradient.randomColor(); + + case net.Gradient: + return this.gradient.evaluate(t); + + case net.TwoGradients: + Bi.lerp(this._color, this.gradientMin.evaluate(t), this.gradientMax.evaluate(t), e); + return this._color; + + default: + return this.color; + } + } + _onBeforeSerialize(t) { + return false[this._mode]; + } + }, iet.Mode = net, set), Bl(qtt.prototype, "mode", [ ztt ], Object.getOwnPropertyDescriptor(qtt.prototype, "mode"), qtt.prototype), + Ktt = Bl(qtt.prototype, "color", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Bi.WHITE.clone(); + } + }), Jtt = Bl(qtt.prototype, "colorMin", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Bi.WHITE.clone(); + } + }), Ztt = Bl(qtt.prototype, "colorMax", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Bi.WHITE.clone(); + } + }), Qtt = Bl(qtt.prototype, "gradient", [ Htt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Utt; + } + }), $tt = Bl(qtt.prototype, "gradientMin", [ jtt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Utt; + } + }), tet = Bl(qtt.prototype, "gradientMax", [ Xtt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Utt; + } + }), eet = Bl(qtt.prototype, "_mode", [ Wtt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return net.Color; + } + }), qtt)) || Ytt)); + function oet(t, e, i) { + switch (t.mode) { + case net.Color: + return t.color; + + case net.TwoColors: + return 0 === i ? t.colorMin : t.colorMax; + + case net.RandomColor: + return t.gradient.randomColor(); + + case net.Gradient: + return t.gradient.evaluate(e); + + case net.TwoGradients: + return 0 === i ? t.gradientMin.evaluate(e) : t.gradientMax.evaluate(e); + + default: + return t.color; + } + } + function aet(t, e, i, s) { + const n = function(t) { + switch (t.mode) { + case net.TwoColors: + case net.TwoGradients: + return 2; + + default: + return 1; + } + }(s); + const r = i * n * 4; + null !== e && e.length === r || (e = new Uint8Array(i * n * 4)); + const o = 1 / i; + let a = 0; + for (let t = 0; t < n; t++) for (let n = 0; n < i; n++) { + const i = oet(s, o * n, t); + e[a] = i.r; + e[a + 1] = i.g; + e[a + 2] = i.b; + e[a + 3] = i.a; + a += 4; + } + if (null === t || i !== t.width || n !== t.height) { + t && t.destroy(); + (t = new LC).create(i, n, Jp.RGBA8888); + t.setFilters(Qp.LINEAR, Qp.LINEAR); + t.setWrapMode(Zp.CLAMP_TO_EDGE, Zp.CLAMP_TO_EDGE); + } + t.uploadData(e); + return { + texture: t, + texdata: e + }; + } + var het, cet, uet, _et, det, pet, met, fet, get, yet, bet, Aet, Tet, vet, Eet, Cet, xet, wet, Ret, Iet, Met, Bet, Det, Pet, Oet, Net, Let, Fet, Vet, ket, Uet, Get, zet, Het, jet, Xet, Wet, Yet, qet, Ket, Jet; + const Zet = { + parent: null, + owner: null, + subModelIdx: 0 + }; + const Qet = { + CC_USE_WORLD_SPACE: !1 + }; + let $et = function(e) { + return t({ + Line: e, + LineComponent: e + }), e; + }((het = Ul("cc.Line"), cet = sh(), uet = $l(), _et = Th(LC), det = Th(LC), pet = ph(), + met = lh(), fet = Th(hm), get = ph(), yet = lh(), bet = ph(), Aet = lh(), Tet = Th([ Pi ]), + vet = Th([ Pi ]), Eet = ph(), Cet = lh(), xet = Th(Dtt), wet = Th(Dtt), Ret = hh(), + Iet = ph(), Met = lh(), Bet = Th(Qi), Det = ph(), Pet = lh(), Oet = Th(Qi), Net = ph(), + Let = lh(), Fet = Th(ret), Vet = Th(ret), ket = ph(), Uet = lh(), het(Get = cet(Get = uet(Get = Ql(Get = (zet = class extends Qc { + get texture() { + return this._texture; + } + set texture(t) { + this._texture = t; + this._materialInstance && this._materialInstance.setProperty("mainTexture", t); + } + get material() { + return this._material; + } + set material(t) { + this._material = t; + } + get worldSpace() { + return this._worldSpace; + } + set worldSpace(t) { + this._worldSpace = t; + if (this._materialInstance) { + Qet.CC_USE_WORLD_SPACE = this.worldSpace; + this._materialInstance.recompileShaders(Qet); + this._model && this._model.setSubModelMaterial(0, this._materialInstance); + } + } + get positions() { + return this._positions; + } + set positions(t) { + this._positions = t; + this._model && this._model.addLineVertexData(this._positions, this._width, this._color); + } + get width() { + return this._width; + } + set width(t) { + this._width = t; + this._model && this._model.addLineVertexData(this._positions, this._width, this._color); + } + get tile() { + return this._tile; + } + set tile(t) { + this._tile.set(t); + if (this._materialInstance) { + this._tile_offset.x = this._tile.x; + this._tile_offset.y = this._tile.y; + this._materialInstance.setProperty("mainTiling_Offset", this._tile_offset); + } + } + get offset() { + return this._offset; + } + set offset(t) { + this._offset.set(t); + if (this._materialInstance) { + this._tile_offset.z = this._offset.x; + this._tile_offset.w = this._offset.y; + this._materialInstance.setProperty("mainTiling_Offset", this._tile_offset); + } + } + get color() { + return this._color; + } + set color(t) { + this._color = t; + this._model && this._model.addLineVertexData(this._positions, this._width, this._color); + } + constructor() { + super(); + Ml(this, "_texture", Het, this); + Ml(this, "_material", jet, this); + this._materialInstance = null; + Ml(this, "_worldSpace", Xet, this); + Ml(this, "_positions", Wet, this); + Ml(this, "_width", Yet, this); + Ml(this, "_tile", qet, this); + Ml(this, "_offset", Ket, this); + Ml(this, "_color", Jet, this); + this._model = null; + this._tile_offset = new is; + } + onLoad() { + const t = this._model = m.director.root.createModel(Ctt); + t.node = t.transform = this.node; + if (null === this._material) { + this._material = new hm; + this._material.copy(xR.get("default-trail-material")); + } + if (this._material) { + Qet.CC_USE_WORLD_SPACE = this.worldSpace; + Zet.parent = this._material; + Zet.subModelIdx = 0; + this._materialInstance = new uS(Zet); + Zet.parent = null; + Zet.subModelIdx = 0; + this._materialInstance.recompileShaders(Qet); + } + t.updateMaterial(this._materialInstance); + t.setCapacity(100); + } + onEnable() { + if (this._model) { + this._attachToScene(); + this.texture = this._texture; + this.tile = this._tile; + this.offset = this._offset; + this._model.addLineVertexData(this._positions, this._width, this._color); + } + } + onDisable() { + this._model && this._detachFromScene(); + } + _attachToScene() { + if (this._model && this.node && this.node.scene) { + this._model.scene && this._detachFromScene(); + this._getRenderScene().addModel(this._model); + } + } + _detachFromScene() { + this._model && this._model.scene && this._model.scene.removeModel(this._model); + } + }, Het = Bl(zet.prototype, "_texture", [ _et ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Bl(zet.prototype, "texture", [ det, pet, met ], Object.getOwnPropertyDescriptor(zet.prototype, "texture"), zet.prototype), + jet = Bl(zet.prototype, "_material", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Bl(zet.prototype, "material", [ fet, get, yet ], Object.getOwnPropertyDescriptor(zet.prototype, "material"), zet.prototype), + Xet = Bl(zet.prototype, "_worldSpace", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Bl(zet.prototype, "worldSpace", [ bet, Aet ], Object.getOwnPropertyDescriptor(zet.prototype, "worldSpace"), zet.prototype), + Wet = Bl(zet.prototype, "_positions", [ Tet ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), Bl(zet.prototype, "positions", [ vet, Eet, Cet ], Object.getOwnPropertyDescriptor(zet.prototype, "positions"), zet.prototype), + Yet = Bl(zet.prototype, "_width", [ xet ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), Bl(zet.prototype, "width", [ wet, Ret, Iet, Met ], Object.getOwnPropertyDescriptor(zet.prototype, "width"), zet.prototype), + qet = Bl(zet.prototype, "_tile", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Qi(1, 1); + } + }), Bl(zet.prototype, "tile", [ Bet, Det, Pet ], Object.getOwnPropertyDescriptor(zet.prototype, "tile"), zet.prototype), + Ket = Bl(zet.prototype, "_offset", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Qi(0, 0); + } + }), Bl(zet.prototype, "offset", [ Oet, Net, Let ], Object.getOwnPropertyDescriptor(zet.prototype, "offset"), zet.prototype), + Jet = Bl(zet.prototype, "_color", [ Fet ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new ret; + } + }), Bl(zet.prototype, "color", [ Vet, ket, Uet ], Object.getOwnPropertyDescriptor(zet.prototype, "color"), zet.prototype), + zet)) || Get) || Get) || Get) || Get)); + class tit { + constructor(t) { + this.particleSystem = void 0; + this.position = void 0; + this.velocity = void 0; + this.animatedVelocity = void 0; + this.ultimateVelocity = void 0; + this.angularVelocity = void 0; + this.axisOfRotation = void 0; + this.rotation = void 0; + this.startEuler = void 0; + this.startRotation = void 0; + this.startRotated = void 0; + this.deltaQuat = void 0; + this.deltaMat = void 0; + this.localMat = void 0; + this.startSize = void 0; + this.size = void 0; + this.startColor = void 0; + this.color = void 0; + this.randomSeed = void 0; + this.remainingLifetime = void 0; + this.loopCount = void 0; + this.lastLoop = void 0; + this.trailDelay = void 0; + this.startLifetime = void 0; + this.emitAccumulator0 = void 0; + this.emitAccumulator1 = void 0; + this.frameIndex = void 0; + this.startRow = void 0; + this.particleSystem = t; + this.position = new Pi(0, 0, 0); + this.velocity = new Pi(0, 0, 0); + this.animatedVelocity = new Pi(0, 0, 0); + this.ultimateVelocity = new Pi(0, 0, 0); + this.angularVelocity = new Pi(0, 0, 0); + this.axisOfRotation = new Pi(0, 0, 0); + this.rotation = new Pi(0, 0, 0); + this.startEuler = new Pi(0, 0, 0); + this.startRotation = new Ui; + this.startRotated = !1; + this.deltaQuat = new Ui; + this.deltaMat = new qi; + this.localMat = new qi; + this.startSize = new Pi(0, 0, 0); + this.size = new Pi(0, 0, 0); + this.startColor = Bi.WHITE.clone(); + this.color = Bi.WHITE.clone(); + this.randomSeed = 0; + this.remainingLifetime = 0; + this.loopCount = 0; + this.lastLoop = 0; + this.trailDelay = 0; + this.startLifetime = 0; + this.emitAccumulator0 = 0; + this.emitAccumulator1 = 0; + this.frameIndex = 0; + this.startRow = 0; + } + reset() { + this.rotation.set(0, 0, 0); + this.startEuler.set(0, 0, 0); + this.startRotation.set(0, 0, 0, 1); + this.startRotated = !1; + this.deltaQuat.set(0, 0, 0, 1); + this.deltaMat.identity(); + this.localMat.identity(); + } + } + tit.INDENTIFY_NEG_QUAT = 10; + tit.R2D = 180 / Math.PI; + const eit = "colorModule", iit = "forceModule", sit = "limitModule", nit = "rotationModule", rit = "sizeModule", oit = "velocityModule", ait = "textureModule", lit = "noiseModule"; + const hit = [ "sizeModule", "colorModule", "forceModule", "velocityModule", "limitModule", "rotationModule", "textureModule", "noiseModule" ]; + const cit = [ "_colorOverLifetimeModule", "_shapeModule", "_sizeOvertimeModule", "_velocityOvertimeModule", "_forceOvertimeModule", "_limitVelocityOvertimeModule", "_rotationOvertimeModule", "_textureAnimationModule", "_noiseModule", "_trailModule" ]; + class uit { + constructor() { + this.target = null; + this.needUpdate = !1; + this.needAnimate = !0; + this.name = void 0; + } + bindTarget(t) { + this.target = t; + } + update(t, e) {} + } + const _it = oe({ + World: 0, + Local: 1, + Custom: 2 + }); + const dit = oe({ + Pause: 0, + PauseAndCatchup: 1, + AlwaysSimulate: 2 + }); + const pit = oe({ + World: 0, + Local: 1, + View: 2 + }); + const mit = oe({ + Billboard: 0, + StrecthedBillboard: 1, + HorizontalBillboard: 2, + VerticalBillboard: 3, + Mesh: 4 + }); + const fit = oe({ + Box: 0, + Circle: 1, + Cone: 2, + Sphere: 3, + Hemisphere: 4 + }); + const git = oe({ + Base: 0, + Edge: 1, + Shell: 2, + Volume: 3 + }); + const yit = oe({ + Random: 0, + Loop: 1, + PingPong: 2 + }); + const bit = oe({ + Particles: 0 + }); + const Sit = oe({ + Stretch: 0 + }); + const Ait = 23541, Tit = 39825, vit = 90794, Eit = 212165, Cit = 125292, xit = 197866, wit = 156497, Rit = 984136; + var Iit, Mit, Bit, Dit, Pit, Oit, Nit, Lit; + const Fit = 91041; + let Vit = (Iit = Ul("cc.ColorOvertimeModule"), Mit = ph(), Bit = Th(ret), Dit = ph(), + Iit(Pit = (Oit = class extends uit { + constructor(...t) { + super(...t); + Ml(this, "_enable", Nit, this); + Ml(this, "color", Lit, this); + this.name = eit; + } + get enable() { + return this._enable; + } + set enable(t) { + if (this._enable !== t) { + this._enable = t; + this.target && this.target.enableModule(this.name, t, this); + } + } + animate(t) { + t.color.set(t.startColor); + t.color.multiply(this.color.evaluate(1 - t.remainingLifetime / t.startLifetime, Si(t.randomSeed + Fit))); + } + }, Nit = Bl(Oit.prototype, "_enable", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Bl(Oit.prototype, "enable", [ Mit ], Object.getOwnPropertyDescriptor(Oit.prototype, "enable"), Oit.prototype), + Lit = Bl(Oit.prototype, "color", [ Bit, Yl, Dit ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new ret; + } + }), Oit)) || Pit); + const kit = new Pi(0, 0, -1); + function Uit(t, e, i, s) { + if (e !== t) { + if (t === _it.World) qi.getRotation(s, i); else { + qi.invert(i, i); + qi.getRotation(s, i); + } + return !0; + } + Ui.set(s, 0, 0, 0, 1); + return !1; + } + function Git(t, e) { + Qi.set(t, Math.cos(e), Math.sin(e)); + } + function zit(t) { + const e = yi(-1, 1); + const i = yi(0, 2 * Math.PI); + const s = Math.sqrt(1 - e * e); + const n = s * Math.cos(i); + const r = s * Math.sin(i); + Pi.set(t, n, r, e); + } + function Hit(t, e, i) { + zit(t); + Pi.multiplyScalar(t, t, e + (i - e) * gi()); + } + function jit(t, e, i, s) { + Git(t, s); + t.z = 0; + Pi.multiplyScalar(t, t, e + (i - e) * gi()); + } + function Xit(t) { + for (let e = 0; e < t.length; e++) { + const i = e + bi(0, t.length - e); + const s = t[i]; + t[i] = t[e]; + t[e] = s; + } + } + function Wit() { + let t = yi(-1, 1); + 0 === t && t++; + return n(t); + } + var Yit, qit, Kit, Jit, Zit, Qit, $it, tst, est, ist, sst, nst, rst, ost, ast, lst, hst, cst, ust, _st, dst, pst, mst, fst, gst; + const yst = Eit; + const bst = new Pi; + let Sst = (Yit = Ul("cc.ForceOvertimeModule"), qit = ph(), Kit = Th(Dtt), Jit = hh(), + Zit = ph(), Qit = lh(), $it = Th(Dtt), tst = hh(), est = ph(), ist = lh(), sst = Th(Dtt), + nst = hh(), rst = ph(), ost = lh(), ast = Th(_it), lst = ph(), hst = lh(), Yit(cst = (ust = (gst = class extends uit { + get enable() { + return this._enable; + } + set enable(t) { + if (this._enable !== t) { + this._enable = t; + this.target && this.target.enableModule(this.name, t, this); + } + } + constructor() { + super(); + Ml(this, "_enable", _st, this); + Ml(this, "x", dst, this); + Ml(this, "y", pst, this); + Ml(this, "z", mst, this); + Ml(this, "space", fst, this); + this.randomized = !1; + this.rotation = void 0; + this.needTransform = void 0; + this.name = iit; + this.rotation = new Ui; + this.needTransform = !1; + this.needUpdate = !0; + } + update(t, e) { + this.needTransform = Uit(t, this.space, e, this.rotation); + } + animate(t, e) { + const i = 1 - t.remainingLifetime / t.startLifetime; + const s = Pi.set(bst, this.x.evaluate(i, Si(t.randomSeed + yst)), this.y.evaluate(i, Si(t.randomSeed + yst)), this.z.evaluate(i, Si(t.randomSeed + yst))); + this.needTransform && Pi.transformQuat(s, s, this.rotation); + Pi.scaleAndAdd(t.velocity, t.velocity, s, e); + Pi.copy(t.ultimateVelocity, t.velocity); + } + }, gst), _st = Bl(ust.prototype, "_enable", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Bl(ust.prototype, "enable", [ qit ], Object.getOwnPropertyDescriptor(ust.prototype, "enable"), ust.prototype), + dst = Bl(ust.prototype, "x", [ Kit, Yl, Jit, Zit, Qit ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), pst = Bl(ust.prototype, "y", [ $it, Yl, tst, est, ist ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), mst = Bl(ust.prototype, "z", [ sst, Yl, nst, rst, ost ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), fst = Bl(ust.prototype, "space", [ ast, Yl, lst, hst ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return _it.Local; + } + }), ust)) || cst); + var Ast, Tst, vst, Est, Cst, xst, wst, Rst, Ist, Mst, Bst, Dst, Pst, Ost, Nst, Lst, Fst, Vst, kst, Ust, Gst, zst, Hst, jst, Xst, Wst, Yst, qst, Kst, Jst, Zst, Qst, $st, tnt, ent, int, snt, nnt, rnt, ont; + const ant = Ait; + const lnt = new Pi; + const hnt = new Pi; + let cnt = (Ast = Ul("cc.LimitVelocityOvertimeModule"), Tst = ph(), vst = Th(Dtt), + Est = hh(), Cst = ph(), xst = lh(), wst = rh(), Rst = Th(Dtt), Ist = hh(), Mst = ph(), + Bst = lh(), Dst = rh(), Pst = Th(Dtt), Ost = hh(), Nst = ph(), Lst = lh(), Fst = rh(), + Vst = Th(Dtt), kst = hh(), Ust = ph(), Gst = lh(), zst = rh(), Hst = ph(), jst = lh(), + Xst = ph(), Wst = lh(), Yst = Th(_it), qst = ph(), Kst = lh(), Ast(Jst = (Zst = (ont = class extends uit { + get enable() { + return this._enable; + } + set enable(t) { + if (this._enable !== t) { + this._enable = t; + this.target && this.target.enableModule(this.name, t, this); + } + } + constructor() { + super(); + Ml(this, "_enable", Qst, this); + Ml(this, "limitX", $st, this); + Ml(this, "limitY", tnt, this); + Ml(this, "limitZ", ent, this); + Ml(this, "limit", int, this); + Ml(this, "dampen", snt, this); + Ml(this, "separateAxes", nnt, this); + Ml(this, "space", rnt, this); + this.drag = null; + this.multiplyDragByParticleSize = !1; + this.multiplyDragByParticleVelocity = !1; + this.name = sit; + this.rotation = void 0; + this.needTransform = void 0; + this.rotation = new Ui; + this.needTransform = !1; + this.needUpdate = !0; + } + update(t, e) { + this.needTransform = Uit(t, this.space, e, this.rotation); + } + animate(t, e) { + const i = 1 - t.remainingLifetime / t.startLifetime; + const s = lnt; + if (this.separateAxes) { + Pi.set(hnt, this.limitX.evaluate(i, Si(t.randomSeed + ant)), this.limitY.evaluate(i, Si(t.randomSeed + ant)), this.limitZ.evaluate(i, Si(t.randomSeed + ant))); + this.needTransform && Pi.transformQuat(hnt, hnt, this.rotation); + Pi.set(s, unt(t.ultimateVelocity.x, hnt.x, this.dampen), unt(t.ultimateVelocity.y, hnt.y, this.dampen), unt(t.ultimateVelocity.z, hnt.z, this.dampen)); + } else { + Pi.normalize(s, t.ultimateVelocity); + Pi.multiplyScalar(s, s, unt(t.ultimateVelocity.length(), this.limit.evaluate(i, Si(t.randomSeed + ant)), this.dampen)); + } + Pi.copy(t.ultimateVelocity, s); + } + }, ont), Qst = Bl(Zst.prototype, "_enable", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Bl(Zst.prototype, "enable", [ Tst ], Object.getOwnPropertyDescriptor(Zst.prototype, "enable"), Zst.prototype), + $st = Bl(Zst.prototype, "limitX", [ vst, Yl, Est, Cst, xst, wst ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), tnt = Bl(Zst.prototype, "limitY", [ Rst, Yl, Ist, Mst, Bst, Dst ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), ent = Bl(Zst.prototype, "limitZ", [ Pst, Yl, Ost, Nst, Lst, Fst ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), int = Bl(Zst.prototype, "limit", [ Vst, Yl, kst, Ust, Gst, zst ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), snt = Bl(Zst.prototype, "dampen", [ Yl, Hst, jst ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 3; + } + }), nnt = Bl(Zst.prototype, "separateAxes", [ Yl, Xst, Wst ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), rnt = Bl(Zst.prototype, "space", [ Yst, Yl, qst, Kst ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return _it.Local; + } + }), Zst)) || Jst); + function unt(t, e, i) { + const s = Math.sign(t); + let n = Math.abs(t); + n > e && (n = pi(n, e, i)); + return n * s; + } + var _nt, dnt, pnt, mnt, fnt, gnt, ynt, bnt, Snt, Ant, Tnt, vnt, Ent, Cnt, xnt, wnt, Rnt, Int, Mnt, Bnt, Dnt, Pnt, Ont, Nnt, Lnt; + const Fnt = Cit; + let Vnt = (_nt = Ul("cc.RotationOvertimeModule"), dnt = ph(), pnt = ph(), mnt = lh(), + fnt = Th(Dtt), gnt = hh(), ynt = ph(), bnt = lh(), Snt = rh(), Ant = Th(Dtt), Tnt = hh(), + vnt = ph(), Ent = lh(), Cnt = rh(), xnt = Th(Dtt), wnt = hh(), Rnt = ph(), Int = lh(), + _nt(Mnt = (Bnt = class extends uit { + constructor(...t) { + super(...t); + Ml(this, "_enable", Dnt, this); + Ml(this, "_separateAxes", Pnt, this); + Ml(this, "x", Ont, this); + Ml(this, "y", Nnt, this); + Ml(this, "z", Lnt, this); + this.name = nit; + this._startMat = new qi; + this._matRot = new qi; + this._quatRot = new Ui; + this._otherEuler = new Pi; + } + get enable() { + return this._enable; + } + set enable(t) { + if (this._enable !== t) { + this._enable = t; + this.target && this.target.enableModule(this.name, t, this); + } + } + get separateAxes() { + return this._separateAxes; + } + set separateAxes(t) { + this._separateAxes = t; + } + _processRotation(t, e) { + const i = t.particleSystem.processor.getInfo().renderMode; + i !== mit.Mesh && i === mit.StrecthedBillboard && this._quatRot.set(0, 0, 0, 1); + Ui.normalize(this._quatRot, this._quatRot); + this._quatRot.w < 0 && (this._quatRot.x += tit.INDENTIFY_NEG_QUAT); + } + animate(t, e) { + const i = 1 - t.remainingLifetime / t.startLifetime; + const s = Si(t.randomSeed + Fnt); + const n = t.particleSystem.processor.getInfo().renderMode; + this._separateAxes && n !== mit.VerticalBillboard && n !== mit.HorizontalBillboard ? Ui.fromEuler(t.deltaQuat, this.x.evaluate(i, s) * e * tit.R2D, this.y.evaluate(i, s) * e * tit.R2D, this.z.evaluate(i, s) * e * tit.R2D) : Ui.fromEuler(t.deltaQuat, 0, 0, this.z.evaluate(i, s) * e * tit.R2D); + t.deltaMat = qi.fromQuat(t.deltaMat, t.deltaQuat); + t.localMat = t.localMat.multiply(t.deltaMat); + if (!t.startRotated) { + n !== mit.Mesh && (n === mit.StrecthedBillboard ? t.startEuler.set(0, 0, 0) : n !== mit.Billboard && t.startEuler.set(0, 0, t.startEuler.z)); + Ui.fromEuler(t.startRotation, t.startEuler.x * tit.R2D, t.startEuler.y * tit.R2D, t.startEuler.z * tit.R2D); + t.startRotated = !0; + } + this._startMat = qi.fromQuat(this._startMat, t.startRotation); + this._matRot = this._startMat.multiply(t.localMat); + qi.getRotation(this._quatRot, this._matRot); + this._processRotation(t, tit.R2D); + t.rotation.set(this._quatRot.x, this._quatRot.y, this._quatRot.z); + } + }, Dnt = Bl(Bnt.prototype, "_enable", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Bl(Bnt.prototype, "enable", [ dnt ], Object.getOwnPropertyDescriptor(Bnt.prototype, "enable"), Bnt.prototype), + Pnt = Bl(Bnt.prototype, "_separateAxes", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Bl(Bnt.prototype, "separateAxes", [ pnt, mnt ], Object.getOwnPropertyDescriptor(Bnt.prototype, "separateAxes"), Bnt.prototype), + Ont = Bl(Bnt.prototype, "x", [ fnt, Yl, gnt, mh, ynt, bnt, Snt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), Nnt = Bl(Bnt.prototype, "y", [ Ant, Yl, Tnt, mh, vnt, Ent, Cnt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), Lnt = Bl(Bnt.prototype, "z", [ xnt, Yl, wnt, mh, Rnt, Int ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), Bnt)) || Mnt); + var knt, Unt, Gnt, znt, Hnt, jnt, Xnt, Wnt, Ynt, qnt, Knt, Jnt, Znt, Qnt, $nt, trt, ert, irt, srt, nrt, rrt, ort, art, lrt, hrt, crt, urt, _rt, drt, prt, mrt, frt; + const grt = Tit; + let yrt = (knt = Ul("cc.SizeOvertimeModule"), Unt = ph(), Gnt = ph(), znt = lh(), + Hnt = Th(Dtt), jnt = hh(), Xnt = ph(), Wnt = lh(), Ynt = rh(), qnt = Th(Dtt), Knt = hh(), + Jnt = ph(), Znt = lh(), Qnt = rh(), $nt = Th(Dtt), trt = hh(), ert = ph(), irt = lh(), + srt = rh(), nrt = Th(Dtt), rrt = hh(), ort = ph(), art = lh(), lrt = rh(), knt(hrt = (crt = class extends uit { + constructor(...t) { + super(...t); + Ml(this, "_enable", urt, this); + Ml(this, "separateAxes", _rt, this); + Ml(this, "size", drt, this); + Ml(this, "x", prt, this); + Ml(this, "y", mrt, this); + Ml(this, "z", frt, this); + this.name = rit; + } + get enable() { + return this._enable; + } + set enable(t) { + if (this._enable !== t) { + this._enable = t; + this.target && this.target.enableModule(this.name, t, this); + } + } + animate(t, e) { + if (this.separateAxes) { + const e = 1 - t.remainingLifetime / t.startLifetime; + const i = Si(t.randomSeed + grt); + t.size.x = t.startSize.x * this.x.evaluate(e, i); + t.size.y = t.startSize.y * this.y.evaluate(e, i); + t.size.z = t.startSize.z * this.z.evaluate(e, i); + } else Pi.multiplyScalar(t.size, t.startSize, this.size.evaluate(1 - t.remainingLifetime / t.startLifetime, Si(t.randomSeed + grt))); + } + }, urt = Bl(crt.prototype, "_enable", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Bl(crt.prototype, "enable", [ Unt ], Object.getOwnPropertyDescriptor(crt.prototype, "enable"), crt.prototype), + _rt = Bl(crt.prototype, "separateAxes", [ Yl, Gnt, znt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), drt = Bl(crt.prototype, "size", [ Hnt, Yl, jnt, Xnt, Wnt, Ynt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), prt = Bl(crt.prototype, "x", [ qnt, Yl, Knt, Jnt, Znt, Qnt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), mrt = Bl(crt.prototype, "y", [ $nt, Yl, trt, ert, irt, srt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), frt = Bl(crt.prototype, "z", [ nrt, Yl, rrt, ort, art, lrt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), crt)) || hrt); + var brt, Srt, Art, Trt, vrt, Ert, Crt, xrt, wrt, Rrt, Irt, Mrt, Brt, Drt, Prt, Ort, Nrt, Lrt, Frt, Vrt, krt, Urt, Grt, zrt, Hrt, jrt, Xrt, Wrt, Yrt, qrt, Krt, Jrt, Zrt, Qrt, $rt, tot, eot, iot, sot, not, rot, oot, aot, lot; + const hot = vit; + const cot = oe({ + Grid: 0 + }); + const uot = oe({ + WholeSheet: 0, + SingleRow: 1 + }); + let _ot = (brt = Ul("cc.TextureAnimationModule"), Srt = ql("numTilesX"), Art = ql("numTilesY"), + Trt = ph(), vrt = Th(cot), Ert = Th(cot), Crt = ph(), xrt = lh(), wrt = ph(), Rrt = lh(), + Irt = ph(), Mrt = lh(), Brt = Th(uot), Drt = ph(), Prt = lh(), Ort = Th(Dtt), Nrt = hh(), + Lrt = ph(), Frt = lh(), Vrt = Th(Dtt), krt = hh(), Urt = ph(), Grt = lh(), zrt = ph(), + Hrt = lh(), jrt = ph(), Xrt = lh(), Wrt = ph(), Yrt = lh(), brt(qrt = (Krt = class extends uit { + constructor(...t) { + super(...t); + Ml(this, "_enable", Jrt, this); + Ml(this, "_numTilesX", Zrt, this); + Ml(this, "_numTilesY", Qrt, this); + Ml(this, "_mode", $rt, this); + Ml(this, "animation", tot, this); + Ml(this, "frameOverTime", eot, this); + Ml(this, "startFrame", iot, this); + Ml(this, "cycleCount", sot, this); + Ml(this, "_flipU", not, this); + Ml(this, "_flipV", rot, this); + Ml(this, "_uvChannelMask", oot, this); + Ml(this, "randomRow", aot, this); + Ml(this, "rowIndex", lot, this); + this.name = ait; + } + get enable() { + return this._enable; + } + set enable(t) { + if (this._enable !== t) { + this._enable = t; + if (this.target) { + this.target.updateMaterialParams(); + this.target.enableModule(this.name, t, this); + } + } + } + get mode() { + return this._mode; + } + set mode(t) { + t !== cot.Grid && console.error("particle texture animation's sprites is not supported!"); + } + get numTilesX() { + return this._numTilesX; + } + set numTilesX(t) { + if (this._numTilesX !== t) { + this._numTilesX = t; + this.target.updateMaterialParams(); + } + } + get numTilesY() { + return this._numTilesY; + } + set numTilesY(t) { + if (this._numTilesY !== t) { + this._numTilesY = t; + this.target.updateMaterialParams(); + } + } + get flipU() { + return this._flipU; + } + set flipU(t) { + console.error("particle texture animation's flipU is not supported!"); + } + get flipV() { + return this._flipV; + } + set flipV(t) { + console.error("particle texture animation's flipV is not supported!"); + } + get uvChannelMask() { + return this._uvChannelMask; + } + set uvChannelMask(t) { + console.error("particle texture animation's uvChannelMask is not supported!"); + } + init(t) { + t.startRow = Math.floor(Math.random() * this.numTilesY); + } + animate(t, e) { + const i = 1 - t.remainingLifetime / t.startLifetime; + const s = this.startFrame.evaluate(i, Si(t.randomSeed + hot)) / (this.numTilesX * this.numTilesY); + if (this.animation === uot.WholeSheet) t.frameIndex = Ei(this.cycleCount * (this.frameOverTime.evaluate(i, Si(t.randomSeed + hot)) + s), 1); else if (this.animation === uot.SingleRow) { + const e = 1 / this.numTilesY; + if (this.randomRow) { + const n = Ei(this.cycleCount * (this.frameOverTime.evaluate(i, Si(t.randomSeed + hot)) + s), 1); + const r = t.startRow * e; + const o = r + e; + t.frameIndex = pi(r, o, n); + } else { + const n = this.rowIndex * e; + const r = n + e; + t.frameIndex = pi(n, r, Ei(this.cycleCount * (this.frameOverTime.evaluate(i, Si(t.randomSeed + hot)) + s), 1)); + } + } + } + }, Jrt = Bl(Krt.prototype, "_enable", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Zrt = Bl(Krt.prototype, "_numTilesX", [ Srt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Qrt = Bl(Krt.prototype, "_numTilesY", [ Art ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Bl(Krt.prototype, "enable", [ Trt ], Object.getOwnPropertyDescriptor(Krt.prototype, "enable"), Krt.prototype), + $rt = Bl(Krt.prototype, "_mode", [ vrt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return cot.Grid; + } + }), Bl(Krt.prototype, "mode", [ Ert, Crt, xrt ], Object.getOwnPropertyDescriptor(Krt.prototype, "mode"), Krt.prototype), + Bl(Krt.prototype, "numTilesX", [ wrt, Rrt ], Object.getOwnPropertyDescriptor(Krt.prototype, "numTilesX"), Krt.prototype), + Bl(Krt.prototype, "numTilesY", [ Irt, Mrt ], Object.getOwnPropertyDescriptor(Krt.prototype, "numTilesY"), Krt.prototype), + tot = Bl(Krt.prototype, "animation", [ Brt, Yl, Drt, Prt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return uot.WholeSheet; + } + }), eot = Bl(Krt.prototype, "frameOverTime", [ Ort, Yl, Nrt, Lrt, Frt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), iot = Bl(Krt.prototype, "startFrame", [ Vrt, Yl, krt, Urt, Grt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), sot = Bl(Krt.prototype, "cycleCount", [ Yl, zrt, Hrt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), not = Bl(Krt.prototype, "_flipU", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), rot = Bl(Krt.prototype, "_flipV", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), oot = Bl(Krt.prototype, "_uvChannelMask", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return -1; + } + }), aot = Bl(Krt.prototype, "randomRow", [ Yl, jrt, Xrt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), lot = Bl(Krt.prototype, "rowIndex", [ Yl, Wrt, Yrt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Krt)) || qrt); + var dot, pot, mot, fot, got, yot, bot, Sot, Aot, Tot, vot, Eot, Cot, xot, wot, Rot, Iot, Mot, Bot, Dot, Pot, Oot, Not, Lot, Fot, Vot, kot, Uot, Got, zot; + const Hot = xit; + const jot = wit; + const Xot = Rit; + const Wot = new Pi; + let Yot = (dot = Ul("cc.VelocityOvertimeModule"), pot = ph(), mot = Th(Dtt), fot = hh(), + got = ph(), yot = lh(), bot = Th(Dtt), Sot = hh(), Aot = ph(), Tot = lh(), vot = Th(Dtt), + Eot = hh(), Cot = ph(), xot = lh(), wot = Th(Dtt), Rot = hh(), Iot = ph(), Mot = lh(), + Bot = Th(_it), Dot = ph(), Pot = lh(), dot(Oot = (Not = (zot = class extends uit { + get enable() { + return this._enable; + } + set enable(t) { + if (this._enable !== t) { + this._enable = t; + this.target && this.target.enableModule(this.name, t, this); + } + } + constructor() { + super(); + Ml(this, "_enable", Lot, this); + Ml(this, "x", Fot, this); + Ml(this, "y", Vot, this); + Ml(this, "z", kot, this); + Ml(this, "speedModifier", Uot, this); + Ml(this, "space", Got, this); + this.rotation = void 0; + this.needTransform = void 0; + this.name = oit; + this.rotation = new Ui; + this.speedModifier.constant = 1; + this.needTransform = !1; + this.needUpdate = !0; + } + update(t, e) { + this.needTransform = Uit(t, this.space, e, this.rotation); + } + animate(t, e) { + const i = 1 - t.remainingLifetime / t.startLifetime; + const s = Pi.set(Wot, this.x.evaluate(i, Si(t.randomSeed ^ Hot)), this.y.evaluate(i, Si(t.randomSeed ^ jot)), this.z.evaluate(i, Si(t.randomSeed ^ Xot))); + this.needTransform && Pi.transformQuat(s, s, this.rotation); + Pi.add(t.animatedVelocity, t.animatedVelocity, s); + Pi.add(t.ultimateVelocity, t.velocity, t.animatedVelocity); + Pi.multiplyScalar(t.ultimateVelocity, t.ultimateVelocity, this.speedModifier.evaluate(1 - t.remainingLifetime / t.startLifetime, Si(t.randomSeed + Hot))); + } + }, zot), Lot = Bl(Not.prototype, "_enable", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Bl(Not.prototype, "enable", [ pot ], Object.getOwnPropertyDescriptor(Not.prototype, "enable"), Not.prototype), + Fot = Bl(Not.prototype, "x", [ mot, Yl, fot, got, yot ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), Vot = Bl(Not.prototype, "y", [ bot, Yl, Sot, Aot, Tot ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), kot = Bl(Not.prototype, "z", [ vot, Yl, Eot, Cot, xot ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), Uot = Bl(Not.prototype, "speedModifier", [ wot, Yl, Rot, Iot, Mot ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), Got = Bl(Not.prototype, "space", [ Bot, Yl, Dot, Pot ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return _it.Local; + } + }), Not)) || Oot); + var qot, Kot, Jot, Zot, Qot, $ot, tat, eat, iat; + let sat = t("Burst", (qot = Ul("cc.Burst"), Kot = Th(Dtt), Jot = hh(), qot(Zot = (Qot = class { + get time() { + return this._time; + } + set time(t) { + this._time = t; + this._curTime = t; + } + get repeatCount() { + return this._repeatCount; + } + set repeatCount(t) { + this._repeatCount = t; + this._remainingCount = t; + } + constructor() { + Ml(this, "_time", $ot, this); + Ml(this, "_repeatCount", tat, this); + Ml(this, "repeatInterval", eat, this); + Ml(this, "count", iat, this); + this._remainingCount = void 0; + this._curTime = void 0; + this._remainingCount = 0; + this._curTime = 0; + } + update(t, e) { + if (0 === this._remainingCount) { + this._remainingCount = this._repeatCount; + this._curTime = this._time; + } + if (this._remainingCount > 0) { + let i = Ei(t._time - t.startDelay.evaluate(0, 1), t.duration) - e; + i = i > 0 ? i : 0; + const s = Ei(t.time - t.startDelay.evaluate(0, 1), t.duration); + if (this._curTime >= i && this._curTime < s) { + t.emit(this.count.evaluate(this._curTime / t.duration, 1), e - (s - this._curTime)); + this._curTime += this.repeatInterval; + --this._remainingCount; + } + } + } + reset() { + this._remainingCount = 0; + this._curTime = 0; + } + getMaxCount(t) { + return this.count.getMax() * Math.min(Math.ceil(t.duration / this.repeatInterval), this.repeatCount); + } + }, $ot = Bl(Qot.prototype, "_time", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Bl(Qot.prototype, "time", [ nh ], Object.getOwnPropertyDescriptor(Qot.prototype, "time"), Qot.prototype), + tat = Bl(Qot.prototype, "_repeatCount", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), Bl(Qot.prototype, "repeatCount", [ nh ], Object.getOwnPropertyDescriptor(Qot.prototype, "repeatCount"), Qot.prototype), + eat = Bl(Qot.prototype, "repeatInterval", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), iat = Bl(Qot.prototype, "count", [ Kot, Yl, Jot ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), Qot)) || Zot)); + var nat, rat, oat, aat, lat, hat, cat, uat, _at, dat, pat, mat, fat, gat, yat, bat, Sat, Aat, Tat, vat, Eat, Cat, xat, wat, Rat, Iat, Mat, Bat, Dat, Pat, Oat, Nat, Lat, Fat, Vat, kat, Uat, Gat, zat, Hat, jat, Xat, Wat, Yat, qat, Kat, Jat, Zat, Qat, $at, tlt, elt, ilt, slt, nlt, rlt, olt, alt, llt, hlt, clt, ult, _lt, dlt, plt, mlt, flt, glt, ylt, blt, Slt, Alt, Tlt, vlt, Elt, Clt, xlt, wlt, Rlt; + const Ilt = new Pi(0, 0, 0); + const Mlt = []; + const Blt = new Pi(.5, .5, .5); + let Dlt = (nat = Ul("cc.ShapeModule"), rat = ph(), oat = lh(), aat = ph(), lat = lh(), + hat = ph(), cat = lh(), uat = ph(), _at = lh(), dat = rh(), pat = ph(), mat = lh(), + fat = rh(), gat = ph(), yat = Th(fit), bat = ql("shapeType"), Sat = ph(), Aat = Th(fit), + Tat = lh(), vat = Th(git), Eat = ph(), Cat = lh(), xat = rh(), wat = ph(), Rat = lh(), + Iat = ph(), Mat = lh(), Bat = ph(), Dat = lh(), Pat = ph(), Oat = lh(), Nat = ph(), + Lat = lh(), Fat = rh(), Vat = ph(), kat = lh(), Uat = rh(), Gat = Th(yit), zat = ph(), + Hat = lh(), jat = rh(), Xat = rh(), Wat = ph(), Yat = lh(), qat = rh(), Kat = Th(Dtt), + Jat = rh(), Zat = hh(), Qat = ph(), $at = lh(), tlt = rh(), elt = ph(), ilt = lh(), + slt = rh(), nlt = ph(), rlt = lh(), olt = rh(), nat(alt = (llt = (Rlt = class { + get position() { + return this._position; + } + set position(t) { + this._position = t; + this.constructMat(); + } + get rotation() { + return this._rotation; + } + set rotation(t) { + this._rotation = t; + this.constructMat(); + } + get scale() { + return this._scale; + } + set scale(t) { + this._scale = t; + this.constructMat(); + } + get arc() { + return fi(this._arc); + } + set arc(t) { + this._arc = mi(t); + } + get angle() { + return Math.round(100 * fi(this._angle)) / 100; + } + set angle(t) { + this._angle = mi(t); + } + get enable() { + return this._enable; + } + set enable(t) { + this._enable = t; + } + get shapeType() { + return this._shapeType; + } + set shapeType(t) { + this._shapeType = t; + switch (this._shapeType) { + case fit.Box: + this.emitFrom === git.Base && (this.emitFrom = git.Volume); + break; + + case fit.Cone: + this.emitFrom === git.Edge && (this.emitFrom = git.Base); + break; + + case fit.Sphere: + case fit.Hemisphere: + this.emitFrom !== git.Base && this.emitFrom !== git.Edge || (this.emitFrom = git.Volume); + } + } + constructor() { + Ml(this, "_enable", hlt, this); + Ml(this, "_shapeType", clt, this); + Ml(this, "emitFrom", ult, this); + Ml(this, "alignToDirection", _lt, this); + Ml(this, "randomDirectionAmount", dlt, this); + Ml(this, "sphericalDirectionAmount", plt, this); + Ml(this, "randomPositionAmount", mlt, this); + Ml(this, "radius", flt, this); + Ml(this, "radiusThickness", glt, this); + Ml(this, "arcMode", ylt, this); + Ml(this, "arcSpread", blt, this); + Ml(this, "arcSpeed", Slt, this); + Ml(this, "length", Alt, this); + Ml(this, "boxThickness", Tlt, this); + Ml(this, "_position", vlt, this); + Ml(this, "_rotation", Elt, this); + Ml(this, "_scale", Clt, this); + Ml(this, "_arc", xlt, this); + Ml(this, "_angle", wlt, this); + this.mat = void 0; + this.quat = void 0; + this.particleSystem = void 0; + this.lastTime = void 0; + this.totalAngle = void 0; + this.mat = new qi; + this.quat = new Ui; + this.particleSystem = null; + this.lastTime = 0; + this.totalAngle = 0; + } + onInit(t) { + this.particleSystem = t; + this.constructMat(); + this.lastTime = this.particleSystem._time; + } + emit(t) { + switch (this.shapeType) { + case fit.Box: + !function(t, e, i, s) { + switch (t) { + case git.Volume: + !function(t, e) { + Pi.set(t, yi(-e.x, e.x), yi(-e.y, e.y), yi(-e.z, e.z)); + }(i, Blt); + break; + + case git.Shell: + Mlt.splice(0, Mlt.length); + Mlt.push(yi(-.5, .5)); + Mlt.push(yi(-.5, .5)); + Mlt.push(.5 * Wit()); + Xit(Mlt); + Plt(Mlt, e); + Pi.set(i, Mlt[0], Mlt[1], Mlt[2]); + break; + + case git.Edge: + Mlt.splice(0, Mlt.length); + Mlt.push(yi(-.5, .5)); + Mlt.push(.5 * Wit()); + Mlt.push(.5 * Wit()); + Xit(Mlt); + Plt(Mlt, e); + Pi.set(i, Mlt[0], Mlt[1], Mlt[2]); + break; + + default: + console.warn(`${t} is not supported for box emitter.`); + } + Pi.copy(s, kit); + }(this.emitFrom, this.boxThickness, t.position, t.velocity); + break; + + case fit.Circle: + !function(t, e, i, s, n) { + jit(s, t * (1 - e), t, i); + Pi.normalize(n, s); + }(this.radius, this.radiusThickness, this.generateArcAngle(), t.position, t.velocity); + break; + + case fit.Cone: + !function(t, e, i, s, n, r, o, a) { + switch (t) { + case git.Base: + jit(o, e * (1 - i), e, s); + Qi.multiplyScalar(a, o, Math.sin(n)); + a.z = -Math.cos(n) * e; + Pi.normalize(a, a); + o.z = 0; + break; + + case git.Shell: + Git(o, s); + Qi.multiplyScalar(a, o, Math.sin(n)); + a.z = -Math.cos(n); + Pi.normalize(a, a); + Qi.multiplyScalar(o, o, e); + o.z = 0; + break; + + case git.Volume: + jit(o, e * (1 - i), e, s); + Qi.multiplyScalar(a, o, Math.sin(n)); + a.z = -Math.cos(n) * e; + Pi.normalize(a, a); + o.z = 0; + Pi.add(o, o, Pi.multiplyScalar(Ilt, a, r * gi() / -a.z)); + break; + + default: + console.warn(`${t} is not supported for cone emitter.`); + } + }(this.emitFrom, this.radius, this.radiusThickness, this.generateArcAngle(), this._angle, this.length, t.position, t.velocity); + break; + + case fit.Sphere: + !function(t, e, i, s, n) { + switch (t) { + case git.Volume: + Hit(s, e * (1 - i), e); + Pi.normalize(n, s); + break; + + case git.Shell: + zit(s); + Pi.multiplyScalar(s, s, e); + Pi.normalize(n, s); + break; + + default: + console.warn(`${t} is not supported for sphere emitter.`); + } + }(this.emitFrom, this.radius, this.radiusThickness, t.position, t.velocity); + break; + + case fit.Hemisphere: + !function(t, e, i, s, n) { + switch (t) { + case git.Volume: + Hit(s, e * (1 - i), e); + s.z > 0 && (s.z *= -1); + Pi.normalize(n, s); + break; + + case git.Shell: + zit(s); + Pi.multiplyScalar(s, s, e); + s.z > 0 && (s.z *= -1); + Pi.normalize(n, s); + break; + + default: + console.warn(`${t} is not supported for hemisphere emitter.`); + } + }(this.emitFrom, this.radius, this.radiusThickness, t.position, t.velocity); + break; + + default: + console.warn(`${this.shapeType} shapeType is not supported by ShapeModule.`); + } + if (this.randomPositionAmount > 0) { + t.position.x += yi(-this.randomPositionAmount, this.randomPositionAmount); + t.position.y += yi(-this.randomPositionAmount, this.randomPositionAmount); + t.position.z += yi(-this.randomPositionAmount, this.randomPositionAmount); + } + Pi.transformQuat(t.velocity, t.velocity, this.quat); + Pi.transformMat4(t.position, t.position, this.mat); + if (this.sphericalDirectionAmount > 0) { + const e = Pi.normalize(Ilt, t.position); + Pi.lerp(t.velocity, t.velocity, e, this.sphericalDirectionAmount); + } + this.lastTime = this.particleSystem._time; + } + constructMat() { + Ui.fromEuler(this.quat, this._rotation.x, this._rotation.y, this._rotation.z); + qi.fromRTS(this.mat, this.quat, this._position, this._scale); + } + generateArcAngle() { + if (this.arcMode === yit.Random) return yi(0, this._arc); + let t = this.totalAngle + 2 * Math.PI * this.arcSpeed.evaluate(this.particleSystem._time, 1) * (this.particleSystem._time - this.lastTime); + this.totalAngle = t; + 0 !== this.arcSpread && (t = Math.floor(t / (this._arc * this.arcSpread)) * this._arc * this.arcSpread); + switch (this.arcMode) { + case yit.Loop: + return Ei(t, this._arc); + + case yit.PingPong: + return Ci(t, this._arc); + + default: + return Ei(t, this._arc); + } + } + }, Rlt), Bl(llt.prototype, "position", [ rat, oat ], Object.getOwnPropertyDescriptor(llt.prototype, "position"), llt.prototype), + Bl(llt.prototype, "rotation", [ aat, lat ], Object.getOwnPropertyDescriptor(llt.prototype, "rotation"), llt.prototype), + Bl(llt.prototype, "scale", [ hat, cat ], Object.getOwnPropertyDescriptor(llt.prototype, "scale"), llt.prototype), + Bl(llt.prototype, "arc", [ uat, _at, dat ], Object.getOwnPropertyDescriptor(llt.prototype, "arc"), llt.prototype), + Bl(llt.prototype, "angle", [ pat, mat, fat ], Object.getOwnPropertyDescriptor(llt.prototype, "angle"), llt.prototype), + hlt = Bl(llt.prototype, "_enable", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Bl(llt.prototype, "enable", [ gat ], Object.getOwnPropertyDescriptor(llt.prototype, "enable"), llt.prototype), + clt = Bl(llt.prototype, "_shapeType", [ yat, bat, Sat ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return fit.Cone; + } + }), Bl(llt.prototype, "shapeType", [ Aat, Tat ], Object.getOwnPropertyDescriptor(llt.prototype, "shapeType"), llt.prototype), + ult = Bl(llt.prototype, "emitFrom", [ vat, Yl, Eat, Cat, xat ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return git.Volume; + } + }), _lt = Bl(llt.prototype, "alignToDirection", [ Yl, wat, Rat ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), dlt = Bl(llt.prototype, "randomDirectionAmount", [ Yl, Iat, Mat ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), plt = Bl(llt.prototype, "sphericalDirectionAmount", [ Yl, Bat, Dat ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), mlt = Bl(llt.prototype, "randomPositionAmount", [ Yl, Pat, Oat ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), flt = Bl(llt.prototype, "radius", [ Yl, Nat, Lat, Fat ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), glt = Bl(llt.prototype, "radiusThickness", [ Yl, Vat, kat, Uat ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), ylt = Bl(llt.prototype, "arcMode", [ Gat, Yl, zat, Hat, jat ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return yit.Random; + } + }), blt = Bl(llt.prototype, "arcSpread", [ Xat, Yl, Wat, Yat, qat ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Slt = Bl(llt.prototype, "arcSpeed", [ Kat, Jat, Zat, Yl, Qat, $at, tlt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), Alt = Bl(llt.prototype, "length", [ Yl, elt, ilt, slt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 5; + } + }), Tlt = Bl(llt.prototype, "boxThickness", [ Yl, nlt, rlt, olt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Pi(0, 0, 0); + } + }), vlt = Bl(llt.prototype, "_position", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Pi(0, 0, 0); + } + }), Elt = Bl(llt.prototype, "_rotation", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Pi(0, 0, 0); + } + }), Clt = Bl(llt.prototype, "_scale", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Pi(1, 1, 1); + } + }), xlt = Bl(llt.prototype, "_arc", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return mi(360); + } + }), wlt = Bl(llt.prototype, "_angle", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return mi(25); + } + }), llt)) || alt); + function Plt(t, e) { + if (e.x > 0) { + t[0] += .5 * yi(-e.x, e.x); + t[0] = _i(t[0], -.5, .5); + } + if (e.y > 0) { + t[1] += .5 * yi(-e.y, e.y); + t[1] = _i(t[1], -.5, .5); + } + if (e.z > 0) { + t[2] += .5 * yi(-e.z, e.z); + t[2] = _i(t[2], -.5, .5); + } + } + const Olt = [ 0, 0, 1, 0, 0, 1, 1, 1 ]; + const Nlt = [ 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0 ]; + class Llt extends wA { + constructor() { + super(); + this._capacity = void 0; + this._vertAttrs = void 0; + this._vertAttribSize = void 0; + this._vBuffer = void 0; + this._vertAttrsFloatCount = void 0; + this._vdataF32 = void 0; + this._vdataUint32 = void 0; + this._iaInfo = void 0; + this._iaInfoBuffer = void 0; + this._subMeshData = void 0; + this._mesh = void 0; + this._vertCount = 0; + this._indexCount = 0; + this._startTimeOffset = 0; + this._lifeTimeOffset = 0; + this._material = null; + this._vertAttribSizeStatic = void 0; + this._vertStaticAttrsFloatCount = void 0; + this._insBuffers = void 0; + this._insIndices = void 0; + this._useInstance = void 0; + this._registerListeners(); + this.type = xA.PARTICLE_BATCH; + this._capacity = 0; + this._vertAttrs = null; + this._vertAttribSize = 0; + this._vBuffer = null; + this._vertAttrsFloatCount = 0; + this._vdataF32 = null; + this._vdataUint32 = null; + this._vertAttribSizeStatic = 0; + this._vertStaticAttrsFloatCount = 0; + this._insBuffers = []; + this._insIndices = null; + zo.gfxDevice.hasFeature(ys.INSTANCED_ARRAYS) ? this._useInstance = !0 : this._useInstance = !1; + this._iaInfo = new Cn([ new vn ]); + this._iaInfoBuffer = this._device.createBuffer(new An(Ts.INDIRECT, Cs.HOST | Cs.DEVICE, mr, mr)); + this._subMeshData = null; + this._mesh = null; + } + setCapacity(t) { + const e = this._capacity !== t; + this._capacity = t; + this._subMeshData && e && this.rebuild(); + } + setVertexAttributes(t, e) { + if (this._useInstance) this.setVertexAttributesIns(t, e); else { + if (this._mesh === t && this._vertAttrs === e) return; + this._mesh = t; + this._vertAttrs = e; + this._vertAttribSize = 0; + for (const t of this._vertAttrs) { + t.offset = this._vertAttribSize; + this._vertAttribSize += ur[t.format].size; + } + this._vertAttrsFloatCount = this._vertAttribSize / 4; + this.rebuild(); + } + } + setVertexAttributesIns(t, e) { + if (this._mesh !== t || this._vertAttrs !== e) { + this._mesh = t; + this._vertAttrs = e; + this._vertAttribSize = 0; + this._vertAttribSizeStatic = 0; + for (const t of this._vertAttrs) if (0 === t.stream) { + t.offset = this._vertAttribSize; + this._vertAttribSize += ur[t.format].size; + } else if (1 === t.stream) { + t.offset = this._vertAttribSizeStatic; + this._vertAttribSizeStatic += ur[t.format].size; + } + this._vertAttrsFloatCount = this._vertAttribSize / 4; + this._vertStaticAttrsFloatCount = this._vertAttribSizeStatic / 4; + this.rebuild(); + } + } + createSubMeshData() { + this.destroySubMeshData(); + this._vertCount = 4; + this._indexCount = 6; + if (this._mesh) { + this._vertCount = this._mesh.struct.vertexBundles[this._mesh.struct.primitives[0].vertexBundelIndices[0]].view.count; + this._indexCount = this._mesh.struct.primitives[0].indexView.count; + } + const t = this._device.createBuffer(new An(Ts.VERTEX | Ts.TRANSFER_DST, Cs.HOST | Cs.DEVICE, this._vertAttribSize * this._capacity * this._vertCount, this._vertAttribSize)); + const e = new ArrayBuffer(this._vertAttribSize * this._capacity * this._vertCount); + if (this._mesh && this._capacity > 0) { + let t = this._vertAttrs[this._vertAttrs.findIndex((t => t.name === cr.ATTR_TEX_COORD))].offset; + this._mesh.copyAttribute(0, cr.ATTR_TEX_COORD, e, this._vertAttribSize, t); + let i = this._vertAttrs.findIndex((t => t.name === cr.ATTR_TEX_COORD3)); + t = this._vertAttrs[i++].offset; + this._mesh.copyAttribute(0, cr.ATTR_POSITION, e, this._vertAttribSize, t); + t = this._vertAttrs[i++].offset; + this._mesh.copyAttribute(0, cr.ATTR_NORMAL, e, this._vertAttribSize, t); + t = this._vertAttrs[i++].offset; + if (!this._mesh.copyAttribute(0, cr.ATTR_COLOR, e, this._vertAttribSize, t)) { + const i = new Uint32Array(e); + for (let e = 0; e < this._vertCount; ++e) i[e * this._vertAttrsFloatCount + t / 4] = Bi.WHITE._val; + } + const s = new Float32Array(e); + for (let t = 1; t < this._capacity; t++) s.copyWithin(t * this._vertAttribSize * this._vertCount / 4, 0, this._vertAttribSize * this._vertCount / 4); + } + t.update(e); + const i = new Uint16Array(this._capacity * this._indexCount); + if (this._mesh && this._capacity > 0) { + this._mesh.copyIndices(0, i); + for (let t = 1; t < this._capacity; t++) for (let e = 0; e < this._indexCount; e++) i[t * this._indexCount + e] = i[e] + t * this._vertCount; + } else { + let t = 0; + for (let e = 0; e < this._capacity; ++e) { + const s = 4 * e; + i[t++] = s; + i[t++] = s + 1; + i[t++] = s + 2; + i[t++] = s + 3; + i[t++] = s + 2; + i[t++] = s + 1; + } + } + const s = this._device.createBuffer(new An(Ts.INDEX | Ts.TRANSFER_DST, Cs.DEVICE, this._capacity * this._indexCount * Uint16Array.BYTES_PER_ELEMENT, Uint16Array.BYTES_PER_ELEMENT)); + s.update(i); + this._iaInfo.drawInfos[0].vertexCount = this._capacity * this._vertCount; + this._iaInfo.drawInfos[0].indexCount = this._capacity * this._indexCount; + this._iaInfoBuffer || (this._iaInfoBuffer = this._device.createBuffer(new An(Ts.INDIRECT, Cs.HOST | Cs.DEVICE, mr, mr))); + this._iaInfoBuffer.update(this._iaInfo); + this._subMeshData = new fC([ t ], this._vertAttrs, Xs.TRIANGLE_LIST, s, this._iaInfoBuffer); + this.initSubModel(0, this._subMeshData, this._material); + return e; + } + createSubMeshDataInsDynamic() { + this.destroySubMeshData(); + const t = this._device.createBuffer(new An(Ts.VERTEX | Ts.TRANSFER_DST, Cs.HOST | Cs.DEVICE, this._vertAttribSize * this._capacity, this._vertAttribSize)); + const e = new ArrayBuffer(this._vertAttribSize * this._capacity); + t.update(e); + this._insBuffers.push(t); + return e; + } + createSubMeshDataInsStatic() { + this._vertCount = 4; + this._indexCount = 6; + if (this._mesh) { + this._vertCount = this._mesh.struct.vertexBundles[this._mesh.struct.primitives[0].vertexBundelIndices[0]].view.count; + this._indexCount = this._mesh.struct.primitives[0].indexView.count; + } + const t = this._device.createBuffer(new An(Ts.VERTEX | Ts.TRANSFER_DST, Cs.HOST | Cs.DEVICE, this._vertAttribSizeStatic * this._vertCount, this._vertAttribSizeStatic)); + const e = new ArrayBuffer(this._vertAttribSizeStatic * this._vertCount); + if (this._mesh) { + let t = this._vertAttrs.findIndex((t => t.name === cr.ATTR_TEX_COORD)); + let i = this._vertAttrs[t].offset; + this._mesh.copyAttribute(0, cr.ATTR_TEX_COORD, e, this._vertAttribSizeStatic, i); + t = this._vertAttrs.findIndex((t => t.name === cr.ATTR_TEX_COORD3)); + i = this._vertAttrs[t++].offset; + this._mesh.copyAttribute(0, cr.ATTR_POSITION, e, this._vertAttribSizeStatic, i); + i = this._vertAttrs[t++].offset; + this._mesh.copyAttribute(0, cr.ATTR_NORMAL, e, this._vertAttribSizeStatic, i); + i = this._vertAttrs[t++].offset; + if (!this._mesh.copyAttribute(0, cr.ATTR_COLOR, e, this._vertAttribSizeStatic, i)) { + const t = new Uint32Array(e); + for (let e = 0; e < this._vertCount; ++e) t[e * this._vertStaticAttrsFloatCount + i / 4] = Bi.WHITE._val; + } + } else { + const t = new Float32Array(e); + for (let e = 0; e < Nlt.length; ++e) t[e] = Nlt[e]; + } + t.update(e); + const i = new Uint16Array(this._indexCount); + if (this._mesh) this._mesh.copyIndices(0, i); else { + i[0] = 0; + i[1] = 1; + i[2] = 2; + i[3] = 3; + i[4] = 2; + i[5] = 1; + } + const s = this._device.createBuffer(new An(Ts.INDEX | Ts.TRANSFER_DST, Cs.DEVICE, this._indexCount * Uint16Array.BYTES_PER_ELEMENT, Uint16Array.BYTES_PER_ELEMENT)); + s.update(i); + this._insIndices = s; + this._iaInfo.drawInfos[0].vertexCount = this._vertCount; + this._iaInfo.drawInfos[0].indexCount = this._indexCount; + this._iaInfoBuffer || (this._iaInfoBuffer = this._device.createBuffer(new An(Ts.INDIRECT, Cs.HOST | Cs.DEVICE, mr, mr))); + this._iaInfoBuffer.update(this._iaInfo); + this._insBuffers.push(t); + } + createInsSubmesh() { + this._subMeshData = new fC(this._insBuffers, this._vertAttrs, Xs.TRIANGLE_LIST, this._insIndices, this._iaInfoBuffer); + this.initSubModel(0, this._subMeshData, this._material); + } + updateMaterial(t) { + this._material = t; + this.setSubModelMaterial(0, t); + } + addParticleVertexData(t, e) { + if (this._useInstance) this.addParticleVertexDataIns(t, e); else if (this._mesh) for (let i = 0; i < this._vertCount; i++) { + let s = (t * this._vertCount + i) * this._vertAttrsFloatCount; + this._vdataF32[s++] = e[0].x; + this._vdataF32[s++] = e[0].y; + this._vdataF32[s++] = e[0].z; + s += 2; + this._vdataF32[s++] = e[1].z; + this._vdataF32[s++] = e[2].x; + this._vdataF32[s++] = e[2].y; + this._vdataF32[s++] = e[2].z; + this._vdataF32[s++] = e[3].x; + this._vdataF32[s++] = e[3].y; + this._vdataF32[s++] = e[3].z; + this._vdataUint32[s++] = e[4]; + } else { + let i = t * this._vertAttrsFloatCount; + this._vdataF32[i++] = e[0].x; + this._vdataF32[i++] = e[0].y; + this._vdataF32[i++] = e[0].z; + this._vdataF32[i++] = e[1].x; + this._vdataF32[i++] = e[1].y; + this._vdataF32[i++] = e[1].z; + this._vdataF32[i++] = e[2].x; + this._vdataF32[i++] = e[2].y; + this._vdataF32[i++] = e[2].z; + this._vdataF32[i++] = e[3].x; + this._vdataF32[i++] = e[3].y; + this._vdataF32[i++] = e[3].z; + this._vdataUint32[i++] = e[4]; + if (e[5]) { + this._vdataF32[i++] = e[5].x; + this._vdataF32[i++] = e[5].y; + this._vdataF32[i++] = e[5].z; + } + } + } + addParticleVertexDataIns(t, e) { + let i = t * this._vertAttrsFloatCount; + if (this._mesh) { + this._vdataF32[i++] = e[0].x; + this._vdataF32[i++] = e[0].y; + this._vdataF32[i++] = e[0].z; + this._vdataF32[i++] = e[1].z; + this._vdataF32[i++] = e[2].x; + this._vdataF32[i++] = e[2].y; + this._vdataF32[i++] = e[2].z; + this._vdataF32[i++] = e[3].x; + this._vdataF32[i++] = e[3].y; + this._vdataF32[i++] = e[3].z; + this._vdataUint32[i++] = e[4]; + } else { + this._vdataF32[i++] = e[0].x; + this._vdataF32[i++] = e[0].y; + this._vdataF32[i++] = e[0].z; + this._vdataF32[i++] = e[1].z; + this._vdataF32[i++] = e[2].x; + this._vdataF32[i++] = e[2].y; + this._vdataF32[i++] = e[2].z; + this._vdataF32[i++] = e[3].x; + this._vdataF32[i++] = e[3].y; + this._vdataF32[i++] = e[3].z; + this._vdataUint32[i++] = e[4]; + if (e[5]) { + this._vdataF32[i++] = e[5].x; + this._vdataF32[i++] = e[5].y; + this._vdataF32[i++] = e[5].z; + } + } + } + addGPUParticleVertexData(t, e, i) { + if (this._useInstance) this.addGPUParticleVertexDataIns(t, e, i); else { + let s = e * this._vertAttrsFloatCount * this._vertCount; + for (let e = 0; e < this._vertCount; e++) { + let n = s; + this._vdataF32[n++] = t.position.x; + this._vdataF32[n++] = t.position.y; + this._vdataF32[n++] = t.position.z; + this._vdataF32[n++] = i; + this._vdataF32[n++] = t.startSize.x; + this._vdataF32[n++] = t.startSize.y; + this._vdataF32[n++] = t.startSize.z; + this._vdataF32[n++] = Olt[2 * e]; + this._vdataF32[n++] = t.rotation.x; + this._vdataF32[n++] = t.rotation.y; + this._vdataF32[n++] = t.rotation.z; + this._vdataF32[n++] = Olt[2 * e + 1]; + this._vdataF32[n++] = t.startColor.r / 255; + this._vdataF32[n++] = t.startColor.g / 255; + this._vdataF32[n++] = t.startColor.b / 255; + this._vdataF32[n++] = t.startColor.a / 255; + this._vdataF32[n++] = t.velocity.x; + this._vdataF32[n++] = t.velocity.y; + this._vdataF32[n++] = t.velocity.z; + this._vdataF32[n++] = t.startLifetime; + this._vdataF32[n++] = t.randomSeed; + s += this._vertAttrsFloatCount; + } + } + } + addGPUParticleVertexDataIns(t, e, i) { + let s = e * this._vertAttrsFloatCount; + let n = s; + this._vdataF32[n++] = t.position.x; + this._vdataF32[n++] = t.position.y; + this._vdataF32[n++] = t.position.z; + this._vdataF32[n++] = i; + this._vdataF32[n++] = t.startSize.x; + this._vdataF32[n++] = t.startSize.y; + this._vdataF32[n++] = t.startSize.z; + this._vdataF32[n++] = t.frameIndex; + this._vdataF32[n++] = t.rotation.x; + this._vdataF32[n++] = t.rotation.y; + this._vdataF32[n++] = t.rotation.z; + this._vdataF32[n++] = t.randomSeed; + this._vdataF32[n++] = t.startColor.r / 255; + this._vdataF32[n++] = t.startColor.g / 255; + this._vdataF32[n++] = t.startColor.b / 255; + this._vdataF32[n++] = t.startColor.a / 255; + this._vdataF32[n++] = t.velocity.x; + this._vdataF32[n++] = t.velocity.y; + this._vdataF32[n++] = t.velocity.z; + this._vdataF32[n++] = t.startLifetime; + s += this._vertAttrsFloatCount; + } + updateGPUParticles(t, e, i) { + if (this._useInstance) return this.updateGPUParticlesIns(t, e, i); + { + const s = this._vertAttrsFloatCount * this._vertCount; + let n = 0; + let r = 0; + let o = 0; + let a = 0; + let l = 0; + for (let h = 0; h < t; ++h) { + n = h * s; + r = this._vdataF32[n + this._startTimeOffset]; + o = this._vdataF32[n + this._lifeTimeOffset]; + l = e - r; + if (o - l < i) { + a = --t * s; + this._vdataF32.copyWithin(n, a, a + s); + h--; + } + } + return t; + } + } + updateGPUParticlesIns(t, e, i) { + const s = this._vertAttrsFloatCount; + let n = 0; + let r = 0; + let o = 0; + let a = 0; + let l = 0; + for (let h = 0; h < t; ++h) { + n = h * s; + r = this._vdataF32[n + this._startTimeOffset]; + o = this._vdataF32[n + this._lifeTimeOffset]; + l = e - r; + if (o - l < i) { + a = --t * s; + this._vdataF32.copyWithin(n, a, a + s); + h--; + } + } + return t; + } + constructAttributeIndex() { + if (!this._vertAttrs) return; + let t = this._vertAttrs.findIndex((t => "a_position_starttime" === t.name)); + let e = this._vertAttrs[t].offset; + this._startTimeOffset = e / 4 + 3; + t = this._vertAttrs.findIndex((t => "a_dir_life" === t.name)); + e = this._vertAttrs[t].offset; + this._lifeTimeOffset = e / 4 + 3; + } + updateIA(t) { + if (this._useInstance) this.updateIAIns(t); else { + if (t <= 0) return; + this._subModels[0].inputAssembler.vertexBuffers[0].update(this._vdataF32); + this._iaInfo.drawInfos[0].firstIndex = 0; + this._iaInfo.drawInfos[0].indexCount = this._indexCount * t; + this._iaInfoBuffer.update(this._iaInfo); + } + } + updateIAIns(t) { + if (t <= 0) return; + const e = this._subModels[0].inputAssembler; + e.vertexBuffers[0].update(this._vdataF32); + e.instanceCount = t; + this._iaInfo.drawInfos[0].firstIndex = 0; + this._iaInfo.drawInfos[0].indexCount = this._indexCount; + this._iaInfo.drawInfos[0].instanceCount = t; + this._iaInfoBuffer.update(this._iaInfo); + } + clear() { + this._useInstance ? this.clearIns() : this._subModels[0].inputAssembler.indexCount = 0; + } + clearIns() { + this._subModels[0].inputAssembler.instanceCount = 0; + } + destroy() { + super.destroy(); + this.doDestroy(); + } + doDestroy() { + this._vBuffer = null; + this._vdataF32 = null; + this._vdataUint32 = null; + this._insBuffers = []; + this._insIndices = null; + this._vertAttrs = null; + this._material = null; + this._mesh = null; + this.destroySubMeshData(); + } + rebuild() { + if (this._useInstance) this.rebuildIns(); else { + this._vBuffer = this.createSubMeshData(); + this._vdataF32 = new Float32Array(this._vBuffer); + this._vdataUint32 = new Uint32Array(this._vBuffer); + } + } + rebuildIns() { + this._vBuffer = this.createSubMeshDataInsDynamic(); + this._vdataF32 = new Float32Array(this._vBuffer); + this._vdataUint32 = new Uint32Array(this._vBuffer); + this.createSubMeshDataInsStatic(); + this.createInsSubmesh(); + } + destroySubMeshData() { + if (this._subMeshData) { + this._subMeshData.destroy(); + this._subMeshData = null; + } + this._iaInfoBuffer && (this._iaInfoBuffer = null); + } + set useInstance(t) { + this._useInstance !== t && (this._useInstance = t); + } + get useInstance() { + return this._useInstance; + } + } + class Flt { + constructor(t) { + this._particleSystem = null; + this._model = null; + this._renderInfo = null; + this._vertAttrs = []; + this._useInstance = void 0; + this._renderInfo = t; + zo.gfxDevice.hasFeature(ys.INSTANCED_ARRAYS) ? this._useInstance = !0 : this._useInstance = !1; + } + getUseInstance() { + return this._useInstance; + } + getInfo() { + return this._renderInfo; + } + onInit(t) { + this._particleSystem = t; + } + onEnable() { + if (!this._particleSystem) return; + this.attachToScene(); + const t = this._model; + t && (t.node = t.transform = this._particleSystem.node); + } + onDisable() { + this.detachFromScene(); + } + onDestroy() { + if (this._model) { + m.director.root.destroyModel(this._model); + this._model = null; + } + } + attachToScene() { + if (this._model) { + this._model.scene && this.detachFromScene(); + this._particleSystem._getRenderScene().addModel(this._model); + } + } + detachFromScene() { + this._model && this._model.scene && this._model.scene.removeModel(this._model); + } + setVertexAttributes() { + if (this._model) { + this.updateVertexAttrib(); + this._model.setVertexAttributes(this._renderInfo.renderMode === mit.Mesh ? this._renderInfo.mesh : null, this._vertAttrs); + } + } + clear() { + this._model && (this._model.enabled = !1); + } + getModel() { + return this._model; + } + _initModel() { + if (!this._model) { + this._model = m.director.root.createModel(Llt); + this._model.setCapacity(this._particleSystem.capacity); + this._model.visFlags = this._particleSystem.visibility; + } + } + updateTrailMaterial() {} + getDefaultTrailMaterial() { + return null; + } + } + class Vlt { + constructor(t) { + this.permutation = [ 151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166, 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244, 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196, 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123, 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42, 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9, 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228, 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107, 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254, 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180 ]; + this.accSpeed = new Pi; + this.noiseSpeed = new Pi; + this.noiseFrequency = 0; + this.noiseAbs = new Pi; + this.noiseAmplitude = new Pi; + this.octaves = new Pi; + this.dt = 0; + this.point = new Pi; + this.result = new Pi; + this.mixOut = new Qi; + t && (this.permutation = t); + } + noise(t, e, i, s = 0, n = 1) { + const r = new Array(512); + for (let t = 0; t < 256; t++) r[256 + t] = r[t] = this.permutation[t]; + const o = 255 & Math.floor(t); + const a = 255 & Math.floor(e); + const l = 255 & Math.floor(i); + t -= Math.floor(t); + e -= Math.floor(e); + i -= Math.floor(i); + const h = this.fade(t); + const c = this.fade(e); + const u = this.fade(i); + const _ = r[o] + a; + const d = r[_] + l; + const p = r[_ + 1] + l; + const m = r[o + 1] + a; + const f = r[m] + l; + const g = r[m + 1] + l; + return s + this.scale(this.lerp(u, this.lerp(c, this.lerp(h, this.grad(r[d], t, e, i), this.grad(r[f], t - 1, e, i)), this.lerp(h, this.grad(r[p], t, e - 1, i), this.grad(r[g], t - 1, e - 1, i))), this.lerp(c, this.lerp(h, this.grad(r[d + 1], t, e, i - 1), this.grad(r[f + 1], t - 1, e, i - 1)), this.lerp(h, this.grad(r[p + 1], t, e - 1, i - 1), this.grad(r[g + 1], t - 1, e - 1, i - 1))))) * (n - s); + } + fade(t) { + return t * t * t * (t * (6 * t - 15) + 10); + } + lerp(t, e, i) { + return e + t * (i - e); + } + grad(t, e, i, s) { + const n = 15 & t; + const r = n < 8 ? e : i; + const o = n < 4 ? i : 12 === n || 14 === n ? e : s; + return (0 == (1 & n) ? r : -r) + (0 == (2 & n) ? o : -o); + } + scale(t) { + return (1 + t) / 2; + } + setSpeed(t, e, i) { + this.noiseSpeed.set(t, e, i); + } + setFrequency(t) { + this.noiseFrequency = t; + } + setAbs(t, e, i) { + this.noiseAbs.set(t, e, i); + } + setAmplititude(t, e, i) { + this.noiseAmplitude.set(t, e, i); + } + setOctaves(t, e, i) { + this.octaves.set(t, e, i); + } + setTime(t) { + this.dt = t; + } + setSamplePoint(t) { + this.point.set(t); + } + getResult() { + return this.result; + } + getNoise(t, e, i, s, n, r, o) { + let a = r; + let l = 0; + l += this.noise(t * a, e * a, i * a, -1, 1); + if (1 === o.x) return l; + let h = 1; + let c = 1; + for (let s = 1; s < o.x; ++s) { + h *= o.y; + a *= o.z; + c += h; + l += this.noise(t * a, e * a, i * a, -1, 1) * h; + } + return l / c; + } + getNoiseMix(t, e, i, s, n, r) { + t.x = this.getNoise(e.x, e.y, e.z, i, s, n, r); + t.y = this.getNoise(e.y, e.z, e.x, i, s, n, r); + } + getNoiseParticle() { + this.accSpeed.set(this.noiseSpeed.x * this.dt, this.noiseSpeed.y * this.dt, this.noiseSpeed.z * this.dt); + const t = this.getNoise(this.point.z + this.accSpeed.x, this.point.y, this.point.x, this.dt, this.accSpeed, this.noiseFrequency, this.octaves); + const e = this.getNoise(this.point.x + 1e3, this.point.z + this.accSpeed.y, this.point.y, this.dt, this.accSpeed, this.noiseFrequency, this.octaves); + const i = this.getNoise(this.point.y, this.point.x + 1e3, this.point.z + this.accSpeed.z, this.dt, this.accSpeed, this.noiseFrequency, this.octaves); + this.result.set(t * this.noiseAmplitude.x, e * this.noiseAmplitude.y, i * this.noiseAmplitude.z); + } + getPreview(t, e, i) { + for (let s = 0; s < i; ++s) for (let n = 0; n < e; ++n) { + const r = (n - .5 * e) / e + this.noiseSpeed.x * this.dt; + const o = (s - .5 * i) / i + this.noiseSpeed.y * this.dt; + const a = this.getNoise(r, o, 0, this.dt, this.accSpeed, this.noiseFrequency, this.octaves); + t[s * e + n] = .5 * (a + 1); + } + } + } + const klt = new Pi; + const Ult = new qi; + const Glt = new qi; + const zlt = new Ui; + new Pi; + const Hlt = [ "_colorOverLifetimeModule", "_sizeOvertimeModule", "_velocityOvertimeModule", "_forceOvertimeModule", "_limitVelocityOvertimeModule", "_rotationOvertimeModule", "_textureAnimationModule", "_noiseModule" ]; + const jlt = [ 0, 0, 1, 0, 0, 1, 1, 1 ]; + const Xlt = [ new Vn(cr.ATTR_POSITION, bs.RGB32F), new Vn(cr.ATTR_TEX_COORD, bs.RGB32F), new Vn(cr.ATTR_TEX_COORD1, bs.RGB32F), new Vn(cr.ATTR_TEX_COORD2, bs.RGB32F), new Vn(cr.ATTR_COLOR, bs.RGBA8, !0) ]; + const Wlt = [ new Vn(cr.ATTR_POSITION, bs.RGB32F), new Vn(cr.ATTR_TEX_COORD, bs.RGB32F), new Vn(cr.ATTR_TEX_COORD1, bs.RGB32F), new Vn(cr.ATTR_TEX_COORD2, bs.RGB32F), new Vn(cr.ATTR_COLOR, bs.RGBA8, !0), new Vn(cr.ATTR_COLOR1, bs.RGB32F) ]; + const Ylt = [ new Vn(cr.ATTR_POSITION, bs.RGB32F), new Vn(cr.ATTR_TEX_COORD, bs.RGB32F), new Vn(cr.ATTR_TEX_COORD1, bs.RGB32F), new Vn(cr.ATTR_TEX_COORD2, bs.RGB32F), new Vn(cr.ATTR_COLOR, bs.RGBA8, !0), new Vn(cr.ATTR_TEX_COORD3, bs.RGB32F), new Vn(cr.ATTR_NORMAL, bs.RGB32F), new Vn(cr.ATTR_COLOR1, bs.RGBA8, !0) ]; + const qlt = [ new Vn(cr.ATTR_TEX_COORD4, bs.RGBA32F, !1, 0, !0), new Vn(cr.ATTR_TEX_COORD1, bs.RGB32F, !1, 0, !0), new Vn(cr.ATTR_TEX_COORD2, bs.RGB32F, !1, 0, !0), new Vn(cr.ATTR_COLOR, bs.RGBA8, !0, 0, !0), new Vn(cr.ATTR_TEX_COORD, bs.RGB32F, !1, 1) ]; + const Klt = [ new Vn(cr.ATTR_TEX_COORD4, bs.RGBA32F, !1, 0, !0), new Vn(cr.ATTR_TEX_COORD1, bs.RGB32F, !1, 0, !0), new Vn(cr.ATTR_TEX_COORD2, bs.RGB32F, !1, 0, !0), new Vn(cr.ATTR_COLOR, bs.RGBA8, !0, 0, !0), new Vn(cr.ATTR_COLOR1, bs.RGB32F, !1, 0, !0), new Vn(cr.ATTR_TEX_COORD, bs.RGB32F, !1, 1) ]; + const Jlt = [ new Vn(cr.ATTR_TEX_COORD4, bs.RGBA32F, !1, 0, !0), new Vn(cr.ATTR_TEX_COORD1, bs.RGB32F, !1, 0, !0), new Vn(cr.ATTR_TEX_COORD2, bs.RGB32F, !1, 0, !0), new Vn(cr.ATTR_COLOR, bs.RGBA8, !0, 0, !0), new Vn(cr.ATTR_TEX_COORD, bs.RGB32F, !1, 1), new Vn(cr.ATTR_TEX_COORD3, bs.RGB32F, !1, 1), new Vn(cr.ATTR_NORMAL, bs.RGB32F, !1, 1), new Vn(cr.ATTR_COLOR1, bs.RGBA8, !0, 1) ]; + const Zlt = { + parent: null, + owner: null, + subModelIdx: 0 + }; + class Qlt extends Flt { + constructor(t) { + super(t); + this._defines = void 0; + this._trailDefines = void 0; + this._frameTile_velLenScale = void 0; + this._tmp_velLenScale = void 0; + this._defaultMat = null; + this._node_scale = void 0; + this._attrs = void 0; + this._particles = null; + this._defaultTrailMat = null; + this._updateList = new Map; + this._animateList = new Map; + this._runAnimateList = new Array; + this._fillDataFunc = null; + this._uScaleHandle = 0; + this._uLenHandle = 0; + this._uNodeRotHandle = 0; + this._alignSpace = pit.View; + this._inited = !1; + this._localMat = new qi; + this._gravity = new is; + this.noise = new Vlt; + this._model = null; + this._frameTile_velLenScale = new is(1, 1, 0, 0); + this._tmp_velLenScale = this._frameTile_velLenScale.clone(); + this._node_scale = new is; + this._attrs = new Array(7); + this._defines = { + CC_USE_WORLD_SPACE: !0, + CC_USE_BILLBOARD: !0, + CC_USE_STRETCHED_BILLBOARD: !1, + CC_USE_HORIZONTAL_BILLBOARD: !1, + CC_USE_VERTICAL_BILLBOARD: !1 + }; + this._trailDefines = { + CC_USE_WORLD_SPACE: !0 + }; + } + onInit(t) { + super.onInit(t); + this._particles = new to((() => new tit(this)), 16); + this._setVertexAttrib(); + this._setFillFunc(); + this._initModuleList(); + this._initModel(); + this.updateMaterialParams(); + this.updateTrailMaterial(); + this.setVertexAttributes(); + this._inited = !0; + } + clear() { + super.clear(); + this._particles.reset(); + this._particleSystem._trailModule && this._particleSystem._trailModule.clear(); + this.updateRenderData(); + this._model.enabled = !1; + } + updateRenderMode() { + this._setVertexAttrib(); + this._setFillFunc(); + this.updateMaterialParams(); + this.setVertexAttributes(); + } + onDestroy() { + var t; + null === (t = this._particles) || void 0 === t || t.destroy(); + super.onDestroy(); + } + getFreeParticle() { + return this._particles.length >= this._particleSystem.capacity ? null : this._particles.add(); + } + getDefaultTrailMaterial() { + return this._defaultTrailMat; + } + setNewParticle(t) {} + _initModuleList() { + Hlt.forEach((t => { + const e = this._particleSystem[t]; + if (e && e.enable) { + e.needUpdate && (this._updateList[e.name] = e); + e.needAnimate && (this._animateList[e.name] = e); + } + })); + this._runAnimateList.length = 0; + for (let t = 0, e = hit.length; t < e; t++) { + const e = this._animateList[hit[t]]; + e && this._runAnimateList.push(e); + } + } + enableModule(t, e, i) { + if (e) { + i.needUpdate && (this._updateList[i.name] = i); + i.needAnimate && (this._animateList[i.name] = i); + } else { + delete this._animateList[t]; + delete this._updateList[t]; + } + this._runAnimateList.length = 0; + for (let t = 0, e = hit.length; t < e; t++) { + const e = this._animateList[hit[t]]; + e && this._runAnimateList.push(e); + } + this.updateMaterialParams(); + } + updateAlignSpace(t) { + this._alignSpace = t; + } + getDefaultMaterial() { + return this._defaultMat; + } + updateRotation(t) { + t && this.doUpdateRotation(t); + } + doUpdateRotation(t) { + if (this._renderInfo.renderMode === mit.Mesh || this._alignSpace !== pit.View) { + if (this._alignSpace === pit.Local) this._particleSystem.node.getRotation(zlt); else if (this._alignSpace === pit.World) this._particleSystem.node.getWorldRotation(zlt); else if (this._alignSpace === pit.View) { + var e; + zlt.set(0, 0, 0, 1); + const t = null === (e = this._particleSystem.node.scene.renderScene) || void 0 === e ? void 0 : e.cameras; + if (void 0 !== t) for (let e = 0; e < (null == t ? void 0 : t.length); ++e) { + const i = t[e]; + if ((i.visibility & this._particleSystem.node.layer) === this._particleSystem.node.layer) { + Ui.fromViewUp(zlt, i.forward); + break; + } + } + } else zlt.set(0, 0, 0, 1); + t.setUniform(this._uNodeRotHandle, zlt); + } + } + updateScale(t) { + t && this.doUpdateScale(t); + } + doUpdateScale(t) { + switch (this._particleSystem.scaleSpace) { + case _it.Local: + this._particleSystem.node.getScale(this._node_scale); + break; + + case _it.World: + this._particleSystem.node.getWorldScale(this._node_scale); + } + t.setUniform(this._uScaleHandle, this._node_scale); + } + updateParticles(t) { + const e = this._particleSystem; + if (!e) return this._particles.length; + e.node.getWorldMatrix(Ult); + const i = (e.getMaterialInstance(0) || this._defaultMat).passes[0]; + this.doUpdateScale(i); + this.doUpdateRotation(i); + this._updateList.forEach(((t, i) => { + t.update(e._simulationSpace, Ult); + })); + const s = e._trailModule; + const n = s && s.enable; + n && s.update(); + if (e.simulationSpace === _it.Local) { + const t = e.node.getRotation(); + qi.fromQuat(this._localMat, t); + this._localMat.transpose(); + } + if (e.node.parent) { + e.node.parent.getWorldMatrix(Glt); + Glt.invert(); + } + for (let i = 0; i < this._particles.length; ++i) { + const r = this._particles.data[i]; + r.remainingLifetime -= t; + Pi.set(r.animatedVelocity, 0, 0, 0); + if (r.remainingLifetime < 0) { + n && s.removeParticle(r); + this._particles.removeAt(i); + --i; + } else { + if (e.simulationSpace === _it.Local) { + const i = 9.8 * -e.gravityModifier.evaluate(1 - r.remainingLifetime / r.startLifetime, Si(r.randomSeed)) * t; + this._gravity.x = 0; + this._gravity.y = i; + this._gravity.z = 0; + this._gravity.w = 1; + if (!ui(i, 0, hi)) { + e.node.parent && (this._gravity = this._gravity.transformMat4(Glt)); + this._gravity = this._gravity.transformMat4(this._localMat); + r.velocity.x += this._gravity.x; + r.velocity.y += this._gravity.y; + r.velocity.z += this._gravity.z; + } + } else r.velocity.y -= 9.8 * e.gravityModifier.evaluate(1 - r.remainingLifetime / r.startLifetime, Si(r.randomSeed)) * t; + Pi.copy(r.ultimateVelocity, r.velocity); + this._runAnimateList.forEach((e => { + e.animate(r, t); + })); + Pi.scaleAndAdd(r.position, r.position, r.ultimateVelocity, t); + n && s.animate(r, t); + } + } + this._model.enabled = this._particles.length > 0; + return this._particles.length; + } + getNoisePreview(t, e, i) { + this._runAnimateList.forEach((s => { + if (s.name === lit) { + s.getNoisePreview(t, this._particleSystem, e, i); + } + })); + } + updateRenderData() { + let t = 0; + for (let e = 0; e < this._particles.length; ++e) { + const i = this._particles.data[e]; + let s = 0; + const n = this._particleSystem._textureAnimationModule; + n && n.enable && (s = i.frameIndex); + t = 4 * e; + this._fillDataFunc(i, t, s); + } + } + beforeRender() { + this._model.updateIA(this._particles.length); + } + getParticleCount() { + return this._particles.length; + } + onMaterialModified(t, e) { + this._inited && (0 === t ? this.updateMaterialParams() : this.updateTrailMaterial()); + } + onRebuildPSO(t, e) { + this._model && 0 === t && this._model.setSubModelMaterial(0, e); + const i = this._particleSystem._trailModule; + i && i._trailModel && 1 === t && i._trailModel.setSubModelMaterial(0, e); + } + _setFillFunc() { + this._renderInfo.renderMode === mit.Mesh ? this._fillDataFunc = this._fillMeshData : this._renderInfo.renderMode === mit.StrecthedBillboard ? this._fillDataFunc = this._fillStrecthedData : this._fillDataFunc = this._fillNormalData; + } + _fillMeshData(t, e, i) { + const s = e / 4; + this._attrs[0] = t.position; + klt.z = i; + this._attrs[1] = klt; + this._attrs[2] = t.size; + this._attrs[3] = t.rotation; + this._attrs[4] = t.color._val; + this._model.addParticleVertexData(s, this._attrs); + } + _fillStrecthedData(t, e, i) { + if (this._useInstance) this._fillStrecthedDataIns(t, e, i); else for (let s = 0; s < 4; ++s) { + this._attrs[0] = t.position; + klt.x = jlt[2 * s]; + klt.y = jlt[2 * s + 1]; + klt.z = i; + this._attrs[1] = klt; + this._attrs[2] = t.size; + this._attrs[3] = t.rotation; + this._attrs[4] = t.color._val; + this._attrs[5] = t.ultimateVelocity; + this._attrs[6] = null; + this._model.addParticleVertexData(e++, this._attrs); + } + } + _fillStrecthedDataIns(t, e, i) { + const s = e / 4; + this._attrs[0] = t.position; + klt.z = i; + this._attrs[1] = klt; + this._attrs[2] = t.size; + this._attrs[3] = t.rotation; + this._attrs[4] = t.color._val; + this._attrs[5] = t.ultimateVelocity; + this._model.addParticleVertexData(s, this._attrs); + } + _fillNormalData(t, e, i) { + if (this._useInstance) this._fillNormalDataIns(t, e, i); else for (let s = 0; s < 4; ++s) { + this._attrs[0] = t.position; + klt.x = jlt[2 * s]; + klt.y = jlt[2 * s + 1]; + klt.z = i; + this._attrs[1] = klt; + this._attrs[2] = t.size; + this._attrs[3] = t.rotation; + this._attrs[4] = t.color._val; + this._attrs[5] = null; + this._model.addParticleVertexData(e++, this._attrs); + } + } + _fillNormalDataIns(t, e, i) { + const s = e / 4; + this._attrs[0] = t.position; + klt.z = i; + this._attrs[1] = klt; + this._attrs[2] = t.size; + this._attrs[3] = t.rotation; + this._attrs[4] = t.color._val; + this._attrs[5] = null; + this._model.addParticleVertexData(s, this._attrs); + } + updateVertexAttrib() { + if (this._renderInfo.renderMode === mit.Mesh && this._renderInfo.mesh) { + const t = this._renderInfo.mesh.readAttributeFormat(0, cr.ATTR_COLOR); + if (t) { + let e = bs.RGBA8; + for (let i = 0; i < ur.length; ++i) if (ur[i].name === t.name) { + e = i; + break; + } + this._vertAttrs[7] = new Vn(cr.ATTR_COLOR1, e, !0, this._useInstance ? 1 : 0); + } else { + const t = bs.RGBA8; + this._vertAttrs[7] = new Vn(cr.ATTR_COLOR1, t, !0, this._useInstance ? 1 : 0); + } + } + } + _setVertexAttrib() { + if (this._useInstance) this._setVertexAttribIns(); else switch (this._renderInfo.renderMode) { + case mit.StrecthedBillboard: + this._vertAttrs = Wlt.slice(); + break; + + case mit.Mesh: + this._vertAttrs = Ylt.slice(); + break; + + default: + this._vertAttrs = Xlt.slice(); + } + } + _setVertexAttribIns() { + switch (this._renderInfo.renderMode) { + case mit.StrecthedBillboard: + this._vertAttrs = Klt.slice(); + break; + + case mit.Mesh: + this._vertAttrs = Jlt.slice(); + break; + + default: + this._vertAttrs = qlt.slice(); + } + } + updateMaterialParams() { + if (!this._particleSystem) return; + const t = this._particleSystem; + const e = t.sharedMaterial; + if (null != e) { + e._effectAsset._name; + this._renderInfo.mainTexture = e.getProperty("mainTexture", 0); + } + if (null == t.sharedMaterial && null == this._defaultMat) { + Zlt.parent = xR.get("default-particle-material"); + Zlt.owner = this._particleSystem; + Zlt.subModelIdx = 0; + this._defaultMat = new uS(Zlt); + Zlt.parent = null; + Zlt.owner = null; + Zlt.subModelIdx = 0; + null !== this._renderInfo.mainTexture && this._defaultMat.setProperty("mainTexture", this._renderInfo.mainTexture); + } + const i = t.getMaterialInstance(0) || this._defaultMat; + t._simulationSpace === _it.World ? this._defines.CC_USE_WORLD_SPACE = !0 : this._defines.CC_USE_WORLD_SPACE = !1; + const s = i.passes[0]; + this._uScaleHandle = s.getHandle("scale"); + this._uLenHandle = s.getHandle("frameTile_velLenScale"); + this._uNodeRotHandle = s.getHandle("nodeRotation"); + const n = this._renderInfo.renderMode; + const r = this._frameTile_velLenScale; + if (n === mit.Billboard) this._defines.CC_RENDER_MODE = 0; else if (n === mit.StrecthedBillboard) { + this._defines.CC_RENDER_MODE = 1; + r.z = this._renderInfo.velocityScale; + r.w = this._renderInfo.lengthScale; + } else n === mit.HorizontalBillboard ? this._defines.CC_RENDER_MODE = 2 : n === mit.VerticalBillboard ? this._defines.CC_RENDER_MODE = 3 : n === mit.Mesh ? this._defines.CC_RENDER_MODE = 4 : console.warn(`particle system renderMode ${n} not support.`); + const o = t._textureAnimationModule; + if (o && o.enable) { + is.copy(this._tmp_velLenScale, r); + Qi.set(this._tmp_velLenScale, o.numTilesX, o.numTilesY); + s.setUniform(this._uLenHandle, this._tmp_velLenScale); + } else s.setUniform(this._uLenHandle, r); + let a = !1; + const l = this._particleSystem._rotationOvertimeModule; + a = l && l.enable; + this._defines.ROTATION_OVER_TIME_MODULE_ENABLE = a; + this._defines.CC_INSTANCE_PARTICLE = this._useInstance; + i.recompileShaders(this._defines); + this._model && this._model.updateMaterial(i); + } + updateTrailMaterial() { + if (!this._particleSystem) return; + const t = this._particleSystem; + const e = t._trailModule; + if (e && e.enable) { + t.simulationSpace === _it.World || e.space === _it.World ? this._trailDefines.CC_USE_WORLD_SPACE = !0 : this._trailDefines.CC_USE_WORLD_SPACE = !1; + let i = t.getMaterialInstance(1); + if (null === i && null === this._defaultTrailMat) { + Zlt.parent = xR.get("default-trail-material"); + Zlt.owner = this._particleSystem; + Zlt.subModelIdx = 1; + this._defaultTrailMat = new uS(Zlt); + Zlt.parent = null; + Zlt.owner = null; + Zlt.subModelIdx = 0; + } + i = i || this._defaultTrailMat; + i.recompileShaders(this._trailDefines); + e.updateMaterial(); + } + } + setUseInstance(t) { + if (this._useInstance !== t) { + this._useInstance = t; + if (this._model) { + this._model.useInstance = t; + this._model.doDestroy(); + } + this.updateRenderMode(); + } + } + } + const $lt = new qi; + const tht = new is; + const eht = new Ui; + const iht = new Ui; + new Pi; + const sht = 32; + const nht = "a_position_starttime", rht = "a_size_uv", oht = "a_rotation_uv", aht = "a_color", lht = "a_dir_life", hht = "a_rndSeed", cht = "a_size_fid", uht = "a_rotation_rnd", _ht = "a_uv"; + const dht = [ new Vn(nht, bs.RGBA32F), new Vn(rht, bs.RGBA32F), new Vn(oht, bs.RGBA32F), new Vn(aht, bs.RGBA32F), new Vn(lht, bs.RGBA32F), new Vn(hht, bs.R32F) ]; + const pht = [ new Vn(nht, bs.RGBA32F), new Vn(rht, bs.RGBA32F), new Vn(oht, bs.RGBA32F), new Vn(aht, bs.RGBA32F), new Vn(lht, bs.RGBA32F), new Vn(hht, bs.R32F), new Vn(cr.ATTR_TEX_COORD, bs.RGB32F), new Vn(cr.ATTR_TEX_COORD3, bs.RGB32F), new Vn(cr.ATTR_NORMAL, bs.RGB32F), new Vn(cr.ATTR_COLOR1, bs.RGBA8, !0) ]; + const mht = [ new Vn(nht, bs.RGBA32F, !1, 0, !0), new Vn(cht, bs.RGBA32F, !1, 0, !0), new Vn(uht, bs.RGBA32F, !1, 0, !0), new Vn(aht, bs.RGBA32F, !1, 0, !0), new Vn(lht, bs.RGBA32F, !1, 0, !0), new Vn(_ht, bs.RGB32F, !1, 1) ]; + const fht = [ new Vn(nht, bs.RGBA32F, !1, 0, !0), new Vn(cht, bs.RGBA32F, !1, 0, !0), new Vn(uht, bs.RGBA32F, !1, 0, !0), new Vn(aht, bs.RGBA32F, !1, 0, !0), new Vn(lht, bs.RGBA32F, !1, 0, !0), new Vn(cr.ATTR_TEX_COORD, bs.RGB32F, !1, 1), new Vn(cr.ATTR_TEX_COORD3, bs.RGB32F, !1, 1), new Vn(cr.ATTR_NORMAL, bs.RGB32F, !1, 1), new Vn(cr.ATTR_COLOR1, bs.RGBA8, !0, 1) ]; + const ght = { + parent: null, + owner: null, + subModelIdx: 0 + }; + class yht extends Flt { + constructor(t) { + super(t); + this._defines = void 0; + this._frameTile_velLenScale = void 0; + this._unifrom_velLenScale = void 0; + this._tmp_velLenScale = void 0; + this._node_scale = void 0; + this._vertAttrs = []; + this._defaultMat = null; + this._particleNum = 0; + this._tempParticle = null; + this._colorTexture = null; + this._forceTexture = null; + this._velocityTexture = null; + this._rotationTexture = null; + this._sizeTexture = null; + this._animTexture = null; + this._colorData = null; + this._forceData = null; + this._velocityData = null; + this._rotationData = null; + this._sizeData = null; + this._animData = null; + this._uTimeHandle = 0; + this._uRotHandle = 0; + this._uNodeRotHandle = 0; + this._alignSpace = pit.View; + this._inited = !1; + this._frameTile_velLenScale = new is(1, 1, 0, 0); + this._unifrom_velLenScale = this._frameTile_velLenScale.clone(); + this._tmp_velLenScale = this._frameTile_velLenScale.clone(); + this._node_scale = new is; + this._defines = { + CC_USE_WORLD_SPACE: !0, + CC_USE_BILLBOARD: !0, + CC_USE_STRETCHED_BILLBOARD: !1, + CC_USE_HORIZONTAL_BILLBOARD: !1, + CC_USE_VERTICAL_BILLBOARD: !1, + COLOR_OVER_TIME_MODULE_ENABLE: !1 + }; + this._tempParticle = new tit(null); + this._particleNum = 0; + } + onInit(t) { + super.onInit(t); + this._setVertexAttrib(); + this._initModel(); + this.updateMaterialParams(); + this.setVertexAttributes(); + this._inited = !0; + } + updateRenderMode() { + this._setVertexAttrib(); + this.updateMaterialParams(); + this.setVertexAttributes(); + } + setVertexAttributes() { + super.setVertexAttributes(); + this._model.constructAttributeIndex(); + } + clear() { + super.clear(); + this._particleNum = 0; + this.updateRenderData(); + } + onDestroy() { + super.onDestroy(); + this._forceTexture && this._forceTexture.destroy(); + this._velocityTexture && this._velocityTexture.destroy(); + this._colorTexture && this._colorTexture.destroy(); + this._sizeTexture && this._sizeTexture.destroy(); + this._rotationTexture && this._rotationTexture.destroy(); + this._animTexture && this._animTexture.destroy(); + this._forceData = null; + this._velocityData = null; + this._colorData = null; + this._sizeData = null; + this._rotationData = null; + this._animData = null; + } + enableModule(t, e, i) { + const s = this._particleSystem.getMaterialInstance(0) || this._defaultMat; + if (s) { + this.initShaderUniform(s); + s.recompileShaders(this._defines); + this._model && this._model.setSubModelMaterial(0, s); + } + } + getFreeParticle() { + return this._particleNum >= this._particleSystem._capacity ? null : this._tempParticle; + } + setNewParticle(t) { + this._model.addGPUParticleVertexData(t, this._particleNum, this._particleSystem._time); + this._particleNum++; + } + getDefaultMaterial() { + return this._defaultMat; + } + updateRotation(t) { + t && this.doUpdateRotation(t); + } + doUpdateRotation(t) { + if (this._renderInfo.renderMode === mit.Mesh || this._alignSpace !== pit.View) { + if (this._alignSpace === pit.Local) this._particleSystem.node.getRotation(iht); else if (this._alignSpace === pit.World) this._particleSystem.node.getWorldRotation(iht); else if (this._alignSpace === pit.View) { + var e; + iht.set(0, 0, 0, 1); + const t = null === (e = this._particleSystem.node.scene.renderScene) || void 0 === e ? void 0 : e.cameras; + if (void 0 !== t) for (let e = 0; e < (null == t ? void 0 : t.length); ++e) { + const i = t[e]; + if ((i.visibility & this._particleSystem.node.layer) === this._particleSystem.node.layer) { + Ui.fromViewUp(iht, i.forward); + break; + } + } + } else iht.set(0, 0, 0, 1); + t.setUniform(this._uNodeRotHandle, iht); + } + } + updateScale(t) { + t && this.doUpdateScale(t); + } + doUpdateScale(t) { + switch (this._particleSystem.scaleSpace) { + case _it.Local: + this._particleSystem.node.getScale(this._node_scale); + break; + + case _it.World: + this._particleSystem.node.getWorldScale(this._node_scale); + } + t.setUniform(t.getHandle("scale"), this._node_scale); + } + updateParticles(t) { + this._particleNum = this._model.updateGPUParticles(this._particleNum, this._particleSystem._time, t); + this.updateShaderUniform(t); + this._model.enabled = this._particleNum > 0; + return this._particleNum; + } + updateRenderData() {} + beforeRender() { + this._model.updateIA(this._particleNum); + } + updateAlignSpace(t) { + this._alignSpace = t; + } + updateShaderUniform(t) { + const e = this._particleSystem.getMaterialInstance(0) || this._defaultMat; + if (!e) return; + const i = e.passes[0]; + tht.x = this._particleSystem._time; + tht.y = t; + i.setUniform(this._uTimeHandle, tht); + this._particleSystem.node.getWorldRotation(eht); + i.setUniform(this._uRotHandle, eht); + this.doUpdateRotation(i); + } + initShaderUniform(t) { + const e = t.passes[0]; + this._uTimeHandle = e.getHandle("u_timeDelta"); + this._uRotHandle = e.getHandle("u_worldRot"); + this._uNodeRotHandle = e.getHandle("nodeRotation"); + this.doUpdateScale(e); + e.setUniform(e.getHandle("frameTile_velLenScale"), this._unifrom_velLenScale); + tht.x = sht; + tht.y = .03125; + e.setUniform(e.getHandle("u_sampleInfo"), tht); + let i = !1; + const s = this._particleSystem._forceOvertimeModule; + i = s && s.enable; + this._defines.FORCE_OVER_TIME_MODULE_ENABLE = i; + if (i) { + const t = Ltt(this._forceTexture, this._forceData, sht, s.x, s.y, s.z); + this._forceTexture = t.texture; + this._forceData = t.texdata; + const i = e.getHandle("force_over_time_tex0"); + const n = XP.getBindingFromHandle(i); + e.bindSampler(n, this._forceTexture.getGFXSampler()); + e.bindTexture(n, this._forceTexture.getGFXTexture()); + const r = e.getHandle("u_force_space"); + e.setUniform(r, s.space); + const o = e.getHandle("u_force_mode"); + e.setUniform(o, this._forceTexture.height); + } + const n = this._particleSystem._velocityOvertimeModule; + i = n && n.enable; + this._defines.VELOCITY_OVER_TIME_MODULE_ENABLE = i; + if (i) { + const t = function(t, e, i, s, n, r, o, a) { + const l = Math.max(Ott(s), Ott(n), Ott(r), Ott(o)); + const h = i * l * 4; + null !== e && e.length === h || (e = new Float32Array(i * l * 4)); + const c = [ s, n, r, o ]; + const u = 1 / (i - 1); + for (let t = 0; t < l; t++) for (let s = 0; s < 4; s++) { + const n = c[s]; + let r = 0; + let o = 0; + for (let l = 0; l < i; l++) { + const h = Ptt(n, u * l, t); + if (a) o = h; else { + r += h; + o = r / (l + 1); + } + e[4 * (t * i + l) + s] = o; + } + } + return { + texture: Ntt(t, e, i, l), + texdata: e + }; + }(this._velocityTexture, this._velocityData, sht, n.x, n.y, n.z, n.speedModifier); + this._velocityTexture = t.texture; + this._velocityData = t.texdata; + const i = e.getHandle("velocity_over_time_tex0"); + const s = XP.getBindingFromHandle(i); + e.bindSampler(s, this._velocityTexture.getGFXSampler()); + e.bindTexture(s, this._velocityTexture.getGFXTexture()); + const r = e.getHandle("u_velocity_space"); + e.setUniform(r, n.space); + const o = e.getHandle("u_velocity_mode"); + e.setUniform(o, this._velocityTexture.height); + } + const r = this._particleSystem._colorOverLifetimeModule; + i = r && r.enable; + this._defines.COLOR_OVER_TIME_MODULE_ENABLE = i; + if (i) { + const t = aet(this._colorTexture, this._colorData, sht, r.color); + this._colorTexture = t.texture; + this._colorData = t.texdata; + const i = e.getHandle("color_over_time_tex0"); + const s = XP.getBindingFromHandle(i); + e.bindSampler(s, this._colorTexture.getGFXSampler()); + e.bindTexture(s, this._colorTexture.getGFXTexture()); + const n = e.getHandle("u_color_mode"); + e.setUniform(n, this._colorTexture.height); + } + const o = this._particleSystem._rotationOvertimeModule; + i = o && o.enable; + this._defines.ROTATION_OVER_TIME_MODULE_ENABLE = i; + if (i) { + let t; + t = o.separateAxes ? Ltt(this._rotationTexture, this._rotationData, sht, o.x, o.y, o.z) : function(t, e, i, s, n) { + const r = Ott(s); + const o = i * r * 4; + null !== e && e.length === o || (e = new Float32Array(i * r * 4)); + const a = 1 / (i - 1); + let l = 0; + for (let t = 0; t < r; t++) for (let n = 0; n < i; n++) { + const i = Ptt(s, a * n, t); + e[l + 2] = i; + l += 4; + } + return { + texture: Ntt(t, e, i, r), + texdata: e + }; + }(this._rotationTexture, this._rotationData, sht, o.z); + this._rotationTexture = t.texture; + this._rotationData = t.texdata; + if (this._rotationTexture) { + const t = e.getHandle("rotation_over_time_tex0"); + const i = XP.getBindingFromHandle(t); + e.bindSampler(i, this._rotationTexture.getGFXSampler()); + e.bindTexture(i, this._rotationTexture.getGFXTexture()); + const s = e.getHandle("u_rotation_mode"); + e.setUniform(s, this._rotationTexture.height); + } + } + const a = this._particleSystem._sizeOvertimeModule; + i = a && a.enable; + this._defines.SIZE_OVER_TIME_MODULE_ENABLE = i; + if (i) { + let t; + t = a.separateAxes ? Ltt(this._sizeTexture, this._sizeData, sht, a.x, a.y, a.z, !0) : function(t, e, i, s, n) { + const r = Ott(s); + const o = i * r * 4; + null !== e && e.length === o || (e = new Float32Array(i * r * 4)); + const a = 1 / (i - 1); + let l = 0; + let h = 0; + let c = 0; + for (let t = 0; t < r; t++) { + l = 0; + for (let r = 0; r < i; r++) { + const i = Ptt(s, a * r, t); + if (n) h = i; else { + l += i; + h = l / (r + 1); + } + e[c] = h; + e[c + 1] = h; + e[c + 2] = h; + c += 4; + } + } + return { + texture: Ntt(t, e, i, r), + texdata: e + }; + }(this._sizeTexture, this._sizeData, sht, a.size, !0); + this._sizeTexture = t.texture; + this._sizeData = t.texdata; + if (this._sizeTexture) { + const t = e.getHandle("size_over_time_tex0"); + const i = XP.getBindingFromHandle(t); + e.bindSampler(i, this._sizeTexture.getGFXSampler()); + e.bindTexture(i, this._sizeTexture.getGFXTexture()); + const s = e.getHandle("u_size_mode"); + e.setUniform(s, this._sizeTexture.height); + } + } + const l = this._particleSystem._textureAnimationModule; + i = l && l.enable; + this._defines.TEXTURE_ANIMATION_MODULE_ENABLE = i; + if (i) { + const t = function(t, e, i, s, n, r) { + const o = Math.max(Ott(s), Ott(n)); + const a = i * o * 4; + null !== e && e.length === a || (e = new Float32Array(i * o * 4)); + const l = [ s, n ]; + const h = 1 / (i - 1); + for (let t = 0; t < o; t++) for (let s = 0; s < 2; s++) { + const n = l[s]; + let o = 0; + let a = 0; + for (let l = 0; l < i; l++) { + const c = Ptt(n, h * l, t); + if (r) a = c; else { + o += c; + a = o / (l + 1); + } + e[4 * (t * i + l) + s] = a; + } + } + return { + texture: Ntt(t, e, i, o), + texdata: e + }; + }(this._animTexture, this._animData, sht, l.startFrame, l.frameOverTime, !0); + this._animTexture = t.texture; + this._animData = t.texdata; + const i = e.getHandle("texture_animation_tex0"); + const s = XP.getBindingFromHandle(i); + e.bindSampler(s, this._animTexture.getGFXSampler()); + e.bindTexture(s, this._animTexture.getGFXTexture()); + const n = e.getHandle("u_anim_info"); + tht.x = this._animTexture.height; + tht.y = l.numTilesX * l.numTilesY; + tht.z = l.cycleCount; + e.setUniform(n, tht); + } + this._defines.USE_VK_SHADER = zo.gfxDevice.gfxAPI === fs.VULKAN; + this._defines.CC_INSTANCE_PARTICLE = this._useInstance; + } + getParticleCount() { + return this._particleNum; + } + onMaterialModified(t, e) { + this._inited && this.updateMaterialParams(); + } + onRebuildPSO(t, e) { + this._model && 0 === t && this._model.setSubModelMaterial(0, e); + } + updateVertexAttrib() { + if (this._renderInfo.renderMode === mit.Mesh && this._renderInfo.mesh) { + const t = this._renderInfo.mesh.readAttributeFormat(0, cr.ATTR_COLOR); + if (t) { + let e = bs.RGBA8; + for (let i = 0; i < ur.length; ++i) if (ur[i].name === t.name) { + e = i; + break; + } + this._vertAttrs[9] = new Vn(cr.ATTR_COLOR1, e, !0, this._useInstance ? 1 : 0); + } else { + const t = bs.RGBA8; + this._vertAttrs[9] = new Vn(cr.ATTR_COLOR1, t, !0, this._useInstance ? 1 : 0); + } + } + } + _setVertexAttrib() { + if (this._useInstance) this._setVertexAttribIns(); else switch (this._renderInfo.renderMode) { + case mit.StrecthedBillboard: + this._vertAttrs = dht.slice(); + break; + + case mit.Mesh: + this._vertAttrs = pht.slice(); + break; + + default: + this._vertAttrs = dht.slice(); + } + } + _setVertexAttribIns() { + switch (this._renderInfo.renderMode) { + case mit.StrecthedBillboard: + this._vertAttrs = mht.slice(); + break; + + case mit.Mesh: + this._vertAttrs = fht.slice(); + break; + + default: + this._vertAttrs = mht.slice(); + } + } + updateMaterialParams() { + if (!this._particleSystem) return; + const t = this._particleSystem; + const e = t.sharedMaterial; + if (null !== e) { + e._effectAsset._name; + this._renderInfo.mainTexture = e.getProperty("mainTexture", 0); + } + if (null == t.sharedMaterial && null == this._defaultMat) { + ght.parent = xR.get("default-particle-gpu-material"); + ght.owner = t; + ght.subModelIdx = 0; + this._defaultMat = new uS(ght); + ght.parent = null; + ght.owner = null; + ght.subModelIdx = 0; + null !== this._renderInfo.mainTexture && this._defaultMat.setProperty("mainTexture", this._renderInfo.mainTexture); + } + const i = t.getMaterialInstance(0) || this._defaultMat; + t.node.getWorldMatrix($lt); + t._simulationSpace === _it.World ? this._defines.CC_USE_WORLD_SPACE = !0 : this._defines.CC_USE_WORLD_SPACE = !1; + const s = this._renderInfo.renderMode; + if (s === mit.Billboard) this._defines.CC_RENDER_MODE = 0; else if (s === mit.StrecthedBillboard) { + this._defines.CC_RENDER_MODE = 1; + this._frameTile_velLenScale.z = this._renderInfo.velocityScale; + this._frameTile_velLenScale.w = this._renderInfo.lengthScale; + } else s === mit.HorizontalBillboard ? this._defines.CC_RENDER_MODE = 2 : s === mit.VerticalBillboard ? this._defines.CC_RENDER_MODE = 3 : s === mit.Mesh ? this._defines.CC_RENDER_MODE = 4 : console.warn(`particle system renderMode ${s} not support.`); + const n = t._textureAnimationModule; + if (n && n.enable) { + Qi.set(this._frameTile_velLenScale, n.numTilesX, n.numTilesY); + is.copy(this._unifrom_velLenScale, this._frameTile_velLenScale); + } else { + this._tmp_velLenScale.z = this._frameTile_velLenScale.z; + this._tmp_velLenScale.w = this._frameTile_velLenScale.w; + is.copy(this._unifrom_velLenScale, this._tmp_velLenScale); + } + this.initShaderUniform(i); + i.recompileShaders(this._defines); + this._model && this._model.updateMaterial(i); + } + setUseInstance(t) { + if (this._useInstance !== t) { + this._useInstance = t; + if (this._model) { + this._model.useInstance = t; + this._model.doDestroy(); + } + this.updateRenderMode(); + } + } + getNoisePreview(t, e, i) {} + } + var bht, Sht, Aht, Tht, vht, Eht, Cht, xht, wht, Rht, Iht, Mht, Bht, Dht, Pht, Oht, Nht, Lht, Fht, Vht, kht, Uht, Ght, zht, Hht, jht, Xht, Wht, Yht, qht, Kht, Jht, Zht, Qht, $ht, tct, ect, ict, sct, nct, rct, oct, act, lct; + function hct() { + const t = IR.root.device; + if (t.capabilities.maxVertexTextureUnits >= 8 && t.getFormatFeatures(bs.RGBA32F) & (Is.RENDER_TARGET | Is.SAMPLED_TEXTURE)) return !0; + m.warn("Maybe the device has restrictions on vertex textures or does not support float textures."); + return !1; + } + let cct = (bht = Ul("cc.ParticleSystemRenderer"), Sht = Th(mit), Aht = ph(), Tht = lh(), + vht = ph(), Eht = lh(), Cht = ph(), xht = lh(), wht = Th(mit), Rht = Th(Ez), Iht = ph(), + Mht = lh(), Bht = Th(hm), Dht = ph(), Pht = rh(), Oht = lh(), Nht = Th(hm), Lht = ph(), + Fht = rh(), Vht = Th(hm), kht = ph(), Uht = rh(), Ght = Th(hm), zht = ph(), Hht = rh(), + jht = lh(), Xht = ph(), Wht = lh(), Yht = Th(pit), qht = ph(), Kht = lh(), bht(Jht = (Bl((Zht = (lct = act = class { + constructor() { + Ml(this, "_renderMode", Qht, this); + Ml(this, "_velocityScale", $ht, this); + Ml(this, "_lengthScale", tct, this); + Ml(this, "_mesh", ect, this); + Ml(this, "_cpuMaterial", ict, this); + Ml(this, "_gpuMaterial", sct, this); + Ml(this, "_mainTexture", nct, this); + Ml(this, "_useGPU", rct, this); + Ml(this, "_alignSpace", oct, this); + this._particleSystem = null; + } + get renderMode() { + return this._renderMode; + } + set renderMode(t) { + if (this._renderMode !== t) { + this._renderMode = t; + this._particleSystem && this._particleSystem.processor.updateRenderMode(); + } + } + get velocityScale() { + return this._velocityScale; + } + set velocityScale(t) { + this._velocityScale = t; + this._particleSystem && this._particleSystem.processor.updateMaterialParams(); + } + get lengthScale() { + return this._lengthScale; + } + set lengthScale(t) { + this._lengthScale = t; + this._particleSystem && this._particleSystem.processor.updateMaterialParams(); + } + get mesh() { + return this._mesh; + } + set mesh(t) { + this._mesh = t; + this._particleSystem && this._particleSystem.processor.setVertexAttributes(); + } + get particleMaterial() { + return this._particleSystem ? this._particleSystem.getMaterial(0) : null; + } + set particleMaterial(t) { + this._particleSystem && this._particleSystem.setMaterial(t, 0); + } + get cpuMaterial() { + return this._cpuMaterial; + } + set cpuMaterial(t) { + if (null !== t) { + { + const e = t.effectName; + if (-1 === e.indexOf("particle") || -1 !== e.indexOf("particle-gpu")) { + N(6035); + return; + } + } + this._cpuMaterial = t; + this.particleMaterial = this._cpuMaterial; + } + } + get gpuMaterial() { + return this._gpuMaterial; + } + set gpuMaterial(t) { + if (null !== t) { + if (-1 === t.effectName.indexOf("particle-gpu")) { + N(6035); + return; + } + this._gpuMaterial = t; + this.particleMaterial = this._gpuMaterial; + } + } + get trailMaterial() { + return this._particleSystem ? this._particleSystem.getMaterial(1) : null; + } + set trailMaterial(t) { + this._particleSystem && this._particleSystem.setMaterial(t, 1); + } + get mainTexture() { + return this._mainTexture; + } + set mainTexture(t) { + this._mainTexture = t; + } + get useGPU() { + return this._useGPU; + } + set useGPU(t) { + if (this._useGPU !== t) { + hct() ? this._useGPU = t : this._useGPU = !1; + this._switchProcessor(); + } + } + get alignSpace() { + return this._alignSpace; + } + set alignSpace(t) { + this._alignSpace = t; + this._particleSystem.processor.updateAlignSpace(this._alignSpace); + } + create(t) { + null === this._particleSystem ? this._particleSystem = t : this._particleSystem !== t && F(6033); + } + onInit(t) { + this.create(t); + const e = this._useGPU && hct(); + if (this._particleSystem.processor) F(6034); else { + this._particleSystem.processor = e ? new yht(this) : new Qlt(this); + this._particleSystem.processor.updateAlignSpace(this.alignSpace); + this._particleSystem.processor.onInit(t); + } + if (e) this.gpuMaterial = this.particleMaterial; else { + if (this.particleMaterial && -1 !== this.particleMaterial.effectName.indexOf("particle-gpu")) { + this.particleMaterial = null; + N(6035); + } + this.cpuMaterial = this.particleMaterial; + } + } + _switchProcessor() { + if (!this._particleSystem) return; + if (this._particleSystem.processor) { + this._particleSystem.processor.detachFromScene(); + this._particleSystem.processor.clear(); + this._particleSystem.processor = null; + } + const t = this._useGPU && hct(); + !t && this.cpuMaterial && (this.particleMaterial = this.cpuMaterial); + t && this.gpuMaterial && (this.particleMaterial = this.gpuMaterial); + this._particleSystem.processor = t ? new yht(this) : new Qlt(this); + this._particleSystem.processor.updateAlignSpace(this.alignSpace); + this._particleSystem.processor.onInit(this._particleSystem); + this._particleSystem.processor.onEnable(); + this._particleSystem.bindModule(); + } + }, act.AlignmentSpace = pit, lct)).prototype, "renderMode", [ Sht, Aht, Tht ], Object.getOwnPropertyDescriptor(Zht.prototype, "renderMode"), Zht.prototype), + Bl(Zht.prototype, "velocityScale", [ vht, Eht ], Object.getOwnPropertyDescriptor(Zht.prototype, "velocityScale"), Zht.prototype), + Bl(Zht.prototype, "lengthScale", [ Cht, xht ], Object.getOwnPropertyDescriptor(Zht.prototype, "lengthScale"), Zht.prototype), + Qht = Bl(Zht.prototype, "_renderMode", [ wht, Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return mit.Billboard; + } + }), $ht = Bl(Zht.prototype, "_velocityScale", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), tct = Bl(Zht.prototype, "_lengthScale", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), ect = Bl(Zht.prototype, "_mesh", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Bl(Zht.prototype, "mesh", [ Rht, Iht, Mht ], Object.getOwnPropertyDescriptor(Zht.prototype, "mesh"), Zht.prototype), + Bl(Zht.prototype, "particleMaterial", [ Bht, Dht, gh, Pht, Oht ], Object.getOwnPropertyDescriptor(Zht.prototype, "particleMaterial"), Zht.prototype), + Bl(Zht.prototype, "cpuMaterial", [ Nht, Lht, gh, Fht ], Object.getOwnPropertyDescriptor(Zht.prototype, "cpuMaterial"), Zht.prototype), + ict = Bl(Zht.prototype, "_cpuMaterial", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Bl(Zht.prototype, "gpuMaterial", [ Vht, kht, gh, Uht ], Object.getOwnPropertyDescriptor(Zht.prototype, "gpuMaterial"), Zht.prototype), + sct = Bl(Zht.prototype, "_gpuMaterial", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Bl(Zht.prototype, "trailMaterial", [ Ght, zht, gh, Hht, jht ], Object.getOwnPropertyDescriptor(Zht.prototype, "trailMaterial"), Zht.prototype), + nct = Bl(Zht.prototype, "_mainTexture", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), rct = Bl(Zht.prototype, "_useGPU", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Bl(Zht.prototype, "useGPU", [ Xht, Wht ], Object.getOwnPropertyDescriptor(Zht.prototype, "useGPU"), Zht.prototype), + Bl(Zht.prototype, "alignSpace", [ Yht, qht, Kht ], Object.getOwnPropertyDescriptor(Zht.prototype, "alignSpace"), Zht.prototype), + oct = Bl(Zht.prototype, "_alignSpace", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return pit.View; + } + }), Zht)) || Jht); + var uct, _ct, dct, pct, mct, fct, gct, yct, bct, Sct, Act, Tct, vct, Ect, Cct, xct, wct, Rct, Ict, Mct, Bct, Dct, Pct, Oct, Nct, Lct, Fct, Vct, kct, Uct, Gct, zct, Hct, jct, Xct, Wct, Yct, qct, Kct, Jct, Zct, Qct, $ct, tut, eut, iut, sut, nut; + const rut = Math.cos(mi(100)); + const out = { + position: new Pi, + velocity: new Pi + }; + const aut = new Ui; + const lut = new qi; + const hut = new Pi; + const cut = new Pi; + const uut = new Bi; + class _ut { + constructor(t) { + this.start = void 0; + this.end = void 0; + this.trailElements = void 0; + this.start = -1; + this.end = -1; + this.trailElements = []; + for (;t--; ) this.trailElements.push({ + position: new Pi, + lifetime: 0, + width: 0, + velocity: new Pi, + direction: 0, + color: new Bi + }); + } + getElement(t) { + if (-1 === this.start) return null; + t < 0 && (t = (t + this.trailElements.length) % this.trailElements.length); + t >= this.trailElements.length && (t %= this.trailElements.length); + return this.trailElements[t]; + } + addElement() { + if (0 === this.trailElements.length) return null; + if (-1 === this.start) { + this.start = 0; + this.end = 1; + return this.trailElements[0]; + } + if (this.start === this.end) { + this.trailElements.splice(this.end, 0, { + position: new Pi, + lifetime: 0, + width: 0, + velocity: new Pi, + direction: 0, + color: new Bi + }); + this.start++; + this.start %= this.trailElements.length; + } + const t = this.end++; + this.end %= this.trailElements.length; + return this.trailElements[t]; + } + iterateElement(t, e, i, s) { + const n = this.start >= this.end ? this.end + this.trailElements.length : this.end; + for (let r = this.start; r < n; r++) if (e(t, this.trailElements[r % this.trailElements.length], i, s)) { + this.start++; + this.start %= this.trailElements.length; + } + if (this.start === n) { + this.start = -1; + this.end = -1; + } + } + count() { + return this.start < this.end ? this.end - this.start : this.trailElements.length + this.end - this.start; + } + clear() { + this.start = -1; + this.end = -1; + } + } + let dut = (uct = Ul("cc.TrailModule"), _ct = ph(), dct = Th(bit), pct = ph(), mct = lh(), + fct = Th(Dtt), gct = hh(), yct = ph(), bct = lh(), Sct = ph(), Act = lh(), Tct = Th(_it), + vct = ph(), Ect = lh(), Cct = Th(Sit), xct = ph(), wct = lh(), Rct = ph(), Ict = lh(), + Mct = Th(Dtt), Bct = hh(), Dct = ph(), Pct = lh(), Oct = ph(), Nct = lh(), Lct = Th(ret), + Fct = ph(), Vct = lh(), kct = Th(ret), Uct = ph(), Gct = lh(), zct = Th(_it), uct(Hct = (jct = (nut = class { + get enable() { + return this._enable; + } + set enable(t) { + if (t !== this._enable || !this._trailModel) { + if (t && !this._enable) { + this._enable = t; + this._particleSystem.processor && this._particleSystem.processor.updateTrailMaterial(); + } + if (t && !this._trailModel) { + this._createModel(); + this.rebuild(); + } + this._enable = t; + this._trailModel && (this._trailModel.enabled = t); + t ? this.onEnable() : this.onDisable(); + } + } + get minParticleDistance() { + return this._minParticleDistance; + } + set minParticleDistance(t) { + this._minParticleDistance = t; + this._minSquaredDistance = t * t; + } + get space() { + return this._space; + } + set space(t) { + this._space = t; + const e = this._particleSystem; + e && e.processor && e.processor.updateTrailMaterial(); + } + getModel() { + return this._trailModel; + } + constructor() { + Ml(this, "_enable", Xct, this); + Ml(this, "mode", Wct, this); + Ml(this, "lifeTime", Yct, this); + Ml(this, "_minParticleDistance", qct, this); + Ml(this, "existWithParticles", Kct, this); + Ml(this, "textureMode", Jct, this); + Ml(this, "widthFromParticle", Zct, this); + Ml(this, "widthRatio", Qct, this); + Ml(this, "colorFromParticle", $ct, this); + Ml(this, "colorOverTrail", tut, this); + Ml(this, "colorOvertime", eut, this); + Ml(this, "_space", iut, this); + Ml(this, "_particleSystem", sut, this); + this._minSquaredDistance = 0; + this._vertSize = void 0; + this._trailNum = 0; + this._trailLifetime = 0; + this.vbOffset = 0; + this.ibOffset = 0; + this._trailSegments = null; + this._particleTrail = void 0; + this._trailModel = null; + this._iaInfo = void 0; + this._iaInfoBuffer = null; + this._subMeshData = null; + this._vertAttrs = void 0; + this._vbF32 = null; + this._vbUint32 = null; + this._iBuffer = null; + this._needTransform = !1; + this._material = null; + this._iaInfo = new Cn([ new vn ]); + this._vertAttrs = [ new Vn(cr.ATTR_POSITION, bs.RGB32F), new Vn(cr.ATTR_TEX_COORD, bs.RGBA32F), new Vn(cr.ATTR_TEX_COORD1, bs.RGB32F), new Vn(cr.ATTR_COLOR, bs.RGBA8, !0) ]; + this._vertSize = 0; + for (const t of this._vertAttrs) this._vertSize += ur[t.format].size; + this._particleTrail = new Map; + } + onInit(t) { + this._particleSystem = t; + this.minParticleDistance = this._minParticleDistance; + let e = 0; + const i = t.startLifetime.getMax(); + const s = t.rateOverTime.getMax(); + const n = t.duration; + for (let s = 0, r = t.bursts.length; s < r; s++) { + e += t.bursts[s].getMaxCount(t) * Math.ceil(i / n); + } + this.lifeTime.getMax() < 1 && N(6036); + this._trailNum = Math.ceil(i * Math.ceil(this.lifeTime.getMax()) * 60 * (s * n + e)); + this._trailSegments = new $r((() => new _ut(10)), Math.ceil(s * n), (t => t.trailElements.length = 0)); + this._enable && (this.enable = this._enable); + } + onEnable() { + this._attachToScene(); + } + onDisable() { + this._particleTrail.clear(); + this._detachFromScene(); + } + _attachToScene() { + if (this._trailModel) { + this._trailModel.scene && this._detachFromScene(); + this._particleSystem._getRenderScene().addModel(this._trailModel); + } + } + _detachFromScene() { + this._trailModel && this._trailModel.scene && this._trailModel.scene.removeModel(this._trailModel); + } + destroy() { + this.destroySubMeshData(); + if (this._trailModel) { + IR.root.destroyModel(this._trailModel); + this._trailModel = null; + } + if (this._trailSegments) { + this._trailSegments.destroy(); + this._trailSegments = null; + } + } + play() { + this._trailModel && this._enable && (this._trailModel.enabled = !0); + } + clear() { + if (this.enable) { + const t = this._particleTrail.values(); + let e = t.next(); + for (;!e.done; ) { + e.value.clear(); + e = t.next(); + } + this._particleTrail.clear(); + this.updateRenderData(); + this._trailModel && (this._trailModel.enabled = !1); + } + } + updateMaterial() { + if (this._particleSystem) { + this._material = this._particleSystem.getMaterialInstance(1) || this._particleSystem.processor._defaultTrailMat; + this._trailModel && this._trailModel.setSubModelMaterial(0, this._material); + } + } + update() { + this._trailLifetime = this.lifeTime.evaluate(this._particleSystem._time, 1); + if (this.space === _it.World && this._particleSystem._simulationSpace === _it.Local) { + this._needTransform = !0; + this._particleSystem.node.getWorldMatrix(lut); + this._particleSystem.node.getWorldRotation(aut); + } else this._needTransform = !1; + } + animate(t, e) { + if (!this._trailSegments) return; + if (t.loopCount > t.lastLoop) { + if (t.trailDelay > 1) { + t.lastLoop = t.loopCount; + t.trailDelay = 0; + } else t.trailDelay++; + return; + } + let i = this._particleTrail.get(t); + if (!i) { + i = this._trailSegments.alloc(); + this._particleTrail.set(t, i); + return; + } + let s = i.getElement(i.end - 1); + this._needTransform ? Pi.transformMat4(hut, t.position, lut) : Pi.copy(hut, t.position); + if (s) { + i.iterateElement(this, this._updateTrailElement, t, e); + if (Pi.squaredDistance(s.position, hut) < this._minSquaredDistance) return; + } + s = i.addElement(); + if (!s) return; + Pi.copy(s.position, hut); + s.lifetime = 0; + this.widthFromParticle ? s.width = t.size.x * this.widthRatio.evaluate(0, 1) : s.width = this.widthRatio.evaluate(0, 1); + const n = i.count(); + if (2 === n) { + const t = i.getElement(i.end - 2); + Pi.subtract(t.velocity, s.position, t.position); + } else if (n > 2) { + const t = i.getElement(i.end - 2); + const e = i.getElement(i.end - 3); + Pi.subtract(hut, e.position, t.position); + Pi.subtract(cut, s.position, t.position); + Pi.subtract(t.velocity, cut, hut); + Pi.equals(Pi.ZERO, t.velocity) && Pi.copy(t.velocity, hut); + Pi.normalize(t.velocity, t.velocity); + this._checkDirectionReverse(t, e); + } + this.colorFromParticle ? s.color.set(t.color) : s.color.set(this.colorOvertime.evaluate(0, 1)); + } + removeParticle(t) { + const e = this._particleTrail.get(t); + if (e && this._trailSegments) { + e.clear(); + this._trailSegments.free(e); + this._particleTrail.delete(t); + } + } + updateRenderData() { + this.vbOffset = 0; + this.ibOffset = 0; + for (const t of this._particleTrail.keys()) { + const e = this._particleTrail.get(t); + if (-1 === e.start) continue; + const i = 4 * this.vbOffset / this._vertSize; + const s = e.start >= e.end ? e.end + e.trailElements.length : e.end; + const n = s - e.start; + const r = 1 / n; + const o = e.trailElements[e.start]; + this._fillVertexBuffer(o, this.colorOverTrail.evaluate(1, 1), i, 1, 0, 4); + for (let t = e.start + 1; t < s; t++) { + const s = e.trailElements[t % e.trailElements.length]; + const o = t - e.start; + this._fillVertexBuffer(s, this.colorOverTrail.evaluate(1 - o / n, 1), i, 1 - o * r, o, 5); + } + this._needTransform ? Pi.transformMat4(out.position, t.position, lut) : Pi.copy(out.position, t.position); + const a = this._trailModel; + a && a.node.invalidateChildren(ay.POSITION); + if (1 === n || 2 === n) { + const t = e.getElement(e.end - 1); + Pi.subtract(t.velocity, out.position, t.position); + this._vbF32[this.vbOffset - this._vertSize / 4 - 4] = t.velocity.x; + this._vbF32[this.vbOffset - this._vertSize / 4 - 3] = t.velocity.y; + this._vbF32[this.vbOffset - this._vertSize / 4 - 2] = t.velocity.z; + this._vbF32[this.vbOffset - 4] = t.velocity.x; + this._vbF32[this.vbOffset - 3] = t.velocity.y; + this._vbF32[this.vbOffset - 2] = t.velocity.z; + Pi.subtract(out.velocity, out.position, t.position); + this._checkDirectionReverse(out, t); + } else if (n > 2) { + const t = e.getElement(e.end - 1); + const s = e.getElement(e.end - 2); + Pi.subtract(hut, s.position, t.position); + Pi.subtract(cut, out.position, t.position); + Pi.normalize(hut, hut); + Pi.normalize(cut, cut); + Pi.subtract(t.velocity, cut, hut); + Pi.normalize(t.velocity, t.velocity); + this._checkDirectionReverse(t, s); + this.vbOffset -= this._vertSize / 4 * 2; + this.ibOffset -= 6; + this._fillVertexBuffer(t, this.colorOverTrail.evaluate(r, 1), i, r, n - 1, 5); + Pi.subtract(out.velocity, out.position, t.position); + Pi.normalize(out.velocity, out.velocity); + this._checkDirectionReverse(out, t); + } + this.widthFromParticle ? out.width = t.size.x * this.widthRatio.evaluate(0, 1) : out.width = this.widthRatio.evaluate(0, 1); + out.color = t.color; + Pi.equals(out.velocity, Pi.ZERO) ? this.ibOffset -= 3 : this._fillVertexBuffer(out, this.colorOverTrail.evaluate(0, 1), i, 0, n, 1); + } + this._trailModel && (this._trailModel.enabled = this.ibOffset > 0); + } + updateIA(t) { + const e = this._trailModel && this._trailModel.subModels; + if (e && e.length > 0) { + const i = e[0]; + i.inputAssembler.vertexBuffers[0].update(this._vbF32); + i.inputAssembler.indexBuffer.update(this._iBuffer); + this._iaInfo.drawInfos[0].firstIndex = 0; + this._iaInfo.drawInfos[0].indexCount = t; + this._iaInfoBuffer.update(this._iaInfo); + } + } + beforeRender() { + this.updateIA(this.ibOffset); + } + _createModel() { + this._trailModel || (this._trailModel = m.director.root.createModel(wA)); + } + rebuild() { + const t = IR.root.device; + const e = t.createBuffer(new An(Ts.VERTEX | Ts.TRANSFER_DST, Cs.HOST | Cs.DEVICE, this._vertSize * (this._trailNum + 1) * 2, this._vertSize)); + const i = new ArrayBuffer(this._vertSize * (this._trailNum + 1) * 2); + this._vbF32 = new Float32Array(i); + this._vbUint32 = new Uint32Array(i); + e.update(i); + const s = t.createBuffer(new An(Ts.INDEX | Ts.TRANSFER_DST, Cs.HOST | Cs.DEVICE, 6 * Math.max(1, this._trailNum) * Uint16Array.BYTES_PER_ELEMENT, Uint16Array.BYTES_PER_ELEMENT)); + this._iBuffer = new Uint16Array(6 * Math.max(1, this._trailNum)); + s.update(this._iBuffer); + this._iaInfoBuffer = t.createBuffer(new An(Ts.INDIRECT, Cs.HOST | Cs.DEVICE, mr, mr)); + this._iaInfo.drawInfos[0].vertexCount = 2 * (this._trailNum + 1); + this._iaInfo.drawInfos[0].indexCount = 6 * this._trailNum; + this._iaInfoBuffer.update(this._iaInfo); + this._subMeshData = new fC([ e ], this._vertAttrs, Xs.TRIANGLE_LIST, s, this._iaInfoBuffer); + const n = this._trailModel; + if (n && this._material) { + n.node = n.transform = this._particleSystem.node; + n.visFlags = this._particleSystem.visibility; + n.initSubModel(0, this._subMeshData, this._material); + n.enabled = !0; + } + } + _updateTrailElement(t, e, i, s) { + e.lifetime += s; + if (t.colorFromParticle) { + e.color.set(i.color); + e.color.multiply(t.colorOvertime.evaluate(1 - i.remainingLifetime / i.startLifetime, 1)); + } else e.color.set(t.colorOvertime.evaluate(1 - i.remainingLifetime / i.startLifetime, 1)); + t.widthFromParticle ? e.width = i.size.x * t.widthRatio.evaluate(e.lifetime / t._trailLifetime, 1) : e.width = t.widthRatio.evaluate(e.lifetime / t._trailLifetime, 1); + return e.lifetime > t._trailLifetime; + } + _fillVertexBuffer(t, e, i, s, n, r) { + this._vbF32[this.vbOffset++] = t.position.x; + this._vbF32[this.vbOffset++] = t.position.y; + this._vbF32[this.vbOffset++] = t.position.z; + this._vbF32[this.vbOffset++] = t.direction; + this._vbF32[this.vbOffset++] = t.width; + this._vbF32[this.vbOffset++] = s; + this._vbF32[this.vbOffset++] = 0; + this._vbF32[this.vbOffset++] = t.velocity.x; + this._vbF32[this.vbOffset++] = t.velocity.y; + this._vbF32[this.vbOffset++] = t.velocity.z; + uut.set(t.color); + uut.multiply(e); + this._vbUint32[this.vbOffset++] = uut._val; + this._vbF32[this.vbOffset++] = t.position.x; + this._vbF32[this.vbOffset++] = t.position.y; + this._vbF32[this.vbOffset++] = t.position.z; + this._vbF32[this.vbOffset++] = 1 - t.direction; + this._vbF32[this.vbOffset++] = t.width; + this._vbF32[this.vbOffset++] = s; + this._vbF32[this.vbOffset++] = 1; + this._vbF32[this.vbOffset++] = t.velocity.x; + this._vbF32[this.vbOffset++] = t.velocity.y; + this._vbF32[this.vbOffset++] = t.velocity.z; + this._vbUint32[this.vbOffset++] = uut._val; + if (1 & r) { + this._iBuffer[this.ibOffset++] = i + 2 * n; + this._iBuffer[this.ibOffset++] = i + 2 * n - 1; + this._iBuffer[this.ibOffset++] = i + 2 * n + 1; + } + if (4 & r) { + this._iBuffer[this.ibOffset++] = i + 2 * n; + this._iBuffer[this.ibOffset++] = i + 2 * n + 1; + this._iBuffer[this.ibOffset++] = i + 2 * n + 2; + } + } + _checkDirectionReverse(t, e) { + Pi.dot(t.velocity, e.velocity) < rut ? t.direction = 1 - e.direction : t.direction = e.direction; + } + destroySubMeshData() { + if (this._subMeshData) { + this._subMeshData.destroy(); + this._subMeshData = null; + } + } + }, nut), Bl(jct.prototype, "enable", [ _ct ], Object.getOwnPropertyDescriptor(jct.prototype, "enable"), jct.prototype), + Xct = Bl(jct.prototype, "_enable", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Wct = Bl(jct.prototype, "mode", [ dct, Yl, pct, mct ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return bit.Particles; + } + }), Yct = Bl(jct.prototype, "lifeTime", [ fct, Yl, gct, yct, bct ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), qct = Bl(jct.prototype, "_minParticleDistance", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .1; + } + }), Bl(jct.prototype, "minParticleDistance", [ Sct, Act ], Object.getOwnPropertyDescriptor(jct.prototype, "minParticleDistance"), jct.prototype), + Bl(jct.prototype, "space", [ Tct, vct, Ect ], Object.getOwnPropertyDescriptor(jct.prototype, "space"), jct.prototype), + Kct = Bl(jct.prototype, "existWithParticles", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), Jct = Bl(jct.prototype, "textureMode", [ Cct, Yl, xct, wct ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Sit.Stretch; + } + }), Zct = Bl(jct.prototype, "widthFromParticle", [ Yl, Rct, Ict ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), Qct = Bl(jct.prototype, "widthRatio", [ Mct, Yl, Bct, Dct, Pct ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), $ct = Bl(jct.prototype, "colorFromParticle", [ Yl, Oct, Nct ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), tut = Bl(jct.prototype, "colorOverTrail", [ Lct, Yl, Fct, Vct ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new ret; + } + }), eut = Bl(jct.prototype, "colorOvertime", [ kct, Yl, Uct, Gct ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new ret; + } + }), iut = Bl(jct.prototype, "_space", [ zct ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return _it.World; + } + }), sut = Bl(jct.prototype, "_particleSystem", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), jct)) || Hct); + const put = new qi; + const mut = new qi; + const fut = new Ui; + const gut = new Pi; + const yut = [ "_colorOverLifetimeModule", "_sizeOvertimeModule", "_velocityOvertimeModule", "_forceOvertimeModule", "_limitVelocityOvertimeModule", "_rotationOvertimeModule", "_textureAnimationModule" ]; + class but { + constructor(t) { + this._particleSystem = void 0; + this._processor = void 0; + this._node = void 0; + this._particlesAll = void 0; + this._updateList = new Map; + this._animateList = new Map; + this._runAnimateList = new Array; + this._localMat = new qi; + this._gravity = new is; + this.minPos = new Pi; + this.maxPos = new Pi; + this._nodePos = new Pi; + this._nodeSize = new Pi; + this._particleSystem = t; + this._processor = this._particleSystem.processor; + this._node = t.node; + this._particlesAll = []; + this._initModuleList(); + } + _updateBoundingNode() { + this._nodeSize.set(this.maxPos.x - this.minPos.x, this.maxPos.y - this.minPos.y, this.maxPos.z - this.minPos.z); + this._nodePos.set(this.minPos.x + .5 * this._nodeSize.x, this.minPos.y + .5 * this._nodeSize.y, this.minPos.z + .5 * this._nodeSize.z); + } + setBoundingBoxSize(t) { + this.maxPos.x = this._nodePos.x + t.x; + this.maxPos.y = this._nodePos.y + t.y; + this.maxPos.z = this._nodePos.z + t.z; + this.minPos.x = this._nodePos.x - t.x; + this.minPos.y = this._nodePos.y - t.y; + this.minPos.z = this._nodePos.z - t.z; + this._updateBoundingNode(); + } + setBoundingBoxCenter(t, e, i) { + this.maxPos.x = t + .5 * this._nodeSize.x; + this.maxPos.y = e + .5 * this._nodeSize.y; + this.maxPos.z = i + .5 * this._nodeSize.z; + this.minPos.x = t - .5 * this._nodeSize.x; + this.minPos.y = e - .5 * this._nodeSize.y; + this.minPos.z = i - .5 * this._nodeSize.z; + this._updateBoundingNode(); + } + _initModuleList() { + yut.forEach((t => { + const e = this._particleSystem[t]; + if (e && e.enable) { + e.needUpdate && (this._updateList[e.name] = e); + e.needAnimate && (this._animateList[e.name] = e); + } + })); + this._runAnimateList.length = 0; + for (let t = 0, e = hit.length; t < e; t++) { + const e = this._animateList[hit[t]]; + e && this._runAnimateList.push(e); + } + } + _emit(t, e, i) { + const n = this._particleSystem; + const r = this._node; + const o = n.time % n.duration / n.duration; + r.invalidateChildren(ay.POSITION); + if (n.simulationSpace === _it.World) { + r.getWorldMatrix(put); + r.getWorldRotation(fut); + } + for (let r = 0; r < t; ++r) { + const t = new tit(n); + t.particleSystem = n; + t.reset(); + const r = Si(bi(0, s)); + if (n._shapeModule && n._shapeModule.enable) n._shapeModule.emit(t); else { + Pi.set(t.position, 0, 0, 0); + Pi.copy(t.velocity, kit); + } + n._textureAnimationModule && n._textureAnimationModule.enable && n._textureAnimationModule.init(t); + const a = n.startSpeed.evaluate(o, r); + Pi.multiplyScalar(t.velocity, t.velocity, a); + if (n.simulationSpace === _it.World) { + Pi.transformMat4(t.position, t.position, put); + Pi.transformQuat(t.velocity, t.velocity, fut); + } + Pi.copy(t.ultimateVelocity, t.velocity); + Pi.set(t.rotation, 0, 0, 0); + if (n.startSize3D) Pi.set(t.startSize, n.startSizeX.evaluate(o, r), n.startSizeY.evaluate(o, r), n.startSizeZ.evaluate(o, r)); else { + Pi.set(t.startSize, n.startSizeX.evaluate(o, r), 1, 1); + t.startSize.y = t.startSize.x; + } + Pi.copy(t.size, t.startSize); + t.startLifetime = n.startLifetime.evaluate(o, r) + e; + t.remainingLifetime = t.startLifetime; + i.push(t); + } + } + _updateParticles(t, e) { + const i = this._particleSystem; + i.node.getWorldMatrix(put); + switch (i.scaleSpace) { + case _it.Local: + i.node.getScale(gut); + break; + + case _it.World: + i.node.getWorldScale(gut); + } + this._updateList.forEach(((t, e) => { + t.update(i.simulationSpace, put); + })); + if (i.simulationSpace === _it.Local) { + const t = i.node.getRotation(); + qi.fromQuat(this._localMat, t); + this._localMat.transpose(); + } + if (i.node.parent) { + i.node.parent.getWorldMatrix(mut); + mut.invert(); + } + for (let s = 0; s < e.length; ++s) { + const n = e[s]; + n.remainingLifetime -= t; + Pi.set(n.animatedVelocity, 0, 0, 0); + if (i.simulationSpace === _it.Local) { + const e = 9.8 * -i.gravityModifier.evaluate(1 - n.remainingLifetime / n.startLifetime, Si(n.randomSeed)) * t; + this._gravity.x = 0; + this._gravity.y = e; + this._gravity.z = 0; + this._gravity.w = 1; + if (!ui(e, 0, hi)) { + i.node.parent && (this._gravity = this._gravity.transformMat4(mut)); + this._gravity = this._gravity.transformMat4(this._localMat); + n.velocity.x += this._gravity.x; + n.velocity.y += this._gravity.y; + n.velocity.z += this._gravity.z; + } + } else n.velocity.y -= 9.8 * i.gravityModifier.evaluate(1 - n.remainingLifetime / n.startLifetime, Si(n.randomSeed)) * t; + Pi.copy(n.ultimateVelocity, n.velocity); + this._runAnimateList.forEach((e => { + e.animate(n, t); + })); + Pi.scaleAndAdd(n.position, n.position, n.ultimateVelocity, t); + } + } + _calculateBounding(t) { + const e = new Pi; + const i = new Pi; + const s = new Pi; + const n = new Pi; + const r = new Pi(1, 1, 1); + if (this._processor.getInfo().renderMode === mit.Mesh) { + const t = this._processor.getInfo().mesh; + if (t && t.struct.minPosition && t.struct.maxPosition) { + const e = new hl; + hl.fromPoints(e, t.struct.minPosition, t.struct.maxPosition); + const i = Math.max(e.halfExtents.x, e.halfExtents.y, e.halfExtents.z); + r.set(i, i, i); + } + } + const o = this._particleSystem.node.worldMatrix; + for (let a = 0; a < this._particlesAll.length; ++a) { + const l = this._particlesAll[a]; + Pi.multiply(e, gut, l.size); + Pi.multiply(e, e, r); + i.set(l.position); + this._particleSystem.simulationSpace !== _it.World && Pi.transformMat4(i, i, o); + if (t && 0 === a) { + Pi.subtract(this.minPos, i, e); + Pi.add(this.maxPos, i, e); + } else { + Pi.subtract(s, i, e); + Pi.add(n, i, e); + Pi.min(this.minPos, this.minPos, s); + Pi.max(this.maxPos, this.maxPos, n); + } + } + } + calculatePositions() { + this._emit(this._particleSystem.capacity, 0, this._particlesAll); + const t = Si(bi(0, s)); + this._updateParticles(0, this._particlesAll); + this._calculateBounding(!0); + this._updateParticles(this._particleSystem.startLifetime.evaluate(0, t), this._particlesAll); + this._calculateBounding(!1); + this._updateBoundingNode(); + } + clear() { + this._particlesAll.length = 0; + } + destroy() {} + } + var Sut, Aut, Tut, vut, Eut, Cut, xut, wut, Rut, Iut, Mut, But, Dut, Put, Out, Nut, Lut, Fut, Vut, kut, Uut, Gut, zut, Hut, jut, Xut, Wut, Yut, qut, Kut, Jut, Zut, Qut, $ut, t_t, e_t, i_t, s_t, n_t, r_t, o_t, a_t, l_t, h_t, c_t, u_t, __t, d_t, p_t, m_t, f_t, g_t, y_t, b_t, S_t, A_t, T_t, v_t, E_t, C_t, x_t, w_t, R_t, I_t, M_t, B_t, D_t, P_t, O_t, N_t; + let L_t = (Sut = Ul("cc.NoiseModule"), Aut = ph(), Tut = Th(Ne), vut = hh(), Eut = ph(), + Cut = Th(Ne), xut = hh(), wut = ph(), Rut = Th(Ne), Iut = hh(), Mut = ph(), But = Th(Ne), + Dut = hh(), Put = ph(), Out = Th(Ne), Nut = hh(), Lut = ph(), Fut = Th(Ne), Vut = hh(), + kut = ph(), Uut = Th(Ne), Gut = hh(), zut = _h(), Hut = ph(), jut = rh(), Xut = Th(Ne), + Wut = hh(), Yut = _h(), qut = ph(), Kut = rh(), Jut = Th(Ne), Zut = hh(), Qut = _h(), + $ut = ph(), t_t = rh(), e_t = Th(Ne), i_t = hh(), s_t = _h(), n_t = ph(), r_t = Th(Oe), + o_t = hh(), a_t = _h(), l_t = ph(), h_t = rh(), c_t = Th(Ne), u_t = hh(), __t = _h(), + d_t = ph(), p_t = rh(), m_t = Th(Ne), f_t = hh(), g_t = _h(), y_t = ph(), Sut(b_t = (S_t = (N_t = class extends uit { + constructor(...t) { + super(...t); + Ml(this, "_enable", A_t, this); + Ml(this, "_strengthX", T_t, this); + Ml(this, "_strengthY", v_t, this); + Ml(this, "_strengthZ", E_t, this); + Ml(this, "_noiseSpeedX", C_t, this); + Ml(this, "_noiseSpeedY", x_t, this); + Ml(this, "_noiseSpeedZ", w_t, this); + Ml(this, "_noiseFrequency", R_t, this); + Ml(this, "_remapX", I_t, this); + Ml(this, "_remapY", M_t, this); + Ml(this, "_remapZ", B_t, this); + Ml(this, "_octaves", D_t, this); + Ml(this, "_octaveMultiplier", P_t, this); + Ml(this, "_octaveScale", O_t, this); + this.name = lit; + this.noise = new Vlt; + this.samplePosition = new Pi; + } + get enable() { + return this._enable; + } + set enable(t) { + if (this._enable !== t) { + this._enable = t; + this.target && this.target.enableModule(this.name, t, this); + } + } + get strengthX() { + return this._strengthX; + } + set strengthX(t) { + this._strengthX = t; + } + get strengthY() { + return this._strengthY; + } + set strengthY(t) { + this._strengthY = t; + } + get strengthZ() { + return this._strengthZ; + } + set strengthZ(t) { + this._strengthZ = t; + } + get noiseSpeedX() { + return this._noiseSpeedX; + } + set noiseSpeedX(t) { + this._noiseSpeedX = t; + } + get noiseSpeedY() { + return this._noiseSpeedY; + } + set noiseSpeedY(t) { + this._noiseSpeedY = t; + } + get noiseSpeedZ() { + return this._noiseSpeedZ; + } + set noiseSpeedZ(t) { + this._noiseSpeedZ = t; + } + get noiseFrequency() { + return this._noiseFrequency; + } + set noiseFrequency(t) { + this._noiseFrequency = t; + } + get remapX() { + return this._remapX; + } + set remapX(t) { + this._remapX = t; + } + get remapY() { + return this._remapY; + } + set remapY(t) { + this._remapY = t; + } + get remapZ() { + return this._remapZ; + } + set remapZ(t) { + this._remapZ = t; + } + get octaves() { + return this._octaves; + } + set octaves(t) { + this._octaves = t; + } + get octaveMultiplier() { + return this._octaveMultiplier; + } + set octaveMultiplier(t) { + this._octaveMultiplier = t; + } + get octaveScale() { + return this._octaveScale; + } + set octaveScale(t) { + this._octaveScale = t; + } + animate(t, e) { + this.noise.setTime(t.particleSystem.time); + this.noise.setSpeed(this.noiseSpeedX, this.noiseSpeedY, this.noiseSpeedZ); + this.noise.setFrequency(this.noiseFrequency); + this.noise.setAbs(this.remapX, this.remapY, this.remapZ); + this.noise.setAmplititude(this.strengthX, this.strengthY, this.strengthZ); + this.noise.setOctaves(this.octaves, this.octaveMultiplier, this.octaveScale); + this.samplePosition.set(t.position); + this.samplePosition.add3f(1 * Math.random(), 1 * Math.random(), 1 * Math.random()); + this.noise.setSamplePoint(this.samplePosition); + this.noise.getNoiseParticle(); + const i = this.noise.getResult(); + i.multiply3f(Math.random(), Math.random(), Math.random()); + Pi.add(t.position, t.position, i.multiplyScalar(e)); + } + getNoisePreview(t, e, i, s) { + this.noise.setTime(e.time); + this.noise.setSpeed(this.noiseSpeedX, this.noiseSpeedY, this.noiseSpeedZ); + this.noise.setFrequency(this.noiseFrequency); + this.noise.setAbs(this.remapX, this.remapY, this.remapZ); + this.noise.setAmplititude(this.strengthX, this.strengthY, this.strengthZ); + this.noise.setOctaves(this.octaves, this.octaveMultiplier, this.octaveScale); + this.noise.getNoiseParticle(); + this.noise.getPreview(t, i, s); + } + }, N_t), A_t = Bl(S_t.prototype, "_enable", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Bl(S_t.prototype, "enable", [ Aut ], Object.getOwnPropertyDescriptor(S_t.prototype, "enable"), S_t.prototype), + Bl(S_t.prototype, "strengthX", [ Tut, vut, Eut, dh ], Object.getOwnPropertyDescriptor(S_t.prototype, "strengthX"), S_t.prototype), + T_t = Bl(S_t.prototype, "_strengthX", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 10; + } + }), Bl(S_t.prototype, "strengthY", [ Cut, xut, wut, dh ], Object.getOwnPropertyDescriptor(S_t.prototype, "strengthY"), S_t.prototype), + v_t = Bl(S_t.prototype, "_strengthY", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 10; + } + }), Bl(S_t.prototype, "strengthZ", [ Rut, Iut, Mut, dh ], Object.getOwnPropertyDescriptor(S_t.prototype, "strengthZ"), S_t.prototype), + E_t = Bl(S_t.prototype, "_strengthZ", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 10; + } + }), Bl(S_t.prototype, "noiseSpeedX", [ But, Dut, dh, Put ], Object.getOwnPropertyDescriptor(S_t.prototype, "noiseSpeedX"), S_t.prototype), + C_t = Bl(S_t.prototype, "_noiseSpeedX", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Bl(S_t.prototype, "noiseSpeedY", [ Out, Nut, Lut, dh ], Object.getOwnPropertyDescriptor(S_t.prototype, "noiseSpeedY"), S_t.prototype), + x_t = Bl(S_t.prototype, "_noiseSpeedY", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Bl(S_t.prototype, "noiseSpeedZ", [ Fut, Vut, kut, dh ], Object.getOwnPropertyDescriptor(S_t.prototype, "noiseSpeedZ"), S_t.prototype), + w_t = Bl(S_t.prototype, "_noiseSpeedZ", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Bl(S_t.prototype, "noiseFrequency", [ Uut, Gut, zut, Hut, dh ], Object.getOwnPropertyDescriptor(S_t.prototype, "noiseFrequency"), S_t.prototype), + R_t = Bl(S_t.prototype, "_noiseFrequency", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), Bl(S_t.prototype, "remapX", [ jut, Xut, Wut, Yut, qut, dh ], Object.getOwnPropertyDescriptor(S_t.prototype, "remapX"), S_t.prototype), + I_t = Bl(S_t.prototype, "_remapX", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Bl(S_t.prototype, "remapY", [ Kut, Jut, Zut, Qut, $ut, dh ], Object.getOwnPropertyDescriptor(S_t.prototype, "remapY"), S_t.prototype), + M_t = Bl(S_t.prototype, "_remapY", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Bl(S_t.prototype, "remapZ", [ t_t, e_t, i_t, s_t, n_t, dh ], Object.getOwnPropertyDescriptor(S_t.prototype, "remapZ"), S_t.prototype), + B_t = Bl(S_t.prototype, "_remapZ", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Bl(S_t.prototype, "octaves", [ r_t, o_t, a_t, l_t, dh ], Object.getOwnPropertyDescriptor(S_t.prototype, "octaves"), S_t.prototype), + D_t = Bl(S_t.prototype, "_octaves", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), Bl(S_t.prototype, "octaveMultiplier", [ h_t, c_t, u_t, __t, d_t ], Object.getOwnPropertyDescriptor(S_t.prototype, "octaveMultiplier"), S_t.prototype), + P_t = Bl(S_t.prototype, "_octaveMultiplier", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .5; + } + }), Bl(S_t.prototype, "octaveScale", [ p_t, m_t, f_t, g_t, y_t ], Object.getOwnPropertyDescriptor(S_t.prototype, "octaveScale"), S_t.prototype), + O_t = Bl(S_t.prototype, "_octaveScale", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 2; + } + }), S_t)) || b_t); + var F_t, V_t, k_t, U_t, G_t, z_t, H_t, j_t, X_t, W_t, Y_t, q_t, K_t, J_t, Z_t, Q_t, $_t, tdt, edt, idt, sdt, ndt, rdt, odt, adt, ldt, hdt, cdt, udt, _dt, ddt, pdt, mdt, fdt, gdt, ydt, bdt, Sdt, Adt, Tdt, vdt, Edt, Cdt, xdt, wdt, Rdt, Idt, Mdt, Bdt, Ddt, Pdt, Odt, Ndt, Ldt, Fdt, Vdt, kdt, Udt, Gdt, zdt, Hdt, jdt, Xdt, Wdt, Ydt, qdt, Kdt, Jdt, Zdt, Qdt, $dt, tpt, ept, ipt, spt, npt, rpt, opt, apt, lpt, hpt, cpt, upt, _pt, dpt, ppt, mpt, fpt, gpt, ypt, bpt, Spt, Apt, Tpt, vpt, Ept, Cpt, xpt, wpt, Rpt, Ipt, Mpt, Bpt, Dpt, Ppt, Opt, Npt, Lpt, Fpt, Vpt, kpt, Upt, Gpt, zpt, Hpt, jpt, Xpt, Wpt, Ypt, qpt, Kpt, Jpt, Zpt, Qpt, $pt, tmt, emt, imt, smt, nmt, rmt, omt, amt, lmt, hmt, cmt, umt, _mt, dmt, pmt, mmt, fmt, gmt, ymt, bmt, Smt, Amt, Tmt, vmt, Emt, Cmt, xmt, wmt, Rmt, Imt, Mmt, Bmt, Dmt, Pmt, Omt, Nmt, Lmt, Fmt, Vmt, kmt, Umt, Gmt, zmt, Hmt, jmt, Xmt, Wmt, Ymt, qmt, Kmt, Jmt, Zmt, Qmt, $mt, tft, eft, ift, sft, nft, rft, oft, aft, lft, hft, cft, uft, _ft, dft, pft, mft, fft; + const gft = new qi; + const yft = new Ui; + const bft = Object.getOwnPropertyDescriptor(vS.prototype, "sharedMaterials"); + let Sft = function(e) { + return t({ + ParticleSystem: e, + ParticleSystemComponent: e + }), e; + }((F_t = Ul("cc.ParticleSystem"), V_t = sh(), k_t = $l(), U_t = zl(99), G_t = hh(), + z_t = ph(), H_t = lh(), j_t = Th(ret), X_t = ph(), W_t = lh(), Y_t = Th(_it), q_t = ph(), + K_t = lh(), J_t = ph(), Z_t = lh(), Q_t = ql("startSize"), $_t = hh(), tdt = Th(Dtt), + edt = ph(), idt = lh(), sdt = Th(Dtt), ndt = hh(), rdt = ph(), odt = lh(), adt = rh(), + ldt = Th(Dtt), hdt = hh(), cdt = ph(), udt = lh(), _dt = rh(), ddt = Th(Dtt), pdt = hh(), + mdt = ph(), fdt = lh(), gdt = ph(), ydt = lh(), bdt = Th(Dtt), Sdt = hh(), Adt = ph(), + Tdt = lh(), vdt = rh(), Edt = Th(Dtt), Cdt = hh(), xdt = ph(), wdt = lh(), Rdt = rh(), + Idt = Th(Dtt), Mdt = ql("startRotation"), Bdt = hh(), Ddt = ph(), Pdt = lh(), Odt = rh(), + Ndt = Th(Dtt), Ldt = hh(), Fdt = ph(), Vdt = lh(), kdt = Th(Dtt), Udt = hh(), Gdt = ph(), + zdt = lh(), Hdt = ph(), jdt = lh(), Xdt = ph(), Wdt = lh(), Ydt = ph(), qdt = lh(), + Kdt = Th(_it), Jdt = ph(), Zdt = lh(), Qdt = ph(), $dt = lh(), tpt = ph(), ept = lh(), + ipt = Th(Dtt), spt = hh(), npt = ph(), rpt = lh(), opt = Th(Dtt), apt = hh(), lpt = ph(), + hpt = lh(), cpt = Th(Dtt), upt = hh(), _pt = ph(), dpt = lh(), ppt = Th([ sat ]), + mpt = ph(), fpt = lh(), gpt = Th(Le), ypt = ph(), bpt = lh(), Spt = Th(dit), Apt = ph(), + Tpt = lh(), vpt = Th(Ne), Ept = ph(), Cpt = lh(), xpt = Th(Ne), wpt = ph(), Rpt = lh(), + Ipt = Th(Ne), Mpt = ph(), Bpt = lh(), Dpt = ph(), Ppt = lh(), Opt = ql("enableCulling"), + Npt = rh(), Lpt = Th(hm), Fpt = ah(), Vpt = Th(Vit), kpt = Th(Vit), Upt = ph(), + Gpt = lh(), zpt = Th(Dlt), Hpt = Th(Dlt), jpt = ph(), Xpt = lh(), Wpt = Th(yrt), + Ypt = Th(yrt), qpt = ph(), Kpt = lh(), Jpt = Th(Yot), Zpt = Th(Yot), Qpt = ph(), + $pt = lh(), tmt = Th(Sst), emt = Th(Sst), imt = ph(), smt = lh(), nmt = Th(cnt), + rmt = Th(cnt), omt = ph(), amt = lh(), lmt = Th(Vnt), hmt = Th(Vnt), cmt = ph(), + umt = lh(), _mt = Th(_ot), dmt = Th(_ot), pmt = ph(), mmt = lh(), fmt = Th(L_t), + gmt = Th(L_t), ymt = ph(), bmt = Th(dut), Smt = Th(dut), Amt = ph(), Tmt = lh(), + vmt = Th(cct), Emt = ph(), Cmt = lh(), F_t(xmt = V_t(xmt = k_t(xmt = U_t(xmt = Ql(xmt = (wmt = (fft = mft = class extends wS { + get capacity() { + return this._capacity; + } + set capacity(t) { + this._capacity = Math.floor(t > 0 ? t : 0); + this.processor && this.processor._model && this.processor._model.setCapacity(this._capacity); + } + get prewarm() { + return this._prewarm; + } + set prewarm(t) { + !0 === t && this.loop; + this._prewarm = t; + } + get simulationSpace() { + return this._simulationSpace; + } + set simulationSpace(t) { + if (t !== this._simulationSpace) { + this._simulationSpace = t; + if (this.processor) { + this.processor.updateMaterialParams(); + this.processor.updateTrailMaterial(); + } + } + } + set renderCulling(t) { + this._renderCulling = t; + if (t && !this._boundingBox) { + this._boundingBox = new hl; + this._calculateBounding(!1); + } + } + get renderCulling() { + return this._renderCulling; + } + get cullingMode() { + return this._cullingMode; + } + set cullingMode(t) { + this._cullingMode = t; + } + get aabbHalfX() { + const t = this.getBoundingX(); + return t || 0; + } + set aabbHalfX(t) { + this.setBoundingX(t); + } + get aabbHalfY() { + const t = this.getBoundingY(); + return t || 0; + } + set aabbHalfY(t) { + this.setBoundingY(t); + } + get aabbHalfZ() { + const t = this.getBoundingZ(); + return t || 0; + } + set aabbHalfZ(t) { + this.setBoundingZ(t); + } + get dataCulling() { + return this._dataCulling; + } + set dataCulling(t) { + this._dataCulling = t; + } + get sharedMaterials() { + return bft.get.call(this); + } + set sharedMaterials(t) { + bft.set.call(this, t); + } + get colorOverLifetimeModule() { + return this._colorOverLifetimeModule; + } + set colorOverLifetimeModule(t) { + t && (this._colorOverLifetimeModule = t); + } + get shapeModule() { + return this._shapeModule; + } + set shapeModule(t) { + t && (this._shapeModule = t); + } + get sizeOvertimeModule() { + return this._sizeOvertimeModule; + } + set sizeOvertimeModule(t) { + t && (this._sizeOvertimeModule = t); + } + get velocityOvertimeModule() { + return this._velocityOvertimeModule; + } + set velocityOvertimeModule(t) { + t && (this._velocityOvertimeModule = t); + } + get forceOvertimeModule() { + return this._forceOvertimeModule; + } + set forceOvertimeModule(t) { + t && (this._forceOvertimeModule = t); + } + get limitVelocityOvertimeModule() { + return this._limitVelocityOvertimeModule; + } + set limitVelocityOvertimeModule(t) { + t && (this._limitVelocityOvertimeModule = t); + } + get rotationOvertimeModule() { + return this._rotationOvertimeModule; + } + set rotationOvertimeModule(t) { + t && (this._rotationOvertimeModule = t); + } + get textureAnimationModule() { + return this._textureAnimationModule; + } + set textureAnimationModule(t) { + t && (this._textureAnimationModule = t); + } + get noiseModule() { + return this._noiseModule; + } + set noiseModule(t) { + t && (this._noiseModule = t); + } + get trailModule() { + return this._trailModule; + } + set trailModule(t) { + t && (this._trailModule = t); + } + constructor() { + super(); + Ml(this, "startColor", Rmt, this); + Ml(this, "scaleSpace", Imt, this); + Ml(this, "startSize3D", Mmt, this); + Ml(this, "startSizeX", Bmt, this); + Ml(this, "startSizeY", Dmt, this); + Ml(this, "startSizeZ", Pmt, this); + Ml(this, "startSpeed", Omt, this); + Ml(this, "startRotation3D", Nmt, this); + Ml(this, "startRotationX", Lmt, this); + Ml(this, "startRotationY", Fmt, this); + Ml(this, "startRotationZ", Vmt, this); + Ml(this, "startDelay", kmt, this); + Ml(this, "startLifetime", Umt, this); + Ml(this, "duration", Gmt, this); + Ml(this, "loop", zmt, this); + Ml(this, "simulationSpeed", Hmt, this); + Ml(this, "playOnAwake", jmt, this); + Ml(this, "gravityModifier", Xmt, this); + Ml(this, "rateOverTime", Wmt, this); + Ml(this, "rateOverDistance", Ymt, this); + Ml(this, "bursts", qmt, this); + Ml(this, "_renderCulling", Kmt, this); + Ml(this, "_cullingMode", Jmt, this); + Ml(this, "_aabbHalfX", Zmt, this); + Ml(this, "_aabbHalfY", Qmt, this); + Ml(this, "_aabbHalfZ", $mt, this); + Ml(this, "_dataCulling", tft, this); + Ml(this, "_colorOverLifetimeModule", eft, this); + Ml(this, "_shapeModule", ift, this); + Ml(this, "_sizeOvertimeModule", sft, this); + Ml(this, "_velocityOvertimeModule", nft, this); + Ml(this, "_forceOvertimeModule", rft, this); + Ml(this, "_limitVelocityOvertimeModule", oft, this); + Ml(this, "_rotationOvertimeModule", aft, this); + Ml(this, "_textureAnimationModule", lft, this); + Ml(this, "_noiseModule", hft, this); + Ml(this, "_trailModule", cft, this); + Ml(this, "renderer", uft, this); + this._isPlaying = void 0; + this._isPaused = void 0; + this._isStopped = void 0; + this._isEmitting = void 0; + this._needRefresh = void 0; + this._time = void 0; + this._emitRateTimeCounter = void 0; + this._emitRateDistanceCounter = void 0; + this._oldWPos = void 0; + this._curWPos = void 0; + this._boundingBox = void 0; + this._culler = void 0; + this._oldPos = void 0; + this._curPos = void 0; + this._isCulled = void 0; + this._isSimulating = void 0; + this._customData1 = void 0; + this._customData2 = void 0; + this._subEmitters = void 0; + this._needAttach = void 0; + Ml(this, "_prewarm", _ft, this); + Ml(this, "_capacity", dft, this); + Ml(this, "_simulationSpace", pft, this); + this.processor = null; + this.rateOverTime.constant = 10; + this.startLifetime.constant = 5; + this.startSizeX.constant = 1; + this.startSpeed.constant = 5; + this._isPlaying = !1; + this._isPaused = !1; + this._isStopped = !0; + this._isEmitting = !1; + this._needRefresh = !0; + this._needAttach = !1; + this._time = 0; + this._emitRateTimeCounter = 0; + this._emitRateDistanceCounter = 0; + this._oldWPos = new Pi; + this._curWPos = new Pi; + this._boundingBox = null; + this._culler = null; + this._oldPos = null; + this._curPos = null; + this._isCulled = !1; + this._isSimulating = !0; + this._customData1 = new Qi; + this._customData2 = new Qi; + this._subEmitters = []; + } + onFocusInEditor() { + this.renderer.create(this); + } + onLoad() { + this.renderer.onInit(this); + this._shapeModule && this._shapeModule.onInit(this); + this._trailModule && !this.renderer.useGPU && this._trailModule.onInit(this); + this.bindModule(); + this._resetPosition(); + } + _onMaterialModified(t, e) { + null !== this.processor && this.processor.onMaterialModified(t, e); + } + _onRebuildPSO(t, e) { + this.processor.onRebuildPSO(t, e); + } + _collectModels() { + this._models.length = 0; + this._models.push(this.processor._model); + this._trailModule && this._trailModule.enable && this._trailModule._trailModel && this._models.push(this._trailModule._trailModel); + return this._models; + } + _attachToScene() { + this.processor.attachToScene(); + this._trailModule && this._trailModule.enable && this._trailModule._attachToScene(); + } + _detachFromScene() { + this.processor.detachFromScene(); + this._trailModule && this._trailModule.enable && this._trailModule._detachFromScene(); + this._boundingBox && (this._boundingBox = null); + if (this._culler) { + this._culler.clear(); + this._culler.destroy(); + this._culler = null; + } + } + bindModule() { + this._colorOverLifetimeModule && this._colorOverLifetimeModule.bindTarget(this.processor); + this._sizeOvertimeModule && this._sizeOvertimeModule.bindTarget(this.processor); + this._rotationOvertimeModule && this._rotationOvertimeModule.bindTarget(this.processor); + this._forceOvertimeModule && this._forceOvertimeModule.bindTarget(this.processor); + this._limitVelocityOvertimeModule && this._limitVelocityOvertimeModule.bindTarget(this.processor); + this._velocityOvertimeModule && this._velocityOvertimeModule.bindTarget(this.processor); + this._textureAnimationModule && this._textureAnimationModule.bindTarget(this.processor); + this._noiseModule && this._noiseModule.bindTarget(this.processor); + } + play() { + this._isPaused && (this._isPaused = !1); + this._isStopped && (this._isStopped = !1); + this._isPlaying = !0; + this._isEmitting = !0; + this._resetPosition(); + this._prewarm && this._prewarmSystem(); + this._trailModule && this._trailModule.play(); + if (this.processor) { + const t = this.processor.getModel(); + t && (t.enabled = this.enabledInHierarchy); + } + } + pause() { + if (this._isStopped) console.warn("pause(): particle system is already stopped."); else { + this._isPlaying && (this._isPlaying = !1); + this._isPaused = !0; + } + } + stopEmitting() { + this._isEmitting = !1; + } + stop() { + (this._isPlaying || this._isPaused) && this.clear(); + this._isPlaying && (this._isPlaying = !1); + this._isPaused && (this._isPaused = !1); + this._isEmitting && (this._isEmitting = !1); + this._time = 0; + this._emitRateTimeCounter = 0; + this._emitRateDistanceCounter = 0; + this._isStopped = !0; + this._needRefresh = !0; + for (const t of this.bursts) t.reset(); + } + clear() { + if (this.enabledInHierarchy) { + this.processor.clear(); + this._trailModule && this._trailModule.clear(); + } + this._calculateBounding(!1); + } + getParticleCount() { + return this.processor.getParticleCount(); + } + setCustomData1(t, e) { + Qi.set(this._customData1, t, e); + } + setCustomData2(t, e) { + Qi.set(this._customData2, t, e); + } + onDestroy() { + var t; + this.stop(); + if (null === (t = this.processor.getModel()) || void 0 === t ? void 0 : t.scene) { + this.processor.detachFromScene(); + this._trailModule && this._trailModule.enable && this._trailModule._detachFromScene(); + } + m.director.off(m.Director.EVENT_BEFORE_COMMIT, this.beforeRender, this); + this.processor.onDestroy(); + this._trailModule && this._trailModule.destroy(); + if (this._culler) { + this._culler.clear(); + this._culler.destroy(); + this._culler = null; + } + } + onEnable() { + super.onEnable(); + m.director.on(m.Director.EVENT_BEFORE_COMMIT, this.beforeRender, this); + this.playOnAwake && this.play(); + this.processor.onEnable(); + this._trailModule && this._trailModule.onEnable(); + } + onDisable() { + m.director.off(m.Director.EVENT_BEFORE_COMMIT, this.beforeRender, this); + this.processor.onDisable(); + this._trailModule && this._trailModule.onDisable(); + this._boundingBox && (this._boundingBox = null); + if (this._culler) { + this._culler.clear(); + this._culler.destroy(); + this._culler = null; + } + } + _calculateBounding(t) { + if (this._boundingBox) { + this._culler || (this._culler = new but(this)); + this._culler.calculatePositions(); + hl.fromPoints(this._boundingBox, this._culler.minPos, this._culler.maxPos); + if (t) { + this.aabbHalfX = this._boundingBox.halfExtents.x; + this.aabbHalfY = this._boundingBox.halfExtents.y; + this.aabbHalfZ = this._boundingBox.halfExtents.z; + } else { + this.aabbHalfX ? this.setBoundingX(this.aabbHalfX) : this.aabbHalfX = this._boundingBox.halfExtents.x; + this.aabbHalfY ? this.setBoundingY(this.aabbHalfY) : this.aabbHalfY = this._boundingBox.halfExtents.y; + this.aabbHalfZ ? this.setBoundingZ(this.aabbHalfZ) : this.aabbHalfZ = this._boundingBox.halfExtents.z; + } + this._culler.clear(); + } + } + update(t) { + const e = t * this.simulationSpeed; + if (this.renderCulling) { + var i; + if (!this._boundingBox) { + this._boundingBox = new hl; + this._calculateBounding(!1); + } + this._curPos || (this._curPos = new Pi); + this.node.getWorldPosition(this._curPos); + if (!this._oldPos) { + this._oldPos = new Pi; + this._oldPos.set(this._curPos); + } + if (!this._curPos.equals(this._oldPos) && this._boundingBox && this._culler) { + const t = this._curPos.x - this._oldPos.x; + const e = this._curPos.y - this._oldPos.y; + const i = this._curPos.z - this._oldPos.z; + const s = this._boundingBox.center; + s.x += t; + s.y += e; + s.z += i; + this._culler.setBoundingBoxCenter(s.x, s.y, s.z); + this._oldPos.set(this._curPos); + } + const t = null === (i = this.node.scene.renderScene) || void 0 === i ? void 0 : i.cameras; + let s = !0; + if (void 0 !== t && this._boundingBox) for (let e = 0; e < t.length; ++e) { + const i = t[e]; + if ((i.visibility & this.node.layer) === this.node.layer && Za.aabbFrustum(this._boundingBox, i.frustum)) { + s = !1; + break; + } + } + if (s) { + this._cullingMode !== dit.AlwaysSimulate && (this._isSimulating = !1); + if (!this._isCulled) { + this.processor.detachFromScene(); + this._isCulled = !0; + } + this._trailModule && this._trailModule.enable && this._trailModule._detachFromScene(); + this._cullingMode === dit.PauseAndCatchup && (this._time += e); + if (this._cullingMode !== dit.AlwaysSimulate) return; + } else { + if (this._isCulled) { + this._attachToScene(); + this._isCulled = !1; + } + this._isSimulating || (this._isSimulating = !0); + } + if (!this._isSimulating) return; + } else { + this._boundingBox && (this._boundingBox = null); + if (this._culler) { + this._culler.clear(); + this._culler.destroy(); + this._culler = null; + } + this._isSimulating = !0; + } + if (this._isPlaying) { + this._time += e; + this._emit(e); + 0 !== this.processor.updateParticles(e) || this._isEmitting || this.stop(); + } else { + const t = (this.getMaterialInstance(0) || this.processor.getDefaultMaterial()).passes[0]; + this.processor.updateRotation(t); + this.processor.updateScale(t); + } + this.processor.updateRenderData(); + this._trailModule && this._trailModule.enable && this._trailModule.updateRenderData(); + if (this._needAttach && this.getParticleCount() > 0 && !this._isCulled) { + var s; + (null === (s = this.processor.getModel()) || void 0 === s ? void 0 : s.scene) || this.processor.attachToScene(); + if (this._trailModule && this._trailModule.enable) { + var n; + (null === (n = this._trailModule.getModel()) || void 0 === n ? void 0 : n.scene) || this._trailModule._attachToScene(); + } + this._needAttach = !1; + } + } + beforeRender() { + var t; + if (this._isPlaying) { + this.processor.beforeRender(); + this._trailModule && this._trailModule.enable && this._trailModule.beforeRender(); + if (this.getParticleCount() <= 0) { + var e; + if (null === (e = this.processor.getModel()) || void 0 === e ? void 0 : e.scene) { + this.processor.detachFromScene(); + this._trailModule && this._trailModule.enable && this._trailModule._detachFromScene(); + this._needAttach = !1; + } + } else (null === (t = this.processor.getModel()) || void 0 === t ? void 0 : t.scene) || (this._needAttach = !0); + } + } + _onVisibilityChange(t) { + this.processor._model && (this.processor._model.visFlags = t); + } + emit(t, e) { + const i = this._time % this.duration / this.duration; + if (this._needRefresh) { + this.node.invalidateChildren(ay.POSITION); + this._needRefresh = !1; + } + if (this._simulationSpace === _it.World) { + this.node.getWorldMatrix(gft); + this.node.getWorldRotation(yft); + } + for (let n = 0; n < t; ++n) { + const t = this.processor.getFreeParticle(); + if (null === t) return; + t.particleSystem = this; + t.reset(); + const n = Si(bi(0, s)); + if (this._shapeModule && this._shapeModule.enable) this._shapeModule.emit(t); else { + Pi.set(t.position, 0, 0, 0); + Pi.copy(t.velocity, kit); + } + this._textureAnimationModule && this._textureAnimationModule.enable && this._textureAnimationModule.init(t); + const r = this.startSpeed.evaluate(i, n); + Pi.multiplyScalar(t.velocity, t.velocity, r); + if (this._simulationSpace === _it.World) { + Pi.transformMat4(t.position, t.position, gft); + Pi.transformQuat(t.velocity, t.velocity, yft); + } + Pi.copy(t.ultimateVelocity, t.velocity); + this.startRotation3D ? t.startEuler.set(this.startRotationX.evaluate(i, n), this.startRotationY.evaluate(i, n), this.startRotationZ.evaluate(i, n)) : t.startEuler.set(0, 0, this.startRotationZ.evaluate(i, n)); + t.rotation.set(t.startEuler); + if (this.startSize3D) Pi.set(t.startSize, this.startSizeX.evaluate(i, n), this.startSizeY.evaluate(i, n), this.startSizeZ.evaluate(i, n)); else { + Pi.set(t.startSize, this.startSizeX.evaluate(i, n), 1, 1); + t.startSize.y = t.startSize.x; + } + Pi.copy(t.size, t.startSize); + t.startColor.set(this.startColor.evaluate(i, n)); + t.color.set(t.startColor); + t.startLifetime = this.startLifetime.evaluate(i, n) + e; + t.remainingLifetime = t.startLifetime; + t.randomSeed = bi(0, 233280); + t.loopCount++; + this.processor.setNewParticle(t); + } + } + _prewarmSystem() { + this.startDelay.mode = Btt.Constant; + this.startDelay.constant = 0; + const t = this.duration / 1; + for (let e = 0; e < t; ++e) { + this._time += 1; + this._emit(1); + this.processor.updateParticles(1); + } + } + _emit(t) { + const e = this.startDelay.evaluate(0, 1); + if (this._time > e) { + this._time > this.duration + e && (this.loop || (this._isEmitting = !1)); + if (!this._isEmitting) return; + this._emitRateTimeCounter += this.rateOverTime.evaluate(this._time / this.duration, 1) * t; + if (this._emitRateTimeCounter > 1) { + const e = Math.floor(this._emitRateTimeCounter); + this._emitRateTimeCounter -= e; + this.emit(e, t); + } + this.node.getWorldPosition(this._curWPos); + const i = Pi.distance(this._curWPos, this._oldWPos); + Pi.copy(this._oldWPos, this._curWPos); + this._emitRateDistanceCounter += i * this.rateOverDistance.evaluate(this._time / this.duration, 1); + if (this._emitRateDistanceCounter > 1) { + const e = Math.floor(this._emitRateDistanceCounter); + this._emitRateDistanceCounter -= e; + this.emit(e, t); + } + for (const e of this.bursts) e.update(this, t); + } + } + _resetPosition() { + this.node.getWorldPosition(this._oldWPos); + Pi.copy(this._curWPos, this._oldWPos); + } + addSubEmitter(t) { + this._subEmitters.push(t); + } + removeSubEmitter(t) { + this._subEmitters.splice(this._subEmitters.indexOf(t), 1); + } + addBurst(t) { + this.bursts.push(t); + } + removeBurst(t) { + this.bursts.splice(this.bursts.indexOf(t), 1); + } + getBoundingX() { + return this._aabbHalfX; + } + getBoundingY() { + return this._aabbHalfY; + } + getBoundingZ() { + return this._aabbHalfZ; + } + setBoundingX(t) { + if (this._boundingBox && this._culler) { + this._boundingBox.halfExtents.x = t; + this._culler.setBoundingBoxSize(this._boundingBox.halfExtents); + this._aabbHalfX = t; + } + } + setBoundingY(t) { + if (this._boundingBox && this._culler) { + this._boundingBox.halfExtents.y = t; + this._culler.setBoundingBoxSize(this._boundingBox.halfExtents); + this._aabbHalfY = t; + } + } + setBoundingZ(t) { + if (this._boundingBox && this._culler) { + this._boundingBox.halfExtents.z = t; + this._culler.setBoundingBoxSize(this._boundingBox.halfExtents); + this._aabbHalfZ = t; + } + } + get isPlaying() { + return this._isPlaying; + } + get isPaused() { + return this._isPaused; + } + get isStopped() { + return this._isStopped; + } + get isEmitting() { + return this._isEmitting; + } + get time() { + return this._time; + } + _onBeforeSerialize(t) { + return this.dataCulling ? t.filter((t => !cit.includes(t) || this[t] && this[t].enable)) : t; + } + getNoisePreview(t, e) { + const i = []; + this.processor && this.processor.getNoisePreview(i, t, e); + return i; + } + }, mft.CullingMode = dit, fft), Bl(wmt.prototype, "capacity", [ G_t, z_t, H_t ], Object.getOwnPropertyDescriptor(wmt.prototype, "capacity"), wmt.prototype), + Rmt = Bl(wmt.prototype, "startColor", [ j_t, Yl, X_t, W_t ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new ret; + } + }), Imt = Bl(wmt.prototype, "scaleSpace", [ Y_t, Yl, q_t, K_t ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return _it.Local; + } + }), Mmt = Bl(wmt.prototype, "startSize3D", [ Yl, J_t, Z_t ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Bmt = Bl(wmt.prototype, "startSizeX", [ Q_t, $_t, tdt, edt, idt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), Dmt = Bl(wmt.prototype, "startSizeY", [ sdt, Yl, ndt, rdt, odt, adt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), Pmt = Bl(wmt.prototype, "startSizeZ", [ ldt, Yl, hdt, cdt, udt, _dt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), Omt = Bl(wmt.prototype, "startSpeed", [ ddt, Yl, pdt, mdt, fdt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), Nmt = Bl(wmt.prototype, "startRotation3D", [ Yl, gdt, ydt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Lmt = Bl(wmt.prototype, "startRotationX", [ bdt, Yl, Sdt, mh, Adt, Tdt, vdt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), Fmt = Bl(wmt.prototype, "startRotationY", [ Edt, Yl, Cdt, mh, xdt, wdt, Rdt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), Vmt = Bl(wmt.prototype, "startRotationZ", [ Idt, Mdt, Bdt, mh, Ddt, Pdt, Odt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), kmt = Bl(wmt.prototype, "startDelay", [ Ndt, Yl, Ldt, Fdt, Vdt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), Umt = Bl(wmt.prototype, "startLifetime", [ kdt, Yl, Udt, Gdt, zdt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), Gmt = Bl(wmt.prototype, "duration", [ Yl, Hdt, jdt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 5; + } + }), zmt = Bl(wmt.prototype, "loop", [ Yl, Xdt, Wdt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), Bl(wmt.prototype, "prewarm", [ Ydt, qdt ], Object.getOwnPropertyDescriptor(wmt.prototype, "prewarm"), wmt.prototype), + Bl(wmt.prototype, "simulationSpace", [ Kdt, Yl, Jdt, Zdt ], Object.getOwnPropertyDescriptor(wmt.prototype, "simulationSpace"), wmt.prototype), + Hmt = Bl(wmt.prototype, "simulationSpeed", [ Yl, Qdt, $dt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), jmt = Bl(wmt.prototype, "playOnAwake", [ Yl, tpt, ept ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), Xmt = Bl(wmt.prototype, "gravityModifier", [ ipt, Yl, spt, npt, rpt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), Wmt = Bl(wmt.prototype, "rateOverTime", [ opt, Yl, apt, lpt, hpt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), Ymt = Bl(wmt.prototype, "rateOverDistance", [ cpt, Yl, upt, _pt, dpt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Dtt; + } + }), qmt = Bl(wmt.prototype, "bursts", [ ppt, Yl, mpt, fpt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), Bl(wmt.prototype, "renderCulling", [ gpt, ypt, bpt ], Object.getOwnPropertyDescriptor(wmt.prototype, "renderCulling"), wmt.prototype), + Kmt = Bl(wmt.prototype, "_renderCulling", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Bl(wmt.prototype, "cullingMode", [ Spt, Apt, Tpt ], Object.getOwnPropertyDescriptor(wmt.prototype, "cullingMode"), wmt.prototype), + Jmt = Bl(wmt.prototype, "_cullingMode", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return dit.Pause; + } + }), Bl(wmt.prototype, "aabbHalfX", [ vpt, Ept, Cpt ], Object.getOwnPropertyDescriptor(wmt.prototype, "aabbHalfX"), wmt.prototype), + Zmt = Bl(wmt.prototype, "_aabbHalfX", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Bl(wmt.prototype, "aabbHalfY", [ xpt, wpt, Rpt ], Object.getOwnPropertyDescriptor(wmt.prototype, "aabbHalfY"), wmt.prototype), + Qmt = Bl(wmt.prototype, "_aabbHalfY", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Bl(wmt.prototype, "aabbHalfZ", [ Ipt, Mpt, Bpt ], Object.getOwnPropertyDescriptor(wmt.prototype, "aabbHalfZ"), wmt.prototype), + $mt = Bl(wmt.prototype, "_aabbHalfZ", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Bl(wmt.prototype, "dataCulling", [ Dpt, Ppt ], Object.getOwnPropertyDescriptor(wmt.prototype, "dataCulling"), wmt.prototype), + tft = Bl(wmt.prototype, "_dataCulling", [ Yl, Opt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Bl(wmt.prototype, "sharedMaterials", [ vh, Npt, Lpt, Yl, Fpt ], Object.getOwnPropertyDescriptor(wmt.prototype, "sharedMaterials"), wmt.prototype), + eft = Bl(wmt.prototype, "_colorOverLifetimeModule", [ Vpt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Bl(wmt.prototype, "colorOverLifetimeModule", [ kpt, Upt, Gpt ], Object.getOwnPropertyDescriptor(wmt.prototype, "colorOverLifetimeModule"), wmt.prototype), + ift = Bl(wmt.prototype, "_shapeModule", [ zpt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Bl(wmt.prototype, "shapeModule", [ Hpt, jpt, Xpt ], Object.getOwnPropertyDescriptor(wmt.prototype, "shapeModule"), wmt.prototype), + sft = Bl(wmt.prototype, "_sizeOvertimeModule", [ Wpt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Bl(wmt.prototype, "sizeOvertimeModule", [ Ypt, qpt, Kpt ], Object.getOwnPropertyDescriptor(wmt.prototype, "sizeOvertimeModule"), wmt.prototype), + nft = Bl(wmt.prototype, "_velocityOvertimeModule", [ Jpt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Bl(wmt.prototype, "velocityOvertimeModule", [ Zpt, Qpt, $pt ], Object.getOwnPropertyDescriptor(wmt.prototype, "velocityOvertimeModule"), wmt.prototype), + rft = Bl(wmt.prototype, "_forceOvertimeModule", [ tmt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Bl(wmt.prototype, "forceOvertimeModule", [ emt, imt, smt ], Object.getOwnPropertyDescriptor(wmt.prototype, "forceOvertimeModule"), wmt.prototype), + oft = Bl(wmt.prototype, "_limitVelocityOvertimeModule", [ nmt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Bl(wmt.prototype, "limitVelocityOvertimeModule", [ rmt, omt, amt ], Object.getOwnPropertyDescriptor(wmt.prototype, "limitVelocityOvertimeModule"), wmt.prototype), + aft = Bl(wmt.prototype, "_rotationOvertimeModule", [ lmt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Bl(wmt.prototype, "rotationOvertimeModule", [ hmt, cmt, umt ], Object.getOwnPropertyDescriptor(wmt.prototype, "rotationOvertimeModule"), wmt.prototype), + lft = Bl(wmt.prototype, "_textureAnimationModule", [ _mt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Bl(wmt.prototype, "textureAnimationModule", [ dmt, pmt, mmt ], Object.getOwnPropertyDescriptor(wmt.prototype, "textureAnimationModule"), wmt.prototype), + hft = Bl(wmt.prototype, "_noiseModule", [ fmt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Bl(wmt.prototype, "noiseModule", [ gmt, ymt ], Object.getOwnPropertyDescriptor(wmt.prototype, "noiseModule"), wmt.prototype), + cft = Bl(wmt.prototype, "_trailModule", [ bmt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Bl(wmt.prototype, "trailModule", [ Smt, Amt, Tmt ], Object.getOwnPropertyDescriptor(wmt.prototype, "trailModule"), wmt.prototype), + uft = Bl(wmt.prototype, "renderer", [ vmt, Yl, Emt, Cmt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new cct; + } + }), _ft = Bl(wmt.prototype, "_prewarm", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), dft = Bl(wmt.prototype, "_capacity", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 100; + } + }), pft = Bl(wmt.prototype, "_simulationSpace", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return _it.Local; + } + }), wmt)) || xmt) || xmt) || xmt) || xmt) || xmt)); + class Aft { + static instantiate(t) { + if (!this.registeredSceneEvent) { + IR.on(RR.EVENT_BEFORE_SCENE_LAUNCH, this.onSceneUnload, this); + this.registeredSceneEvent = !0; + } + this.particleSystemPool.has(t._uuid) || this.particleSystemPool.set(t._uuid, new $r((() => d_(t) || new _y), 1, (t => t.destroy()))); + return this.particleSystemPool.get(t._uuid).alloc(); + } + static destroy(t) { + if (this.particleSystemPool.has(t._prefab.asset._uuid)) { + this.stop(t); + this.particleSystemPool.get(t._prefab.asset._uuid).free(t); + } + } + static play(t) { + for (const e of t.getComponentsInChildren(Sft)) e.play(); + } + static stop(t) { + for (const e of t.getComponentsInChildren(Sft)) e.stop(); + } + static onSceneUnload() { + this.particleSystemPool.forEach((t => t.destroy())); + this.particleSystemPool.clear(); + } + } + t("ParticleUtils", Aft); + Aft.particleSystemPool = new Map; + Aft.registeredSceneEvent = !1; + Y(sat.prototype, "Burst.prototype", [ { + name: "minCount" + }, { + name: "maxCount" + } ]); + W(Sft.prototype, "ParticleSystem.prototype", [ { + name: "enableCulling", + newName: "dataCulling" + } ]); + m.ParticleSystemComponent = Sft; + ee.setClassAlias(Sft, "cc.ParticleSystemComponent"); + m.BillboardComponent = Att; + ee.setClassAlias(Att, "cc.BillboardComponent"); + m.LineComponent = $et; + ee.setClassAlias($et, "cc.LineComponent"); + m.ParticleUtils = Aft; + const Tft = oe({ + GRAVITY: 0, + RADIUS: 1 + }); + const vft = oe({ + FREE: 0, + RELATIVE: 1, + GROUPED: 2 + }); + const Eft = new Qi(0, 0); + const Cft = new Qi; + const xft = new Qi; + const wft = new Qi; + const Rft = new Qi; + const Ift = WM(zM); + class Mft { + constructor() { + this.pos = new Qi(0, 0); + this.startPos = new Qi(0, 0); + this.color = new Bi(0, 0, 0, 255); + this.deltaColor = { + r: 0, + g: 0, + b: 0, + a: 255 + }; + this.size = 0; + this.deltaSize = 0; + this.rotation = 0; + this.deltaRotation = 0; + this.timeToLive = 0; + this.drawPos = new Qi(0, 0); + this.aspectRatio = 1; + this.dir = new Qi(0, 0); + this.radialAccel = 0; + this.tangentialAccel = 0; + this.angle = 0; + this.degreesPerSecond = 0; + this.radius = 0; + this.deltaRadius = 0; + } + } + const Bft = new class extends $t { + get() { + return this._get() || new Mft; + } + }((t => { + t.pos.set(Eft); + t.startPos.set(Eft); + t.color._val = 4278190080; + t.deltaColor.r = t.deltaColor.g = t.deltaColor.b = 0; + t.deltaColor.a = 255; + t.size = 0; + t.deltaSize = 0; + t.rotation = 0; + t.deltaRotation = 0; + t.timeToLive = 0; + t.drawPos.set(Eft); + t.aspectRatio = 1; + t.dir.set(Eft); + t.radialAccel = 0; + t.tangentialAccel = 0; + t.angle = 0; + t.degreesPerSecond = 0; + t.radius = 0; + t.deltaRadius = 0; + }), 1024); + class Dft { + constructor(t) { + this.particles = []; + this.active = !1; + this.uvFilled = 0; + this.finished = !1; + this.readyToPlay = !0; + this.elapsed = 0; + this.emitCounter = 0; + this._worldRotation = 0; + this.sys = t; + this.particles = []; + this.active = !1; + this.readyToPlay = !0; + this.finished = !1; + this.elapsed = 0; + this.emitCounter = 0; + this.uvFilled = 0; + this._worldRotation = 0; + } + stop() { + this.active = !1; + this.readyToPlay = !1; + this.elapsed = this.sys.duration; + this.emitCounter = 0; + } + reset() { + this.active = !0; + this.readyToPlay = !0; + this.elapsed = 0; + this.emitCounter = 0; + this.finished = !1; + const t = this.particles; + for (let e = 0; e < t.length; ++e) Bft.put(t[e]); + t.length = 0; + } + emitParticle(t) { + const e = this.sys; + const i = Bft.get(); + this.particles.push(i); + i.timeToLive = e.life + e.lifeVar * (Math.random() - .5) * 2; + const s = i.timeToLive = Math.max(0, i.timeToLive); + i.pos.x = e.sourcePos.x + e.posVar.x * (Math.random() - .5) * 2; + i.pos.y = e.sourcePos.y + e.posVar.y * (Math.random() - .5) * 2; + let n = 0; + let r = 0; + let o = 0; + let a = 0; + const l = e.startColor; + const h = e.startColorVar; + const c = e.endColor; + const u = e.endColorVar; + i.color.r = n = Ee(l.r + h.r * (Math.random() - .5) * 2, 0, 255); + i.color.g = r = Ee(l.g + h.g * (Math.random() - .5) * 2, 0, 255); + i.color.b = o = Ee(l.b + h.b * (Math.random() - .5) * 2, 0, 255); + i.color.a = a = Ee(l.a + h.a * (Math.random() - .5) * 2, 0, 255); + i.deltaColor.r = (Ee(c.r + u.r * (Math.random() - .5) * 2, 0, 255) - n) / s; + i.deltaColor.g = (Ee(c.g + u.g * (Math.random() - .5) * 2, 0, 255) - r) / s; + i.deltaColor.b = (Ee(c.b + u.b * (Math.random() - .5) * 2, 0, 255) - o) / s; + i.deltaColor.a = (Ee(c.a + u.a * (Math.random() - .5) * 2, 0, 255) - a) / s; + let _ = e.startSize + e.startSizeVar * (Math.random() - .5) * 2; + _ = Math.max(0, _); + i.size = _; + if (-1 === e.endSize) i.deltaSize = 0; else { + let t = e.endSize + e.endSizeVar * (Math.random() - .5) * 2; + t = Math.max(0, t); + i.deltaSize = (t - _) / s; + } + const d = e.startSpin + e.startSpinVar * (Math.random() - .5) * 2; + const p = e.endSpin + e.endSpinVar * (Math.random() - .5) * 2; + i.rotation = d; + i.deltaRotation = (p - d) / s; + i.startPos.x = t.x; + i.startPos.y = t.y; + i.aspectRatio = e.aspectRatio || 1; + const m = Ce(e.angle + this._worldRotation + e.angleVar * (Math.random() - .5) * 2); + if (e.emitterMode === Tft.GRAVITY) { + const t = e.speed + e.speedVar * (Math.random() - .5) * 2; + i.dir.x = Math.cos(m); + i.dir.y = Math.sin(m); + i.dir.multiplyScalar(t); + i.radialAccel = e.radialAccel + e.radialAccelVar * (Math.random() - .5) * 2; + i.tangentialAccel = e.tangentialAccel + e.tangentialAccelVar * (Math.random() - .5) * 2; + e.rotationIsDir && (i.rotation = -xe(Math.atan2(i.dir.y, i.dir.x))); + } else { + const t = e.startRadius + e.startRadiusVar * (Math.random() - .5) * 2; + const n = e.endRadius + e.endRadiusVar * (Math.random() - .5) * 2; + i.radius = t; + i.deltaRadius = -1 === e.endRadius ? 0 : (n - t) / s; + i.angle = m; + i.degreesPerSecond = Ce(e.rotatePerS + e.rotatePerSVar * (Math.random() - .5) * 2); + } + } + updateUVs(t) { + const e = this.renderData; + if (e && this.sys._renderSpriteFrame) { + const i = e.vData; + const s = this.sys._renderSpriteFrame.uv; + const n = t ? 0 : this.uvFilled; + const r = this.particles.length; + for (let t = n; t < r; t++) { + const e = t * Ift * 4; + i[e + 3] = s[0]; + i[e + 4] = s[1]; + i[e + 12] = s[2]; + i[e + 13] = s[3]; + i[e + 21] = s[4]; + i[e + 22] = s[5]; + i[e + 30] = s[6]; + i[e + 31] = s[7]; + } + this.uvFilled = r; + } + } + updateParticleBuffer(t, e, i, s) { + const n = i.vData; + const r = e.x; + const o = e.y; + let a = t.size; + let l = a; + const h = t.aspectRatio; + h > 1 ? l = a / h : a = l * h; + const c = a / 2; + const u = l / 2; + if (t.rotation) { + const e = -c; + const i = -u; + const a = c; + const l = u; + const h = -Ce(t.rotation); + const _ = Math.cos(h); + const d = Math.sin(h); + n[s] = e * _ - i * d + r; + n[s + 1] = e * d + i * _ + o; + n[s + 2] = 0; + n[s + 9] = a * _ - i * d + r; + n[s + 10] = a * d + i * _ + o; + n[s + 11] = 0; + n[s + 18] = e * _ - l * d + r; + n[s + 19] = e * d + l * _ + o; + n[s + 20] = 0; + n[s + 27] = a * _ - l * d + r; + n[s + 28] = a * d + l * _ + o; + n[s + 29] = 0; + } else { + n[s] = r - c; + n[s + 1] = o - u; + n[s + 2] = 0; + n[s + 9] = r + c; + n[s + 10] = o - u; + n[s + 11] = 0; + n[s + 18] = r - c; + n[s + 19] = o + u; + n[s + 20] = 0; + n[s + 27] = r + c; + n[s + 28] = o + u; + n[s + 29] = 0; + } + Bi.toArray(n, t.color, s + 5); + Bi.toArray(n, t.color, s + 14); + Bi.toArray(n, t.color, s + 23); + Bi.toArray(n, t.color, s + 32); + } + step(t) { + const e = this.sys.assembler; + const i = this.sys; + const s = i.node; + const n = this.particles; + t = t > e.maxParticleDeltaTime ? e.maxParticleDeltaTime : t; + s.updateWorldTransform(); + if (i.positionType === vft.FREE) { + this._worldRotation = function(t) { + let e = 0; + let i = t; + for (;i; ) { + e += i.eulerAngles.z; + i = i.parent; + } + return e; + }(s); + const t = s.worldMatrix; + Cft.x = t.m12; + Cft.y = t.m13; + } else if (i.positionType === vft.RELATIVE) { + this._worldRotation = s.eulerAngles.z; + Cft.x = s.position.x; + Cft.y = s.position.y; + } else this._worldRotation = 0; + if (this.active && i.emissionRate) { + const e = 1 / i.emissionRate; + n.length < i.totalParticles && (this.emitCounter += t); + for (;n.length < i.totalParticles && this.emitCounter > e; ) { + this.emitParticle(Cft); + this.emitCounter -= e; + } + this.elapsed += t; + -1 !== i.duration && i.duration < this.elapsed && i.stopSystem(); + } + const r = this.renderData; + const o = n.length; + r.reset(); + this.requestData(4 * o, 6 * o); + o > this.uvFilled && this.updateUVs(); + let a = 0; + for (;a < n.length; ) { + xft.x = xft.y = wft.x = wft.y = Rft.x = Rft.y = 0; + const e = n[a]; + e.timeToLive -= t; + if (e.timeToLive > 0) { + if (i.emitterMode === Tft.GRAVITY) { + const s = Rft; + const n = xft; + const r = wft; + if (e.pos.x || e.pos.y) { + n.set(e.pos); + n.normalize(); + } + r.set(n); + n.multiplyScalar(e.radialAccel); + const o = r.x; + r.x = -r.y; + r.y = o; + r.multiplyScalar(e.tangentialAccel); + s.set(n); + s.add(r); + s.add(i.gravity); + s.multiplyScalar(t); + e.dir.add(s); + s.set(e.dir); + s.multiplyScalar(t); + e.pos.add(s); + } else { + e.angle += e.degreesPerSecond * t; + e.radius += e.deltaRadius * t; + e.pos.x = -Math.cos(e.angle) * e.radius; + e.pos.y = -Math.sin(e.angle) * e.radius; + } + e.color.r += e.deltaColor.r * t; + e.color.g += e.deltaColor.g * t; + e.color.b += e.deltaColor.b * t; + e.color.a += e.deltaColor.a * t; + e.size += e.deltaSize * t; + e.size < 0 && (e.size = 0); + e.rotation += e.deltaRotation * t; + const s = xft; + s.set(e.pos); + i.positionType !== vft.GROUPED && s.add(e.startPos); + const n = Ift * a * 4; + this.updateParticleBuffer(e, s, r, n); + ++a; + } else { + const t = n[a]; + a !== n.length - 1 && (n[a] = n[n.length - 1]); + Bft.put(t); + n.length--; + r.resize(r.vertexCount - 4, r.indexCount - 6); + } + } + this.renderData.material = this.sys.getRenderMaterial(0); + this.renderData.frame = this.sys._renderSpriteFrame; + r.setRenderDrawInfoAttributes(); + if (0 === n.length && !this.active && !this.readyToPlay) { + this.finished = !0; + i._finishedSimulation(); + } + } + requestData(t, e) { + let i = this.renderData.indexCount; + this.renderData.request(t, e); + const s = this.renderData.indexCount / 6; + const n = this.renderData.iData; + for (let t = i; t < s; t++) { + const e = 4 * t; + n[i++] = e; + n[i++] = e + 1; + n[i++] = e + 2; + n[i++] = e + 1; + n[i++] = e + 3; + n[i++] = e + 2; + } + } + initDrawInfo() { + this.renderData.setRenderDrawInfoAttributes(); + } + } + var Pft, Oft, Nft; + let Lft = t("ParticleAsset", Ul("cc.ParticleAsset")(Pft = (Oft = class extends gc { + constructor(...t) { + super(...t); + Ml(this, "spriteFrame", Nft, this); + } + }, Nft = Bl(Oft.prototype, "spriteFrame", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Oft)) || Pft); + m.ParticleAsset = Lft; + var Fft = {}; + (function() { + function t(t) { + throw t; + } + var e = void 0, i = !0, s = this; + function n(t, i) { + var n = t.split("."), r = s; + !(n[0] in r) && r.execScript && r.execScript("var " + n[0]); + for (var o; n.length && (o = n.shift()); ) n.length || i === e ? r = r[o] ? r[o] : r[o] = {} : r[o] = i; + } + var r = "undefined" != typeof Uint8Array && "undefined" != typeof Uint16Array && "undefined" != typeof Uint32Array; + function o(t) { + if ("string" == typeof t) { + var e, i, s = t.split(""); + e = 0; + for (i = s.length; e < i; e++) s[e] = (255 & s[e].charCodeAt(0)) >>> 0; + t = s; + } + for (var n, r = 1, o = 0, a = t.length, l = 0; 0 < a; ) { + a -= n = 1024 < a ? 1024 : a; + do { + o += r += t[l++]; + } while (--n); + r %= 65521; + o %= 65521; + } + return (o << 16 | r) >>> 0; + } + function a(e, i) { + this.index = "number" == typeof i ? i : 0; + this.i = 0; + this.buffer = e instanceof (r ? Uint8Array : Array) ? e : new (r ? Uint8Array : Array)(32768); + 2 * this.buffer.length <= this.index && t(Error("invalid index")); + this.buffer.length <= this.index && this.f(); + } + a.prototype.f = function() { + var t, e = this.buffer, i = e.length, s = new (r ? Uint8Array : Array)(i << 1); + if (r) s.set(e); else for (t = 0; t < i; ++t) s[t] = e[t]; + return this.buffer = s; + }; + a.prototype.d = function(t, e, i) { + var s, n = this.buffer, r = this.index, o = this.i, a = n[r]; + i && 1 < e && (t = 8 < e ? (d[255 & t] << 24 | d[t >>> 8 & 255] << 16 | d[t >>> 16 & 255] << 8 | d[t >>> 24 & 255]) >> 32 - e : d[t] >> 8 - e); + if (8 > e + o) a = a << e | t, o += e; else for (s = 0; s < e; ++s) a = a << 1 | t >> e - s - 1 & 1, + 8 == ++o && (o = 0, n[r++] = d[a], a = 0, r === n.length && (n = this.f())); + n[r] = a; + this.buffer = n; + this.i = o; + this.index = r; + }; + a.prototype.finish = function() { + var t, e = this.buffer, i = this.index; + 0 < this.i && (e[i] <<= 8 - this.i, e[i] = d[e[i]], i++); + r ? t = e.subarray(0, i) : (e.length = i, t = e); + return t; + }; + var l, h = new (r ? Uint8Array : Array)(256); + for (l = 0; 256 > l; ++l) { + for (var c = _ = l, u = 7, _ = _ >>> 1; _; _ >>>= 1) c <<= 1, c |= 1 & _, --u; + h[l] = (c << u & 255) >>> 0; + } + var d = h; + function p(t) { + this.buffer = new (r ? Uint16Array : Array)(2 * t); + this.length = 0; + } + p.prototype.getParent = function(t) { + return 2 * ((t - 2) / 4 | 0); + }; + p.prototype.push = function(t, e) { + var i, s, n, r = this.buffer; + i = this.length; + r[this.length++] = e; + for (r[this.length++] = t; 0 < i && (s = this.getParent(i), r[i] > r[s]); ) n = r[i], + r[i] = r[s], r[s] = n, n = r[i + 1], r[i + 1] = r[s + 1], r[s + 1] = n, i = s; + return this.length; + }; + p.prototype.pop = function() { + var t, e, i, s, n, r = this.buffer; + e = r[0]; + t = r[1]; + this.length -= 2; + r[0] = r[this.length]; + r[1] = r[this.length + 1]; + for (n = 0; !((s = 2 * n + 2) >= this.length); ) { + s + 2 < this.length && r[s + 2] > r[s] && (s += 2); + if (!(r[s] > r[n])) break; + i = r[n], r[n] = r[s], r[s] = i, i = r[n + 1], r[n + 1] = r[s + 1], r[s + 1] = i; + n = s; + } + return { + index: t, + value: e, + length: this.length + }; + }; + function m(t) { + var e, i, s, n, o, a, l, h, c, u = t.length, _ = 0, d = Number.POSITIVE_INFINITY; + for (h = 0; h < u; ++h) t[h] > _ && (_ = t[h]), t[h] < d && (d = t[h]); + e = 1 << _; + i = new (r ? Uint32Array : Array)(e); + s = 1; + n = 0; + for (o = 2; s <= _; ) { + for (h = 0; h < u; ++h) if (t[h] === s) { + a = 0; + l = n; + for (c = 0; c < s; ++c) a = a << 1 | 1 & l, l >>= 1; + for (c = a; c < e; c += o) i[c] = s << 16 | h; + ++n; + } + ++s; + n <<= 1; + o <<= 1; + } + return [ i, _, d ]; + } + function f(t, e) { + this.h = y; + this.w = 0; + this.input = t; + this.b = 0; + e && (e.lazy && (this.w = e.lazy), "number" == typeof e.compressionType && (this.h = e.compressionType), + e.outputBuffer && (this.a = r && e.outputBuffer instanceof Array ? new Uint8Array(e.outputBuffer) : e.outputBuffer), + "number" == typeof e.outputIndex && (this.b = e.outputIndex)); + this.a || (this.a = new (r ? Uint8Array : Array)(32768)); + } + var g, y = 2, b = { + NONE: 0, + r: 1, + j: y, + N: 3 + }, S = []; + for (g = 0; 288 > g; g++) switch (i) { + case 143 >= g: + S.push([ g + 48, 8 ]); + break; + + case 255 >= g: + S.push([ g - 144 + 400, 9 ]); + break; + + case 279 >= g: + S.push([ g - 256 + 0, 7 ]); + break; + + case 287 >= g: + S.push([ g - 280 + 192, 8 ]); + break; + + default: + t("invalid literal: " + g); + } + f.prototype.n = function() { + var s, n, o, l, h = this.input; + switch (this.h) { + case 0: + o = 0; + for (l = h.length; o < l; ) { + var c, u, _, d = n = r ? h.subarray(o, o + 65535) : h.slice(o, o + 65535), p = (o += n.length) === l, m = e, f = e, g = this.a, b = this.b; + if (r) { + for (g = new Uint8Array(this.a.buffer); g.length <= b + d.length + 5; ) g = new Uint8Array(g.length << 1); + g.set(this.a); + } + c = p ? 1 : 0; + g[b++] = 0 | c; + _ = 65536 + ~(u = d.length) & 65535; + g[b++] = 255 & u; + g[b++] = u >>> 8 & 255; + g[b++] = 255 & _; + g[b++] = _ >>> 8 & 255; + if (r) g.set(d, b), b += d.length, g = g.subarray(0, b); else { + m = 0; + for (f = d.length; m < f; ++m) g[b++] = d[m]; + g.length = b; + } + this.b = b; + this.a = g; + } + break; + + case 1: + var A = new a(new Uint8Array(this.a.buffer), this.b); + A.d(1, 1, i); + A.d(1, 2, i); + var T, v, E, C = w(this, h); + T = 0; + for (v = C.length; T < v; T++) if (E = C[T], a.prototype.d.apply(A, S[E]), 256 < E) A.d(C[++T], C[++T], i), + A.d(C[++T], 5), A.d(C[++T], C[++T], i); else if (256 === E) break; + this.a = A.finish(); + this.b = this.a.length; + break; + + case y: + var x, M, B, D, P, O, N, L, F, V, k, U, G, z, H, j = new a(new Uint8Array(this.a), this.b), X = [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ], W = Array(19); + x = y; + j.d(1, 1, i); + j.d(x, 2, i); + M = w(this, h); + N = I(O = R(this.L, 15)); + F = I(L = R(this.K, 7)); + for (B = 286; 257 < B && 0 === O[B - 1]; B--) ; + for (D = 30; 1 < D && 0 === L[D - 1]; D--) ; + var Y, q, K, J, Z, Q, $ = B, tt = D, et = new (r ? Uint32Array : Array)($ + tt), it = new (r ? Uint32Array : Array)(316), st = new (r ? Uint8Array : Array)(19); + for (Y = q = 0; Y < $; Y++) et[q++] = O[Y]; + for (Y = 0; Y < tt; Y++) et[q++] = L[Y]; + if (!r) { + Y = 0; + for (J = st.length; Y < J; ++Y) st[Y] = 0; + } + Y = Z = 0; + for (J = et.length; Y < J; Y += q) { + for (q = 1; Y + q < J && et[Y + q] === et[Y]; ++q) ; + K = q; + if (0 === et[Y]) if (3 > K) for (;0 < K--; ) it[Z++] = 0, st[0]++; else for (;0 < K; ) (Q = 138 > K ? K : 138) > K - 3 && Q < K && (Q = K - 3), + 10 >= Q ? (it[Z++] = 17, it[Z++] = Q - 3, st[17]++) : (it[Z++] = 18, it[Z++] = Q - 11, + st[18]++), K -= Q; else if (it[Z++] = et[Y], st[et[Y]]++, 3 > --K) for (;0 < K--; ) it[Z++] = et[Y], + st[et[Y]]++; else for (;0 < K; ) (Q = 6 > K ? K : 6) > K - 3 && Q < K && (Q = K - 3), + it[Z++] = 16, it[Z++] = Q - 3, st[16]++, K -= Q; + } + s = r ? it.subarray(0, Z) : it.slice(0, Z); + V = R(st, 7); + for (z = 0; 19 > z; z++) W[z] = V[X[z]]; + for (P = 19; 4 < P && 0 === W[P - 1]; P--) ; + k = I(V); + j.d(B - 257, 5, i); + j.d(D - 1, 5, i); + j.d(P - 4, 4, i); + for (z = 0; z < P; z++) j.d(W[z], 3, i); + z = 0; + for (H = s.length; z < H; z++) if (U = s[z], j.d(k[U], V[U], i), 16 <= U) { + z++; + switch (U) { + case 16: + G = 2; + break; + + case 17: + G = 3; + break; + + case 18: + G = 7; + break; + + default: + t("invalid code: " + U); + } + j.d(s[z], G, i); + } + var nt, rt, ot, at, lt, ht, ct, ut, _t = [ N, O ], dt = [ F, L ]; + lt = _t[0]; + ht = _t[1]; + ct = dt[0]; + ut = dt[1]; + nt = 0; + for (rt = M.length; nt < rt; ++nt) if (ot = M[nt], j.d(lt[ot], ht[ot], i), 256 < ot) j.d(M[++nt], M[++nt], i), + at = M[++nt], j.d(ct[at], ut[at], i), j.d(M[++nt], M[++nt], i); else if (256 === ot) break; + this.a = j.finish(); + this.b = this.a.length; + break; + + default: + t("invalid compression type"); + } + return this.a; + }; + function A(t, e) { + this.length = t; + this.G = e; + } + function T() { + var e = v; + switch (i) { + case 3 === e: + return [ 257, e - 3, 0 ]; + + case 4 === e: + return [ 258, e - 4, 0 ]; + + case 5 === e: + return [ 259, e - 5, 0 ]; + + case 6 === e: + return [ 260, e - 6, 0 ]; + + case 7 === e: + return [ 261, e - 7, 0 ]; + + case 8 === e: + return [ 262, e - 8, 0 ]; + + case 9 === e: + return [ 263, e - 9, 0 ]; + + case 10 === e: + return [ 264, e - 10, 0 ]; + + case 12 >= e: + return [ 265, e - 11, 1 ]; + + case 14 >= e: + return [ 266, e - 13, 1 ]; + + case 16 >= e: + return [ 267, e - 15, 1 ]; + + case 18 >= e: + return [ 268, e - 17, 1 ]; + + case 22 >= e: + return [ 269, e - 19, 2 ]; + + case 26 >= e: + return [ 270, e - 23, 2 ]; + + case 30 >= e: + return [ 271, e - 27, 2 ]; + + case 34 >= e: + return [ 272, e - 31, 2 ]; + + case 42 >= e: + return [ 273, e - 35, 3 ]; + + case 50 >= e: + return [ 274, e - 43, 3 ]; + + case 58 >= e: + return [ 275, e - 51, 3 ]; + + case 66 >= e: + return [ 276, e - 59, 3 ]; + + case 82 >= e: + return [ 277, e - 67, 4 ]; + + case 98 >= e: + return [ 278, e - 83, 4 ]; + + case 114 >= e: + return [ 279, e - 99, 4 ]; + + case 130 >= e: + return [ 280, e - 115, 4 ]; + + case 162 >= e: + return [ 281, e - 131, 5 ]; + + case 194 >= e: + return [ 282, e - 163, 5 ]; + + case 226 >= e: + return [ 283, e - 195, 5 ]; + + case 257 >= e: + return [ 284, e - 227, 5 ]; + + case 258 === e: + return [ 285, e - 258, 0 ]; + + default: + t("invalid length: " + e); + } + } + var v, E, C = []; + for (v = 3; 258 >= v; v++) E = T(), C[v] = E[2] << 24 | E[1] << 16 | E[0]; + var x = r ? new Uint32Array(C) : C; + function w(s, n) { + function o(e, s) { + var n, r = e.G, o = [], a = 0; + n = x[e.length]; + o[a++] = 65535 & n; + o[a++] = n >> 16 & 255; + o[a++] = n >> 24; + var l; + switch (i) { + case 1 === r: + l = [ 0, r - 1, 0 ]; + break; + + case 2 === r: + l = [ 1, r - 2, 0 ]; + break; + + case 3 === r: + l = [ 2, r - 3, 0 ]; + break; + + case 4 === r: + l = [ 3, r - 4, 0 ]; + break; + + case 6 >= r: + l = [ 4, r - 5, 1 ]; + break; + + case 8 >= r: + l = [ 5, r - 7, 1 ]; + break; + + case 12 >= r: + l = [ 6, r - 9, 2 ]; + break; + + case 16 >= r: + l = [ 7, r - 13, 2 ]; + break; + + case 24 >= r: + l = [ 8, r - 17, 3 ]; + break; + + case 32 >= r: + l = [ 9, r - 25, 3 ]; + break; + + case 48 >= r: + l = [ 10, r - 33, 4 ]; + break; + + case 64 >= r: + l = [ 11, r - 49, 4 ]; + break; + + case 96 >= r: + l = [ 12, r - 65, 5 ]; + break; + + case 128 >= r: + l = [ 13, r - 97, 5 ]; + break; + + case 192 >= r: + l = [ 14, r - 129, 6 ]; + break; + + case 256 >= r: + l = [ 15, r - 193, 6 ]; + break; + + case 384 >= r: + l = [ 16, r - 257, 7 ]; + break; + + case 512 >= r: + l = [ 17, r - 385, 7 ]; + break; + + case 768 >= r: + l = [ 18, r - 513, 8 ]; + break; + + case 1024 >= r: + l = [ 19, r - 769, 8 ]; + break; + + case 1536 >= r: + l = [ 20, r - 1025, 9 ]; + break; + + case 2048 >= r: + l = [ 21, r - 1537, 9 ]; + break; + + case 3072 >= r: + l = [ 22, r - 2049, 10 ]; + break; + + case 4096 >= r: + l = [ 23, r - 3073, 10 ]; + break; + + case 6144 >= r: + l = [ 24, r - 4097, 11 ]; + break; + + case 8192 >= r: + l = [ 25, r - 6145, 11 ]; + break; + + case 12288 >= r: + l = [ 26, r - 8193, 12 ]; + break; + + case 16384 >= r: + l = [ 27, r - 12289, 12 ]; + break; + + case 24576 >= r: + l = [ 28, r - 16385, 13 ]; + break; + + case 32768 >= r: + l = [ 29, r - 24577, 13 ]; + break; + + default: + t("invalid distance"); + } + n = l; + o[a++] = n[0]; + o[a++] = n[1]; + o[a++] = n[2]; + var h, c; + h = 0; + for (c = o.length; h < c; ++h) g[y++] = o[h]; + S[o[0]]++; + T[o[3]]++; + b = e.length + s - 1; + p = null; + } + var a, l, h, c, u, _, d, p, m, f = {}, g = r ? new Uint16Array(2 * n.length) : [], y = 0, b = 0, S = new (r ? Uint32Array : Array)(286), T = new (r ? Uint32Array : Array)(30), v = s.w; + if (!r) { + for (h = 0; 285 >= h; ) S[h++] = 0; + for (h = 0; 29 >= h; ) T[h++] = 0; + } + S[256] = 1; + a = 0; + for (l = n.length; a < l; ++a) { + h = u = 0; + for (c = 3; h < c && a + h !== l; ++h) u = u << 8 | n[a + h]; + f[u] === e && (f[u] = []); + _ = f[u]; + if (!(0 < b--)) { + for (;0 < _.length && 32768 < a - _[0]; ) _.shift(); + if (a + 3 >= l) { + p && o(p, -1); + h = 0; + for (c = l - a; h < c; ++h) m = n[a + h], g[y++] = m, ++S[m]; + break; + } + if (0 < _.length) { + var E = e, C = e, w = 0, R = e, I = e, M = e, B = n.length, D = (I = 0, _.length); + t: for (;I < D; I++) { + E = _[D - I - 1]; + R = 3; + if (3 < w) { + for (M = w; 3 < M; M--) if (n[E + M - 1] !== n[a + M - 1]) continue t; + R = w; + } + for (;258 > R && a + R < B && n[E + R] === n[a + R]; ) ++R; + R > w && (C = E, w = R); + if (258 === R) break; + } + d = new A(w, a - C); + p ? p.length < d.length ? (m = n[a - 1], g[y++] = m, ++S[m], o(d, 0)) : o(p, -1) : d.length < v ? p = d : o(d, 0); + } else p ? o(p, -1) : (m = n[a], g[y++] = m, ++S[m]); + } + _.push(a); + } + g[y++] = 256; + S[256]++; + s.L = S; + s.K = T; + return r ? g.subarray(0, y) : g; + } + function R(t, e) { + function i(t) { + var e = v[t][E[t]]; + e === y ? (i(t + 1), i(t + 1)) : --A[e]; + ++E[t]; + } + var s, n, o, a, l, h = t.length, c = new p(572), u = new (r ? Uint8Array : Array)(h); + if (!r) for (a = 0; a < h; a++) u[a] = 0; + for (a = 0; a < h; ++a) 0 < t[a] && c.push(a, t[a]); + s = Array(c.length / 2); + n = new (r ? Uint32Array : Array)(c.length / 2); + if (1 === s.length) return u[c.pop().index] = 1, u; + a = 0; + for (l = c.length / 2; a < l; ++a) s[a] = c.pop(), n[a] = s[a].value; + var _, d, m, f, g, y = n.length, b = new (r ? Uint16Array : Array)(e), S = new (r ? Uint8Array : Array)(e), A = new (r ? Uint8Array : Array)(y), T = Array(e), v = Array(e), E = Array(e), C = (1 << e) - y, x = 1 << e - 1; + b[e - 1] = y; + for (d = 0; d < e; ++d) C < x ? S[d] = 0 : (S[d] = 1, C -= x), C <<= 1, b[e - 2 - d] = (b[e - 1 - d] / 2 | 0) + y; + b[0] = S[0]; + T[0] = Array(b[0]); + v[0] = Array(b[0]); + for (d = 1; d < e; ++d) b[d] > 2 * b[d - 1] + S[d] && (b[d] = 2 * b[d - 1] + S[d]), + T[d] = Array(b[d]), v[d] = Array(b[d]); + for (_ = 0; _ < y; ++_) A[_] = e; + for (m = 0; m < b[e - 1]; ++m) T[e - 1][m] = n[m], v[e - 1][m] = m; + for (_ = 0; _ < e; ++_) E[_] = 0; + 1 === S[e - 1] && (--A[0], ++E[e - 1]); + for (d = e - 2; 0 <= d; --d) { + f = _ = 0; + g = E[d + 1]; + for (m = 0; m < b[d]; m++) (f = T[d + 1][g] + T[d + 1][g + 1]) > n[_] ? (T[d][m] = f, + v[d][m] = y, g += 2) : (T[d][m] = n[_], v[d][m] = _, ++_); + E[d] = 0; + 1 === S[d] && i(d); + } + o = A; + a = 0; + for (l = s.length; a < l; ++a) u[s[a].index] = o[a]; + return u; + } + function I(e) { + var i, s, n, o, a = new (r ? Uint16Array : Array)(e.length), l = [], h = [], c = 0; + i = 0; + for (s = e.length; i < s; i++) l[e[i]] = 1 + (0 | l[e[i]]); + i = 1; + for (s = 16; i <= s; i++) h[i] = c, (c += 0 | l[i]) > 1 << i && t("overcommitted"), + c <<= 1; + 65536 > c && t("undercommitted"); + i = 0; + for (s = e.length; i < s; i++) { + c = h[e[i]]; + h[e[i]] += 1; + n = a[i] = 0; + for (o = e[i]; n < o; n++) a[i] = a[i] << 1 | 1 & c, c >>>= 1; + } + return a; + } + function M(t, e) { + this.input = t; + this.a = new (r ? Uint8Array : Array)(32768); + this.h = B.j; + var i, s = {}; + !e && (e = {}) || "number" != typeof e.compressionType || (this.h = e.compressionType); + for (i in e) s[i] = e[i]; + s.outputBuffer = this.a; + this.z = new f(this.input, s); + } + var B = b; + M.prototype.n = function() { + var e, i, s, n, a, l, h, c = 0; + h = this.a; + if ((e = ct) === ct) i = Math.LOG2E * Math.log(32768) - 8; else t(Error("invalid compression method")); + s = i << 4 | e; + h[c++] = s; + if (e === ct) switch (this.h) { + case B.NONE: + a = 0; + break; + + case B.r: + a = 1; + break; + + case B.j: + a = 2; + break; + + default: + t(Error("unsupported compression type")); + } else t(Error("invalid compression method")); + n = a << 6 | 0; + h[c++] = n | 31 - (256 * s + n) % 31; + l = o(this.input); + this.z.b = c; + c = (h = this.z.n()).length; + r && ((h = new Uint8Array(h.buffer)).length <= c + 4 && (this.a = new Uint8Array(h.length + 4), + this.a.set(h), h = this.a), h = h.subarray(0, c + 4)); + h[c++] = l >> 24 & 255; + h[c++] = l >> 16 & 255; + h[c++] = l >> 8 & 255; + h[c++] = 255 & l; + return h; + }; + n("Zlib.Deflate", M); + n("Zlib.Deflate.compress", (function(t, e) { + return new M(t, e).n(); + })); + n("Zlib.Deflate.CompressionType", B); + n("Zlib.Deflate.CompressionType.NONE", B.NONE); + n("Zlib.Deflate.CompressionType.FIXED", B.r); + n("Zlib.Deflate.CompressionType.DYNAMIC", B.j); + function D(e, i) { + this.k = []; + this.l = 32768; + this.e = this.g = this.c = this.q = 0; + this.input = r ? new Uint8Array(e) : e; + this.s = !1; + this.m = O; + this.B = !1; + !i && (i = {}) || (i.index && (this.c = i.index), i.bufferSize && (this.l = i.bufferSize), + i.bufferType && (this.m = i.bufferType), i.resize && (this.B = i.resize)); + switch (this.m) { + case P: + this.b = 32768; + this.a = new (r ? Uint8Array : Array)(32768 + this.l + 258); + break; + + case O: + this.b = 0; + this.a = new (r ? Uint8Array : Array)(this.l); + this.f = this.J; + this.t = this.H; + this.o = this.I; + break; + + default: + t(Error("invalid inflate mode")); + } + } + var P = 0, O = 1, N = { + D: P, + C: O + }; + D.prototype.p = function() { + for (;!this.s; ) { + var s = tt(this, 3); + 1 & s && (this.s = i); + switch (s >>>= 1) { + case 0: + var n = this.input, o = this.c, a = this.a, l = this.b, h = e, c = e, u = e, _ = a.length, d = e; + this.e = this.g = 0; + (h = n[o++]) === e && t(Error("invalid uncompressed block header: LEN (first byte)")); + c = h; + (h = n[o++]) === e && t(Error("invalid uncompressed block header: LEN (second byte)")); + c |= h << 8; + (h = n[o++]) === e && t(Error("invalid uncompressed block header: NLEN (first byte)")); + u = h; + (h = n[o++]) === e && t(Error("invalid uncompressed block header: NLEN (second byte)")); + c === ~(u |= h << 8) && t(Error("invalid uncompressed block header: length verify")); + o + c > n.length && t(Error("input buffer is broken")); + switch (this.m) { + case P: + for (;l + c > a.length; ) { + c -= d = _ - l; + if (r) a.set(n.subarray(o, o + d), l), l += d, o += d; else for (;d--; ) a[l++] = n[o++]; + this.b = l; + a = this.f(); + l = this.b; + } + break; + + case O: + for (;l + c > a.length; ) a = this.f({ + v: 2 + }); + break; + + default: + t(Error("invalid inflate mode")); + } + if (r) a.set(n.subarray(o, o + c), l), l += c, o += c; else for (;c--; ) a[l++] = n[o++]; + this.c = o; + this.b = l; + this.a = a; + break; + + case 1: + this.o(Z, $); + break; + + case 2: + it(this); + break; + + default: + t(Error("unknown BTYPE: " + s)); + } + } + return this.t(); + }; + var L, F, V = [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ], k = r ? new Uint16Array(V) : V, U = [ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 258, 258 ], G = r ? new Uint16Array(U) : U, z = [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0 ], H = r ? new Uint8Array(z) : z, j = [ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 ], X = r ? new Uint16Array(j) : j, W = [ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 ], Y = r ? new Uint8Array(W) : W, q = new (r ? Uint8Array : Array)(288); + L = 0; + for (F = q.length; L < F; ++L) q[L] = 143 >= L ? 8 : 255 >= L ? 9 : 279 >= L ? 7 : 8; + var K, J, Z = m(q), Q = new (r ? Uint8Array : Array)(30); + K = 0; + for (J = Q.length; K < J; ++K) Q[K] = 5; + var $ = m(Q); + function tt(i, s) { + for (var n, r = i.g, o = i.e, a = i.input, l = i.c; o < s; ) (n = a[l++]) === e && t(Error("input buffer is broken")), + r |= n << o, o += 8; + n = r & (1 << s) - 1; + i.g = r >>> s; + i.e = o - s; + i.c = l; + return n; + } + function et(i, s) { + for (var n, r, o, a = i.g, l = i.e, h = i.input, c = i.c, u = s[0], _ = s[1]; l < _; ) (n = h[c++]) === e && t(Error("input buffer is broken")), + a |= n << l, l += 8; + o = (r = u[a & (1 << _) - 1]) >>> 16; + i.g = a >> o; + i.e = l - o; + i.c = c; + return 65535 & r; + } + function it(t) { + function e(t, e, i) { + var s, n, r, o; + for (o = 0; o < t; ) switch (s = et(this, e), s) { + case 16: + for (r = 3 + tt(this, 2); r--; ) i[o++] = n; + break; + + case 17: + for (r = 3 + tt(this, 3); r--; ) i[o++] = 0; + n = 0; + break; + + case 18: + for (r = 11 + tt(this, 7); r--; ) i[o++] = 0; + n = 0; + break; + + default: + n = i[o++] = s; + } + return i; + } + var i, s, n, o, a = tt(t, 5) + 257, l = tt(t, 5) + 1, h = tt(t, 4) + 4, c = new (r ? Uint8Array : Array)(k.length); + for (o = 0; o < h; ++o) c[k[o]] = tt(t, 3); + i = m(c); + s = new (r ? Uint8Array : Array)(a); + n = new (r ? Uint8Array : Array)(l); + t.o(m(e.call(t, a, i, s)), m(e.call(t, l, i, n))); + } + D.prototype.o = function(t, e) { + var i = this.a, s = this.b; + this.u = t; + for (var n, r, o, a, l = i.length - 258; 256 !== (n = et(this, t)); ) if (256 > n) s >= l && (this.b = s, + i = this.f(), s = this.b), i[s++] = n; else { + a = G[r = n - 257]; + 0 < H[r] && (a += tt(this, H[r])); + n = et(this, e); + o = X[n]; + 0 < Y[n] && (o += tt(this, Y[n])); + s >= l && (this.b = s, i = this.f(), s = this.b); + for (;a--; ) i[s] = i[s++ - o]; + } + for (;8 <= this.e; ) this.e -= 8, this.c--; + this.b = s; + }; + D.prototype.I = function(t, e) { + var i = this.a, s = this.b; + this.u = t; + for (var n, r, o, a, l = i.length; 256 !== (n = et(this, t)); ) if (256 > n) s >= l && (l = (i = this.f()).length), + i[s++] = n; else { + a = G[r = n - 257]; + 0 < H[r] && (a += tt(this, H[r])); + n = et(this, e); + o = X[n]; + 0 < Y[n] && (o += tt(this, Y[n])); + s + a > l && (l = (i = this.f()).length); + for (;a--; ) i[s] = i[s++ - o]; + } + for (;8 <= this.e; ) this.e -= 8, this.c--; + this.b = s; + }; + D.prototype.f = function() { + var t, e, i = new (r ? Uint8Array : Array)(this.b - 32768), s = this.b - 32768, n = this.a; + if (r) i.set(n.subarray(32768, i.length)); else { + t = 0; + for (e = i.length; t < e; ++t) i[t] = n[t + 32768]; + } + this.k.push(i); + this.q += i.length; + if (r) n.set(n.subarray(s, s + 32768)); else for (t = 0; 32768 > t; ++t) n[t] = n[s + t]; + this.b = 32768; + return n; + }; + D.prototype.J = function(t) { + var e, i, s, n = this.input.length / this.c + 1 | 0, o = this.input, a = this.a; + t && ("number" == typeof t.v && (n = t.v), "number" == typeof t.F && (n += t.F)); + 2 > n ? i = (s = (o.length - this.c) / this.u[2] / 2 * 258 | 0) < a.length ? a.length + s : a.length << 1 : i = a.length * n; + r ? (e = new Uint8Array(i)).set(a) : e = a; + return this.a = e; + }; + D.prototype.t = function() { + var t, e, i, s, n, o = 0, a = this.a, l = this.k, h = new (r ? Uint8Array : Array)(this.q + (this.b - 32768)); + if (0 === l.length) return r ? this.a.subarray(32768, this.b) : this.a.slice(32768, this.b); + e = 0; + for (i = l.length; e < i; ++e) { + s = 0; + for (n = (t = l[e]).length; s < n; ++s) h[o++] = t[s]; + } + e = 32768; + for (i = this.b; e < i; ++e) h[o++] = a[e]; + this.k = []; + return this.buffer = h; + }; + D.prototype.H = function() { + var t, e = this.b; + r ? this.B ? (t = new Uint8Array(e)).set(this.a.subarray(0, e)) : t = this.a.subarray(0, e) : (this.a.length > e && (this.a.length = e), + t = this.a); + return this.buffer = t; + }; + function st(e, i) { + var s, n; + this.input = e; + this.c = 0; + !i && (i = {}) || (i.index && (this.c = i.index), i.verify && (this.M = i.verify)); + s = e[this.c++]; + n = e[this.c++]; + if ((15 & s) === ct) this.method = ct; else t(Error("unsupported compression method")); + 0 != ((s << 8) + n) % 31 && t(Error("invalid fcheck flag:" + ((s << 8) + n) % 31)); + 32 & n && t(Error("fdict flag is not supported")); + this.A = new D(e, { + index: this.c, + bufferSize: i.bufferSize, + bufferType: i.bufferType, + resize: i.resize + }); + } + st.prototype.p = function() { + var e, i = this.input; + e = this.A.p(); + this.c = this.A.c; + this.M && ((i[this.c++] << 24 | i[this.c++] << 16 | i[this.c++] << 8 | i[this.c++]) >>> 0 !== o(e) && t(Error("invalid adler-32 checksum"))); + return e; + }; + n("Zlib.Inflate", st); + n("Zlib.Inflate.BufferType", N); + N.ADAPTIVE = N.C; + N.BLOCK = N.D; + n("Zlib.Inflate.prototype.decompress", st.prototype.p); + var nt, rt, ot = new (r ? Uint8Array : Array)(288); + nt = 0; + for (rt = ot.length; nt < rt; ++nt) ot[nt] = 143 >= nt ? 8 : 255 >= nt ? 9 : 279 >= nt ? 7 : 8; + m(ot); + var at, lt, ht = new (r ? Uint8Array : Array)(30); + at = 0; + for (lt = ht.length; at < lt; ++at) ht[at] = 5; + m(ht); + var ct = 8; + }).call(Fft); + var Vft = Fft.Zlib; + Vft.Deflate = Vft.Deflate; + Vft.Deflate.compress = Vft.Deflate.compress; + Vft.Inflate = Vft.Inflate; + Vft.Inflate.BufferType = Vft.Inflate.BufferType; + Vft.Inflate.prototype.decompress = Vft.Inflate.prototype.decompress; + class kft { + constructor(t) { + this.pos = 8; + this.palette = []; + this.imgData = []; + this.text = {}; + this.width = 0; + this.height = 0; + this.bits = 0; + this.colorType = 0; + this.compressionMethod = 0; + this.filterMethod = 0; + this.interlaceMethod = 0; + this.colors = 0; + this.hasAlphaChannel = !1; + this.pixelBitlength = 0; + this.data = t; + this.transparency = { + indexed: [], + rgb: 0, + grayscale: 0 + }; + let e; + let i = 0; + let s = 0; + let n = 0; + let r = 0; + for (;;) { + r = this.readUInt32(); + const o = (() => { + const t = []; + for (i = s = 0; s < 4; i = ++s) t.push(String.fromCharCode(this.data[this.pos++])); + return t; + }).call(this).join(""); + switch (o) { + case "IHDR": + this.width = this.readUInt32(); + this.height = this.readUInt32(); + this.bits = this.data[this.pos++]; + this.colorType = this.data[this.pos++]; + this.compressionMethod = this.data[this.pos++]; + this.filterMethod = this.data[this.pos++]; + this.interlaceMethod = this.data[this.pos++]; + break; + + case "acTL": + this.animation = { + numFrames: this.readUInt32(), + numPlays: this.readUInt32() || 1 / 0, + frames: [] + }; + break; + + case "PLTE": + this.palette = this.read(r); + break; + + case "fcTL": + e && this.animation.frames.push(e); + this.pos += 4; + e = { + width: this.readUInt32(), + height: this.readUInt32(), + xOffset: this.readUInt32(), + yOffset: this.readUInt32() + }; + const a = this.readUInt16(); + const l = this.readUInt16() || 100; + e.delay = 1e3 * a / l; + e.disposeOp = this.data[this.pos++]; + e.blendOp = this.data[this.pos++]; + e.data = []; + break; + + case "IDAT": + case "fdAT": + if ("fdAT" === o) { + this.pos += 4; + r -= 4; + } + t = (null != e ? e.data : void 0) || this.imgData; + for (i = s = 0; r >= 0 ? s < r : s > r; i = r >= 0 ? ++s : --s) t.push(this.data[this.pos++]); + break; + + case "tRNS": + this.transparency = {}; + switch (this.colorType) { + case 3: + this.transparency.indexed = this.read(r); + const t = 255 - this.transparency.indexed.length; + if (t > 0) for (i = n = 0; t >= 0 ? n < t : n > t; i = t >= 0 ? ++n : --n) this.transparency.indexed.push(255); + break; + + case 0: + this.transparency.grayscale = this.read(r)[0]; + break; + + case 2: + this.transparency.rgb = this.read(r); + } + break; + + case "tEXt": + const h = this.read(r); + const c = h.indexOf(0); + const u = String.fromCharCode.apply(String, h.slice(0, c)); + this.text[u] = String.fromCharCode.apply(String, h.slice(c + 1)); + break; + + case "IEND": + e && this.animation.frames.push(e); + this.colors = (() => { + switch (this.colorType) { + case 0: + case 3: + case 4: + return 1; + + case 2: + case 6: + return 3; + } + }).call(this); + const _ = this.colorType; + this.hasAlphaChannel = 4 === _ || 6 === _; + const d = this.colors + (this.hasAlphaChannel ? 1 : 0); + this.pixelBitlength = this.bits * d; + this.colorSpace = (() => { + switch (this.colors) { + case 1: + return "DeviceGray"; + + case 3: + return "DeviceRGB"; + } + }).call(this); + this.imgData instanceof Uint8Array || (this.imgData = new Uint8Array(this.imgData)); + return; + + default: + this.pos += r; + } + this.pos += 4; + if (this.pos > this.data.length) throw new Error(G(6017)); + } + } + read(t) { + let e = 0; + let i = 0; + const s = []; + for (e = i = 0; t >= 0 ? i < t : i > t; e = t >= 0 ? ++i : --i) s.push(this.data[this.pos++]); + return s; + } + readUInt32() { + return this.data[this.pos++] << 24 | this.data[this.pos++] << 16 | this.data[this.pos++] << 8 | this.data[this.pos++]; + } + readUInt16() { + return this.data[this.pos++] << 8 | this.data[this.pos++]; + } + decodePixels(t) { + null == t && (t = this.imgData); + if (0 === t.length) return new Uint8Array(0); + t = new Vft.Inflate(t, { + index: 0, + verify: !1 + }).decompress(); + const e = this.pixelBitlength / 8; + const i = e * this.width; + const s = new Uint8Array(i * this.height); + const n = t.length; + let r = 0; + let o = 0; + let a = 0; + let l = 0; + let h = 0; + let c = 0; + let u = 0; + let _ = 0; + let d = 0; + let p = 0; + let m = 0; + let f = 0; + let g = 0; + let y = 0; + let b = 0; + let S = 0; + let A = 0; + let T = 0; + let v = 0; + for (;o < n; ) { + switch (t[o++]) { + case 0: + for (c = u = 0; u < i; c = u += 1) s[a++] = t[o++]; + break; + + case 1: + for (c = _ = 0; _ < i; c = _ += 1) { + l = t[o++]; + f = c < e ? 0 : s[a - e]; + s[a++] = (l + f) % 256; + } + break; + + case 2: + for (c = d = 0; d < i; c = d += 1) { + l = t[o++]; + h = (c - c % e) / e; + T = r && s[(r - 1) * i + h * e + c % e]; + s[a++] = (T + l) % 256; + } + break; + + case 3: + for (c = p = 0; p < i; c = p += 1) { + l = t[o++]; + h = (c - c % e) / e; + f = c < e ? 0 : s[a - e]; + T = r && s[(r - 1) * i + h * e + c % e]; + s[a++] = (l + Math.floor((f + T) / 2)) % 256; + } + break; + + case 4: + for (c = m = 0; m < i; c = m += 1) { + l = t[o++]; + h = (c - c % e) / e; + f = c < e ? 0 : s[a - e]; + if (0 === r) T = v = 0; else { + T = s[(r - 1) * i + h * e + c % e]; + v = h && s[(r - 1) * i + (h - 1) * e + c % e]; + } + g = f + T - v; + y = Math.abs(g - f); + S = Math.abs(g - T); + A = Math.abs(g - v); + b = y <= S && y <= A ? f : S <= A ? T : v; + s[a++] = (l + b) % 256; + } + break; + + default: + throw new Error(G(6018, t[o - 1])); + } + r++; + } + return s; + } + copyToImageData(t, e) { + let i = this.hasAlphaChannel; + let s; + let n = this.colors; + if (this.palette.length) { + s = null != this._decodedPalette ? this._decodedPalette : this._decodedPalette = this.decodePalette(); + n = 4; + i = !0; + } + const r = t.data || t; + const o = r.length; + const a = s || e; + let l = 0; + let h = 0; + let c = 0; + let u = 0; + if (1 === n) for (;l < o; ) { + c = s ? 4 * e[l / 4] : h; + u = a[c++]; + r[l++] = u; + r[l++] = u; + r[l++] = u; + r[l++] = i ? a[c++] : 255; + h = c; + } else for (;l < o; ) { + c = s ? 4 * e[l / 4] : h; + r[l++] = a[c++]; + r[l++] = a[c++]; + r[l++] = a[c++]; + r[l++] = i ? a[c++] : 255; + h = c; + } + } + decodePalette() { + const t = this.palette; + const e = this.transparency.indexed || []; + const i = new Uint8Array((e.length || 0) + t.length); + let s = 0; + let n = 0; + let r = 0; + for (let o = 0, a = 0, l = t.length; a < l; o = a += 3) { + i[s++] = t[o]; + i[s++] = t[o + 1]; + i[s++] = t[o + 2]; + r = e[n++]; + i[s++] = null != r ? r : 255; + } + return i; + } + render(t) { + t.width = this.width; + t.height = this.height; + const e = t.getContext("2d"); + const i = e.createImageData(this.width, this.height); + this.copyToImageData(i, this.decodePixels(null)); + return e.putImageData(i, 0, 0); + } + } + class Uft { + constructor() { + this._littleEndian = !1; + this._tiffData = []; + this._fileDirectories = []; + } + getUint8(t) { + return this._tiffData[t]; + } + getUint16(t) { + return this._littleEndian ? this._tiffData[t + 1] << 8 | this._tiffData[t] : this._tiffData[t] << 8 | this._tiffData[t + 1]; + } + getUint32(t) { + const e = this._tiffData; + return this._littleEndian ? e[t + 3] << 24 | e[t + 2] << 16 | e[t + 1] << 8 | e[t] : e[t] << 24 | e[t + 1] << 16 | e[t + 2] << 8 | e[t + 3]; + } + checkLittleEndian() { + const t = this.getUint16(0); + if (18761 === t) this._littleEndian = !0; else { + if (19789 !== t) { + console.log(t); + throw TypeError(G(6019)); + } + this._littleEndian = !1; + } + return this._littleEndian; + } + hasTowel() { + if (42 !== this.getUint16(2)) throw RangeError(G(6020)); + return !0; + } + getFieldTypeName(t) { + return t in zft ? zft[t] : null; + } + getFieldTagName(t) { + if (t in Gft) return Gft[t]; + P(6021, t); + return `Tag${t}`; + } + getFieldTypeLength(t) { + return -1 !== [ "BYTE", "ASCII", "SBYTE", "UNDEFINED" ].indexOf(t) ? 1 : -1 !== [ "SHORT", "SSHORT" ].indexOf(t) ? 2 : -1 !== [ "LONG", "SLONG", "FLOAT" ].indexOf(t) ? 4 : -1 !== [ "RATIONAL", "SRATIONAL", "DOUBLE" ].indexOf(t) ? 8 : 0; + } + getFieldValues(t, e, i, s) { + const n = []; + const r = this.getFieldTypeLength(e); + if (r * i <= 4) !1 === this._littleEndian ? n.push(s >>> 8 * (4 - r)) : n.push(s); else for (let t = 0; t < i; t++) { + const i = r * t; + if (r >= 8) if (-1 !== [ "RATIONAL", "SRATIONAL" ].indexOf(e)) { + n.push(this.getUint32(s + i)); + n.push(this.getUint32(s + i + 4)); + } else P(8e3); else n.push(this.getBytes(r, s + i)); + } + "ASCII" === e && n.forEach(((t, e, i) => { + i[e] = String.fromCharCode(t); + })); + return n; + } + getBytes(t, e) { + if (t <= 0) P(8001); else { + if (t <= 1) return this.getUint8(e); + if (t <= 2) return this.getUint16(e); + if (t <= 3) return this.getUint32(e) >>> 8; + if (t <= 4) return this.getUint32(e); + P(8002); + } + return 0; + } + getBits(t, e, i) { + i = i || 0; + const s = e + Math.floor(i / 8); + const n = i + t; + const r = 32 - t; + let o = 0; + let a = 0; + if (n <= 0) P(6023); else if (n <= 8) { + o = 24 + i; + a = this.getUint8(s); + } else if (n <= 16) { + o = 16 + i; + a = this.getUint16(s); + } else if (n <= 32) { + o = i; + a = this.getUint32(s); + } else P(6022); + return { + bits: a << o >>> r, + byteOffset: s + Math.floor(n / 8), + bitOffset: n % 8 + }; + } + parseFileDirectory(t) { + const e = this.getUint16(t); + const i = []; + let s = 0; + let n = 0; + for (s = t + 2, n = 0; n < e; s += 12, n++) { + const t = this.getUint16(s); + const e = this.getUint16(s + 2); + const n = this.getUint32(s + 4); + const r = this.getUint32(s + 8); + const o = this.getFieldTagName(t); + const a = this.getFieldTypeName(e); + const l = this.getFieldValues(o, a, n, r); + i[o] = { + type: a, + values: l + }; + } + this._fileDirectories.push(i); + const r = this.getUint32(s); + 0 !== r && this.parseFileDirectory(r); + } + clampColorSample(t, e) { + const i = Math.pow(2, 8 - e); + return Math.floor(t * i + (i - 1)); + } + parseTIFF(t, e) { + e = e || document.createElement("canvas"); + this._tiffData = t; + this._canvas = e; + this.checkLittleEndian(); + if (!this.hasTowel()) return; + const i = this.getUint32(4); + this._fileDirectories.length = 0; + this.parseFileDirectory(i); + const s = this._fileDirectories[0]; + const n = s.ImageWidth.values[0]; + const r = s.ImageLength.values[0]; + this._canvas.width = n; + this._canvas.height = r; + const o = []; + const a = s.Compression ? s.Compression.values[0] : 1; + const l = s.SamplesPerPixel.values[0]; + const h = []; + let c = 0; + let u = !1; + s.BitsPerSample.values.forEach(((t, e, i) => { + h[e] = { + bitsPerSample: t, + hasBytesPerSample: !1, + bytesPerSample: void 0 + }; + if (t % 8 == 0) { + h[e].hasBytesPerSample = !0; + h[e].bytesPerSample = t / 8; + } + c += t; + }), this); + let _ = 0; + if (c % 8 == 0) { + u = !0; + _ = c / 8; + } + const d = s.StripOffsets.values; + const p = d.length; + let m; + if (s.StripByteCounts) m = s.StripByteCounts.values; else { + P(8003); + if (1 !== p) throw Error(G(6024)); + m = [ Math.ceil(n * r * c / 8) ]; + } + let f = 1; + let g = 1; + for (let t = 0; t < p; t++) { + const e = d[t]; + o[t] = []; + const i = m[t]; + for (let s = 0, n = 0, r = 1, c = !0, d = [], p = 0, m = 0, y = 0; s < i; s += r) switch (a) { + case 1: + d = []; + for (let t = 0; t < l; t++) { + const i = h[t]; + if (!i.hasBytesPerSample) { + const t = this.getBits(i.bitsPerSample, e + s, n); + d.push(t.bits); + s = t.byteOffset - e; + n = t.bitOffset; + throw RangeError(G(6025)); + } + { + const n = i.bytesPerSample * t; + d.push(this.getBytes(i.bytesPerSample, e + s + n)); + } + } + o[t].push(d); + if (!u) { + r = 0; + throw RangeError(G(6026)); + } + r = _; + break; + + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + break; + + case 32773: + if (c) { + c = !1; + const t = this.getUint8(e + s); + t >= 0 && t <= 127 ? f = t + 1 : t >= -127 && t <= -1 ? g = 1 - t : c = !0; + } else { + const i = this.getUint8(e + s); + for (let e = 0; e < g; e++) { + const e = h[m]; + if (!e.hasBytesPerSample) throw RangeError(G(6025)); + y = y << 8 * p | i; + p++; + if (p === e.bytesPerSample) { + d.push(y); + y = p = 0; + m++; + } + if (m === l) { + o[t].push(d); + d = []; + m = 0; + } + } + f--; + 0 === f && (c = !0); + } + r = 1; + } + } + if (e.getContext) { + const t = this._canvas.getContext("2d"); + t.fillStyle = "rgba(255, 255, 255, 0)"; + const e = s.RowsPerStrip ? s.RowsPerStrip.values[0] : r; + const i = o.length; + const a = r % e; + const l = 0 === a ? e : a; + let c = e; + let u = 0; + const _ = s.PhotometricInterpretation.values[0]; + let d = []; + let p = 0; + if (s.ExtraSamples) { + d = s.ExtraSamples.values; + p = d.length; + } + let m = []; + let f = 0; + if (s.ColorMap) { + m = s.ColorMap.values; + f = Math.pow(2, h[0].bitsPerSample); + } + for (let e = 0; e < i; e++) { + e + 1 === i && (c = l); + const s = o[e].length; + const r = u * e; + for (let i = 0, a = 0; i < c && a < s; i++) for (let s = 0; s < n; s++, a++) { + const n = o[e][a]; + let l = 0; + let c = 0; + let u = 0; + let g = 1; + if (p > 0) for (let t = 0; t < p; t++) if (1 === d[t] || 2 === d[t]) { + g = n[3 + t] / 256; + break; + } + switch (_) { + case 0: + let t = 0; + h[0].hasBytesPerSample && (t = Math.pow(16, 2 * h[0].bytesPerSample)); + n.forEach(((e, i, s) => { + s[i] = t - e; + })); + + case 1: + l = c = u = this.clampColorSample(n[0], h[0].bitsPerSample); + break; + + case 2: + l = this.clampColorSample(n[0], h[0].bitsPerSample); + c = this.clampColorSample(n[1], h[1].bitsPerSample); + u = this.clampColorSample(n[2], h[2].bitsPerSample); + break; + + case 3: + if (void 0 === m) throw Error(G(6027)); + const e = n[0]; + l = this.clampColorSample(m[e], 16); + c = this.clampColorSample(m[f + e], 16); + u = this.clampColorSample(m[2 * f + e], 16); + break; + + default: + throw RangeError(G(6028, _)); + } + t.fillStyle = `rgba(${l}, ${c}, ${u}, ${g})`; + t.fillRect(s, r + i, 1, 1); + } + u = c; + } + } + return this._canvas; + } + } + const Gft = { + 315: "Artist", + 258: "BitsPerSample", + 265: "CellLength", + 264: "CellWidth", + 320: "ColorMap", + 259: "Compression", + 33432: "Copyright", + 306: "DateTime", + 338: "ExtraSamples", + 266: "FillOrder", + 289: "FreeByteCounts", + 288: "FreeOffsets", + 291: "GrayResponseCurve", + 290: "GrayResponseUnit", + 316: "HostComputer", + 270: "ImageDescription", + 257: "ImageLength", + 256: "ImageWidth", + 271: "Make", + 281: "MaxSampleValue", + 280: "MinSampleValue", + 272: "Model", + 254: "NewSubfileType", + 274: "Orientation", + 262: "PhotometricInterpretation", + 284: "PlanarConfiguration", + 296: "ResolutionUnit", + 278: "RowsPerStrip", + 277: "SamplesPerPixel", + 305: "Software", + 279: "StripByteCounts", + 273: "StripOffsets", + 255: "SubfileType", + 263: "Threshholding", + 282: "XResolution", + 283: "YResolution", + 326: "BadFaxLines", + 327: "CleanFaxData", + 343: "ClipPath", + 328: "ConsecutiveBadFaxLines", + 433: "Decode", + 434: "DefaultImageColor", + 269: "DocumentName", + 336: "DotRange", + 321: "HalftoneHints", + 346: "Indexed", + 347: "JPEGTables", + 285: "PageName", + 297: "PageNumber", + 317: "Predictor", + 319: "PrimaryChromaticities", + 532: "ReferenceBlackWhite", + 339: "SampleFormat", + 559: "StripRowCounts", + 330: "SubIFDs", + 292: "T4Options", + 293: "T6Options", + 325: "TileByteCounts", + 323: "TileLength", + 324: "TileOffsets", + 322: "TileWidth", + 301: "TransferFunction", + 318: "WhitePoint", + 344: "XClipPathUnits", + 286: "XPosition", + 529: "YCbCrCoefficients", + 531: "YCbCrPositioning", + 530: "YCbCrSubSampling", + 345: "YClipPathUnits", + 287: "YPosition", + 37378: "ApertureValue", + 40961: "ColorSpace", + 36868: "DateTimeDigitized", + 36867: "DateTimeOriginal", + 34665: "Exif IFD", + 36864: "ExifVersion", + 33434: "ExposureTime", + 41728: "FileSource", + 37385: "Flash", + 40960: "FlashpixVersion", + 33437: "FNumber", + 42016: "ImageUniqueID", + 37384: "LightSource", + 37500: "MakerNote", + 37377: "ShutterSpeedValue", + 37510: "UserComment", + 33723: "IPTC", + 34675: "ICC Profile", + 700: "XMP", + 42112: "GDAL_METADATA", + 42113: "GDAL_NODATA", + 34377: "Photoshop" + }; + const zft = { + 1: "BYTE", + 2: "ASCII", + 3: "SHORT", + 4: "LONG", + 5: "RATIONAL", + 6: "SBYTE", + 7: "UNDEFINED", + 8: "SSHORT", + 9: "SLONG", + 10: "SRATIONAL", + 11: "FLOAT", + 12: "DOUBLE" + }; + const Hft = new Array(123); + for (let t = 0; t < 123; ++t) Hft[t] = 64; + for (let t = 0; t < 64; ++t) Hft["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charCodeAt(t)] = t; + var jft = { + name: "Jacob__Codec__Base64" + }; + jft.decode = function(t) { + var e, i, s, n, r, o, a = [], l = 0; + t = t.replace(/[^A-Za-z0-9\+\/\=]/g, ""); + for (;l < t.length; ) { + e = Hft[t.charCodeAt(l++)] << 2 | (n = Hft[t.charCodeAt(l++)]) >> 4; + i = (15 & n) << 4 | (r = Hft[t.charCodeAt(l++)]) >> 2; + s = (3 & r) << 6 | (o = Hft[t.charCodeAt(l++)]); + a.push(String.fromCharCode(e)); + 64 !== r && a.push(String.fromCharCode(i)); + 64 !== o && a.push(String.fromCharCode(s)); + } + return a = a.join(""); + }; + jft.decodeAsArray = function(t, e) { + var i, s, n, r = this.decode(t), o = []; + for (i = 0, n = r.length / e; i < n; i++) { + o[i] = 0; + for (s = e - 1; s >= 0; --s) o[i] += r.charCodeAt(i * e + s) << 8 * s; + } + return o; + }; + var Xft = function(t) { + this.data = t; + this.debug = !1; + this.gpflags = void 0; + this.files = 0; + this.unzipped = []; + this.buf32k = new Array(32768); + this.bIdx = 0; + this.modeZIP = !1; + this.bytepos = 0; + this.bb = 1; + this.bits = 0; + this.nameBuf = []; + this.fileout = void 0; + this.literalTree = new Array(Xft.LITERALS); + this.distanceTree = new Array(32); + this.treepos = 0; + this.Places = null; + this.len = 0; + this.fpos = new Array(17); + this.fpos[0] = 0; + this.flens = void 0; + this.fmax = void 0; + }; + Xft.gunzip = function(t) { + t.constructor === Array || t.constructor; + return new Xft(t).gunzip()[0][0]; + }; + Xft.HufNode = function() { + this.b0 = 0; + this.b1 = 0; + this.jump = null; + this.jumppos = -1; + }; + Xft.LITERALS = 288; + Xft.NAMEMAX = 256; + Xft.bitReverse = [ 0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240, 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255 ]; + Xft.cplens = [ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 ]; + Xft.cplext = [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99 ]; + Xft.cpdist = [ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 ]; + Xft.cpdext = [ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 ]; + Xft.border = [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]; + Xft.prototype.gunzip = function() { + this.outputArr = []; + this.nextFile(); + return this.unzipped; + }; + Xft.prototype.readByte = function() { + this.bits += 8; + return this.bytepos < this.data.length ? this.data.charCodeAt(this.bytepos++) : -1; + }; + Xft.prototype.byteAlign = function() { + this.bb = 1; + }; + Xft.prototype.readBit = function() { + var t; + this.bits++; + t = 1 & this.bb; + this.bb >>= 1; + if (0 === this.bb) { + this.bb = this.readByte(); + t = 1 & this.bb; + this.bb = this.bb >> 1 | 128; + } + return t; + }; + Xft.prototype.readBits = function(t) { + var e = 0, i = t; + for (;i--; ) e = e << 1 | this.readBit(); + t && (e = Xft.bitReverse[e] >> 8 - t); + return e; + }; + Xft.prototype.flushBuffer = function() { + this.bIdx = 0; + }; + Xft.prototype.addBuffer = function(t) { + this.buf32k[this.bIdx++] = t; + this.outputArr.push(String.fromCharCode(t)); + 32768 === this.bIdx && (this.bIdx = 0); + }; + Xft.prototype.IsPat = function() { + for (;;) { + if (this.fpos[this.len] >= this.fmax) return -1; + if (this.flens[this.fpos[this.len]] === this.len) return this.fpos[this.len]++; + this.fpos[this.len]++; + } + }; + Xft.prototype.Rec = function() { + var t = this.Places[this.treepos]; + var e; + if (17 === this.len) return -1; + this.treepos++; + this.len++; + if ((e = this.IsPat()) >= 0) t.b0 = e; else { + t.b0 = 32768; + if (this.Rec()) return -1; + } + if ((e = this.IsPat()) >= 0) { + t.b1 = e; + t.jump = null; + } else { + t.b1 = 32768; + t.jump = this.Places[this.treepos]; + t.jumppos = this.treepos; + if (this.Rec()) return -1; + } + this.len--; + return 0; + }; + Xft.prototype.CreateTree = function(t, e, i, s) { + var n; + this.Places = t; + this.treepos = 0; + this.flens = i; + this.fmax = e; + for (n = 0; n < 17; n++) this.fpos[n] = 0; + this.len = 0; + return this.Rec() ? -1 : 0; + }; + Xft.prototype.DecodeValue = function(t) { + var e, i, s = 0, n = t[s]; + for (;;) if (this.readBit()) { + if (!(32768 & n.b1)) return n.b1; + n = n.jump; + e = t.length; + for (i = 0; i < e; i++) if (t[i] === n) { + s = i; + break; + } + } else { + if (!(32768 & n.b0)) return n.b0; + n = t[++s]; + } + return -1; + }; + Xft.prototype.DeflateLoop = function() { + var t, e, i; + do { + t = this.readBit(); + if (0 === (e = this.readBits(2))) { + var s, n; + this.byteAlign(); + s = this.readByte(); + s |= this.readByte() << 8; + n = this.readByte(); + 65535 & (s ^ ~(n |= this.readByte() << 8)) && document.write("BlockLen checksum mismatch\n"); + for (;s--; ) { + r = this.readByte(); + this.addBuffer(r); + } + } else if (1 === e) { + for (;;) { + (o = Xft.bitReverse[this.readBits(7)] >> 1) > 23 ? (o = o << 1 | this.readBit()) > 199 ? o = (o -= 128) << 1 | this.readBit() : (o -= 48) > 143 && (o += 136) : o += 256; + if (o < 256) this.addBuffer(o); else { + if (256 === o) break; + o -= 257; + p = this.readBits(Xft.cplext[o]) + Xft.cplens[o]; + o = Xft.bitReverse[this.readBits(5)] >> 3; + if (Xft.cpdext[o] > 8) { + m = this.readBits(8); + m |= this.readBits(Xft.cpdext[o] - 8) << 8; + } else m = this.readBits(Xft.cpdext[o]); + m += Xft.cpdist[o]; + for (o = 0; o < p; o++) { + var r = this.buf32k[this.bIdx - m & 32767]; + this.addBuffer(r); + } + } + } + } else if (2 === e) { + var o, a, l, h, c; + var u = new Array(320); + l = 257 + this.readBits(5); + h = 1 + this.readBits(5); + c = 4 + this.readBits(4); + for (o = 0; o < 19; o++) u[o] = 0; + for (o = 0; o < c; o++) u[Xft.border[o]] = this.readBits(3); + p = this.distanceTree.length; + for (i = 0; i < p; i++) this.distanceTree[i] = new Xft.HufNode; + if (this.CreateTree(this.distanceTree, 19, u, 0)) { + this.flushBuffer(); + return 1; + } + a = l + h; + i = 0; + for (;i < a; ) if ((o = this.DecodeValue(this.distanceTree)) < 16) u[i++] = o; else if (16 === o) { + var _; + if (i + (o = 3 + this.readBits(2)) > a) { + this.flushBuffer(); + return 1; + } + _ = i ? u[i - 1] : 0; + for (;o--; ) u[i++] = _; + } else { + if (i + (o = 17 === o ? 3 + this.readBits(3) : 11 + this.readBits(7)) > a) { + this.flushBuffer(); + return 1; + } + for (;o--; ) u[i++] = 0; + } + p = this.literalTree.length; + for (i = 0; i < p; i++) this.literalTree[i] = new Xft.HufNode; + if (this.CreateTree(this.literalTree, l, u, 0)) { + this.flushBuffer(); + return 1; + } + p = this.literalTree.length; + for (i = 0; i < p; i++) this.distanceTree[i] = new Xft.HufNode; + var d = new Array; + for (i = l; i < u.length; i++) d[i - l] = u[i]; + if (this.CreateTree(this.distanceTree, h, d, 0)) { + this.flushBuffer(); + return 1; + } + for (;;) if ((o = this.DecodeValue(this.literalTree)) >= 256) { + var p, m; + if (0 === (o -= 256)) break; + o--; + p = this.readBits(Xft.cplext[o]) + Xft.cplens[o]; + o = this.DecodeValue(this.distanceTree); + if (Xft.cpdext[o] > 8) { + m = this.readBits(8); + m |= this.readBits(Xft.cpdext[o] - 8) << 8; + } else m = this.readBits(Xft.cpdext[o]); + m += Xft.cpdist[o]; + for (;p--; ) { + r = this.buf32k[this.bIdx - m & 32767]; + this.addBuffer(r); + } + } else this.addBuffer(o); + } + } while (!t); + this.flushBuffer(); + this.byteAlign(); + return 0; + }; + Xft.prototype.unzipFile = function(t) { + var e; + this.gunzip(); + for (e = 0; e < this.unzipped.length; e++) if (this.unzipped[e][1] === t) return this.unzipped[e][0]; + }; + Xft.prototype.nextFile = function() { + this.outputArr = []; + this.modeZIP = !1; + var t = []; + t[0] = this.readByte(); + t[1] = this.readByte(); + if (120 === t[0] && 218 === t[1]) { + this.DeflateLoop(); + this.unzipped[this.files] = [ this.outputArr.join(""), "geonext.gxt" ]; + this.files++; + } + if (31 === t[0] && 139 === t[1]) { + this.skipdir(); + this.unzipped[this.files] = [ this.outputArr.join(""), "file" ]; + this.files++; + } + if (80 === t[0] && 75 === t[1]) { + this.modeZIP = !0; + t[2] = this.readByte(); + t[3] = this.readByte(); + if (3 === t[2] && 4 === t[3]) { + t[0] = this.readByte(); + t[1] = this.readByte(); + this.gpflags = this.readByte(); + this.gpflags |= this.readByte() << 8; + var e = this.readByte(); + e |= this.readByte() << 8; + this.readByte(); + this.readByte(); + this.readByte(); + this.readByte(); + this.readByte(); + this.readByte() << 8; + this.readByte() << 16; + this.readByte() << 24; + this.readByte(); + this.readByte() << 8; + this.readByte() << 16; + this.readByte() << 24; + var i = this.readByte(); + i |= this.readByte() << 8; + var s = this.readByte(); + s |= this.readByte() << 8; + r = 0; + this.nameBuf = []; + for (;i--; ) { + var n = this.readByte(); + "/" === n | ":" === n ? r = 0 : r < Xft.NAMEMAX - 1 && (this.nameBuf[r++] = String.fromCharCode(n)); + } + this.fileout || (this.fileout = this.nameBuf); + var r = 0; + for (;r < s; ) { + n = this.readByte(); + r++; + } + if (8 === e) { + this.DeflateLoop(); + this.unzipped[this.files] = [ this.outputArr.join(""), this.nameBuf.join("") ]; + this.files++; + } + this.skipdir(); + } + } + }; + Xft.prototype.skipdir = function() { + var t = []; + var e, i; + if (8 & this.gpflags) { + t[0] = this.readByte(); + t[1] = this.readByte(); + t[2] = this.readByte(); + t[3] = this.readByte(); + this.readByte(); + this.readByte() << 8; + this.readByte() << 16; + this.readByte() << 24; + this.readByte(); + this.readByte() << 8; + this.readByte() << 16; + this.readByte() << 24; + } + this.modeZIP && this.nextFile(); + t[0] = this.readByte(); + if (8 !== t[0]) return 0; + this.gpflags = this.readByte(); + this.readByte(); + this.readByte(); + this.readByte(); + this.readByte(); + this.readByte(); + this.readByte(); + if (4 & this.gpflags) { + t[0] = this.readByte(); + t[2] = this.readByte(); + this.len = t[0] + 256 * t[1]; + for (e = 0; e < this.len; e++) this.readByte(); + } + if (8 & this.gpflags) { + e = 0; + this.nameBuf = []; + for (;i = this.readByte(); ) { + "7" !== i && ":" !== i || (e = 0); + e < Xft.NAMEMAX - 1 && (this.nameBuf[e++] = i); + } + } + if (16 & this.gpflags) for (;i = this.readByte(); ) ; + if (2 & this.gpflags) { + this.readByte(); + this.readByte(); + } + this.DeflateLoop(); + this.readByte(); + this.readByte() << 8; + this.readByte() << 16; + this.readByte() << 24; + this.modeZIP && this.nextFile(); + }; + var Wft = { + name: "Jacob__Codec" + }; + Wft.Base64 = jft; + Wft.GZip = Xft; + Wft.unzip = function() { + return Wft.GZip.gunzip.apply(Wft.GZip, arguments); + }; + Wft.unzipBase64 = function() { + var t = Wft.Base64.decode.apply(Wft.Base64, arguments); + try { + return Wft.GZip.gunzip.call(Wft.GZip, t); + } catch (e) { + return t.slice(7); + } + }; + Wft.unzipBase64AsArray = function(t, e) { + e = e || 1; + var i, s, n, r = this.unzipBase64(t), o = []; + for (i = 0, n = r.length / e; i < n; i++) { + o[i] = 0; + for (s = e - 1; s >= 0; --s) o[i] += r.charCodeAt(i * e + s) << 8 * s; + } + return o; + }; + Wft.unzipAsArray = function(t, e) { + e = e || 1; + var i, s, n, r = this.unzip(t), o = []; + for (i = 0, n = r.length / e; i < n; i++) { + o[i] = 0; + for (s = e - 1; s >= 0; --s) o[i] += r.charCodeAt(i * e + s) << 8 * s; + } + return o; + }; + var Yft, qft, Kft, Jft, Zft, Qft, $ft, tgt, egt, igt, sgt, ngt, rgt, ogt, agt, lgt, hgt, cgt, ugt, _gt, dgt, pgt, mgt, fgt, ggt, ygt, bgt, Sgt, Agt, Tgt, vgt, Egt, Cgt, xgt, wgt, Rgt, Igt, Mgt, Bgt, Dgt, Pgt, Ogt, Ngt, Lgt, Fgt, Vgt, kgt, Ugt, Ggt, zgt, Hgt, jgt, Xgt, Wgt, Ygt, qgt, Kgt, Jgt, Zgt, Qgt, $gt, tyt, eyt, iyt, syt, nyt, ryt, oyt, ayt, lyt, hyt, cyt, uyt, _yt, dyt, pyt, myt, fyt, gyt, yyt, byt, Syt, Ayt, Tyt, vyt, Eyt, Cyt, xyt, wyt, Ryt, Iyt, Myt, Byt, Dyt, Pyt, Oyt, Nyt, Lyt, Fyt, Vyt, kyt, Uyt; + let Gyt; + !function(t) { + t[t.JPG = 0] = "JPG"; + t[t.PNG = 1] = "PNG"; + t[t.TIFF = 2] = "TIFF"; + t[t.WEBP = 3] = "WEBP"; + t[t.PVR = 4] = "PVR"; + t[t.ETC = 5] = "ETC"; + t[t.S3TC = 6] = "S3TC"; + t[t.ATITC = 7] = "ATITC"; + t[t.TGA = 8] = "TGA"; + t[t.RAWDATA = 9] = "RAWDATA"; + t[t.UNKNOWN = 10] = "UNKNOWN"; + }(Gyt || (Gyt = {})); + function zyt(t) { + const e = t.parent; + const i = t.getComponent(Hyt); + return e && i ? zyt(e) : t.getComponentsInChildren(Hyt); + } + let Hyt = t("ParticleSystem2D", (Yft = Ul("cc.ParticleSystem2D"), qft = $l(), Kft = ph(), + Jft = lh(), Zft = Th(Lft), Qft = ph(), $ft = lh(), tgt = Th(GI), egt = lh(), igt = lh(), + sgt = lh(), ngt = lh(), rgt = lh(), ogt = lh(), agt = lh(), lgt = lh(), hgt = rh(), + cgt = lh(), ugt = lh(), _gt = lh(), dgt = lh(), pgt = lh(), mgt = lh(), fgt = lh(), + ggt = lh(), ygt = lh(), bgt = lh(), Sgt = lh(), Agt = lh(), Tgt = lh(), vgt = Th(vft), + Egt = lh(), Cgt = ph(), xgt = lh(), wgt = Th(Tft), Rgt = lh(), Igt = lh(), Mgt = lh(), + Bgt = lh(), Dgt = lh(), Pgt = lh(), Ogt = lh(), Ngt = lh(), Lgt = lh(), Fgt = lh(), + Vgt = lh(), kgt = lh(), Ugt = lh(), Ggt = lh(), zgt = lh(), Hgt = ph(), jgt = lh(), + Xgt = ph(), Wgt = lh(), Ygt = ql("preview"), Yft(qgt = qft(qgt = th(qgt = Ql(qgt = (Kgt = (Uyt = kyt = class t extends uD { + get custom() { + return this._custom; + } + set custom(t) { + if (this._custom !== t) { + this._custom = t; + this._applyFile(); + } + } + get file() { + return this._file; + } + set file(t) { + if (this._file !== t) { + this._file = t; + t ? this._applyFile() : this.custom = !0; + } + } + get spriteFrame() { + return this._spriteFrame; + } + set spriteFrame(t) { + if (this._renderSpriteFrame !== t) { + this._renderSpriteFrame = t; + t && !t._uuid || (this._spriteFrame = t); + this._applySpriteFrame(); + } + } + get particleCount() { + return this._simulator.particles.length; + } + get totalParticles() { + return this._totalParticles; + } + set totalParticles(t) { + this._totalParticles !== t && (this._totalParticles = t); + } + get startColor() { + return this._startColor; + } + set startColor(t) { + this._startColor.r = t.r; + this._startColor.g = t.g; + this._startColor.b = t.b; + this._startColor.a = t.a; + } + get startColorVar() { + return this._startColorVar; + } + set startColorVar(t) { + this._startColorVar.r = t.r; + this._startColorVar.g = t.g; + this._startColorVar.b = t.b; + this._startColorVar.a = t.a; + } + set color(t) {} + get color() { + return this._color; + } + get endColor() { + return this._endColor; + } + set endColor(t) { + this._endColor.r = t.r; + this._endColor.g = t.g; + this._endColor.b = t.b; + this._endColor.a = t.a; + } + get endColorVar() { + return this._endColorVar; + } + set endColorVar(t) { + this._endColorVar.r = t.r; + this._endColorVar.g = t.g; + this._endColorVar.b = t.b; + this._endColorVar.a = t.a; + } + get positionType() { + return this._positionType; + } + set positionType(t) { + this._positionType = t; + this._updateMaterial(); + this._updatePositionType(); + } + get preview() { + return this._preview; + } + set preview(t) { + t ? this._startPreview() : this._stopPreview(); + this._preview = t; + } + get stopped() { + return this._stopped; + } + get active() { + return this._simulator.active; + } + get assembler() { + return this._assembler; + } + constructor() { + super(); + Ml(this, "duration", Jgt, this); + Ml(this, "emissionRate", Zgt, this); + Ml(this, "life", Qgt, this); + Ml(this, "lifeVar", $gt, this); + Ml(this, "angle", tyt, this); + Ml(this, "angleVar", eyt, this); + Ml(this, "startSize", iyt, this); + Ml(this, "startSizeVar", syt, this); + Ml(this, "endSize", nyt, this); + Ml(this, "endSizeVar", ryt, this); + Ml(this, "startSpin", oyt, this); + Ml(this, "startSpinVar", ayt, this); + Ml(this, "endSpin", lyt, this); + Ml(this, "endSpinVar", hyt, this); + Ml(this, "sourcePos", cyt, this); + Ml(this, "posVar", uyt, this); + Ml(this, "emitterMode", _yt, this); + Ml(this, "gravity", dyt, this); + Ml(this, "speed", pyt, this); + Ml(this, "speedVar", myt, this); + Ml(this, "tangentialAccel", fyt, this); + Ml(this, "tangentialAccelVar", gyt, this); + Ml(this, "radialAccel", yyt, this); + Ml(this, "radialAccelVar", byt, this); + Ml(this, "rotationIsDir", Syt, this); + Ml(this, "startRadius", Ayt, this); + Ml(this, "startRadiusVar", Tyt, this); + Ml(this, "endRadius", vyt, this); + Ml(this, "endRadiusVar", Eyt, this); + Ml(this, "rotatePerS", Cyt, this); + Ml(this, "rotatePerSVar", xyt, this); + this.aspectRatio = 1; + Ml(this, "playOnLoad", wyt, this); + Ml(this, "autoRemoveOnFinish", Ryt, this); + Ml(this, "_preview", Iyt, this); + Ml(this, "_custom", Myt, this); + Ml(this, "_file", Byt, this); + Ml(this, "_spriteFrame", Dyt, this); + Ml(this, "_totalParticles", Pyt, this); + Ml(this, "_startColor", Oyt, this); + Ml(this, "_startColorVar", Nyt, this); + Ml(this, "_endColor", Lyt, this); + Ml(this, "_endColorVar", Fyt, this); + Ml(this, "_positionType", Vyt, this); + this._stopped = !0; + this.initProperties(); + } + onEnable() { + super.onEnable(); + this._updateMaterial(); + this._updatePositionType(); + } + onDestroy() { + super.onDestroy(); + this.autoRemoveOnFinish && (this.autoRemoveOnFinish = !1); + this._simulator.uvFilled = 0; + this._simulator.renderData && this._assembler && this._assembler.removeData(this._simulator.renderData); + } + initProperties() { + this._previewTimer = null; + this._focused = !1; + this.aspectRatio = 1; + this._simulator = new Dft(this); + } + onFocusInEditor() { + this._focused = !0; + const t = zyt(this.node); + for (let e = 0; e < t.length; ++e) t[e]._startPreview(); + } + onLostFocusInEditor() { + this._focused = !1; + const t = zyt(this.node); + for (let e = 0; e < t.length; ++e) t[e]._stopPreview(); + } + _startPreview() { + this._preview && this.resetSystem(); + } + _stopPreview() { + if (this._preview) { + this.resetSystem(); + this.stopSystem(); + } + this._previewTimer && clearInterval(this._previewTimer); + } + __preload() { + super.__preload(); + if (this._custom && this.spriteFrame && !this._renderSpriteFrame) this._applySpriteFrame(); else if (this._file) if (this._custom) { + !this._getTexture() && this._applyFile(); + } else this._applyFile(); + this.playOnLoad && this.resetSystem(); + } + _flushAssembler() { + const e = t.Assembler.getAssembler(this); + this._assembler !== e && (this._assembler = e); + if (this._assembler && this._assembler.createData) { + this._simulator.renderData = this._assembler.createData(this); + this._simulator.renderData.particleInitRenderDrawInfo(this.renderEntity); + this._simulator.initDrawInfo(); + } + } + lateUpdate(t) { + this._simulator.finished || this._simulator.step(t); + } + addParticle() {} + stopSystem() { + this._stopped = !0; + this._simulator.stop(); + } + resetSystem() { + this._stopped = !1; + this._simulator.reset(); + this.markForUpdateRenderData(); + } + isFull() { + return this.particleCount >= this.totalParticles; + } + _applyFile() { + const t = this._file; + if (t) { + if (!t) { + F(6029); + return; + } + if (!this.isValid) return; + this._plistFile = t.nativeUrl; + if (!this._custom) { + this._spriteFrame !== t.spriteFrame && (this.spriteFrame = t.spriteFrame); + this._initWithDictionary(t._nativeAsset); + } + this._spriteFrame ? !this._renderSpriteFrame && this._spriteFrame && this._applySpriteFrame() : t.spriteFrame ? this.spriteFrame = t.spriteFrame : this._custom && this._initTextureWithDictionary(t._nativeAsset); + } + } + _initTextureWithDictionary(t) { + if (t.spriteFrameUuid) { + const e = t.spriteFrameUuid; + SR.loadAny(e, ((e, i) => { + if (e) { + t.spriteFrameUuid = void 0; + this._initTextureWithDictionary(t); + x(e); + } else this.spriteFrame = i; + })); + } else { + const i = hc(this._plistFile, t.textureFileName || ""); + if (t.textureFileName) SR.loadRemote(i, ((e, i) => { + if (e) { + t.textureFileName = void 0; + this._initTextureWithDictionary(t); + x(e); + } else this.spriteFrame = i ? GI.createWithImage(i) : GI.createWithImage(xR.get("white-texture")); + })); else if (t.textureImageData) { + const s = t.textureImageData; + if (!(s && s.length > 0)) return !1; + { + let t = SR.assets.get(i); + if (!t) { + const n = Wft.unzipBase64AsArray(s, 1); + if (!n) { + N(6030, this._file.name); + return !1; + } + const r = (e = n).length > 8 && 137 === e[0] && 80 === e[1] && 78 === e[2] && 71 === e[3] && 13 === e[4] && 10 === e[5] && 26 === e[6] && 10 === e[7] ? Gyt.PNG : e.length > 2 && (73 === e[0] && 73 === e[1] || 77 === e[0] && 77 === e[1] || 255 === e[0] && 216 === e[1]) ? Gyt.TIFF : Gyt.UNKNOWN; + if (r !== Gyt.TIFF && r !== Gyt.PNG) { + N(6031, this._file.name); + return !1; + } + const o = document.createElement("canvas"); + if (r === Gyt.PNG) { + new kft(n).render(o); + } else { + this._tiffReader || (this._tiffReader = new Uft); + this._tiffReader.parseTIFF(n, o); + } + t = new IC(o); + SR.assets.add(i, t); + } + t || N(6032, this._file.name); + this.spriteFrame = t ? GI.createWithImage(t) : GI.createWithImage(xR.get("white-texture")); + } + } + } + var e; + return !0; + } + _initWithDictionary(t) { + this.totalParticles = parseInt(t.maxParticles || 0); + this.life = parseFloat(t.particleLifespan || 0); + this.lifeVar = parseFloat(t.particleLifespanVariance || 0); + const e = t.emissionRate; + this.emissionRate = e || Math.min(this.totalParticles / this.life, Number.MAX_VALUE); + this.duration = parseFloat(t.duration || 0); + this._srcBlendFactor = parseInt(t.blendFuncSource || Ls.SRC_ALPHA); + this._dstBlendFactor = parseInt(t.blendFuncDestination || Ls.ONE_MINUS_SRC_ALPHA); + const i = this._startColor; + i.r = 255 * parseFloat(t.startColorRed || 0); + i.g = 255 * parseFloat(t.startColorGreen || 0); + i.b = 255 * parseFloat(t.startColorBlue || 0); + i.a = 255 * parseFloat(t.startColorAlpha || 0); + const s = this._startColorVar; + s.r = 255 * parseFloat(t.startColorVarianceRed || 0); + s.g = 255 * parseFloat(t.startColorVarianceGreen || 0); + s.b = 255 * parseFloat(t.startColorVarianceBlue || 0); + s.a = 255 * parseFloat(t.startColorVarianceAlpha || 0); + const n = this._endColor; + n.r = 255 * parseFloat(t.finishColorRed || 0); + n.g = 255 * parseFloat(t.finishColorGreen || 0); + n.b = 255 * parseFloat(t.finishColorBlue || 0); + n.a = 255 * parseFloat(t.finishColorAlpha || 0); + const r = this._endColorVar; + r.r = 255 * parseFloat(t.finishColorVarianceRed || 0); + r.g = 255 * parseFloat(t.finishColorVarianceGreen || 0); + r.b = 255 * parseFloat(t.finishColorVarianceBlue || 0); + r.a = 255 * parseFloat(t.finishColorVarianceAlpha || 0); + this.startSize = parseFloat(t.startParticleSize || 0); + this.startSizeVar = parseFloat(t.startParticleSizeVariance || 0); + this.endSize = parseFloat(t.finishParticleSize || 0); + this.endSizeVar = parseFloat(t.finishParticleSizeVariance || 0); + this.positionType = parseFloat(void 0 !== t.positionType ? t.positionType : vft.FREE); + this.sourcePos.set(0, 0); + this.posVar.set(parseFloat(t.sourcePositionVariancex || 0), parseFloat(t.sourcePositionVariancey || 0)); + this.angle = parseFloat(t.angle || 0); + this.angleVar = parseFloat(t.angleVariance || 0); + this.startSpin = parseFloat(t.rotationStart || 0); + this.startSpinVar = parseFloat(t.rotationStartVariance || 0); + this.endSpin = parseFloat(t.rotationEnd || 0); + this.endSpinVar = parseFloat(t.rotationEndVariance || 0); + this.emitterMode = parseInt(t.emitterType || Tft.GRAVITY); + if (this.emitterMode === Tft.GRAVITY) { + this.gravity.set(parseFloat(t.gravityx || 0), parseFloat(t.gravityy || 0)); + this.speed = parseFloat(t.speed || 0); + this.speedVar = parseFloat(t.speedVariance || 0); + this.radialAccel = parseFloat(t.radialAcceleration || 0); + this.radialAccelVar = parseFloat(t.radialAccelVariance || 0); + this.tangentialAccel = parseFloat(t.tangentialAcceleration || 0); + this.tangentialAccelVar = parseFloat(t.tangentialAccelVariance || 0); + let e = t.rotationIsDir || ""; + if (null !== e) { + e = e.toString().toLowerCase(); + this.rotationIsDir = "true" === e || "1" === e; + } else this.rotationIsDir = !1; + } else { + if (this.emitterMode !== Tft.RADIUS) { + N(6009); + return !1; + } + this.startRadius = parseFloat(t.maxRadius || 0); + this.startRadiusVar = parseFloat(t.maxRadiusVariance || 0); + this.endRadius = parseFloat(t.minRadius || 0); + this.endRadiusVar = parseFloat(t.minRadiusVariance || 0); + this.rotatePerS = parseFloat(t.rotatePerSecond || 0); + this.rotatePerSVar = parseFloat(t.rotatePerSecondVariance || 0); + } + this._initTextureWithDictionary(t); + return !0; + } + _syncAspect() { + if (this._renderSpriteFrame) { + const t = this._renderSpriteFrame.rect; + this.aspectRatio = t.width / t.height; + } + } + _applySpriteFrame() { + this._renderSpriteFrame = this._renderSpriteFrame || this._spriteFrame; + if (this._renderSpriteFrame) { + if (this._renderSpriteFrame.texture) { + this._simulator.updateUVs(!0); + this._syncAspect(); + this._updateMaterial(); + this._stopped = !1; + this.markForUpdateRenderData(); + } + } else this.resetSystem(); + } + _getTexture() { + return this._renderSpriteFrame && this._renderSpriteFrame.texture; + } + _updateMaterial() { + const t = this.getMaterialInstance(0); + t && t.recompileShaders({ + USE_LOCAL: this._positionType !== vft.FREE + }); + t && t.passes.length > 0 && this._updateBlendFunc(); + } + _finishedSimulation() { + this.resetSystem(); + this.stopSystem(); + this.markForUpdateRenderData(); + this.autoRemoveOnFinish && this._stopped && this.node.destroy(); + } + _canRender() { + return super._canRender() && !this._stopped && null !== this._renderSpriteFrame && void 0 !== this._renderSpriteFrame; + } + _render(t) { + this._positionType === vft.RELATIVE ? t.commitComp(this, this._simulator.renderData, this._renderSpriteFrame, this._assembler, this.node.parent) : this.positionType === vft.GROUPED ? t.commitComp(this, this._simulator.renderData, this._renderSpriteFrame, this._assembler, this.node) : t.commitComp(this, this._simulator.renderData, this._renderSpriteFrame, this._assembler, null); + } + _updatePositionType() { + if (this._positionType === vft.RELATIVE) { + this._renderEntity.setRenderTransform(this.node.parent); + this._renderEntity.setUseLocal(!0); + } else if (this.positionType === vft.GROUPED) { + this._renderEntity.setRenderTransform(this.node); + this._renderEntity.setUseLocal(!0); + } else { + this._renderEntity.setRenderTransform(null); + this._renderEntity.setUseLocal(!1); + } + } + }, kyt.EmitterMode = Tft, kyt.PositionType = vft, kyt.DURATION_INFINITY = -1, kyt.START_SIZE_EQUAL_TO_END_SIZE = -1, + kyt.START_RADIUS_EQUAL_TO_END_RADIUS = -1, Uyt), Bl(Kgt.prototype, "custom", [ nh, Kft, Jft ], Object.getOwnPropertyDescriptor(Kgt.prototype, "custom"), Kgt.prototype), + Bl(Kgt.prototype, "file", [ Zft, Qft, $ft ], Object.getOwnPropertyDescriptor(Kgt.prototype, "file"), Kgt.prototype), + Bl(Kgt.prototype, "spriteFrame", [ tgt, egt ], Object.getOwnPropertyDescriptor(Kgt.prototype, "spriteFrame"), Kgt.prototype), + Bl(Kgt.prototype, "totalParticles", [ nh, igt ], Object.getOwnPropertyDescriptor(Kgt.prototype, "totalParticles"), Kgt.prototype), + Jgt = Bl(Kgt.prototype, "duration", [ Yl, nh, sgt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return -1; + } + }), Zgt = Bl(Kgt.prototype, "emissionRate", [ Yl, nh, ngt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 10; + } + }), Qgt = Bl(Kgt.prototype, "life", [ Yl, nh, rgt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), $gt = Bl(Kgt.prototype, "lifeVar", [ Yl, nh, ogt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Bl(Kgt.prototype, "startColor", [ nh, agt ], Object.getOwnPropertyDescriptor(Kgt.prototype, "startColor"), Kgt.prototype), + Bl(Kgt.prototype, "startColorVar", [ nh, lgt ], Object.getOwnPropertyDescriptor(Kgt.prototype, "startColorVar"), Kgt.prototype), + Bl(Kgt.prototype, "color", [ hgt ], Object.getOwnPropertyDescriptor(Kgt.prototype, "color"), Kgt.prototype), + Bl(Kgt.prototype, "endColor", [ nh, cgt ], Object.getOwnPropertyDescriptor(Kgt.prototype, "endColor"), Kgt.prototype), + Bl(Kgt.prototype, "endColorVar", [ nh, ugt ], Object.getOwnPropertyDescriptor(Kgt.prototype, "endColorVar"), Kgt.prototype), + tyt = Bl(Kgt.prototype, "angle", [ Yl, nh, _gt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 90; + } + }), eyt = Bl(Kgt.prototype, "angleVar", [ Yl, nh, dgt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 20; + } + }), iyt = Bl(Kgt.prototype, "startSize", [ Yl, nh, pgt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 50; + } + }), syt = Bl(Kgt.prototype, "startSizeVar", [ Yl, nh, mgt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), nyt = Bl(Kgt.prototype, "endSize", [ Yl, nh, fgt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), ryt = Bl(Kgt.prototype, "endSizeVar", [ Yl, nh, ggt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), oyt = Bl(Kgt.prototype, "startSpin", [ Yl, nh, ygt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), ayt = Bl(Kgt.prototype, "startSpinVar", [ Yl, nh, bgt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), lyt = Bl(Kgt.prototype, "endSpin", [ Yl, nh, Sgt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), hyt = Bl(Kgt.prototype, "endSpinVar", [ Yl, nh, Agt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), cyt = Bl(Kgt.prototype, "sourcePos", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Qi.ZERO.clone(); + } + }), uyt = Bl(Kgt.prototype, "posVar", [ Yl, nh, Tgt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Qi.ZERO.clone(); + } + }), Bl(Kgt.prototype, "positionType", [ vgt, Egt ], Object.getOwnPropertyDescriptor(Kgt.prototype, "positionType"), Kgt.prototype), + Bl(Kgt.prototype, "preview", [ nh, Cgt, xgt ], Object.getOwnPropertyDescriptor(Kgt.prototype, "preview"), Kgt.prototype), + _yt = Bl(Kgt.prototype, "emitterMode", [ Yl, nh, wgt, Rgt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Tft.GRAVITY; + } + }), dyt = Bl(Kgt.prototype, "gravity", [ Yl, nh, Igt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Qi.ZERO.clone(); + } + }), pyt = Bl(Kgt.prototype, "speed", [ Yl, nh, Mgt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 180; + } + }), myt = Bl(Kgt.prototype, "speedVar", [ Yl, nh, Bgt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 50; + } + }), fyt = Bl(Kgt.prototype, "tangentialAccel", [ Yl, nh, Dgt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 80; + } + }), gyt = Bl(Kgt.prototype, "tangentialAccelVar", [ Yl, nh, Pgt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), yyt = Bl(Kgt.prototype, "radialAccel", [ Yl, nh, Ogt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), byt = Bl(Kgt.prototype, "radialAccelVar", [ Yl, nh, Ngt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Syt = Bl(Kgt.prototype, "rotationIsDir", [ Yl, nh, Lgt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Ayt = Bl(Kgt.prototype, "startRadius", [ Yl, nh, Fgt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Tyt = Bl(Kgt.prototype, "startRadiusVar", [ Yl, nh, Vgt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), vyt = Bl(Kgt.prototype, "endRadius", [ Yl, nh, kgt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Eyt = Bl(Kgt.prototype, "endRadiusVar", [ Yl, nh, Ugt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Cyt = Bl(Kgt.prototype, "rotatePerS", [ Yl, nh, Ggt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), xyt = Bl(Kgt.prototype, "rotatePerSVar", [ Yl, nh, zgt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), wyt = Bl(Kgt.prototype, "playOnLoad", [ Yl, nh, Hgt, jgt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), Ryt = Bl(Kgt.prototype, "autoRemoveOnFinish", [ Yl, nh, Xgt, Wgt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Iyt = Bl(Kgt.prototype, "_preview", [ Ygt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), Myt = Bl(Kgt.prototype, "_custom", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Byt = Bl(Kgt.prototype, "_file", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Dyt = Bl(Kgt.prototype, "_spriteFrame", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Pyt = Bl(Kgt.prototype, "_totalParticles", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 150; + } + }), Oyt = Bl(Kgt.prototype, "_startColor", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Bi(255, 255, 255, 255); + } + }), Nyt = Bl(Kgt.prototype, "_startColorVar", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Bi(0, 0, 0, 0); + } + }), Lyt = Bl(Kgt.prototype, "_endColor", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Bi(255, 255, 255, 0); + } + }), Fyt = Bl(Kgt.prototype, "_endColorVar", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Bi(0, 0, 0, 0); + } + }), Vyt = Bl(Kgt.prototype, "_positionType", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return vft.FREE; + } + }), Kgt)) || qgt) || qgt) || qgt) || qgt)); + var jyt, Xyt, Wyt, Yyt, qyt, Kyt, Jyt, Zyt, Qyt, $yt, tbt, ebt, ibt, sbt; + let nbt = t("MotionStreak", (jyt = Ul("cc.MotionStreak"), Xyt = $l(), Wyt = sh(), + Yyt = Th(LC), jyt(qyt = Ql(qyt = th(qyt = Xyt(qyt = Wyt(qyt = (Kyt = (sbt = ibt = class t extends uD { + constructor(...t) { + super(...t); + Ml(this, "_preview", Jyt, this); + Ml(this, "_fadeTime", Zyt, this); + Ml(this, "_minSeg", Qyt, this); + Ml(this, "_stroke", $yt, this); + Ml(this, "_texture", tbt, this); + Ml(this, "_fastMode", ebt, this); + this._points = []; + } + get preview() { + return this._preview; + } + set preview(t) { + this._preview = t; + this.reset(); + } + get fadeTime() { + return this._fadeTime; + } + set fadeTime(t) { + this._fadeTime = t; + this.reset(); + } + get minSeg() { + return this._minSeg; + } + set minSeg(t) { + this._minSeg = t; + } + get stroke() { + return this._stroke; + } + set stroke(t) { + this._stroke = t; + } + get texture() { + return this._texture; + } + set texture(t) { + this._texture !== t && (this._texture = t); + } + get fastMode() { + return this._fastMode; + } + set fastMode(t) { + this._fastMode = t; + } + get points() { + return this._points; + } + onEnable() { + super.onEnable(); + this.reset(); + } + _flushAssembler() { + const e = t.Assembler.getAssembler(this); + this._assembler !== e && (this._assembler = e); + if (!this.renderData && this._assembler && this._assembler.createData) { + this._renderData = this._assembler.createData(this); + this.renderData.material = this.material; + this._updateColor(); + } + } + onFocusInEditor() { + this._preview && this.reset(); + } + onLostFocusInEditor() { + this._preview && this.reset(); + } + reset() { + this._points.length = 0; + this.renderData && this.renderData.clear(); + } + lateUpdate(t) { + this._assembler && this._assembler.update(this, t); + } + _render(t) { + t.commitComp(this, this.renderData, this._texture, this._assembler, null); + } + }, ibt.Point = class { + constructor(t, e) { + this.point = new Qi; + this.dir = new Qi; + this.distance = 0; + this.time = 0; + t && this.point.set(t); + e && this.dir.set(e); + } + setPoint(t, e) { + this.point.x = t; + this.point.y = e; + } + setDir(t, e) { + this.dir.x = t; + this.dir.y = e; + } + }, sbt), Bl(Kyt.prototype, "preview", [ nh ], Object.getOwnPropertyDescriptor(Kyt.prototype, "preview"), Kyt.prototype), + Bl(Kyt.prototype, "fadeTime", [ nh ], Object.getOwnPropertyDescriptor(Kyt.prototype, "fadeTime"), Kyt.prototype), + Bl(Kyt.prototype, "minSeg", [ nh ], Object.getOwnPropertyDescriptor(Kyt.prototype, "minSeg"), Kyt.prototype), + Bl(Kyt.prototype, "stroke", [ nh ], Object.getOwnPropertyDescriptor(Kyt.prototype, "stroke"), Kyt.prototype), + Bl(Kyt.prototype, "texture", [ Yyt ], Object.getOwnPropertyDescriptor(Kyt.prototype, "texture"), Kyt.prototype), + Bl(Kyt.prototype, "fastMode", [ nh ], Object.getOwnPropertyDescriptor(Kyt.prototype, "fastMode"), Kyt.prototype), + Jyt = Bl(Kyt.prototype, "_preview", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Zyt = Bl(Kyt.prototype, "_fadeTime", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), Qyt = Bl(Kyt.prototype, "_minSeg", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), $yt = Bl(Kyt.prototype, "_stroke", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 64; + } + }), tbt = Bl(Kyt.prototype, "_texture", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), ebt = Bl(Kyt.prototype, "_fastMode", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Kyt)) || qyt) || qyt) || qyt) || qyt) || qyt)); + new Qi; + const rbt = new Qi; + const obt = new Qi; + let abt; + function lbt(t, e) { + t.x = -e.y; + t.y = e.x; + return t; + } + const hbt = { + createData(t) { + const e = t.requestRenderData(); + e.dataLength = 4; + e.resize(16, 42); + return e; + }, + update(t, e) { + const i = t.stroke / 2; + const s = t.node.worldMatrix; + const n = s.m12; + const r = s.m13; + const o = t.points; + let a; + if (o.length > 1) { + const e = o[0]; + const i = e.point.x - n; + const s = e.point.y - r; + i * i + s * s < t.minSeg && (a = e); + } + if (!a) { + a = new nbt.Point; + o.unshift(a); + } + a.setPoint(n, r); + a.time = t.fadeTime + e; + let l = 0; + let h = 0; + if (o.length < 2) return; + const c = t.renderData; + this.updateRenderDataCache(t, c); + const u = t.color; + const _ = u.r; + const d = u.g; + const p = u.b; + const m = u.a; + const f = o[1]; + f.distance = Qi.subtract(obt, a.point, f.point).length(); + obt.normalize(); + f.setDir(obt.x, obt.y); + a.setDir(obt.x, obt.y); + c.dataLength = 2 * o.length; + const g = c.data; + const y = t.fadeTime; + let b = !1; + for (let t = o.length - 1; t >= 0; t--) { + const s = o[t]; + const n = s.point; + const r = s.dir; + s.time -= e; + if (s.time < 0) { + o.splice(t, 1); + continue; + } + const a = s.time / y; + const h = o[t - 1]; + if (!b) { + if (!h) { + o.splice(t, 1); + continue; + } + n.x = h.point.x - r.x * a; + n.y = h.point.y - r.y * a; + } + b = !0; + lbt(rbt, r); + const c = (a * m << 24 >>> 0) + (p << 16) + (d << 8) + _; + let u = l; + g[u].x = n.x + rbt.x * i; + g[u].y = n.y + rbt.y * i; + g[u].u = 1; + g[u].v = a; + g[u].color._val = c; + u += 1; + g[u].x = n.x - rbt.x * i; + g[u].y = n.y - rbt.y * i; + g[u].u = 0; + g[u].v = a; + g[u].color._val = c; + l += 2; + } + h = l <= 2 ? 0 : 3 * (l - 2); + c.resize(l, h); + { + const e = c.indexCount; + this.createQuadIndices(t, e); + c.chunk.setIndexBuffer(abt); + this.updateWorldVertexAllData(t); + c.updateRenderData(t, t.texture); + c.renderDrawInfo.setVertDirty(!1); + t.node.hasChangedFlags = 0; + } + }, + updateWorldVertexAllData(t) { + const e = t.renderData; + const i = e.floatStride; + const s = e.data; + const n = e.chunk.vb; + for (let t = 0; t < s.length; t++) { + const e = t * i; + n[e + 0] = s[t].x; + n[e + 1] = s[t].y; + n[e + 2] = s[t].z; + n[e + 3] = s[t].u; + n[e + 4] = s[t].v; + Bi.toArray(n, s[t].color, e + 5); + } + }, + createQuadIndices(t, e) { + let i = t.renderData.chunk.meshBuffer.indexOffset; + abt = null; + abt = new Uint16Array(e); + for (let t = 0, s = e; t < s; t += 2) { + const e = 0 + t; + abt[i++] = e; + abt[i++] = e + 2; + abt[i++] = e + 1; + abt[i++] = e + 1; + abt[i++] = e + 2; + abt[i++] = e + 3; + } + }, + updateRenderDataCache(t, e) { + e.passDirty && e.updatePass(t); + e.nodeDirty && e.updateNode(t); + if (e.textureDirty && t.texture) { + e.updateTexture(t.texture); + e.material = t.getRenderMaterial(0); + } + e.hashDirty && e.updateHash(); + }, + updateRenderData(t) {}, + updateColor(t) {}, + fillBuffers(t, e) { + const i = t.renderData; + const s = i.chunk; + const n = i.data; + const r = i.vertexCount; + const o = i.indexCount; + const a = s.vb; + let l = 0; + for (let t = 0; t < r; t++) { + const e = n[t]; + a[l++] = e.x; + a[l++] = e.y; + a[l++] = e.z; + a[l++] = e.u; + a[l++] = e.v; + Bi.toArray(a, e.color, l); + l += 4; + } + s.bufferId; + const h = s.vertexOffset; + const c = s.meshBuffer; + const u = s.meshBuffer.iData; + let _ = c.indexOffset; + for (let t = 0, e = o; t < e; t += 2) { + const e = h + t; + u[_++] = e; + u[_++] = e + 2; + u[_++] = e + 1; + u[_++] = e + 1; + u[_++] = e + 2; + u[_++] = e + 3; + } + c.indexOffset += i.indexCount; + c.setDirty(); + } + }; + const cbt = t("MotionStreakAssemblerManager", { + getAssembler: t => hbt + }); + nbt.Assembler = cbt; + const ubt = { + maxParticleDeltaTime: 0, + createData: t => AB.add(), + removeData(t) { + AB.remove(t); + }, + updateRenderData() {}, + fillBuffers(t, e) {} + }; + const _bt = t("ParticleSystem2DAssembler", { + getAssembler(t) { + ubt.maxParticleDeltaTime || (ubt.maxParticleDeltaTime = m.game.frameTime / 1e3 * 2); + return ubt; + } + }); + Hyt.Assembler = _bt; + let dbt; + let pbt; + "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self && self; + var mbt = function(t, e) { + return t(e = { + exports: {} + }, e.exports), e.exports; + }((function(t, e) { + !function(t) { + function e(t, ...e) { + if (!t) throw new Error(...e); + } + function i(t, e) { + return void 0 !== t ? t : e; + } + const s = 1e37; + const n = 1e-5; + const r = n * n; + const o = 3.14159265359; + const a = 2; + const l = 8; + const h = .1; + const c = 2; + const u = .008; + const _ = 2 / 180 * o; + const d = 2 * u; + const p = 8; + const m = 32; + const f = 1; + const g = .2; + const y = 8 / 180 * o; + const b = 2; + const S = b * b; + const A = .5 * o; + const T = A * A; + const v = .2; + const E = .75; + const C = -1; + const x = 2147483647; + const w = .75; + const R = 1; + const I = .25; + const M = .5; + const B = 2; + const D = B * B; + const P = 256; + const O = 2.5; + const N = .5; + const L = .01; + const F = 2 / 180 * o; + function V(t) { + return null; + } + function k(t) {} + function U(t, ...e) {} + class G { + constructor(t = 0, e = 0, i = 0) { + this.major = 0; + this.minor = 0; + this.revision = 0; + this.major = t; + this.minor = e; + this.revision = i; + } + toString() { + return this.major + "." + this.minor + "." + this.revision; + } + } + const z = new G(2, 3, 2); + const H = "master"; + const j = "fbf51801d80fc389d43dc46524520e89043b6faf"; + function X(t) { + return parseInt(t, 10); + } + function W(t) { + return Math.abs(parseInt(t, 10)); + } + function Y(t, e) { + const i = new Array(t); + for (let s = 0; s < t; ++s) i[s] = e(s); + return i; + } + function q(t) { + const e = new Array(t); + for (let i = 0; i < t; ++i) e[i] = null; + return e; + } + function K(t, e = 0) { + const i = new Array(t); + for (let s = 0; s < t; ++s) i[s] = e; + return i; + } + const J = o / 180; + const Z = 180 / o; + const Q = 2 * o; + const $ = Math.abs; + function tt(t, e) { + return t < e ? t : e; + } + function et(t, e) { + return t > e ? t : e; + } + function it(t, e, i) { + return t < e ? e : t > i ? i : t; + } + function st(t, e) { + const i = t[0]; + t[0] = e[0]; + e[0] = i; + } + const nt = isFinite; + function rt(t) { + return t * t; + } + function ot(t) { + return 1 / Math.sqrt(t); + } + const at = Math.sqrt; + const lt = Math.pow; + function ht(t) { + return t * J; + } + function ct(t) { + return t * Z; + } + const ut = Math.cos; + const _t = Math.sin; + const dt = Math.acos; + const pt = Math.asin; + const mt = Math.atan2; + function ft(t) { + t |= t >> 1 & 2147483647; + t |= t >> 2 & 1073741823; + t |= t >> 4 & 268435455; + t |= t >> 8 & 16777215; + return 1 + (t |= t >> 16 & 65535); + } + function gt(t) { + return t > 0 && 0 == (t & t - 1); + } + function yt() { + return 2 * Math.random() - 1; + } + function bt(t, e) { + return (e - t) * Math.random() + t; + } + class St { + constructor(...t) { + if (t[0] instanceof Float32Array) { + if (2 !== t[0].length) throw new Error; + this.data = t[0]; + } else { + const e = "number" == typeof t[0] ? t[0] : 0; + const i = "number" == typeof t[1] ? t[1] : 0; + this.data = new Float32Array([ e, i ]); + } + } + get x() { + return this.data[0]; + } + set x(t) { + this.data[0] = t; + } + get y() { + return this.data[1]; + } + set y(t) { + this.data[1] = t; + } + Clone() { + return new St(this.x, this.y); + } + SetZero() { + this.x = 0; + this.y = 0; + return this; + } + Set(t, e) { + this.x = t; + this.y = e; + return this; + } + Copy(t) { + this.x = t.x; + this.y = t.y; + return this; + } + SelfAdd(t) { + this.x += t.x; + this.y += t.y; + return this; + } + SelfAddXY(t, e) { + this.x += t; + this.y += e; + return this; + } + SelfSub(t) { + this.x -= t.x; + this.y -= t.y; + return this; + } + SelfSubXY(t, e) { + this.x -= t; + this.y -= e; + return this; + } + SelfMul(t) { + this.x *= t; + this.y *= t; + return this; + } + SelfMulAdd(t, e) { + this.x += t * e.x; + this.y += t * e.y; + return this; + } + SelfMulSub(t, e) { + this.x -= t * e.x; + this.y -= t * e.y; + return this; + } + Dot(t) { + return this.x * t.x + this.y * t.y; + } + Cross(t) { + return this.x * t.y - this.y * t.x; + } + Length() { + const t = this.x, e = this.y; + return Math.sqrt(t * t + e * e); + } + LengthSquared() { + const t = this.x, e = this.y; + return t * t + e * e; + } + Normalize() { + const t = this.Length(); + if (t >= n) { + const e = 1 / t; + this.x *= e; + this.y *= e; + } + return t; + } + SelfNormalize() { + const t = this.Length(); + if (t >= n) { + const e = 1 / t; + this.x *= e; + this.y *= e; + } + return this; + } + SelfRotate(t) { + const e = Math.cos(t); + const i = Math.sin(t); + const s = this.x; + this.x = e * s - i * this.y; + this.y = i * s + e * this.y; + return this; + } + SelfRotateCosSin(t, e) { + const i = this.x; + this.x = t * i - e * this.y; + this.y = e * i + t * this.y; + return this; + } + IsValid() { + return isFinite(this.x) && isFinite(this.y); + } + SelfCrossVS(t) { + const e = this.x; + this.x = t * this.y; + this.y = -t * e; + return this; + } + SelfCrossSV(t) { + const e = this.x; + this.x = -t * this.y; + this.y = t * e; + return this; + } + SelfMinV(t) { + this.x = tt(this.x, t.x); + this.y = tt(this.y, t.y); + return this; + } + SelfMaxV(t) { + this.x = et(this.x, t.x); + this.y = et(this.y, t.y); + return this; + } + SelfAbs() { + this.x = $(this.x); + this.y = $(this.y); + return this; + } + SelfNeg() { + this.x = -this.x; + this.y = -this.y; + return this; + } + SelfSkew() { + const t = this.x; + this.x = -this.y; + this.y = t; + return this; + } + static MakeArray(t) { + return Y(t, (t => new St)); + } + static AbsV(t, e) { + e.x = $(t.x); + e.y = $(t.y); + return e; + } + static MinV(t, e, i) { + i.x = tt(t.x, e.x); + i.y = tt(t.y, e.y); + return i; + } + static MaxV(t, e, i) { + i.x = et(t.x, e.x); + i.y = et(t.y, e.y); + return i; + } + static ClampV(t, e, i, s) { + s.x = it(t.x, e.x, i.x); + s.y = it(t.y, e.y, i.y); + return s; + } + static RotateV(t, e, i) { + const s = t.x, n = t.y; + const r = Math.cos(e); + const o = Math.sin(e); + i.x = r * s - o * n; + i.y = o * s + r * n; + return i; + } + static DotVV(t, e) { + return t.x * e.x + t.y * e.y; + } + static CrossVV(t, e) { + return t.x * e.y - t.y * e.x; + } + static CrossVS(t, e, i) { + const s = t.x; + i.x = e * t.y; + i.y = -e * s; + return i; + } + static CrossVOne(t, e) { + const i = t.x; + e.x = t.y; + e.y = -i; + return e; + } + static CrossSV(t, e, i) { + const s = e.x; + i.x = -t * e.y; + i.y = t * s; + return i; + } + static CrossOneV(t, e) { + const i = t.x; + e.x = -t.y; + e.y = i; + return e; + } + static AddVV(t, e, i) { + i.x = t.x + e.x; + i.y = t.y + e.y; + return i; + } + static SubVV(t, e, i) { + i.x = t.x - e.x; + i.y = t.y - e.y; + return i; + } + static MulSV(t, e, i) { + i.x = e.x * t; + i.y = e.y * t; + return i; + } + static MulVS(t, e, i) { + i.x = t.x * e; + i.y = t.y * e; + return i; + } + static AddVMulSV(t, e, i, s) { + s.x = t.x + e * i.x; + s.y = t.y + e * i.y; + return s; + } + static SubVMulSV(t, e, i, s) { + s.x = t.x - e * i.x; + s.y = t.y - e * i.y; + return s; + } + static AddVCrossSV(t, e, i, s) { + const n = i.x; + s.x = t.x - e * i.y; + s.y = t.y + e * n; + return s; + } + static MidVV(t, e, i) { + i.x = .5 * (t.x + e.x); + i.y = .5 * (t.y + e.y); + return i; + } + static ExtVV(t, e, i) { + i.x = .5 * (e.x - t.x); + i.y = .5 * (e.y - t.y); + return i; + } + static IsEqualToV(t, e) { + return t.x === e.x && t.y === e.y; + } + static DistanceVV(t, e) { + const i = t.x - e.x; + const s = t.y - e.y; + return Math.sqrt(i * i + s * s); + } + static DistanceSquaredVV(t, e) { + const i = t.x - e.x; + const s = t.y - e.y; + return i * i + s * s; + } + static NegV(t, e) { + e.x = -t.x; + e.y = -t.y; + return e; + } + } + St.ZERO = new St(0, 0); + St.UNITX = new St(1, 0); + St.UNITY = new St(0, 1); + St.s_t0 = new St; + St.s_t1 = new St; + St.s_t2 = new St; + St.s_t3 = new St; + const At = new St(0, 0); + class Tt { + constructor(...t) { + if (t[0] instanceof Float32Array) { + if (3 !== t[0].length) throw new Error; + this.data = t[0]; + } else { + const e = "number" == typeof t[0] ? t[0] : 0; + const i = "number" == typeof t[1] ? t[1] : 0; + const s = "number" == typeof t[2] ? t[2] : 0; + this.data = new Float32Array([ e, i, s ]); + } + } + get x() { + return this.data[0]; + } + set x(t) { + this.data[0] = t; + } + get y() { + return this.data[1]; + } + set y(t) { + this.data[1] = t; + } + get z() { + return this.data[2]; + } + set z(t) { + this.data[2] = t; + } + Clone() { + return new Tt(this.x, this.y, this.z); + } + SetZero() { + this.x = 0; + this.y = 0; + this.z = 0; + return this; + } + SetXYZ(t, e, i) { + this.x = t; + this.y = e; + this.z = i; + return this; + } + Copy(t) { + this.x = t.x; + this.y = t.y; + this.z = t.z; + return this; + } + SelfNeg() { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + return this; + } + SelfAdd(t) { + this.x += t.x; + this.y += t.y; + this.z += t.z; + return this; + } + SelfAddXYZ(t, e, i) { + this.x += t; + this.y += e; + this.z += i; + return this; + } + SelfSub(t) { + this.x -= t.x; + this.y -= t.y; + this.z -= t.z; + return this; + } + SelfSubXYZ(t, e, i) { + this.x -= t; + this.y -= e; + this.z -= i; + return this; + } + SelfMul(t) { + this.x *= t; + this.y *= t; + this.z *= t; + return this; + } + static DotV3V3(t, e) { + return t.x * e.x + t.y * e.y + t.z * e.z; + } + static CrossV3V3(t, e, i) { + const s = t.x, n = t.y, r = t.z; + const o = e.x, a = e.y, l = e.z; + i.x = n * l - r * a; + i.y = r * o - s * l; + i.z = s * a - n * o; + return i; + } + } + Tt.ZERO = new Tt(0, 0, 0); + Tt.s_t0 = new Tt; + class vt { + constructor() { + this.data = new Float32Array([ 1, 0, 0, 1 ]); + this.ex = new St(this.data.subarray(0, 2)); + this.ey = new St(this.data.subarray(2, 4)); + } + Clone() { + return (new vt).Copy(this); + } + static FromVV(t, e) { + return (new vt).SetVV(t, e); + } + static FromSSSS(t, e, i, s) { + return (new vt).SetSSSS(t, e, i, s); + } + static FromAngle(t) { + return (new vt).SetAngle(t); + } + SetSSSS(t, e, i, s) { + this.ex.Set(t, i); + this.ey.Set(e, s); + return this; + } + SetVV(t, e) { + this.ex.Copy(t); + this.ey.Copy(e); + return this; + } + SetAngle(t) { + const e = Math.cos(t); + const i = Math.sin(t); + this.ex.Set(e, i); + this.ey.Set(-i, e); + return this; + } + Copy(t) { + this.ex.Copy(t.ex); + this.ey.Copy(t.ey); + return this; + } + SetIdentity() { + this.ex.Set(1, 0); + this.ey.Set(0, 1); + return this; + } + SetZero() { + this.ex.SetZero(); + this.ey.SetZero(); + return this; + } + GetAngle() { + return Math.atan2(this.ex.y, this.ex.x); + } + GetInverse(t) { + const e = this.ex.x; + const i = this.ey.x; + const s = this.ex.y; + const n = this.ey.y; + let r = e * n - i * s; + 0 !== r && (r = 1 / r); + t.ex.x = r * n; + t.ey.x = -r * i; + t.ex.y = -r * s; + t.ey.y = r * e; + return t; + } + Solve(t, e, i) { + const s = this.ex.x, n = this.ey.x; + const r = this.ex.y, o = this.ey.y; + let a = s * o - n * r; + 0 !== a && (a = 1 / a); + i.x = a * (o * t - n * e); + i.y = a * (s * e - r * t); + return i; + } + SelfAbs() { + this.ex.SelfAbs(); + this.ey.SelfAbs(); + return this; + } + SelfInv() { + this.GetInverse(this); + return this; + } + SelfAddM(t) { + this.ex.SelfAdd(t.ex); + this.ey.SelfAdd(t.ey); + return this; + } + SelfSubM(t) { + this.ex.SelfSub(t.ex); + this.ey.SelfSub(t.ey); + return this; + } + static AbsM(t, e) { + const i = t.ex, s = t.ey; + e.ex.x = $(i.x); + e.ex.y = $(i.y); + e.ey.x = $(s.x); + e.ey.y = $(s.y); + return e; + } + static MulMV(t, e, i) { + const s = t.ex, n = t.ey; + const r = e.x, o = e.y; + i.x = s.x * r + n.x * o; + i.y = s.y * r + n.y * o; + return i; + } + static MulTMV(t, e, i) { + const s = t.ex, n = t.ey; + const r = e.x, o = e.y; + i.x = s.x * r + s.y * o; + i.y = n.x * r + n.y * o; + return i; + } + static AddMM(t, e, i) { + const s = t.ex, n = t.ey; + const r = e.ex, o = e.ey; + i.ex.x = s.x + r.x; + i.ex.y = s.y + r.y; + i.ey.x = n.x + o.x; + i.ey.y = n.y + o.y; + return i; + } + static MulMM(t, e, i) { + const s = t.ex.x, n = t.ex.y; + const r = t.ey.x, o = t.ey.y; + const a = e.ex.x, l = e.ex.y; + const h = e.ey.x, c = e.ey.y; + i.ex.x = s * a + r * l; + i.ex.y = n * a + o * l; + i.ey.x = s * h + r * c; + i.ey.y = n * h + o * c; + return i; + } + static MulTMM(t, e, i) { + const s = t.ex.x, n = t.ex.y; + const r = t.ey.x, o = t.ey.y; + const a = e.ex.x, l = e.ex.y; + const h = e.ey.x, c = e.ey.y; + i.ex.x = s * a + n * l; + i.ex.y = r * a + o * l; + i.ey.x = s * h + n * c; + i.ey.y = r * h + o * c; + return i; + } + } + vt.IDENTITY = new vt; + class Et { + constructor() { + this.data = new Float32Array([ 1, 0, 0, 0, 1, 0, 0, 0, 1 ]); + this.ex = new Tt(this.data.subarray(0, 3)); + this.ey = new Tt(this.data.subarray(3, 6)); + this.ez = new Tt(this.data.subarray(6, 9)); + } + Clone() { + return (new Et).Copy(this); + } + SetVVV(t, e, i) { + this.ex.Copy(t); + this.ey.Copy(e); + this.ez.Copy(i); + return this; + } + Copy(t) { + this.ex.Copy(t.ex); + this.ey.Copy(t.ey); + this.ez.Copy(t.ez); + return this; + } + SetIdentity() { + this.ex.SetXYZ(1, 0, 0); + this.ey.SetXYZ(0, 1, 0); + this.ez.SetXYZ(0, 0, 1); + return this; + } + SetZero() { + this.ex.SetZero(); + this.ey.SetZero(); + this.ez.SetZero(); + return this; + } + SelfAddM(t) { + this.ex.SelfAdd(t.ex); + this.ey.SelfAdd(t.ey); + this.ez.SelfAdd(t.ez); + return this; + } + Solve33(t, e, i, s) { + const n = this.ex.x, r = this.ex.y, o = this.ex.z; + const a = this.ey.x, l = this.ey.y, h = this.ey.z; + const c = this.ez.x, u = this.ez.y, _ = this.ez.z; + let d = n * (l * _ - h * u) + r * (h * c - a * _) + o * (a * u - l * c); + 0 !== d && (d = 1 / d); + s.x = d * (t * (l * _ - h * u) + e * (h * c - a * _) + i * (a * u - l * c)); + s.y = d * (n * (e * _ - i * u) + r * (i * c - t * _) + o * (t * u - e * c)); + s.z = d * (n * (l * i - h * e) + r * (h * t - a * i) + o * (a * e - l * t)); + return s; + } + Solve22(t, e, i) { + const s = this.ex.x, n = this.ey.x; + const r = this.ex.y, o = this.ey.y; + let a = s * o - n * r; + 0 !== a && (a = 1 / a); + i.x = a * (o * t - n * e); + i.y = a * (s * e - r * t); + return i; + } + GetInverse22(t) { + const e = this.ex.x, i = this.ey.x, s = this.ex.y, n = this.ey.y; + let r = e * n - i * s; + 0 !== r && (r = 1 / r); + t.ex.x = r * n; + t.ey.x = -r * i; + t.ex.z = 0; + t.ex.y = -r * s; + t.ey.y = r * e; + t.ey.z = 0; + t.ez.x = 0; + t.ez.y = 0; + t.ez.z = 0; + } + GetSymInverse33(t) { + let e = Tt.DotV3V3(this.ex, Tt.CrossV3V3(this.ey, this.ez, Tt.s_t0)); + 0 !== e && (e = 1 / e); + const i = this.ex.x, s = this.ey.x, n = this.ez.x; + const r = this.ey.y, o = this.ez.y; + const a = this.ez.z; + t.ex.x = e * (r * a - o * o); + t.ex.y = e * (n * o - s * a); + t.ex.z = e * (s * o - n * r); + t.ey.x = t.ex.y; + t.ey.y = e * (i * a - n * n); + t.ey.z = e * (n * s - i * o); + t.ez.x = t.ex.z; + t.ez.y = t.ey.z; + t.ez.z = e * (i * r - s * s); + } + static MulM33V3(t, e, i) { + const s = e.x, n = e.y, r = e.z; + i.x = t.ex.x * s + t.ey.x * n + t.ez.x * r; + i.y = t.ex.y * s + t.ey.y * n + t.ez.y * r; + i.z = t.ex.z * s + t.ey.z * n + t.ez.z * r; + return i; + } + static MulM33XYZ(t, e, i, s, n) { + n.x = t.ex.x * e + t.ey.x * i + t.ez.x * s; + n.y = t.ex.y * e + t.ey.y * i + t.ez.y * s; + n.z = t.ex.z * e + t.ey.z * i + t.ez.z * s; + return n; + } + static MulM33V2(t, e, i) { + const s = e.x, n = e.y; + i.x = t.ex.x * s + t.ey.x * n; + i.y = t.ex.y * s + t.ey.y * n; + return i; + } + static MulM33XY(t, e, i, s) { + s.x = t.ex.x * e + t.ey.x * i; + s.y = t.ex.y * e + t.ey.y * i; + return s; + } + } + Et.IDENTITY = new Et; + class Ct { + constructor(t = 0) { + this.s = 0; + this.c = 1; + if (t) { + this.s = Math.sin(t); + this.c = Math.cos(t); + } + } + Clone() { + return (new Ct).Copy(this); + } + Copy(t) { + this.s = t.s; + this.c = t.c; + return this; + } + SetAngle(t) { + this.s = Math.sin(t); + this.c = Math.cos(t); + return this; + } + SetIdentity() { + this.s = 0; + this.c = 1; + return this; + } + GetAngle() { + return Math.atan2(this.s, this.c); + } + GetXAxis(t) { + t.x = this.c; + t.y = this.s; + return t; + } + GetYAxis(t) { + t.x = -this.s; + t.y = this.c; + return t; + } + static MulRR(t, e, i) { + const s = t.c, n = t.s; + const r = e.c, o = e.s; + i.s = n * r + s * o; + i.c = s * r - n * o; + return i; + } + static MulTRR(t, e, i) { + const s = t.c, n = t.s; + const r = e.c, o = e.s; + i.s = s * o - n * r; + i.c = s * r + n * o; + return i; + } + static MulRV(t, e, i) { + const s = t.c, n = t.s; + const r = e.x, o = e.y; + i.x = s * r - n * o; + i.y = n * r + s * o; + return i; + } + static MulTRV(t, e, i) { + const s = t.c, n = t.s; + const r = e.x, o = e.y; + i.x = s * r + n * o; + i.y = -n * r + s * o; + return i; + } + } + Ct.IDENTITY = new Ct; + class xt { + constructor() { + this.p = new St; + this.q = new Ct; + } + Clone() { + return (new xt).Copy(this); + } + Copy(t) { + this.p.Copy(t.p); + this.q.Copy(t.q); + return this; + } + SetIdentity() { + this.p.SetZero(); + this.q.SetIdentity(); + return this; + } + SetPositionRotation(t, e) { + this.p.Copy(t); + this.q.Copy(e); + return this; + } + SetPositionAngle(t, e) { + this.p.Copy(t); + this.q.SetAngle(e); + return this; + } + SetPosition(t) { + this.p.Copy(t); + return this; + } + SetPositionXY(t, e) { + this.p.Set(t, e); + return this; + } + SetRotation(t) { + this.q.Copy(t); + return this; + } + SetRotationAngle(t) { + this.q.SetAngle(t); + return this; + } + GetPosition() { + return this.p; + } + GetRotation() { + return this.q; + } + GetRotationAngle() { + return this.q.GetAngle(); + } + GetAngle() { + return this.q.GetAngle(); + } + static MulXV(t, e, i) { + const s = t.q.c, n = t.q.s; + const r = e.x, o = e.y; + i.x = s * r - n * o + t.p.x; + i.y = n * r + s * o + t.p.y; + return i; + } + static MulTXV(t, e, i) { + const s = t.q.c, n = t.q.s; + const r = e.x - t.p.x; + const o = e.y - t.p.y; + i.x = s * r + n * o; + i.y = -n * r + s * o; + return i; + } + static MulXX(t, e, i) { + Ct.MulRR(t.q, e.q, i.q); + St.AddVV(Ct.MulRV(t.q, e.p, i.p), t.p, i.p); + return i; + } + static MulTXX(t, e, i) { + Ct.MulTRR(t.q, e.q, i.q); + Ct.MulTRV(t.q, St.SubVV(e.p, t.p, i.p), i.p); + return i; + } + } + xt.IDENTITY = new xt; + class wt { + constructor() { + this.localCenter = new St; + this.c0 = new St; + this.c = new St; + this.a0 = 0; + this.a = 0; + this.alpha0 = 0; + } + Clone() { + return (new wt).Copy(this); + } + Copy(t) { + this.localCenter.Copy(t.localCenter); + this.c0.Copy(t.c0); + this.c.Copy(t.c); + this.a0 = t.a0; + this.a = t.a; + this.alpha0 = t.alpha0; + return this; + } + GetTransform(t, e) { + const i = 1 - e; + t.p.x = i * this.c0.x + e * this.c.x; + t.p.y = i * this.c0.y + e * this.c.y; + const s = i * this.a0 + e * this.a; + t.q.SetAngle(s); + t.p.SelfSub(Ct.MulRV(t.q, this.localCenter, St.s_t0)); + return t; + } + Advance(t) { + const e = (t - this.alpha0) / (1 - this.alpha0); + const i = 1 - e; + this.c0.x = i * this.c0.x + e * this.c.x; + this.c0.y = i * this.c0.y + e * this.c.y; + this.a0 = i * this.a0 + e * this.a; + this.alpha0 = t; + } + Normalize() { + const t = Q * Math.floor(this.a0 / Q); + this.a0 -= t; + this.a -= t; + } + } + class Rt { + constructor(...t) { + if (t[0] instanceof Float32Array) { + if (4 !== t[0].length) throw new Error; + this.data = t[0]; + } else { + const e = "number" == typeof t[0] ? t[0] : .5; + const i = "number" == typeof t[1] ? t[1] : .5; + const s = "number" == typeof t[2] ? t[2] : .5; + const n = "number" == typeof t[3] ? t[3] : 1; + this.data = new Float32Array([ e, i, s, n ]); + } + } + get r() { + return this.data[0]; + } + set r(t) { + this.data[0] = t; + } + get g() { + return this.data[1]; + } + set g(t) { + this.data[1] = t; + } + get b() { + return this.data[2]; + } + set b(t) { + this.data[2] = t; + } + get a() { + return this.data[3]; + } + set a(t) { + this.data[3] = t; + } + Clone() { + return (new Rt).Copy(this); + } + Copy(t) { + this.r = t.r; + this.g = t.g; + this.b = t.b; + this.a = t.a; + return this; + } + IsEqual(t) { + return this.r === t.r && this.g === t.g && this.b === t.b && this.a === t.a; + } + IsZero() { + return 0 === this.r && 0 === this.g && 0 === this.b && 0 === this.a; + } + Set(t, e, i, s = this.a) { + this.SetRGBA(t, e, i, s); + } + SetByteRGB(t, e, i) { + this.r = t / 255; + this.g = e / 255; + this.b = i / 255; + return this; + } + SetByteRGBA(t, e, i, s) { + this.r = t / 255; + this.g = e / 255; + this.b = i / 255; + this.a = s / 255; + return this; + } + SetRGB(t, e, i) { + this.r = t; + this.g = e; + this.b = i; + return this; + } + SetRGBA(t, e, i, s) { + this.r = t; + this.g = e; + this.b = i; + this.a = s; + return this; + } + SelfAdd(t) { + this.r += t.r; + this.g += t.g; + this.b += t.b; + this.a += t.a; + return this; + } + Add(t, e) { + e.r = this.r + t.r; + e.g = this.g + t.g; + e.b = this.b + t.b; + e.a = this.a + t.a; + return e; + } + SelfSub(t) { + this.r -= t.r; + this.g -= t.g; + this.b -= t.b; + this.a -= t.a; + return this; + } + Sub(t, e) { + e.r = this.r - t.r; + e.g = this.g - t.g; + e.b = this.b - t.b; + e.a = this.a - t.a; + return e; + } + SelfMul(t) { + this.r *= t; + this.g *= t; + this.b *= t; + this.a *= t; + return this; + } + Mul(t, e) { + e.r = this.r * t; + e.g = this.g * t; + e.b = this.b * t; + e.a = this.a * t; + return e; + } + Mix(t, e) { + Rt.MixColors(this, t, e); + } + static MixColors(t, e, i) { + const s = i * (e.r - t.r); + const n = i * (e.g - t.g); + const r = i * (e.b - t.b); + const o = i * (e.a - t.a); + t.r += s; + t.g += n; + t.b += r; + t.a += o; + e.r -= s; + e.g -= n; + e.b -= r; + e.a -= o; + } + MakeStyleString(t = this.a) { + return Rt.MakeStyleString(this.r, this.g, this.b, t); + } + static MakeStyleString(t, e, i, s = 1) { + t *= 255; + e *= 255; + i *= 255; + return s < 1 ? `rgba(${t},${e},${i},${s})` : `rgb(${t},${e},${i})`; + } + } + Rt.ZERO = new Rt(0, 0, 0, 0); + Rt.RED = new Rt(1, 0, 0); + Rt.GREEN = new Rt(0, 1, 0); + Rt.BLUE = new Rt(0, 0, 1); + !function(t) { + t[t.e_none = 0] = "e_none"; + t[t.e_shapeBit = 1] = "e_shapeBit"; + t[t.e_jointBit = 2] = "e_jointBit"; + t[t.e_aabbBit = 4] = "e_aabbBit"; + t[t.e_pairBit = 8] = "e_pairBit"; + t[t.e_centerOfMassBit = 16] = "e_centerOfMassBit"; + t[t.e_particleBit = 32] = "e_particleBit"; + t[t.e_controllerBit = 64] = "e_controllerBit"; + t[t.e_all = 63] = "e_all"; + }(t.b2DrawFlags || (t.b2DrawFlags = {})); + class It { + constructor() { + this.m_drawFlags = 0; + } + SetFlags(t) { + this.m_drawFlags = t; + } + GetFlags() { + return this.m_drawFlags; + } + AppendFlags(t) { + this.m_drawFlags |= t; + } + ClearFlags(t) { + this.m_drawFlags &= ~t; + } + } + class Mt { + constructor() { + this.m_start = Date.now(); + } + Reset() { + this.m_start = Date.now(); + return this; + } + GetMilliseconds() { + return Date.now() - this.m_start; + } + } + class Bt { + constructor() { + this.m_count = 0; + this.m_min_count = 0; + this.m_max_count = 0; + } + GetCount() { + return this.m_count; + } + GetMinCount() { + return this.m_min_count; + } + GetMaxCount() { + return this.m_max_count; + } + ResetCount() { + const t = this.m_count; + this.m_count = 0; + return t; + } + ResetMinCount() { + this.m_min_count = 0; + } + ResetMaxCount() { + this.m_max_count = 0; + } + Increment() { + this.m_count++; + this.m_max_count < this.m_count && (this.m_max_count = this.m_count); + } + Decrement() { + this.m_count--; + this.m_min_count > this.m_count && (this.m_min_count = this.m_count); + } + } + class Dt { + constructor(t) { + this.m_stack = []; + this.m_count = 0; + this.m_stack = Y(t, (t => null)); + this.m_count = 0; + } + Reset() { + this.m_count = 0; + return this; + } + Push(t) { + this.m_stack[this.m_count] = t; + this.m_count++; + } + Pop() { + this.m_count--; + const t = this.m_stack[this.m_count]; + this.m_stack[this.m_count] = null; + if (null === t) throw new Error; + return t; + } + GetCount() { + return this.m_count; + } + } + class Pt {} + class Ot {} + class Nt { + constructor() { + this.m_buffer = St.MakeArray(2); + this.m_vertices = this.m_buffer; + this.m_count = 0; + this.m_radius = 0; + } + Copy(t) { + if (t.m_vertices === t.m_buffer) { + this.m_vertices = this.m_buffer; + this.m_buffer[0].Copy(t.m_buffer[0]); + this.m_buffer[1].Copy(t.m_buffer[1]); + } else this.m_vertices = t.m_vertices; + this.m_count = t.m_count; + this.m_radius = t.m_radius; + return this; + } + Reset() { + this.m_vertices = this.m_buffer; + this.m_count = 0; + this.m_radius = 0; + return this; + } + SetShape(t, e) { + t.SetupDistanceProxy(this, e); + } + SetVerticesRadius(t, e, i) { + this.m_vertices = t; + this.m_count = e; + this.m_radius = i; + } + GetSupport(t) { + let e = 0; + let i = St.DotVV(this.m_vertices[0], t); + for (let s = 1; s < this.m_count; ++s) { + const n = St.DotVV(this.m_vertices[s], t); + if (n > i) { + e = s; + i = n; + } + } + return e; + } + GetSupportVertex(t) { + let e = 0; + let i = St.DotVV(this.m_vertices[0], t); + for (let s = 1; s < this.m_count; ++s) { + const n = St.DotVV(this.m_vertices[s], t); + if (n > i) { + e = s; + i = n; + } + } + return this.m_vertices[e]; + } + GetVertexCount() { + return this.m_count; + } + GetVertex(t) { + return this.m_vertices[t]; + } + } + class Lt { + constructor() { + this.metric = 0; + this.count = 0; + this.indexA = [ 0, 0, 0 ]; + this.indexB = [ 0, 0, 0 ]; + } + Reset() { + this.metric = 0; + this.count = 0; + return this; + } + } + class Ft { + constructor() { + this.proxyA = new Nt; + this.proxyB = new Nt; + this.transformA = new xt; + this.transformB = new xt; + this.useRadii = !1; + } + Reset() { + this.proxyA.Reset(); + this.proxyB.Reset(); + this.transformA.SetIdentity(); + this.transformB.SetIdentity(); + this.useRadii = !1; + return this; + } + } + class Vt { + constructor() { + this.pointA = new St; + this.pointB = new St; + this.distance = 0; + this.iterations = 0; + } + Reset() { + this.pointA.SetZero(); + this.pointB.SetZero(); + this.distance = 0; + this.iterations = 0; + return this; + } + } + class kt { + constructor() { + this.proxyA = new Nt; + this.proxyB = new Nt; + this.transformA = new xt; + this.transformB = new xt; + this.translationB = new St; + } + } + class Ut { + constructor() { + this.point = new St; + this.normal = new St; + this.lambda = 0; + this.iterations = 0; + } + } + t.b2_gjkCalls = 0; + t.b2_gjkIters = 0; + t.b2_gjkMaxIters = 0; + function Gt() { + t.b2_gjkCalls = 0; + t.b2_gjkIters = 0; + t.b2_gjkMaxIters = 0; + } + class zt { + constructor() { + this.wA = new St; + this.wB = new St; + this.w = new St; + this.a = 0; + this.indexA = 0; + this.indexB = 0; + } + Copy(t) { + this.wA.Copy(t.wA); + this.wB.Copy(t.wB); + this.w.Copy(t.w); + this.a = t.a; + this.indexA = t.indexA; + this.indexB = t.indexB; + return this; + } + } + class Ht { + constructor() { + this.m_v1 = new zt; + this.m_v2 = new zt; + this.m_v3 = new zt; + this.m_vertices = []; + this.m_count = 0; + this.m_vertices[0] = this.m_v1; + this.m_vertices[1] = this.m_v2; + this.m_vertices[2] = this.m_v3; + } + ReadCache(t, e, i, s, r) { + this.m_count = t.count; + const o = this.m_vertices; + for (let n = 0; n < this.m_count; ++n) { + const a = o[n]; + a.indexA = t.indexA[n]; + a.indexB = t.indexB[n]; + const l = e.GetVertex(a.indexA); + const h = s.GetVertex(a.indexB); + xt.MulXV(i, l, a.wA); + xt.MulXV(r, h, a.wB); + St.SubVV(a.wB, a.wA, a.w); + a.a = 0; + } + if (this.m_count > 1) { + const e = t.metric; + const i = this.GetMetric(); + (i < .5 * e || 2 * e < i || i < n) && (this.m_count = 0); + } + if (0 === this.m_count) { + const t = o[0]; + t.indexA = 0; + t.indexB = 0; + const n = e.GetVertex(0); + const a = s.GetVertex(0); + xt.MulXV(i, n, t.wA); + xt.MulXV(r, a, t.wB); + St.SubVV(t.wB, t.wA, t.w); + t.a = 1; + this.m_count = 1; + } + } + WriteCache(t) { + t.metric = this.GetMetric(); + t.count = this.m_count; + const e = this.m_vertices; + for (let i = 0; i < this.m_count; ++i) { + t.indexA[i] = e[i].indexA; + t.indexB[i] = e[i].indexB; + } + } + GetSearchDirection(t) { + switch (this.m_count) { + case 1: + return St.NegV(this.m_v1.w, t); + + case 2: + { + const e = St.SubVV(this.m_v2.w, this.m_v1.w, t); + return St.CrossVV(e, St.NegV(this.m_v1.w, St.s_t0)) > 0 ? St.CrossOneV(e, t) : St.CrossVOne(e, t); + } + + default: + return t.SetZero(); + } + } + GetClosestPoint(t) { + switch (this.m_count) { + case 0: + case 3: + default: + return t.SetZero(); + + case 1: + return t.Copy(this.m_v1.w); + + case 2: + return t.Set(this.m_v1.a * this.m_v1.w.x + this.m_v2.a * this.m_v2.w.x, this.m_v1.a * this.m_v1.w.y + this.m_v2.a * this.m_v2.w.y); + } + } + GetWitnessPoints(t, e) { + switch (this.m_count) { + case 0: + break; + + case 1: + t.Copy(this.m_v1.wA); + e.Copy(this.m_v1.wB); + break; + + case 2: + t.x = this.m_v1.a * this.m_v1.wA.x + this.m_v2.a * this.m_v2.wA.x; + t.y = this.m_v1.a * this.m_v1.wA.y + this.m_v2.a * this.m_v2.wA.y; + e.x = this.m_v1.a * this.m_v1.wB.x + this.m_v2.a * this.m_v2.wB.x; + e.y = this.m_v1.a * this.m_v1.wB.y + this.m_v2.a * this.m_v2.wB.y; + break; + + case 3: + e.x = t.x = this.m_v1.a * this.m_v1.wA.x + this.m_v2.a * this.m_v2.wA.x + this.m_v3.a * this.m_v3.wA.x; + e.y = t.y = this.m_v1.a * this.m_v1.wA.y + this.m_v2.a * this.m_v2.wA.y + this.m_v3.a * this.m_v3.wA.y; + } + } + GetMetric() { + switch (this.m_count) { + case 0: + case 1: + default: + return 0; + + case 2: + return St.DistanceVV(this.m_v1.w, this.m_v2.w); + + case 3: + return St.CrossVV(St.SubVV(this.m_v2.w, this.m_v1.w, St.s_t0), St.SubVV(this.m_v3.w, this.m_v1.w, St.s_t1)); + } + } + Solve2() { + const t = this.m_v1.w; + const e = this.m_v2.w; + const i = St.SubVV(e, t, Ht.s_e12); + const s = -St.DotVV(t, i); + if (s <= 0) { + this.m_v1.a = 1; + this.m_count = 1; + return; + } + const n = St.DotVV(e, i); + if (n <= 0) { + this.m_v2.a = 1; + this.m_count = 1; + this.m_v1.Copy(this.m_v2); + return; + } + const r = 1 / (n + s); + this.m_v1.a = n * r; + this.m_v2.a = s * r; + this.m_count = 2; + } + Solve3() { + const t = this.m_v1.w; + const e = this.m_v2.w; + const i = this.m_v3.w; + const s = St.SubVV(e, t, Ht.s_e12); + const n = St.DotVV(t, s); + const r = St.DotVV(e, s); + const o = -n; + const a = St.SubVV(i, t, Ht.s_e13); + const l = St.DotVV(t, a); + const h = St.DotVV(i, a); + const c = -l; + const u = St.SubVV(i, e, Ht.s_e23); + const _ = St.DotVV(e, u); + const d = St.DotVV(i, u); + const p = -_; + const m = St.CrossVV(s, a); + const f = m * St.CrossVV(e, i); + const g = m * St.CrossVV(i, t); + const y = m * St.CrossVV(t, e); + if (o <= 0 && c <= 0) { + this.m_v1.a = 1; + this.m_count = 1; + return; + } + if (r > 0 && o > 0 && y <= 0) { + const t = 1 / (r + o); + this.m_v1.a = r * t; + this.m_v2.a = o * t; + this.m_count = 2; + return; + } + if (h > 0 && c > 0 && g <= 0) { + const t = 1 / (h + c); + this.m_v1.a = h * t; + this.m_v3.a = c * t; + this.m_count = 2; + this.m_v2.Copy(this.m_v3); + return; + } + if (r <= 0 && p <= 0) { + this.m_v2.a = 1; + this.m_count = 1; + this.m_v1.Copy(this.m_v2); + return; + } + if (h <= 0 && d <= 0) { + this.m_v3.a = 1; + this.m_count = 1; + this.m_v1.Copy(this.m_v3); + return; + } + if (d > 0 && p > 0 && f <= 0) { + const t = 1 / (d + p); + this.m_v2.a = d * t; + this.m_v3.a = p * t; + this.m_count = 2; + this.m_v1.Copy(this.m_v3); + return; + } + const b = 1 / (f + g + y); + this.m_v1.a = f * b; + this.m_v2.a = g * b; + this.m_v3.a = y * b; + this.m_count = 3; + } + } + Ht.s_e12 = new St; + Ht.s_e13 = new St; + Ht.s_e23 = new St; + const jt = new Ht; + const Xt = [ 0, 0, 0 ]; + const Wt = [ 0, 0, 0 ]; + const Yt = new St; + const qt = new St; + const Kt = new St; + const Jt = new St; + const Zt = new St; + function Qt(e, i, s) { + ++t.b2_gjkCalls; + const o = s.proxyA; + const a = s.proxyB; + const l = s.transformA; + const h = s.transformB; + const c = jt; + c.ReadCache(i, o, l, a, h); + const u = c.m_vertices; + const _ = 20; + const d = Xt; + const p = Wt; + let m = 0; + let f = 0; + for (;f < _; ) { + m = c.m_count; + for (let t = 0; t < m; ++t) { + d[t] = u[t].indexA; + p[t] = u[t].indexB; + } + switch (c.m_count) { + case 1: + break; + + case 2: + c.Solve2(); + break; + + case 3: + c.Solve3(); + } + if (3 === c.m_count) break; + const e = c.GetSearchDirection(qt); + if (e.LengthSquared() < r) break; + const i = u[c.m_count]; + i.indexA = o.GetSupport(Ct.MulTRV(l.q, St.NegV(e, St.s_t0), Jt)); + xt.MulXV(l, o.GetVertex(i.indexA), i.wA); + i.indexB = a.GetSupport(Ct.MulTRV(h.q, e, Zt)); + xt.MulXV(h, a.GetVertex(i.indexB), i.wB); + St.SubVV(i.wB, i.wA, i.w); + ++f; + ++t.b2_gjkIters; + let s = !1; + for (let t = 0; t < m; ++t) if (i.indexA === d[t] && i.indexB === p[t]) { + s = !0; + break; + } + if (s) break; + ++c.m_count; + } + t.b2_gjkMaxIters = et(t.b2_gjkMaxIters, f); + c.GetWitnessPoints(e.pointA, e.pointB); + e.distance = St.DistanceVV(e.pointA, e.pointB); + e.iterations = f; + c.WriteCache(i); + if (s.useRadii) { + const t = o.m_radius; + const i = a.m_radius; + if (e.distance > t + i && e.distance > n) { + e.distance -= t + i; + const s = St.SubVV(e.pointB, e.pointA, Kt); + s.Normalize(); + e.pointA.SelfMulAdd(t, s); + e.pointB.SelfMulSub(i, s); + } else { + const t = St.MidVV(e.pointA, e.pointB, Yt); + e.pointA.Copy(t); + e.pointB.Copy(t); + e.distance = 0; + } + } + } + const $t = new St; + const te = new Ht; + const ee = new St; + const ie = new St; + const se = new St; + const ne = new St; + const re = new St; + const oe = new St; + function ae(t, e) { + t.iterations = 0; + t.lambda = 1; + t.normal.SetZero(); + t.point.SetZero(); + const i = e.proxyA; + const s = e.proxyB; + const n = et(i.m_radius, d) + et(s.m_radius, d); + const r = e.transformA; + const o = e.transformB; + const a = e.translationB; + const l = $t.Set(0, 0); + let h = 0; + const c = te; + c.m_count = 0; + const _ = c.m_vertices; + let p = i.GetSupport(Ct.MulTRV(r.q, St.NegV(a, St.s_t1), St.s_t0)); + let m = xt.MulXV(r, i.GetVertex(p), ee); + let f = s.GetSupport(Ct.MulTRV(o.q, a, St.s_t0)); + let g = xt.MulXV(o, s.GetVertex(f), ie); + const y = St.SubVV(m, g, se); + const b = et(d, n - d); + const S = .5 * u; + const A = 20; + let T = 0; + for (;T < A && $(y.Length() - b) > S; ) { + t.iterations += 1; + p = i.GetSupport(Ct.MulTRV(r.q, St.NegV(y, St.s_t1), St.s_t0)); + m = xt.MulXV(r, i.GetVertex(p), ee); + f = s.GetSupport(Ct.MulTRV(o.q, y, St.s_t0)); + g = xt.MulXV(o, s.GetVertex(f), ie); + const e = St.SubVV(m, g, ne); + y.Normalize(); + const n = St.DotVV(y, e); + const u = St.DotVV(y, a); + if (n - b > h * u) { + if (u <= 0) return !1; + h = (n - b) / u; + if (h > 1) return !1; + l.Copy(y).SelfNeg(); + c.m_count = 0; + } + const d = _[c.m_count]; + d.indexA = f; + d.wA.Copy(g).SelfMulAdd(h, a); + d.indexB = p; + d.wB.Copy(m); + d.w.Copy(d.wB).SelfSub(d.wA); + d.a = 1; + c.m_count += 1; + switch (c.m_count) { + case 1: + break; + + case 2: + c.Solve2(); + break; + + case 3: + c.Solve3(); + } + if (3 === c.m_count) return !1; + c.GetClosestPoint(y); + ++T; + } + const v = re; + const E = oe; + c.GetWitnessPoints(v, E); + if (y.LengthSquared() > 0) { + l.Copy(y).SelfNeg(); + l.Normalize(); + } + t.normal.Copy(l); + t.lambda = h; + t.iterations = T; + return !0; + } + !function(t) { + t[t.e_vertex = 0] = "e_vertex"; + t[t.e_face = 1] = "e_face"; + }(t.b2ContactFeatureType || (t.b2ContactFeatureType = {})); + class le { + constructor() { + this._key = 0; + this._key_invalid = !1; + this._indexA = 0; + this._indexB = 0; + this._typeA = 0; + this._typeB = 0; + } + get key() { + if (this._key_invalid) { + this._key_invalid = !1; + this._key = this._indexA | this._indexB << 8 | this._typeA << 16 | this._typeB << 24; + } + return this._key; + } + set key(t) { + this._key = t; + this._key_invalid = !1; + this._indexA = 255 & this._key; + this._indexB = this._key >> 8 & 255; + this._typeA = this._key >> 16 & 255; + this._typeB = this._key >> 24 & 255; + } + get indexA() { + return this._indexA; + } + set indexA(t) { + this._indexA = t; + this._key_invalid = !0; + } + get indexB() { + return this._indexB; + } + set indexB(t) { + this._indexB = t; + this._key_invalid = !0; + } + get typeA() { + return this._typeA; + } + set typeA(t) { + this._typeA = t; + this._key_invalid = !0; + } + get typeB() { + return this._typeB; + } + set typeB(t) { + this._typeB = t; + this._key_invalid = !0; + } + } + class he { + constructor() { + this.cf = new le; + } + Copy(t) { + this.key = t.key; + return this; + } + Clone() { + return (new he).Copy(this); + } + get key() { + return this.cf.key; + } + set key(t) { + this.cf.key = t; + } + } + class ce { + constructor() { + this.localPoint = new St; + this.normalImpulse = 0; + this.tangentImpulse = 0; + this.id = new he; + } + static MakeArray(t) { + return Y(t, (t => new ce)); + } + Reset() { + this.localPoint.SetZero(); + this.normalImpulse = 0; + this.tangentImpulse = 0; + this.id.key = 0; + } + Copy(t) { + this.localPoint.Copy(t.localPoint); + this.normalImpulse = t.normalImpulse; + this.tangentImpulse = t.tangentImpulse; + this.id.Copy(t.id); + return this; + } + } + !function(t) { + t[t.e_unknown = -1] = "e_unknown"; + t[t.e_circles = 0] = "e_circles"; + t[t.e_faceA = 1] = "e_faceA"; + t[t.e_faceB = 2] = "e_faceB"; + }(t.b2ManifoldType || (t.b2ManifoldType = {})); + class ue { + constructor() { + this.points = ce.MakeArray(a); + this.localNormal = new St; + this.localPoint = new St; + this.type = t.b2ManifoldType.e_unknown; + this.pointCount = 0; + } + Reset() { + for (let t = 0; t < a; ++t) this.points[t].Reset(); + this.localNormal.SetZero(); + this.localPoint.SetZero(); + this.type = t.b2ManifoldType.e_unknown; + this.pointCount = 0; + } + Copy(t) { + this.pointCount = t.pointCount; + for (let e = 0; e < a; ++e) this.points[e].Copy(t.points[e]); + this.localNormal.Copy(t.localNormal); + this.localPoint.Copy(t.localPoint); + this.type = t.type; + return this; + } + Clone() { + return (new ue).Copy(this); + } + } + class _e { + constructor() { + this.normal = new St; + this.points = St.MakeArray(a); + this.separations = K(a); + } + Initialize(e, i, s, n, o) { + if (0 !== e.pointCount) switch (e.type) { + case t.b2ManifoldType.e_circles: + { + this.normal.Set(1, 0); + const t = xt.MulXV(i, e.localPoint, _e.Initialize_s_pointA); + const a = xt.MulXV(n, e.points[0].localPoint, _e.Initialize_s_pointB); + St.DistanceSquaredVV(t, a) > r && St.SubVV(a, t, this.normal).SelfNormalize(); + const l = St.AddVMulSV(t, s, this.normal, _e.Initialize_s_cA); + const h = St.SubVMulSV(a, o, this.normal, _e.Initialize_s_cB); + St.MidVV(l, h, this.points[0]); + this.separations[0] = St.DotVV(St.SubVV(h, l, St.s_t0), this.normal); + break; + } + + case t.b2ManifoldType.e_faceA: + { + Ct.MulRV(i.q, e.localNormal, this.normal); + const t = xt.MulXV(i, e.localPoint, _e.Initialize_s_planePoint); + for (let i = 0; i < e.pointCount; ++i) { + const r = xt.MulXV(n, e.points[i].localPoint, _e.Initialize_s_clipPoint); + const a = s - St.DotVV(St.SubVV(r, t, St.s_t0), this.normal); + const l = St.AddVMulSV(r, a, this.normal, _e.Initialize_s_cA); + const h = St.SubVMulSV(r, o, this.normal, _e.Initialize_s_cB); + St.MidVV(l, h, this.points[i]); + this.separations[i] = St.DotVV(St.SubVV(h, l, St.s_t0), this.normal); + } + break; + } + + case t.b2ManifoldType.e_faceB: + { + Ct.MulRV(n.q, e.localNormal, this.normal); + const t = xt.MulXV(n, e.localPoint, _e.Initialize_s_planePoint); + for (let n = 0; n < e.pointCount; ++n) { + const r = xt.MulXV(i, e.points[n].localPoint, _e.Initialize_s_clipPoint); + const a = o - St.DotVV(St.SubVV(r, t, St.s_t0), this.normal); + const l = St.AddVMulSV(r, a, this.normal, _e.Initialize_s_cB); + const h = St.SubVMulSV(r, s, this.normal, _e.Initialize_s_cA); + St.MidVV(h, l, this.points[n]); + this.separations[n] = St.DotVV(St.SubVV(h, l, St.s_t0), this.normal); + } + this.normal.SelfNeg(); + break; + } + } + } + } + _e.Initialize_s_pointA = new St; + _e.Initialize_s_pointB = new St; + _e.Initialize_s_cA = new St; + _e.Initialize_s_cB = new St; + _e.Initialize_s_planePoint = new St; + _e.Initialize_s_clipPoint = new St; + !function(t) { + t[t.b2_nullState = 0] = "b2_nullState"; + t[t.b2_addState = 1] = "b2_addState"; + t[t.b2_persistState = 2] = "b2_persistState"; + t[t.b2_removeState = 3] = "b2_removeState"; + }(t.b2PointState || (t.b2PointState = {})); + function de(e, i, s, n) { + let r; + for (r = 0; r < s.pointCount; ++r) { + const i = s.points[r].id.key; + e[r] = t.b2PointState.b2_removeState; + for (let s = 0, o = n.pointCount; s < o; ++s) if (n.points[s].id.key === i) { + e[r] = t.b2PointState.b2_persistState; + break; + } + } + for (;r < a; ++r) e[r] = t.b2PointState.b2_nullState; + for (r = 0; r < n.pointCount; ++r) { + const e = n.points[r].id.key; + i[r] = t.b2PointState.b2_addState; + for (let n = 0, o = s.pointCount; n < o; ++n) if (s.points[n].id.key === e) { + i[r] = t.b2PointState.b2_persistState; + break; + } + } + for (;r < a; ++r) i[r] = t.b2PointState.b2_nullState; + } + class pe { + constructor() { + this.v = new St; + this.id = new he; + } + static MakeArray(t) { + return Y(t, (t => new pe)); + } + Copy(t) { + this.v.Copy(t.v); + this.id.Copy(t.id); + return this; + } + } + class me { + constructor() { + this.p1 = new St; + this.p2 = new St; + this.maxFraction = 1; + } + Copy(t) { + this.p1.Copy(t.p1); + this.p2.Copy(t.p2); + this.maxFraction = t.maxFraction; + return this; + } + } + class fe { + constructor() { + this.normal = new St; + this.fraction = 0; + } + Copy(t) { + this.normal.Copy(t.normal); + this.fraction = t.fraction; + return this; + } + } + class ge { + constructor() { + this.lowerBound = new St; + this.upperBound = new St; + this.m_cache_center = new St; + this.m_cache_extent = new St; + } + Copy(t) { + this.lowerBound.Copy(t.lowerBound); + this.upperBound.Copy(t.upperBound); + return this; + } + IsValid() { + return !(!this.lowerBound.IsValid() || !this.upperBound.IsValid() || this.upperBound.x < this.lowerBound.x || this.upperBound.y < this.lowerBound.y); + } + GetCenter() { + return St.MidVV(this.lowerBound, this.upperBound, this.m_cache_center); + } + GetExtents() { + return St.ExtVV(this.lowerBound, this.upperBound, this.m_cache_extent); + } + GetPerimeter() { + return 2 * (this.upperBound.x - this.lowerBound.x + (this.upperBound.y - this.lowerBound.y)); + } + Combine1(t) { + this.lowerBound.x = tt(this.lowerBound.x, t.lowerBound.x); + this.lowerBound.y = tt(this.lowerBound.y, t.lowerBound.y); + this.upperBound.x = et(this.upperBound.x, t.upperBound.x); + this.upperBound.y = et(this.upperBound.y, t.upperBound.y); + return this; + } + Combine2(t, e) { + this.lowerBound.x = tt(t.lowerBound.x, e.lowerBound.x); + this.lowerBound.y = tt(t.lowerBound.y, e.lowerBound.y); + this.upperBound.x = et(t.upperBound.x, e.upperBound.x); + this.upperBound.y = et(t.upperBound.y, e.upperBound.y); + return this; + } + static Combine(t, e, i) { + i.Combine2(t, e); + return i; + } + Contains(t) { + return !(this.lowerBound.x <= t.lowerBound.x || this.lowerBound.y <= t.lowerBound.y || t.upperBound.x <= this.upperBound.x || t.upperBound.y <= this.upperBound.y); + } + RayCast(t, e) { + let i = -s; + let r = s; + const o = e.p1.x; + const a = e.p1.y; + const l = e.p2.x - e.p1.x; + const h = e.p2.y - e.p1.y; + const c = $(l); + const u = $(h); + const _ = t.normal; + if (c < n) { + if (o < this.lowerBound.x || this.upperBound.x < o) return !1; + } else { + const t = 1 / l; + let e = (this.lowerBound.x - o) * t; + let s = (this.upperBound.x - o) * t; + let n = -1; + if (e > s) { + const t = e; + e = s; + s = t; + n = 1; + } + if (e > i) { + _.x = n; + _.y = 0; + i = e; + } + r = tt(r, s); + if (i > r) return !1; + } + if (u < n) { + if (a < this.lowerBound.y || this.upperBound.y < a) return !1; + } else { + const t = 1 / h; + let e = (this.lowerBound.y - a) * t; + let s = (this.upperBound.y - a) * t; + let n = -1; + if (e > s) { + const t = e; + e = s; + s = t; + n = 1; + } + if (e > i) { + _.x = 0; + _.y = n; + i = e; + } + r = tt(r, s); + if (i > r) return !1; + } + if (i < 0 || e.maxFraction < i) return !1; + t.fraction = i; + return !0; + } + TestContain(t) { + return !(t.x < this.lowerBound.x || this.upperBound.x < t.x || t.y < this.lowerBound.y || this.upperBound.y < t.y); + } + TestOverlap(t) { + return !(this.upperBound.x < t.lowerBound.x || this.upperBound.y < t.lowerBound.y || t.upperBound.x < this.lowerBound.x || t.upperBound.y < this.lowerBound.y); + } + } + function ye(t, e) { + return !(t.upperBound.x < e.lowerBound.x || t.upperBound.y < e.lowerBound.y || e.upperBound.x < t.lowerBound.x || e.upperBound.y < t.lowerBound.y); + } + function be(e, i, s, n, r) { + let o = 0; + const a = i[0]; + const l = i[1]; + const h = St.DotVV(s, a.v) - n; + const c = St.DotVV(s, l.v) - n; + h <= 0 && e[o++].Copy(a); + c <= 0 && e[o++].Copy(l); + if (h * c < 0) { + const i = h / (h - c); + const s = e[o].v; + s.x = a.v.x + i * (l.v.x - a.v.x); + s.y = a.v.y + i * (l.v.y - a.v.y); + const n = e[o].id; + n.cf.indexA = r; + n.cf.indexB = a.id.cf.indexB; + n.cf.typeA = t.b2ContactFeatureType.e_vertex; + n.cf.typeB = t.b2ContactFeatureType.e_face; + ++o; + } + return o; + } + const Se = new Ft; + const Ae = new Lt; + const Te = new Vt; + function ve(t, e, i, s, r, o) { + const a = Se.Reset(); + a.proxyA.SetShape(t, e); + a.proxyB.SetShape(i, s); + a.transformA.Copy(r); + a.transformB.Copy(o); + a.useRadii = !0; + const l = Ae.Reset(); + l.count = 0; + const h = Te.Reset(); + Qt(h, l, a); + return h.distance < 10 * n; + } + function Ee(t) { + if (null === t) throw new Error; + return t; + } + class Ce { + constructor(t = 0) { + this.m_id = 0; + this.aabb = new ge; + this._userData = null; + this.parent = null; + this.child1 = null; + this.child2 = null; + this.height = 0; + this.m_id = t; + } + get userData() { + if (null === this._userData) throw new Error; + return this._userData; + } + set userData(t) { + if (null !== this._userData) throw new Error; + this._userData = t; + } + Reset() { + this._userData = null; + } + IsLeaf() { + return null === this.child1; + } + } + class xe { + constructor() { + this.m_root = null; + this.m_freeList = null; + this.m_path = 0; + this.m_insertionCount = 0; + this.m_stack = new Dt(256); + } + Query(t, e) { + const i = this.m_stack.Reset(); + i.Push(this.m_root); + for (;i.GetCount() > 0; ) { + const s = i.Pop(); + if (null !== s && s.aabb.TestOverlap(t)) if (s.IsLeaf()) { + if (!e(s)) return; + } else { + i.Push(s.child1); + i.Push(s.child2); + } + } + } + QueryPoint(t, e) { + const i = this.m_stack.Reset(); + i.Push(this.m_root); + for (;i.GetCount() > 0; ) { + const s = i.Pop(); + if (null !== s && s.aabb.TestContain(t)) if (s.IsLeaf()) { + if (!e(s)) return; + } else { + i.Push(s.child1); + i.Push(s.child2); + } + } + } + RayCast(t, e) { + const i = t.p1; + const s = t.p2; + const n = St.SubVV(s, i, xe.s_r); + n.Normalize(); + const r = St.CrossOneV(n, xe.s_v); + const o = St.AbsV(r, xe.s_abs_v); + let a = t.maxFraction; + const l = xe.s_segmentAABB; + let h = i.x + a * (s.x - i.x); + let c = i.y + a * (s.y - i.y); + l.lowerBound.x = tt(i.x, h); + l.lowerBound.y = tt(i.y, c); + l.upperBound.x = et(i.x, h); + l.upperBound.y = et(i.y, c); + const u = this.m_stack.Reset(); + u.Push(this.m_root); + for (;u.GetCount() > 0; ) { + const n = u.Pop(); + if (null === n) continue; + if (!ye(n.aabb, l)) continue; + const _ = n.aabb.GetCenter(); + const d = n.aabb.GetExtents(); + if (!($(St.DotVV(r, St.SubVV(i, _, St.s_t0))) - St.DotVV(o, d) > 0)) if (n.IsLeaf()) { + const r = xe.s_subInput; + r.p1.Copy(t.p1); + r.p2.Copy(t.p2); + r.maxFraction = a; + const o = e(r, n); + if (0 === o) return; + if (o > 0) { + a = o; + h = i.x + a * (s.x - i.x); + c = i.y + a * (s.y - i.y); + l.lowerBound.x = tt(i.x, h); + l.lowerBound.y = tt(i.y, c); + l.upperBound.x = et(i.x, h); + l.upperBound.y = et(i.y, c); + } + } else { + u.Push(n.child1); + u.Push(n.child2); + } + } + } + AllocateNode() { + if (null !== this.m_freeList) { + const t = this.m_freeList; + this.m_freeList = t.parent; + t.parent = null; + t.child1 = null; + t.child2 = null; + t.height = 0; + return t; + } + return new Ce(xe.s_node_id++); + } + FreeNode(t) { + t.parent = this.m_freeList; + t.child1 = null; + t.child2 = null; + t.height = -1; + t.Reset(); + this.m_freeList = t; + } + CreateProxy(t, e) { + const i = this.AllocateNode(); + const s = h; + const n = h; + i.aabb.lowerBound.x = t.lowerBound.x - s; + i.aabb.lowerBound.y = t.lowerBound.y - n; + i.aabb.upperBound.x = t.upperBound.x + s; + i.aabb.upperBound.y = t.upperBound.y + n; + i.userData = e; + i.height = 0; + this.InsertLeaf(i); + return i; + } + DestroyProxy(t) { + this.RemoveLeaf(t); + this.FreeNode(t); + } + MoveProxy(t, e, i) { + if (t.aabb.Contains(e)) return !1; + this.RemoveLeaf(t); + const s = h; + const n = h; + t.aabb.lowerBound.x = e.lowerBound.x - s; + t.aabb.lowerBound.y = e.lowerBound.y - n; + t.aabb.upperBound.x = e.upperBound.x + s; + t.aabb.upperBound.y = e.upperBound.y + n; + const r = c * i.x; + const o = c * i.y; + r < 0 ? t.aabb.lowerBound.x += r : t.aabb.upperBound.x += r; + o < 0 ? t.aabb.lowerBound.y += o : t.aabb.upperBound.y += o; + this.InsertLeaf(t); + return !0; + } + InsertLeaf(t) { + ++this.m_insertionCount; + if (null === this.m_root) { + this.m_root = t; + this.m_root.parent = null; + return; + } + const e = t.aabb; + let i = this.m_root; + for (;!i.IsLeaf(); ) { + const t = Ee(i.child1); + const s = Ee(i.child2); + const n = i.aabb.GetPerimeter(); + const r = xe.s_combinedAABB; + r.Combine2(i.aabb, e); + const o = r.GetPerimeter(); + const a = 2 * o; + const l = 2 * (o - n); + let h; + const c = xe.s_aabb; + let u; + let _; + if (t.IsLeaf()) { + c.Combine2(e, t.aabb); + h = c.GetPerimeter() + l; + } else { + c.Combine2(e, t.aabb); + u = t.aabb.GetPerimeter(); + _ = c.GetPerimeter(); + h = _ - u + l; + } + let d; + if (s.IsLeaf()) { + c.Combine2(e, s.aabb); + d = c.GetPerimeter() + l; + } else { + c.Combine2(e, s.aabb); + u = s.aabb.GetPerimeter(); + _ = c.GetPerimeter(); + d = _ - u + l; + } + if (a < h && a < d) break; + i = h < d ? t : s; + } + const s = i.parent; + const n = this.AllocateNode(); + n.parent = s; + n.aabb.Combine2(e, i.aabb); + n.height = i.height + 1; + if (null !== s) { + s.child1 === i ? s.child1 = n : s.child2 = n; + n.child1 = i; + n.child2 = t; + i.parent = n; + t.parent = n; + } else { + n.child1 = i; + n.child2 = t; + i.parent = n; + t.parent = n; + this.m_root = n; + } + let r = t.parent; + for (;null !== r; ) { + r = this.Balance(r); + const t = Ee(r.child1); + const e = Ee(r.child2); + r.height = 1 + et(t.height, e.height); + r.aabb.Combine2(t.aabb, e.aabb); + r = r.parent; + } + } + RemoveLeaf(t) { + if (t === this.m_root) { + this.m_root = null; + return; + } + const e = Ee(t.parent); + const i = e && e.parent; + const s = Ee(e.child1 === t ? e.child2 : e.child1); + if (null !== i) { + i.child1 === e ? i.child1 = s : i.child2 = s; + s.parent = i; + this.FreeNode(e); + let t = i; + for (;null !== t; ) { + t = this.Balance(t); + const e = Ee(t.child1); + const i = Ee(t.child2); + t.aabb.Combine2(e.aabb, i.aabb); + t.height = 1 + et(e.height, i.height); + t = t.parent; + } + } else { + this.m_root = s; + s.parent = null; + this.FreeNode(e); + } + } + Balance(t) { + if (t.IsLeaf() || t.height < 2) return t; + const e = Ee(t.child1); + const i = Ee(t.child2); + const s = i.height - e.height; + if (s > 1) { + const s = Ee(i.child1); + const n = Ee(i.child2); + i.child1 = t; + i.parent = t.parent; + t.parent = i; + null !== i.parent ? i.parent.child1 === t ? i.parent.child1 = i : i.parent.child2 = i : this.m_root = i; + if (s.height > n.height) { + i.child2 = s; + t.child2 = n; + n.parent = t; + t.aabb.Combine2(e.aabb, n.aabb); + i.aabb.Combine2(t.aabb, s.aabb); + t.height = 1 + et(e.height, n.height); + i.height = 1 + et(t.height, s.height); + } else { + i.child2 = n; + t.child2 = s; + s.parent = t; + t.aabb.Combine2(e.aabb, s.aabb); + i.aabb.Combine2(t.aabb, n.aabb); + t.height = 1 + et(e.height, s.height); + i.height = 1 + et(t.height, n.height); + } + return i; + } + if (s < -1) { + const s = Ee(e.child1); + const n = Ee(e.child2); + e.child1 = t; + e.parent = t.parent; + t.parent = e; + null !== e.parent ? e.parent.child1 === t ? e.parent.child1 = e : e.parent.child2 = e : this.m_root = e; + if (s.height > n.height) { + e.child2 = s; + t.child1 = n; + n.parent = t; + t.aabb.Combine2(i.aabb, n.aabb); + e.aabb.Combine2(t.aabb, s.aabb); + t.height = 1 + et(i.height, n.height); + e.height = 1 + et(t.height, s.height); + } else { + e.child2 = n; + t.child1 = s; + s.parent = t; + t.aabb.Combine2(i.aabb, s.aabb); + e.aabb.Combine2(t.aabb, n.aabb); + t.height = 1 + et(i.height, s.height); + e.height = 1 + et(t.height, n.height); + } + return e; + } + return t; + } + GetHeight() { + return null === this.m_root ? 0 : this.m_root.height; + } + static GetAreaNode(t) { + if (null === t) return 0; + if (t.IsLeaf()) return 0; + let e = t.aabb.GetPerimeter(); + e += xe.GetAreaNode(t.child1); + e += xe.GetAreaNode(t.child2); + return e; + } + GetAreaRatio() { + if (null === this.m_root) return 0; + const t = this.m_root.aabb.GetPerimeter(); + return xe.GetAreaNode(this.m_root) / t; + } + static ComputeHeightNode(t) { + return null === t || t.IsLeaf() ? 0 : 1 + et(xe.ComputeHeightNode(t.child1), xe.ComputeHeightNode(t.child2)); + } + ComputeHeight() { + return xe.ComputeHeightNode(this.m_root); + } + ValidateStructure(t) { + if (null === t) return; + this.m_root; + if (t.IsLeaf()) return; + const e = Ee(t.child1); + const i = Ee(t.child2); + this.ValidateStructure(e); + this.ValidateStructure(i); + } + ValidateMetrics(t) { + if (null === t) return; + if (t.IsLeaf()) return; + const e = Ee(t.child1); + const i = Ee(t.child2); + xe.s_aabb.Combine2(e.aabb, i.aabb); + this.ValidateMetrics(e); + this.ValidateMetrics(i); + } + Validate() {} + static GetMaxBalanceNode(t, e) { + if (null === t) return e; + if (t.height <= 1) return e; + const i = Ee(t.child1); + const s = Ee(t.child2); + return et(e, $(s.height - i.height)); + } + GetMaxBalance() { + return xe.GetMaxBalanceNode(this.m_root, 0); + } + RebuildBottomUp() { + this.Validate(); + } + static ShiftOriginNode(t, e) { + if (null === t) return; + if (t.height <= 1) return; + const i = t.child1; + const s = t.child2; + xe.ShiftOriginNode(i, e); + xe.ShiftOriginNode(s, e); + t.aabb.lowerBound.SelfSub(e); + t.aabb.upperBound.SelfSub(e); + } + ShiftOrigin(t) { + xe.ShiftOriginNode(this.m_root, t); + } + } + xe.s_r = new St; + xe.s_v = new St; + xe.s_abs_v = new St; + xe.s_segmentAABB = new ge; + xe.s_subInput = new me; + xe.s_combinedAABB = new ge; + xe.s_aabb = new ge; + xe.s_node_id = 0; + function we(t, e, i) { + const s = t[e]; + t[e] = t[i]; + t[i] = s; + } + function Re(t, e) { + return t < e; + } + function Ie(t, e = 0, i = t.length - e, s = Re) { + let n = e; + const r = []; + let o = 0; + for (;;) { + for (;n + 1 < i; i++) { + const e = t[n + Math.floor(Math.random() * (i - n))]; + r[o++] = i; + for (let r = n - 1; ;) { + for (;s(t[++r], e); ) ; + for (;s(e, t[--i]); ) ; + if (r >= i) break; + we(t, r, i); + } + } + if (0 === o) break; + n = i; + i = r[--o]; + } + return t; + } + class Me { + constructor(t, e) { + this.proxyA = t; + this.proxyB = e; + } + } + class Be { + constructor() { + this.m_tree = new xe; + this.m_proxyCount = 0; + this.m_moveCount = 0; + this.m_moveBuffer = []; + this.m_pairCount = 0; + this.m_pairBuffer = []; + } + CreateProxy(t, e) { + const i = this.m_tree.CreateProxy(t, e); + ++this.m_proxyCount; + this.BufferMove(i); + return i; + } + DestroyProxy(t) { + this.UnBufferMove(t); + --this.m_proxyCount; + this.m_tree.DestroyProxy(t); + } + MoveProxy(t, e, i) { + this.m_tree.MoveProxy(t, e, i) && this.BufferMove(t); + } + TouchProxy(t) { + this.BufferMove(t); + } + GetProxyCount() { + return this.m_proxyCount; + } + UpdatePairs(t) { + this.m_pairCount = 0; + for (let t = 0; t < this.m_moveCount; ++t) { + const e = this.m_moveBuffer[t]; + if (null === e) continue; + const i = e.aabb; + this.m_tree.Query(i, (t => { + if (t.m_id === e.m_id) return !0; + let i; + let s; + if (t.m_id < e.m_id) { + i = t; + s = e; + } else { + i = e; + s = t; + } + if (this.m_pairCount === this.m_pairBuffer.length) this.m_pairBuffer[this.m_pairCount] = new Me(i, s); else { + const t = this.m_pairBuffer[this.m_pairCount]; + t.proxyA = i; + t.proxyB = s; + } + ++this.m_pairCount; + return !0; + })); + } + this.m_moveCount = 0; + Ie(this.m_pairBuffer, 0, this.m_pairCount, De); + let e = 0; + for (;e < this.m_pairCount; ) { + const i = this.m_pairBuffer[e]; + t(i.proxyA.userData, i.proxyB.userData); + ++e; + for (;e < this.m_pairCount; ) { + const t = this.m_pairBuffer[e]; + if (t.proxyA.m_id !== i.proxyA.m_id || t.proxyB.m_id !== i.proxyB.m_id) break; + ++e; + } + } + } + Query(t, e) { + this.m_tree.Query(t, e); + } + QueryPoint(t, e) { + this.m_tree.QueryPoint(t, e); + } + RayCast(t, e) { + this.m_tree.RayCast(t, e); + } + GetTreeHeight() { + return this.m_tree.GetHeight(); + } + GetTreeBalance() { + return this.m_tree.GetMaxBalance(); + } + GetTreeQuality() { + return this.m_tree.GetAreaRatio(); + } + ShiftOrigin(t) { + this.m_tree.ShiftOrigin(t); + } + BufferMove(t) { + this.m_moveBuffer[this.m_moveCount] = t; + ++this.m_moveCount; + } + UnBufferMove(t) { + const e = this.m_moveBuffer.indexOf(t); + this.m_moveBuffer[e] = null; + } + } + function De(t, e) { + return t.proxyA.m_id < e.proxyA.m_id || t.proxyA.m_id === e.proxyA.m_id && t.proxyB.m_id < e.proxyB.m_id; + } + t.b2_toiTime = 0; + t.b2_toiMaxTime = 0; + t.b2_toiCalls = 0; + t.b2_toiIters = 0; + t.b2_toiMaxIters = 0; + t.b2_toiRootIters = 0; + t.b2_toiMaxRootIters = 0; + function Pe() { + t.b2_toiTime = 0; + t.b2_toiMaxTime = 0; + t.b2_toiCalls = 0; + t.b2_toiIters = 0; + t.b2_toiMaxIters = 0; + t.b2_toiRootIters = 0; + t.b2_toiMaxRootIters = 0; + } + const Oe = new xt; + const Ne = new xt; + const Le = new St; + const Fe = new St; + const Ve = new St; + const ke = new St; + const Ue = new St; + class Ge { + constructor() { + this.proxyA = new Nt; + this.proxyB = new Nt; + this.sweepA = new wt; + this.sweepB = new wt; + this.tMax = 0; + } + } + !function(t) { + t[t.e_unknown = 0] = "e_unknown"; + t[t.e_failed = 1] = "e_failed"; + t[t.e_overlapped = 2] = "e_overlapped"; + t[t.e_touching = 3] = "e_touching"; + t[t.e_separated = 4] = "e_separated"; + }(t.b2TOIOutputState || (t.b2TOIOutputState = {})); + class ze { + constructor() { + this.state = t.b2TOIOutputState.e_unknown; + this.t = 0; + } + } + !function(t) { + t[t.e_unknown = -1] = "e_unknown"; + t[t.e_points = 0] = "e_points"; + t[t.e_faceA = 1] = "e_faceA"; + t[t.e_faceB = 2] = "e_faceB"; + }(t.b2SeparationFunctionType || (t.b2SeparationFunctionType = {})); + class He { + constructor() { + this.m_sweepA = new wt; + this.m_sweepB = new wt; + this.m_type = t.b2SeparationFunctionType.e_unknown; + this.m_localPoint = new St; + this.m_axis = new St; + } + Initialize(e, i, s, n, r, o) { + this.m_proxyA = i; + this.m_proxyB = n; + const a = e.count; + this.m_sweepA.Copy(s); + this.m_sweepB.Copy(r); + const l = Oe; + const h = Ne; + this.m_sweepA.GetTransform(l, o); + this.m_sweepB.GetTransform(h, o); + if (1 === a) { + this.m_type = t.b2SeparationFunctionType.e_points; + const i = this.m_proxyA.GetVertex(e.indexA[0]); + const s = this.m_proxyB.GetVertex(e.indexB[0]); + const n = xt.MulXV(l, i, Le); + const r = xt.MulXV(h, s, Fe); + St.SubVV(r, n, this.m_axis); + const o = this.m_axis.Normalize(); + this.m_localPoint.SetZero(); + return o; + } + if (e.indexA[0] === e.indexA[1]) { + this.m_type = t.b2SeparationFunctionType.e_faceB; + const i = this.m_proxyB.GetVertex(e.indexB[0]); + const s = this.m_proxyB.GetVertex(e.indexB[1]); + St.CrossVOne(St.SubVV(s, i, St.s_t0), this.m_axis).SelfNormalize(); + const n = Ct.MulRV(h.q, this.m_axis, Ve); + St.MidVV(i, s, this.m_localPoint); + const r = xt.MulXV(h, this.m_localPoint, Fe); + const o = this.m_proxyA.GetVertex(e.indexA[0]); + const a = xt.MulXV(l, o, Le); + let c = St.DotVV(St.SubVV(a, r, St.s_t0), n); + if (c < 0) { + this.m_axis.SelfNeg(); + c = -c; + } + return c; + } + { + this.m_type = t.b2SeparationFunctionType.e_faceA; + const i = this.m_proxyA.GetVertex(e.indexA[0]); + const s = this.m_proxyA.GetVertex(e.indexA[1]); + St.CrossVOne(St.SubVV(s, i, St.s_t0), this.m_axis).SelfNormalize(); + const n = Ct.MulRV(l.q, this.m_axis, Ve); + St.MidVV(i, s, this.m_localPoint); + const r = xt.MulXV(l, this.m_localPoint, Le); + const o = this.m_proxyB.GetVertex(e.indexB[0]); + const a = xt.MulXV(h, o, Fe); + let c = St.DotVV(St.SubVV(a, r, St.s_t0), n); + if (c < 0) { + this.m_axis.SelfNeg(); + c = -c; + } + return c; + } + } + FindMinSeparation(e, i, s) { + const n = Oe; + const r = Ne; + this.m_sweepA.GetTransform(n, s); + this.m_sweepB.GetTransform(r, s); + switch (this.m_type) { + case t.b2SeparationFunctionType.e_points: + { + const t = Ct.MulTRV(n.q, this.m_axis, ke); + const s = Ct.MulTRV(r.q, St.NegV(this.m_axis, St.s_t0), Ue); + e[0] = this.m_proxyA.GetSupport(t); + i[0] = this.m_proxyB.GetSupport(s); + const o = this.m_proxyA.GetVertex(e[0]); + const a = this.m_proxyB.GetVertex(i[0]); + const l = xt.MulXV(n, o, Le); + const h = xt.MulXV(r, a, Fe); + return St.DotVV(St.SubVV(h, l, St.s_t0), this.m_axis); + } + + case t.b2SeparationFunctionType.e_faceA: + { + const t = Ct.MulRV(n.q, this.m_axis, Ve); + const s = xt.MulXV(n, this.m_localPoint, Le); + const o = Ct.MulTRV(r.q, St.NegV(t, St.s_t0), Ue); + e[0] = -1; + i[0] = this.m_proxyB.GetSupport(o); + const a = this.m_proxyB.GetVertex(i[0]); + const l = xt.MulXV(r, a, Fe); + return St.DotVV(St.SubVV(l, s, St.s_t0), t); + } + + case t.b2SeparationFunctionType.e_faceB: + { + const t = Ct.MulRV(r.q, this.m_axis, Ve); + const s = xt.MulXV(r, this.m_localPoint, Fe); + const o = Ct.MulTRV(n.q, St.NegV(t, St.s_t0), ke); + i[0] = -1; + e[0] = this.m_proxyA.GetSupport(o); + const a = this.m_proxyA.GetVertex(e[0]); + const l = xt.MulXV(n, a, Le); + return St.DotVV(St.SubVV(l, s, St.s_t0), t); + } + + default: + e[0] = -1; + i[0] = -1; + return 0; + } + } + Evaluate(e, i, s) { + const n = Oe; + const r = Ne; + this.m_sweepA.GetTransform(n, s); + this.m_sweepB.GetTransform(r, s); + switch (this.m_type) { + case t.b2SeparationFunctionType.e_points: + { + const t = this.m_proxyA.GetVertex(e); + const s = this.m_proxyB.GetVertex(i); + const o = xt.MulXV(n, t, Le); + const a = xt.MulXV(r, s, Fe); + return St.DotVV(St.SubVV(a, o, St.s_t0), this.m_axis); + } + + case t.b2SeparationFunctionType.e_faceA: + { + const t = Ct.MulRV(n.q, this.m_axis, Ve); + const e = xt.MulXV(n, this.m_localPoint, Le); + const s = this.m_proxyB.GetVertex(i); + const o = xt.MulXV(r, s, Fe); + return St.DotVV(St.SubVV(o, e, St.s_t0), t); + } + + case t.b2SeparationFunctionType.e_faceB: + { + const t = Ct.MulRV(r.q, this.m_axis, Ve); + const i = xt.MulXV(r, this.m_localPoint, Fe); + const s = this.m_proxyA.GetVertex(e); + const o = xt.MulXV(n, s, Le); + return St.DotVV(St.SubVV(o, i, St.s_t0), t); + } + + default: + return 0; + } + } + } + const je = new Mt; + const Xe = new Lt; + const We = new Ft; + const Ye = new Vt; + const qe = new He; + const Ke = [ 0 ]; + const Je = [ 0 ]; + const Ze = new wt; + const Qe = new wt; + function $e(e, i) { + const s = je.Reset(); + ++t.b2_toiCalls; + e.state = t.b2TOIOutputState.e_unknown; + e.t = i.tMax; + const n = i.proxyA; + const r = i.proxyB; + const o = et(l, et(n.m_count, r.m_count)); + const a = Ze.Copy(i.sweepA); + const h = Qe.Copy(i.sweepB); + a.Normalize(); + h.Normalize(); + const c = i.tMax; + const _ = n.m_radius + r.m_radius; + const d = et(u, _ - 3 * u); + const p = .25 * u; + let m = 0; + const f = 20; + let g = 0; + const y = Xe; + y.count = 0; + const b = We; + b.proxyA.Copy(i.proxyA); + b.proxyB.Copy(i.proxyB); + b.useRadii = !1; + for (;;) { + const i = Oe; + const s = Ne; + a.GetTransform(i, m); + h.GetTransform(s, m); + b.transformA.Copy(i); + b.transformB.Copy(s); + const l = Ye; + Qt(l, y, b); + if (l.distance <= 0) { + e.state = t.b2TOIOutputState.e_overlapped; + e.t = 0; + break; + } + if (l.distance < d + p) { + e.state = t.b2TOIOutputState.e_touching; + e.t = m; + break; + } + const u = qe; + u.Initialize(y, n, a, r, h, m); + let _ = !1; + let S = c; + let A = 0; + for (;;) { + const i = Ke; + const s = Je; + let n = u.FindMinSeparation(i, s, S); + if (n > d + p) { + e.state = t.b2TOIOutputState.e_separated; + e.t = c; + _ = !0; + break; + } + if (n > d - p) { + m = S; + break; + } + let r = u.Evaluate(i[0], s[0], m); + if (r < d - p) { + e.state = t.b2TOIOutputState.e_failed; + e.t = m; + _ = !0; + break; + } + if (r <= d + p) { + e.state = t.b2TOIOutputState.e_touching; + e.t = m; + _ = !0; + break; + } + let a = 0; + let l = m; + let h = S; + for (;;) { + let e = 0; + e = 1 & a ? l + (d - r) * (h - l) / (n - r) : .5 * (l + h); + ++a; + ++t.b2_toiRootIters; + const o = u.Evaluate(i[0], s[0], e); + if ($(o - d) < p) { + S = e; + break; + } + if (o > d) { + l = e; + r = o; + } else { + h = e; + n = o; + } + if (50 === a) break; + } + t.b2_toiMaxRootIters = et(t.b2_toiMaxRootIters, a); + ++A; + if (A === o) break; + } + ++g; + ++t.b2_toiIters; + if (_) break; + if (g === f) { + e.state = t.b2TOIOutputState.e_failed; + e.t = m; + break; + } + } + t.b2_toiMaxIters = et(t.b2_toiMaxIters, g); + const S = s.GetMilliseconds(); + t.b2_toiMaxTime = et(t.b2_toiMaxTime, S); + t.b2_toiTime += S; + } + const ti = new St; + const ei = new St; + function ii(e, i, s, n, r) { + e.pointCount = 0; + const o = xt.MulXV(s, i.m_p, ti); + const a = xt.MulXV(r, n.m_p, ei); + const l = St.DistanceSquaredVV(o, a); + const h = i.m_radius + n.m_radius; + if (!(l > h * h)) { + e.type = t.b2ManifoldType.e_circles; + e.localPoint.Copy(i.m_p); + e.localNormal.SetZero(); + e.pointCount = 1; + e.points[0].localPoint.Copy(n.m_p); + e.points[0].id.key = 0; + } + } + const si = new St; + const ni = new St; + const ri = new St; + function oi(e, i, r, o, a) { + e.pointCount = 0; + const l = xt.MulXV(a, o.m_p, si); + const h = xt.MulTXV(r, l, ni); + let c = 0; + let u = -s; + const _ = i.m_radius + o.m_radius; + const d = i.m_count; + const p = i.m_vertices; + const m = i.m_normals; + for (let t = 0; t < d; ++t) { + const e = St.DotVV(m[t], St.SubVV(h, p[t], St.s_t0)); + if (e > _) return; + if (e > u) { + u = e; + c = t; + } + } + const f = c; + const g = (f + 1) % d; + const y = p[f]; + const b = p[g]; + if (u < n) { + e.pointCount = 1; + e.type = t.b2ManifoldType.e_faceA; + e.localNormal.Copy(m[c]); + St.MidVV(y, b, e.localPoint); + e.points[0].localPoint.Copy(o.m_p); + e.points[0].id.key = 0; + return; + } + const S = St.DotVV(St.SubVV(h, y, St.s_t0), St.SubVV(b, y, St.s_t1)); + const A = St.DotVV(St.SubVV(h, b, St.s_t0), St.SubVV(y, b, St.s_t1)); + if (S <= 0) { + if (St.DistanceSquaredVV(h, y) > _ * _) return; + e.pointCount = 1; + e.type = t.b2ManifoldType.e_faceA; + St.SubVV(h, y, e.localNormal).SelfNormalize(); + e.localPoint.Copy(y); + e.points[0].localPoint.Copy(o.m_p); + e.points[0].id.key = 0; + } else if (A <= 0) { + if (St.DistanceSquaredVV(h, b) > _ * _) return; + e.pointCount = 1; + e.type = t.b2ManifoldType.e_faceA; + St.SubVV(h, b, e.localNormal).SelfNormalize(); + e.localPoint.Copy(b); + e.points[0].localPoint.Copy(o.m_p); + e.points[0].id.key = 0; + } else { + const i = St.MidVV(y, b, ri); + if (St.DotVV(St.SubVV(h, i, St.s_t1), m[f]) > _) return; + e.pointCount = 1; + e.type = t.b2ManifoldType.e_faceA; + e.localNormal.Copy(m[f]).SelfNormalize(); + e.localPoint.Copy(i); + e.points[0].localPoint.Copy(o.m_p); + e.points[0].id.key = 0; + } + } + const ai = new St; + const li = new St; + const hi = new St; + const ci = new St; + function ui(t, e, i, n, r) { + const o = t.m_vertices; + const a = t.m_normals; + const l = n.m_count; + const h = n.m_vertices; + const c = Ct.MulRV(e.q, a[i], ai); + const u = Ct.MulTRV(r.q, c, li); + let _ = 0; + let d = s; + for (let t = 0; t < l; ++t) { + const e = St.DotVV(h[t], u); + if (e < d) { + d = e; + _ = t; + } + } + const p = xt.MulXV(e, o[i], hi); + const m = xt.MulXV(r, h[_], ci); + return St.DotVV(St.SubVV(m, p, St.s_t0), c); + } + const _i = new St; + const di = new St; + function pi(t, e, i, n, r) { + const o = e.m_count; + const a = e.m_normals; + const l = St.SubVV(xt.MulXV(r, n.m_centroid, St.s_t0), xt.MulXV(i, e.m_centroid, St.s_t1), _i); + const h = Ct.MulTRV(i.q, l, di); + let c = 0; + let u = -s; + for (let t = 0; t < o; ++t) { + const e = St.DotVV(a[t], h); + if (e > u) { + u = e; + c = t; + } + } + let _ = ui(e, i, c, n, r); + const d = (c + o - 1) % o; + const p = ui(e, i, d, n, r); + const m = (c + 1) % o; + const f = ui(e, i, m, n, r); + let g = 0; + let y = 0; + let b = 0; + if (p > _ && p > f) { + b = -1; + g = d; + y = p; + } else { + if (!(f > _)) { + t[0] = c; + return _; + } + b = 1; + g = m; + y = f; + } + for (;;) { + c = -1 === b ? (g + o - 1) % o : (g + 1) % o; + _ = ui(e, i, c, n, r); + if (!(_ > y)) break; + g = c; + y = _; + } + t[0] = g; + return y; + } + const mi = new St; + function fi(e, i, n, r, o, a) { + const l = i.m_normals; + const h = o.m_count; + const c = o.m_vertices; + const u = o.m_normals; + const _ = Ct.MulTRV(a.q, Ct.MulRV(n.q, l[r], St.s_t0), mi); + let d = 0; + let p = s; + for (let t = 0; t < h; ++t) { + const e = St.DotVV(_, u[t]); + if (e < p) { + p = e; + d = t; + } + } + const m = d; + const f = (m + 1) % h; + const g = e[0]; + xt.MulXV(a, c[m], g.v); + const y = g.id.cf; + y.indexA = r; + y.indexB = m; + y.typeA = t.b2ContactFeatureType.e_face; + y.typeB = t.b2ContactFeatureType.e_vertex; + const b = e[1]; + xt.MulXV(a, c[f], b.v); + const S = b.id.cf; + S.indexA = r; + S.indexB = f; + S.typeA = t.b2ContactFeatureType.e_face; + S.typeB = t.b2ContactFeatureType.e_vertex; + } + const gi = pe.MakeArray(2); + const yi = pe.MakeArray(2); + const bi = pe.MakeArray(2); + const Si = [ 0 ]; + const Ai = [ 0 ]; + const Ti = new St; + const vi = new St; + const Ei = new St; + const Ci = new St; + const xi = new St; + const wi = new St; + const Ri = new St; + const Ii = new St; + function Mi(e, i, s, n, r) { + e.pointCount = 0; + const o = i.m_radius + n.m_radius; + const l = Si; + l[0] = 0; + const h = pi(l, i, s, n, r); + if (h > o) return; + const c = Ai; + c[0] = 0; + const u = pi(c, n, r, i, s); + if (u > o) return; + let _; + let d; + let p, m; + let f = 0; + let g = 0; + if (u > .98 * h + .001) { + _ = n; + d = i; + p = r; + m = s; + f = c[0]; + e.type = t.b2ManifoldType.e_faceB; + g = 1; + } else { + _ = i; + d = n; + p = s; + m = r; + f = l[0]; + e.type = t.b2ManifoldType.e_faceA; + g = 0; + } + const y = gi; + fi(y, _, p, f, d, m); + const b = _.m_count; + const S = _.m_vertices; + const A = f; + const T = (f + 1) % b; + const v = S[A]; + const E = S[T]; + const C = St.SubVV(E, v, Ti); + C.Normalize(); + const x = St.CrossVOne(C, vi); + const w = St.MidVV(v, E, Ei); + const R = Ct.MulRV(p.q, C, xi); + const I = St.CrossVOne(R, Ci); + const M = xt.MulXV(p, v, Ri); + const B = xt.MulXV(p, E, Ii); + const D = St.DotVV(I, M); + const P = -St.DotVV(R, M) + o; + const O = St.DotVV(R, B) + o; + const N = yi; + const L = bi; + let F; + F = be(N, y, St.NegV(R, wi), P, A); + if (F < 2) return; + F = be(L, N, R, O, T); + if (F < 2) return; + e.localNormal.Copy(x); + e.localPoint.Copy(w); + let V = 0; + for (let t = 0; t < a; ++t) { + const i = L[t]; + if (St.DotVV(I, i.v) - D <= o) { + const t = e.points[V]; + xt.MulTXV(m, i.v, t.localPoint); + t.id.Copy(i.id); + if (g) { + const e = t.id.cf; + t.id.cf.indexA = e.indexB; + t.id.cf.indexB = e.indexA; + t.id.cf.typeA = e.typeB; + t.id.cf.typeB = e.typeA; + } + ++V; + } + } + e.pointCount = V; + } + const Bi = new St; + const Di = new St; + const Pi = new St; + const Oi = new St; + const Ni = new St; + const Li = new St; + const Fi = new St; + const Vi = new he; + function ki(e, i, s, n, r) { + e.pointCount = 0; + const o = xt.MulTXV(s, xt.MulXV(r, n.m_p, St.s_t0), Bi); + const a = i.m_vertex1; + const l = i.m_vertex2; + const h = St.SubVV(l, a, Di); + const c = St.DotVV(h, St.SubVV(l, o, St.s_t0)); + const u = St.DotVV(h, St.SubVV(o, a, St.s_t0)); + const _ = i.m_radius + n.m_radius; + const d = Vi; + d.cf.indexB = 0; + d.cf.typeB = t.b2ContactFeatureType.e_vertex; + if (u <= 0) { + const s = a; + const r = St.SubVV(o, s, Pi); + if (St.DotVV(r, r) > _ * _) return; + if (i.m_hasVertex0) { + const t = i.m_vertex0; + const e = a; + const s = St.SubVV(e, t, Oi); + if (St.DotVV(s, St.SubVV(e, o, St.s_t0)) > 0) return; + } + d.cf.indexA = 0; + d.cf.typeA = t.b2ContactFeatureType.e_vertex; + e.pointCount = 1; + e.type = t.b2ManifoldType.e_circles; + e.localNormal.SetZero(); + e.localPoint.Copy(s); + e.points[0].id.Copy(d); + e.points[0].localPoint.Copy(n.m_p); + return; + } + if (c <= 0) { + const s = l; + const r = St.SubVV(o, s, Pi); + if (St.DotVV(r, r) > _ * _) return; + if (i.m_hasVertex3) { + const t = i.m_vertex3; + const e = l; + const s = St.SubVV(t, e, Ni); + if (St.DotVV(s, St.SubVV(o, e, St.s_t0)) > 0) return; + } + d.cf.indexA = 1; + d.cf.typeA = t.b2ContactFeatureType.e_vertex; + e.pointCount = 1; + e.type = t.b2ManifoldType.e_circles; + e.localNormal.SetZero(); + e.localPoint.Copy(s); + e.points[0].id.Copy(d); + e.points[0].localPoint.Copy(n.m_p); + return; + } + const p = St.DotVV(h, h); + const m = Li; + m.x = 1 / p * (c * a.x + u * l.x); + m.y = 1 / p * (c * a.y + u * l.y); + const f = St.SubVV(o, m, Pi); + if (St.DotVV(f, f) > _ * _) return; + const g = Fi.Set(-h.y, h.x); + St.DotVV(g, St.SubVV(o, a, St.s_t0)) < 0 && g.Set(-g.x, -g.y); + g.Normalize(); + d.cf.indexA = 0; + d.cf.typeA = t.b2ContactFeatureType.e_face; + e.pointCount = 1; + e.type = t.b2ManifoldType.e_faceA; + e.localNormal.Copy(g); + e.localPoint.Copy(a); + e.points[0].id.Copy(d); + e.points[0].localPoint.Copy(n.m_p); + } + var Ui; + !function(t) { + t[t.e_unknown = 0] = "e_unknown"; + t[t.e_edgeA = 1] = "e_edgeA"; + t[t.e_edgeB = 2] = "e_edgeB"; + }(Ui || (Ui = {})); + class Gi { + constructor() { + this.type = Ui.e_unknown; + this.index = 0; + this.separation = 0; + } + } + class zi { + constructor() { + this.vertices = []; + this.normals = []; + this.count = 0; + } + } + class Hi { + constructor() { + this.i1 = 0; + this.i2 = 0; + this.v1 = new St; + this.v2 = new St; + this.normal = new St; + this.sideNormal1 = new St; + this.sideOffset1 = 0; + this.sideNormal2 = new St; + this.sideOffset2 = 0; + } + } + var ji; + !function(t) { + t[t.e_isolated = 0] = "e_isolated"; + t[t.e_concave = 1] = "e_concave"; + t[t.e_convex = 2] = "e_convex"; + }(ji || (ji = {})); + class Xi { + constructor() { + this.m_polygonB = new zi; + this.m_xf = new xt; + this.m_centroidB = new St; + this.m_v0 = new St; + this.m_v1 = new St; + this.m_v2 = new St; + this.m_v3 = new St; + this.m_normal0 = new St; + this.m_normal1 = new St; + this.m_normal2 = new St; + this.m_normal = new St; + this.m_type1 = ji.e_isolated; + this.m_type2 = ji.e_isolated; + this.m_lowerLimit = new St; + this.m_upperLimit = new St; + this.m_radius = 0; + this.m_front = !1; + } + Collide(e, i, s, n, r) { + xt.MulTXX(s, r, this.m_xf); + xt.MulXV(this.m_xf, n.m_centroid, this.m_centroidB); + this.m_v0.Copy(i.m_vertex0); + this.m_v1.Copy(i.m_vertex1); + this.m_v2.Copy(i.m_vertex2); + this.m_v3.Copy(i.m_vertex3); + const o = i.m_hasVertex0; + const l = i.m_hasVertex3; + const h = St.SubVV(this.m_v2, this.m_v1, Xi.s_edge1); + h.Normalize(); + this.m_normal1.Set(h.y, -h.x); + const c = St.DotVV(this.m_normal1, St.SubVV(this.m_centroidB, this.m_v1, St.s_t0)); + let u = 0; + let _ = 0; + let d = !1; + let p = !1; + if (o) { + const t = St.SubVV(this.m_v1, this.m_v0, Xi.s_edge0); + t.Normalize(); + this.m_normal0.Set(t.y, -t.x); + d = St.CrossVV(t, h) >= 0; + u = St.DotVV(this.m_normal0, St.SubVV(this.m_centroidB, this.m_v0, St.s_t0)); + } + if (l) { + const t = St.SubVV(this.m_v3, this.m_v2, Xi.s_edge2); + t.Normalize(); + this.m_normal2.Set(t.y, -t.x); + p = St.CrossVV(h, t) > 0; + _ = St.DotVV(this.m_normal2, St.SubVV(this.m_centroidB, this.m_v2, St.s_t0)); + } + if (o && l) if (d && p) { + this.m_front = u >= 0 || c >= 0 || _ >= 0; + if (this.m_front) { + this.m_normal.Copy(this.m_normal1); + this.m_lowerLimit.Copy(this.m_normal0); + this.m_upperLimit.Copy(this.m_normal2); + } else { + this.m_normal.Copy(this.m_normal1).SelfNeg(); + this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(); + this.m_upperLimit.Copy(this.m_normal1).SelfNeg(); + } + } else if (d) { + this.m_front = u >= 0 || c >= 0 && _ >= 0; + if (this.m_front) { + this.m_normal.Copy(this.m_normal1); + this.m_lowerLimit.Copy(this.m_normal0); + this.m_upperLimit.Copy(this.m_normal1); + } else { + this.m_normal.Copy(this.m_normal1).SelfNeg(); + this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(); + this.m_upperLimit.Copy(this.m_normal1).SelfNeg(); + } + } else if (p) { + this.m_front = _ >= 0 || u >= 0 && c >= 0; + if (this.m_front) { + this.m_normal.Copy(this.m_normal1); + this.m_lowerLimit.Copy(this.m_normal1); + this.m_upperLimit.Copy(this.m_normal2); + } else { + this.m_normal.Copy(this.m_normal1).SelfNeg(); + this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(); + this.m_upperLimit.Copy(this.m_normal0).SelfNeg(); + } + } else { + this.m_front = u >= 0 && c >= 0 && _ >= 0; + if (this.m_front) { + this.m_normal.Copy(this.m_normal1); + this.m_lowerLimit.Copy(this.m_normal1); + this.m_upperLimit.Copy(this.m_normal1); + } else { + this.m_normal.Copy(this.m_normal1).SelfNeg(); + this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(); + this.m_upperLimit.Copy(this.m_normal0).SelfNeg(); + } + } else if (o) if (d) { + this.m_front = u >= 0 || c >= 0; + if (this.m_front) { + this.m_normal.Copy(this.m_normal1); + this.m_lowerLimit.Copy(this.m_normal0); + this.m_upperLimit.Copy(this.m_normal1).SelfNeg(); + } else { + this.m_normal.Copy(this.m_normal1).SelfNeg(); + this.m_lowerLimit.Copy(this.m_normal1); + this.m_upperLimit.Copy(this.m_normal1).SelfNeg(); + } + } else { + this.m_front = u >= 0 && c >= 0; + if (this.m_front) { + this.m_normal.Copy(this.m_normal1); + this.m_lowerLimit.Copy(this.m_normal1); + this.m_upperLimit.Copy(this.m_normal1).SelfNeg(); + } else { + this.m_normal.Copy(this.m_normal1).SelfNeg(); + this.m_lowerLimit.Copy(this.m_normal1); + this.m_upperLimit.Copy(this.m_normal0).SelfNeg(); + } + } else if (l) if (p) { + this.m_front = c >= 0 || _ >= 0; + if (this.m_front) { + this.m_normal.Copy(this.m_normal1); + this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(); + this.m_upperLimit.Copy(this.m_normal2); + } else { + this.m_normal.Copy(this.m_normal1).SelfNeg(); + this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(); + this.m_upperLimit.Copy(this.m_normal1); + } + } else { + this.m_front = c >= 0 && _ >= 0; + if (this.m_front) { + this.m_normal.Copy(this.m_normal1); + this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(); + this.m_upperLimit.Copy(this.m_normal1); + } else { + this.m_normal.Copy(this.m_normal1).SelfNeg(); + this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(); + this.m_upperLimit.Copy(this.m_normal1); + } + } else { + this.m_front = c >= 0; + if (this.m_front) { + this.m_normal.Copy(this.m_normal1); + this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(); + this.m_upperLimit.Copy(this.m_normal1).SelfNeg(); + } else { + this.m_normal.Copy(this.m_normal1).SelfNeg(); + this.m_lowerLimit.Copy(this.m_normal1); + this.m_upperLimit.Copy(this.m_normal1); + } + } + this.m_polygonB.count = n.m_count; + for (let t = 0; t < n.m_count; ++t) { + this.m_polygonB.vertices.length <= t && this.m_polygonB.vertices.push(new St); + this.m_polygonB.normals.length <= t && this.m_polygonB.normals.push(new St); + xt.MulXV(this.m_xf, n.m_vertices[t], this.m_polygonB.vertices[t]); + Ct.MulRV(this.m_xf.q, n.m_normals[t], this.m_polygonB.normals[t]); + } + this.m_radius = n.m_radius + i.m_radius; + e.pointCount = 0; + const m = this.ComputeEdgeSeparation(Xi.s_edgeAxis); + if (m.type === Ui.e_unknown) return; + if (m.separation > this.m_radius) return; + const f = this.ComputePolygonSeparation(Xi.s_polygonAxis); + if (f.type !== Ui.e_unknown && f.separation > this.m_radius) return; + const g = .98; + const y = .001; + let b; + b = f.type === Ui.e_unknown ? m : f.separation > g * m.separation + y ? f : m; + const S = Xi.s_ie; + const A = Xi.s_rf; + if (b.type === Ui.e_edgeA) { + e.type = t.b2ManifoldType.e_faceA; + let i = 0; + let s = St.DotVV(this.m_normal, this.m_polygonB.normals[0]); + for (let t = 1; t < this.m_polygonB.count; ++t) { + const e = St.DotVV(this.m_normal, this.m_polygonB.normals[t]); + if (e < s) { + s = e; + i = t; + } + } + const n = i; + const r = (n + 1) % this.m_polygonB.count; + const o = S[0]; + o.v.Copy(this.m_polygonB.vertices[n]); + o.id.cf.indexA = 0; + o.id.cf.indexB = n; + o.id.cf.typeA = t.b2ContactFeatureType.e_face; + o.id.cf.typeB = t.b2ContactFeatureType.e_vertex; + const a = S[1]; + a.v.Copy(this.m_polygonB.vertices[r]); + a.id.cf.indexA = 0; + a.id.cf.indexB = r; + a.id.cf.typeA = t.b2ContactFeatureType.e_face; + a.id.cf.typeB = t.b2ContactFeatureType.e_vertex; + if (this.m_front) { + A.i1 = 0; + A.i2 = 1; + A.v1.Copy(this.m_v1); + A.v2.Copy(this.m_v2); + A.normal.Copy(this.m_normal1); + } else { + A.i1 = 1; + A.i2 = 0; + A.v1.Copy(this.m_v2); + A.v2.Copy(this.m_v1); + A.normal.Copy(this.m_normal1).SelfNeg(); + } + } else { + e.type = t.b2ManifoldType.e_faceB; + const i = S[0]; + i.v.Copy(this.m_v1); + i.id.cf.indexA = 0; + i.id.cf.indexB = b.index; + i.id.cf.typeA = t.b2ContactFeatureType.e_vertex; + i.id.cf.typeB = t.b2ContactFeatureType.e_face; + const s = S[1]; + s.v.Copy(this.m_v2); + s.id.cf.indexA = 0; + s.id.cf.indexB = b.index; + s.id.cf.typeA = t.b2ContactFeatureType.e_vertex; + s.id.cf.typeB = t.b2ContactFeatureType.e_face; + A.i1 = b.index; + A.i2 = (A.i1 + 1) % this.m_polygonB.count; + A.v1.Copy(this.m_polygonB.vertices[A.i1]); + A.v2.Copy(this.m_polygonB.vertices[A.i2]); + A.normal.Copy(this.m_polygonB.normals[A.i1]); + } + A.sideNormal1.Set(A.normal.y, -A.normal.x); + A.sideNormal2.Copy(A.sideNormal1).SelfNeg(); + A.sideOffset1 = St.DotVV(A.sideNormal1, A.v1); + A.sideOffset2 = St.DotVV(A.sideNormal2, A.v2); + const T = Xi.s_clipPoints1; + const v = Xi.s_clipPoints2; + let E = 0; + E = be(T, S, A.sideNormal1, A.sideOffset1, A.i1); + if (E < a) return; + E = be(v, T, A.sideNormal2, A.sideOffset2, A.i2); + if (E < a) return; + if (b.type === Ui.e_edgeA) { + e.localNormal.Copy(A.normal); + e.localPoint.Copy(A.v1); + } else { + e.localNormal.Copy(n.m_normals[A.i1]); + e.localPoint.Copy(n.m_vertices[A.i1]); + } + let C = 0; + for (let t = 0; t < a; ++t) { + let i; + i = St.DotVV(A.normal, St.SubVV(v[t].v, A.v1, St.s_t0)); + if (i <= this.m_radius) { + const i = e.points[C]; + if (b.type === Ui.e_edgeA) { + xt.MulTXV(this.m_xf, v[t].v, i.localPoint); + i.id.Copy(v[t].id); + } else { + i.localPoint.Copy(v[t].v); + i.id.cf.typeA = v[t].id.cf.typeB; + i.id.cf.typeB = v[t].id.cf.typeA; + i.id.cf.indexA = v[t].id.cf.indexB; + i.id.cf.indexB = v[t].id.cf.indexA; + } + ++C; + } + } + e.pointCount = C; + } + ComputeEdgeSeparation(t) { + const e = t; + e.type = Ui.e_edgeA; + e.index = this.m_front ? 0 : 1; + e.separation = s; + for (let t = 0; t < this.m_polygonB.count; ++t) { + const i = St.DotVV(this.m_normal, St.SubVV(this.m_polygonB.vertices[t], this.m_v1, St.s_t0)); + i < e.separation && (e.separation = i); + } + return e; + } + ComputePolygonSeparation(t) { + const e = t; + e.type = Ui.e_unknown; + e.index = -1; + e.separation = -s; + const i = Xi.s_perp.Set(-this.m_normal.y, this.m_normal.x); + for (let t = 0; t < this.m_polygonB.count; ++t) { + const s = St.NegV(this.m_polygonB.normals[t], Xi.s_n); + const n = tt(St.DotVV(s, St.SubVV(this.m_polygonB.vertices[t], this.m_v1, St.s_t0)), St.DotVV(s, St.SubVV(this.m_polygonB.vertices[t], this.m_v2, St.s_t0))); + if (n > this.m_radius) { + e.type = Ui.e_edgeB; + e.index = t; + e.separation = n; + return e; + } + if (St.DotVV(s, i) >= 0) { + if (St.DotVV(St.SubVV(s, this.m_upperLimit, St.s_t0), this.m_normal) < -_) continue; + } else if (St.DotVV(St.SubVV(s, this.m_lowerLimit, St.s_t0), this.m_normal) < -_) continue; + if (n > e.separation) { + e.type = Ui.e_edgeB; + e.index = t; + e.separation = n; + } + } + return e; + } + } + Xi.s_edge1 = new St; + Xi.s_edge0 = new St; + Xi.s_edge2 = new St; + Xi.s_ie = pe.MakeArray(2); + Xi.s_rf = new Hi; + Xi.s_clipPoints1 = pe.MakeArray(2); + Xi.s_clipPoints2 = pe.MakeArray(2); + Xi.s_edgeAxis = new Gi; + Xi.s_polygonAxis = new Gi; + Xi.s_n = new St; + Xi.s_perp = new St; + const Wi = new Xi; + function Yi(t, e, i, s, n) { + Wi.Collide(t, e, i, s, n); + } + class qi { + constructor() { + this.mass = 0; + this.center = new St(0, 0); + this.I = 0; + } + } + !function(t) { + t[t.e_unknown = -1] = "e_unknown"; + t[t.e_circleShape = 0] = "e_circleShape"; + t[t.e_edgeShape = 1] = "e_edgeShape"; + t[t.e_polygonShape = 2] = "e_polygonShape"; + t[t.e_chainShape = 3] = "e_chainShape"; + t[t.e_shapeTypeCount = 4] = "e_shapeTypeCount"; + }(t.b2ShapeType || (t.b2ShapeType = {})); + class Ki { + constructor(e, i) { + this.m_type = t.b2ShapeType.e_unknown; + this.m_radius = 0; + this.m_type = e; + this.m_radius = i; + } + Copy(t) { + this.m_radius = t.m_radius; + return this; + } + GetType() { + return this.m_type; + } + } + class Ji extends Ki { + constructor(e = 0) { + super(t.b2ShapeType.e_circleShape, e); + this.m_p = new St; + } + Set(t, e = this.m_radius) { + this.m_p.Copy(t); + this.m_radius = e; + return this; + } + Clone() { + return (new Ji).Copy(this); + } + Copy(t) { + super.Copy(t); + this.m_p.Copy(t.m_p); + return this; + } + GetChildCount() { + return 1; + } + TestPoint(t, e) { + const i = xt.MulXV(t, this.m_p, Ji.TestPoint_s_center); + const s = St.SubVV(e, i, Ji.TestPoint_s_d); + return St.DotVV(s, s) <= rt(this.m_radius); + } + ComputeDistance(t, e, i, s) { + const n = xt.MulXV(t, this.m_p, Ji.ComputeDistance_s_center); + St.SubVV(e, n, i); + return i.Normalize() - this.m_radius; + } + RayCast(t, e, i, s) { + const r = xt.MulXV(i, this.m_p, Ji.RayCast_s_position); + const o = St.SubVV(e.p1, r, Ji.RayCast_s_s); + const a = St.DotVV(o, o) - rt(this.m_radius); + const l = St.SubVV(e.p2, e.p1, Ji.RayCast_s_r); + const h = St.DotVV(o, l); + const c = St.DotVV(l, l); + const u = h * h - c * a; + if (u < 0 || c < n) return !1; + let _ = -(h + at(u)); + if (0 <= _ && _ <= e.maxFraction * c) { + _ /= c; + t.fraction = _; + St.AddVMulSV(o, _, l, t.normal).SelfNormalize(); + return !0; + } + return !1; + } + ComputeAABB(t, e, i) { + const s = xt.MulXV(e, this.m_p, Ji.ComputeAABB_s_p); + t.lowerBound.Set(s.x - this.m_radius, s.y - this.m_radius); + t.upperBound.Set(s.x + this.m_radius, s.y + this.m_radius); + } + ComputeMass(t, e) { + const i = rt(this.m_radius); + t.mass = e * o * i; + t.center.Copy(this.m_p); + t.I = t.mass * (.5 * i + St.DotVV(this.m_p, this.m_p)); + } + SetupDistanceProxy(t, e) { + t.m_vertices = t.m_buffer; + t.m_vertices[0].Copy(this.m_p); + t.m_count = 1; + t.m_radius = this.m_radius; + } + ComputeSubmergedArea(t, e, i, s) { + const r = xt.MulXV(i, this.m_p, new St); + const a = -(St.DotVV(t, r) - e); + if (a < -this.m_radius + n) return 0; + if (a > this.m_radius) { + s.Copy(r); + return o * this.m_radius * this.m_radius; + } + const l = this.m_radius * this.m_radius; + const h = a * a; + const c = l * (pt(a / this.m_radius) + o / 2) + a * at(l - h); + const u = -2 / 3 * lt(l - h, 1.5) / c; + s.x = r.x + t.x * u; + s.y = r.y + t.y * u; + return c; + } + Dump(t) { + t(" const shape: b2CircleShape = new b2CircleShape();\n"); + t(" shape.m_radius = %.15f;\n", this.m_radius); + t(" shape.m_p.Set(%.15f, %.15f);\n", this.m_p.x, this.m_p.y); + } + } + Ji.TestPoint_s_center = new St; + Ji.TestPoint_s_d = new St; + Ji.ComputeDistance_s_center = new St; + Ji.RayCast_s_position = new St; + Ji.RayCast_s_s = new St; + Ji.RayCast_s_r = new St; + Ji.ComputeAABB_s_p = new St; + class Zi extends Ki { + constructor() { + super(t.b2ShapeType.e_polygonShape, d); + this.m_centroid = new St(0, 0); + this.m_vertices = []; + this.m_normals = []; + this.m_count = 0; + } + Clone() { + return (new Zi).Copy(this); + } + Copy(t) { + super.Copy(t); + this.m_centroid.Copy(t.m_centroid); + this.m_count = t.m_count; + this.m_vertices = St.MakeArray(this.m_count); + this.m_normals = St.MakeArray(this.m_count); + for (let e = 0; e < this.m_count; ++e) { + this.m_vertices[e].Copy(t.m_vertices[e]); + this.m_normals[e].Copy(t.m_normals[e]); + } + return this; + } + GetChildCount() { + return 1; + } + Set(...t) { + if ("number" == typeof t[0][0]) { + const e = t[0]; + if (e.length % 2 != 0) throw new Error; + return this._Set((t => ({ + x: e[2 * t], + y: e[2 * t + 1] + })), e.length / 2); + } + { + const e = t[0]; + const i = t[1] || e.length; + return this._Set((t => e[t]), i); + } + } + _Set(t, e) { + if (e < 3) return this.SetAsBox(1, 1); + let i = e; + const s = []; + for (let e = 0; e < i; ++e) { + const i = t(e); + let n = !0; + for (let t = 0; t < s.length; ++t) if (St.DistanceSquaredVV(i, s[t]) < .5 * u * (.5 * u)) { + n = !1; + break; + } + n && s.push(i); + } + i = s.length; + if (i < 3) return this.SetAsBox(1, 1); + let n = 0; + let r = s[0].x; + for (let t = 1; t < i; ++t) { + const e = s[t].x; + if (e > r || e === r && s[t].y < s[n].y) { + n = t; + r = e; + } + } + const o = []; + let a = 0; + let l = n; + for (;;) { + o[a] = l; + let t = 0; + for (let e = 1; e < i; ++e) { + if (t === l) { + t = e; + continue; + } + const i = St.SubVV(s[t], s[o[a]], Zi.Set_s_r); + const n = St.SubVV(s[e], s[o[a]], Zi.Set_s_v); + const r = St.CrossVV(i, n); + r < 0 && (t = e); + 0 === r && n.LengthSquared() > i.LengthSquared() && (t = e); + } + ++a; + l = t; + if (t === n) break; + } + this.m_count = a; + this.m_vertices = St.MakeArray(this.m_count); + this.m_normals = St.MakeArray(this.m_count); + for (let t = 0; t < a; ++t) this.m_vertices[t].Copy(s[o[t]]); + for (let t = 0; t < a; ++t) { + const e = this.m_vertices[t]; + const i = this.m_vertices[(t + 1) % a]; + const s = St.SubVV(i, e, St.s_t0); + St.CrossVOne(s, this.m_normals[t]).SelfNormalize(); + } + Zi.ComputeCentroid(this.m_vertices, a, this.m_centroid); + return this; + } + SetAsBox(t, e, i, s = 0) { + this.m_count = 4; + this.m_vertices = St.MakeArray(this.m_count); + this.m_normals = St.MakeArray(this.m_count); + this.m_vertices[0].Set(-t, -e); + this.m_vertices[1].Set(t, -e); + this.m_vertices[2].Set(t, e); + this.m_vertices[3].Set(-t, e); + this.m_normals[0].Set(0, -1); + this.m_normals[1].Set(1, 0); + this.m_normals[2].Set(0, 1); + this.m_normals[3].Set(-1, 0); + this.m_centroid.SetZero(); + if (i) { + this.m_centroid.Copy(i); + const t = new xt; + t.SetPosition(i); + t.SetRotationAngle(s); + for (let e = 0; e < this.m_count; ++e) { + xt.MulXV(t, this.m_vertices[e], this.m_vertices[e]); + Ct.MulRV(t.q, this.m_normals[e], this.m_normals[e]); + } + } + return this; + } + TestPoint(t, e) { + const i = xt.MulTXV(t, e, Zi.TestPoint_s_pLocal); + for (let t = 0; t < this.m_count; ++t) if (St.DotVV(this.m_normals[t], St.SubVV(i, this.m_vertices[t], St.s_t0)) > 0) return !1; + return !0; + } + ComputeDistance(t, e, i, n) { + const r = xt.MulTXV(t, e, Zi.ComputeDistance_s_pLocal); + let o = -s; + const a = Zi.ComputeDistance_s_normalForMaxDistance.Copy(r); + for (let t = 0; t < this.m_count; ++t) { + const e = St.DotVV(this.m_normals[t], St.SubVV(r, this.m_vertices[t], St.s_t0)); + if (e > o) { + o = e; + a.Copy(this.m_normals[t]); + } + } + if (o > 0) { + const e = Zi.ComputeDistance_s_minDistance.Copy(a); + let s = o * o; + for (let t = 0; t < this.m_count; ++t) { + const i = St.SubVV(r, this.m_vertices[t], Zi.ComputeDistance_s_distance); + const n = i.LengthSquared(); + if (s > n) { + e.Copy(i); + s = n; + } + } + Ct.MulRV(t.q, e, i); + i.Normalize(); + return Math.sqrt(s); + } + Ct.MulRV(t.q, a, i); + return o; + } + RayCast(t, e, i, s) { + const n = xt.MulTXV(i, e.p1, Zi.RayCast_s_p1); + const r = xt.MulTXV(i, e.p2, Zi.RayCast_s_p2); + const o = St.SubVV(r, n, Zi.RayCast_s_d); + let a = 0, l = e.maxFraction; + let h = -1; + for (let t = 0; t < this.m_count; ++t) { + const e = St.DotVV(this.m_normals[t], St.SubVV(this.m_vertices[t], n, St.s_t0)); + const i = St.DotVV(this.m_normals[t], o); + if (0 === i) { + if (e < 0) return !1; + } else if (i < 0 && e < a * i) { + a = e / i; + h = t; + } else i > 0 && e < l * i && (l = e / i); + if (l < a) return !1; + } + if (h >= 0) { + t.fraction = a; + Ct.MulRV(i.q, this.m_normals[h], t.normal); + return !0; + } + return !1; + } + ComputeAABB(t, e, i) { + const s = xt.MulXV(e, this.m_vertices[0], t.lowerBound); + const n = t.upperBound.Copy(s); + for (let t = 0; t < this.m_count; ++t) { + const i = xt.MulXV(e, this.m_vertices[t], Zi.ComputeAABB_s_v); + St.MinV(i, s, s); + St.MaxV(i, n, n); + } + const r = this.m_radius; + s.SelfSubXY(r, r); + n.SelfAddXY(r, r); + } + ComputeMass(t, e) { + const i = Zi.ComputeMass_s_center.SetZero(); + let s = 0; + let n = 0; + const r = Zi.ComputeMass_s_s.SetZero(); + for (let t = 0; t < this.m_count; ++t) r.SelfAdd(this.m_vertices[t]); + r.SelfMul(1 / this.m_count); + const o = 1 / 3; + for (let t = 0; t < this.m_count; ++t) { + const e = St.SubVV(this.m_vertices[t], r, Zi.ComputeMass_s_e1); + const a = St.SubVV(this.m_vertices[(t + 1) % this.m_count], r, Zi.ComputeMass_s_e2); + const l = St.CrossVV(e, a); + const h = .5 * l; + s += h; + i.SelfAdd(St.MulSV(h * o, St.AddVV(e, a, St.s_t0), St.s_t1)); + const c = e.x; + const u = e.y; + const _ = a.x; + const d = a.y; + n += .25 * o * l * (c * c + _ * c + _ * _ + (u * u + d * u + d * d)); + } + t.mass = e * s; + i.SelfMul(1 / s); + St.AddVV(i, r, t.center); + t.I = e * n; + t.I += t.mass * (St.DotVV(t.center, t.center) - St.DotVV(i, i)); + } + Validate() { + for (let t = 0; t < this.m_count; ++t) { + const e = t; + const i = (t + 1) % this.m_count; + const s = this.m_vertices[e]; + const n = St.SubVV(this.m_vertices[i], s, Zi.Validate_s_e); + for (let t = 0; t < this.m_count; ++t) { + if (t === e || t === i) continue; + const r = St.SubVV(this.m_vertices[t], s, Zi.Validate_s_v); + if (St.CrossVV(n, r) < 0) return !1; + } + } + return !0; + } + SetupDistanceProxy(t, e) { + t.m_vertices = this.m_vertices; + t.m_count = this.m_count; + t.m_radius = this.m_radius; + } + ComputeSubmergedArea(t, e, i, s) { + const r = Ct.MulTRV(i.q, t, Zi.ComputeSubmergedArea_s_normalL); + const o = e - St.DotVV(t, i.p); + const a = []; + let l = 0; + let h = -1; + let c = -1; + let u = !1; + for (let t = 0; t < this.m_count; ++t) { + a[t] = St.DotVV(r, this.m_vertices[t]) - o; + const e = a[t] < -n; + if (t > 0) if (e) { + if (!u) { + h = t - 1; + l++; + } + } else if (u) { + c = t - 1; + l++; + } + u = e; + } + switch (l) { + case 0: + if (u) { + const t = Zi.ComputeSubmergedArea_s_md; + this.ComputeMass(t, 1); + xt.MulXV(i, t.center, s); + return t.mass; + } + return 0; + + case 1: + -1 === h ? h = this.m_count - 1 : c = this.m_count - 1; + } + const _ = (h + 1) % this.m_count; + const d = (c + 1) % this.m_count; + const p = (0 - a[h]) / (a[_] - a[h]); + const m = (0 - a[c]) / (a[d] - a[c]); + const f = Zi.ComputeSubmergedArea_s_intoVec.Set(this.m_vertices[h].x * (1 - p) + this.m_vertices[_].x * p, this.m_vertices[h].y * (1 - p) + this.m_vertices[_].y * p); + const g = Zi.ComputeSubmergedArea_s_outoVec.Set(this.m_vertices[c].x * (1 - m) + this.m_vertices[d].x * m, this.m_vertices[c].y * (1 - m) + this.m_vertices[d].y * m); + let y = 0; + const b = Zi.ComputeSubmergedArea_s_center.SetZero(); + let S = this.m_vertices[_]; + let A; + let T = _; + for (;T !== d; ) { + T = (T + 1) % this.m_count; + A = T === d ? g : this.m_vertices[T]; + const t = .5 * ((S.x - f.x) * (A.y - f.y) - (S.y - f.y) * (A.x - f.x)); + y += t; + b.x += t * (f.x + S.x + A.x) / 3; + b.y += t * (f.y + S.y + A.y) / 3; + S = A; + } + b.SelfMul(1 / y); + xt.MulXV(i, b, s); + return y; + } + Dump(t) { + t(" const shape: b2PolygonShape = new b2PolygonShape();\n"); + t(" const vs: b2Vec2[] = [];\n"); + for (let e = 0; e < this.m_count; ++e) t(" vs[%d] = new b2Vec2(%.15f, %.15f);\n", e, this.m_vertices[e].x, this.m_vertices[e].y); + t(" shape.Set(vs, %d);\n", this.m_count); + } + static ComputeCentroid(t, e, i) { + const s = i; + s.SetZero(); + let n = 0; + const r = Zi.ComputeCentroid_s_pRef.SetZero(); + const o = 1 / 3; + for (let i = 0; i < e; ++i) { + const a = r; + const l = t[i]; + const h = t[(i + 1) % e]; + const c = St.SubVV(l, a, Zi.ComputeCentroid_s_e1); + const u = St.SubVV(h, a, Zi.ComputeCentroid_s_e2); + const _ = .5 * St.CrossVV(c, u); + n += _; + s.x += _ * o * (a.x + l.x + h.x); + s.y += _ * o * (a.y + l.y + h.y); + } + s.SelfMul(1 / n); + return s; + } + } + Zi.Set_s_r = new St; + Zi.Set_s_v = new St; + Zi.TestPoint_s_pLocal = new St; + Zi.ComputeDistance_s_pLocal = new St; + Zi.ComputeDistance_s_normalForMaxDistance = new St; + Zi.ComputeDistance_s_minDistance = new St; + Zi.ComputeDistance_s_distance = new St; + Zi.RayCast_s_p1 = new St; + Zi.RayCast_s_p2 = new St; + Zi.RayCast_s_d = new St; + Zi.ComputeAABB_s_v = new St; + Zi.ComputeMass_s_center = new St; + Zi.ComputeMass_s_s = new St; + Zi.ComputeMass_s_e1 = new St; + Zi.ComputeMass_s_e2 = new St; + Zi.Validate_s_e = new St; + Zi.Validate_s_v = new St; + Zi.ComputeSubmergedArea_s_normalL = new St; + Zi.ComputeSubmergedArea_s_md = new qi; + Zi.ComputeSubmergedArea_s_intoVec = new St; + Zi.ComputeSubmergedArea_s_outoVec = new St; + Zi.ComputeSubmergedArea_s_center = new St; + Zi.ComputeCentroid_s_pRef = new St; + Zi.ComputeCentroid_s_e1 = new St; + Zi.ComputeCentroid_s_e2 = new St; + class Qi extends Ki { + constructor() { + super(t.b2ShapeType.e_edgeShape, d); + this.m_vertex1 = new St; + this.m_vertex2 = new St; + this.m_vertex0 = new St; + this.m_vertex3 = new St; + this.m_hasVertex0 = !1; + this.m_hasVertex3 = !1; + } + Set(t, e) { + this.m_vertex1.Copy(t); + this.m_vertex2.Copy(e); + this.m_hasVertex0 = !1; + this.m_hasVertex3 = !1; + return this; + } + Clone() { + return (new Qi).Copy(this); + } + Copy(t) { + super.Copy(t); + this.m_vertex1.Copy(t.m_vertex1); + this.m_vertex2.Copy(t.m_vertex2); + this.m_vertex0.Copy(t.m_vertex0); + this.m_vertex3.Copy(t.m_vertex3); + this.m_hasVertex0 = t.m_hasVertex0; + this.m_hasVertex3 = t.m_hasVertex3; + return this; + } + GetChildCount() { + return 1; + } + TestPoint(t, e) { + return !1; + } + ComputeDistance(t, e, i, s) { + const n = xt.MulXV(t, this.m_vertex1, Qi.ComputeDistance_s_v1); + const r = xt.MulXV(t, this.m_vertex2, Qi.ComputeDistance_s_v2); + const o = St.SubVV(e, n, Qi.ComputeDistance_s_d); + const a = St.SubVV(r, n, Qi.ComputeDistance_s_s); + const l = St.DotVV(o, a); + if (l > 0) { + const t = St.DotVV(a, a); + l > t ? St.SubVV(e, r, o) : o.SelfMulSub(l / t, a); + } + i.Copy(o); + return i.Normalize(); + } + RayCast(t, e, i, s) { + const n = xt.MulTXV(i, e.p1, Qi.RayCast_s_p1); + const r = xt.MulTXV(i, e.p2, Qi.RayCast_s_p2); + const o = St.SubVV(r, n, Qi.RayCast_s_d); + const a = this.m_vertex1; + const l = this.m_vertex2; + const h = St.SubVV(l, a, Qi.RayCast_s_e); + const c = t.normal.Set(h.y, -h.x).SelfNormalize(); + const u = St.DotVV(c, St.SubVV(a, n, St.s_t0)); + const _ = St.DotVV(c, o); + if (0 === _) return !1; + const d = u / _; + if (d < 0 || e.maxFraction < d) return !1; + const p = St.AddVMulSV(n, d, o, Qi.RayCast_s_q); + const m = St.SubVV(l, a, Qi.RayCast_s_r); + const f = St.DotVV(m, m); + if (0 === f) return !1; + const g = St.DotVV(St.SubVV(p, a, St.s_t0), m) / f; + if (g < 0 || 1 < g) return !1; + t.fraction = d; + Ct.MulRV(i.q, t.normal, t.normal); + u > 0 && t.normal.SelfNeg(); + return !0; + } + ComputeAABB(t, e, i) { + const s = xt.MulXV(e, this.m_vertex1, Qi.ComputeAABB_s_v1); + const n = xt.MulXV(e, this.m_vertex2, Qi.ComputeAABB_s_v2); + St.MinV(s, n, t.lowerBound); + St.MaxV(s, n, t.upperBound); + const r = this.m_radius; + t.lowerBound.SelfSubXY(r, r); + t.upperBound.SelfAddXY(r, r); + } + ComputeMass(t, e) { + t.mass = 0; + St.MidVV(this.m_vertex1, this.m_vertex2, t.center); + t.I = 0; + } + SetupDistanceProxy(t, e) { + t.m_vertices = t.m_buffer; + t.m_vertices[0].Copy(this.m_vertex1); + t.m_vertices[1].Copy(this.m_vertex2); + t.m_count = 2; + t.m_radius = this.m_radius; + } + ComputeSubmergedArea(t, e, i, s) { + s.SetZero(); + return 0; + } + Dump(t) { + t(" const shape: b2EdgeShape = new b2EdgeShape();\n"); + t(" shape.m_radius = %.15f;\n", this.m_radius); + t(" shape.m_vertex0.Set(%.15f, %.15f);\n", this.m_vertex0.x, this.m_vertex0.y); + t(" shape.m_vertex1.Set(%.15f, %.15f);\n", this.m_vertex1.x, this.m_vertex1.y); + t(" shape.m_vertex2.Set(%.15f, %.15f);\n", this.m_vertex2.x, this.m_vertex2.y); + t(" shape.m_vertex3.Set(%.15f, %.15f);\n", this.m_vertex3.x, this.m_vertex3.y); + t(" shape.m_hasVertex0 = %s;\n", this.m_hasVertex0); + t(" shape.m_hasVertex3 = %s;\n", this.m_hasVertex3); + } + } + Qi.ComputeDistance_s_v1 = new St; + Qi.ComputeDistance_s_v2 = new St; + Qi.ComputeDistance_s_d = new St; + Qi.ComputeDistance_s_s = new St; + Qi.RayCast_s_p1 = new St; + Qi.RayCast_s_p2 = new St; + Qi.RayCast_s_d = new St; + Qi.RayCast_s_e = new St; + Qi.RayCast_s_q = new St; + Qi.RayCast_s_r = new St; + Qi.ComputeAABB_s_v1 = new St; + Qi.ComputeAABB_s_v2 = new St; + class $i extends Ki { + constructor() { + super(t.b2ShapeType.e_chainShape, d); + this.m_vertices = []; + this.m_count = 0; + this.m_prevVertex = new St; + this.m_nextVertex = new St; + this.m_hasPrevVertex = !1; + this.m_hasNextVertex = !1; + } + CreateLoop(...t) { + if ("number" == typeof t[0][0]) { + const e = t[0]; + if (e.length % 2 != 0) throw new Error; + return this._CreateLoop((t => ({ + x: e[2 * t], + y: e[2 * t + 1] + })), e.length / 2); + } + { + const e = t[0]; + const i = t[1] || e.length; + return this._CreateLoop((t => e[t]), i); + } + } + _CreateLoop(t, e) { + if (e < 3) return this; + this.m_count = e + 1; + this.m_vertices = St.MakeArray(this.m_count); + for (let i = 0; i < e; ++i) this.m_vertices[i].Copy(t(i)); + this.m_vertices[e].Copy(this.m_vertices[0]); + this.m_prevVertex.Copy(this.m_vertices[this.m_count - 2]); + this.m_nextVertex.Copy(this.m_vertices[1]); + this.m_hasPrevVertex = !0; + this.m_hasNextVertex = !0; + return this; + } + CreateChain(...t) { + if ("number" == typeof t[0][0]) { + const e = t[0]; + if (e.length % 2 != 0) throw new Error; + return this._CreateChain((t => ({ + x: e[2 * t], + y: e[2 * t + 1] + })), e.length / 2); + } + { + const e = t[0]; + const i = t[1] || e.length; + return this._CreateChain((t => e[t]), i); + } + } + _CreateChain(t, e) { + this.m_count = e; + this.m_vertices = St.MakeArray(e); + for (let i = 0; i < e; ++i) this.m_vertices[i].Copy(t(i)); + this.m_hasPrevVertex = !1; + this.m_hasNextVertex = !1; + this.m_prevVertex.SetZero(); + this.m_nextVertex.SetZero(); + return this; + } + SetPrevVertex(t) { + this.m_prevVertex.Copy(t); + this.m_hasPrevVertex = !0; + return this; + } + SetNextVertex(t) { + this.m_nextVertex.Copy(t); + this.m_hasNextVertex = !0; + return this; + } + Clone() { + return (new $i).Copy(this); + } + Copy(t) { + super.Copy(t); + this._CreateChain((e => t.m_vertices[e]), t.m_count); + this.m_prevVertex.Copy(t.m_prevVertex); + this.m_nextVertex.Copy(t.m_nextVertex); + this.m_hasPrevVertex = t.m_hasPrevVertex; + this.m_hasNextVertex = t.m_hasNextVertex; + return this; + } + GetChildCount() { + return this.m_count - 1; + } + GetChildEdge(t, e) { + t.m_radius = this.m_radius; + t.m_vertex1.Copy(this.m_vertices[e]); + t.m_vertex2.Copy(this.m_vertices[e + 1]); + if (e > 0) { + t.m_vertex0.Copy(this.m_vertices[e - 1]); + t.m_hasVertex0 = !0; + } else { + t.m_vertex0.Copy(this.m_prevVertex); + t.m_hasVertex0 = this.m_hasPrevVertex; + } + if (e < this.m_count - 2) { + t.m_vertex3.Copy(this.m_vertices[e + 2]); + t.m_hasVertex3 = !0; + } else { + t.m_vertex3.Copy(this.m_nextVertex); + t.m_hasVertex3 = this.m_hasNextVertex; + } + } + TestPoint(t, e) { + return !1; + } + ComputeDistance(t, e, i, s) { + const n = $i.ComputeDistance_s_edgeShape; + this.GetChildEdge(n, s); + return n.ComputeDistance(t, e, i, 0); + } + RayCast(t, e, i, s) { + const n = $i.RayCast_s_edgeShape; + n.m_vertex1.Copy(this.m_vertices[s]); + n.m_vertex2.Copy(this.m_vertices[(s + 1) % this.m_count]); + return n.RayCast(t, e, i, 0); + } + ComputeAABB(t, e, i) { + const s = this.m_vertices[i]; + const n = this.m_vertices[(i + 1) % this.m_count]; + const r = xt.MulXV(e, s, $i.ComputeAABB_s_v1); + const o = xt.MulXV(e, n, $i.ComputeAABB_s_v2); + St.MinV(r, o, t.lowerBound); + St.MaxV(r, o, t.upperBound); + } + ComputeMass(t, e) { + t.mass = 0; + t.center.SetZero(); + t.I = 0; + } + SetupDistanceProxy(t, e) { + t.m_vertices = t.m_buffer; + t.m_vertices[0].Copy(this.m_vertices[e]); + e + 1 < this.m_count ? t.m_vertices[1].Copy(this.m_vertices[e + 1]) : t.m_vertices[1].Copy(this.m_vertices[0]); + t.m_count = 2; + t.m_radius = this.m_radius; + } + ComputeSubmergedArea(t, e, i, s) { + s.SetZero(); + return 0; + } + Dump(t) { + t(" const shape: b2ChainShape = new b2ChainShape();\n"); + t(" const vs: b2Vec2[] = [];\n"); + for (let e = 0; e < this.m_count; ++e) t(" vs[%d] = new bVec2(%.15f, %.15f);\n", e, this.m_vertices[e].x, this.m_vertices[e].y); + t(" shape.CreateChain(vs, %d);\n", this.m_count); + t(" shape.m_prevVertex.Set(%.15f, %.15f);\n", this.m_prevVertex.x, this.m_prevVertex.y); + t(" shape.m_nextVertex.Set(%.15f, %.15f);\n", this.m_nextVertex.x, this.m_nextVertex.y); + t(" shape.m_hasPrevVertex = %s;\n", this.m_hasPrevVertex ? "true" : "false"); + t(" shape.m_hasNextVertex = %s;\n", this.m_hasNextVertex ? "true" : "false"); + } + } + $i.ComputeDistance_s_edgeShape = new Qi; + $i.RayCast_s_edgeShape = new Qi; + $i.ComputeAABB_s_v1 = new St; + $i.ComputeAABB_s_v2 = new St; + class ts { + constructor() { + this.categoryBits = 1; + this.maskBits = 65535; + this.groupIndex = 0; + } + Clone() { + return (new ts).Copy(this); + } + Copy(t) { + this.categoryBits = t.categoryBits; + this.maskBits = t.maskBits; + this.groupIndex = t.groupIndex || 0; + return this; + } + } + ts.DEFAULT = new ts; + class es { + constructor() { + this.userData = null; + this.friction = .2; + this.restitution = 0; + this.density = 0; + this.isSensor = !1; + this.filter = new ts; + } + } + class is { + constructor(t, e) { + this.aabb = new ge; + this.childIndex = 0; + this.fixture = t; + this.childIndex = e; + this.fixture.m_shape.ComputeAABB(this.aabb, this.fixture.m_body.GetTransform(), e); + this.treeNode = this.fixture.m_body.m_world.m_contactManager.m_broadPhase.CreateProxy(this.aabb, this); + } + Reset() { + this.fixture.m_body.m_world.m_contactManager.m_broadPhase.DestroyProxy(this.treeNode); + } + Touch() { + this.fixture.m_body.m_world.m_contactManager.m_broadPhase.TouchProxy(this.treeNode); + } + Synchronize(t, e, i) { + if (t === e) { + this.fixture.m_shape.ComputeAABB(this.aabb, t, this.childIndex); + this.fixture.m_body.m_world.m_contactManager.m_broadPhase.MoveProxy(this.treeNode, this.aabb, i); + } else { + const s = is.Synchronize_s_aabb1; + const n = is.Synchronize_s_aabb2; + this.fixture.m_shape.ComputeAABB(s, t, this.childIndex); + this.fixture.m_shape.ComputeAABB(n, e, this.childIndex); + this.aabb.Combine2(s, n); + this.fixture.m_body.m_world.m_contactManager.m_broadPhase.MoveProxy(this.treeNode, this.aabb, i); + } + } + } + is.Synchronize_s_aabb1 = new ge; + is.Synchronize_s_aabb2 = new ge; + class ss { + constructor(t, e) { + this.m_density = 0; + this.m_next = null; + this.m_friction = 0; + this.m_restitution = 0; + this.m_proxies = []; + this.m_filter = new ts; + this.m_isSensor = !1; + this.m_userData = null; + this.m_body = t; + this.m_shape = e.shape.Clone(); + this.m_userData = i(e.userData, null); + this.m_friction = i(e.friction, .2); + this.m_restitution = i(e.restitution, 0); + this.m_filter.Copy(i(e.filter, ts.DEFAULT)); + this.m_isSensor = i(e.isSensor, !1); + this.m_density = i(e.density, 0); + } + get m_proxyCount() { + return this.m_proxies.length; + } + Reset() {} + GetType() { + return this.m_shape.GetType(); + } + GetShape() { + return this.m_shape; + } + SetSensor(t) { + if (t !== this.m_isSensor) { + this.m_body.SetAwake(!0); + this.m_isSensor = t; + } + } + IsSensor() { + return this.m_isSensor; + } + SetFilterData(t) { + this.m_filter.Copy(t); + this.Refilter(); + } + GetFilterData() { + return this.m_filter; + } + Refilter() { + let t = this.m_body.GetContactList(); + for (;t; ) { + const e = t.contact; + const i = e.GetFixtureA(); + const s = e.GetFixtureB(); + i !== this && s !== this || e.FlagForFiltering(); + t = t.next; + } + this.TouchProxies(); + } + GetBody() { + return this.m_body; + } + GetNext() { + return this.m_next; + } + GetUserData() { + return this.m_userData; + } + SetUserData(t) { + this.m_userData = t; + } + TestPoint(t) { + return this.m_shape.TestPoint(this.m_body.GetTransform(), t); + } + ComputeDistance(t, e, i) { + return this.m_shape.ComputeDistance(this.m_body.GetTransform(), t, e, i); + } + RayCast(t, e, i) { + return this.m_shape.RayCast(t, e, this.m_body.GetTransform(), i); + } + GetMassData(t = new qi) { + this.m_shape.ComputeMass(t, this.m_density); + return t; + } + SetDensity(t) { + this.m_density = t; + } + GetDensity() { + return this.m_density; + } + GetFriction() { + return this.m_friction; + } + SetFriction(t) { + this.m_friction = t; + } + GetRestitution() { + return this.m_restitution; + } + SetRestitution(t) { + this.m_restitution = t; + } + GetAABB(t) { + return this.m_proxies[t].aabb; + } + Dump(t, e) { + t(" const fd: b2FixtureDef = new b2FixtureDef();\n"); + t(" fd.friction = %.15f;\n", this.m_friction); + t(" fd.restitution = %.15f;\n", this.m_restitution); + t(" fd.density = %.15f;\n", this.m_density); + t(" fd.isSensor = %s;\n", this.m_isSensor ? "true" : "false"); + t(" fd.filter.categoryBits = %d;\n", this.m_filter.categoryBits); + t(" fd.filter.maskBits = %d;\n", this.m_filter.maskBits); + t(" fd.filter.groupIndex = %d;\n", this.m_filter.groupIndex); + this.m_shape.Dump(t); + t("\n"); + t(" fd.shape = shape;\n"); + t("\n"); + t(" bodies[%d].CreateFixture(fd);\n", e); + } + CreateProxies() { + if (0 !== this.m_proxies.length) throw new Error; + for (let t = 0; t < this.m_shape.GetChildCount(); ++t) this.m_proxies[t] = new is(this, t); + } + DestroyProxies() { + for (const t of this.m_proxies) t.Reset(); + this.m_proxies.length = 0; + } + TouchProxies() { + for (const t of this.m_proxies) t.Touch(); + } + SynchronizeProxies(t, e, i) { + for (const s of this.m_proxies) s.Synchronize(t, e, i); + } + } + !function(t) { + t[t.b2_unknown = -1] = "b2_unknown"; + t[t.b2_staticBody = 0] = "b2_staticBody"; + t[t.b2_kinematicBody = 1] = "b2_kinematicBody"; + t[t.b2_dynamicBody = 2] = "b2_dynamicBody"; + }(t.b2BodyType || (t.b2BodyType = {})); + class ns { + constructor() { + this.type = t.b2BodyType.b2_staticBody; + this.position = new St(0, 0); + this.angle = 0; + this.linearVelocity = new St(0, 0); + this.angularVelocity = 0; + this.linearDamping = 0; + this.angularDamping = 0; + this.allowSleep = !0; + this.awake = !0; + this.fixedRotation = !1; + this.bullet = !1; + this.active = !0; + this.userData = null; + this.gravityScale = 1; + } + } + class rs { + constructor(e, s) { + this.m_type = t.b2BodyType.b2_staticBody; + this.m_islandFlag = !1; + this.m_awakeFlag = !1; + this.m_autoSleepFlag = !1; + this.m_bulletFlag = !1; + this.m_fixedRotationFlag = !1; + this.m_activeFlag = !1; + this.m_toiFlag = !1; + this.m_islandIndex = 0; + this.m_xf = new xt; + this.m_xf0 = new xt; + this.m_sweep = new wt; + this.m_linearVelocity = new St; + this.m_angularVelocity = 0; + this.m_force = new St; + this.m_torque = 0; + this.m_prev = null; + this.m_next = null; + this.m_fixtureList = null; + this.m_fixtureCount = 0; + this.m_jointList = null; + this.m_contactList = null; + this.m_mass = 1; + this.m_invMass = 1; + this.m_I = 0; + this.m_invI = 0; + this.m_linearDamping = 0; + this.m_angularDamping = 0; + this.m_gravityScale = 1; + this.m_sleepTime = 0; + this.m_userData = null; + this.m_controllerList = null; + this.m_controllerCount = 0; + this.m_bulletFlag = i(e.bullet, !1); + this.m_fixedRotationFlag = i(e.fixedRotation, !1); + this.m_autoSleepFlag = i(e.allowSleep, !0); + this.m_awakeFlag = i(e.awake, !0); + this.m_activeFlag = i(e.active, !0); + this.m_world = s; + this.m_xf.p.Copy(i(e.position, St.ZERO)); + this.m_xf.q.SetAngle(i(e.angle, 0)); + this.m_xf0.Copy(this.m_xf); + this.m_sweep.localCenter.SetZero(); + this.m_sweep.c0.Copy(this.m_xf.p); + this.m_sweep.c.Copy(this.m_xf.p); + this.m_sweep.a0 = this.m_sweep.a = this.m_xf.q.GetAngle(); + this.m_sweep.alpha0 = 0; + this.m_linearVelocity.Copy(i(e.linearVelocity, St.ZERO)); + this.m_angularVelocity = i(e.angularVelocity, 0); + this.m_linearDamping = i(e.linearDamping, 0); + this.m_angularDamping = i(e.angularDamping, 0); + this.m_gravityScale = i(e.gravityScale, 1); + this.m_force.SetZero(); + this.m_torque = 0; + this.m_sleepTime = 0; + this.m_type = i(e.type, t.b2BodyType.b2_staticBody); + if (e.type === t.b2BodyType.b2_dynamicBody) { + this.m_mass = 1; + this.m_invMass = 1; + } else { + this.m_mass = 0; + this.m_invMass = 0; + } + this.m_I = 0; + this.m_invI = 0; + this.m_userData = e.userData; + this.m_fixtureList = null; + this.m_fixtureCount = 0; + this.m_controllerList = null; + this.m_controllerCount = 0; + } + CreateFixture(t, e = 0) { + return t instanceof Ki ? this.CreateFixtureShapeDensity(t, e) : this.CreateFixtureDef(t); + } + CreateFixtureDef(t) { + if (this.m_world.IsLocked()) throw new Error; + const e = new ss(this, t); + this.m_activeFlag && e.CreateProxies(); + e.m_next = this.m_fixtureList; + this.m_fixtureList = e; + ++this.m_fixtureCount; + e.m_density > 0 && this.ResetMassData(); + this.m_world.m_newFixture = !0; + return e; + } + CreateFixtureShapeDensity(t, e = 0) { + const i = rs.CreateFixtureShapeDensity_s_def; + i.shape = t; + i.density = e; + return this.CreateFixtureDef(i); + } + DestroyFixture(t) { + if (this.m_world.IsLocked()) throw new Error; + let e = this.m_fixtureList; + let i = null; + for (;null !== e; ) { + if (e === t) { + i ? i.m_next = t.m_next : this.m_fixtureList = t.m_next; + break; + } + i = e; + e = e.m_next; + } + let s = this.m_contactList; + for (;s; ) { + const e = s.contact; + s = s.next; + const i = e.GetFixtureA(); + const n = e.GetFixtureB(); + t !== i && t !== n || this.m_world.m_contactManager.Destroy(e); + } + this.m_activeFlag && t.DestroyProxies(); + t.m_next = null; + t.Reset(); + --this.m_fixtureCount; + this.ResetMassData(); + } + SetTransformVec(t, e) { + this.SetTransformXY(t.x, t.y, e); + } + SetTransformXY(t, e, i) { + if (this.m_world.IsLocked()) throw new Error; + this.m_xf.q.SetAngle(i); + this.m_xf.p.Set(t, e); + this.m_xf0.Copy(this.m_xf); + xt.MulXV(this.m_xf, this.m_sweep.localCenter, this.m_sweep.c); + this.m_sweep.a = i; + this.m_sweep.c0.Copy(this.m_sweep.c); + this.m_sweep.a0 = i; + for (let t = this.m_fixtureList; t; t = t.m_next) t.SynchronizeProxies(this.m_xf, this.m_xf, St.ZERO); + this.m_world.m_contactManager.FindNewContacts(); + } + SetTransform(t) { + this.SetTransformVec(t.p, t.GetAngle()); + } + GetTransform() { + return this.m_xf; + } + GetPosition() { + return this.m_xf.p; + } + SetPosition(t) { + this.SetTransformVec(t, this.GetAngle()); + } + SetPositionXY(t, e) { + this.SetTransformXY(t, e, this.GetAngle()); + } + GetAngle() { + return this.m_sweep.a; + } + SetAngle(t) { + this.SetTransformVec(this.GetPosition(), t); + } + GetWorldCenter() { + return this.m_sweep.c; + } + GetLocalCenter() { + return this.m_sweep.localCenter; + } + SetLinearVelocity(e) { + if (this.m_type !== t.b2BodyType.b2_staticBody) { + St.DotVV(e, e) > 0 && this.SetAwake(!0); + this.m_linearVelocity.Copy(e); + } + } + GetLinearVelocity() { + return this.m_linearVelocity; + } + SetAngularVelocity(e) { + if (this.m_type !== t.b2BodyType.b2_staticBody) { + e * e > 0 && this.SetAwake(!0); + this.m_angularVelocity = e; + } + } + GetAngularVelocity() { + return this.m_angularVelocity; + } + GetDefinition(t) { + t.type = this.GetType(); + t.allowSleep = this.m_autoSleepFlag; + t.angle = this.GetAngle(); + t.angularDamping = this.m_angularDamping; + t.gravityScale = this.m_gravityScale; + t.angularVelocity = this.m_angularVelocity; + t.fixedRotation = this.m_fixedRotationFlag; + t.bullet = this.m_bulletFlag; + t.awake = this.m_awakeFlag; + t.linearDamping = this.m_linearDamping; + t.linearVelocity.Copy(this.GetLinearVelocity()); + t.position.Copy(this.GetPosition()); + t.userData = this.GetUserData(); + return t; + } + ApplyForce(e, i, s = !0) { + if (this.m_type === t.b2BodyType.b2_dynamicBody) { + s && !this.m_awakeFlag && this.SetAwake(!0); + if (this.m_awakeFlag) { + this.m_force.x += e.x; + this.m_force.y += e.y; + this.m_torque += (i.x - this.m_sweep.c.x) * e.y - (i.y - this.m_sweep.c.y) * e.x; + } + } + } + ApplyForceToCenter(e, i = !0) { + if (this.m_type === t.b2BodyType.b2_dynamicBody) { + i && !this.m_awakeFlag && this.SetAwake(!0); + if (this.m_awakeFlag) { + this.m_force.x += e.x; + this.m_force.y += e.y; + } + } + } + ApplyTorque(e, i = !0) { + if (this.m_type === t.b2BodyType.b2_dynamicBody) { + i && !this.m_awakeFlag && this.SetAwake(!0); + this.m_awakeFlag && (this.m_torque += e); + } + } + ApplyLinearImpulse(e, i, s = !0) { + if (this.m_type === t.b2BodyType.b2_dynamicBody) { + s && !this.m_awakeFlag && this.SetAwake(!0); + if (this.m_awakeFlag) { + this.m_linearVelocity.x += this.m_invMass * e.x; + this.m_linearVelocity.y += this.m_invMass * e.y; + this.m_angularVelocity += this.m_invI * ((i.x - this.m_sweep.c.x) * e.y - (i.y - this.m_sweep.c.y) * e.x); + } + } + } + ApplyLinearImpulseToCenter(e, i = !0) { + if (this.m_type === t.b2BodyType.b2_dynamicBody) { + i && !this.m_awakeFlag && this.SetAwake(!0); + if (this.m_awakeFlag) { + this.m_linearVelocity.x += this.m_invMass * e.x; + this.m_linearVelocity.y += this.m_invMass * e.y; + } + } + } + ApplyAngularImpulse(e, i = !0) { + if (this.m_type === t.b2BodyType.b2_dynamicBody) { + i && !this.m_awakeFlag && this.SetAwake(!0); + this.m_awakeFlag && (this.m_angularVelocity += this.m_invI * e); + } + } + GetMass() { + return this.m_mass; + } + GetInertia() { + return this.m_I + this.m_mass * St.DotVV(this.m_sweep.localCenter, this.m_sweep.localCenter); + } + GetMassData(t) { + t.mass = this.m_mass; + t.I = this.m_I + this.m_mass * St.DotVV(this.m_sweep.localCenter, this.m_sweep.localCenter); + t.center.Copy(this.m_sweep.localCenter); + return t; + } + SetMassData(e) { + if (this.m_world.IsLocked()) throw new Error; + if (this.m_type !== t.b2BodyType.b2_dynamicBody) return; + this.m_invMass = 0; + this.m_I = 0; + this.m_invI = 0; + this.m_mass = e.mass; + this.m_mass <= 0 && (this.m_mass = 1); + this.m_invMass = 1 / this.m_mass; + if (e.I > 0 && !this.m_fixedRotationFlag) { + this.m_I = e.I - this.m_mass * St.DotVV(e.center, e.center); + this.m_invI = 1 / this.m_I; + } + const i = rs.SetMassData_s_oldCenter.Copy(this.m_sweep.c); + this.m_sweep.localCenter.Copy(e.center); + xt.MulXV(this.m_xf, this.m_sweep.localCenter, this.m_sweep.c); + this.m_sweep.c0.Copy(this.m_sweep.c); + St.AddVCrossSV(this.m_linearVelocity, this.m_angularVelocity, St.SubVV(this.m_sweep.c, i, St.s_t0), this.m_linearVelocity); + } + ResetMassData() { + this.m_mass = 0; + this.m_invMass = 0; + this.m_I = 0; + this.m_invI = 0; + this.m_sweep.localCenter.SetZero(); + if (this.m_type === t.b2BodyType.b2_staticBody || this.m_type === t.b2BodyType.b2_kinematicBody) { + this.m_sweep.c0.Copy(this.m_xf.p); + this.m_sweep.c.Copy(this.m_xf.p); + this.m_sweep.a0 = this.m_sweep.a; + return; + } + const e = rs.ResetMassData_s_localCenter.SetZero(); + for (let t = this.m_fixtureList; t; t = t.m_next) { + if (0 === t.m_density) continue; + const i = t.GetMassData(rs.ResetMassData_s_massData); + this.m_mass += i.mass; + e.x += i.center.x * i.mass; + e.y += i.center.y * i.mass; + this.m_I += i.I; + } + if (this.m_mass > 0) { + this.m_invMass = 1 / this.m_mass; + e.x *= this.m_invMass; + e.y *= this.m_invMass; + } else { + this.m_mass = 1; + this.m_invMass = 1; + } + if (this.m_I > 0 && !this.m_fixedRotationFlag) { + this.m_I -= this.m_mass * St.DotVV(e, e); + this.m_invI = 1 / this.m_I; + } else { + this.m_I = 0; + this.m_invI = 0; + } + const i = rs.ResetMassData_s_oldCenter.Copy(this.m_sweep.c); + this.m_sweep.localCenter.Copy(e); + xt.MulXV(this.m_xf, this.m_sweep.localCenter, this.m_sweep.c); + this.m_sweep.c0.Copy(this.m_sweep.c); + St.AddVCrossSV(this.m_linearVelocity, this.m_angularVelocity, St.SubVV(this.m_sweep.c, i, St.s_t0), this.m_linearVelocity); + } + GetWorldPoint(t, e) { + return xt.MulXV(this.m_xf, t, e); + } + GetWorldVector(t, e) { + return Ct.MulRV(this.m_xf.q, t, e); + } + GetLocalPoint(t, e) { + return xt.MulTXV(this.m_xf, t, e); + } + GetLocalVector(t, e) { + return Ct.MulTRV(this.m_xf.q, t, e); + } + GetLinearVelocityFromWorldPoint(t, e) { + return St.AddVCrossSV(this.m_linearVelocity, this.m_angularVelocity, St.SubVV(t, this.m_sweep.c, St.s_t0), e); + } + GetLinearVelocityFromLocalPoint(t, e) { + return this.GetLinearVelocityFromWorldPoint(this.GetWorldPoint(t, e), e); + } + GetLinearDamping() { + return this.m_linearDamping; + } + SetLinearDamping(t) { + this.m_linearDamping = t; + } + GetAngularDamping() { + return this.m_angularDamping; + } + SetAngularDamping(t) { + this.m_angularDamping = t; + } + GetGravityScale() { + return this.m_gravityScale; + } + SetGravityScale(t) { + this.m_gravityScale = t; + } + SetType(e) { + if (this.m_world.IsLocked()) throw new Error; + if (this.m_type === e) return; + this.m_type = e; + this.ResetMassData(); + if (this.m_type === t.b2BodyType.b2_staticBody) { + this.m_linearVelocity.SetZero(); + this.m_angularVelocity = 0; + this.m_sweep.a0 = this.m_sweep.a; + this.m_sweep.c0.Copy(this.m_sweep.c); + this.SynchronizeFixtures(); + } + this.SetAwake(!0); + this.m_force.SetZero(); + this.m_torque = 0; + let i = this.m_contactList; + for (;i; ) { + const t = i; + i = i.next; + this.m_world.m_contactManager.Destroy(t.contact); + } + this.m_contactList = null; + for (let t = this.m_fixtureList; t; t = t.m_next) t.TouchProxies(); + } + GetType() { + return this.m_type; + } + SetBullet(t) { + this.m_bulletFlag = t; + } + IsBullet() { + return this.m_bulletFlag; + } + SetSleepingAllowed(t) { + this.m_autoSleepFlag = t; + t || this.SetAwake(!0); + } + IsSleepingAllowed() { + return this.m_autoSleepFlag; + } + SetAwake(t) { + if (t) { + this.m_awakeFlag = !0; + this.m_sleepTime = 0; + } else { + this.m_awakeFlag = !1; + this.m_sleepTime = 0; + this.m_linearVelocity.SetZero(); + this.m_angularVelocity = 0; + this.m_force.SetZero(); + this.m_torque = 0; + } + } + IsAwake() { + return this.m_awakeFlag; + } + SetActive(t) { + if (this.m_world.IsLocked()) throw new Error; + if (t !== this.IsActive()) { + this.m_activeFlag = t; + if (t) for (let t = this.m_fixtureList; t; t = t.m_next) t.CreateProxies(); else { + for (let t = this.m_fixtureList; t; t = t.m_next) t.DestroyProxies(); + let t = this.m_contactList; + for (;t; ) { + const e = t; + t = t.next; + this.m_world.m_contactManager.Destroy(e.contact); + } + this.m_contactList = null; + } + } + } + IsActive() { + return this.m_activeFlag; + } + SetFixedRotation(t) { + if (this.m_fixedRotationFlag !== t) { + this.m_fixedRotationFlag = t; + this.m_angularVelocity = 0; + this.ResetMassData(); + } + } + IsFixedRotation() { + return this.m_fixedRotationFlag; + } + GetFixtureList() { + return this.m_fixtureList; + } + GetJointList() { + return this.m_jointList; + } + GetContactList() { + return this.m_contactList; + } + GetNext() { + return this.m_next; + } + GetUserData() { + return this.m_userData; + } + SetUserData(t) { + this.m_userData = t; + } + GetWorld() { + return this.m_world; + } + Dump(e) { + const i = this.m_islandIndex; + e("{\n"); + e(" const bd: b2BodyDef = new b2BodyDef();\n"); + let s = ""; + switch (this.m_type) { + case t.b2BodyType.b2_staticBody: + s = "b2BodyType.b2_staticBody"; + break; + + case t.b2BodyType.b2_kinematicBody: + s = "b2BodyType.b2_kinematicBody"; + break; + + case t.b2BodyType.b2_dynamicBody: + s = "b2BodyType.b2_dynamicBody"; + } + e(" bd.type = %s;\n", s); + e(" bd.position.Set(%.15f, %.15f);\n", this.m_xf.p.x, this.m_xf.p.y); + e(" bd.angle = %.15f;\n", this.m_sweep.a); + e(" bd.linearVelocity.Set(%.15f, %.15f);\n", this.m_linearVelocity.x, this.m_linearVelocity.y); + e(" bd.angularVelocity = %.15f;\n", this.m_angularVelocity); + e(" bd.linearDamping = %.15f;\n", this.m_linearDamping); + e(" bd.angularDamping = %.15f;\n", this.m_angularDamping); + e(" bd.allowSleep = %s;\n", this.m_autoSleepFlag ? "true" : "false"); + e(" bd.awake = %s;\n", this.m_awakeFlag ? "true" : "false"); + e(" bd.fixedRotation = %s;\n", this.m_fixedRotationFlag ? "true" : "false"); + e(" bd.bullet = %s;\n", this.m_bulletFlag ? "true" : "false"); + e(" bd.active = %s;\n", this.m_activeFlag ? "true" : "false"); + e(" bd.gravityScale = %.15f;\n", this.m_gravityScale); + e("\n"); + e(" bodies[%d] = this.m_world.CreateBody(bd);\n", this.m_islandIndex); + e("\n"); + for (let t = this.m_fixtureList; t; t = t.m_next) { + e(" {\n"); + t.Dump(e, i); + e(" }\n"); + } + e("}\n"); + } + SynchronizeFixtures() { + const t = rs.SynchronizeFixtures_s_xf1; + t.q.SetAngle(this.m_sweep.a0); + Ct.MulRV(t.q, this.m_sweep.localCenter, t.p); + St.SubVV(this.m_sweep.c0, t.p, t.p); + const e = St.SubVV(this.m_sweep.c, this.m_sweep.c0, rs.SynchronizeFixtures_s_displacement); + for (let i = this.m_fixtureList; i; i = i.m_next) i.SynchronizeProxies(t, this.m_xf, e); + } + SynchronizeTransform() { + this.m_xf.q.SetAngle(this.m_sweep.a); + Ct.MulRV(this.m_xf.q, this.m_sweep.localCenter, this.m_xf.p); + St.SubVV(this.m_sweep.c, this.m_xf.p, this.m_xf.p); + } + ShouldCollide(e) { + return (this.m_type !== t.b2BodyType.b2_staticBody || e.m_type !== t.b2BodyType.b2_staticBody) && this.ShouldCollideConnected(e); + } + ShouldCollideConnected(t) { + for (let e = this.m_jointList; e; e = e.next) if (e.other === t && !e.joint.m_collideConnected) return !1; + return !0; + } + Advance(t) { + this.m_sweep.Advance(t); + this.m_sweep.c.Copy(this.m_sweep.c0); + this.m_sweep.a = this.m_sweep.a0; + this.m_xf.q.SetAngle(this.m_sweep.a); + Ct.MulRV(this.m_xf.q, this.m_sweep.localCenter, this.m_xf.p); + St.SubVV(this.m_sweep.c, this.m_xf.p, this.m_xf.p); + } + GetControllerList() { + return this.m_controllerList; + } + GetControllerCount() { + return this.m_controllerCount; + } + } + rs.CreateFixtureShapeDensity_s_def = new es; + rs.SetMassData_s_oldCenter = new St; + rs.ResetMassData_s_localCenter = new St; + rs.ResetMassData_s_oldCenter = new St; + rs.ResetMassData_s_massData = new qi; + rs.SynchronizeFixtures_s_xf1 = new xt; + rs.SynchronizeFixtures_s_displacement = new St; + !function(t) { + t[t.e_unknownJoint = 0] = "e_unknownJoint"; + t[t.e_revoluteJoint = 1] = "e_revoluteJoint"; + t[t.e_prismaticJoint = 2] = "e_prismaticJoint"; + t[t.e_distanceJoint = 3] = "e_distanceJoint"; + t[t.e_pulleyJoint = 4] = "e_pulleyJoint"; + t[t.e_mouseJoint = 5] = "e_mouseJoint"; + t[t.e_gearJoint = 6] = "e_gearJoint"; + t[t.e_wheelJoint = 7] = "e_wheelJoint"; + t[t.e_weldJoint = 8] = "e_weldJoint"; + t[t.e_frictionJoint = 9] = "e_frictionJoint"; + t[t.e_ropeJoint = 10] = "e_ropeJoint"; + t[t.e_motorJoint = 11] = "e_motorJoint"; + t[t.e_areaJoint = 12] = "e_areaJoint"; + }(t.b2JointType || (t.b2JointType = {})); + !function(t) { + t[t.e_inactiveLimit = 0] = "e_inactiveLimit"; + t[t.e_atLowerLimit = 1] = "e_atLowerLimit"; + t[t.e_atUpperLimit = 2] = "e_atUpperLimit"; + t[t.e_equalLimits = 3] = "e_equalLimits"; + }(t.b2LimitState || (t.b2LimitState = {})); + class os { + constructor() { + this.linear = new St; + this.angularA = 0; + this.angularB = 0; + } + SetZero() { + this.linear.SetZero(); + this.angularA = 0; + this.angularB = 0; + return this; + } + Set(t, e, i) { + this.linear.Copy(t); + this.angularA = e; + this.angularB = i; + return this; + } + } + class as { + constructor(t) { + this._other = null; + this.prev = null; + this.next = null; + this.joint = t; + } + get other() { + if (null === this._other) throw new Error; + return this._other; + } + set other(t) { + if (null !== this._other) throw new Error; + this._other = t; + } + Reset() { + this._other = null; + this.prev = null; + this.next = null; + } + } + class ls { + constructor(e) { + this.type = t.b2JointType.e_unknownJoint; + this.userData = null; + this.collideConnected = !1; + this.type = e; + } + } + class hs { + constructor(e) { + this.m_type = t.b2JointType.e_unknownJoint; + this.m_prev = null; + this.m_next = null; + this.m_edgeA = new as(this); + this.m_edgeB = new as(this); + this.m_index = 0; + this.m_islandFlag = !1; + this.m_collideConnected = !1; + this.m_userData = null; + this.m_type = e.type; + this.m_edgeA.other = e.bodyB; + this.m_edgeB.other = e.bodyA; + this.m_bodyA = e.bodyA; + this.m_bodyB = e.bodyB; + this.m_collideConnected = i(e.collideConnected, !1); + this.m_userData = i(e.userData, null); + } + GetType() { + return this.m_type; + } + GetBodyA() { + return this.m_bodyA; + } + GetBodyB() { + return this.m_bodyB; + } + GetNext() { + return this.m_next; + } + GetUserData() { + return this.m_userData; + } + SetUserData(t) { + this.m_userData = t; + } + IsActive() { + return this.m_bodyA.IsActive() && this.m_bodyB.IsActive(); + } + GetCollideConnected() { + return this.m_collideConnected; + } + Dump(t) { + t("// Dump is not supported for this joint type.\n"); + } + ShiftOrigin(t) {} + } + class cs extends ls { + constructor() { + super(t.b2JointType.e_distanceJoint); + this.localAnchorA = new St; + this.localAnchorB = new St; + this.length = 1; + this.frequencyHz = 0; + this.dampingRatio = 0; + } + Initialize(t, e, i, s) { + this.bodyA = t; + this.bodyB = e; + this.bodyA.GetLocalPoint(i, this.localAnchorA); + this.bodyB.GetLocalPoint(s, this.localAnchorB); + this.length = St.DistanceVV(i, s); + this.frequencyHz = 0; + this.dampingRatio = 0; + } + } + class us extends hs { + constructor(t) { + super(t); + this.m_frequencyHz = 0; + this.m_dampingRatio = 0; + this.m_bias = 0; + this.m_localAnchorA = new St; + this.m_localAnchorB = new St; + this.m_gamma = 0; + this.m_impulse = 0; + this.m_length = 0; + this.m_indexA = 0; + this.m_indexB = 0; + this.m_u = new St; + this.m_rA = new St; + this.m_rB = new St; + this.m_localCenterA = new St; + this.m_localCenterB = new St; + this.m_invMassA = 0; + this.m_invMassB = 0; + this.m_invIA = 0; + this.m_invIB = 0; + this.m_mass = 0; + this.m_qA = new Ct; + this.m_qB = new Ct; + this.m_lalcA = new St; + this.m_lalcB = new St; + this.m_frequencyHz = i(t.frequencyHz, 0); + this.m_dampingRatio = i(t.dampingRatio, 0); + this.m_localAnchorA.Copy(t.localAnchorA); + this.m_localAnchorB.Copy(t.localAnchorB); + this.m_length = t.length; + } + GetAnchorA(t) { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, t); + } + GetAnchorB(t) { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, t); + } + GetReactionForce(t, e) { + e.x = t * this.m_impulse * this.m_u.x; + e.y = t * this.m_impulse * this.m_u.y; + return e; + } + GetReactionTorque(t) { + return 0; + } + GetLocalAnchorA() { + return this.m_localAnchorA; + } + GetLocalAnchorB() { + return this.m_localAnchorB; + } + SetLength(t) { + this.m_length = t; + } + Length() { + return this.m_length; + } + SetFrequency(t) { + this.m_frequencyHz = t; + } + GetFrequency() { + return this.m_frequencyHz; + } + SetDampingRatio(t) { + this.m_dampingRatio = t; + } + GetDampingRatio() { + return this.m_dampingRatio; + } + Dump(t) { + const e = this.m_bodyA.m_islandIndex; + const i = this.m_bodyB.m_islandIndex; + t(" const jd: b2DistanceJointDef = new b2DistanceJointDef();\n"); + t(" jd.bodyA = bodies[%d];\n", e); + t(" jd.bodyB = bodies[%d];\n", i); + t(" jd.collideConnected = %s;\n", this.m_collideConnected ? "true" : "false"); + t(" jd.localAnchorA.Set(%.15f, %.15f);\n", this.m_localAnchorA.x, this.m_localAnchorA.y); + t(" jd.localAnchorB.Set(%.15f, %.15f);\n", this.m_localAnchorB.x, this.m_localAnchorB.y); + t(" jd.length = %.15f;\n", this.m_length); + t(" jd.frequencyHz = %.15f;\n", this.m_frequencyHz); + t(" jd.dampingRatio = %.15f;\n", this.m_dampingRatio); + t(" joints[%d] = this.m_world.CreateJoint(jd);\n", this.m_index); + } + InitVelocityConstraints(t) { + this.m_indexA = this.m_bodyA.m_islandIndex; + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter); + this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_invMassA = this.m_bodyA.m_invMass; + this.m_invMassB = this.m_bodyB.m_invMass; + this.m_invIA = this.m_bodyA.m_invI; + this.m_invIB = this.m_bodyB.m_invI; + const e = t.positions[this.m_indexA].c; + const i = t.positions[this.m_indexA].a; + const s = t.velocities[this.m_indexA].v; + let n = t.velocities[this.m_indexA].w; + const r = t.positions[this.m_indexB].c; + const a = t.positions[this.m_indexB].a; + const l = t.velocities[this.m_indexB].v; + let h = t.velocities[this.m_indexB].w; + const c = this.m_qA.SetAngle(i), _ = this.m_qB.SetAngle(a); + St.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + Ct.MulRV(c, this.m_lalcA, this.m_rA); + St.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + Ct.MulRV(_, this.m_lalcB, this.m_rB); + this.m_u.x = r.x + this.m_rB.x - e.x - this.m_rA.x; + this.m_u.y = r.y + this.m_rB.y - e.y - this.m_rA.y; + const d = this.m_u.Length(); + d > u ? this.m_u.SelfMul(1 / d) : this.m_u.SetZero(); + const p = St.CrossVV(this.m_rA, this.m_u); + const m = St.CrossVV(this.m_rB, this.m_u); + let f = this.m_invMassA + this.m_invIA * p * p + this.m_invMassB + this.m_invIB * m * m; + this.m_mass = 0 !== f ? 1 / f : 0; + if (this.m_frequencyHz > 0) { + const e = d - this.m_length; + const i = 2 * o * this.m_frequencyHz; + const s = 2 * this.m_mass * this.m_dampingRatio * i; + const n = this.m_mass * i * i; + const r = t.step.dt; + this.m_gamma = r * (s + r * n); + this.m_gamma = 0 !== this.m_gamma ? 1 / this.m_gamma : 0; + this.m_bias = e * r * n * this.m_gamma; + f += this.m_gamma; + this.m_mass = 0 !== f ? 1 / f : 0; + } else { + this.m_gamma = 0; + this.m_bias = 0; + } + if (t.step.warmStarting) { + this.m_impulse *= t.step.dtRatio; + const e = St.MulSV(this.m_impulse, this.m_u, us.InitVelocityConstraints_s_P); + s.SelfMulSub(this.m_invMassA, e); + n -= this.m_invIA * St.CrossVV(this.m_rA, e); + l.SelfMulAdd(this.m_invMassB, e); + h += this.m_invIB * St.CrossVV(this.m_rB, e); + } else this.m_impulse = 0; + t.velocities[this.m_indexA].w = n; + t.velocities[this.m_indexB].w = h; + } + SolveVelocityConstraints(t) { + const e = t.velocities[this.m_indexA].v; + let i = t.velocities[this.m_indexA].w; + const s = t.velocities[this.m_indexB].v; + let n = t.velocities[this.m_indexB].w; + const r = St.AddVCrossSV(e, i, this.m_rA, us.SolveVelocityConstraints_s_vpA); + const o = St.AddVCrossSV(s, n, this.m_rB, us.SolveVelocityConstraints_s_vpB); + const a = St.DotVV(this.m_u, St.SubVV(o, r, St.s_t0)); + const l = -this.m_mass * (a + this.m_bias + this.m_gamma * this.m_impulse); + this.m_impulse += l; + const h = St.MulSV(l, this.m_u, us.SolveVelocityConstraints_s_P); + e.SelfMulSub(this.m_invMassA, h); + i -= this.m_invIA * St.CrossVV(this.m_rA, h); + s.SelfMulAdd(this.m_invMassB, h); + n += this.m_invIB * St.CrossVV(this.m_rB, h); + t.velocities[this.m_indexA].w = i; + t.velocities[this.m_indexB].w = n; + } + SolvePositionConstraints(t) { + if (this.m_frequencyHz > 0) return !0; + const e = t.positions[this.m_indexA].c; + let i = t.positions[this.m_indexA].a; + const s = t.positions[this.m_indexB].c; + let n = t.positions[this.m_indexB].a; + const r = this.m_qA.SetAngle(i), o = this.m_qB.SetAngle(n); + const a = Ct.MulRV(r, this.m_lalcA, this.m_rA); + const l = Ct.MulRV(o, this.m_lalcB, this.m_rB); + const h = this.m_u; + h.x = s.x + l.x - e.x - a.x; + h.y = s.y + l.y - e.y - a.y; + let c = this.m_u.Normalize() - this.m_length; + c = it(c, -g, g); + const _ = -this.m_mass * c; + const d = St.MulSV(_, h, us.SolvePositionConstraints_s_P); + e.SelfMulSub(this.m_invMassA, d); + i -= this.m_invIA * St.CrossVV(a, d); + s.SelfMulAdd(this.m_invMassB, d); + n += this.m_invIB * St.CrossVV(l, d); + t.positions[this.m_indexA].a = i; + t.positions[this.m_indexB].a = n; + return $(c) < u; + } + } + us.InitVelocityConstraints_s_P = new St; + us.SolveVelocityConstraints_s_vpA = new St; + us.SolveVelocityConstraints_s_vpB = new St; + us.SolveVelocityConstraints_s_P = new St; + us.SolvePositionConstraints_s_P = new St; + class _s extends ls { + constructor() { + super(t.b2JointType.e_areaJoint); + this.bodies = []; + this.frequencyHz = 0; + this.dampingRatio = 0; + } + AddBody(t) { + this.bodies.push(t); + 1 === this.bodies.length ? this.bodyA = t : 2 === this.bodies.length && (this.bodyB = t); + } + } + class ds extends hs { + constructor(t) { + super(t); + this.m_frequencyHz = 0; + this.m_dampingRatio = 0; + this.m_impulse = 0; + this.m_targetArea = 0; + this.m_delta = new St; + this.m_bodies = t.bodies; + this.m_frequencyHz = i(t.frequencyHz, 0); + this.m_dampingRatio = i(t.dampingRatio, 0); + this.m_targetLengths = K(t.bodies.length); + this.m_normals = St.MakeArray(t.bodies.length); + this.m_joints = []; + this.m_deltas = St.MakeArray(t.bodies.length); + const e = new cs; + e.frequencyHz = this.m_frequencyHz; + e.dampingRatio = this.m_dampingRatio; + this.m_targetArea = 0; + for (let t = 0; t < this.m_bodies.length; ++t) { + const i = this.m_bodies[t]; + const s = this.m_bodies[(t + 1) % this.m_bodies.length]; + const n = i.GetWorldCenter(); + const r = s.GetWorldCenter(); + this.m_targetLengths[t] = St.DistanceVV(n, r); + this.m_targetArea += St.CrossVV(n, r); + e.Initialize(i, s, n, r); + this.m_joints[t] = i.GetWorld().CreateJoint(e); + } + this.m_targetArea *= .5; + } + GetAnchorA(t) { + return t; + } + GetAnchorB(t) { + return t; + } + GetReactionForce(t, e) { + return e; + } + GetReactionTorque(t) { + return 0; + } + SetFrequency(t) { + this.m_frequencyHz = t; + for (let e = 0; e < this.m_joints.length; ++e) this.m_joints[e].SetFrequency(t); + } + GetFrequency() { + return this.m_frequencyHz; + } + SetDampingRatio(t) { + this.m_dampingRatio = t; + for (let e = 0; e < this.m_joints.length; ++e) this.m_joints[e].SetDampingRatio(t); + } + GetDampingRatio() { + return this.m_dampingRatio; + } + Dump(t) { + t("Area joint dumping is not supported.\n"); + } + InitVelocityConstraints(t) { + for (let e = 0; e < this.m_bodies.length; ++e) { + const i = this.m_bodies[(e + this.m_bodies.length - 1) % this.m_bodies.length]; + const s = this.m_bodies[(e + 1) % this.m_bodies.length]; + const n = t.positions[i.m_islandIndex].c; + const r = t.positions[s.m_islandIndex].c; + const o = this.m_deltas[e]; + St.SubVV(r, n, o); + } + if (t.step.warmStarting) { + this.m_impulse *= t.step.dtRatio; + for (let e = 0; e < this.m_bodies.length; ++e) { + const i = this.m_bodies[e]; + const s = t.velocities[i.m_islandIndex].v; + const n = this.m_deltas[e]; + s.x += i.m_invMass * n.y * .5 * this.m_impulse; + s.y += i.m_invMass * -n.x * .5 * this.m_impulse; + } + } else this.m_impulse = 0; + } + SolveVelocityConstraints(t) { + let e = 0; + let i = 0; + for (let s = 0; s < this.m_bodies.length; ++s) { + const n = this.m_bodies[s]; + const r = t.velocities[n.m_islandIndex].v; + const o = this.m_deltas[s]; + e += o.LengthSquared() / n.GetMass(); + i += St.CrossVV(r, o); + } + const s = -2 * i / e; + this.m_impulse += s; + for (let e = 0; e < this.m_bodies.length; ++e) { + const i = this.m_bodies[e]; + const n = t.velocities[i.m_islandIndex].v; + const r = this.m_deltas[e]; + n.x += i.m_invMass * r.y * .5 * s; + n.y += i.m_invMass * -r.x * .5 * s; + } + } + SolvePositionConstraints(t) { + let e = 0; + let i = 0; + for (let s = 0; s < this.m_bodies.length; ++s) { + const r = this.m_bodies[s]; + const o = this.m_bodies[(s + 1) % this.m_bodies.length]; + const a = t.positions[r.m_islandIndex].c; + const l = t.positions[o.m_islandIndex].c; + const h = St.SubVV(l, a, this.m_delta); + let c = h.Length(); + c < n && (c = 1); + this.m_normals[s].x = h.y / c; + this.m_normals[s].y = -h.x / c; + e += c; + i += St.CrossVV(a, l); + } + i *= .5; + const s = .5 * (this.m_targetArea - i) / e; + let r = !0; + for (let e = 0; e < this.m_bodies.length; ++e) { + const i = this.m_bodies[e]; + const n = t.positions[i.m_islandIndex].c; + const o = (e + 1) % this.m_bodies.length; + const a = St.AddVV(this.m_normals[e], this.m_normals[o], this.m_delta); + a.SelfMul(s); + const l = a.LengthSquared(); + l > rt(g) && a.SelfMul(g / at(l)); + l > rt(u) && (r = !1); + n.x += a.x; + n.y += a.y; + } + return r; + } + } + class ps extends ls { + constructor() { + super(t.b2JointType.e_frictionJoint); + this.localAnchorA = new St; + this.localAnchorB = new St; + this.maxForce = 0; + this.maxTorque = 0; + } + Initialize(t, e, i) { + this.bodyA = t; + this.bodyB = e; + this.bodyA.GetLocalPoint(i, this.localAnchorA); + this.bodyB.GetLocalPoint(i, this.localAnchorB); + } + } + class ms extends hs { + constructor(t) { + super(t); + this.m_localAnchorA = new St; + this.m_localAnchorB = new St; + this.m_linearImpulse = new St; + this.m_angularImpulse = 0; + this.m_maxForce = 0; + this.m_maxTorque = 0; + this.m_indexA = 0; + this.m_indexB = 0; + this.m_rA = new St; + this.m_rB = new St; + this.m_localCenterA = new St; + this.m_localCenterB = new St; + this.m_invMassA = 0; + this.m_invMassB = 0; + this.m_invIA = 0; + this.m_invIB = 0; + this.m_linearMass = new vt; + this.m_angularMass = 0; + this.m_qA = new Ct; + this.m_qB = new Ct; + this.m_lalcA = new St; + this.m_lalcB = new St; + this.m_K = new vt; + this.m_localAnchorA.Copy(t.localAnchorA); + this.m_localAnchorB.Copy(t.localAnchorB); + this.m_linearImpulse.SetZero(); + this.m_maxForce = i(t.maxForce, 0); + this.m_maxTorque = i(t.maxTorque, 0); + this.m_linearMass.SetZero(); + } + InitVelocityConstraints(t) { + this.m_indexA = this.m_bodyA.m_islandIndex; + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter); + this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_invMassA = this.m_bodyA.m_invMass; + this.m_invMassB = this.m_bodyB.m_invMass; + this.m_invIA = this.m_bodyA.m_invI; + this.m_invIB = this.m_bodyB.m_invI; + const e = t.positions[this.m_indexA].a; + const i = t.velocities[this.m_indexA].v; + let s = t.velocities[this.m_indexA].w; + const n = t.positions[this.m_indexB].a; + const r = t.velocities[this.m_indexB].v; + let o = t.velocities[this.m_indexB].w; + const a = this.m_qA.SetAngle(e), l = this.m_qB.SetAngle(n); + St.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + const h = Ct.MulRV(a, this.m_lalcA, this.m_rA); + St.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + const c = Ct.MulRV(l, this.m_lalcB, this.m_rB); + const u = this.m_invMassA, _ = this.m_invMassB; + const d = this.m_invIA, p = this.m_invIB; + const m = this.m_K; + m.ex.x = u + _ + d * h.y * h.y + p * c.y * c.y; + m.ex.y = -d * h.x * h.y - p * c.x * c.y; + m.ey.x = m.ex.y; + m.ey.y = u + _ + d * h.x * h.x + p * c.x * c.x; + m.GetInverse(this.m_linearMass); + this.m_angularMass = d + p; + this.m_angularMass > 0 && (this.m_angularMass = 1 / this.m_angularMass); + if (t.step.warmStarting) { + this.m_linearImpulse.SelfMul(t.step.dtRatio); + this.m_angularImpulse *= t.step.dtRatio; + const e = this.m_linearImpulse; + i.SelfMulSub(u, e); + s -= d * (St.CrossVV(this.m_rA, e) + this.m_angularImpulse); + r.SelfMulAdd(_, e); + o += p * (St.CrossVV(this.m_rB, e) + this.m_angularImpulse); + } else { + this.m_linearImpulse.SetZero(); + this.m_angularImpulse = 0; + } + t.velocities[this.m_indexA].w = s; + t.velocities[this.m_indexB].w = o; + } + SolveVelocityConstraints(t) { + const e = t.velocities[this.m_indexA].v; + let i = t.velocities[this.m_indexA].w; + const s = t.velocities[this.m_indexB].v; + let n = t.velocities[this.m_indexB].w; + const r = this.m_invMassA, o = this.m_invMassB; + const a = this.m_invIA, l = this.m_invIB; + const h = t.step.dt; + { + const t = n - i; + let e = -this.m_angularMass * t; + const s = this.m_angularImpulse; + const r = h * this.m_maxTorque; + this.m_angularImpulse = it(this.m_angularImpulse + e, -r, r); + e = this.m_angularImpulse - s; + i -= a * e; + n += l * e; + } + { + const t = St.SubVV(St.AddVCrossSV(s, n, this.m_rB, St.s_t0), St.AddVCrossSV(e, i, this.m_rA, St.s_t1), ms.SolveVelocityConstraints_s_Cdot_v2); + const c = vt.MulMV(this.m_linearMass, t, ms.SolveVelocityConstraints_s_impulseV).SelfNeg(); + const u = ms.SolveVelocityConstraints_s_oldImpulseV.Copy(this.m_linearImpulse); + this.m_linearImpulse.SelfAdd(c); + const _ = h * this.m_maxForce; + if (this.m_linearImpulse.LengthSquared() > _ * _) { + this.m_linearImpulse.Normalize(); + this.m_linearImpulse.SelfMul(_); + } + St.SubVV(this.m_linearImpulse, u, c); + e.SelfMulSub(r, c); + i -= a * St.CrossVV(this.m_rA, c); + s.SelfMulAdd(o, c); + n += l * St.CrossVV(this.m_rB, c); + } + t.velocities[this.m_indexA].w = i; + t.velocities[this.m_indexB].w = n; + } + SolvePositionConstraints(t) { + return !0; + } + GetAnchorA(t) { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, t); + } + GetAnchorB(t) { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, t); + } + GetReactionForce(t, e) { + e.x = t * this.m_linearImpulse.x; + e.y = t * this.m_linearImpulse.y; + return e; + } + GetReactionTorque(t) { + return t * this.m_angularImpulse; + } + GetLocalAnchorA() { + return this.m_localAnchorA; + } + GetLocalAnchorB() { + return this.m_localAnchorB; + } + SetMaxForce(t) { + this.m_maxForce = t; + } + GetMaxForce() { + return this.m_maxForce; + } + SetMaxTorque(t) { + this.m_maxTorque = t; + } + GetMaxTorque() { + return this.m_maxTorque; + } + Dump(t) { + const e = this.m_bodyA.m_islandIndex; + const i = this.m_bodyB.m_islandIndex; + t(" const jd: b2FrictionJointDef = new b2FrictionJointDef();\n"); + t(" jd.bodyA = bodies[%d];\n", e); + t(" jd.bodyB = bodies[%d];\n", i); + t(" jd.collideConnected = %s;\n", this.m_collideConnected ? "true" : "false"); + t(" jd.localAnchorA.Set(%.15f, %.15f);\n", this.m_localAnchorA.x, this.m_localAnchorA.y); + t(" jd.localAnchorB.Set(%.15f, %.15f);\n", this.m_localAnchorB.x, this.m_localAnchorB.y); + t(" jd.maxForce = %.15f;\n", this.m_maxForce); + t(" jd.maxTorque = %.15f;\n", this.m_maxTorque); + t(" joints[%d] = this.m_world.CreateJoint(jd);\n", this.m_index); + } + } + ms.SolveVelocityConstraints_s_Cdot_v2 = new St; + ms.SolveVelocityConstraints_s_impulseV = new St; + ms.SolveVelocityConstraints_s_oldImpulseV = new St; + class fs extends ls { + constructor() { + super(t.b2JointType.e_gearJoint); + this.ratio = 1; + } + } + class gs extends hs { + constructor(e) { + super(e); + this.m_typeA = t.b2JointType.e_unknownJoint; + this.m_typeB = t.b2JointType.e_unknownJoint; + this.m_localAnchorA = new St; + this.m_localAnchorB = new St; + this.m_localAnchorC = new St; + this.m_localAnchorD = new St; + this.m_localAxisC = new St; + this.m_localAxisD = new St; + this.m_referenceAngleA = 0; + this.m_referenceAngleB = 0; + this.m_constant = 0; + this.m_ratio = 0; + this.m_impulse = 0; + this.m_indexA = 0; + this.m_indexB = 0; + this.m_indexC = 0; + this.m_indexD = 0; + this.m_lcA = new St; + this.m_lcB = new St; + this.m_lcC = new St; + this.m_lcD = new St; + this.m_mA = 0; + this.m_mB = 0; + this.m_mC = 0; + this.m_mD = 0; + this.m_iA = 0; + this.m_iB = 0; + this.m_iC = 0; + this.m_iD = 0; + this.m_JvAC = new St; + this.m_JvBD = new St; + this.m_JwA = 0; + this.m_JwB = 0; + this.m_JwC = 0; + this.m_JwD = 0; + this.m_mass = 0; + this.m_qA = new Ct; + this.m_qB = new Ct; + this.m_qC = new Ct; + this.m_qD = new Ct; + this.m_lalcA = new St; + this.m_lalcB = new St; + this.m_lalcC = new St; + this.m_lalcD = new St; + this.m_joint1 = e.joint1; + this.m_joint2 = e.joint2; + this.m_typeA = this.m_joint1.GetType(); + this.m_typeB = this.m_joint2.GetType(); + let s, n; + this.m_bodyC = this.m_joint1.GetBodyA(); + this.m_bodyA = this.m_joint1.GetBodyB(); + const r = this.m_bodyA.m_xf; + const o = this.m_bodyA.m_sweep.a; + const a = this.m_bodyC.m_xf; + const l = this.m_bodyC.m_sweep.a; + if (this.m_typeA === t.b2JointType.e_revoluteJoint) { + const t = e.joint1; + this.m_localAnchorC.Copy(t.m_localAnchorA); + this.m_localAnchorA.Copy(t.m_localAnchorB); + this.m_referenceAngleA = t.m_referenceAngle; + this.m_localAxisC.SetZero(); + s = o - l - this.m_referenceAngleA; + } else { + const t = e.joint1; + this.m_localAnchorC.Copy(t.m_localAnchorA); + this.m_localAnchorA.Copy(t.m_localAnchorB); + this.m_referenceAngleA = t.m_referenceAngle; + this.m_localAxisC.Copy(t.m_localXAxisA); + const i = this.m_localAnchorC; + const n = Ct.MulTRV(a.q, St.AddVV(Ct.MulRV(r.q, this.m_localAnchorA, St.s_t0), St.SubVV(r.p, a.p, St.s_t1), St.s_t0), St.s_t0); + s = St.DotVV(St.SubVV(n, i, St.s_t0), this.m_localAxisC); + } + this.m_bodyD = this.m_joint2.GetBodyA(); + this.m_bodyB = this.m_joint2.GetBodyB(); + const h = this.m_bodyB.m_xf; + const c = this.m_bodyB.m_sweep.a; + const u = this.m_bodyD.m_xf; + const _ = this.m_bodyD.m_sweep.a; + if (this.m_typeB === t.b2JointType.e_revoluteJoint) { + const t = e.joint2; + this.m_localAnchorD.Copy(t.m_localAnchorA); + this.m_localAnchorB.Copy(t.m_localAnchorB); + this.m_referenceAngleB = t.m_referenceAngle; + this.m_localAxisD.SetZero(); + n = c - _ - this.m_referenceAngleB; + } else { + const t = e.joint2; + this.m_localAnchorD.Copy(t.m_localAnchorA); + this.m_localAnchorB.Copy(t.m_localAnchorB); + this.m_referenceAngleB = t.m_referenceAngle; + this.m_localAxisD.Copy(t.m_localXAxisA); + const i = this.m_localAnchorD; + const s = Ct.MulTRV(u.q, St.AddVV(Ct.MulRV(h.q, this.m_localAnchorB, St.s_t0), St.SubVV(h.p, u.p, St.s_t1), St.s_t0), St.s_t0); + n = St.DotVV(St.SubVV(s, i, St.s_t0), this.m_localAxisD); + } + this.m_ratio = i(e.ratio, 1); + this.m_constant = s + this.m_ratio * n; + this.m_impulse = 0; + } + InitVelocityConstraints(e) { + this.m_indexA = this.m_bodyA.m_islandIndex; + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_indexC = this.m_bodyC.m_islandIndex; + this.m_indexD = this.m_bodyD.m_islandIndex; + this.m_lcA.Copy(this.m_bodyA.m_sweep.localCenter); + this.m_lcB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_lcC.Copy(this.m_bodyC.m_sweep.localCenter); + this.m_lcD.Copy(this.m_bodyD.m_sweep.localCenter); + this.m_mA = this.m_bodyA.m_invMass; + this.m_mB = this.m_bodyB.m_invMass; + this.m_mC = this.m_bodyC.m_invMass; + this.m_mD = this.m_bodyD.m_invMass; + this.m_iA = this.m_bodyA.m_invI; + this.m_iB = this.m_bodyB.m_invI; + this.m_iC = this.m_bodyC.m_invI; + this.m_iD = this.m_bodyD.m_invI; + const i = e.positions[this.m_indexA].a; + const s = e.velocities[this.m_indexA].v; + let n = e.velocities[this.m_indexA].w; + const r = e.positions[this.m_indexB].a; + const o = e.velocities[this.m_indexB].v; + let a = e.velocities[this.m_indexB].w; + const l = e.positions[this.m_indexC].a; + const h = e.velocities[this.m_indexC].v; + let c = e.velocities[this.m_indexC].w; + const u = e.positions[this.m_indexD].a; + const _ = e.velocities[this.m_indexD].v; + let d = e.velocities[this.m_indexD].w; + const p = this.m_qA.SetAngle(i), m = this.m_qB.SetAngle(r), f = this.m_qC.SetAngle(l), g = this.m_qD.SetAngle(u); + this.m_mass = 0; + if (this.m_typeA === t.b2JointType.e_revoluteJoint) { + this.m_JvAC.SetZero(); + this.m_JwA = 1; + this.m_JwC = 1; + this.m_mass += this.m_iA + this.m_iC; + } else { + const t = Ct.MulRV(f, this.m_localAxisC, gs.InitVelocityConstraints_s_u); + St.SubVV(this.m_localAnchorC, this.m_lcC, this.m_lalcC); + const e = Ct.MulRV(f, this.m_lalcC, gs.InitVelocityConstraints_s_rC); + St.SubVV(this.m_localAnchorA, this.m_lcA, this.m_lalcA); + const i = Ct.MulRV(p, this.m_lalcA, gs.InitVelocityConstraints_s_rA); + this.m_JvAC.Copy(t); + this.m_JwC = St.CrossVV(e, t); + this.m_JwA = St.CrossVV(i, t); + this.m_mass += this.m_mC + this.m_mA + this.m_iC * this.m_JwC * this.m_JwC + this.m_iA * this.m_JwA * this.m_JwA; + } + if (this.m_typeB === t.b2JointType.e_revoluteJoint) { + this.m_JvBD.SetZero(); + this.m_JwB = this.m_ratio; + this.m_JwD = this.m_ratio; + this.m_mass += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD); + } else { + const t = Ct.MulRV(g, this.m_localAxisD, gs.InitVelocityConstraints_s_u); + St.SubVV(this.m_localAnchorD, this.m_lcD, this.m_lalcD); + const e = Ct.MulRV(g, this.m_lalcD, gs.InitVelocityConstraints_s_rD); + St.SubVV(this.m_localAnchorB, this.m_lcB, this.m_lalcB); + const i = Ct.MulRV(m, this.m_lalcB, gs.InitVelocityConstraints_s_rB); + St.MulSV(this.m_ratio, t, this.m_JvBD); + this.m_JwD = this.m_ratio * St.CrossVV(e, t); + this.m_JwB = this.m_ratio * St.CrossVV(i, t); + this.m_mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * this.m_JwD * this.m_JwD + this.m_iB * this.m_JwB * this.m_JwB; + } + this.m_mass = this.m_mass > 0 ? 1 / this.m_mass : 0; + if (e.step.warmStarting) { + s.SelfMulAdd(this.m_mA * this.m_impulse, this.m_JvAC); + n += this.m_iA * this.m_impulse * this.m_JwA; + o.SelfMulAdd(this.m_mB * this.m_impulse, this.m_JvBD); + a += this.m_iB * this.m_impulse * this.m_JwB; + h.SelfMulSub(this.m_mC * this.m_impulse, this.m_JvAC); + c -= this.m_iC * this.m_impulse * this.m_JwC; + _.SelfMulSub(this.m_mD * this.m_impulse, this.m_JvBD); + d -= this.m_iD * this.m_impulse * this.m_JwD; + } else this.m_impulse = 0; + e.velocities[this.m_indexA].w = n; + e.velocities[this.m_indexB].w = a; + e.velocities[this.m_indexC].w = c; + e.velocities[this.m_indexD].w = d; + } + SolveVelocityConstraints(t) { + const e = t.velocities[this.m_indexA].v; + let i = t.velocities[this.m_indexA].w; + const s = t.velocities[this.m_indexB].v; + let n = t.velocities[this.m_indexB].w; + const r = t.velocities[this.m_indexC].v; + let o = t.velocities[this.m_indexC].w; + const a = t.velocities[this.m_indexD].v; + let l = t.velocities[this.m_indexD].w; + let h = St.DotVV(this.m_JvAC, St.SubVV(e, r, St.s_t0)) + St.DotVV(this.m_JvBD, St.SubVV(s, a, St.s_t0)); + h += this.m_JwA * i - this.m_JwC * o + (this.m_JwB * n - this.m_JwD * l); + const c = -this.m_mass * h; + this.m_impulse += c; + e.SelfMulAdd(this.m_mA * c, this.m_JvAC); + i += this.m_iA * c * this.m_JwA; + s.SelfMulAdd(this.m_mB * c, this.m_JvBD); + n += this.m_iB * c * this.m_JwB; + r.SelfMulSub(this.m_mC * c, this.m_JvAC); + o -= this.m_iC * c * this.m_JwC; + a.SelfMulSub(this.m_mD * c, this.m_JvBD); + l -= this.m_iD * c * this.m_JwD; + t.velocities[this.m_indexA].w = i; + t.velocities[this.m_indexB].w = n; + t.velocities[this.m_indexC].w = o; + t.velocities[this.m_indexD].w = l; + } + SolvePositionConstraints(e) { + const i = e.positions[this.m_indexA].c; + let s = e.positions[this.m_indexA].a; + const n = e.positions[this.m_indexB].c; + let r = e.positions[this.m_indexB].a; + const o = e.positions[this.m_indexC].c; + let a = e.positions[this.m_indexC].a; + const l = e.positions[this.m_indexD].c; + let h = e.positions[this.m_indexD].a; + const c = this.m_qA.SetAngle(s), _ = this.m_qB.SetAngle(r), d = this.m_qC.SetAngle(a), p = this.m_qD.SetAngle(h); + const m = 0; + let f, g; + const y = this.m_JvAC, b = this.m_JvBD; + let S, A, T, v; + let E = 0; + if (this.m_typeA === t.b2JointType.e_revoluteJoint) { + y.SetZero(); + S = 1; + T = 1; + E += this.m_iA + this.m_iC; + f = s - a - this.m_referenceAngleA; + } else { + const t = Ct.MulRV(d, this.m_localAxisC, gs.SolvePositionConstraints_s_u); + const e = Ct.MulRV(d, this.m_lalcC, gs.SolvePositionConstraints_s_rC); + const s = Ct.MulRV(c, this.m_lalcA, gs.SolvePositionConstraints_s_rA); + y.Copy(t); + T = St.CrossVV(e, t); + S = St.CrossVV(s, t); + E += this.m_mC + this.m_mA + this.m_iC * T * T + this.m_iA * S * S; + const n = this.m_lalcC; + const r = Ct.MulTRV(d, St.AddVV(s, St.SubVV(i, o, St.s_t0), St.s_t0), St.s_t0); + f = St.DotVV(St.SubVV(r, n, St.s_t0), this.m_localAxisC); + } + if (this.m_typeB === t.b2JointType.e_revoluteJoint) { + b.SetZero(); + A = this.m_ratio; + v = this.m_ratio; + E += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD); + g = r - h - this.m_referenceAngleB; + } else { + const t = Ct.MulRV(p, this.m_localAxisD, gs.SolvePositionConstraints_s_u); + const e = Ct.MulRV(p, this.m_lalcD, gs.SolvePositionConstraints_s_rD); + const i = Ct.MulRV(_, this.m_lalcB, gs.SolvePositionConstraints_s_rB); + St.MulSV(this.m_ratio, t, b); + v = this.m_ratio * St.CrossVV(e, t); + A = this.m_ratio * St.CrossVV(i, t); + E += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * v * v + this.m_iB * A * A; + const s = this.m_lalcD; + const r = Ct.MulTRV(p, St.AddVV(i, St.SubVV(n, l, St.s_t0), St.s_t0), St.s_t0); + g = St.DotVV(St.SubVV(r, s, St.s_t0), this.m_localAxisD); + } + const C = f + this.m_ratio * g - this.m_constant; + let x = 0; + E > 0 && (x = -C / E); + i.SelfMulAdd(this.m_mA * x, y); + s += this.m_iA * x * S; + n.SelfMulAdd(this.m_mB * x, b); + r += this.m_iB * x * A; + o.SelfMulSub(this.m_mC * x, y); + a -= this.m_iC * x * T; + l.SelfMulSub(this.m_mD * x, b); + h -= this.m_iD * x * v; + e.positions[this.m_indexA].a = s; + e.positions[this.m_indexB].a = r; + e.positions[this.m_indexC].a = a; + e.positions[this.m_indexD].a = h; + return m < u; + } + GetAnchorA(t) { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, t); + } + GetAnchorB(t) { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, t); + } + GetReactionForce(t, e) { + return St.MulSV(t * this.m_impulse, this.m_JvAC, e); + } + GetReactionTorque(t) { + return t * this.m_impulse * this.m_JwA; + } + GetJoint1() { + return this.m_joint1; + } + GetJoint2() { + return this.m_joint2; + } + GetRatio() { + return this.m_ratio; + } + SetRatio(t) { + this.m_ratio = t; + } + Dump(t) { + const e = this.m_bodyA.m_islandIndex; + const i = this.m_bodyB.m_islandIndex; + const s = this.m_joint1.m_index; + const n = this.m_joint2.m_index; + t(" const jd: b2GearJointDef = new b2GearJointDef();\n"); + t(" jd.bodyA = bodies[%d];\n", e); + t(" jd.bodyB = bodies[%d];\n", i); + t(" jd.collideConnected = %s;\n", this.m_collideConnected ? "true" : "false"); + t(" jd.joint1 = joints[%d];\n", s); + t(" jd.joint2 = joints[%d];\n", n); + t(" jd.ratio = %.15f;\n", this.m_ratio); + t(" joints[%d] = this.m_world.CreateJoint(jd);\n", this.m_index); + } + } + gs.InitVelocityConstraints_s_u = new St; + gs.InitVelocityConstraints_s_rA = new St; + gs.InitVelocityConstraints_s_rB = new St; + gs.InitVelocityConstraints_s_rC = new St; + gs.InitVelocityConstraints_s_rD = new St; + gs.SolvePositionConstraints_s_u = new St; + gs.SolvePositionConstraints_s_rA = new St; + gs.SolvePositionConstraints_s_rB = new St; + gs.SolvePositionConstraints_s_rC = new St; + gs.SolvePositionConstraints_s_rD = new St; + class ys extends ls { + constructor() { + super(t.b2JointType.e_motorJoint); + this.linearOffset = new St(0, 0); + this.angularOffset = 0; + this.maxForce = 1; + this.maxTorque = 1; + this.correctionFactor = .3; + } + Initialize(t, e) { + this.bodyA = t; + this.bodyB = e; + this.bodyA.GetLocalPoint(this.bodyB.GetPosition(), this.linearOffset); + const i = this.bodyA.GetAngle(); + const s = this.bodyB.GetAngle(); + this.angularOffset = s - i; + } + } + class bs extends hs { + constructor(t) { + super(t); + this.m_linearOffset = new St; + this.m_angularOffset = 0; + this.m_linearImpulse = new St; + this.m_angularImpulse = 0; + this.m_maxForce = 0; + this.m_maxTorque = 0; + this.m_correctionFactor = .3; + this.m_indexA = 0; + this.m_indexB = 0; + this.m_rA = new St; + this.m_rB = new St; + this.m_localCenterA = new St; + this.m_localCenterB = new St; + this.m_linearError = new St; + this.m_angularError = 0; + this.m_invMassA = 0; + this.m_invMassB = 0; + this.m_invIA = 0; + this.m_invIB = 0; + this.m_linearMass = new vt; + this.m_angularMass = 0; + this.m_qA = new Ct; + this.m_qB = new Ct; + this.m_K = new vt; + this.m_linearOffset.Copy(i(t.linearOffset, St.ZERO)); + this.m_linearImpulse.SetZero(); + this.m_maxForce = i(t.maxForce, 0); + this.m_maxTorque = i(t.maxTorque, 0); + this.m_correctionFactor = i(t.correctionFactor, .3); + } + GetAnchorA(t) { + const e = this.m_bodyA.GetPosition(); + t.x = e.x; + t.y = e.y; + return t; + } + GetAnchorB(t) { + const e = this.m_bodyB.GetPosition(); + t.x = e.x; + t.y = e.y; + return t; + } + GetReactionForce(t, e) { + return St.MulSV(t, this.m_linearImpulse, e); + } + GetReactionTorque(t) { + return t * this.m_angularImpulse; + } + SetLinearOffset(t) { + if (!St.IsEqualToV(t, this.m_linearOffset)) { + this.m_bodyA.SetAwake(!0); + this.m_bodyB.SetAwake(!0); + this.m_linearOffset.Copy(t); + } + } + GetLinearOffset() { + return this.m_linearOffset; + } + SetAngularOffset(t) { + if (t !== this.m_angularOffset) { + this.m_bodyA.SetAwake(!0); + this.m_bodyB.SetAwake(!0); + this.m_angularOffset = t; + } + } + GetAngularOffset() { + return this.m_angularOffset; + } + SetMaxForce(t) { + this.m_maxForce = t; + } + GetMaxForce() { + return this.m_maxForce; + } + SetMaxTorque(t) { + this.m_maxTorque = t; + } + GetMaxTorque() { + return this.m_maxTorque; + } + InitVelocityConstraints(t) { + this.m_indexA = this.m_bodyA.m_islandIndex; + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter); + this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_invMassA = this.m_bodyA.m_invMass; + this.m_invMassB = this.m_bodyB.m_invMass; + this.m_invIA = this.m_bodyA.m_invI; + this.m_invIB = this.m_bodyB.m_invI; + const e = t.positions[this.m_indexA].c; + const i = t.positions[this.m_indexA].a; + const s = t.velocities[this.m_indexA].v; + let n = t.velocities[this.m_indexA].w; + const r = t.positions[this.m_indexB].c; + const o = t.positions[this.m_indexB].a; + const a = t.velocities[this.m_indexB].v; + let l = t.velocities[this.m_indexB].w; + const h = this.m_qA.SetAngle(i), c = this.m_qB.SetAngle(o); + const u = Ct.MulRV(h, St.SubVV(this.m_linearOffset, this.m_localCenterA, St.s_t0), this.m_rA); + const _ = Ct.MulRV(c, St.NegV(this.m_localCenterB, St.s_t0), this.m_rB); + const d = this.m_invMassA, p = this.m_invMassB; + const m = this.m_invIA, f = this.m_invIB; + const g = this.m_K; + g.ex.x = d + p + m * u.y * u.y + f * _.y * _.y; + g.ex.y = -m * u.x * u.y - f * _.x * _.y; + g.ey.x = g.ex.y; + g.ey.y = d + p + m * u.x * u.x + f * _.x * _.x; + g.GetInverse(this.m_linearMass); + this.m_angularMass = m + f; + this.m_angularMass > 0 && (this.m_angularMass = 1 / this.m_angularMass); + St.SubVV(St.AddVV(r, _, St.s_t0), St.AddVV(e, u, St.s_t1), this.m_linearError); + this.m_angularError = o - i - this.m_angularOffset; + if (t.step.warmStarting) { + this.m_linearImpulse.SelfMul(t.step.dtRatio); + this.m_angularImpulse *= t.step.dtRatio; + const e = this.m_linearImpulse; + s.SelfMulSub(d, e); + n -= m * (St.CrossVV(u, e) + this.m_angularImpulse); + a.SelfMulAdd(p, e); + l += f * (St.CrossVV(_, e) + this.m_angularImpulse); + } else { + this.m_linearImpulse.SetZero(); + this.m_angularImpulse = 0; + } + t.velocities[this.m_indexA].w = n; + t.velocities[this.m_indexB].w = l; + } + SolveVelocityConstraints(t) { + const e = t.velocities[this.m_indexA].v; + let i = t.velocities[this.m_indexA].w; + const s = t.velocities[this.m_indexB].v; + let n = t.velocities[this.m_indexB].w; + const r = this.m_invMassA, o = this.m_invMassB; + const a = this.m_invIA, l = this.m_invIB; + const h = t.step.dt; + const c = t.step.inv_dt; + { + const t = n - i + c * this.m_correctionFactor * this.m_angularError; + let e = -this.m_angularMass * t; + const s = this.m_angularImpulse; + const r = h * this.m_maxTorque; + this.m_angularImpulse = it(this.m_angularImpulse + e, -r, r); + e = this.m_angularImpulse - s; + i -= a * e; + n += l * e; + } + { + const t = this.m_rA; + const u = this.m_rB; + const _ = St.AddVV(St.SubVV(St.AddVV(s, St.CrossSV(n, u, St.s_t0), St.s_t0), St.AddVV(e, St.CrossSV(i, t, St.s_t1), St.s_t1), St.s_t2), St.MulSV(c * this.m_correctionFactor, this.m_linearError, St.s_t3), bs.SolveVelocityConstraints_s_Cdot_v2); + const d = vt.MulMV(this.m_linearMass, _, bs.SolveVelocityConstraints_s_impulse_v2).SelfNeg(); + const p = bs.SolveVelocityConstraints_s_oldImpulse_v2.Copy(this.m_linearImpulse); + this.m_linearImpulse.SelfAdd(d); + const m = h * this.m_maxForce; + if (this.m_linearImpulse.LengthSquared() > m * m) { + this.m_linearImpulse.Normalize(); + this.m_linearImpulse.SelfMul(m); + } + St.SubVV(this.m_linearImpulse, p, d); + e.SelfMulSub(r, d); + i -= a * St.CrossVV(t, d); + s.SelfMulAdd(o, d); + n += l * St.CrossVV(u, d); + } + t.velocities[this.m_indexA].w = i; + t.velocities[this.m_indexB].w = n; + } + SolvePositionConstraints(t) { + return !0; + } + Dump(t) { + const e = this.m_bodyA.m_islandIndex; + const i = this.m_bodyB.m_islandIndex; + t(" const jd: b2MotorJointDef = new b2MotorJointDef();\n"); + t(" jd.bodyA = bodies[%d];\n", e); + t(" jd.bodyB = bodies[%d];\n", i); + t(" jd.collideConnected = %s;\n", this.m_collideConnected ? "true" : "false"); + t(" jd.linearOffset.Set(%.15f, %.15f);\n", this.m_linearOffset.x, this.m_linearOffset.y); + t(" jd.angularOffset = %.15f;\n", this.m_angularOffset); + t(" jd.maxForce = %.15f;\n", this.m_maxForce); + t(" jd.maxTorque = %.15f;\n", this.m_maxTorque); + t(" jd.correctionFactor = %.15f;\n", this.m_correctionFactor); + t(" joints[%d] = this.m_world.CreateJoint(jd);\n", this.m_index); + } + } + bs.SolveVelocityConstraints_s_Cdot_v2 = new St; + bs.SolveVelocityConstraints_s_impulse_v2 = new St; + bs.SolveVelocityConstraints_s_oldImpulse_v2 = new St; + class Ss extends ls { + constructor() { + super(t.b2JointType.e_mouseJoint); + this.target = new St; + this.maxForce = 0; + this.frequencyHz = 5; + this.dampingRatio = .7; + } + } + class As extends hs { + constructor(t) { + super(t); + this.m_localAnchorB = new St; + this.m_targetA = new St; + this.m_frequencyHz = 0; + this.m_dampingRatio = 0; + this.m_beta = 0; + this.m_impulse = new St; + this.m_maxForce = 0; + this.m_gamma = 0; + this.m_indexA = 0; + this.m_indexB = 0; + this.m_rB = new St; + this.m_localCenterB = new St; + this.m_invMassB = 0; + this.m_invIB = 0; + this.m_mass = new vt; + this.m_C = new St; + this.m_qB = new Ct; + this.m_lalcB = new St; + this.m_K = new vt; + this.m_targetA.Copy(i(t.target, St.ZERO)); + xt.MulTXV(this.m_bodyB.GetTransform(), this.m_targetA, this.m_localAnchorB); + this.m_maxForce = i(t.maxForce, 0); + this.m_impulse.SetZero(); + this.m_frequencyHz = i(t.frequencyHz, 0); + this.m_dampingRatio = i(t.dampingRatio, 0); + this.m_beta = 0; + this.m_gamma = 0; + } + SetTarget(t) { + this.m_bodyB.IsAwake() || this.m_bodyB.SetAwake(!0); + this.m_targetA.Copy(t); + } + GetTarget() { + return this.m_targetA; + } + SetMaxForce(t) { + this.m_maxForce = t; + } + GetMaxForce() { + return this.m_maxForce; + } + SetFrequency(t) { + this.m_frequencyHz = t; + } + GetFrequency() { + return this.m_frequencyHz; + } + SetDampingRatio(t) { + this.m_dampingRatio = t; + } + GetDampingRatio() { + return this.m_dampingRatio; + } + InitVelocityConstraints(t) { + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_invMassB = this.m_bodyB.m_invMass; + this.m_invIB = this.m_bodyB.m_invI; + const e = t.positions[this.m_indexB].c; + const i = t.positions[this.m_indexB].a; + const s = t.velocities[this.m_indexB].v; + let n = t.velocities[this.m_indexB].w; + const r = this.m_qB.SetAngle(i); + const a = this.m_bodyB.GetMass(); + const l = 2 * o * this.m_frequencyHz; + const h = 2 * a * this.m_dampingRatio * l; + const c = a * (l * l); + const u = t.step.dt; + this.m_gamma = u * (h + u * c); + 0 !== this.m_gamma && (this.m_gamma = 1 / this.m_gamma); + this.m_beta = u * c * this.m_gamma; + St.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + Ct.MulRV(r, this.m_lalcB, this.m_rB); + const _ = this.m_K; + _.ex.x = this.m_invMassB + this.m_invIB * this.m_rB.y * this.m_rB.y + this.m_gamma; + _.ex.y = -this.m_invIB * this.m_rB.x * this.m_rB.y; + _.ey.x = _.ex.y; + _.ey.y = this.m_invMassB + this.m_invIB * this.m_rB.x * this.m_rB.x + this.m_gamma; + _.GetInverse(this.m_mass); + this.m_C.x = e.x + this.m_rB.x - this.m_targetA.x; + this.m_C.y = e.y + this.m_rB.y - this.m_targetA.y; + this.m_C.SelfMul(this.m_beta); + n *= .98; + if (t.step.warmStarting) { + this.m_impulse.SelfMul(t.step.dtRatio); + s.x += this.m_invMassB * this.m_impulse.x; + s.y += this.m_invMassB * this.m_impulse.y; + n += this.m_invIB * St.CrossVV(this.m_rB, this.m_impulse); + } else this.m_impulse.SetZero(); + t.velocities[this.m_indexB].w = n; + } + SolveVelocityConstraints(t) { + const e = t.velocities[this.m_indexB].v; + let i = t.velocities[this.m_indexB].w; + const s = St.AddVCrossSV(e, i, this.m_rB, As.SolveVelocityConstraints_s_Cdot); + const n = vt.MulMV(this.m_mass, St.AddVV(s, St.AddVV(this.m_C, St.MulSV(this.m_gamma, this.m_impulse, St.s_t0), St.s_t0), St.s_t0).SelfNeg(), As.SolveVelocityConstraints_s_impulse); + const r = As.SolveVelocityConstraints_s_oldImpulse.Copy(this.m_impulse); + this.m_impulse.SelfAdd(n); + const o = t.step.dt * this.m_maxForce; + this.m_impulse.LengthSquared() > o * o && this.m_impulse.SelfMul(o / this.m_impulse.Length()); + St.SubVV(this.m_impulse, r, n); + e.SelfMulAdd(this.m_invMassB, n); + i += this.m_invIB * St.CrossVV(this.m_rB, n); + t.velocities[this.m_indexB].w = i; + } + SolvePositionConstraints(t) { + return !0; + } + GetAnchorA(t) { + t.x = this.m_targetA.x; + t.y = this.m_targetA.y; + return t; + } + GetAnchorB(t) { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, t); + } + GetReactionForce(t, e) { + return St.MulSV(t, this.m_impulse, e); + } + GetReactionTorque(t) { + return 0; + } + Dump(t) { + t("Mouse joint dumping is not supported.\n"); + } + ShiftOrigin(t) { + this.m_targetA.SelfSub(t); + } + } + As.SolveVelocityConstraints_s_Cdot = new St; + As.SolveVelocityConstraints_s_impulse = new St; + As.SolveVelocityConstraints_s_oldImpulse = new St; + class Ts extends ls { + constructor() { + super(t.b2JointType.e_prismaticJoint); + this.localAnchorA = new St; + this.localAnchorB = new St; + this.localAxisA = new St(1, 0); + this.referenceAngle = 0; + this.enableLimit = !1; + this.lowerTranslation = 0; + this.upperTranslation = 0; + this.enableMotor = !1; + this.maxMotorForce = 0; + this.motorSpeed = 0; + } + Initialize(t, e, i, s) { + this.bodyA = t; + this.bodyB = e; + this.bodyA.GetLocalPoint(i, this.localAnchorA); + this.bodyB.GetLocalPoint(i, this.localAnchorB); + this.bodyA.GetLocalVector(s, this.localAxisA); + this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle(); + } + } + class vs extends hs { + constructor(e) { + super(e); + this.m_localAnchorA = new St; + this.m_localAnchorB = new St; + this.m_localXAxisA = new St; + this.m_localYAxisA = new St; + this.m_referenceAngle = 0; + this.m_impulse = new Tt(0, 0, 0); + this.m_motorImpulse = 0; + this.m_lowerTranslation = 0; + this.m_upperTranslation = 0; + this.m_maxMotorForce = 0; + this.m_motorSpeed = 0; + this.m_enableLimit = !1; + this.m_enableMotor = !1; + this.m_limitState = t.b2LimitState.e_inactiveLimit; + this.m_indexA = 0; + this.m_indexB = 0; + this.m_localCenterA = new St; + this.m_localCenterB = new St; + this.m_invMassA = 0; + this.m_invMassB = 0; + this.m_invIA = 0; + this.m_invIB = 0; + this.m_axis = new St(0, 0); + this.m_perp = new St(0, 0); + this.m_s1 = 0; + this.m_s2 = 0; + this.m_a1 = 0; + this.m_a2 = 0; + this.m_K = new Et; + this.m_K3 = new Et; + this.m_K2 = new vt; + this.m_motorMass = 0; + this.m_qA = new Ct; + this.m_qB = new Ct; + this.m_lalcA = new St; + this.m_lalcB = new St; + this.m_rA = new St; + this.m_rB = new St; + this.m_localAnchorA.Copy(i(e.localAnchorA, St.ZERO)); + this.m_localAnchorB.Copy(i(e.localAnchorB, St.ZERO)); + this.m_localXAxisA.Copy(i(e.localAxisA, new St(1, 0))).SelfNormalize(); + St.CrossOneV(this.m_localXAxisA, this.m_localYAxisA); + this.m_referenceAngle = i(e.referenceAngle, 0); + this.m_lowerTranslation = i(e.lowerTranslation, 0); + this.m_upperTranslation = i(e.upperTranslation, 0); + this.m_maxMotorForce = i(e.maxMotorForce, 0); + this.m_motorSpeed = i(e.motorSpeed, 0); + this.m_enableLimit = i(e.enableLimit, !1); + this.m_enableMotor = i(e.enableMotor, !1); + } + InitVelocityConstraints(e) { + this.m_indexA = this.m_bodyA.m_islandIndex; + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter); + this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_invMassA = this.m_bodyA.m_invMass; + this.m_invMassB = this.m_bodyB.m_invMass; + this.m_invIA = this.m_bodyA.m_invI; + this.m_invIB = this.m_bodyB.m_invI; + const i = e.positions[this.m_indexA].c; + const s = e.positions[this.m_indexA].a; + const n = e.velocities[this.m_indexA].v; + let r = e.velocities[this.m_indexA].w; + const o = e.positions[this.m_indexB].c; + const a = e.positions[this.m_indexB].a; + const l = e.velocities[this.m_indexB].v; + let h = e.velocities[this.m_indexB].w; + const c = this.m_qA.SetAngle(s), _ = this.m_qB.SetAngle(a); + St.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + const d = Ct.MulRV(c, this.m_lalcA, this.m_rA); + St.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + const p = Ct.MulRV(_, this.m_lalcB, this.m_rB); + const m = St.AddVV(St.SubVV(o, i, St.s_t0), St.SubVV(p, d, St.s_t1), vs.InitVelocityConstraints_s_d); + const f = this.m_invMassA, g = this.m_invMassB; + const y = this.m_invIA, b = this.m_invIB; + Ct.MulRV(c, this.m_localXAxisA, this.m_axis); + this.m_a1 = St.CrossVV(St.AddVV(m, d, St.s_t0), this.m_axis); + this.m_a2 = St.CrossVV(p, this.m_axis); + this.m_motorMass = f + g + y * this.m_a1 * this.m_a1 + b * this.m_a2 * this.m_a2; + this.m_motorMass > 0 && (this.m_motorMass = 1 / this.m_motorMass); + Ct.MulRV(c, this.m_localYAxisA, this.m_perp); + this.m_s1 = St.CrossVV(St.AddVV(m, d, St.s_t0), this.m_perp); + this.m_s2 = St.CrossVV(p, this.m_perp); + this.m_K.ex.x = f + g + y * this.m_s1 * this.m_s1 + b * this.m_s2 * this.m_s2; + this.m_K.ex.y = y * this.m_s1 + b * this.m_s2; + this.m_K.ex.z = y * this.m_s1 * this.m_a1 + b * this.m_s2 * this.m_a2; + this.m_K.ey.x = this.m_K.ex.y; + this.m_K.ey.y = y + b; + 0 === this.m_K.ey.y && (this.m_K.ey.y = 1); + this.m_K.ey.z = y * this.m_a1 + b * this.m_a2; + this.m_K.ez.x = this.m_K.ex.z; + this.m_K.ez.y = this.m_K.ey.z; + this.m_K.ez.z = f + g + y * this.m_a1 * this.m_a1 + b * this.m_a2 * this.m_a2; + if (this.m_enableLimit) { + const e = St.DotVV(this.m_axis, m); + if ($(this.m_upperTranslation - this.m_lowerTranslation) < 2 * u) this.m_limitState = t.b2LimitState.e_equalLimits; else if (e <= this.m_lowerTranslation) { + if (this.m_limitState !== t.b2LimitState.e_atLowerLimit) { + this.m_limitState = t.b2LimitState.e_atLowerLimit; + this.m_impulse.z = 0; + } + } else if (e >= this.m_upperTranslation) { + if (this.m_limitState !== t.b2LimitState.e_atUpperLimit) { + this.m_limitState = t.b2LimitState.e_atUpperLimit; + this.m_impulse.z = 0; + } + } else { + this.m_limitState = t.b2LimitState.e_inactiveLimit; + this.m_impulse.z = 0; + } + } else { + this.m_limitState = t.b2LimitState.e_inactiveLimit; + this.m_impulse.z = 0; + } + this.m_enableMotor || (this.m_motorImpulse = 0); + if (e.step.warmStarting) { + this.m_impulse.SelfMul(e.step.dtRatio); + this.m_motorImpulse *= e.step.dtRatio; + const t = St.AddVV(St.MulSV(this.m_impulse.x, this.m_perp, St.s_t0), St.MulSV(this.m_motorImpulse + this.m_impulse.z, this.m_axis, St.s_t1), vs.InitVelocityConstraints_s_P); + const i = this.m_impulse.x * this.m_s1 + this.m_impulse.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_a1; + const s = this.m_impulse.x * this.m_s2 + this.m_impulse.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_a2; + n.SelfMulSub(f, t); + r -= y * i; + l.SelfMulAdd(g, t); + h += b * s; + } else { + this.m_impulse.SetZero(); + this.m_motorImpulse = 0; + } + e.velocities[this.m_indexA].w = r; + e.velocities[this.m_indexB].w = h; + } + SolveVelocityConstraints(e) { + const i = e.velocities[this.m_indexA].v; + let s = e.velocities[this.m_indexA].w; + const n = e.velocities[this.m_indexB].v; + let r = e.velocities[this.m_indexB].w; + const o = this.m_invMassA, a = this.m_invMassB; + const l = this.m_invIA, h = this.m_invIB; + if (this.m_enableMotor && this.m_limitState !== t.b2LimitState.e_equalLimits) { + const t = St.DotVV(this.m_axis, St.SubVV(n, i, St.s_t0)) + this.m_a2 * r - this.m_a1 * s; + let c = this.m_motorMass * (this.m_motorSpeed - t); + const u = this.m_motorImpulse; + const _ = e.step.dt * this.m_maxMotorForce; + this.m_motorImpulse = it(this.m_motorImpulse + c, -_, _); + c = this.m_motorImpulse - u; + const d = St.MulSV(c, this.m_axis, vs.SolveVelocityConstraints_s_P); + const p = c * this.m_a1; + const m = c * this.m_a2; + i.SelfMulSub(o, d); + s -= l * p; + n.SelfMulAdd(a, d); + r += h * m; + } + const c = St.DotVV(this.m_perp, St.SubVV(n, i, St.s_t0)) + this.m_s2 * r - this.m_s1 * s; + const u = r - s; + if (this.m_enableLimit && this.m_limitState !== t.b2LimitState.e_inactiveLimit) { + const e = St.DotVV(this.m_axis, St.SubVV(n, i, St.s_t0)) + this.m_a2 * r - this.m_a1 * s; + const _ = vs.SolveVelocityConstraints_s_f1.Copy(this.m_impulse); + const d = this.m_K.Solve33(-c, -u, -e, vs.SolveVelocityConstraints_s_df3); + this.m_impulse.SelfAdd(d); + this.m_limitState === t.b2LimitState.e_atLowerLimit ? this.m_impulse.z = et(this.m_impulse.z, 0) : this.m_limitState === t.b2LimitState.e_atUpperLimit && (this.m_impulse.z = tt(this.m_impulse.z, 0)); + const p = -c - (this.m_impulse.z - _.z) * this.m_K.ez.x; + const m = -u - (this.m_impulse.z - _.z) * this.m_K.ez.y; + const f = this.m_K.Solve22(p, m, vs.SolveVelocityConstraints_s_f2r); + f.x += _.x; + f.y += _.y; + this.m_impulse.x = f.x; + this.m_impulse.y = f.y; + d.x = this.m_impulse.x - _.x; + d.y = this.m_impulse.y - _.y; + d.z = this.m_impulse.z - _.z; + const g = St.AddVV(St.MulSV(d.x, this.m_perp, St.s_t0), St.MulSV(d.z, this.m_axis, St.s_t1), vs.SolveVelocityConstraints_s_P); + const y = d.x * this.m_s1 + d.y + d.z * this.m_a1; + const b = d.x * this.m_s2 + d.y + d.z * this.m_a2; + i.SelfMulSub(o, g); + s -= l * y; + n.SelfMulAdd(a, g); + r += h * b; + } else { + const t = this.m_K.Solve22(-c, -u, vs.SolveVelocityConstraints_s_df2); + this.m_impulse.x += t.x; + this.m_impulse.y += t.y; + const e = St.MulSV(t.x, this.m_perp, vs.SolveVelocityConstraints_s_P); + const _ = t.x * this.m_s1 + t.y; + const d = t.x * this.m_s2 + t.y; + i.SelfMulSub(o, e); + s -= l * _; + n.SelfMulAdd(a, e); + r += h * d; + } + e.velocities[this.m_indexA].w = s; + e.velocities[this.m_indexB].w = r; + } + SolvePositionConstraints(t) { + const e = t.positions[this.m_indexA].c; + let i = t.positions[this.m_indexA].a; + const s = t.positions[this.m_indexB].c; + let n = t.positions[this.m_indexB].a; + const r = this.m_qA.SetAngle(i), o = this.m_qB.SetAngle(n); + const a = this.m_invMassA, l = this.m_invMassB; + const h = this.m_invIA, c = this.m_invIB; + const d = Ct.MulRV(r, this.m_lalcA, this.m_rA); + const p = Ct.MulRV(o, this.m_lalcB, this.m_rB); + const m = St.SubVV(St.AddVV(s, p, St.s_t0), St.AddVV(e, d, St.s_t1), vs.SolvePositionConstraints_s_d); + const f = Ct.MulRV(r, this.m_localXAxisA, this.m_axis); + const y = St.CrossVV(St.AddVV(m, d, St.s_t0), f); + const b = St.CrossVV(p, f); + const S = Ct.MulRV(r, this.m_localYAxisA, this.m_perp); + const A = St.CrossVV(St.AddVV(m, d, St.s_t0), S); + const T = St.CrossVV(p, S); + let v = vs.SolvePositionConstraints_s_impulse; + const E = St.DotVV(S, m); + const C = n - i - this.m_referenceAngle; + let x = $(E); + const w = $(C); + let R = !1; + let I = 0; + if (this.m_enableLimit) { + const t = St.DotVV(f, m); + if ($(this.m_upperTranslation - this.m_lowerTranslation) < 2 * u) { + I = it(t, -g, g); + x = et(x, $(t)); + R = !0; + } else if (t <= this.m_lowerTranslation) { + I = it(t - this.m_lowerTranslation + u, -g, 0); + x = et(x, this.m_lowerTranslation - t); + R = !0; + } else if (t >= this.m_upperTranslation) { + I = it(t - this.m_upperTranslation - u, 0, g); + x = et(x, t - this.m_upperTranslation); + R = !0; + } + } + if (R) { + const t = a + l + h * A * A + c * T * T; + const e = h * A + c * T; + const i = h * A * y + c * T * b; + let s = h + c; + 0 === s && (s = 1); + const n = h * y + c * b; + const r = a + l + h * y * y + c * b * b; + const o = this.m_K3; + o.ex.SetXYZ(t, e, i); + o.ey.SetXYZ(e, s, n); + o.ez.SetXYZ(i, n, r); + v = o.Solve33(-E, -C, -I, v); + } else { + const t = a + l + h * A * A + c * T * T; + const e = h * A + c * T; + let i = h + c; + 0 === i && (i = 1); + const s = this.m_K2; + s.ex.Set(t, e); + s.ey.Set(e, i); + const n = s.Solve(-E, -C, vs.SolvePositionConstraints_s_impulse1); + v.x = n.x; + v.y = n.y; + v.z = 0; + } + const M = St.AddVV(St.MulSV(v.x, S, St.s_t0), St.MulSV(v.z, f, St.s_t1), vs.SolvePositionConstraints_s_P); + const B = v.x * A + v.y + v.z * y; + const D = v.x * T + v.y + v.z * b; + e.SelfMulSub(a, M); + i -= h * B; + s.SelfMulAdd(l, M); + n += c * D; + t.positions[this.m_indexA].a = i; + t.positions[this.m_indexB].a = n; + return x <= u && w <= _; + } + GetAnchorA(t) { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, t); + } + GetAnchorB(t) { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, t); + } + GetReactionForce(t, e) { + e.x = t * (this.m_impulse.x * this.m_perp.x + (this.m_motorImpulse + this.m_impulse.z) * this.m_axis.x); + e.y = t * (this.m_impulse.x * this.m_perp.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_axis.y); + return e; + } + GetReactionTorque(t) { + return t * this.m_impulse.y; + } + GetLocalAnchorA() { + return this.m_localAnchorA; + } + GetLocalAnchorB() { + return this.m_localAnchorB; + } + GetLocalAxisA() { + return this.m_localXAxisA; + } + GetReferenceAngle() { + return this.m_referenceAngle; + } + GetJointTranslation() { + const t = this.m_bodyA.GetWorldPoint(this.m_localAnchorA, vs.GetJointTranslation_s_pA); + const e = this.m_bodyB.GetWorldPoint(this.m_localAnchorB, vs.GetJointTranslation_s_pB); + const i = St.SubVV(e, t, vs.GetJointTranslation_s_d); + const s = this.m_bodyA.GetWorldVector(this.m_localXAxisA, vs.GetJointTranslation_s_axis); + return St.DotVV(i, s); + } + GetJointSpeed() { + const t = this.m_bodyA; + const e = this.m_bodyB; + St.SubVV(this.m_localAnchorA, t.m_sweep.localCenter, this.m_lalcA); + const i = Ct.MulRV(t.m_xf.q, this.m_lalcA, this.m_rA); + St.SubVV(this.m_localAnchorB, e.m_sweep.localCenter, this.m_lalcB); + const s = Ct.MulRV(e.m_xf.q, this.m_lalcB, this.m_rB); + const n = St.AddVV(t.m_sweep.c, i, St.s_t0); + const r = St.AddVV(e.m_sweep.c, s, St.s_t1); + const o = St.SubVV(r, n, St.s_t2); + const a = t.GetWorldVector(this.m_localXAxisA, this.m_axis); + const l = t.m_linearVelocity; + const h = e.m_linearVelocity; + const c = t.m_angularVelocity; + const u = e.m_angularVelocity; + return St.DotVV(o, St.CrossSV(c, a, St.s_t0)) + St.DotVV(a, St.SubVV(St.AddVCrossSV(h, u, s, St.s_t0), St.AddVCrossSV(l, c, i, St.s_t1), St.s_t0)); + } + IsLimitEnabled() { + return this.m_enableLimit; + } + EnableLimit(t) { + if (t !== this.m_enableLimit) { + this.m_bodyA.SetAwake(!0); + this.m_bodyB.SetAwake(!0); + this.m_enableLimit = t; + this.m_impulse.z = 0; + } + } + GetLowerLimit() { + return this.m_lowerTranslation; + } + GetUpperLimit() { + return this.m_upperTranslation; + } + SetLimits(t, e) { + if (t !== this.m_lowerTranslation || e !== this.m_upperTranslation) { + this.m_bodyA.SetAwake(!0); + this.m_bodyB.SetAwake(!0); + this.m_lowerTranslation = t; + this.m_upperTranslation = e; + this.m_impulse.z = 0; + } + } + IsMotorEnabled() { + return this.m_enableMotor; + } + EnableMotor(t) { + if (t !== this.m_enableMotor) { + this.m_bodyA.SetAwake(!0); + this.m_bodyB.SetAwake(!0); + this.m_enableMotor = t; + } + } + SetMotorSpeed(t) { + if (t !== this.m_motorSpeed) { + this.m_bodyA.SetAwake(!0); + this.m_bodyB.SetAwake(!0); + this.m_motorSpeed = t; + } + } + GetMotorSpeed() { + return this.m_motorSpeed; + } + SetMaxMotorForce(t) { + if (t !== this.m_maxMotorForce) { + this.m_bodyA.SetAwake(!0); + this.m_bodyB.SetAwake(!0); + this.m_maxMotorForce = t; + } + } + GetMaxMotorForce() { + return this.m_maxMotorForce; + } + GetMotorForce(t) { + return t * this.m_motorImpulse; + } + Dump(t) { + const e = this.m_bodyA.m_islandIndex; + const i = this.m_bodyB.m_islandIndex; + t(" const jd: b2PrismaticJointDef = new b2PrismaticJointDef();\n"); + t(" jd.bodyA = bodies[%d];\n", e); + t(" jd.bodyB = bodies[%d];\n", i); + t(" jd.collideConnected = %s;\n", this.m_collideConnected ? "true" : "false"); + t(" jd.localAnchorA.Set(%.15f, %.15f);\n", this.m_localAnchorA.x, this.m_localAnchorA.y); + t(" jd.localAnchorB.Set(%.15f, %.15f);\n", this.m_localAnchorB.x, this.m_localAnchorB.y); + t(" jd.localAxisA.Set(%.15f, %.15f);\n", this.m_localXAxisA.x, this.m_localXAxisA.y); + t(" jd.referenceAngle = %.15f;\n", this.m_referenceAngle); + t(" jd.enableLimit = %s;\n", this.m_enableLimit ? "true" : "false"); + t(" jd.lowerTranslation = %.15f;\n", this.m_lowerTranslation); + t(" jd.upperTranslation = %.15f;\n", this.m_upperTranslation); + t(" jd.enableMotor = %s;\n", this.m_enableMotor ? "true" : "false"); + t(" jd.motorSpeed = %.15f;\n", this.m_motorSpeed); + t(" jd.maxMotorForce = %.15f;\n", this.m_maxMotorForce); + t(" joints[%d] = this.m_world.CreateJoint(jd);\n", this.m_index); + } + } + vs.InitVelocityConstraints_s_d = new St; + vs.InitVelocityConstraints_s_P = new St; + vs.SolveVelocityConstraints_s_P = new St; + vs.SolveVelocityConstraints_s_f2r = new St; + vs.SolveVelocityConstraints_s_f1 = new Tt; + vs.SolveVelocityConstraints_s_df3 = new Tt; + vs.SolveVelocityConstraints_s_df2 = new St; + vs.SolvePositionConstraints_s_d = new St; + vs.SolvePositionConstraints_s_impulse = new Tt; + vs.SolvePositionConstraints_s_impulse1 = new St; + vs.SolvePositionConstraints_s_P = new St; + vs.GetJointTranslation_s_pA = new St; + vs.GetJointTranslation_s_pB = new St; + vs.GetJointTranslation_s_d = new St; + vs.GetJointTranslation_s_axis = new St; + const Es = 2; + class Cs extends ls { + constructor() { + super(t.b2JointType.e_pulleyJoint); + this.groundAnchorA = new St(-1, 1); + this.groundAnchorB = new St(1, 1); + this.localAnchorA = new St(-1, 0); + this.localAnchorB = new St(1, 0); + this.lengthA = 0; + this.lengthB = 0; + this.ratio = 1; + this.collideConnected = !0; + } + Initialize(t, e, i, s, n, r, o) { + this.bodyA = t; + this.bodyB = e; + this.groundAnchorA.Copy(i); + this.groundAnchorB.Copy(s); + this.bodyA.GetLocalPoint(n, this.localAnchorA); + this.bodyB.GetLocalPoint(r, this.localAnchorB); + this.lengthA = St.DistanceVV(n, i); + this.lengthB = St.DistanceVV(r, s); + this.ratio = o; + } + } + class xs extends hs { + constructor(t) { + super(t); + this.m_groundAnchorA = new St; + this.m_groundAnchorB = new St; + this.m_lengthA = 0; + this.m_lengthB = 0; + this.m_localAnchorA = new St; + this.m_localAnchorB = new St; + this.m_constant = 0; + this.m_ratio = 0; + this.m_impulse = 0; + this.m_indexA = 0; + this.m_indexB = 0; + this.m_uA = new St; + this.m_uB = new St; + this.m_rA = new St; + this.m_rB = new St; + this.m_localCenterA = new St; + this.m_localCenterB = new St; + this.m_invMassA = 0; + this.m_invMassB = 0; + this.m_invIA = 0; + this.m_invIB = 0; + this.m_mass = 0; + this.m_qA = new Ct; + this.m_qB = new Ct; + this.m_lalcA = new St; + this.m_lalcB = new St; + this.m_groundAnchorA.Copy(i(t.groundAnchorA, new St(-1, 1))); + this.m_groundAnchorB.Copy(i(t.groundAnchorB, new St(1, 0))); + this.m_localAnchorA.Copy(i(t.localAnchorA, new St(-1, 0))); + this.m_localAnchorB.Copy(i(t.localAnchorB, new St(1, 0))); + this.m_lengthA = i(t.lengthA, 0); + this.m_lengthB = i(t.lengthB, 0); + this.m_ratio = i(t.ratio, 1); + this.m_constant = i(t.lengthA, 0) + this.m_ratio * i(t.lengthB, 0); + this.m_impulse = 0; + } + InitVelocityConstraints(t) { + this.m_indexA = this.m_bodyA.m_islandIndex; + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter); + this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_invMassA = this.m_bodyA.m_invMass; + this.m_invMassB = this.m_bodyB.m_invMass; + this.m_invIA = this.m_bodyA.m_invI; + this.m_invIB = this.m_bodyB.m_invI; + const e = t.positions[this.m_indexA].c; + const i = t.positions[this.m_indexA].a; + const s = t.velocities[this.m_indexA].v; + let n = t.velocities[this.m_indexA].w; + const r = t.positions[this.m_indexB].c; + const o = t.positions[this.m_indexB].a; + const a = t.velocities[this.m_indexB].v; + let l = t.velocities[this.m_indexB].w; + const h = this.m_qA.SetAngle(i), c = this.m_qB.SetAngle(o); + St.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + Ct.MulRV(h, this.m_lalcA, this.m_rA); + St.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + Ct.MulRV(c, this.m_lalcB, this.m_rB); + this.m_uA.Copy(e).SelfAdd(this.m_rA).SelfSub(this.m_groundAnchorA); + this.m_uB.Copy(r).SelfAdd(this.m_rB).SelfSub(this.m_groundAnchorB); + const _ = this.m_uA.Length(); + const d = this.m_uB.Length(); + _ > 10 * u ? this.m_uA.SelfMul(1 / _) : this.m_uA.SetZero(); + d > 10 * u ? this.m_uB.SelfMul(1 / d) : this.m_uB.SetZero(); + const p = St.CrossVV(this.m_rA, this.m_uA); + const m = St.CrossVV(this.m_rB, this.m_uB); + const f = this.m_invMassA + this.m_invIA * p * p; + const g = this.m_invMassB + this.m_invIB * m * m; + this.m_mass = f + this.m_ratio * this.m_ratio * g; + this.m_mass > 0 && (this.m_mass = 1 / this.m_mass); + if (t.step.warmStarting) { + this.m_impulse *= t.step.dtRatio; + const e = St.MulSV(-this.m_impulse, this.m_uA, xs.InitVelocityConstraints_s_PA); + const i = St.MulSV(-this.m_ratio * this.m_impulse, this.m_uB, xs.InitVelocityConstraints_s_PB); + s.SelfMulAdd(this.m_invMassA, e); + n += this.m_invIA * St.CrossVV(this.m_rA, e); + a.SelfMulAdd(this.m_invMassB, i); + l += this.m_invIB * St.CrossVV(this.m_rB, i); + } else this.m_impulse = 0; + t.velocities[this.m_indexA].w = n; + t.velocities[this.m_indexB].w = l; + } + SolveVelocityConstraints(t) { + const e = t.velocities[this.m_indexA].v; + let i = t.velocities[this.m_indexA].w; + const s = t.velocities[this.m_indexB].v; + let n = t.velocities[this.m_indexB].w; + const r = St.AddVCrossSV(e, i, this.m_rA, xs.SolveVelocityConstraints_s_vpA); + const o = St.AddVCrossSV(s, n, this.m_rB, xs.SolveVelocityConstraints_s_vpB); + const a = -St.DotVV(this.m_uA, r) - this.m_ratio * St.DotVV(this.m_uB, o); + const l = -this.m_mass * a; + this.m_impulse += l; + const h = St.MulSV(-l, this.m_uA, xs.SolveVelocityConstraints_s_PA); + const c = St.MulSV(-this.m_ratio * l, this.m_uB, xs.SolveVelocityConstraints_s_PB); + e.SelfMulAdd(this.m_invMassA, h); + i += this.m_invIA * St.CrossVV(this.m_rA, h); + s.SelfMulAdd(this.m_invMassB, c); + n += this.m_invIB * St.CrossVV(this.m_rB, c); + t.velocities[this.m_indexA].w = i; + t.velocities[this.m_indexB].w = n; + } + SolvePositionConstraints(t) { + const e = t.positions[this.m_indexA].c; + let i = t.positions[this.m_indexA].a; + const s = t.positions[this.m_indexB].c; + let n = t.positions[this.m_indexB].a; + const r = this.m_qA.SetAngle(i), o = this.m_qB.SetAngle(n); + St.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + const a = Ct.MulRV(r, this.m_lalcA, this.m_rA); + St.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + const l = Ct.MulRV(o, this.m_lalcB, this.m_rB); + const h = this.m_uA.Copy(e).SelfAdd(a).SelfSub(this.m_groundAnchorA); + const c = this.m_uB.Copy(s).SelfAdd(l).SelfSub(this.m_groundAnchorB); + const _ = h.Length(); + const d = c.Length(); + _ > 10 * u ? h.SelfMul(1 / _) : h.SetZero(); + d > 10 * u ? c.SelfMul(1 / d) : c.SetZero(); + const p = St.CrossVV(a, h); + const m = St.CrossVV(l, c); + const f = this.m_invMassA + this.m_invIA * p * p; + const g = this.m_invMassB + this.m_invIB * m * m; + let y = f + this.m_ratio * this.m_ratio * g; + y > 0 && (y = 1 / y); + const b = this.m_constant - _ - this.m_ratio * d; + const S = $(b); + const A = -y * b; + const T = St.MulSV(-A, h, xs.SolvePositionConstraints_s_PA); + const v = St.MulSV(-this.m_ratio * A, c, xs.SolvePositionConstraints_s_PB); + e.SelfMulAdd(this.m_invMassA, T); + i += this.m_invIA * St.CrossVV(a, T); + s.SelfMulAdd(this.m_invMassB, v); + n += this.m_invIB * St.CrossVV(l, v); + t.positions[this.m_indexA].a = i; + t.positions[this.m_indexB].a = n; + return S < u; + } + GetAnchorA(t) { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, t); + } + GetAnchorB(t) { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, t); + } + GetReactionForce(t, e) { + e.x = t * this.m_impulse * this.m_uB.x; + e.y = t * this.m_impulse * this.m_uB.y; + return e; + } + GetReactionTorque(t) { + return 0; + } + GetGroundAnchorA() { + return this.m_groundAnchorA; + } + GetGroundAnchorB() { + return this.m_groundAnchorB; + } + GetLengthA() { + return this.m_lengthA; + } + GetLengthB() { + return this.m_lengthB; + } + GetRatio() { + return this.m_ratio; + } + GetCurrentLengthA() { + const t = this.m_bodyA.GetWorldPoint(this.m_localAnchorA, xs.GetCurrentLengthA_s_p); + const e = this.m_groundAnchorA; + return St.DistanceVV(t, e); + } + GetCurrentLengthB() { + const t = this.m_bodyB.GetWorldPoint(this.m_localAnchorB, xs.GetCurrentLengthB_s_p); + const e = this.m_groundAnchorB; + return St.DistanceVV(t, e); + } + Dump(t) { + const e = this.m_bodyA.m_islandIndex; + const i = this.m_bodyB.m_islandIndex; + t(" const jd: b2PulleyJointDef = new b2PulleyJointDef();\n"); + t(" jd.bodyA = bodies[%d];\n", e); + t(" jd.bodyB = bodies[%d];\n", i); + t(" jd.collideConnected = %s;\n", this.m_collideConnected ? "true" : "false"); + t(" jd.groundAnchorA.Set(%.15f, %.15f);\n", this.m_groundAnchorA.x, this.m_groundAnchorA.y); + t(" jd.groundAnchorB.Set(%.15f, %.15f);\n", this.m_groundAnchorB.x, this.m_groundAnchorB.y); + t(" jd.localAnchorA.Set(%.15f, %.15f);\n", this.m_localAnchorA.x, this.m_localAnchorA.y); + t(" jd.localAnchorB.Set(%.15f, %.15f);\n", this.m_localAnchorB.x, this.m_localAnchorB.y); + t(" jd.lengthA = %.15f;\n", this.m_lengthA); + t(" jd.lengthB = %.15f;\n", this.m_lengthB); + t(" jd.ratio = %.15f;\n", this.m_ratio); + t(" joints[%d] = this.m_world.CreateJoint(jd);\n", this.m_index); + } + ShiftOrigin(t) { + this.m_groundAnchorA.SelfSub(t); + this.m_groundAnchorB.SelfSub(t); + } + } + xs.InitVelocityConstraints_s_PA = new St; + xs.InitVelocityConstraints_s_PB = new St; + xs.SolveVelocityConstraints_s_vpA = new St; + xs.SolveVelocityConstraints_s_vpB = new St; + xs.SolveVelocityConstraints_s_PA = new St; + xs.SolveVelocityConstraints_s_PB = new St; + xs.SolvePositionConstraints_s_PA = new St; + xs.SolvePositionConstraints_s_PB = new St; + xs.GetCurrentLengthA_s_p = new St; + xs.GetCurrentLengthB_s_p = new St; + class ws extends ls { + constructor() { + super(t.b2JointType.e_revoluteJoint); + this.localAnchorA = new St(0, 0); + this.localAnchorB = new St(0, 0); + this.referenceAngle = 0; + this.enableLimit = !1; + this.lowerAngle = 0; + this.upperAngle = 0; + this.enableMotor = !1; + this.motorSpeed = 0; + this.maxMotorTorque = 0; + } + Initialize(t, e, i) { + this.bodyA = t; + this.bodyB = e; + this.bodyA.GetLocalPoint(i, this.localAnchorA); + this.bodyB.GetLocalPoint(i, this.localAnchorB); + this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle(); + } + } + class Rs extends hs { + constructor(e) { + super(e); + this.m_localAnchorA = new St; + this.m_localAnchorB = new St; + this.m_impulse = new Tt; + this.m_motorImpulse = 0; + this.m_enableMotor = !1; + this.m_maxMotorTorque = 0; + this.m_motorSpeed = 0; + this.m_enableLimit = !1; + this.m_referenceAngle = 0; + this.m_lowerAngle = 0; + this.m_upperAngle = 0; + this.m_indexA = 0; + this.m_indexB = 0; + this.m_rA = new St; + this.m_rB = new St; + this.m_localCenterA = new St; + this.m_localCenterB = new St; + this.m_invMassA = 0; + this.m_invMassB = 0; + this.m_invIA = 0; + this.m_invIB = 0; + this.m_mass = new Et; + this.m_motorMass = 0; + this.m_limitState = t.b2LimitState.e_inactiveLimit; + this.m_qA = new Ct; + this.m_qB = new Ct; + this.m_lalcA = new St; + this.m_lalcB = new St; + this.m_K = new vt; + this.m_localAnchorA.Copy(i(e.localAnchorA, St.ZERO)); + this.m_localAnchorB.Copy(i(e.localAnchorB, St.ZERO)); + this.m_referenceAngle = i(e.referenceAngle, 0); + this.m_impulse.SetZero(); + this.m_motorImpulse = 0; + this.m_lowerAngle = i(e.lowerAngle, 0); + this.m_upperAngle = i(e.upperAngle, 0); + this.m_maxMotorTorque = i(e.maxMotorTorque, 0); + this.m_motorSpeed = i(e.motorSpeed, 0); + this.m_enableLimit = i(e.enableLimit, !1); + this.m_enableMotor = i(e.enableMotor, !1); + this.m_limitState = t.b2LimitState.e_inactiveLimit; + } + InitVelocityConstraints(e) { + this.m_indexA = this.m_bodyA.m_islandIndex; + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter); + this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_invMassA = this.m_bodyA.m_invMass; + this.m_invMassB = this.m_bodyB.m_invMass; + this.m_invIA = this.m_bodyA.m_invI; + this.m_invIB = this.m_bodyB.m_invI; + const i = e.positions[this.m_indexA].a; + const s = e.velocities[this.m_indexA].v; + let n = e.velocities[this.m_indexA].w; + const r = e.positions[this.m_indexB].a; + const o = e.velocities[this.m_indexB].v; + let a = e.velocities[this.m_indexB].w; + const l = this.m_qA.SetAngle(i), h = this.m_qB.SetAngle(r); + St.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + Ct.MulRV(l, this.m_lalcA, this.m_rA); + St.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + Ct.MulRV(h, this.m_lalcB, this.m_rB); + const c = this.m_invMassA, u = this.m_invMassB; + const d = this.m_invIA, p = this.m_invIB; + const m = d + p === 0; + this.m_mass.ex.x = c + u + this.m_rA.y * this.m_rA.y * d + this.m_rB.y * this.m_rB.y * p; + this.m_mass.ey.x = -this.m_rA.y * this.m_rA.x * d - this.m_rB.y * this.m_rB.x * p; + this.m_mass.ez.x = -this.m_rA.y * d - this.m_rB.y * p; + this.m_mass.ex.y = this.m_mass.ey.x; + this.m_mass.ey.y = c + u + this.m_rA.x * this.m_rA.x * d + this.m_rB.x * this.m_rB.x * p; + this.m_mass.ez.y = this.m_rA.x * d + this.m_rB.x * p; + this.m_mass.ex.z = this.m_mass.ez.x; + this.m_mass.ey.z = this.m_mass.ez.y; + this.m_mass.ez.z = d + p; + this.m_motorMass = d + p; + this.m_motorMass > 0 && (this.m_motorMass = 1 / this.m_motorMass); + this.m_enableMotor && !m || (this.m_motorImpulse = 0); + if (this.m_enableLimit && !m) { + const e = r - i - this.m_referenceAngle; + if ($(this.m_upperAngle - this.m_lowerAngle) < 2 * _) this.m_limitState = t.b2LimitState.e_equalLimits; else if (e <= this.m_lowerAngle) { + this.m_limitState !== t.b2LimitState.e_atLowerLimit && (this.m_impulse.z = 0); + this.m_limitState = t.b2LimitState.e_atLowerLimit; + } else if (e >= this.m_upperAngle) { + this.m_limitState !== t.b2LimitState.e_atUpperLimit && (this.m_impulse.z = 0); + this.m_limitState = t.b2LimitState.e_atUpperLimit; + } else { + this.m_limitState = t.b2LimitState.e_inactiveLimit; + this.m_impulse.z = 0; + } + } else this.m_limitState = t.b2LimitState.e_inactiveLimit; + if (e.step.warmStarting) { + this.m_impulse.SelfMul(e.step.dtRatio); + this.m_motorImpulse *= e.step.dtRatio; + const t = Rs.InitVelocityConstraints_s_P.Set(this.m_impulse.x, this.m_impulse.y); + s.SelfMulSub(c, t); + n -= d * (St.CrossVV(this.m_rA, t) + this.m_motorImpulse + this.m_impulse.z); + o.SelfMulAdd(u, t); + a += p * (St.CrossVV(this.m_rB, t) + this.m_motorImpulse + this.m_impulse.z); + } else { + this.m_impulse.SetZero(); + this.m_motorImpulse = 0; + } + e.velocities[this.m_indexA].w = n; + e.velocities[this.m_indexB].w = a; + } + SolveVelocityConstraints(e) { + const i = e.velocities[this.m_indexA].v; + let s = e.velocities[this.m_indexA].w; + const n = e.velocities[this.m_indexB].v; + let r = e.velocities[this.m_indexB].w; + const o = this.m_invMassA, a = this.m_invMassB; + const l = this.m_invIA, h = this.m_invIB; + const c = l + h === 0; + if (this.m_enableMotor && this.m_limitState !== t.b2LimitState.e_equalLimits && !c) { + const t = r - s - this.m_motorSpeed; + let i = -this.m_motorMass * t; + const n = this.m_motorImpulse; + const o = e.step.dt * this.m_maxMotorTorque; + this.m_motorImpulse = it(this.m_motorImpulse + i, -o, o); + i = this.m_motorImpulse - n; + s -= l * i; + r += h * i; + } + if (this.m_enableLimit && this.m_limitState !== t.b2LimitState.e_inactiveLimit && !c) { + const e = St.SubVV(St.AddVCrossSV(n, r, this.m_rB, St.s_t0), St.AddVCrossSV(i, s, this.m_rA, St.s_t1), Rs.SolveVelocityConstraints_s_Cdot1); + const c = r - s; + const u = this.m_mass.Solve33(e.x, e.y, c, Rs.SolveVelocityConstraints_s_impulse_v3).SelfNeg(); + if (this.m_limitState === t.b2LimitState.e_equalLimits) this.m_impulse.SelfAdd(u); else if (this.m_limitState === t.b2LimitState.e_atLowerLimit) if (this.m_impulse.z + u.z < 0) { + const t = -e.x + this.m_impulse.z * this.m_mass.ez.x; + const i = -e.y + this.m_impulse.z * this.m_mass.ez.y; + const s = this.m_mass.Solve22(t, i, Rs.SolveVelocityConstraints_s_reduced_v2); + u.x = s.x; + u.y = s.y; + u.z = -this.m_impulse.z; + this.m_impulse.x += s.x; + this.m_impulse.y += s.y; + this.m_impulse.z = 0; + } else this.m_impulse.SelfAdd(u); else if (this.m_limitState === t.b2LimitState.e_atUpperLimit) if (this.m_impulse.z + u.z > 0) { + const t = -e.x + this.m_impulse.z * this.m_mass.ez.x; + const i = -e.y + this.m_impulse.z * this.m_mass.ez.y; + const s = this.m_mass.Solve22(t, i, Rs.SolveVelocityConstraints_s_reduced_v2); + u.x = s.x; + u.y = s.y; + u.z = -this.m_impulse.z; + this.m_impulse.x += s.x; + this.m_impulse.y += s.y; + this.m_impulse.z = 0; + } else this.m_impulse.SelfAdd(u); + const _ = Rs.SolveVelocityConstraints_s_P.Set(u.x, u.y); + i.SelfMulSub(o, _); + s -= l * (St.CrossVV(this.m_rA, _) + u.z); + n.SelfMulAdd(a, _); + r += h * (St.CrossVV(this.m_rB, _) + u.z); + } else { + const t = St.SubVV(St.AddVCrossSV(n, r, this.m_rB, St.s_t0), St.AddVCrossSV(i, s, this.m_rA, St.s_t1), Rs.SolveVelocityConstraints_s_Cdot_v2); + const e = this.m_mass.Solve22(-t.x, -t.y, Rs.SolveVelocityConstraints_s_impulse_v2); + this.m_impulse.x += e.x; + this.m_impulse.y += e.y; + i.SelfMulSub(o, e); + s -= l * St.CrossVV(this.m_rA, e); + n.SelfMulAdd(a, e); + r += h * St.CrossVV(this.m_rB, e); + } + e.velocities[this.m_indexA].w = s; + e.velocities[this.m_indexB].w = r; + } + SolvePositionConstraints(e) { + const i = e.positions[this.m_indexA].c; + let s = e.positions[this.m_indexA].a; + const n = e.positions[this.m_indexB].c; + let r = e.positions[this.m_indexB].a; + const o = this.m_qA.SetAngle(s), a = this.m_qB.SetAngle(r); + let l = 0; + let h = 0; + const c = this.m_invIA + this.m_invIB === 0; + if (this.m_enableLimit && this.m_limitState !== t.b2LimitState.e_inactiveLimit && !c) { + const e = r - s - this.m_referenceAngle; + let i = 0; + if (this.m_limitState === t.b2LimitState.e_equalLimits) { + const t = it(e - this.m_lowerAngle, -y, y); + i = -this.m_motorMass * t; + l = $(t); + } else if (this.m_limitState === t.b2LimitState.e_atLowerLimit) { + let t = e - this.m_lowerAngle; + l = -t; + t = it(t + _, -y, 0); + i = -this.m_motorMass * t; + } else if (this.m_limitState === t.b2LimitState.e_atUpperLimit) { + let t = e - this.m_upperAngle; + l = t; + t = it(t - _, 0, y); + i = -this.m_motorMass * t; + } + s -= this.m_invIA * i; + r += this.m_invIB * i; + } + { + o.SetAngle(s); + a.SetAngle(r); + St.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + const t = Ct.MulRV(o, this.m_lalcA, this.m_rA); + St.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + const e = Ct.MulRV(a, this.m_lalcB, this.m_rB); + const l = St.SubVV(St.AddVV(n, e, St.s_t0), St.AddVV(i, t, St.s_t1), Rs.SolvePositionConstraints_s_C_v2); + h = l.Length(); + const c = this.m_invMassA, u = this.m_invMassB; + const _ = this.m_invIA, d = this.m_invIB; + const p = this.m_K; + p.ex.x = c + u + _ * t.y * t.y + d * e.y * e.y; + p.ex.y = -_ * t.x * t.y - d * e.x * e.y; + p.ey.x = p.ex.y; + p.ey.y = c + u + _ * t.x * t.x + d * e.x * e.x; + const m = p.Solve(l.x, l.y, Rs.SolvePositionConstraints_s_impulse).SelfNeg(); + i.SelfMulSub(c, m); + s -= _ * St.CrossVV(t, m); + n.SelfMulAdd(u, m); + r += d * St.CrossVV(e, m); + } + e.positions[this.m_indexA].a = s; + e.positions[this.m_indexB].a = r; + return h <= u && l <= _; + } + GetAnchorA(t) { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, t); + } + GetAnchorB(t) { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, t); + } + GetReactionForce(t, e) { + e.x = t * this.m_impulse.x; + e.y = t * this.m_impulse.y; + return e; + } + GetReactionTorque(t) { + return t * this.m_impulse.z; + } + GetLocalAnchorA() { + return this.m_localAnchorA; + } + GetLocalAnchorB() { + return this.m_localAnchorB; + } + GetReferenceAngle() { + return this.m_referenceAngle; + } + GetJointAngle() { + return this.m_bodyB.m_sweep.a - this.m_bodyA.m_sweep.a - this.m_referenceAngle; + } + GetJointSpeed() { + return this.m_bodyB.m_angularVelocity - this.m_bodyA.m_angularVelocity; + } + IsMotorEnabled() { + return this.m_enableMotor; + } + EnableMotor(t) { + if (t !== this.m_enableMotor) { + this.m_bodyA.SetAwake(!0); + this.m_bodyB.SetAwake(!0); + this.m_enableMotor = t; + } + } + GetMotorTorque(t) { + return t * this.m_motorImpulse; + } + GetMotorSpeed() { + return this.m_motorSpeed; + } + SetMaxMotorTorque(t) { + if (t !== this.m_maxMotorTorque) { + this.m_bodyA.SetAwake(!0); + this.m_bodyB.SetAwake(!0); + this.m_maxMotorTorque = t; + } + } + GetMaxMotorTorque() { + return this.m_maxMotorTorque; + } + IsLimitEnabled() { + return this.m_enableLimit; + } + EnableLimit(t) { + if (t !== this.m_enableLimit) { + this.m_bodyA.SetAwake(!0); + this.m_bodyB.SetAwake(!0); + this.m_enableLimit = t; + this.m_impulse.z = 0; + } + } + GetLowerLimit() { + return this.m_lowerAngle; + } + GetUpperLimit() { + return this.m_upperAngle; + } + SetLimits(t, e) { + if (t !== this.m_lowerAngle || e !== this.m_upperAngle) { + this.m_bodyA.SetAwake(!0); + this.m_bodyB.SetAwake(!0); + this.m_impulse.z = 0; + this.m_lowerAngle = t; + this.m_upperAngle = e; + } + } + SetMotorSpeed(t) { + if (t !== this.m_motorSpeed) { + this.m_bodyA.SetAwake(!0); + this.m_bodyB.SetAwake(!0); + this.m_motorSpeed = t; + } + } + Dump(t) { + const e = this.m_bodyA.m_islandIndex; + const i = this.m_bodyB.m_islandIndex; + t(" const jd: b2RevoluteJointDef = new b2RevoluteJointDef();\n"); + t(" jd.bodyA = bodies[%d];\n", e); + t(" jd.bodyB = bodies[%d];\n", i); + t(" jd.collideConnected = %s;\n", this.m_collideConnected ? "true" : "false"); + t(" jd.localAnchorA.Set(%.15f, %.15f);\n", this.m_localAnchorA.x, this.m_localAnchorA.y); + t(" jd.localAnchorB.Set(%.15f, %.15f);\n", this.m_localAnchorB.x, this.m_localAnchorB.y); + t(" jd.referenceAngle = %.15f;\n", this.m_referenceAngle); + t(" jd.enableLimit = %s;\n", this.m_enableLimit ? "true" : "false"); + t(" jd.lowerAngle = %.15f;\n", this.m_lowerAngle); + t(" jd.upperAngle = %.15f;\n", this.m_upperAngle); + t(" jd.enableMotor = %s;\n", this.m_enableMotor ? "true" : "false"); + t(" jd.motorSpeed = %.15f;\n", this.m_motorSpeed); + t(" jd.maxMotorTorque = %.15f;\n", this.m_maxMotorTorque); + t(" joints[%d] = this.m_world.CreateJoint(jd);\n", this.m_index); + } + } + Rs.InitVelocityConstraints_s_P = new St; + Rs.SolveVelocityConstraints_s_P = new St; + Rs.SolveVelocityConstraints_s_Cdot_v2 = new St; + Rs.SolveVelocityConstraints_s_Cdot1 = new St; + Rs.SolveVelocityConstraints_s_impulse_v3 = new Tt; + Rs.SolveVelocityConstraints_s_reduced_v2 = new St; + Rs.SolveVelocityConstraints_s_impulse_v2 = new St; + Rs.SolvePositionConstraints_s_C_v2 = new St; + Rs.SolvePositionConstraints_s_impulse = new St; + class Is extends ls { + constructor() { + super(t.b2JointType.e_ropeJoint); + this.localAnchorA = new St(-1, 0); + this.localAnchorB = new St(1, 0); + this.maxLength = 0; + } + } + class Ms extends hs { + constructor(e) { + super(e); + this.m_localAnchorA = new St; + this.m_localAnchorB = new St; + this.m_maxLength = 0; + this.m_length = 0; + this.m_impulse = 0; + this.m_indexA = 0; + this.m_indexB = 0; + this.m_u = new St; + this.m_rA = new St; + this.m_rB = new St; + this.m_localCenterA = new St; + this.m_localCenterB = new St; + this.m_invMassA = 0; + this.m_invMassB = 0; + this.m_invIA = 0; + this.m_invIB = 0; + this.m_mass = 0; + this.m_state = t.b2LimitState.e_inactiveLimit; + this.m_qA = new Ct; + this.m_qB = new Ct; + this.m_lalcA = new St; + this.m_lalcB = new St; + this.m_localAnchorA.Copy(i(e.localAnchorA, new St(-1, 0))); + this.m_localAnchorB.Copy(i(e.localAnchorB, new St(1, 0))); + this.m_maxLength = i(e.maxLength, 0); + } + InitVelocityConstraints(e) { + this.m_indexA = this.m_bodyA.m_islandIndex; + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter); + this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_invMassA = this.m_bodyA.m_invMass; + this.m_invMassB = this.m_bodyB.m_invMass; + this.m_invIA = this.m_bodyA.m_invI; + this.m_invIB = this.m_bodyB.m_invI; + const i = e.positions[this.m_indexA].c; + const s = e.positions[this.m_indexA].a; + const n = e.velocities[this.m_indexA].v; + let r = e.velocities[this.m_indexA].w; + const o = e.positions[this.m_indexB].c; + const a = e.positions[this.m_indexB].a; + const l = e.velocities[this.m_indexB].v; + let h = e.velocities[this.m_indexB].w; + const c = this.m_qA.SetAngle(s), _ = this.m_qB.SetAngle(a); + St.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + Ct.MulRV(c, this.m_lalcA, this.m_rA); + St.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + Ct.MulRV(_, this.m_lalcB, this.m_rB); + this.m_u.Copy(o).SelfAdd(this.m_rB).SelfSub(i).SelfSub(this.m_rA); + this.m_length = this.m_u.Length(); + const d = this.m_length - this.m_maxLength; + this.m_state = d > 0 ? t.b2LimitState.e_atUpperLimit : t.b2LimitState.e_inactiveLimit; + if (!(this.m_length > u)) { + this.m_u.SetZero(); + this.m_mass = 0; + this.m_impulse = 0; + return; + } + this.m_u.SelfMul(1 / this.m_length); + const p = St.CrossVV(this.m_rA, this.m_u); + const m = St.CrossVV(this.m_rB, this.m_u); + const f = this.m_invMassA + this.m_invIA * p * p + this.m_invMassB + this.m_invIB * m * m; + this.m_mass = 0 !== f ? 1 / f : 0; + if (e.step.warmStarting) { + this.m_impulse *= e.step.dtRatio; + const t = St.MulSV(this.m_impulse, this.m_u, Ms.InitVelocityConstraints_s_P); + n.SelfMulSub(this.m_invMassA, t); + r -= this.m_invIA * St.CrossVV(this.m_rA, t); + l.SelfMulAdd(this.m_invMassB, t); + h += this.m_invIB * St.CrossVV(this.m_rB, t); + } else this.m_impulse = 0; + e.velocities[this.m_indexA].w = r; + e.velocities[this.m_indexB].w = h; + } + SolveVelocityConstraints(t) { + const e = t.velocities[this.m_indexA].v; + let i = t.velocities[this.m_indexA].w; + const s = t.velocities[this.m_indexB].v; + let n = t.velocities[this.m_indexB].w; + const r = St.AddVCrossSV(e, i, this.m_rA, Ms.SolveVelocityConstraints_s_vpA); + const o = St.AddVCrossSV(s, n, this.m_rB, Ms.SolveVelocityConstraints_s_vpB); + const a = this.m_length - this.m_maxLength; + let l = St.DotVV(this.m_u, St.SubVV(o, r, St.s_t0)); + a < 0 && (l += t.step.inv_dt * a); + let h = -this.m_mass * l; + const c = this.m_impulse; + this.m_impulse = tt(0, this.m_impulse + h); + h = this.m_impulse - c; + const u = St.MulSV(h, this.m_u, Ms.SolveVelocityConstraints_s_P); + e.SelfMulSub(this.m_invMassA, u); + i -= this.m_invIA * St.CrossVV(this.m_rA, u); + s.SelfMulAdd(this.m_invMassB, u); + n += this.m_invIB * St.CrossVV(this.m_rB, u); + t.velocities[this.m_indexA].w = i; + t.velocities[this.m_indexB].w = n; + } + SolvePositionConstraints(t) { + const e = t.positions[this.m_indexA].c; + let i = t.positions[this.m_indexA].a; + const s = t.positions[this.m_indexB].c; + let n = t.positions[this.m_indexB].a; + const r = this.m_qA.SetAngle(i), o = this.m_qB.SetAngle(n); + St.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + const a = Ct.MulRV(r, this.m_lalcA, this.m_rA); + St.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + const l = Ct.MulRV(o, this.m_lalcB, this.m_rB); + const h = this.m_u.Copy(s).SelfAdd(l).SelfSub(e).SelfSub(a); + const c = h.Normalize(); + let _ = c - this.m_maxLength; + _ = it(_, 0, g); + const d = -this.m_mass * _; + const p = St.MulSV(d, h, Ms.SolvePositionConstraints_s_P); + e.SelfMulSub(this.m_invMassA, p); + i -= this.m_invIA * St.CrossVV(a, p); + s.SelfMulAdd(this.m_invMassB, p); + n += this.m_invIB * St.CrossVV(l, p); + t.positions[this.m_indexA].a = i; + t.positions[this.m_indexB].a = n; + return c - this.m_maxLength < u; + } + GetAnchorA(t) { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, t); + } + GetAnchorB(t) { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, t); + } + GetReactionForce(t, e) { + return St.MulSV(t * this.m_impulse, this.m_u, e); + } + GetReactionTorque(t) { + return 0; + } + GetLocalAnchorA() { + return this.m_localAnchorA; + } + GetLocalAnchorB() { + return this.m_localAnchorB; + } + SetMaxLength(t) { + this.m_maxLength = t; + } + GetMaxLength() { + return this.m_maxLength; + } + GetLimitState() { + return this.m_state; + } + Dump(t) { + const e = this.m_bodyA.m_islandIndex; + const i = this.m_bodyB.m_islandIndex; + t(" const jd: b2RopeJointDef = new b2RopeJointDef();\n"); + t(" jd.bodyA = bodies[%d];\n", e); + t(" jd.bodyB = bodies[%d];\n", i); + t(" jd.collideConnected = %s;\n", this.m_collideConnected ? "true" : "false"); + t(" jd.localAnchorA.Set(%.15f, %.15f);\n", this.m_localAnchorA.x, this.m_localAnchorA.y); + t(" jd.localAnchorB.Set(%.15f, %.15f);\n", this.m_localAnchorB.x, this.m_localAnchorB.y); + t(" jd.maxLength = %.15f;\n", this.m_maxLength); + t(" joints[%d] = this.m_world.CreateJoint(jd);\n", this.m_index); + } + } + Ms.InitVelocityConstraints_s_P = new St; + Ms.SolveVelocityConstraints_s_vpA = new St; + Ms.SolveVelocityConstraints_s_vpB = new St; + Ms.SolveVelocityConstraints_s_P = new St; + Ms.SolvePositionConstraints_s_P = new St; + class Bs extends ls { + constructor() { + super(t.b2JointType.e_weldJoint); + this.localAnchorA = new St; + this.localAnchorB = new St; + this.referenceAngle = 0; + this.frequencyHz = 0; + this.dampingRatio = 0; + } + Initialize(t, e, i) { + this.bodyA = t; + this.bodyB = e; + this.bodyA.GetLocalPoint(i, this.localAnchorA); + this.bodyB.GetLocalPoint(i, this.localAnchorB); + this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle(); + } + } + class Ds extends hs { + constructor(t) { + super(t); + this.m_frequencyHz = 0; + this.m_dampingRatio = 0; + this.m_bias = 0; + this.m_localAnchorA = new St; + this.m_localAnchorB = new St; + this.m_referenceAngle = 0; + this.m_gamma = 0; + this.m_impulse = new Tt(0, 0, 0); + this.m_indexA = 0; + this.m_indexB = 0; + this.m_rA = new St; + this.m_rB = new St; + this.m_localCenterA = new St; + this.m_localCenterB = new St; + this.m_invMassA = 0; + this.m_invMassB = 0; + this.m_invIA = 0; + this.m_invIB = 0; + this.m_mass = new Et; + this.m_qA = new Ct; + this.m_qB = new Ct; + this.m_lalcA = new St; + this.m_lalcB = new St; + this.m_K = new Et; + this.m_frequencyHz = i(t.frequencyHz, 0); + this.m_dampingRatio = i(t.dampingRatio, 0); + this.m_localAnchorA.Copy(i(t.localAnchorA, St.ZERO)); + this.m_localAnchorB.Copy(i(t.localAnchorB, St.ZERO)); + this.m_referenceAngle = i(t.referenceAngle, 0); + this.m_impulse.SetZero(); + } + InitVelocityConstraints(t) { + this.m_indexA = this.m_bodyA.m_islandIndex; + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter); + this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_invMassA = this.m_bodyA.m_invMass; + this.m_invMassB = this.m_bodyB.m_invMass; + this.m_invIA = this.m_bodyA.m_invI; + this.m_invIB = this.m_bodyB.m_invI; + const e = t.positions[this.m_indexA].a; + const i = t.velocities[this.m_indexA].v; + let s = t.velocities[this.m_indexA].w; + const n = t.positions[this.m_indexB].a; + const r = t.velocities[this.m_indexB].v; + let a = t.velocities[this.m_indexB].w; + const l = this.m_qA.SetAngle(e), h = this.m_qB.SetAngle(n); + St.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + Ct.MulRV(l, this.m_lalcA, this.m_rA); + St.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + Ct.MulRV(h, this.m_lalcB, this.m_rB); + const c = this.m_invMassA, u = this.m_invMassB; + const _ = this.m_invIA, d = this.m_invIB; + const p = this.m_K; + p.ex.x = c + u + this.m_rA.y * this.m_rA.y * _ + this.m_rB.y * this.m_rB.y * d; + p.ey.x = -this.m_rA.y * this.m_rA.x * _ - this.m_rB.y * this.m_rB.x * d; + p.ez.x = -this.m_rA.y * _ - this.m_rB.y * d; + p.ex.y = p.ey.x; + p.ey.y = c + u + this.m_rA.x * this.m_rA.x * _ + this.m_rB.x * this.m_rB.x * d; + p.ez.y = this.m_rA.x * _ + this.m_rB.x * d; + p.ex.z = p.ez.x; + p.ey.z = p.ez.y; + p.ez.z = _ + d; + if (this.m_frequencyHz > 0) { + p.GetInverse22(this.m_mass); + let i = _ + d; + const s = i > 0 ? 1 / i : 0; + const r = n - e - this.m_referenceAngle; + const a = 2 * o * this.m_frequencyHz; + const l = 2 * s * this.m_dampingRatio * a; + const h = s * a * a; + const c = t.step.dt; + this.m_gamma = c * (l + c * h); + this.m_gamma = 0 !== this.m_gamma ? 1 / this.m_gamma : 0; + this.m_bias = r * c * h * this.m_gamma; + i += this.m_gamma; + this.m_mass.ez.z = 0 !== i ? 1 / i : 0; + } else { + p.GetSymInverse33(this.m_mass); + this.m_gamma = 0; + this.m_bias = 0; + } + if (t.step.warmStarting) { + this.m_impulse.SelfMul(t.step.dtRatio); + const e = Ds.InitVelocityConstraints_s_P.Set(this.m_impulse.x, this.m_impulse.y); + i.SelfMulSub(c, e); + s -= _ * (St.CrossVV(this.m_rA, e) + this.m_impulse.z); + r.SelfMulAdd(u, e); + a += d * (St.CrossVV(this.m_rB, e) + this.m_impulse.z); + } else this.m_impulse.SetZero(); + t.velocities[this.m_indexA].w = s; + t.velocities[this.m_indexB].w = a; + } + SolveVelocityConstraints(t) { + const e = t.velocities[this.m_indexA].v; + let i = t.velocities[this.m_indexA].w; + const s = t.velocities[this.m_indexB].v; + let n = t.velocities[this.m_indexB].w; + const r = this.m_invMassA, o = this.m_invMassB; + const a = this.m_invIA, l = this.m_invIB; + if (this.m_frequencyHz > 0) { + const t = n - i; + const h = -this.m_mass.ez.z * (t + this.m_bias + this.m_gamma * this.m_impulse.z); + this.m_impulse.z += h; + i -= a * h; + n += l * h; + const c = St.SubVV(St.AddVCrossSV(s, n, this.m_rB, St.s_t0), St.AddVCrossSV(e, i, this.m_rA, St.s_t1), Ds.SolveVelocityConstraints_s_Cdot1); + const u = Et.MulM33XY(this.m_mass, c.x, c.y, Ds.SolveVelocityConstraints_s_impulse1).SelfNeg(); + this.m_impulse.x += u.x; + this.m_impulse.y += u.y; + const _ = u; + e.SelfMulSub(r, _); + i -= a * St.CrossVV(this.m_rA, _); + s.SelfMulAdd(o, _); + n += l * St.CrossVV(this.m_rB, _); + } else { + const t = St.SubVV(St.AddVCrossSV(s, n, this.m_rB, St.s_t0), St.AddVCrossSV(e, i, this.m_rA, St.s_t1), Ds.SolveVelocityConstraints_s_Cdot1); + const h = n - i; + const c = Et.MulM33XYZ(this.m_mass, t.x, t.y, h, Ds.SolveVelocityConstraints_s_impulse).SelfNeg(); + this.m_impulse.SelfAdd(c); + const u = Ds.SolveVelocityConstraints_s_P.Set(c.x, c.y); + e.SelfMulSub(r, u); + i -= a * (St.CrossVV(this.m_rA, u) + c.z); + s.SelfMulAdd(o, u); + n += l * (St.CrossVV(this.m_rB, u) + c.z); + } + t.velocities[this.m_indexA].w = i; + t.velocities[this.m_indexB].w = n; + } + SolvePositionConstraints(t) { + const e = t.positions[this.m_indexA].c; + let i = t.positions[this.m_indexA].a; + const s = t.positions[this.m_indexB].c; + let n = t.positions[this.m_indexB].a; + const r = this.m_qA.SetAngle(i), o = this.m_qB.SetAngle(n); + const a = this.m_invMassA, l = this.m_invMassB; + const h = this.m_invIA, c = this.m_invIB; + St.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + const d = Ct.MulRV(r, this.m_lalcA, this.m_rA); + St.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + const p = Ct.MulRV(o, this.m_lalcB, this.m_rB); + let m, f; + const g = this.m_K; + g.ex.x = a + l + d.y * d.y * h + p.y * p.y * c; + g.ey.x = -d.y * d.x * h - p.y * p.x * c; + g.ez.x = -d.y * h - p.y * c; + g.ex.y = g.ey.x; + g.ey.y = a + l + d.x * d.x * h + p.x * p.x * c; + g.ez.y = d.x * h + p.x * c; + g.ex.z = g.ez.x; + g.ey.z = g.ez.y; + g.ez.z = h + c; + if (this.m_frequencyHz > 0) { + const t = St.SubVV(St.AddVV(s, p, St.s_t0), St.AddVV(e, d, St.s_t1), Ds.SolvePositionConstraints_s_C1); + m = t.Length(); + f = 0; + const r = g.Solve22(t.x, t.y, Ds.SolvePositionConstraints_s_P).SelfNeg(); + e.SelfMulSub(a, r); + i -= h * St.CrossVV(d, r); + s.SelfMulAdd(l, r); + n += c * St.CrossVV(p, r); + } else { + const t = St.SubVV(St.AddVV(s, p, St.s_t0), St.AddVV(e, d, St.s_t1), Ds.SolvePositionConstraints_s_C1); + const r = n - i - this.m_referenceAngle; + m = t.Length(); + f = $(r); + const o = g.Solve33(t.x, t.y, r, Ds.SolvePositionConstraints_s_impulse).SelfNeg(); + const u = Ds.SolvePositionConstraints_s_P.Set(o.x, o.y); + e.SelfMulSub(a, u); + i -= h * (St.CrossVV(this.m_rA, u) + o.z); + s.SelfMulAdd(l, u); + n += c * (St.CrossVV(this.m_rB, u) + o.z); + } + t.positions[this.m_indexA].a = i; + t.positions[this.m_indexB].a = n; + return m <= u && f <= _; + } + GetAnchorA(t) { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, t); + } + GetAnchorB(t) { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, t); + } + GetReactionForce(t, e) { + e.x = t * this.m_impulse.x; + e.y = t * this.m_impulse.y; + return e; + } + GetReactionTorque(t) { + return t * this.m_impulse.z; + } + GetLocalAnchorA() { + return this.m_localAnchorA; + } + GetLocalAnchorB() { + return this.m_localAnchorB; + } + GetReferenceAngle() { + return this.m_referenceAngle; + } + SetFrequency(t) { + this.m_frequencyHz = t; + } + GetFrequency() { + return this.m_frequencyHz; + } + SetDampingRatio(t) { + this.m_dampingRatio = t; + } + GetDampingRatio() { + return this.m_dampingRatio; + } + Dump(t) { + const e = this.m_bodyA.m_islandIndex; + const i = this.m_bodyB.m_islandIndex; + t(" const jd: b2WeldJointDef = new b2WeldJointDef();\n"); + t(" jd.bodyA = bodies[%d];\n", e); + t(" jd.bodyB = bodies[%d];\n", i); + t(" jd.collideConnected = %s;\n", this.m_collideConnected ? "true" : "false"); + t(" jd.localAnchorA.Set(%.15f, %.15f);\n", this.m_localAnchorA.x, this.m_localAnchorA.y); + t(" jd.localAnchorB.Set(%.15f, %.15f);\n", this.m_localAnchorB.x, this.m_localAnchorB.y); + t(" jd.referenceAngle = %.15f;\n", this.m_referenceAngle); + t(" jd.frequencyHz = %.15f;\n", this.m_frequencyHz); + t(" jd.dampingRatio = %.15f;\n", this.m_dampingRatio); + t(" joints[%d] = this.m_world.CreateJoint(jd);\n", this.m_index); + } + } + Ds.InitVelocityConstraints_s_P = new St; + Ds.SolveVelocityConstraints_s_Cdot1 = new St; + Ds.SolveVelocityConstraints_s_impulse1 = new St; + Ds.SolveVelocityConstraints_s_impulse = new Tt; + Ds.SolveVelocityConstraints_s_P = new St; + Ds.SolvePositionConstraints_s_C1 = new St; + Ds.SolvePositionConstraints_s_P = new St; + Ds.SolvePositionConstraints_s_impulse = new Tt; + class Ps extends ls { + constructor() { + super(t.b2JointType.e_wheelJoint); + this.localAnchorA = new St(0, 0); + this.localAnchorB = new St(0, 0); + this.localAxisA = new St(1, 0); + this.enableMotor = !1; + this.maxMotorTorque = 0; + this.motorSpeed = 0; + this.frequencyHz = 2; + this.dampingRatio = .7; + } + Initialize(t, e, i, s) { + this.bodyA = t; + this.bodyB = e; + this.bodyA.GetLocalPoint(i, this.localAnchorA); + this.bodyB.GetLocalPoint(i, this.localAnchorB); + this.bodyA.GetLocalVector(s, this.localAxisA); + } + } + class Os extends hs { + constructor(t) { + super(t); + this.m_frequencyHz = 0; + this.m_dampingRatio = 0; + this.m_localAnchorA = new St; + this.m_localAnchorB = new St; + this.m_localXAxisA = new St; + this.m_localYAxisA = new St; + this.m_impulse = 0; + this.m_motorImpulse = 0; + this.m_springImpulse = 0; + this.m_maxMotorTorque = 0; + this.m_motorSpeed = 0; + this.m_enableMotor = !1; + this.m_indexA = 0; + this.m_indexB = 0; + this.m_localCenterA = new St; + this.m_localCenterB = new St; + this.m_invMassA = 0; + this.m_invMassB = 0; + this.m_invIA = 0; + this.m_invIB = 0; + this.m_ax = new St; + this.m_ay = new St; + this.m_sAx = 0; + this.m_sBx = 0; + this.m_sAy = 0; + this.m_sBy = 0; + this.m_mass = 0; + this.m_motorMass = 0; + this.m_springMass = 0; + this.m_bias = 0; + this.m_gamma = 0; + this.m_qA = new Ct; + this.m_qB = new Ct; + this.m_lalcA = new St; + this.m_lalcB = new St; + this.m_rA = new St; + this.m_rB = new St; + this.m_frequencyHz = i(t.frequencyHz, 2); + this.m_dampingRatio = i(t.dampingRatio, .7); + this.m_localAnchorA.Copy(i(t.localAnchorA, St.ZERO)); + this.m_localAnchorB.Copy(i(t.localAnchorB, St.ZERO)); + this.m_localXAxisA.Copy(i(t.localAxisA, St.UNITX)); + St.CrossOneV(this.m_localXAxisA, this.m_localYAxisA); + this.m_maxMotorTorque = i(t.maxMotorTorque, 0); + this.m_motorSpeed = i(t.motorSpeed, 0); + this.m_enableMotor = i(t.enableMotor, !1); + this.m_ax.SetZero(); + this.m_ay.SetZero(); + } + GetMotorSpeed() { + return this.m_motorSpeed; + } + GetMaxMotorTorque() { + return this.m_maxMotorTorque; + } + SetSpringFrequencyHz(t) { + this.m_frequencyHz = t; + } + GetSpringFrequencyHz() { + return this.m_frequencyHz; + } + SetSpringDampingRatio(t) { + this.m_dampingRatio = t; + } + GetSpringDampingRatio() { + return this.m_dampingRatio; + } + InitVelocityConstraints(t) { + this.m_indexA = this.m_bodyA.m_islandIndex; + this.m_indexB = this.m_bodyB.m_islandIndex; + this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter); + this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter); + this.m_invMassA = this.m_bodyA.m_invMass; + this.m_invMassB = this.m_bodyB.m_invMass; + this.m_invIA = this.m_bodyA.m_invI; + this.m_invIB = this.m_bodyB.m_invI; + const e = this.m_invMassA, i = this.m_invMassB; + const s = this.m_invIA, n = this.m_invIB; + const r = t.positions[this.m_indexA].c; + const a = t.positions[this.m_indexA].a; + const l = t.velocities[this.m_indexA].v; + let h = t.velocities[this.m_indexA].w; + const c = t.positions[this.m_indexB].c; + const u = t.positions[this.m_indexB].a; + const _ = t.velocities[this.m_indexB].v; + let d = t.velocities[this.m_indexB].w; + const p = this.m_qA.SetAngle(a), m = this.m_qB.SetAngle(u); + St.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + const f = Ct.MulRV(p, this.m_lalcA, this.m_rA); + St.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + const g = Ct.MulRV(m, this.m_lalcB, this.m_rB); + const y = St.SubVV(St.AddVV(c, g, St.s_t0), St.AddVV(r, f, St.s_t1), Os.InitVelocityConstraints_s_d); + Ct.MulRV(p, this.m_localYAxisA, this.m_ay); + this.m_sAy = St.CrossVV(St.AddVV(y, f, St.s_t0), this.m_ay); + this.m_sBy = St.CrossVV(g, this.m_ay); + this.m_mass = e + i + s * this.m_sAy * this.m_sAy + n * this.m_sBy * this.m_sBy; + this.m_mass > 0 && (this.m_mass = 1 / this.m_mass); + this.m_springMass = 0; + this.m_bias = 0; + this.m_gamma = 0; + if (this.m_frequencyHz > 0) { + Ct.MulRV(p, this.m_localXAxisA, this.m_ax); + this.m_sAx = St.CrossVV(St.AddVV(y, f, St.s_t0), this.m_ax); + this.m_sBx = St.CrossVV(g, this.m_ax); + const r = e + i + s * this.m_sAx * this.m_sAx + n * this.m_sBx * this.m_sBx; + if (r > 0) { + this.m_springMass = 1 / r; + const e = St.DotVV(y, this.m_ax); + const i = 2 * o * this.m_frequencyHz; + const s = 2 * this.m_springMass * this.m_dampingRatio * i; + const n = this.m_springMass * i * i; + const a = t.step.dt; + this.m_gamma = a * (s + a * n); + this.m_gamma > 0 && (this.m_gamma = 1 / this.m_gamma); + this.m_bias = e * a * n * this.m_gamma; + this.m_springMass = r + this.m_gamma; + this.m_springMass > 0 && (this.m_springMass = 1 / this.m_springMass); + } + } else this.m_springImpulse = 0; + if (this.m_enableMotor) { + this.m_motorMass = s + n; + this.m_motorMass > 0 && (this.m_motorMass = 1 / this.m_motorMass); + } else { + this.m_motorMass = 0; + this.m_motorImpulse = 0; + } + if (t.step.warmStarting) { + this.m_impulse *= t.step.dtRatio; + this.m_springImpulse *= t.step.dtRatio; + this.m_motorImpulse *= t.step.dtRatio; + const e = St.AddVV(St.MulSV(this.m_impulse, this.m_ay, St.s_t0), St.MulSV(this.m_springImpulse, this.m_ax, St.s_t1), Os.InitVelocityConstraints_s_P); + const i = this.m_impulse * this.m_sAy + this.m_springImpulse * this.m_sAx + this.m_motorImpulse; + const s = this.m_impulse * this.m_sBy + this.m_springImpulse * this.m_sBx + this.m_motorImpulse; + l.SelfMulSub(this.m_invMassA, e); + h -= this.m_invIA * i; + _.SelfMulAdd(this.m_invMassB, e); + d += this.m_invIB * s; + } else { + this.m_impulse = 0; + this.m_springImpulse = 0; + this.m_motorImpulse = 0; + } + t.velocities[this.m_indexA].w = h; + t.velocities[this.m_indexB].w = d; + } + SolveVelocityConstraints(t) { + const e = this.m_invMassA, i = this.m_invMassB; + const s = this.m_invIA, n = this.m_invIB; + const r = t.velocities[this.m_indexA].v; + let o = t.velocities[this.m_indexA].w; + const a = t.velocities[this.m_indexB].v; + let l = t.velocities[this.m_indexB].w; + { + const t = St.DotVV(this.m_ax, St.SubVV(a, r, St.s_t0)) + this.m_sBx * l - this.m_sAx * o; + const h = -this.m_springMass * (t + this.m_bias + this.m_gamma * this.m_springImpulse); + this.m_springImpulse += h; + const c = St.MulSV(h, this.m_ax, Os.SolveVelocityConstraints_s_P); + const u = h * this.m_sAx; + const _ = h * this.m_sBx; + r.SelfMulSub(e, c); + o -= s * u; + a.SelfMulAdd(i, c); + l += n * _; + } + { + const e = l - o - this.m_motorSpeed; + let i = -this.m_motorMass * e; + const r = this.m_motorImpulse; + const a = t.step.dt * this.m_maxMotorTorque; + this.m_motorImpulse = it(this.m_motorImpulse + i, -a, a); + i = this.m_motorImpulse - r; + o -= s * i; + l += n * i; + } + { + const t = St.DotVV(this.m_ay, St.SubVV(a, r, St.s_t0)) + this.m_sBy * l - this.m_sAy * o; + const h = -this.m_mass * t; + this.m_impulse += h; + const c = St.MulSV(h, this.m_ay, Os.SolveVelocityConstraints_s_P); + const u = h * this.m_sAy; + const _ = h * this.m_sBy; + r.SelfMulSub(e, c); + o -= s * u; + a.SelfMulAdd(i, c); + l += n * _; + } + t.velocities[this.m_indexA].w = o; + t.velocities[this.m_indexB].w = l; + } + SolvePositionConstraints(t) { + const e = t.positions[this.m_indexA].c; + let i = t.positions[this.m_indexA].a; + const s = t.positions[this.m_indexB].c; + let n = t.positions[this.m_indexB].a; + const r = this.m_qA.SetAngle(i), o = this.m_qB.SetAngle(n); + St.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA); + const a = Ct.MulRV(r, this.m_lalcA, this.m_rA); + St.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB); + const l = Ct.MulRV(o, this.m_lalcB, this.m_rB); + const h = St.AddVV(St.SubVV(s, e, St.s_t0), St.SubVV(l, a, St.s_t1), Os.SolvePositionConstraints_s_d); + const c = Ct.MulRV(r, this.m_localYAxisA, this.m_ay); + const _ = St.CrossVV(St.AddVV(h, a, St.s_t0), c); + const d = St.CrossVV(l, c); + const p = St.DotVV(h, this.m_ay); + const m = this.m_invMassA + this.m_invMassB + this.m_invIA * this.m_sAy * this.m_sAy + this.m_invIB * this.m_sBy * this.m_sBy; + let f; + f = 0 !== m ? -p / m : 0; + const g = St.MulSV(f, c, Os.SolvePositionConstraints_s_P); + const y = f * _; + const b = f * d; + e.SelfMulSub(this.m_invMassA, g); + i -= this.m_invIA * y; + s.SelfMulAdd(this.m_invMassB, g); + n += this.m_invIB * b; + t.positions[this.m_indexA].a = i; + t.positions[this.m_indexB].a = n; + return $(p) <= u; + } + GetDefinition(t) { + return t; + } + GetAnchorA(t) { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, t); + } + GetAnchorB(t) { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, t); + } + GetReactionForce(t, e) { + e.x = t * (this.m_impulse * this.m_ay.x + this.m_springImpulse * this.m_ax.x); + e.y = t * (this.m_impulse * this.m_ay.y + this.m_springImpulse * this.m_ax.y); + return e; + } + GetReactionTorque(t) { + return t * this.m_motorImpulse; + } + GetLocalAnchorA() { + return this.m_localAnchorA; + } + GetLocalAnchorB() { + return this.m_localAnchorB; + } + GetLocalAxisA() { + return this.m_localXAxisA; + } + GetJointTranslation() { + return this.GetPrismaticJointTranslation(); + } + GetJointLinearSpeed() { + return this.GetPrismaticJointSpeed(); + } + GetJointAngle() { + return this.GetRevoluteJointAngle(); + } + GetJointAngularSpeed() { + return this.GetRevoluteJointSpeed(); + } + GetPrismaticJointTranslation() { + const t = this.m_bodyA; + const e = this.m_bodyB; + const i = t.GetWorldPoint(this.m_localAnchorA, new St); + const s = e.GetWorldPoint(this.m_localAnchorB, new St); + const n = St.SubVV(s, i, new St); + const r = t.GetWorldVector(this.m_localXAxisA, new St); + return St.DotVV(n, r); + } + GetPrismaticJointSpeed() { + const t = this.m_bodyA; + const e = this.m_bodyB; + St.SubVV(this.m_localAnchorA, t.m_sweep.localCenter, this.m_lalcA); + const i = Ct.MulRV(t.m_xf.q, this.m_lalcA, this.m_rA); + St.SubVV(this.m_localAnchorB, e.m_sweep.localCenter, this.m_lalcB); + const s = Ct.MulRV(e.m_xf.q, this.m_lalcB, this.m_rB); + const n = St.AddVV(t.m_sweep.c, i, St.s_t0); + const r = St.AddVV(e.m_sweep.c, s, St.s_t1); + const o = St.SubVV(r, n, St.s_t2); + const a = t.GetWorldVector(this.m_localXAxisA, new St); + const l = t.m_linearVelocity; + const h = e.m_linearVelocity; + const c = t.m_angularVelocity; + const u = e.m_angularVelocity; + return St.DotVV(o, St.CrossSV(c, a, St.s_t0)) + St.DotVV(a, St.SubVV(St.AddVCrossSV(h, u, s, St.s_t0), St.AddVCrossSV(l, c, i, St.s_t1), St.s_t0)); + } + GetRevoluteJointAngle() { + return this.m_bodyB.m_sweep.a - this.m_bodyA.m_sweep.a; + } + GetRevoluteJointSpeed() { + const t = this.m_bodyA.m_angularVelocity; + return this.m_bodyB.m_angularVelocity - t; + } + IsMotorEnabled() { + return this.m_enableMotor; + } + EnableMotor(t) { + if (t !== this.m_enableMotor) { + this.m_bodyA.SetAwake(!0); + this.m_bodyB.SetAwake(!0); + this.m_enableMotor = t; + } + } + SetMotorSpeed(t) { + if (t !== this.m_motorSpeed) { + this.m_bodyA.SetAwake(!0); + this.m_bodyB.SetAwake(!0); + this.m_motorSpeed = t; + } + } + SetMaxMotorTorque(t) { + if (t !== this.m_maxMotorTorque) { + this.m_bodyA.SetAwake(!0); + this.m_bodyB.SetAwake(!0); + this.m_maxMotorTorque = t; + } + } + GetMotorTorque(t) { + return t * this.m_motorImpulse; + } + Dump(t) { + const e = this.m_bodyA.m_islandIndex; + const i = this.m_bodyB.m_islandIndex; + t(" const jd: b2WheelJointDef = new b2WheelJointDef();\n"); + t(" jd.bodyA = bodies[%d];\n", e); + t(" jd.bodyB = bodies[%d];\n", i); + t(" jd.collideConnected = %s;\n", this.m_collideConnected ? "true" : "false"); + t(" jd.localAnchorA.Set(%.15f, %.15f);\n", this.m_localAnchorA.x, this.m_localAnchorA.y); + t(" jd.localAnchorB.Set(%.15f, %.15f);\n", this.m_localAnchorB.x, this.m_localAnchorB.y); + t(" jd.localAxisA.Set(%.15f, %.15f);\n", this.m_localXAxisA.x, this.m_localXAxisA.y); + t(" jd.enableMotor = %s;\n", this.m_enableMotor ? "true" : "false"); + t(" jd.motorSpeed = %.15f;\n", this.m_motorSpeed); + t(" jd.maxMotorTorque = %.15f;\n", this.m_maxMotorTorque); + t(" jd.frequencyHz = %.15f;\n", this.m_frequencyHz); + t(" jd.dampingRatio = %.15f;\n", this.m_dampingRatio); + t(" joints[%d] = this.m_world.CreateJoint(jd);\n", this.m_index); + } + } + Os.InitVelocityConstraints_s_d = new St; + Os.InitVelocityConstraints_s_P = new St; + Os.SolveVelocityConstraints_s_P = new St; + Os.SolvePositionConstraints_s_d = new St; + Os.SolvePositionConstraints_s_P = new St; + function Ns(t, e) { + return at(t * e); + } + function Ls(t, e) { + return t > e ? t : e; + } + class Fs { + constructor(t) { + this._other = null; + this.prev = null; + this.next = null; + this.contact = t; + } + get other() { + if (null === this._other) throw new Error; + return this._other; + } + set other(t) { + if (null !== this._other) throw new Error; + this._other = t; + } + Reset() { + this._other = null; + this.prev = null; + this.next = null; + } + } + class Vs { + constructor() { + this.m_islandFlag = !1; + this.m_touchingFlag = !1; + this.m_enabledFlag = !1; + this.m_filterFlag = !1; + this.m_bulletHitFlag = !1; + this.m_toiFlag = !1; + this.m_prev = null; + this.m_next = null; + this.m_nodeA = new Fs(this); + this.m_nodeB = new Fs(this); + this.m_indexA = 0; + this.m_indexB = 0; + this.m_manifold = new ue; + this.m_toiCount = 0; + this.m_toi = 0; + this.m_friction = 0; + this.m_restitution = 0; + this.m_tangentSpeed = 0; + this.m_oldManifold = new ue; + } + GetManifold() { + return this.m_manifold; + } + GetWorldManifold(t) { + const e = this.m_fixtureA.GetBody(); + const i = this.m_fixtureB.GetBody(); + const s = this.GetShapeA(); + const n = this.GetShapeB(); + t.Initialize(this.m_manifold, e.GetTransform(), s.m_radius, i.GetTransform(), n.m_radius); + } + IsTouching() { + return this.m_touchingFlag; + } + SetEnabled(t) { + this.m_enabledFlag = t; + } + IsEnabled() { + return this.m_enabledFlag; + } + GetNext() { + return this.m_next; + } + GetFixtureA() { + return this.m_fixtureA; + } + GetChildIndexA() { + return this.m_indexA; + } + GetShapeA() { + return this.m_fixtureA.GetShape(); + } + GetFixtureB() { + return this.m_fixtureB; + } + GetChildIndexB() { + return this.m_indexB; + } + GetShapeB() { + return this.m_fixtureB.GetShape(); + } + FlagForFiltering() { + this.m_filterFlag = !0; + } + SetFriction(t) { + this.m_friction = t; + } + GetFriction() { + return this.m_friction; + } + ResetFriction() { + this.m_friction = Ns(this.m_fixtureA.m_friction, this.m_fixtureB.m_friction); + } + SetRestitution(t) { + this.m_restitution = t; + } + GetRestitution() { + return this.m_restitution; + } + ResetRestitution() { + this.m_restitution = Ls(this.m_fixtureA.m_restitution, this.m_fixtureB.m_restitution); + } + SetTangentSpeed(t) { + this.m_tangentSpeed = t; + } + GetTangentSpeed() { + return this.m_tangentSpeed; + } + Reset(t, e, i, s) { + this.m_islandFlag = !1; + this.m_touchingFlag = !1; + this.m_enabledFlag = !0; + this.m_filterFlag = !1; + this.m_bulletHitFlag = !1; + this.m_toiFlag = !1; + this.m_fixtureA = t; + this.m_fixtureB = i; + this.m_indexA = e; + this.m_indexB = s; + this.m_manifold.pointCount = 0; + this.m_prev = null; + this.m_next = null; + this.m_nodeA.Reset(); + this.m_nodeB.Reset(); + this.m_toiCount = 0; + this.m_friction = Ns(this.m_fixtureA.m_friction, this.m_fixtureB.m_friction); + this.m_restitution = Ls(this.m_fixtureA.m_restitution, this.m_fixtureB.m_restitution); + } + Update(t) { + const e = this.m_oldManifold; + this.m_oldManifold = this.m_manifold; + this.m_manifold = e; + this.m_enabledFlag = !0; + let i = !1; + const s = this.m_touchingFlag; + const n = this.m_fixtureA.IsSensor(); + const r = this.m_fixtureB.IsSensor(); + const o = n || r; + const a = this.m_fixtureA.GetBody(); + const l = this.m_fixtureB.GetBody(); + const h = a.GetTransform(); + const c = l.GetTransform(); + if (o) { + const t = this.GetShapeA(); + const e = this.GetShapeB(); + i = ve(t, this.m_indexA, e, this.m_indexB, h, c); + this.m_manifold.pointCount = 0; + } else { + this.Evaluate(this.m_manifold, h, c); + i = this.m_manifold.pointCount > 0; + for (let t = 0; t < this.m_manifold.pointCount; ++t) { + const e = this.m_manifold.points[t]; + e.normalImpulse = 0; + e.tangentImpulse = 0; + const i = e.id; + for (let t = 0; t < this.m_oldManifold.pointCount; ++t) { + const s = this.m_oldManifold.points[t]; + if (s.id.key === i.key) { + e.normalImpulse = s.normalImpulse; + e.tangentImpulse = s.tangentImpulse; + break; + } + } + } + if (i !== s) { + a.SetAwake(!0); + l.SetAwake(!0); + } + } + this.m_touchingFlag = i; + !s && i && t && t.BeginContact(this); + s && !i && t && t.EndContact(this); + !o && i && t && t.PreSolve(this, this.m_oldManifold); + } + ComputeTOI(t, e) { + const i = Vs.ComputeTOI_s_input; + i.proxyA.SetShape(this.GetShapeA(), this.m_indexA); + i.proxyB.SetShape(this.GetShapeB(), this.m_indexB); + i.sweepA.Copy(t); + i.sweepB.Copy(e); + i.tMax = u; + const s = Vs.ComputeTOI_s_output; + $e(s, i); + return s.t; + } + } + Vs.ComputeTOI_s_input = new Ge; + Vs.ComputeTOI_s_output = new ze; + class ks extends Vs { + static Create() { + return new ks; + } + static Destroy(t) {} + Evaluate(t, e, i) { + ii(t, this.GetShapeA(), e, this.GetShapeB(), i); + } + } + class Us extends Vs { + static Create() { + return new Us; + } + static Destroy(t) {} + Evaluate(t, e, i) { + Mi(t, this.GetShapeA(), e, this.GetShapeB(), i); + } + } + class Gs extends Vs { + static Create() { + return new Gs; + } + static Destroy(t) {} + Evaluate(t, e, i) { + oi(t, this.GetShapeA(), e, this.GetShapeB(), i); + } + } + class zs extends Vs { + static Create() { + return new zs; + } + static Destroy(t) {} + Evaluate(t, e, i) { + ki(t, this.GetShapeA(), e, this.GetShapeB(), i); + } + } + class Hs extends Vs { + static Create() { + return new Hs; + } + static Destroy(t) {} + Evaluate(t, e, i) { + Yi(t, this.GetShapeA(), e, this.GetShapeB(), i); + } + } + class js extends Vs { + static Create() { + return new js; + } + static Destroy(t) {} + Evaluate(t, e, i) { + const s = js.Evaluate_s_edge; + this.GetShapeA().GetChildEdge(s, this.m_indexA); + ki(t, s, e, this.GetShapeB(), i); + } + } + js.Evaluate_s_edge = new Qi; + class Xs extends Vs { + static Create() { + return new Xs; + } + static Destroy(t) {} + Evaluate(t, e, i) { + const s = Xs.Evaluate_s_edge; + this.GetShapeA().GetChildEdge(s, this.m_indexA); + Yi(t, s, e, this.GetShapeB(), i); + } + } + Xs.Evaluate_s_edge = new Qi; + class Ws { + constructor() { + this.pool = []; + this.createFcn = null; + this.destroyFcn = null; + this.primary = !1; + } + } + class Ys { + constructor() { + this.m_registers = []; + this.InitializeRegisters(); + } + AddType(t, e, i, s) { + const n = []; + function r() { + return n.pop() || t(); + } + function o(t) { + n.push(t); + } + this.m_registers[i][s].pool = n; + this.m_registers[i][s].createFcn = r; + this.m_registers[i][s].destroyFcn = o; + this.m_registers[i][s].primary = !0; + if (i !== s) { + this.m_registers[s][i].pool = n; + this.m_registers[s][i].createFcn = r; + this.m_registers[s][i].destroyFcn = o; + this.m_registers[s][i].primary = !1; + } + } + InitializeRegisters() { + for (let e = 0; e < t.b2ShapeType.e_shapeTypeCount; e++) { + this.m_registers[e] = []; + for (let i = 0; i < t.b2ShapeType.e_shapeTypeCount; i++) this.m_registers[e][i] = new Ws; + } + this.AddType(ks.Create, ks.Destroy, t.b2ShapeType.e_circleShape, t.b2ShapeType.e_circleShape); + this.AddType(Gs.Create, Gs.Destroy, t.b2ShapeType.e_polygonShape, t.b2ShapeType.e_circleShape); + this.AddType(Us.Create, Us.Destroy, t.b2ShapeType.e_polygonShape, t.b2ShapeType.e_polygonShape); + this.AddType(zs.Create, zs.Destroy, t.b2ShapeType.e_edgeShape, t.b2ShapeType.e_circleShape); + this.AddType(Hs.Create, Hs.Destroy, t.b2ShapeType.e_edgeShape, t.b2ShapeType.e_polygonShape); + this.AddType(js.Create, js.Destroy, t.b2ShapeType.e_chainShape, t.b2ShapeType.e_circleShape); + this.AddType(Xs.Create, Xs.Destroy, t.b2ShapeType.e_chainShape, t.b2ShapeType.e_polygonShape); + } + Create(t, e, i, s) { + const n = t.GetType(); + const r = i.GetType(); + const o = this.m_registers[n][r]; + if (o.createFcn) { + const n = o.createFcn(); + o.primary ? n.Reset(t, e, i, s) : n.Reset(i, s, t, e); + return n; + } + return null; + } + Destroy(t) { + const e = t.m_fixtureA.GetType(); + const i = t.m_fixtureB.GetType(); + const s = this.m_registers[e][i]; + s.destroyFcn && s.destroyFcn(t); + } + } + class qs { + SayGoodbyeJoint(t) {} + SayGoodbyeFixture(t) {} + SayGoodbyeParticleGroup(t) {} + SayGoodbyeParticle(t, e) {} + } + class Ks { + ShouldCollide(e, i) { + const s = e.GetBody(); + const n = i.GetBody(); + if (n.GetType() === t.b2BodyType.b2_staticBody && s.GetType() === t.b2BodyType.b2_staticBody) return !1; + if (!n.ShouldCollideConnected(s)) return !1; + const r = e.GetFilterData(); + const o = i.GetFilterData(); + return r.groupIndex === o.groupIndex && 0 !== r.groupIndex ? r.groupIndex > 0 : 0 != (r.maskBits & o.categoryBits) && 0 != (r.categoryBits & o.maskBits); + } + ShouldCollideFixtureParticle(t, e, i) { + return !0; + } + ShouldCollideParticleParticle(t, e, i) { + return !0; + } + } + Ks.b2_defaultFilter = new Ks; + class Js { + constructor() { + this.normalImpulses = K(a); + this.tangentImpulses = K(a); + this.count = 0; + } + } + class Zs { + BeginContact(t) {} + EndContact(t) {} + BeginContactFixtureParticle(t, e) {} + EndContactFixtureParticle(t, e) {} + BeginContactParticleParticle(t, e) {} + EndContactParticleParticle(t, e) {} + PreSolve(t, e) {} + PostSolve(t, e) {} + } + Zs.b2_defaultListener = new Zs; + class Qs { + ReportFixture(t) { + return !0; + } + ReportParticle(t, e) { + return !1; + } + ShouldQueryParticleSystem(t) { + return !0; + } + } + class $s { + ReportFixture(t, e, i, s) { + return s; + } + ReportParticle(t, e, i, s, n) { + return 0; + } + ShouldQueryParticleSystem(t) { + return !0; + } + } + class tn { + constructor() { + this.m_broadPhase = new Be; + this.m_contactList = null; + this.m_contactCount = 0; + this.m_contactFilter = Ks.b2_defaultFilter; + this.m_contactListener = Zs.b2_defaultListener; + this.m_contactFactory = new Ys; + } + AddPair(t, e) { + let i = t.fixture; + let s = e.fixture; + let n = t.childIndex; + let r = e.childIndex; + let o = i.GetBody(); + let a = s.GetBody(); + if (o === a) return; + let l = a.GetContactList(); + for (;l; ) { + if (l.other === o) { + const t = l.contact.GetFixtureA(); + const e = l.contact.GetFixtureB(); + const o = l.contact.GetChildIndexA(); + const a = l.contact.GetChildIndexB(); + if (t === i && e === s && o === n && a === r) return; + if (t === s && e === i && o === r && a === n) return; + } + l = l.next; + } + if (this.m_contactFilter && !this.m_contactFilter.ShouldCollide(i, s)) return; + const h = this.m_contactFactory.Create(i, n, s, r); + if (null !== h) { + i = h.GetFixtureA(); + s = h.GetFixtureB(); + n = h.GetChildIndexA(); + r = h.GetChildIndexB(); + o = i.m_body; + a = s.m_body; + h.m_prev = null; + h.m_next = this.m_contactList; + null !== this.m_contactList && (this.m_contactList.m_prev = h); + this.m_contactList = h; + h.m_nodeA.other = a; + h.m_nodeA.prev = null; + h.m_nodeA.next = o.m_contactList; + null !== o.m_contactList && (o.m_contactList.prev = h.m_nodeA); + o.m_contactList = h.m_nodeA; + h.m_nodeB.other = o; + h.m_nodeB.prev = null; + h.m_nodeB.next = a.m_contactList; + null !== a.m_contactList && (a.m_contactList.prev = h.m_nodeB); + a.m_contactList = h.m_nodeB; + if (!i.IsSensor() && !s.IsSensor()) { + o.SetAwake(!0); + a.SetAwake(!0); + } + ++this.m_contactCount; + } + } + FindNewContacts() { + this.m_broadPhase.UpdatePairs(((t, e) => { + this.AddPair(t, e); + })); + } + Destroy(t) { + const e = t.GetFixtureA(); + const i = t.GetFixtureB(); + const s = e.GetBody(); + const n = i.GetBody(); + this.m_contactListener && t.IsTouching() && this.m_contactListener.EndContact(t); + t.m_prev && (t.m_prev.m_next = t.m_next); + t.m_next && (t.m_next.m_prev = t.m_prev); + t === this.m_contactList && (this.m_contactList = t.m_next); + t.m_nodeA.prev && (t.m_nodeA.prev.next = t.m_nodeA.next); + t.m_nodeA.next && (t.m_nodeA.next.prev = t.m_nodeA.prev); + t.m_nodeA === s.m_contactList && (s.m_contactList = t.m_nodeA.next); + t.m_nodeB.prev && (t.m_nodeB.prev.next = t.m_nodeB.next); + t.m_nodeB.next && (t.m_nodeB.next.prev = t.m_nodeB.prev); + t.m_nodeB === n.m_contactList && (n.m_contactList = t.m_nodeB.next); + if (t.m_manifold.pointCount > 0 && !e.IsSensor() && !i.IsSensor()) { + e.GetBody().SetAwake(!0); + i.GetBody().SetAwake(!0); + } + this.m_contactFactory.Destroy(t); + --this.m_contactCount; + } + Collide() { + let e = this.m_contactList; + for (;e; ) { + const i = e.GetFixtureA(); + const s = e.GetFixtureB(); + const n = e.GetChildIndexA(); + const r = e.GetChildIndexB(); + const o = i.GetBody(); + const a = s.GetBody(); + if (e.m_filterFlag) { + if (this.m_contactFilter && !this.m_contactFilter.ShouldCollide(i, s)) { + const t = e; + e = t.m_next; + this.Destroy(t); + continue; + } + e.m_filterFlag = !1; + } + const l = o.IsAwake() && o.m_type !== t.b2BodyType.b2_staticBody; + const h = a.IsAwake() && a.m_type !== t.b2BodyType.b2_staticBody; + if (!l && !h) { + e = e.m_next; + continue; + } + const c = i.m_proxies[n].treeNode; + const u = s.m_proxies[r].treeNode; + if (ye(c.aabb, u.aabb)) { + e.Update(this.m_contactListener); + e = e.m_next; + } else { + const t = e; + e = t.m_next; + this.Destroy(t); + } + } + } + } + class en { + constructor() { + this.step = 0; + this.collide = 0; + this.solve = 0; + this.solveInit = 0; + this.solveVelocity = 0; + this.solvePosition = 0; + this.broadphase = 0; + this.solveTOI = 0; + } + Reset() { + this.step = 0; + this.collide = 0; + this.solve = 0; + this.solveInit = 0; + this.solveVelocity = 0; + this.solvePosition = 0; + this.broadphase = 0; + this.solveTOI = 0; + return this; + } + } + class sn { + constructor() { + this.dt = 0; + this.inv_dt = 0; + this.dtRatio = 0; + this.velocityIterations = 0; + this.positionIterations = 0; + this.particleIterations = 0; + this.warmStarting = !1; + } + Copy(t) { + this.dt = t.dt; + this.inv_dt = t.inv_dt; + this.dtRatio = t.dtRatio; + this.positionIterations = t.positionIterations; + this.velocityIterations = t.velocityIterations; + this.particleIterations = t.particleIterations; + this.warmStarting = t.warmStarting; + return this; + } + } + class nn { + constructor() { + this.c = new St; + this.a = 0; + } + static MakeArray(t) { + return Y(t, (t => new nn)); + } + } + class rn { + constructor() { + this.v = new St; + this.w = 0; + } + static MakeArray(t) { + return Y(t, (t => new rn)); + } + } + class on { + constructor() { + this.step = new sn; + } + } + let an = !1; + class ln { + constructor() { + this.rA = new St; + this.rB = new St; + this.normalImpulse = 0; + this.tangentImpulse = 0; + this.normalMass = 0; + this.tangentMass = 0; + this.velocityBias = 0; + } + static MakeArray(t) { + return Y(t, (t => new ln)); + } + } + class hn { + constructor() { + this.points = ln.MakeArray(a); + this.normal = new St; + this.tangent = new St; + this.normalMass = new vt; + this.K = new vt; + this.indexA = 0; + this.indexB = 0; + this.invMassA = 0; + this.invMassB = 0; + this.invIA = 0; + this.invIB = 0; + this.friction = 0; + this.restitution = 0; + this.tangentSpeed = 0; + this.pointCount = 0; + this.contactIndex = 0; + } + static MakeArray(t) { + return Y(t, (t => new hn)); + } + } + class cn { + constructor() { + this.localPoints = St.MakeArray(a); + this.localNormal = new St; + this.localPoint = new St; + this.indexA = 0; + this.indexB = 0; + this.invMassA = 0; + this.invMassB = 0; + this.localCenterA = new St; + this.localCenterB = new St; + this.invIA = 0; + this.invIB = 0; + this.type = t.b2ManifoldType.e_unknown; + this.radiusA = 0; + this.radiusB = 0; + this.pointCount = 0; + } + static MakeArray(t) { + return Y(t, (t => new cn)); + } + } + class un { + constructor() { + this.step = new sn; + this.count = 0; + } + } + class _n { + constructor() { + this.normal = new St; + this.point = new St; + this.separation = 0; + } + Initialize(e, i, s, n) { + const r = _n.Initialize_s_pointA; + const o = _n.Initialize_s_pointB; + const a = _n.Initialize_s_planePoint; + const l = _n.Initialize_s_clipPoint; + switch (e.type) { + case t.b2ManifoldType.e_circles: + xt.MulXV(i, e.localPoint, r); + xt.MulXV(s, e.localPoints[0], o); + St.SubVV(o, r, this.normal).SelfNormalize(); + St.MidVV(r, o, this.point); + this.separation = St.DotVV(St.SubVV(o, r, St.s_t0), this.normal) - e.radiusA - e.radiusB; + break; + + case t.b2ManifoldType.e_faceA: + Ct.MulRV(i.q, e.localNormal, this.normal); + xt.MulXV(i, e.localPoint, a); + xt.MulXV(s, e.localPoints[n], l); + this.separation = St.DotVV(St.SubVV(l, a, St.s_t0), this.normal) - e.radiusA - e.radiusB; + this.point.Copy(l); + break; + + case t.b2ManifoldType.e_faceB: + Ct.MulRV(s.q, e.localNormal, this.normal); + xt.MulXV(s, e.localPoint, a); + xt.MulXV(i, e.localPoints[n], l); + this.separation = St.DotVV(St.SubVV(l, a, St.s_t0), this.normal) - e.radiusA - e.radiusB; + this.point.Copy(l); + this.normal.SelfNeg(); + } + } + } + _n.Initialize_s_pointA = new St; + _n.Initialize_s_pointB = new St; + _n.Initialize_s_planePoint = new St; + _n.Initialize_s_clipPoint = new St; + class dn { + constructor() { + this.m_step = new sn; + this.m_positionConstraints = cn.MakeArray(1024); + this.m_velocityConstraints = hn.MakeArray(1024); + this.m_count = 0; + } + Initialize(t) { + this.m_step.Copy(t.step); + this.m_count = t.count; + if (this.m_positionConstraints.length < this.m_count) { + const t = et(2 * this.m_positionConstraints.length, this.m_count); + for (;this.m_positionConstraints.length < t; ) this.m_positionConstraints[this.m_positionConstraints.length] = new cn; + } + if (this.m_velocityConstraints.length < this.m_count) { + const t = et(2 * this.m_velocityConstraints.length, this.m_count); + for (;this.m_velocityConstraints.length < t; ) this.m_velocityConstraints[this.m_velocityConstraints.length] = new hn; + } + this.m_positions = t.positions; + this.m_velocities = t.velocities; + this.m_contacts = t.contacts; + for (let t = 0; t < this.m_count; ++t) { + const e = this.m_contacts[t]; + const i = e.m_fixtureA; + const s = e.m_fixtureB; + const n = i.GetShape(); + const r = s.GetShape(); + const o = n.m_radius; + const a = r.m_radius; + const l = i.GetBody(); + const h = s.GetBody(); + const c = e.GetManifold(); + const u = c.pointCount; + const _ = this.m_velocityConstraints[t]; + _.friction = e.m_friction; + _.restitution = e.m_restitution; + _.tangentSpeed = e.m_tangentSpeed; + _.indexA = l.m_islandIndex; + _.indexB = h.m_islandIndex; + _.invMassA = l.m_invMass; + _.invMassB = h.m_invMass; + _.invIA = l.m_invI; + _.invIB = h.m_invI; + _.contactIndex = t; + _.pointCount = u; + _.K.SetZero(); + _.normalMass.SetZero(); + const d = this.m_positionConstraints[t]; + d.indexA = l.m_islandIndex; + d.indexB = h.m_islandIndex; + d.invMassA = l.m_invMass; + d.invMassB = h.m_invMass; + d.localCenterA.Copy(l.m_sweep.localCenter); + d.localCenterB.Copy(h.m_sweep.localCenter); + d.invIA = l.m_invI; + d.invIB = h.m_invI; + d.localNormal.Copy(c.localNormal); + d.localPoint.Copy(c.localPoint); + d.pointCount = u; + d.radiusA = o; + d.radiusB = a; + d.type = c.type; + for (let t = 0; t < u; ++t) { + const e = c.points[t]; + const i = _.points[t]; + if (this.m_step.warmStarting) { + i.normalImpulse = this.m_step.dtRatio * e.normalImpulse; + i.tangentImpulse = this.m_step.dtRatio * e.tangentImpulse; + } else { + i.normalImpulse = 0; + i.tangentImpulse = 0; + } + i.rA.SetZero(); + i.rB.SetZero(); + i.normalMass = 0; + i.tangentMass = 0; + i.velocityBias = 0; + d.localPoints[t].Copy(e.localPoint); + } + } + return this; + } + InitializeVelocityConstraints() { + const t = dn.InitializeVelocityConstraints_s_xfA; + const e = dn.InitializeVelocityConstraints_s_xfB; + const i = dn.InitializeVelocityConstraints_s_worldManifold; + const s = 1e3; + for (let n = 0; n < this.m_count; ++n) { + const r = this.m_velocityConstraints[n]; + const o = this.m_positionConstraints[n]; + const a = o.radiusA; + const l = o.radiusB; + const h = this.m_contacts[r.contactIndex].GetManifold(); + const c = r.indexA; + const u = r.indexB; + const _ = r.invMassA; + const d = r.invMassB; + const p = r.invIA; + const m = r.invIB; + const g = o.localCenterA; + const y = o.localCenterB; + const b = this.m_positions[c].c; + const S = this.m_positions[c].a; + const A = this.m_velocities[c].v; + const T = this.m_velocities[c].w; + const v = this.m_positions[u].c; + const E = this.m_positions[u].a; + const C = this.m_velocities[u].v; + const x = this.m_velocities[u].w; + t.q.SetAngle(S); + e.q.SetAngle(E); + St.SubVV(b, Ct.MulRV(t.q, g, St.s_t0), t.p); + St.SubVV(v, Ct.MulRV(e.q, y, St.s_t0), e.p); + i.Initialize(h, t, a, e, l); + r.normal.Copy(i.normal); + St.CrossVOne(r.normal, r.tangent); + const w = r.pointCount; + for (let t = 0; t < w; ++t) { + const e = r.points[t]; + St.SubVV(i.points[t], b, e.rA); + St.SubVV(i.points[t], v, e.rB); + const s = St.CrossVV(e.rA, r.normal); + const n = St.CrossVV(e.rB, r.normal); + const o = _ + d + p * s * s + m * n * n; + e.normalMass = o > 0 ? 1 / o : 0; + const a = r.tangent; + const l = St.CrossVV(e.rA, a); + const h = St.CrossVV(e.rB, a); + const c = _ + d + p * l * l + m * h * h; + e.tangentMass = c > 0 ? 1 / c : 0; + e.velocityBias = 0; + const u = St.DotVV(r.normal, St.SubVV(St.AddVCrossSV(C, x, e.rB, St.s_t0), St.AddVCrossSV(A, T, e.rA, St.s_t1), St.s_t0)); + u < -f && (e.velocityBias += -r.restitution * u); + } + if (2 === r.pointCount && an) { + const t = r.points[0]; + const e = r.points[1]; + const i = St.CrossVV(t.rA, r.normal); + const n = St.CrossVV(t.rB, r.normal); + const o = St.CrossVV(e.rA, r.normal); + const a = St.CrossVV(e.rB, r.normal); + const l = _ + d + p * i * i + m * n * n; + const h = _ + d + p * o * o + m * a * a; + const c = _ + d + p * i * o + m * n * a; + if (l * l < s * (l * h - c * c)) { + r.K.ex.Set(l, c); + r.K.ey.Set(c, h); + r.K.GetInverse(r.normalMass); + } else r.pointCount = 1; + } + } + } + WarmStart() { + const t = dn.WarmStart_s_P; + for (let e = 0; e < this.m_count; ++e) { + const i = this.m_velocityConstraints[e]; + const s = i.indexA; + const n = i.indexB; + const r = i.invMassA; + const o = i.invIA; + const a = i.invMassB; + const l = i.invIB; + const h = i.pointCount; + const c = this.m_velocities[s].v; + let u = this.m_velocities[s].w; + const _ = this.m_velocities[n].v; + let d = this.m_velocities[n].w; + const p = i.normal; + const m = i.tangent; + for (let e = 0; e < h; ++e) { + const s = i.points[e]; + St.AddVV(St.MulSV(s.normalImpulse, p, St.s_t0), St.MulSV(s.tangentImpulse, m, St.s_t1), t); + u -= o * St.CrossVV(s.rA, t); + c.SelfMulSub(r, t); + d += l * St.CrossVV(s.rB, t); + _.SelfMulAdd(a, t); + } + this.m_velocities[s].w = u; + this.m_velocities[n].w = d; + } + } + SolveVelocityConstraints() { + const t = dn.SolveVelocityConstraints_s_dv; + const e = dn.SolveVelocityConstraints_s_dv1; + const i = dn.SolveVelocityConstraints_s_dv2; + const s = dn.SolveVelocityConstraints_s_P; + const n = dn.SolveVelocityConstraints_s_a; + const r = dn.SolveVelocityConstraints_s_b; + const o = dn.SolveVelocityConstraints_s_x; + const a = dn.SolveVelocityConstraints_s_d; + const l = dn.SolveVelocityConstraints_s_P1; + const h = dn.SolveVelocityConstraints_s_P2; + const c = dn.SolveVelocityConstraints_s_P1P2; + for (let u = 0; u < this.m_count; ++u) { + const _ = this.m_velocityConstraints[u]; + const d = _.indexA; + const p = _.indexB; + const m = _.invMassA; + const f = _.invIA; + const g = _.invMassB; + const y = _.invIB; + const b = _.pointCount; + const S = this.m_velocities[d].v; + let A = this.m_velocities[d].w; + const T = this.m_velocities[p].v; + let v = this.m_velocities[p].w; + const E = _.normal; + const C = _.tangent; + const x = _.friction; + for (let e = 0; e < b; ++e) { + const i = _.points[e]; + St.SubVV(St.AddVCrossSV(T, v, i.rB, St.s_t0), St.AddVCrossSV(S, A, i.rA, St.s_t1), t); + const n = St.DotVV(t, C) - _.tangentSpeed; + let r = i.tangentMass * -n; + const o = x * i.normalImpulse; + const a = it(i.tangentImpulse + r, -o, o); + r = a - i.tangentImpulse; + i.tangentImpulse = a; + St.MulSV(r, C, s); + S.SelfMulSub(m, s); + A -= f * St.CrossVV(i.rA, s); + T.SelfMulAdd(g, s); + v += y * St.CrossVV(i.rB, s); + } + if (1 === _.pointCount || !1 === an) for (let e = 0; e < b; ++e) { + const i = _.points[e]; + St.SubVV(St.AddVCrossSV(T, v, i.rB, St.s_t0), St.AddVCrossSV(S, A, i.rA, St.s_t1), t); + const n = St.DotVV(t, E); + let r = -i.normalMass * (n - i.velocityBias); + const o = et(i.normalImpulse + r, 0); + r = o - i.normalImpulse; + i.normalImpulse = o; + St.MulSV(r, E, s); + S.SelfMulSub(m, s); + A -= f * St.CrossVV(i.rA, s); + T.SelfMulAdd(g, s); + v += y * St.CrossVV(i.rB, s); + } else { + const t = _.points[0]; + const s = _.points[1]; + n.Set(t.normalImpulse, s.normalImpulse); + St.SubVV(St.AddVCrossSV(T, v, t.rB, St.s_t0), St.AddVCrossSV(S, A, t.rA, St.s_t1), e); + St.SubVV(St.AddVCrossSV(T, v, s.rB, St.s_t0), St.AddVCrossSV(S, A, s.rA, St.s_t1), i); + let u = St.DotVV(e, E); + let d = St.DotVV(i, E); + r.x = u - t.velocityBias; + r.y = d - s.velocityBias; + r.SelfSub(vt.MulMV(_.K, n, St.s_t0)); + for (;;) { + vt.MulMV(_.normalMass, r, o).SelfNeg(); + if (o.x >= 0 && o.y >= 0) { + St.SubVV(o, n, a); + St.MulSV(a.x, E, l); + St.MulSV(a.y, E, h); + St.AddVV(l, h, c); + S.SelfMulSub(m, c); + A -= f * (St.CrossVV(t.rA, l) + St.CrossVV(s.rA, h)); + T.SelfMulAdd(g, c); + v += y * (St.CrossVV(t.rB, l) + St.CrossVV(s.rB, h)); + t.normalImpulse = o.x; + s.normalImpulse = o.y; + break; + } + o.x = -t.normalMass * r.x; + o.y = 0; + u = 0; + d = _.K.ex.y * o.x + r.y; + if (o.x >= 0 && d >= 0) { + St.SubVV(o, n, a); + St.MulSV(a.x, E, l); + St.MulSV(a.y, E, h); + St.AddVV(l, h, c); + S.SelfMulSub(m, c); + A -= f * (St.CrossVV(t.rA, l) + St.CrossVV(s.rA, h)); + T.SelfMulAdd(g, c); + v += y * (St.CrossVV(t.rB, l) + St.CrossVV(s.rB, h)); + t.normalImpulse = o.x; + s.normalImpulse = o.y; + break; + } + o.x = 0; + o.y = -s.normalMass * r.y; + u = _.K.ey.x * o.y + r.x; + d = 0; + if (o.y >= 0 && u >= 0) { + St.SubVV(o, n, a); + St.MulSV(a.x, E, l); + St.MulSV(a.y, E, h); + St.AddVV(l, h, c); + S.SelfMulSub(m, c); + A -= f * (St.CrossVV(t.rA, l) + St.CrossVV(s.rA, h)); + T.SelfMulAdd(g, c); + v += y * (St.CrossVV(t.rB, l) + St.CrossVV(s.rB, h)); + t.normalImpulse = o.x; + s.normalImpulse = o.y; + break; + } + o.x = 0; + o.y = 0; + u = r.x; + d = r.y; + if (u >= 0 && d >= 0) { + St.SubVV(o, n, a); + St.MulSV(a.x, E, l); + St.MulSV(a.y, E, h); + St.AddVV(l, h, c); + S.SelfMulSub(m, c); + A -= f * (St.CrossVV(t.rA, l) + St.CrossVV(s.rA, h)); + T.SelfMulAdd(g, c); + v += y * (St.CrossVV(t.rB, l) + St.CrossVV(s.rB, h)); + t.normalImpulse = o.x; + s.normalImpulse = o.y; + break; + } + break; + } + } + this.m_velocities[d].w = A; + this.m_velocities[p].w = v; + } + } + StoreImpulses() { + for (let t = 0; t < this.m_count; ++t) { + const e = this.m_velocityConstraints[t]; + const i = this.m_contacts[e.contactIndex].GetManifold(); + for (let t = 0; t < e.pointCount; ++t) { + i.points[t].normalImpulse = e.points[t].normalImpulse; + i.points[t].tangentImpulse = e.points[t].tangentImpulse; + } + } + } + SolvePositionConstraints() { + const t = dn.SolvePositionConstraints_s_xfA; + const e = dn.SolvePositionConstraints_s_xfB; + const i = dn.SolvePositionConstraints_s_psm; + const s = dn.SolvePositionConstraints_s_rA; + const n = dn.SolvePositionConstraints_s_rB; + const r = dn.SolvePositionConstraints_s_P; + let o = 0; + for (let a = 0; a < this.m_count; ++a) { + const l = this.m_positionConstraints[a]; + const h = l.indexA; + const c = l.indexB; + const _ = l.localCenterA; + const d = l.invMassA; + const p = l.invIA; + const m = l.localCenterB; + const f = l.invMassB; + const y = l.invIB; + const b = l.pointCount; + const S = this.m_positions[h].c; + let A = this.m_positions[h].a; + const T = this.m_positions[c].c; + let E = this.m_positions[c].a; + for (let a = 0; a < b; ++a) { + t.q.SetAngle(A); + e.q.SetAngle(E); + St.SubVV(S, Ct.MulRV(t.q, _, St.s_t0), t.p); + St.SubVV(T, Ct.MulRV(e.q, m, St.s_t0), e.p); + i.Initialize(l, t, e, a); + const h = i.normal; + const c = i.point; + const b = i.separation; + St.SubVV(c, S, s); + St.SubVV(c, T, n); + o = tt(o, b); + const C = it(v * (b + u), -g, 0); + const x = St.CrossVV(s, h); + const w = St.CrossVV(n, h); + const R = d + f + p * x * x + y * w * w; + const I = R > 0 ? -C / R : 0; + St.MulSV(I, h, r); + S.SelfMulSub(d, r); + A -= p * St.CrossVV(s, r); + T.SelfMulAdd(f, r); + E += y * St.CrossVV(n, r); + } + this.m_positions[h].a = A; + this.m_positions[c].a = E; + } + return o > -3 * u; + } + SolveTOIPositionConstraints(t, e) { + const i = dn.SolveTOIPositionConstraints_s_xfA; + const s = dn.SolveTOIPositionConstraints_s_xfB; + const n = dn.SolveTOIPositionConstraints_s_psm; + const r = dn.SolveTOIPositionConstraints_s_rA; + const o = dn.SolveTOIPositionConstraints_s_rB; + const a = dn.SolveTOIPositionConstraints_s_P; + let l = 0; + for (let h = 0; h < this.m_count; ++h) { + const c = this.m_positionConstraints[h]; + const _ = c.indexA; + const d = c.indexB; + const p = c.localCenterA; + const m = c.localCenterB; + const f = c.pointCount; + let y = 0; + let b = 0; + if (_ === t || _ === e) { + y = c.invMassA; + b = c.invIA; + } + let S = 0; + let A = 0; + if (d === t || d === e) { + S = c.invMassB; + A = c.invIB; + } + const T = this.m_positions[_].c; + let v = this.m_positions[_].a; + const C = this.m_positions[d].c; + let x = this.m_positions[d].a; + for (let t = 0; t < f; ++t) { + i.q.SetAngle(v); + s.q.SetAngle(x); + St.SubVV(T, Ct.MulRV(i.q, p, St.s_t0), i.p); + St.SubVV(C, Ct.MulRV(s.q, m, St.s_t0), s.p); + n.Initialize(c, i, s, t); + const e = n.normal; + const h = n.point; + const _ = n.separation; + St.SubVV(h, T, r); + St.SubVV(h, C, o); + l = tt(l, _); + const d = it(E * (_ + u), -g, 0); + const f = St.CrossVV(r, e); + const w = St.CrossVV(o, e); + const R = y + S + b * f * f + A * w * w; + const I = R > 0 ? -d / R : 0; + St.MulSV(I, e, a); + T.SelfMulSub(y, a); + v -= b * St.CrossVV(r, a); + C.SelfMulAdd(S, a); + x += A * St.CrossVV(o, a); + } + this.m_positions[_].a = v; + this.m_positions[d].a = x; + } + return l >= -1.5 * u; + } + } + dn.InitializeVelocityConstraints_s_xfA = new xt; + dn.InitializeVelocityConstraints_s_xfB = new xt; + dn.InitializeVelocityConstraints_s_worldManifold = new _e; + dn.WarmStart_s_P = new St; + dn.SolveVelocityConstraints_s_dv = new St; + dn.SolveVelocityConstraints_s_dv1 = new St; + dn.SolveVelocityConstraints_s_dv2 = new St; + dn.SolveVelocityConstraints_s_P = new St; + dn.SolveVelocityConstraints_s_a = new St; + dn.SolveVelocityConstraints_s_b = new St; + dn.SolveVelocityConstraints_s_x = new St; + dn.SolveVelocityConstraints_s_d = new St; + dn.SolveVelocityConstraints_s_P1 = new St; + dn.SolveVelocityConstraints_s_P2 = new St; + dn.SolveVelocityConstraints_s_P1P2 = new St; + dn.SolvePositionConstraints_s_xfA = new xt; + dn.SolvePositionConstraints_s_xfB = new xt; + dn.SolvePositionConstraints_s_psm = new _n; + dn.SolvePositionConstraints_s_rA = new St; + dn.SolvePositionConstraints_s_rB = new St; + dn.SolvePositionConstraints_s_P = new St; + dn.SolveTOIPositionConstraints_s_xfA = new xt; + dn.SolveTOIPositionConstraints_s_xfB = new xt; + dn.SolveTOIPositionConstraints_s_psm = new _n; + dn.SolveTOIPositionConstraints_s_rA = new St; + dn.SolveTOIPositionConstraints_s_rB = new St; + dn.SolveTOIPositionConstraints_s_P = new St; + class pn { + constructor() { + this.m_bodies = []; + this.m_contacts = []; + this.m_joints = []; + this.m_positions = nn.MakeArray(1024); + this.m_velocities = rn.MakeArray(1024); + this.m_bodyCount = 0; + this.m_jointCount = 0; + this.m_contactCount = 0; + this.m_bodyCapacity = 0; + this.m_contactCapacity = 0; + this.m_jointCapacity = 0; + } + Initialize(t, e, i, s) { + this.m_bodyCapacity = t; + this.m_contactCapacity = e; + this.m_jointCapacity = i; + this.m_bodyCount = 0; + this.m_contactCount = 0; + this.m_jointCount = 0; + this.m_listener = s; + if (this.m_positions.length < t) { + const e = et(2 * this.m_positions.length, t); + for (;this.m_positions.length < e; ) this.m_positions[this.m_positions.length] = new nn; + } + if (this.m_velocities.length < t) { + const e = et(2 * this.m_velocities.length, t); + for (;this.m_velocities.length < e; ) this.m_velocities[this.m_velocities.length] = new rn; + } + } + Clear() { + this.m_bodyCount = 0; + this.m_contactCount = 0; + this.m_jointCount = 0; + } + AddBody(t) { + t.m_islandIndex = this.m_bodyCount; + this.m_bodies[this.m_bodyCount++] = t; + } + AddContact(t) { + this.m_contacts[this.m_contactCount++] = t; + } + AddJoint(t) { + this.m_joints[this.m_jointCount++] = t; + } + Solve(e, i, n, r) { + const o = pn.s_timer.Reset(); + const a = i.dt; + for (let e = 0; e < this.m_bodyCount; ++e) { + const i = this.m_bodies[e]; + this.m_positions[e].c.Copy(i.m_sweep.c); + const s = i.m_sweep.a; + const r = this.m_velocities[e].v.Copy(i.m_linearVelocity); + let o = i.m_angularVelocity; + i.m_sweep.c0.Copy(i.m_sweep.c); + i.m_sweep.a0 = i.m_sweep.a; + if (i.m_type === t.b2BodyType.b2_dynamicBody) { + r.x += a * (i.m_gravityScale * n.x + i.m_invMass * i.m_force.x); + r.y += a * (i.m_gravityScale * n.y + i.m_invMass * i.m_force.y); + o += a * i.m_invI * i.m_torque; + r.SelfMul(1 / (1 + a * i.m_linearDamping)); + o *= 1 / (1 + a * i.m_angularDamping); + } + this.m_positions[e].a = s; + this.m_velocities[e].w = o; + } + o.Reset(); + const l = pn.s_solverData; + l.step.Copy(i); + l.positions = this.m_positions; + l.velocities = this.m_velocities; + const h = pn.s_contactSolverDef; + h.step.Copy(i); + h.contacts = this.m_contacts; + h.count = this.m_contactCount; + h.positions = this.m_positions; + h.velocities = this.m_velocities; + const c = pn.s_contactSolver.Initialize(h); + c.InitializeVelocityConstraints(); + i.warmStarting && c.WarmStart(); + for (let t = 0; t < this.m_jointCount; ++t) this.m_joints[t].InitVelocityConstraints(l); + e.solveInit = o.GetMilliseconds(); + o.Reset(); + for (let t = 0; t < i.velocityIterations; ++t) { + for (let t = 0; t < this.m_jointCount; ++t) this.m_joints[t].SolveVelocityConstraints(l); + c.SolveVelocityConstraints(); + } + c.StoreImpulses(); + e.solveVelocity = o.GetMilliseconds(); + for (let t = 0; t < this.m_bodyCount; ++t) { + const e = this.m_positions[t].c; + let i = this.m_positions[t].a; + const s = this.m_velocities[t].v; + let n = this.m_velocities[t].w; + const r = St.MulSV(a, s, pn.s_translation); + if (St.DotVV(r, r) > S) { + const t = b / r.Length(); + s.SelfMul(t); + } + const o = a * n; + o * o > T && (n *= A / $(o)); + e.x += a * s.x; + e.y += a * s.y; + i += a * n; + this.m_positions[t].a = i; + this.m_velocities[t].w = n; + } + o.Reset(); + let u = !1; + for (let t = 0; t < i.positionIterations; ++t) { + const t = c.SolvePositionConstraints(); + let e = !0; + for (let t = 0; t < this.m_jointCount; ++t) { + const i = this.m_joints[t].SolvePositionConstraints(l); + e = e && i; + } + if (t && e) { + u = !0; + break; + } + } + for (let t = 0; t < this.m_bodyCount; ++t) { + const e = this.m_bodies[t]; + e.m_sweep.c.Copy(this.m_positions[t].c); + e.m_sweep.a = this.m_positions[t].a; + e.m_linearVelocity.Copy(this.m_velocities[t].v); + e.m_angularVelocity = this.m_velocities[t].w; + e.SynchronizeTransform(); + } + e.solvePosition = o.GetMilliseconds(); + this.Report(c.m_velocityConstraints); + if (r) { + let e = s; + const i = L * L; + const n = F * F; + for (let s = 0; s < this.m_bodyCount; ++s) { + const r = this.m_bodies[s]; + if (r.GetType() !== t.b2BodyType.b2_staticBody) if (!r.m_autoSleepFlag || r.m_angularVelocity * r.m_angularVelocity > n || St.DotVV(r.m_linearVelocity, r.m_linearVelocity) > i) { + r.m_sleepTime = 0; + e = 0; + } else { + r.m_sleepTime += a; + e = tt(e, r.m_sleepTime); + } + } + if (e >= N && u) for (let t = 0; t < this.m_bodyCount; ++t) this.m_bodies[t].SetAwake(!1); + } + } + SolveTOI(t, e, i) { + for (let t = 0; t < this.m_bodyCount; ++t) { + const e = this.m_bodies[t]; + this.m_positions[t].c.Copy(e.m_sweep.c); + this.m_positions[t].a = e.m_sweep.a; + this.m_velocities[t].v.Copy(e.m_linearVelocity); + this.m_velocities[t].w = e.m_angularVelocity; + } + const s = pn.s_contactSolverDef; + s.contacts = this.m_contacts; + s.count = this.m_contactCount; + s.step.Copy(t); + s.positions = this.m_positions; + s.velocities = this.m_velocities; + const n = pn.s_contactSolver.Initialize(s); + for (let s = 0; s < t.positionIterations && !n.SolveTOIPositionConstraints(e, i); ++s) ; + this.m_bodies[e].m_sweep.c0.Copy(this.m_positions[e].c); + this.m_bodies[e].m_sweep.a0 = this.m_positions[e].a; + this.m_bodies[i].m_sweep.c0.Copy(this.m_positions[i].c); + this.m_bodies[i].m_sweep.a0 = this.m_positions[i].a; + n.InitializeVelocityConstraints(); + for (let e = 0; e < t.velocityIterations; ++e) n.SolveVelocityConstraints(); + const r = t.dt; + for (let t = 0; t < this.m_bodyCount; ++t) { + const e = this.m_positions[t].c; + let i = this.m_positions[t].a; + const s = this.m_velocities[t].v; + let n = this.m_velocities[t].w; + const o = St.MulSV(r, s, pn.s_translation); + if (St.DotVV(o, o) > S) { + const t = b / o.Length(); + s.SelfMul(t); + } + const a = r * n; + a * a > T && (n *= A / $(a)); + e.SelfMulAdd(r, s); + i += r * n; + this.m_positions[t].a = i; + this.m_velocities[t].w = n; + const l = this.m_bodies[t]; + l.m_sweep.c.Copy(e); + l.m_sweep.a = i; + l.m_linearVelocity.Copy(s); + l.m_angularVelocity = n; + l.SynchronizeTransform(); + } + this.Report(n.m_velocityConstraints); + } + Report(t) { + if (null !== this.m_listener) for (let e = 0; e < this.m_contactCount; ++e) { + const i = this.m_contacts[e]; + if (!i) continue; + const s = t[e]; + const n = pn.s_impulse; + n.count = s.pointCount; + for (let t = 0; t < s.pointCount; ++t) { + n.normalImpulses[t] = s.points[t].normalImpulse; + n.tangentImpulses[t] = s.points[t].tangentImpulse; + } + this.m_listener.PostSolve(i, n); + } + } + } + pn.s_timer = new Mt; + pn.s_solverData = new on; + pn.s_contactSolverDef = new un; + pn.s_contactSolver = new dn; + pn.s_translation = new St; + pn.s_impulse = new Js; + !function(t) { + t[t.b2_waterParticle = 0] = "b2_waterParticle"; + t[t.b2_zombieParticle = 2] = "b2_zombieParticle"; + t[t.b2_wallParticle = 4] = "b2_wallParticle"; + t[t.b2_springParticle = 8] = "b2_springParticle"; + t[t.b2_elasticParticle = 16] = "b2_elasticParticle"; + t[t.b2_viscousParticle = 32] = "b2_viscousParticle"; + t[t.b2_powderParticle = 64] = "b2_powderParticle"; + t[t.b2_tensileParticle = 128] = "b2_tensileParticle"; + t[t.b2_colorMixingParticle = 256] = "b2_colorMixingParticle"; + t[t.b2_destructionListenerParticle = 512] = "b2_destructionListenerParticle"; + t[t.b2_barrierParticle = 1024] = "b2_barrierParticle"; + t[t.b2_staticPressureParticle = 2048] = "b2_staticPressureParticle"; + t[t.b2_reactiveParticle = 4096] = "b2_reactiveParticle"; + t[t.b2_repulsiveParticle = 8192] = "b2_repulsiveParticle"; + t[t.b2_fixtureContactListenerParticle = 16384] = "b2_fixtureContactListenerParticle"; + t[t.b2_particleContactListenerParticle = 32768] = "b2_particleContactListenerParticle"; + t[t.b2_fixtureContactFilterParticle = 65536] = "b2_fixtureContactFilterParticle"; + t[t.b2_particleContactFilterParticle = 131072] = "b2_particleContactFilterParticle"; + }(t.b2ParticleFlag || (t.b2ParticleFlag = {})); + class mn { + constructor() { + this.flags = 0; + this.position = new St; + this.velocity = new St; + this.color = new Rt(0, 0, 0, 0); + this.lifetime = 0; + this.userData = null; + this.group = null; + } + } + function fn(t, e, i) { + const s = 8; + const n = .01; + return it(Math.ceil(Math.sqrt(t / (n * e)) * i), 1, s); + } + class gn { + constructor() { + this.m_index = C; + } + GetIndex() { + return this.m_index; + } + SetIndex(t) { + this.m_index = t; + } + } + !function(t) { + t[t.b2_solidParticleGroup = 1] = "b2_solidParticleGroup"; + t[t.b2_rigidParticleGroup = 2] = "b2_rigidParticleGroup"; + t[t.b2_particleGroupCanBeEmpty = 4] = "b2_particleGroupCanBeEmpty"; + t[t.b2_particleGroupWillBeDestroyed = 8] = "b2_particleGroupWillBeDestroyed"; + t[t.b2_particleGroupNeedsUpdateDepth = 16] = "b2_particleGroupNeedsUpdateDepth"; + t[t.b2_particleGroupInternalMask = 24] = "b2_particleGroupInternalMask"; + }(t.b2ParticleGroupFlag || (t.b2ParticleGroupFlag = {})); + class yn { + constructor() { + this.flags = 0; + this.groupFlags = 0; + this.position = new St; + this.angle = 0; + this.linearVelocity = new St; + this.angularVelocity = 0; + this.color = new Rt; + this.strength = 1; + this.shapeCount = 0; + this.stride = 0; + this.particleCount = 0; + this.lifetime = 0; + this.userData = null; + this.group = null; + } + } + class bn { + constructor(t) { + this.m_firstIndex = 0; + this.m_lastIndex = 0; + this.m_groupFlags = 0; + this.m_strength = 1; + this.m_prev = null; + this.m_next = null; + this.m_timestamp = -1; + this.m_mass = 0; + this.m_inertia = 0; + this.m_center = new St; + this.m_linearVelocity = new St; + this.m_angularVelocity = 0; + this.m_transform = new xt; + this.m_userData = null; + this.m_system = t; + } + GetNext() { + return this.m_next; + } + GetParticleSystem() { + return this.m_system; + } + GetParticleCount() { + return this.m_lastIndex - this.m_firstIndex; + } + GetBufferIndex() { + return this.m_firstIndex; + } + ContainsParticle(t) { + return this.m_firstIndex <= t && t < this.m_lastIndex; + } + GetAllParticleFlags() { + if (!this.m_system.m_flagsBuffer.data) throw new Error; + let t = 0; + for (let e = this.m_firstIndex; e < this.m_lastIndex; e++) t |= this.m_system.m_flagsBuffer.data[e]; + return t; + } + GetGroupFlags() { + return this.m_groupFlags; + } + SetGroupFlags(e) { + e |= this.m_groupFlags & t.b2ParticleGroupFlag.b2_particleGroupInternalMask; + this.m_system.SetGroupFlags(this, e); + } + GetMass() { + this.UpdateStatistics(); + return this.m_mass; + } + GetInertia() { + this.UpdateStatistics(); + return this.m_inertia; + } + GetCenter() { + this.UpdateStatistics(); + return this.m_center; + } + GetLinearVelocity() { + this.UpdateStatistics(); + return this.m_linearVelocity; + } + GetAngularVelocity() { + this.UpdateStatistics(); + return this.m_angularVelocity; + } + GetTransform() { + return this.m_transform; + } + GetPosition() { + return this.m_transform.p; + } + GetAngle() { + return this.m_transform.q.GetAngle(); + } + GetLinearVelocityFromWorldPoint(t, e) { + const i = bn.GetLinearVelocityFromWorldPoint_s_t0; + this.UpdateStatistics(); + return St.AddVCrossSV(this.m_linearVelocity, this.m_angularVelocity, St.SubVV(t, this.m_center, i), e); + } + GetUserData() { + return this.m_userData; + } + SetUserData(t) { + this.m_userData = t; + } + ApplyForce(t) { + this.m_system.ApplyForce(this.m_firstIndex, this.m_lastIndex, t); + } + ApplyLinearImpulse(t) { + this.m_system.ApplyLinearImpulse(this.m_firstIndex, this.m_lastIndex, t); + } + DestroyParticles(t) { + if (this.m_system.m_world.IsLocked()) throw new Error; + for (let e = this.m_firstIndex; e < this.m_lastIndex; e++) this.m_system.DestroyParticle(e, t); + } + UpdateStatistics() { + if (!this.m_system.m_positionBuffer.data) throw new Error; + if (!this.m_system.m_velocityBuffer.data) throw new Error; + const t = new St; + const e = new St; + if (this.m_timestamp !== this.m_system.m_timestamp) { + const i = this.m_system.GetParticleMass(); + this.m_mass = i * (this.m_lastIndex - this.m_firstIndex); + this.m_center.SetZero(); + this.m_linearVelocity.SetZero(); + for (let t = this.m_firstIndex; t < this.m_lastIndex; t++) { + this.m_center.SelfMulAdd(i, this.m_system.m_positionBuffer.data[t]); + this.m_linearVelocity.SelfMulAdd(i, this.m_system.m_velocityBuffer.data[t]); + } + if (this.m_mass > 0) { + const t = 1 / this.m_mass; + this.m_center.SelfMul(t); + this.m_linearVelocity.SelfMul(t); + } + this.m_inertia = 0; + this.m_angularVelocity = 0; + for (let s = this.m_firstIndex; s < this.m_lastIndex; s++) { + St.SubVV(this.m_system.m_positionBuffer.data[s], this.m_center, t); + St.SubVV(this.m_system.m_velocityBuffer.data[s], this.m_linearVelocity, e); + this.m_inertia += i * St.DotVV(t, t); + this.m_angularVelocity += i * St.CrossVV(t, e); + } + this.m_inertia > 0 && (this.m_angularVelocity *= 1 / this.m_inertia); + this.m_timestamp = this.m_system.m_timestamp; + } + } + } + bn.GetLinearVelocityFromWorldPoint_s_t0 = new St; + class Sn { + constructor(t) { + this.m_buffer = []; + this.m_front = 0; + this.m_back = 0; + this.m_buffer.fill(null, 0, t); + } + get m_capacity() { + return this.m_buffer.length; + } + Push(t) { + if (this.m_back >= this.m_capacity) { + for (let t = this.m_front; t < this.m_back; t++) this.m_buffer[t - this.m_front] = this.m_buffer[t]; + this.m_back -= this.m_front; + this.m_front = 0; + } + this.m_buffer[this.m_back] = t; + this.m_back++; + } + Pop() { + this.m_buffer[this.m_front] = null; + this.m_front++; + } + Empty() { + return this.m_front === this.m_back; + } + Front() { + const t = this.m_buffer[this.m_front]; + if (!t) throw new Error; + return t; + } + } + class An { + constructor(t) { + this.m_generatorCapacity = 0; + this.m_generatorCount = 0; + this.m_countX = 0; + this.m_countY = 0; + this.m_diagram = []; + this.m_generatorBuffer = Y(t, (t => new Tn)); + this.m_generatorCapacity = t; + } + AddGenerator(t, e, i) { + const s = this.m_generatorBuffer[this.m_generatorCount++]; + s.center.Copy(t); + s.tag = e; + s.necessary = i; + } + Generate(t, e) { + const i = 1 / t; + const n = new St(+s, +s); + const r = new St(-s, -s); + let o = 0; + for (let t = 0; t < this.m_generatorCount; t++) { + const e = this.m_generatorBuffer[t]; + if (e.necessary) { + St.MinV(n, e.center, n); + St.MaxV(r, e.center, r); + ++o; + } + } + if (0 === o) { + this.m_countX = 0; + this.m_countY = 0; + return; + } + n.x -= e; + n.y -= e; + r.x += e; + r.y += e; + this.m_countX = 1 + Math.floor(i * (r.x - n.x)); + this.m_countY = 1 + Math.floor(i * (r.y - n.y)); + this.m_diagram = []; + const a = new Sn(4 * this.m_countX * this.m_countY); + for (let t = 0; t < this.m_generatorCount; t++) { + const e = this.m_generatorBuffer[t]; + e.center.SelfSub(n).SelfMul(i); + const s = Math.floor(e.center.x); + const r = Math.floor(e.center.y); + s >= 0 && r >= 0 && s < this.m_countX && r < this.m_countY && a.Push(new vn(s, r, s + r * this.m_countX, e)); + } + for (;!a.Empty(); ) { + const t = a.Front(); + const e = t.m_x; + const i = t.m_y; + const s = t.m_i; + const n = t.m_generator; + a.Pop(); + if (!this.m_diagram[s]) { + this.m_diagram[s] = n; + e > 0 && a.Push(new vn(e - 1, i, s - 1, n)); + i > 0 && a.Push(new vn(e, i - 1, s - this.m_countX, n)); + e < this.m_countX - 1 && a.Push(new vn(e + 1, i, s + 1, n)); + i < this.m_countY - 1 && a.Push(new vn(e, i + 1, s + this.m_countX, n)); + } + } + for (let t = 0; t < this.m_countY; t++) for (let e = 0; e < this.m_countX - 1; e++) { + const i = e + t * this.m_countX; + const s = this.m_diagram[i]; + const n = this.m_diagram[i + 1]; + if (s !== n) { + a.Push(new vn(e, t, i, n)); + a.Push(new vn(e + 1, t, i + 1, s)); + } + } + for (let t = 0; t < this.m_countY - 1; t++) for (let e = 0; e < this.m_countX; e++) { + const i = e + t * this.m_countX; + const s = this.m_diagram[i]; + const n = this.m_diagram[i + this.m_countX]; + if (s !== n) { + a.Push(new vn(e, t, i, n)); + a.Push(new vn(e, t + 1, i + this.m_countX, s)); + } + } + for (;!a.Empty(); ) { + const t = a.Front(); + const e = t.m_x; + const i = t.m_y; + const s = t.m_i; + const n = t.m_generator; + a.Pop(); + const r = this.m_diagram[s]; + const o = n; + if (r !== o) { + const t = r.center.x - e; + const n = r.center.y - i; + const l = o.center.x - e; + const h = o.center.y - i; + if (t * t + n * n > l * l + h * h) { + this.m_diagram[s] = o; + e > 0 && a.Push(new vn(e - 1, i, s - 1, o)); + i > 0 && a.Push(new vn(e, i - 1, s - this.m_countX, o)); + e < this.m_countX - 1 && a.Push(new vn(e + 1, i, s + 1, o)); + i < this.m_countY - 1 && a.Push(new vn(e, i + 1, s + this.m_countX, o)); + } + } + } + } + GetNodes(t) { + for (let e = 0; e < this.m_countY - 1; e++) for (let i = 0; i < this.m_countX - 1; i++) { + const s = i + e * this.m_countX; + const n = this.m_diagram[s]; + const r = this.m_diagram[s + 1]; + const o = this.m_diagram[s + this.m_countX]; + const a = this.m_diagram[s + 1 + this.m_countX]; + if (r !== o) { + n !== r && n !== o && (n.necessary || r.necessary || o.necessary) && t(n.tag, r.tag, o.tag); + a !== r && a !== o && (n.necessary || r.necessary || o.necessary) && t(r.tag, a.tag, o.tag); + } + } + } + } + class Tn { + constructor() { + this.center = new St; + this.tag = 0; + this.necessary = !1; + } + } + class vn { + constructor(t, e, i, s) { + this.m_x = t; + this.m_y = e; + this.m_i = i; + this.m_generator = s; + } + } + function En(t, e, i) { + const s = t[e]; + t[e] = t[i]; + t[i] = s; + } + function Cn(t, e) { + return t < e; + } + function xn(t, e = 0, i = t.length - e, s = Cn) { + let n = e; + const r = []; + let o = 0; + for (;;) { + for (;n + 1 < i; i++) { + const e = t[n + Math.floor(Math.random() * (i - n))]; + r[o++] = i; + for (let r = n - 1; ;) { + for (;s(t[++r], e); ) ; + for (;s(e, t[--i]); ) ; + if (r >= i) break; + En(t, r, i); + } + } + if (0 === o) break; + n = i; + i = r[--o]; + } + return t; + } + function wn(t, e = 0, i = t.length - e, s = Cn) { + return xn(t, e, i, s); + } + function Rn(t, e, i = t.length) { + let s = 0; + for (let n = 0; n < i; ++n) e(t[n]) || (n !== s ? En(t, s++, n) : ++s); + return s; + } + function In(t, e, i, s, n) { + let r = i - e; + for (;r > 0; ) { + const i = Math.floor(r / 2); + let o = e + i; + if (n(t[o], s)) { + e = ++o; + r -= i + 1; + } else r = i; + } + return e; + } + function Mn(t, e, i, s, n) { + let r = i - e; + for (;r > 0; ) { + const i = Math.floor(r / 2); + let o = e + i; + if (n(s, t[o])) r = i; else { + e = ++o; + r -= i + 1; + } + } + return e; + } + function Bn(t, e, i, s) { + let n = i; + for (;e !== n; ) { + En(t, e++, n++); + n === s ? n = i : e === i && (i = n); + } + } + function Dn(t, e, i, s) { + if (e === i) return i; + let n = e; + for (;++e !== i; ) s(t[n], t[e]) || En(t, ++n, e); + return ++n; + } + class Pn { + constructor(t) { + this.data = []; + this.count = 0; + this.capacity = 0; + this.allocator = t; + } + Append() { + this.count >= this.capacity && this.Grow(); + return this.count++; + } + Reserve(t) { + if (!(this.capacity >= t)) { + for (let e = this.capacity; e < t; ++e) this.data[e] = this.allocator(); + this.capacity = t; + } + } + Grow() { + const t = this.capacity ? 2 * this.capacity : P; + this.Reserve(t); + } + Free() { + if (0 !== this.data.length) { + this.data = []; + this.capacity = 0; + this.count = 0; + } + } + Shorten(t) {} + Data() { + return this.data; + } + GetCount() { + return this.count; + } + SetCount(t) { + this.count = t; + } + GetCapacity() { + return this.capacity; + } + RemoveIf(t) { + this.count = Rn(this.data, t, this.count); + } + Unique(t) { + this.count = Dn(this.data, 0, this.count, t); + } + } + class On extends Qs { + constructor(t) { + super(); + this.m_system = t; + } + ShouldQueryParticleSystem(t) { + return !1; + } + ReportFixture(t) { + if (t.IsSensor()) return !0; + const e = t.GetShape().GetChildCount(); + for (let i = 0; i < e; i++) { + const e = t.GetAABB(i); + const s = this.m_system.GetInsideBoundsEnumerator(e); + let n; + for (;(n = s.GetNext()) >= 0; ) this.ReportFixtureAndParticle(t, i, n); + } + return !0; + } + ReportParticle(t, e) { + return !1; + } + ReportFixtureAndParticle(t, e, i) {} + } + class Nn { + constructor() { + this.indexA = 0; + this.indexB = 0; + this.weight = 0; + this.normal = new St; + this.flags = 0; + } + SetIndices(t, e) { + this.indexA = t; + this.indexB = e; + } + SetWeight(t) { + this.weight = t; + } + SetNormal(t) { + this.normal.Copy(t); + } + SetFlags(t) { + this.flags = t; + } + GetIndexA() { + return this.indexA; + } + GetIndexB() { + return this.indexB; + } + GetWeight() { + return this.weight; + } + GetNormal() { + return this.normal; + } + GetFlags() { + return this.flags; + } + IsEqual(t) { + return this.indexA === t.indexA && this.indexB === t.indexB && this.flags === t.flags && this.weight === t.weight && this.normal.x === t.normal.x && this.normal.y === t.normal.y; + } + IsNotEqual(t) { + return !this.IsEqual(t); + } + ApproximatelyEqual(t) { + const e = .01; + const i = 1e-4; + return this.indexA === t.indexA && this.indexB === t.indexB && this.flags === t.flags && $(this.weight - t.weight) < e && St.DistanceSquaredVV(this.normal, t.normal) < i; + } + } + class Ln { + constructor() { + this.index = 0; + this.weight = 0; + this.normal = new St; + this.mass = 0; + } + } + class Fn { + constructor() { + this.indexA = 0; + this.indexB = 0; + this.flags = 0; + this.strength = 0; + this.distance = 0; + } + } + class Vn { + constructor() { + this.indexA = 0; + this.indexB = 0; + this.indexC = 0; + this.flags = 0; + this.strength = 0; + this.pa = new St(0, 0); + this.pb = new St(0, 0); + this.pc = new St(0, 0); + this.ka = 0; + this.kb = 0; + this.kc = 0; + this.s = 0; + } + } + class kn { + constructor() { + this.strictContactCheck = !1; + this.density = 1; + this.gravityScale = 1; + this.radius = 1; + this.maxCount = 0; + this.pressureStrength = .005; + this.dampingStrength = 1; + this.elasticStrength = .25; + this.springStrength = .25; + this.viscousStrength = .25; + this.surfaceTensionPressureStrength = .2; + this.surfaceTensionNormalStrength = .2; + this.repulsiveStrength = 1; + this.powderStrength = .5; + this.ejectionStrength = .5; + this.staticPressureStrength = .2; + this.staticPressureRelaxation = .2; + this.staticPressureIterations = 8; + this.colorMixingStrength = .5; + this.destroyByAge = !0; + this.lifetimeGranularity = 1 / 60; + } + Copy(t) { + this.strictContactCheck = t.strictContactCheck; + this.density = t.density; + this.gravityScale = t.gravityScale; + this.radius = t.radius; + this.maxCount = t.maxCount; + this.pressureStrength = t.pressureStrength; + this.dampingStrength = t.dampingStrength; + this.elasticStrength = t.elasticStrength; + this.springStrength = t.springStrength; + this.viscousStrength = t.viscousStrength; + this.surfaceTensionPressureStrength = t.surfaceTensionPressureStrength; + this.surfaceTensionNormalStrength = t.surfaceTensionNormalStrength; + this.repulsiveStrength = t.repulsiveStrength; + this.powderStrength = t.powderStrength; + this.ejectionStrength = t.ejectionStrength; + this.staticPressureStrength = t.staticPressureStrength; + this.staticPressureRelaxation = t.staticPressureRelaxation; + this.staticPressureIterations = t.staticPressureIterations; + this.colorMixingStrength = t.colorMixingStrength; + this.destroyByAge = t.destroyByAge; + this.lifetimeGranularity = t.lifetimeGranularity; + return this; + } + Clone() { + return (new kn).Copy(this); + } + } + class Un { + constructor(t, e) { + this.m_paused = !1; + this.m_timestamp = 0; + this.m_allParticleFlags = 0; + this.m_needsUpdateAllParticleFlags = !1; + this.m_allGroupFlags = 0; + this.m_needsUpdateAllGroupFlags = !1; + this.m_hasForce = !1; + this.m_iterationIndex = 0; + this.m_inverseDensity = 0; + this.m_particleDiameter = 0; + this.m_inverseDiameter = 0; + this.m_squaredDiameter = 0; + this.m_count = 0; + this.m_internalAllocatedCapacity = 0; + this.m_handleIndexBuffer = new Gn; + this.m_flagsBuffer = new Gn; + this.m_positionBuffer = new Gn; + this.m_velocityBuffer = new Gn; + this.m_forceBuffer = []; + this.m_weightBuffer = []; + this.m_staticPressureBuffer = []; + this.m_accumulationBuffer = []; + this.m_accumulation2Buffer = []; + this.m_depthBuffer = []; + this.m_colorBuffer = new Gn; + this.m_groupBuffer = []; + this.m_userDataBuffer = new Gn; + this.m_stuckThreshold = 0; + this.m_lastBodyContactStepBuffer = new Gn; + this.m_bodyContactCountBuffer = new Gn; + this.m_consecutiveContactStepsBuffer = new Gn; + this.m_stuckParticleBuffer = new Pn((() => 0)); + this.m_proxyBuffer = new Pn((() => new zn)); + this.m_contactBuffer = new Pn((() => new Nn)); + this.m_bodyContactBuffer = new Pn((() => new Ln)); + this.m_pairBuffer = new Pn((() => new Fn)); + this.m_triadBuffer = new Pn((() => new Vn)); + this.m_expirationTimeBuffer = new Gn; + this.m_indexByExpirationTimeBuffer = new Gn; + this.m_timeElapsed = 0; + this.m_expirationTimeBufferRequiresSorting = !1; + this.m_groupCount = 0; + this.m_groupList = null; + this.m_def = new kn; + this.m_prev = null; + this.m_next = null; + this.UpdateBodyContacts_callback = null; + this.SolveCollision_callback = null; + this.SetStrictContactCheck(t.strictContactCheck); + this.SetDensity(t.density); + this.SetGravityScale(t.gravityScale); + this.SetRadius(t.radius); + this.SetMaxParticleCount(t.maxCount); + this.m_def = t.Clone(); + this.m_world = e; + this.SetDestructionByAge(this.m_def.destroyByAge); + } + static computeTag(t, e) { + return (e + Un.yOffset >>> 0 << Un.yShift) + (Un.xScale * t + Un.xOffset >>> 0) >>> 0; + } + static computeRelativeTag(t, e, i) { + return t + (i << Un.yShift) + (e << Un.xShift) >>> 0; + } + Drop() { + for (;this.m_groupList; ) this.DestroyParticleGroup(this.m_groupList); + this.FreeUserOverridableBuffer(this.m_handleIndexBuffer); + this.FreeUserOverridableBuffer(this.m_flagsBuffer); + this.FreeUserOverridableBuffer(this.m_lastBodyContactStepBuffer); + this.FreeUserOverridableBuffer(this.m_bodyContactCountBuffer); + this.FreeUserOverridableBuffer(this.m_consecutiveContactStepsBuffer); + this.FreeUserOverridableBuffer(this.m_positionBuffer); + this.FreeUserOverridableBuffer(this.m_velocityBuffer); + this.FreeUserOverridableBuffer(this.m_colorBuffer); + this.FreeUserOverridableBuffer(this.m_userDataBuffer); + this.FreeUserOverridableBuffer(this.m_expirationTimeBuffer); + this.FreeUserOverridableBuffer(this.m_indexByExpirationTimeBuffer); + this.FreeBuffer(this.m_forceBuffer, this.m_internalAllocatedCapacity); + this.FreeBuffer(this.m_weightBuffer, this.m_internalAllocatedCapacity); + this.FreeBuffer(this.m_staticPressureBuffer, this.m_internalAllocatedCapacity); + this.FreeBuffer(this.m_accumulationBuffer, this.m_internalAllocatedCapacity); + this.FreeBuffer(this.m_accumulation2Buffer, this.m_internalAllocatedCapacity); + this.FreeBuffer(this.m_depthBuffer, this.m_internalAllocatedCapacity); + this.FreeBuffer(this.m_groupBuffer, this.m_internalAllocatedCapacity); + } + CreateParticle(t) { + if (this.m_world.IsLocked()) throw new Error; + if (this.m_count >= this.m_internalAllocatedCapacity) { + const t = this.m_count ? 2 * this.m_count : P; + this.ReallocateInternalAllocatedBuffers(t); + } + if (this.m_count >= this.m_internalAllocatedCapacity) { + if (!this.m_def.destroyByAge) return C; + this.DestroyOldestParticle(0, !1); + this.SolveZombie(); + } + const e = this.m_count++; + this.m_flagsBuffer.data[e] = 0; + this.m_lastBodyContactStepBuffer.data && (this.m_lastBodyContactStepBuffer.data[e] = 0); + this.m_bodyContactCountBuffer.data && (this.m_bodyContactCountBuffer.data[e] = 0); + this.m_consecutiveContactStepsBuffer.data && (this.m_consecutiveContactStepsBuffer.data[e] = 0); + this.m_positionBuffer.data[e] = (this.m_positionBuffer.data[e] || new St).Copy(i(t.position, St.ZERO)); + this.m_velocityBuffer.data[e] = (this.m_velocityBuffer.data[e] || new St).Copy(i(t.velocity, St.ZERO)); + this.m_weightBuffer[e] = 0; + this.m_forceBuffer[e] = (this.m_forceBuffer[e] || new St).SetZero(); + this.m_staticPressureBuffer && (this.m_staticPressureBuffer[e] = 0); + this.m_depthBuffer && (this.m_depthBuffer[e] = 0); + const s = (new Rt).Copy(i(t.color, Rt.ZERO)); + if (this.m_colorBuffer.data || !s.IsZero()) { + this.m_colorBuffer.data = this.RequestBuffer(this.m_colorBuffer.data); + this.m_colorBuffer.data[e] = (this.m_colorBuffer.data[e] || new Rt).Copy(s); + } + if (this.m_userDataBuffer.data || t.userData) { + this.m_userDataBuffer.data = this.RequestBuffer(this.m_userDataBuffer.data); + this.m_userDataBuffer.data[e] = t.userData; + } + this.m_handleIndexBuffer.data && (this.m_handleIndexBuffer.data[e] = null); + const n = this.m_proxyBuffer.data[this.m_proxyBuffer.Append()]; + const r = i(t.lifetime, 0); + const o = r > 0; + if (this.m_expirationTimeBuffer.data || o) { + this.SetParticleLifetime(e, o ? r : this.ExpirationTimeToLifetime(-this.GetQuantizedTimeElapsed())); + this.m_indexByExpirationTimeBuffer.data[e] = e; + } + n.index = e; + const a = i(t.group, null); + this.m_groupBuffer[e] = a; + if (a) if (a.m_firstIndex < a.m_lastIndex) { + this.RotateBuffer(a.m_firstIndex, a.m_lastIndex, e); + a.m_lastIndex = e + 1; + } else { + a.m_firstIndex = e; + a.m_lastIndex = e + 1; + } + this.SetParticleFlags(e, i(t.flags, 0)); + return e; + } + GetParticleHandleFromIndex(t) { + this.m_handleIndexBuffer.data = this.RequestBuffer(this.m_handleIndexBuffer.data); + let e = this.m_handleIndexBuffer.data[t]; + if (e) return e; + e = new gn; + e.SetIndex(t); + this.m_handleIndexBuffer.data[t] = e; + return e; + } + DestroyParticle(e, i = !1) { + let s = t.b2ParticleFlag.b2_zombieParticle; + i && (s |= t.b2ParticleFlag.b2_destructionListenerParticle); + this.SetParticleFlags(e, this.m_flagsBuffer.data[e] | s); + } + DestroyOldestParticle(t, e = !1) { + const i = this.GetParticleCount(); + const s = this.m_indexByExpirationTimeBuffer.data[i - (t + 1)]; + const n = this.m_indexByExpirationTimeBuffer.data[t]; + this.DestroyParticle(this.m_expirationTimeBuffer.data[s] > 0 ? s : n, e); + } + DestroyParticlesInShape(t, e, i = !1) { + const s = Un.DestroyParticlesInShape_s_aabb; + if (this.m_world.IsLocked()) throw new Error; + const n = new Zn(this, t, e, i); + const r = s; + t.ComputeAABB(r, e, 0); + this.m_world.QueryAABB(n, r); + return n.Destroyed(); + } + CreateParticleGroup(t) { + const e = Un.CreateParticleGroup_s_transform; + if (this.m_world.IsLocked()) throw new Error; + const s = e; + s.SetPositionAngle(i(t.position, St.ZERO), i(t.angle, 0)); + const n = this.m_count; + t.shape && this.CreateParticlesWithShapeForGroup(t.shape, t, s); + t.shapes && this.CreateParticlesWithShapesForGroup(t.shapes, i(t.shapeCount, t.shapes.length), t, s); + if (t.positionData) { + const e = i(t.particleCount, t.positionData.length); + for (let i = 0; i < e; i++) { + const e = t.positionData[i]; + this.CreateParticleForGroup(t, s, e); + } + } + const r = this.m_count; + let o = new bn(this); + o.m_firstIndex = n; + o.m_lastIndex = r; + o.m_strength = i(t.strength, 1); + o.m_userData = t.userData; + o.m_transform.Copy(s); + o.m_prev = null; + o.m_next = this.m_groupList; + this.m_groupList && (this.m_groupList.m_prev = o); + this.m_groupList = o; + ++this.m_groupCount; + for (let t = n; t < r; t++) this.m_groupBuffer[t] = o; + this.SetGroupFlags(o, i(t.groupFlags, 0)); + const a = new Jn; + this.UpdateContacts(!0); + this.UpdatePairsAndTriads(n, r, a); + if (t.group) { + this.JoinParticleGroups(t.group, o); + o = t.group; + } + return o; + } + JoinParticleGroups(t, e) { + if (this.m_world.IsLocked()) throw new Error; + this.RotateBuffer(e.m_firstIndex, e.m_lastIndex, this.m_count); + this.RotateBuffer(t.m_firstIndex, t.m_lastIndex, e.m_firstIndex); + const i = new Qn(e.m_firstIndex); + this.UpdateContacts(!0); + this.UpdatePairsAndTriads(t.m_firstIndex, e.m_lastIndex, i); + for (let i = e.m_firstIndex; i < e.m_lastIndex; i++) this.m_groupBuffer[i] = t; + const s = t.m_groupFlags | e.m_groupFlags; + this.SetGroupFlags(t, s); + t.m_lastIndex = e.m_lastIndex; + e.m_firstIndex = e.m_lastIndex; + this.DestroyParticleGroup(e); + } + SplitParticleGroup(t) { + this.UpdateContacts(!0); + const e = Y(t.GetParticleCount(), (t => new jn)); + Un.InitializeParticleLists(t, e); + this.MergeParticleListsInContact(t, e); + const i = Un.FindLongestParticleList(t, e); + this.MergeZombieParticleListNodes(t, e, i); + this.CreateParticleGroupsFromParticleList(t, e, i); + this.UpdatePairsAndTriadsWithParticleList(t, e); + } + GetParticleGroupList() { + return this.m_groupList; + } + GetParticleGroupCount() { + return this.m_groupCount; + } + GetParticleCount() { + return this.m_count; + } + GetMaxParticleCount() { + return this.m_def.maxCount; + } + SetMaxParticleCount(t) { + this.m_def.maxCount = t; + } + GetAllParticleFlags() { + return this.m_allParticleFlags; + } + GetAllGroupFlags() { + return this.m_allGroupFlags; + } + SetPaused(t) { + this.m_paused = t; + } + GetPaused() { + return this.m_paused; + } + SetDensity(t) { + this.m_def.density = t; + this.m_inverseDensity = 1 / this.m_def.density; + } + GetDensity() { + return this.m_def.density; + } + SetGravityScale(t) { + this.m_def.gravityScale = t; + } + GetGravityScale() { + return this.m_def.gravityScale; + } + SetDamping(t) { + this.m_def.dampingStrength = t; + } + GetDamping() { + return this.m_def.dampingStrength; + } + SetStaticPressureIterations(t) { + this.m_def.staticPressureIterations = t; + } + GetStaticPressureIterations() { + return this.m_def.staticPressureIterations; + } + SetRadius(t) { + this.m_particleDiameter = 2 * t; + this.m_squaredDiameter = this.m_particleDiameter * this.m_particleDiameter; + this.m_inverseDiameter = 1 / this.m_particleDiameter; + } + GetRadius() { + return this.m_particleDiameter / 2; + } + GetPositionBuffer() { + return this.m_positionBuffer.data; + } + GetVelocityBuffer() { + return this.m_velocityBuffer.data; + } + GetColorBuffer() { + this.m_colorBuffer.data = this.RequestBuffer(this.m_colorBuffer.data); + return this.m_colorBuffer.data; + } + GetGroupBuffer() { + return this.m_groupBuffer; + } + GetWeightBuffer() { + return this.m_weightBuffer; + } + GetUserDataBuffer() { + this.m_userDataBuffer.data = this.RequestBuffer(this.m_userDataBuffer.data); + return this.m_userDataBuffer.data; + } + GetFlagsBuffer() { + return this.m_flagsBuffer.data; + } + SetParticleFlags(e, i) { + this.m_flagsBuffer.data[e] & ~i && (this.m_needsUpdateAllParticleFlags = !0); + if (~this.m_allParticleFlags & i) { + i & t.b2ParticleFlag.b2_tensileParticle && (this.m_accumulation2Buffer = this.RequestBuffer(this.m_accumulation2Buffer)); + i & t.b2ParticleFlag.b2_colorMixingParticle && (this.m_colorBuffer.data = this.RequestBuffer(this.m_colorBuffer.data)); + this.m_allParticleFlags |= i; + } + this.m_flagsBuffer.data[e] = i; + } + GetParticleFlags(t) { + return this.m_flagsBuffer.data[t]; + } + SetFlagsBuffer(t) { + this.SetUserOverridableBuffer(this.m_flagsBuffer, t); + } + SetPositionBuffer(t) { + if (t instanceof Float32Array) { + if (t.length % 2 != 0) throw new Error; + const e = t.length / 2; + const i = new Array(e); + for (let s = 0; s < e; ++s) i[s] = new St(t.subarray(2 * s, 2 * s + 2)); + t = i; + } + this.SetUserOverridableBuffer(this.m_positionBuffer, t); + } + SetVelocityBuffer(t) { + if (t instanceof Float32Array) { + if (t.length % 2 != 0) throw new Error; + const e = t.length / 2; + const i = new Array(e); + for (let s = 0; s < e; ++s) i[s] = new St(t.subarray(2 * s, 2 * s + 2)); + t = i; + } + this.SetUserOverridableBuffer(this.m_velocityBuffer, t); + } + SetColorBuffer(t) { + if (t instanceof Float32Array) { + if (t.length % 4 != 0) throw new Error; + const e = t.length / 4; + const i = new Array(e); + for (let s = 0; s < e; ++s) i[s] = new Rt(t.subarray(4 * s, 4 * s + 4)); + t = i; + } + this.SetUserOverridableBuffer(this.m_colorBuffer, t); + } + SetUserDataBuffer(t) { + this.SetUserOverridableBuffer(this.m_userDataBuffer, t); + } + GetContacts() { + return this.m_contactBuffer.data; + } + GetContactCount() { + return this.m_contactBuffer.count; + } + GetBodyContacts() { + return this.m_bodyContactBuffer.data; + } + GetBodyContactCount() { + return this.m_bodyContactBuffer.count; + } + GetPairs() { + return this.m_pairBuffer.data; + } + GetPairCount() { + return this.m_pairBuffer.count; + } + GetTriads() { + return this.m_triadBuffer.data; + } + GetTriadCount() { + return this.m_triadBuffer.count; + } + SetStuckThreshold(t) { + this.m_stuckThreshold = t; + if (t > 0) { + this.m_lastBodyContactStepBuffer.data = this.RequestBuffer(this.m_lastBodyContactStepBuffer.data); + this.m_bodyContactCountBuffer.data = this.RequestBuffer(this.m_bodyContactCountBuffer.data); + this.m_consecutiveContactStepsBuffer.data = this.RequestBuffer(this.m_consecutiveContactStepsBuffer.data); + } + } + GetStuckCandidates() { + return this.m_stuckParticleBuffer.Data(); + } + GetStuckCandidateCount() { + return this.m_stuckParticleBuffer.GetCount(); + } + ComputeCollisionEnergy() { + const t = Un.ComputeCollisionEnergy_s_v; + const e = this.m_velocityBuffer.data; + let i = 0; + for (let s = 0; s < this.m_contactBuffer.count; s++) { + const n = this.m_contactBuffer.data[s]; + const r = n.indexA; + const o = n.indexB; + const a = n.normal; + const l = St.SubVV(e[o], e[r], t); + const h = St.DotVV(l, a); + h < 0 && (i += h * h); + } + return .5 * this.GetParticleMass() * i; + } + SetStrictContactCheck(t) { + this.m_def.strictContactCheck = t; + } + GetStrictContactCheck() { + return this.m_def.strictContactCheck; + } + SetParticleLifetime(t, e) { + const i = null === this.m_indexByExpirationTimeBuffer.data; + this.m_expirationTimeBuffer.data = this.RequestBuffer(this.m_expirationTimeBuffer.data); + this.m_indexByExpirationTimeBuffer.data = this.RequestBuffer(this.m_indexByExpirationTimeBuffer.data); + if (i) { + const t = this.GetParticleCount(); + for (let e = 0; e < t; ++e) this.m_indexByExpirationTimeBuffer.data[e] = e; + } + const s = e / this.m_def.lifetimeGranularity; + const n = s > 0 ? this.GetQuantizedTimeElapsed() + s : s; + if (n !== this.m_expirationTimeBuffer.data[t]) { + this.m_expirationTimeBuffer.data[t] = n; + this.m_expirationTimeBufferRequiresSorting = !0; + } + } + GetParticleLifetime(t) { + return this.ExpirationTimeToLifetime(this.GetExpirationTimeBuffer()[t]); + } + SetDestructionByAge(t) { + t && this.GetExpirationTimeBuffer(); + this.m_def.destroyByAge = t; + } + GetDestructionByAge() { + return this.m_def.destroyByAge; + } + GetExpirationTimeBuffer() { + this.m_expirationTimeBuffer.data = this.RequestBuffer(this.m_expirationTimeBuffer.data); + return this.m_expirationTimeBuffer.data; + } + ExpirationTimeToLifetime(t) { + return (t > 0 ? t - this.GetQuantizedTimeElapsed() : t) * this.m_def.lifetimeGranularity; + } + GetIndexByExpirationTimeBuffer() { + this.GetParticleCount() ? this.SetParticleLifetime(0, this.GetParticleLifetime(0)) : this.m_indexByExpirationTimeBuffer.data = this.RequestBuffer(this.m_indexByExpirationTimeBuffer.data); + return this.m_indexByExpirationTimeBuffer.data; + } + ParticleApplyLinearImpulse(t, e) { + this.ApplyLinearImpulse(t, t + 1, e); + } + ApplyLinearImpulse(t, e, i) { + const s = this.m_velocityBuffer.data; + const n = (e - t) * this.GetParticleMass(); + const r = (new St).Copy(i).SelfMul(1 / n); + for (let i = t; i < e; i++) s[i].SelfAdd(r); + } + static IsSignificantForce(t) { + return 0 !== t.x || 0 !== t.y; + } + ParticleApplyForce(t, e) { + if (Un.IsSignificantForce(e) && this.ForceCanBeApplied(this.m_flagsBuffer.data[t])) { + this.PrepareForceBuffer(); + this.m_forceBuffer[t].SelfAdd(e); + } + } + ApplyForce(t, e, i) { + const s = (new St).Copy(i).SelfMul(1 / (e - t)); + if (Un.IsSignificantForce(s)) { + this.PrepareForceBuffer(); + for (let i = t; i < e; i++) this.m_forceBuffer[i].SelfAdd(s); + } + } + GetNext() { + return this.m_next; + } + QueryAABB(t, e) { + if (0 === this.m_proxyBuffer.count) return; + const i = 0; + const s = this.m_proxyBuffer.count; + const n = In(this.m_proxyBuffer.data, i, s, Un.computeTag(this.m_inverseDiameter * e.lowerBound.x, this.m_inverseDiameter * e.lowerBound.y), zn.CompareProxyTag); + const r = Mn(this.m_proxyBuffer.data, n, s, Un.computeTag(this.m_inverseDiameter * e.upperBound.x, this.m_inverseDiameter * e.upperBound.y), zn.CompareTagProxy); + const o = this.m_positionBuffer.data; + for (let i = n; i < r; ++i) { + const s = this.m_proxyBuffer.data[i].index; + const n = o[s]; + if (e.lowerBound.x < n.x && n.x < e.upperBound.x && e.lowerBound.y < n.y && n.y < e.upperBound.y && !t.ReportParticle(this, s)) break; + } + } + QueryShapeAABB(t, e, i, s = 0) { + const n = Un.QueryShapeAABB_s_aabb; + e.ComputeAABB(n, i, s); + this.QueryAABB(t, n); + } + QueryPointAABB(t, e, i = u) { + const s = Un.QueryPointAABB_s_aabb; + s.lowerBound.Set(e.x - i, e.y - i); + s.upperBound.Set(e.x + i, e.y + i); + this.QueryAABB(t, s); + } + RayCast(t, e, i) { + const s = Un.RayCast_s_aabb; + const n = Un.RayCast_s_p; + const r = Un.RayCast_s_v; + const o = Un.RayCast_s_n; + const a = Un.RayCast_s_point; + if (0 === this.m_proxyBuffer.count) return; + const l = this.m_positionBuffer.data; + const h = s; + St.MinV(e, i, h.lowerBound); + St.MaxV(e, i, h.upperBound); + let c = 1; + const u = St.SubVV(i, e, r); + const _ = St.DotVV(u, u); + const d = this.GetInsideBoundsEnumerator(h); + let p; + for (;(p = d.GetNext()) >= 0; ) { + const i = St.SubVV(e, l[p], n); + const s = St.DotVV(i, u); + const r = s * s - _ * (St.DotVV(i, i) - this.m_squaredDiameter); + if (r >= 0) { + const n = at(r); + let l = (-s - n) / _; + if (l > c) continue; + if (l < 0) { + l = (-s + n) / _; + if (l < 0 || l > c) continue; + } + const h = St.AddVMulSV(i, l, u, o); + h.Normalize(); + c = tt(c, t.ReportParticle(this, p, St.AddVMulSV(e, l, u, a), h, l)); + if (c <= 0) break; + } + } + } + ComputeAABB(t) { + const e = this.GetParticleCount(); + t.lowerBound.x = +s; + t.lowerBound.y = +s; + t.upperBound.x = -s; + t.upperBound.y = -s; + const i = this.m_positionBuffer.data; + for (let s = 0; s < e; s++) { + const e = i[s]; + St.MinV(t.lowerBound, e, t.lowerBound); + St.MaxV(t.upperBound, e, t.upperBound); + } + t.lowerBound.x -= this.m_particleDiameter; + t.lowerBound.y -= this.m_particleDiameter; + t.upperBound.x += this.m_particleDiameter; + t.upperBound.y += this.m_particleDiameter; + } + FreeBuffer(t, e) { + null !== t && (t.length = 0); + } + FreeUserOverridableBuffer(t) { + 0 === t.userSuppliedCapacity && this.FreeBuffer(t.data, this.m_internalAllocatedCapacity); + } + ReallocateBuffer3(t, e, i) { + if (i <= e) throw new Error; + const s = t ? t.slice() : []; + s.length = i; + return s; + } + ReallocateBuffer5(t, e, i, s, n) { + if (s <= i) throw new Error; + if (e && !(s <= e)) throw new Error; + n && !t || e || (t = this.ReallocateBuffer3(t, i, s)); + return t; + } + ReallocateBuffer4(t, e, i, s) { + return this.ReallocateBuffer5(t.data, t.userSuppliedCapacity, e, i, s); + } + RequestBuffer(t) { + if (!t) { + 0 === this.m_internalAllocatedCapacity && this.ReallocateInternalAllocatedBuffers(P); + (t = []).length = this.m_internalAllocatedCapacity; + } + return t; + } + ReallocateHandleBuffers(t) { + this.m_handleIndexBuffer.data = this.ReallocateBuffer4(this.m_handleIndexBuffer, this.m_internalAllocatedCapacity, t, !0); + } + ReallocateInternalAllocatedBuffers(t) { + function e(t, e) { + return e && t > e ? e : t; + } + t = e(t, this.m_def.maxCount); + t = e(t, this.m_flagsBuffer.userSuppliedCapacity); + t = e(t, this.m_positionBuffer.userSuppliedCapacity); + t = e(t, this.m_velocityBuffer.userSuppliedCapacity); + t = e(t, this.m_colorBuffer.userSuppliedCapacity); + t = e(t, this.m_userDataBuffer.userSuppliedCapacity); + if (this.m_internalAllocatedCapacity < t) { + this.ReallocateHandleBuffers(t); + this.m_flagsBuffer.data = this.ReallocateBuffer4(this.m_flagsBuffer, this.m_internalAllocatedCapacity, t, !1); + const e = this.m_stuckThreshold > 0; + this.m_lastBodyContactStepBuffer.data = this.ReallocateBuffer4(this.m_lastBodyContactStepBuffer, this.m_internalAllocatedCapacity, t, e); + this.m_bodyContactCountBuffer.data = this.ReallocateBuffer4(this.m_bodyContactCountBuffer, this.m_internalAllocatedCapacity, t, e); + this.m_consecutiveContactStepsBuffer.data = this.ReallocateBuffer4(this.m_consecutiveContactStepsBuffer, this.m_internalAllocatedCapacity, t, e); + this.m_positionBuffer.data = this.ReallocateBuffer4(this.m_positionBuffer, this.m_internalAllocatedCapacity, t, !1); + this.m_velocityBuffer.data = this.ReallocateBuffer4(this.m_velocityBuffer, this.m_internalAllocatedCapacity, t, !1); + this.m_forceBuffer = this.ReallocateBuffer5(this.m_forceBuffer, 0, this.m_internalAllocatedCapacity, t, !1); + this.m_weightBuffer = this.ReallocateBuffer5(this.m_weightBuffer, 0, this.m_internalAllocatedCapacity, t, !1); + this.m_staticPressureBuffer = this.ReallocateBuffer5(this.m_staticPressureBuffer, 0, this.m_internalAllocatedCapacity, t, !0); + this.m_accumulationBuffer = this.ReallocateBuffer5(this.m_accumulationBuffer, 0, this.m_internalAllocatedCapacity, t, !1); + this.m_accumulation2Buffer = this.ReallocateBuffer5(this.m_accumulation2Buffer, 0, this.m_internalAllocatedCapacity, t, !0); + this.m_depthBuffer = this.ReallocateBuffer5(this.m_depthBuffer, 0, this.m_internalAllocatedCapacity, t, !0); + this.m_colorBuffer.data = this.ReallocateBuffer4(this.m_colorBuffer, this.m_internalAllocatedCapacity, t, !0); + this.m_groupBuffer = this.ReallocateBuffer5(this.m_groupBuffer, 0, this.m_internalAllocatedCapacity, t, !1); + this.m_userDataBuffer.data = this.ReallocateBuffer4(this.m_userDataBuffer, this.m_internalAllocatedCapacity, t, !0); + this.m_expirationTimeBuffer.data = this.ReallocateBuffer4(this.m_expirationTimeBuffer, this.m_internalAllocatedCapacity, t, !0); + this.m_indexByExpirationTimeBuffer.data = this.ReallocateBuffer4(this.m_indexByExpirationTimeBuffer, this.m_internalAllocatedCapacity, t, !1); + this.m_internalAllocatedCapacity = t; + } + } + CreateParticleForGroup(t, e, s) { + const n = new mn; + n.flags = i(t.flags, 0); + xt.MulXV(e, s, n.position); + St.AddVV(i(t.linearVelocity, St.ZERO), St.CrossSV(i(t.angularVelocity, 0), St.SubVV(n.position, i(t.position, St.ZERO), St.s_t0), St.s_t0), n.velocity); + n.color.Copy(i(t.color, Rt.ZERO)); + n.lifetime = i(t.lifetime, 0); + n.userData = t.userData; + this.CreateParticle(n); + } + CreateParticlesStrokeShapeForGroup(e, s, n) { + const r = Un.CreateParticlesStrokeShapeForGroup_s_edge; + const o = Un.CreateParticlesStrokeShapeForGroup_s_d; + const a = Un.CreateParticlesStrokeShapeForGroup_s_p; + let l = i(s.stride, 0); + 0 === l && (l = this.GetParticleStride()); + let h = 0; + const c = e.GetChildCount(); + for (let i = 0; i < c; i++) { + let c = null; + if (e.GetType() === t.b2ShapeType.e_edgeShape) c = e; else { + c = r; + e.GetChildEdge(c, i); + } + const u = St.SubVV(c.m_vertex2, c.m_vertex1, o); + const _ = u.Length(); + for (;h < _; ) { + const t = St.AddVMulSV(c.m_vertex1, h / _, u, a); + this.CreateParticleForGroup(s, n, t); + h += l; + } + h -= _; + } + } + CreateParticlesFillShapeForGroup(t, e, s) { + const n = Un.CreateParticlesFillShapeForGroup_s_aabb; + const r = Un.CreateParticlesFillShapeForGroup_s_p; + let o = i(e.stride, 0); + 0 === o && (o = this.GetParticleStride()); + const a = xt.IDENTITY; + const l = n; + t.ComputeAABB(l, a, 0); + for (let i = Math.floor(l.lowerBound.y / o) * o; i < l.upperBound.y; i += o) for (let n = Math.floor(l.lowerBound.x / o) * o; n < l.upperBound.x; n += o) { + const o = r.Set(n, i); + t.TestPoint(a, o) && this.CreateParticleForGroup(e, s, o); + } + } + CreateParticlesWithShapeForGroup(e, i, s) { + switch (e.GetType()) { + case t.b2ShapeType.e_edgeShape: + case t.b2ShapeType.e_chainShape: + this.CreateParticlesStrokeShapeForGroup(e, i, s); + break; + + case t.b2ShapeType.e_polygonShape: + case t.b2ShapeType.e_circleShape: + this.CreateParticlesFillShapeForGroup(e, i, s); + } + } + CreateParticlesWithShapesForGroup(t, e, i, s) { + const n = new $n(t, e); + this.CreateParticlesFillShapeForGroup(n, i, s); + } + CloneParticle(t, e) { + const i = new mn; + i.flags = this.m_flagsBuffer.data[t]; + i.position.Copy(this.m_positionBuffer.data[t]); + i.velocity.Copy(this.m_velocityBuffer.data[t]); + this.m_colorBuffer.data && i.color.Copy(this.m_colorBuffer.data[t]); + this.m_userDataBuffer.data && (i.userData = this.m_userDataBuffer.data[t]); + i.group = e; + const s = this.CreateParticle(i); + if (this.m_handleIndexBuffer.data) { + const e = this.m_handleIndexBuffer.data[t]; + e && e.SetIndex(s); + this.m_handleIndexBuffer.data[s] = e; + this.m_handleIndexBuffer.data[t] = null; + } + this.m_lastBodyContactStepBuffer.data && (this.m_lastBodyContactStepBuffer.data[s] = this.m_lastBodyContactStepBuffer.data[t]); + this.m_bodyContactCountBuffer.data && (this.m_bodyContactCountBuffer.data[s] = this.m_bodyContactCountBuffer.data[t]); + this.m_consecutiveContactStepsBuffer.data && (this.m_consecutiveContactStepsBuffer.data[s] = this.m_consecutiveContactStepsBuffer.data[t]); + this.m_hasForce && this.m_forceBuffer[s].Copy(this.m_forceBuffer[t]); + this.m_staticPressureBuffer && (this.m_staticPressureBuffer[s] = this.m_staticPressureBuffer[t]); + this.m_depthBuffer && (this.m_depthBuffer[s] = this.m_depthBuffer[t]); + this.m_expirationTimeBuffer.data && (this.m_expirationTimeBuffer.data[s] = this.m_expirationTimeBuffer.data[t]); + return s; + } + DestroyParticlesInGroup(t, e = !1) { + for (let i = t.m_firstIndex; i < t.m_lastIndex; i++) this.DestroyParticle(i, e); + } + DestroyParticleGroup(t) { + this.m_world.m_destructionListener && this.m_world.m_destructionListener.SayGoodbyeParticleGroup(t); + this.SetGroupFlags(t, 0); + for (let e = t.m_firstIndex; e < t.m_lastIndex; e++) this.m_groupBuffer[e] = null; + t.m_prev && (t.m_prev.m_next = t.m_next); + t.m_next && (t.m_next.m_prev = t.m_prev); + t === this.m_groupList && (this.m_groupList = t.m_next); + --this.m_groupCount; + } + static ParticleCanBeConnected(e, i) { + return 0 != (e & (t.b2ParticleFlag.b2_wallParticle | t.b2ParticleFlag.b2_springParticle | t.b2ParticleFlag.b2_elasticParticle)) || null !== i && 0 != (i.GetGroupFlags() & t.b2ParticleGroupFlag.b2_rigidParticleGroup); + } + UpdatePairsAndTriads(e, i, s) { + const n = Un.UpdatePairsAndTriads_s_dab; + const r = Un.UpdatePairsAndTriads_s_dbc; + const o = Un.UpdatePairsAndTriads_s_dca; + const a = this.m_positionBuffer.data; + let l = 0; + for (let t = e; t < i; t++) l |= this.m_flagsBuffer.data[t]; + if (l & Un.k_pairFlags) for (let n = 0; n < this.m_contactBuffer.count; n++) { + const r = this.m_contactBuffer.data[n]; + const o = r.indexA; + const l = r.indexB; + const h = this.m_flagsBuffer.data[o]; + const c = this.m_flagsBuffer.data[l]; + const u = this.m_groupBuffer[o]; + const _ = this.m_groupBuffer[l]; + if (o >= e && o < i && l >= e && l < i && !((h | c) & t.b2ParticleFlag.b2_zombieParticle) && (h | c) & Un.k_pairFlags && (s.IsNecessary(o) || s.IsNecessary(l)) && Un.ParticleCanBeConnected(h, u) && Un.ParticleCanBeConnected(c, _) && s.ShouldCreatePair(o, l)) { + const t = this.m_pairBuffer.data[this.m_pairBuffer.Append()]; + t.indexA = o; + t.indexB = l; + t.flags = r.flags; + t.strength = tt(u ? u.m_strength : 1, _ ? _.m_strength : 1); + t.distance = St.DistanceVV(a[o], a[l]); + } + wn(this.m_pairBuffer.data, 0, this.m_pairBuffer.count, Un.ComparePairIndices); + this.m_pairBuffer.Unique(Un.MatchPairIndices); + } + if (l & Un.k_triadFlags) { + const l = new An(i - e); + for (let n = e; n < i; n++) { + const e = this.m_flagsBuffer.data[n]; + const i = this.m_groupBuffer[n]; + e & t.b2ParticleFlag.b2_zombieParticle || !Un.ParticleCanBeConnected(e, i) || l.AddGenerator(a[n], n, s.IsNecessary(n)); + } + const h = this.GetParticleStride(); + l.Generate(h / 2, 2 * h); + const c = this; + const u = (t, e, i) => { + const l = c.m_flagsBuffer.data[t]; + const h = c.m_flagsBuffer.data[e]; + const u = c.m_flagsBuffer.data[i]; + if ((l | h | u) & Un.k_triadFlags && s.ShouldCreateTriad(t, e, i)) { + const s = a[t]; + const _ = a[e]; + const d = a[i]; + const p = St.SubVV(s, _, n); + const m = St.SubVV(_, d, r); + const f = St.SubVV(d, s, o); + const g = D * c.m_squaredDiameter; + if (St.DotVV(p, p) > g || St.DotVV(m, m) > g || St.DotVV(f, f) > g) return; + const y = c.m_groupBuffer[t]; + const b = c.m_groupBuffer[e]; + const S = c.m_groupBuffer[i]; + const A = c.m_triadBuffer.data[c.m_triadBuffer.Append()]; + A.indexA = t; + A.indexB = e; + A.indexC = i; + A.flags = l | h | u; + A.strength = tt(tt(y ? y.m_strength : 1, b ? b.m_strength : 1), S ? S.m_strength : 1); + const T = (s.x + _.x + d.x) / 3; + const v = (s.y + _.y + d.y) / 3; + A.pa.x = s.x - T; + A.pa.y = s.y - v; + A.pb.x = _.x - T; + A.pb.y = _.y - v; + A.pc.x = d.x - T; + A.pc.y = d.y - v; + A.ka = -St.DotVV(f, p); + A.kb = -St.DotVV(p, m); + A.kc = -St.DotVV(m, f); + A.s = St.CrossVV(s, _) + St.CrossVV(_, d) + St.CrossVV(d, s); + } + }; + l.GetNodes(u); + wn(this.m_triadBuffer.data, 0, this.m_triadBuffer.count, Un.CompareTriadIndices); + this.m_triadBuffer.Unique(Un.MatchTriadIndices); + } + } + UpdatePairsAndTriadsWithReactiveParticles() { + const e = new tr(this.m_flagsBuffer); + this.UpdatePairsAndTriads(0, this.m_count, e); + for (let e = 0; e < this.m_count; e++) this.m_flagsBuffer.data[e] &= ~t.b2ParticleFlag.b2_reactiveParticle; + this.m_allParticleFlags &= ~t.b2ParticleFlag.b2_reactiveParticle; + } + static ComparePairIndices(t, e) { + const i = t.indexA - e.indexA; + return 0 !== i ? i < 0 : t.indexB < e.indexB; + } + static MatchPairIndices(t, e) { + return t.indexA === e.indexA && t.indexB === e.indexB; + } + static CompareTriadIndices(t, e) { + const i = t.indexA - e.indexA; + if (0 !== i) return i < 0; + const s = t.indexB - e.indexB; + return 0 !== s ? s < 0 : t.indexC < e.indexC; + } + static MatchTriadIndices(t, e) { + return t.indexA === e.indexA && t.indexB === e.indexB && t.indexC === e.indexC; + } + static InitializeParticleLists(t, e) { + const i = t.GetBufferIndex(); + const s = t.GetParticleCount(); + for (let t = 0; t < s; t++) { + const s = e[t]; + s.list = s; + s.next = null; + s.count = 1; + s.index = t + i; + } + } + MergeParticleListsInContact(t, e) { + const i = t.GetBufferIndex(); + for (let s = 0; s < this.m_contactBuffer.count; s++) { + const n = this.m_contactBuffer.data[s]; + const r = n.indexA; + const o = n.indexB; + if (!t.ContainsParticle(r) || !t.ContainsParticle(o)) continue; + let a = e[r - i].list; + let l = e[o - i].list; + if (a !== l) { + if (a.count < l.count) { + const t = a; + a = l; + l = t; + } + Un.MergeParticleLists(a, l); + } + } + } + static MergeParticleLists(t, e) { + for (let i = e; ;) { + i.list = t; + const e = i.next; + if (!e) { + i.next = t.next; + break; + } + i = e; + } + t.next = e; + t.count += e.count; + e.count = 0; + } + static FindLongestParticleList(t, e) { + const i = t.GetParticleCount(); + let s = e[0]; + for (let t = 0; t < i; t++) { + const i = e[t]; + s.count < i.count && (s = i); + } + return s; + } + MergeZombieParticleListNodes(e, i, s) { + const n = e.GetParticleCount(); + for (let e = 0; e < n; e++) { + const n = i[e]; + n !== s && this.m_flagsBuffer.data[n.index] & t.b2ParticleFlag.b2_zombieParticle && Un.MergeParticleListAndNode(s, n); + } + } + static MergeParticleListAndNode(t, e) { + e.list = t; + e.next = t.next; + t.next = e; + t.count++; + e.count = 0; + } + CreateParticleGroupsFromParticleList(e, i, s) { + const n = e.GetParticleCount(); + const r = new yn; + r.groupFlags = e.GetGroupFlags(); + r.userData = e.GetUserData(); + for (let e = 0; e < n; e++) { + const n = i[e]; + if (!n.count || n === s) continue; + const o = this.CreateParticleGroup(r); + for (let e = n; e; e = e.next) { + const i = e.index; + const s = this.CloneParticle(i, o); + this.m_flagsBuffer.data[i] |= t.b2ParticleFlag.b2_zombieParticle; + e.index = s; + } + } + } + UpdatePairsAndTriadsWithParticleList(t, e) { + const i = t.GetBufferIndex(); + for (let s = 0; s < this.m_pairBuffer.count; s++) { + const n = this.m_pairBuffer.data[s]; + const r = n.indexA; + const o = n.indexB; + t.ContainsParticle(r) && (n.indexA = e[r - i].index); + t.ContainsParticle(o) && (n.indexB = e[o - i].index); + } + for (let s = 0; s < this.m_triadBuffer.count; s++) { + const n = this.m_triadBuffer.data[s]; + const r = n.indexA; + const o = n.indexB; + const a = n.indexC; + t.ContainsParticle(r) && (n.indexA = e[r - i].index); + t.ContainsParticle(o) && (n.indexB = e[o - i].index); + t.ContainsParticle(a) && (n.indexC = e[a - i].index); + } + } + ComputeDepth() { + const e = []; + let i = 0; + for (let s = 0; s < this.m_contactBuffer.count; s++) { + const n = this.m_contactBuffer.data[s]; + const r = n.indexA; + const o = n.indexB; + const a = this.m_groupBuffer[r]; + const l = this.m_groupBuffer[o]; + a && a === l && a.m_groupFlags & t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth && (e[i++] = n); + } + const n = []; + let r = 0; + for (let e = this.m_groupList; e; e = e.GetNext()) if (e.m_groupFlags & t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth) { + n[r++] = e; + this.SetGroupFlags(e, e.m_groupFlags & ~t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth); + for (let t = e.m_firstIndex; t < e.m_lastIndex; t++) this.m_accumulationBuffer[t] = 0; + } + for (let t = 0; t < i; t++) { + const i = e[t]; + const s = i.indexA; + const n = i.indexB; + const r = i.weight; + this.m_accumulationBuffer[s] += r; + this.m_accumulationBuffer[n] += r; + } + for (let t = 0; t < r; t++) { + const e = n[t]; + for (let t = e.m_firstIndex; t < e.m_lastIndex; t++) { + const e = this.m_accumulationBuffer[t]; + this.m_depthBuffer[t] = e < .8 ? 0 : s; + } + } + const o = at(this.m_count) >> 0; + for (let t = 0; t < o; t++) { + let t = !1; + for (let s = 0; s < i; s++) { + const i = e[s]; + const n = i.indexA; + const r = i.indexB; + const o = 1 - i.weight; + const a = this.m_depthBuffer[n]; + const l = this.m_depthBuffer[r]; + const h = l + o; + const c = a + o; + if (a > h) { + this.m_depthBuffer[n] = h; + t = !0; + } + if (l > c) { + this.m_depthBuffer[r] = c; + t = !0; + } + } + if (!t) break; + } + for (let t = 0; t < r; t++) { + const e = n[t]; + for (let t = e.m_firstIndex; t < e.m_lastIndex; t++) this.m_depthBuffer[t] < s ? this.m_depthBuffer[t] *= this.m_particleDiameter : this.m_depthBuffer[t] = 0; + } + } + GetInsideBoundsEnumerator(t) { + const e = Un.computeTag(this.m_inverseDiameter * t.lowerBound.x - 1, this.m_inverseDiameter * t.lowerBound.y - 1); + const i = Un.computeTag(this.m_inverseDiameter * t.upperBound.x + 1, this.m_inverseDiameter * t.upperBound.y + 1); + const s = 0; + const n = this.m_proxyBuffer.count; + const r = In(this.m_proxyBuffer.data, s, n, e, zn.CompareProxyTag); + const o = Mn(this.m_proxyBuffer.data, s, n, i, zn.CompareTagProxy); + return new Hn(this, e, i, r, o); + } + UpdateAllParticleFlags() { + this.m_allParticleFlags = 0; + for (let t = 0; t < this.m_count; t++) this.m_allParticleFlags |= this.m_flagsBuffer.data[t]; + this.m_needsUpdateAllParticleFlags = !1; + } + UpdateAllGroupFlags() { + this.m_allGroupFlags = 0; + for (let t = this.m_groupList; t; t = t.GetNext()) this.m_allGroupFlags |= t.m_groupFlags; + this.m_needsUpdateAllGroupFlags = !1; + } + AddContact(t, e, i) { + const s = this.m_flagsBuffer.data; + const n = this.m_positionBuffer.data; + const r = St.SubVV(n[e], n[t], Un.AddContact_s_d); + const o = St.DotVV(r, r); + if (0 < o && o < this.m_squaredDiameter) { + const i = ot(o); + const n = this.m_contactBuffer.data[this.m_contactBuffer.Append()]; + n.indexA = t; + n.indexB = e; + n.flags = s[t] | s[e]; + n.weight = 1 - o * i * this.m_inverseDiameter; + n.normal.x = i * r.x; + n.normal.y = i * r.y; + } + } + FindContacts_Reference(t) { + const e = 0; + const i = this.m_proxyBuffer.count; + this.m_contactBuffer.count = 0; + for (let t = e, s = e; t < i; t++) { + const e = Un.computeRelativeTag(this.m_proxyBuffer.data[t].tag, 1, 0); + for (let s = t + 1; s < i && !(e < this.m_proxyBuffer.data[s].tag); s++) this.AddContact(this.m_proxyBuffer.data[t].index, this.m_proxyBuffer.data[s].index, this.m_contactBuffer); + const n = Un.computeRelativeTag(this.m_proxyBuffer.data[t].tag, -1, 1); + for (;s < i && !(n <= this.m_proxyBuffer.data[s].tag); s++) ; + const r = Un.computeRelativeTag(this.m_proxyBuffer.data[t].tag, 1, 1); + for (let e = s; e < i && !(r < this.m_proxyBuffer.data[e].tag); e++) this.AddContact(this.m_proxyBuffer.data[t].index, this.m_proxyBuffer.data[e].index, this.m_contactBuffer); + } + } + FindContacts(t) { + this.FindContacts_Reference(t); + } + UpdateProxies_Reference(t) { + const e = this.m_positionBuffer.data; + const i = this.m_inverseDiameter; + for (let t = 0; t < this.m_proxyBuffer.count; ++t) { + const s = this.m_proxyBuffer.data[t]; + const n = e[s.index]; + s.tag = Un.computeTag(i * n.x, i * n.y); + } + } + UpdateProxies(t) { + this.UpdateProxies_Reference(t); + } + SortProxies(t) { + xn(this.m_proxyBuffer.data, 0, this.m_proxyBuffer.count, zn.CompareProxyProxy); + } + FilterContacts(e) { + const i = this.GetParticleContactFilter(); + if (null === i) return; + const s = this; + const n = e => 0 != (e.flags & t.b2ParticleFlag.b2_particleContactFilterParticle) && !i.ShouldCollideParticleParticle(s, e.indexA, e.indexB); + this.m_contactBuffer.RemoveIf(n); + } + NotifyContactListenerPreContact(t) { + if (null !== this.GetParticleContactListener()) { + t.Initialize(this.m_contactBuffer, this.m_flagsBuffer); + throw new Error; + } + } + NotifyContactListenerPostContact(t) { + const e = this.GetParticleContactListener(); + if (null !== e) { + for (let t = 0; t < this.m_contactBuffer.count; ++t) { + const i = this.m_contactBuffer.data[t]; + e.BeginContactParticleParticle(this, i); + } + throw new Error; + } + } + static b2ParticleContactIsZombie(e) { + return (e.flags & t.b2ParticleFlag.b2_zombieParticle) === t.b2ParticleFlag.b2_zombieParticle; + } + UpdateContacts(t) { + this.UpdateProxies(this.m_proxyBuffer); + this.SortProxies(this.m_proxyBuffer); + const e = new Kn; + this.NotifyContactListenerPreContact(e); + this.FindContacts(this.m_contactBuffer); + this.FilterContacts(this.m_contactBuffer); + this.NotifyContactListenerPostContact(e); + t && this.m_contactBuffer.RemoveIf(Un.b2ParticleContactIsZombie); + } + NotifyBodyContactListenerPreContact(t) { + if (null !== this.GetFixtureContactListener()) { + t.Initialize(this.m_bodyContactBuffer, this.m_flagsBuffer); + throw new Error; + } + } + NotifyBodyContactListenerPostContact(t) { + const e = this.GetFixtureContactListener(); + if (null !== e) { + for (let t = 0; t < this.m_bodyContactBuffer.count; t++) { + const i = this.m_bodyContactBuffer.data[t]; + e.BeginContactFixtureParticle(this, i); + } + throw new Error; + } + } + UpdateBodyContacts() { + const t = Un.UpdateBodyContacts_s_aabb; + const e = new Yn; + this.NotifyBodyContactListenerPreContact(e); + if (this.m_stuckThreshold > 0) { + const t = this.GetParticleCount(); + for (let e = 0; e < t; e++) { + this.m_bodyContactCountBuffer.data[e] = 0; + this.m_timestamp > this.m_lastBodyContactStepBuffer.data[e] + 1 && (this.m_consecutiveContactStepsBuffer.data[e] = 0); + } + } + this.m_bodyContactBuffer.SetCount(0); + this.m_stuckParticleBuffer.SetCount(0); + const i = t; + this.ComputeAABB(i); + null === this.UpdateBodyContacts_callback && (this.UpdateBodyContacts_callback = new er(this)); + const s = this.UpdateBodyContacts_callback; + s.m_contactFilter = this.GetFixtureContactFilter(); + this.m_world.QueryAABB(s, i); + this.m_def.strictContactCheck && this.RemoveSpuriousBodyContacts(); + this.NotifyBodyContactListenerPostContact(e); + } + Solve(e) { + const i = Un.Solve_s_subStep; + if (0 !== this.m_count) { + this.m_expirationTimeBuffer.data && this.SolveLifetimes(e); + this.m_allParticleFlags & t.b2ParticleFlag.b2_zombieParticle && this.SolveZombie(); + this.m_needsUpdateAllParticleFlags && this.UpdateAllParticleFlags(); + this.m_needsUpdateAllGroupFlags && this.UpdateAllGroupFlags(); + if (!this.m_paused) for (this.m_iterationIndex = 0; this.m_iterationIndex < e.particleIterations; this.m_iterationIndex++) { + ++this.m_timestamp; + const s = i.Copy(e); + s.dt /= e.particleIterations; + s.inv_dt *= e.particleIterations; + this.UpdateContacts(!1); + this.UpdateBodyContacts(); + this.ComputeWeight(); + this.m_allGroupFlags & t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth && this.ComputeDepth(); + this.m_allParticleFlags & t.b2ParticleFlag.b2_reactiveParticle && this.UpdatePairsAndTriadsWithReactiveParticles(); + this.m_hasForce && this.SolveForce(s); + this.m_allParticleFlags & t.b2ParticleFlag.b2_viscousParticle && this.SolveViscous(); + this.m_allParticleFlags & t.b2ParticleFlag.b2_repulsiveParticle && this.SolveRepulsive(s); + this.m_allParticleFlags & t.b2ParticleFlag.b2_powderParticle && this.SolvePowder(s); + this.m_allParticleFlags & t.b2ParticleFlag.b2_tensileParticle && this.SolveTensile(s); + this.m_allGroupFlags & t.b2ParticleGroupFlag.b2_solidParticleGroup && this.SolveSolid(s); + this.m_allParticleFlags & t.b2ParticleFlag.b2_colorMixingParticle && this.SolveColorMixing(); + this.SolveGravity(s); + this.m_allParticleFlags & t.b2ParticleFlag.b2_staticPressureParticle && this.SolveStaticPressure(s); + this.SolvePressure(s); + this.SolveDamping(s); + this.m_allParticleFlags & Un.k_extraDampingFlags && this.SolveExtraDamping(); + this.m_allParticleFlags & t.b2ParticleFlag.b2_elasticParticle && this.SolveElastic(s); + this.m_allParticleFlags & t.b2ParticleFlag.b2_springParticle && this.SolveSpring(s); + this.LimitVelocity(s); + this.m_allGroupFlags & t.b2ParticleGroupFlag.b2_rigidParticleGroup && this.SolveRigidDamping(); + this.m_allParticleFlags & t.b2ParticleFlag.b2_barrierParticle && this.SolveBarrier(s); + this.SolveCollision(s); + this.m_allGroupFlags & t.b2ParticleGroupFlag.b2_rigidParticleGroup && this.SolveRigid(s); + this.m_allParticleFlags & t.b2ParticleFlag.b2_wallParticle && this.SolveWall(); + for (let t = 0; t < this.m_count; t++) this.m_positionBuffer.data[t].SelfMulAdd(s.dt, this.m_velocityBuffer.data[t]); + } + } + } + SolveCollision(t) { + const e = Un.SolveCollision_s_aabb; + const i = this.m_positionBuffer.data; + const n = this.m_velocityBuffer.data; + const r = e; + r.lowerBound.x = +s; + r.lowerBound.y = +s; + r.upperBound.x = -s; + r.upperBound.y = -s; + for (let e = 0; e < this.m_count; e++) { + const s = n[e]; + const o = i[e]; + const a = o.x + t.dt * s.x; + const l = o.y + t.dt * s.y; + r.lowerBound.x = tt(r.lowerBound.x, tt(o.x, a)); + r.lowerBound.y = tt(r.lowerBound.y, tt(o.y, l)); + r.upperBound.x = et(r.upperBound.x, et(o.x, a)); + r.upperBound.y = et(r.upperBound.y, et(o.y, l)); + } + null === this.SolveCollision_callback && (this.SolveCollision_callback = new ir(this, t)); + const o = this.SolveCollision_callback; + o.m_step = t; + this.m_world.QueryAABB(o, r); + } + LimitVelocity(t) { + const e = this.m_velocityBuffer.data; + const i = this.GetCriticalVelocitySquared(t); + for (let t = 0; t < this.m_count; t++) { + const s = e[t]; + const n = St.DotVV(s, s); + n > i && s.SelfMul(at(i / n)); + } + } + SolveGravity(t) { + const e = Un.SolveGravity_s_gravity; + const i = this.m_velocityBuffer.data; + const s = St.MulSV(t.dt * this.m_def.gravityScale, this.m_world.GetGravity(), e); + for (let t = 0; t < this.m_count; t++) i[t].SelfAdd(s); + } + SolveBarrier(e) { + const i = Un.SolveBarrier_s_aabb; + const s = Un.SolveBarrier_s_va; + const n = Un.SolveBarrier_s_vb; + const r = Un.SolveBarrier_s_pba; + const o = Un.SolveBarrier_s_vba; + const a = Un.SolveBarrier_s_vc; + const l = Un.SolveBarrier_s_pca; + const h = Un.SolveBarrier_s_vca; + const c = Un.SolveBarrier_s_qba; + const u = Un.SolveBarrier_s_qca; + const _ = Un.SolveBarrier_s_dv; + const d = Un.SolveBarrier_s_f; + const p = this.m_positionBuffer.data; + const m = this.m_velocityBuffer.data; + for (let t = 0; t < this.m_count; t++) 0 != (this.m_flagsBuffer.data[t] & Un.k_barrierWallFlags) && m[t].SetZero(); + const f = O * e.dt; + const g = this.GetParticleMass(); + for (let y = 0; y < this.m_pairBuffer.count; y++) { + const b = this.m_pairBuffer.data[y]; + if (b.flags & t.b2ParticleFlag.b2_barrierParticle) { + const t = b.indexA; + const y = b.indexB; + const S = p[t]; + const A = p[y]; + const T = i; + St.MinV(S, A, T.lowerBound); + St.MaxV(S, A, T.upperBound); + const v = this.m_groupBuffer[t]; + const E = this.m_groupBuffer[y]; + const C = this.GetLinearVelocity(v, t, S, s); + const x = this.GetLinearVelocity(E, y, A, n); + const w = St.SubVV(A, S, r); + const R = St.SubVV(x, C, o); + const I = this.GetInsideBoundsEnumerator(T); + let M; + for (;(M = I.GetNext()) >= 0; ) { + const t = p[M]; + const i = this.m_groupBuffer[M]; + if (v !== i && E !== i) { + const s = this.GetLinearVelocity(i, M, t, a); + const n = St.SubVV(t, S, l); + const r = St.SubVV(s, C, h); + const o = St.CrossVV(R, r); + const p = St.CrossVV(w, r) - St.CrossVV(n, R); + const y = St.CrossVV(w, n); + let b, A; + const T = c, v = u; + if (0 === o) { + if (0 === p) continue; + A = -y / p; + if (!(A >= 0 && A < f)) continue; + St.AddVMulSV(w, A, R, T); + St.AddVMulSV(n, A, r, v); + b = St.DotVV(T, v) / St.DotVV(T, T); + if (!(b >= 0 && b <= 1)) continue; + } else { + const t = p * p - 4 * y * o; + if (t < 0) continue; + const e = at(t); + let i = (-p - e) / (2 * o); + let s = (-p + e) / (2 * o); + if (i > s) { + const t = i; + i = s; + s = t; + } + A = i; + St.AddVMulSV(w, A, R, T); + St.AddVMulSV(n, A, r, v); + b = St.DotVV(T, v) / St.DotVV(T, T); + if (!(A >= 0 && A < f && b >= 0 && b <= 1)) { + A = s; + if (!(A >= 0 && A < f)) continue; + St.AddVMulSV(w, A, R, T); + St.AddVMulSV(n, A, r, v); + b = St.DotVV(T, v) / St.DotVV(T, T); + if (!(b >= 0 && b <= 1)) continue; + } + } + const E = _; + E.x = C.x + b * R.x - s.x; + E.y = C.y + b * R.y - s.y; + const x = St.MulSV(g, E, d); + if (i && this.IsRigidGroup(i)) { + const e = i.GetMass(); + const s = i.GetInertia(); + e > 0 && i.m_linearVelocity.SelfMulAdd(1 / e, x); + s > 0 && (i.m_angularVelocity += St.CrossVV(St.SubVV(t, i.GetCenter(), St.s_t0), x) / s); + } else m[M].SelfAdd(E); + this.ParticleApplyForce(M, x.SelfMul(-e.inv_dt)); + } + } + } + } + } + SolveStaticPressure(e) { + this.m_staticPressureBuffer = this.RequestBuffer(this.m_staticPressureBuffer); + const i = this.GetCriticalPressure(e); + const s = this.m_def.staticPressureStrength * i; + const n = I * i; + const r = this.m_def.staticPressureRelaxation; + for (let e = 0; e < this.m_def.staticPressureIterations; e++) { + for (let t = 0; t < this.m_count; t++) this.m_accumulationBuffer[t] = 0; + for (let e = 0; e < this.m_contactBuffer.count; e++) { + const i = this.m_contactBuffer.data[e]; + if (i.flags & t.b2ParticleFlag.b2_staticPressureParticle) { + const t = i.indexA; + const e = i.indexB; + const s = i.weight; + this.m_accumulationBuffer[t] += s * this.m_staticPressureBuffer[e]; + this.m_accumulationBuffer[e] += s * this.m_staticPressureBuffer[t]; + } + } + for (let e = 0; e < this.m_count; e++) { + const i = this.m_weightBuffer[e]; + if (this.m_flagsBuffer.data[e] & t.b2ParticleFlag.b2_staticPressureParticle) { + const t = (this.m_accumulationBuffer[e] + s * (i - R)) / (i + r); + this.m_staticPressureBuffer[e] = it(t, 0, n); + } else this.m_staticPressureBuffer[e] = 0; + } + } + } + ComputeWeight() { + for (let t = 0; t < this.m_count; t++) this.m_weightBuffer[t] = 0; + for (let t = 0; t < this.m_bodyContactBuffer.count; t++) { + const e = this.m_bodyContactBuffer.data[t]; + const i = e.index; + const s = e.weight; + this.m_weightBuffer[i] += s; + } + for (let t = 0; t < this.m_contactBuffer.count; t++) { + const e = this.m_contactBuffer.data[t]; + const i = e.indexA; + const s = e.indexB; + const n = e.weight; + this.m_weightBuffer[i] += n; + this.m_weightBuffer[s] += n; + } + } + SolvePressure(e) { + const i = Un.SolvePressure_s_f; + const s = this.m_positionBuffer.data; + const n = this.m_velocityBuffer.data; + const r = this.GetCriticalPressure(e); + const o = this.m_def.pressureStrength * r; + const a = I * r; + for (let t = 0; t < this.m_count; t++) { + const e = o * et(0, this.m_weightBuffer[t] - R); + this.m_accumulationBuffer[t] = tt(e, a); + } + if (this.m_allParticleFlags & Un.k_noPressureFlags) for (let t = 0; t < this.m_count; t++) this.m_flagsBuffer.data[t] & Un.k_noPressureFlags && (this.m_accumulationBuffer[t] = 0); + if (this.m_allParticleFlags & t.b2ParticleFlag.b2_staticPressureParticle) for (let e = 0; e < this.m_count; e++) this.m_flagsBuffer.data[e] & t.b2ParticleFlag.b2_staticPressureParticle && (this.m_accumulationBuffer[e] += this.m_staticPressureBuffer[e]); + const l = e.dt / (this.m_def.density * this.m_particleDiameter); + const h = this.GetParticleInvMass(); + for (let t = 0; t < this.m_bodyContactBuffer.count; t++) { + const e = this.m_bodyContactBuffer.data[t]; + const r = e.index; + const a = e.body; + const c = e.weight; + const u = e.mass; + const _ = e.normal; + const d = s[r]; + const p = this.m_accumulationBuffer[r] + o * c; + const m = St.MulSV(l * c * u * p, _, i); + n[r].SelfMulSub(h, m); + a.ApplyLinearImpulse(m, d, !0); + } + for (let t = 0; t < this.m_contactBuffer.count; t++) { + const e = this.m_contactBuffer.data[t]; + const s = e.indexA; + const r = e.indexB; + const o = e.weight; + const a = e.normal; + const h = this.m_accumulationBuffer[s] + this.m_accumulationBuffer[r]; + const c = St.MulSV(l * o * h, a, i); + n[s].SelfSub(c); + n[r].SelfAdd(c); + } + } + SolveDamping(t) { + const e = Un.SolveDamping_s_v; + const i = Un.SolveDamping_s_f; + const s = this.m_positionBuffer.data; + const n = this.m_velocityBuffer.data; + const r = this.m_def.dampingStrength; + const o = 1 / this.GetCriticalVelocity(t); + const a = this.GetParticleInvMass(); + for (let t = 0; t < this.m_bodyContactBuffer.count; t++) { + const l = this.m_bodyContactBuffer.data[t]; + const h = l.index; + const c = l.body; + const u = l.weight; + const _ = l.mass; + const d = l.normal; + const p = s[h]; + const m = St.SubVV(c.GetLinearVelocityFromWorldPoint(p, St.s_t0), n[h], e); + const f = St.DotVV(m, d); + if (f < 0) { + const t = et(r * u, tt(-o * f, .5)); + const e = St.MulSV(t * _ * f, d, i); + n[h].SelfMulAdd(a, e); + c.ApplyLinearImpulse(e.SelfNeg(), p, !0); + } + } + for (let t = 0; t < this.m_contactBuffer.count; t++) { + const s = this.m_contactBuffer.data[t]; + const a = s.indexA; + const l = s.indexB; + const h = s.weight; + const c = s.normal; + const u = St.SubVV(n[l], n[a], e); + const _ = St.DotVV(u, c); + if (_ < 0) { + const t = et(r * h, tt(-o * _, .5)); + const e = St.MulSV(t * _, c, i); + n[a].SelfAdd(e); + n[l].SelfSub(e); + } + } + } + SolveRigidDamping() { + const t = Un.SolveRigidDamping_s_t0; + const e = Un.SolveRigidDamping_s_t1; + const i = Un.SolveRigidDamping_s_p; + const s = Un.SolveRigidDamping_s_v; + const n = [ 0 ], r = [ 0 ], o = [ 0 ]; + const a = [ 0 ], l = [ 0 ], h = [ 0 ]; + const c = this.m_positionBuffer.data; + const u = this.m_def.dampingStrength; + for (let i = 0; i < this.m_bodyContactBuffer.count; i++) { + const _ = this.m_bodyContactBuffer.data[i]; + const d = _.index; + const p = this.m_groupBuffer[d]; + if (p && this.IsRigidGroup(p)) { + const i = _.body; + const m = _.normal; + const f = _.weight; + const g = c[d]; + const y = St.SubVV(i.GetLinearVelocityFromWorldPoint(g, t), p.GetLinearVelocityFromWorldPoint(g, e), s); + const b = St.DotVV(y, m); + if (b < 0) { + this.InitDampingParameterWithRigidGroupOrParticle(n, r, o, !0, p, d, g, m); + this.InitDampingParameter(a, l, h, i.GetMass(), i.GetInertia() - i.GetMass() * i.GetLocalCenter().LengthSquared(), i.GetWorldCenter(), g, m); + const t = u * tt(f, 1) * this.ComputeDampingImpulse(n[0], r[0], o[0], a[0], l[0], h[0], b); + this.ApplyDamping(n[0], r[0], o[0], !0, p, d, t, m); + i.ApplyLinearImpulse(St.MulSV(-t, m, St.s_t0), g, !0); + } + } + } + for (let _ = 0; _ < this.m_contactBuffer.count; _++) { + const d = this.m_contactBuffer.data[_]; + const p = d.indexA; + const m = d.indexB; + const f = d.normal; + const g = d.weight; + const y = this.m_groupBuffer[p]; + const b = this.m_groupBuffer[m]; + const S = this.IsRigidGroup(y); + const A = this.IsRigidGroup(b); + if (y !== b && (S || A)) { + const _ = St.MidVV(c[p], c[m], i); + const d = St.SubVV(this.GetLinearVelocity(b, m, _, t), this.GetLinearVelocity(y, p, _, e), s); + const T = St.DotVV(d, f); + if (T < 0) { + this.InitDampingParameterWithRigidGroupOrParticle(n, r, o, S, y, p, _, f); + this.InitDampingParameterWithRigidGroupOrParticle(a, l, h, A, b, m, _, f); + const t = u * g * this.ComputeDampingImpulse(n[0], r[0], o[0], a[0], l[0], h[0], T); + this.ApplyDamping(n[0], r[0], o[0], S, y, p, t, f); + this.ApplyDamping(a[0], l[0], h[0], A, b, m, -t, f); + } + } + } + } + SolveExtraDamping() { + const t = Un.SolveExtraDamping_s_v; + const e = Un.SolveExtraDamping_s_f; + const i = this.m_velocityBuffer.data; + const s = this.m_positionBuffer.data; + const n = this.GetParticleInvMass(); + for (let r = 0; r < this.m_bodyContactBuffer.count; r++) { + const o = this.m_bodyContactBuffer.data[r]; + const a = o.index; + if (this.m_flagsBuffer.data[a] & Un.k_extraDampingFlags) { + const r = o.body; + const l = o.mass; + const h = o.normal; + const c = s[a]; + const u = St.SubVV(r.GetLinearVelocityFromWorldPoint(c, St.s_t0), i[a], t); + const _ = St.DotVV(u, h); + if (_ < 0) { + const t = St.MulSV(.5 * l * _, h, e); + i[a].SelfMulAdd(n, t); + r.ApplyLinearImpulse(t.SelfNeg(), c, !0); + } + } + } + } + SolveWall() { + const e = this.m_velocityBuffer.data; + for (let i = 0; i < this.m_count; i++) this.m_flagsBuffer.data[i] & t.b2ParticleFlag.b2_wallParticle && e[i].SetZero(); + } + SolveRigid(e) { + const i = Un.SolveRigid_s_position; + const s = Un.SolveRigid_s_rotation; + const n = Un.SolveRigid_s_transform; + const r = Un.SolveRigid_s_velocityTransform; + const o = this.m_positionBuffer.data; + const a = this.m_velocityBuffer.data; + for (let l = this.m_groupList; l; l = l.GetNext()) if (l.m_groupFlags & t.b2ParticleGroupFlag.b2_rigidParticleGroup) { + l.UpdateStatistics(); + const t = s; + t.SetAngle(e.dt * l.m_angularVelocity); + const h = St.AddVV(l.m_center, St.SubVV(St.MulSV(e.dt, l.m_linearVelocity, St.s_t0), Ct.MulRV(t, l.m_center, St.s_t1), St.s_t0), i); + const c = n; + c.SetPositionRotation(h, t); + xt.MulXX(c, l.m_transform, l.m_transform); + const u = r; + u.p.x = e.inv_dt * c.p.x; + u.p.y = e.inv_dt * c.p.y; + u.q.s = e.inv_dt * c.q.s; + u.q.c = e.inv_dt * (c.q.c - 1); + for (let t = l.m_firstIndex; t < l.m_lastIndex; t++) xt.MulXV(u, o[t], a[t]); + } + } + SolveElastic(e) { + const i = Un.SolveElastic_s_pa; + const s = Un.SolveElastic_s_pb; + const n = Un.SolveElastic_s_pc; + const r = Un.SolveElastic_s_r; + const o = Un.SolveElastic_s_t0; + const a = this.m_positionBuffer.data; + const l = this.m_velocityBuffer.data; + const h = e.inv_dt * this.m_def.elasticStrength; + for (let c = 0; c < this.m_triadBuffer.count; c++) { + const u = this.m_triadBuffer.data[c]; + if (u.flags & t.b2ParticleFlag.b2_elasticParticle) { + const t = u.indexA; + const c = u.indexB; + const _ = u.indexC; + const d = u.pa; + const p = u.pb; + const m = u.pc; + const f = i.Copy(a[t]); + const g = s.Copy(a[c]); + const y = n.Copy(a[_]); + const b = l[t]; + const S = l[c]; + const A = l[_]; + f.SelfMulAdd(e.dt, b); + g.SelfMulAdd(e.dt, S); + y.SelfMulAdd(e.dt, A); + const T = (f.x + g.x + y.x) / 3; + const v = (f.y + g.y + y.y) / 3; + f.x -= T; + f.y -= v; + g.x -= T; + g.y -= v; + y.x -= T; + y.y -= v; + const E = r; + E.s = St.CrossVV(d, f) + St.CrossVV(p, g) + St.CrossVV(m, y); + E.c = St.DotVV(d, f) + St.DotVV(p, g) + St.DotVV(m, y); + let C = ot(E.s * E.s + E.c * E.c); + isFinite(C) || (C = 198177537e11); + E.s *= C; + E.c *= C; + const x = h * u.strength; + Ct.MulRV(E, d, o); + St.SubVV(o, f, o); + St.MulSV(x, o, o); + b.SelfAdd(o); + Ct.MulRV(E, p, o); + St.SubVV(o, g, o); + St.MulSV(x, o, o); + S.SelfAdd(o); + Ct.MulRV(E, m, o); + St.SubVV(o, y, o); + St.MulSV(x, o, o); + A.SelfAdd(o); + } + } + } + SolveSpring(e) { + const i = Un.SolveSpring_s_pa; + const s = Un.SolveSpring_s_pb; + const n = Un.SolveSpring_s_d; + const r = Un.SolveSpring_s_f; + const o = this.m_positionBuffer.data; + const a = this.m_velocityBuffer.data; + const l = e.inv_dt * this.m_def.springStrength; + for (let h = 0; h < this.m_pairBuffer.count; h++) { + const c = this.m_pairBuffer.data[h]; + if (c.flags & t.b2ParticleFlag.b2_springParticle) { + const t = c.indexA; + const h = c.indexB; + const u = i.Copy(o[t]); + const _ = s.Copy(o[h]); + const d = a[t]; + const p = a[h]; + u.SelfMulAdd(e.dt, d); + _.SelfMulAdd(e.dt, p); + const m = St.SubVV(_, u, n); + const f = c.distance; + const g = m.Length(); + const y = l * c.strength; + const b = St.MulSV(y * (f - g) / g, m, r); + d.SelfSub(b); + p.SelfAdd(b); + } + } + } + SolveTensile(e) { + const i = Un.SolveTensile_s_weightedNormal; + const s = Un.SolveTensile_s_s; + const n = Un.SolveTensile_s_f; + const r = this.m_velocityBuffer.data; + for (let t = 0; t < this.m_count; t++) { + this.m_accumulation2Buffer[t] = new St; + this.m_accumulation2Buffer[t].SetZero(); + } + for (let e = 0; e < this.m_contactBuffer.count; e++) { + const s = this.m_contactBuffer.data[e]; + if (s.flags & t.b2ParticleFlag.b2_tensileParticle) { + const t = s.indexA; + const e = s.indexB; + const n = s.weight; + const r = s.normal; + const o = St.MulSV((1 - n) * n, r, i); + this.m_accumulation2Buffer[t].SelfSub(o); + this.m_accumulation2Buffer[e].SelfAdd(o); + } + } + const o = this.GetCriticalVelocity(e); + const a = this.m_def.surfaceTensionPressureStrength * o; + const l = this.m_def.surfaceTensionNormalStrength * o; + const h = M * o; + for (let e = 0; e < this.m_contactBuffer.count; e++) { + const i = this.m_contactBuffer.data[e]; + if (i.flags & t.b2ParticleFlag.b2_tensileParticle) { + const t = i.indexA; + const e = i.indexB; + const o = i.weight; + const c = i.normal; + const u = this.m_weightBuffer[t] + this.m_weightBuffer[e]; + const _ = St.SubVV(this.m_accumulation2Buffer[e], this.m_accumulation2Buffer[t], s); + const d = tt(a * (u - 2) + l * St.DotVV(_, c), h) * o; + const p = St.MulSV(d, c, n); + r[t].SelfSub(p); + r[e].SelfAdd(p); + } + } + } + SolveViscous() { + const e = Un.SolveViscous_s_v; + const i = Un.SolveViscous_s_f; + const s = this.m_positionBuffer.data; + const n = this.m_velocityBuffer.data; + const r = this.m_def.viscousStrength; + const o = this.GetParticleInvMass(); + for (let a = 0; a < this.m_bodyContactBuffer.count; a++) { + const l = this.m_bodyContactBuffer.data[a]; + const h = l.index; + if (this.m_flagsBuffer.data[h] & t.b2ParticleFlag.b2_viscousParticle) { + const t = l.body; + const a = l.weight; + const c = l.mass; + const u = s[h]; + const _ = St.SubVV(t.GetLinearVelocityFromWorldPoint(u, St.s_t0), n[h], e); + const d = St.MulSV(r * c * a, _, i); + n[h].SelfMulAdd(o, d); + t.ApplyLinearImpulse(d.SelfNeg(), u, !0); + } + } + for (let s = 0; s < this.m_contactBuffer.count; s++) { + const o = this.m_contactBuffer.data[s]; + if (o.flags & t.b2ParticleFlag.b2_viscousParticle) { + const t = o.indexA; + const s = o.indexB; + const a = o.weight; + const l = St.SubVV(n[s], n[t], e); + const h = St.MulSV(r * a, l, i); + n[t].SelfAdd(h); + n[s].SelfSub(h); + } + } + } + SolveRepulsive(e) { + const i = Un.SolveRepulsive_s_f; + const s = this.m_velocityBuffer.data; + const n = this.m_def.repulsiveStrength * this.GetCriticalVelocity(e); + for (let e = 0; e < this.m_contactBuffer.count; e++) { + const r = this.m_contactBuffer.data[e]; + if (r.flags & t.b2ParticleFlag.b2_repulsiveParticle) { + const t = r.indexA; + const e = r.indexB; + if (this.m_groupBuffer[t] !== this.m_groupBuffer[e]) { + const o = r.weight; + const a = r.normal; + const l = St.MulSV(n * o, a, i); + s[t].SelfSub(l); + s[e].SelfAdd(l); + } + } + } + } + SolvePowder(e) { + const i = Un.SolvePowder_s_f; + const s = this.m_positionBuffer.data; + const n = this.m_velocityBuffer.data; + const r = this.m_def.powderStrength * this.GetCriticalVelocity(e); + const o = 1 - w; + const a = this.GetParticleInvMass(); + for (let e = 0; e < this.m_bodyContactBuffer.count; e++) { + const l = this.m_bodyContactBuffer.data[e]; + const h = l.index; + if (this.m_flagsBuffer.data[h] & t.b2ParticleFlag.b2_powderParticle) { + const t = l.weight; + if (t > o) { + const e = l.body; + const c = l.mass; + const u = s[h]; + const _ = l.normal; + const d = St.MulSV(r * c * (t - o), _, i); + n[h].SelfMulSub(a, d); + e.ApplyLinearImpulse(d, u, !0); + } + } + } + for (let e = 0; e < this.m_contactBuffer.count; e++) { + const s = this.m_contactBuffer.data[e]; + if (s.flags & t.b2ParticleFlag.b2_powderParticle) { + const t = s.weight; + if (t > o) { + const e = s.indexA; + const a = s.indexB; + const l = s.normal; + const h = St.MulSV(r * (t - o), l, i); + n[e].SelfSub(h); + n[a].SelfAdd(h); + } + } + } + } + SolveSolid(t) { + const e = Un.SolveSolid_s_f; + const i = this.m_velocityBuffer.data; + this.m_depthBuffer = this.RequestBuffer(this.m_depthBuffer); + const s = t.inv_dt * this.m_def.ejectionStrength; + for (let t = 0; t < this.m_contactBuffer.count; t++) { + const n = this.m_contactBuffer.data[t]; + const r = n.indexA; + const o = n.indexB; + if (this.m_groupBuffer[r] !== this.m_groupBuffer[o]) { + const t = n.weight; + const a = n.normal; + const l = this.m_depthBuffer[r] + this.m_depthBuffer[o]; + const h = St.MulSV(s * l * t, a, e); + i[r].SelfSub(h); + i[o].SelfAdd(h); + } + } + } + SolveForce(t) { + const e = this.m_velocityBuffer.data; + const i = t.dt * this.GetParticleInvMass(); + for (let t = 0; t < this.m_count; t++) e[t].SelfMulAdd(i, this.m_forceBuffer[t]); + this.m_hasForce = !1; + } + SolveColorMixing() { + const e = .5 * this.m_def.colorMixingStrength; + if (e) for (let i = 0; i < this.m_contactBuffer.count; i++) { + const s = this.m_contactBuffer.data[i]; + const n = s.indexA; + const r = s.indexB; + if (this.m_flagsBuffer.data[n] & this.m_flagsBuffer.data[r] & t.b2ParticleFlag.b2_colorMixingParticle) { + const t = this.m_colorBuffer.data[n]; + const i = this.m_colorBuffer.data[r]; + Rt.MixColors(t, i, e); + } + } + } + SolveZombie() { + let e = 0; + const i = []; + for (let t = 0; t < this.m_count; t++) i[t] = C; + let s = 0; + for (let n = 0; n < this.m_count; n++) { + const r = this.m_flagsBuffer.data[n]; + if (r & t.b2ParticleFlag.b2_zombieParticle) { + const e = this.m_world.m_destructionListener; + r & t.b2ParticleFlag.b2_destructionListenerParticle && e && e.SayGoodbyeParticle(this, n); + if (this.m_handleIndexBuffer.data) { + const t = this.m_handleIndexBuffer.data[n]; + if (t) { + t.SetIndex(C); + this.m_handleIndexBuffer.data[n] = null; + } + } + i[n] = C; + } else { + i[n] = e; + if (n !== e) { + if (this.m_handleIndexBuffer.data) { + const t = this.m_handleIndexBuffer.data[n]; + t && t.SetIndex(e); + this.m_handleIndexBuffer.data[e] = t; + } + this.m_flagsBuffer.data[e] = this.m_flagsBuffer.data[n]; + this.m_lastBodyContactStepBuffer.data && (this.m_lastBodyContactStepBuffer.data[e] = this.m_lastBodyContactStepBuffer.data[n]); + this.m_bodyContactCountBuffer.data && (this.m_bodyContactCountBuffer.data[e] = this.m_bodyContactCountBuffer.data[n]); + this.m_consecutiveContactStepsBuffer.data && (this.m_consecutiveContactStepsBuffer.data[e] = this.m_consecutiveContactStepsBuffer.data[n]); + this.m_positionBuffer.data[e].Copy(this.m_positionBuffer.data[n]); + this.m_velocityBuffer.data[e].Copy(this.m_velocityBuffer.data[n]); + this.m_groupBuffer[e] = this.m_groupBuffer[n]; + this.m_hasForce && this.m_forceBuffer[e].Copy(this.m_forceBuffer[n]); + this.m_staticPressureBuffer && (this.m_staticPressureBuffer[e] = this.m_staticPressureBuffer[n]); + this.m_depthBuffer && (this.m_depthBuffer[e] = this.m_depthBuffer[n]); + this.m_colorBuffer.data && this.m_colorBuffer.data[e].Copy(this.m_colorBuffer.data[n]); + this.m_userDataBuffer.data && (this.m_userDataBuffer.data[e] = this.m_userDataBuffer.data[n]); + this.m_expirationTimeBuffer.data && (this.m_expirationTimeBuffer.data[e] = this.m_expirationTimeBuffer.data[n]); + } + e++; + s |= r; + } + } + const n = { + IsProxyInvalid: t => t.index < 0, + IsContactInvalid: t => t.indexA < 0 || t.indexB < 0, + IsBodyContactInvalid: t => t.index < 0, + IsPairInvalid: t => t.indexA < 0 || t.indexB < 0, + IsTriadInvalid: t => t.indexA < 0 || t.indexB < 0 || t.indexC < 0 + }; + for (let t = 0; t < this.m_proxyBuffer.count; t++) { + const e = this.m_proxyBuffer.data[t]; + e.index = i[e.index]; + } + this.m_proxyBuffer.RemoveIf(n.IsProxyInvalid); + for (let t = 0; t < this.m_contactBuffer.count; t++) { + const e = this.m_contactBuffer.data[t]; + e.indexA = i[e.indexA]; + e.indexB = i[e.indexB]; + } + this.m_contactBuffer.RemoveIf(n.IsContactInvalid); + for (let t = 0; t < this.m_bodyContactBuffer.count; t++) { + const e = this.m_bodyContactBuffer.data[t]; + e.index = i[e.index]; + } + this.m_bodyContactBuffer.RemoveIf(n.IsBodyContactInvalid); + for (let t = 0; t < this.m_pairBuffer.count; t++) { + const e = this.m_pairBuffer.data[t]; + e.indexA = i[e.indexA]; + e.indexB = i[e.indexB]; + } + this.m_pairBuffer.RemoveIf(n.IsPairInvalid); + for (let t = 0; t < this.m_triadBuffer.count; t++) { + const e = this.m_triadBuffer.data[t]; + e.indexA = i[e.indexA]; + e.indexB = i[e.indexB]; + e.indexC = i[e.indexC]; + } + this.m_triadBuffer.RemoveIf(n.IsTriadInvalid); + if (this.m_indexByExpirationTimeBuffer.data) { + let t = 0; + for (let e = 0; e < this.m_count; e++) { + const s = i[this.m_indexByExpirationTimeBuffer.data[e]]; + s !== C && (this.m_indexByExpirationTimeBuffer.data[t++] = s); + } + } + for (let s = this.m_groupList; s; s = s.GetNext()) { + let n = e; + let r = 0; + let o = !1; + for (let t = s.m_firstIndex; t < s.m_lastIndex; t++) { + const e = i[t]; + if (e >= 0) { + n = tt(n, e); + r = et(r, e + 1); + } else o = !0; + } + if (n < r) { + s.m_firstIndex = n; + s.m_lastIndex = r; + o && s.m_groupFlags & t.b2ParticleGroupFlag.b2_solidParticleGroup && this.SetGroupFlags(s, s.m_groupFlags | t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth); + } else { + s.m_firstIndex = 0; + s.m_lastIndex = 0; + s.m_groupFlags & t.b2ParticleGroupFlag.b2_particleGroupCanBeEmpty || this.SetGroupFlags(s, s.m_groupFlags | t.b2ParticleGroupFlag.b2_particleGroupWillBeDestroyed); + } + } + this.m_count = e; + this.m_allParticleFlags = s; + this.m_needsUpdateAllParticleFlags = !1; + for (let e = this.m_groupList; e; ) { + const i = e.GetNext(); + e.m_groupFlags & t.b2ParticleGroupFlag.b2_particleGroupWillBeDestroyed && this.DestroyParticleGroup(e); + e = i; + } + } + SolveLifetimes(t) { + this.m_timeElapsed = this.LifetimeToExpirationTime(t.dt); + const e = this.GetQuantizedTimeElapsed(); + const i = this.m_expirationTimeBuffer.data; + const s = this.m_indexByExpirationTimeBuffer.data; + const n = this.GetParticleCount(); + if (this.m_expirationTimeBufferRequiresSorting) { + xn(s, 0, n, ((t, e) => { + const s = i[t]; + const n = i[e]; + const r = s <= 0; + return r === n <= 0 ? s > n : r; + })); + this.m_expirationTimeBufferRequiresSorting = !1; + } + for (let t = n - 1; t >= 0; --t) { + const n = s[t]; + const r = i[n]; + if (e < r || r <= 0) break; + this.DestroyParticle(n); + } + } + RotateBuffer(t, e, i) { + if (t !== e && e !== i) { + Bn(this.m_flagsBuffer.data, t, e, i); + this.m_lastBodyContactStepBuffer.data && Bn(this.m_lastBodyContactStepBuffer.data, t, e, i); + this.m_bodyContactCountBuffer.data && Bn(this.m_bodyContactCountBuffer.data, t, e, i); + this.m_consecutiveContactStepsBuffer.data && Bn(this.m_consecutiveContactStepsBuffer.data, t, e, i); + Bn(this.m_positionBuffer.data, t, e, i); + Bn(this.m_velocityBuffer.data, t, e, i); + Bn(this.m_groupBuffer, t, e, i); + this.m_hasForce && Bn(this.m_forceBuffer, t, e, i); + this.m_staticPressureBuffer && Bn(this.m_staticPressureBuffer, t, e, i); + this.m_depthBuffer && Bn(this.m_depthBuffer, t, e, i); + this.m_colorBuffer.data && Bn(this.m_colorBuffer.data, t, e, i); + this.m_userDataBuffer.data && Bn(this.m_userDataBuffer.data, t, e, i); + if (this.m_handleIndexBuffer.data) { + Bn(this.m_handleIndexBuffer.data, t, e, i); + for (let e = t; e < i; ++e) { + const t = this.m_handleIndexBuffer.data[e]; + t && t.SetIndex(s(t.GetIndex())); + } + } + if (this.m_expirationTimeBuffer.data) { + Bn(this.m_expirationTimeBuffer.data, t, e, i); + const n = this.GetParticleCount(); + const r = this.m_indexByExpirationTimeBuffer.data; + for (let t = 0; t < n; ++t) r[t] = s(r[t]); + } + for (let t = 0; t < this.m_proxyBuffer.count; t++) { + const e = this.m_proxyBuffer.data[t]; + e.index = s(e.index); + } + for (let t = 0; t < this.m_contactBuffer.count; t++) { + const e = this.m_contactBuffer.data[t]; + e.indexA = s(e.indexA); + e.indexB = s(e.indexB); + } + for (let t = 0; t < this.m_bodyContactBuffer.count; t++) { + const e = this.m_bodyContactBuffer.data[t]; + e.index = s(e.index); + } + for (let t = 0; t < this.m_pairBuffer.count; t++) { + const e = this.m_pairBuffer.data[t]; + e.indexA = s(e.indexA); + e.indexB = s(e.indexB); + } + for (let t = 0; t < this.m_triadBuffer.count; t++) { + const e = this.m_triadBuffer.data[t]; + e.indexA = s(e.indexA); + e.indexB = s(e.indexB); + e.indexC = s(e.indexC); + } + for (let t = this.m_groupList; t; t = t.GetNext()) { + t.m_firstIndex = s(t.m_firstIndex); + t.m_lastIndex = s(t.m_lastIndex - 1) + 1; + } + } + function s(s) { + return s < t ? s : s < e ? s + i - e : s < i ? s + t - e : s; + } + } + GetCriticalVelocity(t) { + return this.m_particleDiameter * t.inv_dt; + } + GetCriticalVelocitySquared(t) { + const e = this.GetCriticalVelocity(t); + return e * e; + } + GetCriticalPressure(t) { + return this.m_def.density * this.GetCriticalVelocitySquared(t); + } + GetParticleStride() { + return w * this.m_particleDiameter; + } + GetParticleMass() { + const t = this.GetParticleStride(); + return this.m_def.density * t * t; + } + GetParticleInvMass() { + const t = this.m_inverseDiameter * (1 / w); + return this.m_inverseDensity * t * t; + } + GetFixtureContactFilter() { + return this.m_allParticleFlags & t.b2ParticleFlag.b2_fixtureContactFilterParticle ? this.m_world.m_contactManager.m_contactFilter : null; + } + GetParticleContactFilter() { + return this.m_allParticleFlags & t.b2ParticleFlag.b2_particleContactFilterParticle ? this.m_world.m_contactManager.m_contactFilter : null; + } + GetFixtureContactListener() { + return this.m_allParticleFlags & t.b2ParticleFlag.b2_fixtureContactListenerParticle ? this.m_world.m_contactManager.m_contactListener : null; + } + GetParticleContactListener() { + return this.m_allParticleFlags & t.b2ParticleFlag.b2_particleContactListenerParticle ? this.m_world.m_contactManager.m_contactListener : null; + } + SetUserOverridableBuffer(t, e) { + t.data = e; + t.userSuppliedCapacity = e.length; + } + SetGroupFlags(e, i) { + const s = e.m_groupFlags; + (s ^ i) & t.b2ParticleGroupFlag.b2_solidParticleGroup && (i |= t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth); + s & ~i && (this.m_needsUpdateAllGroupFlags = !0); + if (~this.m_allGroupFlags & i) { + i & t.b2ParticleGroupFlag.b2_solidParticleGroup && (this.m_depthBuffer = this.RequestBuffer(this.m_depthBuffer)); + this.m_allGroupFlags |= i; + } + e.m_groupFlags = i; + } + static BodyContactCompare(t, e) { + return t.index === e.index ? t.weight > e.weight : t.index < e.index; + } + RemoveSpuriousBodyContacts() { + xn(this.m_bodyContactBuffer.data, 0, this.m_bodyContactBuffer.count, Un.BodyContactCompare); + const t = Un.RemoveSpuriousBodyContacts_s_n; + const e = Un.RemoveSpuriousBodyContacts_s_pos; + const i = Un.RemoveSpuriousBodyContacts_s_normal; + const s = 3; + const n = this; + let r = -1; + let o = 0; + const a = a => { + if (a.index !== r) { + o = 0; + r = a.index; + } + if (o++ > s) return !0; + const l = t.Copy(a.normal); + l.SelfMul(n.m_particleDiameter * (1 - a.weight)); + const h = St.AddVV(n.m_positionBuffer.data[a.index], l, e); + if (!a.fixture.TestPoint(h)) { + const t = a.fixture.GetShape().GetChildCount(); + for (let e = 0; e < t; e++) { + const t = i; + if (a.fixture.ComputeDistance(h, t, e) < u) return !1; + } + return !0; + } + return !1; + }; + this.m_bodyContactBuffer.count = Rn(this.m_bodyContactBuffer.data, a, this.m_bodyContactBuffer.count); + } + DetectStuckParticle(t) { + if (!(this.m_stuckThreshold <= 0)) { + ++this.m_bodyContactCountBuffer.data[t]; + if (2 === this.m_bodyContactCountBuffer.data[t]) { + ++this.m_consecutiveContactStepsBuffer.data[t]; + this.m_consecutiveContactStepsBuffer.data[t] > this.m_stuckThreshold && (this.m_stuckParticleBuffer.data[this.m_stuckParticleBuffer.Append()] = t); + } + this.m_lastBodyContactStepBuffer.data[t] = this.m_timestamp; + } + } + ValidateParticleIndex(t) { + return t >= 0 && t < this.GetParticleCount() && t !== C; + } + GetQuantizedTimeElapsed() { + return Math.floor(this.m_timeElapsed / 4294967296); + } + LifetimeToExpirationTime(t) { + return this.m_timeElapsed + Math.floor(t / this.m_def.lifetimeGranularity * 4294967296); + } + ForceCanBeApplied(e) { + return !(e & t.b2ParticleFlag.b2_wallParticle); + } + PrepareForceBuffer() { + if (!this.m_hasForce) { + for (let t = 0; t < this.m_count; t++) this.m_forceBuffer[t].SetZero(); + this.m_hasForce = !0; + } + } + IsRigidGroup(e) { + return null !== e && 0 != (e.m_groupFlags & t.b2ParticleGroupFlag.b2_rigidParticleGroup); + } + GetLinearVelocity(t, e, i, s) { + return t && this.IsRigidGroup(t) ? t.GetLinearVelocityFromWorldPoint(i, s) : s.Copy(this.m_velocityBuffer.data[e]); + } + InitDampingParameter(t, e, i, s, n, r, o, a) { + t[0] = s > 0 ? 1 / s : 0; + e[0] = n > 0 ? 1 / n : 0; + i[0] = St.CrossVV(St.SubVV(o, r, St.s_t0), a); + } + InitDampingParameterWithRigidGroupOrParticle(e, i, s, n, r, o, a, l) { + if (r && n) this.InitDampingParameter(e, i, s, r.GetMass(), r.GetInertia(), r.GetCenter(), a, l); else { + const n = this.m_flagsBuffer.data[o]; + this.InitDampingParameter(e, i, s, n & t.b2ParticleFlag.b2_wallParticle ? 0 : this.GetParticleMass(), 0, a, a, l); + } + } + ComputeDampingImpulse(t, e, i, s, n, r, o) { + const a = t + e * i * i + s + n * r * r; + return a > 0 ? o / a : 0; + } + ApplyDamping(t, e, i, s, n, r, o, a) { + if (n && s) { + n.m_linearVelocity.SelfMulAdd(o * t, a); + n.m_angularVelocity += o * i * e; + } else this.m_velocityBuffer.data[r].SelfMulAdd(o * t, a); + } + } + Un.xTruncBits = 12; + Un.yTruncBits = 12; + Un.tagBits = 32; + Un.yOffset = 1 << Un.yTruncBits - 1; + Un.yShift = Un.tagBits - Un.yTruncBits; + Un.xShift = Un.tagBits - Un.yTruncBits - Un.xTruncBits; + Un.xScale = 1 << Un.xShift; + Un.xOffset = Un.xScale * (1 << Un.xTruncBits - 1); + Un.yMask = (1 << Un.yTruncBits) - 1 << Un.yShift; + Un.xMask = ~Un.yMask; + Un.DestroyParticlesInShape_s_aabb = new ge; + Un.CreateParticleGroup_s_transform = new xt; + Un.ComputeCollisionEnergy_s_v = new St; + Un.QueryShapeAABB_s_aabb = new ge; + Un.QueryPointAABB_s_aabb = new ge; + Un.RayCast_s_aabb = new ge; + Un.RayCast_s_p = new St; + Un.RayCast_s_v = new St; + Un.RayCast_s_n = new St; + Un.RayCast_s_point = new St; + Un.k_pairFlags = t.b2ParticleFlag.b2_springParticle; + Un.k_triadFlags = t.b2ParticleFlag.b2_elasticParticle; + Un.k_noPressureFlags = t.b2ParticleFlag.b2_powderParticle | t.b2ParticleFlag.b2_tensileParticle; + Un.k_extraDampingFlags = t.b2ParticleFlag.b2_staticPressureParticle; + Un.k_barrierWallFlags = t.b2ParticleFlag.b2_barrierParticle | t.b2ParticleFlag.b2_wallParticle; + Un.CreateParticlesStrokeShapeForGroup_s_edge = new Qi; + Un.CreateParticlesStrokeShapeForGroup_s_d = new St; + Un.CreateParticlesStrokeShapeForGroup_s_p = new St; + Un.CreateParticlesFillShapeForGroup_s_aabb = new ge; + Un.CreateParticlesFillShapeForGroup_s_p = new St; + Un.UpdatePairsAndTriads_s_dab = new St; + Un.UpdatePairsAndTriads_s_dbc = new St; + Un.UpdatePairsAndTriads_s_dca = new St; + Un.AddContact_s_d = new St; + Un.UpdateBodyContacts_s_aabb = new ge; + Un.Solve_s_subStep = new sn; + Un.SolveCollision_s_aabb = new ge; + Un.SolveGravity_s_gravity = new St; + Un.SolveBarrier_s_aabb = new ge; + Un.SolveBarrier_s_va = new St; + Un.SolveBarrier_s_vb = new St; + Un.SolveBarrier_s_pba = new St; + Un.SolveBarrier_s_vba = new St; + Un.SolveBarrier_s_vc = new St; + Un.SolveBarrier_s_pca = new St; + Un.SolveBarrier_s_vca = new St; + Un.SolveBarrier_s_qba = new St; + Un.SolveBarrier_s_qca = new St; + Un.SolveBarrier_s_dv = new St; + Un.SolveBarrier_s_f = new St; + Un.SolvePressure_s_f = new St; + Un.SolveDamping_s_v = new St; + Un.SolveDamping_s_f = new St; + Un.SolveRigidDamping_s_t0 = new St; + Un.SolveRigidDamping_s_t1 = new St; + Un.SolveRigidDamping_s_p = new St; + Un.SolveRigidDamping_s_v = new St; + Un.SolveExtraDamping_s_v = new St; + Un.SolveExtraDamping_s_f = new St; + Un.SolveRigid_s_position = new St; + Un.SolveRigid_s_rotation = new Ct; + Un.SolveRigid_s_transform = new xt; + Un.SolveRigid_s_velocityTransform = new xt; + Un.SolveElastic_s_pa = new St; + Un.SolveElastic_s_pb = new St; + Un.SolveElastic_s_pc = new St; + Un.SolveElastic_s_r = new Ct; + Un.SolveElastic_s_t0 = new St; + Un.SolveSpring_s_pa = new St; + Un.SolveSpring_s_pb = new St; + Un.SolveSpring_s_d = new St; + Un.SolveSpring_s_f = new St; + Un.SolveTensile_s_weightedNormal = new St; + Un.SolveTensile_s_s = new St; + Un.SolveTensile_s_f = new St; + Un.SolveViscous_s_v = new St; + Un.SolveViscous_s_f = new St; + Un.SolveRepulsive_s_f = new St; + Un.SolvePowder_s_f = new St; + Un.SolveSolid_s_f = new St; + Un.RemoveSpuriousBodyContacts_s_n = new St; + Un.RemoveSpuriousBodyContacts_s_pos = new St; + Un.RemoveSpuriousBodyContacts_s_normal = new St; + class Gn { + constructor() { + this._data = null; + this.userSuppliedCapacity = 0; + } + get data() { + return this._data; + } + set data(t) { + this._data = t; + } + } + class zn { + constructor() { + this.index = C; + this.tag = 0; + } + static CompareProxyProxy(t, e) { + return t.tag < e.tag; + } + static CompareTagProxy(t, e) { + return t < e.tag; + } + static CompareProxyTag(t, e) { + return t.tag < e; + } + } + class Hn { + constructor(t, e, i, s, n) { + this.m_system = t; + this.m_xLower = (e & Un.xMask) >>> 0; + this.m_xUpper = (i & Un.xMask) >>> 0; + this.m_yLower = (e & Un.yMask) >>> 0; + this.m_yUpper = (i & Un.yMask) >>> 0; + this.m_first = s; + this.m_last = n; + } + GetNext() { + for (;this.m_first < this.m_last; ) { + const t = (this.m_system.m_proxyBuffer.data[this.m_first].tag & Un.xMask) >>> 0; + if (t >= this.m_xLower && t <= this.m_xUpper) return this.m_system.m_proxyBuffer.data[this.m_first++].index; + this.m_first++; + } + return C; + } + } + class jn { + constructor() { + this.next = null; + this.count = 0; + this.index = 0; + } + } + class Xn { + Allocate(t, e) { + return e; + } + Clear() {} + GetCount() { + return 0; + } + Invalidate(t) {} + GetValidBuffer() { + return []; + } + GetBuffer() { + return []; + } + SetCount(t) {} + } + class Wn { + constructor(t, e) { + this.second = C; + this.first = t; + this.second = e; + } + } + class Yn extends Xn { + Initialize(t, e) {} + Find(t) { + return C; + } + } + class qn { + constructor(t, e) { + this.first = C; + this.second = C; + this.first = t; + this.second = e; + } + } + class Kn extends Xn { + Initialize(t, e) {} + Find(t) { + return C; + } + } + class Jn { + IsNecessary(t) { + return !0; + } + ShouldCreatePair(t, e) { + return !0; + } + ShouldCreateTriad(t, e, i) { + return !0; + } + } + class Zn extends Qs { + constructor(t, e, i, s) { + super(); + this.m_callDestructionListener = !1; + this.m_destroyed = 0; + this.m_system = t; + this.m_shape = e; + this.m_xf = i; + this.m_callDestructionListener = s; + this.m_destroyed = 0; + } + ReportFixture(t) { + return !1; + } + ReportParticle(t, e) { + if (t !== this.m_system) return !1; + if (this.m_shape.TestPoint(this.m_xf, this.m_system.m_positionBuffer.data[e])) { + this.m_system.DestroyParticle(e, this.m_callDestructionListener); + this.m_destroyed++; + } + return !0; + } + Destroyed() { + return this.m_destroyed; + } + } + class Qn extends Jn { + constructor(t) { + super(); + this.m_threshold = 0; + this.m_threshold = t; + } + ShouldCreatePair(t, e) { + return t < this.m_threshold && this.m_threshold <= e || e < this.m_threshold && this.m_threshold <= t; + } + ShouldCreateTriad(t, e, i) { + return (t < this.m_threshold || e < this.m_threshold || i < this.m_threshold) && (this.m_threshold <= t || this.m_threshold <= e || this.m_threshold <= i); + } + } + class $n extends Ki { + constructor(e, i = e.length) { + super(t.b2ShapeType.e_unknown, 0); + this.m_shapeCount = 0; + this.m_shapes = e; + this.m_shapeCount = i; + } + Clone() { + throw new Error; + } + GetChildCount() { + return 1; + } + TestPoint(t, e) { + for (let i = 0; i < this.m_shapeCount; i++) if (this.m_shapes[i].TestPoint(t, e)) return !0; + return !1; + } + ComputeDistance(t, e, i, s) { + return 0; + } + RayCast(t, e, i, s) { + return !1; + } + ComputeAABB(t, e, i) { + const n = new ge; + t.lowerBound.x = +s; + t.lowerBound.y = +s; + t.upperBound.x = -s; + t.upperBound.y = -s; + for (let i = 0; i < this.m_shapeCount; i++) { + const s = this.m_shapes[i].GetChildCount(); + for (let r = 0; r < s; r++) { + const s = n; + this.m_shapes[i].ComputeAABB(s, e, r); + t.Combine1(s); + } + } + } + ComputeMass(t, e) {} + SetupDistanceProxy(t, e) {} + ComputeSubmergedArea(t, e, i, s) { + return 0; + } + Dump(t) {} + } + class tr extends Jn { + constructor(t) { + super(); + this.m_flagsBuffer = t; + } + IsNecessary(e) { + return 0 != (this.m_flagsBuffer.data[e] & t.b2ParticleFlag.b2_reactiveParticle); + } + } + class er extends On { + constructor(t, e = null) { + super(t); + this.m_contactFilter = null; + this.m_contactFilter = e; + } + ShouldCollideFixtureParticle(e, i, s) { + return !(this.m_contactFilter && this.m_system.GetFlagsBuffer()[s] & t.b2ParticleFlag.b2_fixtureContactFilterParticle) || this.m_contactFilter.ShouldCollideFixtureParticle(e, this.m_system, s); + } + ReportFixtureAndParticle(e, i, s) { + const n = er.ReportFixtureAndParticle_s_n; + const r = er.ReportFixtureAndParticle_s_rp; + const o = this.m_system.m_positionBuffer.data[s]; + const a = n; + const l = e.ComputeDistance(o, a, i); + if (l < this.m_system.m_particleDiameter && this.ShouldCollideFixtureParticle(e, this.m_system, s)) { + const i = e.GetBody(); + const n = i.GetWorldCenter(); + const h = i.GetMass(); + const c = i.GetInertia() - h * i.GetLocalCenter().LengthSquared(); + const u = h > 0 ? 1 / h : 0; + const _ = c > 0 ? 1 / c : 0; + const d = this.m_system.m_flagsBuffer.data[s] & t.b2ParticleFlag.b2_wallParticle ? 0 : this.m_system.GetParticleInvMass(); + const p = St.SubVV(o, n, r); + const m = St.CrossVV(p, a); + const f = d + u + _ * m * m; + const g = this.m_system.m_bodyContactBuffer.data[this.m_system.m_bodyContactBuffer.Append()]; + g.index = s; + g.body = i; + g.fixture = e; + g.weight = 1 - l * this.m_system.m_inverseDiameter; + g.normal.Copy(a.SelfNeg()); + g.mass = f > 0 ? 1 / f : 0; + this.m_system.DetectStuckParticle(s); + } + } + } + er.ReportFixtureAndParticle_s_n = new St; + er.ReportFixtureAndParticle_s_rp = new St; + class ir extends On { + constructor(t, e) { + super(t); + this.m_step = e; + } + ReportFixtureAndParticle(e, i, s) { + const n = ir.ReportFixtureAndParticle_s_p1; + const r = ir.ReportFixtureAndParticle_s_output; + const o = ir.ReportFixtureAndParticle_s_input; + const a = ir.ReportFixtureAndParticle_s_p; + const l = ir.ReportFixtureAndParticle_s_v; + const h = ir.ReportFixtureAndParticle_s_f; + const c = e.GetBody(); + const _ = this.m_system.m_positionBuffer.data[s]; + const d = this.m_system.m_velocityBuffer.data[s]; + const p = r; + const m = o; + if (0 === this.m_system.m_iterationIndex) { + const i = xt.MulTXV(c.m_xf0, _, n); + if (e.GetShape().GetType() === t.b2ShapeType.e_circleShape) { + i.SelfSub(c.GetLocalCenter()); + Ct.MulRV(c.m_xf0.q, i, i); + Ct.MulTRV(c.m_xf.q, i, i); + i.SelfAdd(c.GetLocalCenter()); + } + xt.MulXV(c.m_xf, i, m.p1); + } else m.p1.Copy(_); + St.AddVMulSV(_, this.m_step.dt, d, m.p2); + m.maxFraction = 1; + if (e.RayCast(p, m, i)) { + const t = p.normal; + const e = a; + e.x = (1 - p.fraction) * m.p1.x + p.fraction * m.p2.x + u * t.x; + e.y = (1 - p.fraction) * m.p1.y + p.fraction * m.p2.y + u * t.y; + const i = l; + i.x = this.m_step.inv_dt * (e.x - _.x); + i.y = this.m_step.inv_dt * (e.y - _.y); + this.m_system.m_velocityBuffer.data[s].Copy(i); + const n = h; + n.x = this.m_step.inv_dt * this.m_system.GetParticleMass() * (d.x - i.x); + n.y = this.m_step.inv_dt * this.m_system.GetParticleMass() * (d.y - i.y); + this.m_system.ParticleApplyForce(s, n); + } + } + ReportParticle(t, e) { + return !1; + } + } + ir.ReportFixtureAndParticle_s_p1 = new St; + ir.ReportFixtureAndParticle_s_output = new fe; + ir.ReportFixtureAndParticle_s_input = new me; + ir.ReportFixtureAndParticle_s_p = new St; + ir.ReportFixtureAndParticle_s_v = new St; + ir.ReportFixtureAndParticle_s_f = new St; + class sr { + constructor(t) { + this.m_newFixture = !1; + this.m_locked = !1; + this.m_clearForces = !0; + this.m_contactManager = new tn; + this.m_bodyList = null; + this.m_jointList = null; + this.m_particleSystemList = null; + this.m_bodyCount = 0; + this.m_jointCount = 0; + this.m_gravity = new St; + this.m_allowSleep = !0; + this.m_destructionListener = null; + this.m_debugDraw = null; + this.m_inv_dt0 = 0; + this.m_warmStarting = !0; + this.m_continuousPhysics = !0; + this.m_subStepping = !1; + this.m_stepComplete = !0; + this.m_profile = new en; + this.m_island = new pn; + this.s_stack = []; + this.m_controllerList = null; + this.m_controllerCount = 0; + this.m_gravity.Copy(t); + } + SetDestructionListener(t) { + this.m_destructionListener = t; + } + SetContactFilter(t) { + this.m_contactManager.m_contactFilter = t; + } + SetContactListener(t) { + this.m_contactManager.m_contactListener = t; + } + SetDebugDraw(t) { + this.m_debugDraw = t; + } + CreateBody(t = {}) { + if (this.IsLocked()) throw new Error; + const e = new rs(t, this); + e.m_prev = null; + e.m_next = this.m_bodyList; + this.m_bodyList && (this.m_bodyList.m_prev = e); + this.m_bodyList = e; + ++this.m_bodyCount; + return e; + } + DestroyBody(t) { + if (this.IsLocked()) throw new Error; + let e = t.m_jointList; + for (;e; ) { + const i = e; + e = e.next; + this.m_destructionListener && this.m_destructionListener.SayGoodbyeJoint(i.joint); + this.DestroyJoint(i.joint); + t.m_jointList = e; + } + t.m_jointList = null; + let i = t.m_controllerList; + for (;i; ) { + const e = i; + i = i.nextController; + e.controller.RemoveBody(t); + } + let s = t.m_contactList; + for (;s; ) { + const t = s; + s = s.next; + this.m_contactManager.Destroy(t.contact); + } + t.m_contactList = null; + let n = t.m_fixtureList; + for (;n; ) { + const e = n; + n = n.m_next; + this.m_destructionListener && this.m_destructionListener.SayGoodbyeFixture(e); + e.DestroyProxies(); + e.Reset(); + t.m_fixtureList = n; + t.m_fixtureCount -= 1; + } + t.m_fixtureList = null; + t.m_fixtureCount = 0; + t.m_prev && (t.m_prev.m_next = t.m_next); + t.m_next && (t.m_next.m_prev = t.m_prev); + t === this.m_bodyList && (this.m_bodyList = t.m_next); + --this.m_bodyCount; + } + static _Joint_Create(e) { + switch (e.type) { + case t.b2JointType.e_distanceJoint: + return new us(e); + + case t.b2JointType.e_mouseJoint: + return new As(e); + + case t.b2JointType.e_prismaticJoint: + return new vs(e); + + case t.b2JointType.e_revoluteJoint: + return new Rs(e); + + case t.b2JointType.e_pulleyJoint: + return new xs(e); + + case t.b2JointType.e_gearJoint: + return new gs(e); + + case t.b2JointType.e_wheelJoint: + return new Os(e); + + case t.b2JointType.e_weldJoint: + return new Ds(e); + + case t.b2JointType.e_frictionJoint: + return new ms(e); + + case t.b2JointType.e_ropeJoint: + return new Ms(e); + + case t.b2JointType.e_motorJoint: + return new bs(e); + + case t.b2JointType.e_areaJoint: + return new ds(e); + } + throw new Error; + } + static _Joint_Destroy(t) {} + CreateJoint(t) { + if (this.IsLocked()) throw new Error; + const e = sr._Joint_Create(t); + e.m_prev = null; + e.m_next = this.m_jointList; + this.m_jointList && (this.m_jointList.m_prev = e); + this.m_jointList = e; + ++this.m_jointCount; + e.m_edgeA.prev = null; + e.m_edgeA.next = e.m_bodyA.m_jointList; + e.m_bodyA.m_jointList && (e.m_bodyA.m_jointList.prev = e.m_edgeA); + e.m_bodyA.m_jointList = e.m_edgeA; + e.m_edgeB.prev = null; + e.m_edgeB.next = e.m_bodyB.m_jointList; + e.m_bodyB.m_jointList && (e.m_bodyB.m_jointList.prev = e.m_edgeB); + e.m_bodyB.m_jointList = e.m_edgeB; + const i = e.m_bodyA; + const s = e.m_bodyB; + if (!e.m_collideConnected) { + let t = s.GetContactList(); + for (;t; ) { + t.other === i && t.contact.FlagForFiltering(); + t = t.next; + } + } + return e; + } + DestroyJoint(t) { + if (this.IsLocked()) throw new Error; + t.m_prev && (t.m_prev.m_next = t.m_next); + t.m_next && (t.m_next.m_prev = t.m_prev); + t === this.m_jointList && (this.m_jointList = t.m_next); + const e = t.m_bodyA; + const i = t.m_bodyB; + const s = t.m_collideConnected; + e.SetAwake(!0); + i.SetAwake(!0); + t.m_edgeA.prev && (t.m_edgeA.prev.next = t.m_edgeA.next); + t.m_edgeA.next && (t.m_edgeA.next.prev = t.m_edgeA.prev); + t.m_edgeA === e.m_jointList && (e.m_jointList = t.m_edgeA.next); + t.m_edgeA.Reset(); + t.m_edgeB.prev && (t.m_edgeB.prev.next = t.m_edgeB.next); + t.m_edgeB.next && (t.m_edgeB.next.prev = t.m_edgeB.prev); + t.m_edgeB === i.m_jointList && (i.m_jointList = t.m_edgeB.next); + t.m_edgeB.Reset(); + sr._Joint_Destroy(t); + --this.m_jointCount; + if (!s) { + let t = i.GetContactList(); + for (;t; ) { + t.other === e && t.contact.FlagForFiltering(); + t = t.next; + } + } + } + CreateParticleSystem(t) { + if (this.IsLocked()) throw new Error; + const e = new Un(t, this); + e.m_prev = null; + e.m_next = this.m_particleSystemList; + this.m_particleSystemList && (this.m_particleSystemList.m_prev = e); + this.m_particleSystemList = e; + return e; + } + DestroyParticleSystem(t) { + if (this.IsLocked()) throw new Error; + t.m_prev && (t.m_prev.m_next = t.m_next); + t.m_next && (t.m_next.m_prev = t.m_prev); + t === this.m_particleSystemList && (this.m_particleSystemList = t.m_next); + } + CalculateReasonableParticleIterations(t) { + if (null === this.m_particleSystemList) return 1; + function e(t) { + let e = s; + for (let i = t.GetParticleSystemList(); null !== i; i = i.m_next) e = tt(e, i.GetRadius()); + return e; + } + return fn(this.m_gravity.Length(), e(this), t); + } + Step(t, e, i, s = this.CalculateReasonableParticleIterations(t)) { + const n = sr.Step_s_stepTimer.Reset(); + if (this.m_newFixture) { + this.m_contactManager.FindNewContacts(); + this.m_newFixture = !1; + } + this.m_locked = !0; + const r = sr.Step_s_step; + r.dt = t; + r.velocityIterations = e; + r.positionIterations = i; + r.particleIterations = s; + r.inv_dt = t > 0 ? 1 / t : 0; + r.dtRatio = this.m_inv_dt0 * t; + r.warmStarting = this.m_warmStarting; + const o = sr.Step_s_timer.Reset(); + this.m_contactManager.Collide(); + this.m_profile.collide = o.GetMilliseconds(); + if (this.m_stepComplete && r.dt > 0) { + const t = sr.Step_s_timer.Reset(); + for (let t = this.m_particleSystemList; t; t = t.m_next) t.Solve(r); + this.Solve(r); + this.m_profile.solve = t.GetMilliseconds(); + } + if (this.m_continuousPhysics && r.dt > 0) { + const t = sr.Step_s_timer.Reset(); + this.SolveTOI(r); + this.m_profile.solveTOI = t.GetMilliseconds(); + } + r.dt > 0 && (this.m_inv_dt0 = r.inv_dt); + this.m_clearForces && this.ClearForces(); + this.m_locked = !1; + this.m_profile.step = n.GetMilliseconds(); + } + ClearForces() { + for (let t = this.m_bodyList; t; t = t.m_next) { + t.m_force.SetZero(); + t.m_torque = 0; + } + } + DrawParticleSystem(t) { + if (null === this.m_debugDraw) return; + const e = t.GetParticleCount(); + if (e) { + const i = t.GetRadius(); + const s = t.GetPositionBuffer(); + if (t.m_colorBuffer.data) { + const n = t.GetColorBuffer(); + this.m_debugDraw.DrawParticles(s, i, n, e); + } else this.m_debugDraw.DrawParticles(s, i, null, e); + } + } + DrawDebugData() { + if (null === this.m_debugDraw) return; + const e = this.m_debugDraw.GetFlags(); + const i = sr.DrawDebugData_s_color.SetRGB(0, 0, 0); + if (e & t.b2DrawFlags.e_shapeBit) for (let e = this.m_bodyList; e; e = e.m_next) { + const s = e.m_xf; + this.m_debugDraw.PushTransform(s); + for (let s = e.GetFixtureList(); s; s = s.m_next) if (e.IsActive()) if (e.GetType() === t.b2BodyType.b2_staticBody) { + i.SetRGB(.5, .9, .5); + this.DrawShape(s, i); + } else if (e.GetType() === t.b2BodyType.b2_kinematicBody) { + i.SetRGB(.5, .5, .9); + this.DrawShape(s, i); + } else if (e.IsAwake()) { + i.SetRGB(.9, .7, .7); + this.DrawShape(s, i); + } else { + i.SetRGB(.6, .6, .6); + this.DrawShape(s, i); + } else { + i.SetRGB(.5, .5, .3); + this.DrawShape(s, i); + } + this.m_debugDraw.PopTransform(s); + } + if (e & t.b2DrawFlags.e_particleBit) for (let t = this.m_particleSystemList; t; t = t.m_next) this.DrawParticleSystem(t); + if (e & t.b2DrawFlags.e_jointBit) for (let t = this.m_jointList; t; t = t.m_next) this.DrawJoint(t); + if (e & t.b2DrawFlags.e_aabbBit) { + i.SetRGB(.9, .3, .9); + const t = sr.DrawDebugData_s_vs; + for (let e = this.m_bodyList; e; e = e.m_next) if (e.IsActive()) for (let s = e.GetFixtureList(); s; s = s.m_next) for (let e = 0; e < s.m_proxyCount; ++e) { + const n = s.m_proxies[e].treeNode.aabb; + t[0].Set(n.lowerBound.x, n.lowerBound.y); + t[1].Set(n.upperBound.x, n.lowerBound.y); + t[2].Set(n.upperBound.x, n.upperBound.y); + t[3].Set(n.lowerBound.x, n.upperBound.y); + this.m_debugDraw.DrawPolygon(t, 4, i); + } + } + if (e & t.b2DrawFlags.e_centerOfMassBit) for (let t = this.m_bodyList; t; t = t.m_next) { + const e = sr.DrawDebugData_s_xf; + e.q.Copy(t.m_xf.q); + e.p.Copy(t.GetWorldCenter()); + this.m_debugDraw.DrawTransform(e); + } + if (e & t.b2DrawFlags.e_controllerBit) for (let t = this.m_controllerList; t; t = t.m_next) t.Draw(this.m_debugDraw); + } + QueryAABB(...t) { + t[0] instanceof Qs ? this._QueryAABB(t[0], t[1]) : this._QueryAABB(null, t[0], t[1]); + } + _QueryAABB(t, e, i) { + this.m_contactManager.m_broadPhase.Query(e, (e => { + const s = e.userData.fixture; + return t ? t.ReportFixture(s) : !i || i(s); + })); + if (t instanceof Qs) for (let i = this.m_particleSystemList; i; i = i.m_next) t.ShouldQueryParticleSystem(i) && i.QueryAABB(t, e); + } + QueryAllAABB(t, e = []) { + this.QueryAABB(t, (t => { + e.push(t); + return !0; + })); + return e; + } + QueryPointAABB(...t) { + t[0] instanceof Qs ? this._QueryPointAABB(t[0], t[1]) : this._QueryPointAABB(null, t[0], t[1]); + } + _QueryPointAABB(t, e, i) { + this.m_contactManager.m_broadPhase.QueryPoint(e, (e => { + const s = e.userData.fixture; + return t ? t.ReportFixture(s) : !i || i(s); + })); + if (t instanceof Qs) for (let i = this.m_particleSystemList; i; i = i.m_next) t.ShouldQueryParticleSystem(i) && i.QueryPointAABB(t, e); + } + QueryAllPointAABB(t, e = []) { + this.QueryPointAABB(t, (t => { + e.push(t); + return !0; + })); + return e; + } + QueryFixtureShape(...t) { + t[0] instanceof Qs ? this._QueryFixtureShape(t[0], t[1], t[2], t[3]) : this._QueryFixtureShape(null, t[0], t[1], t[2], t[3]); + } + _QueryFixtureShape(t, e, i, s, n) { + const r = sr.QueryFixtureShape_s_aabb; + e.ComputeAABB(r, s, i); + this.m_contactManager.m_broadPhase.Query(r, (r => { + const o = r.userData; + const a = o.fixture; + if (ve(e, i, a.GetShape(), o.childIndex, s, a.GetBody().GetTransform())) { + if (t) return t.ReportFixture(a); + if (n) return n(a); + } + return !0; + })); + if (t instanceof Qs) for (let e = this.m_particleSystemList; e; e = e.m_next) t.ShouldQueryParticleSystem(e) && e.QueryAABB(t, r); + } + QueryAllFixtureShape(t, e, i, s = []) { + this.QueryFixtureShape(t, e, i, (t => { + s.push(t); + return !0; + })); + return s; + } + QueryFixturePoint(...t) { + t[0] instanceof Qs ? this._QueryFixturePoint(t[0], t[1]) : this._QueryFixturePoint(null, t[0], t[1]); + } + _QueryFixturePoint(t, e, i) { + this.m_contactManager.m_broadPhase.QueryPoint(e, (s => { + const n = s.userData.fixture; + if (n.TestPoint(e)) { + if (t) return t.ReportFixture(n); + if (i) return i(n); + } + return !0; + })); + if (t) for (let i = this.m_particleSystemList; i; i = i.m_next) t.ShouldQueryParticleSystem(i) && i.QueryPointAABB(t, e); + } + QueryAllFixturePoint(t, e = []) { + this.QueryFixturePoint(t, (t => { + e.push(t); + return !0; + })); + return e; + } + RayCast(...t) { + t[0] instanceof $s ? this._RayCast(t[0], t[1], t[2]) : this._RayCast(null, t[0], t[1], t[2]); + } + _RayCast(t, e, i, s) { + const n = sr.RayCast_s_input; + n.maxFraction = 1; + n.p1.Copy(e); + n.p2.Copy(i); + this.m_contactManager.m_broadPhase.RayCast(n, ((n, r) => { + const o = r.userData; + const a = o.fixture; + const l = o.childIndex; + const h = sr.RayCast_s_output; + if (a.RayCast(h, n, l)) { + const n = h.fraction; + const r = sr.RayCast_s_point; + r.Set((1 - n) * e.x + n * i.x, (1 - n) * e.y + n * i.y); + if (t) return t.ReportFixture(a, r, h.normal, n); + if (s) return s(a, r, h.normal, n); + } + return n.maxFraction; + })); + if (t) for (let s = this.m_particleSystemList; s; s = s.m_next) t.ShouldQueryParticleSystem(s) && s.RayCast(t, e, i); + } + RayCastOne(t, e) { + let i = null; + let s = 1; + this.RayCast(t, e, ((t, e, n, r) => { + if (r < s) { + s = r; + i = t; + } + return s; + })); + return i; + } + RayCastAll(t, e, i = []) { + this.RayCast(t, e, ((t, e, s, n) => { + i.push(t); + return 1; + })); + return i; + } + GetBodyList() { + return this.m_bodyList; + } + GetJointList() { + return this.m_jointList; + } + GetParticleSystemList() { + return this.m_particleSystemList; + } + GetContactList() { + return this.m_contactManager.m_contactList; + } + SetAllowSleeping(t) { + if (t !== this.m_allowSleep) { + this.m_allowSleep = t; + if (!this.m_allowSleep) for (let t = this.m_bodyList; t; t = t.m_next) t.SetAwake(!0); + } + } + GetAllowSleeping() { + return this.m_allowSleep; + } + SetWarmStarting(t) { + this.m_warmStarting = t; + } + GetWarmStarting() { + return this.m_warmStarting; + } + SetContinuousPhysics(t) { + this.m_continuousPhysics = t; + } + GetContinuousPhysics() { + return this.m_continuousPhysics; + } + SetSubStepping(t) { + this.m_subStepping = t; + } + GetSubStepping() { + return this.m_subStepping; + } + GetProxyCount() { + return this.m_contactManager.m_broadPhase.GetProxyCount(); + } + GetBodyCount() { + return this.m_bodyCount; + } + GetJointCount() { + return this.m_jointCount; + } + GetContactCount() { + return this.m_contactManager.m_contactCount; + } + GetTreeHeight() { + return this.m_contactManager.m_broadPhase.GetTreeHeight(); + } + GetTreeBalance() { + return this.m_contactManager.m_broadPhase.GetTreeBalance(); + } + GetTreeQuality() { + return this.m_contactManager.m_broadPhase.GetTreeQuality(); + } + SetGravity(t, e = !0) { + if (!St.IsEqualToV(this.m_gravity, t)) { + this.m_gravity.Copy(t); + if (e) for (let t = this.m_bodyList; t; t = t.m_next) t.SetAwake(!0); + } + } + GetGravity() { + return this.m_gravity; + } + IsLocked() { + return this.m_locked; + } + SetAutoClearForces(t) { + this.m_clearForces = t; + } + GetAutoClearForces() { + return this.m_clearForces; + } + ShiftOrigin(t) { + if (this.IsLocked()) throw new Error; + for (let e = this.m_bodyList; e; e = e.m_next) { + e.m_xf.p.SelfSub(t); + e.m_sweep.c0.SelfSub(t); + e.m_sweep.c.SelfSub(t); + } + for (let e = this.m_jointList; e; e = e.m_next) e.ShiftOrigin(t); + this.m_contactManager.m_broadPhase.ShiftOrigin(t); + } + GetContactManager() { + return this.m_contactManager; + } + GetProfile() { + return this.m_profile; + } + Dump(e) { + if (this.m_locked) return; + e("const g: b2Vec2 = new b2Vec2(%.15f, %.15f);\n", this.m_gravity.x, this.m_gravity.y); + e("this.m_world.SetGravity(g);\n"); + e("const bodies: b2Body[] = [];\n"); + e("const joints: b2Joint[] = [];\n"); + let i = 0; + for (let t = this.m_bodyList; t; t = t.m_next) { + t.m_islandIndex = i; + t.Dump(e); + ++i; + } + i = 0; + for (let t = this.m_jointList; t; t = t.m_next) { + t.m_index = i; + ++i; + } + for (let i = this.m_jointList; i; i = i.m_next) if (i.m_type !== t.b2JointType.e_gearJoint) { + e("{\n"); + i.Dump(e); + e("}\n"); + } + for (let i = this.m_jointList; i; i = i.m_next) if (i.m_type === t.b2JointType.e_gearJoint) { + e("{\n"); + i.Dump(e); + e("}\n"); + } + } + DrawJoint(e) { + if (null === this.m_debugDraw) return; + const i = e.GetBodyA(); + const s = e.GetBodyB(); + const n = i.m_xf; + const r = s.m_xf; + const o = n.p; + const a = r.p; + const l = e.GetAnchorA(sr.DrawJoint_s_p1); + const h = e.GetAnchorB(sr.DrawJoint_s_p2); + const c = sr.DrawJoint_s_color.SetRGB(.5, .8, .8); + switch (e.m_type) { + case t.b2JointType.e_distanceJoint: + this.m_debugDraw.DrawSegment(l, h, c); + break; + + case t.b2JointType.e_pulleyJoint: + { + const t = e; + const i = t.GetGroundAnchorA(); + const s = t.GetGroundAnchorB(); + this.m_debugDraw.DrawSegment(i, l, c); + this.m_debugDraw.DrawSegment(s, h, c); + this.m_debugDraw.DrawSegment(i, s, c); + break; + } + + case t.b2JointType.e_mouseJoint: + { + const t = sr.DrawJoint_s_c; + t.Set(0, 1, 0); + this.m_debugDraw.DrawPoint(l, 4, t); + this.m_debugDraw.DrawPoint(h, 4, t); + t.Set(.8, .8, .8); + this.m_debugDraw.DrawSegment(l, h, t); + break; + } + + default: + this.m_debugDraw.DrawSegment(o, l, c); + this.m_debugDraw.DrawSegment(l, h, c); + this.m_debugDraw.DrawSegment(a, h, c); + } + } + DrawShape(e, i) { + if (null === this.m_debugDraw) return; + const s = e.GetShape(); + switch (s.m_type) { + case t.b2ShapeType.e_circleShape: + { + const t = s; + const e = t.m_p; + const n = t.m_radius; + const r = St.UNITX; + this.m_debugDraw.DrawSolidCircle(e, n, r, i); + break; + } + + case t.b2ShapeType.e_edgeShape: + { + const t = s; + const e = t.m_vertex1; + const n = t.m_vertex2; + this.m_debugDraw.DrawSegment(e, n, i); + break; + } + + case t.b2ShapeType.e_chainShape: + { + const t = s; + const e = t.m_count; + const n = t.m_vertices; + const r = sr.DrawShape_s_ghostColor.SetRGBA(.75 * i.r, .75 * i.g, .75 * i.b, i.a); + let o = n[0]; + this.m_debugDraw.DrawPoint(o, 4, i); + if (t.m_hasPrevVertex) { + const e = t.m_prevVertex; + this.m_debugDraw.DrawSegment(e, o, r); + this.m_debugDraw.DrawCircle(e, .1, r); + } + for (let t = 1; t < e; ++t) { + const e = n[t]; + this.m_debugDraw.DrawSegment(o, e, i); + this.m_debugDraw.DrawPoint(e, 4, i); + o = e; + } + if (t.m_hasNextVertex) { + const e = t.m_nextVertex; + this.m_debugDraw.DrawSegment(e, o, r); + this.m_debugDraw.DrawCircle(e, .1, r); + } + break; + } + + case t.b2ShapeType.e_polygonShape: + { + const t = s; + const e = t.m_count; + const n = t.m_vertices; + this.m_debugDraw.DrawSolidPolygon(n, e, i); + break; + } + } + } + Solve(e) { + for (let t = this.m_bodyList; t; t = t.m_next) t.m_xf0.Copy(t.m_xf); + for (let t = this.m_controllerList; t; t = t.m_next) t.Step(e); + this.m_profile.solveInit = 0; + this.m_profile.solveVelocity = 0; + this.m_profile.solvePosition = 0; + const i = this.m_island; + i.Initialize(this.m_bodyCount, this.m_contactManager.m_contactCount, this.m_jointCount, this.m_contactManager.m_contactListener); + for (let t = this.m_bodyList; t; t = t.m_next) t.m_islandFlag = !1; + for (let t = this.m_contactManager.m_contactList; t; t = t.m_next) t.m_islandFlag = !1; + for (let t = this.m_jointList; t; t = t.m_next) t.m_islandFlag = !1; + const s = this.s_stack; + for (let n = this.m_bodyList; n; n = n.m_next) { + if (n.m_islandFlag) continue; + if (!n.IsAwake() || !n.IsActive()) continue; + if (n.GetType() === t.b2BodyType.b2_staticBody) continue; + i.Clear(); + let r = 0; + s[r++] = n; + n.m_islandFlag = !0; + for (;r > 0; ) { + const e = s[--r]; + if (!e) throw new Error; + i.AddBody(e); + e.m_awakeFlag = !0; + if (e.GetType() !== t.b2BodyType.b2_staticBody) { + for (let t = e.m_contactList; t; t = t.next) { + const e = t.contact; + if (e.m_islandFlag) continue; + if (!e.IsEnabled() || !e.IsTouching()) continue; + const n = e.m_fixtureA.m_isSensor; + const o = e.m_fixtureB.m_isSensor; + if (n || o) continue; + i.AddContact(e); + e.m_islandFlag = !0; + const a = t.other; + if (!a.m_islandFlag) { + s[r++] = a; + a.m_islandFlag = !0; + } + } + for (let t = e.m_jointList; t; t = t.next) { + if (t.joint.m_islandFlag) continue; + const e = t.other; + if (e.IsActive()) { + i.AddJoint(t.joint); + t.joint.m_islandFlag = !0; + if (!e.m_islandFlag) { + s[r++] = e; + e.m_islandFlag = !0; + } + } + } + } + } + const o = new en; + i.Solve(o, e, this.m_gravity, this.m_allowSleep); + this.m_profile.solveInit += o.solveInit; + this.m_profile.solveVelocity += o.solveVelocity; + this.m_profile.solvePosition += o.solvePosition; + for (let e = 0; e < i.m_bodyCount; ++e) { + const s = i.m_bodies[e]; + s.GetType() === t.b2BodyType.b2_staticBody && (s.m_islandFlag = !1); + } + } + for (let t = 0; t < s.length && s[t]; ++t) s[t] = null; + const n = new Mt; + for (let e = this.m_bodyList; e; e = e.m_next) e.m_islandFlag && e.GetType() !== t.b2BodyType.b2_staticBody && e.SynchronizeFixtures(); + this.m_contactManager.FindNewContacts(); + this.m_profile.broadphase = n.GetMilliseconds(); + } + SolveTOI(e) { + const i = this.m_island; + i.Initialize(2 * m, m, 0, this.m_contactManager.m_contactListener); + if (this.m_stepComplete) { + for (let t = this.m_bodyList; t; t = t.m_next) { + t.m_islandFlag = !1; + t.m_sweep.alpha0 = 0; + } + for (let t = this.m_contactManager.m_contactList; t; t = t.m_next) { + t.m_toiFlag = !1; + t.m_islandFlag = !1; + t.m_toiCount = 0; + t.m_toi = 1; + } + } + for (;;) { + let s = null; + let r = 1; + for (let e = this.m_contactManager.m_contactList; e; e = e.m_next) { + if (!e.IsEnabled()) continue; + if (e.m_toiCount > p) continue; + let i = 1; + if (e.m_toiFlag) i = e.m_toi; else { + const s = e.GetFixtureA(); + const n = e.GetFixtureB(); + if (s.IsSensor() || n.IsSensor()) continue; + const r = s.GetBody(); + const o = n.GetBody(); + const a = r.m_type; + const l = o.m_type; + const h = r.IsAwake() && a !== t.b2BodyType.b2_staticBody; + const c = o.IsAwake() && l !== t.b2BodyType.b2_staticBody; + if (!h && !c) continue; + const u = r.IsBullet() || a !== t.b2BodyType.b2_dynamicBody; + const _ = o.IsBullet() || l !== t.b2BodyType.b2_dynamicBody; + if (!u && !_) continue; + let d = r.m_sweep.alpha0; + if (r.m_sweep.alpha0 < o.m_sweep.alpha0) { + d = o.m_sweep.alpha0; + r.m_sweep.Advance(d); + } else if (o.m_sweep.alpha0 < r.m_sweep.alpha0) { + d = r.m_sweep.alpha0; + o.m_sweep.Advance(d); + } + const p = e.GetChildIndexA(); + const m = e.GetChildIndexB(); + const f = sr.SolveTOI_s_toi_input; + f.proxyA.SetShape(s.GetShape(), p); + f.proxyB.SetShape(n.GetShape(), m); + f.sweepA.Copy(r.m_sweep); + f.sweepB.Copy(o.m_sweep); + f.tMax = 1; + const g = sr.SolveTOI_s_toi_output; + $e(g, f); + const y = g.t; + i = g.state === t.b2TOIOutputState.e_touching ? tt(d + (1 - d) * y, 1) : 1; + e.m_toi = i; + e.m_toiFlag = !0; + } + if (i < r) { + s = e; + r = i; + } + } + if (null === s || 1 - 10 * n < r) { + this.m_stepComplete = !0; + break; + } + const o = s.GetFixtureA(); + const a = s.GetFixtureB(); + const l = o.GetBody(); + const h = a.GetBody(); + const c = sr.SolveTOI_s_backup1.Copy(l.m_sweep); + const u = sr.SolveTOI_s_backup2.Copy(h.m_sweep); + l.Advance(r); + h.Advance(r); + s.Update(this.m_contactManager.m_contactListener); + s.m_toiFlag = !1; + ++s.m_toiCount; + if (!s.IsEnabled() || !s.IsTouching()) { + s.SetEnabled(!1); + l.m_sweep.Copy(c); + h.m_sweep.Copy(u); + l.SynchronizeTransform(); + h.SynchronizeTransform(); + continue; + } + l.SetAwake(!0); + h.SetAwake(!0); + i.Clear(); + i.AddBody(l); + i.AddBody(h); + i.AddContact(s); + l.m_islandFlag = !0; + h.m_islandFlag = !0; + s.m_islandFlag = !0; + for (let e = 0; e < 2; ++e) { + const s = 0 === e ? l : h; + if (s.m_type === t.b2BodyType.b2_dynamicBody) for (let e = s.m_contactList; e && i.m_bodyCount !== i.m_bodyCapacity && i.m_contactCount !== i.m_contactCapacity; e = e.next) { + const n = e.contact; + if (n.m_islandFlag) continue; + const o = e.other; + if (o.m_type === t.b2BodyType.b2_dynamicBody && !s.IsBullet() && !o.IsBullet()) continue; + const a = n.m_fixtureA.m_isSensor; + const l = n.m_fixtureB.m_isSensor; + if (a || l) continue; + const h = sr.SolveTOI_s_backup.Copy(o.m_sweep); + o.m_islandFlag || o.Advance(r); + n.Update(this.m_contactManager.m_contactListener); + if (n.IsEnabled()) if (n.IsTouching()) { + n.m_islandFlag = !0; + i.AddContact(n); + if (!o.m_islandFlag) { + o.m_islandFlag = !0; + o.m_type !== t.b2BodyType.b2_staticBody && o.SetAwake(!0); + i.AddBody(o); + } + } else { + o.m_sweep.Copy(h); + o.SynchronizeTransform(); + } else { + o.m_sweep.Copy(h); + o.SynchronizeTransform(); + } + } + } + const _ = sr.SolveTOI_s_subStep; + _.dt = (1 - r) * e.dt; + _.inv_dt = 1 / _.dt; + _.dtRatio = 1; + _.positionIterations = 20; + _.velocityIterations = e.velocityIterations; + _.particleIterations = e.particleIterations; + _.warmStarting = !1; + i.SolveTOI(_, l.m_islandIndex, h.m_islandIndex); + for (let e = 0; e < i.m_bodyCount; ++e) { + const s = i.m_bodies[e]; + s.m_islandFlag = !1; + if (s.m_type === t.b2BodyType.b2_dynamicBody) { + s.SynchronizeFixtures(); + for (let t = s.m_contactList; t; t = t.next) { + t.contact.m_toiFlag = !1; + t.contact.m_islandFlag = !1; + } + } + } + this.m_contactManager.FindNewContacts(); + if (this.m_subStepping) { + this.m_stepComplete = !1; + break; + } + } + } + AddController(t) { + t.m_next = this.m_controllerList; + t.m_prev = null; + this.m_controllerList && (this.m_controllerList.m_prev = t); + this.m_controllerList = t; + ++this.m_controllerCount; + return t; + } + RemoveController(t) { + t.m_prev && (t.m_prev.m_next = t.m_next); + t.m_next && (t.m_next.m_prev = t.m_prev); + this.m_controllerList === t && (this.m_controllerList = t.m_next); + --this.m_controllerCount; + t.m_prev = null; + t.m_next = null; + return t; + } + } + sr.Step_s_step = new sn; + sr.Step_s_stepTimer = new Mt; + sr.Step_s_timer = new Mt; + sr.DrawDebugData_s_color = new Rt(0, 0, 0); + sr.DrawDebugData_s_vs = St.MakeArray(4); + sr.DrawDebugData_s_xf = new xt; + sr.QueryFixtureShape_s_aabb = new ge; + sr.RayCast_s_input = new me; + sr.RayCast_s_output = new fe; + sr.RayCast_s_point = new St; + sr.DrawJoint_s_p1 = new St; + sr.DrawJoint_s_p2 = new St; + sr.DrawJoint_s_color = new Rt(.5, .8, .8); + sr.DrawJoint_s_c = new Rt; + sr.DrawShape_s_ghostColor = new Rt; + sr.SolveTOI_s_subStep = new sn; + sr.SolveTOI_s_backup = new wt; + sr.SolveTOI_s_backup1 = new wt; + sr.SolveTOI_s_backup2 = new wt; + sr.SolveTOI_s_toi_input = new Ge; + sr.SolveTOI_s_toi_output = new ze; + class nr { + constructor(t, e) { + this.prevBody = null; + this.nextBody = null; + this.prevController = null; + this.nextController = null; + this.controller = t; + this.body = e; + } + } + class rr { + constructor() { + this.m_bodyList = null; + this.m_bodyCount = 0; + this.m_prev = null; + this.m_next = null; + } + GetNext() { + return this.m_next; + } + GetPrev() { + return this.m_prev; + } + GetBodyList() { + return this.m_bodyList; + } + AddBody(t) { + const e = new nr(this, t); + e.nextBody = this.m_bodyList; + e.prevBody = null; + this.m_bodyList && (this.m_bodyList.prevBody = e); + this.m_bodyList = e; + ++this.m_bodyCount; + e.nextController = t.m_controllerList; + e.prevController = null; + t.m_controllerList && (t.m_controllerList.prevController = e); + t.m_controllerList = e; + ++t.m_controllerCount; + } + RemoveBody(t) { + if (this.m_bodyCount <= 0) throw new Error; + let e = this.m_bodyList; + for (;e && e.body !== t; ) e = e.nextBody; + if (null === e) throw new Error; + e.prevBody && (e.prevBody.nextBody = e.nextBody); + e.nextBody && (e.nextBody.prevBody = e.prevBody); + this.m_bodyList === e && (this.m_bodyList = e.nextBody); + --this.m_bodyCount; + e.nextController && (e.nextController.prevController = e.prevController); + e.prevController && (e.prevController.nextController = e.nextController); + t.m_controllerList === e && (t.m_controllerList = e.nextController); + --t.m_controllerCount; + } + Clear() { + for (;this.m_bodyList; ) this.RemoveBody(this.m_bodyList.body); + this.m_bodyCount = 0; + } + } + class or extends rr { + constructor() { + super(...arguments); + this.normal = new St(0, 1); + this.offset = 0; + this.density = 0; + this.velocity = new St(0, 0); + this.linearDrag = 0; + this.angularDrag = 0; + this.useDensity = !1; + this.useWorldGravity = !0; + this.gravity = new St(0, 0); + } + Step(t) { + if (this.m_bodyList) { + this.useWorldGravity && this.gravity.Copy(this.m_bodyList.body.GetWorld().GetGravity()); + for (let t = this.m_bodyList; t; t = t.nextBody) { + const e = t.body; + if (!e.IsAwake()) continue; + const i = new St; + const s = new St; + let r = 0; + let o = 0; + for (let t = e.GetFixtureList(); t; t = t.m_next) { + const n = new St; + const a = t.GetShape().ComputeSubmergedArea(this.normal, this.offset, e.GetTransform(), n); + r += a; + i.x += a * n.x; + i.y += a * n.y; + let l = 0; + l = this.useDensity ? t.GetDensity() : 1; + o += a * l; + s.x += a * n.x * l; + s.y += a * n.y * l; + } + i.x /= r; + i.y /= r; + s.x /= o; + s.y /= o; + if (r < n) continue; + const a = this.gravity.Clone().SelfNeg(); + a.SelfMul(this.density * r); + e.ApplyForce(a, s); + const l = e.GetLinearVelocityFromWorldPoint(i, new St); + l.SelfSub(this.velocity); + l.SelfMul(-this.linearDrag * r); + e.ApplyForce(l, i); + e.ApplyTorque(-e.GetInertia() / e.GetMass() * r * e.GetAngularVelocity() * this.angularDrag); + } + } + } + Draw(t) { + const e = 100; + const i = new St; + const s = new St; + i.x = this.normal.x * this.offset + this.normal.y * e; + i.y = this.normal.y * this.offset - this.normal.x * e; + s.x = this.normal.x * this.offset - this.normal.y * e; + s.y = this.normal.y * this.offset + this.normal.x * e; + const n = new Rt(0, 0, .8); + t.DrawSegment(i, s, n); + } + } + class ar extends rr { + constructor() { + super(...arguments); + this.A = new St(0, 0); + } + Step(t) { + const e = St.MulSV(t.dt, this.A, ar.Step_s_dtA); + for (let t = this.m_bodyList; t; t = t.nextBody) { + const i = t.body; + i.IsAwake() && i.SetLinearVelocity(St.AddVV(i.GetLinearVelocity(), e, St.s_t0)); + } + } + Draw(t) {} + } + ar.Step_s_dtA = new St; + class lr extends rr { + constructor() { + super(...arguments); + this.F = new St(0, 0); + } + Step(t) { + for (let t = this.m_bodyList; t; t = t.nextBody) { + const e = t.body; + e.IsAwake() && e.ApplyForce(this.F, e.GetWorldCenter()); + } + } + Draw(t) {} + } + class hr extends rr { + constructor() { + super(...arguments); + this.G = 1; + this.invSqr = !0; + } + Step(t) { + if (this.invSqr) for (let t = this.m_bodyList; t; t = t.nextBody) { + const e = t.body; + const i = e.GetWorldCenter(); + const s = e.GetMass(); + for (let r = this.m_bodyList; r && r !== t; r = r.nextBody) { + const t = r.body; + const o = t.GetWorldCenter(); + const a = t.GetMass(); + const l = o.x - i.x; + const h = o.y - i.y; + const c = l * l + h * h; + if (c < n) continue; + const u = hr.Step_s_f.Set(l, h); + u.SelfMul(this.G / c / at(c) * s * a); + e.IsAwake() && e.ApplyForce(u, i); + t.IsAwake() && t.ApplyForce(u.SelfMul(-1), o); + } + } else for (let t = this.m_bodyList; t; t = t.nextBody) { + const e = t.body; + const i = e.GetWorldCenter(); + const s = e.GetMass(); + for (let r = this.m_bodyList; r && r !== t; r = r.nextBody) { + const t = r.body; + const o = t.GetWorldCenter(); + const a = t.GetMass(); + const l = o.x - i.x; + const h = o.y - i.y; + const c = l * l + h * h; + if (c < n) continue; + const u = hr.Step_s_f.Set(l, h); + u.SelfMul(this.G / c * s * a); + e.IsAwake() && e.ApplyForce(u, i); + t.IsAwake() && t.ApplyForce(u.SelfMul(-1), o); + } + } + } + Draw(t) {} + } + hr.Step_s_f = new St; + class cr extends rr { + constructor() { + super(...arguments); + this.T = new vt; + this.maxTimestep = 0; + } + Step(t) { + let e = t.dt; + if (!(e <= n)) { + e > this.maxTimestep && this.maxTimestep > 0 && (e = this.maxTimestep); + for (let t = this.m_bodyList; t; t = t.nextBody) { + const i = t.body; + if (!i.IsAwake()) continue; + const s = i.GetWorldVector(vt.MulMV(this.T, i.GetLocalVector(i.GetLinearVelocity(), St.s_t0), St.s_t1), cr.Step_s_damping); + i.SetLinearVelocity(St.AddVV(i.GetLinearVelocity(), St.MulSV(e, s, St.s_t0), St.s_t1)); + } + } + } + Draw(t) {} + SetAxisAligned(t, e) { + this.T.ex.x = -t; + this.T.ex.y = 0; + this.T.ey.x = 0; + this.T.ey.y = -e; + this.maxTimestep = t > 0 || e > 0 ? 1 / et(t, e) : 0; + } + } + cr.Step_s_damping = new St; + class ur { + constructor() { + this.vertices = []; + this.count = 0; + this.masses = []; + this.gravity = new St(0, 0); + this.damping = .1; + this.k2 = .9; + this.k3 = .1; + } + } + class _r { + constructor() { + this.m_count = 0; + this.m_ps = []; + this.m_p0s = []; + this.m_vs = []; + this.m_ims = []; + this.m_Ls = []; + this.m_as = []; + this.m_gravity = new St; + this.m_damping = 0; + this.m_k2 = 1; + this.m_k3 = .1; + } + GetVertexCount() { + return this.m_count; + } + GetVertices() { + return this.m_ps; + } + Initialize(t) { + this.m_count = t.count; + this.m_ps = St.MakeArray(this.m_count); + this.m_p0s = St.MakeArray(this.m_count); + this.m_vs = St.MakeArray(this.m_count); + this.m_ims = K(this.m_count); + for (let e = 0; e < this.m_count; ++e) { + this.m_ps[e].Copy(t.vertices[e]); + this.m_p0s[e].Copy(t.vertices[e]); + this.m_vs[e].SetZero(); + const i = t.masses[e]; + this.m_ims[e] = i > 0 ? 1 / i : 0; + } + const e = this.m_count - 1; + const i = this.m_count - 2; + this.m_Ls = K(e); + this.m_as = K(i); + for (let t = 0; t < e; ++t) { + const e = this.m_ps[t]; + const i = this.m_ps[t + 1]; + this.m_Ls[t] = St.DistanceVV(e, i); + } + for (let t = 0; t < i; ++t) { + const e = this.m_ps[t]; + const i = this.m_ps[t + 1]; + const s = this.m_ps[t + 2]; + const n = St.SubVV(i, e, St.s_t0); + const r = St.SubVV(s, i, St.s_t1); + const o = St.CrossVV(n, r); + const a = St.DotVV(n, r); + this.m_as[t] = mt(o, a); + } + this.m_gravity.Copy(t.gravity); + this.m_damping = t.damping; + this.m_k2 = t.k2; + this.m_k3 = t.k3; + } + Step(t, e) { + if (0 === t) return; + const i = Math.exp(-t * this.m_damping); + for (let e = 0; e < this.m_count; ++e) { + this.m_p0s[e].Copy(this.m_ps[e]); + this.m_ims[e] > 0 && this.m_vs[e].SelfMulAdd(t, this.m_gravity); + this.m_vs[e].SelfMul(i); + this.m_ps[e].SelfMulAdd(t, this.m_vs[e]); + } + for (let t = 0; t < e; ++t) { + this.SolveC2(); + this.SolveC3(); + this.SolveC2(); + } + const s = 1 / t; + for (let t = 0; t < this.m_count; ++t) St.MulSV(s, St.SubVV(this.m_ps[t], this.m_p0s[t], St.s_t0), this.m_vs[t]); + } + SolveC2() { + const t = this.m_count - 1; + for (let e = 0; e < t; ++e) { + const t = this.m_ps[e]; + const i = this.m_ps[e + 1]; + const s = St.SubVV(i, t, _r.s_d); + const n = s.Normalize(); + const r = this.m_ims[e]; + const o = this.m_ims[e + 1]; + if (r + o === 0) continue; + const a = r / (r + o); + const l = o / (r + o); + t.SelfMulSub(this.m_k2 * a * (this.m_Ls[e] - n), s); + i.SelfMulAdd(this.m_k2 * l * (this.m_Ls[e] - n), s); + } + } + SetAngle(t) { + const e = this.m_count - 2; + for (let i = 0; i < e; ++i) this.m_as[i] = t; + } + SolveC3() { + const t = this.m_count - 2; + for (let e = 0; e < t; ++e) { + const t = this.m_ps[e]; + const i = this.m_ps[e + 1]; + const s = this.m_ps[e + 2]; + const n = this.m_ims[e]; + const r = this.m_ims[e + 1]; + const a = this.m_ims[e + 2]; + const l = St.SubVV(i, t, _r.s_d1); + const h = St.SubVV(s, i, _r.s_d2); + const c = l.LengthSquared(); + const u = h.LengthSquared(); + if (c * u == 0) continue; + const _ = St.CrossVV(l, h); + const d = St.DotVV(l, h); + let p = mt(_, d); + const m = St.MulSV(-1 / c, l.SelfSkew(), _r.s_Jd1); + const f = St.MulSV(1 / u, h.SelfSkew(), _r.s_Jd2); + const g = St.NegV(m, _r.s_J1); + const y = St.SubVV(m, f, _r.s_J2); + const b = f; + let S = n * St.DotVV(g, g) + r * St.DotVV(y, y) + a * St.DotVV(b, b); + if (0 === S) continue; + S = 1 / S; + let A = p - this.m_as[e]; + for (;A > o; ) { + p -= 2 * o; + A = p - this.m_as[e]; + } + for (;A < -o; ) { + p += 2 * o; + A = p - this.m_as[e]; + } + const T = -this.m_k3 * S * A; + t.SelfMulAdd(n * T, g); + i.SelfMulAdd(r * T, y); + s.SelfMulAdd(a * T, b); + } + } + Draw(t) { + const e = new Rt(.4, .5, .7); + for (let i = 0; i < this.m_count - 1; ++i) t.DrawSegment(this.m_ps[i], this.m_ps[i + 1], e); + } + } + _r.s_d = new St; + _r.s_d1 = new St; + _r.s_d2 = new St; + _r.s_Jd1 = new St; + _r.s_Jd2 = new St; + _r.s_J1 = new St; + _r.s_J2 = new St; + t.b2AABB = ge; + t.b2Abs = $; + t.b2Acos = dt; + t.b2Alloc = V; + t.b2AreaJoint = ds; + t.b2AreaJointDef = _s; + t.b2Asin = pt; + t.b2Assert = e; + t.b2Atan2 = mt; + t.b2BlockAllocator = Pt; + t.b2Body = rs; + t.b2BodyDef = ns; + t.b2BroadPhase = Be; + t.b2BuoyancyController = or; + t.b2CalculateParticleIterations = fn; + t.b2ChainAndCircleContact = js; + t.b2ChainAndPolygonContact = Xs; + t.b2ChainShape = $i; + t.b2CircleContact = ks; + t.b2CircleShape = Ji; + t.b2Clamp = it; + t.b2ClipSegmentToLine = be; + t.b2ClipVertex = pe; + t.b2CollideCircles = ii; + t.b2CollideEdgeAndCircle = ki; + t.b2CollideEdgeAndPolygon = Yi; + t.b2CollidePolygonAndCircle = oi; + t.b2CollidePolygons = Mi; + t.b2Color = Rt; + t.b2ConstantAccelController = ar; + t.b2ConstantForceController = lr; + t.b2Contact = Vs; + t.b2ContactEdge = Fs; + t.b2ContactFactory = Ys; + t.b2ContactFeature = le; + t.b2ContactFilter = Ks; + t.b2ContactID = he; + t.b2ContactImpulse = Js; + t.b2ContactListener = Zs; + t.b2ContactManager = tn; + t.b2ContactPositionConstraint = cn; + t.b2ContactRegister = Ws; + t.b2ContactSolver = dn; + t.b2ContactSolverDef = un; + t.b2ContactVelocityConstraint = hn; + t.b2Controller = rr; + t.b2ControllerEdge = nr; + t.b2Cos = ut; + t.b2Counter = Bt; + t.b2DegToRad = ht; + t.b2DestructionListener = qs; + t.b2Distance = Qt; + t.b2DistanceInput = Ft; + t.b2DistanceJoint = us; + t.b2DistanceJointDef = cs; + t.b2DistanceOutput = Vt; + t.b2DistanceProxy = Nt; + t.b2Draw = It; + t.b2DynamicTree = xe; + t.b2EdgeAndCircleContact = zs; + t.b2EdgeAndPolygonContact = Hs; + t.b2EdgeShape = Qi; + t.b2Filter = ts; + t.b2Fixture = ss; + t.b2FixtureDef = es; + t.b2FixtureParticleQueryCallback = On; + t.b2FixtureProxy = is; + t.b2Free = k; + t.b2FrictionJoint = ms; + t.b2FrictionJointDef = ps; + t.b2GearJoint = gs; + t.b2GearJointDef = fs; + t.b2GetPointStates = de; + t.b2GravityController = hr; + t.b2GrowableBuffer = Pn; + t.b2GrowableStack = Dt; + t.b2InvSqrt = ot; + t.b2IsPowerOfTwo = gt; + t.b2IsValid = nt; + t.b2Island = pn; + t.b2Jacobian = os; + t.b2Joint = hs; + t.b2JointDef = ls; + t.b2JointEdge = as; + t.b2Log = U; + t.b2MakeArray = Y; + t.b2MakeNullArray = q; + t.b2MakeNumberArray = K; + t.b2Manifold = ue; + t.b2ManifoldPoint = ce; + t.b2MassData = qi; + t.b2Mat22 = vt; + t.b2Mat33 = Et; + t.b2Max = et; + t.b2Maybe = i; + t.b2Min = tt; + t.b2MixFriction = Ns; + t.b2MixRestitution = Ls; + t.b2MotorJoint = bs; + t.b2MotorJointDef = ys; + t.b2MouseJoint = As; + t.b2MouseJointDef = Ss; + t.b2NextPowerOfTwo = ft; + t.b2Pair = Me; + t.b2PairLessThan = De; + t.b2ParseInt = X; + t.b2ParseUInt = W; + t.b2ParticleBodyContact = Ln; + t.b2ParticleContact = Nn; + t.b2ParticleDef = mn; + t.b2ParticleGroup = bn; + t.b2ParticleGroupDef = yn; + t.b2ParticleHandle = gn; + t.b2ParticlePair = Fn; + t.b2ParticlePairSet = Kn; + t.b2ParticleSystem = Un; + t.b2ParticleSystemDef = kn; + t.b2ParticleSystem_CompositeShape = $n; + t.b2ParticleSystem_ConnectionFilter = Jn; + t.b2ParticleSystem_DestroyParticlesInShapeCallback = Zn; + t.b2ParticleSystem_FixedSetAllocator = Xn; + t.b2ParticleSystem_FixtureParticle = Wn; + t.b2ParticleSystem_FixtureParticleSet = Yn; + t.b2ParticleSystem_InsideBoundsEnumerator = Hn; + t.b2ParticleSystem_JoinParticleGroupsFilter = Qn; + t.b2ParticleSystem_ParticleListNode = jn; + t.b2ParticleSystem_ParticlePair = qn; + t.b2ParticleSystem_Proxy = zn; + t.b2ParticleSystem_ReactiveFilter = tr; + t.b2ParticleSystem_SolveCollisionCallback = ir; + t.b2ParticleSystem_UpdateBodyContactsCallback = er; + t.b2ParticleSystem_UserOverridableBuffer = Gn; + t.b2ParticleTriad = Vn; + t.b2PolygonAndCircleContact = Gs; + t.b2PolygonContact = Us; + t.b2PolygonShape = Zi; + t.b2Position = nn; + t.b2PositionSolverManifold = _n; + t.b2Pow = lt; + t.b2PrismaticJoint = vs; + t.b2PrismaticJointDef = Ts; + t.b2Profile = en; + t.b2PulleyJoint = xs; + t.b2PulleyJointDef = Cs; + t.b2QueryCallback = Qs; + t.b2RadToDeg = ct; + t.b2Random = yt; + t.b2RandomRange = bt; + t.b2RayCastCallback = $s; + t.b2RayCastInput = me; + t.b2RayCastOutput = fe; + t.b2RevoluteJoint = Rs; + t.b2RevoluteJointDef = ws; + t.b2Rope = _r; + t.b2RopeDef = ur; + t.b2RopeJoint = Ms; + t.b2RopeJointDef = Is; + t.b2Rot = Ct; + t.b2SeparationFunction = He; + t.b2Shape = Ki; + t.b2ShapeCast = ae; + t.b2ShapeCastInput = kt; + t.b2ShapeCastOutput = Ut; + t.b2Simplex = Ht; + t.b2SimplexCache = Lt; + t.b2SimplexVertex = zt; + t.b2Sin = _t; + t.b2SolverData = on; + t.b2Sq = rt; + t.b2Sqrt = at; + t.b2StackAllocator = Ot; + t.b2Swap = st; + t.b2Sweep = wt; + t.b2TOIInput = Ge; + t.b2TOIOutput = ze; + t.b2TensorDampingController = cr; + t.b2TestOverlapAABB = ye; + t.b2TestOverlapShape = ve; + t.b2TimeOfImpact = $e; + t.b2TimeStep = sn; + t.b2Timer = Mt; + t.b2Transform = xt; + t.b2TreeNode = Ce; + t.b2Vec2 = St; + t.b2Vec2_zero = At; + t.b2Vec3 = Tt; + t.b2Velocity = rn; + t.b2VelocityConstraintPoint = ln; + t.b2Version = G; + t.b2WeldJoint = Ds; + t.b2WeldJointDef = Bs; + t.b2WheelJoint = Os; + t.b2WheelJointDef = Ps; + t.b2World = sr; + t.b2WorldManifold = _e; + t.b2_180_over_pi = Z; + t.b2_aabbExtension = h; + t.b2_aabbMultiplier = c; + t.b2_angularSleepTolerance = F; + t.b2_angularSlop = _; + t.b2_barrierCollisionTime = O; + t.b2_baumgarte = v; + t.b2_branch = H; + t.b2_commit = j; + t.b2_epsilon = n; + t.b2_epsilon_sq = r; + t.b2_gjk_reset = Gt; + t.b2_invalidParticleIndex = C; + t.b2_linearSleepTolerance = L; + t.b2_linearSlop = u; + t.b2_maxAngularCorrection = y; + t.b2_maxFloat = s; + t.b2_maxLinearCorrection = g; + t.b2_maxManifoldPoints = a; + t.b2_maxParticleForce = M; + t.b2_maxParticleIndex = x; + t.b2_maxParticlePressure = I; + t.b2_maxPolygonVertices = l; + t.b2_maxRotation = A; + t.b2_maxRotationSquared = T; + t.b2_maxSubSteps = p; + t.b2_maxTOIContacts = m; + t.b2_maxTranslation = b; + t.b2_maxTranslationSquared = S; + t.b2_maxTriadDistance = B; + t.b2_maxTriadDistanceSquared = D; + t.b2_minParticleSystemBufferCapacity = P; + t.b2_minParticleWeight = R; + t.b2_minPulleyLength = Es; + t.b2_particleStride = w; + t.b2_pi = o; + t.b2_pi_over_180 = J; + t.b2_polygonRadius = d; + t.b2_timeToSleep = N; + t.b2_toiBaumgarte = E; + t.b2_toi_reset = Pe; + t.b2_two_pi = Q; + t.b2_velocityThreshold = f; + t.b2_version = z; + t.g_blockSolve = an; + Object.defineProperty(t, "__esModule", { + value: !0 + }); + }(e); + })); + (fbt = mbt) && fbt.__esModule && Object.prototype.hasOwnProperty.call(fbt, "default") && fbt.default; + var fbt; + let gbt = {}; + for (var ybt in mbt) { + if (-1 !== ybt.indexOf("b2_")) continue; + gbt[ybt.replace("b2", "")] = mbt[ybt]; + } + var bbt = gbt; + let Sbt; + !function(t) { + t[t.Static = 0] = "Static"; + t[t.Kinematic = 1] = "Kinematic"; + t[t.Dynamic = 2] = "Dynamic"; + t[t.Animated = 3] = "Animated"; + }(Sbt || (Sbt = t("ERigidBody2DType", {}))); + oe(Sbt); + let Abt; + !function(t) { + t[t.None = 0] = "None"; + t[t.BOX = 1] = "BOX"; + t[t.CIRCLE = 2] = "CIRCLE"; + t[t.POLYGON = 3] = "POLYGON"; + }(Abt || (Abt = t("ECollider2DType", {}))); + oe(Abt); + let Tbt; + !function(t) { + t[t.None = 0] = "None"; + t[t.DISTANCE = 1] = "DISTANCE"; + t[t.SPRING = 2] = "SPRING"; + t[t.WHEEL = 3] = "WHEEL"; + t[t.MOUSE = 4] = "MOUSE"; + t[t.FIXED = 5] = "FIXED"; + t[t.SLIDER = 6] = "SLIDER"; + t[t.RELATIVE = 7] = "RELATIVE"; + t[t.HINGE = 8] = "HINGE"; + }(Tbt || (Tbt = t("EJoint2DType", {}))); + oe(Tbt); + let vbt; + !function(t) { + t[t.DEFAULT = 1] = "DEFAULT"; + }(vbt || (vbt = t("PhysicsGroup", {}))); + oe(vbt); + let Ebt; + !function(t) { + t[t.Closest = 0] = "Closest"; + t[t.Any = 1] = "Any"; + t[t.AllClosest = 2] = "AllClosest"; + t[t.All = 3] = "All"; + }(Ebt || (Ebt = t("ERaycast2DType", {}))); + const Cbt = t("Contact2DType", { + None: "none-contact", + BEGIN_CONTACT: "begin-contact", + END_CONTACT: "end-contact", + PRE_SOLVE: "pre-solve", + POST_SOLVE: "post-solve" + }); + let xbt; + !function(t) { + t[t.None = 0] = "None"; + t[t.Shape = 1] = "Shape"; + t[t.Joint = 2] = "Joint"; + t[t.Aabb = 4] = "Aabb"; + t[t.Pair = 8] = "Pair"; + t[t.CenterOfMass = 16] = "CenterOfMass"; + t[t.Particle = 32] = "Particle"; + t[t.Controller = 64] = "Controller"; + t[t.All = 63] = "All"; + }(xbt || (xbt = t("EPhysics2DDrawFlags", {}))); + const wbt = t("PHYSICS_2D_PTM_RATIO", 32); + class Rbt extends bbt.ContactListener { + constructor(...t) { + super(...t); + this._contactFixtures = []; + this._BeginContact = null; + this._EndContact = null; + this._PreSolve = null; + this._PostSolve = null; + } + setBeginContact(t) { + this._BeginContact = t; + } + setEndContact(t) { + this._EndContact = t; + } + setPreSolve(t) { + this._PreSolve = t; + } + setPostSolve(t) { + this._PostSolve = t; + } + BeginContact(t) { + if (!this._BeginContact) return; + const e = t.GetFixtureA(); + const i = t.GetFixtureB(); + const s = this._contactFixtures; + t._shouldReport = !1; + if (-1 !== s.indexOf(e) || -1 !== s.indexOf(i)) { + t._shouldReport = !0; + this._BeginContact(t); + } + } + EndContact(t) { + if (this._EndContact && t._shouldReport) { + t._shouldReport = !1; + this._EndContact(t); + } + } + PreSolve(t, e) { + this._PreSolve && t._shouldReport && this._PreSolve(t, e); + } + PostSolve(t, e) { + this._PostSolve && t._shouldReport && this._PostSolve(t, e); + } + registerContactFixture(t) { + this._contactFixtures.push(t); + } + unregisterContactFixture(t) { + at(this._contactFixtures, t); + } + } + class Ibt extends bbt.QueryCallback { + constructor(...t) { + super(...t); + this._point = new bbt.Vec2; + this._isPoint = !1; + this._fixtures = []; + } + init(t) { + if (t) { + this._isPoint = !0; + this._point.x = t.x; + this._point.y = t.y; + } else this._isPoint = !1; + this._fixtures.length = 0; + } + ReportFixture(t) { + this._isPoint ? t.TestPoint(this._point) && this._fixtures.push(t) : this._fixtures.push(t); + return !0; + } + getFixture() { + return this._fixtures[0]; + } + getFixtures() { + return this._fixtures; + } + } + function Mbt(t, e) { + const i = e.length; + return e[t < 0 ? i - -t % i : t % i]; + } + function Bbt(t, e, i) { + const s = []; + for (;e < t; ) e += i.length; + for (;t <= e; ++t) s.push(Mbt(t, i)); + return s; + } + function Dbt(t) { + Ubt(t); + let e = []; + let i; + let s; + let n; + let r; + let o = new Qi; + let a = new Qi; + let l = 0; + let h = 0; + let c; + let u; + for (let _ = 0; _ < t.length; ++_) if (Obt(_, t)) { + s = n = 1e8; + for (let e = 0; e < t.length; ++e) { + if (Lbt(Mbt(_ - 1, t), Mbt(_, t), Mbt(e, t)) && Vbt(Mbt(_ - 1, t), Mbt(_, t), Mbt(e - 1, t))) { + r = zbt(Mbt(_ - 1, t), Mbt(_, t), Mbt(e, t), Mbt(e - 1, t)); + if (Nbt(Mbt(_ + 1, t), Mbt(_, t), r)) { + i = kbt(Mbt(_, t), r); + if (i < s) { + s = i; + o = r; + l = e; + } + } + } + if (Lbt(Mbt(_ + 1, t), Mbt(_, t), Mbt(e + 1, t)) && Vbt(Mbt(_ + 1, t), Mbt(_, t), Mbt(e, t))) { + r = zbt(Mbt(_ + 1, t), Mbt(_, t), Mbt(e, t), Mbt(e + 1, t)); + if (Lbt(Mbt(_ - 1, t), Mbt(_, t), r)) { + i = kbt(Mbt(_, t), r); + if (i < n) { + n = i; + h = e; + a = r; + } + } + } + } + if (l == (h + 1) % t.length) { + const e = o.add(a).multiplyScalar(.5); + c = Bbt(_, h, t); + c.push(e); + u = Bbt(l, _, t); + u.push(e); + } else { + let e = 0; + let i = l; + for (;h < l; ) h += t.length; + for (let s = l; s <= h; ++s) if (Pbt(_, s, t)) { + let n = 1 / (kbt(Mbt(_, t), Mbt(s, t)) + 1); + Obt(s, t) ? Vbt(Mbt(s - 1, t), Mbt(s, t), Mbt(_, t)) && Fbt(Mbt(s + 1, t), Mbt(s, t), Mbt(_, t)) ? n += 3 : n += 2 : n += 1; + if (n > e) { + i = s; + e = n; + } + } + c = Bbt(_, i, t); + u = Bbt(i, _, t); + } + e = e.concat(Dbt(c)); + e = e.concat(Dbt(u)); + return e; + } + e.push(t); + for (let t = e.length - 1; t >= 0; t--) 0 == e[t].length && e.splice(t, 0); + return e; + } + function Pbt(t, e, i) { + if (Obt(t, i)) { + if (Fbt(Mbt(t, i), Mbt(t - 1, i), Mbt(e, i)) && Vbt(Mbt(t, i), Mbt(t + 1, i), Mbt(e, i))) return !1; + } else if (Vbt(Mbt(t, i), Mbt(t + 1, i), Mbt(e, i)) || Fbt(Mbt(t, i), Mbt(t - 1, i), Mbt(e, i))) return !1; + if (Obt(e, i)) { + if (Fbt(Mbt(e, i), Mbt(e - 1, i), Mbt(t, i)) && Vbt(Mbt(e, i), Mbt(e + 1, i), Mbt(t, i))) return !1; + } else if (Vbt(Mbt(e, i), Mbt(e + 1, i), Mbt(t, i)) || Fbt(Mbt(e, i), Mbt(e - 1, i), Mbt(t, i))) return !1; + for (let s = 0; s < i.length; ++s) { + if ((s + 1) % i.length == t || s == t || (s + 1) % i.length == e || s == e) continue; + const n = new Qi; + if (Hbt(Mbt(t, i), Mbt(e, i), Mbt(s, i), Mbt(s + 1, i), n)) return !1; + } + return !0; + } + function Obt(t, e) { + return Nbt(t, e); + } + function Nbt(t, e, i) { + if (void 0 === i) { + const s = t; + const n = e; + t = Mbt(s - 1, n); + e = Mbt(s, n); + void 0 === t && (t = e); + void 0 === (i = Mbt(s + 1, n)) && (i = e); + } + return jbt(t, e, i) < 0; + } + function Lbt(t, e, i) { + return jbt(t, e, i) > 0; + } + function Fbt(t, e, i) { + return jbt(t, e, i) >= 0; + } + function Vbt(t, e, i) { + return jbt(t, e, i) <= 0; + } + function kbt(t, e) { + const i = e.x - t.x; + const s = e.y - t.y; + return i * i + s * s; + } + function Ubt(t) { + Gbt(t) || t.reverse(); + } + function Gbt(t) { + return t.length < 3 || function(t) { + let e; + let i = 0; + for (e = 0; e < t.length; e++) { + const s = (e + 1) % t.length; + i += t[e].x * t[s].y; + i -= t[e].y * t[s].x; + } + i /= 2; + return i; + }(t) > 0; + } + function zbt(t, e, i, s) { + const n = new Qi; + const r = e.y - t.y; + const o = t.x - e.x; + const a = r * t.x + o * t.y; + const l = s.y - i.y; + const h = i.x - s.x; + const c = l * i.x + h * i.y; + const u = r * h - l * o; + if (!(_ = u, d = 0, Math.abs(_ - d) <= 1e-6)) { + n.x = (h * a - o * c) / u; + n.y = (r * c - l * a) / u; + } + var _, d; + return n; + } + function Hbt(t, e, i, s, n) { + if (t == i || t == s || e == i || e == s) return !1; + const r = t.x; + const o = t.y; + const a = e.x; + const l = e.y; + const h = i.x; + const c = i.y; + const u = s.x; + const _ = s.y; + if (Math.max(r, a) < Math.min(h, u) || Math.max(h, u) < Math.min(r, a)) return !1; + if (Math.max(o, l) < Math.min(c, _) || Math.max(c, _) < Math.min(o, l)) return !1; + let d = (u - h) * (o - c) - (_ - c) * (r - h); + let p = (a - r) * (o - c) - (l - o) * (r - h); + const m = (_ - c) * (a - r) - (u - h) * (l - o); + if (Math.abs(m) < 1e-6) return !1; + d /= m; + p /= m; + if (d > 0 && d < 1 && p > 0 && p < 1) { + n.x = r + d * (a - r); + n.y = o + d * (l - o); + return !0; + } + return !1; + } + function jbt(t, e, i) { + return t.x * (e.y - i.y) + e.x * (i.y - t.y) + i.x * (t.y - e.y); + } + var Xbt = Object.freeze({ + __proto__: null, + ConvexPartition: Dbt, + ForceCounterClockWise: Ubt, + IsCounterClockWise: Gbt + }); + const Wbt = (...t) => 0; + function Ybt(t) { + if (null == t) { + F(9600); + return !0; + } + return !1; + } + const qbt = { + impl: null, + rigidBody: null, + isAwake: !1, + isSleeping: !1, + initialize: Wbt, + setType: Wbt, + setLinearDamping: Wbt, + setAngularDamping: Wbt, + setGravityScale: Wbt, + setFixedRotation: Wbt, + setAllowSleep: Wbt, + isActive: Wbt, + setActive: Wbt, + wakeUp: Wbt, + sleep: Wbt, + getMass: Wbt, + getInertia: Wbt, + getLinearVelocity: Wbt, + setLinearVelocity: Wbt, + getLinearVelocityFromWorldPoint: Wbt, + getAngularVelocity: Wbt, + setAngularVelocity: Wbt, + getLocalVector: Wbt, + getWorldVector: Wbt, + getLocalPoint: Wbt, + getWorldPoint: Wbt, + getLocalCenter: Wbt, + getWorldCenter: Wbt, + applyForce: Wbt, + applyForceToCenter: Wbt, + applyTorque: Wbt, + applyLinearImpulse: Wbt, + applyLinearImpulseToCenter: Wbt, + applyAngularImpulse: Wbt, + onEnable: Wbt, + onDisable: Wbt, + onDestroy: Wbt + }; + const Kbt = { + INITED: !1 + }; + const Jbt = { + impl: null, + collider: null, + worldAABB: null, + worldPoints: null, + worldPosition: null, + worldRadius: null, + initialize: Wbt, + apply: Wbt, + onLoad: Wbt, + onEnable: Wbt, + onDisable: Wbt, + onDestroy: Wbt, + onGroupChanged: Wbt + }; + function Zbt(t) { + !function() { + if (Kbt.INITED) return; + Kbt.INITED = !0; + Kbt[Abt.BOX] = function() { + return Ybt(dbt.BoxShape) ? Jbt : new dbt.BoxShape; + }; + Kbt[Abt.CIRCLE] = function() { + return Ybt(dbt.CircleShape) ? Jbt : new dbt.CircleShape; + }; + Kbt[Abt.POLYGON] = function() { + return Ybt(dbt.PolygonShape) ? Jbt : new dbt.PolygonShape; + }; + }(); + return Kbt[t](); + } + const Qbt = { + INITED: !1 + }; + const $bt = { + impl: null, + initialize: Wbt, + setDampingRatio: Wbt, + setFrequency: Wbt, + setMaxForce: Wbt, + setTarget: Wbt, + setDistance: Wbt, + setAngularOffset: Wbt, + setCorrectionFactor: Wbt, + setLinearOffset: Wbt, + setMaxLength: Wbt, + setMaxTorque: Wbt, + setLowerLimit: Wbt, + setUpperLimit: Wbt, + setMaxMotorForce: Wbt, + setMaxMotorTorque: Wbt, + setMotorSpeed: Wbt, + enableLimit: Wbt, + enableMotor: Wbt, + setLowerAngle: Wbt, + setUpperAngle: Wbt + }; + function tSt(t) { + !function() { + if (Qbt.INITED) return; + Qbt.INITED = !0; + const t = m._global.CC_PHYSICS_2D_BUILTIN; + Qbt[Tbt.SPRING] = function() { + return t || Ybt(dbt.SpringJoint) ? $bt : new dbt.SpringJoint; + }; + Qbt[Tbt.DISTANCE] = function() { + return t || Ybt(dbt.DistanceJoint) ? $bt : new dbt.DistanceJoint; + }; + Qbt[Tbt.FIXED] = function() { + return t || Ybt(dbt.FixedJoint) ? $bt : new dbt.FixedJoint; + }; + Qbt[Tbt.MOUSE] = function() { + return t || Ybt(dbt.MouseJoint) ? $bt : new dbt.MouseJoint; + }; + Qbt[Tbt.RELATIVE] = function() { + return t || Ybt(dbt.RelativeJoint) ? $bt : new dbt.RelativeJoint; + }; + Qbt[Tbt.SLIDER] = function() { + return t || Ybt(dbt.SliderJoint) ? $bt : new dbt.SliderJoint; + }; + Qbt[Tbt.WHEEL] = function() { + return t || Ybt(dbt.WheelJoint) ? $bt : new dbt.WheelJoint; + }; + Qbt[Tbt.HINGE] = function() { + return t || Ybt(dbt.HingeJoint) ? $bt : new dbt.HingeJoint; + }; + }(); + return Qbt[t](); + } + let eSt; + !function(t) { + t[t.DYNAMIC = 1] = "DYNAMIC"; + t[t.STATIC = 2] = "STATIC"; + t[t.KINEMATIC = 4] = "KINEMATIC"; + }(eSt || (eSt = t("ERigidBodyType", {}))); + oe(eSt); + let iSt; + !function(t) { + t[t.X_AXIS = 0] = "X_AXIS"; + t[t.Y_AXIS = 1] = "Y_AXIS"; + t[t.Z_AXIS = 2] = "Z_AXIS"; + }(iSt || (iSt = t("EAxisDirection", {}))); + oe(iSt); + let sSt; + !function(t) { + t[t.VERTEX = 1] = "VERTEX"; + t[t.LINE = 2] = "LINE"; + t[t.TRIANGLE = 3] = "TRIANGLE"; + t[t.TETRAHEDRON = 4] = "TETRAHEDRON"; + }(sSt || (sSt = {})); + oe(sSt); + let nSt; + !function(t) { + t[t.BOX = 0] = "BOX"; + t[t.SPHERE = 1] = "SPHERE"; + t[t.CAPSULE = 2] = "CAPSULE"; + t[t.CYLINDER = 3] = "CYLINDER"; + t[t.CONE = 4] = "CONE"; + t[t.MESH = 5] = "MESH"; + t[t.PLANE = 6] = "PLANE"; + t[t.SIMPLEX = 7] = "SIMPLEX"; + t[t.TERRAIN = 8] = "TERRAIN"; + }(nSt || (nSt = {})); + oe(nSt); + let rSt; + !function(t) { + t[t.POINT_TO_POINT = 0] = "POINT_TO_POINT"; + t[t.HINGE = 1] = "HINGE"; + t[t.CONE_TWIST = 2] = "CONE_TWIST"; + }(rSt || (rSt = {})); + oe(rSt); + let oSt; + !function(t) { + t[t.DEFAULT = 1] = "DEFAULT"; + }(oSt || (oSt = {})); + oe(oSt); + class aSt { + constructor(t) { + if (1 === t) { + const t = this; + for (let e = 0; e < 32; e++) { + const i = "_" + (1 << e); + t[i] = 0; + t.updateArray = []; + Object.defineProperty(t, 1 << e, { + get() { + return this[i]; + }, + set(t) { + if (this[i] !== t) { + this[i] = t; + this.updateArray.indexOf(e) < 0 && this.updateArray.push(e); + } + } + }); + } + this._1 = oSt.DEFAULT; + } else { + for (let t = 0; t < 32; t++) { + this[`${1 << t}`] = 0; + } + this[1] = oSt.DEFAULT; + } + } + } + let lSt = null; + m.internal.PhysicsGroup2D = vbt; + class hSt extends(To(Tg)){ + get enable() { + return this._enable; + } + set enable(t) { + this._enable = t; + } + get allowSleep() { + return this._allowSleep; + } + set allowSleep(t) { + this._allowSleep = t; + this.physicsWorld.setAllowSleep(t); + } + get gravity() { + return this._gravity; + } + set gravity(t) { + this._gravity.set(t); + this.physicsWorld.setGravity(new Qi(t.x / wbt, t.y / wbt)); + } + get maxSubSteps() { + return this._maxSubSteps; + } + set maxSubSteps(t) { + this._maxSubSteps = t; + } + get fixedTimeStep() { + return this._fixedTimeStep; + } + set fixedTimeStep(t) { + this._fixedTimeStep = t; + } + get autoSimulation() { + return this._autoSimulation; + } + set autoSimulation(t) { + this._autoSimulation = t; + } + get debugDrawFlags() { + return this.physicsWorld.debugDrawFlags; + } + set debugDrawFlags(t) { + this.physicsWorld.debugDrawFlags = t; + } + static get PHYSICS_NONE() { + return !pbt; + } + static get PHYSICS_BUILTIN() { + return "builtin" === pbt; + } + static get PHYSICS_BOX2D() { + return "box2d" === pbt; + } + static get PhysicsGroup() { + return vbt; + } + static get instance() { + lSt || (lSt = new hSt); + return lSt; + } + get stepping() { + return this._steping; + } + constructor() { + var t, e, i, s; + super(); + this.velocityIterations = 10; + this.positionIterations = 10; + this.physicsWorld = void 0; + this.collisionMatrix = new aSt; + this._enable = !0; + this._allowSleep = !0; + this._maxSubSteps = 1; + this._fixedTimeStep = 1 / 60; + this._autoSimulation = !0; + this._accumulator = 0; + this._steping = !1; + this._gravity = new Qi(0, -10 * wbt); + this._delayEvents = []; + const n = de.querySettings(_e.Category.PHYSICS, "gravity"); + if (n) { + Qi.copy(this._gravity, n); + this._gravity.multiplyScalar(wbt); + } + this._allowSleep = null !== (t = de.querySettings(_e.Category.PHYSICS, "allowSleep")) && void 0 !== t ? t : this._allowSleep; + this._fixedTimeStep = null !== (e = de.querySettings(_e.Category.PHYSICS, "fixedTimeStep")) && void 0 !== e ? e : this._fixedTimeStep; + this._maxSubSteps = null !== (i = de.querySettings(_e.Category.PHYSICS, "maxSubSteps")) && void 0 !== i ? i : this._maxSubSteps; + this._autoSimulation = null !== (s = de.querySettings(_e.Category.PHYSICS, "autoSimulation")) && void 0 !== s ? s : this._autoSimulation; + const r = de.querySettings(_e.Category.PHYSICS, "collisionMatrix"); + if (r) for (const t in r) { + const e = parseInt(t); + const i = 1 << parseInt(t); + this.collisionMatrix[`${i}`] = r[e]; + } + const o = de.querySettings(_e.Category.PHYSICS, "collisionGroups"); + if (o) { + const t = o; + if (t instanceof Array) { + t.forEach((t => { + vbt[t.name] = 1 << t.index; + })); + oe.update(vbt); + } + } + this.physicsWorld = Ybt(dbt.PhysicsWorld) ? null : new dbt.PhysicsWorld; + this.gravity = this._gravity; + this.allowSleep = this._allowSleep; + } + postUpdate(t) { + if (!this._enable) return; + if (!this._autoSimulation) return; + IR.emit(RR.EVENT_BEFORE_PHYSICS); + this._steping = !0; + const e = this._fixedTimeStep; + const i = this.velocityIterations; + const s = this.positionIterations; + this._accumulator += t; + let n = 0; + for (;n++ < this._maxSubSteps && this._accumulator > e; ) { + this.physicsWorld.step(e, i, s); + this._accumulator -= e; + } + const r = this._delayEvents; + for (let t = 0, e = r.length; t < e; t++) { + const e = r[t]; + e.func.call(e.target); + } + r.length = 0; + this.physicsWorld.syncPhysicsToScene(); + this.debugDrawFlags && this.physicsWorld.drawDebug(); + this._steping = !1; + IR.emit(RR.EVENT_AFTER_PHYSICS); + } + _callAfterStep(t, e) { + this._steping ? this._delayEvents.push({ + target: t, + func: e + }) : e.call(t); + } + resetAccumulator(t = 0) { + this._accumulator = t; + } + step(t) { + this.physicsWorld.step(t, this.velocityIterations, this.positionIterations); + } + raycast(t, e, i = Ebt.Closest, s = 4294967295) { + return this.physicsWorld.raycast(t, e, i, s); + } + testPoint(t) { + return this.physicsWorld.testPoint(t); + } + testAABB(t) { + return this.physicsWorld.testAABB(t); + } + } + t("PhysicsSystem2D", hSt); + hSt.ID = "PHYSICS_2D"; + IR.once(RR.EVENT_INIT, (() => { + hSt.PHYSICS_NONE || IR.registerSystem(hSt.ID, hSt.instance, Tg.Priority.LOW); + })); + let cSt; + !function(t) { + t[t.Circles = 0] = "Circles"; + t[t.FaceA = 1] = "FaceA"; + t[t.FaceB = 2] = "FaceB"; + }(cSt || (cSt = t("Physics2DManifoldType", {}))); + var uSt, _St, dSt, pSt, mSt, fSt, gSt, ySt, bSt, SSt, ASt, TSt, vSt, ESt, CSt, xSt, wSt, RSt, ISt; + const {property: MSt, type: BSt, menu: DSt} = wh; + let PSt = t("RigidBody2D", (uSt = Ul("cc.RigidBody2D"), _St = DSt("Physics2D/RigidBody2D"), + dSt = BSt(oSt), pSt = BSt(Sbt), uSt(mSt = _St(mSt = (fSt = (ISt = class extends Qc { + constructor(...t) { + super(...t); + Ml(this, "enabledContactListener", gSt, this); + Ml(this, "bullet", ySt, this); + Ml(this, "awakeOnLoad", bSt, this); + this._body = null; + Ml(this, "_group", SSt, this); + Ml(this, "_type", ASt, this); + Ml(this, "_allowSleep", TSt, this); + Ml(this, "_gravityScale", vSt, this); + Ml(this, "_linearDamping", ESt, this); + Ml(this, "_angularDamping", CSt, this); + Ml(this, "_linearVelocity", xSt, this); + Ml(this, "_angularVelocity", wSt, this); + Ml(this, "_fixedRotation", RSt, this); + } + get group() { + return this._group; + } + set group(t) { + this._group = t; + } + get type() { + return this._type; + } + set type(t) { + this._type = t; + this._body && (t === Sbt.Animated ? this._body.setType(Sbt.Kinematic) : this._body.setType(t)); + } + get allowSleep() { + return this._allowSleep; + } + set allowSleep(t) { + this._allowSleep = t; + this._body && this._body.setAllowSleep(t); + } + get gravityScale() { + return this._gravityScale; + } + set gravityScale(t) { + this._gravityScale = t; + this._body && this._body.setGravityScale(t); + } + get linearDamping() { + return this._linearDamping; + } + set linearDamping(t) { + this._linearDamping = t; + this._body && this._body.setLinearDamping(t); + } + get angularDamping() { + return this._angularDamping; + } + set angularDamping(t) { + this._angularDamping = t; + this._body && this._body.setAngularDamping(t); + } + get linearVelocity() { + this._body && this._body.getLinearVelocity(this._linearVelocity); + return this._linearVelocity; + } + set linearVelocity(t) { + this._linearVelocity = t; + this._body && this._body.setLinearVelocity(t); + } + get angularVelocity() { + this._body && (this._angularVelocity = this._body.getAngularVelocity()); + return this._angularVelocity; + } + set angularVelocity(t) { + this._angularVelocity = t; + this._body && this._body.setAngularVelocity(t); + } + get fixedRotation() { + return this._fixedRotation; + } + set fixedRotation(t) { + this._fixedRotation = t; + this._body && this._body.setFixedRotation(t); + } + isAwake() { + return !!this._body && this._body.isAwake; + } + wakeUp() { + this._body && this._body.wakeUp(); + } + sleep() { + this._body && this._body.sleep(); + } + getMass() { + return this._body ? this._body.getMass() : 0; + } + applyForce(t, e, i) { + this._body && this._body.applyForce(t, e, i); + } + applyForceToCenter(t, e) { + this._body && this._body.applyForceToCenter(t, e); + } + applyTorque(t, e) { + this._body && this._body.applyTorque(t, e); + } + applyLinearImpulse(t, e, i) { + this._body && this._body.applyLinearImpulse(t, e, i); + } + applyLinearImpulseToCenter(t, e) { + this._body && this._body.applyLinearImpulseToCenter(t, e); + } + applyAngularImpulse(t, e) { + this._body && this._body.applyAngularImpulse(t, e); + } + getLinearVelocityFromWorldPoint(t, e) { + return this._body ? this._body.getLinearVelocityFromWorldPoint(t, e) : e; + } + getLocalVector(t, e) { + return this._body ? this._body.getLocalVector(t, e) : e; + } + getWorldVector(t, e) { + return this._body ? this._body.getWorldVector(t, e) : e; + } + getLocalPoint(t, e) { + return this._body ? this._body.getLocalPoint(t, e) : e; + } + getWorldPoint(t, e) { + return this._body ? this._body.getWorldPoint(t, e) : e; + } + getLocalCenter(t) { + return this._body ? this._body.getLocalCenter(t) : t; + } + getWorldCenter(t) { + return this._body ? this._body.getWorldCenter(t) : t; + } + getInertia() { + this._body && this._body.getInertia(); + return 0; + } + onLoad() { + this._body = m._global.CC_PHYSICS_2D_BUILTIN ? qbt : Ybt(dbt.RigidBody) ? null : new dbt.RigidBody; + this._body.initialize(this); + } + onEnable() { + this._body && this._body.onEnable(); + } + onDisable() { + this._body && this._body.onDisable(); + } + onDestroy() { + this._body && this._body.onDestroy(); + } + get impl() { + return this._body; + } + }, ISt), Bl(fSt.prototype, "group", [ dSt ], Object.getOwnPropertyDescriptor(fSt.prototype, "group"), fSt.prototype), + gSt = Bl(fSt.prototype, "enabledContactListener", [ MSt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), ySt = Bl(fSt.prototype, "bullet", [ MSt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Bl(fSt.prototype, "type", [ pSt ], Object.getOwnPropertyDescriptor(fSt.prototype, "type"), fSt.prototype), + Bl(fSt.prototype, "allowSleep", [ MSt ], Object.getOwnPropertyDescriptor(fSt.prototype, "allowSleep"), fSt.prototype), + Bl(fSt.prototype, "gravityScale", [ MSt ], Object.getOwnPropertyDescriptor(fSt.prototype, "gravityScale"), fSt.prototype), + Bl(fSt.prototype, "linearDamping", [ MSt ], Object.getOwnPropertyDescriptor(fSt.prototype, "linearDamping"), fSt.prototype), + Bl(fSt.prototype, "angularDamping", [ MSt ], Object.getOwnPropertyDescriptor(fSt.prototype, "angularDamping"), fSt.prototype), + Bl(fSt.prototype, "linearVelocity", [ MSt ], Object.getOwnPropertyDescriptor(fSt.prototype, "linearVelocity"), fSt.prototype), + Bl(fSt.prototype, "angularVelocity", [ MSt ], Object.getOwnPropertyDescriptor(fSt.prototype, "angularVelocity"), fSt.prototype), + Bl(fSt.prototype, "fixedRotation", [ MSt ], Object.getOwnPropertyDescriptor(fSt.prototype, "fixedRotation"), fSt.prototype), + bSt = Bl(fSt.prototype, "awakeOnLoad", [ MSt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), SSt = Bl(fSt.prototype, "_group", [ MSt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return oSt.DEFAULT; + } + }), ASt = Bl(fSt.prototype, "_type", [ MSt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Sbt.Dynamic; + } + }), TSt = Bl(fSt.prototype, "_allowSleep", [ MSt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), vSt = Bl(fSt.prototype, "_gravityScale", [ MSt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), ESt = Bl(fSt.prototype, "_linearDamping", [ MSt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), CSt = Bl(fSt.prototype, "_angularDamping", [ MSt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), xSt = Bl(fSt.prototype, "_linearVelocity", [ MSt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Qi; + } + }), wSt = Bl(fSt.prototype, "_angularVelocity", [ MSt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), RSt = Bl(fSt.prototype, "_fixedRotation", [ MSt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), fSt)) || mSt) || mSt)); + var OSt, NSt, LSt, FSt, VSt, kSt, USt, GSt, zSt, HSt, jSt, XSt, WSt; + let YSt = t("Collider2D", (OSt = Ul("cc.Collider2D"), NSt = Th(oSt), OSt(LSt = (FSt = (WSt = class extends(To(Qc)){ + constructor(...t) { + super(...t); + Ml(this, "editing", VSt, this); + Ml(this, "tag", kSt, this); + this.TYPE = Abt.None; + this._shape = null; + this._body = null; + Ml(this, "_group", USt, this); + Ml(this, "_density", GSt, this); + Ml(this, "_sensor", zSt, this); + Ml(this, "_friction", HSt, this); + Ml(this, "_restitution", jSt, this); + Ml(this, "_offset", XSt, this); + } + get group() { + return this._group; + } + set group(t) { + this._group = t; + this._shape && this._shape.onGroupChanged && this._shape.onGroupChanged(); + } + get density() { + return this._density; + } + set density(t) { + this._density = t; + } + get sensor() { + return this._sensor; + } + set sensor(t) { + this._sensor = t; + } + get friction() { + return this._friction; + } + set friction(t) { + this._friction = t; + } + get restitution() { + return this._restitution; + } + set restitution(t) { + this._restitution = t; + } + get offset() { + return this._offset; + } + set offset(t) { + this._offset = t; + } + get body() { + return this._body; + } + get impl() { + return this._shape; + } + onLoad() { + this._shape = Zbt(this.TYPE); + this._shape.initialize(this); + this._shape.onLoad && this._shape.onLoad(); + this._body = this.getComponent(PSt); + } + onEnable() { + this._shape && this._shape.onEnable(); + } + onDisable() { + this._shape && this._shape.onDisable && this._shape.onDisable(); + } + onDestroy() { + this._shape && this._shape.onDestroy && this._shape.onDestroy(); + } + apply() { + this._shape && this._shape.apply && this._shape.apply(); + } + get worldAABB() { + return this._shape ? this._shape.worldAABB : new as; + } + }, WSt), VSt = Bl(FSt.prototype, "editing", [ nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), kSt = Bl(FSt.prototype, "tag", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Bl(FSt.prototype, "group", [ NSt ], Object.getOwnPropertyDescriptor(FSt.prototype, "group"), FSt.prototype), + Bl(FSt.prototype, "density", [ jl ], Object.getOwnPropertyDescriptor(FSt.prototype, "density"), FSt.prototype), + Bl(FSt.prototype, "sensor", [ jl ], Object.getOwnPropertyDescriptor(FSt.prototype, "sensor"), FSt.prototype), + Bl(FSt.prototype, "friction", [ jl ], Object.getOwnPropertyDescriptor(FSt.prototype, "friction"), FSt.prototype), + Bl(FSt.prototype, "restitution", [ jl ], Object.getOwnPropertyDescriptor(FSt.prototype, "restitution"), FSt.prototype), + Bl(FSt.prototype, "offset", [ jl ], Object.getOwnPropertyDescriptor(FSt.prototype, "offset"), FSt.prototype), + USt = Bl(FSt.prototype, "_group", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return oSt.DEFAULT; + } + }), GSt = Bl(FSt.prototype, "_density", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), zSt = Bl(FSt.prototype, "_sensor", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), HSt = Bl(FSt.prototype, "_friction", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .2; + } + }), jSt = Bl(FSt.prototype, "_restitution", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), XSt = Bl(FSt.prototype, "_offset", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Qi; + } + }), FSt)) || LSt)); + var qSt, KSt, JSt, ZSt; + t("BoxCollider2D", Ul("cc.BoxCollider2D")(qSt = $l()(qSt = (KSt = (ZSt = class extends YSt { + constructor(...t) { + super(...t); + Ml(this, "_size", JSt, this); + this.TYPE = Abt.BOX; + } + get size() { + return this._size; + } + set size(t) { + this._size = t; + } + get worldPoints() { + return this._shape ? this._shape.worldPoints : []; + } + }, ZSt), JSt = Bl(KSt.prototype, "_size", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new rs(1, 1); + } + }), Bl(KSt.prototype, "size", [ jl ], Object.getOwnPropertyDescriptor(KSt.prototype, "size"), KSt.prototype), + KSt)) || qSt) || qSt); + var QSt, $St, tAt, eAt; + t("CircleCollider2D", Ul("cc.CircleCollider2D")(QSt = $l()(QSt = ($St = (eAt = class extends YSt { + constructor(...t) { + super(...t); + Ml(this, "_radius", tAt, this); + this.TYPE = Abt.CIRCLE; + } + get radius() { + return this._radius; + } + set radius(t) { + this._radius = t < 0 ? 0 : t; + } + get worldPosition() { + return this._shape ? this._shape.worldPosition : new Qi; + } + get worldRadius() { + return this._shape ? this._shape.worldRadius : 0; + } + }, eAt), tAt = Bl($St.prototype, "_radius", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), Bl($St.prototype, "radius", [ jl ], Object.getOwnPropertyDescriptor($St.prototype, "radius"), $St.prototype), + $St)) || QSt) || QSt); + var iAt, sAt, nAt, rAt, oAt, aAt, lAt, hAt, cAt; + t("PolygonCollider2D", (iAt = Ul("cc.PolygonCollider2D"), sAt = $l(), nAt = jl({ + serializable: !1, + displayOrder: 0 + }), rAt = jl({ + type: Qi + }), iAt(oAt = sAt(oAt = (aAt = (cAt = class extends YSt { + constructor(...t) { + super(...t); + Ml(this, "threshold", lAt, this); + Ml(this, "_points", hAt, this); + this.TYPE = Abt.POLYGON; + } + get points() { + return this._points; + } + set points(t) { + this._points = t; + } + get worldPoints() { + return this._shape ? this._shape.worldPoints : []; + } + }, cAt), lAt = Bl(aAt.prototype, "threshold", [ nAt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), hAt = Bl(aAt.prototype, "_points", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return [ new Qi(-1, -1), new Qi(1, -1), new Qi(1, 1), new Qi(-1, 1) ]; + } + }), Bl(aAt.prototype, "points", [ rAt ], Object.getOwnPropertyDescriptor(aAt.prototype, "points"), aAt.prototype), + aAt)) || oAt) || oAt)); + var uAt, _At, dAt, pAt, mAt, fAt, gAt, yAt; + let bAt = t("Joint2D", (uAt = Ul("cc.Joint2D"), _At = Th(PSt), uAt(dAt = (pAt = class extends Qc { + constructor(...t) { + super(...t); + Ml(this, "anchor", mAt, this); + Ml(this, "connectedAnchor", fAt, this); + Ml(this, "collideConnected", gAt, this); + Ml(this, "connectedBody", yAt, this); + this._body = null; + this._joint = null; + this.TYPE = Tbt.None; + } + get body() { + return this._body; + } + get impl() { + return this._joint; + } + onLoad() { + this._joint = tSt(this.TYPE); + this._joint.initialize(this); + this._body = this.getComponent(PSt); + } + onEnable() { + this._joint && this._joint.onEnable && this._joint.onEnable(); + } + onDisable() { + this._joint && this._joint.onDisable && this._joint.onDisable(); + } + start() { + this._joint && this._joint.start && this._joint.start(); + } + onDestroy() { + this._joint && this._joint.onDestroy && this._joint.onDestroy(); + } + }, mAt = Bl(pAt.prototype, "anchor", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Qi; + } + }), fAt = Bl(pAt.prototype, "connectedAnchor", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Qi; + } + }), gAt = Bl(pAt.prototype, "collideConnected", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), yAt = Bl(pAt.prototype, "connectedBody", [ _At ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), pAt)) || dAt)); + var SAt, AAt, TAt, vAt, EAt; + t("DistanceJoint2D", Ul("cc.DistanceJoint2D")(SAt = $l()(SAt = (AAt = (EAt = class extends bAt { + constructor(...t) { + super(...t); + this.TYPE = Tbt.DISTANCE; + Ml(this, "_maxLength", TAt, this); + Ml(this, "_autoCalcDistance", vAt, this); + } + get maxLength() { + return this._autoCalcDistance && this.connectedBody ? Pi.distance(this.node.worldPosition, this.connectedBody.node.worldPosition) : this._maxLength; + } + set maxLength(t) { + this._maxLength = t; + this._joint && this._joint.setMaxLength(t); + } + get autoCalcDistance() { + return this._autoCalcDistance; + } + set autoCalcDistance(t) { + this._autoCalcDistance = t; + } + }, EAt), Bl(AAt.prototype, "maxLength", [ jl ], Object.getOwnPropertyDescriptor(AAt.prototype, "maxLength"), AAt.prototype), + Bl(AAt.prototype, "autoCalcDistance", [ jl ], Object.getOwnPropertyDescriptor(AAt.prototype, "autoCalcDistance"), AAt.prototype), + TAt = Bl(AAt.prototype, "_maxLength", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 5; + } + }), vAt = Bl(AAt.prototype, "_autoCalcDistance", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), AAt)) || SAt) || SAt); + var CAt, xAt, wAt, RAt, IAt, MAt, BAt; + t("SpringJoint2D", Ul("cc.SpringJoint2D")(CAt = $l()(CAt = (xAt = (BAt = class extends bAt { + constructor(...t) { + super(...t); + this.TYPE = Tbt.SPRING; + Ml(this, "_frequency", wAt, this); + Ml(this, "_dampingRatio", RAt, this); + Ml(this, "_distance", IAt, this); + Ml(this, "_autoCalcDistance", MAt, this); + } + get frequency() { + return this._frequency; + } + set frequency(t) { + this._frequency = t; + this._joint && this._joint.setFrequency(t); + } + get dampingRatio() { + return this._dampingRatio; + } + set dampingRatio(t) { + this._dampingRatio = t; + this._joint && this._joint.setDampingRatio(t); + } + get distance() { + return this._autoCalcDistance && this.connectedBody ? Pi.distance(this.node.worldPosition, this.connectedBody.node.worldPosition) : this._distance; + } + set distance(t) { + this._distance = t; + this._joint && this._joint.setDistance(t); + } + get autoCalcDistance() { + return this._autoCalcDistance; + } + set autoCalcDistance(t) { + this._autoCalcDistance = t; + } + }, BAt), Bl(xAt.prototype, "frequency", [ jl ], Object.getOwnPropertyDescriptor(xAt.prototype, "frequency"), xAt.prototype), + Bl(xAt.prototype, "dampingRatio", [ jl ], Object.getOwnPropertyDescriptor(xAt.prototype, "dampingRatio"), xAt.prototype), + Bl(xAt.prototype, "distance", [ jl ], Object.getOwnPropertyDescriptor(xAt.prototype, "distance"), xAt.prototype), + Bl(xAt.prototype, "autoCalcDistance", [ jl ], Object.getOwnPropertyDescriptor(xAt.prototype, "autoCalcDistance"), xAt.prototype), + wAt = Bl(xAt.prototype, "_frequency", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 5; + } + }), RAt = Bl(xAt.prototype, "_dampingRatio", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .7; + } + }), IAt = Bl(xAt.prototype, "_distance", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 10; + } + }), MAt = Bl(xAt.prototype, "_autoCalcDistance", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), xAt)) || CAt) || CAt); + var DAt, PAt, OAt, NAt, LAt, FAt; + t("MouseJoint2D", Ul("cc.MouseJoint2D")(DAt = $l()(DAt = (PAt = (FAt = class extends bAt { + constructor(...t) { + super(...t); + this.TYPE = Tbt.MOUSE; + Ml(this, "_maxForce", OAt, this); + Ml(this, "_dampingRatio", NAt, this); + Ml(this, "_frequency", LAt, this); + this._target = new Qi; + } + get target() { + return this._target; + } + set target(t) { + this._target = t; + this._joint && this._joint.setTarget(t); + } + get frequency() { + return this._frequency; + } + set frequency(t) { + this._frequency = t; + this._joint && this._joint.setFrequency(t); + } + get dampingRatio() { + return this._dampingRatio; + } + set dampingRatio(t) { + this._dampingRatio = t; + this._joint && this._joint.setDampingRatio(t); + } + get maxForce() { + return this._maxForce; + } + set maxForce(t) { + this._maxForce = t; + this._joint && this._joint.setMaxForce(t); + } + update(t) { + this._joint.update(t); + } + }, FAt), Bl(PAt.prototype, "frequency", [ jl ], Object.getOwnPropertyDescriptor(PAt.prototype, "frequency"), PAt.prototype), + Bl(PAt.prototype, "dampingRatio", [ jl ], Object.getOwnPropertyDescriptor(PAt.prototype, "dampingRatio"), PAt.prototype), + Bl(PAt.prototype, "maxForce", [ jl ], Object.getOwnPropertyDescriptor(PAt.prototype, "maxForce"), PAt.prototype), + OAt = Bl(PAt.prototype, "_maxForce", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1e3; + } + }), NAt = Bl(PAt.prototype, "_dampingRatio", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .7; + } + }), LAt = Bl(PAt.prototype, "_frequency", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 5; + } + }), PAt)) || DAt) || DAt); + var VAt, kAt, UAt, GAt, zAt, HAt, jAt, XAt, WAt; + const YAt = new Pi; + const qAt = new Pi; + t("RelativeJoint2D", Ul("cc.RelativeJoint2D")(VAt = $l()(VAt = (kAt = (WAt = class extends bAt { + constructor(...t) { + super(...t); + this.TYPE = Tbt.RELATIVE; + Ml(this, "_maxForce", UAt, this); + Ml(this, "_maxTorque", GAt, this); + Ml(this, "_correctionFactor", zAt, this); + Ml(this, "_angularOffset", HAt, this); + Ml(this, "_linearOffset", jAt, this); + Ml(this, "_autoCalcOffset", XAt, this); + } + get maxForce() { + return this._maxForce; + } + set maxForce(t) { + this._maxForce = t; + this._joint && this._joint.setMaxForce(t); + } + get maxTorque() { + return this._maxTorque; + } + set maxTorque(t) { + this._maxTorque = t; + this._joint && this._joint.setMaxTorque(t); + } + get correctionFactor() { + return this._correctionFactor; + } + set correctionFactor(t) { + this._correctionFactor = t; + this._joint && this._joint.setCorrectionFactor(t); + } + get linearOffset() { + return this._autoCalcOffset && this.connectedBody ? Qi.subtract(this._linearOffset, this.connectedBody.node.worldPosition, this.node.worldPosition) : this._linearOffset; + } + set linearOffset(t) { + this._linearOffset.set(t); + this._joint && this._joint.setLinearOffset(t); + } + get angularOffset() { + if (this._autoCalcOffset && this.connectedBody) { + Ui.toEuler(YAt, this.node.worldRotation); + Ui.toEuler(qAt, this.connectedBody.node.worldRotation); + this._angularOffset = qAt.z - YAt.z; + } + return this._angularOffset; + } + set angularOffset(t) { + this._angularOffset = t; + this._joint && this._joint.setAngularOffset(t); + } + get autoCalcOffset() { + return this._autoCalcOffset; + } + set autoCalcOffset(t) { + this._autoCalcOffset = t; + } + }, WAt), Bl(kAt.prototype, "maxForce", [ jl ], Object.getOwnPropertyDescriptor(kAt.prototype, "maxForce"), kAt.prototype), + Bl(kAt.prototype, "maxTorque", [ jl ], Object.getOwnPropertyDescriptor(kAt.prototype, "maxTorque"), kAt.prototype), + Bl(kAt.prototype, "correctionFactor", [ jl ], Object.getOwnPropertyDescriptor(kAt.prototype, "correctionFactor"), kAt.prototype), + Bl(kAt.prototype, "linearOffset", [ jl ], Object.getOwnPropertyDescriptor(kAt.prototype, "linearOffset"), kAt.prototype), + Bl(kAt.prototype, "angularOffset", [ jl ], Object.getOwnPropertyDescriptor(kAt.prototype, "angularOffset"), kAt.prototype), + Bl(kAt.prototype, "autoCalcOffset", [ jl ], Object.getOwnPropertyDescriptor(kAt.prototype, "autoCalcOffset"), kAt.prototype), + UAt = Bl(kAt.prototype, "_maxForce", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 5; + } + }), GAt = Bl(kAt.prototype, "_maxTorque", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .7; + } + }), zAt = Bl(kAt.prototype, "_correctionFactor", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .3; + } + }), HAt = Bl(kAt.prototype, "_angularOffset", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), jAt = Bl(kAt.prototype, "_linearOffset", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Qi; + } + }), XAt = Bl(kAt.prototype, "_autoCalcOffset", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), kAt)) || VAt) || VAt); + var KAt, JAt, ZAt, QAt, $At, tTt, eTt, iTt, sTt, nTt, rTt; + const oTt = new Qi; + t("SliderJoint2D", Ul("cc.SliderJoint2D")(KAt = $l()(KAt = (JAt = (rTt = class extends bAt { + constructor(...t) { + super(...t); + this.TYPE = Tbt.SLIDER; + Ml(this, "_angle", ZAt, this); + Ml(this, "_autoCalcAngle", QAt, this); + Ml(this, "_enableMotor", $At, this); + Ml(this, "_maxMotorForce", tTt, this); + Ml(this, "_motorSpeed", eTt, this); + Ml(this, "_enableLimit", iTt, this); + Ml(this, "_lowerLimit", sTt, this); + Ml(this, "_upperLimit", nTt, this); + } + get angle() { + if (this._autoCalcAngle && this.connectedBody) { + Qi.subtract(oTt, this.connectedBody.node.worldPosition, this.node.worldPosition); + this._angle = fi(Math.atan2(oTt.y, oTt.x)); + } + return this._angle; + } + set angle(t) { + this._angle = t; + } + get autoCalcAngle() { + return this._autoCalcAngle; + } + set autoCalcAngle(t) { + this._autoCalcAngle = t; + } + get enableMotor() { + return this._enableMotor; + } + set enableMotor(t) { + this._enableMotor = t; + } + get maxMotorForce() { + return this._maxMotorForce; + } + set maxMotorForce(t) { + this._maxMotorForce = t; + this._joint && this._joint.setMaxMotorForce(t); + } + get motorSpeed() { + return this._motorSpeed; + } + set motorSpeed(t) { + this._motorSpeed = t; + this._joint && this._joint.setMotorSpeed(t); + } + get enableLimit() { + return this._enableLimit; + } + set enableLimit(t) { + this._enableLimit = t; + } + get lowerLimit() { + return this._lowerLimit; + } + set lowerLimit(t) { + this._lowerLimit = t; + this._joint && this._joint.setLowerLimit(t); + } + get upperLimit() { + return this._upperLimit; + } + set upperLimit(t) { + this._upperLimit = t; + this._joint && this._joint.setUpperLimit(t); + } + }, rTt), Bl(JAt.prototype, "angle", [ jl ], Object.getOwnPropertyDescriptor(JAt.prototype, "angle"), JAt.prototype), + Bl(JAt.prototype, "autoCalcAngle", [ jl ], Object.getOwnPropertyDescriptor(JAt.prototype, "autoCalcAngle"), JAt.prototype), + Bl(JAt.prototype, "enableMotor", [ jl ], Object.getOwnPropertyDescriptor(JAt.prototype, "enableMotor"), JAt.prototype), + Bl(JAt.prototype, "maxMotorForce", [ jl ], Object.getOwnPropertyDescriptor(JAt.prototype, "maxMotorForce"), JAt.prototype), + Bl(JAt.prototype, "motorSpeed", [ jl ], Object.getOwnPropertyDescriptor(JAt.prototype, "motorSpeed"), JAt.prototype), + Bl(JAt.prototype, "enableLimit", [ jl ], Object.getOwnPropertyDescriptor(JAt.prototype, "enableLimit"), JAt.prototype), + Bl(JAt.prototype, "lowerLimit", [ jl ], Object.getOwnPropertyDescriptor(JAt.prototype, "lowerLimit"), JAt.prototype), + Bl(JAt.prototype, "upperLimit", [ jl ], Object.getOwnPropertyDescriptor(JAt.prototype, "upperLimit"), JAt.prototype), + ZAt = Bl(JAt.prototype, "_angle", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), QAt = Bl(JAt.prototype, "_autoCalcAngle", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), $At = Bl(JAt.prototype, "_enableMotor", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), tTt = Bl(JAt.prototype, "_maxMotorForce", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1e3; + } + }), eTt = Bl(JAt.prototype, "_motorSpeed", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1e3; + } + }), iTt = Bl(JAt.prototype, "_enableLimit", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), sTt = Bl(JAt.prototype, "_lowerLimit", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), nTt = Bl(JAt.prototype, "_upperLimit", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), JAt)) || KAt) || KAt); + var aTt, lTt, hTt, cTt, uTt; + t("FixedJoint2D", Ul("cc.FixedJoint2D")(aTt = $l()(aTt = (lTt = (uTt = class extends bAt { + constructor(...t) { + super(...t); + this.TYPE = Tbt.FIXED; + Ml(this, "_frequency", hTt, this); + Ml(this, "_dampingRatio", cTt, this); + } + get frequency() { + return this._frequency; + } + set frequency(t) { + this._frequency = t; + this._joint && this._joint.setFrequency(t); + } + get dampingRatio() { + return this._dampingRatio; + } + set dampingRatio(t) { + this._dampingRatio = t; + this._joint && this._joint.setDampingRatio(t); + } + }, uTt), Bl(lTt.prototype, "frequency", [ jl ], Object.getOwnPropertyDescriptor(lTt.prototype, "frequency"), lTt.prototype), + Bl(lTt.prototype, "dampingRatio", [ jl ], Object.getOwnPropertyDescriptor(lTt.prototype, "dampingRatio"), lTt.prototype), + hTt = Bl(lTt.prototype, "_frequency", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .7; + } + }), cTt = Bl(lTt.prototype, "_dampingRatio", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .5; + } + }), lTt)) || aTt) || aTt); + var _Tt, dTt, pTt, mTt, fTt, gTt, yTt, bTt, STt; + t("WheelJoint2D", Ul("cc.WheelJoint2D")(_Tt = $l()(_Tt = (dTt = (STt = class extends bAt { + constructor(...t) { + super(...t); + this.TYPE = Tbt.WHEEL; + Ml(this, "_angle", pTt, this); + Ml(this, "_enableMotor", mTt, this); + Ml(this, "_maxMotorTorque", fTt, this); + Ml(this, "_motorSpeed", gTt, this); + Ml(this, "_frequency", yTt, this); + Ml(this, "_dampingRatio", bTt, this); + } + get angle() { + return this._angle; + } + set angle(t) { + this._angle = t; + } + get enableMotor() { + return this._enableMotor; + } + set enableMotor(t) { + this._enableMotor = t; + this._joint && this._joint.enableMotor(t); + } + get maxMotorTorque() { + return this._maxMotorTorque; + } + set maxMotorTorque(t) { + this._maxMotorTorque = t; + this._joint && this._joint.setMaxMotorTorque(t); + } + get motorSpeed() { + return this._motorSpeed; + } + set motorSpeed(t) { + this._motorSpeed = t; + this._joint && this._joint.setMotorSpeed(t); + } + get frequency() { + return this._frequency; + } + set frequency(t) { + this._frequency = t; + this._joint && this._joint.setFrequency(t); + } + get dampingRatio() { + return this._dampingRatio; + } + set dampingRatio(t) { + this._dampingRatio = t; + this._joint && this._joint.setDampingRatio(t); + } + }, STt), Bl(dTt.prototype, "angle", [ jl ], Object.getOwnPropertyDescriptor(dTt.prototype, "angle"), dTt.prototype), + Bl(dTt.prototype, "enableMotor", [ jl ], Object.getOwnPropertyDescriptor(dTt.prototype, "enableMotor"), dTt.prototype), + Bl(dTt.prototype, "maxMotorTorque", [ jl ], Object.getOwnPropertyDescriptor(dTt.prototype, "maxMotorTorque"), dTt.prototype), + Bl(dTt.prototype, "motorSpeed", [ jl ], Object.getOwnPropertyDescriptor(dTt.prototype, "motorSpeed"), dTt.prototype), + Bl(dTt.prototype, "frequency", [ jl ], Object.getOwnPropertyDescriptor(dTt.prototype, "frequency"), dTt.prototype), + Bl(dTt.prototype, "dampingRatio", [ jl ], Object.getOwnPropertyDescriptor(dTt.prototype, "dampingRatio"), dTt.prototype), + pTt = Bl(dTt.prototype, "_angle", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 90; + } + }), mTt = Bl(dTt.prototype, "_enableMotor", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), fTt = Bl(dTt.prototype, "_maxMotorTorque", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1e3; + } + }), gTt = Bl(dTt.prototype, "_motorSpeed", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), yTt = Bl(dTt.prototype, "_frequency", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 5; + } + }), bTt = Bl(dTt.prototype, "_dampingRatio", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .7; + } + }), dTt)) || _Tt) || _Tt); + var ATt, TTt, vTt, ETt, CTt, xTt, wTt, RTt, ITt; + t("HingeJoint2D", Ul("cc.HingeJoint2D")(ATt = $l()(ATt = (TTt = (ITt = class extends bAt { + constructor(...t) { + super(...t); + this.TYPE = Tbt.HINGE; + Ml(this, "_enableLimit", vTt, this); + Ml(this, "_lowerAngle", ETt, this); + Ml(this, "_upperAngle", CTt, this); + Ml(this, "_enableMotor", xTt, this); + Ml(this, "_maxMotorTorque", wTt, this); + Ml(this, "_motorSpeed", RTt, this); + } + get enableLimit() { + return this._enableLimit; + } + set enableLimit(t) { + this._enableLimit = t; + } + get lowerAngle() { + return this._lowerAngle; + } + set lowerAngle(t) { + this._lowerAngle = t; + this._joint && this._joint.setLowerAngle(t); + } + get upperAngle() { + return this._upperAngle; + } + set upperAngle(t) { + this._upperAngle = t; + this._joint && this._joint.setUpperAngle(t); + } + get enableMotor() { + return this._enableMotor; + } + set enableMotor(t) { + this._enableMotor = t; + this._joint && this._joint.enableMotor(t); + } + get maxMotorTorque() { + return this._maxMotorTorque; + } + set maxMotorTorque(t) { + this._maxMotorTorque = t; + this._joint && this._joint.setMaxMotorTorque(t); + } + get motorSpeed() { + return this._motorSpeed; + } + set motorSpeed(t) { + this._motorSpeed = t; + this._joint && this._joint.setMotorSpeed(t); + } + }, ITt), Bl(TTt.prototype, "enableLimit", [ jl ], Object.getOwnPropertyDescriptor(TTt.prototype, "enableLimit"), TTt.prototype), + Bl(TTt.prototype, "lowerAngle", [ jl ], Object.getOwnPropertyDescriptor(TTt.prototype, "lowerAngle"), TTt.prototype), + Bl(TTt.prototype, "upperAngle", [ jl ], Object.getOwnPropertyDescriptor(TTt.prototype, "upperAngle"), TTt.prototype), + Bl(TTt.prototype, "enableMotor", [ jl ], Object.getOwnPropertyDescriptor(TTt.prototype, "enableMotor"), TTt.prototype), + Bl(TTt.prototype, "maxMotorTorque", [ jl ], Object.getOwnPropertyDescriptor(TTt.prototype, "maxMotorTorque"), TTt.prototype), + Bl(TTt.prototype, "motorSpeed", [ jl ], Object.getOwnPropertyDescriptor(TTt.prototype, "motorSpeed"), TTt.prototype), + vTt = Bl(TTt.prototype, "_enableLimit", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), ETt = Bl(TTt.prototype, "_lowerAngle", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), CTt = Bl(TTt.prototype, "_upperAngle", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), xTt = Bl(TTt.prototype, "_enableMotor", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), wTt = Bl(TTt.prototype, "_maxMotorTorque", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1e3; + } + }), RTt = Bl(TTt.prototype, "_motorSpeed", [ jl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), TTt)) || ATt) || ATt); + t("Physics2DUtils", { + PolygonSeparator: Xbt + }); + class MTt extends bbt.RayCastCallback { + constructor(...t) { + super(...t); + this._type = Ebt.Closest; + this._fixtures = []; + this._points = []; + this._normals = []; + this._fractions = []; + this._mask = 4294967295; + } + init(t, e) { + this._type = t; + this._mask = e; + this._fixtures.length = 0; + this._points.length = 0; + this._normals.length = 0; + this._fractions.length = 0; + } + ReportFixture(t, e, i, s) { + if (0 == (t.GetFilterData().categoryBits & this._mask)) return 0; + if (this._type === Ebt.Closest) { + this._fixtures[0] = t; + this._points[0] = e; + this._normals[0] = i; + this._fractions[0] = s; + return s; + } + this._fixtures.push(t); + this._points.push(new Qi(e.x, e.y)); + this._normals.push(new Qi(i.x, i.y)); + this._fractions.push(s); + return this._type === Ebt.Any ? 0 : this._type >= Ebt.All ? 1 : s; + } + getFixtures() { + return this._fixtures; + } + getPoints() { + return this._points; + } + getNormals() { + return this._normals; + } + getFractions() { + return this._fractions; + } + } + const BTt = []; + const DTt = [ new Qi, new Qi ]; + const PTt = new bbt.WorldManifold; + const OTt = { + points: [], + separations: [], + normal: new Qi + }; + class NTt { + constructor() { + this.localPoint = new Qi; + this.normalImpulse = 0; + this.tangentImpulse = 0; + } + } + const LTt = [ new NTt, new NTt ]; + const FTt = { + type: 0, + localPoint: new Qi, + localNormal: new Qi, + points: [] + }; + const VTt = { + normalImpulses: [], + tangentImpulses: [] + }; + class kTt { + constructor() { + this.colliderA = null; + this.colliderB = null; + this.disabled = !1; + this.disabledOnce = !1; + this._impulse = null; + this._inverted = !1; + this._b2contact = null; + } + static get(t) { + let e = BTt.pop(); + e || (e = new kTt); + e.init(t); + return e; + } + static put(t) { + const e = t.m_userData; + if (e) { + BTt.push(e); + e.reset(); + } + } + _setImpulse(t) { + this._impulse = t; + } + init(t) { + this.colliderA = t.m_fixtureA.m_userData.collider; + this.colliderB = t.m_fixtureB.m_userData.collider; + this.disabled = !1; + this.disabledOnce = !1; + this._impulse = null; + this._inverted = !1; + this._b2contact = t; + t.m_userData = this; + } + reset() { + this.setTangentSpeed(0); + this.resetFriction(); + this.resetRestitution(); + this.colliderA = null; + this.colliderB = null; + this.disabled = !1; + this._impulse = null; + this._b2contact.m_userData = null; + this._b2contact = null; + } + getWorldManifold() { + const t = OTt.points; + const e = OTt.separations; + const i = OTt.normal; + this._b2contact.GetWorldManifold(PTt); + const s = PTt.points; + const n = PTt.separations; + const r = this._b2contact.GetManifold().pointCount; + t.length = e.length = r; + for (let i = 0; i < r; i++) { + const r = DTt[i]; + r.x = s[i].x * wbt; + r.y = s[i].y * wbt; + t[i] = r; + e[i] = n[i] * wbt; + } + i.x = PTt.normal.x; + i.y = PTt.normal.y; + if (this._inverted) { + i.x *= -1; + i.y *= -1; + } + return OTt; + } + getManifold() { + const t = FTt.points; + const e = FTt.localNormal; + const i = FTt.localPoint; + const s = this._b2contact.GetManifold(); + const n = s.points; + const r = t.length = s.pointCount; + for (let e = 0; e < r; e++) { + const i = LTt[e]; + const s = n[e]; + i.localPoint.x = s.localPoint.x * wbt; + i.localPoint.y = s.localPoint.y * wbt; + i.normalImpulse = s.normalImpulse * wbt; + i.tangentImpulse = s.tangentImpulse; + t[e] = i; + } + i.x = s.localPoint.x * wbt; + i.y = s.localPoint.y * wbt; + e.x = s.localNormal.x; + e.y = s.localNormal.y; + FTt.type = s.type; + if (this._inverted) { + e.x *= -1; + e.y *= -1; + } + return FTt; + } + getImpulse() { + const t = this._impulse; + if (!t) return null; + const e = VTt.normalImpulses; + const i = VTt.tangentImpulses; + const s = t.count; + for (let n = 0; n < s; n++) { + e[n] = t.normalImpulses[n] * wbt; + i[n] = t.tangentImpulses[n]; + } + i.length = e.length = s; + return VTt; + } + emit(t) { + const e = this.colliderA; + const i = this.colliderB; + const s = e.body; + const n = i.body; + s.enabledContactListener && (null == e || e.emit(t, e, i, this)); + n.enabledContactListener && (null == i || i.emit(t, i, e, this)); + (s.enabledContactListener || n.enabledContactListener) && hSt.instance.emit(t, e, i, this); + if (this.disabled || this.disabledOnce) { + this.setEnabled(!1); + this.disabledOnce = !1; + } + } + setEnabled(t) { + this._b2contact.SetEnabled(t); + } + isTouching() { + return this._b2contact.IsTouching(); + } + setTangentSpeed(t) { + this._b2contact.SetTangentSpeed(t); + } + getTangentSpeed() { + return this._b2contact.GetTangentSpeed(); + } + setFriction(t) { + this._b2contact.SetFriction(t); + } + getFriction() { + return this._b2contact.GetFriction(); + } + resetFriction() { + return this._b2contact.ResetFriction(); + } + setRestitution(t) { + this._b2contact.SetRestitution(t); + } + getRestitution() { + return this._b2contact.GetRestitution(); + } + resetRestitution() { + return this._b2contact.ResetRestitution(); + } + } + const UTt = new bbt.Vec2; + const GTt = new Bi; + const zTt = Bi.GREEN; + const HTt = Bi.RED; + class jTt extends bbt.Draw { + constructor(t) { + super(); + this._drawer = null; + this._xf = new bbt.Transform; + this._dxf = new bbt.Transform; + this._drawer = t; + } + _DrawPolygon(t, e) { + const i = this._drawer; + for (let s = 0; s < e; s++) { + bbt.Transform.MulXV(this._xf, t[s], UTt); + const e = UTt.x * wbt; + const n = UTt.y * wbt; + 0 === s ? i.moveTo(e, n) : i.lineTo(e, n); + } + i.close(); + } + DrawPolygon(t, e, i) { + this._applyStrokeColor(i); + this._DrawPolygon(t, e); + this._drawer.stroke(); + } + DrawSolidPolygon(t, e, i) { + this._applyFillColor(i); + this._DrawPolygon(t, e); + this._drawer.fill(); + this._drawer.stroke(); + } + _DrawCircle(t, e) { + const i = this._xf.p; + this._drawer.circle((t.x + i.x) * wbt, (t.y + i.y) * wbt, e * wbt); + } + DrawCircle(t, e, i) { + this._applyStrokeColor(i); + this._DrawCircle(t, e); + this._drawer.stroke(); + } + DrawSolidCircle(t, e, i, s) { + this._applyFillColor(s); + this._DrawCircle(t, e); + this._drawer.fill(); + } + DrawSegment(t, e, i) { + const s = this._drawer; + if (t.x !== e.x || t.y !== e.y) { + this._applyStrokeColor(i); + bbt.Transform.MulXV(this._xf, t, UTt); + s.moveTo(UTt.x * wbt, UTt.y * wbt); + bbt.Transform.MulXV(this._xf, e, UTt); + s.lineTo(UTt.x * wbt, UTt.y * wbt); + s.stroke(); + } else { + this._applyFillColor(i); + this._DrawCircle(t, 2 / wbt); + s.fill(); + } + } + DrawTransform(t) { + const e = this._drawer; + e.strokeColor = HTt; + UTt.x = UTt.y = 0; + bbt.Transform.MulXV(t, UTt, UTt); + e.moveTo(UTt.x * wbt, UTt.y * wbt); + UTt.x = 1; + UTt.y = 0; + bbt.Transform.MulXV(t, UTt, UTt); + e.lineTo(UTt.x * wbt, UTt.y * wbt); + e.stroke(); + e.strokeColor = zTt; + UTt.x = UTt.y = 0; + bbt.Transform.MulXV(t, UTt, UTt); + e.moveTo(UTt.x * wbt, UTt.y * wbt); + UTt.x = 0; + UTt.y = 1; + bbt.Transform.MulXV(t, UTt, UTt); + e.lineTo(UTt.x * wbt, UTt.y * wbt); + e.stroke(); + } + DrawPoint(t, e, i) {} + DrawParticles() {} + _applyStrokeColor(t) { + this._drawer.strokeColor = GTt.set(255 * t.r, 255 * t.g, 255 * t.b, 150); + } + _applyFillColor(t) { + this._drawer.fillColor = GTt.set(255 * t.r, 255 * t.g, 255 * t.b, 150); + } + PushTransform(t) { + this._xf = t; + } + PopTransform() { + this._xf = this._dxf; + } + } + const XTt = new Pi; + const WTt = new Qi; + const YTt = new Qi; + const qTt = new bbt.BodyDef; + const KTt = new bbt.AABB; + const JTt = []; + new Pi; + const ZTt = new bbt.Vec2; + const QTt = new bbt.Filter; + function $Tt(t) { + const e = t.collider; + QTt.categoryBits = e.group === oSt.DEFAULT ? e.body.group : e.group; + QTt.maskBits = hSt.instance.collisionMatrix[QTt.categoryBits]; + return QTt; + } + class tvt { + constructor() { + this._shapes = []; + this._fixtures = []; + this._collider = null; + this._body = null; + this._inited = !1; + this._rect = new as; + } + get impl() { + return this._shapes; + } + get collider() { + return this._collider; + } + initialize(t) { + this._collider = t; + } + onLoad() {} + onEnable() { + hSt.instance._callAfterStep(this, this._init); + } + onDisable() { + hSt.instance._callAfterStep(this, this._destroy); + } + start() {} + onGroupChanged() { + const t = $Tt(this); + this._fixtures.forEach((e => { + e.SetFilterData(t); + })); + } + apply() { + this._destroy(); + this._init(); + } + get worldAABB() { + const t = 1e7; + let e = t; + let i = t; + let s = -t; + let n = -t; + const r = this._fixtures; + for (let t = 0; t < r.length; t++) { + const o = r[t]; + const a = o.GetShape().GetChildCount(); + for (let t = 0; t < a; t++) { + const r = o.GetAABB(t); + r.lowerBound.x < e && (e = r.lowerBound.x); + r.lowerBound.y < i && (i = r.lowerBound.y); + r.upperBound.x > s && (s = r.upperBound.x); + r.upperBound.y > n && (n = r.upperBound.y); + } + } + e *= wbt; + i *= wbt; + s *= wbt; + n *= wbt; + const o = this._rect; + o.x = e; + o.y = i; + o.width = s - e; + o.height = n - i; + return o; + } + getFixtureIndex(t) { + return this._fixtures.indexOf(t); + } + _createShapes(t, e) { + return []; + } + _init() { + var t; + if (this._inited) return; + const e = this.collider; + const i = e.getComponent(PSt); + if (!i) return; + const s = null === (t = i.impl) || void 0 === t ? void 0 : t.impl; + if (!s) return; + const n = i.node.worldScale; + const r = 0 === n.x && 0 === n.y ? [] : this._createShapes(n.x, n.y); + const o = $Tt(this); + for (let t = 0; t < r.length; t++) { + const n = r[t]; + const a = { + density: e.density, + isSensor: e.sensor, + friction: e.friction, + restitution: e.restitution, + shape: n, + filter: o + }; + const l = s.CreateFixture(a); + l.m_userData = this; + i.enabledContactListener && hSt.instance.physicsWorld.registerContactFixture(l); + this._shapes.push(n); + this._fixtures.push(l); + } + this._body = s; + this._inited = !0; + } + _destroy() { + if (!this._inited) return; + const t = this._fixtures; + const e = this._body; + for (let i = t.length - 1; i >= 0; i--) { + const s = t[i]; + s.m_userData = null; + hSt.instance.physicsWorld.unregisterContactFixture(s); + e && e.DestroyFixture(s); + } + this._body = null; + this._fixtures.length = 0; + this._shapes.length = 0; + this._inited = !1; + } + } + const evt = new as; + class ivt { + constructor() { + this._b2joint = null; + this._jointComp = null; + this._body = null; + this._inited = !1; + } + get impl() { + return this._b2joint; + } + get comp() { + return this._jointComp; + } + get body() { + return this._body; + } + initialize(t) { + this._jointComp = t; + } + onEnable() { + hSt.instance._callAfterStep(this, this._init); + } + onDisable() { + hSt.instance._callAfterStep(this, this._destroy); + } + start() { + hSt.instance._callAfterStep(this, this._init); + } + _init() { + if (this._inited) return; + const t = this._jointComp; + if (!t.isValid) return; + this._body = t.getComponent(PSt); + const e = this._createJointDef(); + if (!e) return; + const i = t.connectedBody; + if (i && i.enabledInHierarchy) { + e.bodyA = this._body.impl.impl; + e.bodyB = i.impl.impl; + e.collideConnected = t.collideConnected; + this._b2joint = hSt.instance.physicsWorld.impl.CreateJoint(e); + this._inited = !0; + } + } + _destroy() { + if (this._inited) { + hSt.instance.physicsWorld.impl.DestroyJoint(this._b2joint); + this._b2joint = null; + this._inited = !1; + } + } + _createJointDef() { + return null; + } + isValid() { + return this._b2joint && this._body && this._body.impl && this._jointComp && this._jointComp.connectedBody && this._jointComp.connectedBody.impl; + } + } + const svt = new bbt.Vec2; + !function(t, e) { + pbt = t; + m._global.CC_PHYSICS_2D_BUILTIN = "builtin" == t; + m._global.CC_PHYSICS_2D_BOX2D = "box2d" == t; + dbt = e; + }("box2d", { + PhysicsWorld: class { + get impl() { + return this._world; + } + constructor() { + this._world = void 0; + this._bodies = []; + this._animatedBodies = []; + this._rotationAxis = new Pi; + this._contactListener = void 0; + this._aabbQueryCallback = void 0; + this._raycastQueryCallback = void 0; + this._debugGraphics = null; + this._b2DebugDrawer = null; + this._debugDrawFlags = 0; + this._world = new bbt.World(new bbt.Vec2(0, -10)); + const t = new Rbt; + t.setBeginContact(this._onBeginContact); + t.setEndContact(this._onEndContact); + t.setPreSolve(this._onPreSolve); + t.setPostSolve(this._onPostSolve); + this._world.SetContactListener(t); + this._contactListener = t; + this._aabbQueryCallback = new Ibt; + this._raycastQueryCallback = new MTt; + } + get debugDrawFlags() { + return this._debugDrawFlags; + } + set debugDrawFlags(t) { + t || this._debugGraphics && (this._debugGraphics.node.parent = null); + this._debugDrawFlags = t; + } + _checkDebugDrawValid() { + if (!this._debugGraphics || !this._debugGraphics.isValid) { + let t = mv("Canvas"); + if (!t) { + const e = IR.getScene(); + if (!e) return; + t = new _y("Canvas"); + t.addComponent(mF); + t.parent = e; + } + const e = new _y("PHYSICS_2D_DEBUG_DRAW"); + e.hideFlags |= co.Flags.DontSave; + e.parent = t; + e.worldPosition = Pi.ZERO; + e.layer = mm.Enum.UI_2D; + this._debugGraphics = e.addComponent(dN); + this._debugGraphics.lineWidth = 2; + const i = new jTt(this._debugGraphics); + this._b2DebugDrawer = i; + this._world.SetDebugDraw(i); + } + const t = this._debugGraphics.node.parent; + this._debugGraphics.node.setSiblingIndex(t.children.length - 1); + this._b2DebugDrawer && this._b2DebugDrawer.SetFlags(this.debugDrawFlags); + } + setGravity(t) { + this._world.SetGravity(t); + } + setAllowSleep(t) { + this._world.SetAllowSleeping(!0); + } + step(t, e = 10, i = 10) { + const s = this._animatedBodies; + for (let e = 0, i = s.length; e < i; e++) s[e].animate(t); + this._world.Step(t, e, i); + } + raycast(t, e, i, s) { + if (t.equals(e)) return []; + i = i || Ebt.Closest; + WTt.x = t.x / wbt; + WTt.y = t.y / wbt; + YTt.x = e.x / wbt; + YTt.y = e.y / wbt; + const n = this._raycastQueryCallback; + n.init(i, s); + this._world.RayCast(n, WTt, YTt); + const r = n.getFixtures(); + if (r.length > 0) { + const t = n.getPoints(); + const e = n.getNormals(); + const s = n.getFractions(); + const o = []; + for (let n = 0, a = r.length; n < a; n++) { + const a = r[n]; + const l = a.m_userData; + const h = l.collider; + if (i === Ebt.AllClosest) { + let i; + for (let t = 0; t < o.length; t++) o[t].collider === h && (i = o[t]); + if (i) { + if (s[n] < i.fraction) { + i.fixtureIndex = l.getFixtureIndex(a); + i.point.x = t[n].x * wbt; + i.point.y = t[n].y * wbt; + i.normal.x = e[n].x; + i.normal.y = e[n].y; + i.fraction = s[n]; + } + continue; + } + } + o.push({ + collider: h, + fixtureIndex: l.getFixtureIndex(a), + point: new Qi(t[n].x * wbt, t[n].y * wbt), + normal: new Qi(e[n].x, e[n].y), + fraction: s[n] + }); + } + return o; + } + return []; + } + syncPhysicsToScene() { + const t = this._bodies; + for (let e = 0, i = t.length; e < i; e++) { + const i = t[e]; + const s = i.rigidBody; + if (s.type === Sbt.Animated) { + i.resetVelocity(); + continue; + } + const n = s.node; + const r = i.impl; + const o = r.GetPosition(); + XTt.x = o.x * wbt; + XTt.y = o.y * wbt; + XTt.z = 0; + n.worldPosition = XTt; + const a = fi(r.GetAngle()); + n.setWorldRotationFromEuler(0, 0, a); + } + } + syncSceneToPhysics() { + const t = this._bodies; + for (let e = 0; e < t.length; e++) { + t[e].syncRotationToPhysics(); + t[e].syncPositionToPhysics(); + } + } + addBody(t) { + if (this._bodies.includes(t)) return; + const e = qTt; + const i = t.rigidBody; + e.allowSleep = i.allowSleep; + e.gravityScale = i.gravityScale; + e.linearDamping = i.linearDamping; + e.angularDamping = i.angularDamping; + e.fixedRotation = i.fixedRotation; + e.bullet = i.bullet; + const s = i.node; + const n = s.worldPosition; + e.position.Set(n.x / wbt, n.y / wbt); + XTt.z = Ui.getAxisAngle(this._rotationAxis, s.worldRotation); + this._rotationAxis.z < 0 && (XTt.z = 2 * Math.PI - XTt.z); + e.angle = XTt.z; + e.awake = i.awakeOnLoad; + if (i.type === Sbt.Animated) { + e.type = Sbt.Kinematic; + this._animatedBodies.push(t); + t._animatedPos.set(e.position.x, e.position.y); + t._animatedAngle = e.angle; + } else e.type = i.type; + const r = i; + const o = r._linearVelocity; + e.linearVelocity.Set(o.x, o.y); + e.angularVelocity = mi(r._angularVelocity); + const a = this._world.CreateBody(e); + a.m_userData = t; + t._imp = a; + this._bodies.push(t); + } + removeBody(t) { + if (!this._bodies.includes(t)) return; + if (t.impl) { + t.impl.m_userData = null; + this._world.DestroyBody(t.impl); + t._imp = null; + } + te.remove(this._bodies, t); + t.rigidBody.type === Sbt.Animated && te.remove(this._animatedBodies, t); + } + registerContactFixture(t) { + this._contactListener.registerContactFixture(t); + } + unregisterContactFixture(t) { + this._contactListener.unregisterContactFixture(t); + } + testPoint(t) { + const e = WTt.x = t.x / wbt; + const i = WTt.y = t.y / wbt; + const s = .2 / wbt; + KTt.lowerBound.x = e - s; + KTt.lowerBound.y = i - s; + KTt.upperBound.x = e + s; + KTt.upperBound.y = i + s; + const n = this._aabbQueryCallback; + n.init(WTt); + this._world.QueryAABB(n, KTt); + const r = n.getFixtures(); + JTt.length = 0; + for (let t = 0; t < r.length; t++) { + const e = r[t].m_userData.collider; + JTt.includes(e) || JTt.push(e); + } + return JTt; + } + testAABB(t) { + KTt.lowerBound.x = t.xMin / wbt; + KTt.lowerBound.y = t.yMin / wbt; + KTt.upperBound.x = t.xMax / wbt; + KTt.upperBound.y = t.yMax / wbt; + const e = this._aabbQueryCallback; + e.init(); + this._world.QueryAABB(e, KTt); + const i = e.getFixtures(); + JTt.length = 0; + for (let t = 0; t < i.length; t++) { + const e = i[t].m_userData.collider; + JTt.includes(e) || JTt.push(e); + } + return JTt; + } + drawDebug() { + this._checkDebugDrawValid(); + if (this._debugGraphics) { + this._debugGraphics.clear(); + this._world.DrawDebugData(); + } + } + _onBeginContact(t) { + kTt.get(t).emit(Cbt.BEGIN_CONTACT); + } + _onEndContact(t) { + const e = t.m_userData; + if (e) { + e.emit(Cbt.END_CONTACT); + kTt.put(t); + } + } + _onPreSolve(t) { + const e = t.m_userData; + e && e.emit(Cbt.PRE_SOLVE); + } + _onPostSolve(t, e) { + const i = t.m_userData; + if (i) { + i._setImpulse(e); + i.emit(Cbt.POST_SOLVE); + i._setImpulse(null); + } + } + }, + RigidBody: class { + constructor() { + this._animatedPos = new Qi; + this._animatedAngle = 0; + this._body = null; + this._inited = !1; + } + get impl() { + return this._body; + } + set _imp(t) { + this._body = t; + } + get rigidBody() { + return this._rigidBody; + } + get isAwake() { + return this._body.IsAwake(); + } + get isSleeping() { + return !this._body.IsAwake(); + } + initialize(t) { + this._rigidBody = t; + hSt.instance._callAfterStep(this, this._init); + } + onDestroy() { + hSt.instance._callAfterStep(this, this._destroy); + } + onEnable() { + this.setActive(!0); + } + onDisable() { + this.setActive(!1); + } + _registerNodeEvents() { + this.rigidBody.node.on(ny.TRANSFORM_CHANGED, this._onNodeTransformChanged, this); + } + _unregisterNodeEvents() { + this.rigidBody.node.off(ny.TRANSFORM_CHANGED, this._onNodeTransformChanged, this); + } + _onNodeTransformChanged(t) { + if (!hSt.instance.stepping) { + if (t & _y.TransformBit.SCALE) { + const t = this.rigidBody.getComponents(YSt); + for (let e = 0; e < t.length; e++) t[e].apply(); + } + t & _y.TransformBit.POSITION && this.syncPositionToPhysics(!0); + t & _y.TransformBit.ROTATION && this.syncRotationToPhysics(!0); + } + } + _init() { + if (!this._inited) { + this._registerNodeEvents(); + hSt.instance.physicsWorld.addBody(this); + this._inited = !0; + } + } + _destroy() { + if (this._inited) { + hSt.instance.physicsWorld.removeBody(this); + this._unregisterNodeEvents(); + this._inited = !1; + } + } + animate(t) { + const e = this._body; + if (!e) return; + const i = e.GetPosition(); + e.SetAwake(!0); + const s = 1 / t; + ZTt.x = (this._animatedPos.x - i.x) * s; + ZTt.y = (this._animatedPos.y - i.y) * s; + e.SetLinearVelocity(ZTt); + const n = e.GetAngle(); + e.SetAngularVelocity((this._animatedAngle - n) * s); + } + syncPositionToPhysics(t = !1) { + const e = this._body; + if (!e) return; + const i = this._rigidBody.node.worldPosition; + let s; + const n = this._rigidBody.type; + s = n === Sbt.Animated ? e.GetLinearVelocity() : e.GetPosition(); + s.x = i.x / wbt; + s.y = i.y / wbt; + n === Sbt.Animated && t ? this._animatedPos.set(s.x, s.y) : e.SetTransformVec(s, e.GetAngle()); + } + syncRotationToPhysics(t = !1) { + const e = this._body; + if (!e) return; + const i = mi(this._rigidBody.node.eulerAngles.z); + this._rigidBody.type === Sbt.Animated && t ? this._animatedAngle = i : e.SetTransformVec(e.GetPosition(), i); + } + resetVelocity() { + const t = this._body; + if (!t) return; + const e = t.m_linearVelocity; + e.Set(0, 0); + t.SetLinearVelocity(e); + t.SetAngularVelocity(0); + } + setType(t) { + this._body.SetType(t); + } + setLinearDamping(t) { + this._body.SetLinearDamping(t); + } + setAngularDamping(t) { + this._body.SetAngularDamping(t); + } + setGravityScale(t) { + this._body.SetGravityScale(t); + } + setFixedRotation(t) { + this._body.SetFixedRotation(t); + } + setAllowSleep(t) { + this._body.SetSleepingAllowed(t); + } + isActive() { + return this._body.IsActive(); + } + setActive(t) { + this._body.SetActive(t); + } + wakeUp() { + this._body.SetAwake(!0); + } + sleep() { + this._body.SetAwake(!1); + } + getMass() { + return this._body.GetMass(); + } + setLinearVelocity(t) { + this._body.SetLinearVelocity(t); + } + getLinearVelocity(t) { + const e = this._body.GetLinearVelocity(); + t.x = e.x; + t.y = e.y; + return t; + } + getLinearVelocityFromWorldPoint(t, e) { + ZTt.Set(t.x / wbt, t.y / wbt); + this._body.GetLinearVelocityFromWorldPoint(ZTt, e); + e.x *= wbt; + e.y *= wbt; + return e; + } + setAngularVelocity(t) { + this._body.SetAngularVelocity(t); + } + getAngularVelocity() { + return fi(this._body.GetAngularVelocity()); + } + getLocalVector(t, e) { + e = e || new Qi; + ZTt.Set(t.x / wbt, t.y / wbt); + this._body.GetLocalVector(ZTt, e); + e.x *= wbt; + e.y *= wbt; + return e; + } + getWorldVector(t, e) { + ZTt.Set(t.x / wbt, t.y / wbt); + this._body.GetWorldVector(ZTt, e); + e.x *= wbt; + e.y *= wbt; + return e; + } + getLocalPoint(t, e) { + e = e || new Qi; + ZTt.Set(t.x / wbt, t.y / wbt); + this._body.GetLocalPoint(ZTt, e); + e.x *= wbt; + e.y *= wbt; + return e; + } + getWorldPoint(t, e) { + e = e || new Qi; + ZTt.Set(t.x / wbt, t.y / wbt); + this._body.GetWorldPoint(ZTt, e); + e.x *= wbt; + e.y *= wbt; + return e; + } + getLocalCenter(t) { + t = t || new Qi; + const e = this._body.GetLocalCenter(); + t.x = e.x * wbt; + t.y = e.y * wbt; + return t; + } + getWorldCenter(t) { + t = t || new Qi; + const e = this._body.GetWorldCenter(); + t.x = e.x * wbt; + t.y = e.y * wbt; + return t; + } + getInertia() { + return this._body.GetInertia(); + } + applyForce(t, e, i) { + if (this._body) { + ZTt.Set(e.x / wbt, e.y / wbt); + this._body.ApplyForce(t, ZTt, i); + } + } + applyForceToCenter(t, e) { + this._body && this._body.ApplyForceToCenter(t, e); + } + applyTorque(t, e) { + this._body && this._body.ApplyTorque(t, e); + } + applyLinearImpulse(t, e, i) { + if (this._body) { + ZTt.Set(e.x / wbt, e.y / wbt); + this._body.ApplyLinearImpulse(t, ZTt, i); + } + } + applyLinearImpulseToCenter(t, e) { + this._body && this._body.ApplyLinearImpulse(t, this._body.GetPosition(), e); + } + applyAngularImpulse(t, e) { + this._body && this._body.ApplyAngularImpulse(t, e); + } + }, + BoxShape: class extends tvt { + constructor(...t) { + super(...t); + this._worldPoints = [ new Qi, new Qi, new Qi, new Qi ]; + } + get worldPoints() { + const t = evt; + const e = this.collider; + const i = e.size; + const s = e.offset; + t.x = s.x - i.width / 2; + t.y = s.y - i.height / 2; + t.width = i.width; + t.height = i.height; + const n = this._worldPoints; + const r = n[0]; + const o = n[1]; + const a = n[2]; + const l = n[3]; + t.transformMat4ToPoints(e.node.worldMatrix, r, o, a, l); + return n; + } + _createShapes(t, e) { + t = Math.abs(t); + e = Math.abs(e); + const i = this.collider; + const s = i.size.width / 2 / wbt * t; + const n = i.size.height / 2 / wbt * e; + const r = i.offset.x / wbt * t; + const o = i.offset.y / wbt * e; + const a = new bbt.PolygonShape; + a.SetAsBox(s, n, new bbt.Vec2(r, o), 0); + return [ a ]; + } + }, + CircleShape: class extends tvt { + constructor(...t) { + super(...t); + this._worldPosition = new Qi; + } + get worldRadius() { + return this._shapes[0].m_radius * wbt; + } + get worldPosition() { + const t = this._shapes[0].m_p; + return this._worldPosition.set(t.x * wbt, t.y * wbt); + } + _createShapes(t, e) { + t = Math.abs(t); + e = Math.abs(e); + const i = this.collider; + const s = i.offset.x / wbt * t; + const n = i.offset.y / wbt * e; + const r = new bbt.CircleShape; + r.m_radius = i.radius / wbt * t; + r.m_p.Set(s, n); + return [ r ]; + } + }, + PolygonShape: class extends tvt { + constructor(...t) { + super(...t); + this._worldPoints = []; + } + get worldPoints() { + const t = this.collider; + const e = t.points; + const i = this._worldPoints; + const s = t.node.worldMatrix; + for (let t = 0; t < e.length; t++) { + i[t] || (i[t] = new Qi); + Qi.transformMat4(i[t], e[t], s); + } + i.length = e.length; + return this._worldPoints; + } + _createShapes(t, e) { + const i = []; + const s = this.collider; + const n = s.points; + n.length > 0 && n[0].equals(n[n.length - 1]) && (n.length -= 1); + const r = Dbt(n); + const o = s.offset; + for (let s = 0; s < r.length; s++) { + const n = r[s]; + let a = null; + let l = []; + let h = null; + for (let s = 0, r = n.length; s < r; s++) { + a || (a = new bbt.PolygonShape); + const c = n[s]; + const u = (c.x + o.x) / wbt * t; + const _ = (c.y + o.y) / wbt * e; + const d = new bbt.Vec2(u, _); + l.push(d); + h || (h = d); + if (l.length === bbt.maxPolygonVertices) { + a.Set(l, l.length); + i.push(a); + a = null; + s < r - 1 && (l = [ h, l[l.length - 1] ]); + } + } + if (a) { + a.Set(l, l.length); + i.push(a); + } + } + return i; + } + }, + MouseJoint: class extends ivt { + constructor(...t) { + super(...t); + this._touchPoint = new Qi; + this._isTouched = !1; + } + setTarget(t) { + if (this._b2joint) { + svt.x = t.x / wbt; + svt.y = t.y / wbt; + this._b2joint.SetTarget(svt); + } + } + setDampingRatio(t) { + this._b2joint && this._b2joint.SetDampingRatio(t); + } + setFrequency(t) { + this._b2joint && this._b2joint.SetFrequency(t); + } + setMaxForce(t) { + this._b2joint && this._b2joint.SetMaxForce(t); + } + _createJointDef() { + const t = new bbt.MouseJointDef; + const e = this._jointComp; + t.target.Set(this._touchPoint.x / wbt, this._touchPoint.y / wbt); + t.maxForce = e.maxForce; + t.dampingRatio = e.dampingRatio; + t.frequencyHz = e.frequency; + return t; + } + initialize(t) { + super.initialize(t); + const e = mv("Canvas"); + if (e) { + e.on(ny.TOUCH_START, this.onTouchBegan, this); + e.on(ny.TOUCH_MOVE, this.onTouchMove, this); + e.on(ny.TOUCH_END, this.onTouchEnd, this); + e.on(ny.TOUCH_CANCEL, this.onTouchEnd, this); + } + } + onEnable() {} + start() {} + onTouchBegan(t) { + this._isTouched = !0; + const e = this._touchPoint.set(t.getUILocation()); + const i = hSt.instance.physicsWorld.testPoint(e); + if (i.length <= 0) return; + const s = i[0].body; + s.wakeUp(); + const n = this._jointComp; + n.connectedBody = s; + this._init(); + this.setMaxForce(n.maxForce * s.getMass()); + this.setTarget(e); + } + onTouchMove(t) { + this._touchPoint = t.getUILocation(); + } + onTouchEnd(t) { + this._destroy(); + this._isTouched = !1; + } + update() { + this._isTouched && this.isValid() && this.setTarget(this._touchPoint); + } + }, + DistanceJoint: class extends ivt { + setMaxLength(t) { + this._b2joint && this._b2joint.SetMaxLength(t); + } + _createJointDef() { + const t = this._jointComp; + const e = new bbt.RopeJointDef; + e.localAnchorA.Set(t.anchor.x / wbt, t.anchor.y / wbt); + e.localAnchorB.Set(t.connectedAnchor.x / wbt, t.connectedAnchor.y / wbt); + e.maxLength = t.maxLength / wbt; + return e; + } + }, + SpringJoint: class extends ivt { + setDampingRatio(t) { + this._b2joint && this._b2joint.SetDampingRatio(t); + } + setFrequency(t) { + this._b2joint && this._b2joint.SetFrequency(t); + } + setDistance(t) { + this._b2joint && this._b2joint.SetLength(t); + } + _createJointDef() { + const t = this._jointComp; + const e = new bbt.DistanceJointDef; + e.localAnchorA.Set(t.anchor.x / wbt, t.anchor.y / wbt); + e.localAnchorB.Set(t.connectedAnchor.x / wbt, t.connectedAnchor.y / wbt); + e.length = t.distance / wbt; + e.dampingRatio = t.dampingRatio; + e.frequencyHz = t.frequency; + return e; + } + }, + RelativeJoint: class extends ivt { + setMaxForce(t) { + this._b2joint && this._b2joint.SetMaxForce(t); + } + setAngularOffset(t) { + this._b2joint && this._b2joint.SetAngularOffset(mi(t)); + } + setLinearOffset(t) { + this._b2joint && this._b2joint.SetLinearOffset(new bbt.Vec2(t.x / wbt, t.y / wbt)); + } + setCorrectionFactor(t) { + this._b2joint && (this._b2joint.m_correctionFactor = t); + } + setMaxTorque(t) { + this._b2joint && this._b2joint.SetMaxTorque(t); + } + _createJointDef() { + const t = this._jointComp; + const e = new bbt.MotorJointDef; + e.linearOffset.Set(t.linearOffset.x / wbt, t.linearOffset.y / wbt); + e.angularOffset = mi(t.angularOffset); + e.maxForce = t.maxForce; + e.maxTorque = t.maxTorque; + e.correctionFactor = t.correctionFactor; + return e; + } + }, + SliderJoint: class extends ivt { + enableLimit(t) { + this._b2joint && this._b2joint.EnableLimit(t); + } + setLowerLimit(t) { + this.updateLimits(); + } + setUpperLimit(t) { + this.updateLimits(); + } + updateLimits() { + if (this._b2joint) { + const t = this._jointComp; + this._b2joint.SetLimits(t.lowerLimit / wbt, t.upperLimit / wbt); + } + } + enableMotor(t) { + this._b2joint && this._b2joint.EnableMotor(t); + } + setMaxMotorForce(t) { + this._b2joint && this._b2joint.SetMaxMotorForce(t); + } + setMotorSpeed(t) { + this._b2joint && this._b2joint.SetMotorSpeed(t); + } + _createJointDef() { + const t = this._jointComp; + const e = new bbt.PrismaticJointDef; + e.localAnchorA.Set(t.anchor.x / wbt, t.anchor.y / wbt); + e.localAnchorB.Set(t.connectedAnchor.x / wbt, t.connectedAnchor.y / wbt); + const i = mi(t.angle); + e.localAxisA.Set(Math.cos(i), Math.sin(i)); + e.referenceAngle = 0; + e.enableLimit = t.enableLimit; + e.lowerTranslation = t.lowerLimit / wbt; + e.upperTranslation = t.upperLimit / wbt; + e.enableMotor = t.enableMotor; + e.maxMotorForce = t.maxMotorForce; + e.motorSpeed = t.motorSpeed; + return e; + } + }, + FixedJoint: class extends ivt { + setFrequency(t) { + this._b2joint && this._b2joint.SetFrequency(t); + } + setDampingRatio(t) { + this._b2joint && this._b2joint.SetDampingRatio(t); + } + _createJointDef() { + const t = this._jointComp; + const e = new bbt.WeldJointDef; + e.localAnchorA.Set(t.anchor.x / wbt, t.anchor.y / wbt); + e.localAnchorB.Set(t.connectedAnchor.x / wbt, t.connectedAnchor.y / wbt); + e.referenceAngle = 0; + e.frequencyHz = t.frequency; + e.dampingRatio = t.dampingRatio; + return e; + } + }, + WheelJoint: class extends ivt { + setDampingRatio(t) { + this._b2joint && this._b2joint.SetSpringDampingRatio(t); + } + setFrequency(t) { + this._b2joint && this._b2joint.SetSpringFrequencyHz(t); + } + enableMotor(t) { + this._b2joint && this._b2joint.EnableMotor(t); + } + setMaxMotorTorque(t) { + this._b2joint && this._b2joint.SetMaxMotorTorque(t); + } + setMotorSpeed(t) { + this._b2joint && this._b2joint.SetMotorSpeed(t); + } + _createJointDef() { + const t = this._jointComp; + const e = new bbt.WheelJointDef; + e.localAnchorA.Set(t.anchor.x / wbt, t.anchor.y / wbt); + e.localAnchorB.Set(t.connectedAnchor.x / wbt, t.connectedAnchor.y / wbt); + const i = mi(t.angle); + e.localAxisA.Set(Math.cos(i), Math.sin(i)); + e.maxMotorTorque = t.maxMotorTorque; + e.motorSpeed = mi(t.motorSpeed); + e.enableMotor = t.enableMotor; + e.dampingRatio = t.dampingRatio; + e.frequencyHz = t.frequency; + return e; + } + }, + HingeJoint: class extends ivt { + enableLimit(t) { + this._b2joint && this._b2joint.EnableLimit(t); + } + setLowerAngle(t) { + this.updateLimits(); + } + setUpperAngle(t) { + this.updateLimits(); + } + updateLimits() { + if (this._b2joint) { + const t = this._jointComp; + this._b2joint.SetLimits(mi(t.lowerAngle), mi(t.upperAngle)); + } + } + enableMotor(t) { + this._b2joint && this._b2joint.EnableMotor(t); + } + setMaxMotorTorque(t) { + this._b2joint && this._b2joint.SetMaxMotorTorque(t); + } + setMotorSpeed(t) { + this._b2joint && this._b2joint.SetMotorSpeed(t); + } + _createJointDef() { + const t = this._jointComp; + const e = new bbt.RevoluteJointDef; + e.localAnchorA.Set(t.anchor.x / wbt, t.anchor.y / wbt); + e.localAnchorB.Set(t.connectedAnchor.x / wbt, t.connectedAnchor.y / wbt); + e.enableMotor = t.enableMotor; + e.maxMotorTorque = t.maxMotorTorque; + e.motorSpeed = mi(t.motorSpeed); + e.enableLimit = t.enableLimit; + e.lowerAngle = t.lowerAngle; + e.upperAngle = t.upperAngle; + return e; + } + } + }); + function nvt(t) { + m._global.CC_PHYSICS_BUILTIN = "builtin" === t; + m._global.CC_PHYSICS_CANNON = "cannon.js" === t; + m._global.CC_PHYSICS_AMMO = "bullet" === t; + } + let rvt; + const ovt = { + id: "", + switchTo: function(t) { + if (!ovt.runInEditor) return; + const e = ovt; + if (ovt.physicsWorld && t !== ovt.id && null != ovt.backend[t]) { + ovt.physicsWorld.destroy(); + console.info(`[PHYSICS]: switch from ${ovt.id} to ${t}.`); + nvt(t); + e.id = t; + e.wrapper = ovt.backend[t]; + e.physicsWorld = uvt(); + } else { + console.info(`[PHYSICS]: using ${t}.`); + e.physicsWorld = uvt(); + } + if (rvt) { + const t = e.physicsWorld; + t.setGravity(rvt.gravity); + t.setAllowSleep(rvt.allowSleep); + } + }, + register: function(t, e) { + console.info(`[PHYSICS]: register ${t}.`); + ovt.backend[t] = e; + if (!ovt.physicsWorld || ovt.id === t) { + nvt(t); + const i = ovt; + i.id = t; + i.wrapper = e; + } + }, + wrapper: {}, + backend: {}, + physicsWorld: null, + runInEditor: !0 + }; + const avt = (...t) => 0; + const lvt = { + impl: null, + setGravity: avt, + setAllowSleep: avt, + setDefaultMaterial: avt, + step: avt, + syncAfterEvents: avt, + syncSceneToPhysics: avt, + raycast: avt, + raycastClosest: avt, + emitEvents: avt, + destroy: avt + }; + var hvt; + !function(t) { + t[t.World = 0] = "World"; + t[t.RigidBody = 1] = "RigidBody"; + t[t.BoxCollider = 2] = "BoxCollider"; + t[t.SphereCollider = 3] = "SphereCollider"; + t[t.CapsuleCollider = 4] = "CapsuleCollider"; + t[t.MeshCollider = 5] = "MeshCollider"; + t[t.CylinderCollider = 6] = "CylinderCollider"; + t[t.ConeCollider = 7] = "ConeCollider"; + t[t.TerrainCollider = 8] = "TerrainCollider"; + t[t.SimplexCollider = 9] = "SimplexCollider"; + t[t.PlaneCollider = 10] = "PlaneCollider"; + t[t.PointToPointConstraint = 11] = "PointToPointConstraint"; + t[t.HingeConstraint = 12] = "HingeConstraint"; + t[t.ConeTwistConstraint = 13] = "ConeTwistConstraint"; + }(hvt || (hvt = {})); + function cvt(t, e) { + if (null == t) { + ovt.id ? C(`${ovt.id} physics does not support ${hvt[e]}`) : F(9600); + return !0; + } + return !1; + } + function uvt() { + return cvt(ovt.wrapper.PhysicsWorld, hvt.World) ? lvt : new ovt.wrapper.PhysicsWorld; + } + const _vt = { + impl: null, + rigidBody: null, + isAwake: !1, + isSleepy: !1, + isSleeping: !1, + initialize: avt, + onEnable: avt, + onDisable: avt, + onDestroy: avt, + setType: avt, + setMass: avt, + setLinearDamping: avt, + setAngularDamping: avt, + useGravity: avt, + setLinearFactor: avt, + setAngularFactor: avt, + setAllowSleep: avt, + wakeUp: avt, + sleep: avt, + clearState: avt, + clearForces: avt, + clearVelocity: avt, + setSleepThreshold: avt, + getSleepThreshold: avt, + getLinearVelocity: avt, + setLinearVelocity: avt, + getAngularVelocity: avt, + setAngularVelocity: avt, + applyForce: avt, + applyLocalForce: avt, + applyImpulse: avt, + applyLocalImpulse: avt, + applyTorque: avt, + applyLocalTorque: avt, + setGroup: avt, + getGroup: avt, + addGroup: avt, + removeGroup: avt, + setMask: avt, + getMask: avt, + addMask: avt, + removeMask: avt, + isUsingCCD: avt, + useCCD: avt + }; + const dvt = { + INITED: !1 + }; + const pvt = { + impl: null, + collider: null, + attachedRigidBody: null, + initialize: avt, + onLoad: avt, + onEnable: avt, + onDisable: avt, + onDestroy: avt, + setGroup: avt, + getGroup: avt, + addGroup: avt, + removeGroup: avt, + setMask: avt, + getMask: avt, + addMask: avt, + removeMask: avt, + setMaterial: avt, + setAsTrigger: avt, + setCenter: avt, + getAABB: avt, + getBoundingSphere: avt, + updateSize: avt, + updateRadius: avt, + setRadius: avt, + setCylinderHeight: avt, + setDirection: avt, + setHeight: avt, + setShapeType: avt, + setVertices: avt, + setMesh: avt, + setTerrain: avt, + setNormal: avt, + setConstant: avt, + updateEventListener: avt + }; + function mvt(t) { + !function() { + if (dvt.INITED) return; + dvt.INITED = !0; + dvt[nSt.BOX] = function() { + return cvt(ovt.wrapper.BoxShape, hvt.BoxCollider) ? pvt : new ovt.wrapper.BoxShape; + }; + dvt[nSt.SPHERE] = function() { + return cvt(ovt.wrapper.SphereShape, hvt.SphereCollider) ? pvt : new ovt.wrapper.SphereShape; + }; + dvt[nSt.CAPSULE] = function() { + return cvt(ovt.wrapper.CapsuleShape, hvt.CapsuleCollider) ? pvt : new ovt.wrapper.CapsuleShape; + }; + dvt[nSt.CYLINDER] = function() { + return cvt(ovt.wrapper.CylinderShape, hvt.CylinderCollider) ? pvt : new ovt.wrapper.CylinderShape; + }; + dvt[nSt.CONE] = function() { + return cvt(ovt.wrapper.ConeShape, hvt.ConeCollider) ? pvt : new ovt.wrapper.ConeShape; + }; + dvt[nSt.MESH] = function() { + return cvt(ovt.wrapper.TrimeshShape, hvt.MeshCollider) ? pvt : new ovt.wrapper.TrimeshShape; + }; + dvt[nSt.TERRAIN] = function() { + return cvt(ovt.wrapper.TerrainShape, hvt.TerrainCollider) ? pvt : new ovt.wrapper.TerrainShape; + }; + dvt[nSt.SIMPLEX] = function() { + return cvt(ovt.wrapper.SimplexShape, hvt.SimplexCollider) ? pvt : new ovt.wrapper.SimplexShape; + }; + dvt[nSt.PLANE] = function() { + return cvt(ovt.wrapper.PlaneShape, hvt.PlaneCollider) ? pvt : new ovt.wrapper.PlaneShape; + }; + }(); + return dvt[t](); + } + const fvt = { + INITED: !1 + }; + const gvt = { + impl: null, + initialize: avt, + onLoad: avt, + onEnable: avt, + onDisable: avt, + onDestroy: avt, + setEnableCollision: avt, + setConnectedBody: avt, + setPivotA: avt, + setPivotB: avt, + setAxis: avt + }; + function yvt(t) { + !function() { + if (fvt.INITED) return; + fvt.INITED = !0; + fvt[rSt.POINT_TO_POINT] = function() { + return cvt(ovt.wrapper.PointToPointConstraint, hvt.PointToPointConstraint) ? gvt : new ovt.wrapper.PointToPointConstraint; + }; + fvt[rSt.HINGE] = function() { + return cvt(ovt.wrapper.HingeConstraint, hvt.HingeConstraint) ? gvt : new ovt.wrapper.HingeConstraint; + }; + fvt[rSt.CONE_TWIST] = function() { + return cvt(ovt.wrapper.ConeTwistConstraint, hvt.ConeTwistConstraint) ? gvt : new ovt.wrapper.ConeTwistConstraint; + }; + }(); + return fvt[t](); + } + ovt.id = "physx"; + var bvt, Svt, Avt, Tvt, vvt, Evt, Cvt, xvt; + let wvt = function(e) { + return t({ + PhysicsMaterial: e, + PhysicMaterial: e + }), e; + }(Ul("cc.PhysicsMaterial")(bvt = (Svt = (xvt = Cvt = class t extends gc { + get friction() { + return this._friction; + } + set friction(e) { + if (!ci(this._friction, e)) { + this._friction = e; + this.emit(t.EVENT_UPDATE); + } + } + get rollingFriction() { + return this._rollingFriction; + } + set rollingFriction(e) { + if (!ci(this._rollingFriction, e)) { + this._rollingFriction = e; + this.emit(t.EVENT_UPDATE); + } + } + get spinningFriction() { + return this._spinningFriction; + } + set spinningFriction(e) { + if (!ci(this._spinningFriction, e)) { + this._spinningFriction = e; + this.emit(t.EVENT_UPDATE); + } + } + get restitution() { + return this._restitution; + } + set restitution(e) { + if (!ci(this._restitution, e)) { + this._restitution = e; + this.emit(t.EVENT_UPDATE); + } + } + constructor() { + super(); + this.id = void 0; + Ml(this, "_friction", Avt, this); + Ml(this, "_rollingFriction", Tvt, this); + Ml(this, "_spinningFriction", vvt, this); + Ml(this, "_restitution", Evt, this); + t.allMaterials.push(this); + this.id = t._idCounter++; + this._uuid || (this._uuid = `pm_${this.id}`); + } + clone() { + const e = new t; + e._friction = this._friction; + e._restitution = this._restitution; + e._rollingFriction = this._rollingFriction; + e._spinningFriction = this._spinningFriction; + return e; + } + destroy() { + if (super.destroy()) { + const e = t.allMaterials.indexOf(this); + e >= 0 && t.allMaterials.splice(e, 1); + return !0; + } + return !1; + } + setValues(e, i, s, n) { + const r = this._friction !== e || this._rollingFriction !== i || this._spinningFriction !== s || this._restitution !== n; + this._friction = e; + this._rollingFriction = i; + this._spinningFriction = s; + this._restitution = n; + r && this.emit(t.EVENT_UPDATE); + } + }, Cvt.allMaterials = [], Cvt.EVENT_UPDATE = "event_update", Cvt._idCounter = 0, + xvt), Bl(Svt.prototype, "friction", [ nh ], Object.getOwnPropertyDescriptor(Svt.prototype, "friction"), Svt.prototype), + Bl(Svt.prototype, "rollingFriction", [ nh ], Object.getOwnPropertyDescriptor(Svt.prototype, "rollingFriction"), Svt.prototype), + Bl(Svt.prototype, "spinningFriction", [ nh ], Object.getOwnPropertyDescriptor(Svt.prototype, "spinningFriction"), Svt.prototype), + Bl(Svt.prototype, "restitution", [ nh ], Object.getOwnPropertyDescriptor(Svt.prototype, "restitution"), Svt.prototype), + Avt = Bl(Svt.prototype, "_friction", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .6; + } + }), Tvt = Bl(Svt.prototype, "_rollingFriction", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), vvt = Bl(Svt.prototype, "_spinningFriction", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Evt = Bl(Svt.prototype, "_restitution", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Svt)) || bvt); + class Rvt { + constructor() { + this._hitPoint = new Pi; + this._hitNormal = new Pi; + this._distance = 0; + this._collider = null; + } + get hitPoint() { + return this._hitPoint; + } + get distance() { + return this._distance; + } + get collider() { + return this._collider; + } + get hitNormal() { + return this._hitNormal; + } + _assign(t, e, i, s) { + Pi.copy(this._hitPoint, t); + Pi.copy(this._hitNormal, s); + this._distance = e; + this._collider = i; + } + clone() { + const t = new Rvt; + Pi.copy(t._hitPoint, this._hitPoint); + Pi.copy(t._hitNormal, this._hitNormal); + t._distance = this._distance; + t._collider = this._collider; + return t; + } + } + t("PhysicsRayResult", Rvt); + m.internal.PhysicsGroup = oSt; + class Ivt extends Tg { + static get PHYSICS_NONE() { + return !ovt.id; + } + static get PHYSICS_BUILTIN() { + return "builtin" === ovt.id; + } + static get PHYSICS_CANNON() { + return "cannon.js" === ovt.id; + } + static get PHYSICS_BULLET() { + return "bullet" === ovt.id; + } + static get PHYSICS_PHYSX() { + return "physx" === ovt.id; + } + static get PhysicsGroup() { + return oSt; + } + static get instance() { + return Ivt._instance; + } + get enable() { + return this._enable; + } + set enable(t) { + this._enable = t; + } + get allowSleep() { + return this._allowSleep; + } + set allowSleep(t) { + this._allowSleep = t; + this.physicsWorld && this.physicsWorld.setAllowSleep(t); + } + get maxSubSteps() { + return this._maxSubSteps; + } + set maxSubSteps(t) { + this._maxSubSteps = t; + } + get fixedTimeStep() { + return this._fixedTimeStep; + } + set fixedTimeStep(t) { + this._fixedTimeStep = t; + } + get gravity() { + return this._gravity; + } + set gravity(t) { + this._gravity.set(t); + this.physicsWorld && this.physicsWorld.setGravity(t); + } + get sleepThreshold() { + return this._sleepThreshold; + } + set sleepThreshold(t) { + this._sleepThreshold = t; + } + get autoSimulation() { + return this._autoSimulation; + } + set autoSimulation(t) { + this._autoSimulation = t; + } + get defaultMaterial() { + return this._material; + } + initDefaultMaterial() { + if (null == this._material) { + this._material = xR.get("default-physics-material"); + if (null != this._material) { + this.physicsWorld.setDefaultMaterial(this._material); + this._material.on(wvt.EVENT_UPDATE, this._updateMaterial, this); + this.setDefaultMaterial(this._materialConfig); + } else console.error("PhysicsSystem initDefaultMaterial failed"); + } + } + get physicsWorld() { + return ovt.physicsWorld; + } + constructor() { + super(); + this.raycastClosestResult = new Rvt; + this.raycastResults = []; + this.collisionMatrix = new aSt(1); + this.minVolumeSize = 1e-5; + this.useNodeChains = !1; + this._enable = !0; + this._allowSleep = !0; + this._maxSubSteps = 1; + this._subStepCount = 0; + this._fixedTimeStep = 1 / 60; + this._autoSimulation = !0; + this._accumulator = 0; + this._sleepThreshold = .1; + this._gravity = new Pi(0, -10, 0); + this._materialConfig = new wvt; + this.raycastOptions = { + group: -1, + mask: -1, + queryTrigger: !0, + maxDistance: 1e7 + }; + this.raycastResultPool = new to((() => new Rvt), 1); + } + postUpdate(t) { + if (this.physicsWorld) if (this._enable) { + if (this._autoSimulation) { + this._subStepCount = 0; + this._accumulator += t; + IR.emit(RR.EVENT_BEFORE_PHYSICS); + for (;this._subStepCount < this._maxSubSteps; ) { + if (!(this._accumulator >= this._fixedTimeStep)) { + this.physicsWorld.syncSceneToPhysics(); + break; + } + this.physicsWorld.syncSceneToPhysics(); + this.physicsWorld.step(this._fixedTimeStep); + this.physicsWorld.emitEvents(); + this.physicsWorld.syncAfterEvents(); + this._accumulator -= this._fixedTimeStep; + this._subStepCount++; + } + IR.emit(RR.EVENT_AFTER_PHYSICS); + } + } else this.physicsWorld.syncSceneToPhysics(); + } + resetConfiguration(t) { + const e = t ? t.allowSleep : de.querySettings(_e.Category.PHYSICS, "allowSleep"); + "boolean" == typeof e && (this._allowSleep = e); + const i = t ? t.fixedTimeStep : de.querySettings(_e.Category.PHYSICS, "fixedTimeStep"); + "number" == typeof i && (this._fixedTimeStep = i); + const s = t ? t.maxSubSteps : de.querySettings(_e.Category.PHYSICS, "maxSubSteps"); + "number" == typeof s && (this._maxSubSteps = s); + const n = t ? t.sleepThreshold : de.querySettings(_e.Category.PHYSICS, "sleepThreshold"); + "number" == typeof n && (this._sleepThreshold = n); + const r = t ? t.autoSimulation : de.querySettings(_e.Category.PHYSICS, "autoSimulation"); + "boolean" == typeof r && (this.autoSimulation = r); + const o = t ? t.gravity : de.querySettings(_e.Category.PHYSICS, "gravity"); + o && Pi.copy(this._gravity, o); + const a = t ? t.defaultMaterial : de.querySettings(_e.Category.PHYSICS, "defaultMaterial"); + this._materialConfig = a; + const l = t ? t.collisionMatrix : de.querySettings(_e.Category.PHYSICS, "collisionMatrix"); + if (l) for (const t in l) this.collisionMatrix["" + (1 << parseInt(t))] = l[t]; + const h = t ? t.collisionGroups : de.querySettings(_e.Category.PHYSICS, "collisionGroups"); + if (h) { + const t = h; + if (t instanceof Array) { + t.forEach((t => { + oSt[t.name] = 1 << t.index; + })); + oe.update(oSt); + } + } + if (this.physicsWorld) { + this.physicsWorld.setGravity(this._gravity); + this.physicsWorld.setAllowSleep(this._allowSleep); + } + } + setDefaultMaterial(t) { + this._material && t && this._material.setValues(t.friction, t.rollingFriction, t.spinningFriction, t.restitution); + } + resetAccumulator(t = 0) { + this._accumulator = t; + } + step(t, e, i) { + this.physicsWorld && this.physicsWorld.step(t, e, i); + } + syncSceneToPhysics() { + this.physicsWorld && this.physicsWorld.syncSceneToPhysics(); + } + emitEvents() { + this.physicsWorld && this.physicsWorld.emitEvents(); + } + raycast(t, e = 4294967295, i = 1e7, s = !0) { + if (!this.physicsWorld) return !1; + this.raycastResultPool.reset(); + this.raycastResults.length = 0; + this.raycastOptions.mask = e >>> 0; + this.raycastOptions.maxDistance = i; + this.raycastOptions.queryTrigger = s; + return this.physicsWorld.raycast(t, this.raycastOptions, this.raycastResultPool, this.raycastResults); + } + raycastClosest(t, e = 4294967295, i = 1e7, s = !0) { + if (!this.physicsWorld) return !1; + this.raycastOptions.mask = e >>> 0; + this.raycastOptions.maxDistance = i; + this.raycastOptions.queryTrigger = s; + return this.physicsWorld.raycastClosest(t, this.raycastOptions, this.raycastClosestResult); + } + _updateMaterial() { + this.physicsWorld && this.physicsWorld.setDefaultMaterial(this._material); + } + static constructAndRegister() { + if (!Ivt._instance) { + const t = new Ivt; + t.resetConfiguration(); + !function(t) { + rvt || (rvt = t); + if (ovt.runInEditor && !ovt.physicsWorld) { + console.info(`[PHYSICS]: using ${ovt.id}.`); + const t = ovt.physicsWorld = uvt(); + t.setGravity(rvt.gravity); + t.setAllowSleep(rvt.allowSleep); + } + }(t); + Ivt._instance = t; + IR.registerSystem(Ivt.ID, t, t.priority); + xR.get("default-physics-material") ? t.initDefaultMaterial() : BR.onPostProjectInitDelegate.add(t.initDefaultMaterial.bind(t)); + } + } + } + t("PhysicsSystem", Ivt); + Ivt.ID = "PHYSICS"; + Ivt._instance = null; + IR.once(RR.EVENT_INIT, (() => { + Ivt.constructAndRegister(); + })); + var Mvt, Bvt, Dvt, Pvt, Ovt, Nvt, Lvt, Fvt, Vvt, kvt, Uvt, Gvt, zvt, Hvt, jvt, Xvt, Wvt, Yvt, qvt, Kvt, Jvt, Zvt, Qvt, $vt, tEt, eEt, iEt, sEt, nEt, rEt, oEt, aEt, lEt, hEt, cEt, uEt, _Et, dEt, pEt, mEt, fEt, gEt, yEt, bEt; + let SEt = function(e) { + return t({ + RigidBody: e, + RigidBodyComponent: e + }), e; + }((Mvt = Ul("cc.RigidBody"), Bvt = sh(), Dvt = $l(), Pvt = zl(-1), Ovt = Th(Ivt.PhysicsGroup), + Nvt = ph(), Lvt = lh(), Fvt = Th(eSt), Vvt = ph(), kvt = lh(), Uvt = rh(), Gvt = ph(), + zvt = lh(), Hvt = rh(), jvt = ph(), Xvt = lh(), Wvt = rh(), Yvt = ph(), qvt = lh(), + Kvt = rh(), Jvt = ph(), Zvt = lh(), Qvt = rh(), $vt = ph(), tEt = lh(), eEt = rh(), + iEt = ph(), sEt = lh(), nEt = rh(), rEt = ph(), oEt = lh(), Mvt(aEt = Bvt(aEt = Dvt(aEt = Ql(aEt = Hl(aEt = Pvt(aEt = (lEt = (bEt = yEt = class extends Qc { + constructor(...t) { + super(...t); + this._body = null; + Ml(this, "_group", hEt, this); + Ml(this, "_type", cEt, this); + Ml(this, "_mass", uEt, this); + Ml(this, "_allowSleep", _Et, this); + Ml(this, "_linearDamping", dEt, this); + Ml(this, "_angularDamping", pEt, this); + Ml(this, "_useGravity", mEt, this); + Ml(this, "_linearFactor", fEt, this); + Ml(this, "_angularFactor", gEt, this); + } + get group() { + return this._group; + } + set group(t) { + Number.isInteger(Math.log2(t >>> 0)) || C("[Physics]: The group should only have one bit."); + this._group = t; + this._body && this._body.getGroup() !== t && this._body.setGroup(t); + } + get type() { + return this._type; + } + set type(t) { + if (this._type !== t) { + this._type = t; + this._body && this._body.setType(t); + } + } + get mass() { + return this._mass; + } + set mass(t) { + t <= 0 && C("[Physics]: The mass should be greater than zero."); + if (this._mass !== t) { + t = t <= 0 ? 1e-4 : t; + this._mass = t; + this._body && this._body.setMass(t); + } + } + get allowSleep() { + return this._allowSleep; + } + set allowSleep(t) { + this._allowSleep = t; + this._body && this._body.setAllowSleep(t); + } + get linearDamping() { + return this._linearDamping; + } + set linearDamping(t) { + (t < 0 || t > 1) && C("[Physics]: The damping should be between zero to one."); + this._linearDamping = t; + this._body && this._body.setLinearDamping(t); + } + get angularDamping() { + return this._angularDamping; + } + set angularDamping(t) { + (t < 0 || t > 1) && C("[Physics]: The damping should be between zero to one."); + this._angularDamping = t; + this._body && this._body.setAngularDamping(t); + } + get useGravity() { + return this._useGravity; + } + set useGravity(t) { + this._useGravity = t; + this._body && this._body.useGravity(t); + } + get linearFactor() { + return this._linearFactor; + } + set linearFactor(t) { + Pi.copy(this._linearFactor, t); + this._body && this._body.setLinearFactor(this._linearFactor); + } + get angularFactor() { + return this._angularFactor; + } + set angularFactor(t) { + Pi.copy(this._angularFactor, t); + this._body && this._body.setAngularFactor(this._angularFactor); + } + get sleepThreshold() { + return this._isInitialized ? this._body.getSleepThreshold() : .1; + } + set sleepThreshold(t) { + this._isInitialized && this._body.setSleepThreshold(t); + } + get useCCD() { + return !!this._isInitialized && this._body.isUsingCCD(); + } + set useCCD(t) { + this._isInitialized && this._body.useCCD(t); + } + get isAwake() { + return !!this._isInitialized && this._body.isAwake; + } + get isSleepy() { + return !!this._isInitialized && this._body.isSleepy; + } + get isSleeping() { + return !!this._isInitialized && this._body.isSleeping; + } + get isStatic() { + return this._type === eSt.STATIC; + } + set isStatic(t) { + t && this.isStatic || !t && !this.isStatic || (this.type = t ? eSt.STATIC : eSt.DYNAMIC); + } + get isDynamic() { + return this._type === eSt.DYNAMIC; + } + set isDynamic(t) { + t && this.isDynamic || !t && !this.isDynamic || (this.type = t ? eSt.DYNAMIC : eSt.KINEMATIC); + } + get isKinematic() { + return this._type === eSt.KINEMATIC; + } + set isKinematic(t) { + t && this.isKinematic || !t && !this.isKinematic || (this.type = t ? eSt.KINEMATIC : eSt.DYNAMIC); + } + get body() { + return this._body; + } + get _isInitialized() { + const t = null === this._body; + t && x("[Physics]: This component has not been call onLoad yet, please make sure the node has been added to the scene."); + return !t; + } + onLoad() { + if (ovt.runInEditor) { + this._body = cvt(ovt.wrapper.RigidBody, hvt.RigidBody) ? _vt : new ovt.wrapper.RigidBody; + this._body.initialize(this); + } + } + onEnable() { + this._body && this._body.onEnable(); + } + onDisable() { + this._body && this._body.onDisable(); + } + onDestroy() { + this._body && this._body.onDestroy(); + } + applyForce(t, e) { + this._isInitialized && this._body.applyForce(t, e); + } + applyLocalForce(t, e) { + this._isInitialized && this._body.applyLocalForce(t, e); + } + applyImpulse(t, e) { + this._isInitialized && this._body.applyImpulse(t, e); + } + applyLocalImpulse(t, e) { + this._isInitialized && this._body.applyLocalImpulse(t, e); + } + applyTorque(t) { + this._isInitialized && this._body.applyTorque(t); + } + applyLocalTorque(t) { + this._isInitialized && this._body.applyLocalTorque(t); + } + wakeUp() { + this._isInitialized && this._body.wakeUp(); + } + sleep() { + this._isInitialized && this._body.sleep(); + } + clearState() { + this._isInitialized && this._body.clearState(); + } + clearForces() { + this._isInitialized && this._body.clearForces(); + } + clearVelocity() { + this._isInitialized && this._body.clearVelocity(); + } + getLinearVelocity(t) { + this._isInitialized && this._body.getLinearVelocity(t); + } + setLinearVelocity(t) { + this._isInitialized && this._body.setLinearVelocity(t); + } + getAngularVelocity(t) { + this._isInitialized && this._body.getAngularVelocity(t); + } + setAngularVelocity(t) { + this._isInitialized && this._body.setAngularVelocity(t); + } + getGroup() { + return this._isInitialized ? this._body.getGroup() : 0; + } + setGroup(t) { + this._isInitialized && this._body.setGroup(t); + } + addGroup(t) { + this._isInitialized && this._body.addGroup(t); + } + removeGroup(t) { + this._isInitialized && this._body.removeGroup(t); + } + getMask() { + return this._isInitialized ? this._body.getMask() : 0; + } + setMask(t) { + this._isInitialized && this._body.setMask(t); + } + addMask(t) { + this._isInitialized && this._body.addMask(t); + } + removeMask(t) { + this._isInitialized && this._body.removeMask(t); + } + }, yEt.Type = eSt, bEt), Bl(lEt.prototype, "group", [ Ovt, Nvt, Lvt ], Object.getOwnPropertyDescriptor(lEt.prototype, "group"), lEt.prototype), + Bl(lEt.prototype, "type", [ Fvt, Vvt, kvt ], Object.getOwnPropertyDescriptor(lEt.prototype, "type"), lEt.prototype), + Bl(lEt.prototype, "mass", [ Uvt, Gvt, zvt ], Object.getOwnPropertyDescriptor(lEt.prototype, "mass"), lEt.prototype), + Bl(lEt.prototype, "allowSleep", [ Hvt, jvt, Xvt ], Object.getOwnPropertyDescriptor(lEt.prototype, "allowSleep"), lEt.prototype), + Bl(lEt.prototype, "linearDamping", [ Wvt, Yvt, qvt ], Object.getOwnPropertyDescriptor(lEt.prototype, "linearDamping"), lEt.prototype), + Bl(lEt.prototype, "angularDamping", [ Kvt, Jvt, Zvt ], Object.getOwnPropertyDescriptor(lEt.prototype, "angularDamping"), lEt.prototype), + Bl(lEt.prototype, "useGravity", [ Qvt, $vt, tEt ], Object.getOwnPropertyDescriptor(lEt.prototype, "useGravity"), lEt.prototype), + Bl(lEt.prototype, "linearFactor", [ eEt, iEt, sEt ], Object.getOwnPropertyDescriptor(lEt.prototype, "linearFactor"), lEt.prototype), + Bl(lEt.prototype, "angularFactor", [ nEt, rEt, oEt ], Object.getOwnPropertyDescriptor(lEt.prototype, "angularFactor"), lEt.prototype), + hEt = Bl(lEt.prototype, "_group", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Ivt.PhysicsGroup.DEFAULT; + } + }), cEt = Bl(lEt.prototype, "_type", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return eSt.DYNAMIC; + } + }), uEt = Bl(lEt.prototype, "_mass", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), _Et = Bl(lEt.prototype, "_allowSleep", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), dEt = Bl(lEt.prototype, "_linearDamping", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .1; + } + }), pEt = Bl(lEt.prototype, "_angularDamping", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .1; + } + }), mEt = Bl(lEt.prototype, "_useGravity", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), fEt = Bl(lEt.prototype, "_linearFactor", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Pi(1, 1, 1); + } + }), gEt = Bl(lEt.prototype, "_angularFactor", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Pi(1, 1, 1); + } + }), lEt)) || aEt) || aEt) || aEt) || aEt) || aEt) || aEt)); + SEt || (SEt = function(e) { + return t({ + RigidBody: e, + RigidBodyComponent: e + }), e; + }({})); + var AEt, TEt, vEt, EEt, CEt, xEt, wEt, REt, IEt, MEt, BEt, DEt, PEt, OEt, NEt, LEt, FEt, VEt, kEt, UEt, GEt, zEt; + let HEt = function(e) { + return t({ + Collider: e, + ColliderComponent: e + }), e; + }((AEt = Ul("cc.Collider"), TEt = Th(SEt), vEt = ah(), EEt = ph(), CEt = lh(), xEt = Th(wvt), + wEt = ah(), REt = ph(), IEt = lh(), MEt = ph(), BEt = lh(), DEt = Th(Pi), PEt = ph(), + OEt = lh(), NEt = Th(wvt), AEt(LEt = (FEt = (zEt = GEt = class extends(To(Qc)){ + get attachedRigidBody() { + return function(t) { + const e = t.getComponent(SEt); + if (e && e.isValid) return e; + return null; + }(this.node); + } + get sharedMaterial() { + return this._material; + } + set sharedMaterial(t) { + this.material = t; + } + get material() { + if (this._isSharedMaterial && this._material) { + this._material.off(wvt.EVENT_UPDATE, this._updateMaterial, this); + this._material = this._material.clone(); + this._material.on(wvt.EVENT_UPDATE, this._updateMaterial, this); + this._isSharedMaterial = !1; + } + return this._material; + } + set material(t) { + if (this._shape) { + if (t && this._material) { + if (this._material.id !== t.id) { + this._material.off(wvt.EVENT_UPDATE, this._updateMaterial, this); + t.on(wvt.EVENT_UPDATE, this._updateMaterial, this); + this._isSharedMaterial = !1; + this._material = t; + } + } else if (t && !this._material) { + t.on(wvt.EVENT_UPDATE, this._updateMaterial, this); + this._material = t; + } else if (!t && this._material) { + this._material.off(wvt.EVENT_UPDATE, this._updateMaterial, this); + this._material = t; + } + this._updateMaterial(); + } else this._material = t; + } + get isTrigger() { + return this._isTrigger; + } + set isTrigger(t) { + this._isTrigger = t; + this._shape && this._shape.setAsTrigger(this._isTrigger); + } + get center() { + return this._center; + } + set center(t) { + Pi.copy(this._center, t); + this._shape && this._shape.setCenter(this._center); + } + get shape() { + return this._shape; + } + get worldBounds() { + null == this._aabb && (this._aabb = new hl); + this._shape && this._shape.getAABB(this._aabb); + return this._aabb; + } + get boundingSphere() { + null == this._boundingSphere && (this._boundingSphere = new ua); + this._shape && this._shape.getBoundingSphere(this._boundingSphere); + return this._boundingSphere; + } + get needTriggerEvent() { + return this._needTriggerEvent; + } + get needCollisionEvent() { + return this._needCollisionEvent; + } + get _isInitialized() { + const t = null === this._shape; + t && x("[Physics]: This component has not been call onLoad yet, please make sure the node has been added to the scene."); + return !t; + } + constructor(t) { + super(); + this.type = void 0; + this._shape = null; + this._aabb = null; + this._boundingSphere = null; + this._isSharedMaterial = !0; + this._needTriggerEvent = !1; + this._needCollisionEvent = !1; + Ml(this, "_material", VEt, this); + Ml(this, "_isTrigger", kEt, this); + Ml(this, "_center", UEt, this); + this.type = t; + } + on(t, e, i, s) { + const n = super.on(t, e, i, s); + this._updateNeedEvent(t); + return n; + } + off(t, e, i) { + super.off(t, e, i); + this._updateNeedEvent(); + } + once(t, e, i) { + const s = super.once(t, e, i); + this._updateNeedEvent(t); + return s; + } + removeAll(t) { + super.removeAll(t); + this._updateNeedEvent(); + } + getGroup() { + return this._isInitialized ? this._shape.getGroup() : 0; + } + setGroup(t) { + this._isInitialized && this._shape.setGroup(t); + } + addGroup(t) { + this._isInitialized && this._shape.addGroup(t); + } + removeGroup(t) { + this._isInitialized && this._shape.removeGroup(t); + } + getMask() { + return this._isInitialized ? this._shape.getMask() : 0; + } + setMask(t) { + this._isInitialized && this._shape.setMask(t); + } + addMask(t) { + this._isInitialized && this._shape.addMask(t); + } + removeMask(t) { + this._isInitialized && this._shape.removeMask(t); + } + onLoad() { + if (ovt.runInEditor) { + this.sharedMaterial = null == this._material ? Ivt.instance.defaultMaterial : this._material; + this._shape = mvt(this.type); + this._shape.initialize(this); + this._shape.onLoad(); + } + } + onEnable() { + this._shape && this._shape.onEnable(); + } + onDisable() { + this._shape && this._shape.onDisable(); + } + onDestroy() { + if (this._shape) { + this._needTriggerEvent = !1; + this._needCollisionEvent = !1; + this._shape.updateEventListener(); + this._material && this._material.off(wvt.EVENT_UPDATE, this._updateMaterial, this); + this._shape.onDestroy(); + } + this._boundingSphere && this._boundingSphere.destroy(); + } + _updateMaterial() { + this._shape && this._shape.setMaterial(this._material); + } + _updateNeedEvent(t) { + if (this.isValid) { + if (void 0 !== t) { + "onCollisionEnter" !== t && "onCollisionStay" !== t && "onCollisionExit" !== t || (this._needCollisionEvent = !0); + "onTriggerEnter" !== t && "onTriggerStay" !== t && "onTriggerExit" !== t || (this._needTriggerEvent = !0); + } else { + this.hasEventListener("onTriggerEnter") || this.hasEventListener("onTriggerStay") || this.hasEventListener("onTriggerExit") || (this._needTriggerEvent = !1); + this.hasEventListener("onCollisionEnter") || this.hasEventListener("onCollisionStay") || this.hasEventListener("onCollisionExit") || (this._needCollisionEvent = !1); + } + this._shape && this._shape.updateEventListener(); + } + } + }, GEt.Type = nSt, GEt.Axis = iSt, zEt), Bl(FEt.prototype, "attachedRigidBody", [ TEt, oh, vEt, EEt, CEt ], Object.getOwnPropertyDescriptor(FEt.prototype, "attachedRigidBody"), FEt.prototype), + Bl(FEt.prototype, "sharedMaterial", [ xEt, wEt, REt, IEt ], Object.getOwnPropertyDescriptor(FEt.prototype, "sharedMaterial"), FEt.prototype), + Bl(FEt.prototype, "isTrigger", [ MEt, BEt ], Object.getOwnPropertyDescriptor(FEt.prototype, "isTrigger"), FEt.prototype), + Bl(FEt.prototype, "center", [ DEt, PEt, OEt ], Object.getOwnPropertyDescriptor(FEt.prototype, "center"), FEt.prototype), + VEt = Bl(FEt.prototype, "_material", [ NEt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), kEt = Bl(FEt.prototype, "_isTrigger", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), UEt = Bl(FEt.prototype, "_center", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Pi; + } + }), FEt)) || LEt)); + HEt || (HEt = function(e) { + return t({ + Collider: e, + ColliderComponent: e + }), e; + }({})); + function jEt(t) { + void 0 === (t = t || {}).includeNormal && (t.includeNormal = !0); + void 0 === t.includeUV && (t.includeUV = !0); + return t; + } + const XEt = new Pi; + const WEt = new Pi; + const YEt = new Pi; + const qEt = new Pi; + const KEt = new Pi; + const JEt = new Pi; + const ZEt = new Pi; + const QEt = new Pi; + const $Et = new Pi; + const tCt = new Pi; + const eCt = new Pi; + const iCt = new Pi; + const sCt = new Pi(0, 0, 0); + const nCt = new Pi(0, 0, 0); + function rCt(t = .5, e = .5, i = 2, s = {}) { + const n = .5 * i; + const r = s.radialSegments || 32; + const o = s.heightSegments || 1; + const a = void 0 === s.capped || s.capped; + const l = s.arc || 2 * Math.PI; + let h = 0; + if (!a) { + t > 0 && h++; + e > 0 && h++; + } + let c = (r + 1) * (o + 1); + a && (c += (r + 1) * h + r * h); + let u = r * o * 2 * 3; + a && (u += r * h * 3); + const _ = new Array(u); + const d = new Array(3 * c); + const p = new Array(3 * c); + const m = new Array(2 * c); + const f = Math.max(t, e); + const g = new Pi(-f, -n, -f); + const y = new Pi(f, n, f); + const b = Math.sqrt(f * f + n * n); + let S = 0; + let A = 0; + !function() { + const s = []; + const a = t - e; + const h = a * a / i * Math.sign(a); + for (let t = 0; t <= o; t++) { + const c = []; + const u = t / o; + const _ = u * a + e; + for (let t = 0; t <= r; ++t) { + const e = t / r; + const s = e * l; + const o = Math.sin(s); + const a = Math.cos(s); + d[3 * S] = _ * o; + d[3 * S + 1] = u * i - n; + d[3 * S + 2] = _ * a; + Pi.normalize(sCt, Pi.set(nCt, o, -h, a)); + p[3 * S] = sCt.x; + p[3 * S + 1] = sCt.y; + p[3 * S + 2] = sCt.z; + m[2 * S] = 2 * (1 - e) % 1; + m[2 * S + 1] = u; + c.push(S); + ++S; + } + s.push(c); + } + for (let t = 0; t < o; ++t) for (let e = 0; e < r; ++e) { + const i = s[t][e]; + const n = s[t + 1][e]; + const r = s[t + 1][e + 1]; + const o = s[t][e + 1]; + _[A] = i; + ++A; + _[A] = o; + ++A; + _[A] = n; + ++A; + _[A] = o; + ++A; + _[A] = r; + ++A; + _[A] = n; + ++A; + } + }(); + if (a) { + e > 0 && T(!1); + t > 0 && T(!0); + } + return { + positions: d, + normals: p, + uvs: m, + indices: _, + minPos: g, + maxPos: y, + boundingRadius: b + }; + function T(i) { + const s = i ? t : e; + const o = i ? 1 : -1; + const a = S; + for (let t = 1; t <= r; ++t) { + d[3 * S] = 0; + d[3 * S + 1] = n * o; + d[3 * S + 2] = 0; + p[3 * S] = 0; + p[3 * S + 1] = o; + p[3 * S + 2] = 0; + m[2 * S] = .5; + m[2 * S + 1] = .5; + ++S; + } + const h = S; + for (let t = 0; t <= r; ++t) { + const e = t / r * l; + const i = Math.cos(e); + const a = Math.sin(e); + d[3 * S] = s * a; + d[3 * S + 1] = n * o; + d[3 * S + 2] = s * i; + p[3 * S] = 0; + p[3 * S + 1] = o; + p[3 * S + 2] = 0; + m[2 * S] = .5 - .5 * a * o; + m[2 * S + 1] = .5 + .5 * i; + ++S; + } + for (let t = 0; t < r; ++t) { + const e = a + t; + const s = h + t; + if (i) { + _[A] = s + 1; + ++A; + _[A] = e; + ++A; + _[A] = s; + ++A; + } else { + _[A] = e; + ++A; + _[A] = s + 1; + ++A; + _[A] = s; + ++A; + } + } + } + } + const oCt = new Pi(0, 0, 0); + const aCt = new Pi(0, 0, 0); + const lCt = new Pi(0, 0, 0); + const hCt = new Pi(0, 0, 0); + const cCt = new Pi(0, 0, 0); + const uCt = new Pi(0, 0, 0); + const _Ct = new Pi(0, 0, 0); + const dCt = new Pi(0, 0, 0); + const pCt = new Pi(0, 0, 0); + var mCt = Object.freeze({ + __proto__: null, + box: function(t) { + const e = (t = t || {}).widthSegments || 1; + const i = t.heightSegments || 1; + const s = t.lengthSegments || 1; + const n = (t.width || 1) / 2; + const r = (t.height || 1) / 2; + const o = (t.length || 1) / 2; + const a = [ Pi.set(KEt, -n, -r, o), Pi.set(JEt, n, -r, o), Pi.set(ZEt, n, r, o), Pi.set(QEt, -n, r, o), Pi.set($Et, n, -r, -o), Pi.set(tCt, -n, -r, -o), Pi.set(eCt, -n, r, -o), Pi.set(iCt, n, r, -o) ]; + const l = [ [ 2, 3, 1 ], [ 4, 5, 7 ], [ 7, 6, 2 ], [ 1, 0, 4 ], [ 1, 4, 2 ], [ 5, 0, 6 ] ]; + const h = [ [ 0, 0, 1 ], [ 0, 0, -1 ], [ 0, 1, 0 ], [ 0, -1, 0 ], [ 1, 0, 0 ], [ -1, 0, 0 ] ]; + const c = [ [ -1, 0, 0, 1 ], [ -1, 0, 0, 1 ], [ -1, 0, 0, 1 ], [ -1, 0, 0, 1 ], [ 0, 0, -1, 1 ], [ 0, 0, 1, 1 ] ]; + const u = []; + const _ = []; + const d = []; + const p = []; + const m = []; + const f = new Pi(-n, -r, -o); + const g = new Pi(n, r, o); + const y = Math.sqrt(n * n + r * r + o * o); + function b(t, e, i) { + let s; + let n; + let r; + let o; + const f = u.length / 3; + const g = l[t]; + const y = h[t]; + const b = c[t]; + for (o = 0; o <= i; o++) for (r = 0; r <= e; r++) { + s = r / e; + n = o / i; + Pi.lerp(XEt, a[g[0]], a[g[1]], s); + Pi.lerp(WEt, a[g[0]], a[g[2]], n); + Pi.subtract(YEt, WEt, a[g[0]]); + Pi.add(qEt, XEt, YEt); + u.push(qEt.x, qEt.y, qEt.z); + _.push(y[0], y[1], y[2]); + d.push(s, n); + p.push(b[0], b[1], b[2], b[3]); + if (r < e && o < i) { + const t = e + 1; + const i = r + o * t; + const s = r + (o + 1) * t; + const n = r + 1 + (o + 1) * t; + const a = r + 1 + o * t; + m.push(f + i, f + a, f + s); + m.push(f + s, f + a, f + n); + } + } + } + b(0, e, i); + b(4, s, i); + b(1, e, i); + b(5, s, i); + b(3, e, s); + b(2, e, s); + return { + positions: u, + normals: _, + uvs: d, + tangents: p, + indices: m, + minPos: f, + maxPos: g, + boundingRadius: y + }; + }, + cone: function(t = .5, e = 1, i = {}) { + return rCt(0, t, e, i); + }, + cylinder: rCt, + plane: function(t) { + const e = function(t) { + (t = jEt(t)).width = t.width || 10; + t.length = t.length || 10; + t.widthSegments = t.widthSegments || 10; + t.lengthSegments = t.lengthSegments || 10; + return t; + }(t); + const {width: i, length: s, widthSegments: n, lengthSegments: r} = e; + const o = .5 * i; + const a = .5 * s; + const l = []; + const h = []; + const c = []; + const u = new Pi(-o, 0, -a); + const _ = new Pi(o, 0, a); + const d = Math.sqrt(i * i + s * s); + Pi.set(cCt, -o, 0, a); + Pi.set(uCt, o, 0, a); + Pi.set(_Ct, -o, 0, -a); + for (let t = 0; t <= r; t++) for (let i = 0; i <= n; i++) { + const s = i / n; + const o = t / r; + Pi.lerp(oCt, cCt, uCt, s); + Pi.lerp(aCt, cCt, _Ct, o); + Pi.subtract(lCt, aCt, cCt); + Pi.add(hCt, oCt, lCt); + l.push(hCt.x, hCt.y, hCt.z); + e.includeUV && h.push(s, o); + if (i < n && t < r) { + const e = n + 1; + const s = i + t * e; + const r = i + (t + 1) * e; + const o = i + 1 + (t + 1) * e; + const a = i + 1 + t * e; + c.push(s, a, r); + c.push(a, o, r); + } + } + const p = { + positions: l, + indices: c, + minPos: u, + maxPos: _, + boundingRadius: d + }; + if (e.includeNormal) { + const t = (r + 1) * (n + 1); + const e = new Array(3 * t); + p.normals = e; + for (let i = 0; i < t; ++i) { + e[3 * i + 0] = 0; + e[3 * i + 1] = 1; + e[3 * i + 2] = 0; + } + } + e.includeUV && (p.uvs = h); + return p; + }, + quad: function(t) { + const e = jEt(t); + const i = { + positions: [ -.5, -.5, 0, -.5, .5, 0, .5, .5, 0, .5, -.5, 0 ], + indices: [ 0, 3, 1, 3, 2, 1 ], + minPos: { + x: -.5, + y: -.5, + z: 0 + }, + maxPos: { + x: .5, + y: .5, + z: 0 + }, + boundingRadius: Math.sqrt(.5) + }; + !1 !== e.includeNormal && (i.normals = [ 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1 ]); + !1 !== e.includeUV && (i.uvs = [ 0, 0, 0, 1, 1, 1, 1, 0 ]); + return i; + }, + sphere: function(t = .5, e = {}) { + const i = void 0 !== e.segments ? e.segments : 32; + const s = []; + const n = []; + const r = []; + const o = []; + const a = new Pi(-t, -t, -t); + const l = new Pi(t, t, t); + const h = t; + for (let e = 0; e <= i; ++e) { + const a = e * Math.PI / i; + const l = Math.sin(a); + const h = -Math.cos(a); + for (let a = 0; a <= i; ++a) { + const c = 2 * a * Math.PI / i - Math.PI / 2; + const u = Math.sin(c) * l; + const _ = h; + const d = Math.cos(c) * l; + const p = a / i; + const m = e / i; + s.push(u * t, _ * t, d * t); + n.push(u, _, d); + r.push(p, m); + if (e < i && a < i) { + const t = i + 1; + const s = t * e + a; + const n = t * (e + 1) + a; + const r = t * (e + 1) + a + 1; + const l = t * e + a + 1; + o.push(s, l, n); + o.push(l, r, n); + } + } + } + return { + positions: s, + indices: o, + normals: n, + uvs: r, + minPos: a, + maxPos: l, + boundingRadius: h + }; + }, + torus: function(t = .4, e = .1, i = {}) { + const s = i.radialSegments || 32; + const n = i.tubularSegments || 32; + const r = i.arc || 2 * Math.PI; + const o = []; + const a = []; + const l = []; + const h = []; + const c = new Pi(-t - e, -e, -t - e); + const u = new Pi(t + e, e, t + e); + const _ = t + e; + for (let i = 0; i <= s; i++) for (let c = 0; c <= n; c++) { + const u = c / n; + const _ = i / s; + const d = u * r; + const p = _ * Math.PI * 2; + const m = (t + e * Math.cos(p)) * Math.sin(d); + const f = e * Math.sin(p); + const g = (t + e * Math.cos(p)) * Math.cos(d); + const y = Math.sin(d) * Math.cos(p); + const b = Math.sin(p); + const S = Math.cos(d) * Math.cos(p); + o.push(m, f, g); + a.push(y, b, S); + l.push(u, _); + if (c < n && i < s) { + const t = n + 1; + const e = t * i + c; + const s = t * (i + 1) + c; + const r = t * (i + 1) + c + 1; + const o = t * i + c + 1; + h.push(e, o, s); + h.push(o, r, s); + } + } + return { + positions: o, + normals: a, + uvs: l, + indices: h, + minPos: c, + maxPos: u, + boundingRadius: _ + }; + }, + capsule: function(t = .5, e = .5, i = 2, s = {}) { + const n = i - t - e; + const r = s.sides || 32; + const o = s.heightSegments || 32; + const a = e / i; + const l = n / i; + const h = t / i; + const c = Math.floor(o * a); + const u = Math.floor(o * h); + const _ = Math.floor(o * l); + const d = n + e - i / 2; + const p = e - i / 2; + const m = e - i / 2; + const f = s.arc || 2 * Math.PI; + const g = []; + const y = []; + const b = []; + const S = []; + const A = Math.max(t, e); + const T = new Pi(-A, -i / 2, -A); + const v = new Pi(A, i / 2, A); + const E = i / 2; + let C = 0; + const x = []; + !function() { + for (let t = 0; t <= c; ++t) { + const i = t * Math.PI / c / 2; + const s = Math.sin(i); + const n = -Math.cos(i); + for (let i = 0; i <= r; ++i) { + const a = 2 * i * Math.PI / r - Math.PI / 2; + const l = Math.sin(a); + const h = Math.cos(a); + const u = l * s; + const _ = n; + const d = h * s; + const p = i / r; + const f = t / o; + g.push(u * e, _ * e + m, d * e); + y.push(u, _, d); + b.push(p, f); + if (t < c && i < r) { + const e = r + 1; + const s = e * t + i; + const n = e * (t + 1) + i; + const o = e * (t + 1) + i + 1; + const a = e * t + i + 1; + S.push(s, a, n); + S.push(a, o, n); + } + ++C; + } + } + }(); + !function() { + const i = (t - e) / n; + for (let s = 0; s <= _; s++) { + const o = []; + const h = s / _; + const c = h * (t - e) + e; + for (let t = 0; t <= r; ++t) { + const e = t / r; + const s = h * l + a; + const u = e * f - f / 4; + const _ = Math.sin(u); + const d = Math.cos(u); + g.push(c * _); + g.push(h * n + p); + g.push(c * d); + Pi.normalize(dCt, Pi.set(pCt, _, -i, d)); + y.push(dCt.x); + y.push(dCt.y); + y.push(dCt.z); + b.push(e, s); + o.push(C); + ++C; + } + x.push(o); + } + for (let t = 0; t < _; ++t) for (let e = 0; e < r; ++e) { + const i = x[t][e]; + const s = x[t + 1][e]; + const n = x[t + 1][e + 1]; + const r = x[t][e + 1]; + S.push(i); + S.push(r); + S.push(s); + S.push(r); + S.push(n); + S.push(s); + } + }(); + !function() { + for (let e = 0; e <= u; ++e) { + const i = e * Math.PI / u / 2 + Math.PI / 2; + const s = Math.sin(i); + const n = -Math.cos(i); + for (let i = 0; i <= r; ++i) { + const a = 2 * i * Math.PI / r - Math.PI / 2; + const l = Math.sin(a); + const c = Math.cos(a); + const p = l * s; + const m = n; + const f = c * s; + const A = i / r; + const T = e / o + (1 - h); + g.push(p * t, m * t + d, f * t); + y.push(p, m, f); + b.push(A, T); + if (e < u && i < r) { + const t = r + 1; + const s = t * e + i + x[_][r] + 1; + const n = t * (e + 1) + i + x[_][r] + 1; + const o = t * (e + 1) + i + 1 + x[_][r] + 1; + const a = t * e + i + 1 + x[_][r] + 1; + S.push(s, a, n); + S.push(a, o, n); + } + } + } + }(); + return { + positions: g, + normals: y, + uvs: b, + indices: S, + minPos: T, + maxPos: v, + boundingRadius: E + }; + }, + circle: function(t) { + const e = function(t) { + (t = jEt(t)).segments = 64; + return t; + }(t); + const i = e.segments; + const s = new Array(3 * (i + 1)); + s[0] = 0; + s[1] = 0; + s[2] = 0; + const n = new Array(1 + 2 * i); + n[0] = 0; + const r = 2 * Math.PI / i; + for (let t = 0; t < i; ++t) { + const e = r * t; + const i = Math.cos(e); + const o = Math.sin(e); + const a = 3 * (t + 1); + s[a + 0] = i; + s[a + 1] = o; + s[a + 2] = 0; + const l = 2 * t; + n[1 + l] = t + 1; + n[1 + (l + 1)] = t + 2; + } + i > 0 && (n[n.length - 1] = 1); + return { + positions: s, + indices: n, + minPos: { + x: 1, + y: 1, + z: 0 + }, + maxPos: { + x: -1, + y: -1, + z: 0 + }, + boundingRadius: 1, + primitiveMode: Xs.TRIANGLE_FAN + }; + }, + translate: function(t, e) { + const i = e.x || 0; + const s = e.y || 0; + const n = e.z || 0; + const r = Math.floor(t.positions.length / 3); + for (let e = 0; e < r; ++e) { + const r = 3 * e; + const o = 3 * e + 1; + const a = 3 * e + 2; + t.positions[r] += i; + t.positions[o] += s; + t.positions[a] += n; + } + if (t.minPos) { + t.minPos.x += i; + t.minPos.y += s; + t.minPos.z += n; + } + if (t.maxPos) { + t.maxPos.x += i; + t.maxPos.y += s; + t.maxPos.z += n; + } + return t; + }, + scale: function(t, e) { + const i = e.x || 0; + const s = e.y || 0; + const n = e.z || 0; + const r = Math.floor(t.positions.length / 3); + for (let e = 0; e < r; ++e) { + const r = 3 * e; + const o = 3 * e + 1; + const a = 3 * e + 2; + t.positions[r] *= i; + t.positions[o] *= s; + t.positions[a] *= n; + } + if (t.minPos) { + t.minPos.x *= i; + t.minPos.y *= s; + t.minPos.z *= n; + } + if (t.maxPos) { + t.maxPos.x *= i; + t.maxPos.y *= s; + t.maxPos.z *= n; + } + t.boundingRadius = Math.max(Math.max(i, s), n); + return t; + }, + wireframed: function(t) { + const {indices: e} = t; + if (!e) return t; + if (t.primitiveMode && t.primitiveMode !== Xs.TRIANGLE_LIST) return t; + const i = [ [ 0, 1 ], [ 1, 2 ], [ 2, 0 ] ]; + const s = []; + const n = {}; + for (let t = 0; t < e.length; t += 3) for (let r = 0; r < 3; ++r) { + const o = e[t + i[r][0]]; + const a = e[t + i[r][1]]; + const l = o > a ? a << 16 | o : o << 16 | a; + if (void 0 === n[l]) { + n[l] = 0; + s.push(o, a); + } + } + t.indices = s; + t.primitiveMode = Xs.LINE_LIST; + return t; + }, + wireframe: function(t) { + const e = [ [ 0, 1 ], [ 1, 2 ], [ 2, 0 ] ]; + const i = []; + const s = {}; + for (let n = 0; n < t.length; n += 3) for (let r = 0; r < 3; ++r) { + const o = t[n + e[r][0]]; + const a = t[n + e[r][1]]; + const l = o > a ? a << 16 | o : o << 16 | a; + if (void 0 === s[l]) { + s[l] = 0; + i.push(o, a); + } + } + return i; + }, + invWinding: function(t) { + const e = []; + for (let i = 0; i < t.length; i += 3) e.push(t[i], t[i + 2], t[i + 1]); + return e; + }, + toWavefrontOBJ: function(t, e = 1) { + if (!t.indices || !t.uvs || !t.normals || void 0 !== t.primitiveMode && t.primitiveMode !== Xs.TRIANGLE_LIST) return ""; + const i = t.positions; + const s = t.uvs; + const n = t.normals; + const r = t.indices; + const o = t => `${r[t] + 1}/${r[t] + 1}/${r[t] + 1}`; + let a = ""; + for (let t = 0; t < i.length; t += 3) a += `v ${i[t] * e} ${i[t + 1] * e} ${i[t + 2] * e}\n`; + for (let t = 0; t < s.length; t += 2) a += `vt ${s[t]} ${s[t + 1]}\n`; + for (let t = 0; t < n.length; t += 3) a += `vn ${n[t]} ${n[t + 1]} ${n[t + 2]}\n`; + for (let t = 0; t < r.length; t += 3) a += `f ${o(t)} ${o(t + 1)} ${o(t + 2)}\n`; + return a; + }, + normals: function(t, e, i = 1) { + const s = new Array(2 * t.length); + for (let n = 0; n < t.length / 3; ++n) { + const r = 3 * n; + const o = 6 * n; + s[o + 0] = t[r + 0]; + s[o + 1] = t[r + 1]; + s[o + 2] = t[r + 2]; + s[o + 3] = t[r + 0] + e[r + 0] * i; + s[o + 4] = t[r + 1] + e[r + 1] * i; + s[o + 5] = t[r + 2] + e[r + 2] * i; + } + return s; + }, + applyDefaultGeometryOptions: jEt + }); + t("primitives", mCt); + const fCt = new Pi; + function gCt(t) { + t.x = Math.abs(t.x); + t.y = Math.abs(t.y); + t.z = Math.abs(t.z); + return t; + } + var yCt = Object.freeze({ + __proto__: null, + setWrap: function(t, e) { + t.__cc_wrapper__ = e; + }, + getWrap: function(t) { + return t.__cc_wrapper__; + }, + maxComponent: function(t) { + return Math.max(t.x, Math.max(t.y, t.z)); + }, + VEC3_0: fCt, + TriggerEventObject: { + type: "onTriggerEnter", + selfCollider: null, + otherCollider: null, + impl: null + }, + CollisionEventObject: { + type: "onCollisionEnter", + selfCollider: null, + otherCollider: null, + contacts: [], + impl: null + }, + shrinkPositions: function(t) { + const e = []; + if (t.length >= 3) { + e[0] = t[0], e[1] = t[1], e[2] = t[2]; + const i = t.length; + for (let s = 3; s < i; s += 3) { + const i = t[s]; + const n = t[s + 1]; + const r = t[s + 2]; + const o = e.length; + let a = !0; + for (let t = 0; t < o; t += 3) if (ci(i, e[t]) && ci(n, e[t + 1]) && ci(r, e[t + 2])) { + a = !1; + break; + } + if (a) { + e.push(i); + e.push(n); + e.push(r); + } + } + } + return e; + }, + absolute: gCt, + cylinder: rCt + }); + var bCt, SCt, ACt, TCt, vCt, ECt, CCt, xCt, wCt; + let RCt = function(e) { + return t({ + BoxCollider: e, + BoxColliderComponent: e + }), e; + }((bCt = Ul("cc.BoxCollider"), SCt = sh(), ACt = $l(), TCt = Th(Pi), vCt = lh(), + bCt(ECt = SCt(ECt = ACt(ECt = Ql(ECt = (CCt = (wCt = class extends HEt { + get size() { + return this._size; + } + set size(t) { + if (!Pi.strictEquals(this._size, t)) { + Pi.copy(this._size, t); + gCt(this._size); + this._shape && this.shape.updateSize(); + } + } + get shape() { + return this._shape; + } + constructor() { + super(nSt.BOX); + Ml(this, "_size", xCt, this); + } + }, wCt), Bl(CCt.prototype, "size", [ TCt, vCt ], Object.getOwnPropertyDescriptor(CCt.prototype, "size"), CCt.prototype), + xCt = Bl(CCt.prototype, "_size", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Pi(1, 1, 1); + } + }), CCt)) || ECt) || ECt) || ECt) || ECt)); + var ICt, MCt, BCt, DCt, PCt, OCt, NCt, LCt; + let FCt = function(e) { + return t({ + SphereCollider: e, + SphereColliderComponent: e + }), e; + }((ICt = Ul("cc.SphereCollider"), MCt = sh(), BCt = $l(), DCt = lh(), ICt(PCt = MCt(PCt = BCt(PCt = Ql(PCt = (OCt = (LCt = class extends HEt { + get radius() { + return this._radius; + } + set radius(t) { + if (this._radius !== t) { + this._radius = Math.abs(t); + this._shape && this.shape.updateRadius(); + } + } + get shape() { + return this._shape; + } + constructor() { + super(nSt.SPHERE); + Ml(this, "_radius", NCt, this); + } + }, LCt), Bl(OCt.prototype, "radius", [ DCt ], Object.getOwnPropertyDescriptor(OCt.prototype, "radius"), OCt.prototype), + NCt = Bl(OCt.prototype, "_radius", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .5; + } + }), OCt)) || PCt) || PCt) || PCt) || PCt)); + var VCt, kCt, UCt, GCt, zCt, HCt, jCt, XCt, WCt, YCt, qCt, KCt, JCt; + let ZCt = function(e) { + return t({ + CapsuleCollider: e, + CapsuleColliderComponent: e + }), e; + }((VCt = Ul("cc.CapsuleCollider"), kCt = sh(), UCt = $l(), GCt = lh(), zCt = lh(), + HCt = Th(iSt), jCt = lh(), VCt(XCt = kCt(XCt = UCt(XCt = Ql(XCt = (WCt = (JCt = class extends HEt { + get radius() { + return this._radius; + } + set radius(t) { + if (this._radius !== t) { + this._radius = Math.abs(t); + this._shape && this.shape.setRadius(t); + } + } + get cylinderHeight() { + return this._cylinderHeight; + } + set cylinderHeight(t) { + if (this._cylinderHeight !== t) { + this._cylinderHeight = Math.abs(t); + this._shape && this.shape.setCylinderHeight(t); + } + } + get direction() { + return this._direction; + } + set direction(t) { + if (!((t = Math.floor(t)) < iSt.X_AXIS || t > iSt.Z_AXIS) && this._direction !== t) { + this._direction = t; + this._shape && this.shape.setDirection(t); + } + } + get height() { + return 2 * this._radius + this._cylinderHeight; + } + set height(t) { + let e = t - 2 * this._radius; + e < 0 && (e = 0); + this.cylinderHeight = e; + } + get worldHeight() { + return 2 * this._radius * this._getRadiusScale() + this._cylinderHeight * this._getHeightScale(); + } + get shape() { + return this._shape; + } + constructor() { + super(nSt.CAPSULE); + Ml(this, "_radius", YCt, this); + Ml(this, "_cylinderHeight", qCt, this); + Ml(this, "_direction", KCt, this); + } + _getRadiusScale() { + if (null == this.node) return 1; + const t = this.node.worldScale; + return this._direction === iSt.Y_AXIS ? Math.abs(Ri(t.x, t.z)) : this._direction === iSt.X_AXIS ? Math.abs(Ri(t.y, t.z)) : Math.abs(Ri(t.x, t.y)); + } + _getHeightScale() { + if (null == this.node) return 1; + const t = this.node.worldScale; + return this._direction === iSt.Y_AXIS ? Math.abs(t.y) : this._direction === iSt.X_AXIS ? Math.abs(t.x) : Math.abs(t.z); + } + }, JCt), Bl(WCt.prototype, "radius", [ GCt ], Object.getOwnPropertyDescriptor(WCt.prototype, "radius"), WCt.prototype), + Bl(WCt.prototype, "cylinderHeight", [ zCt ], Object.getOwnPropertyDescriptor(WCt.prototype, "cylinderHeight"), WCt.prototype), + Bl(WCt.prototype, "direction", [ HCt, jCt ], Object.getOwnPropertyDescriptor(WCt.prototype, "direction"), WCt.prototype), + YCt = Bl(WCt.prototype, "_radius", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .5; + } + }), qCt = Bl(WCt.prototype, "_cylinderHeight", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), KCt = Bl(WCt.prototype, "_direction", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return iSt.Y_AXIS; + } + }), WCt)) || XCt) || XCt) || XCt) || XCt)); + var QCt, $Ct, txt, ext, ixt, sxt, nxt, rxt, oxt, axt, lxt, hxt, cxt; + let uxt = function(e) { + return t({ + CylinderCollider: e, + CylinderColliderComponent: e + }), e; + }((QCt = Ul("cc.CylinderCollider"), $Ct = sh(), txt = $l(), ext = lh(), ixt = lh(), + sxt = Th(iSt), nxt = lh(), QCt(rxt = $Ct(rxt = txt(rxt = Ql(rxt = (oxt = (cxt = class extends HEt { + get radius() { + return this._radius; + } + set radius(t) { + if (this._radius !== t) { + this._radius = Math.abs(t); + this._shape && this.shape.setRadius(t); + } + } + get height() { + return this._height; + } + set height(t) { + if (this._height !== t) { + this._height = Math.abs(t); + this._shape && this.shape.setHeight(t); + } + } + get direction() { + return this._direction; + } + set direction(t) { + if (this._direction !== t && !(t < iSt.X_AXIS || t > iSt.Z_AXIS)) { + this._direction = t; + this._shape && this.shape.setDirection(t); + } + } + get shape() { + return this._shape; + } + constructor() { + super(nSt.CYLINDER); + Ml(this, "_radius", axt, this); + Ml(this, "_height", lxt, this); + Ml(this, "_direction", hxt, this); + } + }, cxt), Bl(oxt.prototype, "radius", [ ext ], Object.getOwnPropertyDescriptor(oxt.prototype, "radius"), oxt.prototype), + Bl(oxt.prototype, "height", [ ixt ], Object.getOwnPropertyDescriptor(oxt.prototype, "height"), oxt.prototype), + Bl(oxt.prototype, "direction", [ sxt, nxt ], Object.getOwnPropertyDescriptor(oxt.prototype, "direction"), oxt.prototype), + axt = Bl(oxt.prototype, "_radius", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .5; + } + }), lxt = Bl(oxt.prototype, "_height", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 2; + } + }), hxt = Bl(oxt.prototype, "_direction", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return iSt.Y_AXIS; + } + }), oxt)) || rxt) || rxt) || rxt) || rxt)); + var _xt, dxt, pxt, mxt, fxt, gxt, yxt, bxt, Sxt, Axt, Txt, vxt, Ext; + let Cxt = t("ConeCollider", (_xt = Ul("cc.ConeCollider"), dxt = sh(), pxt = $l(), + mxt = lh(), fxt = lh(), gxt = Th(iSt), yxt = lh(), _xt(bxt = dxt(bxt = pxt(bxt = Ql(bxt = (Sxt = (Ext = class extends HEt { + get radius() { + return this._radius; + } + set radius(t) { + if (this._radius !== t) { + this._radius = Math.abs(t); + this._shape && this.shape.setRadius(t); + } + } + get height() { + return this._height; + } + set height(t) { + if (this._height !== t) { + t < 0 && (t = 0); + this._height = t; + this._shape && this.shape.setHeight(t); + } + } + get direction() { + return this._direction; + } + set direction(t) { + if (this._direction !== t && !(t < iSt.X_AXIS || t > iSt.Z_AXIS)) { + this._direction = t; + this._shape && this.shape.setDirection(t); + } + } + get shape() { + return this._shape; + } + constructor() { + super(nSt.CONE); + Ml(this, "_radius", Axt, this); + Ml(this, "_height", Txt, this); + Ml(this, "_direction", vxt, this); + } + }, Ext), Bl(Sxt.prototype, "radius", [ mxt ], Object.getOwnPropertyDescriptor(Sxt.prototype, "radius"), Sxt.prototype), + Bl(Sxt.prototype, "height", [ fxt ], Object.getOwnPropertyDescriptor(Sxt.prototype, "height"), Sxt.prototype), + Bl(Sxt.prototype, "direction", [ gxt, yxt ], Object.getOwnPropertyDescriptor(Sxt.prototype, "direction"), Sxt.prototype), + Axt = Bl(Sxt.prototype, "_radius", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .5; + } + }), Txt = Bl(Sxt.prototype, "_height", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), vxt = Bl(Sxt.prototype, "_direction", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return iSt.Y_AXIS; + } + }), Sxt)) || bxt) || bxt) || bxt) || bxt)); + var xxt, wxt, Rxt, Ixt, Mxt, Bxt, Dxt, Pxt, Oxt, Nxt, Lxt; + let Fxt = function(e) { + return t({ + MeshCollider: e, + MeshColliderComponent: e + }), e; + }((xxt = Ul("cc.MeshCollider"), wxt = sh(), Rxt = $l(), Ixt = Th(Ez), Mxt = lh(), + Bxt = lh(), xxt(Dxt = wxt(Dxt = Rxt(Dxt = Ql(Dxt = (Pxt = (Lxt = class extends HEt { + get mesh() { + return this._mesh; + } + set mesh(t) { + if (this._mesh !== t) { + this._mesh = t; + this._shape && this.shape.setMesh(this._mesh); + } + } + get convex() { + return this._convex; + } + set convex(t) { + this._convex !== t && (this._convex = t); + } + get shape() { + return this._shape; + } + constructor() { + super(nSt.MESH); + Ml(this, "_mesh", Oxt, this); + Ml(this, "_convex", Nxt, this); + } + }, Lxt), Bl(Pxt.prototype, "mesh", [ Ixt, Mxt ], Object.getOwnPropertyDescriptor(Pxt.prototype, "mesh"), Pxt.prototype), + Bl(Pxt.prototype, "convex", [ nh, Bxt ], Object.getOwnPropertyDescriptor(Pxt.prototype, "convex"), Pxt.prototype), + Oxt = Bl(Pxt.prototype, "_mesh", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Nxt = Bl(Pxt.prototype, "_convex", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Pxt)) || Dxt) || Dxt) || Dxt) || Dxt)); + var Vxt, kxt, Uxt, Gxt, zxt, Hxt, jxt, Xxt, Wxt, Yxt, qxt, Kxt, Jxt, Zxt, Qxt, $xt, twt, ewt, iwt; + let swt = t("ConstantForce", (Vxt = Ul("cc.ConstantForce"), kxt = sh(), Uxt = Gl(SEt), + Gxt = $l(), zxt = ph(), Hxt = lh(), jxt = ph(), Xxt = lh(), Wxt = ph(), Yxt = lh(), + qxt = ph(), Kxt = lh(), Vxt(Jxt = kxt(Jxt = Uxt(Jxt = Gxt(Jxt = Hl(Jxt = Ql(Jxt = (Zxt = (iwt = class extends Qc { + constructor(...t) { + super(...t); + this._rigidBody = null; + Ml(this, "_force", Qxt, this); + Ml(this, "_localForce", $xt, this); + Ml(this, "_torque", twt, this); + Ml(this, "_localTorque", ewt, this); + this._mask = 0; + } + get force() { + return this._force; + } + set force(t) { + Pi.copy(this._force, t); + this._maskUpdate(this._force, 1); + } + get localForce() { + return this._localForce; + } + set localForce(t) { + Pi.copy(this._localForce, t); + this._maskUpdate(this.localForce, 2); + } + get torque() { + return this._torque; + } + set torque(t) { + Pi.copy(this._torque, t); + this._maskUpdate(this._torque, 4); + } + get localTorque() { + return this._localTorque; + } + set localTorque(t) { + Pi.copy(this._localTorque, t); + this._maskUpdate(this._localTorque, 8); + } + onLoad() { + this._rigidBody = this.node.getComponent(SEt); + this._maskUpdate(this._force, 1); + this._maskUpdate(this._localForce, 2); + this._maskUpdate(this._torque, 4); + this._maskUpdate(this._localTorque, 8); + } + lateUpdate(t) { + if (null != this._rigidBody && 0 !== this._mask) { + 1 & this._mask && this._rigidBody.applyForce(this._force); + 2 & this._mask && this._rigidBody.applyLocalForce(this.localForce); + 4 & this._mask && this._rigidBody.applyTorque(this._torque); + 8 & this._mask && this._rigidBody.applyLocalTorque(this._localTorque); + } + } + _maskUpdate(t, e) { + t.strictEquals(Pi.ZERO) ? this._mask &= ~e : this._mask |= e; + } + }, iwt), Qxt = Bl(Zxt.prototype, "_force", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Pi; + } + }), $xt = Bl(Zxt.prototype, "_localForce", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Pi; + } + }), twt = Bl(Zxt.prototype, "_torque", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Pi; + } + }), ewt = Bl(Zxt.prototype, "_localTorque", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Pi; + } + }), Bl(Zxt.prototype, "force", [ zxt, Hxt ], Object.getOwnPropertyDescriptor(Zxt.prototype, "force"), Zxt.prototype), + Bl(Zxt.prototype, "localForce", [ jxt, Xxt ], Object.getOwnPropertyDescriptor(Zxt.prototype, "localForce"), Zxt.prototype), + Bl(Zxt.prototype, "torque", [ Wxt, Yxt ], Object.getOwnPropertyDescriptor(Zxt.prototype, "torque"), Zxt.prototype), + Bl(Zxt.prototype, "localTorque", [ qxt, Kxt ], Object.getOwnPropertyDescriptor(Zxt.prototype, "localTorque"), Zxt.prototype), + Zxt)) || Jxt) || Jxt) || Jxt) || Jxt) || Jxt) || Jxt)); + var nwt, rwt, owt, awt, lwt, hwt, cwt, uwt, _wt, dwt, pwt, mwt, fwt; + t("TERRAIN_MAX_LEVELS", 4); + const gwt = t("TERRAIN_MAX_BLEND_LAYERS", 4); + const ywt = t("TERRAIN_MAX_LAYER_COUNT", 256); + const bwt = t("TERRAIN_BLOCK_TILE_COMPLEXITY", 32); + const Swt = t("TERRAIN_BLOCK_VERTEX_COMPLEXITY", 33); + const Awt = t("TERRAIN_BLOCK_VERTEX_SIZE", 8); + const Twt = t("TERRAIN_HEIGHT_BASE", 32768); + const vwt = t("TERRAIN_HEIGHT_FACTORY", 1 / 512); + const Ewt = t("TERRAIN_HEIGHT_FMIN", -Twt * vwt); + const Cwt = t("TERRAIN_HEIGHT_FMAX", (65535 - Twt) * vwt); + t("TERRAIN_NORTH_INDEX", 0); + t("TERRAIN_SOUTH_INDEX", 1); + t("TERRAIN_WEST_INDEX", 2); + t("TERRAIN_EAST_INDEX", 3); + const xwt = t("TERRAIN_DATA_VERSION", 16842753); + const wwt = t("TERRAIN_DATA_VERSION2", 16842754); + const Rwt = t("TERRAIN_DATA_VERSION3", 16842755); + const Iwt = t("TERRAIN_DATA_VERSION4", 16842756); + const Mwt = t("TERRAIN_DATA_VERSION5", 16842757); + const Bwt = t("TERRAIN_DATA_VERSION6", 16842758); + const Dwt = t("TERRAIN_DATA_VERSION_DEFAULT", 16843025); + class Pwt { + constructor() { + this.length = 0; + this.buffer = new Uint8Array(2048); + this._buffView = new DataView(this.buffer.buffer); + this._seekPos = 0; + } + reserve(t) { + if (this.buffer.byteLength > t) return; + let e = this.buffer.byteLength; + for (;e < t; ) e += e; + const i = new Uint8Array(e); + for (let t = 0; t < this.length; ++t) i[t] = this.buffer[t]; + this.buffer = i; + this._buffView = new DataView(this.buffer.buffer); + } + assign(t) { + this.buffer = t; + this.length = t.length; + this._seekPos = t.byteOffset; + this._buffView = new DataView(t.buffer); + } + writeInt8(t) { + this.reserve(this.length + 1); + this._buffView.setInt8(this.length, t); + this.length += 1; + } + writeInt16(t) { + this.reserve(this.length + 2); + this._buffView.setInt16(this.length, t, !0); + this.length += 2; + } + writeInt32(t) { + this.reserve(this.length + 4); + this._buffView.setInt32(this.length, t, !0); + this.length += 4; + } + writeIntArray(t) { + this.reserve(this.length + 4 * t.length); + for (let e = 0; e < t.length; ++e) this._buffView.setInt32(this.length + 4 * e, t[e], !0); + this.length += 4 * t.length; + } + writeFloat(t) { + this.reserve(this.length + 4); + this._buffView.setFloat32(this.length, t, !0); + this.length += 4; + } + writeFloatArray(t) { + this.reserve(this.length + 4 * t.length); + for (let e = 0; e < t.length; ++e) this._buffView.setFloat32(this.length + 4 * e, t[e], !0); + this.length += 4 * t.length; + } + writeString(t) { + this.reserve(this.length + t.length + 4); + this._buffView.setInt32(this.length, t.length, !0); + for (let e = 0; e < t.length; ++e) this._buffView.setInt8(this.length + 4 + e, t.charCodeAt(e)); + this.length += t.length + 4; + } + readInt8() { + const t = this._buffView.getInt8(this._seekPos); + this._seekPos += 1; + return t; + } + readInt16() { + const t = this._buffView.getInt16(this._seekPos, !0); + this._seekPos += 2; + return t; + } + readInt() { + const t = this._buffView.getInt32(this._seekPos, !0); + this._seekPos += 4; + return t; + } + readIntArray(t) { + for (let e = 0; e < t.length; ++e) t[e] = this._buffView.getInt32(this._seekPos + 4 * e, !0); + this._seekPos += 4 * t.length; + return t; + } + readFloat() { + const t = this._buffView.getFloat32(this._seekPos, !0); + this._seekPos += 4; + return t; + } + readFloatArray(t) { + for (let e = 0; e < t.length; ++e) t[e] = this._buffView.getFloat32(this._seekPos + 4 * e, !0); + this._seekPos += 4 * t.length; + return t; + } + readString() { + const t = this.readInt(); + let e = ""; + for (let i = 0; i < t; ++i) e += String.fromCharCode(this.readInt8()); + return e; + } + } + let Owt = t("TerrainLayerInfo", Ul("cc.TerrainLayerInfo")(nwt = (rwt = class { + constructor() { + Ml(this, "slot", owt, this); + Ml(this, "tileSize", awt, this); + Ml(this, "detailMap", lwt, this); + Ml(this, "normalMap", hwt, this); + Ml(this, "roughness", cwt, this); + Ml(this, "metallic", uwt, this); + } + }, owt = Bl(rwt.prototype, "slot", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), awt = Bl(rwt.prototype, "tileSize", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), lwt = Bl(rwt.prototype, "detailMap", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), hwt = Bl(rwt.prototype, "normalMap", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), cwt = Bl(rwt.prototype, "roughness", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), uwt = Bl(rwt.prototype, "metallic", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), rwt)) || nwt); + let Nwt = t("TerrainLayerBinaryInfo", Ul("cc.TerrainLayerBinaryInfo")(_wt = class { + constructor() { + this.slot = 0; + this.tileSize = 1; + this.roughness = 1; + this.metallic = 0; + this.detailMapId = ""; + this.normalMapId = ""; + } + }) || _wt); + let Lwt = t("TerrainAsset", Ul("cc.TerrainAsset")(dwt = (pwt = (fwt = class extends gc { + constructor() { + super(); + this._version = 0; + this._data = null; + this._tileSize = 1; + this._blockCount = [ 1, 1 ]; + this._weightMapSize = 128; + this._lightMapSize = 128; + this._heights = new Uint16Array; + this._normals = new Float32Array; + this._weights = new Uint8Array; + this._layerBuffer = [ -1, -1, -1, -1 ]; + this._layerBinaryInfos = []; + Ml(this, "_layerInfos", mwt, this); + } + get _nativeAsset() { + return this._data.buffer; + } + set _nativeAsset(t) { + this._data && this._data.byteLength === t.byteLength ? this._data.set(new Uint8Array(t)) : this._data = new Uint8Array(t); + this._loadNativeData(this._data); + } + get version() { + return this._version; + } + set tileSize(t) { + this._tileSize = t; + } + get tileSize() { + return this._tileSize; + } + set blockCount(t) { + this._blockCount = t; + } + get blockCount() { + return this._blockCount; + } + set lightMapSize(t) { + this._lightMapSize = t; + } + get lightMapSize() { + return this._lightMapSize; + } + set weightMapSize(t) { + this._weightMapSize = t; + } + get weightMapSize() { + return this._weightMapSize; + } + set heights(t) { + this._heights = t; + } + get heights() { + return this._heights; + } + set normals(t) { + this._normals = t; + } + get normals() { + return this._normals; + } + set weights(t) { + this._weights = t; + } + get weights() { + return this._weights; + } + set layerBuffer(t) { + this._layerBuffer = t; + } + get layerBuffer() { + return this._layerBuffer; + } + set layerInfos(t) { + this._layerInfos = t; + } + get layerInfos() { + return this._layerInfos; + } + get layerBinaryInfos() { + return this._layerBinaryInfos; + } + getLayer(t, e, i) { + const s = 4 * (e * this.blockCount[0] + t) + i; + return t < this.blockCount[0] && e < this.blockCount[1] && s < this._layerBuffer.length ? this._layerBuffer[s] : -1; + } + getHeight(t, e) { + const i = this._blockCount[0] * bwt + 1; + return (this._heights[e * i + t] - Twt) * vwt; + } + getVertexCountI() { + return this._blockCount.length < 1 ? 0 : this._blockCount[0] * bwt + 1; + } + getVertexCountJ() { + return this._blockCount.length < 2 ? 0 : this._blockCount[1] * bwt + 1; + } + _setNativeData(t) { + this._data = t; + } + _loadNativeData(t) { + if (!t || 0 === t.length) return !1; + const e = new Pwt; + e.assign(t); + this._version = e.readInt(); + if (this._version === Dwt) return !0; + if (this._version !== xwt && this._version !== wwt && this._version !== Rwt && this._version !== Iwt && this._version !== Mwt && this._version !== Bwt) return !1; + this.tileSize = e.readFloat(); + e.readIntArray(this._blockCount); + this.weightMapSize = e.readInt16(); + this.lightMapSize = e.readInt16(); + const i = e.readInt(); + this.heights = new Uint16Array(i); + for (let t = 0; t < this.heights.length; ++t) this.heights[t] = e.readInt16(); + if (this._version >= Bwt) { + const t = e.readInt(); + this.normals = new Float32Array(t); + for (let t = 0; t < this.normals.length; ++t) this.normals[t] = e.readFloat(); + } + const s = e.readInt(); + this.weights = new Uint8Array(s); + for (let t = 0; t < this.weights.length; ++t) this.weights[t] = e.readInt8(); + if (this._version >= wwt) { + const t = e.readInt(); + this.layerBuffer = new Array(t); + for (let t = 0; t < this.layerBuffer.length; ++t) this.layerBuffer[t] = e.readInt16(); + } + if (this._version >= Rwt) { + const t = e.readInt(); + this._layerBinaryInfos = new Array(t); + for (let t = 0; t < this._layerBinaryInfos.length; ++t) { + this._layerBinaryInfos[t] = new Nwt; + this._layerBinaryInfos[t].slot = e.readInt(); + this._layerBinaryInfos[t].tileSize = e.readFloat(); + this._layerBinaryInfos[t].detailMapId = e.readString(); + if (this._version >= Iwt) { + this._layerBinaryInfos[t].normalMapId = e.readString(); + this._layerBinaryInfos[t].roughness = e.readFloat(); + this._layerBinaryInfos[t].metallic = e.readFloat(); + } + } + } + return !0; + } + _exportNativeData() { + const t = new Pwt; + t.writeInt32(Bwt); + t.writeFloat(this.tileSize); + t.writeIntArray(this._blockCount); + t.writeInt16(this.weightMapSize); + t.writeInt16(this.lightMapSize); + t.writeInt32(this.heights.length); + for (let e = 0; e < this.heights.length; ++e) t.writeInt16(this.heights[e]); + t.writeInt32(this.normals.length); + for (let e = 0; e < this.normals.length; ++e) t.writeFloat(this.normals[e]); + t.writeInt32(this.weights.length); + for (let e = 0; e < this.weights.length; ++e) t.writeInt8(this.weights[e]); + t.writeInt32(this.layerBuffer.length); + for (let e = 0; e < this.layerBuffer.length; ++e) t.writeInt16(this.layerBuffer[e]); + const e = []; + e.length = this.layerInfos.length; + for (let t = 0; t < e.length; ++t) { + const i = this.layerInfos[t]; + const s = new Nwt; + s.slot = t; + s.tileSize = i.tileSize; + s.detailMapId = i.detailMap ? i.detailMap._uuid : ""; + s.normalMapId = i.normalMap ? i.normalMap._uuid : ""; + s.metallic = i.metallic; + s.roughness = i.roughness; + e[t] = s; + } + t.writeInt32(e.length); + for (let i = 0; i < e.length; ++i) { + t.writeInt32(e[i].slot); + t.writeFloat(e[i].tileSize); + t.writeString(e[i].detailMapId); + t.writeString(e[i].normalMapId); + t.writeFloat(e[i].roughness); + t.writeFloat(e[i].metallic); + } + return t.buffer; + } + _exportDefaultNativeData() { + const t = new Pwt; + t.writeInt32(Dwt); + return t.buffer; + } + }, fwt), mwt = Bl(pwt.prototype, "_layerInfos", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), pwt)) || dwt); + var Fwt, Vwt, kwt, Uwt, Gwt, zwt, Hwt, jwt, Xwt; + let Wwt = t("TerrainCollider", (Fwt = Ul("cc.TerrainCollider"), Vwt = sh(), kwt = $l(), + Uwt = Th(Lwt), Gwt = lh(), Fwt(zwt = Vwt(zwt = kwt(zwt = Ql(zwt = (Hwt = (Xwt = class extends HEt { + get terrain() { + return this._terrain; + } + set terrain(t) { + this._terrain = t; + this._shape && this.shape.setTerrain(this._terrain); + } + get shape() { + return this._shape; + } + constructor() { + super(nSt.TERRAIN); + Ml(this, "_terrain", jwt, this); + } + }, Xwt), Bl(Hwt.prototype, "terrain", [ Uwt, Gwt ], Object.getOwnPropertyDescriptor(Hwt.prototype, "terrain"), Hwt.prototype), + jwt = Bl(Hwt.prototype, "_terrain", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Hwt)) || zwt) || zwt) || zwt) || zwt)); + var Ywt, qwt, Kwt, Jwt, Zwt, Qwt, $wt, tRt, eRt, iRt, sRt, nRt, rRt, oRt, aRt, lRt, hRt, cRt; + let uRt = t("SimplexCollider", (Ywt = Ul("cc.SimplexCollider"), qwt = sh(), Kwt = $l(), + Jwt = Th(sSt), Zwt = lh(), Qwt = lh(), $wt = rh(), tRt = lh(), eRt = rh(), iRt = lh(), + sRt = rh(), nRt = lh(), Ywt(rRt = qwt(rRt = Kwt(rRt = Ql(rRt = (oRt = (cRt = hRt = class extends HEt { + get shapeType() { + return this._shapeType; + } + set shapeType(t) { + this._shapeType = t; + this._shape && this.shape.setShapeType(t); + } + get vertex0() { + return this._vertices[0]; + } + set vertex0(t) { + Pi.copy(this._vertices[0], t); + this.updateVertices(); + } + get vertex1() { + return this._vertices[1]; + } + set vertex1(t) { + Pi.copy(this._vertices[1], t); + this.updateVertices(); + } + get vertex2() { + return this._vertices[2]; + } + set vertex2(t) { + Pi.copy(this._vertices[2], t); + this.updateVertices(); + } + get vertex3() { + return this._vertices[3]; + } + set vertex3(t) { + Pi.copy(this._vertices[3], t); + this.updateVertices(); + } + get shape() { + return this._shape; + } + get vertices() { + return this._vertices; + } + constructor() { + super(nSt.SIMPLEX); + Ml(this, "_shapeType", aRt, this); + Ml(this, "_vertices", lRt, this); + } + updateVertices() { + this._shape && this.shape.setVertices(this._vertices); + } + }, hRt.ESimplexType = sSt, cRt), Bl(oRt.prototype, "shapeType", [ Jwt, Zwt ], Object.getOwnPropertyDescriptor(oRt.prototype, "shapeType"), oRt.prototype), + Bl(oRt.prototype, "vertex0", [ nh, Qwt ], Object.getOwnPropertyDescriptor(oRt.prototype, "vertex0"), oRt.prototype), + Bl(oRt.prototype, "vertex1", [ $wt, tRt ], Object.getOwnPropertyDescriptor(oRt.prototype, "vertex1"), oRt.prototype), + Bl(oRt.prototype, "vertex2", [ eRt, iRt ], Object.getOwnPropertyDescriptor(oRt.prototype, "vertex2"), oRt.prototype), + Bl(oRt.prototype, "vertex3", [ sRt, nRt ], Object.getOwnPropertyDescriptor(oRt.prototype, "vertex3"), oRt.prototype), + aRt = Bl(oRt.prototype, "_shapeType", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return sSt.TETRAHEDRON; + } + }), lRt = Bl(oRt.prototype, "_vertices", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return [ new Pi(0, 0, 0), new Pi(0, 0, 1), new Pi(1, 0, 0), new Pi(0, 1, 0) ]; + } + }), oRt)) || rRt) || rRt) || rRt) || rRt)); + uRt || (uRt = t("SimplexCollider", {})); + var _Rt, dRt, pRt, mRt, fRt, gRt, yRt, bRt, SRt, ARt, TRt; + let vRt = t("PlaneCollider", (_Rt = Ul("cc.PlaneCollider"), dRt = sh(), pRt = $l(), + mRt = Th(Pi), fRt = lh(), gRt = lh(), _Rt(yRt = dRt(yRt = pRt(yRt = Ql(yRt = (bRt = (TRt = class extends HEt { + get normal() { + return this._normal; + } + set normal(t) { + if (!Pi.strictEquals(this._normal, t)) { + Pi.copy(this._normal, t); + this._shape && this.shape.setNormal(this._normal); + } + } + get constant() { + return this._constant; + } + set constant(t) { + if (this._constant !== t) { + this._constant = t; + this._shape && this.shape.setConstant(this._constant); + } + } + get shape() { + return this._shape; + } + constructor() { + super(nSt.PLANE); + Ml(this, "_normal", SRt, this); + Ml(this, "_constant", ARt, this); + } + }, TRt), Bl(bRt.prototype, "normal", [ mRt, fRt ], Object.getOwnPropertyDescriptor(bRt.prototype, "normal"), bRt.prototype), + Bl(bRt.prototype, "constant", [ nh, gRt ], Object.getOwnPropertyDescriptor(bRt.prototype, "constant"), bRt.prototype), + SRt = Bl(bRt.prototype, "_normal", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Pi(0, 1, 0); + } + }), ARt = Bl(bRt.prototype, "_constant", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), bRt)) || yRt) || yRt) || yRt) || yRt)); + var ERt, CRt, xRt, wRt, RRt, IRt, MRt, BRt, DRt, PRt, ORt, NRt, LRt, FRt; + let VRt = t("Constraint", (ERt = Ul("cc.Constraint"), CRt = Gl(SEt), xRt = Th(SEt), + wRt = ph(), RRt = Th(SEt), IRt = ph(), MRt = ph(), BRt = Th(SEt), ERt(DRt = CRt(DRt = (PRt = (FRt = LRt = class extends(To(Qc)){ + get attachedBody() { + return this.getComponent(SEt); + } + get connectedBody() { + return this._connectedBody; + } + set connectedBody(t) { + this._connectedBody = t; + this._constraint && this._constraint.setConnectedBody(t); + } + get enableCollision() { + return this._enableCollision; + } + set enableCollision(t) { + this._enableCollision = t; + this._constraint && this._constraint.setEnableCollision(t); + } + constructor(t) { + super(); + this.TYPE = void 0; + Ml(this, "_enableCollision", ORt, this); + Ml(this, "_connectedBody", NRt, this); + this._constraint = null; + this.TYPE = t; + } + onLoad() { + if (ovt.runInEditor) { + this._constraint = yvt(this.TYPE); + this._constraint.initialize(this); + } + } + onEnable() { + this._constraint && this._constraint.onEnable(); + } + onDisable() { + this._constraint && this._constraint.onDisable(); + } + onDestroy() { + this._constraint && this._constraint.onDestroy(); + } + }, LRt.Type = rSt, FRt), Bl(PRt.prototype, "attachedBody", [ xRt, oh, wRt ], Object.getOwnPropertyDescriptor(PRt.prototype, "attachedBody"), PRt.prototype), + Bl(PRt.prototype, "connectedBody", [ RRt, IRt ], Object.getOwnPropertyDescriptor(PRt.prototype, "connectedBody"), PRt.prototype), + Bl(PRt.prototype, "enableCollision", [ MRt ], Object.getOwnPropertyDescriptor(PRt.prototype, "enableCollision"), PRt.prototype), + ORt = Bl(PRt.prototype, "_enableCollision", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), NRt = Bl(PRt.prototype, "_connectedBody", [ BRt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), PRt)) || DRt) || DRt)); + VRt || (VRt = t("Constraint", {})); + var kRt, URt, GRt, zRt, HRt, jRt, XRt, WRt, YRt, qRt, KRt, JRt, ZRt, QRt, $Rt; + let tIt = t("HingeConstraint", (kRt = Ul("cc.HingeConstraint"), URt = sh(), GRt = $l(), + zRt = Th(Pi), HRt = Th(Pi), jRt = Th(Pi), XRt = ql("axisA"), WRt = ql("pivotA"), + YRt = ql("pivotB"), kRt(qRt = URt(qRt = GRt(qRt = (KRt = ($Rt = class extends VRt { + get pivotA() { + return this._pivotA; + } + set pivotA(t) { + Pi.copy(this._pivotA, t); + this.constraint.setPivotA(this._pivotA); + } + get pivotB() { + return this._pivotB; + } + set pivotB(t) { + Pi.copy(this._pivotB, t); + this.constraint.setPivotB(this._pivotB); + } + get axis() { + return this._axis; + } + set axis(t) { + Pi.copy(this._axis, t); + this.constraint.setAxis(this._axis); + } + get constraint() { + return this._constraint; + } + constructor() { + super(rSt.HINGE); + Ml(this, "_axis", JRt, this); + Ml(this, "_pivotA", ZRt, this); + Ml(this, "_pivotB", QRt, this); + } + }, $Rt), Bl(KRt.prototype, "pivotA", [ zRt ], Object.getOwnPropertyDescriptor(KRt.prototype, "pivotA"), KRt.prototype), + Bl(KRt.prototype, "pivotB", [ HRt ], Object.getOwnPropertyDescriptor(KRt.prototype, "pivotB"), KRt.prototype), + Bl(KRt.prototype, "axis", [ jRt ], Object.getOwnPropertyDescriptor(KRt.prototype, "axis"), KRt.prototype), + JRt = Bl(KRt.prototype, "_axis", [ Yl, XRt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Pi; + } + }), ZRt = Bl(KRt.prototype, "_pivotA", [ Yl, WRt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Pi; + } + }), QRt = Bl(KRt.prototype, "_pivotB", [ Yl, YRt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Pi; + } + }), KRt)) || qRt) || qRt) || qRt)); + var eIt, iIt, sIt, nIt, rIt, oIt, aIt, lIt, hIt, cIt; + let uIt = t("PointToPointConstraint", (eIt = Ul("cc.PointToPointConstraint"), iIt = sh(), + sIt = $l(), nIt = Th(Pi), rIt = Th(Pi), eIt(oIt = iIt(oIt = sIt(oIt = (aIt = (cIt = class extends VRt { + get pivotA() { + return this._pivotA; + } + set pivotA(t) { + Pi.copy(this._pivotA, t); + this.constraint.setPivotA(this._pivotA); + } + get pivotB() { + return this._pivotB; + } + set pivotB(t) { + Pi.copy(this._pivotB, t); + this.constraint.setPivotB(this._pivotB); + } + get constraint() { + return this._constraint; + } + constructor() { + super(rSt.POINT_TO_POINT); + Ml(this, "_pivotA", lIt, this); + Ml(this, "_pivotB", hIt, this); + } + }, cIt), Bl(aIt.prototype, "pivotA", [ nIt ], Object.getOwnPropertyDescriptor(aIt.prototype, "pivotA"), aIt.prototype), + Bl(aIt.prototype, "pivotB", [ rIt ], Object.getOwnPropertyDescriptor(aIt.prototype, "pivotB"), aIt.prototype), + lIt = Bl(aIt.prototype, "_pivotA", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Pi; + } + }), hIt = Bl(aIt.prototype, "_pivotB", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Pi; + } + }), aIt)) || oIt) || oIt) || oIt)); + m.PhysicsSystem = Ivt; + m.PhysicsMaterial = wvt; + m.PhysicsRayResult = Rvt; + m.ConstantForce = swt; + var _It = Object.freeze({ + __proto__: null, + PhysicsSystem: Ivt, + PhysicsRayResult: Rvt, + get Collider() { + return HEt; + }, + BoxCollider: RCt, + SphereCollider: FCt, + CapsuleCollider: ZCt, + MeshCollider: Fxt, + CylinderCollider: uxt, + ConeCollider: Cxt, + TerrainCollider: Wwt, + get SimplexCollider() { + return uRt; + }, + PlaneCollider: vRt, + get Constraint() { + return VRt; + }, + HingeConstraint: tIt, + PointToPointConstraint: uIt, + get RigidBody() { + return SEt; + }, + PhysicsMaterial: wvt, + ConstantForce: swt, + selector: ovt, + utils: yCt, + get ERigidBodyType() { + return eSt; + }, + get EAxisDirection() { + return iSt; + }, + get ESimplexType() { + return sSt; + }, + get EColliderType() { + return nSt; + }, + get EConstraintType() { + return rSt; + }, + get PhysicsGroup() { + return oSt; + } + }); + t("physics", _It); + W(Ivt, "PhysicsSystem", [ { + name: "ins", + newName: "instance" + }, { + name: "PHYSICS_AMMO", + newName: "PHYSICS_BULLET" + } ]); + W(Ivt.prototype, "PhysicsSystem.prototype", [ { + name: "deltaTime", + newName: "fixedTimeStep" + }, { + name: "maxSubStep", + newName: "maxSubSteps" + } ]); + Y(Ivt.prototype, "PhysicsSystem.prototype", [ { + name: "useFixedTime" + }, { + name: "useCollisionMatrix" + }, { + name: "updateCollisionMatrix" + }, { + name: "resetCollisionMatrix" + }, { + name: "isCollisionGroup" + }, { + name: "setCollisionGroup" + } ]); + W(HEt.prototype, "Collider.prototype", [ { + name: "attachedRigidbody", + newName: "attachedRigidBody" + }, { + name: "TYPE", + newName: "type" + } ]); + W(HEt, "Collider", [ { + name: "EColliderType", + newName: "Type" + }, { + name: "EAxisDirection", + newName: "Axis" + } ]); + W(VRt, "Constraint", [ { + name: "EConstraintType", + newName: "Type" + } ]); + W(RCt.prototype, "BoxCollider.prototype", [ { + name: "boxShape", + newName: "shape" + } ]); + W(FCt.prototype, "SphereCollider.prototype", [ { + name: "sphereShape", + newName: "shape" + } ]); + W(ZCt.prototype, "CapsuleCollider.prototype", [ { + name: "capsuleShape", + newName: "shape" + } ]); + W(SEt.prototype, "RigidBody.prototype", [ { + name: "rigidBody", + newName: "body" + } ]); + W(SEt, "RigidBody", [ { + name: "ERigidBodyType", + newName: "Type" + } ]); + Y(SEt.prototype, "RigidBody.prototype", [ { + name: "fixedRotation" + } ]); + m.RigidBodyComponent = SEt; + ee.setClassAlias(SEt, "cc.RigidBodyComponent"); + m.ColliderComponent = HEt; + ee.setClassAlias(HEt, "cc.ColliderComponent"); + m.BoxColliderComponent = RCt; + ee.setClassAlias(RCt, "cc.BoxColliderComponent"); + m.SphereColliderComponent = FCt; + ee.setClassAlias(FCt, "cc.SphereColliderComponent"); + ee.setClassAlias(ZCt, "cc.CapsuleColliderComponent"); + ee.setClassAlias(Fxt, "cc.MeshColliderComponent"); + ee.setClassAlias(uxt, "cc.CylinderColliderComponent"); + m.PhysicMaterial = wvt; + ee.setClassAlias(wvt, "cc.PhysicMaterial"); + m.physics = _It; + var dIt, pIt, mIt, fIt, gIt, yIt, bIt, SIt; + var AIt; + !function(t) { + t[t.BOX = 0] = "BOX"; + t[t.SPHERE = 1] = "SPHERE"; + t[t.CYLINDER = 2] = "CYLINDER"; + t[t.CONE = 3] = "CONE"; + t[t.CAPSULE = 4] = "CAPSULE"; + t[t.TORUS = 5] = "TORUS"; + t[t.PLANE = 6] = "PLANE"; + t[t.QUAD = 7] = "QUAD"; + }(AIt || (AIt = {})); + he(AIt); + let TIt = t("Primitive", (dIt = Ul("cc.Primitive"), pIt = Th(AIt), dIt(mIt = (fIt = (SIt = bIt = class extends Ez { + constructor(t = AIt.BOX) { + super(); + Ml(this, "type", gIt, this); + Ml(this, "info", yIt, this); + this.type = t; + } + onLoaded() { + DI(mCt[AIt[this.type].toLowerCase()](this.info), this); + } + }, bIt.PrimitiveType = AIt, SIt), gIt = Bl(fIt.prototype, "type", [ pIt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return AIt.BOX; + } + }), yIt = Bl(fIt.prototype, "info", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return {}; + } + }), fIt)) || mIt)); + m.Primitive = TIt; + m.primitives = mCt; + var vIt, EIt; + let CIt = Ul("cc.PerfCounter")(vIt = (EIt = class extends class { + get value() { + return this._value; + } + set value(t) { + this._value = t; + } + constructor(t, e, i) { + this._id = void 0; + this._opts = void 0; + this._accumStart = void 0; + this._total = 0; + this._value = 0; + this._averageValue = 0; + this._accumValue = 0; + this._accumSamples = 0; + this._id = t; + this._opts = e; + this._accumStart = i; + } + sample(t) { + this._average(this._value, t); + } + human() { + const {average: t, isInteger: e} = this._opts; + const i = t ? this._averageValue : this._value; + return e ? Math.round(i) : Math.round(100 * i) / 100; + } + alarm() { + return this._opts.below && this._value < this._opts.below || this._opts.over && this._value > this._opts.over; + } + _average(t, e = 0) { + if (this._opts.average) { + this._accumValue += t; + ++this._accumSamples; + const i = e; + if (i - this._accumStart >= this._opts.average) { + this._averageValue = this._accumValue / this._accumSamples; + this._accumValue = 0; + this._accumStart = i; + this._accumSamples = 0; + } + } + } + } { + constructor(t, e, i) { + super(t, e, i); + this._time = void 0; + this._time = i; + } + start(t = 0) { + this._time = t; + } + end(t = 0) { + this._value = t - this._time; + this._average(this._value); + } + tick() { + this.end(); + this.start(); + } + frame(t) { + const e = t; + const i = e - this._time; + this._total++; + if (i > (this._opts.average || 1e3)) { + this._value = 1e3 * this._total / i; + this._total = 0; + this._time = e; + this._average(this._value); + } + } + }, EIt)) || vIt; + const xIt = "0123456789. "; + const wIt = 500; + const RIt = { + 0: 0, + 1: 1, + 2: 2, + 3: 3, + 4: 4, + 5: 5, + 6: 6, + 7: 7, + 8: 8, + 9: 9, + ".": 10 + }; + const IIt = { + fps: { + desc: "Framerate (FPS)", + below: 30, + average: wIt, + isInteger: !0 + }, + draws: { + desc: "Draw call", + isInteger: !0 + }, + frame: { + desc: "Frame time (ms)", + min: 0, + max: 50, + average: wIt + }, + instances: { + desc: "Instance Count", + isInteger: !0 + }, + tricount: { + desc: "Triangle", + isInteger: !0 + }, + logic: { + desc: "Game Logic (ms)", + min: 0, + max: 50, + average: wIt, + color: "#080" + }, + physics: { + desc: "Physics (ms)", + min: 0, + max: 50, + average: wIt + }, + render: { + desc: "Renderer (ms)", + min: 0, + max: 50, + average: wIt, + color: "#f90" + }, + textureMemory: { + desc: "GFX Texture Mem(M)" + }, + bufferMemory: { + desc: "GFX Buffer Mem(M)" + } + }; + const MIt = { + fontSize: 23, + quadHeight: .4, + segmentsPerLine: 8, + textureWidth: 256, + textureHeight: 256 + }; + class BIt extends Tg { + constructor() { + super(); + this._stats = null; + this._showFPS = !1; + this._rootNode = null; + this._device = null; + this._swapchain = null; + this._pipeline = null; + this._meshRenderer = null; + this._canvas = null; + this._ctx = null; + this._texture = null; + this._region = new mn; + this._canvasArr = []; + this._regionArr = [ this._region ]; + this.digitsData = null; + this.offsetData = null; + this.pass = null; + this._canvasDone = !1; + this._statsDone = !1; + this._inited = !1; + this._lineHeight = MIt.textureHeight / (Object.keys(IIt).length + 1); + this._wordHeight = 0; + this._eachNumWidth = 0; + this._totalLines = 0; + this.lastTime = 0; + this._canvas = document.createElement("canvas"); + this._ctx = this._canvas.getContext("2d"); + this._canvasArr.push(this._canvas); + } + init() { + !!de.querySettings(_e.Category.PROFILING, "showFPS") ? this.showStats() : this.hideStats(); + } + isShowingStats() { + return this._showFPS; + } + hideStats() { + if (this._showFPS) { + this._rootNode && (this._rootNode.active = !1); + m.director.off(m.Director.EVENT_BEFORE_UPDATE, this.beforeUpdate, this); + m.director.off(m.Director.EVENT_AFTER_UPDATE, this.afterUpdate, this); + m.director.off(m.Director.EVENT_BEFORE_PHYSICS, this.beforePhysics, this); + m.director.off(m.Director.EVENT_AFTER_PHYSICS, this.afterPhysics, this); + m.director.off(m.Director.EVENT_BEFORE_DRAW, this.beforeDraw, this); + m.director.off(m.Director.EVENT_AFTER_DRAW, this.afterDraw, this); + this._showFPS = !1; + IR.root.pipeline.profiler = null; + m.game.config.showFPS = !1; + } + } + showStats() { + if (!this._showFPS) { + if (!this._device) { + const t = m.director.root; + this._device = zo.gfxDevice; + this._swapchain = t.mainWindow.swapchain; + this._pipeline = t.pipeline; + } + this.generateCanvas(); + this.generateStats(); + m.game.once(m.Game.EVENT_ENGINE_INITED, this.generateNode, this); + m.game.on(m.Game.EVENT_RESTART, this.generateNode, this); + this._rootNode && (this._rootNode.active = !0); + m.director.on(m.Director.EVENT_BEFORE_UPDATE, this.beforeUpdate, this); + m.director.on(m.Director.EVENT_AFTER_UPDATE, this.afterUpdate, this); + m.director.on(m.Director.EVENT_BEFORE_PHYSICS, this.beforePhysics, this); + m.director.on(m.Director.EVENT_AFTER_PHYSICS, this.afterPhysics, this); + m.director.on(m.Director.EVENT_BEFORE_DRAW, this.beforeDraw, this); + m.director.on(m.Director.EVENT_AFTER_DRAW, this.afterDraw, this); + this._showFPS = !0; + this._canvasDone = !0; + this._statsDone = !0; + m.game.config.showFPS = !0; + } + } + generateCanvas() { + if (this._canvasDone) return; + const {textureWidth: t, textureHeight: e} = MIt; + if (this._ctx && this._canvas) { + this._canvas.width = t; + this._canvas.height = e; + this._canvas.style.width = `${this._canvas.width}`; + this._canvas.style.height = `${this._canvas.height}`; + this._ctx.font = `${MIt.fontSize}px Arial`; + this._ctx.textBaseline = "top"; + this._ctx.fillStyle = "#fff"; + this._texture = this._device.createTexture(new xn(xs.TEX2D, ws.SAMPLED | ws.TRANSFER_DST, bs.RGBA8, t, e)); + this._region.texExtent.width = t; + this._region.texExtent.height = e; + } + } + generateStats() { + if (this._statsDone || !this._ctx || !this._canvas) return; + this._stats = null; + const t = performance.now(); + this._ctx.textAlign = "left"; + let e = 0; + for (const i in IIt) { + const s = IIt[i]; + this._ctx.fillText(s.desc, 0, e * this._lineHeight); + s.counter = new CIt(i, s, t); + e++; + } + this._totalLines = e; + this._wordHeight = this._totalLines * this._lineHeight / this._canvas.height; + for (let t = 0; t < xIt.length; ++t) { + const e = this._ctx.measureText(xIt[t]).width; + this._eachNumWidth = Math.max(this._eachNumWidth, e); + } + for (let t = 0; t < xIt.length; ++t) this._ctx.fillText(xIt[t], t * this._eachNumWidth, this._totalLines * this._lineHeight); + this._eachNumWidth /= this._canvas.width; + this._stats = IIt; + this._canvasArr[0] = this._canvas; + this._device.copyTexImagesToTexture(this._canvasArr, this._texture, this._regionArr); + } + generateNode() { + if (this._rootNode && this._rootNode.isValid) return; + this._rootNode = new _y("PROFILER_NODE"); + this._rootNode._objFlags = m.Object.Flags.DontSave | m.Object.Flags.HideInHierarchy; + m.game.addPersistRootNode(this._rootNode); + const t = new _y("Profiler_Root"); + t.parent = this._rootNode; + const e = MIt.quadHeight; + const i = e / this._totalLines; + const s = e / this._wordHeight; + const n = i / MIt.fontSize; + const r = this._eachNumWidth * this._canvas.width * n; + const o = [ 0, e, 0, s, e, 0, s, 0, 0, 0, 0, 0 ]; + const a = [ 0, 2, 1, 0, 3, 2 ]; + const l = [ 0, 0, -1, 0, 1, 0, -1, 0, 1, this._wordHeight, -1, 0, 0, this._wordHeight, -1, 0 ]; + let h = 0; + for (let t = 0; t < this._totalLines; t++) for (let n = 0; n < MIt.segmentsPerLine; n++) { + o.push(s + n * r, e - t * i, 0); + o.push(s + (n + 1) * r, e - t * i, 0); + o.push(s + (n + 1) * r, e - (t + 1) * i, 0); + o.push(s + n * r, e - (t + 1) * i, 0); + h = 4 * (t * MIt.segmentsPerLine + n + 1); + a.push(0 + h, 2 + h, 1 + h, 0 + h, 3 + h, 2 + h); + const c = t * MIt.segmentsPerLine + n; + const u = Math.floor(c / 4); + const _ = c - 4 * u; + l.push(0, this._wordHeight, u, _); + l.push(this._eachNumWidth, this._wordHeight, u, _); + l.push(this._eachNumWidth, 1, u, _); + l.push(0, 1, u, _); + } + this._meshRenderer = t.addComponent(bH); + this._meshRenderer.mesh = DI({ + positions: o, + indices: a, + colors: l + }); + const c = new hm; + c.initialize({ + effectName: "util/profiler" + }); + const u = this.pass = c.passes[0]; + const _ = u.getBinding("mainTexture"); + const d = u.getBinding("digits"); + const p = u.getBinding("offset"); + u.bindTexture(_, this._texture); + this.digitsData = u.blocks[d]; + this.offsetData = u.blocks[p]; + this.offsetData[3] = -1; + this._meshRenderer.material = c; + this._meshRenderer.node.layer = mm.Enum.PROFILER; + this._inited = !0; + } + beforeUpdate() { + if (!this._stats) return; + const t = performance.now(); + this._stats.frame.counter.start(t); + this._stats.logic.counter.start(t); + } + afterUpdate() { + if (!this._stats) return; + const t = performance.now(); + m.director.isPaused() ? this._stats.frame.counter.start(t) : this._stats.logic.counter.end(t); + } + beforePhysics() { + if (!this._stats) return; + const t = performance.now(); + this._stats.physics.counter.start(t); + } + afterPhysics() { + if (!this._stats) return; + const t = performance.now(); + this._stats.physics.counter.end(t); + } + beforeDraw() { + if (!this._stats || !this._inited) return; + { + const t = this._swapchain.surfaceTransform; + const e = this._device.capabilities.clipSpaceSignY; + if (t !== this.offsetData[3]) { + const i = Yi[t]; + let s = -.9; + let n = -.9 * e; + if (Vo.isXR) { + s = -.5; + n = -.5 * e; + } + this.offsetData[0] = s * i[0] + n * i[2]; + this.offsetData[1] = s * i[1] + n * i[3]; + this.offsetData[2] = this._eachNumWidth; + this.offsetData[3] = t; + } + this.pass._rootBufferDirty = !0; + } + this._meshRenderer.model ? IR.root.pipeline.profiler = this._meshRenderer.model : IR.root.pipeline.profiler = null; + const t = performance.now(); + this._stats.render.counter.start(t); + } + afterDraw() { + if (!this._stats || !this._inited) return; + const t = performance.now(); + this._stats.frame.counter.end(t); + this._stats.fps.counter.frame(t); + this._stats.render.counter.end(t); + if (t - this.lastTime < wIt) return; + this.lastTime = t; + const e = this._device; + this._stats.draws.counter.value = e.numDrawCalls; + this._stats.instances.counter.value = e.numInstances; + this._stats.bufferMemory.counter.value = e.memoryStatus.bufferSize / 1048576; + this._stats.textureMemory.counter.value = e.memoryStatus.textureSize / 1048576; + this._stats.tricount.counter.value = e.numTris; + let i = 0; + { + const e = this.digitsData; + for (const s in this._stats) { + const n = this._stats[s]; + n.counter.sample(t); + const r = n.counter.human().toString(); + for (let t = MIt.segmentsPerLine - 1; t >= 0; t--) { + const s = i * MIt.segmentsPerLine + t; + const n = r[r.length - (MIt.segmentsPerLine - t)]; + let o = RIt[n]; + void 0 === o && (o = 11); + e[s] = o; + } + i++; + } + } + } + } + t("Profiler", BIt); + const DIt = t("profiler", new BIt); + IR.registerSystem("profiler", DIt, 0); + m.profiler = DIt; + new Rn(Ds.POINT, Ds.POINT, Ds.NONE, Ps.CLAMP, Ps.CLAMP, Ps.CLAMP); + const PIt = function(t, e, i, s) { + t[e + 0] = i.m00; + t[e + 1] = i.m01; + t[e + 2] = i.m02; + t[e + 3] = i.m12; + t[e + 4] = i.m04; + t[e + 5] = i.m05; + t[e + 6] = i.m06; + t[e + 7] = i.m13; + t[e + 8] = i.m08; + t[e + 9] = i.m09; + t[e + 10] = i.m10; + t[e + 11] = i.m14; + }; + new Ui; + new Ui; + new Pi; + new Ui; + new Pi; + function OIt(t, e) { + const i = 4 / Math.sqrt(e); + return 12 * Math.ceil(Math.max(480 * i, t) / 12); + } + const NIt = new Pi; + const LIt = new Pi; + const FIt = new Pi; + const VIt = new Pi; + const kIt = new qi; + const UIt = new qi; + const GIt = new hl; + const zIt = Number.MAX_SAFE_INTEGER; + class HIt { + get pixelsPerJoint() { + return this._pixelsPerJoint; + } + constructor(t) { + this._device = void 0; + this._pool = void 0; + this._textureBuffers = new Map; + this._formatSize = void 0; + this._pixelsPerJoint = void 0; + this._customPool = void 0; + this._chunkIdxMap = new Map; + this._device = t; + const e = function(t) { + return t.getFormatFeatures(bs.RGBA32F) & Is.SAMPLED_TEXTURE ? bs.RGBA32F : bs.RGBA8; + }(this._device); + this._formatSize = ur[e].size; + this._pixelsPerJoint = 48 / this._formatSize; + this._pool = new KP(t); + this._pool.initialize({ + format: e, + roundUpFn: OIt + }); + this._customPool = new KP(t); + this._customPool.initialize({ + format: e, + roundUpFn: OIt + }); + } + clear() { + this._pool.destroy(); + this._textureBuffers.clear(); + } + registerCustomTextureLayouts(t) { + for (let e = 0; e < t.length; e++) { + const i = t[e]; + const s = this._customPool.createChunk(i.textureLength); + for (let t = 0; t < i.contents.length; t++) { + const e = i.contents[t]; + const {skeleton: n} = e; + this._chunkIdxMap.set(n, s); + for (let t = 0; t < e.clips.length; t++) { + const i = e.clips[t]; + this._chunkIdxMap.set(n ^ i, s); + } + } + } + } + getDefaultPoseTexture(t, e, i) { + const s = 0 ^ t.hash; + let n = this._textureBuffers.get(s) || null; + if (n && n.bounds.has(e.hash)) { + n.refCount++; + return n; + } + const {joints: r, bindposes: o} = t; + let a = null; + let l = !1; + const h = r.length; + if (n) n.refCount++; else { + const e = 12 * h; + const i = this._chunkIdxMap.get(s); + const r = void 0 !== i ? this._customPool.alloc(e * Float32Array.BYTES_PER_ELEMENT, i) : this._pool.alloc(e * Float32Array.BYTES_PER_ELEMENT); + if (!r) return n; + n = { + pixelOffset: r.start / this._formatSize, + refCount: 1, + bounds: new Map, + skeletonHash: t.hash, + clipHash: 0, + readyToBeDeleted: !1, + handle: r + }; + a = new Float32Array(e); + l = !0; + } + Pi.set(FIt, zIt, zIt, zIt); + Pi.set(VIt, -zIt, -zIt, -zIt); + const c = e.getBoneSpaceBounds(t); + for (let e = 0, s = 0; e < h; e++, s += 12) { + const n = i.getChildByPath(r[e]); + const h = n ? KW(n, i, kIt) : t.inverseBindposes[e]; + const u = c[e]; + if (u) { + hl.transform(GIt, u, h); + GIt.getBoundary(NIt, LIt); + Pi.min(FIt, FIt, NIt); + Pi.max(VIt, VIt, LIt); + } + if (l) { + n && qi.multiply(h, h, o[e]); + PIt(a, s, n ? h : qi.IDENTITY); + } + } + const u = [ new hl ]; + n.bounds.set(e.hash, u); + hl.fromPoints(u[0], FIt, VIt); + if (l) { + this._pool.update(n.handle, a.buffer); + this._textureBuffers.set(s, n); + } + return n; + } + getSequencePoseTexture(t, e, i, s) { + const n = t.hash ^ e.hash; + let r = this._textureBuffers.get(n) || null; + if (r && r.bounds.has(i.hash)) { + r.refCount++; + return r; + } + const {joints: o, bindposes: a} = t; + const l = XZ.getOrExtract(e); + const {frames: h} = l; + let c = null; + let u = !1; + const _ = o.length; + if (r) r.refCount++; else { + const i = 12 * _ * h; + const o = this._chunkIdxMap.get(n); + const a = void 0 !== o ? this._customPool.alloc(i * Float32Array.BYTES_PER_ELEMENT, o) : this._pool.alloc(i * Float32Array.BYTES_PER_ELEMENT); + if (!a) return null; + const l = this._createAnimInfos(t, e, s); + r = { + pixelOffset: a.start / this._formatSize, + refCount: 1, + bounds: new Map, + skeletonHash: t.hash, + clipHash: e.hash, + readyToBeDeleted: !1, + handle: a, + animInfos: l + }; + c = new Float32Array(i); + u = !0; + } + const d = i.getBoneSpaceBounds(t); + const p = []; + r.bounds.set(i.hash, p); + for (let t = 0; t < h; t++) p.push(new hl(zIt, zIt, zIt, -zIt, -zIt, -zIt)); + for (let e = 0, i = 0; e < h; e++) { + const s = p[e]; + for (let n = 0; n < _; n++, i += 12) { + const {curveData: o, downstream: l, bindposeIdx: h, bindposeCorrection: _} = r.animInfos[n]; + let p; + let m = !0; + if (o && l) p = qi.multiply(kIt, o[e], l); else if (o) p = o[e]; else if (l) p = l; else { + p = t.inverseBindposes[h]; + m = !1; + } + const f = d[n]; + if (f) { + const t = _ ? qi.multiply(UIt, p, _) : p; + hl.transform(GIt, f, t); + GIt.getBoundary(NIt, LIt); + Pi.min(s.center, s.center, NIt); + Pi.max(s.halfExtents, s.halfExtents, LIt); + } + if (u) { + m && qi.multiply(kIt, p, a[h]); + PIt(c, i, m ? kIt : qi.IDENTITY); + } + } + hl.fromPoints(s, s.center, s.halfExtents); + } + if (u) { + this._pool.update(r.handle, c.buffer); + this._textureBuffers.set(n, r); + } + return r; + } + releaseHandle(t) { + t.refCount > 0 && t.refCount--; + if (!t.refCount && t.readyToBeDeleted) { + const e = t.skeletonHash ^ t.clipHash; + (void 0 !== this._chunkIdxMap.get(e) ? this._customPool : this._pool).free(t.handle); + this._textureBuffers.get(e) === t && this._textureBuffers.delete(e); + } + } + releaseSkeleton(t) { + const e = this._textureBuffers.values(); + let i = e.next(); + for (;!i.done; ) { + const s = i.value; + if (s.skeletonHash === t.hash) { + s.readyToBeDeleted = !0; + s.refCount ? this._textureBuffers.delete(s.skeletonHash ^ s.clipHash) : this.releaseHandle(s); + } + i = e.next(); + } + } + releaseAnimationClip(t) { + const e = this._textureBuffers.values(); + let i = e.next(); + for (;!i.done; ) { + const s = i.value; + if (s.clipHash === t.hash) { + s.readyToBeDeleted = !0; + s.refCount ? this._textureBuffers.delete(s.skeletonHash ^ s.clipHash) : this.releaseHandle(s); + } + i = e.next(); + } + } + _createAnimInfos(t, e, i) { + const s = []; + const {joints: n, bindposes: r} = t; + const o = n.length; + const a = XZ.getOrExtract(e); + for (let e = 0; e < o; e++) { + let l = n[e]; + let h = a.joints[l]; + let c = i.getChildByPath(l); + let u; + let _; + for (;!h; ) { + const t = l.lastIndexOf("/"); + l = l.substring(0, t); + h = a.joints[l]; + if (c) { + u || (u = new qi); + qi.fromRTS(kIt, c.rotation, c.position, c.scale); + qi.multiply(u, kIt, u); + c = c.parent; + } else _ = l; + if (t < 0) break; + } + let d = e; + let p; + if (void 0 !== _ && h) { + d = e - 1; + for (let i = 0; i < o; i++) if (n[i] === _) { + d = i; + p = new qi; + qi.multiply(p, r[i], t.inverseBindposes[e]); + break; + } + } + s.push({ + curveData: h && h.transforms, + downstream: u, + bindposeIdx: d, + bindposeCorrection: p + }); + } + return s; + } + } + class jIt { + constructor(t) { + this._pool = new Map; + this._device = void 0; + this._device = t; + } + getData(t = "-1") { + const e = this._pool.get(t); + if (e) return e; + const i = this._device.createBuffer(new An(Ts.UNIFORM | Ts.TRANSFER_DST, Cs.HOST | Cs.DEVICE, ef.SIZE, ef.SIZE)); + const s = new Float32Array([ 0, 0, 0, 0 ]); + i.update(s); + const n = { + buffer: i, + data: s, + dirty: !1, + dirtyForJSB: new Uint8Array([ 0 ]), + currentClip: null + }; + this._pool.set(t, n); + return n; + } + destroy(t) { + const e = this._pool.get(t); + if (e) { + e.buffer.destroy(); + this._pool.delete(t); + } + } + switchClip(t, e) { + t.currentClip = e; + t.data[0] = -1; + t.buffer.update(t.data); + t.dirty = !1; + t.dirtyForJSB[0] = 0; + return t; + } + clear() { + for (const t of this._pool.values()) t.buffer.destroy(); + this._pool.clear(); + } + } + m.internal.DataPoolManager = class { + constructor(t) { + this.jointTexturePool = void 0; + this.jointAnimationInfo = void 0; + this.jointTexturePool = new HIt(t); + this.jointAnimationInfo = new jIt(t); + } + releaseSkeleton(t) { + this.jointTexturePool.releaseSkeleton(t); + } + releaseAnimationClip(t) { + this.jointTexturePool.releaseAnimationClip(t); + } + clear() { + this.jointTexturePool.clear(); + this.jointAnimationInfo.clear(); + } + }; + const XIt = new qi; + const WIt = new qi; + class YIt extends YY { + constructor(t, e = "") { + super(t, e); + this._frames = 1; + this._bakedDuration = 0; + this._animInfo = null; + this._sockets = []; + this._animInfoMgr = void 0; + this._parent = null; + this._curvesInited = !1; + this._animInfoMgr = m.director.root.dataPoolManager.jointAnimationInfo; + } + initialize(t) { + if (this._curveLoaded) return; + this._parent = t.getComponent("cc.SkeletalAnimation"); + const e = this._parent.useBakedAnimation; + this._doNotCreateEval = e; + super.initialize(t); + this._curvesInited = !e; + const {frames: i, samples: s} = XZ.getOrExtract(this.clip); + this._frames = i - 1; + this._animInfo = this._animInfoMgr.getData(t.uuid); + this._bakedDuration = this._frames / s; + this.setUseBaked(e); + } + setUseBaked(t) { + if (t) { + this._sampleCurves = this._sampleCurvesBaked; + this.duration = this._bakedDuration; + } else { + this._sampleCurves = super._sampleCurves; + this.duration = this.clip.duration; + if (!this._curvesInited) { + this._curveLoaded = !1; + super.initialize(this._targetNode); + this._curvesInited = !0; + } + } + } + rebuildSocketCurves(t) { + this._sockets.length = 0; + if (!this._targetNode) return; + const e = this._targetNode; + for (let i = 0; i < t.length; ++i) { + const s = t[i]; + const n = e.getChildByPath(s.path); + if (!s.target) continue; + const r = XZ.getOrExtract(this.clip); + let o = s.path; + let a = r.joints[o]; + let l = n; + let h; + for (;!a; ) { + const t = o.lastIndexOf("/"); + o = o.substring(0, t); + a = r.joints[o]; + if (l) { + h || (h = qi.identity(WIt)); + qi.fromRTS(XIt, l.rotation, l.position, l.scale); + qi.multiply(h, XIt, h); + l = l.parent; + } + if (t < 0) break; + } + const c = a && a.transforms; + const {frames: u} = r; + const _ = []; + for (let t = 0; t < u; t++) { + let e; + e = c && h ? qi.multiply(XIt, c[t], h) : c ? c[t] : h || new qi; + const i = { + pos: new Pi, + rot: new Ui, + scale: new Pi + }; + qi.toRTS(e, i.rot, i.pos, i.scale); + _.push(i); + } + this._sockets.push({ + target: s.target, + frames: _ + }); + } + } + _sampleCurvesBaked(t) { + const e = t / this.duration; + const i = this._animInfo; + const s = this.clip; + if (i.currentClip !== s) { + this._animInfoMgr.switchClip(this._animInfo, s); + this._parent.getUsers().forEach((t => { + t.uploadAnimation(s); + })); + } + const n = e * this._frames + .5 | 0; + if (n !== i.data[0]) { + i.data[0] = n; + i.dirty = !0; + i.dirtyForJSB[0] = 1; + for (let t = 0; t < this._sockets.length; ++t) { + const {target: e, frames: i} = this._sockets[t]; + const {pos: s, rot: r, scale: o} = i[n]; + e.setRTS(r, s, o); + } + } + } + } + t("SkeletalAnimationState", YIt); + var qIt, KIt, JIt, ZIt, QIt, $It, tMt, eMt, iMt, sMt, nMt, rMt, oMt, aMt, lMt, hMt, cMt, uMt, _Mt, dMt, pMt; + let mMt = t("Socket", (qIt = Ul("cc.SkeletalAnimation.Socket"), KIt = Th(_y), qIt(JIt = (ZIt = (tMt = class { + constructor(t = "", e = null) { + Ml(this, "path", QIt, this); + Ml(this, "target", $It, this); + this.path = t; + this.target = e; + } + }, tMt), QIt = Bl(ZIt.prototype, "path", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), $It = Bl(ZIt.prototype, "target", [ KIt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), ZIt)) || JIt)); + ee.setClassAlias(mMt, "cc.SkeletalAnimationComponent.Socket"); + const fMt = new qi; + const gMt = new qi; + function yMt(t, e = "", i = []) { + for (let s = 0; s < t.children.length; s++) { + const n = t.children[s]; + if (!n) continue; + const r = e ? `${e}/${n.name}` : n.name; + i.push(r); + yMt(n, r, i); + } + return i; + } + let bMt = function(e) { + return t({ + SkeletalAnimation: e, + SkeletalAnimationComponent: e + }), e; + }((eMt = Ul("cc.SkeletalAnimation"), iMt = sh(), sMt = zl(99), nMt = $l(), rMt = Th([ mMt ]), + oMt = lh(), aMt = lh(), lMt = Th([ mMt ]), eMt(hMt = iMt(hMt = sMt(hMt = Ql(hMt = nMt(hMt = (cMt = (pMt = dMt = class extends o3 { + constructor(...t) { + super(...t); + Ml(this, "_useBakedAnimation", uMt, this); + Ml(this, "_sockets", _Mt, this); + this._users = new Set; + this._currentBakedState = null; + } + get sockets() { + return this._sockets; + } + set sockets(t) { + if (!this._useBakedAnimation) { + const e = XY(); + e.removeSockets(this.node, this._sockets); + e.addSockets(this.node, t); + } + this._sockets = t; + this.rebuildSocketAnimations(); + } + get useBakedAnimation() { + return this._useBakedAnimation; + } + set useBakedAnimation(t) { + this._useBakedAnimation = t; + for (const e in this._nameToState) { + this._nameToState[e].setUseBaked(t); + } + this._users.forEach((e => { + e.setUseBakedAnimation(t); + })); + if (this._useBakedAnimation) XY().removeSockets(this.node, this._sockets); else { + XY().addSockets(this.node, this._sockets); + this._currentBakedState = null; + } + } + onLoad() { + super.onLoad(); + const t = this.node.getComponentsInChildren(YW); + for (let e = 0; e < t.length; ++e) { + const i = t[e]; + i.skinningRoot === this.node && this.notifySkinnedMeshAdded(i); + } + } + onDestroy() { + super.onDestroy(); + m.director.root.dataPoolManager.jointAnimationInfo.destroy(this.node.uuid); + XY().removeSockets(this.node, this._sockets); + this._removeAllUsers(); + } + onEnable() { + var t; + super.onEnable(); + null === (t = this._currentBakedState) || void 0 === t || t.resume(); + } + onDisable() { + var t; + super.onDisable(); + null === (t = this._currentBakedState) || void 0 === t || t.pause(); + } + start() { + this.sockets = this._sockets; + this.useBakedAnimation = this._useBakedAnimation; + super.start(); + } + pause() { + if (this._useBakedAnimation) { + var t; + null === (t = this._currentBakedState) || void 0 === t || t.pause(); + } else super.pause(); + } + resume() { + if (this._useBakedAnimation) { + var t; + null === (t = this._currentBakedState) || void 0 === t || t.resume(); + } else super.resume(); + } + stop() { + if (this._useBakedAnimation) { + if (this._currentBakedState) { + this._currentBakedState.stop(); + this._currentBakedState = null; + } + } else super.stop(); + } + querySockets() { + const t = this._defaultClip && Object.keys(XZ.getOrExtract(this._defaultClip).joints).sort().reduce(((t, e) => (e.startsWith(t[t.length - 1]) || t.push(e), + t)), []) || []; + if (!t.length) return [ "please specify a valid default animation clip first" ]; + const e = []; + for (let i = 0; i < t.length; i++) { + const s = t[i]; + const n = this.node.getChildByPath(s); + if (n) { + e.push(s); + yMt(n, s, e); + } + } + return e; + } + rebuildSocketAnimations() { + for (const t of this._sockets) { + const e = this.node.getChildByPath(t.path); + const {target: i} = t; + if (e && i) { + i.name = `${t.path.substring(t.path.lastIndexOf("/") + 1)} Socket`; + i.parent = this.node; + KW(e, this.node, fMt); + qi.fromRTS(gMt, i.rotation, i.position, i.scale); + qi.equals(gMt, fMt) || (i.matrix = fMt); + } + } + for (const t of Object.keys(this._nameToState)) { + this._nameToState[t].rebuildSocketCurves(this._sockets); + } + } + createSocket(t) { + const e = this._sockets.find((e => e.path === t)); + if (e) return e.target; + if (!this.node.getChildByPath(t)) { + console.warn("illegal socket path"); + return null; + } + const i = new _y; + i.parent = this.node; + this._sockets.push(new mMt(t, i)); + this.rebuildSocketAnimations(); + return i; + } + notifySkinnedMeshAdded(t) { + const {_useBakedAnimation: e} = this; + const i = t.associatedAnimation; + i && i._users.delete(t); + t.associatedAnimation = this; + t.setUseBakedAnimation(e, !0); + if (e) { + const {_currentBakedState: e} = this; + e && t.uploadAnimation(e.clip); + } + this._users.add(t); + } + notifySkinnedMeshRemoved(t) { + ne(t.associatedAnimation === this || null === t.associatedAnimation); + t.setUseBakedAnimation(!1); + t.associatedAnimation = null; + this._users.delete(t); + } + getUsers() { + return this._users; + } + _createState(t, e) { + return new YIt(t, e); + } + _doCreateState(t, e) { + const i = super._doCreateState(t, e); + i.rebuildSocketCurves(this._sockets); + return i; + } + doPlayOrCrossFade(t, e) { + if (this._useBakedAnimation) { + this._currentBakedState && this._currentBakedState.stop(); + const e = t; + this._currentBakedState = e; + e.play(); + } else super.doPlayOrCrossFade(t, e); + } + _removeAllUsers() { + Array.from(this._users).forEach((t => { + this.notifySkinnedMeshRemoved(t); + })); + } + }, dMt.Socket = mMt, pMt), Bl(cMt.prototype, "sockets", [ rMt, oMt ], Object.getOwnPropertyDescriptor(cMt.prototype, "sockets"), cMt.prototype), + Bl(cMt.prototype, "useBakedAnimation", [ aMt ], Object.getOwnPropertyDescriptor(cMt.prototype, "useBakedAnimation"), cMt.prototype), + uMt = Bl(cMt.prototype, "_useBakedAnimation", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), _Mt = Bl(cMt.prototype, "_sockets", [ lMt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), cMt)) || hMt) || hMt) || hMt) || hMt) || hMt)); + m.SkeletalAnimationComponent = bMt; + ee.setClassAlias(bMt, "cc.SkeletalAnimationComponent"); + class SMt { + constructor() { + this.start = void 0; + this.interrupt = void 0; + this.end = void 0; + this.dispose = void 0; + this.complete = void 0; + this.event = void 0; + } + static getListeners(t) { + t.listener || (t.listener = new SMt); + return t.listener; + } + } + var AMt = function() { + var t = function(e, i) { + t = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function(t, e) { + t.__proto__ = e; + } || function(t, e) { + for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]); + }; + return t(e, i); + }; + return function(e, i) { + t(e, i); + function s() { + this.constructor = e; + } + e.prototype = null === i ? Object.create(i) : (s.prototype = i.prototype, new s); + }; + }(); + !function(t) { + var e = function() { + function t(t, e, i) { + if (null == t) throw new Error("name cannot be null."); + if (null == e) throw new Error("timelines cannot be null."); + this.name = t; + this.timelines = e; + this.timelineIds = []; + for (var s = 0; s < e.length; s++) this.timelineIds[e[s].getPropertyId()] = !0; + this.duration = i; + } + t.prototype.hasTimeline = function(t) { + return 1 == this.timelineIds[t]; + }; + t.prototype.apply = function(t, e, i, s, n, r, o, a) { + if (null == t) throw new Error("skeleton cannot be null."); + if (s && 0 != this.duration) { + i %= this.duration; + e > 0 && (e %= this.duration); + } + var l = this.timelines; + for (var h = 0, c = l.length; h < c; h++) l[h].apply(t, e, i, n, r, o, a); + }; + t.binarySearch = function(t, e, i) { + void 0 === i && (i = 1); + var s = 0; + var n = t.length / i - 2; + if (0 == n) return i; + var r = n >>> 1; + for (;;) { + t[(r + 1) * i] <= e ? s = r + 1 : n = r; + if (s == n) return (s + 1) * i; + r = s + n >>> 1; + } + }; + t.linearSearch = function(t, e, i) { + for (var s = 0, n = t.length - i; s <= n; s += i) if (t[s] > e) return s; + return -1; + }; + return t; + }(); + t.Animation = e; + var i; + !function(t) { + t[t.setup = 0] = "setup"; + t[t.first = 1] = "first"; + t[t.replace = 2] = "replace"; + t[t.add = 3] = "add"; + }(i = t.MixBlend || (t.MixBlend = {})); + var s; + !function(t) { + t[t.mixIn = 0] = "mixIn"; + t[t.mixOut = 1] = "mixOut"; + }(s = t.MixDirection || (t.MixDirection = {})); + var n; + !function(t) { + t[t.rotate = 0] = "rotate"; + t[t.translate = 1] = "translate"; + t[t.scale = 2] = "scale"; + t[t.shear = 3] = "shear"; + t[t.attachment = 4] = "attachment"; + t[t.color = 5] = "color"; + t[t.deform = 6] = "deform"; + t[t.event = 7] = "event"; + t[t.drawOrder = 8] = "drawOrder"; + t[t.ikConstraint = 9] = "ikConstraint"; + t[t.transformConstraint = 10] = "transformConstraint"; + t[t.pathConstraintPosition = 11] = "pathConstraintPosition"; + t[t.pathConstraintSpacing = 12] = "pathConstraintSpacing"; + t[t.pathConstraintMix = 13] = "pathConstraintMix"; + t[t.twoColor = 14] = "twoColor"; + }(n = t.TimelineType || (t.TimelineType = {})); + var r = function() { + function e(i) { + if (i <= 0) throw new Error("frameCount must be > 0: " + i); + this.curves = t.Utils.newFloatArray((i - 1) * e.BEZIER_SIZE); + } + e.prototype.getFrameCount = function() { + return this.curves.length / e.BEZIER_SIZE + 1; + }; + e.prototype.setLinear = function(t) { + this.curves[t * e.BEZIER_SIZE] = e.LINEAR; + }; + e.prototype.setStepped = function(t) { + this.curves[t * e.BEZIER_SIZE] = e.STEPPED; + }; + e.prototype.getCurveType = function(t) { + var i = t * e.BEZIER_SIZE; + if (i == this.curves.length) return e.LINEAR; + var s = this.curves[i]; + return s == e.LINEAR ? e.LINEAR : s == e.STEPPED ? e.STEPPED : e.BEZIER; + }; + e.prototype.setCurve = function(t, i, s, n, r) { + var o = .03 * (2 * -i + n), a = .03 * (2 * -s + r); + var l = .006 * (3 * (i - n) + 1), h = .006 * (3 * (s - r) + 1); + var c = 2 * o + l, u = 2 * a + h; + var _ = .3 * i + o + .16666667 * l, d = .3 * s + a + .16666667 * h; + var p = t * e.BEZIER_SIZE; + var m = this.curves; + m[p++] = e.BEZIER; + var f = _, g = d; + for (var y = p + e.BEZIER_SIZE - 1; p < y; p += 2) { + m[p] = f; + m[p + 1] = g; + _ += c; + d += u; + c += l; + u += h; + f += _; + g += d; + } + }; + e.prototype.getCurvePercent = function(i, s) { + s = t.MathUtils.clamp(s, 0, 1); + var n = this.curves; + var r = i * e.BEZIER_SIZE; + var o = n[r]; + if (o == e.LINEAR) return s; + if (o == e.STEPPED) return 0; + var a = 0; + for (var l = ++r, h = r + e.BEZIER_SIZE - 1; r < h; r += 2) if ((a = n[r]) >= s) { + var c = void 0, u = void 0; + if (r == l) { + c = 0; + u = 0; + } else { + c = n[r - 2]; + u = n[r - 1]; + } + return u + (n[r + 1] - u) * (s - c) / (a - c); + } + var _ = n[r - 1]; + return _ + (1 - _) * (s - a) / (1 - a); + }; + e.LINEAR = 0; + e.STEPPED = 1; + e.BEZIER = 2; + e.BEZIER_SIZE = 19; + return e; + }(); + t.CurveTimeline = r; + var o = function(s) { + AMt(r, s); + function r(e) { + var i = s.call(this, e) || this; + i.frames = t.Utils.newFloatArray(e << 1); + return i; + } + r.prototype.getPropertyId = function() { + return (n.rotate << 24) + this.boneIndex; + }; + r.prototype.setFrame = function(t, e, i) { + t <<= 1; + this.frames[t] = e; + this.frames[t + r.ROTATION] = i; + }; + r.prototype.apply = function(t, s, n, o, a, l, h) { + var c = this.frames; + var u = t.bones[this.boneIndex]; + if (u.active) if (n < c[0]) switch (l) { + case i.setup: + u.rotation = u.data.rotation; + return; + + case i.first: + var _ = u.data.rotation - u.rotation; + u.rotation += (_ - 360 * (16384 - (16384.499999999996 - _ / 360 | 0))) * a; + } else if (n >= c[c.length - r.ENTRIES]) { + var d = c[c.length + r.PREV_ROTATION]; + switch (l) { + case i.setup: + u.rotation = u.data.rotation + d * a; + break; + + case i.first: + case i.replace: + d += u.data.rotation - u.rotation; + d -= 360 * (16384 - (16384.499999999996 - d / 360 | 0)); + + case i.add: + u.rotation += d * a; + } + } else { + var p = e.binarySearch(c, n, r.ENTRIES); + var m = c[p + r.PREV_ROTATION]; + var f = c[p]; + var g = this.getCurvePercent((p >> 1) - 1, 1 - (n - f) / (c[p + r.PREV_TIME] - f)); + var y = c[p + r.ROTATION] - m; + y = m + (y - 360 * (16384 - (16384.499999999996 - y / 360 | 0))) * g; + switch (l) { + case i.setup: + u.rotation = u.data.rotation + (y - 360 * (16384 - (16384.499999999996 - y / 360 | 0))) * a; + break; + + case i.first: + case i.replace: + y += u.data.rotation - u.rotation; + + case i.add: + u.rotation += (y - 360 * (16384 - (16384.499999999996 - y / 360 | 0))) * a; + } + } + }; + r.ENTRIES = 2; + r.PREV_TIME = -2; + r.PREV_ROTATION = -1; + r.ROTATION = 1; + return r; + }(r); + t.RotateTimeline = o; + var a = function(s) { + AMt(r, s); + function r(e) { + var i = s.call(this, e) || this; + i.frames = t.Utils.newFloatArray(e * r.ENTRIES); + return i; + } + r.prototype.getPropertyId = function() { + return (n.translate << 24) + this.boneIndex; + }; + r.prototype.setFrame = function(t, e, i, s) { + t *= r.ENTRIES; + this.frames[t] = e; + this.frames[t + r.X] = i; + this.frames[t + r.Y] = s; + }; + r.prototype.apply = function(t, s, n, o, a, l, h) { + var c = this.frames; + var u = t.bones[this.boneIndex]; + if (u.active) if (n < c[0]) switch (l) { + case i.setup: + u.x = u.data.x; + u.y = u.data.y; + return; + + case i.first: + u.x += (u.data.x - u.x) * a; + u.y += (u.data.y - u.y) * a; + } else { + var _ = 0, d = 0; + if (n >= c[c.length - r.ENTRIES]) { + _ = c[c.length + r.PREV_X]; + d = c[c.length + r.PREV_Y]; + } else { + var p = e.binarySearch(c, n, r.ENTRIES); + _ = c[p + r.PREV_X]; + d = c[p + r.PREV_Y]; + var m = c[p]; + var f = this.getCurvePercent(p / r.ENTRIES - 1, 1 - (n - m) / (c[p + r.PREV_TIME] - m)); + _ += (c[p + r.X] - _) * f; + d += (c[p + r.Y] - d) * f; + } + switch (l) { + case i.setup: + u.x = u.data.x + _ * a; + u.y = u.data.y + d * a; + break; + + case i.first: + case i.replace: + u.x += (u.data.x + _ - u.x) * a; + u.y += (u.data.y + d - u.y) * a; + break; + + case i.add: + u.x += _ * a; + u.y += d * a; + } + } + }; + r.ENTRIES = 3; + r.PREV_TIME = -3; + r.PREV_X = -2; + r.PREV_Y = -1; + r.X = 1; + r.Y = 2; + return r; + }(r); + t.TranslateTimeline = a; + var l = function(r) { + AMt(o, r); + function o(t) { + return r.call(this, t) || this; + } + o.prototype.getPropertyId = function() { + return (n.scale << 24) + this.boneIndex; + }; + o.prototype.apply = function(n, r, a, l, h, c, u) { + var _ = this.frames; + var d = n.bones[this.boneIndex]; + if (d.active) if (a < _[0]) switch (c) { + case i.setup: + d.scaleX = d.data.scaleX; + d.scaleY = d.data.scaleY; + return; + + case i.first: + d.scaleX += (d.data.scaleX - d.scaleX) * h; + d.scaleY += (d.data.scaleY - d.scaleY) * h; + } else { + var p = 0, m = 0; + if (a >= _[_.length - o.ENTRIES]) { + p = _[_.length + o.PREV_X] * d.data.scaleX; + m = _[_.length + o.PREV_Y] * d.data.scaleY; + } else { + var f = e.binarySearch(_, a, o.ENTRIES); + p = _[f + o.PREV_X]; + m = _[f + o.PREV_Y]; + var g = _[f]; + var y = this.getCurvePercent(f / o.ENTRIES - 1, 1 - (a - g) / (_[f + o.PREV_TIME] - g)); + p = (p + (_[f + o.X] - p) * y) * d.data.scaleX; + m = (m + (_[f + o.Y] - m) * y) * d.data.scaleY; + } + if (1 == h) if (c == i.add) { + d.scaleX += p - d.data.scaleX; + d.scaleY += m - d.data.scaleY; + } else { + d.scaleX = p; + d.scaleY = m; + } else { + var b = 0, S = 0; + if (u == s.mixOut) switch (c) { + case i.setup: + b = d.data.scaleX; + S = d.data.scaleY; + d.scaleX = b + (Math.abs(p) * t.MathUtils.signum(b) - b) * h; + d.scaleY = S + (Math.abs(m) * t.MathUtils.signum(S) - S) * h; + break; + + case i.first: + case i.replace: + b = d.scaleX; + S = d.scaleY; + d.scaleX = b + (Math.abs(p) * t.MathUtils.signum(b) - b) * h; + d.scaleY = S + (Math.abs(m) * t.MathUtils.signum(S) - S) * h; + break; + + case i.add: + b = d.scaleX; + S = d.scaleY; + d.scaleX = b + (Math.abs(p) * t.MathUtils.signum(b) - d.data.scaleX) * h; + d.scaleY = S + (Math.abs(m) * t.MathUtils.signum(S) - d.data.scaleY) * h; + } else switch (c) { + case i.setup: + b = Math.abs(d.data.scaleX) * t.MathUtils.signum(p); + S = Math.abs(d.data.scaleY) * t.MathUtils.signum(m); + d.scaleX = b + (p - b) * h; + d.scaleY = S + (m - S) * h; + break; + + case i.first: + case i.replace: + b = Math.abs(d.scaleX) * t.MathUtils.signum(p); + S = Math.abs(d.scaleY) * t.MathUtils.signum(m); + d.scaleX = b + (p - b) * h; + d.scaleY = S + (m - S) * h; + break; + + case i.add: + b = t.MathUtils.signum(p); + S = t.MathUtils.signum(m); + d.scaleX = Math.abs(d.scaleX) * b + (p - Math.abs(d.data.scaleX) * b) * h; + d.scaleY = Math.abs(d.scaleY) * S + (m - Math.abs(d.data.scaleY) * S) * h; + } + } + } + }; + return o; + }(a); + t.ScaleTimeline = l; + var h = function(t) { + AMt(s, t); + function s(e) { + return t.call(this, e) || this; + } + s.prototype.getPropertyId = function() { + return (n.shear << 24) + this.boneIndex; + }; + s.prototype.apply = function(t, n, r, o, a, l, h) { + var c = this.frames; + var u = t.bones[this.boneIndex]; + if (u.active) if (r < c[0]) switch (l) { + case i.setup: + u.shearX = u.data.shearX; + u.shearY = u.data.shearY; + return; + + case i.first: + u.shearX += (u.data.shearX - u.shearX) * a; + u.shearY += (u.data.shearY - u.shearY) * a; + } else { + var _ = 0, d = 0; + if (r >= c[c.length - s.ENTRIES]) { + _ = c[c.length + s.PREV_X]; + d = c[c.length + s.PREV_Y]; + } else { + var p = e.binarySearch(c, r, s.ENTRIES); + _ = c[p + s.PREV_X]; + d = c[p + s.PREV_Y]; + var m = c[p]; + var f = this.getCurvePercent(p / s.ENTRIES - 1, 1 - (r - m) / (c[p + s.PREV_TIME] - m)); + _ += (c[p + s.X] - _) * f; + d += (c[p + s.Y] - d) * f; + } + switch (l) { + case i.setup: + u.shearX = u.data.shearX + _ * a; + u.shearY = u.data.shearY + d * a; + break; + + case i.first: + case i.replace: + u.shearX += (u.data.shearX + _ - u.shearX) * a; + u.shearY += (u.data.shearY + d - u.shearY) * a; + break; + + case i.add: + u.shearX += _ * a; + u.shearY += d * a; + } + } + }; + return s; + }(a); + t.ShearTimeline = h; + var c = function(s) { + AMt(r, s); + function r(e) { + var i = s.call(this, e) || this; + i.frames = t.Utils.newFloatArray(e * r.ENTRIES); + return i; + } + r.prototype.getPropertyId = function() { + return (n.color << 24) + this.slotIndex; + }; + r.prototype.setFrame = function(t, e, i, s, n, o) { + t *= r.ENTRIES; + this.frames[t] = e; + this.frames[t + r.R] = i; + this.frames[t + r.G] = s; + this.frames[t + r.B] = n; + this.frames[t + r.A] = o; + }; + r.prototype.apply = function(t, s, n, o, a, l, h) { + var c = t.slots[this.slotIndex]; + if (c.bone.active) { + var u = this.frames; + if (n < u[0]) switch (l) { + case i.setup: + c.color.setFromColor(c.data.color); + return; + + case i.first: + var _ = c.color, d = c.data.color; + _.add((d.r - _.r) * a, (d.g - _.g) * a, (d.b - _.b) * a, (d.a - _.a) * a); + } else { + var p = 0, m = 0, f = 0, g = 0; + if (n >= u[u.length - r.ENTRIES]) { + var y = u.length; + p = u[y + r.PREV_R]; + m = u[y + r.PREV_G]; + f = u[y + r.PREV_B]; + g = u[y + r.PREV_A]; + } else { + var b = e.binarySearch(u, n, r.ENTRIES); + p = u[b + r.PREV_R]; + m = u[b + r.PREV_G]; + f = u[b + r.PREV_B]; + g = u[b + r.PREV_A]; + var S = u[b]; + var A = this.getCurvePercent(b / r.ENTRIES - 1, 1 - (n - S) / (u[b + r.PREV_TIME] - S)); + p += (u[b + r.R] - p) * A; + m += (u[b + r.G] - m) * A; + f += (u[b + r.B] - f) * A; + g += (u[b + r.A] - g) * A; + } + if (1 == a) c.color.set(p, m, f, g); else { + _ = c.color; + l == i.setup && _.setFromColor(c.data.color); + _.add((p - _.r) * a, (m - _.g) * a, (f - _.b) * a, (g - _.a) * a); + } + } + } + }; + r.ENTRIES = 5; + r.PREV_TIME = -5; + r.PREV_R = -4; + r.PREV_G = -3; + r.PREV_B = -2; + r.PREV_A = -1; + r.R = 1; + r.G = 2; + r.B = 3; + r.A = 4; + return r; + }(r); + t.ColorTimeline = c; + var u = function(s) { + AMt(r, s); + function r(e) { + var i = s.call(this, e) || this; + i.frames = t.Utils.newFloatArray(e * r.ENTRIES); + return i; + } + r.prototype.getPropertyId = function() { + return (n.twoColor << 24) + this.slotIndex; + }; + r.prototype.setFrame = function(t, e, i, s, n, o, a, l, h) { + t *= r.ENTRIES; + this.frames[t] = e; + this.frames[t + r.R] = i; + this.frames[t + r.G] = s; + this.frames[t + r.B] = n; + this.frames[t + r.A] = o; + this.frames[t + r.R2] = a; + this.frames[t + r.G2] = l; + this.frames[t + r.B2] = h; + }; + r.prototype.apply = function(t, s, n, o, a, l, h) { + var c = t.slots[this.slotIndex]; + if (c.bone.active) { + var u = this.frames; + if (n < u[0]) switch (l) { + case i.setup: + c.color.setFromColor(c.data.color); + c.darkColor.setFromColor(c.data.darkColor); + return; + + case i.first: + var _ = c.color, d = c.darkColor, p = c.data.color, m = c.data.darkColor; + _.add((p.r - _.r) * a, (p.g - _.g) * a, (p.b - _.b) * a, (p.a - _.a) * a); + d.add((m.r - d.r) * a, (m.g - d.g) * a, (m.b - d.b) * a, 0); + } else { + var f = 0, g = 0, y = 0, b = 0, S = 0, A = 0, T = 0; + if (n >= u[u.length - r.ENTRIES]) { + var v = u.length; + f = u[v + r.PREV_R]; + g = u[v + r.PREV_G]; + y = u[v + r.PREV_B]; + b = u[v + r.PREV_A]; + S = u[v + r.PREV_R2]; + A = u[v + r.PREV_G2]; + T = u[v + r.PREV_B2]; + } else { + var E = e.binarySearch(u, n, r.ENTRIES); + f = u[E + r.PREV_R]; + g = u[E + r.PREV_G]; + y = u[E + r.PREV_B]; + b = u[E + r.PREV_A]; + S = u[E + r.PREV_R2]; + A = u[E + r.PREV_G2]; + T = u[E + r.PREV_B2]; + var C = u[E]; + var x = this.getCurvePercent(E / r.ENTRIES - 1, 1 - (n - C) / (u[E + r.PREV_TIME] - C)); + f += (u[E + r.R] - f) * x; + g += (u[E + r.G] - g) * x; + y += (u[E + r.B] - y) * x; + b += (u[E + r.A] - b) * x; + S += (u[E + r.R2] - S) * x; + A += (u[E + r.G2] - A) * x; + T += (u[E + r.B2] - T) * x; + } + if (1 == a) { + c.color.set(f, g, y, b); + c.darkColor.set(S, A, T, 1); + } else { + _ = c.color, d = c.darkColor; + if (l == i.setup) { + _.setFromColor(c.data.color); + d.setFromColor(c.data.darkColor); + } + _.add((f - _.r) * a, (g - _.g) * a, (y - _.b) * a, (b - _.a) * a); + d.add((S - d.r) * a, (A - d.g) * a, (T - d.b) * a, 0); + } + } + } + }; + r.ENTRIES = 8; + r.PREV_TIME = -8; + r.PREV_R = -7; + r.PREV_G = -6; + r.PREV_B = -5; + r.PREV_A = -4; + r.PREV_R2 = -3; + r.PREV_G2 = -2; + r.PREV_B2 = -1; + r.R = 1; + r.G = 2; + r.B = 3; + r.A = 4; + r.R2 = 5; + r.G2 = 6; + r.B2 = 7; + return r; + }(r); + t.TwoColorTimeline = u; + var _ = function() { + function r(e) { + this.frames = t.Utils.newFloatArray(e); + this.attachmentNames = new Array(e); + } + r.prototype.getPropertyId = function() { + return (n.attachment << 24) + this.slotIndex; + }; + r.prototype.getFrameCount = function() { + return this.frames.length; + }; + r.prototype.setFrame = function(t, e, i) { + this.frames[t] = e; + this.attachmentNames[t] = i; + }; + r.prototype.apply = function(t, n, r, o, a, l, h) { + var c = t.slots[this.slotIndex]; + if (c.bone.active) if (h != s.mixOut || l != i.setup) { + var u = this.frames; + if (r < u[0]) { + if (l == i.setup || l == i.first) { + var _ = c.data.attachmentName; + c.setAttachment(null == _ ? null : t.getAttachment(this.slotIndex, _)); + } + } else { + var d = 0; + d = r >= u[u.length - 1] ? u.length - 1 : e.binarySearch(u, r, 1) - 1; + var p = this.attachmentNames[d]; + t.slots[this.slotIndex].setAttachment(null == p ? null : t.getAttachment(this.slotIndex, p)); + } + } else { + var m = c.data.attachmentName; + c.setAttachment(null == m ? null : t.getAttachment(this.slotIndex, m)); + } + }; + return r; + }(); + t.AttachmentTimeline = _; + var d = null; + var p = function(s) { + AMt(r, s); + function r(e) { + var i = s.call(this, e) || this; + i.frames = t.Utils.newFloatArray(e); + i.frameVertices = new Array(e); + null == d && (d = t.Utils.newFloatArray(64)); + return i; + } + r.prototype.getPropertyId = function() { + return (n.deform << 27) + +this.attachment.id + this.slotIndex; + }; + r.prototype.setFrame = function(t, e, i) { + this.frames[t] = e; + this.frameVertices[t] = i; + }; + r.prototype.apply = function(s, n, r, o, a, l, h) { + var c = s.slots[this.slotIndex]; + if (c.bone.active) { + var u = c.getAttachment(); + if (u instanceof t.VertexAttachment && u.deformAttachment == this.attachment) { + var _ = c.deform; + 0 == _.length && (l = i.setup); + var d = this.frameVertices; + var p = d[0].length; + var m = this.frames; + if (r < m[0]) { + var f = u; + switch (l) { + case i.setup: + _.length = 0; + return; + + case i.first: + if (1 == a) { + _.length = 0; + break; + } + var g = t.Utils.setArraySize(_, p); + if (null == f.bones) { + var y = f.vertices; + for (var b = 0; b < p; b++) g[b] += (y[b] - g[b]) * a; + } else { + a = 1 - a; + for (b = 0; b < p; b++) g[b] *= a; + } + } + } else { + var S = t.Utils.setArraySize(_, p); + if (r >= m[m.length - 1]) { + var A = d[m.length - 1]; + if (1 == a) if (l == i.add) { + if (null == (f = u).bones) { + y = f.vertices; + for (var T = 0; T < p; T++) S[T] += A[T] - y[T]; + } else for (var v = 0; v < p; v++) S[v] += A[v]; + } else t.Utils.arrayCopy(A, 0, S, 0, p); else switch (l) { + case i.setup: + var E = u; + if (null == E.bones) { + y = E.vertices; + for (var C = 0; C < p; C++) { + var x = y[C]; + S[C] = x + (A[C] - x) * a; + } + } else for (var w = 0; w < p; w++) S[w] = A[w] * a; + break; + + case i.first: + case i.replace: + for (var R = 0; R < p; R++) S[R] += (A[R] - S[R]) * a; + + case i.add: + if (null == (f = u).bones) { + y = f.vertices; + for (var I = 0; I < p; I++) S[I] += (A[I] - y[I]) * a; + } else for (var M = 0; M < p; M++) S[M] += A[M] * a; + } + } else { + var B = e.binarySearch(m, r); + var D = d[B - 1]; + var P = d[B]; + var O = m[B]; + var N = this.getCurvePercent(B - 1, 1 - (r - O) / (m[B - 1] - O)); + if (1 == a) if (l == i.add) { + if (null == (f = u).bones) { + y = f.vertices; + for (var L = 0; L < p; L++) { + var F = D[L]; + S[L] += F + (P[L] - F) * N - y[L]; + } + } else for (var V = 0; V < p; V++) { + F = D[V]; + S[V] += F + (P[V] - F) * N; + } + } else for (var k = 0; k < p; k++) { + F = D[k]; + S[k] = F + (P[k] - F) * N; + } else switch (l) { + case i.setup: + var U = u; + if (null == U.bones) { + y = U.vertices; + for (var G = 0; G < p; G++) { + F = D[G], x = y[G]; + S[G] = x + (F + (P[G] - F) * N - x) * a; + } + } else for (var z = 0; z < p; z++) { + F = D[z]; + S[z] = (F + (P[z] - F) * N) * a; + } + break; + + case i.first: + case i.replace: + for (var H = 0; H < p; H++) { + F = D[H]; + S[H] += (F + (P[H] - F) * N - S[H]) * a; + } + break; + + case i.add: + if (null == (f = u).bones) { + y = f.vertices; + for (var j = 0; j < p; j++) { + F = D[j]; + S[j] += (F + (P[j] - F) * N - y[j]) * a; + } + } else for (var X = 0; X < p; X++) { + F = D[X]; + S[X] += (F + (P[X] - F) * N) * a; + } + } + } + } + } + } + }; + return r; + }(r); + t.DeformTimeline = p; + var m = function() { + function i(e) { + this.frames = t.Utils.newFloatArray(e); + this.events = new Array(e); + } + i.prototype.getPropertyId = function() { + return n.event << 24; + }; + i.prototype.getFrameCount = function() { + return this.frames.length; + }; + i.prototype.setFrame = function(t, e) { + this.frames[t] = e.time; + this.events[t] = e; + }; + i.prototype.apply = function(t, i, s, n, r, o, a) { + if (null != n) { + var l = this.frames; + var h = this.frames.length; + if (i > s) { + this.apply(t, i, Number.MAX_VALUE, n, r, o, a); + i = -1; + } else if (i >= l[h - 1]) return; + if (!(s < l[0])) { + var c = 0; + if (i < l[0]) c = 0; else { + var u = l[c = e.binarySearch(l, i)]; + for (;c > 0 && l[c - 1] == u; ) c--; + } + for (;c < h && s >= l[c]; c++) n.push(this.events[c]); + } + } + }; + return i; + }(); + t.EventTimeline = m; + var f = function() { + function r(e) { + this.frames = t.Utils.newFloatArray(e); + this.drawOrders = new Array(e); + } + r.prototype.getPropertyId = function() { + return n.drawOrder << 24; + }; + r.prototype.getFrameCount = function() { + return this.frames.length; + }; + r.prototype.setFrame = function(t, e, i) { + this.frames[t] = e; + this.drawOrders[t] = i; + }; + r.prototype.apply = function(n, r, o, a, l, h, c) { + var u = n.drawOrder; + var _ = n.slots; + if (c != s.mixOut || h != i.setup) { + var d = this.frames; + if (o < d[0]) h != i.setup && h != i.first || t.Utils.arrayCopy(n.slots, 0, n.drawOrder, 0, n.slots.length); else { + var p = 0; + p = o >= d[d.length - 1] ? d.length - 1 : e.binarySearch(d, o) - 1; + var m = this.drawOrders[p]; + if (null == m) t.Utils.arrayCopy(_, 0, u, 0, _.length); else for (var f = 0, g = m.length; f < g; f++) u[f] = _[m[f]]; + } + } else t.Utils.arrayCopy(n.slots, 0, n.drawOrder, 0, n.slots.length); + }; + return r; + }(); + t.DrawOrderTimeline = f; + var g = function(r) { + AMt(o, r); + function o(e) { + var i = r.call(this, e) || this; + i.frames = t.Utils.newFloatArray(e * o.ENTRIES); + return i; + } + o.prototype.getPropertyId = function() { + return (n.ikConstraint << 24) + this.ikConstraintIndex; + }; + o.prototype.setFrame = function(t, e, i, s, n, r, a) { + t *= o.ENTRIES; + this.frames[t] = e; + this.frames[t + o.MIX] = i; + this.frames[t + o.SOFTNESS] = s; + this.frames[t + o.BEND_DIRECTION] = n; + this.frames[t + o.COMPRESS] = r ? 1 : 0; + this.frames[t + o.STRETCH] = a ? 1 : 0; + }; + o.prototype.apply = function(t, n, r, a, l, h, c) { + var u = this.frames; + var _ = t.ikConstraints[this.ikConstraintIndex]; + if (_.active) if (r < u[0]) switch (h) { + case i.setup: + _.mix = _.data.mix; + _.softness = _.data.softness; + _.bendDirection = _.data.bendDirection; + _.compress = _.data.compress; + _.stretch = _.data.stretch; + return; + + case i.first: + _.mix += (_.data.mix - _.mix) * l; + _.softness += (_.data.softness - _.softness) * l; + _.bendDirection = _.data.bendDirection; + _.compress = _.data.compress; + _.stretch = _.data.stretch; + } else if (r >= u[u.length - o.ENTRIES]) if (h == i.setup) { + _.mix = _.data.mix + (u[u.length + o.PREV_MIX] - _.data.mix) * l; + _.softness = _.data.softness + (u[u.length + o.PREV_SOFTNESS] - _.data.softness) * l; + if (c == s.mixOut) { + _.bendDirection = _.data.bendDirection; + _.compress = _.data.compress; + _.stretch = _.data.stretch; + } else { + _.bendDirection = u[u.length + o.PREV_BEND_DIRECTION]; + _.compress = 0 != u[u.length + o.PREV_COMPRESS]; + _.stretch = 0 != u[u.length + o.PREV_STRETCH]; + } + } else { + _.mix += (u[u.length + o.PREV_MIX] - _.mix) * l; + _.softness += (u[u.length + o.PREV_SOFTNESS] - _.softness) * l; + if (c == s.mixIn) { + _.bendDirection = u[u.length + o.PREV_BEND_DIRECTION]; + _.compress = 0 != u[u.length + o.PREV_COMPRESS]; + _.stretch = 0 != u[u.length + o.PREV_STRETCH]; + } + } else { + var d = e.binarySearch(u, r, o.ENTRIES); + var p = u[d + o.PREV_MIX]; + var m = u[d + o.PREV_SOFTNESS]; + var f = u[d]; + var g = this.getCurvePercent(d / o.ENTRIES - 1, 1 - (r - f) / (u[d + o.PREV_TIME] - f)); + if (h == i.setup) { + _.mix = _.data.mix + (p + (u[d + o.MIX] - p) * g - _.data.mix) * l; + _.softness = _.data.softness + (m + (u[d + o.SOFTNESS] - m) * g - _.data.softness) * l; + if (c == s.mixOut) { + _.bendDirection = _.data.bendDirection; + _.compress = _.data.compress; + _.stretch = _.data.stretch; + } else { + _.bendDirection = u[d + o.PREV_BEND_DIRECTION]; + _.compress = 0 != u[d + o.PREV_COMPRESS]; + _.stretch = 0 != u[d + o.PREV_STRETCH]; + } + } else { + _.mix += (p + (u[d + o.MIX] - p) * g - _.mix) * l; + _.softness += (m + (u[d + o.SOFTNESS] - m) * g - _.softness) * l; + if (c == s.mixIn) { + _.bendDirection = u[d + o.PREV_BEND_DIRECTION]; + _.compress = 0 != u[d + o.PREV_COMPRESS]; + _.stretch = 0 != u[d + o.PREV_STRETCH]; + } + } + } + }; + o.ENTRIES = 6; + o.PREV_TIME = -6; + o.PREV_MIX = -5; + o.PREV_SOFTNESS = -4; + o.PREV_BEND_DIRECTION = -3; + o.PREV_COMPRESS = -2; + o.PREV_STRETCH = -1; + o.MIX = 1; + o.SOFTNESS = 2; + o.BEND_DIRECTION = 3; + o.COMPRESS = 4; + o.STRETCH = 5; + return o; + }(r); + t.IkConstraintTimeline = g; + var y = function(s) { + AMt(r, s); + function r(e) { + var i = s.call(this, e) || this; + i.frames = t.Utils.newFloatArray(e * r.ENTRIES); + return i; + } + r.prototype.getPropertyId = function() { + return (n.transformConstraint << 24) + this.transformConstraintIndex; + }; + r.prototype.setFrame = function(t, e, i, s, n, o) { + t *= r.ENTRIES; + this.frames[t] = e; + this.frames[t + r.ROTATE] = i; + this.frames[t + r.TRANSLATE] = s; + this.frames[t + r.SCALE] = n; + this.frames[t + r.SHEAR] = o; + }; + r.prototype.apply = function(t, s, n, o, a, l, h) { + var c = this.frames; + var u = t.transformConstraints[this.transformConstraintIndex]; + if (u.active) if (n < c[0]) { + var _ = u.data; + switch (l) { + case i.setup: + u.rotateMix = _.rotateMix; + u.translateMix = _.translateMix; + u.scaleMix = _.scaleMix; + u.shearMix = _.shearMix; + return; + + case i.first: + u.rotateMix += (_.rotateMix - u.rotateMix) * a; + u.translateMix += (_.translateMix - u.translateMix) * a; + u.scaleMix += (_.scaleMix - u.scaleMix) * a; + u.shearMix += (_.shearMix - u.shearMix) * a; + } + } else { + var d = 0, p = 0, m = 0, f = 0; + if (n >= c[c.length - r.ENTRIES]) { + var g = c.length; + d = c[g + r.PREV_ROTATE]; + p = c[g + r.PREV_TRANSLATE]; + m = c[g + r.PREV_SCALE]; + f = c[g + r.PREV_SHEAR]; + } else { + var y = e.binarySearch(c, n, r.ENTRIES); + d = c[y + r.PREV_ROTATE]; + p = c[y + r.PREV_TRANSLATE]; + m = c[y + r.PREV_SCALE]; + f = c[y + r.PREV_SHEAR]; + var b = c[y]; + var S = this.getCurvePercent(y / r.ENTRIES - 1, 1 - (n - b) / (c[y + r.PREV_TIME] - b)); + d += (c[y + r.ROTATE] - d) * S; + p += (c[y + r.TRANSLATE] - p) * S; + m += (c[y + r.SCALE] - m) * S; + f += (c[y + r.SHEAR] - f) * S; + } + if (l == i.setup) { + _ = u.data; + u.rotateMix = _.rotateMix + (d - _.rotateMix) * a; + u.translateMix = _.translateMix + (p - _.translateMix) * a; + u.scaleMix = _.scaleMix + (m - _.scaleMix) * a; + u.shearMix = _.shearMix + (f - _.shearMix) * a; + } else { + u.rotateMix += (d - u.rotateMix) * a; + u.translateMix += (p - u.translateMix) * a; + u.scaleMix += (m - u.scaleMix) * a; + u.shearMix += (f - u.shearMix) * a; + } + } + }; + r.ENTRIES = 5; + r.PREV_TIME = -5; + r.PREV_ROTATE = -4; + r.PREV_TRANSLATE = -3; + r.PREV_SCALE = -2; + r.PREV_SHEAR = -1; + r.ROTATE = 1; + r.TRANSLATE = 2; + r.SCALE = 3; + r.SHEAR = 4; + return r; + }(r); + t.TransformConstraintTimeline = y; + var b = function(s) { + AMt(r, s); + function r(e) { + var i = s.call(this, e) || this; + i.frames = t.Utils.newFloatArray(e * r.ENTRIES); + return i; + } + r.prototype.getPropertyId = function() { + return (n.pathConstraintPosition << 24) + this.pathConstraintIndex; + }; + r.prototype.setFrame = function(t, e, i) { + t *= r.ENTRIES; + this.frames[t] = e; + this.frames[t + r.VALUE] = i; + }; + r.prototype.apply = function(t, s, n, o, a, l, h) { + var c = this.frames; + var u = t.pathConstraints[this.pathConstraintIndex]; + if (u.active) if (n < c[0]) switch (l) { + case i.setup: + u.position = u.data.position; + return; + + case i.first: + u.position += (u.data.position - u.position) * a; + } else { + var _ = 0; + if (n >= c[c.length - r.ENTRIES]) _ = c[c.length + r.PREV_VALUE]; else { + var d = e.binarySearch(c, n, r.ENTRIES); + _ = c[d + r.PREV_VALUE]; + var p = c[d]; + var m = this.getCurvePercent(d / r.ENTRIES - 1, 1 - (n - p) / (c[d + r.PREV_TIME] - p)); + _ += (c[d + r.VALUE] - _) * m; + } + l == i.setup ? u.position = u.data.position + (_ - u.data.position) * a : u.position += (_ - u.position) * a; + } + }; + r.ENTRIES = 2; + r.PREV_TIME = -2; + r.PREV_VALUE = -1; + r.VALUE = 1; + return r; + }(r); + t.PathConstraintPositionTimeline = b; + var S = function(t) { + AMt(s, t); + function s(e) { + return t.call(this, e) || this; + } + s.prototype.getPropertyId = function() { + return (n.pathConstraintSpacing << 24) + this.pathConstraintIndex; + }; + s.prototype.apply = function(t, n, r, o, a, l, h) { + var c = this.frames; + var u = t.pathConstraints[this.pathConstraintIndex]; + if (u.active) if (r < c[0]) switch (l) { + case i.setup: + u.spacing = u.data.spacing; + return; + + case i.first: + u.spacing += (u.data.spacing - u.spacing) * a; + } else { + var _ = 0; + if (r >= c[c.length - s.ENTRIES]) _ = c[c.length + s.PREV_VALUE]; else { + var d = e.binarySearch(c, r, s.ENTRIES); + _ = c[d + s.PREV_VALUE]; + var p = c[d]; + var m = this.getCurvePercent(d / s.ENTRIES - 1, 1 - (r - p) / (c[d + s.PREV_TIME] - p)); + _ += (c[d + s.VALUE] - _) * m; + } + l == i.setup ? u.spacing = u.data.spacing + (_ - u.data.spacing) * a : u.spacing += (_ - u.spacing) * a; + } + }; + return s; + }(b); + t.PathConstraintSpacingTimeline = S; + var A = function(s) { + AMt(r, s); + function r(e) { + var i = s.call(this, e) || this; + i.frames = t.Utils.newFloatArray(e * r.ENTRIES); + return i; + } + r.prototype.getPropertyId = function() { + return (n.pathConstraintMix << 24) + this.pathConstraintIndex; + }; + r.prototype.setFrame = function(t, e, i, s) { + t *= r.ENTRIES; + this.frames[t] = e; + this.frames[t + r.ROTATE] = i; + this.frames[t + r.TRANSLATE] = s; + }; + r.prototype.apply = function(t, s, n, o, a, l, h) { + var c = this.frames; + var u = t.pathConstraints[this.pathConstraintIndex]; + if (u.active) if (n < c[0]) switch (l) { + case i.setup: + u.rotateMix = u.data.rotateMix; + u.translateMix = u.data.translateMix; + return; + + case i.first: + u.rotateMix += (u.data.rotateMix - u.rotateMix) * a; + u.translateMix += (u.data.translateMix - u.translateMix) * a; + } else { + var _ = 0, d = 0; + if (n >= c[c.length - r.ENTRIES]) { + _ = c[c.length + r.PREV_ROTATE]; + d = c[c.length + r.PREV_TRANSLATE]; + } else { + var p = e.binarySearch(c, n, r.ENTRIES); + _ = c[p + r.PREV_ROTATE]; + d = c[p + r.PREV_TRANSLATE]; + var m = c[p]; + var f = this.getCurvePercent(p / r.ENTRIES - 1, 1 - (n - m) / (c[p + r.PREV_TIME] - m)); + _ += (c[p + r.ROTATE] - _) * f; + d += (c[p + r.TRANSLATE] - d) * f; + } + if (l == i.setup) { + u.rotateMix = u.data.rotateMix + (_ - u.data.rotateMix) * a; + u.translateMix = u.data.translateMix + (d - u.data.translateMix) * a; + } else { + u.rotateMix += (_ - u.rotateMix) * a; + u.translateMix += (d - u.translateMix) * a; + } + } + }; + r.ENTRIES = 3; + r.PREV_TIME = -3; + r.PREV_ROTATE = -2; + r.PREV_TRANSLATE = -1; + r.ROTATE = 1; + r.TRANSLATE = 2; + return r; + }(r); + t.PathConstraintMixTimeline = A; + }(TMt || (TMt = {})); + !function(t) { + var e = function() { + function e(e) { + this.tracks = new Array; + this.timeScale = 1; + this.events = new Array; + this.listeners = new Array; + this.queue = new s(this); + this.propertyIDs = new t.IntSet; + this.animationsChanged = !1; + this.trackEntryPool = new t.Pool((function() { + return new i; + })); + this.data = e; + } + e.prototype.update = function(t) { + t *= this.timeScale; + var e = this.tracks; + for (var i = 0, s = e.length; i < s; i++) { + var n = e[i]; + if (null != n) { + n.animationLast = n.nextAnimationLast; + n.trackLast = n.nextTrackLast; + var r = t * n.timeScale; + if (n.delay > 0) { + n.delay -= r; + if (n.delay > 0) continue; + r = -n.delay; + n.delay = 0; + } + var o = n.next; + if (null != o) { + var a = n.trackLast - o.delay; + if (a >= 0) { + o.delay = 0; + o.trackTime += 0 == n.timeScale ? 0 : (a / n.timeScale + t) * o.timeScale; + n.trackTime += r; + this.setCurrent(i, o, !0); + for (;null != o.mixingFrom; ) { + o.mixTime += t; + o = o.mixingFrom; + } + continue; + } + } else if (n.trackLast >= n.trackEnd && null == n.mixingFrom) { + e[i] = null; + this.queue.end(n); + this.disposeNext(n); + continue; + } + if (null != n.mixingFrom && this.updateMixingFrom(n, t)) { + var l = n.mixingFrom; + n.mixingFrom = null; + null != l && (l.mixingTo = null); + for (;null != l; ) { + this.queue.end(l); + l = l.mixingFrom; + } + } + n.trackTime += r; + } + } + this.queue.drain(); + }; + e.prototype.updateMixingFrom = function(t, e) { + var i = t.mixingFrom; + if (null == i) return !0; + var s = this.updateMixingFrom(i, e); + i.animationLast = i.nextAnimationLast; + i.trackLast = i.nextTrackLast; + if (t.mixTime > 0 && t.mixTime >= t.mixDuration) { + if (0 == i.totalAlpha || 0 == t.mixDuration) { + t.mixingFrom = i.mixingFrom; + null != i.mixingFrom && (i.mixingFrom.mixingTo = t); + t.interruptAlpha = i.interruptAlpha; + this.queue.end(i); + } + return s; + } + i.trackTime += e * i.timeScale; + t.mixTime += e; + return !1; + }; + e.prototype.apply = function(i) { + if (null == i) throw new Error("skeleton cannot be null."); + this.animationsChanged && this._animationsChanged(); + var s = this.events; + var n = this.tracks; + var r = !1; + for (var o = 0, a = n.length; o < a; o++) { + var l = n[o]; + if (!(null == l || l.delay > 0)) { + r = !0; + var h = 0 == o ? t.MixBlend.first : l.mixBlend; + var c = l.alpha; + null != l.mixingFrom ? c *= this.applyMixingFrom(l, i, h) : l.trackTime >= l.trackEnd && null == l.next && (c = 0); + var u = l.animationLast, _ = l.getAnimationTime(); + var d = l.animation.timelines.length; + var p = l.animation.timelines; + if (0 == o && 1 == c || h == t.MixBlend.add) for (var m = 0; m < d; m++) { + t.Utils.webkit602BugfixHelper(c, h); + p[m].apply(i, u, _, s, c, h, t.MixDirection.mixIn); + } else { + var f = l.timelineMode; + var g = 0 == l.timelinesRotation.length; + g && t.Utils.setArraySize(l.timelinesRotation, d << 1, null); + var y = l.timelinesRotation; + for (m = 0; m < d; m++) { + var b = p[m]; + var S = (f[m] & e.NOT_LAST - 1) == e.SUBSEQUENT ? h : t.MixBlend.setup; + if (b instanceof t.RotateTimeline) this.applyRotateTimeline(b, i, _, c, S, y, m << 1, g); else { + t.Utils.webkit602BugfixHelper(c, h); + b.apply(i, u, _, s, c, S, t.MixDirection.mixIn); + } + } + } + this.queueEvents(l, _); + s.length = 0; + l.nextAnimationLast = _; + l.nextTrackLast = l.trackTime; + } + } + this.queue.drain(); + return r; + }; + e.prototype.applyMixingFrom = function(i, s, n) { + var r = i.mixingFrom; + null != r.mixingFrom && this.applyMixingFrom(r, s, n); + var o = 0; + if (0 == i.mixDuration) { + o = 1; + n == t.MixBlend.first && (n = t.MixBlend.setup); + } else { + (o = i.mixTime / i.mixDuration) > 1 && (o = 1); + n != t.MixBlend.first && (n = r.mixBlend); + } + var a = o < r.eventThreshold ? this.events : null; + var l = o < r.attachmentThreshold, h = o < r.drawOrderThreshold; + var c = r.animationLast, u = r.getAnimationTime(); + var _ = r.animation.timelines.length; + var d = r.animation.timelines; + var p = r.alpha * i.interruptAlpha, m = p * (1 - o); + if (n == t.MixBlend.add) for (var f = 0; f < _; f++) d[f].apply(s, c, u, a, m, n, t.MixDirection.mixOut); else { + var g = r.timelineMode; + var y = r.timelineHoldMix; + var b = 0 == r.timelinesRotation.length; + b && t.Utils.setArraySize(r.timelinesRotation, _ << 1, null); + var S = r.timelinesRotation; + r.totalAlpha = 0; + for (f = 0; f < _; f++) { + var A = d[f]; + var T = t.MixDirection.mixOut; + var v = void 0; + var E = 0; + switch (g[f] & e.NOT_LAST - 1) { + case e.SUBSEQUENT: + v = n; + if (!l && A instanceof t.AttachmentTimeline) { + if ((g[f] & e.NOT_LAST) == e.NOT_LAST) continue; + v = t.MixBlend.setup; + } + if (!h && A instanceof t.DrawOrderTimeline) continue; + E = m; + break; + + case e.FIRST: + v = t.MixBlend.setup; + E = m; + break; + + case e.HOLD: + v = t.MixBlend.setup; + E = p; + break; + + default: + v = t.MixBlend.setup; + var C = y[f]; + E = p * Math.max(0, 1 - C.mixTime / C.mixDuration); + } + r.totalAlpha += E; + if (A instanceof t.RotateTimeline) this.applyRotateTimeline(A, s, u, E, v, S, f << 1, b); else { + t.Utils.webkit602BugfixHelper(E, n); + v == t.MixBlend.setup && (A instanceof t.AttachmentTimeline ? (l || (g[f] & e.NOT_LAST) == e.NOT_LAST) && (T = t.MixDirection.mixIn) : A instanceof t.DrawOrderTimeline && h && (T = t.MixDirection.mixIn)); + A.apply(s, c, u, a, E, v, T); + } + } + } + i.mixDuration > 0 && this.queueEvents(r, u); + this.events.length = 0; + r.nextAnimationLast = u; + r.nextTrackLast = r.trackTime; + return o; + }; + e.prototype.applyRotateTimeline = function(e, i, s, n, r, o, a, l) { + l && (o[a] = 0); + if (1 != n) { + var h = e; + var c = h.frames; + var u = i.bones[h.boneIndex]; + if (u.active) { + var _ = 0, d = 0; + if (s < c[0]) switch (r) { + case t.MixBlend.setup: + u.rotation = u.data.rotation; + + default: + return; + + case t.MixBlend.first: + _ = u.rotation; + d = u.data.rotation; + } else { + _ = r == t.MixBlend.setup ? u.data.rotation : u.rotation; + if (s >= c[c.length - t.RotateTimeline.ENTRIES]) d = u.data.rotation + c[c.length + t.RotateTimeline.PREV_ROTATION]; else { + var p = t.Animation.binarySearch(c, s, t.RotateTimeline.ENTRIES); + var m = c[p + t.RotateTimeline.PREV_ROTATION]; + var f = c[p]; + var g = h.getCurvePercent((p >> 1) - 1, 1 - (s - f) / (c[p + t.RotateTimeline.PREV_TIME] - f)); + d = c[p + t.RotateTimeline.ROTATION] - m; + d = m + (d -= 360 * (16384 - (16384.499999999996 - d / 360 | 0))) * g + u.data.rotation; + d -= 360 * (16384 - (16384.499999999996 - d / 360 | 0)); + } + } + var y = 0, b = d - _; + if (0 == (b -= 360 * (16384 - (16384.499999999996 - b / 360 | 0)))) y = o[a]; else { + var S = 0, A = 0; + if (l) { + S = 0; + A = b; + } else { + S = o[a]; + A = o[a + 1]; + } + var T = b > 0, v = S >= 0; + if (t.MathUtils.signum(A) != t.MathUtils.signum(b) && Math.abs(A) <= 90) { + Math.abs(S) > 180 && (S += 360 * t.MathUtils.signum(S)); + v = T; + } + y = b + S - S % 360; + v != T && (y += 360 * t.MathUtils.signum(S)); + o[a] = y; + } + o[a + 1] = b; + _ += y * n; + u.rotation = _ - 360 * (16384 - (16384.499999999996 - _ / 360 | 0)); + } + } else e.apply(i, 0, s, null, 1, r, t.MixDirection.mixIn); + }; + e.prototype.queueEvents = function(t, e) { + var i = t.animationStart, s = t.animationEnd; + var n = s - i; + var r = t.trackLast % n; + var o = this.events; + var a = 0, l = o.length; + for (;a < l; a++) { + var h = o[a]; + if (h.time < r) break; + h.time > s || this.queue.event(t, h); + } + (t.loop ? 0 == n || r > t.trackTime % n : e >= s && t.animationLast < s) && this.queue.complete(t); + for (;a < l; a++) { + o[a].time < i || this.queue.event(t, o[a]); + } + }; + e.prototype.clearTracks = function() { + var t = this.queue.drainDisabled; + this.queue.drainDisabled = !0; + for (var e = 0, i = this.tracks.length; e < i; e++) this.clearTrack(e); + this.tracks.length = 0; + this.queue.drainDisabled = t; + this.queue.drain(); + }; + e.prototype.clearTrack = function(t) { + if (!(t >= this.tracks.length)) { + var e = this.tracks[t]; + if (null != e) { + this.queue.end(e); + this.disposeNext(e); + var i = e; + for (;;) { + var s = i.mixingFrom; + if (null == s) break; + this.queue.end(s); + i.mixingFrom = null; + i.mixingTo = null; + i = s; + } + this.tracks[e.trackIndex] = null; + this.queue.drain(); + } + } + }; + e.prototype.setCurrent = function(t, e, i) { + var s = this.expandToIndex(t); + this.tracks[t] = e; + if (null != s) { + i && this.queue.interrupt(s); + e.mixingFrom = s; + s.mixingTo = e; + e.mixTime = 0; + null != s.mixingFrom && s.mixDuration > 0 && (e.interruptAlpha *= Math.min(1, s.mixTime / s.mixDuration)); + s.timelinesRotation.length = 0; + } + this.queue.start(e); + }; + e.prototype.setAnimation = function(t, e, i) { + var s = this.data.skeletonData.findAnimation(e); + if (null == s) throw new Error("Animation not found: " + e); + return this.setAnimationWith(t, s, i); + }; + e.prototype.setAnimationWith = function(t, e, i) { + if (null == e) throw new Error("animation cannot be null."); + var s = !0; + var n = this.expandToIndex(t); + if (null != n) if (-1 == n.nextTrackLast) { + this.tracks[t] = n.mixingFrom; + this.queue.interrupt(n); + this.queue.end(n); + this.disposeNext(n); + n = n.mixingFrom; + s = !1; + } else this.disposeNext(n); + var r = this.trackEntry(t, e, i, n); + this.setCurrent(t, r, s); + this.queue.drain(); + return r; + }; + e.prototype.addAnimation = function(t, e, i, s) { + var n = this.data.skeletonData.findAnimation(e); + if (null == n) throw new Error("Animation not found: " + e); + return this.addAnimationWith(t, n, i, s); + }; + e.prototype.addAnimationWith = function(t, e, i, s) { + if (null == e) throw new Error("animation cannot be null."); + var n = this.expandToIndex(t); + if (null != n) for (;null != n.next; ) n = n.next; + var r = this.trackEntry(t, e, i, n); + if (null == n) { + this.setCurrent(t, r, !0); + this.queue.drain(); + } else { + n.next = r; + if (s <= 0) { + var o = n.animationEnd - n.animationStart; + if (0 != o) { + n.loop ? s += o * (1 + (n.trackTime / o | 0)) : s += Math.max(o, n.trackTime); + s -= this.data.getMix(n.animation, e); + } else s = n.trackTime; + } + } + r.delay = s; + return r; + }; + e.prototype.setEmptyAnimation = function(t, i) { + var s = this.setAnimationWith(t, e.emptyAnimation, !1); + s.mixDuration = i; + s.trackEnd = i; + return s; + }; + e.prototype.addEmptyAnimation = function(t, i, s) { + s <= 0 && (s -= i); + var n = this.addAnimationWith(t, e.emptyAnimation, !1, s); + n.mixDuration = i; + n.trackEnd = i; + return n; + }; + e.prototype.setEmptyAnimations = function(t) { + var e = this.queue.drainDisabled; + this.queue.drainDisabled = !0; + for (var i = 0, s = this.tracks.length; i < s; i++) { + var n = this.tracks[i]; + null != n && this.setEmptyAnimation(n.trackIndex, t); + } + this.queue.drainDisabled = e; + this.queue.drain(); + }; + e.prototype.expandToIndex = function(e) { + if (e < this.tracks.length) return this.tracks[e]; + t.Utils.ensureArrayCapacity(this.tracks, e + 1, null); + this.tracks.length = e + 1; + return null; + }; + e.prototype.trackEntry = function(t, e, i, s) { + var n = this.trackEntryPool.obtain(); + n.trackIndex = t; + n.animation = e; + n.loop = i; + n.holdPrevious = !1; + n.eventThreshold = 0; + n.attachmentThreshold = 0; + n.drawOrderThreshold = 0; + n.animationStart = 0; + n.animationEnd = e.duration; + n.animationLast = -1; + n.nextAnimationLast = -1; + n.delay = 0; + n.trackTime = 0; + n.trackLast = -1; + n.nextTrackLast = -1; + n.trackEnd = Number.MAX_VALUE; + n.timeScale = 1; + n.alpha = 1; + n.interruptAlpha = 1; + n.mixTime = 0; + n.mixDuration = null == s ? 0 : this.data.getMix(s.animation, e); + return n; + }; + e.prototype.disposeNext = function(t) { + var e = t.next; + for (;null != e; ) { + this.queue.dispose(e); + e = e.next; + } + t.next = null; + }; + e.prototype._animationsChanged = function() { + this.animationsChanged = !1; + this.propertyIDs.clear(); + for (var e = 0, i = this.tracks.length; e < i; e++) { + if (null != (s = this.tracks[e])) { + for (;null != s.mixingFrom; ) s = s.mixingFrom; + do { + null != s.mixingFrom && s.mixBlend == t.MixBlend.add || this.computeHold(s); + s = s.mixingTo; + } while (null != s); + } + } + this.propertyIDs.clear(); + for (e = this.tracks.length - 1; e >= 0; e--) { + var s = this.tracks[e]; + for (;null != s; ) { + this.computeNotLast(s); + s = s.mixingFrom; + } + } + }; + e.prototype.computeHold = function(i) { + var s = i.mixingTo; + var n = i.animation.timelines; + var r = i.animation.timelines.length; + var o = t.Utils.setArraySize(i.timelineMode, r); + i.timelineHoldMix.length = 0; + var a = t.Utils.setArraySize(i.timelineHoldMix, r); + var l = this.propertyIDs; + if (null != s && s.holdPrevious) for (var h = 0; h < r; h++) { + l.add(n[h].getPropertyId()); + o[h] = e.HOLD; + } else t: for (h = 0; h < r; h++) { + var c = n[h]; + var u = c.getPropertyId(); + if (l.add(u)) if (null == s || c instanceof t.AttachmentTimeline || c instanceof t.DrawOrderTimeline || c instanceof t.EventTimeline || !s.animation.hasTimeline(u)) o[h] = e.FIRST; else { + for (var _ = s.mixingTo; null != _; _ = _.mixingTo) if (!_.animation.hasTimeline(u)) { + if (i.mixDuration > 0) { + o[h] = e.HOLD_MIX; + a[h] = _; + continue t; + } + break; + } + o[h] = e.HOLD; + } else o[h] = e.SUBSEQUENT; + } + }; + e.prototype.computeNotLast = function(i) { + var s = i.animation.timelines; + var n = i.animation.timelines.length; + var r = i.timelineMode; + var o = this.propertyIDs; + for (var a = 0; a < n; a++) if (s[a] instanceof t.AttachmentTimeline) { + var l = s[a]; + o.add(l.slotIndex) || (r[a] |= e.NOT_LAST); + } + }; + e.prototype.getCurrent = function(t) { + return t >= this.tracks.length ? null : this.tracks[t]; + }; + e.prototype.addListener = function(t) { + if (null == t) throw new Error("listener cannot be null."); + this.listeners.push(t); + }; + e.prototype.removeListener = function(t) { + var e = this.listeners.indexOf(t); + e >= 0 && this.listeners.splice(e, 1); + }; + e.prototype.clearListeners = function() { + this.listeners.length = 0; + }; + e.prototype.clearListenerNotifications = function() { + this.queue.clear(); + }; + e.emptyAnimation = new t.Animation("", [], 0); + e.SUBSEQUENT = 0; + e.FIRST = 1; + e.HOLD = 2; + e.HOLD_MIX = 3; + e.NOT_LAST = 4; + return e; + }(); + t.AnimationState = e; + var i = function() { + function e() { + this.mixBlend = t.MixBlend.replace; + this.timelineMode = new Array; + this.timelineHoldMix = new Array; + this.timelinesRotation = new Array; + } + e.prototype.reset = function() { + this.next = null; + this.mixingFrom = null; + this.mixingTo = null; + this.animation = null; + this.listener = null; + this.timelineMode.length = 0; + this.timelineHoldMix.length = 0; + this.timelinesRotation.length = 0; + }; + e.prototype.getAnimationTime = function() { + if (this.loop) { + var t = this.animationEnd - this.animationStart; + return 0 == t ? this.animationStart : this.trackTime % t + this.animationStart; + } + return Math.min(this.trackTime + this.animationStart, this.animationEnd); + }; + e.prototype.setAnimationLast = function(t) { + this.animationLast = t; + this.nextAnimationLast = t; + }; + e.prototype.isComplete = function() { + return this.trackTime >= this.animationEnd - this.animationStart; + }; + e.prototype.resetRotationDirections = function() { + this.timelinesRotation.length = 0; + }; + return e; + }(); + t.TrackEntry = i; + var s = function() { + function t(t) { + this.objects = []; + this.drainDisabled = !1; + this.animState = t; + } + t.prototype.start = function(t) { + this.objects.push(n.start); + this.objects.push(t); + this.animState.animationsChanged = !0; + }; + t.prototype.interrupt = function(t) { + this.objects.push(n.interrupt); + this.objects.push(t); + }; + t.prototype.end = function(t) { + this.objects.push(n.end); + this.objects.push(t); + this.animState.animationsChanged = !0; + }; + t.prototype.dispose = function(t) { + this.objects.push(n.dispose); + this.objects.push(t); + }; + t.prototype.complete = function(t) { + this.objects.push(n.complete); + this.objects.push(t); + }; + t.prototype.event = function(t, e) { + this.objects.push(n.event); + this.objects.push(t); + this.objects.push(e); + }; + t.prototype.drain = function() { + if (!this.drainDisabled) { + this.drainDisabled = !0; + var t = this.objects; + var e = this.animState.listeners; + for (var i = 0; i < t.length; i += 2) { + var s = t[i]; + var r = t[i + 1]; + switch (s) { + case n.start: + null != r.listener && r.listener.start && r.listener.start(r); + for (var o = 0; o < e.length; o++) e[o].start && e[o].start(r); + break; + + case n.interrupt: + null != r.listener && r.listener.interrupt && r.listener.interrupt(r); + for (o = 0; o < e.length; o++) e[o].interrupt && e[o].interrupt(r); + break; + + case n.end: + null != r.listener && r.listener.end && r.listener.end(r); + for (o = 0; o < e.length; o++) e[o].end && e[o].end(r); + + case n.dispose: + null != r.listener && r.listener.dispose && r.listener.dispose(r); + for (o = 0; o < e.length; o++) e[o].dispose && e[o].dispose(r); + this.animState.trackEntryPool.free(r); + break; + + case n.complete: + null != r.listener && r.listener.complete && r.listener.complete(r); + for (o = 0; o < e.length; o++) e[o].complete && e[o].complete(r); + break; + + case n.event: + var a = t[2 + i++]; + null != r.listener && r.listener.event && r.listener.event(r, a); + for (o = 0; o < e.length; o++) e[o].event && e[o].event(r, a); + } + } + this.clear(); + this.drainDisabled = !1; + } + }; + t.prototype.clear = function() { + this.objects.length = 0; + }; + return t; + }(); + t.EventQueue = s; + var n; + !function(t) { + t[t.start = 0] = "start"; + t[t.interrupt = 1] = "interrupt"; + t[t.end = 2] = "end"; + t[t.dispose = 3] = "dispose"; + t[t.complete = 4] = "complete"; + t[t.event = 5] = "event"; + }(n = t.EventType || (t.EventType = {})); + var r = function() { + function t() {} + t.prototype.start = function(t) {}; + t.prototype.interrupt = function(t) {}; + t.prototype.end = function(t) {}; + t.prototype.dispose = function(t) {}; + t.prototype.complete = function(t) {}; + t.prototype.event = function(t, e) {}; + return t; + }(); + t.AnimationStateAdapter = r; + }(TMt || (TMt = {})); + !function(t) { + var e = function() { + function t(t) { + this.animationToMixTime = {}; + this.defaultMix = 0; + if (null == t) throw new Error("skeletonData cannot be null."); + this.skeletonData = t; + } + t.prototype.setMix = function(t, e, i) { + var s = this.skeletonData.findAnimation(t); + if (null == s) throw new Error("Animation not found: " + t); + var n = this.skeletonData.findAnimation(e); + if (null == n) throw new Error("Animation not found: " + e); + this.setMixWith(s, n, i); + }; + t.prototype.setMixWith = function(t, e, i) { + if (null == t) throw new Error("from cannot be null."); + if (null == e) throw new Error("to cannot be null."); + var s = t.name + "." + e.name; + this.animationToMixTime[s] = i; + }; + t.prototype.getMix = function(t, e) { + var i = t.name + "." + e.name; + var s = this.animationToMixTime[i]; + return void 0 === s ? this.defaultMix : s; + }; + return t; + }(); + t.AnimationStateData = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function() { + function e(t, e) { + void 0 === e && (e = ""); + this.assets = {}; + this.errors = {}; + this.toLoad = 0; + this.loaded = 0; + this.textureLoader = t; + this.pathPrefix = e; + } + e.downloadText = function(t, e, i) { + var s = new XMLHttpRequest; + s.open("GET", t, !0); + s.onload = function() { + 200 == s.status ? e(s.responseText) : i(s.status, s.responseText); + }; + s.onerror = function() { + i(s.status, s.responseText); + }; + s.send(); + }; + e.downloadBinary = function(t, e, i) { + var s = new XMLHttpRequest; + s.open("GET", t, !0); + s.responseType = "arraybuffer"; + s.onload = function() { + 200 == s.status ? e(new Uint8Array(s.response)) : i(s.status, s.responseText); + }; + s.onerror = function() { + i(s.status, s.responseText); + }; + s.send(); + }; + e.prototype.loadBinary = function(t, i, s) { + var n = this; + void 0 === i && (i = null); + void 0 === s && (s = null); + t = this.pathPrefix + t; + this.toLoad++; + e.downloadBinary(t, (function(e) { + n.assets[t] = e; + i && i(t, e); + n.toLoad--; + n.loaded++; + }), (function(e, i) { + n.errors[t] = "Couldn't load binary " + t + ": status " + status + ", " + i; + s && s(t, "Couldn't load binary " + t + ": status " + status + ", " + i); + n.toLoad--; + n.loaded++; + })); + }; + e.prototype.loadText = function(t, i, s) { + var n = this; + void 0 === i && (i = null); + void 0 === s && (s = null); + t = this.pathPrefix + t; + this.toLoad++; + e.downloadText(t, (function(e) { + n.assets[t] = e; + i && i(t, e); + n.toLoad--; + n.loaded++; + }), (function(e, i) { + n.errors[t] = "Couldn't load text " + t + ": status " + status + ", " + i; + s && s(t, "Couldn't load text " + t + ": status " + status + ", " + i); + n.toLoad--; + n.loaded++; + })); + }; + e.prototype.loadTexture = function(t, e, i) { + var s = this; + void 0 === e && (e = null); + void 0 === i && (i = null); + t = this.pathPrefix + t; + this.toLoad++; + var n = new Image; + n.crossOrigin = "anonymous"; + n.onload = function(i) { + var r = s.textureLoader(n); + s.assets[t] = r; + s.toLoad--; + s.loaded++; + e && e(t, n); + }; + n.onerror = function(e) { + s.errors[t] = "Couldn't load image " + t; + s.toLoad--; + s.loaded++; + i && i(t, "Couldn't load image " + t); + }; + n.src = t; + }; + e.prototype.loadTextureData = function(t, e, i, s) { + var n = this; + void 0 === i && (i = null); + void 0 === s && (s = null); + t = this.pathPrefix + t; + this.toLoad++; + var r = new Image; + r.onload = function(e) { + var s = n.textureLoader(r); + n.assets[t] = s; + n.toLoad--; + n.loaded++; + i && i(t, r); + }; + r.onerror = function(e) { + n.errors[t] = "Couldn't load image " + t; + n.toLoad--; + n.loaded++; + s && s(t, "Couldn't load image " + t); + }; + r.src = e; + }; + e.prototype.loadTextureAtlas = function(i, s, n) { + var r = this; + void 0 === s && (s = null); + void 0 === n && (n = null); + var o = i.lastIndexOf("/") >= 0 ? i.substring(0, i.lastIndexOf("/")) : ""; + i = this.pathPrefix + i; + this.toLoad++; + e.downloadText(i, (function(e) { + var a = { + count: 0 + }; + var l = new Array; + try { + new t.TextureAtlas(e, (function(e) { + l.push(o + "/" + e); + var i = document.createElement("img"); + i.width = 16; + i.height = 16; + return new t.FakeTexture(i); + })); + } catch (t) { + var h = t; + r.errors[i] = "Couldn't load texture atlas " + i + ": " + h.message; + n && n(i, "Couldn't load texture atlas " + i + ": " + h.message); + r.toLoad--; + r.loaded++; + return; + } + var c = function(h) { + var c = !1; + r.loadTexture(h, (function(h, u) { + a.count++; + if (a.count == l.length) if (c) { + r.errors[i] = "Couldn't load texture atlas page " + h + "} of atlas " + i; + n && n(i, "Couldn't load texture atlas page " + h + " of atlas " + i); + r.toLoad--; + r.loaded++; + } else try { + var _ = new t.TextureAtlas(e, (function(t) { + return r.get(o + "/" + t); + })); + r.assets[i] = _; + s && s(i, _); + r.toLoad--; + r.loaded++; + } catch (t) { + var d = t; + r.errors[i] = "Couldn't load texture atlas " + i + ": " + d.message; + n && n(i, "Couldn't load texture atlas " + i + ": " + d.message); + r.toLoad--; + r.loaded++; + } + }), (function(t, e) { + c = !0; + a.count++; + if (a.count == l.length) { + r.errors[i] = "Couldn't load texture atlas page " + t + "} of atlas " + i; + n && n(i, "Couldn't load texture atlas page " + t + " of atlas " + i); + r.toLoad--; + r.loaded++; + } + })); + }; + for (var u = 0, _ = l; u < _.length; u++) { + c(_[u]); + } + }), (function(t, e) { + r.errors[i] = "Couldn't load texture atlas " + i + ": status " + status + ", " + e; + n && n(i, "Couldn't load texture atlas " + i + ": status " + status + ", " + e); + r.toLoad--; + r.loaded++; + })); + }; + e.prototype.get = function(t) { + t = this.pathPrefix + t; + return this.assets[t]; + }; + e.prototype.remove = function(t) { + t = this.pathPrefix + t; + var e = this.assets[t]; + e.dispose && e.dispose(); + this.assets[t] = null; + }; + e.prototype.removeAll = function() { + for (var t in this.assets) { + var e = this.assets[t]; + e.dispose && e.dispose(); + } + this.assets = {}; + }; + e.prototype.isLoadingComplete = function() { + return 0 == this.toLoad; + }; + e.prototype.getToLoad = function() { + return this.toLoad; + }; + e.prototype.getLoaded = function() { + return this.loaded; + }; + e.prototype.dispose = function() { + this.removeAll(); + }; + e.prototype.hasErrors = function() { + return Object.keys(this.errors).length > 0; + }; + e.prototype.getErrors = function() { + return this.errors; + }; + return e; + }(); + t.AssetManager = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function() { + function e(t) { + this.atlas = t; + } + e.prototype.newRegionAttachment = function(e, i, s) { + var n = this.atlas.findRegion(s); + if (null == n) return null; + n.renderObject = n; + var r = new t.RegionAttachment(i); + r.setRegion(n); + return r; + }; + e.prototype.newMeshAttachment = function(e, i, s) { + var n = this.atlas.findRegion(s); + if (null == n) return null; + n.renderObject = n; + var r = new t.MeshAttachment(i); + r.region = n; + return r; + }; + e.prototype.newBoundingBoxAttachment = function(e, i) { + return new t.BoundingBoxAttachment(i); + }; + e.prototype.newPathAttachment = function(e, i) { + return new t.PathAttachment(i); + }; + e.prototype.newPointAttachment = function(e, i) { + return new t.PointAttachment(i); + }; + e.prototype.newClippingAttachment = function(e, i) { + return new t.ClippingAttachment(i); + }; + return e; + }(); + t.AtlasAttachmentLoader = e; + }(TMt || (TMt = {})); + !function(t) { + !function(t) { + t[t.Normal = 0] = "Normal"; + t[t.Additive = 1] = "Additive"; + t[t.Multiply = 2] = "Multiply"; + t[t.Screen = 3] = "Screen"; + }(t.BlendMode || (t.BlendMode = {})); + }(TMt || (TMt = {})); + !function(t) { + var e = function() { + function e(t, e, i) { + this.children = new Array; + this.x = 0; + this.y = 0; + this.rotation = 0; + this.scaleX = 0; + this.scaleY = 0; + this.shearX = 0; + this.shearY = 0; + this.ax = 0; + this.ay = 0; + this.arotation = 0; + this.ascaleX = 0; + this.ascaleY = 0; + this.ashearX = 0; + this.ashearY = 0; + this.appliedValid = !1; + this.a = 0; + this.b = 0; + this.c = 0; + this.d = 0; + this.worldY = 0; + this.worldX = 0; + this.sorted = !1; + this.active = !1; + if (null == t) throw new Error("data cannot be null."); + if (null == e) throw new Error("skeleton cannot be null."); + this.data = t; + this.skeleton = e; + this.parent = i; + this.setToSetupPose(); + } + e.prototype.isActive = function() { + return this.active; + }; + e.prototype.update = function() { + this.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY); + }; + e.prototype.updateWorldTransform = function() { + this.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY); + }; + e.prototype.updateWorldTransformWith = function(e, i, s, n, r, o, a) { + this.ax = e; + this.ay = i; + this.arotation = s; + this.ascaleX = n; + this.ascaleY = r; + this.ashearX = o; + this.ashearY = a; + this.appliedValid = !0; + var l = this.parent; + if (null != l) { + var h = l.a, c = l.b, u = l.c, _ = l.d; + this.worldX = h * e + c * i + l.worldX; + this.worldY = u * e + _ * i + l.worldY; + switch (this.data.transformMode) { + case t.TransformMode.Normal: + I = s + 90 + a; + var d = t.MathUtils.cosDeg(s + o) * n; + var p = t.MathUtils.cosDeg(I) * r; + var m = t.MathUtils.sinDeg(s + o) * n; + var f = t.MathUtils.sinDeg(I) * r; + this.a = h * d + c * m; + this.b = h * p + c * f; + this.c = u * d + _ * m; + this.d = u * p + _ * f; + return; + + case t.TransformMode.OnlyTranslation: + I = s + 90 + a; + this.a = t.MathUtils.cosDeg(s + o) * n; + this.b = t.MathUtils.cosDeg(I) * r; + this.c = t.MathUtils.sinDeg(s + o) * n; + this.d = t.MathUtils.sinDeg(I) * r; + break; + + case t.TransformMode.NoRotationOrReflection: + var g = 0; + if ((E = h * h + u * u) > 1e-4) { + c = u * (E = Math.abs(h * _ - c * u) / E); + _ = h * E; + g = Math.atan2(u, h) * t.MathUtils.radDeg; + } else { + h = 0; + u = 0; + g = 90 - Math.atan2(_, c) * t.MathUtils.radDeg; + } + var y = s + o - g; + var b = s + a - g + 90; + d = t.MathUtils.cosDeg(y) * n; + p = t.MathUtils.cosDeg(b) * r; + m = t.MathUtils.sinDeg(y) * n; + f = t.MathUtils.sinDeg(b) * r; + this.a = h * d - c * m; + this.b = h * p - c * f; + this.c = u * d + _ * m; + this.d = u * p + _ * f; + break; + + case t.TransformMode.NoScale: + case t.TransformMode.NoScaleOrReflection: + var S = t.MathUtils.cosDeg(s); + var A = t.MathUtils.sinDeg(s); + var T = (h * S + c * A) / this.skeleton.scaleX; + var v = (u * S + _ * A) / this.skeleton.scaleY; + var E; + (E = Math.sqrt(T * T + v * v)) > 1e-5 && (E = 1 / E); + T *= E; + v *= E; + E = Math.sqrt(T * T + v * v); + this.data.transformMode == t.TransformMode.NoScale && h * _ - c * u < 0 != (this.skeleton.scaleX < 0 != this.skeleton.scaleY < 0) && (E = -E); + var C = Math.PI / 2 + Math.atan2(v, T); + var x = Math.cos(C) * E; + var w = Math.sin(C) * E; + d = t.MathUtils.cosDeg(o) * n; + p = t.MathUtils.cosDeg(90 + a) * r; + m = t.MathUtils.sinDeg(o) * n; + f = t.MathUtils.sinDeg(90 + a) * r; + this.a = T * d + x * m; + this.b = T * p + x * f; + this.c = v * d + w * m; + this.d = v * p + w * f; + } + this.a *= this.skeleton.scaleX; + this.b *= this.skeleton.scaleX; + this.c *= this.skeleton.scaleY; + this.d *= this.skeleton.scaleY; + } else { + var R = this.skeleton; + var I = s + 90 + a; + var M = R.scaleX; + var B = R.scaleY; + this.a = t.MathUtils.cosDeg(s + o) * n * M; + this.b = t.MathUtils.cosDeg(I) * r * M; + this.c = t.MathUtils.sinDeg(s + o) * n * B; + this.d = t.MathUtils.sinDeg(I) * r * B; + this.worldX = e * M + R.x; + this.worldY = i * B + R.y; + } + }; + e.prototype.setToSetupPose = function() { + var t = this.data; + this.x = t.x; + this.y = t.y; + this.rotation = t.rotation; + this.scaleX = t.scaleX; + this.scaleY = t.scaleY; + this.shearX = t.shearX; + this.shearY = t.shearY; + }; + e.prototype.getWorldRotationX = function() { + return Math.atan2(this.c, this.a) * t.MathUtils.radDeg; + }; + e.prototype.getWorldRotationY = function() { + return Math.atan2(this.d, this.b) * t.MathUtils.radDeg; + }; + e.prototype.getWorldScaleX = function() { + return Math.sqrt(this.a * this.a + this.c * this.c); + }; + e.prototype.getWorldScaleY = function() { + return Math.sqrt(this.b * this.b + this.d * this.d); + }; + e.prototype.updateAppliedTransform = function() { + this.appliedValid = !0; + var e = this.parent; + if (null != e) { + var i = e.a, s = e.b, n = e.c, r = e.d; + var o = 1 / (i * r - s * n); + var a = this.worldX - e.worldX, l = this.worldY - e.worldY; + this.ax = a * r * o - l * s * o; + this.ay = l * i * o - a * n * o; + var h = o * r; + var c = o * i; + var u = o * s; + var _ = o * n; + var d = h * this.a - u * this.c; + var p = h * this.b - u * this.d; + var m = c * this.c - _ * this.a; + var f = c * this.d - _ * this.b; + this.ashearX = 0; + this.ascaleX = Math.sqrt(d * d + m * m); + if (this.ascaleX > 1e-4) { + var g = d * f - p * m; + this.ascaleY = g / this.ascaleX; + this.ashearY = Math.atan2(d * p + m * f, g) * t.MathUtils.radDeg; + this.arotation = Math.atan2(m, d) * t.MathUtils.radDeg; + } else { + this.ascaleX = 0; + this.ascaleY = Math.sqrt(p * p + f * f); + this.ashearY = 0; + this.arotation = 90 - Math.atan2(f, p) * t.MathUtils.radDeg; + } + } else { + this.ax = this.worldX; + this.ay = this.worldY; + this.arotation = Math.atan2(this.c, this.a) * t.MathUtils.radDeg; + this.ascaleX = Math.sqrt(this.a * this.a + this.c * this.c); + this.ascaleY = Math.sqrt(this.b * this.b + this.d * this.d); + this.ashearX = 0; + this.ashearY = Math.atan2(this.a * this.b + this.c * this.d, this.a * this.d - this.b * this.c) * t.MathUtils.radDeg; + } + }; + e.prototype.worldToLocal = function(t) { + var e = this.a, i = this.b, s = this.c, n = this.d; + var r = 1 / (e * n - i * s); + var o = t.x - this.worldX, a = t.y - this.worldY; + t.x = o * n * r - a * i * r; + t.y = a * e * r - o * s * r; + return t; + }; + e.prototype.localToWorld = function(t) { + var e = t.x, i = t.y; + t.x = e * this.a + i * this.b + this.worldX; + t.y = e * this.c + i * this.d + this.worldY; + return t; + }; + e.prototype.worldToLocalRotation = function(e) { + var i = t.MathUtils.sinDeg(e), s = t.MathUtils.cosDeg(e); + return Math.atan2(this.a * i - this.c * s, this.d * s - this.b * i) * t.MathUtils.radDeg + this.rotation - this.shearX; + }; + e.prototype.localToWorldRotation = function(e) { + e -= this.rotation - this.shearX; + var i = t.MathUtils.sinDeg(e), s = t.MathUtils.cosDeg(e); + return Math.atan2(s * this.c + i * this.d, s * this.a + i * this.b) * t.MathUtils.radDeg; + }; + e.prototype.rotateWorld = function(e) { + var i = this.a, s = this.b, n = this.c, r = this.d; + var o = t.MathUtils.cosDeg(e), a = t.MathUtils.sinDeg(e); + this.a = o * i - a * n; + this.b = o * s - a * r; + this.c = a * i + o * n; + this.d = a * s + o * r; + this.appliedValid = !1; + }; + return e; + }(); + t.Bone = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function(e, s, n) { + this.x = 0; + this.y = 0; + this.rotation = 0; + this.scaleX = 1; + this.scaleY = 1; + this.shearX = 0; + this.shearY = 0; + this.transformMode = i.Normal; + this.skinRequired = !1; + this.color = new t.Color; + if (e < 0) throw new Error("index must be >= 0."); + if (null == s) throw new Error("name cannot be null."); + this.index = e; + this.name = s; + this.parent = n; + }; + t.BoneData = e; + var i; + !function(t) { + t[t.Normal = 0] = "Normal"; + t[t.OnlyTranslation = 1] = "OnlyTranslation"; + t[t.NoRotationOrReflection = 2] = "NoRotationOrReflection"; + t[t.NoScale = 3] = "NoScale"; + t[t.NoScaleOrReflection = 4] = "NoScaleOrReflection"; + }(i = t.TransformMode || (t.TransformMode = {})); + }(TMt || (TMt = {})); + !function(t) { + var e = function(t, e, i) { + this.name = t; + this.order = e; + this.skinRequired = i; + }; + t.ConstraintData = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function(t, e) { + if (null == e) throw new Error("data cannot be null."); + this.time = t; + this.data = e; + }; + t.Event = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function(t) { + this.name = t; + }; + t.EventData = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function() { + function e(t, e) { + this.bendDirection = 0; + this.compress = !1; + this.stretch = !1; + this.mix = 1; + this.softness = 0; + this.active = !1; + if (null == t) throw new Error("data cannot be null."); + if (null == e) throw new Error("skeleton cannot be null."); + this.data = t; + this.mix = t.mix; + this.softness = t.softness; + this.bendDirection = t.bendDirection; + this.compress = t.compress; + this.stretch = t.stretch; + this.bones = new Array; + for (var i = 0; i < t.bones.length; i++) this.bones.push(e.findBone(t.bones[i].name)); + this.target = e.findBone(t.target.name); + } + e.prototype.isActive = function() { + return this.active; + }; + e.prototype.apply = function() { + this.update(); + }; + e.prototype.update = function() { + var t = this.target; + var e = this.bones; + switch (e.length) { + case 1: + this.apply1(e[0], t.worldX, t.worldY, this.compress, this.stretch, this.data.uniform, this.mix); + break; + + case 2: + this.apply2(e[0], e[1], t.worldX, t.worldY, this.bendDirection, this.stretch, this.softness, this.mix); + } + }; + e.prototype.apply1 = function(e, i, s, n, r, o, a) { + e.appliedValid || e.updateAppliedTransform(); + var l = e.parent; + var h = 1 / (l.a * l.d - l.b * l.c); + var c = i - l.worldX, u = s - l.worldY; + var _ = (c * l.d - u * l.b) * h - e.ax, d = (u * l.a - c * l.c) * h - e.ay; + var p = Math.atan2(d, _) * t.MathUtils.radDeg - e.ashearX - e.arotation; + e.ascaleX < 0 && (p += 180); + p > 180 ? p -= 360 : p < -180 && (p += 360); + var m = e.ascaleX, f = e.ascaleY; + if (n || r) { + var g = e.data.length * m, y = Math.sqrt(_ * _ + d * d); + if (n && y < g || r && y > g && g > 1e-4) { + var b = (y / g - 1) * a + 1; + m *= b; + o && (f *= b); + } + } + e.updateWorldTransformWith(e.ax, e.ay, e.arotation + p * a, m, f, e.ashearX, e.ashearY); + }; + e.prototype.apply2 = function(e, i, s, n, r, o, a, l) { + if (0 != l) { + e.appliedValid || e.updateAppliedTransform(); + i.appliedValid || i.updateAppliedTransform(); + var h = e.ax, c = e.ay, u = e.ascaleX, _ = u, d = e.ascaleY, p = i.ascaleX; + var m = 0, f = 0, g = 0; + if (u < 0) { + u = -u; + m = 180; + g = -1; + } else { + m = 0; + g = 1; + } + if (d < 0) { + d = -d; + g = -g; + } + if (p < 0) { + p = -p; + f = 180; + } else f = 0; + var y = i.ax, b = 0, S = 0, A = 0, T = e.a, v = e.b, E = e.c, C = e.d; + var x = Math.abs(u - d) <= 1e-4; + if (x) { + S = T * y + v * (b = i.ay) + e.worldX; + A = E * y + C * b + e.worldY; + } else { + b = 0; + S = T * y + e.worldX; + A = E * y + e.worldY; + } + var w = e.parent; + T = w.a; + v = w.b; + E = w.c; + var R = 1 / (T * (C = w.d) - v * E), I = S - w.worldX, M = A - w.worldY; + var B = (I * C - M * v) * R - h, D = (M * T - I * E) * R - c; + var P, O, N = Math.sqrt(B * B + D * D), L = i.data.length * p; + if (N < 1e-4) { + this.apply1(e, s, n, !1, o, !1, l); + i.updateWorldTransformWith(y, b, 0, i.ascaleX, i.ascaleY, i.ashearX, i.ashearY); + } else { + var F = ((I = s - w.worldX) * C - (M = n - w.worldY) * v) * R - h, V = (M * T - I * E) * R - c; + var k = F * F + V * V; + if (0 != a) { + a *= u * (p + 1) / 2; + var U = Math.sqrt(k), G = U - N - L * u + a; + if (G > 0) { + var z = Math.min(1, G / (2 * a)) - 1; + k = (F -= (z = (G - a * (1 - z * z)) / U) * F) * F + (V -= z * V) * V; + } + } + t: if (x) { + var H = (k - N * N - (L *= u) * L) / (2 * N * L); + if (H < -1) H = -1; else if (H > 1) { + H = 1; + o && (_ *= (Math.sqrt(k) / (N + L) - 1) * l + 1); + } + O = Math.acos(H) * r; + T = N + L * H; + v = L * Math.sin(O); + P = Math.atan2(V * T - F * v, F * T + V * v); + } else { + var j = (T = u * L) * T, X = (v = d * L) * v, W = Math.atan2(V, F); + var Y = -2 * X * N, q = X - j; + if ((C = Y * Y - 4 * q * (E = X * N * N + j * k - j * X)) >= 0) { + var K = Math.sqrt(C); + Y < 0 && (K = -K); + var J = (K = -(Y + K) / 2) / q, Z = E / K; + var Q = Math.abs(J) < Math.abs(Z) ? J : Z; + if (Q * Q <= k) { + M = Math.sqrt(k - Q * Q) * r; + P = W - Math.atan2(M, Q); + O = Math.atan2(M / d, (Q - N) / u); + break t; + } + } + var $ = t.MathUtils.PI, tt = N - T, et = tt * tt, it = 0; + var st = 0, nt = N + T, rt = nt * nt, ot = 0; + if ((E = -T * N / (j - X)) >= -1 && E <= 1) { + E = Math.acos(E); + if ((C = (I = T * Math.cos(E) + N) * I + (M = v * Math.sin(E)) * M) < et) { + $ = E; + et = C; + tt = I; + it = M; + } + if (C > rt) { + st = E; + rt = C; + nt = I; + ot = M; + } + } + if (k <= (et + rt) / 2) { + P = W - Math.atan2(it * r, tt); + O = $ * r; + } else { + P = W - Math.atan2(ot * r, nt); + O = st * r; + } + } + var at = Math.atan2(b, y) * g; + var lt = e.arotation; + (P = (P - at) * t.MathUtils.radDeg + m - lt) > 180 ? P -= 360 : P < -180 && (P += 360); + e.updateWorldTransformWith(h, c, lt + P * l, _, e.ascaleY, 0, 0); + lt = i.arotation; + (O = ((O + at) * t.MathUtils.radDeg - i.ashearX) * g + f - lt) > 180 ? O -= 360 : O < -180 && (O += 360); + i.updateWorldTransformWith(y, b, lt + O * l, i.ascaleX, i.ascaleY, i.ashearX, i.ashearY); + } + } else i.updateWorldTransform(); + }; + return e; + }(); + t.IkConstraint = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function(t) { + AMt(e, t); + function e(e) { + var i = t.call(this, e, 0, !1) || this; + i.bones = new Array; + i.bendDirection = 1; + i.compress = !1; + i.stretch = !1; + i.uniform = !1; + i.mix = 1; + i.softness = 0; + return i; + } + return e; + }(t.ConstraintData); + t.IkConstraintData = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function() { + function e(t, e) { + this.position = 0; + this.spacing = 0; + this.rotateMix = 0; + this.translateMix = 0; + this.spaces = new Array; + this.positions = new Array; + this.world = new Array; + this.curves = new Array; + this.lengths = new Array; + this.segments = new Array; + this.active = !1; + if (null == t) throw new Error("data cannot be null."); + if (null == e) throw new Error("skeleton cannot be null."); + this.data = t; + this.bones = new Array; + for (var i = 0, s = t.bones.length; i < s; i++) this.bones.push(e.findBone(t.bones[i].name)); + this.target = e.findSlot(t.target.name); + this.position = t.position; + this.spacing = t.spacing; + this.rotateMix = t.rotateMix; + this.translateMix = t.translateMix; + } + e.prototype.isActive = function() { + return this.active; + }; + e.prototype.apply = function() { + this.update(); + }; + e.prototype.update = function() { + var i = this.target.getAttachment(); + if (i instanceof t.PathAttachment) { + var s = this.rotateMix, n = this.translateMix; + var r = s > 0; + if (n > 0 || r) { + var o = this.data; + var a = o.spacingMode == t.SpacingMode.Percent; + var l = o.rotateMode; + var h = l == t.RotateMode.Tangent, c = l == t.RotateMode.ChainScale; + var u = this.bones.length, _ = h ? u : u + 1; + var d = this.bones; + var p = t.Utils.setArraySize(this.spaces, _), m = null; + var f = this.spacing; + if (c || !a) { + c && (m = t.Utils.setArraySize(this.lengths, u)); + var g = o.spacingMode == t.SpacingMode.Length; + for (var y = 0, b = _ - 1; y < b; ) { + var S = (B = d[y]).data.length; + if (S < e.epsilon) { + c && (m[y] = 0); + p[++y] = 0; + } else if (a) { + if (c) { + var A = S * B.a, T = S * B.c; + var v = Math.sqrt(A * A + T * T); + m[y] = v; + } + p[++y] = f; + } else { + A = S * B.a, T = S * B.c; + var E = Math.sqrt(A * A + T * T); + c && (m[y] = E); + p[++y] = (g ? S + f : f) * E / S; + } + } + } else for (y = 1; y < _; y++) p[y] = f; + var C = this.computeWorldPositions(i, _, h, o.positionMode == t.PositionMode.Percent, a); + var x = C[0], w = C[1], R = o.offsetRotation; + var I = !1; + if (0 == R) I = l == t.RotateMode.Chain; else { + I = !1; + R *= (M = this.target.bone).a * M.d - M.b * M.c > 0 ? t.MathUtils.degRad : -t.MathUtils.degRad; + } + y = 0; + for (var M = 3; y < u; y++, M += 3) { + var B; + (B = d[y]).worldX += (x - B.worldX) * n; + B.worldY += (w - B.worldY) * n; + var D = (A = C[M]) - x, P = (T = C[M + 1]) - w; + if (c) { + var O = m[y]; + if (0 != O) { + var N = (Math.sqrt(D * D + P * P) / O - 1) * s + 1; + B.a *= N; + B.c *= N; + } + } + x = A; + w = T; + if (r) { + var L = B.a, F = B.b, V = B.c, k = B.d, U = 0, G = 0, z = 0; + U = h ? C[M - 1] : 0 == p[y + 1] ? C[M + 2] : Math.atan2(P, D); + U -= Math.atan2(V, L); + if (I) { + G = Math.cos(U); + z = Math.sin(U); + var H = B.data.length; + x += (H * (G * L - z * V) - D) * s; + w += (H * (z * L + G * V) - P) * s; + } else U += R; + U > t.MathUtils.PI ? U -= t.MathUtils.PI2 : U < -t.MathUtils.PI && (U += t.MathUtils.PI2); + U *= s; + G = Math.cos(U); + z = Math.sin(U); + B.a = G * L - z * V; + B.b = G * F - z * k; + B.c = z * L + G * V; + B.d = z * F + G * k; + } + B.appliedValid = !1; + } + } + } + }; + e.prototype.computeWorldPositions = function(i, s, n, r, o) { + var a = this.target; + var l = this.position; + var h = this.spaces, c = t.Utils.setArraySize(this.positions, 3 * s + 2), u = null; + var _ = i.closed; + var d = i.worldVerticesLength, p = d / 6, m = e.NONE; + if (!i.constantSpeed) { + var f = i.lengths; + var g = f[p -= _ ? 1 : 2]; + r && (l *= g); + if (o) for (var y = 1; y < s; y++) h[y] *= g; + u = t.Utils.setArraySize(this.world, 8); + y = 0; + for (var b = 0, S = 0; y < s; y++, b += 3) { + var A = l += X = h[y]; + if (_) { + (A %= g) < 0 && (A += g); + S = 0; + } else { + if (A < 0) { + if (m != e.BEFORE) { + m = e.BEFORE; + i.computeWorldVertices(a, 2, 4, u, 0, 2); + } + this.addBeforePosition(A, u, 0, c, b); + continue; + } + if (A > g) { + if (m != e.AFTER) { + m = e.AFTER; + i.computeWorldVertices(a, d - 6, 4, u, 0, 2); + } + this.addAfterPosition(A - g, u, 0, c, b); + continue; + } + } + for (;;S++) { + var T = f[S]; + if (!(A > T)) { + if (0 == S) A /= T; else { + A = (A - (K = f[S - 1])) / (T - K); + } + break; + } + } + if (S != m) { + m = S; + if (_ && S == p) { + i.computeWorldVertices(a, d - 4, 4, u, 0, 2); + i.computeWorldVertices(a, 0, 4, u, 4, 2); + } else i.computeWorldVertices(a, 6 * S + 2, 8, u, 0, 2); + } + this.addCurvePosition(A, u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7], c, b, n || y > 0 && 0 == X); + } + return c; + } + if (_) { + d += 2; + u = t.Utils.setArraySize(this.world, d); + i.computeWorldVertices(a, 2, d - 4, u, 0, 2); + i.computeWorldVertices(a, 0, 2, u, d - 4, 2); + u[d - 2] = u[0]; + u[d - 1] = u[1]; + } else { + p--; + d -= 4; + u = t.Utils.setArraySize(this.world, d); + i.computeWorldVertices(a, 2, d, u, 0, 2); + } + var v = t.Utils.setArraySize(this.curves, p); + var E = 0; + var C = u[0], x = u[1], w = 0, R = 0, I = 0, M = 0, B = 0, D = 0; + var P = 0, O = 0, N = 0, L = 0, F = 0, V = 0, k = 0, U = 0; + y = 0; + for (var G = 2; y < p; y++, G += 6) { + w = u[G]; + R = u[G + 1]; + I = u[G + 2]; + M = u[G + 3]; + F = 2 * (P = .1875 * (C - 2 * w + I)) + (N = .09375 * (3 * (w - I) - C + (B = u[G + 4]))); + V = 2 * (O = .1875 * (x - 2 * R + M)) + (L = .09375 * (3 * (R - M) - x + (D = u[G + 5]))); + k = .75 * (w - C) + P + .16666667 * N; + U = .75 * (R - x) + O + .16666667 * L; + E += Math.sqrt(k * k + U * U); + k += F; + U += V; + F += N; + V += L; + E += Math.sqrt(k * k + U * U); + k += F; + U += V; + E += Math.sqrt(k * k + U * U); + k += F + N; + U += V + L; + E += Math.sqrt(k * k + U * U); + v[y] = E; + C = B; + x = D; + } + l *= r ? E : E / i.lengths[p - 1]; + if (o) for (y = 1; y < s; y++) h[y] *= E; + var z = this.segments; + var H = 0; + y = 0, b = 0, S = 0; + for (var j = 0; y < s; y++, b += 3) { + var X; + A = l += X = h[y]; + if (_) { + (A %= E) < 0 && (A += E); + S = 0; + } else { + if (A < 0) { + this.addBeforePosition(A, u, 0, c, b); + continue; + } + if (A > E) { + this.addAfterPosition(A - E, u, d - 4, c, b); + continue; + } + } + for (;;S++) { + var W = v[S]; + if (!(A > W)) { + if (0 == S) A /= W; else { + A = (A - (K = v[S - 1])) / (W - K); + } + break; + } + } + if (S != m) { + m = S; + var Y = 6 * S; + C = u[Y]; + x = u[Y + 1]; + w = u[Y + 2]; + R = u[Y + 3]; + I = u[Y + 4]; + M = u[Y + 5]; + F = 2 * (P = .03 * (C - 2 * w + I)) + (N = .006 * (3 * (w - I) - C + (B = u[Y + 6]))); + V = 2 * (O = .03 * (x - 2 * R + M)) + (L = .006 * (3 * (R - M) - x + (D = u[Y + 7]))); + k = .3 * (w - C) + P + .16666667 * N; + U = .3 * (R - x) + O + .16666667 * L; + H = Math.sqrt(k * k + U * U); + z[0] = H; + for (Y = 1; Y < 8; Y++) { + k += F; + U += V; + F += N; + V += L; + H += Math.sqrt(k * k + U * U); + z[Y] = H; + } + k += F; + U += V; + H += Math.sqrt(k * k + U * U); + z[8] = H; + k += F + N; + U += V + L; + H += Math.sqrt(k * k + U * U); + z[9] = H; + j = 0; + } + A *= H; + for (;;j++) { + var q = z[j]; + if (!(A > q)) { + if (0 == j) A /= q; else { + var K; + A = j + (A - (K = z[j - 1])) / (q - K); + } + break; + } + } + this.addCurvePosition(.1 * A, C, x, w, R, I, M, B, D, c, b, n || y > 0 && 0 == X); + } + return c; + }; + e.prototype.addBeforePosition = function(t, e, i, s, n) { + var r = e[i], o = e[i + 1], a = e[i + 2] - r, l = e[i + 3] - o, h = Math.atan2(l, a); + s[n] = r + t * Math.cos(h); + s[n + 1] = o + t * Math.sin(h); + s[n + 2] = h; + }; + e.prototype.addAfterPosition = function(t, e, i, s, n) { + var r = e[i + 2], o = e[i + 3], a = r - e[i], l = o - e[i + 1], h = Math.atan2(l, a); + s[n] = r + t * Math.cos(h); + s[n + 1] = o + t * Math.sin(h); + s[n + 2] = h; + }; + e.prototype.addCurvePosition = function(t, e, i, s, n, r, o, a, l, h, c, u) { + if (0 == t || isNaN(t)) { + h[c] = e; + h[c + 1] = i; + h[c + 2] = Math.atan2(n - i, s - e); + } else { + var _ = t * t, d = _ * t, p = 1 - t, m = p * p, f = m * p; + var g = p * t, y = 3 * g, b = p * y, S = y * t; + var A = e * f + s * b + r * S + a * d, T = i * f + n * b + o * S + l * d; + h[c] = A; + h[c + 1] = T; + u && (h[c + 2] = t < .001 ? Math.atan2(n - i, s - e) : Math.atan2(T - (i * m + n * g * 2 + o * _), A - (e * m + s * g * 2 + r * _))); + } + }; + e.NONE = -1; + e.BEFORE = -2; + e.AFTER = -3; + e.epsilon = 1e-5; + return e; + }(); + t.PathConstraint = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function(t) { + AMt(e, t); + function e(e) { + var i = t.call(this, e, 0, !1) || this; + i.bones = new Array; + return i; + } + return e; + }(t.ConstraintData); + t.PathConstraintData = e; + !function(t) { + t[t.Fixed = 0] = "Fixed"; + t[t.Percent = 1] = "Percent"; + }(t.PositionMode || (t.PositionMode = {})); + !function(t) { + t[t.Length = 0] = "Length"; + t[t.Fixed = 1] = "Fixed"; + t[t.Percent = 2] = "Percent"; + }(t.SpacingMode || (t.SpacingMode = {})); + !function(t) { + t[t.Tangent = 0] = "Tangent"; + t[t.Chain = 1] = "Chain"; + t[t.ChainScale = 2] = "ChainScale"; + }(t.RotateMode || (t.RotateMode = {})); + }(TMt || (TMt = {})); + !function(t) { + var e = function() { + function t(t) { + this.toLoad = new Array; + this.assets = {}; + this.clientId = t; + } + t.prototype.loaded = function() { + var t = 0; + for (var e in this.assets) t++; + return t; + }; + return t; + }(); + var i = function() { + function t(t) { + void 0 === t && (t = ""); + this.clientAssets = {}; + this.queuedAssets = {}; + this.rawAssets = {}; + this.errors = {}; + this.pathPrefix = t; + } + t.prototype.queueAsset = function(t, i, s) { + var n = this.clientAssets[t]; + if (null == n) { + n = new e(t); + this.clientAssets[t] = n; + } + null !== i && (n.textureLoader = i); + n.toLoad.push(s); + if (this.queuedAssets[s] === s) return !1; + this.queuedAssets[s] = s; + return !0; + }; + t.prototype.loadText = function(t, e) { + var i = this; + e = this.pathPrefix + e; + if (this.queueAsset(t, null, e)) { + var s = new XMLHttpRequest; + s.onreadystatechange = function() { + s.readyState == XMLHttpRequest.DONE && (s.status >= 200 && s.status < 300 ? i.rawAssets[e] = s.responseText : i.errors[e] = "Couldn't load text " + e + ": status " + s.status + ", " + s.responseText); + }; + s.open("GET", e, !0); + s.send(); + } + }; + t.prototype.loadJson = function(t, e) { + var i = this; + e = this.pathPrefix + e; + if (this.queueAsset(t, null, e)) { + var s = new XMLHttpRequest; + s.onreadystatechange = function() { + s.readyState == XMLHttpRequest.DONE && (s.status >= 200 && s.status < 300 ? i.rawAssets[e] = JSON.parse(s.responseText) : i.errors[e] = "Couldn't load text " + e + ": status " + s.status + ", " + s.responseText); + }; + s.open("GET", e, !0); + s.send(); + } + }; + t.prototype.loadTexture = function(t, e, i) { + var s = this; + i = this.pathPrefix + i; + if (this.queueAsset(t, e, i)) { + var n = new Image; + n.src = i; + n.crossOrigin = "anonymous"; + n.onload = function(t) { + s.rawAssets[i] = n; + }; + n.onerror = function(t) { + s.errors[i] = "Couldn't load image " + i; + }; + } + }; + t.prototype.get = function(t, e) { + e = this.pathPrefix + e; + var i = this.clientAssets[t]; + return null == i || i.assets[e]; + }; + t.prototype.updateClientAssets = function(t) { + for (var e = 0; e < t.toLoad.length; e++) { + var i = t.toLoad[e]; + var s = t.assets[i]; + if (null == s) { + var n = this.rawAssets[i]; + if (null == n) continue; + n instanceof HTMLImageElement ? t.assets[i] = t.textureLoader(n) : t.assets[i] = n; + } + } + }; + t.prototype.isLoadingComplete = function(t) { + var e = this.clientAssets[t]; + if (null == e) return !0; + this.updateClientAssets(e); + return e.toLoad.length == e.loaded(); + }; + t.prototype.dispose = function() {}; + t.prototype.hasErrors = function() { + return Object.keys(this.errors).length > 0; + }; + t.prototype.getErrors = function() { + return this.errors; + }; + return t; + }(); + t.SharedAssetManager = i; + }(TMt || (TMt = {})); + !function(t) { + var e = function() { + function e(e) { + this._updateCache = new Array; + this.updateCacheReset = new Array; + this.time = 0; + this.scaleX = 1; + this.scaleY = 1; + this.x = 0; + this.y = 0; + if (null == e) throw new Error("data cannot be null."); + this.data = e; + this.bones = new Array; + for (var i = 0; i < e.bones.length; i++) { + var s = e.bones[i]; + var n = void 0; + if (null == s.parent) n = new t.Bone(s, this, null); else { + var r = this.bones[s.parent.index]; + n = new t.Bone(s, this, r); + r.children.push(n); + } + this.bones.push(n); + } + this.slots = new Array; + this.drawOrder = new Array; + for (i = 0; i < e.slots.length; i++) { + var o = e.slots[i]; + n = this.bones[o.boneData.index]; + var a = new t.Slot(o, n); + this.slots.push(a); + this.drawOrder.push(a); + } + this.ikConstraints = new Array; + for (i = 0; i < e.ikConstraints.length; i++) { + var l = e.ikConstraints[i]; + this.ikConstraints.push(new t.IkConstraint(l, this)); + } + this.transformConstraints = new Array; + for (i = 0; i < e.transformConstraints.length; i++) { + var h = e.transformConstraints[i]; + this.transformConstraints.push(new t.TransformConstraint(h, this)); + } + this.pathConstraints = new Array; + for (i = 0; i < e.pathConstraints.length; i++) { + var c = e.pathConstraints[i]; + this.pathConstraints.push(new t.PathConstraint(c, this)); + } + this.color = new t.Color(1, 1, 1, 1); + this.updateCache(); + } + e.prototype.updateCache = function() { + this._updateCache.length = 0; + this.updateCacheReset.length = 0; + var t = this.bones; + for (var e = 0, i = t.length; e < i; e++) { + (n = t[e]).sorted = n.data.skinRequired; + n.active = !n.sorted; + } + if (null != this.skin) { + var s = this.skin.bones; + for (e = 0, i = this.skin.bones.length; e < i; e++) { + var n = this.bones[s[e].index]; + do { + n.sorted = !1; + n.active = !0; + n = n.parent; + } while (null != n); + } + } + var r = this.ikConstraints; + var o = this.transformConstraints; + var a = this.pathConstraints; + var l = r.length, h = o.length, c = a.length; + var u = l + h + c; + t: for (e = 0; e < u; e++) { + for (var _ = 0; _ < l; _++) { + if ((d = r[_]).data.order == e) { + this.sortIkConstraint(d); + continue t; + } + } + for (_ = 0; _ < h; _++) { + if ((d = o[_]).data.order == e) { + this.sortTransformConstraint(d); + continue t; + } + } + for (_ = 0; _ < c; _++) { + var d; + if ((d = a[_]).data.order == e) { + this.sortPathConstraint(d); + continue t; + } + } + } + for (e = 0, i = t.length; e < i; e++) this.sortBone(t[e]); + }; + e.prototype.sortIkConstraint = function(e) { + e.active = e.target.isActive() && (!e.data.skinRequired || null != this.skin && t.Utils.contains(this.skin.constraints, e.data, !0)); + if (e.active) { + var i = e.target; + this.sortBone(i); + var s = e.bones; + var n = s[0]; + this.sortBone(n); + if (s.length > 1) { + var r = s[s.length - 1]; + this._updateCache.indexOf(r) > -1 || this.updateCacheReset.push(r); + } + this._updateCache.push(e); + this.sortReset(n.children); + s[s.length - 1].sorted = !0; + } + }; + e.prototype.sortPathConstraint = function(e) { + e.active = e.target.bone.isActive() && (!e.data.skinRequired || null != this.skin && t.Utils.contains(this.skin.constraints, e.data, !0)); + if (e.active) { + var i = e.target; + var s = i.data.index; + var n = i.bone; + null != this.skin && this.sortPathConstraintAttachment(this.skin, s, n); + null != this.data.defaultSkin && this.data.defaultSkin != this.skin && this.sortPathConstraintAttachment(this.data.defaultSkin, s, n); + for (var r = 0, o = this.data.skins.length; r < o; r++) this.sortPathConstraintAttachment(this.data.skins[r], s, n); + var a = i.getAttachment(); + a instanceof t.PathAttachment && this.sortPathConstraintAttachmentWith(a, n); + var l = e.bones; + var h = l.length; + for (r = 0; r < h; r++) this.sortBone(l[r]); + this._updateCache.push(e); + for (r = 0; r < h; r++) this.sortReset(l[r].children); + for (r = 0; r < h; r++) l[r].sorted = !0; + } + }; + e.prototype.sortTransformConstraint = function(e) { + e.active = e.target.isActive() && (!e.data.skinRequired || null != this.skin && t.Utils.contains(this.skin.constraints, e.data, !0)); + if (e.active) { + this.sortBone(e.target); + var i = e.bones; + var s = i.length; + if (e.data.local) for (var n = 0; n < s; n++) { + var r = i[n]; + this.sortBone(r.parent); + this._updateCache.indexOf(r) > -1 || this.updateCacheReset.push(r); + } else for (n = 0; n < s; n++) this.sortBone(i[n]); + this._updateCache.push(e); + for (var o = 0; o < s; o++) this.sortReset(i[o].children); + for (o = 0; o < s; o++) i[o].sorted = !0; + } + }; + e.prototype.sortPathConstraintAttachment = function(t, e, i) { + var s = t.attachments[e]; + if (s) for (var n in s) this.sortPathConstraintAttachmentWith(s[n], i); + }; + e.prototype.sortPathConstraintAttachmentWith = function(e, i) { + if (e instanceof t.PathAttachment) { + var s = e.bones; + if (null == s) this.sortBone(i); else { + var n = this.bones; + var r = 0; + for (;r < s.length; ) { + var o = s[r++]; + for (var a = r + o; r < a; r++) { + var l = s[r]; + this.sortBone(n[l]); + } + } + } + } + }; + e.prototype.sortBone = function(t) { + if (!t.sorted) { + var e = t.parent; + null != e && this.sortBone(e); + t.sorted = !0; + this._updateCache.push(t); + } + }; + e.prototype.sortReset = function(t) { + for (var e = 0, i = t.length; e < i; e++) { + var s = t[e]; + if (s.active) { + s.sorted && this.sortReset(s.children); + s.sorted = !1; + } + } + }; + e.prototype.updateWorldTransform = function() { + var t = this.updateCacheReset; + for (var e = 0, i = t.length; e < i; e++) { + var s = t[e]; + s.ax = s.x; + s.ay = s.y; + s.arotation = s.rotation; + s.ascaleX = s.scaleX; + s.ascaleY = s.scaleY; + s.ashearX = s.shearX; + s.ashearY = s.shearY; + s.appliedValid = !0; + } + var n = this._updateCache; + for (e = 0, i = n.length; e < i; e++) n[e].update(); + }; + e.prototype.setToSetupPose = function() { + this.setBonesToSetupPose(); + this.setSlotsToSetupPose(); + }; + e.prototype.setBonesToSetupPose = function() { + var t = this.bones; + for (var e = 0, i = t.length; e < i; e++) t[e].setToSetupPose(); + var s = this.ikConstraints; + for (e = 0, i = s.length; e < i; e++) { + (a = s[e]).mix = a.data.mix; + a.softness = a.data.softness; + a.bendDirection = a.data.bendDirection; + a.compress = a.data.compress; + a.stretch = a.data.stretch; + } + var n = this.transformConstraints; + for (e = 0, i = n.length; e < i; e++) { + var r = (a = n[e]).data; + a.rotateMix = r.rotateMix; + a.translateMix = r.translateMix; + a.scaleMix = r.scaleMix; + a.shearMix = r.shearMix; + } + var o = this.pathConstraints; + for (e = 0, i = o.length; e < i; e++) { + var a; + r = (a = o[e]).data; + a.position = r.position; + a.spacing = r.spacing; + a.rotateMix = r.rotateMix; + a.translateMix = r.translateMix; + } + }; + e.prototype.setSlotsToSetupPose = function() { + var e = this.slots; + t.Utils.arrayCopy(e, 0, this.drawOrder, 0, e.length); + for (var i = 0, s = e.length; i < s; i++) e[i].setToSetupPose(); + }; + e.prototype.getRootBone = function() { + return 0 == this.bones.length ? null : this.bones[0]; + }; + e.prototype.findBone = function(t) { + if (null == t) throw new Error("boneName cannot be null."); + var e = this.bones; + for (var i = 0, s = e.length; i < s; i++) { + var n = e[i]; + if (n.data.name == t) return n; + } + return null; + }; + e.prototype.findBoneIndex = function(t) { + if (null == t) throw new Error("boneName cannot be null."); + var e = this.bones; + for (var i = 0, s = e.length; i < s; i++) if (e[i].data.name == t) return i; + return -1; + }; + e.prototype.findSlot = function(t) { + if (null == t) throw new Error("slotName cannot be null."); + var e = this.slots; + for (var i = 0, s = e.length; i < s; i++) { + var n = e[i]; + if (n.data.name == t) return n; + } + return null; + }; + e.prototype.findSlotIndex = function(t) { + if (null == t) throw new Error("slotName cannot be null."); + var e = this.slots; + for (var i = 0, s = e.length; i < s; i++) if (e[i].data.name == t) return i; + return -1; + }; + e.prototype.setSkinByName = function(t) { + var e = this.data.findSkin(t); + if (null == e) throw new Error("Skin not found: " + t); + this.setSkin(e); + }; + e.prototype.setSkin = function(t) { + if (t != this.skin) { + if (null != t) if (null != this.skin) t.attachAll(this, this.skin); else { + var e = this.slots; + for (var i = 0, s = e.length; i < s; i++) { + var n = e[i]; + var r = n.data.attachmentName; + if (null != r) { + var o = t.getAttachment(i, r); + null != o && n.setAttachment(o); + } + } + } + this.skin = t; + this.updateCache(); + } + }; + e.prototype.getAttachmentByName = function(t, e) { + return this.getAttachment(this.data.findSlotIndex(t), e); + }; + e.prototype.getAttachment = function(t, e) { + if (null == e) throw new Error("attachmentName cannot be null."); + if (null != this.skin) { + var i = this.skin.getAttachment(t, e); + if (null != i) return i; + } + return null != this.data.defaultSkin ? this.data.defaultSkin.getAttachment(t, e) : null; + }; + e.prototype.setAttachment = function(t, e) { + if (null == t) throw new Error("slotName cannot be null."); + var i = this.slots; + for (var s = 0, n = i.length; s < n; s++) { + var r = i[s]; + if (r.data.name == t) { + var o = null; + if (null != e && null == (o = this.getAttachment(s, e))) throw new Error("Attachment not found: " + e + ", for slot: " + t); + r.setAttachment(o); + return; + } + } + throw new Error("Slot not found: " + t); + }; + e.prototype.findIkConstraint = function(t) { + if (null == t) throw new Error("constraintName cannot be null."); + var e = this.ikConstraints; + for (var i = 0, s = e.length; i < s; i++) { + var n = e[i]; + if (n.data.name == t) return n; + } + return null; + }; + e.prototype.findTransformConstraint = function(t) { + if (null == t) throw new Error("constraintName cannot be null."); + var e = this.transformConstraints; + for (var i = 0, s = e.length; i < s; i++) { + var n = e[i]; + if (n.data.name == t) return n; + } + return null; + }; + e.prototype.findPathConstraint = function(t) { + if (null == t) throw new Error("constraintName cannot be null."); + var e = this.pathConstraints; + for (var i = 0, s = e.length; i < s; i++) { + var n = e[i]; + if (n.data.name == t) return n; + } + return null; + }; + e.prototype.getBounds = function(e, i, s) { + void 0 === s && (s = new Array(2)); + if (null == e) throw new Error("offset cannot be null."); + if (null == i) throw new Error("size cannot be null."); + var n = this.drawOrder; + var r = Number.POSITIVE_INFINITY, o = Number.POSITIVE_INFINITY, a = Number.NEGATIVE_INFINITY, l = Number.NEGATIVE_INFINITY; + for (var h = 0, c = n.length; h < c; h++) { + var u = n[h]; + if (u.bone.active) { + var _ = 0; + var d = null; + var p = u.getAttachment(); + if (p instanceof t.RegionAttachment) { + _ = 8; + d = t.Utils.setArraySize(s, _, 0); + p.computeWorldVertices(u.bone, d, 0, 2); + } else if (p instanceof t.MeshAttachment) { + var m = p; + _ = m.worldVerticesLength; + d = t.Utils.setArraySize(s, _, 0); + m.computeWorldVertices(u, 0, _, d, 0, 2); + } + if (null != d) for (var f = 0, g = d.length; f < g; f += 2) { + var y = d[f], b = d[f + 1]; + r = Math.min(r, y); + o = Math.min(o, b); + a = Math.max(a, y); + l = Math.max(l, b); + } + } + } + e.set(r, o); + i.set(a - r, l - o); + }; + e.prototype.update = function(t) { + this.time += t; + }; + return e; + }(); + t.Skeleton = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function() { + function e(t) { + this.scale = 1; + this.linkedMeshes = new Array; + this.attachmentLoader = t; + } + e.prototype.readSkeletonData = function(s) { + var n = this.scale; + var r = new t.SkeletonData; + r.name = ""; + var o = new i(s); + r.hash = o.readString(); + r.version = o.readString(); + r.x = o.readFloat(); + r.y = o.readFloat(); + r.width = o.readFloat(); + r.height = o.readFloat(); + var a = o.readBoolean(); + if (a) { + r.fps = o.readFloat(); + r.imagesPath = o.readString(); + r.audioPath = o.readString(); + } + var l = 0; + l = o.readInt(!0); + for (var h = 0; h < l; h++) o.strings.push(o.readString()); + l = o.readInt(!0); + for (h = 0; h < l; h++) { + var c = o.readString(); + var u = 0 == h ? null : r.bones[o.readInt(!0)]; + (p = new t.BoneData(h, c, u)).rotation = o.readFloat(); + p.x = o.readFloat() * n; + p.y = o.readFloat() * n; + p.scaleX = o.readFloat(); + p.scaleY = o.readFloat(); + p.shearX = o.readFloat(); + p.shearY = o.readFloat(); + p.length = o.readFloat() * n; + p.transformMode = e.TransformModeValues[o.readInt(!0)]; + p.skinRequired = o.readBoolean(); + a && t.Color.rgba8888ToColor(p.color, o.readInt32()); + r.bones.push(p); + } + l = o.readInt(!0); + for (h = 0; h < l; h++) { + var _ = o.readString(); + var d = r.bones[o.readInt(!0)]; + var p = new t.SlotData(h, _, d); + t.Color.rgba8888ToColor(p.color, o.readInt32()); + var m = o.readInt32(); + -1 != m && t.Color.rgb888ToColor(p.darkColor = new t.Color, m); + p.attachmentName = o.readStringRef(); + p.blendMode = e.BlendModeValues[o.readInt(!0)]; + r.slots.push(p); + } + l = o.readInt(!0); + h = 0; + for (var f = void 0; h < l; h++) { + (p = new t.IkConstraintData(o.readString())).order = o.readInt(!0); + p.skinRequired = o.readBoolean(); + f = o.readInt(!0); + for (var g = 0; g < f; g++) p.bones.push(r.bones[o.readInt(!0)]); + p.target = r.bones[o.readInt(!0)]; + p.mix = o.readFloat(); + p.softness = o.readFloat() * n; + p.bendDirection = o.readByte(); + p.compress = o.readBoolean(); + p.stretch = o.readBoolean(); + p.uniform = o.readBoolean(); + r.ikConstraints.push(p); + } + l = o.readInt(!0); + for (h = 0, f = void 0; h < l; h++) { + (p = new t.TransformConstraintData(o.readString())).order = o.readInt(!0); + p.skinRequired = o.readBoolean(); + f = o.readInt(!0); + for (g = 0; g < f; g++) p.bones.push(r.bones[o.readInt(!0)]); + p.target = r.bones[o.readInt(!0)]; + p.local = o.readBoolean(); + p.relative = o.readBoolean(); + p.offsetRotation = o.readFloat(); + p.offsetX = o.readFloat() * n; + p.offsetY = o.readFloat() * n; + p.offsetScaleX = o.readFloat(); + p.offsetScaleY = o.readFloat(); + p.offsetShearY = o.readFloat(); + p.rotateMix = o.readFloat(); + p.translateMix = o.readFloat(); + p.scaleMix = o.readFloat(); + p.shearMix = o.readFloat(); + r.transformConstraints.push(p); + } + l = o.readInt(!0); + for (h = 0, f = void 0; h < l; h++) { + (p = new t.PathConstraintData(o.readString())).order = o.readInt(!0); + p.skinRequired = o.readBoolean(); + f = o.readInt(!0); + for (g = 0; g < f; g++) p.bones.push(r.bones[o.readInt(!0)]); + p.target = r.slots[o.readInt(!0)]; + p.positionMode = e.PositionModeValues[o.readInt(!0)]; + p.spacingMode = e.SpacingModeValues[o.readInt(!0)]; + p.rotateMode = e.RotateModeValues[o.readInt(!0)]; + p.offsetRotation = o.readFloat(); + p.position = o.readFloat(); + p.positionMode == t.PositionMode.Fixed && (p.position *= n); + p.spacing = o.readFloat(); + p.spacingMode != t.SpacingMode.Length && p.spacingMode != t.SpacingMode.Fixed || (p.spacing *= n); + p.rotateMix = o.readFloat(); + p.translateMix = o.readFloat(); + r.pathConstraints.push(p); + } + var y = this.readSkin(o, r, !0, a); + if (null != y) { + r.defaultSkin = y; + r.skins.push(y); + } + h = r.skins.length; + t.Utils.setArraySize(r.skins, l = h + o.readInt(!0)); + for (;h < l; h++) r.skins[h] = this.readSkin(o, r, !1, a); + l = this.linkedMeshes.length; + for (h = 0; h < l; h++) { + var b = this.linkedMeshes[h]; + var S = null == b.skin ? r.defaultSkin : r.findSkin(b.skin); + if (null == S) throw new Error("Skin not found: " + b.skin); + var A = S.getAttachment(b.slotIndex, b.parent); + if (null == A) throw new Error("Parent mesh not found: " + b.parent); + b.mesh.deformAttachment = b.inheritDeform ? A : b.mesh; + b.mesh.setParentMesh(A); + b.mesh.updateUVs(); + } + this.linkedMeshes.length = 0; + l = o.readInt(!0); + for (h = 0; h < l; h++) { + (p = new t.EventData(o.readStringRef())).intValue = o.readInt(!1); + p.floatValue = o.readFloat(); + p.stringValue = o.readString(); + p.audioPath = o.readString(); + if (null != p.audioPath) { + p.volume = o.readFloat(); + p.balance = o.readFloat(); + } + r.events.push(p); + } + l = o.readInt(!0); + for (h = 0; h < l; h++) r.animations.push(this.readAnimation(o, o.readString(), r)); + return r; + }; + e.prototype.readSkin = function(e, i, s, n) { + var r = null; + var o = 0; + if (s) { + if (0 == (o = e.readInt(!0))) return null; + r = new t.Skin("default"); + } else { + (r = new t.Skin(e.readStringRef())).bones.length = e.readInt(!0); + for (var a = 0, l = r.bones.length; a < l; a++) r.bones[a] = i.bones[e.readInt(!0)]; + for (a = 0, l = e.readInt(!0); a < l; a++) r.constraints.push(i.ikConstraints[e.readInt(!0)]); + for (a = 0, l = e.readInt(!0); a < l; a++) r.constraints.push(i.transformConstraints[e.readInt(!0)]); + for (a = 0, l = e.readInt(!0); a < l; a++) r.constraints.push(i.pathConstraints[e.readInt(!0)]); + o = e.readInt(!0); + } + for (a = 0; a < o; a++) { + var h = e.readInt(!0); + for (var c = 0, u = e.readInt(!0); c < u; c++) { + var _ = e.readStringRef(); + var d = this.readAttachment(e, i, r, h, _, n); + null != d && r.setAttachment(h, _, d); + } + } + return r; + }; + e.prototype.readAttachment = function(i, n, r, o, a, l) { + var h = this.scale; + var c = i.readStringRef(); + null == c && (c = a); + var u = i.readByte(); + switch (e.AttachmentTypeValues[u]) { + case t.AttachmentType.Region: + var _ = i.readStringRef(); + var d = i.readFloat(); + var p = i.readFloat(); + var m = i.readFloat(); + var f = i.readFloat(); + var g = i.readFloat(); + var y = i.readFloat(); + var b = i.readFloat(); + var S = i.readInt32(); + null == _ && (_ = c); + var A = this.attachmentLoader.newRegionAttachment(r, c, _); + if (null == A) return null; + A.path = _; + A.x = p * h; + A.y = m * h; + A.scaleX = f; + A.scaleY = g; + A.rotation = d; + A.width = y * h; + A.height = b * h; + t.Color.rgba8888ToColor(A.color, S); + A.updateOffset(); + return A; + + case t.AttachmentType.BoundingBox: + var T = i.readInt(!0); + var v = this.readVertices(i, T); + S = l ? i.readInt32() : 0; + var E = this.attachmentLoader.newBoundingBoxAttachment(r, c); + if (null == E) return null; + E.worldVerticesLength = T << 1; + E.vertices = v.vertices; + E.bones = v.bones; + l && t.Color.rgba8888ToColor(E.color, S); + return E; + + case t.AttachmentType.Mesh: + _ = i.readStringRef(); + S = i.readInt32(); + T = i.readInt(!0); + var C = this.readFloatArray(i, T << 1, 1); + var x = this.readShortArray(i); + v = this.readVertices(i, T); + var w = i.readInt(!0); + var R = null; + y = 0, b = 0; + if (l) { + R = this.readShortArray(i); + y = i.readFloat(); + b = i.readFloat(); + } + null == _ && (_ = c); + if (null == (D = this.attachmentLoader.newMeshAttachment(r, c, _))) return null; + D.path = _; + t.Color.rgba8888ToColor(D.color, S); + D.bones = v.bones; + D.vertices = v.vertices; + D.worldVerticesLength = T << 1; + D.triangles = x; + D.regionUVs = C; + D.updateUVs(); + D.hullLength = w << 1; + if (l) { + D.edges = R; + D.width = y * h; + D.height = b * h; + } + return D; + + case t.AttachmentType.LinkedMesh: + _ = i.readStringRef(); + S = i.readInt32(); + var I = i.readStringRef(); + var M = i.readStringRef(); + var B = i.readBoolean(); + y = 0, b = 0; + if (l) { + y = i.readFloat(); + b = i.readFloat(); + } + null == _ && (_ = c); + var D; + if (null == (D = this.attachmentLoader.newMeshAttachment(r, c, _))) return null; + D.path = _; + t.Color.rgba8888ToColor(D.color, S); + if (l) { + D.width = y * h; + D.height = b * h; + } + this.linkedMeshes.push(new s(D, I, o, M, B)); + return D; + + case t.AttachmentType.Path: + var P = i.readBoolean(); + var O = i.readBoolean(); + T = i.readInt(!0); + v = this.readVertices(i, T); + var N = t.Utils.newArray(T / 3, 0); + for (var L = 0, F = N.length; L < F; L++) N[L] = i.readFloat() * h; + S = l ? i.readInt32() : 0; + if (null == (_ = this.attachmentLoader.newPathAttachment(r, c))) return null; + _.closed = P; + _.constantSpeed = O; + _.worldVerticesLength = T << 1; + _.vertices = v.vertices; + _.bones = v.bones; + _.lengths = N; + l && t.Color.rgba8888ToColor(_.color, S); + return _; + + case t.AttachmentType.Point: + d = i.readFloat(); + p = i.readFloat(); + m = i.readFloat(); + S = l ? i.readInt32() : 0; + var V = this.attachmentLoader.newPointAttachment(r, c); + if (null == V) return null; + V.x = p * h; + V.y = m * h; + V.rotation = d; + l && t.Color.rgba8888ToColor(V.color, S); + return V; + + case t.AttachmentType.Clipping: + var k = i.readInt(!0); + T = i.readInt(!0); + v = this.readVertices(i, T); + S = l ? i.readInt32() : 0; + var U = this.attachmentLoader.newClippingAttachment(r, c); + if (null == U) return null; + U.endSlot = n.slots[k]; + U.worldVerticesLength = T << 1; + U.vertices = v.vertices; + U.bones = v.bones; + l && t.Color.rgba8888ToColor(U.color, S); + return U; + } + return null; + }; + e.prototype.readVertices = function(e, i) { + var s = i << 1; + var r = new n; + var o = this.scale; + if (!e.readBoolean()) { + r.vertices = this.readFloatArray(e, s, o); + return r; + } + var a = new Array; + var l = new Array; + for (var h = 0; h < i; h++) { + var c = e.readInt(!0); + l.push(c); + for (var u = 0; u < c; u++) { + l.push(e.readInt(!0)); + a.push(e.readFloat() * o); + a.push(e.readFloat() * o); + a.push(e.readFloat()); + } + } + r.vertices = t.Utils.toFloatArray(a); + r.bones = l; + return r; + }; + e.prototype.readFloatArray = function(t, e, i) { + var s = new Array(e); + if (1 == i) for (var n = 0; n < e; n++) s[n] = t.readFloat(); else for (n = 0; n < e; n++) s[n] = t.readFloat() * i; + return s; + }; + e.prototype.readShortArray = function(t) { + var e = t.readInt(!0); + var i = new Array(e); + for (var s = 0; s < e; s++) i[s] = t.readShort(); + return i; + }; + e.prototype.readAnimation = function(i, s, n) { + var r = new Array; + var o = this.scale; + var a = 0; + var l = new t.Color; + var h = new t.Color; + for (var c = 0, u = i.readInt(!0); c < u; c++) { + var _ = i.readInt(!0); + for (var d = 0, p = i.readInt(!0); d < p; d++) { + var m = i.readByte(); + var f = i.readInt(!0); + switch (m) { + case e.SLOT_ATTACHMENT: + (S = new t.AttachmentTimeline(f)).slotIndex = _; + for (var g = 0; g < f; g++) S.setFrame(g, i.readFloat(), i.readStringRef()); + r.push(S); + a = Math.max(a, S.frames[f - 1]); + break; + + case e.SLOT_COLOR: + (S = new t.ColorTimeline(f)).slotIndex = _; + for (g = 0; g < f; g++) { + var y = i.readFloat(); + t.Color.rgba8888ToColor(l, i.readInt32()); + S.setFrame(g, y, l.r, l.g, l.b, l.a); + g < f - 1 && this.readCurve(i, g, S); + } + r.push(S); + a = Math.max(a, S.frames[(f - 1) * t.ColorTimeline.ENTRIES]); + break; + + case e.SLOT_TWO_COLOR: + (S = new t.TwoColorTimeline(f)).slotIndex = _; + for (g = 0; g < f; g++) { + y = i.readFloat(); + t.Color.rgba8888ToColor(l, i.readInt32()); + t.Color.rgb888ToColor(h, i.readInt32()); + S.setFrame(g, y, l.r, l.g, l.b, l.a, h.r, h.g, h.b); + g < f - 1 && this.readCurve(i, g, S); + } + r.push(S); + a = Math.max(a, S.frames[(f - 1) * t.TwoColorTimeline.ENTRIES]); + } + } + } + for (c = 0, u = i.readInt(!0); c < u; c++) { + var b = i.readInt(!0); + for (d = 0, p = i.readInt(!0); d < p; d++) { + m = i.readByte(); + f = i.readInt(!0); + switch (m) { + case e.BONE_ROTATE: + (S = new t.RotateTimeline(f)).boneIndex = b; + for (g = 0; g < f; g++) { + S.setFrame(g, i.readFloat(), i.readFloat()); + g < f - 1 && this.readCurve(i, g, S); + } + r.push(S); + a = Math.max(a, S.frames[(f - 1) * t.RotateTimeline.ENTRIES]); + break; + + case e.BONE_TRANSLATE: + case e.BONE_SCALE: + case e.BONE_SHEAR: + var S = void 0; + var A = 1; + if (m == e.BONE_SCALE) S = new t.ScaleTimeline(f); else if (m == e.BONE_SHEAR) S = new t.ShearTimeline(f); else { + S = new t.TranslateTimeline(f); + A = o; + } + S.boneIndex = b; + for (g = 0; g < f; g++) { + S.setFrame(g, i.readFloat(), i.readFloat() * A, i.readFloat() * A); + g < f - 1 && this.readCurve(i, g, S); + } + r.push(S); + a = Math.max(a, S.frames[(f - 1) * t.TranslateTimeline.ENTRIES]); + } + } + } + for (c = 0, u = i.readInt(!0); c < u; c++) { + var T = i.readInt(!0); + f = i.readInt(!0); + (S = new t.IkConstraintTimeline(f)).ikConstraintIndex = T; + for (g = 0; g < f; g++) { + S.setFrame(g, i.readFloat(), i.readFloat(), i.readFloat() * o, i.readByte(), i.readBoolean(), i.readBoolean()); + g < f - 1 && this.readCurve(i, g, S); + } + r.push(S); + a = Math.max(a, S.frames[(f - 1) * t.IkConstraintTimeline.ENTRIES]); + } + for (c = 0, u = i.readInt(!0); c < u; c++) { + T = i.readInt(!0); + f = i.readInt(!0); + (S = new t.TransformConstraintTimeline(f)).transformConstraintIndex = T; + for (g = 0; g < f; g++) { + S.setFrame(g, i.readFloat(), i.readFloat(), i.readFloat(), i.readFloat(), i.readFloat()); + g < f - 1 && this.readCurve(i, g, S); + } + r.push(S); + a = Math.max(a, S.frames[(f - 1) * t.TransformConstraintTimeline.ENTRIES]); + } + for (c = 0, u = i.readInt(!0); c < u; c++) { + T = i.readInt(!0); + var v = n.pathConstraints[T]; + for (d = 0, p = i.readInt(!0); d < p; d++) { + m = i.readByte(); + f = i.readInt(!0); + switch (m) { + case e.PATH_POSITION: + case e.PATH_SPACING: + S = void 0; + A = 1; + if (m == e.PATH_SPACING) { + S = new t.PathConstraintSpacingTimeline(f); + v.spacingMode != t.SpacingMode.Length && v.spacingMode != t.SpacingMode.Fixed || (A = o); + } else { + S = new t.PathConstraintPositionTimeline(f); + v.positionMode == t.PositionMode.Fixed && (A = o); + } + S.pathConstraintIndex = T; + for (g = 0; g < f; g++) { + S.setFrame(g, i.readFloat(), i.readFloat() * A); + g < f - 1 && this.readCurve(i, g, S); + } + r.push(S); + a = Math.max(a, S.frames[(f - 1) * t.PathConstraintPositionTimeline.ENTRIES]); + break; + + case e.PATH_MIX: + (S = new t.PathConstraintMixTimeline(f)).pathConstraintIndex = T; + for (g = 0; g < f; g++) { + S.setFrame(g, i.readFloat(), i.readFloat(), i.readFloat()); + g < f - 1 && this.readCurve(i, g, S); + } + r.push(S); + a = Math.max(a, S.frames[(f - 1) * t.PathConstraintMixTimeline.ENTRIES]); + } + } + } + for (c = 0, u = i.readInt(!0); c < u; c++) { + var E = n.skins[i.readInt(!0)]; + for (d = 0, p = i.readInt(!0); d < p; d++) { + _ = i.readInt(!0); + for (var C = 0, x = i.readInt(!0); C < x; C++) { + var w = E.getAttachment(_, i.readStringRef()); + var R = null != w.bones; + var I = w.vertices; + var M = R ? I.length / 3 * 2 : I.length; + f = i.readInt(!0); + (S = new t.DeformTimeline(f)).slotIndex = _; + S.attachment = w; + for (g = 0; g < f; g++) { + y = i.readFloat(); + var B = void 0; + var D = i.readInt(!0); + if (0 == D) B = R ? t.Utils.newFloatArray(M) : I; else { + B = t.Utils.newFloatArray(M); + var P = i.readInt(!0); + D += P; + if (1 == o) for (var O = P; O < D; O++) B[O] = i.readFloat(); else for (O = P; O < D; O++) B[O] = i.readFloat() * o; + if (!R) { + O = 0; + for (var N = B.length; O < N; O++) B[O] += I[O]; + } + } + S.setFrame(g, y, B); + g < f - 1 && this.readCurve(i, g, S); + } + r.push(S); + a = Math.max(a, S.frames[f - 1]); + } + } + } + var L = i.readInt(!0); + if (L > 0) { + S = new t.DrawOrderTimeline(L); + var F = n.slots.length; + for (c = 0; c < L; c++) { + y = i.readFloat(); + var V = i.readInt(!0); + var k = t.Utils.newArray(F, 0); + for (d = F - 1; d >= 0; d--) k[d] = -1; + var U = t.Utils.newArray(F - V, 0); + var G = 0, z = 0; + for (d = 0; d < V; d++) { + _ = i.readInt(!0); + for (;G != _; ) U[z++] = G++; + k[G + i.readInt(!0)] = G++; + } + for (;G < F; ) U[z++] = G++; + for (d = F - 1; d >= 0; d--) -1 == k[d] && (k[d] = U[--z]); + S.setFrame(c, y, k); + } + r.push(S); + a = Math.max(a, S.frames[L - 1]); + } + var H = i.readInt(!0); + if (H > 0) { + S = new t.EventTimeline(H); + for (c = 0; c < H; c++) { + y = i.readFloat(); + var j = n.events[i.readInt(!0)]; + var X = new t.Event(y, j); + X.intValue = i.readInt(!1); + X.floatValue = i.readFloat(); + X.stringValue = i.readBoolean() ? i.readString() : j.stringValue; + if (null != X.data.audioPath) { + X.volume = i.readFloat(); + X.balance = i.readFloat(); + } + S.setFrame(c, X); + } + r.push(S); + a = Math.max(a, S.frames[H - 1]); + } + return new t.Animation(s, r, a); + }; + e.prototype.readCurve = function(t, i, s) { + switch (t.readByte()) { + case e.CURVE_STEPPED: + s.setStepped(i); + break; + + case e.CURVE_BEZIER: + this.setCurve(s, i, t.readFloat(), t.readFloat(), t.readFloat(), t.readFloat()); + } + }; + e.prototype.setCurve = function(t, e, i, s, n, r) { + t.setCurve(e, i, s, n, r); + }; + e.AttachmentTypeValues = [ 0, 1, 2, 3, 4, 5, 6 ]; + e.TransformModeValues = [ t.TransformMode.Normal, t.TransformMode.OnlyTranslation, t.TransformMode.NoRotationOrReflection, t.TransformMode.NoScale, t.TransformMode.NoScaleOrReflection ]; + e.PositionModeValues = [ t.PositionMode.Fixed, t.PositionMode.Percent ]; + e.SpacingModeValues = [ t.SpacingMode.Length, t.SpacingMode.Fixed, t.SpacingMode.Percent ]; + e.RotateModeValues = [ t.RotateMode.Tangent, t.RotateMode.Chain, t.RotateMode.ChainScale ]; + e.BlendModeValues = [ t.BlendMode.Normal, t.BlendMode.Additive, t.BlendMode.Multiply, t.BlendMode.Screen ]; + e.BONE_ROTATE = 0; + e.BONE_TRANSLATE = 1; + e.BONE_SCALE = 2; + e.BONE_SHEAR = 3; + e.SLOT_ATTACHMENT = 0; + e.SLOT_COLOR = 1; + e.SLOT_TWO_COLOR = 2; + e.PATH_POSITION = 0; + e.PATH_SPACING = 1; + e.PATH_MIX = 2; + e.CURVE_LINEAR = 0; + e.CURVE_STEPPED = 1; + e.CURVE_BEZIER = 2; + return e; + }(); + t.SkeletonBinary = e; + var i = function() { + function t(t, e, i, s) { + void 0 === e && (e = new Array); + void 0 === i && (i = 0); + void 0 === s && (s = new DataView(t.buffer)); + this.strings = e; + this.index = i; + this.buffer = s; + } + t.prototype.readByte = function() { + return this.buffer.getInt8(this.index++); + }; + t.prototype.readShort = function() { + var t = this.buffer.getInt16(this.index); + this.index += 2; + return t; + }; + t.prototype.readInt32 = function() { + var t = this.buffer.getInt32(this.index); + this.index += 4; + return t; + }; + t.prototype.readInt = function(t) { + var e = this.readByte(); + var i = 127 & e; + if (0 != (128 & e)) { + i |= (127 & (e = this.readByte())) << 7; + if (0 != (128 & e)) { + i |= (127 & (e = this.readByte())) << 14; + if (0 != (128 & e)) { + i |= (127 & (e = this.readByte())) << 21; + 0 != (128 & e) && (i |= (127 & (e = this.readByte())) << 28); + } + } + } + return t ? i : i >>> 1 ^ -(1 & i); + }; + t.prototype.readStringRef = function() { + var t = this.readInt(!0); + return 0 == t ? null : this.strings[t - 1]; + }; + t.prototype.readString = function() { + var t = this.readInt(!0); + switch (t) { + case 0: + return null; + + case 1: + return ""; + } + t--; + var e = ""; + for (var i = 0; i < t; ) { + var s = this.readByte(); + switch (s >> 4) { + case 12: + case 13: + e += String.fromCharCode((31 & s) << 6 | 63 & this.readByte()); + i += 2; + break; + + case 14: + e += String.fromCharCode((15 & s) << 12 | (63 & this.readByte()) << 6 | 63 & this.readByte()); + i += 3; + break; + + default: + e += String.fromCharCode(s); + i++; + } + } + return e; + }; + t.prototype.readFloat = function() { + var t = this.buffer.getFloat32(this.index); + this.index += 4; + return t; + }; + t.prototype.readBoolean = function() { + return 0 != this.readByte(); + }; + return t; + }(); + var s = function(t, e, i, s, n) { + this.mesh = t; + this.skin = e; + this.slotIndex = i; + this.parent = s; + this.inheritDeform = n; + }; + var n = function(t, e) { + void 0 === t && (t = null); + void 0 === e && (e = null); + this.bones = t; + this.vertices = e; + }; + }(TMt || (TMt = {})); + !function(t) { + var e = function() { + function e() { + this.minX = 0; + this.minY = 0; + this.maxX = 0; + this.maxY = 0; + this.boundingBoxes = new Array; + this.polygons = new Array; + this.polygonPool = new t.Pool((function() { + return t.Utils.newFloatArray(16); + })); + } + e.prototype.update = function(e, i) { + if (null == e) throw new Error("skeleton cannot be null."); + var s = this.boundingBoxes; + var n = this.polygons; + var r = this.polygonPool; + var o = e.slots; + var a = o.length; + s.length = 0; + r.freeAll(n); + n.length = 0; + for (var l = 0; l < a; l++) { + var h = o[l]; + if (h.bone.active) { + var c = h.getAttachment(); + if (c instanceof t.BoundingBoxAttachment) { + var u = c; + s.push(u); + var _ = r.obtain(); + _.length != u.worldVerticesLength && (_ = t.Utils.newFloatArray(u.worldVerticesLength)); + n.push(_); + u.computeWorldVertices(h, 0, u.worldVerticesLength, _, 0, 2); + } + } + } + if (i) this.aabbCompute(); else { + this.minX = Number.POSITIVE_INFINITY; + this.minY = Number.POSITIVE_INFINITY; + this.maxX = Number.NEGATIVE_INFINITY; + this.maxY = Number.NEGATIVE_INFINITY; + } + }; + e.prototype.aabbCompute = function() { + var t = Number.POSITIVE_INFINITY, e = Number.POSITIVE_INFINITY, i = Number.NEGATIVE_INFINITY, s = Number.NEGATIVE_INFINITY; + var n = this.polygons; + for (var r = 0, o = n.length; r < o; r++) { + var a = n[r]; + var l = a; + for (var h = 0, c = a.length; h < c; h += 2) { + var u = l[h]; + var _ = l[h + 1]; + t = Math.min(t, u); + e = Math.min(e, _); + i = Math.max(i, u); + s = Math.max(s, _); + } + } + this.minX = t; + this.minY = e; + this.maxX = i; + this.maxY = s; + }; + e.prototype.aabbContainsPoint = function(t, e) { + return t >= this.minX && t <= this.maxX && e >= this.minY && e <= this.maxY; + }; + e.prototype.aabbIntersectsSegment = function(t, e, i, s) { + var n = this.minX; + var r = this.minY; + var o = this.maxX; + var a = this.maxY; + if (t <= n && i <= n || e <= r && s <= r || t >= o && i >= o || e >= a && s >= a) return !1; + var l = (s - e) / (i - t); + var h = l * (n - t) + e; + if (h > r && h < a) return !0; + if ((h = l * (o - t) + e) > r && h < a) return !0; + var c = (r - e) / l + t; + return c > n && c < o || (c = (a - e) / l + t) > n && c < o; + }; + e.prototype.aabbIntersectsSkeleton = function(t) { + return this.minX < t.maxX && this.maxX > t.minX && this.minY < t.maxY && this.maxY > t.minY; + }; + e.prototype.containsPoint = function(t, e) { + var i = this.polygons; + for (var s = 0, n = i.length; s < n; s++) if (this.containsPointPolygon(i[s], t, e)) return this.boundingBoxes[s]; + return null; + }; + e.prototype.containsPointPolygon = function(t, e, i) { + var s = t; + var n = t.length; + var r = n - 2; + var o = !1; + for (var a = 0; a < n; a += 2) { + var l = s[a + 1]; + var h = s[r + 1]; + if (l < i && h >= i || h < i && l >= i) { + var c = s[a]; + c + (i - l) / (h - l) * (s[r] - c) < e && (o = !o); + } + r = a; + } + return o; + }; + e.prototype.intersectsSegment = function(t, e, i, s) { + var n = this.polygons; + for (var r = 0, o = n.length; r < o; r++) if (this.intersectsSegmentPolygon(n[r], t, e, i, s)) return this.boundingBoxes[r]; + return null; + }; + e.prototype.intersectsSegmentPolygon = function(t, e, i, s, n) { + var r = t; + var o = t.length; + var a = e - s, l = i - n; + var h = e * n - i * s; + var c = r[o - 2], u = r[o - 1]; + for (var _ = 0; _ < o; _ += 2) { + var d = r[_], p = r[_ + 1]; + var m = c * p - u * d; + var f = c - d, g = u - p; + var y = a * g - l * f; + var b = (h * f - a * m) / y; + if ((b >= c && b <= d || b >= d && b <= c) && (b >= e && b <= s || b >= s && b <= e)) { + var S = (h * g - l * m) / y; + if ((S >= u && S <= p || S >= p && S <= u) && (S >= i && S <= n || S >= n && S <= i)) return !0; + } + c = d; + u = p; + } + return !1; + }; + e.prototype.getPolygon = function(t) { + if (null == t) throw new Error("boundingBox cannot be null."); + var e = this.boundingBoxes.indexOf(t); + return -1 == e ? null : this.polygons[e]; + }; + e.prototype.getWidth = function() { + return this.maxX - this.minX; + }; + e.prototype.getHeight = function() { + return this.maxY - this.minY; + }; + return e; + }(); + t.SkeletonBounds = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function() { + function e() { + this.triangulator = new t.Triangulator; + this.clippingPolygon = new Array; + this.clipOutput = new Array; + this.clippedVertices = new Array; + this.clippedTriangles = new Array; + this.scratch = new Array; + } + e.prototype.clipStart = function(i, s) { + if (null != this.clipAttachment) return 0; + this.clipAttachment = s; + var n = s.worldVerticesLength; + var r = t.Utils.setArraySize(this.clippingPolygon, n); + s.computeWorldVertices(i, 0, n, r, 0, 2); + var o = this.clippingPolygon; + e.makeClockwise(o); + var a = this.clippingPolygons = this.triangulator.decompose(o, this.triangulator.triangulate(o)); + for (var l = 0, h = a.length; l < h; l++) { + var c = a[l]; + e.makeClockwise(c); + c.push(c[0]); + c.push(c[1]); + } + return a.length; + }; + e.prototype.clipEndWithSlot = function(t) { + null != this.clipAttachment && this.clipAttachment.endSlot == t.data && this.clipEnd(); + }; + e.prototype.clipEnd = function() { + if (null != this.clipAttachment) { + this.clipAttachment = null; + this.clippingPolygons = null; + this.clippedVertices.length = 0; + this.clippedTriangles.length = 0; + this.clippingPolygon.length = 0; + } + }; + e.prototype.isClipping = function() { + return null != this.clipAttachment; + }; + e.prototype.clipTriangles = function(e, i, s, n, r, o, a, l, h, c, u) { + void 0 === h && (h = 2); + void 0 === c && (c = 0); + void 0 === u && (u = 0); + var _ = this.clipOutput, d = this.clippedVertices; + var p = this.clippedTriangles; + var m = this.clippingPolygons; + var f = this.clippingPolygons.length; + var g = l ? 12 : 8; + var y = 0; + d.length = 0; + p.length = 0; + t: for (var b = 0; b < n; b += 3) { + var S = s[b] * h; + var A = e[S + c], T = e[S + c + 1]; + var v = r[S + u], E = r[S + u + 1]; + var C = e[(S = s[b + 1] * h) + c], x = e[S + c + 1]; + var w = r[S + u], R = r[S + u + 1]; + var I = e[(S = s[b + 2] * h) + c], M = e[S + c + 1]; + var B = r[S + u], D = r[S + u + 1]; + for (var P = 0; P < f; P++) { + var O = d.length; + if (!this.clip(A, T, C, x, I, M, m[P], _)) { + (H = t.Utils.setArraySize(d, O + 3 * g))[O] = A; + H[O + 1] = T; + H[O + 2] = o.r; + H[O + 3] = o.g; + H[O + 4] = o.b; + H[O + 5] = o.a; + if (l) { + H[O + 6] = v; + H[O + 7] = E; + H[O + 8] = a.r; + H[O + 9] = a.g; + H[O + 10] = a.b; + H[O + 11] = a.a; + H[O + 12] = C; + H[O + 13] = x; + H[O + 14] = o.r; + H[O + 15] = o.g; + H[O + 16] = o.b; + H[O + 17] = o.a; + H[O + 18] = w; + H[O + 19] = R; + H[O + 20] = a.r; + H[O + 21] = a.g; + H[O + 22] = a.b; + H[O + 23] = a.a; + H[O + 24] = I; + H[O + 25] = M; + H[O + 26] = o.r; + H[O + 27] = o.g; + H[O + 28] = o.b; + H[O + 29] = o.a; + H[O + 30] = B; + H[O + 31] = D; + H[O + 32] = a.r; + H[O + 33] = a.g; + H[O + 34] = a.b; + H[O + 35] = a.a; + } else { + H[O + 6] = v; + H[O + 7] = E; + H[O + 8] = C; + H[O + 9] = x; + H[O + 10] = o.r; + H[O + 11] = o.g; + H[O + 12] = o.b; + H[O + 13] = o.a; + H[O + 14] = w; + H[O + 15] = R; + H[O + 16] = I; + H[O + 17] = M; + H[O + 18] = o.r; + H[O + 19] = o.g; + H[O + 20] = o.b; + H[O + 21] = o.a; + H[O + 22] = B; + H[O + 23] = D; + } + O = p.length; + (Q = t.Utils.setArraySize(p, O + 3))[O] = y; + Q[O + 1] = y + 1; + Q[O + 2] = y + 2; + y += 3; + continue t; + } + var N = _.length; + if (0 != N) { + var L = x - M, F = I - C, V = A - I, k = M - T; + var U = 1 / (L * V + F * (T - M)); + var G = N >> 1; + var z = this.clipOutput; + var H = t.Utils.setArraySize(d, O + G * g); + for (var j = 0; j < N; j += 2) { + var X = z[j], W = z[j + 1]; + H[O] = X; + H[O + 1] = W; + H[O + 2] = o.r; + H[O + 3] = o.g; + H[O + 4] = o.b; + H[O + 5] = o.a; + var Y = X - I, q = W - M; + var K = (L * Y + F * q) * U; + var J = (k * Y + V * q) * U; + var Z = 1 - K - J; + H[O + 6] = v * K + w * J + B * Z; + H[O + 7] = E * K + R * J + D * Z; + if (l) { + H[O + 8] = a.r; + H[O + 9] = a.g; + H[O + 10] = a.b; + H[O + 11] = a.a; + } + O += g; + } + O = p.length; + var Q = t.Utils.setArraySize(p, O + 3 * (G - 2)); + G--; + for (j = 1; j < G; j++) { + Q[O] = y; + Q[O + 1] = y + j; + Q[O + 2] = y + j + 1; + O += 3; + } + y += G + 1; + } + } + } + }; + e.prototype.clip = function(t, e, i, s, n, r, o, a) { + var l = a; + var h = !1; + var c = null; + if (o.length % 4 >= 2) { + c = a; + a = this.scratch; + } else c = this.scratch; + c.length = 0; + c.push(t); + c.push(e); + c.push(i); + c.push(s); + c.push(n); + c.push(r); + c.push(t); + c.push(e); + a.length = 0; + var u = o; + var _ = o.length - 4; + for (var d = 0; ;d += 2) { + var p = u[d], m = u[d + 1]; + var f = u[d + 2], g = u[d + 3]; + var y = p - f, b = m - g; + var S = c; + var A = c.length - 2, T = a.length; + for (var v = 0; v < A; v += 2) { + var E = S[v], C = S[v + 1]; + var x = S[v + 2], w = S[v + 3]; + var R = y * (w - g) - b * (x - f) > 0; + if (y * (C - g) - b * (E - f) > 0) { + if (R) { + a.push(x); + a.push(w); + continue; + } + var I = (B = w - C) * (f - p) - (D = x - E) * (g - m); + if (Math.abs(I) > 1e-6) { + var M = (D * (m - C) - B * (p - E)) / I; + a.push(p + (f - p) * M); + a.push(m + (g - m) * M); + } else { + a.push(p); + a.push(m); + } + } else if (R) { + var B, D; + I = (B = w - C) * (f - p) - (D = x - E) * (g - m); + if (Math.abs(I) > 1e-6) { + M = (D * (m - C) - B * (p - E)) / I; + a.push(p + (f - p) * M); + a.push(m + (g - m) * M); + } else { + a.push(p); + a.push(m); + } + a.push(x); + a.push(w); + } + h = !0; + } + if (T == a.length) { + l.length = 0; + return !0; + } + a.push(a[0]); + a.push(a[1]); + if (d == _) break; + var P = a; + (a = c).length = 0; + c = P; + } + if (l != a) { + l.length = 0; + d = 0; + for (var O = a.length - 2; d < O; d++) l[d] = a[d]; + } else l.length = l.length - 2; + return h; + }; + e.makeClockwise = function(t) { + var e = t; + var i = t.length; + var s = e[i - 2] * e[1] - e[0] * e[i - 1], n = 0, r = 0, o = 0; + for (var a = 0, l = i - 3; a < l; a += 2) { + n = e[a]; + r = e[a + 1]; + o = e[a + 2]; + s += n * e[a + 3] - o * r; + } + if (!(s < 0)) { + a = 0; + var h = i - 2; + for (l = i >> 1; a < l; a += 2) { + var c = e[a], u = e[a + 1]; + var _ = h - a; + e[a] = e[_]; + e[a + 1] = e[_ + 1]; + e[_] = c; + e[_ + 1] = u; + } + } + }; + return e; + }(); + t.SkeletonClipping = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function() { + function t() { + this.bones = new Array; + this.slots = new Array; + this.skins = new Array; + this.events = new Array; + this.animations = new Array; + this.ikConstraints = new Array; + this.transformConstraints = new Array; + this.pathConstraints = new Array; + this.fps = 0; + } + t.prototype.findBone = function(t) { + if (null == t) throw new Error("boneName cannot be null."); + var e = this.bones; + for (var i = 0, s = e.length; i < s; i++) { + var n = e[i]; + if (n.name == t) return n; + } + return null; + }; + t.prototype.findBoneIndex = function(t) { + if (null == t) throw new Error("boneName cannot be null."); + var e = this.bones; + for (var i = 0, s = e.length; i < s; i++) if (e[i].name == t) return i; + return -1; + }; + t.prototype.findSlot = function(t) { + if (null == t) throw new Error("slotName cannot be null."); + var e = this.slots; + for (var i = 0, s = e.length; i < s; i++) { + var n = e[i]; + if (n.name == t) return n; + } + return null; + }; + t.prototype.findSlotIndex = function(t) { + if (null == t) throw new Error("slotName cannot be null."); + var e = this.slots; + for (var i = 0, s = e.length; i < s; i++) if (e[i].name == t) return i; + return -1; + }; + t.prototype.findSkin = function(t) { + if (null == t) throw new Error("skinName cannot be null."); + var e = this.skins; + for (var i = 0, s = e.length; i < s; i++) { + var n = e[i]; + if (n.name == t) return n; + } + return null; + }; + t.prototype.findEvent = function(t) { + if (null == t) throw new Error("eventDataName cannot be null."); + var e = this.events; + for (var i = 0, s = e.length; i < s; i++) { + var n = e[i]; + if (n.name == t) return n; + } + return null; + }; + t.prototype.findAnimation = function(t) { + if (null == t) throw new Error("animationName cannot be null."); + var e = this.animations; + for (var i = 0, s = e.length; i < s; i++) { + var n = e[i]; + if (n.name == t) return n; + } + return null; + }; + t.prototype.findIkConstraint = function(t) { + if (null == t) throw new Error("constraintName cannot be null."); + var e = this.ikConstraints; + for (var i = 0, s = e.length; i < s; i++) { + var n = e[i]; + if (n.name == t) return n; + } + return null; + }; + t.prototype.findTransformConstraint = function(t) { + if (null == t) throw new Error("constraintName cannot be null."); + var e = this.transformConstraints; + for (var i = 0, s = e.length; i < s; i++) { + var n = e[i]; + if (n.name == t) return n; + } + return null; + }; + t.prototype.findPathConstraint = function(t) { + if (null == t) throw new Error("constraintName cannot be null."); + var e = this.pathConstraints; + for (var i = 0, s = e.length; i < s; i++) { + var n = e[i]; + if (n.name == t) return n; + } + return null; + }; + t.prototype.findPathConstraintIndex = function(t) { + if (null == t) throw new Error("pathConstraintName cannot be null."); + var e = this.pathConstraints; + for (var i = 0, s = e.length; i < s; i++) if (e[i].name == t) return i; + return -1; + }; + return t; + }(); + t.SkeletonData = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function() { + function e(t) { + this.scale = 1; + this.linkedMeshes = new Array; + this.attachmentLoader = t; + } + e.prototype.readSkeletonData = function(i) { + var s = this.scale; + var n = new t.SkeletonData; + var r = "string" == typeof i ? JSON.parse(i) : i; + var o = r.skeleton; + if (null != o) { + n.hash = o.hash; + n.version = o.spine; + n.x = o.x; + n.y = o.y; + n.width = o.width; + n.height = o.height; + n.fps = o.fps; + n.imagesPath = o.images; + } + if (r.bones) for (var a = 0; a < r.bones.length; a++) { + var l = r.bones[a]; + var h = null; + var c = this.getValue(l, "parent", null); + if (null != c && null == (h = n.findBone(c))) throw new Error("Parent bone not found: " + c); + (p = new t.BoneData(n.bones.length, l.name, h)).length = this.getValue(l, "length", 0) * s; + p.x = this.getValue(l, "x", 0) * s; + p.y = this.getValue(l, "y", 0) * s; + p.rotation = this.getValue(l, "rotation", 0); + p.scaleX = this.getValue(l, "scaleX", 1); + p.scaleY = this.getValue(l, "scaleY", 1); + p.shearX = this.getValue(l, "shearX", 0); + p.shearY = this.getValue(l, "shearY", 0); + p.transformMode = e.transformModeFromString(this.getValue(l, "transform", "normal")); + p.skinRequired = this.getValue(l, "skin", !1); + n.bones.push(p); + } + if (r.slots) for (a = 0; a < r.slots.length; a++) { + var u = (I = r.slots[a]).name; + var _ = I.bone; + var d = n.findBone(_); + if (null == d) throw new Error("Slot bone not found: " + _); + var p = new t.SlotData(n.slots.length, u, d); + var m = this.getValue(I, "color", null); + null != m && p.color.setFromString(m); + var f = this.getValue(I, "dark", null); + if (null != f) { + p.darkColor = new t.Color(1, 1, 1, 1); + p.darkColor.setFromString(f); + } + p.attachmentName = this.getValue(I, "attachment", null); + p.blendMode = e.blendModeFromString(this.getValue(I, "blend", "normal")); + n.slots.push(p); + } + if (r.ik) for (a = 0; a < r.ik.length; a++) { + var g = r.ik[a]; + (p = new t.IkConstraintData(g.name)).order = this.getValue(g, "order", 0); + p.skinRequired = this.getValue(g, "skin", !1); + for (var y = 0; y < g.bones.length; y++) { + _ = g.bones[y]; + if (null == (x = n.findBone(_))) throw new Error("IK bone not found: " + _); + p.bones.push(x); + } + var b = g.target; + p.target = n.findBone(b); + if (null == p.target) throw new Error("IK target bone not found: " + b); + p.mix = this.getValue(g, "mix", 1); + p.softness = this.getValue(g, "softness", 0) * s; + p.bendDirection = this.getValue(g, "bendPositive", !0) ? 1 : -1; + p.compress = this.getValue(g, "compress", !1); + p.stretch = this.getValue(g, "stretch", !1); + p.uniform = this.getValue(g, "uniform", !1); + n.ikConstraints.push(p); + } + if (r.transform) for (a = 0; a < r.transform.length; a++) { + g = r.transform[a]; + (p = new t.TransformConstraintData(g.name)).order = this.getValue(g, "order", 0); + p.skinRequired = this.getValue(g, "skin", !1); + for (y = 0; y < g.bones.length; y++) { + _ = g.bones[y]; + if (null == (x = n.findBone(_))) throw new Error("Transform constraint bone not found: " + _); + p.bones.push(x); + } + b = g.target; + p.target = n.findBone(b); + if (null == p.target) throw new Error("Transform constraint target bone not found: " + b); + p.local = this.getValue(g, "local", !1); + p.relative = this.getValue(g, "relative", !1); + p.offsetRotation = this.getValue(g, "rotation", 0); + p.offsetX = this.getValue(g, "x", 0) * s; + p.offsetY = this.getValue(g, "y", 0) * s; + p.offsetScaleX = this.getValue(g, "scaleX", 0); + p.offsetScaleY = this.getValue(g, "scaleY", 0); + p.offsetShearY = this.getValue(g, "shearY", 0); + p.rotateMix = this.getValue(g, "rotateMix", 1); + p.translateMix = this.getValue(g, "translateMix", 1); + p.scaleMix = this.getValue(g, "scaleMix", 1); + p.shearMix = this.getValue(g, "shearMix", 1); + n.transformConstraints.push(p); + } + if (r.path) for (a = 0; a < r.path.length; a++) { + g = r.path[a]; + (p = new t.PathConstraintData(g.name)).order = this.getValue(g, "order", 0); + p.skinRequired = this.getValue(g, "skin", !1); + for (y = 0; y < g.bones.length; y++) { + _ = g.bones[y]; + if (null == (x = n.findBone(_))) throw new Error("Transform constraint bone not found: " + _); + p.bones.push(x); + } + b = g.target; + p.target = n.findSlot(b); + if (null == p.target) throw new Error("Path target slot not found: " + b); + p.positionMode = e.positionModeFromString(this.getValue(g, "positionMode", "percent")); + p.spacingMode = e.spacingModeFromString(this.getValue(g, "spacingMode", "length")); + p.rotateMode = e.rotateModeFromString(this.getValue(g, "rotateMode", "tangent")); + p.offsetRotation = this.getValue(g, "rotation", 0); + p.position = this.getValue(g, "position", 0); + p.positionMode == t.PositionMode.Fixed && (p.position *= s); + p.spacing = this.getValue(g, "spacing", 0); + p.spacingMode != t.SpacingMode.Length && p.spacingMode != t.SpacingMode.Fixed || (p.spacing *= s); + p.rotateMix = this.getValue(g, "rotateMix", 1); + p.translateMix = this.getValue(g, "translateMix", 1); + n.pathConstraints.push(p); + } + if (r.skins) { + var S = r.skins; + if (!(S instanceof Array)) { + var A = []; + for (var T in S) A.push({ + name: T, + attachments: S[T] + }); + S = A; + } + for (a = 0; a < S.length; a++) { + var v = S[a]; + var E = new t.Skin(v.name); + if (v.bones) for (var C = 0; C < v.bones.length; C++) { + var x; + if (null == (x = n.findBone(v.bones[C]))) throw new Error("Skin bone not found: " + v.bones[C]); + E.bones.push(x); + } + if (v.ik) for (C = 0; C < v.ik.length; C++) { + if (null == (w = n.findIkConstraint(v.ik[C]))) throw new Error("Skin IK constraint not found: " + v.ik[C]); + E.constraints.push(w); + } + if (v.transform) for (C = 0; C < v.transform.length; C++) { + if (null == (w = n.findTransformConstraint(v.transform[C]))) throw new Error("Skin transform constraint not found: " + v.transform[C]); + E.constraints.push(w); + } + if (v.path) for (C = 0; C < v.path.length; C++) { + var w; + if (null == (w = n.findPathConstraint(v.path[C]))) throw new Error("Skin path constraint not found: " + v.path[C]); + E.constraints.push(w); + } + for (var u in v.attachments) { + var R = n.findSlot(u); + if (null == R) throw new Error("Slot not found: " + u); + var I = v.attachments[u]; + for (var M in I) { + var B = this.readAttachment(I[M], E, R.index, M, n); + null != B && E.setAttachment(R.index, M, B); + } + } + n.skins.push(E); + "default" == E.name && (n.defaultSkin = E); + } + } + a = 0; + for (var D = this.linkedMeshes.length; a < D; a++) { + var P = this.linkedMeshes[a]; + if (null == (E = null == P.skin ? n.defaultSkin : n.findSkin(P.skin))) throw new Error("Skin not found: " + P.skin); + var O = E.getAttachment(P.slotIndex, P.parent); + if (null == O) throw new Error("Parent mesh not found: " + P.parent); + P.mesh.deformAttachment = P.inheritDeform ? O : P.mesh; + P.mesh.setParentMesh(O); + P.mesh.updateUVs(); + } + this.linkedMeshes.length = 0; + if (r.events) for (var N in r.events) { + var L = r.events[N]; + (p = new t.EventData(N)).intValue = this.getValue(L, "int", 0); + p.floatValue = this.getValue(L, "float", 0); + p.stringValue = this.getValue(L, "string", ""); + p.audioPath = this.getValue(L, "audio", null); + if (null != p.audioPath) { + p.volume = this.getValue(L, "volume", 1); + p.balance = this.getValue(L, "balance", 0); + } + n.events.push(p); + } + if (r.animations) for (var F in r.animations) { + var V = r.animations[F]; + this.readAnimation(V, F, n); + } + return n; + }; + e.prototype.readAttachment = function(e, s, n, r, o) { + var a = this.scale; + r = this.getValue(e, "name", r); + switch (this.getValue(e, "type", "region")) { + case "region": + var l = this.getValue(e, "path", r); + var h = this.attachmentLoader.newRegionAttachment(s, r, l); + if (null == h) return null; + h.path = l; + h.x = this.getValue(e, "x", 0) * a; + h.y = this.getValue(e, "y", 0) * a; + h.scaleX = this.getValue(e, "scaleX", 1); + h.scaleY = this.getValue(e, "scaleY", 1); + h.rotation = this.getValue(e, "rotation", 0); + h.width = e.width * a; + h.height = e.height * a; + null != (A = this.getValue(e, "color", null)) && h.color.setFromString(A); + h.updateOffset(); + return h; + + case "boundingbox": + var c = this.attachmentLoader.newBoundingBoxAttachment(s, r); + if (null == c) return null; + this.readVertices(e, c, e.vertexCount << 1); + null != (A = this.getValue(e, "color", null)) && c.color.setFromString(A); + return c; + + case "mesh": + case "linkedmesh": + l = this.getValue(e, "path", r); + var u = this.attachmentLoader.newMeshAttachment(s, r, l); + if (null == u) return null; + u.path = l; + null != (A = this.getValue(e, "color", null)) && u.color.setFromString(A); + u.width = this.getValue(e, "width", 0) * a; + u.height = this.getValue(e, "height", 0) * a; + var _ = this.getValue(e, "parent", null); + if (null != _) { + this.linkedMeshes.push(new i(u, this.getValue(e, "skin", null), n, _, this.getValue(e, "deform", !0))); + return u; + } + var d = e.uvs; + this.readVertices(e, u, d.length); + u.triangles = e.triangles; + u.regionUVs = d; + u.updateUVs(); + u.edges = this.getValue(e, "edges", null); + u.hullLength = 2 * this.getValue(e, "hull", 0); + return u; + + case "path": + if (null == (l = this.attachmentLoader.newPathAttachment(s, r))) return null; + l.closed = this.getValue(e, "closed", !1); + l.constantSpeed = this.getValue(e, "constantSpeed", !0); + var p = e.vertexCount; + this.readVertices(e, l, p << 1); + var m = t.Utils.newArray(p / 3, 0); + for (var f = 0; f < e.lengths.length; f++) m[f] = e.lengths[f] * a; + l.lengths = m; + null != (A = this.getValue(e, "color", null)) && l.color.setFromString(A); + return l; + + case "point": + var g = this.attachmentLoader.newPointAttachment(s, r); + if (null == g) return null; + g.x = this.getValue(e, "x", 0) * a; + g.y = this.getValue(e, "y", 0) * a; + g.rotation = this.getValue(e, "rotation", 0); + null != (A = this.getValue(e, "color", null)) && g.color.setFromString(A); + return g; + + case "clipping": + var y = this.attachmentLoader.newClippingAttachment(s, r); + if (null == y) return null; + var b = this.getValue(e, "end", null); + if (null != b) { + var S = o.findSlot(b); + if (null == S) throw new Error("Clipping end slot not found: " + b); + y.endSlot = S; + } + p = e.vertexCount; + this.readVertices(e, y, p << 1); + var A; + null != (A = this.getValue(e, "color", null)) && y.color.setFromString(A); + return y; + } + return null; + }; + e.prototype.readVertices = function(e, i, s) { + var n = this.scale; + i.worldVerticesLength = s; + var r = e.vertices; + if (s != r.length) { + var o = new Array; + var a = new Array; + for (u = 0, _ = r.length; u < _; ) { + var l = r[u++]; + a.push(l); + for (var h = u + 4 * l; u < h; u += 4) { + a.push(r[u]); + o.push(r[u + 1] * n); + o.push(r[u + 2] * n); + o.push(r[u + 3]); + } + } + i.bones = a; + i.vertices = t.Utils.toFloatArray(o); + } else { + var c = t.Utils.toFloatArray(r); + if (1 != n) for (var u = 0, _ = r.length; u < _; u++) c[u] *= n; + i.vertices = c; + } + }; + e.prototype.readAnimation = function(e, i, s) { + var n = this.scale; + var r = new Array; + var o = 0; + if (e.slots) for (var a in e.slots) { + var l = e.slots[a]; + if (-1 == (Q = s.findSlotIndex(a))) throw new Error("Slot not found: " + a); + for (var h in l) { + var c = l[h]; + if ("attachment" == h) { + (S = new t.AttachmentTimeline(c.length)).slotIndex = Q; + var u = 0; + for (var _ = 0; _ < c.length; _++) { + var d = c[_]; + S.setFrame(u++, this.getValue(d, "time", 0), d.name); + } + r.push(S); + o = Math.max(o, S.frames[S.getFrameCount() - 1]); + } else if ("color" == h) { + (S = new t.ColorTimeline(c.length)).slotIndex = Q; + u = 0; + for (_ = 0; _ < c.length; _++) { + d = c[_]; + var p = new t.Color; + p.setFromString(d.color); + S.setFrame(u, this.getValue(d, "time", 0), p.r, p.g, p.b, p.a); + this.readCurve(d, S, u); + u++; + } + r.push(S); + o = Math.max(o, S.frames[(S.getFrameCount() - 1) * t.ColorTimeline.ENTRIES]); + } else { + if ("twoColor" != h) throw new Error("Invalid timeline type for a slot: " + h + " (" + a + ")"); + (S = new t.TwoColorTimeline(c.length)).slotIndex = Q; + u = 0; + for (_ = 0; _ < c.length; _++) { + d = c[_]; + var m = new t.Color; + var f = new t.Color; + m.setFromString(d.light); + f.setFromString(d.dark); + S.setFrame(u, this.getValue(d, "time", 0), m.r, m.g, m.b, m.a, f.r, f.g, f.b); + this.readCurve(d, S, u); + u++; + } + r.push(S); + o = Math.max(o, S.frames[(S.getFrameCount() - 1) * t.TwoColorTimeline.ENTRIES]); + } + } + } + if (e.bones) for (var g in e.bones) { + var y = e.bones[g]; + var b = s.findBoneIndex(g); + if (-1 == b) throw new Error("Bone not found: " + g); + for (var h in y) { + c = y[h]; + if ("rotate" === h) { + (S = new t.RotateTimeline(c.length)).boneIndex = b; + u = 0; + for (_ = 0; _ < c.length; _++) { + d = c[_]; + S.setFrame(u, this.getValue(d, "time", 0), this.getValue(d, "angle", 0)); + this.readCurve(d, S, u); + u++; + } + r.push(S); + o = Math.max(o, S.frames[(S.getFrameCount() - 1) * t.RotateTimeline.ENTRIES]); + } else { + if ("translate" !== h && "scale" !== h && "shear" !== h) throw new Error("Invalid timeline type for a bone: " + h + " (" + g + ")"); + var S = null; + var A = 1, T = 0; + if ("scale" === h) { + S = new t.ScaleTimeline(c.length); + T = 1; + } else if ("shear" === h) S = new t.ShearTimeline(c.length); else { + S = new t.TranslateTimeline(c.length); + A = n; + } + S.boneIndex = b; + u = 0; + for (_ = 0; _ < c.length; _++) { + d = c[_]; + var v = this.getValue(d, "x", T), E = this.getValue(d, "y", T); + S.setFrame(u, this.getValue(d, "time", 0), v * A, E * A); + this.readCurve(d, S, u); + u++; + } + r.push(S); + o = Math.max(o, S.frames[(S.getFrameCount() - 1) * t.TranslateTimeline.ENTRIES]); + } + } + } + if (e.ik) for (var C in e.ik) { + var x = e.ik[C]; + var w = s.findIkConstraint(C); + (S = new t.IkConstraintTimeline(x.length)).ikConstraintIndex = s.ikConstraints.indexOf(w); + u = 0; + for (_ = 0; _ < x.length; _++) { + d = x[_]; + S.setFrame(u, this.getValue(d, "time", 0), this.getValue(d, "mix", 1), this.getValue(d, "softness", 0) * n, this.getValue(d, "bendPositive", !0) ? 1 : -1, this.getValue(d, "compress", !1), this.getValue(d, "stretch", !1)); + this.readCurve(d, S, u); + u++; + } + r.push(S); + o = Math.max(o, S.frames[(S.getFrameCount() - 1) * t.IkConstraintTimeline.ENTRIES]); + } + if (e.transform) for (var C in e.transform) { + x = e.transform[C]; + w = s.findTransformConstraint(C); + (S = new t.TransformConstraintTimeline(x.length)).transformConstraintIndex = s.transformConstraints.indexOf(w); + u = 0; + for (_ = 0; _ < x.length; _++) { + d = x[_]; + S.setFrame(u, this.getValue(d, "time", 0), this.getValue(d, "rotateMix", 1), this.getValue(d, "translateMix", 1), this.getValue(d, "scaleMix", 1), this.getValue(d, "shearMix", 1)); + this.readCurve(d, S, u); + u++; + } + r.push(S); + o = Math.max(o, S.frames[(S.getFrameCount() - 1) * t.TransformConstraintTimeline.ENTRIES]); + } + let R = e.path || e.paths; + if (R) for (var C in R) { + x = R[C]; + var I = s.findPathConstraintIndex(C); + if (-1 == I) throw new Error("Path constraint not found: " + C); + var M = s.pathConstraints[I]; + for (var h in x) { + c = x[h]; + if ("position" === h || "spacing" === h) { + S = null; + A = 1; + if ("spacing" === h) { + S = new t.PathConstraintSpacingTimeline(c.length); + M.spacingMode != t.SpacingMode.Length && M.spacingMode != t.SpacingMode.Fixed || (A = n); + } else { + S = new t.PathConstraintPositionTimeline(c.length); + M.positionMode == t.PositionMode.Fixed && (A = n); + } + S.pathConstraintIndex = I; + u = 0; + for (_ = 0; _ < c.length; _++) { + d = c[_]; + S.setFrame(u, this.getValue(d, "time", 0), this.getValue(d, h, 0) * A); + this.readCurve(d, S, u); + u++; + } + r.push(S); + o = Math.max(o, S.frames[(S.getFrameCount() - 1) * t.PathConstraintPositionTimeline.ENTRIES]); + } else if ("mix" === h) { + (S = new t.PathConstraintMixTimeline(c.length)).pathConstraintIndex = I; + u = 0; + for (_ = 0; _ < c.length; _++) { + d = c[_]; + S.setFrame(u, this.getValue(d, "time", 0), this.getValue(d, "rotateMix", 1), this.getValue(d, "translateMix", 1)); + this.readCurve(d, S, u); + u++; + } + r.push(S); + o = Math.max(o, S.frames[(S.getFrameCount() - 1) * t.PathConstraintMixTimeline.ENTRIES]); + } + } + } + if (e.deform) for (var B in e.deform) { + var D = e.deform[B]; + var P = s.findSkin(B); + if (null == P) throw new Error("Skin not found: " + B); + for (var a in D) { + l = D[a]; + if (-1 == (Q = s.findSlotIndex(a))) throw new Error("Slot not found: " + l.name); + for (var h in l) { + c = l[h]; + var O = P.getAttachment(Q, h); + if (null != O) { + var N = null != O.bones; + var L = O.vertices; + var F = N ? L.length / 3 * 2 : L.length; + (S = new t.DeformTimeline(c.length)).slotIndex = Q; + S.attachment = O; + u = 0; + for (var V = 0; V < c.length; V++) { + d = c[V]; + var k = void 0; + var U = this.getValue(d, "vertices", null); + if (null == U) k = N ? t.Utils.newFloatArray(F) : L; else { + k = t.Utils.newFloatArray(F); + var G = this.getValue(d, "offset", 0); + t.Utils.arrayCopy(U, 0, k, G, U.length); + if (1 != n) for (var z = (_ = G) + U.length; _ < z; _++) k[_] *= n; + if (!N) for (_ = 0; _ < F; _++) k[_] += L[_]; + } + S.setFrame(u, this.getValue(d, "time", 0), k); + this.readCurve(d, S, u); + u++; + } + r.push(S); + o = Math.max(o, S.frames[S.getFrameCount() - 1]); + } + } + } + } + var H = e.drawOrder; + null == H && (H = e.draworder); + if (null != H) { + S = new t.DrawOrderTimeline(H.length); + var j = s.slots.length; + u = 0; + for (V = 0; V < H.length; V++) { + var X = H[V]; + var W = null; + var Y = this.getValue(X, "offsets", null); + if (null != Y) { + W = t.Utils.newArray(j, -1); + var q = t.Utils.newArray(j - Y.length, 0); + var K = 0, J = 0; + for (_ = 0; _ < Y.length; _++) { + var Z = Y[_]; + var Q; + if (-1 == (Q = s.findSlotIndex(Z.slot))) throw new Error("Slot not found: " + Z.slot); + for (;K != Q; ) q[J++] = K++; + W[K + Z.offset] = K++; + } + for (;K < j; ) q[J++] = K++; + for (_ = j - 1; _ >= 0; _--) -1 == W[_] && (W[_] = q[--J]); + } + S.setFrame(u++, this.getValue(X, "time", 0), W); + } + r.push(S); + o = Math.max(o, S.frames[S.getFrameCount() - 1]); + } + if (e.events) { + S = new t.EventTimeline(e.events.length); + u = 0; + for (_ = 0; _ < e.events.length; _++) { + var $ = e.events[_]; + var tt = s.findEvent($.name); + if (null == tt) throw new Error("Event not found: " + $.name); + var et = new t.Event(t.Utils.toSinglePrecision(this.getValue($, "time", 0)), tt); + et.intValue = this.getValue($, "int", tt.intValue); + et.floatValue = this.getValue($, "float", tt.floatValue); + et.stringValue = this.getValue($, "string", tt.stringValue); + if (null != et.data.audioPath) { + et.volume = this.getValue($, "volume", 1); + et.balance = this.getValue($, "balance", 0); + } + S.setFrame(u++, et); + } + r.push(S); + o = Math.max(o, S.frames[S.getFrameCount() - 1]); + } + if (isNaN(o)) throw new Error("Error while parsing animation, duration is NaN"); + s.animations.push(new t.Animation(i, r, o)); + }; + e.prototype.readCurve = function(t, e, i) { + var s = t.curve; + s && ("stepped" == s ? e.setStepped(i) : "[object Array]" === Object.prototype.toString.call(s) ? e.setCurve(i, s[0], s[1], s[2], s[3]) : e.setCurve(i, s, this.getValue(t, "c2", 0), this.getValue(t, "c3", 1), this.getValue(t, "c4", 1))); + }; + e.prototype.getValue = function(t, e, i) { + return void 0 !== t[e] ? t[e] : i; + }; + e.blendModeFromString = function(e) { + if ("normal" == (e = e.toLowerCase())) return t.BlendMode.Normal; + if ("additive" == e) return t.BlendMode.Additive; + if ("multiply" == e) return t.BlendMode.Multiply; + if ("screen" == e) return t.BlendMode.Screen; + throw new Error("Unknown blend mode: " + e); + }; + e.positionModeFromString = function(e) { + if ("fixed" == (e = e.toLowerCase())) return t.PositionMode.Fixed; + if ("percent" == e) return t.PositionMode.Percent; + throw new Error("Unknown position mode: " + e); + }; + e.spacingModeFromString = function(e) { + if ("length" == (e = e.toLowerCase())) return t.SpacingMode.Length; + if ("fixed" == e) return t.SpacingMode.Fixed; + if ("percent" == e) return t.SpacingMode.Percent; + throw new Error("Unknown position mode: " + e); + }; + e.rotateModeFromString = function(e) { + if ("tangent" == (e = e.toLowerCase())) return t.RotateMode.Tangent; + if ("chain" == e) return t.RotateMode.Chain; + if ("chainscale" == e) return t.RotateMode.ChainScale; + throw new Error("Unknown rotate mode: " + e); + }; + e.transformModeFromString = function(e) { + if ("normal" == (e = e.toLowerCase())) return t.TransformMode.Normal; + if ("onlytranslation" == e) return t.TransformMode.OnlyTranslation; + if ("norotationorreflection" == e) return t.TransformMode.NoRotationOrReflection; + if ("noscale" == e) return t.TransformMode.NoScale; + if ("noscaleorreflection" == e) return t.TransformMode.NoScaleOrReflection; + throw new Error("Unknown transform mode: " + e); + }; + return e; + }(); + t.SkeletonJson = e; + var i = function(t, e, i, s, n) { + this.mesh = t; + this.skin = e; + this.slotIndex = i; + this.parent = s; + this.inheritDeform = n; + }; + }(TMt || (TMt = {})); + !function(t) { + var e = function(t, e, i) { + this.slotIndex = t; + this.name = e; + this.attachment = i; + }; + t.SkinEntry = e; + var i = function() { + function i(t) { + this.attachments = new Array; + this.bones = Array(); + this.constraints = new Array; + if (null == t) throw new Error("name cannot be null."); + this.name = t; + } + i.prototype.setAttachment = function(t, e, i) { + if (null == i) throw new Error("attachment cannot be null."); + var s = this.attachments; + t >= s.length && (s.length = t + 1); + s[t] || (s[t] = {}); + s[t][e] = i; + }; + i.prototype.addSkin = function(t) { + for (var e = 0; e < t.bones.length; e++) { + var i = t.bones[e]; + var s = !1; + for (var n = 0; n < this.bones.length; n++) if (this.bones[n] == i) { + s = !0; + break; + } + s || this.bones.push(i); + } + for (e = 0; e < t.constraints.length; e++) { + var r = t.constraints[e]; + s = !1; + for (n = 0; n < this.constraints.length; n++) if (this.constraints[n] == r) { + s = !0; + break; + } + s || this.constraints.push(r); + } + var o = t.getAttachments(); + for (e = 0; e < o.length; e++) { + var a = o[e]; + this.setAttachment(a.slotIndex, a.name, a.attachment); + } + }; + i.prototype.copySkin = function(e) { + for (var i = 0; i < e.bones.length; i++) { + var s = e.bones[i]; + var n = !1; + for (var r = 0; r < this.bones.length; r++) if (this.bones[r] == s) { + n = !0; + break; + } + n || this.bones.push(s); + } + for (i = 0; i < e.constraints.length; i++) { + var o = e.constraints[i]; + n = !1; + for (r = 0; r < this.constraints.length; r++) if (this.constraints[r] == o) { + n = !0; + break; + } + n || this.constraints.push(o); + } + var a = e.getAttachments(); + for (i = 0; i < a.length; i++) { + var l = a[i]; + if (null != l.attachment) if (l.attachment instanceof t.MeshAttachment) { + l.attachment = l.attachment.newLinkedMesh(); + this.setAttachment(l.slotIndex, l.name, l.attachment); + } else { + l.attachment = l.attachment.copy(); + this.setAttachment(l.slotIndex, l.name, l.attachment); + } + } + }; + i.prototype.getAttachment = function(t, e) { + var i = this.attachments[t]; + return i ? i[e] : null; + }; + i.prototype.removeAttachment = function(t, e) { + var i = this.attachments[t]; + i && (i[e] = null); + }; + i.prototype.getAttachments = function() { + var t = new Array; + for (var i = 0; i < this.attachments.length; i++) { + var s = this.attachments[i]; + if (s) for (var n in s) { + var r = s[n]; + r && t.push(new e(i, n, r)); + } + } + return t; + }; + i.prototype.getAttachmentsForSlot = function(t, i) { + var s = this.attachments[t]; + if (s) for (var n in s) { + var r = s[n]; + r && i.push(new e(t, n, r)); + } + }; + i.prototype.clear = function() { + this.attachments.length = 0; + this.bones.length = 0; + this.constraints.length = 0; + }; + i.prototype.attachAll = function(t, e) { + var i = 0; + for (var s = 0; s < t.slots.length; s++) { + var n = t.slots[s]; + var r = n.getAttachment(); + if (r && i < e.attachments.length) { + var o = e.attachments[i]; + for (var a in o) { + if (r == o[a]) { + var l = this.getAttachment(i, a); + null != l && n.setAttachment(l); + break; + } + } + } + i++; + } + }; + return i; + }(); + t.Skin = i; + }(TMt || (TMt = {})); + !function(t) { + var e = function() { + function e(e, i) { + this.deform = new Array; + if (null == e) throw new Error("data cannot be null."); + if (null == i) throw new Error("bone cannot be null."); + this.data = e; + this.bone = i; + this.color = new t.Color; + this.darkColor = null == e.darkColor ? null : new t.Color; + this.setToSetupPose(); + } + e.prototype.getSkeleton = function() { + return this.bone.skeleton; + }; + e.prototype.getAttachment = function() { + return this.attachment; + }; + e.prototype.setAttachment = function(t) { + if (this.attachment != t) { + this.attachment = t; + this.attachmentTime = this.bone.skeleton.time; + this.deform.length = 0; + } + }; + e.prototype.setAttachmentTime = function(t) { + this.attachmentTime = this.bone.skeleton.time - t; + }; + e.prototype.getAttachmentTime = function() { + return this.bone.skeleton.time - this.attachmentTime; + }; + e.prototype.setToSetupPose = function() { + this.color.setFromColor(this.data.color); + null != this.darkColor && this.darkColor.setFromColor(this.data.darkColor); + if (null == this.data.attachmentName) this.attachment = null; else { + this.attachment = null; + this.setAttachment(this.bone.skeleton.getAttachment(this.data.index, this.data.attachmentName)); + } + }; + return e; + }(); + t.Slot = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function(e, i, s) { + this.color = new t.Color(1, 1, 1, 1); + if (e < 0) throw new Error("index must be >= 0."); + if (null == i) throw new Error("name cannot be null."); + if (null == s) throw new Error("boneData cannot be null."); + this.index = e; + this.name = i; + this.boneData = s; + }; + t.SlotData = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function() { + function t(t) { + this._image = t; + } + t.prototype.getImage = function() { + return this._image; + }; + t.filterFromString = function(t) { + switch (t.toLowerCase()) { + case "nearest": + return i.Nearest; + + case "linear": + return i.Linear; + + case "mipmap": + return i.MipMap; + + case "mipmapnearestnearest": + return i.MipMapNearestNearest; + + case "mipmaplinearnearest": + return i.MipMapLinearNearest; + + case "mipmapnearestlinear": + return i.MipMapNearestLinear; + + case "mipmaplinearlinear": + return i.MipMapLinearLinear; + + default: + throw new Error("Unknown texture filter " + t); + } + }; + t.wrapFromString = function(t) { + switch (t.toLowerCase()) { + case "mirroredtepeat": + return s.MirroredRepeat; + + case "clamptoedge": + return s.ClampToEdge; + + case "repeat": + return s.Repeat; + + default: + throw new Error("Unknown texture wrap " + t); + } + }; + return t; + }(); + t.Texture = e; + var i; + !function(t) { + t[t.Nearest = 9728] = "Nearest"; + t[t.Linear = 9729] = "Linear"; + t[t.MipMap = 9987] = "MipMap"; + t[t.MipMapNearestNearest = 9984] = "MipMapNearestNearest"; + t[t.MipMapLinearNearest = 9985] = "MipMapLinearNearest"; + t[t.MipMapNearestLinear = 9986] = "MipMapNearestLinear"; + t[t.MipMapLinearLinear = 9987] = "MipMapLinearLinear"; + }(i = t.TextureFilter || (t.TextureFilter = {})); + var s; + !function(t) { + t[t.MirroredRepeat = 33648] = "MirroredRepeat"; + t[t.ClampToEdge = 33071] = "ClampToEdge"; + t[t.Repeat = 10497] = "Repeat"; + }(s = t.TextureWrap || (t.TextureWrap = {})); + var n = function() { + this.u = 0; + this.v = 0; + this.u2 = 0; + this.v2 = 0; + this.width = 0; + this.height = 0; + this.rotate = !1; + this.offsetX = 0; + this.offsetY = 0; + this.originalWidth = 0; + this.originalHeight = 0; + }; + t.TextureRegion = n; + var r = function(t) { + AMt(e, t); + function e() { + return null !== t && t.apply(this, arguments) || this; + } + e.prototype.setFilters = function(t, e) {}; + e.prototype.setWraps = function(t, e) {}; + e.prototype.dispose = function() {}; + return e; + }(e); + t.FakeTexture = r; + }(TMt || (TMt = {})); + !function(t) { + var e = function() { + function e(t, e) { + this.pages = new Array; + this.regions = new Array; + this.load(t, e); + } + e.prototype.load = function(e, r) { + if (null == r) throw new Error("textureLoader cannot be null."); + var o = new i(e); + var a = new Array(4); + var l = null; + for (;;) { + var h = o.readLine(); + if (null == h) break; + if (0 == (h = h.trim()).length) l = null; else if (l) { + var c = new n; + c.name = h; + c.page = l; + var u = o.readValue(); + "true" == u.toLocaleLowerCase() ? c.degrees = 90 : "false" == u.toLocaleLowerCase() ? c.degrees = 0 : c.degrees = parseFloat(u); + c.rotate = 90 == c.degrees; + o.readTuple(a); + var _ = parseInt(a[0]); + var d = parseInt(a[1]); + o.readTuple(a); + var p = parseInt(a[0]); + var m = parseInt(a[1]); + c.u = _ / l.width; + c.v = d / l.height; + if (c.rotate) { + c.u2 = (_ + m) / l.width; + c.v2 = (d + p) / l.height; + } else { + c.u2 = (_ + p) / l.width; + c.v2 = (d + m) / l.height; + } + c.x = _; + c.y = d; + c.width = Math.abs(p); + c.height = Math.abs(m); + 4 == o.readTuple(a) && 4 == o.readTuple(a) && o.readTuple(a); + c.originalWidth = parseInt(a[0]); + c.originalHeight = parseInt(a[1]); + o.readTuple(a); + c.offsetX = parseInt(a[0]); + c.offsetY = parseInt(a[1]); + c.index = parseInt(o.readValue()); + c.texture = l.texture; + this.regions.push(c); + } else { + (l = new s).name = h; + if (2 == o.readTuple(a)) { + l.width = parseInt(a[0]); + l.height = parseInt(a[1]); + o.readTuple(a); + } + o.readTuple(a); + l.minFilter = t.Texture.filterFromString(a[0]); + l.magFilter = t.Texture.filterFromString(a[1]); + var f = o.readValue(); + l.uWrap = t.TextureWrap.ClampToEdge; + l.vWrap = t.TextureWrap.ClampToEdge; + "x" == f ? l.uWrap = t.TextureWrap.Repeat : "y" == f ? l.vWrap = t.TextureWrap.Repeat : "xy" == f && (l.uWrap = l.vWrap = t.TextureWrap.Repeat); + l.texture = r(h); + l.texture.setFilters(l.minFilter, l.magFilter); + l.texture.setWraps(l.uWrap, l.vWrap); + l.width = l.texture.getImage().width; + l.height = l.texture.getImage().height; + this.pages.push(l); + } + } + }; + e.prototype.findRegion = function(t) { + for (var e = 0; e < this.regions.length; e++) if (this.regions[e].name == t) return this.regions[e]; + return null; + }; + e.prototype.dispose = function() { + for (var t = 0; t < this.pages.length; t++) this.pages[t].texture.dispose(); + }; + return e; + }(); + t.TextureAtlas = e; + var i = function() { + function t(t) { + this.index = 0; + this.lines = t.split(/\r\n|\r|\n/); + } + t.prototype.readLine = function() { + return this.index >= this.lines.length ? null : this.lines[this.index++]; + }; + t.prototype.readValue = function() { + var t = this.readLine(); + var e = t.indexOf(":"); + if (-1 == e) throw new Error("Invalid line: " + t); + return t.substring(e + 1).trim(); + }; + t.prototype.readTuple = function(t) { + var e = this.readLine(); + var i = e.indexOf(":"); + if (-1 == i) throw new Error("Invalid line: " + e); + var s = 0, n = i + 1; + for (;s < 3; s++) { + var r = e.indexOf(",", n); + if (-1 == r) break; + t[s] = e.substr(n, r - n).trim(); + n = r + 1; + } + t[s] = e.substring(n).trim(); + return s + 1; + }; + return t; + }(); + var s = function() {}; + t.TextureAtlasPage = s; + var n = function(t) { + AMt(e, t); + function e() { + return null !== t && t.apply(this, arguments) || this; + } + return e; + }(t.TextureRegion); + t.TextureAtlasRegion = n; + }(TMt || (TMt = {})); + !function(t) { + var e = function() { + function e(e, i) { + this.rotateMix = 0; + this.translateMix = 0; + this.scaleMix = 0; + this.shearMix = 0; + this.temp = new t.Vector2; + this.active = !1; + if (null == e) throw new Error("data cannot be null."); + if (null == i) throw new Error("skeleton cannot be null."); + this.data = e; + this.rotateMix = e.rotateMix; + this.translateMix = e.translateMix; + this.scaleMix = e.scaleMix; + this.shearMix = e.shearMix; + this.bones = new Array; + for (var s = 0; s < e.bones.length; s++) this.bones.push(i.findBone(e.bones[s].name)); + this.target = i.findBone(e.target.name); + } + e.prototype.isActive = function() { + return this.active; + }; + e.prototype.apply = function() { + this.update(); + }; + e.prototype.update = function() { + this.data.local ? this.data.relative ? this.applyRelativeLocal() : this.applyAbsoluteLocal() : this.data.relative ? this.applyRelativeWorld() : this.applyAbsoluteWorld(); + }; + e.prototype.applyAbsoluteWorld = function() { + var e = this.rotateMix, i = this.translateMix, s = this.scaleMix, n = this.shearMix; + var r = this.target; + var o = r.a, a = r.b, l = r.c, h = r.d; + var c = o * h - a * l > 0 ? t.MathUtils.degRad : -t.MathUtils.degRad; + var u = this.data.offsetRotation * c; + var _ = this.data.offsetShearY * c; + var d = this.bones; + for (var p = 0, m = d.length; p < m; p++) { + var f = d[p]; + var g = !1; + if (0 != e) { + var y = f.a, b = f.b, S = f.c, A = f.d; + (R = Math.atan2(l, o) - Math.atan2(S, y) + u) > t.MathUtils.PI ? R -= t.MathUtils.PI2 : R < -t.MathUtils.PI && (R += t.MathUtils.PI2); + R *= e; + var T = Math.cos(R), v = Math.sin(R); + f.a = T * y - v * S; + f.b = T * b - v * A; + f.c = v * y + T * S; + f.d = v * b + T * A; + g = !0; + } + if (0 != i) { + var E = this.temp; + r.localToWorld(E.set(this.data.offsetX, this.data.offsetY)); + f.worldX += (E.x - f.worldX) * i; + f.worldY += (E.y - f.worldY) * i; + g = !0; + } + if (s > 0) { + var C = Math.sqrt(f.a * f.a + f.c * f.c); + var x = Math.sqrt(o * o + l * l); + C > 1e-5 && (C = (C + (x - C + this.data.offsetScaleX) * s) / C); + f.a *= C; + f.c *= C; + C = Math.sqrt(f.b * f.b + f.d * f.d); + x = Math.sqrt(a * a + h * h); + C > 1e-5 && (C = (C + (x - C + this.data.offsetScaleY) * s) / C); + f.b *= C; + f.d *= C; + g = !0; + } + if (n > 0) { + b = f.b, A = f.d; + var w = Math.atan2(A, b); + var R; + (R = Math.atan2(h, a) - Math.atan2(l, o) - (w - Math.atan2(f.c, f.a))) > t.MathUtils.PI ? R -= t.MathUtils.PI2 : R < -t.MathUtils.PI && (R += t.MathUtils.PI2); + R = w + (R + _) * n; + C = Math.sqrt(b * b + A * A); + f.b = Math.cos(R) * C; + f.d = Math.sin(R) * C; + g = !0; + } + g && (f.appliedValid = !1); + } + }; + e.prototype.applyRelativeWorld = function() { + var e = this.rotateMix, i = this.translateMix, s = this.scaleMix, n = this.shearMix; + var r = this.target; + var o = r.a, a = r.b, l = r.c, h = r.d; + var c = o * h - a * l > 0 ? t.MathUtils.degRad : -t.MathUtils.degRad; + var u = this.data.offsetRotation * c, _ = this.data.offsetShearY * c; + var d = this.bones; + for (var p = 0, m = d.length; p < m; p++) { + var f = d[p]; + var g = !1; + if (0 != e) { + var y = f.a, b = f.b, S = f.c, A = f.d; + (x = Math.atan2(l, o) + u) > t.MathUtils.PI ? x -= t.MathUtils.PI2 : x < -t.MathUtils.PI && (x += t.MathUtils.PI2); + x *= e; + var T = Math.cos(x), v = Math.sin(x); + f.a = T * y - v * S; + f.b = T * b - v * A; + f.c = v * y + T * S; + f.d = v * b + T * A; + g = !0; + } + if (0 != i) { + var E = this.temp; + r.localToWorld(E.set(this.data.offsetX, this.data.offsetY)); + f.worldX += E.x * i; + f.worldY += E.y * i; + g = !0; + } + if (s > 0) { + var C = (Math.sqrt(o * o + l * l) - 1 + this.data.offsetScaleX) * s + 1; + f.a *= C; + f.c *= C; + C = (Math.sqrt(a * a + h * h) - 1 + this.data.offsetScaleY) * s + 1; + f.b *= C; + f.d *= C; + g = !0; + } + if (n > 0) { + var x; + (x = Math.atan2(h, a) - Math.atan2(l, o)) > t.MathUtils.PI ? x -= t.MathUtils.PI2 : x < -t.MathUtils.PI && (x += t.MathUtils.PI2); + b = f.b, A = f.d; + x = Math.atan2(A, b) + (x - t.MathUtils.PI / 2 + _) * n; + C = Math.sqrt(b * b + A * A); + f.b = Math.cos(x) * C; + f.d = Math.sin(x) * C; + g = !0; + } + g && (f.appliedValid = !1); + } + }; + e.prototype.applyAbsoluteLocal = function() { + var t = this.rotateMix, e = this.translateMix, i = this.scaleMix, s = this.shearMix; + var n = this.target; + n.appliedValid || n.updateAppliedTransform(); + var r = this.bones; + for (var o = 0, a = r.length; o < a; o++) { + var l = r[o]; + l.appliedValid || l.updateAppliedTransform(); + var h = l.arotation; + if (0 != t) { + var c = n.arotation - h + this.data.offsetRotation; + h += (c -= 360 * (16384 - (16384.499999999996 - c / 360 | 0))) * t; + } + var u = l.ax, _ = l.ay; + if (0 != e) { + u += (n.ax - u + this.data.offsetX) * e; + _ += (n.ay - _ + this.data.offsetY) * e; + } + var d = l.ascaleX, p = l.ascaleY; + if (0 != i) { + d > 1e-5 && (d = (d + (n.ascaleX - d + this.data.offsetScaleX) * i) / d); + p > 1e-5 && (p = (p + (n.ascaleY - p + this.data.offsetScaleY) * i) / p); + } + var m = l.ashearY; + if (0 != s) { + c = n.ashearY - m + this.data.offsetShearY; + c -= 360 * (16384 - (16384.499999999996 - c / 360 | 0)); + l.shearY += c * s; + } + l.updateWorldTransformWith(u, _, h, d, p, l.ashearX, m); + } + }; + e.prototype.applyRelativeLocal = function() { + var t = this.rotateMix, e = this.translateMix, i = this.scaleMix, s = this.shearMix; + var n = this.target; + n.appliedValid || n.updateAppliedTransform(); + var r = this.bones; + for (var o = 0, a = r.length; o < a; o++) { + var l = r[o]; + l.appliedValid || l.updateAppliedTransform(); + var h = l.arotation; + 0 != t && (h += (n.arotation + this.data.offsetRotation) * t); + var c = l.ax, u = l.ay; + if (0 != e) { + c += (n.ax + this.data.offsetX) * e; + u += (n.ay + this.data.offsetY) * e; + } + var _ = l.ascaleX, d = l.ascaleY; + if (0 != i) { + _ > 1e-5 && (_ *= (n.ascaleX - 1 + this.data.offsetScaleX) * i + 1); + d > 1e-5 && (d *= (n.ascaleY - 1 + this.data.offsetScaleY) * i + 1); + } + var p = l.ashearY; + 0 != s && (p += (n.ashearY + this.data.offsetShearY) * s); + l.updateWorldTransformWith(c, u, h, _, d, l.ashearX, p); + } + }; + return e; + }(); + t.TransformConstraint = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function(t) { + AMt(e, t); + function e(e) { + var i = t.call(this, e, 0, !1) || this; + i.bones = new Array; + i.rotateMix = 0; + i.translateMix = 0; + i.scaleMix = 0; + i.shearMix = 0; + i.offsetRotation = 0; + i.offsetX = 0; + i.offsetY = 0; + i.offsetScaleX = 0; + i.offsetScaleY = 0; + i.offsetShearY = 0; + i.relative = !1; + i.local = !1; + return i; + } + return e; + }(t.ConstraintData); + t.TransformConstraintData = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function() { + function e() { + this.convexPolygons = new Array; + this.convexPolygonsIndices = new Array; + this.indicesArray = new Array; + this.isConcaveArray = new Array; + this.triangles = new Array; + this.polygonPool = new t.Pool((function() { + return new Array; + })); + this.polygonIndicesPool = new t.Pool((function() { + return new Array; + })); + } + e.prototype.triangulate = function(t) { + var i = t; + var s = t.length >> 1; + var n = this.indicesArray; + n.length = 0; + for (var r = 0; r < s; r++) n[r] = r; + var o = this.isConcaveArray; + o.length = 0; + r = 0; + for (var a = s; r < a; ++r) o[r] = e.isConcave(r, s, i, n); + var l = this.triangles; + l.length = 0; + for (;s > 3; ) { + var h = s - 1, c = (r = 0, 1); + for (;;) { + t: if (!o[r]) { + var u = n[h] << 1, _ = n[r] << 1, d = n[c] << 1; + var p = i[u], m = i[u + 1]; + var f = i[_], g = i[_ + 1]; + var y = i[d], b = i[d + 1]; + for (var S = (c + 1) % s; S != h; S = (S + 1) % s) if (o[S]) { + var A = n[S] << 1; + var T = i[A], v = i[A + 1]; + if (e.positiveArea(y, b, p, m, T, v) && e.positiveArea(p, m, f, g, T, v) && e.positiveArea(f, g, y, b, T, v)) break t; + } + break; + } + if (0 == c) { + do { + if (!o[r]) break; + r--; + } while (r > 0); + break; + } + h = r; + r = c; + c = (c + 1) % s; + } + l.push(n[(s + r - 1) % s]); + l.push(n[r]); + l.push(n[(r + 1) % s]); + n.splice(r, 1); + o.splice(r, 1); + var E = (--s + r - 1) % s; + var C = r == s ? 0 : r; + o[E] = e.isConcave(E, s, i, n); + o[C] = e.isConcave(C, s, i, n); + } + if (3 == s) { + l.push(n[2]); + l.push(n[0]); + l.push(n[1]); + } + return l; + }; + e.prototype.decompose = function(t, i) { + var s = t; + var n = this.convexPolygons; + this.polygonPool.freeAll(n); + n.length = 0; + var r = this.convexPolygonsIndices; + this.polygonIndicesPool.freeAll(r); + r.length = 0; + var o = this.polygonIndicesPool.obtain(); + o.length = 0; + var a = this.polygonPool.obtain(); + a.length = 0; + var l = -1, h = 0; + for (var c = 0, u = i.length; c < u; c += 3) { + var _ = i[c] << 1, d = i[c + 1] << 1, p = i[c + 2] << 1; + var m = s[_], f = s[_ + 1]; + var g = s[d], y = s[d + 1]; + var b = s[p], S = s[p + 1]; + var A = !1; + if (l == _) { + var T = a.length - 4; + var v = e.winding(a[T], a[T + 1], a[T + 2], a[T + 3], b, S); + var E = e.winding(b, S, a[0], a[1], a[2], a[3]); + if (v == h && E == h) { + a.push(b); + a.push(S); + o.push(p); + A = !0; + } + } + if (!A) { + if (a.length > 0) { + n.push(a); + r.push(o); + } else { + this.polygonPool.free(a); + this.polygonIndicesPool.free(o); + } + (a = this.polygonPool.obtain()).length = 0; + a.push(m); + a.push(f); + a.push(g); + a.push(y); + a.push(b); + a.push(S); + (o = this.polygonIndicesPool.obtain()).length = 0; + o.push(_); + o.push(d); + o.push(p); + h = e.winding(m, f, g, y, b, S); + l = _; + } + } + if (a.length > 0) { + n.push(a); + r.push(o); + } + for (c = 0, u = n.length; c < u; c++) if (0 != (o = r[c]).length) { + var C = o[0]; + var x = o[o.length - 1]; + var w = (a = n[c])[T = a.length - 4], R = a[T + 1]; + var I = a[T + 2], M = a[T + 3]; + var B = a[0], D = a[1]; + var P = a[2], O = a[3]; + var N = e.winding(w, R, I, M, B, D); + for (var L = 0; L < u; L++) if (L != c) { + var F = r[L]; + if (3 == F.length) { + var V = F[0]; + var k = F[1]; + var U = F[2]; + var G = n[L]; + b = G[G.length - 2], S = G[G.length - 1]; + if (V == C && k == x) { + v = e.winding(w, R, I, M, b, S); + E = e.winding(b, S, B, D, P, O); + if (v == N && E == N) { + G.length = 0; + F.length = 0; + a.push(b); + a.push(S); + o.push(U); + w = I; + R = M; + I = b; + M = S; + L = 0; + } + } + } + } + } + for (c = n.length - 1; c >= 0; c--) if (0 == (a = n[c]).length) { + n.splice(c, 1); + this.polygonPool.free(a); + o = r[c]; + r.splice(c, 1); + this.polygonIndicesPool.free(o); + } + return n; + }; + e.isConcave = function(t, e, i, s) { + var n = s[(e + t - 1) % e] << 1; + var r = s[t] << 1; + var o = s[(t + 1) % e] << 1; + return !this.positiveArea(i[n], i[n + 1], i[r], i[r + 1], i[o], i[o + 1]); + }; + e.positiveArea = function(t, e, i, s, n, r) { + return t * (r - s) + i * (e - r) + n * (s - e) >= 0; + }; + e.winding = function(t, e, i, s, n, r) { + var o = i - t, a = s - e; + return n * a - r * o + o * e - t * a >= 0 ? 1 : -1; + }; + return e; + }(); + t.Triangulator = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function() { + function t() { + this.array = new Array; + } + t.prototype.add = function(t) { + var e = this.contains(t); + this.array[0 | t] = 0 | t; + return !e; + }; + t.prototype.contains = function(t) { + return null != this.array[0 | t]; + }; + t.prototype.remove = function(t) { + this.array[0 | t] = void 0; + }; + t.prototype.clear = function() { + this.array.length = 0; + }; + return t; + }(); + t.IntSet = e; + var i = function() { + function t(t, e, i, s) { + void 0 === t && (t = 0); + void 0 === e && (e = 0); + void 0 === i && (i = 0); + void 0 === s && (s = 0); + this.r = t; + this.g = e; + this.b = i; + this.a = s; + } + t.prototype.set = function(t, e, i, s) { + this.r = t; + this.g = e; + this.b = i; + this.a = s; + this.clamp(); + return this; + }; + t.prototype.setFromColor = function(t) { + this.r = t.r; + this.g = t.g; + this.b = t.b; + this.a = t.a; + return this; + }; + t.prototype.setFromString = function(t) { + t = "#" == t.charAt(0) ? t.substr(1) : t; + this.r = parseInt(t.substr(0, 2), 16) / 255; + this.g = parseInt(t.substr(2, 2), 16) / 255; + this.b = parseInt(t.substr(4, 2), 16) / 255; + this.a = (8 != t.length ? 255 : parseInt(t.substr(6, 2), 16)) / 255; + return this; + }; + t.prototype.add = function(t, e, i, s) { + this.r += t; + this.g += e; + this.b += i; + this.a += s; + this.clamp(); + return this; + }; + t.prototype.clamp = function() { + this.r < 0 ? this.r = 0 : this.r > 1 && (this.r = 1); + this.g < 0 ? this.g = 0 : this.g > 1 && (this.g = 1); + this.b < 0 ? this.b = 0 : this.b > 1 && (this.b = 1); + this.a < 0 ? this.a = 0 : this.a > 1 && (this.a = 1); + return this; + }; + t.rgba8888ToColor = function(t, e) { + t.r = ((4278190080 & e) >>> 24) / 255; + t.g = ((16711680 & e) >>> 16) / 255; + t.b = ((65280 & e) >>> 8) / 255; + t.a = (255 & e) / 255; + }; + t.rgb888ToColor = function(t, e) { + t.r = ((16711680 & e) >>> 16) / 255; + t.g = ((65280 & e) >>> 8) / 255; + t.b = (255 & e) / 255; + }; + t.WHITE = new t(1, 1, 1, 1); + t.RED = new t(1, 0, 0, 1); + t.GREEN = new t(0, 1, 0, 1); + t.BLUE = new t(0, 0, 1, 1); + t.MAGENTA = new t(1, 0, 1, 1); + return t; + }(); + t.Color = i; + var s = function() { + function t() {} + t.clamp = function(t, e, i) { + return t < e ? e : t > i ? i : t; + }; + t.cosDeg = function(e) { + return Math.cos(e * t.degRad); + }; + t.sinDeg = function(e) { + return Math.sin(e * t.degRad); + }; + t.signum = function(t) { + return t > 0 ? 1 : t < 0 ? -1 : 0; + }; + t.toInt = function(t) { + return t > 0 ? Math.floor(t) : Math.ceil(t); + }; + t.cbrt = function(t) { + var e = Math.pow(Math.abs(t), 1 / 3); + return t < 0 ? -e : e; + }; + t.randomTriangular = function(e, i) { + return t.randomTriangularWith(e, i, .5 * (e + i)); + }; + t.randomTriangularWith = function(t, e, i) { + var s = Math.random(); + var n = e - t; + return s <= (i - t) / n ? t + Math.sqrt(s * n * (i - t)) : e - Math.sqrt((1 - s) * n * (e - i)); + }; + t.PI = 3.1415927; + t.PI2 = 2 * t.PI; + t.radiansToDegrees = 180 / t.PI; + t.radDeg = t.radiansToDegrees; + t.degreesToRadians = t.PI / 180; + t.degRad = t.degreesToRadians; + return t; + }(); + t.MathUtils = s; + var n = function() { + function t() {} + t.prototype.apply = function(t, e, i) { + return t + (e - t) * this.applyInternal(i); + }; + return t; + }(); + t.Interpolation = n; + var r = function(t) { + AMt(e, t); + function e(e) { + var i = t.call(this) || this; + i.power = 2; + i.power = e; + return i; + } + e.prototype.applyInternal = function(t) { + return t <= .5 ? Math.pow(2 * t, this.power) / 2 : Math.pow(2 * (t - 1), this.power) / (this.power % 2 == 0 ? -2 : 2) + 1; + }; + return e; + }(n); + t.Pow = r; + var o = function(t) { + AMt(e, t); + function e(e) { + return t.call(this, e) || this; + } + e.prototype.applyInternal = function(t) { + return Math.pow(t - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1; + }; + return e; + }(r); + t.PowOut = o; + var a = function() { + function t() {} + t.arrayCopy = function(t, e, i, s, n) { + for (var r = e, o = s; r < e + n; r++, o++) i[o] = t[r]; + }; + t.setArraySize = function(t, e, i) { + void 0 === i && (i = 0); + var s = t.length; + if (s == e) return t; + t.length = e; + if (s < e) for (var n = s; n < e; n++) t[n] = i; + return t; + }; + t.ensureArrayCapacity = function(e, i, s) { + void 0 === s && (s = 0); + return e.length >= i ? e : t.setArraySize(e, i, s); + }; + t.newArray = function(t, e) { + var i = new Array(t); + for (var s = 0; s < t; s++) i[s] = e; + return i; + }; + t.newFloatArray = function(e) { + if (t.SUPPORTS_TYPED_ARRAYS) return new Float32Array(e); + var i = new Array(e); + for (var s = 0; s < i.length; s++) i[s] = 0; + return i; + }; + t.newShortArray = function(e) { + if (t.SUPPORTS_TYPED_ARRAYS) return new Int16Array(e); + var i = new Array(e); + for (var s = 0; s < i.length; s++) i[s] = 0; + return i; + }; + t.toFloatArray = function(e) { + return t.SUPPORTS_TYPED_ARRAYS ? new Float32Array(e) : e; + }; + t.toSinglePrecision = function(e) { + return t.SUPPORTS_TYPED_ARRAYS ? Math.fround(e) : e; + }; + t.webkit602BugfixHelper = function(t, e) {}; + t.contains = function(t, e, i) { + for (var s = 0; s < t.length; s++) if (t[s] == e) return !0; + return !1; + }; + t.SUPPORTS_TYPED_ARRAYS = "undefined" != typeof Float32Array; + return t; + }(); + t.Utils = a; + var l = function() { + function t() {} + t.logBones = function(t) { + for (var e = 0; e < t.bones.length; e++) { + var i = t.bones[e]; + console.log(i.data.name + ", " + i.a + ", " + i.b + ", " + i.c + ", " + i.d + ", " + i.worldX + ", " + i.worldY); + } + }; + return t; + }(); + t.DebugUtils = l; + var h = function() { + function t(t) { + this.items = new Array; + this.instantiator = t; + } + t.prototype.obtain = function() { + return this.items.length > 0 ? this.items.pop() : this.instantiator(); + }; + t.prototype.free = function(t) { + t.reset && t.reset(); + this.items.push(t); + }; + t.prototype.freeAll = function(t) { + for (var e = 0; e < t.length; e++) { + t[e].reset && t[e].reset(); + this.items[e] = t[e]; + } + }; + t.prototype.clear = function() { + this.items.length = 0; + }; + return t; + }(); + t.Pool = h; + var c = function() { + function t(t, e) { + void 0 === t && (t = 0); + void 0 === e && (e = 0); + this.x = t; + this.y = e; + } + t.prototype.set = function(t, e) { + this.x = t; + this.y = e; + return this; + }; + t.prototype.length = function() { + var t = this.x; + var e = this.y; + return Math.sqrt(t * t + e * e); + }; + t.prototype.normalize = function() { + var t = this.length(); + if (0 != t) { + this.x /= t; + this.y /= t; + } + return this; + }; + return t; + }(); + t.Vector2 = c; + var u = function() { + function t() { + this.maxDelta = .064; + this.framesPerSecond = 0; + this.delta = 0; + this.totalTime = 0; + this.lastTime = Date.now() / 1e3; + this.frameCount = 0; + this.frameTime = 0; + } + t.prototype.update = function() { + var t = Date.now() / 1e3; + this.delta = t - this.lastTime; + this.frameTime += this.delta; + this.totalTime += this.delta; + this.delta > this.maxDelta && (this.delta = this.maxDelta); + this.lastTime = t; + this.frameCount++; + if (this.frameTime > 1) { + this.framesPerSecond = this.frameCount / this.frameTime; + this.frameTime = 0; + this.frameCount = 0; + } + }; + return t; + }(); + t.TimeKeeper = u; + var _ = function() { + function t(t) { + void 0 === t && (t = 32); + this.addedValues = 0; + this.lastValue = 0; + this.mean = 0; + this.dirty = !0; + this.values = new Array(t); + } + t.prototype.hasEnoughData = function() { + return this.addedValues >= this.values.length; + }; + t.prototype.addValue = function(t) { + this.addedValues < this.values.length && this.addedValues++; + this.values[this.lastValue++] = t; + this.lastValue > this.values.length - 1 && (this.lastValue = 0); + this.dirty = !0; + }; + t.prototype.getMean = function() { + if (this.hasEnoughData()) { + if (this.dirty) { + var t = 0; + for (var e = 0; e < this.values.length; e++) t += this.values[e]; + this.mean = t / this.values.length; + this.dirty = !1; + } + return this.mean; + } + return 0; + }; + return t; + }(); + t.WindowedMean = _; + }(TMt || (TMt = {})); + Math.fround || (Math.fround = function(t) { + return function(e) { + return t[0] = e, t[0]; + }; + }(new Float32Array(1))); + !function(t) { + var e = function(t) { + if (null == t) throw new Error("name cannot be null."); + this.name = t; + }; + t.Attachment = e; + var i = function(e) { + AMt(i, e); + function i(t) { + var s = e.call(this, t) || this; + s.id = (65535 & i.nextID++) << 11; + s.worldVerticesLength = 0; + s.deformAttachment = s; + return s; + } + i.prototype.computeWorldVertices = function(t, e, i, s, n, r) { + i = n + (i >> 1) * r; + var o = t.bone.skeleton; + var a = t.deform; + var l = this.vertices; + var h = this.bones; + if (null != h) { + var c = 0, u = 0; + for (var _ = 0; _ < e; _ += 2) { + c += (f = h[c]) + 1; + u += f; + } + var d = o.bones; + if (0 == a.length) for (R = n, E = 3 * u; R < i; R += r) { + var p = 0, m = 0; + var f = h[c++]; + f += c; + for (;c < f; c++, E += 3) { + S = d[h[c]]; + I = l[E], M = l[E + 1]; + var g = l[E + 2]; + p += (I * S.a + M * S.b + S.worldX) * g; + m += (I * S.c + M * S.d + S.worldY) * g; + } + s[R] = p; + s[R + 1] = m; + } else { + var y = a; + R = n, E = 3 * u; + for (var b = u << 1; R < i; R += r) { + p = 0, m = 0; + f = h[c++]; + f += c; + for (;c < f; c++, E += 3, b += 2) { + S = d[h[c]]; + I = l[E] + y[b], M = l[E + 1] + y[b + 1], g = l[E + 2]; + p += (I * S.a + M * S.b + S.worldX) * g; + m += (I * S.c + M * S.d + S.worldY) * g; + } + s[R] = p; + s[R + 1] = m; + } + } + } else { + a.length > 0 && (l = a); + var S; + var A = (S = t.bone).worldX; + var T = S.worldY; + var v = S.a, E = S.b, C = S.c, x = S.d; + for (var w = e, R = n; R < i; w += 2, R += r) { + var I = l[w], M = l[w + 1]; + s[R] = I * v + M * E + A; + s[R + 1] = I * C + M * x + T; + } + } + }; + i.prototype.copyTo = function(e) { + if (null != this.bones) { + e.bones = new Array(this.bones.length); + t.Utils.arrayCopy(this.bones, 0, e.bones, 0, this.bones.length); + } else e.bones = null; + if (null != this.vertices) { + e.vertices = t.Utils.newFloatArray(this.vertices.length); + t.Utils.arrayCopy(this.vertices, 0, e.vertices, 0, this.vertices.length); + } else e.vertices = null; + e.worldVerticesLength = this.worldVerticesLength; + e.deformAttachment = this.deformAttachment; + }; + i.nextID = 0; + return i; + }(e); + t.VertexAttachment = i; + }(TMt || (TMt = {})); + !function(t) { + !function(t) { + t[t.Region = 0] = "Region"; + t[t.BoundingBox = 1] = "BoundingBox"; + t[t.Mesh = 2] = "Mesh"; + t[t.LinkedMesh = 3] = "LinkedMesh"; + t[t.Path = 4] = "Path"; + t[t.Point = 5] = "Point"; + t[t.Clipping = 6] = "Clipping"; + }(t.AttachmentType || (t.AttachmentType = {})); + }(TMt || (TMt = {})); + !function(t) { + var e = function(e) { + AMt(i, e); + function i(i) { + var s = e.call(this, i) || this; + s.color = new t.Color(1, 1, 1, 1); + return s; + } + i.prototype.copy = function() { + var t = new i(this.name); + this.copyTo(t); + t.color.setFromColor(this.color); + return t; + }; + return i; + }(t.VertexAttachment); + t.BoundingBoxAttachment = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function(e) { + AMt(i, e); + function i(i) { + var s = e.call(this, i) || this; + s.color = new t.Color(.2275, .2275, .8078, 1); + return s; + } + i.prototype.copy = function() { + var t = new i(this.name); + this.copyTo(t); + t.endSlot = this.endSlot; + t.color.setFromColor(this.color); + return t; + }; + return i; + }(t.VertexAttachment); + t.ClippingAttachment = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function(e) { + AMt(i, e); + function i(i) { + var s = e.call(this, i) || this; + s.color = new t.Color(1, 1, 1, 1); + s.tempColor = new t.Color(0, 0, 0, 0); + return s; + } + i.prototype.updateUVs = function() { + var e = this.regionUVs; + null != this.uvs && this.uvs.length == e.length || (this.uvs = t.Utils.newFloatArray(e.length)); + var i = this.uvs; + var s = this.uvs.length; + var n = this.region.u, r = this.region.v, o = 0, a = 0; + if (this.region instanceof t.TextureAtlasRegion) { + var l = this.region; + var h = l.texture.getImage().width, c = l.texture.getImage().height; + switch (l.degrees) { + case 90: + n -= (l.originalHeight - l.offsetY - l.height) / h; + r -= (l.originalWidth - l.offsetX - l.width) / c; + o = l.originalHeight / h; + a = l.originalWidth / c; + for (var u = 0; u < s; u += 2) { + i[u] = n + e[u + 1] * o; + i[u + 1] = r + (1 - e[u]) * a; + } + return; + + case 180: + n -= (l.originalWidth - l.offsetX - l.width) / h; + r -= l.offsetY / c; + o = l.originalWidth / h; + a = l.originalHeight / c; + for (u = 0; u < s; u += 2) { + i[u] = n + (1 - e[u]) * o; + i[u + 1] = r + (1 - e[u + 1]) * a; + } + return; + + case 270: + n -= l.offsetY / h; + r -= l.offsetX / c; + o = l.originalHeight / h; + a = l.originalWidth / c; + for (u = 0; u < s; u += 2) { + i[u] = n + (1 - e[u + 1]) * o; + i[u + 1] = r + e[u] * a; + } + return; + } + n -= l.offsetX / h; + r -= (l.originalHeight - l.offsetY - l.height) / c; + o = l.originalWidth / h; + a = l.originalHeight / c; + } else if (null == this.region) { + n = r = 0; + o = a = 1; + } else { + o = this.region.u2 - n; + a = this.region.v2 - r; + } + for (u = 0; u < s; u += 2) { + i[u] = n + e[u] * o; + i[u + 1] = r + e[u + 1] * a; + } + }; + i.prototype.getParentMesh = function() { + return this.parentMesh; + }; + i.prototype.setParentMesh = function(t) { + this.parentMesh = t; + if (null != t) { + this.bones = t.bones; + this.vertices = t.vertices; + this.worldVerticesLength = t.worldVerticesLength; + this.regionUVs = t.regionUVs; + this.triangles = t.triangles; + this.hullLength = t.hullLength; + this.worldVerticesLength = t.worldVerticesLength; + } + }; + i.prototype.copy = function() { + if (null != this.parentMesh) return this.newLinkedMesh(); + var e = new i(this.name); + e.region = this.region; + e.path = this.path; + e.color.setFromColor(this.color); + this.copyTo(e); + e.regionUVs = new Array(this.regionUVs.length); + t.Utils.arrayCopy(this.regionUVs, 0, e.regionUVs, 0, this.regionUVs.length); + e.uvs = new Array(this.uvs.length); + t.Utils.arrayCopy(this.uvs, 0, e.uvs, 0, this.uvs.length); + e.triangles = new Array(this.triangles.length); + t.Utils.arrayCopy(this.triangles, 0, e.triangles, 0, this.triangles.length); + e.hullLength = this.hullLength; + if (null != this.edges) { + e.edges = new Array(this.edges.length); + t.Utils.arrayCopy(this.edges, 0, e.edges, 0, this.edges.length); + } + e.width = this.width; + e.height = this.height; + return e; + }; + i.prototype.newLinkedMesh = function() { + var t = new i(this.name); + t.region = this.region; + t.path = this.path; + t.color.setFromColor(this.color); + t.deformAttachment = this.deformAttachment; + t.setParentMesh(null != this.parentMesh ? this.parentMesh : this); + t.updateUVs(); + return t; + }; + return i; + }(t.VertexAttachment); + t.MeshAttachment = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function(e) { + AMt(i, e); + function i(i) { + var s = e.call(this, i) || this; + s.closed = !1; + s.constantSpeed = !1; + s.color = new t.Color(1, 1, 1, 1); + return s; + } + i.prototype.copy = function() { + var e = new i(this.name); + this.copyTo(e); + e.lengths = new Array(this.lengths.length); + t.Utils.arrayCopy(this.lengths, 0, e.lengths, 0, this.lengths.length); + e.closed = closed; + e.constantSpeed = this.constantSpeed; + e.color.setFromColor(this.color); + return e; + }; + return i; + }(t.VertexAttachment); + t.PathAttachment = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function(e) { + AMt(i, e); + function i(i) { + var s = e.call(this, i) || this; + s.color = new t.Color(.38, .94, 0, 1); + return s; + } + i.prototype.computeWorldPosition = function(t, e) { + e.x = this.x * t.a + this.y * t.b + t.worldX; + e.y = this.x * t.c + this.y * t.d + t.worldY; + return e; + }; + i.prototype.computeWorldRotation = function(e) { + var i = t.MathUtils.cosDeg(this.rotation), s = t.MathUtils.sinDeg(this.rotation); + var n = i * e.a + s * e.b; + var r = i * e.c + s * e.d; + return Math.atan2(r, n) * t.MathUtils.radDeg; + }; + i.prototype.copy = function() { + var t = new i(this.name); + t.x = this.x; + t.y = this.y; + t.rotation = this.rotation; + t.color.setFromColor(this.color); + return t; + }; + return i; + }(t.VertexAttachment); + t.PointAttachment = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function(e) { + AMt(i, e); + function i(i) { + var s = e.call(this, i) || this; + s.x = 0; + s.y = 0; + s.scaleX = 1; + s.scaleY = 1; + s.rotation = 0; + s.width = 0; + s.height = 0; + s.color = new t.Color(1, 1, 1, 1); + s.offset = t.Utils.newFloatArray(8); + s.uvs = t.Utils.newFloatArray(8); + s.tempColor = new t.Color(1, 1, 1, 1); + return s; + } + i.prototype.updateOffset = function() { + var t = this.width / this.region.originalWidth * this.scaleX; + var e = this.height / this.region.originalHeight * this.scaleY; + var s = -this.width / 2 * this.scaleX + this.region.offsetX * t; + var n = -this.height / 2 * this.scaleY + this.region.offsetY * e; + var r = s + this.region.width * t; + var o = n + this.region.height * e; + var a = this.rotation * Math.PI / 180; + var l = Math.cos(a); + var h = Math.sin(a); + var c = s * l + this.x; + var u = s * h; + var _ = n * l + this.y; + var d = n * h; + var p = r * l + this.x; + var m = r * h; + var f = o * l + this.y; + var g = o * h; + var y = this.offset; + y[i.OX1] = c - d; + y[i.OY1] = _ + u; + y[i.OX2] = c - g; + y[i.OY2] = f + u; + y[i.OX3] = p - g; + y[i.OY3] = f + m; + y[i.OX4] = p - d; + y[i.OY4] = _ + m; + }; + i.prototype.setRegion = function(t) { + this.region = t; + var e = this.uvs; + if (t.rotate) { + e[2] = t.u; + e[3] = t.v2; + e[4] = t.u; + e[5] = t.v; + e[6] = t.u2; + e[7] = t.v; + e[0] = t.u2; + e[1] = t.v2; + } else { + e[0] = t.u; + e[1] = t.v2; + e[2] = t.u; + e[3] = t.v; + e[4] = t.u2; + e[5] = t.v; + e[6] = t.u2; + e[7] = t.v2; + } + }; + i.prototype.computeWorldVertices = function(t, e, s, n) { + var r = this.offset; + var o = t.worldX, a = t.worldY; + var l = t.a, h = t.b, c = t.c, u = t.d; + var _ = 0, d = 0; + _ = r[i.OX1]; + d = r[i.OY1]; + e[s] = _ * l + d * h + o; + e[s + 1] = _ * c + d * u + a; + s += n; + _ = r[i.OX2]; + d = r[i.OY2]; + e[s] = _ * l + d * h + o; + e[s + 1] = _ * c + d * u + a; + s += n; + _ = r[i.OX3]; + d = r[i.OY3]; + e[s] = _ * l + d * h + o; + e[s + 1] = _ * c + d * u + a; + s += n; + _ = r[i.OX4]; + d = r[i.OY4]; + e[s] = _ * l + d * h + o; + e[s + 1] = _ * c + d * u + a; + }; + i.prototype.copy = function() { + var e = new i(this.name); + e.region = this.region; + e.rendererObject = this.rendererObject; + e.path = this.path; + e.x = this.x; + e.y = this.y; + e.scaleX = this.scaleX; + e.scaleY = this.scaleY; + e.rotation = this.rotation; + e.width = this.width; + e.height = this.height; + t.Utils.arrayCopy(this.uvs, 0, e.uvs, 0, 8); + t.Utils.arrayCopy(this.offset, 0, e.offset, 0, 8); + e.color.setFromColor(this.color); + return e; + }; + i.OX1 = 0; + i.OY1 = 1; + i.OX2 = 2; + i.OY2 = 3; + i.OX3 = 4; + i.OY3 = 5; + i.OX4 = 6; + i.OY4 = 7; + i.X1 = 0; + i.Y1 = 1; + i.C1R = 2; + i.C1G = 3; + i.C1B = 4; + i.C1A = 5; + i.U1 = 6; + i.V1 = 7; + i.X2 = 8; + i.Y2 = 9; + i.C2R = 10; + i.C2G = 11; + i.C2B = 12; + i.C2A = 13; + i.U2 = 14; + i.V2 = 15; + i.X3 = 16; + i.Y3 = 17; + i.C3R = 18; + i.C3G = 19; + i.C3B = 20; + i.C3A = 21; + i.U3 = 22; + i.V3 = 23; + i.X4 = 24; + i.Y4 = 25; + i.C4R = 26; + i.C4G = 27; + i.C4B = 28; + i.C4A = 29; + i.U4 = 30; + i.V4 = 31; + return i; + }(t.Attachment); + t.RegionAttachment = e; + }(TMt || (TMt = {})); + !function(t) { + var e = function() { + function e(t, e) { + this.jitterX = 0; + this.jitterY = 0; + this.jitterX = t; + this.jitterY = e; + } + e.prototype.begin = function(t) {}; + e.prototype.transform = function(e, i, s, n) { + e.x += t.MathUtils.randomTriangular(-this.jitterX, this.jitterY); + e.y += t.MathUtils.randomTriangular(-this.jitterX, this.jitterY); + }; + e.prototype.end = function() {}; + return e; + }(); + t.JitterEffect = e; + }(TMt || (TMt = {})); + var TMt; + !function(t) { + var e = function() { + function e(t, e) { + this.centerX = 0; + this.centerY = 0; + this.radius = 0; + this.angle = 0; + this.worldX = 0; + this.worldY = 0; + this.radius = t; + this.interpolation = e; + } + e.prototype.begin = function(t) { + this.worldX = t.x + this.centerX; + this.worldY = t.y + this.centerY; + }; + e.prototype.transform = function(e, i, s, n) { + var r = this.angle * t.MathUtils.degreesToRadians; + var o = e.x - this.worldX; + var a = e.y - this.worldY; + var l = Math.sqrt(o * o + a * a); + if (l < this.radius) { + var h = this.interpolation.apply(0, r, (this.radius - l) / this.radius); + var c = Math.cos(h); + var u = Math.sin(h); + e.x = c * o - u * a + this.worldX; + e.y = u * o + c * a + this.worldY; + } + }; + e.prototype.end = function() {}; + e.interpolation = new t.PowOut(2); + return e; + }(); + t.SwirlEffect = e; + }(TMt || (TMt = {})); + var vMt = TMt; + const EMt = 1 / 60; + const CMt = []; + const xMt = []; + let wMt = 0; + let RMt = 0; + let IMt = 0; + let MMt = null; + let BMt = null; + let DMt = 0; + let PMt = 0; + let OMt = 0; + let NMt = 0; + let LMt = null; + let FMt = null; + let VMt = 0; + let kMt = 0; + let UMt; + let GMt; + let zMt; + let HMt; + let jMt; + let XMt; + const WMt = new vMt.Color(1, 1, 1, 1); + const YMt = new vMt.Color(1, 1, 1, 1); + const qMt = [ 0, 1, 2, 2, 3, 0 ]; + class KMt { + constructor() { + this.frames = []; + this.totalTime = 0; + this.isCompleted = !1; + this.maxVertexCount = 0; + this.maxIndexCount = 0; + this._privateMode = !1; + this._inited = !1; + this._invalid = !0; + this._enableCacheAttachedInfo = !1; + this._frameIdx = -1; + this._skeletonInfo = null; + this._animationName = null; + this._tempSegments = null; + this._tempColors = null; + this._tempBoneInfos = null; + this._privateMode = !1; + this._inited = !1; + this._invalid = !0; + this._enableCacheAttachedInfo = !1; + this.frames = []; + this.totalTime = 0; + this._frameIdx = -1; + this.isCompleted = !1; + this._skeletonInfo = null; + this._animationName = null; + this._tempSegments = null; + this._tempColors = null; + this._tempBoneInfos = null; + } + init(t, e) { + this._inited = !0; + this._animationName = e; + this._skeletonInfo = t; + } + clear() { + this._inited = !1; + for (let t = 0, e = this.frames.length; t < e; t++) { + this.frames[t].segments.length = 0; + } + this.invalidAllFrame(); + } + bind(t) { + t.complete = t => { + t && t.animation.name === this._animationName && (this.isCompleted = !0); + }; + } + unbind(t) { + t.complete = null; + } + begin() { + if (!this._invalid) return; + const t = this._skeletonInfo; + const e = null == t ? void 0 : t.curAnimationCache; + e && e !== this && (this._privateMode ? e.invalidAllFrame() : e.updateToFrame()); + const i = null == t ? void 0 : t.skeleton; + const s = null == t ? void 0 : t.listener; + const n = null == t ? void 0 : t.state; + const r = null == i ? void 0 : i.data.findAnimation(this._animationName); + null == n || n.setAnimationWith(0, r, !1); + this.bind(s); + t.curAnimationCache = this; + this._frameIdx = -1; + this.isCompleted = !1; + this.totalTime = 0; + this._invalid = !1; + } + end() { + if (!this.needToUpdate()) { + this._skeletonInfo.curAnimationCache = null; + this.frames.length = this._frameIdx + 1; + this.isCompleted = !0; + this.unbind(this._skeletonInfo.listener); + } + } + updateToFrame(t) { + if (!this._inited) return; + this.begin(); + if (!this.needToUpdate(t)) return; + const e = this._skeletonInfo; + const i = null == e ? void 0 : e.skeleton; + const s = null == e ? void 0 : e.clipper; + const n = null == e ? void 0 : e.state; + do { + null == i || i.update(EMt); + null == n || n.update(EMt); + null == n || n.apply(i); + null == i || i.updateWorldTransform(); + this._frameIdx++; + this.updateFrame(i, s, this._frameIdx); + this.totalTime += EMt; + } while (this.needToUpdate(t)); + this.end(); + } + isInited() { + return this._inited; + } + isInvalid() { + return this._invalid; + } + invalidAllFrame() { + this.isCompleted = !1; + this._invalid = !0; + } + updateAllFrame() { + this.invalidAllFrame(); + this.updateToFrame(); + } + enableCacheAttachedInfo() { + if (!this._enableCacheAttachedInfo) { + this._enableCacheAttachedInfo = !0; + this.invalidAllFrame(); + } + } + fillVertices(t, e, i, s, n) { + HMt = i.a * e.a * t.a * 255; + UMt = e.r * t.r * 255; + GMt = e.g * t.g * 255; + zMt = e.b * t.b * 255; + WMt.r = UMt * i.r; + WMt.g = GMt * i.g; + WMt.b = zMt * i.b; + WMt.a = HMt; + if (null == n.darkColor) YMt.set(0, 0, 0, 1); else { + YMt.r = n.darkColor.r * UMt; + YMt.g = n.darkColor.g * GMt; + YMt.b = n.darkColor.b * zMt; + } + YMt.a = 0; + jMt = (WMt.a << 24 >>> 0) + (WMt.b << 16) + (WMt.g << 8) + WMt.r; + XMt = (YMt.a << 24 >>> 0) + (YMt.b << 16) + (YMt.g << 8) + YMt.r; + if (LMt !== jMt || FMt !== XMt) { + const t = this._tempColors; + LMt = jMt; + FMt = XMt; + NMt > 0 && (t[NMt - 1].vfOffset = IMt); + t[NMt++] = { + fr: WMt.r, + fg: WMt.g, + fb: WMt.b, + fa: WMt.a, + dr: YMt.r, + dg: YMt.g, + db: YMt.b, + da: YMt.a, + vfOffset: 0 + }; + } + if (s.isClipping()) { + s.clipTriangles(CMt, VMt, xMt, kMt, CMt, WMt, YMt, !0, 6, IMt, IMt + 2); + const t = s.clippedVertices; + const e = s.clippedTriangles; + kMt = e.length; + VMt = t.length / 12 * 6; + for (let t = 0, i = RMt, s = e.length; t < s; ) xMt[i++] = e[t++]; + for (let e = 0, i = t.length, s = IMt; e < i; e += 12, s += 6) { + CMt[s] = t[e]; + CMt[s + 1] = t[e + 1]; + CMt[s + 2] = t[e + 6]; + CMt[s + 3] = t[e + 7]; + CMt[s + 4] = jMt; + CMt[s + 5] = XMt; + } + } else for (let t = IMt, e = IMt + VMt; t < e; t += 6) { + CMt[t + 4] = jMt; + CMt[t + 5] = XMt; + } + } + updateFrame(t, e, i) { + IMt = 0; + wMt = 0; + RMt = 0; + MMt = null; + BMt = null; + DMt = 0; + PMt = 0; + OMt = 0; + NMt = 0; + LMt = null; + FMt = null; + this.frames[i] = this.frames[i] || { + segments: [], + colors: [], + boneInfos: [], + vertices: null, + uintVert: null, + indices: null + }; + const s = this.frames[i]; + const n = this._tempSegments = s.segments; + const r = this._tempColors = s.colors; + const o = this._tempBoneInfos = s.boneInfos; + this.traverseSkeleton(t, e); + NMt > 0 && (r[NMt - 1].vfOffset = IMt); + r.length = NMt; + o.length = wMt; + const a = OMt - 1; + if (a >= 0) if (PMt > 0) { + const t = n[a]; + t.indexCount = PMt; + t.vfCount = 7 * DMt; + t.vertexCount = DMt; + n.length = OMt; + } else n.length = OMt - 1; + if (0 === n.length) return; + let l = s.vertices; + const h = IMt / 6; + const c = 7 * h; + (!l || l.length < c) && (l = s.vertices = new Float32Array(c)); + const u = new Uint32Array(l.buffer); + for (let t = 0, e = 0; t < c; ) { + l[t] = CMt[e++]; + l[t + 1] = CMt[e++]; + l[t + 3] = CMt[e++]; + l[t + 4] = CMt[e++]; + u[t + 5] = CMt[e++]; + u[t + 6] = CMt[e++]; + t += 7; + } + let _ = s.indices; + (!_ || _.length < RMt) && (_ = s.indices = new Uint16Array(RMt)); + for (let t = 0; t < RMt; t++) _[t] = xMt[t]; + s.vertices = l; + s.indices = _; + this.maxVertexCount = h > this.maxVertexCount ? h : this.maxVertexCount; + this.maxIndexCount = _.length > this.maxIndexCount ? _.length : this.maxIndexCount; + } + needToUpdate(t) { + return !this.isCompleted && this.totalTime < 30 && (void 0 === t || this._frameIdx < t); + } + traverseSkeleton(t, e) { + const i = this._tempSegments; + const s = this._tempBoneInfos; + const n = t.color; + let r; + let o; + let a; + let l; + let h; + let c; + let u; + let _; + let d; + let p; + let m; + let f; + let g; + const y = t.bones; + if (this._enableCacheAttachedInfo) for (let t = 0, e = y.length; t < e; t++, wMt++) { + const e = y[t]; + let i = s[wMt]; + i || (i = s[wMt] = {}); + i.a = e.a; + i.b = e.b; + i.c = e.c; + i.d = e.d; + i.worldX = e.worldX; + i.worldY = e.worldY; + } + for (let s = 0, y = t.drawOrder.length; s < y; s++) { + g = t.drawOrder[s]; + if (g.bone.active) { + VMt = 0; + kMt = 0; + r = g.getAttachment(); + if (r) { + c = r instanceof vMt.RegionAttachment; + u = r instanceof vMt.MeshAttachment; + _ = r instanceof vMt.ClippingAttachment; + if (_) e.clipStart(g, r); else if (c || u) { + d = r.region.texture.getRealTexture(); + if (d) { + f = g.data.blendMode; + if (MMt !== d.getId() || BMt !== f) { + MMt = d.getId(); + BMt = f; + p = OMt - 1; + if (p >= 0) if (PMt > 0) { + m = i[p]; + m.indexCount = PMt; + m.vertexCount = DMt; + m.vfCount = 7 * DMt; + } else OMt--; + i[OMt] = { + tex: d, + blendMode: f, + indexCount: 0, + vertexCount: 0, + vfCount: 0 + }; + OMt++; + PMt = 0; + DMt = 0; + } + if (c) { + h = qMt; + VMt = 24; + kMt = 6; + r.computeWorldVertices(g.bone, CMt, IMt, 6); + } else if (u) { + const t = r; + h = t.triangles; + VMt = 6 * (t.worldVerticesLength >> 1); + kMt = h.length; + t.computeWorldVertices(g, 0, t.worldVerticesLength, CMt, IMt, 6); + } + if (0 !== VMt && 0 !== kMt) { + for (let t = 0, e = RMt, i = h.length; t < i; ) xMt[e++] = h[t++]; + l = r.uvs; + for (let t = IMt, e = IMt + VMt, i = 0; t < e; t += 6, i += 2) { + CMt[t + 2] = l[i]; + CMt[t + 3] = l[i + 1]; + } + o = r.color; + a = g.color; + this.fillVertices(n, o, a, e, g); + if (kMt > 0) { + for (let t = RMt, e = RMt + kMt; t < e; t++) xMt[t] += DMt; + RMt += kMt; + IMt += VMt; + PMt += kMt; + DMt += VMt / 6; + } + e.clipEndWithSlot(g); + } else e.clipEndWithSlot(g); + } else e.clipEndWithSlot(g); + } else e.clipEndWithSlot(g); + } else e.clipEndWithSlot(g); + } + } + e.clipEnd(); + } + } + class JMt { + constructor() { + this._privateMode = void 0; + this._skeletonCache = void 0; + this._animationPool = void 0; + this._privateMode = !1; + this._animationPool = {}; + this._skeletonCache = {}; + } + enablePrivateMode() { + this._privateMode = !0; + } + clear() { + this._animationPool = {}; + this._skeletonCache = {}; + } + removeSkeleton(t) { + const e = this._skeletonCache[t]; + if (!e) return; + const i = e.animationsCache; + for (const e in i) { + const s = i[e]; + if (s) { + this._animationPool[`${t}#${e}`] = s; + s.clear(); + } + } + delete this._skeletonCache[t]; + } + getSkeletonCache(t, e) { + let i = this._skeletonCache[t]; + if (!i) { + const s = new vMt.Skeleton(e); + const n = new vMt.SkeletonClipping; + const r = new vMt.AnimationStateData(s.data); + const o = new vMt.AnimationState(r); + const a = new SMt; + o.addListener(a); + this._skeletonCache[t] = i = { + skeleton: s, + clipper: n, + state: o, + listener: a, + animationsCache: {}, + curAnimationCache: null + }; + } + return i; + } + getAnimationCache(t, e) { + const i = this._skeletonCache[t]; + if (!i) return null; + return i.animationsCache[e]; + } + invalidAnimationCache(t) { + const e = this._skeletonCache[t]; + if (!(e && e.skeleton)) return; + const i = e.animationsCache; + for (const t in i) { + i[t].invalidAllFrame(); + } + } + initAnimationCache(t, e) { + if (!e) return null; + const i = this._skeletonCache[t]; + const s = i && i.skeleton; + if (!s) return null; + if (!s.data.findAnimation(e)) return null; + const n = i.animationsCache; + let r = n[e]; + if (!r) { + const s = `${t}#${e}`; + r = this._animationPool[s]; + if (r) delete this._animationPool[s]; else { + r = new KMt; + r._privateMode = this._privateMode; + } + r.init(i, e); + n[e] = r; + } + return r; + } + updateAnimationCache(t, e) { + if (e) { + const i = this.initAnimationCache(t, e); + if (!i) return; + i.updateAllFrame(); + } else { + const e = this._skeletonCache[t]; + if (!(e && e.skeleton)) return; + const i = e.animationsCache; + for (const t in i) { + i[t].updateAllFrame(); + } + } + } + } + JMt.FrameTime = EMt; + JMt.sharedCache = new JMt; + const ZMt = new qi; + class QMt { + constructor() { + this._inited = !1; + this._skeleton = null; + this._skeletonNode = null; + this._skeletonComp = null; + this._inited = !1; + this._skeleton = null; + this._skeletonNode = null; + this._skeletonComp = null; + } + init(t) { + this._inited = !0; + this._skeleton = t._skeleton; + this._skeletonNode = t.node; + this._skeletonComp = t; + } + reset() { + this._inited = !1; + this._skeleton = null; + this._skeletonNode = null; + this._skeletonComp = null; + } + _syncAttachedNode() { + if (!this._inited) return; + const t = this._skeletonComp.socketNodes; + if (0 === t.size) return; + let e = null; + e = this._skeletonComp.isAnimationCached() ? this._skeletonComp._curFrame && this._skeletonComp._curFrame.boneInfos : this._skeleton.bones; + if (!e) return; + const i = (t, e) => { + const i = ZMt; + i.m00 = e.a; + i.m01 = e.c; + i.m04 = e.b; + i.m05 = e.d; + i.m12 = e.worldX; + i.m13 = e.worldY; + t.matrix = ZMt; + }; + for (const s of t.keys()) { + const n = t.get(s); + if (!n || !n.isValid) { + t.delete(s); + continue; + } + const r = e[s]; + if (r) i(n, r); else { + n.removeFromParent(); + n.destroy(); + t.delete(s); + } + } + } + } + class $Mt extends vMt.Texture { + constructor(t) { + super(t); + this.name = "sp.SkeletonTexture"; + this._texture = null; + this._material = null; + } + setRealTexture(t) { + this._texture = t; + } + getRealTexture() { + return this._texture; + } + setFilters(t, e) { + this._texture && this.getRealTexture().setFilters(tBt(t), tBt(e)); + } + setWraps(t, e) { + this._texture && this.getRealTexture().setWrapMode(eBt(t), eBt(e)); + } + dispose() {} + } + function tBt(t) { + switch (t) { + case vMt.TextureFilter.Nearest: + case vMt.TextureFilter.MipMapNearestNearest: + case vMt.TextureFilter.MipMapLinearNearest: + return Qp.NEAREST; + + case vMt.TextureFilter.MipMap: + case vMt.TextureFilter.MipMapNearestLinear: + case vMt.TextureFilter.MipMapLinearLinear: + case vMt.TextureFilter.Linear: + default: + return Qp.LINEAR; + } + } + function eBt(t) { + switch (t) { + case vMt.TextureWrap.MirroredRepeat: + return Zp.MIRRORED_REPEAT; + + case vMt.TextureWrap.ClampToEdge: + return Zp.CLAMP_TO_EDGE; + + case vMt.TextureWrap.Repeat: + default: + return Zp.REPEAT; + } + } + var iBt, sBt, nBt, rBt, oBt, aBt, lBt, hBt, cBt, uBt, _Bt; + let dBt = (iBt = Ul("sp.SkeletonData"), sBt = Th([ LC ]), nBt = Th([ Fe ]), iBt(rBt = (oBt = (_Bt = class extends gc { + get skeletonJsonStr() { + return this._skeletonJson ? JSON.stringify(this._skeletonJson) : ""; + } + get skeletonJson() { + return this._skeletonJson; + } + set skeletonJson(t) { + this.reset(); + this._skeletonJson = "string" == typeof t ? JSON.parse(t) : t; + !this._uuid && t.skeleton && (this._uuid = t.skeleton.hash); + } + get atlasText() { + return this._atlasText; + } + set atlasText(t) { + this._atlasText = t; + this.reset(); + } + get _nativeAsset() { + return this._buffer; + } + set _nativeAsset(t) { + this._buffer = t; + this.reset(); + } + constructor() { + super(); + Ml(this, "_skeletonJson", aBt, this); + Ml(this, "textures", lBt, this); + Ml(this, "textureNames", hBt, this); + Ml(this, "scale", cBt, this); + Ml(this, "_atlasText", uBt, this); + this._buffer = void 0; + this._skeletonCache = null; + this._atlasCache = null; + this._skinsEnum = null; + this._animsEnum = null; + this.reset(); + } + createNode(t) { + const e = new _y(this.name); + e.addComponent("cc.Skeleton").skeletonData = this; + return t(null, e); + } + reset() { + this._skeletonCache = null; + this._atlasCache = null; + } + resetEnums() {} + getRuntimeData(t) { + if (this._skeletonCache) return this._skeletonCache; + if (!(this.textures && this.textures.length > 0) && this.textureNames && this.textureNames.length > 0) { + t || console.error(`${this.name} no textures found!`); + return null; + } + const e = this._getAtlas(t); + if (!e) return null; + const i = new vMt.AtlasAttachmentLoader(e); + let s = null; + let n = null; + if (this.skeletonJson) { + n = new vMt.SkeletonJson(i); + s = this.skeletonJson; + } else { + n = new vMt.SkeletonBinary(i); + s = new Uint8Array(this._nativeAsset); + } + n.scale = this.scale; + this._skeletonCache = n.readSkeletonData(s); + e.dispose(); + return this._skeletonCache; + } + getSkinsEnum() { + if (this._skinsEnum) return this._skinsEnum; + const t = this.getRuntimeData(!0); + if (t) { + const e = t.skins; + const i = {}; + for (let t = 0; t < e.length; t++) { + i[e[t].name] = t; + } + return this._skinsEnum = oe(i); + } + return null; + } + getAnimsEnum() { + if (this._animsEnum && Object.keys(this._animsEnum).length > 1) return this._animsEnum; + const t = this.getRuntimeData(!0); + if (t) { + const e = { + "": 0 + }; + const i = t.animations; + for (let t = 0; t < i.length; t++) { + e[i[t].name] = t + 1; + } + return this._animsEnum = oe(e); + } + return null; + } + destroy() { + JMt.sharedCache.removeSkeleton(this._uuid); + return super.destroy(); + } + _getTexture(t) { + const e = this.textureNames; + for (let i = 0; i < e.length; i++) if (e[i] === t) { + const t = this.textures[i]; + const e = new $Mt({ + width: t.width, + height: t.height + }); + e.setRealTexture(t); + return e; + } + console.error(`${this.name} no textures found!`); + return null; + } + _getAtlas(t) { + if (this._atlasCache) return this._atlasCache; + if (!this.atlasText) { + t || console.error(`${this.name} no atlas found!`); + return null; + } + return this._atlasCache = new vMt.TextureAtlas(this.atlasText, this._getTexture.bind(this)); + } + }, _Bt), aBt = Bl(oBt.prototype, "_skeletonJson", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), lBt = Bl(oBt.prototype, "textures", [ Yl, sBt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), hBt = Bl(oBt.prototype, "textureNames", [ Yl, nBt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), cBt = Bl(oBt.prototype, "scale", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), uBt = Bl(oBt.prototype, "_atlasText", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), oBt)) || rBt); + m.internal.SpineSkeletonData = dBt; + class pBt extends Tg { + constructor() { + super(); + this._skeletons = new Set; + } + static getInstance() { + if (!pBt._instance) { + pBt._instance = new pBt; + IR.registerSystem(pBt.ID, pBt._instance, Tg.Priority.HIGH); + } + return pBt._instance; + } + add(t) { + t && (this._skeletons.has(t) || this._skeletons.add(t)); + } + remove(t) { + t && this._skeletons.has(t) && this._skeletons.delete(t); + } + postUpdate(t) { + this._skeletons && this._skeletons.forEach((e => { + e.updateAnimation(t); + })); + } + prepareRenderData() { + this._skeletons && this._skeletons.forEach((t => { + t.markForUpdateRenderData(); + })); + } + } + pBt.ID = "SKELETON"; + pBt._instance = void 0; + m.internal.SpineSkeletonSystem = pBt; + var mBt, fBt, gBt, yBt, bBt, SBt, ABt, TBt, vBt, EBt, CBt, xBt, wBt, RBt, IBt, MBt, BBt, DBt, PBt, OBt, NBt, LBt, FBt, VBt, kBt, UBt, GBt, zBt, HBt, jBt, XBt, WBt, YBt, qBt, KBt, JBt, ZBt, QBt, $Bt, tDt, eDt, iDt, sDt, nDt, rDt, oDt, aDt, lDt, hDt, cDt, uDt, _Dt; + let dDt; + !function(t) { + t[t.default = 0] = "default"; + }(dDt || (dDt = {})); + he(dDt); + let pDt; + !function(t) { + t[t[""] = 0] = ""; + }(pDt || (pDt = {})); + he(pDt); + let mDt; + !function(t) { + t[t.REALTIME = 0] = "REALTIME"; + t[t.SHARED_CACHE = 1] = "SHARED_CACHE"; + t[t.PRIVATE_CACHE = 2] = "PRIVATE_CACHE"; + }(mDt || (mDt = {})); + he(mDt); + function fDt(t, e, i) { + si.Attr.setClassAttr(t, e, "type", "Enum"); + si.Attr.setClassAttr(t, e, "enumList", oe.getList(i)); + } + let gDt; + !function(t) { + t[t.COLORED_TEXTURED = 0] = "COLORED_TEXTURED"; + t[t.TWO_COLORED = 1] = "TWO_COLORED"; + }(gDt || (gDt = {})); + let yDt = (mBt = Ul("sp.Skeleton.SpineSocket"), fBt = Th(_y), mBt(gBt = (yBt = (ABt = class { + constructor(t = "", e = null) { + Ml(this, "path", bBt, this); + Ml(this, "target", SBt, this); + this.path = t; + this.target = e; + } + }, ABt), bBt = Bl(yBt.prototype, "path", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), SBt = Bl(yBt.prototype, "target", [ fBt, nh, Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), yBt)) || gBt); + ee.setClassAlias(yDt, "sp.Skeleton.SpineSocket"); + let bDt = (TBt = Ul("sp.Skeleton"), vBt = sh(), EBt = $l(), CBt = Th(hm), xBt = ph(), + wBt = ah(), RBt = Th(dBt), IBt = ah(), MBt = Th(dDt), BBt = lh(), DBt = ah(), PBt = Th(pDt), + OBt = lh(), NBt = ah(), LBt = lh(), FBt = Th(mDt), VBt = lh(), kBt = lh(), UBt = lh(), + GBt = lh(), zBt = lh(), HBt = lh(), jBt = lh(), XBt = Th([ yDt ]), WBt = lh(), YBt = rh(), + qBt = rh(), TBt(KBt = vBt(KBt = EBt(KBt = Ql(KBt = (JBt = (_Dt = uDt = class t extends uD { + get drawList() { + return this._drawList; + } + get customMaterial() { + return this._customMaterial; + } + set customMaterial(t) { + this._customMaterial = t; + this._cleanMaterialCache(); + this.setMaterial(this._customMaterial, 0); + this.markForUpdateRenderData(); + } + get paused() { + return this._paused; + } + set paused(t) { + this._paused = t; + } + get skeletonData() { + return this._skeletonData; + } + set skeletonData(t) { + t && t.resetEnums(); + if (this._skeletonData !== t) { + this.destroyRenderData(); + this._skeletonData = t; + this._needUpdateSkeltonData = !0; + this.defaultSkin = ""; + this.defaultAnimation = ""; + this._updateSkeletonData(); + } + } + get animation() { + if (this.isAnimationCached()) return this._animationName; + const t = this.getCurrent(0); + return t && t.animation.name || ""; + } + set animation(t) { + if (t) { + this.setAnimation(0, t, this.loop); + this.markForUpdateRenderData(); + } else if (!this.isAnimationCached()) { + this.clearTrack(0); + this.setToSetupPose(); + } + } + get _defaultSkinIndex() { + if (this.skeletonData) { + const t = this.skeletonData.getSkinsEnum(); + if (t) if ("" === this.defaultSkin) { + if (t.hasOwnProperty(0)) { + this._defaultSkinIndex = 0; + return 0; + } + } else { + const e = t[this.defaultSkin]; + if (void 0 !== e) return e; + } + } + return 0; + } + set _defaultSkinIndex(t) { + let e; + this.skeletonData && (e = this.skeletonData.getSkinsEnum()); + if (!e) { + console.error(`${this.name} skin enums are invalid`); + return; + } + const i = e[t]; + if (void 0 !== i) { + this.defaultSkin = i; + this.setSkin(this.defaultSkin); + } else console.error(`${this.name} skin enums are invalid`); + } + get _animationIndex() { + const t = this.animation; + if (this.skeletonData) if (t) { + const e = this.skeletonData.getAnimsEnum(); + if (e) { + const i = e[t]; + if (void 0 !== i) return i; + } + } else this._refreshInspector(); + return 0; + } + set _animationIndex(t) { + let e; + this.skeletonData && (e = this.skeletonData.getAnimsEnum()); + if (!e) { + console.error(`${this.name} animation enums are invalid`); + return; + } + const i = e[t]; + if (void 0 !== i) { + this.animation = i; + this.animation = i; + } else console.error(`${this.name} animation enums are invalid`); + } + get defaultCacheMode() { + return this._defaultCacheMode; + } + set defaultCacheMode(t) { + this._defaultCacheMode = t; + this.setAnimationCacheMode(this._defaultCacheMode); + } + get premultipliedAlpha() { + return this._premultipliedAlpha; + } + set premultipliedAlpha(t) { + if (t !== this._premultipliedAlpha) { + this._premultipliedAlpha = t; + this.markForUpdateRenderData(); + } + } + get timeScale() { + return this._timeScale; + } + set timeScale(t) { + t !== this._timeScale && (this._timeScale = t); + } + get debugSlots() { + return this._debugSlots; + } + set debugSlots(t) { + if (t !== this._debugSlots) { + this._debugSlots = t; + this._updateDebugDraw(); + this.markForUpdateRenderData(); + } + } + get debugBones() { + return this._debugBones; + } + set debugBones(t) { + if (t !== this._debugBones) { + this._debugBones = t; + this._updateDebugDraw(); + this.markForUpdateRenderData(); + } + } + get debugMesh() { + return this._debugMesh; + } + set debugMesh(t) { + if (t !== this._debugMesh) { + this._debugMesh = t; + this._updateDebugDraw(); + this.markForUpdateRenderData(); + } + } + get useTint() { + return this._useTint; + } + set useTint(t) { + if (t !== this._useTint) { + this._useTint = t; + this._updateUseTint(); + } + } + get sockets() { + return this._sockets; + } + set sockets(t) { + this._sockets = t; + this._updateSocketBindings(); + this.attachUtil._syncAttachedNode(); + } + get socketNodes() { + return this._socketNodes; + } + requestDrawInfo(t) { + this._drawInfoList[t] || (this._drawInfoList[t] = new aB); + return this._drawInfoList[t]; + } + constructor() { + super(); + Ml(this, "loop", ZBt, this); + this._frameCache = null; + this._curFrame = null; + this._effectDelegate = null; + this._skeleton = void 0; + this._clipper = void 0; + this._debugRenderer = void 0; + this._startSlotIndex = void 0; + this._endSlotIndex = void 0; + this._startEntry = void 0; + this._endEntry = void 0; + this.attachUtil = void 0; + this.maxVertexCount = 0; + this.maxIndexCount = 0; + this._materialCache = {}; + this._enumSkins = oe({}); + this._enumAnimations = oe({}); + this._playTimes = 0; + Ml(this, "_timeScale", QBt, this); + this._paused = !1; + this._accTime = 0; + this._playCount = 0; + this._skeletonCache = null; + this._animationName = ""; + this._animationQueue = []; + this._headAniInfo = null; + this._isAniComplete = !0; + this._needUpdateSkeltonData = !0; + Ml(this, "_useTint", $Bt, this); + Ml(this, "_preCacheMode", tDt, this); + Ml(this, "_cacheMode", eDt, this); + Ml(this, "_defaultCacheMode", iDt, this); + Ml(this, "_debugBones", sDt, this); + Ml(this, "_debugSlots", nDt, this); + Ml(this, "_skeletonData", rDt, this); + Ml(this, "_premultipliedAlpha", oDt, this); + Ml(this, "defaultSkin", aDt, this); + Ml(this, "defaultAnimation", lDt, this); + Ml(this, "_sockets", hDt, this); + this._drawIdx = 0; + this._drawList = new to((() => ({ + material: null, + texture: null, + indexOffset: 0, + indexCount: 0 + })), 1); + Ml(this, "_debugMesh", cDt, this); + this._rootBone = void 0; + this._state = void 0; + this._listener = void 0; + this._socketNodes = new Map; + this._cachedSockets = new Map; + this._drawInfoList = []; + this._effectDelegate = null; + this._skeleton = null; + this._rootBone = null; + this._listener = null; + this._debugRenderer = null; + this._startSlotIndex = -1; + this._endSlotIndex = -1; + this._startEntry = { + animation: { + name: "" + }, + trackIndex: 0 + }; + this._endEntry = { + animation: { + name: "" + }, + trackIndex: 0 + }; + this.attachUtil = new QMt; + fDt(this, "_defaultSkinIndex", this._enumSkins); + fDt(this, "_animationIndex", this._enumAnimations); + this._useVertexOpacity = !0; + } + setSkeletonData(t) { + const e = this.node._uiProps.uiTransformComp; + null != t.width && null != t.height && e.setContentSize(t.width, t.height); + if (this._cacheMode === mDt.SHARED_CACHE) this._skeletonCache = JMt.sharedCache; else if (this._cacheMode === mDt.PRIVATE_CACHE) { + this._skeletonCache = new JMt; + this._skeletonCache.enablePrivateMode(); + } + if (this.isAnimationCached()) { + (this.debugBones || this.debugSlots) && C("Debug bones or slots is invalid in cached mode"); + const e = this._skeletonCache.getSkeletonCache(this.skeletonData._uuid, t); + this._skeleton = e.skeleton; + this._clipper = e.clipper; + this._rootBone = this._skeleton.getRootBone(); + } else { + this._skeleton = new vMt.Skeleton(t); + this._clipper = new vMt.SkeletonClipping; + this._rootBone = this._skeleton.getRootBone(); + } + this._flushAssembler(); + } + setSlotsRange(t, e) { + if (this.isAnimationCached()) C("Slots visible range can not be modified in cached mode."); else { + this._startSlotIndex = t; + this._endSlotIndex = e; + } + } + setAnimationStateData(t) { + if (this.isAnimationCached()) C("'setAnimationStateData' interface can not be invoked in cached mode."); else { + const e = new vMt.AnimationState(t); + if (this._listener) { + this._state && this._state.removeListener(this._listener); + e.addListener(this._listener); + } + this._state = e; + } + } + __preload() { + super.__preload(); + const t = this.node.children; + for (let e = 0, i = t.length; e < i; e++) { + const i = t[e]; + i && "DEBUG_DRAW_NODE" === i.name && i.destroy(); + } + this._updateSkeletonData(); + this._updateDebugDraw(); + this._indexBoneSockets(); + this._updateSocketBindings(); + } + setAnimationCacheMode(t) { + if (this._preCacheMode !== t) { + this._cacheMode = t; + this._needUpdateSkeltonData = !0; + this._updateSkeletonData(); + this._updateUseTint(); + this._updateSocketBindings(); + this.markForUpdateRenderData(); + } + } + isAnimationCached() { + return this._cacheMode !== mDt.REALTIME; + } + updateAnimation(t) { + this.markForUpdateRenderData(); + if (!this.paused) { + t *= 1 * this._timeScale; + if (this.isAnimationCached()) { + if (this._isAniComplete) { + if (0 === this._animationQueue.length && !this._headAniInfo) { + const t = this._frameCache; + if (t && t.isInvalid()) { + t.updateToFrame(); + const e = t.frames; + this._curFrame = e[e.length - 1]; + } + return; + } + this._headAniInfo || (this._headAniInfo = this._animationQueue.shift()); + this._accTime += t; + if (this._accTime > this._headAniInfo.delay) { + const t = this._headAniInfo; + this._headAniInfo = null; + this.setAnimation(0, t.animationName, t.loop); + } + return; + } + this._updateCache(t); + } else this._updateRealtime(t); + } + } + setVertexEffectDelegate(t) { + this._effectDelegate = t; + } + setToSetupPose() { + this._skeleton && this._skeleton.setToSetupPose(); + } + setBonesToSetupPose() { + this._skeleton && this._skeleton.setBonesToSetupPose(); + } + setSlotsToSetupPose() { + this._skeleton && this._skeleton.setSlotsToSetupPose(); + } + updateAnimationCache(t) { + if (!this.isAnimationCached()) return; + const e = this._skeletonData._uuid; + this._skeletonCache && this._skeletonCache.updateAnimationCache(e, t); + } + invalidAnimationCache() { + this.isAnimationCached() && this._skeletonCache && this._skeletonCache.invalidAnimationCache(this._skeletonData._uuid); + } + findBone(t) { + return this._skeleton ? this._skeleton.findBone(t) : null; + } + findSlot(t) { + return this._skeleton ? this._skeleton.findSlot(t) : null; + } + setSkin(t) { + if (this._skeleton) { + this._skeleton.setSkinByName(t); + this._skeleton.setSlotsToSetupPose(); + } + this.invalidAnimationCache(); + } + getAttachment(t, e) { + return this._skeleton ? this._skeleton.getAttachmentByName(t, e) : null; + } + setAttachment(t, e) { + this._skeleton && this._skeleton.setAttachment(t, e); + this.invalidAnimationCache(); + } + getTextureAtlas(t) { + return t.region; + } + setMix(t, e, i) { + this._state && this._state.data.setMix(t, e, i); + } + setAnimation(t, e, i) { + this._playTimes = i ? 0 : 1; + this._animationName = e; + if (this.isAnimationCached()) { + 0 !== t && C("Track index can not greater than 0 in cached mode."); + if (!this._skeletonCache) return null; + let i = this._skeletonCache.getAnimationCache(this._skeletonData._uuid, e); + i || (i = this._skeletonCache.initAnimationCache(this._skeletonData._uuid, e)); + if (i) { + this._isAniComplete = !1; + this._accTime = 0; + this._playCount = 0; + this._frameCache = i; + this._socketNodes.size > 0 && this._frameCache.enableCacheAttachedInfo(); + this._frameCache.updateToFrame(0); + this._curFrame = this._frameCache.frames[0]; + } + } else if (this._skeleton) { + const s = this._skeleton.data.findAnimation(e); + if (!s) { + P(7509, e); + return null; + } + const n = this._state.setAnimationWith(t, s, i); + this._state.apply(this._skeleton); + return n; + } + return null; + } + addAnimation(t, e, i, s) { + s = s || 0; + if (this.isAnimationCached()) { + 0 !== t && C("Track index can not greater than 0 in cached mode."); + this._animationQueue.push({ + animationName: e, + loop: i, + delay: s + }); + } else if (this._skeleton) { + var n; + const r = this._skeleton.data.findAnimation(e); + if (!r) { + P(7510, e); + return null; + } + return null === (n = this._state) || void 0 === n ? void 0 : n.addAnimationWith(t, r, i, s); + } + return null; + } + findAnimation(t) { + return this._skeleton ? this._skeleton.data.findAnimation(t) : null; + } + getCurrent(t) { + if (this.isAnimationCached()) C("'getCurrent' interface can not be invoked in cached mode."); else if (this._state) return this._state.getCurrent(t); + return null; + } + clearTracks() { + if (this.isAnimationCached()) C("'clearTracks' interface can not be invoked in cached mode."); else if (this._state) { + this._state.clearTracks(); + this.setToSetupPose(); + } + } + clearTrack(t) { + this.isAnimationCached() ? C("'clearTrack' interface can not be invoked in cached mode.") : this._state && this._state.clearTrack(t); + } + setStartListener(t) { + this._ensureListener(); + this._listener.start = t; + } + setInterruptListener(t) { + this._ensureListener(); + this._listener.interrupt = t; + } + setEndListener(t) { + this._ensureListener(); + this._listener.end = t; + } + setDisposeListener(t) { + this._ensureListener(); + this._listener.dispose = t; + } + setCompleteListener(t) { + this._ensureListener(); + this._listener.complete = t; + } + setEventListener(t) { + this._ensureListener(); + this._listener.event = t; + } + setTrackStartListener(t, e) { + SMt.getListeners(t).start = e; + } + setTrackInterruptListener(t, e) { + SMt.getListeners(t).interrupt = e; + } + setTrackEndListener(t, e) { + SMt.getListeners(t).end = e; + } + setTrackDisposeListener(t, e) { + SMt.getListeners(t).dispose = e; + } + setTrackCompleteListener(t, e) { + SMt.getListeners(t).complete = function(t) { + const i = Math.floor(t.trackTime / t.animationEnd); + e(t, i); + }; + } + setTrackEventListener(t, e) { + SMt.getListeners(t).event = e; + } + getState() { + return this._state; + } + onEnable() { + super.onEnable(); + this._flushAssembler(); + pBt.getInstance().add(this); + } + onDisable() { + super.onDisable(); + pBt.getInstance().remove(this); + } + onDestroy() { + this._cleanMaterialCache(); + this._drawList.destroy(); + super.onDestroy(); + } + destroyRenderData() { + this._drawList.reset(); + super.destroyRenderData(); + } + getMaterialForBlendAndTint(t, e, i) { + const s = `${i}/${t}/${e}`; + let n = this._materialCache[s]; + if (n) return n; + let r = this.customMaterial; + null === r && (r = xR.get("default-spine-material")); + let o = !1; + switch (i) { + case gDt.TWO_COLORED: + o = !0; + + case gDt.COLORED_TEXTURED: + } + n = new uS({ + parent: r, + subModelIdx: 0, + owner: this + }); + this._materialCache[s] = n; + n.overridePipelineStates({ + blendState: { + blendColor: Bi.WHITE, + targets: [ { + blendEq: Fs.ADD, + blendAlphaEq: Fs.ADD, + blendSrc: t, + blendDst: e, + blendSrcAlpha: t, + blendDstAlpha: e + } ] + } + }); + n.recompileShaders({ + TWO_COLORED: o, + USE_LOCAL: !0 + }); + return n; + } + onRestore() { + this.updateMaterial(); + this.markForUpdateRenderData(); + } + querySockets() { + if (!this._skeleton) return []; + 0 === this._cachedSockets.size && this._indexBoneSockets(); + return this._cachedSockets.size > 0 ? Array.from(this._cachedSockets.keys()).sort() : []; + } + _requestDrawData(t, e, i, s) { + const n = this._drawList.add(); + n.material = t; + n.texture = e; + n.indexOffset = i; + n.indexCount = s; + return n; + } + _render(t) { + if (this.renderData && this._drawList) { + const e = this.renderData; + const i = e.chunk; + const s = i.vertexAccessor; + const n = e.getMeshBuffer(); + const r = n.indexOffset; + s.appendIndices(i.bufferId, e.indices); + for (let e = 0; e < this._drawList.length; e++) { + this._drawIdx = e; + const i = this._drawList.data[e]; + if (i.texture) { + const e = n.requireFreeIA(t.device); + e.firstIndex = r + i.indexOffset; + e.indexCount = i.indexCount; + t.commitIA(this, e, i.texture, i.material, this.node); + } + } + } + } + updateWorldTransform() { + this.isAnimationCached() && this._skeleton && this._skeleton.updateWorldTransform(); + } + _emitCacheCompleteEvent() { + if (this._listener) { + this._endEntry.animation.name = this._animationName; + this._listener.complete && this._listener.complete(this._endEntry); + this._listener.end && this._listener.end(this._endEntry); + } + } + _updateCache(t) { + const e = this._frameCache; + if (!e.isInited()) return; + const i = e.frames; + const s = JMt.FrameTime; + if (0 === this._accTime && 0 === this._playCount) { + this._startEntry.animation.name = this._animationName; + this._listener && this._listener.start && this._listener.start(this._startEntry); + } + this._accTime += t; + let n = Math.floor(this._accTime / s); + if (!e.isCompleted) { + e.updateToFrame(n); + if (this.renderData && (this.renderData.vertexCount < e.maxVertexCount || this.renderData.indexCount < e.maxIndexCount)) { + this.maxVertexCount = e.maxVertexCount > this.maxVertexCount ? e.maxVertexCount : this.maxVertexCount; + this.maxIndexCount = e.maxIndexCount > this.maxIndexCount ? e.maxIndexCount : this.maxIndexCount; + this.renderData.resize(this.maxVertexCount, this.maxIndexCount); + (!this.renderData.indices || this.maxIndexCount > this.renderData.indices.length) && (this.renderData.indices = new Uint16Array(this.maxIndexCount)); + } + } + if (e.isCompleted && n >= i.length) { + this._playCount++; + if (this._playTimes > 0 && this._playCount >= this._playTimes) { + this._curFrame = i[i.length - 1]; + this._accTime = 0; + this._playCount = 0; + this._isAniComplete = !0; + this._emitCacheCompleteEvent(); + return; + } + this._accTime = 0; + n = 0; + this._emitCacheCompleteEvent(); + } + this._curFrame = i[n]; + } + _updateRealtime(t) { + const e = this._skeleton; + const i = this._state; + if (e) { + e.update(t); + if (i) { + i.update(t); + i.apply(e); + } + } + } + _indexBoneSockets() { + if (!this._skeleton) return; + this._cachedSockets.clear(); + const t = this._skeleton.bones; + const e = i => null == i.parent ? i.data.name || "" : `${e(t[i.parent.data.index])}/${i.data.name}`; + for (let i = 0, s = t.length; i < s; i++) { + const s = t[i].data; + const n = e(t[i]); + this._cachedSockets.set(n, s.index); + } + } + _updateUseTint() { + this._cleanMaterialCache(); + this.destroyRenderData(); + if (this._assembler && this._skeleton) { + this._renderData = this._assembler.createData(this); + this.markForUpdateRenderData(); + } + } + _updateBatch() { + this.markForUpdateRenderData(); + } + _updateAnimEnum() { + let t; + t = this.skeletonData ? this.skeletonData.getAnimsEnum() : pDt; + this._enumAnimations = oe({}); + Object.assign(this._enumAnimations, t); + oe.update(this._enumAnimations); + fDt(this, "_animationIndex", this._enumAnimations); + } + _updateSkinEnum() { + let t; + t = this.skeletonData ? this.skeletonData.getSkinsEnum() : dDt; + this._enumSkins = oe({}); + Object.assign(this._enumSkins, t); + oe.update(this._enumSkins); + fDt(this, "_defaultSkinIndex", this._enumSkins); + } + _ensureListener() { + if (!this._listener) { + this._listener = new SMt; + this._state && this._state.addListener(this._listener); + } + } + _updateSkeletonData() { + if (!this.skeletonData || !1 === this._needUpdateSkeltonData) return; + this._needUpdateSkeltonData = !1; + const t = this.skeletonData.getRuntimeData(); + if (t) { + try { + this.setSkeletonData(t); + this.isAnimationCached() || this.setAnimationStateData(new vMt.AnimationStateData(this._skeleton.data)); + this.defaultSkin && this.setSkin(this.defaultSkin); + } catch (t) { + C(t); + } + this._indexBoneSockets(); + this.attachUtil.init(this); + this._preCacheMode = this._cacheMode; + this.animation = this.defaultAnimation; + } + } + _refreshInspector() { + this._updateAnimEnum(); + this._updateSkinEnum(); + } + _updateDebugDraw() { + if (this.debugBones || this.debugSlots || this.debugMesh) { + if (!this._debugRenderer) { + const t = new _y("DEBUG_DRAW_NODE"); + t.hideFlags |= co.Flags.DontSave | co.Flags.HideInHierarchy; + const e = t.addComponent(dN); + e.lineWidth = 1; + e.strokeColor = new Bi(255, 0, 0, 255); + this._debugRenderer = e; + t.parent = this.node; + } + this.isAnimationCached() && C("Debug bones or slots is invalid in cached mode"); + } else if (this._debugRenderer) { + this._debugRenderer.node.destroy(); + this._debugRenderer = null; + } + } + _flushAssembler() { + const e = t.Assembler.getAssembler(this); + this._assembler !== e && (this._assembler = e); + if (this._skeleton && this._assembler) { + this._renderData = this._assembler.createData(this); + this.markForUpdateRenderData(); + this._updateColor(); + } + } + _updateSocketBindings() { + if (this._skeleton) { + this._socketNodes.clear(); + for (let t = 0, e = this._sockets.length; t < e; t++) { + const e = this._sockets[t]; + if (e.path && e.target) { + const t = this._cachedSockets.get(e.path); + if (!t) { + console.error(`Skeleton data does not contain path ${e.path}`); + continue; + } + this._socketNodes.set(t, e.target); + } + } + } + } + _verifySockets(t) { + for (let e = 0, i = t.length; e < i; e++) { + const i = t[e].target; + !i || i.parent && i.parent === this.node || console.error(`Target node ${i.name} is expected to be a direct child of ${this.node.name}`); + } + const e = new Map; + t.forEach((t => { + t.target && (e.get(t.target) ? console.error(`Target node ${t.target.name} has existed.`) : e.set(t.target, !0)); + })); + } + _cleanMaterialCache() { + for (const t in this._materialCache) this._materialCache[t].destroy(); + this._materialCache = {}; + } + createRenderEntity() { + const t = new fB(uB.DYNAMIC); + t.setUseLocal(!0); + return t; + } + markForUpdateRenderData(t = !0) { + super.markForUpdateRenderData(t); + this._debugRenderer && this._debugRenderer.markForUpdateRenderData(t); + } + }, uDt.SpineSocket = yDt, uDt.AnimationCacheMode = mDt, _Dt), Bl(JBt.prototype, "customMaterial", [ vh, CBt, xBt, wBt ], Object.getOwnPropertyDescriptor(JBt.prototype, "customMaterial"), JBt.prototype), + Bl(JBt.prototype, "skeletonData", [ nh, RBt ], Object.getOwnPropertyDescriptor(JBt.prototype, "skeletonData"), JBt.prototype), + Bl(JBt.prototype, "_defaultSkinIndex", [ IBt, MBt, BBt ], Object.getOwnPropertyDescriptor(JBt.prototype, "_defaultSkinIndex"), JBt.prototype), + Bl(JBt.prototype, "_animationIndex", [ DBt, PBt, OBt ], Object.getOwnPropertyDescriptor(JBt.prototype, "_animationIndex"), JBt.prototype), + Bl(JBt.prototype, "defaultCacheMode", [ NBt, LBt, nh, FBt ], Object.getOwnPropertyDescriptor(JBt.prototype, "defaultCacheMode"), JBt.prototype), + ZBt = Bl(JBt.prototype, "loop", [ Yl, VBt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), Bl(JBt.prototype, "premultipliedAlpha", [ nh, kBt ], Object.getOwnPropertyDescriptor(JBt.prototype, "premultipliedAlpha"), JBt.prototype), + Bl(JBt.prototype, "timeScale", [ UBt, nh ], Object.getOwnPropertyDescriptor(JBt.prototype, "timeScale"), JBt.prototype), + Bl(JBt.prototype, "debugSlots", [ nh, GBt ], Object.getOwnPropertyDescriptor(JBt.prototype, "debugSlots"), JBt.prototype), + Bl(JBt.prototype, "debugBones", [ nh, zBt ], Object.getOwnPropertyDescriptor(JBt.prototype, "debugBones"), JBt.prototype), + Bl(JBt.prototype, "debugMesh", [ nh, HBt ], Object.getOwnPropertyDescriptor(JBt.prototype, "debugMesh"), JBt.prototype), + Bl(JBt.prototype, "useTint", [ nh, jBt ], Object.getOwnPropertyDescriptor(JBt.prototype, "useTint"), JBt.prototype), + Bl(JBt.prototype, "sockets", [ XBt, WBt ], Object.getOwnPropertyDescriptor(JBt.prototype, "sockets"), JBt.prototype), + QBt = Bl(JBt.prototype, "_timeScale", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), $Bt = Bl(JBt.prototype, "_useTint", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), tDt = Bl(JBt.prototype, "_preCacheMode", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return -1; + } + }), eDt = Bl(JBt.prototype, "_cacheMode", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return mDt.REALTIME; + } + }), iDt = Bl(JBt.prototype, "_defaultCacheMode", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return mDt.REALTIME; + } + }), sDt = Bl(JBt.prototype, "_debugBones", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), nDt = Bl(JBt.prototype, "_debugSlots", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), rDt = Bl(JBt.prototype, "_skeletonData", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), oDt = Bl(JBt.prototype, "_premultipliedAlpha", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), aDt = Bl(JBt.prototype, "defaultSkin", [ Yl, YBt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), lDt = Bl(JBt.prototype, "defaultAnimation", [ qBt, Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), hDt = Bl(JBt.prototype, "_sockets", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), cDt = Bl(JBt.prototype, "_debugMesh", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), JBt)) || KBt) || KBt) || KBt) || KBt); + m.internal.SpineSkeleton = bDt; + const SDt = [ 0, 1, 2, 2, 3, 0 ]; + const ADt = new Bi(0, 0, 255, 255); + const TDt = new Bi(255, 0, 0, 255); + const vDt = new Bi(0, 255, 0, 255); + const EDt = new Bi(255, 255, 0, 255); + const CDt = new vMt.Color(1, 1, 1, 1); + const xDt = new vMt.Color(1, 1, 1, 1); + const wDt = new vMt.Vector2; + const RDt = new vMt.Vector2; + let IDt; + let MDt; + let BDt; + let DDt; + let PDt; + let ODt; + let NDt; + let LDt; + let FDt; + let VDt; + let kDt; + let UDt; + let GDt; + let zDt; + let HDt; + let jDt; + let XDt = 0; + let WDt = 0; + let YDt = 0; + let qDt = 0; + let KDt = 0; + let JDt = 0; + let ZDt = 0; + let QDt = 0; + let $Dt; + let tPt; + let ePt; + let iPt; + let sPt; + let nPt; + let rPt; + let oPt; + let aPt; + let lPt; + let hPt; + let cPt; + let uPt; + let _Pt; + let dPt; + let pPt; + let mPt; + let fPt; + let gPt; + let yPt; + let bPt; + let SPt; + let APt = null; + let TPt = null; + let vPt = null; + function EPt(t) { + let e; + let i; + switch (t) { + case vMt.BlendMode.Additive: + e = IDt ? Ls.ONE : Ls.SRC_ALPHA; + i = Ls.ONE; + break; + + case vMt.BlendMode.Multiply: + e = Ls.DST_COLOR; + i = Ls.ONE_MINUS_SRC_ALPHA; + break; + + case vMt.BlendMode.Screen: + e = Ls.ONE; + i = Ls.ONE_MINUS_SRC_COLOR; + break; + + case vMt.BlendMode.Normal: + default: + e = IDt ? Ls.ONE : Ls.SRC_ALPHA; + i = Ls.ONE_MINUS_SRC_ALPHA; + } + return mPt.getMaterialForBlendAndTint(e, i, PDt ? gDt.TWO_COLORED : gDt.COLORED_TEXTURED); + } + function CPt(t) { + cPt = t.fa * UDt; + MDt = IDt ? cPt / 255 : 1; + nPt = FDt * MDt; + rPt = VDt * MDt; + oPt = kDt * MDt; + aPt = t.fr * nPt; + lPt = t.fg * rPt; + hPt = t.fb * oPt; + GDt = (cPt << 24 >>> 0) + (hPt << 16) + (lPt << 8) + aPt; + uPt = t.dr * nPt; + _Pt = t.dg * rPt; + dPt = t.db * oPt; + pPt = IDt ? 255 : 0; + zDt = (pPt << 24 >>> 0) + (dPt << 16) + (_Pt << 8) + uPt; + } + function xPt(t) { + return (t.a << 24 >>> 0) + (t.b << 16) + (t.g << 8) + t.r; + } + function wPt(t, e, i, s) { + return (s << 24 >>> 0) + (i << 16) + (e << 8) + t; + } + let RPt = null; + let IPt = null; + const MPt = { + vCount: 32767, + ensureAccessor(t) { + let e = t ? IPt : RPt; + if (!e) { + const i = IR.root.device; + const s = IR.root.batcher2D; + const n = t ? XM : HM; + if (t) { + e = IPt = new iB(i, n, this.vCount); + s.registerBufferAccessor(Number.parseInt("SPINETINT", 36), IPt); + } else { + e = RPt = new iB(i, n, this.vCount); + s.registerBufferAccessor(Number.parseInt("SPINE", 36), RPt); + } + } + return e; + }, + createData(t) { + let e = t.renderData; + if (!e) { + const i = t.useTint || t.isAnimationCached(); + const s = this.ensureAccessor(i); + const n = t._skeleton.data.skins; + let r = 0; + let o = 0; + for (let t = 0; t < n.length; ++t) { + const e = n[t].attachments; + for (let t = 0; t < e.length; t++) { + const i = e[t]; + for (const t in i) { + const e = i[t]; + if (e instanceof vMt.RegionAttachment) { + r += 4; + o += 6; + } else if (e instanceof vMt.MeshAttachment) { + r += e.worldVerticesLength >> 1; + o += e.triangles.length; + } + } + } + } + e = SB.add(i ? XM : HM, s); + e.resize(r, o); + e.indices && o === e.indices.length || (e.indices = new Uint16Array(o)); + t.maxVertexCount = r; + t.maxIndexCount = o; + } + return e; + }, + updateRenderData(t, e) { + mPt = t; + const i = t._skeleton; + !t.isAnimationCached() && i && i.updateWorldTransform(); + i && function(t, e) { + if (!t._skeleton) return; + const i = t.color; + FDt = i.r / 255; + VDt = i.g / 255; + kDt = i.b / 255; + UDt = t.node._uiProps.opacity; + PDt = t.useTint || t.isAnimationCached(); + HDt = (s = PDt, YM(s ? XM : HM) >> 2); + var s; + t.drawList.reset(); + mPt = t; + fPt = t.renderData; + TPt = null; + sPt = !0; + IDt = t.premultipliedAlpha; + MDt = 1; + SPt = !1; + APt = t._effectDelegate && t._effectDelegate._vertexEffect; + (4294967295 !== i._val || IDt) && (SPt = !0); + if (t.isAnimationCached()) !function() { + const t = mPt._curFrame; + if (!t) return; + const e = t.segments; + if (0 === e.length) return; + jDt = 12; + qDt = 0; + KDt = 0; + YDt = 0; + JDt = 0; + let i = null; + const s = t.vertices; + const n = t.indices; + let r = 0; + let o = 0; + let a = 0; + let l = 0; + const h = t.colors; + let c = 0; + let u = h[c++]; + let _ = u.vfOffset; + CPt(u); + let d = 0; + const p = fPt; + const m = p.chunk.vb; + const f = p.indices; + for (let t = 0, g = e.length; t < g; t++) { + const g = e[t]; + i = EPt(g.blendMode); + if (i) { + TPt || (TPt = i); + if (sPt || i.hash !== TPt.hash || g.tex && g.tex !== vPt) { + sPt = !1; + const t = JDt - d; + if (t > 0) { + mPt._requestDrawData(TPt, vPt, d, t); + d = JDt; + } + TPt = i; + vPt = g.tex; + } + WDt = g.vertexCount; + KDt = g.indexCount; + r = p.chunk.vertexOffset; + for (let t = JDt, e = JDt + KDt; t < e; t++) f[t] = r + YDt + n[a++]; + l = g.vfCount; + m.set(s.subarray(o, o + l), o); + if (SPt) { + let t = o / 7 * 6; + for (let e = o, i = o + l; e < i; e += HDt, t += 6) { + if (t >= _) { + u = h[c++]; + CPt(u); + _ = u.vfOffset; + } + bPt[e + 5] = GDt; + bPt[e + 6] = zDt; + } + } + o += l; + YDt += WDt; + JDt += KDt; + WDt = 0; + KDt = 0; + } + } + const g = JDt - d; + vPt && g > 0 && mPt._requestDrawData(TPt, vPt, d, g); + }(); else { + APt && APt.begin(t._skeleton); + !function(t) { + const e = fPt; + yPt = e.chunk.vb; + bPt = new Uint32Array(yPt.buffer, yPt.byteOffset, yPt.length); + gPt = e.indices; + ZDt = mPt.maxVertexCount; + QDt = mPt.maxIndexCount; + const i = mPt._skeleton; + const s = i.color; + const n = mPt._debugRenderer; + const r = mPt._clipper; + let o = null; + let a; + let l; + let h; + let c; + let u; + let _; + let d; + BDt = mPt._startSlotIndex; + DDt = mPt._endSlotIndex; + iPt = !1; + -1 === BDt && (iPt = !0); + ODt = mPt.debugSlots; + NDt = mPt.debugBones; + LDt = mPt.debugMesh; + if (n && (NDt || ODt || LDt)) { + n.clear(); + n.lineWidth = 5; + } + jDt = 12; + XDt = 0; + YDt = 0; + qDt = 0; + KDt = 0; + JDt = 0; + let p = 0; + for (let t = 0, m = i.drawOrder.length; t < m; t++) { + d = i.drawOrder[t]; + if (void 0 === d || !d.bone.active) continue; + BDt >= 0 && BDt === d.data.index && (iPt = !0); + if (!iPt) { + r.clipEndWithSlot(d); + continue; + } + DDt >= 0 && DDt === d.data.index && (iPt = !1); + XDt = 0; + KDt = 0; + a = d.getAttachment(); + if (!a) { + r.clipEndWithSlot(d); + continue; + } + c = a instanceof vMt.RegionAttachment; + u = a instanceof vMt.MeshAttachment; + _ = a instanceof vMt.ClippingAttachment; + if (_) { + r.clipStart(d, a); + continue; + } + if (!c && !u) { + r.clipEndWithSlot(d); + continue; + } + const m = a.region.texture.getRealTexture(); + o = EPt(d.data.blendMode); + if (!o) { + r.clipEndWithSlot(d); + continue; + } + TPt || (TPt = o); + if (sPt || o.hash !== TPt.hash || m && vPt !== m) { + sPt = !1; + const t = JDt - p; + if (t > 0) { + mPt._requestDrawData(TPt, vPt, p, t); + p = JDt; + } + vPt = m; + TPt = o; + } + if (c) { + h = SDt; + WDt = 4; + XDt = WDt * HDt; + KDt = 6; + a.computeWorldVertices(d.bone, yPt, qDt, HDt); + if (n && ODt) { + n.strokeColor = ADt; + n.moveTo(yPt[qDt], yPt[qDt + 1]); + for (let t = qDt + HDt, e = qDt + XDt; t < e; t += HDt) n.lineTo(yPt[t], yPt[t + 1]); + n.close(); + n.stroke(); + } + } else if (u) { + const t = a; + h = t.triangles; + WDt = t.worldVerticesLength >> 1; + XDt = WDt * HDt; + KDt = h.length; + t.computeWorldVertices(d, 0, t.worldVerticesLength, yPt, qDt, HDt); + if (n && LDt) { + n.strokeColor = EDt; + for (let t = 0, e = h.length; t < e; t += 3) { + const e = h[t] * HDt + qDt; + const i = h[t + 1] * HDt + qDt; + const s = h[t + 2] * HDt + qDt; + n.moveTo(yPt[e], yPt[e + 1]); + n.lineTo(yPt[i], yPt[i + 1]); + n.lineTo(yPt[s], yPt[s + 1]); + n.close(); + n.stroke(); + } + } + } + if (0 === XDt || 0 === KDt) { + r.clipEndWithSlot(d); + continue; + } + const f = a; + gPt = e.indices; + gPt.set(h, JDt); + l = f.uvs; + for (let t = qDt, e = qDt + XDt, i = 0; t < e; t += HDt, i += 2) { + yPt[t + 3] = l[i]; + yPt[t + 4] = l[i + 1]; + } + DPt(s, f.color, d.color, r, d); + if (KDt > 0) { + const t = e.chunk.vertexOffset; + for (let e = JDt, i = JDt + KDt; e < i; e++) gPt[e] += YDt + t; + } + qDt += XDt; + YDt += WDt; + JDt += KDt; + WDt = 0; + KDt = 0; + r.clipEndWithSlot(d); + } + const m = JDt - p; + vPt && m > 0 && mPt._requestDrawData(TPt, vPt, p, m); + r.clipEnd(); + if (n && NDt) { + let t; + n.strokeColor = TDt; + n.fillColor = ADt; + for (let e = 0, s = i.bones.length; e < s; e++) { + t = i.bones[e]; + const s = t.data.length * t.a + t.worldX; + const r = t.data.length * t.c + t.worldY; + n.moveTo(t.worldX, t.worldY); + n.lineTo(s, r); + n.stroke(); + n.circle(t.worldX, t.worldY, 1.5 * Math.PI); + n.fill(); + 0 === e && (n.fillColor = vDt); + } + } + }(); + APt && APt.end(); + } + (PDt ? IPt : RPt).getMeshBuffer(fPt.chunk.bufferId).setDirty(); + t.attachUtil._syncAttachedNode(); + mPt = void 0; + APt = null; + }(t); + }, + updateColor(t) { + if (t) { + mPt = t; + mPt.markForUpdateRenderData(); + } + }, + fillBuffers(t, e) {} + }; + function BPt(t, e) { + const i = WDt; + const s = KDt; + const n = fPt; + KDt = e.length; + WDt = t.length / jDt; + XDt = WDt * HDt; + ZDt += WDt - i; + QDt += KDt - s; + const r = gPt; + const o = n.chunk.vertexOffset; + let a = !1; + if (ZDt > n.vertexCount) { + n.resizeAndCopy(ZDt, QDt > n.indexCount ? QDt : n.indexCount); + yPt = n.chunk.vb; + bPt = new Uint32Array(yPt.buffer, yPt.byteOffset, yPt.length); + a = !0; + } + if (QDt > gPt.length) { + gPt = n.indices = new Uint16Array(QDt); + a = !0; + } + if (a) { + const t = n.chunk.vertexOffset - o; + for (let e = 0; e < JDt; ++e) gPt[e] = r[e] + t; + } + } + function DPt(t, e, i, s, n) { + CDt.a = i.a * e.a * t.a * UDt * 255; + MDt = IDt ? CDt.a : 255; + $Dt = FDt * e.r * t.r * MDt; + tPt = VDt * e.g * t.g * MDt; + ePt = kDt * e.b * t.b * MDt; + CDt.r = $Dt * i.r; + CDt.g = tPt * i.g; + CDt.b = ePt * i.b; + if (null == n.darkColor) xDt.set(0, 0, 0, 1); else { + xDt.r = n.darkColor.r * $Dt; + xDt.g = n.darkColor.g * tPt; + xDt.b = n.darkColor.b * ePt; + } + xDt.a = IDt ? 255 : 0; + if (PDt) if (s.isClipping()) { + jDt = PDt ? 12 : 8; + const t = yPt.subarray(qDt); + const e = yPt.subarray(qDt + 3); + s.clipTriangles(t, XDt, gPt.subarray(JDt), KDt, e, CDt, xDt, PDt, HDt); + const i = s.clippedVertices; + const n = s.clippedTriangles; + BPt(i, n); + n.length > 0 && gPt.set(n, JDt); + if (APt) for (let t = 0, e = i.length, s = qDt; t < e; t += jDt, s += HDt) { + wDt.x = i[t]; + wDt.y = i[t + 1]; + RDt.x = i[t + 6]; + RDt.y = i[t + 7]; + APt.transform(wDt, RDt, CDt, xDt); + yPt[s] = wDt.x; + yPt[s + 1] = wDt.y; + yPt[s + 3] = RDt.x; + yPt[s + 4] = RDt.y; + bPt[s + 5] = wPt(i[t + 2], i[t + 3], i[t + 4], i[t + 5]); + bPt[s + 6] = wPt(i[t + 8], i[t + 9], i[t + 10], i[t + 11]); + } else for (let t = 0, e = i.length, s = qDt; t < e; t += jDt, s += HDt) { + yPt[s] = i[t]; + yPt[s + 1] = i[t + 1]; + yPt[s + 3] = i[t + 6]; + yPt[s + 4] = i[t + 7]; + bPt[s + 5] = wPt(i[t + 2], i[t + 3], i[t + 4], i[t + 5]); + bPt[s + 6] = wPt(i[t + 8], i[t + 9], i[t + 10], i[t + 11]); + } + } else { + GDt = xPt(CDt); + zDt = xPt(xDt); + if (APt) for (let t = qDt, e = qDt + XDt; t < e; t += HDt) { + wDt.x = yPt[t]; + wDt.y = yPt[t + 1]; + RDt.x = yPt[t + 3]; + RDt.y = yPt[t + 4]; + APt.transform(wDt, RDt, CDt, xDt); + yPt[t] = wDt.x; + yPt[t + 1] = wDt.y; + yPt[t + 3] = RDt.x; + yPt[t + 4] = RDt.y; + bPt[t + 5] = GDt; + bPt[t + 6] = zDt; + } else for (let t = qDt, e = qDt + XDt; t < e; t += HDt) { + bPt[t + 5] = GDt; + bPt[t + 6] = zDt; + } + } else if (s.isClipping()) { + jDt = PDt ? 12 : 8; + const t = yPt.subarray(qDt); + const e = yPt.subarray(qDt + 3); + s.clipTriangles(t, XDt, gPt.subarray(JDt), KDt, e, CDt, xDt, PDt, HDt); + const i = s.clippedVertices; + const n = s.clippedTriangles; + BPt(i, n); + n.length > 0 && gPt.set(n, JDt); + if (APt) for (let t = 0, e = i.length, s = qDt; t < e; t += jDt, s += HDt) { + wDt.x = i[t]; + wDt.y = i[t + 1]; + RDt.x = i[t + 6]; + RDt.y = i[t + 7]; + APt.transform(wDt, RDt, CDt, xDt); + yPt[s] = wDt.x; + yPt[s + 1] = wDt.y; + yPt[s + 3] = RDt.x; + yPt[s + 4] = RDt.y; + bPt[s + 5] = wPt(i[t + 2], i[t + 3], i[t + 4], i[t + 5]); + } else for (let t = 0, e = i.length, s = qDt; t < e; t += jDt, s += HDt) { + yPt[s] = i[t]; + yPt[s + 1] = i[t + 1]; + yPt[s + 3] = i[t + 6]; + yPt[s + 4] = i[t + 7]; + bPt[s + 5] = wPt(i[t + 2], i[t + 3], i[t + 4], i[t + 5]); + } + } else { + GDt = xPt(CDt); + if (APt) for (let t = qDt, e = qDt + XDt; t < e; t += HDt) { + wDt.x = yPt[t]; + wDt.y = yPt[t + 1]; + RDt.x = yPt[t + 3]; + RDt.y = yPt[t + 4]; + APt.transform(wDt, RDt, CDt, xDt); + yPt[t] = wDt.x; + yPt[t + 1] = wDt.y; + yPt[t + 3] = RDt.x; + yPt[t + 4] = RDt.y; + bPt[t + 5] = GDt; + } else for (let t = qDt, e = qDt + XDt; t < e; t += HDt) bPt[t + 5] = GDt; + } + } + m.internal.SpineAssembler = MPt; + const PPt = { + getAssembler: () => MPt + }; + bDt.Assembler = PPt; + const OPt = window.spine; + const NPt = OPt.VertexEffectDelegate; + let LPt; + !function(t) { + t[t.REGION = 0] = "REGION"; + t[t.BOUNDING_BOX = 1] = "BOUNDING_BOX"; + t[t.MESH = 2] = "MESH"; + t[t.SKINNED_MESH = 3] = "SKINNED_MESH"; + }(LPt || (LPt = {})); + he(LPt); + let FPt; + !function(t) { + t[t.START = 0] = "START"; + t[t.INTERRUPT = 1] = "INTERRUPT"; + t[t.END = 2] = "END"; + t[t.DISPOSE = 3] = "DISPOSE"; + t[t.COMPLETE = 4] = "COMPLETE"; + t[t.EVENT = 5] = "EVENT"; + }(FPt || (FPt = {})); + he(FPt); + m.internal.SpineAnimationEventType = FPt; + t("sp", Object.freeze({ + __proto__: null, + timeScale: 1, + get DefaultSkinsEnum() { + return dDt; + }, + get DefaultAnimsEnum() { + return pDt; + }, + get AnimationCacheMode() { + return mDt; + }, + get SpineMaterialType() { + return gDt; + }, + SpineSocket: yDt, + Skeleton: bDt, + SkeletonData: dBt, + simpleSpineAssembler: PPt, + spine: OPt, + VertexEffectDelegate: NPt, + get ATTACHMENT_TYPE() { + return LPt; + }, + get AnimationEventType() { + return FPt; + } + })); + t("HeightField", class { + constructor(t, e) { + this.data = new Uint16Array; + this.w = 0; + this.h = 0; + this.w = t; + this.h = e; + this.data = new Uint16Array(t * e); + for (let i = 0; i < t * e; ++i) this.data[i] = 0; + } + set(t, e, i) { + this.data[e * this.w + t] = i; + } + get(t, e) { + return this.data[e * this.w + t]; + } + getClamp(t, e) { + t = _i(t, 0, this.w - 1); + e = _i(e, 0, this.h - 1); + return this.get(t, e); + } + getAt(t, e) { + const i = t; + const s = e; + let n = Math.floor(i); + let r = Math.floor(s); + let o = n + 1; + let a = r + 1; + const l = i - n; + const h = s - r; + n = _i(n, 0, this.w - 1); + r = _i(r, 0, this.h - 1); + o = _i(o, 0, this.w - 1); + a = _i(a, 0, this.h - 1); + let c = this.get(n, r); + const u = this.get(o, r); + const _ = this.get(n, a); + let d = this.get(o, a); + const p = .5 * (u + _); + l + h <= 1 ? d = p + (p - c) : c = p + (p - d); + return (c * (1 - l) + u * l) * (1 - h) + (_ * (1 - l) + d * l) * h; + } + }); + const VPt = 33; + const kPt = 32; + const UPt = 1e14; + class GPt { + constructor() { + this.level = 0; + this.north = 0; + this.south = 0; + this.west = 0; + this.east = 0; + } + equals(t) { + return this.level === t.level && this.north === t.north && this.south === t.south && this.west === t.west && this.east === t.east; + } + } + class zPt { + constructor() { + this.size = 0; + this.indices = null; + } + } + class HPt { + constructor() { + this.key = new GPt; + this.start = 0; + this.size = 0; + this.buffer = null; + this.primCount = 0; + } + } + class jPt { + static mapIndex(t, e, i) { + return 16 * t + 4 * e + i; + } + constructor() { + this._bodyIndexPool = void 0; + this._connecterIndexPool = void 0; + this._indexMap = []; + this._indexBuffer = new Uint16Array; + this._bodyIndexPool = new Array(4); + for (let t = 0; t < 4; ++t) this._bodyIndexPool[t] = new zPt; + this._connecterIndexPool = new Array(64); + for (let t = 0; t < 4; ++t) for (let e = 0; e < 4; ++e) for (let i = 0; i < 4; ++i) this._connecterIndexPool[jPt.mapIndex(t, e, i)] = new zPt; + for (let t = 0; t < 4; ++t) this._genBodyIndex(t); + for (let t = 0; t < 4; ++t) for (let e = 0; e < 4; ++e) { + this._genConnecterIndexNorth(t, e); + this._genConnecterIndexSouth(t, e); + this._genConnecterIndexWest(t, e); + this._genConnecterIndexEast(t, e); + } + for (let t = 0; t < 4; ++t) for (let e = 0; e < 4; ++e) if (!(e < t)) for (let i = 0; i < 4; ++i) if (!(i < t)) for (let s = 0; s < 4; ++s) if (!(s < t)) for (let n = 0; n < 4; ++n) { + if (n < t) continue; + const r = new GPt; + r.level = t; + r.north = e; + r.south = i; + r.west = s; + r.east = n; + this._genIndexData(r); + } + } + getIndexData(t) { + for (let e = 0; e < this._indexMap.length; ++e) if (this._indexMap[e].key.equals(t)) return this._indexMap[e]; + return null; + } + _genBodyIndex(t) { + const e = 1 << t; + let i = kPt >> t; + let s = 0; + if (t < 3) { + i -= 2; + s = e * VPt + e; + } + if (0 === i || 0 === i) return; + const n = i * i * 6; + this._bodyIndexPool[t].indices = new Uint16Array(n); + let r = 0; + const o = new Uint16Array(n); + let a = s; + let l = a + VPt * e; + for (let t = 0; t < i; ++t) { + for (let t = 0; t < i; ++t) { + o[r++] = l + t * e; + o[r++] = l + (t + 1) * e; + o[r++] = a + t * e; + o[r++] = l + (t + 1) * e; + o[r++] = a + (t + 1) * e; + o[r++] = a + t * e; + } + a += VPt * e; + l += VPt * e; + } + this._bodyIndexPool[t].size = r; + this._bodyIndexPool[t].indices = o; + } + _genConnecterIndexNorth(t, e) { + const i = jPt.mapIndex(t, e, 0); + if (e < t || 3 === t) { + this._connecterIndexPool[i].size = 0; + this._connecterIndexPool[i].indices = null; + return; + } + const s = 1 << t; + const n = 1 << e; + const r = kPt >> t; + let o = 0; + const a = new Uint16Array(2 * r + 2); + a[o++] = 0; + a[o++] = 0; + for (let t = 1; t < r; ++t) { + const e = t * s; + const i = s * VPt + e; + const r = (s - s) * VPt + e / n * n; + a[o++] = i; + a[o++] = r; + } + a[o++] = 32; + a[o++] = 32; + this._connecterIndexPool[i].size = o; + this._connecterIndexPool[i].indices = a; + } + _genConnecterIndexSouth(t, e) { + const i = jPt.mapIndex(t, e, 1); + if (e < t || 3 === t) { + this._connecterIndexPool[i].size = 0; + this._connecterIndexPool[i].indices = null; + return; + } + const s = 1 << t; + const n = 1 << e; + const r = kPt >> t; + let o = 0; + const a = new Uint16Array(2 * r + 2); + a[o++] = 1056; + a[o++] = 1056; + for (let t = 1; t < r; ++t) { + const e = t * s; + const i = 32 - s; + const r = (i + s) * VPt + e / n * n; + const l = i * VPt + e; + a[o++] = r; + a[o++] = l; + } + a[o++] = 1088; + a[o++] = 1088; + this._connecterIndexPool[i].size = o; + this._connecterIndexPool[i].indices = a; + } + _genConnecterIndexWest(t, e) { + const i = jPt.mapIndex(t, e, 2); + if (e < t || 3 === t) { + this._connecterIndexPool[i].size = 0; + this._connecterIndexPool[i].indices = null; + return; + } + const s = 1 << t; + const n = 1 << e; + const r = kPt >> t; + let o = 0; + const a = new Uint16Array(2 * r + 2); + a[o++] = 0; + a[o++] = 0; + for (let t = 1; t < r; ++t) { + const e = t * s / n * n * VPt + 0; + const i = t * s * VPt + s; + a[o++] = e; + a[o++] = i; + } + a[o++] = 1056; + a[o++] = 1056; + this._connecterIndexPool[i].size = o; + this._connecterIndexPool[i].indices = a; + } + _genConnecterIndexEast(t, e) { + const i = jPt.mapIndex(t, e, 3); + if (e < t || 3 === t) { + this._connecterIndexPool[i].size = 0; + this._connecterIndexPool[i].indices = null; + return; + } + const s = 1 << t; + const n = 1 << e; + const r = kPt >> t; + let o = 0; + const a = new Uint16Array(2 * r + 2); + a[o++] = 32; + a[o++] = 32; + for (let t = 1; t < r; ++t) { + const e = t * s * VPt + (32 - s); + const i = t * s / n * n * VPt + 32; + a[o++] = e; + a[o++] = i; + } + a[o++] = 1088; + a[o++] = 1088; + this._connecterIndexPool[i].size = o; + this._connecterIndexPool[i].indices = a; + } + _getConnenterIndex(t, e, i) { + return this._connecterIndexPool[jPt.mapIndex(t, e, i)]; + } + _genIndexData(t) { + let e = this.getIndexData(t); + if (null != e) return e; + const i = this._bodyIndexPool[t.level]; + const s = this._getConnenterIndex(t.level, t.north, 0); + const n = this._getConnenterIndex(t.level, t.south, 1); + const r = this._getConnenterIndex(t.level, t.west, 2); + const o = this._getConnenterIndex(t.level, t.east, 3); + e = new HPt; + e.size = 0; + e.primCount = 0; + null != i.indices && (e.size += i.size); + s.indices && (e.size += 3 * (s.size - 2)); + n.indices && (e.size += 3 * (n.size - 2)); + r.indices && (e.size += 3 * (r.size - 2)); + o.indices && (e.size += 3 * (o.size - 2)); + if (0 === e.size) return null; + let a = 0; + e.buffer = new Uint16Array(e.size); + e.key.level = t.level; + e.key.east = t.east; + e.key.west = t.west; + e.key.north = t.north; + e.key.south = t.south; + if (i.indices) for (let t = 0; t < i.size; ++t) e.buffer[a++] = i.indices[t]; + if (s.indices) for (let t = 0; t < s.size - 2; t += 2) { + const i = s.indices[t + 0]; + const n = s.indices[t + 1]; + const r = s.indices[t + 2]; + const o = s.indices[t + 3]; + e.buffer[a++] = i; + e.buffer[a++] = r; + e.buffer[a++] = n; + e.buffer[a++] = r; + e.buffer[a++] = o; + e.buffer[a++] = n; + } + if (n.indices) for (let t = 0; t < n.size - 2; t += 2) { + const i = n.indices[t + 0]; + const s = n.indices[t + 1]; + const r = n.indices[t + 2]; + const o = n.indices[t + 3]; + e.buffer[a++] = i; + e.buffer[a++] = r; + e.buffer[a++] = s; + e.buffer[a++] = r; + e.buffer[a++] = o; + e.buffer[a++] = s; + } + if (r.indices) for (let t = 0; t < r.size - 2; t += 2) { + const i = r.indices[t + 0]; + const s = r.indices[t + 1]; + const n = r.indices[t + 2]; + const o = r.indices[t + 3]; + e.buffer[a++] = i; + e.buffer[a++] = n; + e.buffer[a++] = s; + e.buffer[a++] = n; + e.buffer[a++] = o; + e.buffer[a++] = s; + } + if (o.indices) for (let t = 0; t < o.size - 2; t += 2) { + const i = o.indices[t + 0]; + const s = o.indices[t + 1]; + const n = o.indices[t + 2]; + const r = o.indices[t + 3]; + e.buffer[a++] = i; + e.buffer[a++] = n; + e.buffer[a++] = s; + e.buffer[a++] = n; + e.buffer[a++] = r; + e.buffer[a++] = s; + } + e.primCount = a / 3; + e.start = this._indexBuffer.length; + this._indexMap.push(e); + const l = new Uint16Array(e.start + e.size); + l.set(this._indexBuffer, 0); + l.set(e.buffer, e.start); + this._indexBuffer = l; + return e; + } + } + var XPt, WPt, YPt, qPt, KPt, JPt, ZPt, QPt, $Pt, tOt, eOt, iOt, sOt, nOt, rOt, oOt, aOt, lOt, hOt, cOt, uOt, _Ot, dOt, pOt, mOt, fOt, gOt, yOt, bOt, SOt, AOt, TOt, vOt, EOt, COt, xOt, wOt, ROt, IOt, MOt, BOt, DOt, POt, OOt, NOt, LOt, FOt, VOt; + let kOt = t("TerrainInfo", Ul("cc.TerrainInfo")(XPt = (WPt = (ZPt = class { + constructor() { + Ml(this, "tileSize", YPt, this); + Ml(this, "blockCount", qPt, this); + Ml(this, "weightMapSize", KPt, this); + Ml(this, "lightMapSize", JPt, this); + } + get size() { + const t = new rs(0, 0); + t.width = this.blockCount[0] * bwt * this.tileSize; + t.height = this.blockCount[1] * bwt * this.tileSize; + return t; + } + get tileCount() { + const t = [ 0, 0 ]; + t[0] = this.blockCount[0] * bwt; + t[1] = this.blockCount[1] * bwt; + return t; + } + get vertexCount() { + const t = this.tileCount; + t[0] += 1; + t[1] += 1; + return t; + } + }, ZPt), YPt = Bl(WPt.prototype, "tileSize", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), qPt = Bl(WPt.prototype, "blockCount", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return [ 1, 1 ]; + } + }), KPt = Bl(WPt.prototype, "weightMapSize", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 128; + } + }), JPt = Bl(WPt.prototype, "lightMapSize", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 128; + } + }), WPt)) || XPt); + let UOt = t("TerrainLayer", Ul("cc.TerrainLayer")(QPt = ($Pt = class { + constructor() { + Ml(this, "detailMap", tOt, this); + Ml(this, "normalMap", eOt, this); + Ml(this, "tileSize", iOt, this); + Ml(this, "metallic", sOt, this); + Ml(this, "roughness", nOt, this); + } + }, tOt = Bl($Pt.prototype, "detailMap", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), eOt = Bl($Pt.prototype, "normalMap", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), iOt = Bl($Pt.prototype, "tileSize", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), sOt = Bl($Pt.prototype, "metallic", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), nOt = Bl($Pt.prototype, "roughness", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), $Pt)) || QPt); + class GOt extends wS { + constructor(...t) { + super(...t); + this._model = null; + this._meshData = null; + this._brushPass = null; + this._brushMaterial = null; + this._currentMaterial = null; + this._currentMaterialLayers = 0; + } + destroy() { + if (null != this._model) { + m.director.root.destroyModel(this._model); + this._model = null; + } + return super.destroy(); + } + _destroyModel() { + if (null != this._model) { + m.director.root.destroyModel(this._model); + this._model = null; + } + } + _invalidMaterial() { + if (null != this._currentMaterial) { + this._clearMaterials(); + this._brushPass = null; + this._currentMaterial = null; + null != this._model && (this._model.enabled = !1); + } + } + _updateMaterial(t, e) { + if (null == this._meshData || null == this._model) return !1; + const i = t.getMaxLayer(); + if (null == this._currentMaterial || i !== this._currentMaterialLayers) { + this._currentMaterial = new hm; + this._currentMaterial.initialize({ + effectAsset: t.getTerrain().getEffectAsset(), + defines: t._getMaterialDefines(i) + }); + if (null !== this._brushMaterial) { + const t = new hm; + t.copy(this._brushMaterial); + this._brushPass = null; + if (null !== t.passes && t.passes.length > 0) { + this._brushPass = t.passes[0]; + this._currentMaterial.passes.push(this._brushPass); + t.passes.pop(); + } + } + e && this._model.initSubModel(0, this._meshData, this._currentMaterial); + this.setMaterial(this._currentMaterial, 0); + this._currentMaterialLayers = i; + this._model.enabled = !0; + this._model.receiveShadow = t.getTerrain().receiveShadow; + return !0; + } + return !1; + } + _onMaterialModified(t, e) { + null != this._model && this._onRebuildPSO(t, e || this._getBuiltinMaterial()); + } + _onRebuildPSO(t, e) { + this._model && this._model.setSubModelMaterial(t, e); + } + _clearMaterials() { + null != this._model && this._onMaterialModified(0, null); + } + _getBuiltinMaterial() { + return xR.get("missing-material"); + } + } + let zOt = t("TerrainBlockLightmapInfo", Ul("cc.TerrainBlockLightmapInfo")(rOt = (oOt = class { + constructor() { + Ml(this, "texture", aOt, this); + Ml(this, "UOff", lOt, this); + Ml(this, "VOff", hOt, this); + Ml(this, "UScale", cOt, this); + Ml(this, "VScale", uOt, this); + } + }, aOt = Bl(oOt.prototype, "texture", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), lOt = Bl(oOt.prototype, "UOff", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), hOt = Bl(oOt.prototype, "VOff", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), cOt = Bl(oOt.prototype, "UScale", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), uOt = Bl(oOt.prototype, "VScale", [ Yl, nh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), oOt)) || rOt); + class HOt { + constructor(t, e, i) { + this._terrain = void 0; + this._node = void 0; + this._renderable = void 0; + this._index = [ 1, 1 ]; + this._weightMap = null; + this._lightmapInfo = null; + this._lodLevel = 0; + this._lodKey = new GPt; + this._errorMetrics = [ 0, 0, 0, 0 ]; + this._LevelDistances = [ UPt, UPt, UPt, UPt ]; + this._bbMin = new Pi; + this._bbMax = new Pi; + this._terrain = t; + this._index[0] = e; + this._index[1] = i; + this._lightmapInfo = t._getLightmapInfo(e, i); + this._node = new _y("TerrainBlock"); + this._node.setParent(this._terrain.node); + this._node.hideFlags |= co.Flags.DontSave | co.Flags.HideInHierarchy; + this._node.layer = this._terrain.node.layer; + this._renderable = this._node.addComponent(GOt); + } + build() { + const t = IR.root.device; + const e = new Float32Array(Awt * Swt * Swt); + this._buildVertexData(e); + const i = t.createBuffer(new An(Ts.VERTEX | Ts.TRANSFER_DST, Cs.DEVICE, Awt * Float32Array.BYTES_PER_ELEMENT * Swt * Swt, Awt * Float32Array.BYTES_PER_ELEMENT)); + i.update(e); + this._buildBoundingBox(); + const s = [ new Vn(cr.ATTR_POSITION, bs.RGB32F), new Vn(cr.ATTR_NORMAL, bs.RGB32F), new Vn(cr.ATTR_TEX_COORD, bs.RG32F) ]; + this._renderable._meshData = new fC([ i ], s, Xs.TRIANGLE_LIST, this._terrain._getSharedIndexBuffer(), null, !1); + this._renderable._model = m.director.root.createModel(wA); + this._renderable._model.createBoundingShape(this._bbMin, this._bbMax); + this._renderable._model.node = this._renderable._model.transform = this._node; + null != this._renderable.node.scene && (this.visible = !0); + this._updateWeightMap(); + this._updateMaterial(!0); + if (this._terrain.lodEnable) { + this._updateLodBuffer(e); + this._updateIndexBuffer(); + } + } + rebuild() { + this._updateHeight(); + this._updateWeightMap(); + this._renderable._invalidMaterial(); + this._updateMaterial(!1); + } + destroy() { + this.visible = !1; + this._renderable._destroyModel(); + null != this._node && this._node.isValid && this._node.destroy(); + null != this._weightMap && this._weightMap.destroy(); + } + update() { + this._updateMaterial(!1); + const t = this._terrain.useNormalMap; + const e = this._terrain.usePBR; + const i = t => null !== t ? t.detailMap : null; + const s = t => { + let e = null !== t ? t.normalMap : null; + null === e && (e = m.builtinResMgr.get("normal-texture")); + return e; + }; + const n = this._renderable._currentMaterial; + if (null !== n) { + const r = this.getMaxLayer(); + const o = new is(1, 1, 1, 1); + const a = new is(1, 1, 1, 1); + const l = new is(0, 0, 0, 0); + if (0 === r) if (-1 !== this.layers[0]) { + const e = this._terrain.getLayer(this.layers[0]); + if (null !== e) { + o.x = 1 / e.tileSize; + a.x = e.roughness; + l.x = e.metallic; + } + n.setProperty("detailMap0", i(e)); + t && n.setProperty("normalMap0", s(e)); + } else { + n.setProperty("detailMap0", m.builtinResMgr.get("default-texture")); + t && n.setProperty("normalMap0", m.builtinResMgr.get("normal-texture")); + } else if (1 === r) { + const e = this._terrain.getLayer(this.layers[0]); + const r = this._terrain.getLayer(this.layers[1]); + if (null !== e) { + o.x = 1 / e.tileSize; + a.x = e.roughness; + l.x = e.metallic; + } + if (null !== r) { + o.y = 1 / r.tileSize; + a.y = r.roughness; + l.y = r.metallic; + } + n.setProperty("weightMap", this._weightMap); + n.setProperty("detailMap0", i(e)); + n.setProperty("detailMap1", i(r)); + if (t) { + n.setProperty("normalMap0", s(e)); + n.setProperty("normalMap1", s(r)); + } + } else if (2 === r) { + const e = this._terrain.getLayer(this.layers[0]); + const r = this._terrain.getLayer(this.layers[1]); + const h = this._terrain.getLayer(this.layers[2]); + if (null !== e) { + o.x = 1 / e.tileSize; + a.x = e.roughness; + l.x = e.metallic; + } + if (null !== r) { + o.y = 1 / r.tileSize; + a.y = r.roughness; + l.y = r.metallic; + } + if (null !== h) { + o.z = 1 / h.tileSize; + a.z = h.roughness; + l.z = h.metallic; + } + n.setProperty("weightMap", this._weightMap); + n.setProperty("detailMap0", i(e)); + n.setProperty("detailMap1", i(r)); + n.setProperty("detailMap2", i(h)); + if (t) { + n.setProperty("normalMap0", s(e)); + n.setProperty("normalMap1", s(r)); + n.setProperty("normalMap2", s(h)); + } + } else if (3 === r) { + const e = this._terrain.getLayer(this.layers[0]); + const r = this._terrain.getLayer(this.layers[1]); + const h = this._terrain.getLayer(this.layers[2]); + const c = this._terrain.getLayer(this.layers[3]); + if (null !== e) { + o.x = 1 / e.tileSize; + a.x = e.roughness; + l.x = e.metallic; + } + if (null !== r) { + o.y = 1 / r.tileSize; + a.y = r.roughness; + l.y = r.metallic; + } + if (null !== h) { + o.z = 1 / h.tileSize; + a.z = h.roughness; + l.z = h.metallic; + } + if (null !== c) { + o.w = 1 / c.tileSize; + a.w = c.roughness; + l.w = c.metallic; + } + n.setProperty("weightMap", this._weightMap); + n.setProperty("detailMap0", i(e)); + n.setProperty("detailMap1", i(r)); + n.setProperty("detailMap2", i(h)); + n.setProperty("detailMap3", i(c)); + if (t) { + n.setProperty("normalMap0", s(e)); + n.setProperty("normalMap1", s(r)); + n.setProperty("normalMap2", s(h)); + n.setProperty("normalMap3", s(c)); + } + } + n.setProperty("UVScale", o); + if (e) { + n.setProperty("roughness", a); + n.setProperty("metallic", l); + } + if (null !== this.lightmap) { + n.setProperty("lightMap", this.lightmap); + n.setProperty("lightMapUVParam", this.lightmapUVParam); + } + } + } + _updateLevel(t) { + const e = new Pi; + const i = new Pi; + Pi.add(e, this._bbMin, this._terrain.node.getWorldPosition()); + Pi.add(i, this._bbMax, this._terrain.node.getWorldPosition()); + const s = Pi.distance(e, t); + const n = Pi.distance(i, t); + let r = Math.min(s, n); + r -= this._terrain.LodBias; + this._lodLevel = 0; + for (;this._lodLevel < 3; ) { + if (r <= this._LevelDistances[this._lodLevel + 1]) break; + ++this._lodLevel; + } + } + setBrushMaterial(t) { + if (this._renderable._brushMaterial !== t) { + this._renderable._invalidMaterial(); + this._renderable._brushMaterial = t; + } + } + _getBrushMaterial() { + return this._renderable ? this._renderable._brushMaterial : null; + } + _getBrushPass() { + return this._renderable ? this._renderable._brushPass : null; + } + get valid() { + if (null === this._terrain) return !1; + const t = this._terrain.getBlocks(); + for (let e = 0; e < t.length; ++e) if (t[e] === this) return !0; + return !1; + } + get material() { + return this._renderable ? this._renderable._currentMaterial : null; + } + get layers() { + return this._terrain.getBlockLayers(this._index[0], this._index[1]); + } + get weightmap() { + return this._weightMap; + } + get lightmap() { + return this._lightmapInfo ? this._lightmapInfo.texture : null; + } + get lightmapUVParam() { + return null != this._lightmapInfo ? new is(this._lightmapInfo.UOff, this._lightmapInfo.VOff, this._lightmapInfo.UScale, this._lightmapInfo.VScale) : new is(0, 0, 0, 0); + } + set visible(t) { + null !== this._renderable._model && (t ? null != this._terrain.node && null != this._terrain.node.scene && null != this._terrain.node.scene.renderScene && null == this._renderable._model.scene && this._terrain.node.scene.renderScene.addModel(this._renderable._model) : null !== this._renderable._model.scene && this._renderable._model.scene.removeModel(this._renderable._model)); + } + get visible() { + return null !== this._renderable._model && null !== this._renderable._model.scene; + } + getTerrain() { + return this._terrain; + } + getIndex() { + return this._index; + } + getRect() { + const t = new as; + t.x = this._index[0] * bwt; + t.y = this._index[1] * bwt; + t.width = bwt; + t.height = bwt; + return t; + } + setLayer(t, e) { + if (this.layers[t] !== e) { + this._terrain.setBlockLayer(this._index[0], this._index[1], t, e); + this._renderable._invalidMaterial(); + this._updateMaterial(!1); + } + } + getLayer(t) { + return this.layers[t]; + } + getMaxLayer() { + return this.layers[3] >= 0 ? 3 : this.layers[2] >= 0 ? 2 : this.layers[1] >= 0 ? 1 : 0; + } + _getMaterialDefines(t) { + return { + LAYERS: t + 1, + CC_USE_LIGHTMAP: null !== this.lightmap ? 1 : 0, + USE_NORMALMAP: this._terrain.useNormalMap ? 1 : 0, + USE_PBR: this._terrain.usePBR ? 1 : 0 + }; + } + _invalidMaterial() { + this._renderable._invalidMaterial(); + } + _updateMaterial(t) { + this._renderable._updateMaterial(this, t) && null !== this.lightmap && this.lightmap.setWrapMode(Zp.CLAMP_TO_BORDER, Zp.CLAMP_TO_BORDER); + } + _updateHeight() { + if (null == this._renderable._meshData) return; + const t = new Float32Array(Awt * Swt * Swt); + this._buildVertexData(t); + this._renderable._meshData.vertexBuffers[0].update(t); + this._buildBoundingBox(); + this._renderable._model.createBoundingShape(this._bbMin, this._bbMax); + this._renderable._model.updateWorldBound(); + this._updateLodBuffer(t); + this._updateIndexBuffer(); + } + _updateWeightMap() { + if (0 === this.getMaxLayer()) { + if (null != this._weightMap) { + this._weightMap.destroy(); + this._weightMap = null; + } + return; + } + if (null == this._weightMap) { + this._weightMap = new LC; + this._weightMap.create(this._terrain.weightMapSize, this._terrain.weightMapSize, Jp.RGBA8888); + this._weightMap.setFilters(Qp.LINEAR, Qp.LINEAR); + this._weightMap.setWrapMode(Zp.CLAMP_TO_EDGE, Zp.CLAMP_TO_EDGE); + } + const t = new Uint8Array(this._terrain.weightMapSize * this._terrain.weightMapSize * 4); + let e = 0; + for (let i = 0; i < this._terrain.weightMapSize; ++i) for (let s = 0; s < this._terrain.weightMapSize; ++s) { + const n = this._index[0] * this._terrain.weightMapSize + s; + const r = this._index[1] * this._terrain.weightMapSize + i; + const o = this._terrain.getWeight(n, r); + t[4 * e + 0] = Math.floor(255 * o.x); + t[4 * e + 1] = Math.floor(255 * o.y); + t[4 * e + 2] = Math.floor(255 * o.z); + t[4 * e + 3] = Math.floor(255 * o.w); + e += 1; + } + this._weightMap.uploadData(t); + } + _updateLightmap(t) { + this._lightmapInfo = t; + this._invalidMaterial(); + } + _updateLod() { + const t = new GPt; + t.level = this._lodLevel; + t.north = this._lodLevel; + t.south = this._lodLevel; + t.west = this._lodLevel; + t.east = this._lodLevel; + if (this._index[0] > 0) { + const e = this.getTerrain().getBlock(this._index[0] - 1, this._index[1]); + t.west = e._lodLevel; + t.west < this._lodLevel && (t.west = this._lodLevel); + } + if (this._index[0] < this._terrain.info.blockCount[0] - 1) { + const e = this.getTerrain().getBlock(this._index[0] + 1, this._index[1]); + t.east = e._lodLevel; + t.east < this._lodLevel && (t.east = this._lodLevel); + } + if (this._index[1] > 0) { + const e = this.getTerrain().getBlock(this._index[0], this._index[1] - 1); + t.north = e._lodLevel; + t.north < this._lodLevel && (t.north = this._lodLevel); + } + if (this._index[1] < this._terrain.info.blockCount[1] - 1) { + const e = this.getTerrain().getBlock(this._index[0], this._index[1] + 1); + t.south = e._lodLevel; + t.south < this._lodLevel && (t.south = this._lodLevel); + } + if (!this._lodKey.equals(t)) { + this._lodKey = t; + this._updateIndexBuffer(); + } + } + _resetLod() { + const t = new GPt; + t.level = 0; + t.north = 0; + t.south = 0; + t.west = 0; + t.east = 0; + if (!this._lodKey.equals(t)) { + this._lodKey = t; + this._updateIndexBuffer(); + } + } + _updateIndexBuffer() { + if (null === this._renderable._meshData) return; + if (null === this._renderable._model) return; + if (0 === this._renderable._model.subModels.length) return; + const t = this._terrain._getIndexData(this._lodKey); + if (null === t) return; + const e = this._renderable._model.subModels[0]; + e.inputAssembler.firstIndex = t.start; + e.inputAssembler.indexCount = t.size; + } + _getHeight(t, e, i) { + return i[(Swt * e + t) * Awt + 1]; + } + _updateLodBuffer(t) { + this._lodLevel = 0; + this._lodKey = new GPt; + this._calcErrorMetrics(t); + this._calcLevelDistances(t); + } + _calcErrorMetrics(t) { + this._errorMetrics[0] = 0; + for (let e = 1; e < 4; ++e) this._errorMetrics[e] = this._calcErrorMetric(e, t); + for (let t = 2; t < 4; ++t) this._errorMetrics[t] = Math.max(this._errorMetrics[t], this._errorMetrics[t - 1]); + } + _calcErrorMetric(t, e) { + let i = 0; + const s = 1 << t; + const n = Swt; + const r = Swt; + const o = n - 1 >> t; + const a = r - 1 >> t; + for (let t = 0; t < r; t += s) for (let n = 0; n < o; ++n) { + const r = n * s; + const o = r + s; + const a = (o + r) / 2; + const l = this._getHeight(r, t, e); + const h = this._getHeight(o, t, e); + const c = this._getHeight(a, t, e); + const u = (l + h) / 2; + const _ = Math.abs(c - u); + i = Math.max(i, _); + } + for (let t = 0; t < n; t += s) for (let n = 0; n < a; ++n) { + const r = n * s; + const o = r + s; + const a = (r + o) / 2; + const l = this._getHeight(t, r, e); + const h = this._getHeight(t, o, e); + const c = this._getHeight(t, a, e); + const u = (l + h) / 2; + const _ = Math.abs(c - u); + i = Math.max(i, _); + } + for (let t = 0; t < a; ++t) { + const n = t * s; + const r = n + s; + const a = (n + r) / 2; + for (let t = 0; t < o; ++t) { + const o = t * s; + const l = o + s; + const h = (o + l) / 2; + const c = this._getHeight(o, n, e); + const u = this._getHeight(l, r, e); + const _ = this._getHeight(h, a, e); + const d = (c + u) / 2; + const p = Math.abs(_ - d); + i = Math.max(i, p); + } + } + return i; + } + _calcLevelDistances(t) { + for (let t = 1; t < 4; ++t) { + const e = 96 * this._errorMetrics[t]; + this._LevelDistances[t] = e; + } + } + _buildVertexData(t) { + let e = 0; + for (let i = 0; i < Swt; ++i) for (let s = 0; s < Swt; ++s) { + const n = this._index[0] * bwt + s; + const r = this._index[1] * bwt + i; + const o = this._terrain.getPosition(n, r); + const a = this._terrain.getNormal(n, r); + const l = new Qi(s / bwt, i / bwt); + t[e++] = o.x; + t[e++] = o.y; + t[e++] = o.z; + t[e++] = a.x; + t[e++] = a.y; + t[e++] = a.z; + t[e++] = l.x; + t[e++] = l.y; + } + } + _buildBoundingBox() { + this._bbMin.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE); + this._bbMax.set(Number.MIN_VALUE, Number.MIN_VALUE, Number.MIN_VALUE); + for (let t = 0; t < Swt; ++t) for (let e = 0; e < Swt; ++e) { + const i = this._index[0] * bwt + e; + const s = this._index[1] * bwt + t; + const n = this._terrain.getPosition(i, s); + Pi.min(this._bbMin, this._bbMin, n); + Pi.max(this._bbMax, this._bbMax, n); + } + } + } + t("TerrainBlock", HOt); + t("Terrain", (_Ot = Ul("cc.Terrain"), dOt = sh(), pOt = Th(Lwt), mOt = Th(Yp), fOt = rh(), + gOt = Th(zOt), yOt = Th(Le), bOt = Th(Le), SOt = Th(Le), AOt = Th(Le), TOt = Th(Ne), + vOt = Th(Lwt), EOt = rh(), COt = Th(Yp), xOt = rh(), wOt = Th(kOt), _Ot(ROt = dOt(ROt = Ql(ROt = Hl(ROt = (IOt = (VOt = class extends Qc { + constructor() { + super(); + Ml(this, "__asset", MOt, this); + Ml(this, "_effectAsset", BOt, this); + Ml(this, "_lightmapInfos", DOt, this); + Ml(this, "_receiveShadow", POt, this); + Ml(this, "_useNormalmap", OOt, this); + Ml(this, "_usePBR", NOt, this); + Ml(this, "_lodEnable", LOt, this); + Ml(this, "_lodBias", FOt, this); + this._buitinAsset = null; + this._tileSize = 1; + this._blockCount = [ 1, 1 ]; + this._weightMapSize = 128; + this._lightMapSize = 128; + this._heights = new Uint16Array; + this._weights = new Uint8Array; + this._normals = new Float32Array; + this._layerList = []; + this._layerBuffer = []; + this._blocks = []; + this._lod = null; + this._sharedIndexBuffer = null; + this._sharedLodIndexBuffer = null; + for (let t = 0; t < ywt; ++t) this._layerList.push(null); + } + set _asset(t) { + this.__asset = t; + if (this._buitinAsset !== this.__asset) { + this._buitinAsset = this.__asset; + for (let t = 0; t < this._blocks.length; ++t) this._blocks[t].destroy(); + this._blocks = []; + if (null === this.__asset) { + this._effectAsset = null; + this._lightmapInfos = []; + this._receiveShadow = !1; + this._useNormalmap = !1; + this._usePBR = !1; + this._tileSize = 1; + this._blockCount = [ 1, 1 ]; + this._weightMapSize = 128; + this._lightMapSize = 128; + this._heights = new Uint16Array; + this._weights = new Uint8Array; + this._normals = new Float32Array; + this._layerBuffer = []; + this._blocks = []; + this._layerList = []; + for (let t = 0; t < ywt; ++t) this._layerList.push(null); + } + zo.gfxDevice && this._buildImp(); + } + } + get _asset() { + return this.__asset; + } + set effectAsset(t) { + if (this._effectAsset !== t) { + this._effectAsset = t; + for (let t = 0; t < this._blocks.length; ++t) this._blocks[t]._invalidMaterial(); + } + } + get effectAsset() { + return this._effectAsset; + } + get receiveShadow() { + return this._receiveShadow; + } + set receiveShadow(t) { + this._receiveShadow = t; + for (let t = 0; t < this._blocks.length; t++) this._blocks[t]._invalidMaterial(); + } + get useNormalMap() { + return this._useNormalmap; + } + set useNormalMap(t) { + this._useNormalmap = t; + for (let t = 0; t < this._blocks.length; t++) this._blocks[t]._invalidMaterial(); + } + get usePBR() { + return this._usePBR; + } + set usePBR(t) { + this._usePBR = t; + for (let t = 0; t < this._blocks.length; t++) this._blocks[t]._invalidMaterial(); + } + get lodEnable() { + return this._lodEnable; + } + set lodEnable(t) { + this._lodEnable = t; + this._lodEnable && null === this._lod && (this._lod = new jPt); + if (!this._lodEnable) for (let t = 0; t < this._blocks.length; t++) this._blocks[t]._resetLod(); + } + get LodBias() { + return this._lodBias; + } + set LodBias(t) { + this._lodBias = t; + } + get size() { + const t = new rs(0, 0); + t.width = this.blockCount[0] * bwt * this.tileSize; + t.height = this.blockCount[1] * bwt * this.tileSize; + return t; + } + get tileSize() { + return this._tileSize; + } + get tileCount() { + return [ this.blockCount[0] * bwt, this.blockCount[1] * bwt ]; + } + get vertexCount() { + const t = this.tileCount; + t[0] += 1; + t[1] += 1; + return t; + } + get blockCount() { + return this._blockCount; + } + get lightMapSize() { + return this._lightMapSize; + } + get weightMapSize() { + return this._weightMapSize; + } + get heights() { + return this._heights; + } + get weights() { + return this._weights; + } + get valid() { + return this._blocks.length > 0; + } + get info() { + const t = new kOt; + t.tileSize = this.tileSize; + t.blockCount[0] = this.blockCount[0]; + t.blockCount[1] = this.blockCount[1]; + t.weightMapSize = this.weightMapSize; + t.lightMapSize = this.lightMapSize; + return t; + } + build(t) { + this._tileSize = t.tileSize; + this._blockCount[0] = t.blockCount[0]; + this._blockCount[1] = t.blockCount[1]; + this._weightMapSize = t.weightMapSize; + this._lightMapSize = t.lightMapSize; + return this._buildImp(); + } + rebuild(t) { + for (let t = 0; t < this._blocks.length; ++t) this._blocks[t].destroy(); + this._blocks = []; + this._resetLightmap(!1); + this._rebuildLayerBuffer(t); + this._rebuildHeights(t); + this._rebuildWeights(t); + this._tileSize = t.tileSize; + this._blockCount[0] = t.blockCount[0]; + this._blockCount[1] = t.blockCount[1]; + this._weightMapSize = t.weightMapSize; + this._lightMapSize = t.lightMapSize; + this._buildNormals(); + for (let t = 0; t < this._blockCount[1]; ++t) for (let e = 0; e < this._blockCount[0]; ++e) this._blocks.push(new HOt(this, e, t)); + for (let t = 0; t < this._blocks.length; ++t) this._blocks[t].build(); + } + importHeightField(t, e) { + let i = 0; + for (let s = 0; s < this.vertexCount[1]; ++s) for (let n = 0; n < this.vertexCount[0]; ++n) { + const r = n / this.tileCount[0]; + const o = s / this.tileCount[1]; + const a = t.getAt(r * t.w, o * t.h) * e; + this._heights[i++] = a; + } + this._buildNormals(); + for (let t = 0; t < this._blocks.length; ++t) this._blocks[t]._updateHeight(); + } + exportHeightField(t, e) { + let i = 0; + for (let s = 0; s < t.h; ++s) for (let n = 0; n < t.w; ++n) { + const r = n / (t.w - 1); + const o = s / (t.h - 1); + const a = r * this.size.width; + const l = o * this.size.height; + const h = this.getHeightAt(a, l); + null != h && (t.data[i++] = h * e); + } + } + exportAsset() { + const t = new Lwt; + t.tileSize = this.tileSize; + t.blockCount = this.blockCount; + t.lightMapSize = this.lightMapSize; + t.weightMapSize = this.weightMapSize; + t.heights = this.heights; + t.weights = this.weights; + t.layerBuffer = new Array(4 * this._blocks.length); + for (let e = 0; e < this._blocks.length; ++e) { + t.layerBuffer[4 * e + 0] = this._blocks[e].layers[0]; + t.layerBuffer[4 * e + 1] = this._blocks[e].layers[1]; + t.layerBuffer[4 * e + 2] = this._blocks[e].layers[2]; + t.layerBuffer[4 * e + 3] = this._blocks[e].layers[3]; + } + this.exportLayerListToAsset(t); + return t; + } + exportLayerListToAsset(t) { + t.layerInfos.length = 0; + for (let e = 0; e < this._layerList.length; ++e) { + const i = this._layerList[e]; + if (i && i.detailMap && po(i.detailMap)) { + const s = new Owt; + s.slot = e; + s.tileSize = i.tileSize; + s.detailMap = i.detailMap; + s.normalMap = i.normalMap; + s.metallic = i.metallic; + s.roughness = i.roughness; + t.layerInfos.push(s); + } + } + } + getEffectAsset() { + return null === this._effectAsset ? m.EffectAsset.get("builtin-terrain") : this._effectAsset; + } + onEnable() { + 0 === this._blocks.length && this._buildImp(); + for (let t = 0; t < this._blocks.length; ++t) this._blocks[t].visible = !0; + m.director.root.pipelineEvent.on(Wf.RENDER_CAMERA_BEGIN, this.onUpdateFromCamera, this); + } + onDisable() { + m.director.root.pipelineEvent.off(Wf.RENDER_CAMERA_BEGIN, this.onUpdateFromCamera, this); + for (let t = 0; t < this._blocks.length; ++t) this._blocks[t].visible = !1; + } + onDestroy() { + for (let t = 0; t < this._blocks.length; ++t) this._blocks[t].destroy(); + this._blocks = []; + for (let t = 0; t < this._layerList.length; ++t) this._layerList[t] = null; + null != this._sharedIndexBuffer && this._sharedIndexBuffer.destroy(); + } + onRestore() { + this.onEnable(); + this._buildImp(!0); + } + update(t) { + for (let t = 0; t < this._blocks.length; ++t) this._blocks[t].update(); + } + onUpdateFromCamera(t) { + if (this.lodEnable && null != this._sharedLodIndexBuffer && t.scene === this._getRenderScene()) { + for (let e = 0; e < this._blocks.length; ++e) this._blocks[e]._updateLevel(t.position); + for (let t = 0; t < this._blocks.length; ++t) this._blocks[t]._updateLod(); + } + } + addLayer(t) { + for (let i = 0; i < this._layerList.length; ++i) { + var e; + if (null === this._layerList[i] || this._layerList[i] && null === (null === (e = this._layerList[i]) || void 0 === e ? void 0 : e.detailMap)) { + this._layerList[i] = t; + this._asset && this.exportLayerListToAsset(this._asset); + return i; + } + } + return -1; + } + setLayer(t, e) { + this._layerList[t] = e; + this._asset && this.exportLayerListToAsset(this._asset); + } + removeLayer(t) { + this._layerList[t] = null; + this._asset && this.exportLayerListToAsset(this._asset); + } + getLayer(t) { + return -1 === t ? null : this._layerList[t]; + } + getPosition(t, e) { + const i = t * this._tileSize; + const s = e * this._tileSize; + const n = this.getHeight(t, e); + return new Pi(i, n, s); + } + getHeightField() { + return this._heights; + } + setHeight(t, e, i) { + i = _i(i, Ewt, Cwt); + this._heights[e * this.vertexCount[0] + t] = Twt + i / vwt; + } + getHeight(t, e) { + return (this._heights[e * this.vertexCount[0] + t] - Twt) * vwt; + } + getHeightClamp(t, e) { + t = _i(t, 0, this.vertexCount[0] - 1); + e = _i(e, 0, this.vertexCount[1] - 1); + return this.getHeight(t, e); + } + getHeightAt(t, e) { + const i = t / this.tileSize; + const s = e / this.tileSize; + let n = Math.floor(i); + let r = Math.floor(s); + let o = n + 1; + let a = r + 1; + const l = i - n; + const h = s - r; + if (n < 0 || n > this.vertexCount[0] - 1 || r < 0 || r > this.vertexCount[1] - 1) return null; + n = _i(n, 0, this.vertexCount[0] - 1); + r = _i(r, 0, this.vertexCount[1] - 1); + o = _i(o, 0, this.vertexCount[0] - 1); + a = _i(a, 0, this.vertexCount[1] - 1); + let c = this.getHeight(n, r); + const u = this.getHeight(o, r); + const _ = this.getHeight(n, a); + let d = this.getHeight(o, a); + const p = .5 * (u + _); + l + h <= 1 ? d = p + (p - c) : c = p + (p - d); + return (c * (1 - l) + u * l) * (1 - h) + (_ * (1 - l) + d * l) * h; + } + _setNormal(t, e, i) { + const s = e * this.vertexCount[0] + t; + this._normals[3 * s + 0] = i.x; + this._normals[3 * s + 1] = i.y; + this._normals[3 * s + 2] = i.z; + } + getNormal(t, e) { + const i = e * this.vertexCount[0] + t; + const s = new Pi; + s.x = this._normals[3 * i + 0]; + s.y = this._normals[3 * i + 1]; + s.z = this._normals[3 * i + 2]; + return s; + } + getNormalAt(t, e) { + const i = t / this.tileSize; + const s = e / this.tileSize; + let n = Math.floor(i); + let r = Math.floor(s); + let o = n + 1; + let a = r + 1; + const l = i - n; + const h = s - r; + if (n < 0 || n > this.vertexCount[0] - 1 || r < 0 || r > this.vertexCount[1] - 1) return null; + n = _i(n, 0, this.vertexCount[0] - 1); + r = _i(r, 0, this.vertexCount[1] - 1); + o = _i(o, 0, this.vertexCount[0] - 1); + a = _i(a, 0, this.vertexCount[1] - 1); + const c = this.getNormal(n, r); + const u = this.getNormal(o, r); + const _ = this.getNormal(n, a); + const d = this.getNormal(o, a); + const p = new Pi; + Pi.add(p, u, _).multiplyScalar(.5); + if (l + h <= 1) { + d.set(p); + d.subtract(c); + d.add(p); + } else { + c.set(p); + c.subtract(d); + c.add(p); + } + const m = new Pi; + const f = new Pi; + const g = new Pi; + Pi.lerp(m, c, u, l); + Pi.lerp(f, _, d, l); + Pi.lerp(g, m, f, h); + return g; + } + setWeight(t, e, i) { + const s = e * this._weightMapSize * this._blockCount[0] + t; + this._weights[4 * s + 0] = 255 * i.x; + this._weights[4 * s + 1] = 255 * i.y; + this._weights[4 * s + 2] = 255 * i.z; + this._weights[4 * s + 3] = 255 * i.w; + } + getWeight(t, e) { + const i = e * this._weightMapSize * this._blockCount[0] + t; + const s = new is; + s.x = this._weights[4 * i + 0] / 255; + s.y = this._weights[4 * i + 1] / 255; + s.z = this._weights[4 * i + 2] / 255; + s.w = this._weights[4 * i + 3] / 255; + return s; + } + getWeightAt(t, e) { + const i = this.weightMapSize * this.blockCount[0]; + const s = this.weightMapSize * this.blockCount[1]; + if (0 === i || 0 === s) return null; + const n = t / i; + const r = e / s; + let o = Math.floor(n); + let a = Math.floor(r); + let l = o + 1; + let h = a + 1; + const c = n - o; + const u = r - a; + if (o < 0 || o > i - 1 || a < 0 || a > s - 1) return null; + o = _i(o, 0, i - 1); + a = _i(a, 0, s - 1); + l = _i(l, 0, i - 1); + h = _i(h, 0, s - 1); + let _ = this.getWeight(o, a); + const d = this.getWeight(l, a); + const p = this.getWeight(o, h); + let m = this.getWeight(l, h); + const f = new is; + is.add(f, d, p).multiplyScalar(.5); + if (c + u <= 1) { + m = new is; + is.subtract(m, f, _).add(f); + } else { + _ = new is; + is.subtract(_, f, m).add(f); + } + const g = new is; + const y = new is; + const b = new is; + is.lerp(g, _, d, c); + is.lerp(y, p, m, c); + is.lerp(b, g, y, u); + return b; + } + getMaxWeightLayerAt(t, e) { + const i = this.weightMapSize * this.blockCount[0]; + const s = this.weightMapSize * this.blockCount[1]; + if (0 === i || 0 === s) return null; + const n = t / i; + const r = e / s; + const o = Math.floor(n); + const a = Math.floor(r); + if (o < 0 || o > i - 1 || a < 0 || a > s - 1) return null; + const l = this.getWeight(o, a); + const h = Math.floor(t / this.weightMapSize); + const c = Math.floor(e / this.weightMapSize); + const u = this.getBlock(h, c); + let _ = 0; + l.y > l[_] && -1 !== u.getLayer(1) && (_ = 1); + l.y > l[_] && -1 !== u.getLayer(2) && (_ = 2); + l.z > l[_] && -1 !== u.getLayer(3) && (_ = 3); + _ = u.getLayer(_); + return this.getLayer(_); + } + getBlockLayers(t, e) { + const i = (e * this._blockCount[0] + t) * gwt; + return [ this._layerBuffer[i], this._layerBuffer[i + 1], this._layerBuffer[i + 2], this._layerBuffer[i + 3] ]; + } + getBlockLayer(t, e, i) { + const s = (e * this._blockCount[0] + t) * gwt; + return this._layerBuffer[s + i]; + } + setBlockLayer(t, e, i, s) { + const n = (e * this._blockCount[0] + t) * gwt; + this._layerBuffer[n + i] = s; + } + getBlock(t, e) { + return this._blocks[e * this._blockCount[0] + t]; + } + getBlocks() { + return this._blocks; + } + rayCheck(t, e, i, s = !0) { + const n = t; + s && Pi.subtract(n, t, this.node.getWorldPosition()); + const r = new Pi; + r.set(e); + r.multiplyScalar(i); + let o = null; + if (e.equals(new Pi(0, 1, 0))) { + const t = this.getHeightAt(n.x, n.z); + null != t && n.y <= t && (o = new Pi(n.x, t, n.z)); + } else if (e.equals(new Pi(0, -1, 0))) { + const t = this.getHeightAt(n.x, n.z); + null != t && n.y >= t && (o = new Pi(n.x, t, n.z)); + } else { + let t = 0; + for (;t++ < 2e3; ) { + const t = this.getHeightAt(n.x, n.z); + if (null != t && n.y <= t) break; + n.add(e); + } + for (;t++ < 2e3; ) { + const t = this.getHeightAt(n.x, n.z); + if (null != t && n.y <= t) { + o = new Pi(n.x, t, n.z); + break; + } + n.add(r); + } + } + return o; + } + _createSharedIndexBuffer() { + const t = zo.gfxDevice; + if (null !== this._lod) { + const e = t.createBuffer(new An(Ts.INDEX | Ts.TRANSFER_DST, Cs.DEVICE, Uint16Array.BYTES_PER_ELEMENT * this._lod._indexBuffer.length, Uint16Array.BYTES_PER_ELEMENT)); + e.update(this._lod._indexBuffer); + return e; + } + { + const e = new Uint16Array(bwt * bwt * 6); + let i = 0; + for (let t = 0; t < bwt; ++t) for (let s = 0; s < bwt; ++s) { + const n = t * Swt + s; + const r = t * Swt + s + 1; + const o = (t + 1) * Swt + s; + const a = (t + 1) * Swt + s + 1; + e[i++] = n; + e[i++] = o; + e[i++] = r; + e[i++] = r; + e[i++] = o; + e[i++] = a; + } + const s = t.createBuffer(new An(Ts.INDEX | Ts.TRANSFER_DST, Cs.DEVICE, Uint16Array.BYTES_PER_ELEMENT * e.length, Uint16Array.BYTES_PER_ELEMENT)); + s.update(e); + return s; + } + } + _getSharedIndexBuffer() { + if (null !== this._sharedIndexBuffer) return this._sharedIndexBuffer; + if (null !== this._sharedLodIndexBuffer) return this._sharedLodIndexBuffer; + if (null !== this._lod) { + this._sharedLodIndexBuffer = this._createSharedIndexBuffer(); + return this._sharedLodIndexBuffer; + } + this._sharedIndexBuffer = this._createSharedIndexBuffer(); + return this._sharedIndexBuffer; + } + _getIndexData(t) { + return null !== this._sharedLodIndexBuffer && null !== this._lod ? this._lod.getIndexData(t) : null; + } + _resetLightmap(t) { + this._lightmapInfos.length = 0; + if (t) for (let t = 0; t < this._blockCount[0] * this._blockCount[1]; ++t) this._lightmapInfos.push(new zOt); + } + _updateLightmap(t, e, i, s, n, r) { + this._lightmapInfos[t].texture = e; + this._lightmapInfos[t].UOff = i; + this._lightmapInfos[t].VOff = s; + this._lightmapInfos[t].UScale = n; + this._lightmapInfos[t].VScale = r; + this._blocks[t]._updateLightmap(this._lightmapInfos[t]); + } + _getLightmapInfo(t, e) { + const i = e * this._blockCount[0] + t; + return i < this._lightmapInfos.length ? this._lightmapInfos[i] : null; + } + _calcNormal(t, e) { + let i = 1; + const s = this.getPosition(t, e); + let n; + let r; + if (t < this.vertexCount[0] - 1) n = this.getPosition(t + 1, e); else { + i *= -1; + n = this.getPosition(t - 1, e); + } + if (e < this.vertexCount[1] - 1) r = this.getPosition(t, e + 1); else { + i *= -1; + r = this.getPosition(t, e - 1); + } + n.subtract(s); + r.subtract(s); + const o = new Pi; + o.set(r); + o.cross(n); + o.multiplyScalar(i); + o.normalize(); + return o; + } + _buildNormals() { + let t = 0; + for (let e = 0; e < this.vertexCount[1]; ++e) for (let i = 0; i < this.vertexCount[0]; ++i) { + const s = this._calcNormal(i, e); + this._normals[3 * t + 0] = s.x; + this._normals[3 * t + 1] = s.y; + this._normals[3 * t + 2] = s.z; + t += 1; + } + } + _buildImp(t = !1) { + if (this.valid) return; + const e = this.__asset; + this._buitinAsset !== e && (this._buitinAsset = e); + if (!t && null !== e) { + this._tileSize = e.tileSize; + this._blockCount = e.blockCount; + this._weightMapSize = e.weightMapSize; + this._lightMapSize = e.lightMapSize; + this._heights = e.heights; + this._normals = e.normals; + this._weights = e.weights; + this._layerBuffer = e.layerBuffer; + for (let t = 0; t < this._layerList.length; ++t) this._layerList[t] = null; + if (e.version < Mwt) for (let t = 0; t < e.layerBinaryInfos.length; ++t) { + const i = new UOt; + const s = e.layerBinaryInfos[t]; + i.tileSize = s.tileSize; + m.assetManager.loadAny(s.detailMapId, ((t, e) => { + i.detailMap = e; + })); + "" !== s.normalMapId && m.assetManager.loadAny(s.normalMapId, ((t, e) => { + i.normalMap = e; + })); + i.roughness = s.roughness; + i.metallic = s.metallic; + this._layerList[s.slot] = i; + } else for (let t = 0; t < e.layerInfos.length; ++t) { + const i = new UOt; + const s = e.layerInfos[t]; + i.tileSize = s.tileSize; + i.detailMap = s.detailMap; + i.normalMap = s.normalMap; + i.roughness = s.roughness; + i.metallic = s.metallic; + this._layerList[s.slot] = i; + } + } + if (0 === this._blockCount[0] || 0 === this._blockCount[1]) return; + const i = this.vertexCount[0] * this.vertexCount[1]; + if (null === this._heights || this._heights.length !== i) { + this._heights = new Uint16Array(i); + this._normals = new Float32Array(3 * i); + for (let t = 0; t < i; ++t) { + this._heights[t] = Twt; + this._normals[3 * t + 0] = 0; + this._normals[3 * t + 1] = 1; + this._normals[3 * t + 2] = 0; + } + } + if (null === this._normals || this._normals.length !== 3 * i) { + this._normals = new Float32Array(3 * i); + this._buildNormals(); + } + const s = this.blockCount[0] * this.blockCount[1] * gwt; + if (null === this._layerBuffer || this._layerBuffer.length !== s) { + this._layerBuffer = new Array(s); + for (let t = 0; t < s; ++t) this._layerBuffer[t] = -1; + } + const n = this._weightMapSize * this._blockCount[0]; + const r = this._weightMapSize * this._blockCount[1]; + if (this._weights.length !== n * r * 4) { + this._weights = new Uint8Array(n * r * 4); + for (let t = 0; t < n * r; ++t) { + this._weights[4 * t + 0] = 255; + this._weights[4 * t + 1] = 0; + this._weights[4 * t + 2] = 0; + this._weights[4 * t + 3] = 0; + } + } + for (let t = 0; t < this._blockCount[1]; ++t) for (let e = 0; e < this._blockCount[0]; ++e) this._blocks.push(new HOt(this, e, t)); + for (let t = 0; t < this._blocks.length; ++t) this._blocks[t].build(); + } + _rebuildHeights(t) { + if (this.vertexCount[0] === t.vertexCount[0] && this.vertexCount[1] === t.vertexCount[1]) return !1; + const e = new Uint16Array(t.vertexCount[0] * t.vertexCount[1]); + for (let t = 0; t < e.length; ++t) e[t] = Twt; + const i = Math.min(this.vertexCount[0], t.vertexCount[0]); + const s = Math.min(this.vertexCount[1], t.vertexCount[1]); + for (let n = 0; n < s; ++n) for (let s = 0; s < i; ++s) { + const i = n * t.vertexCount[0] + s; + const r = n * this.vertexCount[0] + s; + e[i] = this._heights[r]; + } + this._heights = e; + return !0; + } + _rebuildLayerBuffer(t) { + if (this.blockCount[0] === t.blockCount[0] && this.blockCount[1] === t.blockCount[1]) return !1; + const e = []; + e.length = t.blockCount[0] * t.blockCount[1] * gwt; + for (let t = 0; t < e.length; ++t) e[t] = -1; + const i = Math.min(this.blockCount[0], t.blockCount[0]); + const s = Math.min(this.blockCount[1], t.blockCount[1]); + for (let n = 0; n < s; ++n) for (let s = 0; s < i; ++s) { + const i = n * t.blockCount[0] + s; + const r = n * this.blockCount[0] + s; + for (let t = 0; t < gwt; ++t) e[i * gwt + t] = this._layerBuffer[r * gwt + t]; + } + this._layerBuffer = e; + return !0; + } + _rebuildWeights(t) { + const e = this._weightMapSize; + const i = this._weightMapSize * this._blockCount[0]; + const s = this._weightMapSize * this._blockCount[1]; + const n = t.weightMapSize * t.blockCount[0]; + const r = t.weightMapSize * t.blockCount[1]; + if (n === i && r === s) return !1; + const o = new Uint8Array(n * r * 4); + for (let t = 0; t < n * r; ++t) { + o[4 * t + 0] = 255; + o[4 * t + 1] = 0; + o[4 * t + 2] = 0; + o[4 * t + 3] = 0; + } + const a = Math.min(t.blockCount[0], this._blockCount[0]); + const l = Math.min(t.blockCount[1], this._blockCount[1]); + const h = (t, e, s) => { + const n = e * i + t; + const r = new is; + r.x = s[4 * n + 0] / 255; + r.y = s[4 * n + 1] / 255; + r.z = s[4 * n + 2] / 255; + r.w = s[4 * n + 3] / 255; + return r; + }; + const c = (t, i, s, n, r) => { + const o = Math.floor(t); + const a = Math.floor(i); + const l = Math.min(o + 1, e - 1); + const c = Math.min(a + 1, e - 1); + const u = t - o; + const _ = i - a; + const d = h(o + s, a + n, this._weights); + const p = h(l + s, a + n, this._weights); + const m = h(o + s, c + n, this._weights); + const f = h(l + s, c + n, this._weights); + const g = new is; + is.add(g, p, m).multiplyScalar(.5); + if (u + _ <= 1) { + f.set(g); + f.subtract(d); + f.add(g); + } else { + d.set(g); + d.subtract(f); + d.add(g); + } + const y = new is; + const b = new is; + const S = new is; + is.lerp(y, d, p, u); + is.lerp(b, m, f, u); + is.lerp(S, y, b, _); + return S; + }; + for (let i = 0; i < l; ++i) for (let s = 0; s < a; ++s) { + const r = s * e; + const a = i * e; + for (let l = 0; l < t.weightMapSize; ++l) for (let u = 0; u < t.weightMapSize; ++u) { + let _; + if (t.weightMapSize === e) _ = h(u + r, l + a, this._weights); else { + _ = c(u / (t.weightMapSize - 1) * (e - 1), l / (t.weightMapSize - 1) * (e - 1), r, a, this._weights); + } + const d = s * t.weightMapSize + u; + const p = (i * t.weightMapSize + l) * n + d; + o[4 * p + 0] = 255 * _.x; + o[4 * p + 1] = 255 * _.y; + o[4 * p + 2] = 255 * _.z; + o[4 * p + 3] = 255 * _.w; + } + } + this._weights = o; + return !0; + } + }, VOt), MOt = Bl(IOt.prototype, "__asset", [ pOt, Yl, gh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), BOt = Bl(IOt.prototype, "_effectAsset", [ mOt, Yl, gh, fOt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), DOt = Bl(IOt.prototype, "_lightmapInfos", [ gOt, Yl, gh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), POt = Bl(IOt.prototype, "_receiveShadow", [ yOt, Yl, gh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), OOt = Bl(IOt.prototype, "_useNormalmap", [ bOt, Yl, gh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), NOt = Bl(IOt.prototype, "_usePBR", [ SOt, Yl, gh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), LOt = Bl(IOt.prototype, "_lodEnable", [ AOt, Yl, gh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), FOt = Bl(IOt.prototype, "_lodBias", [ TOt, Yl, gh ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Bl(IOt.prototype, "_asset", [ vOt, EOt ], Object.getOwnPropertyDescriptor(IOt.prototype, "_asset"), IOt.prototype), + Bl(IOt.prototype, "effectAsset", [ COt, xOt ], Object.getOwnPropertyDescriptor(IOt.prototype, "effectAsset"), IOt.prototype), + Bl(IOt.prototype, "receiveShadow", [ nh ], Object.getOwnPropertyDescriptor(IOt.prototype, "receiveShadow"), IOt.prototype), + Bl(IOt.prototype, "useNormalMap", [ nh ], Object.getOwnPropertyDescriptor(IOt.prototype, "useNormalMap"), IOt.prototype), + Bl(IOt.prototype, "usePBR", [ nh ], Object.getOwnPropertyDescriptor(IOt.prototype, "usePBR"), IOt.prototype), + Bl(IOt.prototype, "lodEnable", [ nh ], Object.getOwnPropertyDescriptor(IOt.prototype, "lodEnable"), IOt.prototype), + Bl(IOt.prototype, "LodBias", [ nh ], Object.getOwnPropertyDescriptor(IOt.prototype, "LodBias"), IOt.prototype), + Bl(IOt.prototype, "info", [ wOt ], Object.getOwnPropertyDescriptor(IOt.prototype, "info"), IOt.prototype), + IOt)) || ROt) || ROt) || ROt) || ROt)); + let jOt; + !function(t) { + t[t.ORTHO = 0] = "ORTHO"; + t[t.HEX = 1] = "HEX"; + t[t.ISO = 2] = "ISO"; + }(jOt || (jOt = {})); + he(jOt); + let XOt; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.MAP = 1] = "MAP"; + t[t.LAYER = 2] = "LAYER"; + t[t.OBJECTGROUP = 3] = "OBJECTGROUP"; + t[t.OBJECT = 4] = "OBJECT"; + t[t.TILE = 5] = "TILE"; + }(XOt || (XOt = {})); + he(XOt); + let WOt; + !function(t) { + t[t.HORIZONTAL = 2147483648] = "HORIZONTAL"; + t[t.VERTICAL = 1073741824] = "VERTICAL"; + t[t.DIAGONAL = 536870912] = "DIAGONAL"; + t[t.FLIPPED_ALL = 4026531840] = "FLIPPED_ALL"; + t[t.FLIPPED_MASK = 268435455] = "FLIPPED_MASK"; + }(WOt || (WOt = {})); + he(WOt); + let YOt; + !function(t) { + t[t.STAGGERAXIS_X = 0] = "STAGGERAXIS_X"; + t[t.STAGGERAXIS_Y = 1] = "STAGGERAXIS_Y"; + }(YOt || (YOt = {})); + he(YOt); + let qOt; + !function(t) { + t[t.STAGGERINDEX_ODD = 0] = "STAGGERINDEX_ODD"; + t[t.STAGGERINDEX_EVEN = 1] = "STAGGERINDEX_EVEN"; + }(qOt || (qOt = {})); + he(qOt); + let KOt; + !function(t) { + t[t.RightDown = 0] = "RightDown"; + t[t.RightUp = 1] = "RightUp"; + t[t.LeftDown = 2] = "LeftDown"; + t[t.LeftUp = 3] = "LeftUp"; + }(KOt || (KOt = {})); + he(KOt); + let JOt; + !function(t) { + t[t.RECT = 0] = "RECT"; + t[t.ELLIPSE = 1] = "ELLIPSE"; + t[t.POLYGON = 2] = "POLYGON"; + t[t.POLYLINE = 3] = "POLYLINE"; + t[t.IMAGE = 4] = "IMAGE"; + t[t.TEXT = 5] = "TEXT"; + }(JOt || (JOt = {})); + he(JOt); + class ZOt { + constructor() { + this.name = ""; + this.firstGid = 0; + this.spacing = 0; + this.margin = 0; + this.sourceImage = void 0; + this.imageName = null; + this.imageSize = new rs(0, 0); + this.tileOffset = new Qi(0, 0); + this._tileSize = new rs(0, 0); + this.collection = !1; + } + rectForGID(t, e) { + const i = e || new as(0, 0, 0, 0); + i.width = this._tileSize.width; + i.height = this._tileSize.height; + let s = t; + s &= WOt.FLIPPED_MASK; + s -= this.firstGid; + const n = Math.floor((this.imageSize.width - 2 * this.margin + this.spacing) / (this._tileSize.width + this.spacing)); + i.x = Math.round(s % n * (this._tileSize.width + this.spacing) + this.margin); + i.y = Math.round(Math.floor(s / n) * (this._tileSize.height + this.spacing) + this.margin); + return i; + } + } + class QOt { + constructor() { + this.properties = {}; + this.name = ""; + this.objects = []; + this.visible = !0; + this.opacity = 0; + this.color = new Bi(255, 255, 255, 255); + this.offset = new Qi(0, 0); + this.draworder = "topdown"; + this.tintColor = null; + } + getProperties() { + return this.properties; + } + setProperties(t) { + this.properties = t; + } + } + class $Ot { + constructor() { + this.properties = {}; + this.name = ""; + this.layerSize = null; + this.tiles = []; + this.visible = !0; + this.opacity = 0; + this.ownTiles = !0; + this.minGID = 1e5; + this.maxGID = 0; + this.offset = new Qi(0, 0); + this.tintColor = null; + } + getProperties() { + return this.properties; + } + setProperties(t) { + this.properties = t; + } + } + $Ot.ATTRIB_NONE = 1; + $Ot.ATTRIB_BASE64 = 2; + $Ot.ATTRIB_GZIP = 4; + $Ot.ATTRIB_ZLIB = 8; + class tNt { + constructor() { + this.name = ""; + this.visible = !0; + this.width = 0; + this.height = 0; + this.offset = new Qi(0, 0); + this.opacity = 0; + this.trans = new Bi(255, 255, 255, 255); + this.sourceImage = void 0; + this.tintColor = null; + } + } + function eNt(t) { + const e = IP.HorizontalAlign; + switch (t) { + case "center": + return e.CENTER; + + case "right": + return e.RIGHT; + + default: + return e.LEFT; + } + } + function iNt(t) { + const e = IP.VerticalAlign; + switch (t) { + case "center": + return e.CENTER; + + case "bottom": + return e.BOTTOM; + + default: + return e.TOP; + } + } + function sNt(t) { + if (!t) return new Bi(0, 0, 0, 255); + if (8 === (t = -1 !== t.indexOf("#") ? t.substring(1) : t).length) { + const e = parseInt(t.substr(0, 2), 16) || 255; + const i = parseInt(t.substr(2, 2), 16) || 0; + const s = parseInt(t.substr(4, 2), 16) || 0; + const n = parseInt(t.substr(6, 2), 16) || 0; + return new Bi(i, s, n, e); + } + { + const e = parseInt(t.substr(0, 2), 16) || 0; + const i = parseInt(t.substr(2, 2), 16) || 0; + const s = parseInt(t.substr(4, 2), 16) || 0; + return new Bi(e, i, s, 255); + } + } + function nNt(t, e) { + const i = []; + const s = t.getElementsByTagName("properties"); + for (let t = 0; t < s.length; ++t) { + const e = s[t].getElementsByTagName("property"); + for (let t = 0; t < e.length; ++t) i.push(e[t]); + } + e = e || {}; + for (let t = 0; t < i.length; t++) { + const s = i[t]; + const n = s.getAttribute("name"); + const r = s.getAttribute("type") || "string"; + let o = s.getAttribute("value"); + "int" === r ? o = parseInt(o) : "float" === r ? o = parseFloat(o) : "bool" === r ? o = "true" === o : "color" === r && (o = sNt(o)); + e[n] = o; + } + return e; + } + class rNt { + get mapSize() { + return this._mapSize; + } + get tileSize() { + return this._tileSize; + } + constructor(t, e, i, s, n) { + this.properties = {}; + this.orientation = null; + this.parentElement = null; + this.parentGID = 0; + this.layerAttrs = 0; + this.storingCharacters = !1; + this.currentString = null; + this.renderOrder = KOt.RightDown; + this._supportVersion = [ 1, 4, 0 ]; + this._objectGroups = []; + this._allChildren = []; + this._mapSize = new rs(0, 0); + this._tileSize = new rs(0, 0); + this._layers = []; + this._tilesets = []; + this._imageLayers = []; + this._tileProperties = new Map; + this._tileAnimations = {}; + this._tsxContentMap = null; + this._spriteFrameMap = null; + this._spfSizeMap = {}; + this._staggerAxis = null; + this._staggerIndex = null; + this._hexSideLength = 0; + this._imageLayerSPF = null; + this.initWithXML(t, e, i, s, n); + } + getOrientation() { + return this.orientation; + } + setOrientation(t) { + this.orientation = t; + } + getStaggerAxis() { + return this._staggerAxis; + } + setStaggerAxis(t) { + this._staggerAxis = t; + } + getStaggerIndex() { + return this._staggerIndex; + } + setStaggerIndex(t) { + this._staggerIndex = t; + } + getHexSideLength() { + return this._hexSideLength; + } + setHexSideLength(t) { + this._hexSideLength = t; + } + getMapSize() { + return new rs(this._mapSize.width, this._mapSize.height); + } + setMapSize(t) { + this._mapSize.width = t.width; + this._mapSize.height = t.height; + } + get mapWidth() { + return this._mapSize.width; + } + set mapWidth(t) { + this._mapSize.width = t; + } + get mapHeight() { + return this._mapSize.height; + } + set mapHeight(t) { + this._mapSize.height = t; + } + getTileSize() { + return new rs(this._tileSize.width, this._tileSize.height); + } + setTileSize(t) { + this._tileSize.width = t.width; + this._tileSize.height = t.height; + } + get tileWidth() { + return this._tileSize.width; + } + set tileWidth(t) { + this._tileSize.width = t; + } + get tileHeight() { + return this._tileSize.height; + } + set tileHeight(t) { + this._tileSize.height = t; + } + getLayers() { + return this._layers; + } + setLayers(t) { + this._allChildren.push(t); + this._layers.push(t); + } + getImageLayers() { + return this._imageLayers; + } + setImageLayers(t) { + this._allChildren.push(t); + this._imageLayers.push(t); + } + getTilesets() { + return this._tilesets; + } + setTilesets(t) { + this._tilesets.push(t); + } + getObjectGroups() { + return this._objectGroups; + } + setObjectGroups(t) { + this._allChildren.push(t); + this._objectGroups.push(t); + } + getAllChildren() { + return this._allChildren; + } + getParentElement() { + return this.parentElement; + } + setParentElement(t) { + this.parentElement = t; + } + getParentGID() { + return this.parentGID; + } + setParentGID(t) { + this.parentGID = t; + } + getLayerAttribs() { + return this.layerAttrs; + } + setLayerAttribs(t) { + this.layerAttrs = t; + } + getStoringCharacters() { + return this.storingCharacters; + } + setStoringCharacters(t) { + this.storingCharacters = t; + } + getProperties() { + return this.properties; + } + setProperties(t) { + this.properties = t; + } + initWithXML(t, e, i, s, n) { + this._tilesets.length = 0; + this._layers.length = 0; + this._imageLayers.length = 0; + this._tsxContentMap = e; + this._spriteFrameMap = i; + this._imageLayerSPF = n; + this._spfSizeMap = s; + this._objectGroups.length = 0; + this._allChildren.length = 0; + this.properties = {}; + this._tileProperties = new Map; + this._tileAnimations = new Map; + this.currentString = ""; + this.storingCharacters = !1; + this.layerAttrs = $Ot.ATTRIB_NONE; + this.parentElement = null; + return this.parseXMLString(t); + } + parseXMLString(t, e) { + let i; + const s = (new aR).parse(t).documentElement; + const n = s.getAttribute("orientation"); + const r = s.getAttribute("staggeraxis"); + const o = s.getAttribute("staggerindex"); + const a = s.getAttribute("hexsidelength"); + const l = s.getAttribute("renderorder"); + const h = s.getAttribute("version") || "1.0.0"; + if ("map" === s.nodeName) { + const t = h.split("."); + const e = this._supportVersion; + for (i = 0; i < e.length; i++) { + const s = parseInt(t[i]) || 0; + if (e[i] < s) { + P(7216, h); + break; + } + } + "orthogonal" === n ? this.orientation = jOt.ORTHO : "isometric" === n ? this.orientation = jOt.ISO : "hexagonal" === n ? this.orientation = jOt.HEX : null !== n && P(7217, n); + this.renderOrder = "right-up" === l ? KOt.RightUp : "left-up" === l ? KOt.LeftUp : "left-down" === l ? KOt.LeftDown : KOt.RightDown; + "x" === r ? this.setStaggerAxis(YOt.STAGGERAXIS_X) : "y" === r && this.setStaggerAxis(YOt.STAGGERAXIS_Y); + "odd" === o ? this.setStaggerIndex(qOt.STAGGERINDEX_ODD) : "even" === o && this.setStaggerIndex(qOt.STAGGERINDEX_EVEN); + a && this.setHexSideLength(parseFloat(a)); + let c = new rs(0, 0); + c.width = parseFloat(s.getAttribute("width")); + c.height = parseFloat(s.getAttribute("height")); + this.setMapSize(c); + c = new rs(0, 0); + c.width = parseFloat(s.getAttribute("tilewidth")); + c.height = parseFloat(s.getAttribute("tileheight")); + this.setTileSize(c); + this.properties = nNt(s); + } + let c = s.getElementsByTagName("tileset"); + if ("map" !== s.nodeName) { + c = []; + c.push(s); + } + for (i = 0; i < c.length; i++) { + const t = c[i]; + const s = t.getAttribute("source"); + if (s) { + const e = parseInt(t.getAttribute("firstgid")); + const i = this._tsxContentMap[s]; + i && this.parseXMLString(i, e); + } else { + const i = t.getElementsByTagName("image"); + const s = i.length > 1; + const n = i[0]; + let r = n.getAttribute("source"); + r = r.replace(/\\/g, "/"); + const o = t.getElementsByTagName("tile"); + const a = o && o.length || 1; + let l = null; + const h = t.getAttribute("name") || ""; + const c = parseInt(t.getAttribute("spacing")) || 0; + const u = parseInt(t.getAttribute("margin")) || 0; + const _ = e || parseInt(t.getAttribute("firstgid")) || 0; + const d = new rs(0, 0); + d.width = parseFloat(t.getAttribute("tilewidth")); + d.height = parseFloat(t.getAttribute("tileheight")); + const p = t.getElementsByTagName("tileoffset")[0]; + let m = 0; + let f = 0; + if (p) { + m = parseFloat(p.getAttribute("x")) || 0; + f = parseFloat(p.getAttribute("y")) || 0; + } + let g = null; + for (let t = 0; t < a; t++) { + const e = i[t] ? i[t] : n; + if (!e) continue; + let r = e.getAttribute("source"); + r = r.replace(/\\/g, "/"); + if (!g || s) { + g = new ZOt; + g.name = h; + g.firstGid = _ & WOt.FLIPPED_MASK; + g.tileOffset.x = m; + g.tileOffset.y = f; + g.collection = s; + if (!s) { + g.imageName = r; + g.imageSize.width = parseFloat(e.getAttribute("width")) || 0; + g.imageSize.height = parseFloat(e.getAttribute("height")) || 0; + g.sourceImage = this._spriteFrameMap[r]; + if (!g.sourceImage) { + const t = rNt.getNameWithPostfix(r); + g.imageName = t; + g.sourceImage = this._spriteFrameMap[t]; + if (!g.sourceImage) { + const t = rNt.getShortName(r); + g.imageName = t; + g.sourceImage = this._spriteFrameMap[t]; + if (!g.sourceImage) { + console.error(`[error]: ${t} not find in [${Object.keys(this._spriteFrameMap).join(", ")}]`); + F(7221, r); + console.warn(`Please try asset type of ${r} to 'sprite-frame'`); + } + } + } + } + g.spacing = c; + g.margin = u; + g._tileSize.width = d.width; + g._tileSize.height = d.height; + this.setTilesets(g); + } + l = o && o[t]; + if (!l) continue; + this.parentGID = _ + (parseInt(l.getAttribute("id")) || 0); + const a = l.getElementsByTagName("image"); + if (a && a.length > 0) { + const t = a[0]; + let e = t.getAttribute("source"); + e = e.replace(/\\/g, "/"); + g.imageName = e; + g.imageSize.width = parseFloat(t.getAttribute("width")) || 0; + g.imageSize.height = parseFloat(t.getAttribute("height")) || 0; + g._tileSize.width = g.imageSize.width; + g._tileSize.height = g.imageSize.height; + g.sourceImage = this._spriteFrameMap[e]; + if (!g.sourceImage) { + const t = rNt.getNameWithPostfix(e); + g.imageName = t; + g.sourceImage = this._spriteFrameMap[t]; + if (!g.sourceImage) { + const t = rNt.getShortName(e); + g.imageName = t; + g.sourceImage = this._spriteFrameMap[t]; + if (!g.sourceImage) { + F(7221, e); + console.warn(`Please try asset type of ${e} to 'sprite-frame'`); + } + } + } + g.firstGid = this.parentGID & WOt.FLIPPED_MASK; + } + const p = (WOt.FLIPPED_MASK & this.parentGID) >>> 0; + this._tileProperties.set(p, nNt(l)); + const y = l.getElementsByTagName("animation"); + if (y && y.length > 0) { + const t = y[0].getElementsByTagName("frame"); + const e = { + frames: [], + dt: 0, + frameIdx: 0 + }; + this._tileAnimations.set(p, e); + const i = e.frames; + for (let e = 0; e < t.length; e++) { + const s = t[e]; + const n = _ + (parseInt(s.getAttribute("tileid")) || 0); + const r = parseFloat(s.getAttribute("duration")) || 0; + i.push({ + tileid: n, + duration: r / 1e3, + grid: null + }); + } + } + } + } + } + const u = s.childNodes; + for (i = 0; i < u.length; i++) { + const t = u[i]; + if (!this._shouldIgnoreNode(t)) { + if ("imagelayer" === t.nodeName) { + const e = this._parseImageLayer(t); + e && this.setImageLayers(e); + } + if ("layer" === t.nodeName) { + const e = this._parseLayer(t); + this.setLayers(e); + } + if ("objectgroup" === t.nodeName) { + const e = this._parseObjectGroup(t); + this.setObjectGroups(e); + } + } + } + return s; + } + _shouldIgnoreNode(t) { + return 3 === t.nodeType || 8 === t.nodeType || 4 === t.nodeType; + } + _parseImageLayer(t) { + const e = t.getElementsByTagName("image"); + if (!e || 0 === e.length) return null; + const i = new tNt; + i.name = t.getAttribute("name"); + i.offset.x = parseFloat(t.getAttribute("offsetx")) || 0; + i.offset.y = parseFloat(t.getAttribute("offsety")) || 0; + const s = t.getAttribute("visible"); + i.visible = !("0" === s); + const n = t.getAttribute("opacity"); + i.opacity = n ? Math.round(255 * parseFloat(n)) : 255; + const r = t.getAttribute("tintcolor"); + i.tintColor = r ? sNt(r) : null; + const o = e[0]; + const a = o.getAttribute("source"); + i.sourceImage = this._imageLayerSPF[a]; + i.width = parseInt(o.getAttribute("width")) || 0; + i.height = parseInt(o.getAttribute("height")) || 0; + i.trans = sNt(o.getAttribute("trans")); + if (!i.sourceImage) { + F(7221, a); + console.warn(`Please try asset type of ${a} to 'sprite-frame'`); + return null; + } + return i; + } + _parseLayer(t) { + const e = t.getElementsByTagName("data")[0]; + const i = new $Ot; + i.name = t.getAttribute("name"); + const s = new rs(0, 0); + s.width = parseFloat(t.getAttribute("width")); + s.height = parseFloat(t.getAttribute("height")); + i.layerSize = s; + const n = t.getAttribute("visible"); + i.visible = !("0" === n); + const r = t.getAttribute("opacity"); + i.opacity = r ? Math.round(255 * parseFloat(r)) : 255; + i.offset = new Qi(parseFloat(t.getAttribute("offsetx")) || 0, parseFloat(t.getAttribute("offsety")) || 0); + const o = t.getAttribute("tintcolor"); + i.tintColor = o ? sNt(o) : null; + let a = ""; + for (let t = 0; t < e.childNodes.length; t++) a += e.childNodes[t].nodeValue; + a = a.trim(); + const l = e.getAttribute("compression"); + const h = e.getAttribute("encoding"); + if (l && "gzip" !== l && "zlib" !== l) { + P(7218); + return null; + } + let c; + switch (l) { + case "gzip": + c = Wft.unzipBase64AsArray(a, 4); + break; + + case "zlib": + c = function(t) { + if (t.length % 4 != 0) return null; + const e = t.length / 4; + const i = window.Uint32Array ? new Uint32Array(e) : []; + for (let s = 0; s < e; s++) { + const e = 4 * s; + i[s] = t[e] + 256 * t[e + 1] + 65536 * t[e + 2] + t[e + 3] * (1 << 24); + } + return i; + }(new Vft.Inflate(Wft.Base64.decodeAsArray(a, 1)).decompress()); + break; + + case null: + case "": + if ("base64" === h) c = Wft.Base64.decodeAsArray(a, 4); else if ("csv" === h) { + c = []; + const t = a.split(","); + for (let e = 0; e < t.length; e++) c.push(parseInt(t[e])); + } else { + const t = e.getElementsByTagName("tile"); + c = []; + for (let e = 0; e < t.length; e++) c.push(parseInt(t[e].getAttribute("gid"))); + } + break; + + default: + this.layerAttrs === $Ot.ATTRIB_NONE && P(7219); + } + c && (i.tiles = new Uint32Array(c)); + i.properties = nNt(t); + return i; + } + _parseObjectGroup(t) { + const e = new QOt; + e.name = t.getAttribute("name") || ""; + e.offset = new Qi(parseFloat(t.getAttribute("offsetx")), parseFloat(t.getAttribute("offsety"))); + const i = t.getAttribute("opacity"); + e.opacity = i ? Math.round(255 * parseFloat(i)) : 255; + const s = t.getAttribute("tintcolor"); + e.tintColor = s ? sNt(s) : null; + const n = t.getAttribute("visible"); + n && 0 === parseInt(n) && (e.visible = !1); + const r = t.getAttribute("color"); + r && e.color.fromHEX(r); + const o = t.getAttribute("draworder"); + o && (e.draworder = o); + e.setProperties(nNt(t)); + const a = t.getElementsByTagName("object"); + if (a) { + for (let t = 0; t < a.length; t++) { + const i = a[t]; + const s = {}; + s.id = i.getAttribute("id") || t; + s.name = i.getAttribute("name") || ""; + s.width = parseFloat(i.getAttribute("width")) || 0; + s.height = parseFloat(i.getAttribute("height")) || 0; + s.x = parseFloat(i.getAttribute("x")) || 0; + s.y = parseFloat(i.getAttribute("y")) || 0; + s.rotation = parseFloat(i.getAttribute("rotation")) || 0; + nNt(i, s); + const n = i.getAttribute("visible"); + s.visible = !(n && 0 === parseInt(n)); + const r = i.getElementsByTagName("text"); + if (r && r.length > 0) { + const t = r[0]; + s.type = JOt.TEXT; + s.wrap = "1" === t.getAttribute("wrap"); + s.color = sNt(t.getAttribute("color")); + s.halign = eNt(t.getAttribute("halign")); + s.valign = iNt(t.getAttribute("valign")); + s.pixelsize = parseInt(t.getAttribute("pixelsize")) || 16; + s.text = t.childNodes[0].nodeValue; + } + const o = i.getAttribute("gid"); + if (o) { + s.gid = parseInt(o); + s.type = JOt.IMAGE; + } + const l = i.getElementsByTagName("ellipse"); + l && l.length > 0 && (s.type = JOt.ELLIPSE); + const h = i.getElementsByTagName("polygon"); + if (h && h.length > 0) { + s.type = JOt.POLYGON; + const t = h[0].getAttribute("points"); + t && (s.points = this._parsePointsString(t)); + } + const c = i.getElementsByTagName("polyline"); + if (c && c.length > 0) { + s.type = JOt.POLYLINE; + const t = c[0].getAttribute("points"); + t && (s.polylinePoints = this._parsePointsString(t)); + } + s.type || (s.type = JOt.RECT); + e.objects.push(s); + } + "index" !== o && e.objects.sort(((t, e) => t.y - e.y)); + } + return e; + } + _parsePointsString(t) { + if (!t) return null; + const e = []; + const i = t.split(" "); + for (let t = 0; t < i.length; t++) { + const s = i[t].split(","); + e.push({ + x: parseFloat(s[0]), + y: parseFloat(s[1]) + }); + } + return e; + } + setTileAnimations(t) { + this._tileAnimations = t; + } + getTileAnimations() { + return this._tileAnimations; + } + getTileProperties() { + return this._tileProperties; + } + setTileProperties(t) { + this._tileProperties = t; + } + getCurrentString() { + return this.currentString; + } + setCurrentString(t) { + this.currentString = t; + } + static getNameWithPostfix(t) { + const e = (t = t.replace(/\\/g, "/")).lastIndexOf("/") + 1; + const i = t.length; + return t.substring(e, i); + } + static getShortName(t) { + const e = (t = t.replace(/\\/g, "/")).lastIndexOf("/") + 1; + let i = t.lastIndexOf("."); + i = i < 0 ? t.length : i; + return t.substring(e, i); + } + } + var oNt, aNt, lNt, hNt, cNt, uNt, _Nt, dNt, pNt, mNt, fNt, gNt, yNt, bNt; + let SNt = t("TiledTile", (oNt = Ul("cc.TiledTile"), aNt = sh(), lNt = $l(), hNt = Gl(jB), + cNt = Th(Oe), uNt = Th(Oe), _Nt = Th(Oe), dNt = Th(Oe), pNt = Th(Oe), oNt(mNt = aNt(mNt = lNt(mNt = hNt(mNt = Ql(mNt = (fNt = (bNt = class extends Qc { + constructor() { + super(); + this._layer = null; + Ml(this, "_x", gNt, this); + Ml(this, "_y", yNt, this); + } + get x() { + return this._x; + } + set x(t) { + if (t !== this._x) if (this._layer && this._layer.isInvalidPosition(t, this._y)) C("Invalid x, the valid value is between [%s] ~ [%s]", 0, this._layer.layerSize.width); else { + this._resetTile(); + this._x = t; + this.updateInfo(); + } + } + get y() { + return this._y; + } + set y(t) { + if (t !== this._y) if (this._layer && this._layer.isInvalidPosition(this._x, t)) C("Invalid y, the valid value is between [%s] ~ [%s]", 0, this._layer.layerSize.height); else { + this._resetTile(); + this._y = t; + this.updateInfo(); + } + } + get grid() { + return this._layer ? this._layer.getTileGIDAt(this._x, this._y) : 0; + } + set grid(t) { + this._layer && this._layer.setTileGIDAt(t, this._x, this._y); + } + onEnable() { + const t = this.node.parent; + this._layer = t.getComponent("cc.TiledLayer"); + this.node.on(ny.TRANSFORM_CHANGED, this._updatePosition, this); + this.node.on(ny.SIZE_CHANGED, this._updatePosition, this); + this._resetTile(); + this.updateInfo(); + } + onDisable() { + this._resetTile(); + this.node.off(ny.TRANSFORM_CHANGED, this._updatePosition, this); + this.node.off(ny.SIZE_CHANGED, this._updatePosition, this); + } + _resetTile() { + this._layer && this._layer.getTiledTileAt(this._x, this._y) === this && this._layer.setTiledTileAt(this._x, this._y, null); + } + updateInfo() { + if (!this._layer) return; + const t = this._x; + const e = this._y; + if (this._layer.getTiledTileAt(t, e)) { + C("There is already a TiledTile at [%s, %s]", t, e); + return; + } + const i = this._layer.getPositionAt(t, e); + this.node.setPosition(i.x, i.y); + this._layer.setTiledTileAt(t, e, this); + this._layer.markForUpdateRenderData(); + } + _updatePosition() { + this._layer.markForUpdateRenderData(); + } + }, bNt), gNt = Bl(fNt.prototype, "_x", [ cNt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), yNt = Bl(fNt.prototype, "_y", [ uNt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Bl(fNt.prototype, "x", [ _Nt ], Object.getOwnPropertyDescriptor(fNt.prototype, "x"), fNt.prototype), + Bl(fNt.prototype, "y", [ dNt ], Object.getOwnPropertyDescriptor(fNt.prototype, "y"), fNt.prototype), + Bl(fNt.prototype, "grid", [ pNt ], Object.getOwnPropertyDescriptor(fNt.prototype, "grid"), fNt.prototype), + fNt)) || mNt) || mNt) || mNt) || mNt) || mNt)); + function ANt(t, e, i) { + const s = i || t.sourceImage; + const n = s.texture; + const r = t.collection; + if (!t.imageSize.width || !t.imageSize.height) { + const e = t.sourceImage; + t.imageSize.width = e.width; + t.imageSize.height = e.height; + } + const o = t.imageSize.width; + const a = t.imageSize.height; + const l = t._tileSize.width; + const h = t._tileSize.height; + const c = s.width; + const u = s.height; + const _ = t.spacing; + const d = t.margin; + let p = 1; + if (!r) { + const t = Math.floor((o - 2 * d + _) / (l + _)); + const e = Math.floor((a - 2 * d + _) / (h + _)); + p = Math.max(1, e * t); + } + const m = t.firstGid; + let f = null; + let g = !!e.get(m); + const y = t.firstGid + p; + let b = m; + for (;b < y; ++b) { + g && !e.get(b) && (g = !1); + if (!g && e.get(b)) break; + f = { + tileset: t, + x: 0, + y: 0, + width: l, + height: h, + t: 0, + l: 0, + r: 0, + b: 0, + cx: 0, + cy: 0, + offsetX: 0, + offsetY: 0, + rotated: !1, + gid: b, + spriteFrame: s, + texture: n + }; + t.rectForGID(b, f); + if (!i || p > 1) if (i) { + f._name = i.name; + const t = i.unbiasUV[0]; + const e = i.rotated ? i.unbiasUV[1] : i.unbiasUV[5]; + f.l = t + (f.x + .5) / c; + f.t = e + (f.y + .5) / u; + f.r = t + (f.x + f.width - .5) / c; + f.b = e + (f.y + f.height - .5) / u; + f._rect = new as(f.x, f.y, f.width, f.height); + } else { + f.l = f.x / c; + f.t = f.y / u; + f.r = (f.x + f.width) / c; + f.b = (f.y + f.height) / u; + f._rect = new as(f.x, f.y, f.width, f.height); + } else if (i.rotated) { + f._rotated = !0; + f._name = i.name; + f._rect = i.getRect(); + f.l = i.unbiasUV[0]; + f.t = i.unbiasUV[1]; + f.r = i.unbiasUV[4]; + f.b = i.unbiasUV[3]; + } else { + f._name = i.name; + f._rect = i.getRect(); + f.l = i.unbiasUV[0]; + f.t = i.unbiasUV[5]; + f.r = i.unbiasUV[2]; + f.b = i.unbiasUV[1]; + } + f.cx = (f.l + f.r) / 2; + f.cy = (f.t + f.b) / 2; + e.set(b, f); + } + } + var TNt, vNt, ENt; + const CNt = new qi; + const xNt = new Qi; + const wNt = new Pi; + const RNt = new Pi; + const INt = { + row: 0, + col: 0 + }; + let MNt = t("TiledUserNodeData", Ul("cc.TiledUserNodeData")(TNt = class extends Qc { + constructor() { + super(); + this._index = -1; + this._row = -1; + this._col = -1; + this._tiledLayer = null; + } + }) || TNt); + let BNt = t("TiledLayer", Ul("cc.TiledLayer")(vNt = (ENt = class t extends uD { + get cullingRect() { + return this._cullingRect; + } + get rightTop() { + return this._rightTop; + } + get layerSize() { + return this._layerSize; + } + get tiledDataArray() { + return this._tiledDataArray; + } + get leftDownToCenterX() { + return this._leftDownToCenterX; + } + get leftDownToCenterY() { + return this._leftDownToCenterY; + } + requestDrawInfo(t) { + if (!this._drawInfoList[t]) { + this._drawInfoList[t] = new aB; + this._drawInfoList[t].setDrawInfoType(oB.IA); + } + return this._drawInfoList[t]; + } + constructor() { + super(); + this._userNodeGrid = {}; + this._userNodeMap = {}; + this._userNodeDirty = !1; + this.tiledTiles = []; + this._viewPort = { + x: -1, + y: -1, + width: -1, + height: -1 + }; + this._cullingRect = { + leftDown: { + row: -1, + col: -1 + }, + rightTop: { + row: -1, + col: -1 + } + }; + this._cullingDirty = !0; + this._rightTop = { + row: -1, + col: -1 + }; + this._layerInfo = null; + this._mapInfo = null; + this._topOffset = 0; + this._downOffset = 0; + this._leftOffset = 0; + this._rightOffset = 0; + this.tiles = []; + this.vertices = []; + this._verticesDirty = !0; + this._layerName = ""; + this._layerSize = void 0; + this._minGID = void 0; + this._maxGID = void 0; + this._layerOrientation = null; + this._opacity = void 0; + this._tintColor = void 0; + this.texGrids = null; + this._textures = []; + this._tilesets = []; + this._leftDownToCenterX = 0; + this._leftDownToCenterY = 0; + this._hasTiledNodeGrid = !1; + this._hasAniGrid = !1; + this._animations = null; + this._enableCulling = void 0; + this.colorChanged = !1; + this._properties = void 0; + this.renderOrder = void 0; + this._staggerAxis = void 0; + this._staggerIndex = void 0; + this._hexSideLength = void 0; + this._mapTileSize = void 0; + this._odd_even = void 0; + this._diffX1 = void 0; + this._diffY1 = void 0; + this._useAutomaticVertexZ = void 0; + this._vertexZvalue = void 0; + this._offset = void 0; + this._tiledDataArray = []; + this._drawInfoList = []; + this._tiledDataArrayIdx = 0; + } + hasTiledNode() { + return this._hasTiledNodeGrid; + } + hasAnimation() { + return this._hasAniGrid; + } + set enableCulling(t) { + if (this._enableCulling !== t) { + this._enableCulling = t; + this._cullingDirty = !0; + this.markForUpdateRenderData(); + } + } + get enableCulling() { + return this._enableCulling; + } + addUserNode(t) { + let e = t.getComponent(MNt); + if (e) { + C("CCTiledLayer:addUserNode node has been added"); + return !1; + } + e = t.addComponent(MNt); + t.parent = this.node; + this._userNodeMap[t.uuid] = e; + e._row = -1; + e._col = -1; + e._tiledLayer = this; + this._nodeLocalPosToLayerPos(t.getPosition(), xNt); + this._positionToRowCol(xNt.x, xNt.y, INt); + this._addUserNodeToGrid(e, INt); + this._updateCullingOffsetByUserNode(t); + t.on(ny.TRANSFORM_CHANGED, this._userNodePosChange, e); + t.on(ny.SIZE_CHANGED, this._userNodeSizeChange, e); + return !0; + } + removeUserNode(t) { + const e = t.getComponent(MNt); + if (!e) { + C("CCTiledLayer:removeUserNode node is not exist"); + return !1; + } + t.off(ny.TRANSFORM_CHANGED, this._userNodePosChange, e); + t.off(ny.SIZE_CHANGED, this._userNodeSizeChange, e); + this._removeUserNodeFromGrid(e); + delete this._userNodeMap[t.uuid]; + t._removeComponent(e); + e.destroy(); + t.removeFromParent(); + return !0; + } + destroyUserNode(t) { + this.removeUserNode(t); + t.destroy(); + } + _nodeLocalPosToLayerPos(t, e) { + e.x = t.x + this._leftDownToCenterX; + e.y = t.y + this._leftDownToCenterY; + } + getNodesByRowCol(t, e) { + const i = this._userNodeGrid[t]; + return i ? i[e] : null; + } + getNodesCountByRow(t) { + const e = this._userNodeGrid[t]; + return e ? e.count : 0; + } + _updateAllUserNode() { + this._userNodeGrid = {}; + for (const t in this._userNodeMap) { + const e = this._userNodeMap[t]; + this._nodeLocalPosToLayerPos(e.node.getPosition(), xNt); + this._positionToRowCol(xNt.x, xNt.y, INt); + this._addUserNodeToGrid(e, INt); + this._updateCullingOffsetByUserNode(e.node); + } + } + _updateCullingOffsetByUserNode(t) { + const e = t._uiProps.uiTransformComp.contentSize; + this._topOffset < e.height && (this._topOffset = e.height); + this._downOffset < e.height && (this._downOffset = e.height); + this._leftOffset < e.width && (this._leftOffset = e.width); + this._rightOffset < e.width && (this._rightOffset = e.width); + } + _userNodeSizeChange() { + const t = this.node; + const e = this._tiledLayer; + e._updateCullingOffsetByUserNode(t); + e._userNodeDirty = !0; + e.markForUpdateRenderData(); + } + _userNodePosChange() { + const t = this; + const e = t.node; + const i = t._tiledLayer; + i._nodeLocalPosToLayerPos(e.getPosition(), xNt); + i._positionToRowCol(xNt.x, xNt.y, INt); + i._limitInLayer(INt); + if (INt.row !== t._row || INt.col !== t._col) { + i._removeUserNodeFromGrid(t); + i._addUserNodeToGrid(t, INt); + } + } + _removeUserNodeFromGrid(t) { + const e = t._row; + const i = t._col; + const s = t._index; + const n = this._userNodeGrid[e]; + const r = n && n[i]; + if (r) { + n.count--; + r.count--; + r.list[s] = null; + if (r.count <= 0) { + r.list.length = 0; + r.count = 0; + } + } + t._row = -1; + t._col = -1; + t._index = -1; + this._userNodeDirty = !0; + this.markForUpdateRenderData(); + } + _limitInLayer(t) { + const e = t.row; + const i = t.col; + e < 0 && (t.row = 0); + e > this._rightTop.row && (t.row = this._rightTop.row); + i < 0 && (t.col = 0); + i > this._rightTop.col && (t.col = this._rightTop.col); + } + _addUserNodeToGrid(t, e) { + const i = e.row; + const s = e.col; + const n = this._userNodeGrid[i] = this._userNodeGrid[i] || { + count: 0 + }; + const r = n[s] = n[s] || { + count: 0, + list: [] + }; + t._row = i; + t._col = s; + t._index = r.list.length; + n.count++; + r.count++; + r.list.push(t); + this._userNodeDirty = !0; + } + isUserNodeDirty() { + return this._userNodeDirty; + } + setUserNodeDirty(t) { + this._userNodeDirty = t; + } + onEnable() { + super.onEnable(); + this.node.on(ny.ANCHOR_CHANGED, this._syncAnchorPoint, this); + this.node.on(ny.TRANSFORM_CHANGED, this.updateCulling, this); + this.node.on(ny.SIZE_CHANGED, this.updateCulling, this); + this.node.parent.on(ny.TRANSFORM_CHANGED, this.updateCulling, this); + this.node.parent.on(ny.SIZE_CHANGED, this.updateCulling, this); + this.markForUpdateRenderData(); + this.scheduleOnce(this.updateCulling.bind(this)); + } + onDisable() { + var t, e; + super.onDisable(); + null === (t = this.node.parent) || void 0 === t || t.off(ny.SIZE_CHANGED, this.updateCulling, this); + null === (e = this.node.parent) || void 0 === e || e.off(ny.TRANSFORM_CHANGED, this.updateCulling, this); + this.node.off(ny.SIZE_CHANGED, this.updateCulling, this); + this.node.off(ny.TRANSFORM_CHANGED, this.updateCulling, this); + this.node.off(ny.ANCHOR_CHANGED, this._syncAnchorPoint, this); + } + _syncAnchorPoint() { + const t = this.node; + const e = t._uiProps.uiTransformComp; + const i = t.getScale(); + this._leftDownToCenterX = e.width * e.anchorX * i.x; + this._leftDownToCenterY = e.height * e.anchorY * i.y; + this._cullingDirty = !0; + this.markForUpdateRenderData(); + } + getLayerName() { + return this._layerName; + } + setLayerName(t) { + this._layerName = t; + } + getProperty(t) { + return this._properties[t]; + } + getPositionAt(t, e) { + let i; + if (void 0 !== e) { + i = Math.floor(t); + e = Math.floor(e); + } else { + i = Math.floor(t.x); + e = Math.floor(t.y); + } + switch (this._layerOrientation) { + case jOt.ORTHO: + return this._positionForOrthoAt(i, e); + + case jOt.ISO: + return this._positionForIsoAt(i, e); + + case jOt.HEX: + return this._positionForHexAt(i, e); + } + return null; + } + isInvalidPosition(t, e) { + return t >= this._layerSize.width || e >= this._layerSize.height || t < 0 || e < 0; + } + _positionForIsoAt(t, e) { + let i = 0; + let s = 0; + const n = Math.floor(t) + Math.floor(e) * this._layerSize.width; + const r = this.tiles[n]; + if (r) { + const t = (r & WOt.FLIPPED_MASK) >>> 0; + const e = this.texGrids.get(t).tileset.tileOffset; + i = e.x; + s = e.y; + } + return new Qi(.5 * this._mapTileSize.width * (this._layerSize.height + t - e - 1) + i, .5 * this._mapTileSize.height * (this._layerSize.width - t + this._layerSize.height - e - 2) - s); + } + _positionForOrthoAt(t, e) { + let i = 0; + let s = 0; + const n = Math.floor(t) + Math.floor(e) * this._layerSize.width; + const r = this.tiles[n]; + if (r) { + const t = (r & WOt.FLIPPED_MASK) >>> 0; + const e = this.texGrids.get(t).tileset.tileOffset; + i = e.x; + s = e.y; + } + return new Qi(t * this._mapTileSize.width + i, (this._layerSize.height - e - 1) * this._mapTileSize.height - s); + } + _positionForHexAt(t, e) { + const i = this._mapTileSize.width; + const s = this._mapTileSize.height; + const n = this._layerSize.height; + const r = Math.floor(t) + Math.floor(e) * this._layerSize.width; + const o = (this.tiles[r] & WOt.FLIPPED_MASK) >>> 0; + let a; + a = this.texGrids.get(o) ? this.texGrids.get(o).tileset.tileOffset : { + x: 0, + y: 0 + }; + const l = this._staggerIndex === qOt.STAGGERINDEX_ODD ? 1 : -1; + let h = 0; + let c = 0; + let u = 0; + let _ = 0; + switch (this._staggerAxis) { + case YOt.STAGGERAXIS_Y: + u = 0; + e % 2 == 1 && (u = i / 2 * l); + h = t * i + u + a.x; + c = (n - e - 1) * (s - (s - this._hexSideLength) / 2) - a.y; + break; + + case YOt.STAGGERAXIS_X: + _ = 0; + t % 2 == 1 && (_ = s / 2 * -l); + h = t * (i - (i - this._hexSideLength) / 2) + a.x; + c = (n - e - 1) * s + _ - a.y; + } + return new Qi(h, c); + } + setTilesGIDAt(t, e, i, s) { + if (!t || 0 === t.length || s <= 0) return; + i < 0 && (i = 0); + e < 0 && (e = 0); + let n = 0; + const r = e + s; + for (let s = i; ;s++) for (let i = e; i < r; i++) { + if (n >= t.length) return; + this._updateTileForGID(t[n], i, s); + n++; + } + } + setTileGIDAt(t, e, i, s) { + const n = (t & WOt.FLIPPED_MASK) >>> 0; + e = Math.floor(e); + i = Math.floor(i); + if (this.isInvalidPosition(e, i)) throw new Error("cc.TiledLayer.setTileGIDAt(): invalid position"); + if (this.tiles && this._tilesets && 0 !== this._tilesets.length) if (0 !== n && n < this._tilesets[0].firstGid) P(7239, t); else { + s = s || 0; + this._updateTileForGID((n | s) >>> 0, e, i); + } else P(7238); + } + _updateTileForGID(t, e, i) { + const s = 0 | e + i * this._layerSize.width; + if (s >= this.tiles.length) return; + if (t === this.tiles[s]) return; + const n = (t & WOt.FLIPPED_MASK) >>> 0; + if (this.texGrids.get(n)) { + this.tiles[s] = t; + this._updateVertex(e, i); + } else this.tiles[s] = 0; + this._cullingDirty = !0; + } + getTileGIDAt(t, e) { + if (this.isInvalidPosition(t, e)) throw new Error("cc.TiledLayer.getTileGIDAt(): invalid position"); + if (!this.tiles) { + P(7237); + return null; + } + const i = Math.floor(t) + Math.floor(e) * this._layerSize.width; + return (this.tiles[i] & WOt.FLIPPED_MASK) >>> 0; + } + getTileFlagsAt(t, e) { + if (this.isInvalidPosition(t, e)) throw new Error("TiledLayer.getTileFlagsAt: invalid position"); + if (!this.tiles) { + P(7240); + return null; + } + const i = Math.floor(t) + Math.floor(e) * this._layerSize.width; + return (this.tiles[i] & WOt.FLIPPED_ALL) >>> 0; + } + setCullingDirty(t) { + this._cullingDirty = t; + } + isCullingDirty() { + return this._cullingDirty; + } + updateViewPort(t, e, i, s) { + if (this._viewPort.width === i && this._viewPort.height === s && this._viewPort.x === t && this._viewPort.y === e) return; + this._viewPort.x = t; + this._viewPort.y = e; + this._viewPort.width = i; + this._viewPort.height = s; + let n = 1; + this._layerOrientation === jOt.ISO && (n = 2); + const r = this._viewPort.x - this._offset.x + this._leftDownToCenterX; + const o = this._viewPort.y - this._offset.y + this._leftDownToCenterY; + let a = r - this._leftOffset; + let l = o - this._downOffset; + const h = r + i + this._rightOffset; + const c = o + s + this._topOffset; + const u = this._cullingRect.leftDown; + const _ = this._cullingRect.rightTop; + a < 0 && (a = 0); + l < 0 && (l = 0); + this._positionToRowCol(a, l, INt); + INt.row -= n; + INt.col -= n; + INt.row = INt.row > 0 ? INt.row : 0; + INt.col = INt.col > 0 ? INt.col : 0; + if (INt.row !== u.row || INt.col !== u.col) { + u.row = INt.row; + u.col = INt.col; + this._cullingDirty = !0; + } + if (h < 0 || c < 0) { + INt.row = -1; + INt.col = -1; + } else { + this._positionToRowCol(h, c, INt); + INt.row++; + INt.col++; + } + INt.row > this._rightTop.row && (INt.row = this._rightTop.row); + INt.col > this._rightTop.col && (INt.col = this._rightTop.col); + if (INt.row !== _.row || INt.col !== _.col) { + _.row = INt.row; + _.col = INt.col; + this._cullingDirty = !0; + this.markForUpdateRenderData(); + } + } + _positionToRowCol(t, e, i) { + const s = this._mapTileSize.width; + const n = this._mapTileSize.height; + const r = .5 * s; + const o = .5 * n; + let a = 0; + let l = 0; + let h = 0; + let c = 0; + const u = this._staggerAxis; + switch (this._layerOrientation) { + case jOt.ORTHO: + l = Math.floor(t / s); + a = Math.floor(e / n); + break; + + case jOt.ISO: + l = Math.floor(t / r); + a = Math.floor(e / o); + break; + + case jOt.HEX: + if (u === YOt.STAGGERAXIS_Y) { + a = Math.floor(e / (n - this._diffY1)); + h = a % 2 == 1 ? r * this._odd_even : 0; + l = Math.floor((t - h) / s); + } else { + l = Math.floor(t / (s - this._diffX1)); + c = l % 2 == 1 ? o * -this._odd_even : 0; + a = Math.floor((e - c) / n); + } + } + i.row = a; + i.col = l; + return i; + } + updateCulling() { + if (this._enableCulling) { + this.node.updateWorldTransform(); + qi.invert(CNt, this.node.getWorldMatrix()); + const t = IR.root.batcher2D.getFirstRenderCamera(this.node); + if (t) { + wNt.x = 0; + wNt.y = 0; + wNt.z = 0; + RNt.x = t.width; + RNt.y = t.height; + RNt.z = 0; + t.screenToWorld(wNt, wNt); + t.screenToWorld(RNt, RNt); + Pi.transformMat4(wNt, wNt, CNt); + Pi.transformMat4(RNt, RNt, CNt); + this.updateViewPort(wNt.x, wNt.y, RNt.x - wNt.x, RNt.y - wNt.y); + } + } + } + getLayerOrientation() { + return this._layerOrientation; + } + getProperties() { + return this._properties; + } + _updateVertex(t, e) { + const i = WOt.FLIPPED_MASK; + const s = this.vertices; + const n = this._layerOrientation; + const r = this.tiles; + if (!r) return; + const o = this._rightTop; + const a = this._mapTileSize.width; + const l = this._mapTileSize.height; + const h = .5 * a; + const c = .5 * l; + const u = this._layerSize.height; + const _ = this._layerSize.width; + const d = this.texGrids; + let p = 0; + let m = 0; + let f; + let g; + let y; + let b; + let S; + let A; + if (n === jOt.HEX) { + f = this._staggerAxis; + g = this._diffX1; + y = this._diffY1; + b = this._odd_even; + } + let T = 0; + let v = 0; + let E = 0; + let C = 0; + let x = 0; + let w = 0; + let R = 0; + const I = e * _ + t; + E = (r[I] & i) >>> 0; + const M = d.get(E); + if (!M) return; + this._animations.get(E) && (this._hasAniGrid = this._hasAniGrid || !0); + switch (n) { + case jOt.ORTHO: + T = t; + v = u - e - 1; + p = T * a; + m = v * l; + break; + + case jOt.ISO: + T = u + t - e - 1; + v = u + _ - t - e - 2; + p = h * T; + m = c * v; + break; + + case jOt.HEX: + S = f === YOt.STAGGERAXIS_Y && e % 2 == 1 ? h * b : 0; + A = f === YOt.STAGGERAXIS_X && t % 2 == 1 ? c * -b : 0; + p = t * (a - g) + S; + m = (u - e - 1) * (l - y) + A; + T = t; + v = u - e - 1; + } + const B = s[v] = s[v] || { + minCol: 0, + maxCol: 0 + }; + const D = B[T] = B[T] || {}; + B.minCol > T && (B.minCol = T); + B.maxCol < T && (B.maxCol = T); + if (o.row < v) { + o.row = v; + n === jOt.ISO && (o.row += 1); + } + if (o.col < T) { + o.col = T; + n === jOt.ISO && (o.col += 1); + } + const P = M.tileset.tileOffset; + p += this._offset.x + P.x + M.offsetX; + m += this._offset.y - P.y - M.offsetY; + C = -P.y + M.tileset._tileSize.height - l; + C = C < 0 ? 0 : C; + x = P.y < 0 ? 0 : P.y; + w = -P.x < 0 ? 0 : -P.x; + R = P.x + M.tileset._tileSize.width - a; + R = R < 0 ? 0 : R; + this._rightOffset < w && (this._rightOffset = w); + this._leftOffset < R && (this._leftOffset = R); + this._topOffset < x && (this._topOffset = x); + this._downOffset < C && (this._downOffset = C); + D.left = p; + D.bottom = m; + D.index = I; + this._cullingDirty = !0; + } + _updateVertices() { + this.vertices.length = 0; + if (!this.tiles) return; + const t = this._rightTop; + t.row = -1; + t.col = -1; + const e = this._layerSize.height; + const i = this._layerSize.width; + this._topOffset = 0; + this._downOffset = 0; + this._leftOffset = 0; + this._rightOffset = 0; + this._hasAniGrid = !1; + for (let t = 0; t < e; ++t) for (let e = 0; e < i; ++e) this._updateVertex(e, t); + this._verticesDirty = !1; + } + getTiledTileAt(t, e, i) { + if (this.isInvalidPosition(t, e)) throw new Error("TiledLayer.getTiledTileAt: invalid position"); + if (!this.tiles) { + P(7236); + return null; + } + const s = Math.floor(t) + Math.floor(e) * this._layerSize.width; + let n = this.tiledTiles[s]; + if (!n && i) { + const i = new _y; + n = i.addComponent(SNt); + n._x = t; + n._y = e; + n._layer = this; + n.updateInfo(); + i.parent = this.node; + return n; + } + return n; + } + setTiledTileAt(t, e, i) { + if (this.isInvalidPosition(t, e)) throw new Error("TiledLayer.setTiledTileAt: invalid position"); + if (!this.tiles) { + P(7236); + return null; + } + const s = Math.floor(t) + Math.floor(e) * this._layerSize.width; + this.tiledTiles[s] = i; + this._cullingDirty = !0; + this._hasTiledNodeGrid = !!i || this.tiledTiles.some((t => !!t)); + return i; + } + getTexture(t) { + t = t || 0; + return this._textures && t >= 0 && this._textures.length > t ? this._textures[t] : null; + } + getTextures() { + return this._textures; + } + setTexture(t) { + this.setTextures([ t ]); + } + setTextures(t) { + this._textures = t; + this.markForUpdateRenderData(); + } + getLayerSize() { + return this._layerSize; + } + getMapTileSize() { + return this._mapTileSize; + } + getTileSet(t) { + t = t || 0; + return this._tilesets && t >= 0 && this._tilesets.length > t ? this._tilesets[t] : null; + } + getTileSets() { + return this._tilesets; + } + setTileSet(t) { + this.setTileSets([ t ]); + } + setTileSets(t) { + this._tilesets = t; + const e = this._textures = []; + const i = this.texGrids; + i.clear(); + for (let i = 0; i < t.length; i++) { + const s = t[i]; + s && (e[i] = s.sourceImage); + } + for (let e = 0, s = t.length; e < s; ++e) { + const s = t[e]; + s && ANt(s, i, s.sourceImage); + } + this._prepareToRender(); + } + init(t, e, i, s, n) { + this._cullingDirty = !0; + this._layerInfo = t; + this._mapInfo = e; + const r = t.layerSize; + this._layerName = t.name; + this.tiles = t.tiles; + this._properties = t.properties; + this._layerSize = r; + this._minGID = t.minGID; + this._maxGID = t.maxGID; + this._opacity = t.opacity; + t.tintColor && (this._tintColor = t.tintColor); + this.renderOrder = e.renderOrder; + this._staggerAxis = e.getStaggerAxis(); + this._staggerIndex = e.getStaggerIndex(); + this._hexSideLength = e.getHexSideLength(); + this._animations = e.getTileAnimations(); + this._tilesets = i; + this._textures = s; + this.texGrids = n; + this._layerOrientation = e.orientation; + this._mapTileSize = e.getTileSize(); + const o = this._mapTileSize.width; + const a = this._mapTileSize.height; + const l = this._layerSize.width; + const h = this._layerSize.height; + if (this._layerOrientation === jOt.HEX) { + let t = 0; + let e = 0; + this._odd_even = this._staggerIndex === qOt.STAGGERINDEX_ODD ? 1 : -1; + if (this._staggerAxis === YOt.STAGGERAXIS_X) { + this._diffX1 = (o - this._hexSideLength) / 2; + this._diffY1 = 0; + e = a * (h + .5); + t = (o + this._hexSideLength) * Math.floor(l / 2) + o * (l % 2); + } else { + this._diffX1 = 0; + this._diffY1 = (a - this._hexSideLength) / 2; + t = o * (l + .5); + e = (a + this._hexSideLength) * Math.floor(h / 2) + a * (h % 2); + } + this.node._uiProps.uiTransformComp.setContentSize(t, e); + } else if (this._layerOrientation === jOt.ISO) { + const t = l + h; + this.node._uiProps.uiTransformComp.setContentSize(.5 * o * t, .5 * a * t); + } else this.node._uiProps.uiTransformComp.setContentSize(l * o, h * a); + this._offset = new Qi(t.offset.x, -t.offset.y); + this._useAutomaticVertexZ = !1; + this._vertexZvalue = 0; + this._syncAnchorPoint(); + this._prepareToRender(); + } + _prepareToRender() { + this._updateVertices(); + this._updateAllUserNode(); + } + requestTiledRenderData() { + const t = this._tiledDataArray; + for (;t.length > 0 && t[t.length - 1].subNodes && 0 === t[t.length - 1].subNodes.length; ) t.pop(); + if (t.length > 0) { + const e = t[t.length - 1]; + if (e.renderData && 0 === e.renderData.vertexCount) return e; + } + const e = { + renderData: null, + texture: null + }; + this._tiledDataArray.push(e); + return e; + } + requestSubNodesData() { + const t = this._tiledDataArray; + if (t.length > 0 && t[t.length - 1].subNodes && 0 === t[t.length - 1].subNodes.length) return t[t.length - 1]; + const e = { + subNodes: [] + }; + this._tiledDataArray.push(e); + return e; + } + destroyRenderData() { + this._tiledDataArray.forEach((t => { + const e = t.renderData; + e && SB.remove(e); + })); + this._tiledDataArray.length = 0; + super.destroyRenderData(); + } + _flushAssembler() { + const e = t.Assembler.getAssembler(this); + if (this._assembler !== e) { + this._assembler = e; + this._assembler.createData(this); + } + if (0 === this._tiledDataArray.length) { + this.markForUpdateRenderData(); + this._updateColor(); + } + } + _render(t) { + for (let e = 0; e < this._tiledDataArray.length; e++) { + this._tiledDataArrayIdx = e; + const i = this._tiledDataArray[e]; + if (i.subNodes) i.subNodes.forEach((e => { + e && t.walk(e.node); + })); else { + const e = i; + e.texture && t.commitComp(this, e.renderData, e.texture, this._assembler, null); + } + } + this.node._static = !0; + } + createRenderEntity() { + return new fB(uB.CROSSED); + } + fillIndicesBuffer(t, e) { + const i = t.chunk.meshBuffer.iData; + let s = t.chunk.meshBuffer.indexOffset; + e.setIndexOffset(s); + let n = t.chunk.vertexOffset; + const r = t.vertexCount / 4; + for (let t = 0; t < r; t += 1) { + i[s] = n; + i[s + 1] = n + 1; + i[s + 2] = n + 2; + i[s + 3] = n + 2; + i[s + 4] = n + 1; + i[s + 5] = n + 3; + s += 6; + n += 4; + } + t.chunk.meshBuffer.indexOffset = s; + e.setIBCount(6 * r); + } + prepareDrawData() { + this._drawInfoList.length = 0; + const t = this.renderEntity; + t.clearDynamicRenderDrawInfos(); + const e = this._tiledDataArray; + let i = 0; + e.forEach((e => { + if (e.subNodes) e.subNodes.forEach((e => { + if (e) { + this._drawInfoList[i] || (this._drawInfoList[i] = new aB); + const s = this._drawInfoList[i]; + s.setDrawInfoType(oB.SUB_NODE); + s.setSubNode(e.node); + t.setDynamicRenderDrawInfo(s, i); + i++; + } + })); else { + const s = e; + if (s.texture) { + this._drawInfoList[i] || (this._drawInfoList[i] = new aB); + const e = this._drawInfoList[i]; + s.renderData.fillDrawInfoAttributes(e); + e.setTexture(s.texture.getGFXTexture()); + e.setSampler(s.texture.getGFXSampler()); + e.setMaterial(this.getRenderMaterial(0)); + this.fillIndicesBuffer(s.renderData, e); + t.setDynamicRenderDrawInfo(e, i); + i++; + } + } + })); + } + }, ENt)) || vNt); + var DNt, PNt, ONt, NNt, LNt, FNt, VNt; + let kNt = t("TiledObjectGroup", (DNt = Ul("cc.TiledObjectGroup"), PNt = sh(), ONt = Gl(jB), + NNt = Th(Le), DNt(LNt = PNt(LNt = ONt(LNt = (FNt = (VNt = class extends Qc { + constructor(...t) { + super(...t); + this._premultiplyAlpha = !1; + this._groupName = void 0; + this._positionOffset = void 0; + this._mapInfo = void 0; + this._properties = void 0; + this._offset = void 0; + this._opacity = void 0; + this._tintColor = null; + this._animations = void 0; + this._hasAniObj = void 0; + this._texGrids = void 0; + this.aniObjects = void 0; + this._objects = []; + } + get premultiplyAlpha() { + return this._premultiplyAlpha; + } + set premultiplyAlpha(t) { + this._premultiplyAlpha = t; + } + getPositionOffset() { + return this._positionOffset; + } + getProperties() { + return this._properties; + } + getGroupName() { + return this._groupName; + } + getProperty(t) { + return this._properties[t.toString()]; + } + getObject(t) { + for (let e = 0, i = this._objects.length; e < i; e++) { + const i = this._objects[e]; + if (i && i.name === t) return i; + } + return null; + } + getObjects() { + return this._objects; + } + get offset() { + return this._offset; + } + _init(t, e, i) { + const s = WOt.FLIPPED_MASK; + const n = WOt.HORIZONTAL; + const r = WOt.VERTICAL; + this._groupName = t.name; + this._positionOffset = t.offset; + this._mapInfo = e; + this._properties = t.getProperties(); + this._offset = new Qi(t.offset.x, -t.offset.y); + this._opacity = t.opacity; + t.tintColor && (this._tintColor = t.tintColor); + this._texGrids = i; + this._animations = e.getTileAnimations(); + this.aniObjects = []; + this._hasAniObj = !1; + const o = e.mapSize; + const a = e.tileSize; + let l = 0; + let h = 0; + const c = new Bi; + const u = jOt.ISO === e.orientation; + if (e.orientation === jOt.HEX) if (e.getStaggerAxis() === YOt.STAGGERAXIS_X) { + h = a.height * (o.height + .5); + l = (a.width + e.getHexSideLength()) * Math.floor(o.width / 2) + a.width * (o.width % 2); + } else { + l = a.width * (o.width + .5); + h = (a.height + e.getHexSideLength()) * Math.floor(o.height / 2) + a.height * (o.height % 2); + } else if (u) { + const t = o.width + o.height; + l = .5 * a.width * t; + h = .5 * a.height * t; + } else { + l = o.width * a.width; + h = o.height * a.height; + } + const _ = this.node._uiProps.uiTransformComp; + _.setContentSize(l, h); + const d = l * _.anchorX; + const p = h * (1 - _.anchorY); + const m = t.objects; + const f = {}; + for (let t = 0, e = m.length; t < e; t++) { + const e = m[t]; + const l = e.type; + e.offset = new Qi(e.x, e.y); + const _ = e.points || e.polylinePoints; + if (_) for (let t = 0; t < _.length; t++) _[t].y *= -1; + if (u) { + const t = e.x / a.height; + const i = e.y / a.height; + e.x = .5 * a.width * (o.height + t - i); + e.y = .5 * a.height * (o.width + o.height - t - i); + } else e.y = h - e.y; + if (l === JOt.TEXT) { + const i = `text${e.id}`; + f[i] = !0; + let s = this.node.getChildByName(i); + s || (s = new _y); + s.setRotationFromEuler(0, 0, -e.rotation); + s.setPosition(e.x - d, e.y - p); + s.name = i; + s.parent = this.node; + s.setSiblingIndex(t); + let n = s.getComponent(IP); + n || (n = s.addComponent(IP)); + const r = s._uiProps.uiTransformComp; + s.active = e.visible; + r.anchorX = 0; + r.anchorY = 1; + if (this._tintColor) { + c.set(this._tintColor); + c.a *= this._opacity / 255; + n.color.set(c); + } else { + n.color.a *= this._opacity / 255; + } + n.overflow = IP.Overflow.SHRINK; + n.lineHeight = e.height; + n.string = e.text; + n.horizontalAlign = e.halign; + n.verticalAlign = e.valign; + n.fontSize = e.pixelsize; + r.setContentSize(e.width, e.height); + } else if (l === JOt.IMAGE) { + const o = e.gid; + const a = (o & s) >>> 0; + const l = i.get(a); + if (!l) continue; + const h = l.tileset; + const _ = `img${e.id}`; + f[_] = !0; + let m = this.node.getChildByName(_); + e.width = e.width || l.width; + e.height = e.height || l.height; + if (m && m._objFlags & co.Flags.HideInHierarchy) { + m.removeFromParent(); + m.hideFlags |= co.Flags.DontSave; + m.destroy(); + m = null; + } + m || (m = new _y); + if (this._animations.get(a)) { + this.aniObjects.push({ + object: e, + imgNode: m, + gridGID: a + }); + this._hasAniObj = !0; + } + const g = h.tileOffset.x; + const y = h.tileOffset.y; + m.active = e.visible; + m.setRotationFromEuler(0, 0, -e.rotation); + m.setPosition(e.x - d, e.y - p); + m.name = _; + m.parent = this.node; + m.setSiblingIndex(t); + let b = m.getComponent(cL); + b || (b = m.addComponent(cL)); + const S = m._uiProps.uiTransformComp; + if (u) { + S.anchorX = .5 + g / e.width; + S.anchorY = y / e.height; + } else { + S.anchorX = g / e.width; + S.anchorY = y / e.height; + } + if (this._tintColor) { + c.set(this._tintColor); + c.a *= this._opacity / 255; + b.color.set(c); + } else { + b.color.a *= this._opacity / 255; + } + b.sizeMode = cL.SizeMode.CUSTOM; + const A = this._premultiplyAlpha ? Ls.ONE : Ls.SRC_ALPHA; + if (b._srcBlendFactor !== A) { + b._srcBlendFactor = A; + b.material && b._updateBlendFunc(); + } + let T = l.spriteFrame; + T = T ? T.clone() : new GI; + (o & n) >>> 0 && (T.flipUVX = !T.flipUVX); + (o & r) >>> 0 && (T.flipUVY = !T.flipUVY); + T.rotated = l._rotated; + T.rect = l._rect; + b.spriteFrame = T; + S.setContentSize(e.width, e.height); + b.markForUpdateRenderData(); + } + } + this._objects = m; + const g = this.node.children; + const y = /^(?:img|text)\d+$/; + for (let t = 0, e = g.length; t < e; t++) { + const e = g[t]; + const i = e.name; + y.test(i) && !f[i] && e.destroy(); + } + } + update(t) { + if (!this._hasAniObj) return; + const e = this.aniObjects; + const i = this._texGrids; + const s = jOt.ISO === this._mapInfo.orientation; + for (let t = 0, n = e.length; t < n; t++) { + const n = e[t]; + const r = n.gridGID; + const o = i.get(r); + if (!o) continue; + const a = o.tileset; + const l = n.object; + const h = n.imgNode; + const c = a.tileOffset.x; + const u = a.tileOffset.y; + const _ = h._uiProps.uiTransformComp; + if (s) { + _.anchorX = .5 + c / l.width; + _.anchorY = u / l.height; + } else { + _.anchorX = c / l.width; + _.anchorY = u / l.height; + } + const d = h.getComponent(cL); + const p = d.spriteFrame; + p.rotated = o._rotated; + p.rect = o._rect; + d.spriteFrame = p; + d.markForUpdateRenderData(); + } + } + }, VNt), Bl(FNt.prototype, "premultiplyAlpha", [ NNt ], Object.getOwnPropertyDescriptor(FNt.prototype, "premultiplyAlpha"), FNt.prototype), + FNt)) || LNt) || LNt) || LNt)); + var UNt, GNt, zNt, HNt, jNt, XNt, WNt, YNt, qNt, KNt, JNt, ZNt, QNt, $Nt, tLt, eLt, iLt, sLt; + let nLt = t("TiledMapAsset", (UNt = Ul("cc.TiledMapAsset"), GNt = Th([ EC ]), zNt = Th([ Fe ]), + HNt = Th([ GI ]), jNt = Th([ GI ]), XNt = Th([ Fe ]), WNt = Th([ Fe ]), YNt = Th([ rs ]), + UNt(qNt = (KNt = class extends gc { + constructor(...t) { + super(...t); + Ml(this, "tmxXmlStr", JNt, this); + Ml(this, "tsxFiles", ZNt, this); + Ml(this, "tsxFileNames", QNt, this); + Ml(this, "spriteFrames", $Nt, this); + Ml(this, "imageLayerSpriteFrame", tLt, this); + Ml(this, "imageLayerSpriteFrameNames", eLt, this); + Ml(this, "spriteFrameNames", iLt, this); + Ml(this, "spriteFrameSizes", sLt, this); + } + }, JNt = Bl(KNt.prototype, "tmxXmlStr", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), ZNt = Bl(KNt.prototype, "tsxFiles", [ Yl, GNt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), QNt = Bl(KNt.prototype, "tsxFileNames", [ Yl, zNt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), $Nt = Bl(KNt.prototype, "spriteFrames", [ Yl, HNt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), tLt = Bl(KNt.prototype, "imageLayerSpriteFrame", [ Yl, jNt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), eLt = Bl(KNt.prototype, "imageLayerSpriteFrameNames", [ Yl, XNt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), iLt = Bl(KNt.prototype, "spriteFrameNames", [ Yl, WNt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), sLt = Bl(KNt.prototype, "spriteFrameSizes", [ Yl, YNt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), KNt)) || qNt)); + var rLt, oLt, aLt, lLt, hLt, cLt, uLt, _Lt, dLt, pLt, mLt, fLt, gLt; + t("TiledMap", (rLt = Ul("cc.TiledMap"), oLt = sh(), aLt = $l(), lLt = Gl(jB), hLt = Th(nLt), + cLt = ph(), rLt(uLt = oLt(uLt = aLt(uLt = lLt(uLt = Ql(uLt = (_Lt = (gLt = fLt = class extends Qc { + constructor(...t) { + super(...t); + this._texGrids = new Map; + this._textures = []; + this._tilesets = []; + this._animations = new Map; + this._imageLayers = []; + this._layers = []; + this._groups = []; + this._images = []; + this._properties = {}; + this._tileProperties = new Map; + this._mapInfo = null; + this._mapSize = new rs(0, 0); + this._tileSize = new rs(0, 0); + this._mapOrientation = jOt.ORTHO; + this._isApplied = !1; + Ml(this, "_tmxFile", dLt, this); + Ml(this, "_enableCulling", pLt, this); + Ml(this, "cleanupImageCache", mLt, this); + } + get tmxAsset() { + return this._tmxFile; + } + set tmxAsset(t) { + if (this._tmxFile !== t) { + this._tmxFile = t; + this._applyFile(); + this._isApplied = !0; + } + } + get enableCulling() { + return this._enableCulling; + } + set enableCulling(t) { + this._enableCulling = t; + const e = this._layers; + for (let i = 0; i < e.length; ++i) e[i].enableCulling = t; + } + getMapSize() { + return this._mapSize; + } + getTileSize() { + return this._tileSize; + } + getMapOrientation() { + return this._mapOrientation; + } + getObjectGroups() { + return this._groups; + } + getObjectGroup(t) { + const e = this._groups; + for (let i = 0, s = e.length; i < s; i++) { + const s = e[i]; + if (s && s.getGroupName() === t) return s; + } + return null; + } + getProperties() { + return this._properties; + } + getLayers() { + return this._layers; + } + getLayer(t) { + const e = this._layers; + for (let i = 0, s = e.length; i < s; i++) { + const s = e[i]; + if (s && s.getLayerName() === t) return s; + } + return null; + } + _changeLayer(t, e) { + const i = this._layers; + for (let s = 0, n = i.length; s < n; s++) { + const n = i[s]; + if (n && n.getLayerName() === t) { + i[s] = e; + return; + } + } + } + getProperty(t) { + return this._properties[t.toString()]; + } + getPropertiesForGID(t) { + return this._tileProperties.get(t); + } + __preload() { + if (this._tmxFile && !1 === this._isApplied) { + this._applyFile(); + this._isApplied = !0; + } + } + onEnable() { + this.node.on(ny.ANCHOR_CHANGED, this._syncAnchorPoint, this); + } + onDisable() { + this.node.off(ny.ANCHOR_CHANGED, this._syncAnchorPoint, this); + } + _applyFile() { + const t = []; + const e = {}; + const i = this._tmxFile; + if (i) { + let s = i.spriteFrameNames; + const n = i.spriteFrameSizes; + const r = i.spriteFrames; + const o = {}; + const a = {}; + for (let i = 0; i < s.length; ++i) { + const l = s[i]; + a[l] = n[i]; + t[i] = r[i]; + const h = t[i]; + if (h) { + e[h.name] = h; + o[l] = h; + } + } + const l = {}; + const h = i.imageLayerSpriteFrame; + s = i.imageLayerSpriteFrameNames; + for (let t = 0; t < h.length; ++t) l[s[t]] = h[t]; + const c = i.tsxFileNames; + const u = i.tsxFiles; + const _ = {}; + for (let t = 0; t < c.length; ++t) c[t].length > 0 && (_[c[t]] = u[t].text); + const d = new rNt(i.tmxXmlStr, _, o, a, l); + const p = d.getTilesets(); + p && 0 !== p.length || P(7241); + this._buildWithMapInfo(d); + } else this._releaseMapInfo(); + } + _releaseMapInfo() { + const t = this._layers; + for (let s = 0, n = t.length; s < n; s++) { + var e, i; + null === (e = t[s].node.parent) || void 0 === e || e.off(ny.SIZE_CHANGED, t[s].updateCulling, t[s]); + null === (i = t[s].node.parent) || void 0 === i || i.off(ny.TRANSFORM_CHANGED, t[s].updateCulling, t[s]); + t[s].node.removeFromParent(); + t[s].node.destroy(); + } + t.length = 0; + const s = this._groups; + for (let t = 0, e = s.length; t < e; t++) { + s[t].node.removeFromParent(); + s[t].node.destroy(); + } + s.length = 0; + const n = this._images; + for (let t = 0, e = n.length; t < e; t++) { + n[t].removeFromParent(); + n[t].destroy(); + } + n.length = 0; + } + _syncAnchorPoint() { + const t = this.node._uiProps.uiTransformComp.anchorPoint; + const e = this.node._uiProps.uiTransformComp.width * t.x; + const i = this.node._uiProps.uiTransformComp.height * (1 - t.y); + let s; + let n; + for (s = 0, n = this._layers.length; s < n; s++) { + this._layers[s].node._uiProps.uiTransformComp.setAnchorPoint(t); + } + for (s = 0, n = this._groups.length; s < n; s++) { + const t = this._groups[s]; + const n = t.node._uiProps.uiTransformComp; + n.anchorX = .5; + n.anchorY = .5; + const r = t.offset.x - e + n.width * n.anchorX; + const o = t.offset.y + i - n.height * n.anchorY; + t.node.setPosition(r, o); + } + for (s = 0, n = this._images.length; s < n; s++) { + const t = this._images[s]._uiProps.uiTransformComp; + t.anchorX = .5; + t.anchorY = .5; + const n = this._images[s]._offset.x - e + t.width * t.anchorX; + const r = this._images[s]._offset.y + i - t.height * t.anchorY; + this._images[s].setPosition(n, r); + } + } + _fillAniGrids(t, e) { + for (const i of e.keys()) { + const s = e.get(i); + if (!s) continue; + const n = s.frames; + for (let e = 0; e < n.length; e++) { + const i = n[e]; + i.grid = t.get(i.tileid); + } + } + } + _buildLayerAndGroup() { + const t = this._tilesets; + const e = this._texGrids; + const i = this._animations; + e.clear(); + for (let i = 0, s = t.length; i < s; ++i) { + const s = t[i]; + s && (s.sourceImage ? ANt(s, e, s.sourceImage) : console.warn(`Can't find the spriteFrame of tilesets ${i}`)); + } + this._fillAniGrids(e, i); + let s = this._layers; + let n = this._groups; + let r = this._images; + const o = {}; + for (let t = 0, e = s.length; t < e; t++) o[s[t].node.name] = !0; + for (let t = 0, e = n.length; t < e; t++) o[n[t].node.name] = !0; + for (let t = 0, e = r.length; t < e; t++) o[r[t].name] = !0; + s = this._layers = []; + n = this._groups = []; + r = this._images = []; + const a = this._mapInfo; + const l = this.node; + const h = a.getAllChildren(); + const c = this._textures; + let u = 0; + let _ = 0; + if (h && h.length > 0) for (let i = 0, d = h.length; i < d; i++) { + const d = h[i]; + const p = d.name; + let m = this.node.getChildByName(p); + o[p] = !1; + if (!m) { + m = new _y; + m.name = p; + m.layer = l.layer; + l.addChild(m); + } + m.setSiblingIndex(i); + m.active = d.visible; + if (d instanceof $Ot) { + let i = m.getComponent(BNt); + i || (i = m.addComponent(BNt)); + i.init(d, a, t, c, e); + i.enableCulling = this._enableCulling; + d.ownTiles = !1; + s.push(i); + } else if (d instanceof QOt) { + let t = m.getComponent(kNt); + t || (t = m.addComponent(kNt)); + t._init(d, a, e); + n.push(t); + } else if (d instanceof tNt) { + const t = d.sourceImage; + m.layerInfo = d; + m._offset = new Qi(d.offset.x, -d.offset.y); + let e = m.getComponent(cL); + e || (e = m.addComponent(cL)); + e.color.a *= d.opacity; + e.spriteFrame = t; + let i = t.width; + let s = t.height; + if (t.original) { + i = t.originalSize.width; + s = t.originalSize.height; + } + m._uiProps.uiTransformComp.setContentSize(i, s); + r.push(m); + } + u = Math.max(u, m._uiProps.uiTransformComp.width); + _ = Math.max(_, m._uiProps.uiTransformComp.height); + } + const d = l.children; + for (let t = 0, e = d.length; t < e; t++) { + const e = d[t]; + o[e.name] && e.destroy(); + } + this.node._uiProps.uiTransformComp.setContentSize(u, _); + this._syncAnchorPoint(); + } + _buildWithMapInfo(t) { + this._mapInfo = t; + this._mapSize = t.getMapSize(); + this._tileSize = t.getTileSize(); + this._mapOrientation = t.orientation; + this._properties = t.properties; + this._tileProperties = t.getTileProperties(); + this._imageLayers = t.getImageLayers(); + this._animations = t.getTileAnimations(); + this._tilesets = t.getTilesets(); + const e = this._tilesets; + this._textures.length = 0; + const i = []; + for (let t = 0, s = e.length; t < s; ++t) { + const s = e[t]; + if (s && s.sourceImage) { + this._textures[t] = s.sourceImage; + i.push(s.sourceImage); + } + } + for (let t = 0; t < this._imageLayers.length; t++) { + const e = this._imageLayers[t]; + e && e.sourceImage && i.push(e.sourceImage); + } + this._buildLayerAndGroup(); + this.cleanupImageCache && this._textures.forEach((t => { + this.doCleanupImageCache(t); + })); + } + doCleanupImageCache(t) { + if (t._image instanceof HTMLImageElement) { + t._image.src = ""; + t._image.destroy(); + } else Vo.hasFeature(Vo.Feature.IMAGE_BITMAP) && t._image instanceof ImageBitmap && t._image.close && t._image.close(); + t._image = null; + } + lateUpdate(t) { + const e = this._animations; + const i = this._texGrids; + for (const s of e.keys()) { + const n = e.get(s); + const r = n.frames; + let o = r[n.frameIdx]; + n.dt += t; + if (o.duration < n.dt) { + n.dt = 0; + n.frameIdx++; + n.frameIdx >= r.length && (n.frameIdx = 0); + o = r[n.frameIdx]; + } + i.set(s, o.grid); + } + const s = this.getLayers(); + for (let t = 0, e = s.length; t < e; t++) { + const e = s[t]; + (e.hasAnimation() || e.node.hasChangedFlags) && e.markForUpdateRenderData(); + } + } + }, fLt.Orientation = jOt, fLt.Property = XOt, fLt.TileFlag = WOt, fLt.StaggerAxis = YOt, + fLt.StaggerIndex = qOt, fLt.TMXObjectType = JOt, fLt.RenderOrder = KOt, gLt), dLt = Bl(_Lt.prototype, "_tmxFile", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Bl(_Lt.prototype, "tmxAsset", [ hLt, cLt ], Object.getOwnPropertyDescriptor(_Lt.prototype, "tmxAsset"), _Lt.prototype), + pLt = Bl(_Lt.prototype, "_enableCulling", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), Bl(_Lt.prototype, "enableCulling", [ nh ], Object.getOwnPropertyDescriptor(_Lt.prototype, "enableCulling"), _Lt.prototype), + mLt = Bl(_Lt.prototype, "cleanupImageCache", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), _Lt)) || uLt) || uLt) || uLt) || uLt) || uLt)); + const yLt = Math.ceil(10922.5); + const bLt = []; + for (let t = 0; t < 4; t++) bLt.push(new Pi); + const SLt = new qi; + const ALt = new Pi; + const TLt = { + row: 0, + col: 0 + }; + let vLt = { + x: 0, + y: 0 + }; + let ELt = { + x: 0, + y: 0 + }; + let CLt = { + x: 0, + y: 0 + }; + let xLt = { + x: 0, + y: 0 + }; + let wLt = 0; + let RLt = 0; + let ILt = 0; + let MLt = 0; + let BLt = null; + let DLt; + let PLt; + let OLt; + let NLt = null; + const LLt = { + ensureAccessor() { + if (!NLt) { + const t = IR.root.device; + IR.root.batcher2D; + NLt = new iB(t, zM, this.vCount); + IR.on(RR.EVENT_BEFORE_DRAW, (() => { + NLt.reset(); + })); + } + }, + createData(t) { + this.ensureAccessor(); + }, + fillBuffers(t, e) { + if (!t || 0 === t.tiledDataArray.length) return; + const i = t.tiledDataArray[t._tiledDataArrayIdx].renderData; + const s = i.chunk.meshBuffer.iData; + let n = i.chunk.meshBuffer.indexOffset; + let r = i.chunk.vertexOffset; + const o = i.vertexCount / 4; + for (let t = 0; t < o; t += 1) { + s[n] = r; + s[n + 1] = r + 1; + s[n + 2] = r + 2; + s[n + 3] = r + 2; + s[n + 4] = r + 1; + s[n + 5] = r + 3; + n += 6; + r += 4; + } + i.chunk.meshBuffer.indexOffset = n; + }, + updateRenderData(t) { + t.updateCulling(); + RLt = t.leftDownToCenterX; + ILt = t.leftDownToCenterY; + if (t.colorChanged || t.isCullingDirty() || t.isUserNodeDirty() || t.hasAnimation() || t.hasTiledNode() || t.node.hasChangedFlags) { + t.colorChanged = !1; + t.destroyRenderData(); + let e; + let i; + if (t.enableCulling) { + const s = t.cullingRect; + e = s.leftDown; + i = s.rightTop; + } else { + e = TLt; + i = t.rightTop; + } + switch (t.renderOrder) { + case KOt.RightDown: + kLt(e, i, -1, 1, t); + break; + + case KOt.LeftDown: + kLt(e, i, -1, -1, t); + break; + + case KOt.RightUp: + kLt(e, i, 1, 1, t); + break; + + case KOt.LeftUp: + default: + kLt(e, i, 1, -1, t); + } + t.setCullingDirty(!1); + t.setUserNodeDirty(!1); + } + t.prepareDrawData(); + }, + updateColor(t) { + const e = t.color; + const i = new Float32Array(4); + i[0] = e.r / 255; + i[1] = e.g / 255; + i[2] = e.b / 255; + i[3] = e.a / 255; + const s = t.tiledDataArray; + for (const t of s) { + if (!t.renderData) continue; + const e = t.renderData; + const s = e.vData; + for (let t = e.vertexStart, n = e.vertexCount; t < n; t++) s.set(i, 9 * t + 5); + } + } + }; + function FLt(t, e) { + if (t._rotated) { + vLt.x = t.r; + vLt.y = t.t; + ELt.x = t.l; + ELt.y = t.t; + CLt.x = t.r; + CLt.y = t.b; + xLt.x = t.l; + xLt.y = t.b; + } else { + vLt.x = t.l; + vLt.y = t.t; + ELt.x = t.l; + ELt.y = t.b; + CLt.x = t.r; + CLt.y = t.t; + xLt.x = t.r; + xLt.y = t.b; + } + let i; + if ((e & WOt.DIAGONAL) >>> 0) { + i = ELt; + ELt = CLt; + CLt = i; + } + if ((e & WOt.HORIZONTAL) >>> 0) { + i = vLt; + vLt = CLt; + CLt = i; + i = ELt; + ELt = xLt; + xLt = i; + } + if ((e & WOt.VERTICAL) >>> 0) { + i = vLt; + vLt = ELt; + ELt = i; + i = CLt; + CLt = xLt; + xLt = i; + } + } + function VLt() { + if (MLt < 1 || !BLt) return; + const t = 4 * MLt; + const e = 6 * MLt; + const i = PLt.requestTiledRenderData(); + i.renderData = SB.add(zM, NLt); + i.renderData.drawInfoType = oB.IA; + i.texture = BLt; + const s = i.renderData; + s.resize(t, e); + s.chunk.vb.set(DLt.subarray(0, 9 * t), 0); + MLt = 0; + BLt = null; + } + function kLt(t, e, i, s, n) { + if (e.row < 0 || e.col < 0) return; + PLt = n; + const r = n.node.worldMatrix; + wLt = 0; + const o = n.tiledTiles; + const a = n.texGrids; + const l = n.tiles; + const h = 18; + const c = 27; + const u = n.vertices; + let _; + let d; + let p; + let m; + let f; + let g; + let y; + let b; + let S = 0; + let A = 0; + let T = 0; + let v = 0; + let E = 0; + let C; + let x = 0; + let w = !0; + OLt = FLt; + const R = new Float32Array(4); + R[0] = n.color.r / 255; + R[1] = n.color.g / 255; + R[2] = n.color.b / 255; + R[3] = n.color.a / 255; + if (-1 === i) { + m = e.row; + f = t.row; + } else { + m = t.row; + f = e.row; + } + const I = Math.abs(t.row - e.row) + 1; + const M = Math.abs(e.col - t.col) + 1; + DLt = new Float32Array(I * M * 9 * 4); + MLt = 0; + const B = DLt; + for (;(f - m) * i >= 0; m += i) { + _ = u[m]; + x = n.getNodesCountByRow(m); + w = _ && 0 === x; + if (1 === s) { + d = w && t.col < _.minCol ? _.minCol : t.col; + p = w && e.col > _.maxCol ? _.maxCol : e.col; + } else { + d = w && e.col > _.maxCol ? _.maxCol : e.col; + p = w && t.col < _.minCol ? _.minCol : t.col; + } + for (;(p - d) * s >= 0; d += s) { + g = _ && _[d]; + if (x > 0) { + VLt(); + const t = n.requestSubNodesData(); + const e = n.getNodesByRowCol(m, d); + e && e.count > 0 && (t.subNodes = e.list); + } + if (g) { + S = l[g.index]; + b = a.get((S & WOt.FLIPPED_MASK) >>> 0); + if (b) { + if (BLt !== b.texture) { + VLt(); + BLt = b.texture; + } + y = b.tileset._tileSize; + A = g.left - RLt; + T = g.bottom - ILt; + v = A + y.width; + E = T + y.height; + C = o[g.index]; + wLt = 4 * MLt * 9; + if (C) C.node.active && ULt(C.node, R, B, A, v, E, T, false); else { + bLt[0].x = A; + bLt[0].y = E; + bLt[1].x = A; + bLt[1].y = T; + bLt[2].x = v; + bLt[2].y = E; + bLt[3].x = v; + bLt[3].y = T; + bLt[0].transformMat4(r); + B[wLt] = bLt[0].x; + B[wLt + 1] = bLt[0].y; + B[wLt + 2] = bLt[0].z; + bLt[1].transformMat4(r); + B[wLt + 9] = bLt[1].x; + B[wLt + 9 + 1] = bLt[1].y; + B[wLt + 9 + 2] = bLt[1].z; + bLt[2].transformMat4(r); + B[wLt + h] = bLt[2].x; + B[wLt + h + 1] = bLt[2].y; + B[wLt + h + 2] = bLt[2].z; + bLt[3].transformMat4(r); + B[wLt + c] = bLt[3].x; + B[wLt + c + 1] = bLt[3].y; + B[wLt + c + 2] = bLt[3].z; + B.set(R, wLt + 5); + B.set(R, wLt + 9 + 5); + B.set(R, wLt + h + 5); + B.set(R, wLt + c + 5); + } + OLt(b, S); + B[wLt + 3] = vLt.x; + B[wLt + 4] = vLt.y; + B[wLt + 9 + 3] = ELt.x; + B[wLt + 9 + 4] = ELt.y; + B[wLt + h + 3] = CLt.x; + B[wLt + h + 4] = CLt.y; + B[wLt + c + 3] = xLt.x; + B[wLt + c + 4] = xLt.y; + MLt++; + MLt >= yLt && VLt(); + } + } + } + } + VLt(); + } + function ULt(t, e, i, s, n, r, o, a) { + const l = 18; + const h = 27; + t.updateWorldTransform(); + qi.fromRTS(SLt, t.rotation, t.position, t.scale); + Pi.set(ALt, -(s + RLt), -(o + ILt), 0); + qi.transform(SLt, SLt, ALt); + qi.multiply(SLt, t.parent.worldMatrix, SLt); + const c = SLt; + const u = c.m12; + const _ = c.m13; + const d = c.m00; + const p = c.m01; + const m = c.m04; + const f = c.m05; + const g = 1 === d && 0 === p && 0 === m && 1 === f; + if (a) { + const t = (s + n) / 2; + const e = (r + o) / 2; + if (g) { + i[wLt] = t + u; + i[wLt + 1] = r + _; + i[wLt + 9] = s + u; + i[wLt + 9 + 1] = e + _; + i[wLt + l] = n + u; + i[wLt + l + 1] = e + _; + i[wLt + h] = t + u; + i[wLt + h + 1] = o + _; + } else { + i[wLt] = t * d + r * m + u; + i[wLt + 1] = t * p + r * f + _; + i[wLt + 9] = s * d + e * m + u; + i[wLt + 9 + 1] = s * p + e * f + _; + i[wLt + l] = n * d + e * m + u; + i[wLt + l + 1] = n * p + e * f + _; + i[wLt + h] = t * d + o * m + u; + i[wLt + h + 1] = t * p + o * f + _; + } + } else if (g) { + i[wLt] = s + u; + i[wLt + 1] = r + _; + i[wLt + 9] = s + u; + i[wLt + 9 + 1] = o + _; + i[wLt + l] = n + u; + i[wLt + l + 1] = r + _; + i[wLt + h] = n + u; + i[wLt + h + 1] = o + _; + } else { + i[wLt] = s * d + r * m + u; + i[wLt + 1] = s * p + r * f + _; + i[wLt + 9] = s * d + o * m + u; + i[wLt + 9 + 1] = s * p + o * f + _; + i[wLt + l] = n * d + r * m + u; + i[wLt + l + 1] = n * p + r * f + _; + i[wLt + h] = n * d + o * m + u; + i[wLt + h + 1] = n * p + o * f + _; + } + i.set(e, wLt + 5); + i.set(e, wLt + 9 + 5); + i.set(e, wLt + l + 5); + i.set(e, wLt + h + 5); + } + const GLt = t("tiledLayerAssembler", { + getAssembler: () => LLt + }); + BNt.Assembler = GLt; + class zLt { + constructor() { + this.originalTarget = null; + this.target = null; + this.tag = zLt.TAG_INVALID; + } + clone() { + const t = new zLt; + t.originalTarget = null; + t.target = null; + t.tag = this.tag; + return t; + } + isDone() { + return !0; + } + startWithTarget(t) { + this.originalTarget = t; + this.target = t; + } + stop() { + this.target = null; + } + step(t) { + P(1006); + } + update(t) { + P(1007); + } + getTarget() { + return this.target; + } + setTarget(t) { + this.target = t; + } + getOriginalTarget() { + return this.originalTarget; + } + setOriginalTarget(t) { + this.originalTarget = t; + } + getTag() { + return this.tag; + } + setTag(t) { + this.tag = t; + } + reverse() { + P(1008); + return null; + } + retain() {} + release() {} + } + zLt.TAG_INVALID = -1; + class HLt extends zLt { + constructor(...t) { + super(...t); + this._duration = 0; + this._timesForRepeat = 1; + } + getDuration() { + return this._duration * (this._timesForRepeat || 1); + } + setDuration(t) { + this._duration = t; + } + clone() { + return new HLt; + } + } + let jLt = 0; + class XLt { + constructor() { + this.actions = []; + this.target = null; + this.actionIndex = 0; + this.currentAction = null; + this.paused = !1; + this.lock = !1; + } + } + class WLt { + constructor() { + this._hashTargets = new Map; + this._arrayTargets = []; + this._elementPool = []; + } + _searchElementByTarget(t, e) { + for (let i = 0; i < t.length; i++) if (e === t[i].target) return t[i]; + return null; + } + _getElement(t, e) { + let i = this._elementPool.pop(); + i || (i = new XLt); + i.target = t; + i.paused = !!e; + return i; + } + _putElement(t) { + t.actions.length = 0; + t.actionIndex = 0; + t.currentAction = null; + t.paused = !1; + t.target = null; + t.lock = !1; + this._elementPool.push(t); + } + addAction(t, e, i) { + if (!t || !e) { + F(1e3); + return; + } + null == e.uuid && (e.uuid = "_TWEEN_UUID_" + jLt++); + let s = this._hashTargets.get(e); + if (s) s.actions || (s.actions = []); else { + s = this._getElement(e, i); + this._hashTargets.set(e, s); + this._arrayTargets.push(s); + } + s.target = e; + s.actions.push(t); + t.startWithTarget(e); + } + removeAllActions() { + const t = this._arrayTargets; + for (let e = 0; e < t.length; e++) { + const i = t[e]; + i && this._putElement(i); + } + this._arrayTargets.length = 0; + this._hashTargets = new Map; + } + removeAllActionsFromTarget(t) { + if (null == t) return; + const e = this._hashTargets.get(t); + if (e) { + e.actions.length = 0; + this._deleteHashElement(e); + } + } + removeAction(t) { + if (null == t) return; + const e = t.getOriginalTarget(); + const i = this._hashTargets.get(e); + if (i) for (let e = 0; e < i.actions.length; e++) if (i.actions[e] === t) { + i.actions.splice(e, 1); + i.actionIndex >= e && i.actionIndex--; + break; + } + } + _removeActionByTag(t, e, i) { + for (let s = 0, n = e.actions.length; s < n; ++s) { + const n = e.actions[s]; + if (n && n.getTag() === t) { + if (i && n.getOriginalTarget() !== i) continue; + this._removeActionAtIndex(s, e); + break; + } + } + } + _removeAllActionsByTag(t, e, i) { + for (let s = e.actions.length - 1; s >= 0; --s) { + const n = e.actions[s]; + if (n && n.getTag() === t) { + if (i && n.getOriginalTarget() !== i) continue; + this._removeActionAtIndex(s, e); + } + } + } + removeActionByTag(t, e) { + t === zLt.TAG_INVALID && P(1002); + const i = this._hashTargets; + if (e) { + const s = i.get(e); + s && this._removeActionByTag(t, s, e); + } else i.forEach((e => { + this._removeActionByTag(t, e); + })); + } + removeAllActionsByTag(t, e) { + t === zLt.TAG_INVALID && P(1002); + const i = this._hashTargets; + if (e) { + const s = i.get(e); + s && this._removeAllActionsByTag(t, s, e); + } else i.forEach((e => { + this._removeAllActionsByTag(t, e); + })); + } + getActionByTag(t, e) { + t === zLt.TAG_INVALID && P(1004); + const i = this._hashTargets.get(e); + if (i) { + if (null != i.actions) for (let e = 0; e < i.actions.length; ++e) { + const s = i.actions[e]; + if (s && s.getTag() === t) return s; + } + P(1005, t); + } + return null; + } + getNumberOfRunningActionsInTarget(t) { + const e = this._hashTargets.get(t); + return e && e.actions ? e.actions.length : 0; + } + pauseTarget(t) { + const e = this._hashTargets.get(t); + e && (e.paused = !0); + } + resumeTarget(t) { + const e = this._hashTargets.get(t); + e && (e.paused = !1); + } + pauseAllRunningActions() { + const t = []; + const e = this._arrayTargets; + for (let i = 0; i < e.length; i++) { + const s = e[i]; + if (s && !s.paused) { + s.paused = !0; + t.push(s.target); + } + } + return t; + } + resumeTargets(t) { + if (t) for (let e = 0; e < t.length; e++) t[e] && this.resumeTarget(t[e]); + } + pauseTargets(t) { + if (t) for (let e = 0; e < t.length; e++) t[e] && this.pauseTarget(t[e]); + } + purgeSharedManager() { + m.director.getScheduler().unscheduleUpdate(this); + } + _removeActionAtIndex(t, e) { + e.actions[t]; + e.actions.splice(t, 1); + e.actionIndex >= t && e.actionIndex--; + 0 === e.actions.length && this._deleteHashElement(e); + } + _deleteHashElement(t) { + let e = !1; + if (t && !t.lock && this._hashTargets.get(t.target)) { + this._hashTargets.delete(t.target); + const i = this._arrayTargets; + for (let e = 0, s = i.length; e < s; e++) if (i[e] === t) { + i.splice(e, 1); + break; + } + this._putElement(t); + e = !0; + } + return e; + } + update(t) { + const e = this._arrayTargets; + let i; + for (let s = 0; s < e.length; s++) { + this._currentTarget = e[s]; + i = this._currentTarget; + const n = i.target; + if (!_o(n) || n.isValid) { + if (!i.paused && i.actions) { + i.lock = !0; + for (i.actionIndex = 0; i.actionIndex < i.actions.length; i.actionIndex++) { + i.currentAction = i.actions[i.actionIndex]; + if (i.currentAction) { + i.currentAction.step(t * (i.currentAction._speedMethod ? i.currentAction._speed : 1)); + if (i.currentAction && i.currentAction.isDone()) { + i.currentAction.stop(); + const t = i.currentAction; + i.currentAction = null; + this.removeAction(t); + } + i.currentAction = null; + } + } + i.lock = !1; + } + 0 === i.actions.length && this._deleteHashElement(i) && s--; + } else { + this.removeAllActionsFromTarget(n); + s--; + } + } + } + } + class YLt extends Tg { + constructor(...t) { + super(...t); + this.actionMgr = new WLt; + } + get ActionManager() { + return this.actionMgr; + } + update(t) { + this.actionMgr.update(t); + } + } + t("TweenSystem", YLt); + YLt.ID = "TWEEN"; + YLt.instance = void 0; + IR.on(RR.EVENT_INIT, (() => { + const t = new YLt; + YLt.instance = t; + IR.registerSystem(YLt.ID, t, Tg.Priority.MEDIUM); + })); + class qLt extends HLt { + isDone() { + return !0; + } + step(t) { + this.update(1); + } + update(t) {} + reverse() { + return this.clone(); + } + clone() { + return new qLt; + } + } + class KLt extends qLt { + update(t) { + const e = this.target.getComponentsInChildren(vS); + for (let t = 0; t < e.length; ++t) { + e[t].enabled = !0; + } + } + reverse() { + return new JLt; + } + clone() { + return new KLt; + } + } + class JLt extends qLt { + update(t) { + const e = this.target.getComponentsInChildren(vS); + for (let t = 0; t < e.length; ++t) { + e[t].enabled = !1; + } + } + reverse() { + return new KLt; + } + clone() { + return new JLt; + } + } + class ZLt extends qLt { + constructor(t) { + super(); + this._isNeedCleanUp = !0; + void 0 !== t && this.init(t); + } + update(t) { + this.target.removeFromParent(); + this._isNeedCleanUp && this.target.destroy(); + } + init(t) { + this._isNeedCleanUp = t; + return !0; + } + reverse() { + return new ZLt(this._isNeedCleanUp); + } + clone() { + return new ZLt(this._isNeedCleanUp); + } + } + class QLt extends qLt { + constructor(t, e, i) { + super(); + this._selectorTarget = null; + this._function = null; + this._data = null; + this.initWithFunction(t, e, i); + } + initWithFunction(t, e, i) { + t && (this._function = t); + e && (this._selectorTarget = e); + void 0 !== i && (this._data = i); + return !0; + } + execute() { + this._function && this._function.call(this._selectorTarget, this.target, this._data); + } + update(t) { + this.execute(); + } + getTargetCallback() { + return this._selectorTarget; + } + setTargetCallback(t) { + if (t !== this._selectorTarget) { + this._selectorTarget && (this._selectorTarget = null); + this._selectorTarget = t; + } + } + clone() { + const t = new QLt; + t.initWithFunction(this._function, this._selectorTarget, this._data); + return t; + } + } + class $Lt extends HLt { + constructor(t) { + super(); + this.MAX_VALUE = 2; + this._elapsed = 0; + this._firstTick = !1; + this._easeList = []; + this._speed = 1; + this._repeatForever = !1; + this._repeatMethod = !1; + this._speedMethod = !1; + void 0 === t || isNaN(t) || this.initWithDuration(t); + } + getElapsed() { + return this._elapsed; + } + initWithDuration(t) { + this._duration = 0 === t ? pe.FLT_EPSILON : t; + this._elapsed = 0; + this._firstTick = !0; + return !0; + } + isDone() { + return this._elapsed >= this._duration; + } + _cloneDecoration(t) { + t._repeatForever = this._repeatForever; + t._speed = this._speed; + t._timesForRepeat = this._timesForRepeat; + t._easeList = this._easeList; + t._speedMethod = this._speedMethod; + t._repeatMethod = this._repeatMethod; + } + _reverseEaseList(t) { + if (this._easeList) { + t._easeList = []; + for (let e = 0; e < this._easeList.length; e++) t._easeList.push(this._easeList[e]); + } + } + clone() { + const t = new $Lt(this._duration); + this._cloneDecoration(t); + return t; + } + easing(t) { + this._easeList ? this._easeList.length = 0 : this._easeList = []; + for (let t = 0; t < arguments.length; t++) this._easeList.push(arguments[t]); + return this; + } + _computeEaseTime(t) { + return t; + } + step(t) { + if (this._firstTick) { + this._firstTick = !1; + this._elapsed = 0; + } else this._elapsed += t; + let e = this._elapsed / (this._duration > 1.192092896e-7 ? this._duration : 1.192092896e-7); + e = e < 1 ? e : 1; + this.update(e > 0 ? e : 0); + if (this._repeatMethod && this._timesForRepeat > 1 && this.isDone()) { + this._repeatForever || this._timesForRepeat--; + this.startWithTarget(this.target); + this.step(this._elapsed - this._duration); + } + } + startWithTarget(t) { + zLt.prototype.startWithTarget.call(this, t); + this._elapsed = 0; + this._firstTick = !0; + } + reverse() { + P(1010); + return this; + } + setAmplitudeRate(t) { + P(1011); + } + getAmplitudeRate() { + P(1012); + return 0; + } + speed(t) { + if (t <= 0) { + P(1013); + return this; + } + this._speedMethod = !0; + this._speed *= t; + return this; + } + getSpeed() { + return this._speed; + } + setSpeed(t) { + this._speed = t; + return this; + } + repeat(t) { + t = Math.round(t); + if (isNaN(t) || t < 1) { + P(1014); + return this; + } + this._repeatMethod = !0; + this._timesForRepeat *= t; + return this; + } + repeatForever() { + this._repeatMethod = !0; + this._timesForRepeat = this.MAX_VALUE; + this._repeatForever = !0; + return this; + } + } + class tFt extends $Lt { + constructor(t) { + super(); + this._actions = []; + this._split = 0; + this._last = 0; + this._reversed = !1; + const e = t instanceof Array ? t : arguments; + if (1 === e.length) { + F(1019); + return; + } + const i = e.length - 1; + i >= 0 && null == e[i] && P(1015); + if (i >= 0) { + let t = e[0]; + let s; + for (let n = 1; n < i; n++) if (e[n]) { + s = t; + t = tFt._actionOneTwo(s, e[n]); + } + this.initWithTwoActions(t, e[i]); + } + } + initWithTwoActions(t, e) { + if (!t || !e) { + F(1025); + return !1; + } + let i = t._duration; + let s = e._duration; + i *= t._repeatMethod ? t._timesForRepeat : 1; + s *= e._repeatMethod ? e._timesForRepeat : 1; + const n = i + s; + this.initWithDuration(n); + this._actions[0] = t; + this._actions[1] = e; + return !0; + } + clone() { + const t = new tFt; + this._cloneDecoration(t); + t.initWithTwoActions(this._actions[0].clone(), this._actions[1].clone()); + return t; + } + startWithTarget(t) { + $Lt.prototype.startWithTarget.call(this, t); + this._split = this._actions[0]._duration / this._duration; + this._split *= this._actions[0]._repeatMethod ? this._actions[0]._timesForRepeat : 1; + this._last = -1; + } + stop() { + -1 !== this._last && this._actions[this._last].stop(); + zLt.prototype.stop.call(this); + } + update(t) { + let e; + let i = 0; + const s = this._split; + const n = this._actions; + const r = this._last; + let o; + if ((t = this._computeEaseTime(t)) < s) { + e = 0 !== s ? t / s : 1; + if (0 === i && 1 === r && this._reversed) { + n[1].update(0); + n[1].stop(); + } + } else { + i = 1; + e = 1 === s ? 1 : (t - s) / (1 - s); + if (-1 === r) { + n[0].startWithTarget(this.target); + n[0].update(1); + n[0].stop(); + } + if (0 === r) { + n[0].update(1); + n[0].stop(); + } + } + o = n[i]; + if (r !== i || !o.isDone()) { + r !== i && o.startWithTarget(this.target); + e *= o._timesForRepeat; + o.update(e > 1 ? e % 1 : e); + this._last = i; + } + } + reverse() { + const t = tFt._actionOneTwo(this._actions[1].reverse(), this._actions[0].reverse()); + this._cloneDecoration(t); + this._reverseEaseList(t); + t._reversed = !0; + return t; + } + } + tFt._actionOneTwo = function(t, e) { + const i = new tFt; + i.initWithTwoActions(t, e); + return i; + }; + function eFt(t) { + const e = t instanceof Array ? t : arguments; + if (1 === e.length) { + F(1019); + return null; + } + const i = e.length - 1; + i >= 0 && null == e[i] && P(1015); + let s = null; + if (i >= 0) { + s = e[0]; + for (let t = 1; t <= i; t++) e[t] && (s = tFt._actionOneTwo(s, e[t])); + } + return s; + } + class iFt extends $Lt { + constructor(t, e) { + super(); + this._times = 0; + this._total = 0; + this._nextDt = 0; + this._actionInstant = !1; + this._innerAction = null; + void 0 !== e && this.initWithAction(t, e); + } + initWithAction(t, e) { + const i = t._duration * e; + if (this.initWithDuration(i)) { + this._times = e; + this._innerAction = t; + if (t instanceof qLt) { + this._actionInstant = !0; + this._times -= 1; + } + this._total = 0; + return !0; + } + return !1; + } + clone() { + const t = new iFt; + this._cloneDecoration(t); + t.initWithAction(this._innerAction.clone(), this._times); + return t; + } + startWithTarget(t) { + this._total = 0; + this._nextDt = this._innerAction._duration / this._duration; + $Lt.prototype.startWithTarget.call(this, t); + this._innerAction.startWithTarget(t); + } + stop() { + this._innerAction.stop(); + zLt.prototype.stop.call(this); + } + update(t) { + t = this._computeEaseTime(t); + const e = this._innerAction; + const i = this._duration; + const s = this._times; + let n = this._nextDt; + if (t >= n) { + for (;t > n && this._total < s; ) { + e.update(1); + this._total++; + e.stop(); + e.startWithTarget(this.target); + n += e._duration / i; + this._nextDt = n > 1 ? 1 : n; + } + if (t >= 1 && this._total < s) { + e.update(1); + this._total++; + } + this._actionInstant || (this._total === s ? e.stop() : e.update(t - (n - e._duration / i))); + } else e.update(t * s % 1); + } + isDone() { + return this._total === this._times; + } + reverse() { + const t = new iFt(this._innerAction.reverse(), this._times); + this._cloneDecoration(t); + this._reverseEaseList(t); + return t; + } + setInnerAction(t) { + this._innerAction !== t && (this._innerAction = t); + } + getInnerAction() { + return this._innerAction; + } + } + class sFt extends $Lt { + constructor(t) { + super(); + this._innerAction = null; + t && this.initWithAction(t); + } + initWithAction(t) { + if (!t) { + F(1026); + return !1; + } + this._innerAction = t; + return !0; + } + clone() { + const t = new sFt; + this._cloneDecoration(t); + t.initWithAction(this._innerAction.clone()); + return t; + } + startWithTarget(t) { + $Lt.prototype.startWithTarget.call(this, t); + this._innerAction.startWithTarget(t); + } + step(t) { + const e = this._innerAction; + e.step(t); + if (e.isDone()) { + e.startWithTarget(this.target); + e.step(e.getElapsed() - e._duration); + } + } + isDone() { + return !1; + } + reverse() { + const t = new sFt(this._innerAction.reverse()); + this._cloneDecoration(t); + this._reverseEaseList(t); + return t; + } + setInnerAction(t) { + this._innerAction !== t && (this._innerAction = t); + } + getInnerAction() { + return this._innerAction; + } + } + class nFt extends $Lt { + constructor(t) { + super(); + this._one = null; + this._two = null; + const e = t instanceof Array ? t : arguments; + if (1 === e.length) { + F(1020); + return; + } + const i = e.length - 1; + i >= 0 && null == e[i] && P(1015); + if (i >= 0) { + let t = e[0]; + let s; + for (let n = 1; n < i; n++) if (e[n]) { + s = t; + t = nFt._actionOneTwo(s, e[n]); + } + this.initWithTwoActions(t, e[i]); + } + } + initWithTwoActions(t, e) { + if (!t || !e) { + F(1027); + return !1; + } + let i = !1; + const s = t._duration; + const n = e._duration; + if (this.initWithDuration(Math.max(s, n))) { + this._one = t; + this._two = e; + s > n ? this._two = tFt._actionOneTwo(e, aFt(s - n)) : s < n && (this._one = tFt._actionOneTwo(t, aFt(n - s))); + i = !0; + } + return i; + } + clone() { + const t = new nFt; + this._cloneDecoration(t); + t.initWithTwoActions(this._one.clone(), this._two.clone()); + return t; + } + startWithTarget(t) { + $Lt.prototype.startWithTarget.call(this, t); + this._one.startWithTarget(t); + this._two.startWithTarget(t); + } + stop() { + this._one.stop(); + this._two.stop(); + zLt.prototype.stop.call(this); + } + update(t) { + t = this._computeEaseTime(t); + this._one && this._one.update(t); + this._two && this._two.update(t); + } + reverse() { + const t = nFt._actionOneTwo(this._one.reverse(), this._two.reverse()); + this._cloneDecoration(t); + this._reverseEaseList(t); + return t; + } + } + nFt._actionOneTwo = function(t, e) { + const i = new nFt; + i.initWithTwoActions(t, e); + return i; + }; + function rFt(t) { + const e = t instanceof Array ? t : arguments; + if (1 === e.length) { + F(1020); + return null; + } + e.length > 0 && null == e[e.length - 1] && P(1015); + let i = e[0]; + for (let t = 1; t < e.length; t++) null != e[t] && (i = nFt._actionOneTwo(i, e[t])); + return i; + } + class oFt extends $Lt { + update(t) {} + reverse() { + const t = new oFt(this._duration); + this._cloneDecoration(t); + this._reverseEaseList(t); + return t; + } + clone() { + const t = new oFt; + this._cloneDecoration(t); + t.initWithDuration(this._duration); + return t; + } + } + function aFt(t) { + return new oFt(t); + } + class lFt extends $Lt { + constructor(t) { + super(); + this._other = null; + t && this.initWithAction(t); + } + initWithAction(t) { + if (!t) { + F(1028); + return !1; + } + if (t === this._other) { + F(1029); + return !1; + } + if ($Lt.prototype.initWithDuration.call(this, t._duration)) { + this._other = t; + return !0; + } + return !1; + } + clone() { + const t = new lFt; + this._cloneDecoration(t); + t.initWithAction(this._other.clone()); + return t; + } + startWithTarget(t) { + $Lt.prototype.startWithTarget.call(this, t); + this._other.startWithTarget(t); + } + update(t) { + t = this._computeEaseTime(t); + this._other && this._other.update(1 - t); + } + reverse() { + return this._other.clone(); + } + stop() { + this._other.stop(); + zLt.prototype.stop.call(this); + } + } + class hFt extends $Lt { + constructor(t, e, i) { + super(); + this._opts = void 0; + this._props = void 0; + this._originProps = void 0; + if (null == i) i = Object.create(null); else { + !function(t) { + const e = " [Tween:] "; + const i = ` option is not support in v + ${f}`; + const s = t; + s.delay && C(`${e}delay${i}`); + s.repeat && C(`${e}repeat${i}`); + s.repeatDelay && C(`${e}repeatDelay${i}`); + s.interpolation && C(`${e}interpolation${i}`); + s.onStop && C(`${e}onStop${i}`); + }(i); + i.easing && "string" == typeof i.easing && (i.easing = function(t) { + const e = t.charAt(0); + if (/[A-Z]/.test(e)) { + const i = (t = t.replace(e, e.toLowerCase())).split("-"); + if (2 === i.length) { + const e = i[0]; + if ("linear" === e) t = "linear"; else { + const s = i[1]; + switch (e) { + case "quadratic": + t = `quad${s}`; + break; + + case "quartic": + t = `quart${s}`; + break; + + case "quintic": + t = `quint${s}`; + break; + + case "sinusoidal": + t = `sine${s}`; + break; + + case "exponential": + t = `expo${s}`; + break; + + case "circular": + t = `circ${s}`; + break; + + default: + t = e + s; + } + } + } + } + return t; + }(i.easing)); + i.progress || (i.progress = this.progress); + if (i.easing && "string" == typeof i.easing) { + const t = i.easing; + i.easing = Td[t]; + i.easing || N(1031, t); + } + } + this._opts = i; + this._props = Object.create(null); + for (const t in e) { + if (!e.hasOwnProperty(t)) continue; + let i = e[t]; + "function" == typeof i && (i = i()); + if (null == i || "string" == typeof i) continue; + let s; + let n; + if (void 0 !== i.value && (i.easing || i.progress)) { + if ("string" == typeof i.easing) { + s = Td[i.easing]; + s || N(1031, i.easing); + } else s = i.easing; + n = i.progress; + i = i.value; + } + const r = Object.create(null); + r.value = i; + r.easing = s; + r.progress = n; + this._props[t] = r; + } + this._originProps = e; + this.initWithDuration(t); + } + clone() { + const t = new hFt(this._duration, this._originProps, this._opts); + this._cloneDecoration(t); + return t; + } + startWithTarget(t) { + $Lt.prototype.startWithTarget.call(this, t); + const e = !!this._opts.relative; + const i = this._props; + for (const s in i) { + const n = t[s]; + if (void 0 === n) continue; + const r = i[s]; + const o = r.value; + if ("number" == typeof n) { + r.start = n; + r.current = n; + r.end = e ? n + o : o; + } else if ("object" == typeof n) { + if (null == r.start) { + r.start = {}; + r.current = {}; + r.end = {}; + } + for (const t in o) if (!isNaN(n[t])) { + r.start[t] = n[t]; + r.current[t] = n[t]; + r.end[t] = e ? n[t] + o[t] : o[t]; + } + } + } + this._opts.onStart && this._opts.onStart(this.target); + } + update(t) { + const e = this.target; + if (!e) return; + const i = this._props; + const s = this._opts; + let n = t; + s.easing && (n = s.easing(t)); + const r = s.progress; + for (const s in i) { + const o = i[s]; + const a = o.easing ? o.easing(t) : n; + const l = o.progress ? o.progress : r; + const h = o.start; + const c = o.end; + if ("number" == typeof h) o.current = l(h, c, o.current, a); else if ("object" == typeof h) for (const t in h) o.current[t] = l(h[t], c[t], o.current[t], a); + e[s] = o.current; + } + s.onUpdate && s.onUpdate(this.target, t); + 1 === t && s.onComplete && s.onComplete(this.target); + } + progress(t, e, i, s) { + return t + (e - t) * s; + } + } + t("TweenAction", hFt); + class cFt extends qLt { + constructor(t) { + super(); + this._props = void 0; + this._props = {}; + void 0 !== t && this.init(t); + } + init(t) { + for (const e in t) this._props[e] = t[e]; + return !0; + } + update() { + const t = this._props; + const e = this.target; + for (const i in t) e[i] = t[i]; + } + clone() { + const t = new cFt; + t.init(this._props); + return t; + } + } + class uFt { + constructor(t) { + this._actions = []; + this._finalAction = null; + this._target = null; + this._tag = zLt.TAG_INVALID; + this._target = void 0 === t ? null : t; + } + tag(t) { + this._tag = t; + return this; + } + then(t) { + t instanceof zLt ? this._actions.push(t.clone()) : this._actions.push(t._union()); + return this; + } + target(t) { + this._target = t; + return this; + } + start() { + if (!this._target) { + C("Please set target to tween first"); + return this; + } + this._finalAction && YLt.instance.ActionManager.removeAction(this._finalAction); + this._finalAction = this._union(); + this._finalAction.setTag(this._tag); + YLt.instance.ActionManager.addAction(this._finalAction, this._target, !1); + return this; + } + stop() { + this._finalAction && YLt.instance.ActionManager.removeAction(this._finalAction); + return this; + } + clone(t) { + const e = this._union(); + return _Ft(t).then(e.clone()); + } + union() { + const t = this._union(); + this._actions.length = 0; + this._actions.push(t); + return this; + } + to(t, e, i) { + (i = i || Object.create(null)).relative = !1; + const s = new hFt(t, e, i); + this._actions.push(s); + return this; + } + by(t, e, i) { + (i = i || Object.create(null)).relative = !0; + const s = new hFt(t, e, i); + this._actions.push(s); + return this; + } + set(t) { + const e = new cFt(t); + this._actions.push(e); + return this; + } + delay(t) { + const e = aFt(t); + this._actions.push(e); + return this; + } + call(t) { + const e = function(t, e, i) { + return new QLt(t, e, i); + }(t); + this._actions.push(e); + return this; + } + sequence(...t) { + const e = uFt._wrappedSequence(...t); + this._actions.push(e); + return this; + } + parallel(...t) { + const e = uFt._wrappedParallel(...t); + this._actions.push(e); + return this; + } + repeat(t, e) { + if (t === 1 / 0) return this.repeatForever(e); + const i = this._actions; + let s; + s = e instanceof uFt ? e._union() : i.pop(); + i.push(function(t, e) { + return new iFt(t, e); + }(s, t)); + return this; + } + repeatForever(t) { + const e = this._actions; + let i; + i = t instanceof uFt ? t._union() : e.pop(); + e.push(function(t) { + return new sFt(t); + }(i)); + return this; + } + reverseTime(t) { + const e = this._actions; + let i; + i = t instanceof uFt ? t._union() : e.pop(); + e.push(function(t) { + return new lFt(t); + }(i)); + return this; + } + hide() { + const t = new JLt; + this._actions.push(t); + return this; + } + show() { + const t = new KLt; + this._actions.push(t); + return this; + } + removeSelf() { + const t = new ZLt(!1); + this._actions.push(t); + return this; + } + static stopAll() { + YLt.instance.ActionManager.removeAllActions(); + } + static stopAllByTag(t, e) { + YLt.instance.ActionManager.removeAllActionsByTag(t, e); + } + static stopAllByTarget(t) { + YLt.instance.ActionManager.removeAllActionsFromTarget(t); + } + _union() { + const t = this._actions; + let e; + e = 1 === t.length ? t[0] : eFt(t); + return e; + } + _destroy() { + this.stop(); + } + static _wrappedSequence(...t) { + const e = uFt._tmp_args; + e.length = 0; + for (let i = t.length, s = 0; s < i; s++) { + const i = e[s] = t[s]; + i instanceof uFt && (e[s] = i._union()); + } + return eFt.apply(eFt, e); + } + static _wrappedParallel(...t) { + const e = uFt._tmp_args; + e.length = 0; + for (let i = t.length, s = 0; s < i; s++) { + const i = e[s] = t[s]; + i instanceof uFt && (e[s] = i._union()); + } + return rFt.apply(rFt, e); + } + } + t("Tween", uFt); + uFt._tmp_args = []; + m.Tween = uFt; + function _Ft(t) { + return new uFt(t); + } + m.tween = _Ft; + function dFt(t) { + C("tweenUtil' is deprecated, please use 'tween' instead "); + return new uFt(t); + } + m.tweenUtil = dFt; + let pFt; + !function(t) { + t[t.Other = 0] = "Other"; + t[t.Left = 1] = "Left"; + t[t.Right = 2] = "Right"; + }(pFt || (pFt = t("DeviceType", {}))); + let mFt; + !function(t) { + t.SELECT_ENTERED = "select-entered"; + t.SELECT_EXITED = "select-exited"; + t.SELECT_CANCELED = "select-canceled"; + t.ACTIVATED = "OnActivited"; + t.DEACTIVITED = "Deactivited"; + t.ACTIVATE_CANCELED = "activate-canceled"; + t.UIPRESS_ENTERED = "UI-press-entered"; + t.UIPRESS_EXITED = "UI-press-exited"; + t.UIPRESS_CANCELED = "UI-press-canceled"; + t.HOVER_ENTERED = "hover-entered"; + t.HOVER_EXITED = "hover-exited"; + t.HOVER_STAY = "hover-stay"; + t.HOVER_CANCELED = "hover-canceled"; + }(mFt || (mFt = t("XrControlEventType", {}))); + t("XrEventHandle", class extends RS { + constructor(...t) { + super(...t); + this.deviceType = pFt.Other; + this.hitPoint = new Pi; + this.model = null; + this.eventHandle = 0; + this.triggerId = ""; + this.attachNode = null; + this.forceGrab = !0; + } + }); + let fFt; + !function(t) { + t.XRUI_HOVER_ENTERED = "xrui-hover-entered"; + t.XRUI_HOVER_EXITED = "xrui-hover-exited"; + t.XRUI_HOVER_STAY = "xrui-hover-stay"; + t.XRUI_CLICK = "xrui-click"; + t.XRUI_UNCLICK = "xrui-unclick"; + }(fFt || (fFt = t("XrUIPressEventType", {}))); + let gFt; + !function(t) { + t.XR_CAPS_LOCK = "xr-caps-lock"; + t.XR_KEYBOARD_INIT = "xr-keyboard-init"; + t.XR_KEYBOARD_INPUT = "xr-keyboard-input"; + t.TO_LATIN = "to-latin"; + t.TO_SYMBOL = "to-symbol"; + t.TO_MATH_SYMBOL = "to-math-symbol"; + }(gFt || (gFt = t("XrKeyboardEventType", {}))); + t("XrUIPressEvent", class extends RS { + constructor(...t) { + super(...t); + this.deviceType = pFt.Other; + this.hitPoint = new Pi; + } + }); + var yFt, bFt, SFt, AFt, TFt, vFt, EFt, CFt, xFt, wFt, RFt, IFt, MFt, BFt, DFt, PFt, OFt, NFt, LFt, FFt, VFt, kFt, UFt, GFt, zFt, HFt, jFt, XFt, WFt, YFt, qFt, KFt, JFt, ZFt, QFt, $Ft, tVt, eVt, iVt, sVt, nVt, rVt, oVt, aVt, lVt, hVt, cVt, uVt, _Vt, dVt, pVt, mVt, fVt, gVt, yVt, bVt, SVt, AVt, TVt, vVt; + const EVt = new Bi; + var CVt; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.COLOR = 1] = "COLOR"; + t[t.SPRITE = 2] = "SPRITE"; + t[t.SCALE = 3] = "SCALE"; + }(CVt || (CVt = {})); + he(CVt); + var xVt; + !function(t) { + t.NORMAL = "normal"; + t.HOVER = "hover"; + t.PRESSED = "pressed"; + t.DISABLED = "disabled"; + }(xVt || (xVt = {})); + let wVt; + !function(t) { + t.CLICK = "click"; + }(wVt || (wVt = {})); + let RVt = function(e) { + return t({ + Button: e, + ButtonComponent: e + }), e; + }((yFt = Ul("cc.Button"), bFt = sh(), SFt = zl(110), AFt = $l(), TFt = Gl(jB), vFt = Th(_y), + EFt = ph(), CFt = lh(), xFt = ph(), wFt = lh(), RFt = Th(CVt), IFt = ph(), MFt = lh(), + BFt = ph(), DFt = lh(), PFt = ph(), OFt = lh(), NFt = ph(), LFt = lh(), FFt = ph(), + VFt = lh(), kFt = ch(), UFt = uh(), GFt = ph(), zFt = lh(), HFt = ph(), jFt = lh(), + XFt = Th(GI), WFt = ph(), YFt = lh(), qFt = Th(GI), KFt = ph(), JFt = lh(), ZFt = Th(GI), + QFt = ph(), $Ft = lh(), tVt = Th(GI), eVt = ph(), iVt = lh(), sVt = Th([ Vc ]), + nVt = ph(), rVt = lh(), yFt(oVt = bFt(oVt = SFt(oVt = AFt(oVt = TFt(oVt = Ql(oVt = (aVt = (vVt = TVt = class extends Qc { + constructor(...t) { + super(...t); + Ml(this, "clickEvents", lVt, this); + Ml(this, "_interactable", hVt, this); + Ml(this, "_transition", cVt, this); + Ml(this, "_normalColor", uVt, this); + Ml(this, "_hoverColor", _Vt, this); + Ml(this, "_pressedColor", dVt, this); + Ml(this, "_disabledColor", pVt, this); + Ml(this, "_normalSprite", mVt, this); + Ml(this, "_hoverSprite", fVt, this); + Ml(this, "_pressedSprite", gVt, this); + Ml(this, "_disabledSprite", yVt, this); + Ml(this, "_duration", bVt, this); + Ml(this, "_zoomScale", SVt, this); + Ml(this, "_target", AVt, this); + this._pressed = !1; + this._hovered = !1; + this._fromColor = new Bi; + this._toColor = new Bi; + this._time = 0; + this._transitionFinished = !0; + this._fromScale = new Pi; + this._toScale = new Pi; + this._originalScale = null; + this._sprite = null; + this._targetScale = new Pi; + } + get target() { + return this._target || this.node; + } + set target(t) { + if (this._target !== t) { + this._target && this._unregisterTargetEvent(this._target); + this._target = t; + this._applyTarget(); + } + } + get interactable() { + return this._interactable; + } + set interactable(t) { + if (this._interactable !== t) { + this._interactable = t; + this._updateState(); + this._interactable || this._resetState(); + } + } + set _resizeToTarget(t) { + t && this._resizeNodeToTargetNode(); + } + get transition() { + return this._transition; + } + set transition(t) { + if (this._transition !== t) { + this._transition === CVt.COLOR ? this._updateColorTransition(xVt.NORMAL) : this._transition === CVt.SPRITE && this._updateSpriteTransition(xVt.NORMAL); + this._transition = t; + this._updateState(); + } + } + get normalColor() { + return this._normalColor; + } + set normalColor(t) { + if (this._normalColor !== t) { + this._normalColor.set(t); + this._updateState(); + } + } + get pressedColor() { + return this._pressedColor; + } + set pressedColor(t) { + this._pressedColor !== t && this._pressedColor.set(t); + } + get hoverColor() { + return this._hoverColor; + } + set hoverColor(t) { + this._hoverColor !== t && this._hoverColor.set(t); + } + get disabledColor() { + return this._disabledColor; + } + set disabledColor(t) { + if (this._disabledColor !== t) { + this._disabledColor.set(t); + this._updateState(); + } + } + get duration() { + return this._duration; + } + set duration(t) { + this._duration !== t && (this._duration = t); + } + get zoomScale() { + return this._zoomScale; + } + set zoomScale(t) { + this._zoomScale !== t && (this._zoomScale = t); + } + get normalSprite() { + return this._normalSprite; + } + set normalSprite(t) { + if (this._normalSprite === t) return; + this._normalSprite = t; + const e = this.node.getComponent(cL); + e && (e.spriteFrame = t); + this._updateState(); + } + get pressedSprite() { + return this._pressedSprite; + } + set pressedSprite(t) { + if (this._pressedSprite !== t) { + this._pressedSprite = t; + this._updateState(); + } + } + get hoverSprite() { + return this._hoverSprite; + } + set hoverSprite(t) { + if (this._hoverSprite !== t) { + this._hoverSprite = t; + this._updateState(); + } + } + get disabledSprite() { + return this._disabledSprite; + } + set disabledSprite(t) { + if (this._disabledSprite !== t) { + this._disabledSprite = t; + this._updateState(); + } + } + __preload() { + this.target || (this.target = this.node); + const t = this.node.getComponent(cL); + t && (this._normalSprite = t.spriteFrame); + this._applyTarget(); + this._resetState(); + } + onEnable() { + this._registerNodeEvent(); + } + onDisable() { + this._resetState(); + this._unregisterNodeEvent(); + } + onDestroy() { + this.target.isValid && this._unregisterTargetEvent(this.target); + } + update(t) { + const e = this.target; + if (this._transitionFinished || !e) return; + if (this._transition !== CVt.COLOR && this._transition !== CVt.SCALE) return; + this._time += t; + let i = 1; + this._duration > 0 && (i = this._time / this._duration); + i >= 1 && (i = 1); + if (this._transition === CVt.COLOR) { + const t = e._uiProps.uiComp; + Bi.lerp(EVt, this._fromColor, this._toColor, i); + t && (t.color = EVt); + } else if (this.transition === CVt.SCALE) { + e.getScale(this._targetScale); + this._targetScale.x = pi(this._fromScale.x, this._toScale.x, i); + this._targetScale.y = pi(this._fromScale.y, this._toScale.y, i); + e.setScale(this._targetScale); + } + 1 === i && (this._transitionFinished = !0); + } + _resizeNodeToTargetNode() { + if (!this.target) return; + this.target._uiProps.uiTransformComp; + } + _resetState() { + this._pressed = !1; + this._hovered = !1; + const t = this.target; + if (!t) return; + const e = this._transition; + if (e === CVt.COLOR && this._interactable) { + const e = t.getComponent(uD); + e && (e.color = this._normalColor); + } else e === CVt.SCALE && this._originalScale && t.setScale(this._originalScale); + this._transitionFinished = !0; + } + _registerNodeEvent() { + this.node.on(ny.TOUCH_START, this._onTouchBegan, this); + this.node.on(ny.TOUCH_MOVE, this._onTouchMove, this); + this.node.on(ny.TOUCH_END, this._onTouchEnded, this); + this.node.on(ny.TOUCH_CANCEL, this._onTouchCancel, this); + this.node.on(ny.MOUSE_ENTER, this._onMouseMoveIn, this); + this.node.on(ny.MOUSE_LEAVE, this._onMouseMoveOut, this); + this.node.on(fFt.XRUI_HOVER_ENTERED, this._xrHoverEnter, this); + this.node.on(fFt.XRUI_HOVER_EXITED, this._xrHoverExit, this); + this.node.on(fFt.XRUI_CLICK, this._xrClick, this); + this.node.on(fFt.XRUI_UNCLICK, this._xrUnClick, this); + } + _registerTargetEvent(t) { + t.on(ny.TRANSFORM_CHANGED, this._onTargetTransformChanged, this); + } + _unregisterNodeEvent() { + this.node.off(ny.TOUCH_START, this._onTouchBegan, this); + this.node.off(ny.TOUCH_MOVE, this._onTouchMove, this); + this.node.off(ny.TOUCH_END, this._onTouchEnded, this); + this.node.off(ny.TOUCH_CANCEL, this._onTouchCancel, this); + this.node.off(ny.MOUSE_ENTER, this._onMouseMoveIn, this); + this.node.off(ny.MOUSE_LEAVE, this._onMouseMoveOut, this); + this.node.off(fFt.XRUI_HOVER_ENTERED, this._xrHoverEnter, this); + this.node.off(fFt.XRUI_HOVER_EXITED, this._xrHoverExit, this); + this.node.off(fFt.XRUI_CLICK, this._xrClick, this); + this.node.off(fFt.XRUI_UNCLICK, this._xrUnClick, this); + } + _unregisterTargetEvent(t) { + t.off(ny.TRANSFORM_CHANGED); + } + _getTargetSprite(t) { + let e = null; + t && (e = t.getComponent(cL)); + return e; + } + _applyTarget() { + if (this.target) { + this._sprite = this._getTargetSprite(this.target); + this._originalScale || (this._originalScale = new Pi); + Pi.copy(this._originalScale, this.target.getScale()); + this._registerTargetEvent(this.target); + } + } + _onTargetSpriteFrameChanged(t) { + this._transition === CVt.SPRITE && this._setCurrentStateSpriteFrame(t.spriteFrame); + } + _setCurrentStateSpriteFrame(t) { + if (t) switch (this._getButtonState()) { + case xVt.NORMAL: + this._normalSprite = t; + break; + + case xVt.HOVER: + this._hoverSprite = t; + break; + + case xVt.PRESSED: + this._pressedSprite = t; + break; + + case xVt.DISABLED: + this._disabledSprite = t; + } + } + _onTargetColorChanged(t) { + this._transition === CVt.COLOR && this._setCurrentStateColor(t); + } + _setCurrentStateColor(t) { + switch (this._getButtonState()) { + case xVt.NORMAL: + this._normalColor = t; + break; + + case xVt.HOVER: + this._hoverColor = t; + break; + + case xVt.PRESSED: + this._pressedColor = t; + break; + + case xVt.DISABLED: + this._disabledColor = t; + } + } + _onTargetTransformChanged(t) { + t & ay.SCALE && this._originalScale && this._transition === CVt.SCALE && this._transitionFinished && Pi.copy(this._originalScale, this.target.getScale()); + } + _onTouchBegan(t) { + if (this._interactable && this.enabledInHierarchy) { + this._pressed = !0; + this._updateState(); + t && (t.propagationStopped = !0); + } + } + _onTouchMove(t) { + if (!this._interactable || !this.enabledInHierarchy || !this._pressed) return; + if (!t) return; + const e = t.touch; + if (!e) return; + const i = this.node._uiProps.uiTransformComp.hitTest(e.getLocation()); + if (this._transition === CVt.SCALE && this.target && this._originalScale) if (i) { + Pi.copy(this._fromScale, this._originalScale); + Pi.multiplyScalar(this._toScale, this._originalScale, this._zoomScale); + this._transitionFinished = !1; + } else { + this._time = 0; + this._transitionFinished = !0; + this.target.setScale(this._originalScale); + } else { + let t; + t = i ? xVt.PRESSED : xVt.NORMAL; + this._applyTransition(t); + } + t && (t.propagationStopped = !0); + } + _onTouchEnded(t) { + if (this._interactable && this.enabledInHierarchy) { + if (this._pressed) { + Vc.emitEvents(this.clickEvents, t); + this.node.emit(wVt.CLICK, this); + } + this._pressed = !1; + this._updateState(); + t && (t.propagationStopped = !0); + } + } + _onTouchCancel(t) { + if (this._interactable && this.enabledInHierarchy) { + this._pressed = !1; + this._updateState(); + } + } + _onMouseMoveIn(t) { + if (!this._pressed && this.interactable && this.enabledInHierarchy && (this._transition !== CVt.SPRITE || this._hoverSprite) && !this._hovered) { + this._hovered = !0; + this._updateState(); + } + } + _onMouseMoveOut(t) { + if (this._hovered) { + this._hovered = !1; + this._updateState(); + } + } + _updateState() { + const t = this._getButtonState(); + this._applyTransition(t); + } + _getButtonState() { + let t = xVt.NORMAL; + this._interactable ? this._pressed ? t = xVt.PRESSED : this._hovered && (t = xVt.HOVER) : t = xVt.DISABLED; + return t.toString(); + } + _updateColorTransition(t) { + var e; + const i = this[`${t}Color`]; + const s = null === (e = this.target) || void 0 === e ? void 0 : e.getComponent(uD); + if (s) if (t === xVt.DISABLED) s.color = i; else { + this._fromColor = s.color.clone(); + this._toColor = i; + this._time = 0; + this._transitionFinished = !1; + } + } + _updateSpriteTransition(t) { + const e = this[`${t}Sprite`]; + this._sprite && e && (this._sprite.spriteFrame = e); + } + _updateScaleTransition(t) { + this._interactable && (t === xVt.PRESSED ? this._zoomUp() : this._zoomBack()); + } + _zoomUp() { + if (this._originalScale) { + Pi.copy(this._fromScale, this._originalScale); + Pi.multiplyScalar(this._toScale, this._originalScale, this._zoomScale); + this._time = 0; + this._transitionFinished = !1; + } + } + _zoomBack() { + if (this.target && this._originalScale) { + Pi.copy(this._fromScale, this.target.getScale()); + Pi.copy(this._toScale, this._originalScale); + this._time = 0; + this._transitionFinished = !1; + } + } + _applyTransition(t) { + const e = this._transition; + e === CVt.COLOR ? this._updateColorTransition(t) : e === CVt.SPRITE ? this._updateSpriteTransition(t) : e === CVt.SCALE && this._updateScaleTransition(t); + } + _xrHoverEnter() { + this._onMouseMoveIn(); + this._updateState(); + } + _xrHoverExit() { + this._onMouseMoveOut(); + if (this._pressed) { + this._pressed = !1; + this._updateState(); + } + } + _xrClick() { + if (this._interactable && this.enabledInHierarchy) { + this._pressed = !0; + this._updateState(); + } + } + _xrUnClick() { + if (this._interactable && this.enabledInHierarchy) { + if (this._pressed) { + Vc.emitEvents(this.clickEvents, this); + this.node.emit(wVt.CLICK, this); + } + this._pressed = !1; + this._updateState(); + } + } + }, TVt.Transition = CVt, TVt.EventType = wVt, vVt), Bl(aVt.prototype, "target", [ vFt, EFt, CFt ], Object.getOwnPropertyDescriptor(aVt.prototype, "target"), aVt.prototype), + Bl(aVt.prototype, "interactable", [ xFt, wFt ], Object.getOwnPropertyDescriptor(aVt.prototype, "interactable"), aVt.prototype), + Bl(aVt.prototype, "transition", [ RFt, IFt, MFt ], Object.getOwnPropertyDescriptor(aVt.prototype, "transition"), aVt.prototype), + Bl(aVt.prototype, "normalColor", [ BFt, DFt ], Object.getOwnPropertyDescriptor(aVt.prototype, "normalColor"), aVt.prototype), + Bl(aVt.prototype, "pressedColor", [ PFt, OFt ], Object.getOwnPropertyDescriptor(aVt.prototype, "pressedColor"), aVt.prototype), + Bl(aVt.prototype, "hoverColor", [ NFt, LFt ], Object.getOwnPropertyDescriptor(aVt.prototype, "hoverColor"), aVt.prototype), + Bl(aVt.prototype, "disabledColor", [ FFt, VFt ], Object.getOwnPropertyDescriptor(aVt.prototype, "disabledColor"), aVt.prototype), + Bl(aVt.prototype, "duration", [ kFt, UFt, GFt, zFt ], Object.getOwnPropertyDescriptor(aVt.prototype, "duration"), aVt.prototype), + Bl(aVt.prototype, "zoomScale", [ HFt, jFt ], Object.getOwnPropertyDescriptor(aVt.prototype, "zoomScale"), aVt.prototype), + Bl(aVt.prototype, "normalSprite", [ XFt, WFt, YFt ], Object.getOwnPropertyDescriptor(aVt.prototype, "normalSprite"), aVt.prototype), + Bl(aVt.prototype, "pressedSprite", [ qFt, KFt, JFt ], Object.getOwnPropertyDescriptor(aVt.prototype, "pressedSprite"), aVt.prototype), + Bl(aVt.prototype, "hoverSprite", [ ZFt, QFt, $Ft ], Object.getOwnPropertyDescriptor(aVt.prototype, "hoverSprite"), aVt.prototype), + Bl(aVt.prototype, "disabledSprite", [ tVt, eVt, iVt ], Object.getOwnPropertyDescriptor(aVt.prototype, "disabledSprite"), aVt.prototype), + lVt = Bl(aVt.prototype, "clickEvents", [ sVt, Yl, nVt, rVt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), hVt = Bl(aVt.prototype, "_interactable", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), cVt = Bl(aVt.prototype, "_transition", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return CVt.NONE; + } + }), uVt = Bl(aVt.prototype, "_normalColor", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Bi.WHITE.clone(); + } + }), _Vt = Bl(aVt.prototype, "_hoverColor", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Bi(211, 211, 211, 255); + } + }), dVt = Bl(aVt.prototype, "_pressedColor", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return Bi.WHITE.clone(); + } + }), pVt = Bl(aVt.prototype, "_disabledColor", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new Bi(124, 124, 124, 255); + } + }), mVt = Bl(aVt.prototype, "_normalSprite", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), fVt = Bl(aVt.prototype, "_hoverSprite", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), gVt = Bl(aVt.prototype, "_pressedSprite", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), yVt = Bl(aVt.prototype, "_disabledSprite", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), bVt = Bl(aVt.prototype, "_duration", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .1; + } + }), SVt = Bl(aVt.prototype, "_zoomScale", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1.2; + } + }), AVt = Bl(aVt.prototype, "_target", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), aVt)) || oVt) || oVt) || oVt) || oVt) || oVt) || oVt)); + m.Button = RVt; + class IVt { + static add(t) { + const e = this._tabIndexList; + -1 === e.indexOf(t) && e.push(t); + } + static remove(t) { + const e = this._tabIndexList; + const i = e.indexOf(t); + -1 !== i && e.splice(i, 1); + } + static resort() { + this._tabIndexList.sort(((t, e) => t._delegate.tabIndex - e._delegate.tabIndex)); + } + static next(t) { + const e = this._tabIndexList; + const i = e.indexOf(t); + t.setFocus(!1); + if (-1 !== i) { + const t = e[i + 1]; + t && t._delegate.tabIndex >= 0 && t.setFocus(!0); + } + } + } + IVt._tabIndexList = []; + let MVt; + !function(t) { + t[t.DEFAULT = 0] = "DEFAULT"; + t[t.DONE = 1] = "DONE"; + t[t.SEND = 2] = "SEND"; + t[t.SEARCH = 3] = "SEARCH"; + t[t.GO = 4] = "GO"; + t[t.NEXT = 5] = "NEXT"; + }(MVt || (MVt = {})); + oe(MVt); + let BVt; + !function(t) { + t[t.ANY = 0] = "ANY"; + t[t.EMAIL_ADDR = 1] = "EMAIL_ADDR"; + t[t.NUMERIC = 2] = "NUMERIC"; + t[t.PHONE_NUMBER = 3] = "PHONE_NUMBER"; + t[t.URL = 4] = "URL"; + t[t.DECIMAL = 5] = "DECIMAL"; + t[t.SINGLE_LINE = 6] = "SINGLE_LINE"; + }(BVt || (BVt = {})); + oe(BVt); + let DVt; + !function(t) { + t[t.PASSWORD = 0] = "PASSWORD"; + t[t.SENSITIVE = 1] = "SENSITIVE"; + t[t.INITIAL_CAPS_WORD = 2] = "INITIAL_CAPS_WORD"; + t[t.INITIAL_CAPS_SENTENCE = 3] = "INITIAL_CAPS_SENTENCE"; + t[t.INITIAL_CAPS_ALL_CHARACTERS = 4] = "INITIAL_CAPS_ALL_CHARACTERS"; + t[t.DEFAULT = 5] = "DEFAULT"; + }(DVt || (DVt = {})); + oe(DVt); + class PVt { + constructor() { + this._editing = !1; + this._delegate = null; + } + init(t) {} + onEnable() {} + update() {} + onDisable() { + this._editing && this.endEditing(); + } + clear() { + this._delegate = null; + } + setTabIndex(t) {} + setSize(t, e) {} + setFocus(t) { + t ? this.beginEditing() : this.endEditing(); + } + isFocused() { + return this._editing; + } + beginEditing() {} + endEditing() {} + } + new qi; + new qi; + new Pi; + var OVt, NVt, LVt, FVt, VVt, kVt, UVt, GVt, zVt, HVt, jVt, XVt, WVt, YVt, qVt, KVt, JVt, ZVt, QVt, $Vt, tkt, ekt, ikt, skt, nkt, rkt, okt, akt, lkt, hkt, ckt, ukt, _kt, dkt, pkt, mkt, fkt, gkt, ykt, bkt, Skt, Akt, Tkt, vkt, Ekt, Ckt, xkt, wkt, Rkt, Ikt, Mkt, Bkt, Dkt, Pkt, Okt, Nkt, Lkt, Fkt, Vkt, kkt; + var Ukt; + !function(t) { + t.EDITING_DID_BEGAN = "editing-did-began"; + t.EDITING_DID_ENDED = "editing-did-ended"; + t.TEXT_CHANGED = "text-changed"; + t.EDITING_RETURN = "editing-return"; + t.XR_EDITING_DID_BEGAN = "xr-editing-did-began"; + t.XR_EDITING_DID_ENDED = "xr-editing-did-ended"; + }(Ukt || (Ukt = {})); + let Gkt = function(e) { + return t({ + EditBox: e, + EditBoxComponent: e + }), e; + }((OVt = Ul("cc.EditBox"), NVt = sh(), LVt = zl(110), FVt = $l(), VVt = Gl(jB), + kVt = ph(), UVt = lh(), GVt = ph(), zVt = lh(), HVt = Th(IP), jVt = ph(), XVt = lh(), + WVt = Th(IP), YVt = ph(), qVt = lh(), KVt = Th(GI), JVt = ph(), ZVt = lh(), QVt = Th(DVt), + $Vt = ph(), tkt = lh(), ekt = Th(BVt), ikt = ph(), skt = lh(), nkt = Th(MVt), rkt = ph(), + okt = lh(), akt = ph(), lkt = lh(), hkt = ph(), ckt = lh(), ukt = Th([ Vc ]), _kt = ph(), + dkt = lh(), pkt = Th([ Vc ]), mkt = ph(), fkt = lh(), gkt = Th([ Vc ]), ykt = ph(), + bkt = lh(), Skt = Th([ Vc ]), Akt = ph(), Tkt = lh(), OVt(vkt = NVt(vkt = LVt(vkt = FVt(vkt = VVt(vkt = Ql(vkt = (Ekt = (kkt = Vkt = class t extends Qc { + constructor(...t) { + super(...t); + Ml(this, "editingDidBegan", Ckt, this); + Ml(this, "textChanged", xkt, this); + Ml(this, "editingDidEnded", wkt, this); + Ml(this, "editingReturn", Rkt, this); + this._impl = null; + this._background = null; + Ml(this, "_textLabel", Ikt, this); + Ml(this, "_placeholderLabel", Mkt, this); + Ml(this, "_returnType", Bkt, this); + Ml(this, "_string", Dkt, this); + Ml(this, "_tabIndex", Pkt, this); + Ml(this, "_backgroundImage", Okt, this); + Ml(this, "_inputFlag", Nkt, this); + Ml(this, "_inputMode", Lkt, this); + Ml(this, "_maxLength", Fkt, this); + this._isLabelVisible = !1; + } + get string() { + return this._string; + } + set string(t) { + this._maxLength >= 0 && t.length >= this._maxLength && (t = t.slice(0, this._maxLength)); + if (this._string !== t) { + this._string = t; + this._updateString(t); + } + } + get placeholder() { + return this._placeholderLabel ? this._placeholderLabel.string : ""; + } + set placeholder(t) { + this._placeholderLabel && (this._placeholderLabel.string = t); + } + get textLabel() { + return this._textLabel; + } + set textLabel(t) { + if (this._textLabel !== t) { + this._textLabel = t; + if (this._textLabel) { + this._updateTextLabel(); + this._updateLabels(); + } + } + } + get placeholderLabel() { + return this._placeholderLabel; + } + set placeholderLabel(t) { + if (this._placeholderLabel !== t) { + this._placeholderLabel = t; + if (this._placeholderLabel) { + this._updatePlaceholderLabel(); + this._updateLabels(); + } + } + } + get backgroundImage() { + return this._backgroundImage; + } + set backgroundImage(t) { + if (this._backgroundImage !== t) { + this._backgroundImage = t; + this._ensureBackgroundSprite(); + this._background.spriteFrame = t; + } + } + get inputFlag() { + return this._inputFlag; + } + set inputFlag(t) { + if (this._inputFlag !== t) { + this._inputFlag = t; + this._updateString(this._string); + } + } + get inputMode() { + return this._inputMode; + } + set inputMode(t) { + if (this._inputMode !== t) { + this._inputMode = t; + this._updateTextLabel(); + this._updatePlaceholderLabel(); + } + } + get returnType() { + return this._returnType; + } + set returnType(t) { + this._returnType = t; + } + get maxLength() { + return this._maxLength; + } + set maxLength(t) { + this._maxLength = t; + } + get tabIndex() { + return this._tabIndex; + } + set tabIndex(t) { + if (this._tabIndex !== t) { + this._tabIndex = t; + this._impl && this._impl.setTabIndex(t); + } + } + __preload() { + this._init(); + } + onEnable() { + this._registerEvent(); + this._ensureBackgroundSprite(); + this._impl && this._impl.onEnable(); + } + update() { + this._impl && this._impl.update(); + } + onDisable() { + this._unregisterEvent(); + this._unregisterBackgroundEvent(); + this._impl && this._impl.onDisable(); + } + onDestroy() { + this._impl && this._impl.clear(); + } + setFocus() { + this._impl && this._impl.setFocus(!0); + } + focus() { + this._impl && this._impl.setFocus(!0); + } + blur() { + this._impl && this._impl.setFocus(!1); + } + isFocused() { + return !!this._impl && this._impl.isFocused(); + } + _editBoxEditingDidBegan() { + Vc.emitEvents(this.editingDidBegan, this); + this.node.emit(Ukt.EDITING_DID_BEGAN, this); + } + _editBoxEditingDidEnded() { + Vc.emitEvents(this.editingDidEnded, this); + this.node.emit(Ukt.EDITING_DID_ENDED, this); + } + _editBoxTextChanged(t) { + t = this._updateLabelStringStyle(t, !0); + this.string = t; + Vc.emitEvents(this.textChanged, t, this); + this.node.emit(Ukt.TEXT_CHANGED, this); + } + _editBoxEditingReturn() { + Vc.emitEvents(this.editingReturn, this); + this.node.emit(Ukt.EDITING_RETURN, this); + } + _showLabels() { + this._isLabelVisible = !0; + this._updateLabels(); + } + _hideLabels() { + this._isLabelVisible = !1; + this._textLabel && (this._textLabel.node.active = !1); + this._placeholderLabel && (this._placeholderLabel.node.active = !1); + } + _onTouchBegan(t) { + t.propagationStopped = !0; + } + _onTouchCancel(t) { + t.propagationStopped = !0; + } + _onTouchEnded(t) { + this._impl && this._impl.beginEditing(); + t.propagationStopped = !0; + } + _init() { + this._updatePlaceholderLabel(); + this._updateTextLabel(); + this._isLabelVisible = !0; + this.node.on(ny.SIZE_CHANGED, this._resizeChildNodes, this); + (this._impl = new t._EditBoxImpl).init(this); + this._updateString(this._string); + this._syncSize(); + } + _ensureBackgroundSprite() { + if (!this._background) { + let t = this.node.getComponent(cL); + t || (t = this.node.addComponent(cL)); + if (t !== this._background) { + t.type = cL.Type.SLICED; + t.spriteFrame = this._backgroundImage; + this._background = t; + this._registerBackgroundEvent(); + } + } + } + _updateTextLabel() { + let t = this._textLabel; + if (!t) { + let e = this.node.getChildByName("TEXT_LABEL"); + if (!e) { + e = new _y("TEXT_LABEL"); + e.layer = this.node.layer; + } + t = e.getComponent(IP); + t || (t = e.addComponent(IP)); + e.parent = this.node; + this._textLabel = t; + } + this._textLabel.node._uiProps.uiTransformComp.setAnchorPoint(0, 1); + t.overflow = IP.Overflow.CLAMP; + if (this._inputMode === BVt.ANY) { + t.verticalAlign = xP.TOP; + t.enableWrapText = !0; + } else t.enableWrapText = !1; + t.string = this._updateLabelStringStyle(this._string); + } + _updatePlaceholderLabel() { + let t = this._placeholderLabel; + if (!t) { + let e = this.node.getChildByName("PLACEHOLDER_LABEL"); + if (!e) { + e = new _y("PLACEHOLDER_LABEL"); + e.layer = this.node.layer; + } + t = e.getComponent(IP); + t || (t = e.addComponent(IP)); + e.parent = this.node; + this._placeholderLabel = t; + } + this._placeholderLabel.node._uiProps.uiTransformComp.setAnchorPoint(0, 1); + this._inputMode === BVt.ANY ? t.enableWrapText = !0 : t.enableWrapText = !1; + t.string = this.placeholder; + } + _syncSize() { + const t = this.node._uiProps.uiTransformComp; + const e = t.contentSize; + if (this._background) { + const i = this._background.node._uiProps.uiTransformComp; + i.anchorPoint = t.anchorPoint; + i.setContentSize(e); + } + this._updateLabelPosition(e); + this._impl && this._impl.setSize(e.width, e.height); + } + _updateLabels() { + if (this._isLabelVisible) { + const t = this._string; + this._textLabel && (this._textLabel.node.active = "" !== t); + this._placeholderLabel && (this._placeholderLabel.node.active = "" === t); + } + } + _updateString(t) { + const e = this._textLabel; + if (!e) return; + let i = t; + i && (i = this._updateLabelStringStyle(i)); + e.string = i; + this._updateLabels(); + } + _updateLabelStringStyle(t, e = !1) { + const i = this._inputFlag; + if (e || i !== DVt.PASSWORD) i === DVt.INITIAL_CAPS_ALL_CHARACTERS ? t = t.toUpperCase() : i === DVt.INITIAL_CAPS_WORD ? t = t.replace(/(?:^|\s)\S/g, (t => t.toUpperCase())) : i === DVt.INITIAL_CAPS_SENTENCE && (t = function(t) { + return t.charAt(0).toUpperCase() + t.slice(1); + }(t)); else { + let e = ""; + const i = t.length; + for (let t = 0; t < i; ++t) e += "●"; + t = e; + } + return t; + } + _registerEvent() { + this.node.on(ny.TOUCH_START, this._onTouchBegan, this); + this.node.on(ny.TOUCH_END, this._onTouchEnded, this); + this.node.on(fFt.XRUI_UNCLICK, this._xrUnClick, this); + this.node.on(gFt.XR_KEYBOARD_INPUT, this._xrKeyBoardInput, this); + } + _unregisterEvent() { + this.node.off(ny.TOUCH_START, this._onTouchBegan, this); + this.node.off(ny.TOUCH_END, this._onTouchEnded, this); + this.node.off(fFt.XRUI_UNCLICK, this._xrUnClick, this); + this.node.off(gFt.XR_KEYBOARD_INPUT, this._xrKeyBoardInput, this); + } + _onBackgroundSpriteFrameChanged() { + this._background && (this.backgroundImage = this._background.spriteFrame); + } + _registerBackgroundEvent() { + const t = this._background && this._background.node; + null == t || t.on(cL.EventType.SPRITE_FRAME_CHANGED, this._onBackgroundSpriteFrameChanged, this); + } + _unregisterBackgroundEvent() { + const t = this._background && this._background.node; + null == t || t.off(cL.EventType.SPRITE_FRAME_CHANGED, this._onBackgroundSpriteFrameChanged, this); + } + _updateLabelPosition(t) { + const e = this.node._uiProps.uiTransformComp; + const i = -e.anchorX * e.width; + const s = -e.anchorY * e.height; + const n = this._placeholderLabel; + const r = this._textLabel; + if (r) { + r.node._uiProps.uiTransformComp.setContentSize(t.width - 2, t.height); + r.node.setPosition(i + 2, s + t.height, r.node.position.z); + this._inputMode === BVt.ANY && (r.verticalAlign = xP.TOP); + r.enableWrapText = this._inputMode === BVt.ANY; + } + if (n) { + n.node._uiProps.uiTransformComp.setContentSize(t.width - 2, t.height); + n.lineHeight = t.height; + n.node.setPosition(i + 2, s + t.height, n.node.position.z); + n.enableWrapText = this._inputMode === BVt.ANY; + } + } + _resizeChildNodes() { + const t = this.node._uiProps.uiTransformComp; + const e = this._textLabel && this._textLabel.node; + if (e) { + e.setPosition(-t.width / 2, t.height / 2, e.position.z); + e._uiProps.uiTransformComp.setContentSize(t.contentSize); + } + const i = this._placeholderLabel && this._placeholderLabel.node; + if (i) { + i.setPosition(-t.width / 2, t.height / 2, i.position.z); + i._uiProps.uiTransformComp.setContentSize(t.contentSize); + } + const s = this._background && this._background.node; + s && s._uiProps.uiTransformComp.setContentSize(t.contentSize); + this._syncSize(); + } + _xrUnClick() { + this.node.emit(Ukt.XR_EDITING_DID_BEGAN, this._maxLength, this.string); + } + _xrKeyBoardInput(t) { + this.string = t; + } + }, Vkt._EditBoxImpl = PVt, Vkt.KeyboardReturnType = MVt, Vkt.InputFlag = DVt, Vkt.InputMode = BVt, + Vkt.EventType = Ukt, kkt), Bl(Ekt.prototype, "string", [ kVt, UVt ], Object.getOwnPropertyDescriptor(Ekt.prototype, "string"), Ekt.prototype), + Bl(Ekt.prototype, "placeholder", [ GVt, zVt ], Object.getOwnPropertyDescriptor(Ekt.prototype, "placeholder"), Ekt.prototype), + Bl(Ekt.prototype, "textLabel", [ HVt, jVt, XVt ], Object.getOwnPropertyDescriptor(Ekt.prototype, "textLabel"), Ekt.prototype), + Bl(Ekt.prototype, "placeholderLabel", [ WVt, YVt, qVt ], Object.getOwnPropertyDescriptor(Ekt.prototype, "placeholderLabel"), Ekt.prototype), + Bl(Ekt.prototype, "backgroundImage", [ KVt, JVt, ZVt ], Object.getOwnPropertyDescriptor(Ekt.prototype, "backgroundImage"), Ekt.prototype), + Bl(Ekt.prototype, "inputFlag", [ QVt, $Vt, tkt ], Object.getOwnPropertyDescriptor(Ekt.prototype, "inputFlag"), Ekt.prototype), + Bl(Ekt.prototype, "inputMode", [ ekt, ikt, skt ], Object.getOwnPropertyDescriptor(Ekt.prototype, "inputMode"), Ekt.prototype), + Bl(Ekt.prototype, "returnType", [ nkt, rkt, okt ], Object.getOwnPropertyDescriptor(Ekt.prototype, "returnType"), Ekt.prototype), + Bl(Ekt.prototype, "maxLength", [ akt, lkt ], Object.getOwnPropertyDescriptor(Ekt.prototype, "maxLength"), Ekt.prototype), + Bl(Ekt.prototype, "tabIndex", [ hkt, ckt ], Object.getOwnPropertyDescriptor(Ekt.prototype, "tabIndex"), Ekt.prototype), + Ckt = Bl(Ekt.prototype, "editingDidBegan", [ ukt, Yl, _kt, dkt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), xkt = Bl(Ekt.prototype, "textChanged", [ pkt, Yl, mkt, fkt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), wkt = Bl(Ekt.prototype, "editingDidEnded", [ gkt, Yl, ykt, bkt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), Rkt = Bl(Ekt.prototype, "editingReturn", [ Skt, Yl, Akt, Tkt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), Ikt = Bl(Ekt.prototype, "_textLabel", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Mkt = Bl(Ekt.prototype, "_placeholderLabel", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Bkt = Bl(Ekt.prototype, "_returnType", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return MVt.DEFAULT; + } + }), Dkt = Bl(Ekt.prototype, "_string", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), Pkt = Bl(Ekt.prototype, "_tabIndex", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Okt = Bl(Ekt.prototype, "_backgroundImage", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Nkt = Bl(Ekt.prototype, "_inputFlag", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return DVt.DEFAULT; + } + }), Lkt = Bl(Ekt.prototype, "_inputMode", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return BVt.ANY; + } + }), Fkt = Bl(Ekt.prototype, "_maxLength", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 20; + } + }), Ekt)) || vkt) || vkt) || vkt) || vkt) || vkt) || vkt)); + 0; + m.internal.EditBox = Gkt; + var zkt, Hkt, jkt, Xkt, Wkt, Ykt, qkt, Kkt, Jkt, Zkt, Qkt, $kt, tUt, eUt, iUt, sUt, nUt, rUt, oUt, aUt, lUt, hUt, cUt, uUt, _Ut, dUt, pUt, mUt, fUt, gUt, yUt, bUt, SUt, AUt, TUt, vUt, EUt, CUt, xUt, wUt, RUt, IUt, MUt, BUt, DUt, PUt, OUt, NUt, LUt, FUt, VUt, kUt, UUt, GUt, zUt; + var HUt; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.HORIZONTAL = 1] = "HORIZONTAL"; + t[t.VERTICAL = 2] = "VERTICAL"; + t[t.GRID = 3] = "GRID"; + }(HUt || (HUt = {})); + he(HUt); + var jUt; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.CONTAINER = 1] = "CONTAINER"; + t[t.CHILDREN = 2] = "CHILDREN"; + }(jUt || (jUt = {})); + he(jUt); + var XUt; + !function(t) { + t[t.HORIZONTAL = 0] = "HORIZONTAL"; + t[t.VERTICAL = 1] = "VERTICAL"; + }(XUt || (XUt = {})); + he(XUt); + var WUt; + !function(t) { + t[t.BOTTOM_TO_TOP = 0] = "BOTTOM_TO_TOP"; + t[t.TOP_TO_BOTTOM = 1] = "TOP_TO_BOTTOM"; + }(WUt || (WUt = {})); + he(WUt); + var YUt; + !function(t) { + t[t.LEFT_TO_RIGHT = 0] = "LEFT_TO_RIGHT"; + t[t.RIGHT_TO_LEFT = 1] = "RIGHT_TO_LEFT"; + }(YUt || (YUt = {})); + he(YUt); + var qUt; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.FIXED_ROW = 1] = "FIXED_ROW"; + t[t.FIXED_COL = 2] = "FIXED_COL"; + }(qUt || (qUt = {})); + he(qUt); + const KUt = new Pi; + let JUt = function(e) { + return t({ + Layout: e, + LayoutComponent: e + }), e; + }((zkt = Ul("cc.Layout"), Hkt = sh(), jkt = zl(110), Xkt = $l(), Wkt = Gl(jB), Ykt = rh(), + qkt = lh(), Kkt = rh(), Jkt = lh(), Zkt = Th(HUt), Qkt = ph(), $kt = lh(), tUt = Th(jUt), + eUt = rh(), iUt = lh(), sUt = rh(), nUt = lh(), rUt = Th(XUt), oUt = lh(), aUt = lh(), + lUt = lh(), hUt = lh(), cUt = lh(), uUt = lh(), _Ut = lh(), dUt = Th(WUt), pUt = lh(), + mUt = Th(YUt), fUt = lh(), gUt = Th(qUt), yUt = rh(), bUt = lh(), SUt = rh(), AUt = lh(), + TUt = lh(), zkt(vUt = Hkt(vUt = jkt(vUt = Xkt(vUt = Wkt(vUt = Ql(vUt = (EUt = (zUt = GUt = class extends Qc { + constructor(...t) { + super(...t); + Ml(this, "_resizeMode", CUt, this); + Ml(this, "_layoutType", xUt, this); + Ml(this, "_cellSize", wUt, this); + Ml(this, "_startAxis", RUt, this); + Ml(this, "_paddingLeft", IUt, this); + Ml(this, "_paddingRight", MUt, this); + Ml(this, "_paddingTop", BUt, this); + Ml(this, "_paddingBottom", DUt, this); + Ml(this, "_spacingX", PUt, this); + Ml(this, "_spacingY", OUt, this); + Ml(this, "_verticalDirection", NUt, this); + Ml(this, "_horizontalDirection", LUt, this); + Ml(this, "_constraint", FUt, this); + Ml(this, "_constraintNum", VUt, this); + Ml(this, "_affectedByScale", kUt, this); + Ml(this, "_isAlign", UUt, this); + this._layoutSize = new rs(300, 200); + this._layoutDirty = !0; + this._childrenDirty = !1; + this._usefulLayoutObj = []; + this._init = !1; + } + get alignHorizontal() { + return this._isAlign; + } + set alignHorizontal(t) { + if (this._layoutType === HUt.HORIZONTAL) { + this._isAlign = t; + this._doLayoutDirty(); + } + } + get alignVertical() { + return this._isAlign; + } + set alignVertical(t) { + if (this._layoutType === HUt.VERTICAL) { + this._isAlign = t; + this._doLayoutDirty(); + } + } + get type() { + return this._layoutType; + } + set type(t) { + this._layoutType = t; + this._doLayoutDirty(); + } + get resizeMode() { + return this._resizeMode; + } + set resizeMode(t) { + if (this._layoutType !== HUt.NONE) { + this._resizeMode = t; + this._doLayoutDirty(); + } + } + get cellSize() { + return this._cellSize; + } + set cellSize(t) { + if (this._cellSize !== t) { + this._cellSize.set(t); + this._doLayoutDirty(); + } + } + get startAxis() { + return this._startAxis; + } + set startAxis(t) { + if (this._startAxis !== t) { + this._startAxis = t; + this._doLayoutDirty(); + } + } + get paddingLeft() { + return this._paddingLeft; + } + set paddingLeft(t) { + if (this._paddingLeft !== t) { + this._paddingLeft = t; + this._doLayoutDirty(); + } + } + get paddingRight() { + return this._paddingRight; + } + set paddingRight(t) { + if (this._paddingRight !== t) { + this._paddingRight = t; + this._doLayoutDirty(); + } + } + get paddingTop() { + return this._paddingTop; + } + set paddingTop(t) { + if (this._paddingTop !== t) { + this._paddingTop = t; + this._doLayoutDirty(); + } + } + get paddingBottom() { + return this._paddingBottom; + } + set paddingBottom(t) { + if (this._paddingBottom !== t) { + this._paddingBottom = t; + this._doLayoutDirty(); + } + } + get spacingX() { + return this._spacingX; + } + set spacingX(t) { + if (this._spacingX !== t) { + this._spacingX = t; + this._doLayoutDirty(); + } + } + get spacingY() { + return this._spacingY; + } + set spacingY(t) { + if (this._spacingY !== t) { + this._spacingY = t; + this._doLayoutDirty(); + } + } + get verticalDirection() { + return this._verticalDirection; + } + set verticalDirection(t) { + if (this._verticalDirection !== t) { + this._verticalDirection = t; + this._doLayoutDirty(); + } + } + get horizontalDirection() { + return this._horizontalDirection; + } + set horizontalDirection(t) { + if (this._horizontalDirection !== t) { + this._horizontalDirection = t; + this._doLayoutDirty(); + } + } + get padding() { + return this._paddingLeft; + } + set padding(t) { + if (this.paddingLeft !== t || this._paddingRight !== t || this._paddingTop !== t || this._paddingBottom !== t) { + this._paddingLeft = this._paddingRight = this._paddingTop = this._paddingBottom = t; + this._doLayoutDirty(); + } + } + get constraint() { + return this._constraint; + } + set constraint(t) { + if (this._layoutType !== HUt.NONE && this._constraint !== t) { + this._constraint = t; + this._doLayoutDirty(); + } + } + get constraintNum() { + return this._constraintNum; + } + set constraintNum(t) { + if (this._constraint !== qUt.NONE && this._constraintNum !== t) { + t <= 0 && C("Limit values to be greater than 0"); + this._constraintNum = t; + this._doLayoutDirty(); + } + } + get affectedByScale() { + return this._affectedByScale; + } + set affectedByScale(t) { + this._affectedByScale = t; + this._doLayoutDirty(); + } + updateLayout(t = !1) { + if ((this._layoutDirty || t) && this.node.children.length > 0) { + this._doLayout(); + this._layoutDirty = !1; + } + } + onEnable() { + this._addEventListeners(); + const t = this.node._uiProps.uiTransformComp; + t.contentSize.equals(rs.ZERO) && t.setContentSize(this._layoutSize); + this._childrenChanged(); + } + onDisable() { + this._usefulLayoutObj.length = 0; + this._removeEventListeners(); + } + _checkUsefulObj() { + this._usefulLayoutObj.length = 0; + const t = this.node.children; + for (let e = 0; e < t.length; ++e) { + const i = t[e]; + const s = i._uiProps.uiTransformComp; + i.activeInHierarchy && s && this._usefulLayoutObj.push(s); + } + } + _addEventListeners() { + IR.on(RR.EVENT_AFTER_UPDATE, this.updateLayout, this); + this.node.on(ny.SIZE_CHANGED, this._resized, this); + this.node.on(ny.ANCHOR_CHANGED, this._doLayoutDirty, this); + this.node.on(ny.CHILD_ADDED, this._childAdded, this); + this.node.on(ny.CHILD_REMOVED, this._childRemoved, this); + this.node.on(ny.SIBLING_ORDER_CHANGED, this._childrenChanged, this); + this.node.on("childrenSiblingOrderChanged", this.updateLayout, this); + this._addChildrenEventListeners(); + } + _removeEventListeners() { + IR.off(RR.EVENT_AFTER_UPDATE, this.updateLayout, this); + this.node.off(ny.SIZE_CHANGED, this._resized, this); + this.node.off(ny.ANCHOR_CHANGED, this._doLayoutDirty, this); + this.node.off(ny.CHILD_ADDED, this._childAdded, this); + this.node.off(ny.CHILD_REMOVED, this._childRemoved, this); + this.node.off(ny.SIBLING_ORDER_CHANGED, this._childrenChanged, this); + this.node.off("childrenSiblingOrderChanged", this.updateLayout, this); + this._removeChildrenEventListeners(); + } + _addChildrenEventListeners() { + const t = this.node.children; + for (let e = 0; e < t.length; ++e) { + const i = t[e]; + i.on(ny.SIZE_CHANGED, this._doLayoutDirty, this); + i.on(ny.TRANSFORM_CHANGED, this._transformDirty, this); + i.on(ny.ANCHOR_CHANGED, this._doLayoutDirty, this); + i.on(ny.ACTIVE_IN_HIERARCHY_CHANGED, this._childrenChanged, this); + } + } + _removeChildrenEventListeners() { + const t = this.node.children; + for (let e = 0; e < t.length; ++e) { + const i = t[e]; + i.off(ny.SIZE_CHANGED, this._doLayoutDirty, this); + i.off(ny.TRANSFORM_CHANGED, this._transformDirty, this); + i.off(ny.ANCHOR_CHANGED, this._doLayoutDirty, this); + i.off(ny.ACTIVE_IN_HIERARCHY_CHANGED, this._childrenChanged, this); + } + } + _childAdded(t) { + t.on(ny.SIZE_CHANGED, this._doLayoutDirty, this); + t.on(ny.TRANSFORM_CHANGED, this._transformDirty, this); + t.on(ny.ANCHOR_CHANGED, this._doLayoutDirty, this); + t.on(ny.ACTIVE_IN_HIERARCHY_CHANGED, this._childrenChanged, this); + this._childrenChanged(); + } + _childRemoved(t) { + t.off(ny.SIZE_CHANGED, this._doLayoutDirty, this); + t.off(ny.TRANSFORM_CHANGED, this._transformDirty, this); + t.off(ny.ANCHOR_CHANGED, this._doLayoutDirty, this); + t.off(ny.ACTIVE_IN_HIERARCHY_CHANGED, this._childrenChanged, this); + this._childrenChanged(); + } + _resized() { + this._layoutSize.set(this.node._uiProps.uiTransformComp.contentSize); + this._doLayoutDirty(); + } + _doLayoutHorizontally(t, e, i, s) { + const n = this.node._uiProps.uiTransformComp.anchorPoint; + const r = this._getFixedBreakingNum(); + let o = 1; + let a = this._paddingLeft; + if (this._horizontalDirection === YUt.RIGHT_TO_LEFT) { + o = -1; + a = this._paddingRight; + } + const l = (this._horizontalDirection - n.x) * t + o * a; + let h = l - o * this._spacingX; + let c = 0; + let u = 0; + let _ = 0; + let d = 0; + let p = !1; + const m = this._usefulLayoutObj.length; + let f = this._cellSize.width; + const g = this._getPaddingH(); + this._layoutType !== HUt.GRID && this._resizeMode === jUt.CHILDREN && (f = (t - g - (m - 1) * this._spacingX) / m); + const y = this._usefulLayoutObj; + for (let a = 0; a < y.length; ++a) { + const m = y[a]; + const b = m.node; + const S = b.scale; + const A = this._getUsedScaleValue(S.x); + const T = this._getUsedScaleValue(S.y); + if (this._resizeMode === jUt.CHILDREN) { + m.width = f / A; + this._layoutType === HUt.GRID && (m.height = this._cellSize.height / T); + } + const v = Math.abs(this._horizontalDirection - m.anchorX); + const E = m.width * A; + const C = m.height * T; + if (C > _) { + d = Math.max(_, d); + u = _ || C; + _ = C; + } + h += o * (v * E + this._spacingX); + const x = o * (1 - v) * E; + if (e) { + if (r > 0) { + p = a / r > 0 && a % r == 0; + p && (u = _ > C ? _ : u); + } else if (E > t - g) h > l + o * (v * E) && (p = !0); else { + const e = (1 - this._horizontalDirection - n.x) * t; + const i = h + x + o * (o > 0 ? this._paddingRight : this._paddingLeft); + p = Math.abs(i) > Math.abs(e); + } + if (p) { + h = l + o * (v * E); + C !== _ && (u = _); + c += u + this._spacingY; + u = _ = C; + } + } + const w = i(b, m, c); + s && b.setPosition(h, w); + h += x; + } + u = Math.max(u, _); + return Math.max(d, c + u) + this._getPaddingV(); + } + _doLayoutVertically(t, e, i, s) { + const n = this.node._uiProps.uiTransformComp.anchorPoint; + const r = this._getFixedBreakingNum(); + let o = 1; + let a = this._paddingBottom; + if (this._verticalDirection === WUt.TOP_TO_BOTTOM) { + o = -1; + a = this._paddingTop; + } + const l = (this._verticalDirection - n.y) * t + o * a; + let h = l - o * this._spacingY; + let c = 0; + let u = 0; + let _ = 0; + let d = 0; + let p = !1; + const m = this._usefulLayoutObj.length; + let f = this._cellSize.height; + const g = this._getPaddingV(); + this._layoutType !== HUt.GRID && this._resizeMode === jUt.CHILDREN && (f = (t - g - (m - 1) * this._spacingY) / m); + const y = this._usefulLayoutObj; + for (let a = 0; a < y.length; ++a) { + const m = y[a]; + const b = m.node; + const S = b.scale; + const A = this._getUsedScaleValue(S.x); + const T = this._getUsedScaleValue(S.y); + if (this._resizeMode === jUt.CHILDREN) { + m.height = f / T; + this._layoutType === HUt.GRID && (m.width = this._cellSize.width / A); + } + const v = Math.abs(this._verticalDirection - m.anchorY); + const E = m.width * A; + const C = m.height * T; + if (E > c) { + u = Math.max(c, u); + _ = c || E; + c = E; + } + h += o * (v * C + this._spacingY); + const x = o * (1 - v) * C; + if (e) { + if (r > 0) { + p = a / r > 0 && a % r == 0; + p && (_ = c > C ? c : _); + } else if (C > t - g) h > l + o * (v * C) && (p = !0); else { + const e = (1 - this._verticalDirection - n.y) * t; + const i = h + x + o * (o > 0 ? this._paddingTop : this._paddingBottom); + p = Math.abs(i) > Math.abs(e); + } + if (p) { + h = l + o * (v * C); + E !== c && (_ = c); + d += _ + this._spacingX; + _ = c = E; + } + } + const w = i(b, m, d); + if (s) { + b.getPosition(KUt); + b.setPosition(w, h, KUt.z); + } + h += x; + } + _ = Math.max(_, c); + return Math.max(u, d + _) + this._getPaddingH(); + } + _doLayoutGridAxisHorizontal(t, e) { + const i = e.width; + let s = 1; + let n = -t.y * e.height; + let r = this._paddingBottom; + if (this._verticalDirection === WUt.TOP_TO_BOTTOM) { + s = -1; + n = (1 - t.y) * e.height; + r = this._paddingTop; + } + const o = (t, e, i) => n + s * (i + (1 - e.anchorY) * e.height * this._getUsedScaleValue(t.scale.y) + r); + let a = 0; + if (this._resizeMode === jUt.CONTAINER) { + a = this._doLayoutHorizontally(i, !0, o, !1); + n = -t.y * a; + if (this._verticalDirection === WUt.TOP_TO_BOTTOM) { + s = -1; + n = (1 - t.y) * a; + } + } + this._doLayoutHorizontally(i, !0, o, !0); + this._resizeMode === jUt.CONTAINER && this.node._uiProps.uiTransformComp.setContentSize(i, a); + } + _doLayoutGridAxisVertical(t, e) { + const i = e.height; + let s = 1; + let n = -t.x * e.width; + let r = this._paddingLeft; + if (this._horizontalDirection === YUt.RIGHT_TO_LEFT) { + s = -1; + n = (1 - t.x) * e.width; + r = this._paddingRight; + } + const o = (t, e, i) => n + s * (i + (1 - e.anchorX) * e.width * this._getUsedScaleValue(t.scale.x) + r); + let a = 0; + if (this._resizeMode === jUt.CONTAINER) { + a = this._doLayoutVertically(i, !0, o, !1); + n = -t.x * a; + if (this._horizontalDirection === YUt.RIGHT_TO_LEFT) { + s = -1; + n = (1 - t.x) * a; + } + } + this._doLayoutVertically(i, !0, o, !0); + this._resizeMode === jUt.CONTAINER && this.node._uiProps.uiTransformComp.setContentSize(a, i); + } + _doLayoutGrid() { + const t = this.node._uiProps.uiTransformComp; + const e = t.anchorPoint; + const i = t.contentSize; + this.startAxis === XUt.HORIZONTAL ? this._doLayoutGridAxisHorizontal(e, i) : this.startAxis === XUt.VERTICAL && this._doLayoutGridAxisVertical(e, i); + } + _getHorizontalBaseWidth(t = !0) { + const e = this._usefulLayoutObj; + let i = 0; + const s = e.length; + if (this._resizeMode === jUt.CONTAINER) { + for (let t = 0; t < e.length; ++t) { + const s = e[t]; + const n = s.node.scale; + i += s.width * this._getUsedScaleValue(n.x); + } + i += (s - 1) * this._spacingX + this._getPaddingH(); + } else i = this.node._uiProps.uiTransformComp.width; + return i; + } + _getVerticalBaseHeight() { + const t = this._usefulLayoutObj; + let e = 0; + const i = t.length; + if (this._resizeMode === jUt.CONTAINER) { + for (let i = 0; i < t.length; ++i) { + const s = t[i]; + const n = s.node.scale; + e += s.height * this._getUsedScaleValue(n.y); + } + e += (i - 1) * this._spacingY + this._getPaddingV(); + } else e = this.node._uiProps.uiTransformComp.height; + return e; + } + _doLayout() { + if (!this._init || this._childrenDirty) { + this._checkUsefulObj(); + this._init = !0; + this._childrenDirty = !1; + } + if (this._layoutType === HUt.HORIZONTAL) { + const t = this._getHorizontalBaseWidth(); + const e = t => (this._isAlign ? Pi.ZERO : t.position).y; + this._doLayoutHorizontally(t, !1, e, !0); + this.node._uiProps.uiTransformComp.width = t; + } else if (this._layoutType === HUt.VERTICAL) { + const t = this._getVerticalBaseHeight(); + const e = t => (this._isAlign ? Pi.ZERO : t.position).x; + this._doLayoutVertically(t, !1, e, !0); + this.node._uiProps.uiTransformComp.height = t; + } else this._layoutType === HUt.GRID && this._doLayoutGrid(); + } + _getUsedScaleValue(t) { + return this._affectedByScale ? Math.abs(t) : 1; + } + _transformDirty(t) { + t & ay.SCALE && t & ay.POSITION && this._affectedByScale && this._doLayoutDirty(); + } + _doLayoutDirty() { + this._layoutDirty = !0; + } + _childrenChanged() { + this._childrenDirty = !0; + this._doLayoutDirty(); + } + _getPaddingH() { + return this._paddingLeft + this._paddingRight; + } + _getPaddingV() { + return this._paddingTop + this._paddingBottom; + } + _getFixedBreakingNum() { + if (this._layoutType !== HUt.GRID || this._constraint === qUt.NONE || this._constraintNum <= 0) return 0; + let t = this._constraint === qUt.FIXED_ROW ? Math.ceil(this._usefulLayoutObj.length / this._constraintNum) : this._constraintNum; + this._startAxis === XUt.VERTICAL && (t = this._constraint === qUt.FIXED_COL ? Math.ceil(this._usefulLayoutObj.length / this._constraintNum) : this._constraintNum); + return t; + } + }, GUt.Type = HUt, GUt.VerticalDirection = WUt, GUt.HorizontalDirection = YUt, GUt.ResizeMode = jUt, + GUt.AxisDirection = XUt, GUt.Constraint = qUt, zUt), Bl(EUt.prototype, "alignHorizontal", [ Ykt, qkt ], Object.getOwnPropertyDescriptor(EUt.prototype, "alignHorizontal"), EUt.prototype), + Bl(EUt.prototype, "alignVertical", [ Kkt, Jkt ], Object.getOwnPropertyDescriptor(EUt.prototype, "alignVertical"), EUt.prototype), + Bl(EUt.prototype, "type", [ Zkt, Qkt, $kt ], Object.getOwnPropertyDescriptor(EUt.prototype, "type"), EUt.prototype), + Bl(EUt.prototype, "resizeMode", [ tUt, eUt, iUt ], Object.getOwnPropertyDescriptor(EUt.prototype, "resizeMode"), EUt.prototype), + Bl(EUt.prototype, "cellSize", [ sUt, nUt ], Object.getOwnPropertyDescriptor(EUt.prototype, "cellSize"), EUt.prototype), + Bl(EUt.prototype, "startAxis", [ rUt, oUt ], Object.getOwnPropertyDescriptor(EUt.prototype, "startAxis"), EUt.prototype), + Bl(EUt.prototype, "paddingLeft", [ aUt ], Object.getOwnPropertyDescriptor(EUt.prototype, "paddingLeft"), EUt.prototype), + Bl(EUt.prototype, "paddingRight", [ lUt ], Object.getOwnPropertyDescriptor(EUt.prototype, "paddingRight"), EUt.prototype), + Bl(EUt.prototype, "paddingTop", [ hUt ], Object.getOwnPropertyDescriptor(EUt.prototype, "paddingTop"), EUt.prototype), + Bl(EUt.prototype, "paddingBottom", [ cUt ], Object.getOwnPropertyDescriptor(EUt.prototype, "paddingBottom"), EUt.prototype), + Bl(EUt.prototype, "spacingX", [ uUt ], Object.getOwnPropertyDescriptor(EUt.prototype, "spacingX"), EUt.prototype), + Bl(EUt.prototype, "spacingY", [ _Ut ], Object.getOwnPropertyDescriptor(EUt.prototype, "spacingY"), EUt.prototype), + Bl(EUt.prototype, "verticalDirection", [ dUt, pUt ], Object.getOwnPropertyDescriptor(EUt.prototype, "verticalDirection"), EUt.prototype), + Bl(EUt.prototype, "horizontalDirection", [ mUt, fUt ], Object.getOwnPropertyDescriptor(EUt.prototype, "horizontalDirection"), EUt.prototype), + Bl(EUt.prototype, "constraint", [ gUt, yUt, bUt ], Object.getOwnPropertyDescriptor(EUt.prototype, "constraint"), EUt.prototype), + Bl(EUt.prototype, "constraintNum", [ SUt, AUt ], Object.getOwnPropertyDescriptor(EUt.prototype, "constraintNum"), EUt.prototype), + Bl(EUt.prototype, "affectedByScale", [ TUt ], Object.getOwnPropertyDescriptor(EUt.prototype, "affectedByScale"), EUt.prototype), + CUt = Bl(EUt.prototype, "_resizeMode", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return jUt.NONE; + } + }), xUt = Bl(EUt.prototype, "_layoutType", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return HUt.NONE; + } + }), wUt = Bl(EUt.prototype, "_cellSize", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new rs(40, 40); + } + }), RUt = Bl(EUt.prototype, "_startAxis", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return XUt.HORIZONTAL; + } + }), IUt = Bl(EUt.prototype, "_paddingLeft", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), MUt = Bl(EUt.prototype, "_paddingRight", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), BUt = Bl(EUt.prototype, "_paddingTop", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), DUt = Bl(EUt.prototype, "_paddingBottom", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), PUt = Bl(EUt.prototype, "_spacingX", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), OUt = Bl(EUt.prototype, "_spacingY", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), NUt = Bl(EUt.prototype, "_verticalDirection", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return WUt.TOP_TO_BOTTOM; + } + }), LUt = Bl(EUt.prototype, "_horizontalDirection", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return YUt.LEFT_TO_RIGHT; + } + }), FUt = Bl(EUt.prototype, "_constraint", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return qUt.NONE; + } + }), VUt = Bl(EUt.prototype, "_constraintNum", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 2; + } + }), kUt = Bl(EUt.prototype, "_affectedByScale", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), UUt = Bl(EUt.prototype, "_isAlign", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), EUt)) || vUt) || vUt) || vUt) || vUt) || vUt) || vUt)); + m.Layout = JUt; + var ZUt, QUt, $Ut, tGt, eGt, iGt, sGt, nGt, rGt, oGt, aGt, lGt, hGt, cGt, uGt, _Gt, dGt, pGt, mGt, fGt, gGt, yGt; + var bGt; + !function(t) { + t[t.HORIZONTAL = 0] = "HORIZONTAL"; + t[t.VERTICAL = 1] = "VERTICAL"; + t[t.FILLED = 2] = "FILLED"; + }(bGt || (bGt = {})); + oe(bGt); + let SGt = function(e) { + return t({ + ProgressBar: e, + ProgressBarComponent: e + }), e; + }((ZUt = Ul("cc.ProgressBar"), QUt = sh(), $Ut = zl(110), tGt = $l(), eGt = Gl(jB), + iGt = Th(cL), sGt = lh(), nGt = Th(bGt), rGt = lh(), oGt = lh(), aGt = hh(), lGt = lh(), + hGt = lh(), ZUt(cGt = QUt(cGt = $Ut(cGt = tGt(cGt = eGt(cGt = (uGt = (yGt = gGt = class extends Qc { + constructor(...t) { + super(...t); + Ml(this, "_barSprite", _Gt, this); + Ml(this, "_mode", dGt, this); + Ml(this, "_totalLength", pGt, this); + Ml(this, "_progress", mGt, this); + Ml(this, "_reverse", fGt, this); + } + get barSprite() { + return this._barSprite; + } + set barSprite(t) { + if (this._barSprite !== t) { + this._barSprite = t; + this._initBarSprite(); + } + } + get mode() { + return this._mode; + } + set mode(t) { + if (this._mode !== t) { + this._mode = t; + if (this._barSprite) { + const t = this._barSprite.node; + if (!t) return; + const e = t._uiProps.uiTransformComp.contentSize; + this._mode === bGt.HORIZONTAL ? this.totalLength = e.width : this._mode === bGt.VERTICAL ? this.totalLength = e.height : this._mode === bGt.FILLED && (this.totalLength = this._barSprite.fillRange); + } + } + } + get totalLength() { + return this._totalLength; + } + set totalLength(t) { + this._mode === bGt.FILLED && (t = di(t)); + if (this._totalLength !== t) { + this._totalLength = t; + this._updateBarStatus(); + } + } + get progress() { + return this._progress; + } + set progress(t) { + if (this._progress !== t) { + this._progress = t; + this._updateBarStatus(); + } + } + get reverse() { + return this._reverse; + } + set reverse(t) { + if (this._reverse !== t) { + this._reverse = t; + this._barSprite && (this._barSprite.fillStart = 1 - this._barSprite.fillStart); + this._updateBarStatus(); + } + } + _initBarSprite() { + if (this._barSprite) { + const t = this._barSprite.node; + if (!t) return; + const e = this.node._uiProps.uiTransformComp; + const i = e.contentSize; + const s = e.anchorPoint; + const n = t._uiProps.uiTransformComp.contentSize; + this._barSprite.fillType === cL.FillType.RADIAL && (this._mode = bGt.FILLED); + this._mode === bGt.HORIZONTAL ? this.totalLength = n.width : this._mode === bGt.VERTICAL ? this.totalLength = n.height : this.totalLength = this._barSprite.fillRange; + if (t.parent === this.node) { + const e = -i.width * s.x; + t.setPosition(e, 0, 0); + } + } + } + _updateBarStatus() { + if (this._barSprite) { + const t = this._barSprite.node; + if (!t) return; + const e = t._uiProps.uiTransformComp; + const i = e.anchorPoint; + const s = e.contentSize; + const n = t.getPosition(); + let r = new Qi(0, .5); + const o = di(this._progress); + let a = this._totalLength * o; + let l = s; + let h = 0; + let c = 0; + switch (this._mode) { + case bGt.HORIZONTAL: + this._reverse && (r = new Qi(1, .5)); + l = new rs(a, s.height); + h = this._totalLength; + c = s.height; + break; + + case bGt.VERTICAL: + r = this._reverse ? new Qi(.5, 1) : new Qi(.5, 0); + l = new rs(s.width, a); + h = s.width; + c = this._totalLength; + } + if (this._mode === bGt.FILLED) if (this._barSprite.type !== cL.Type.FILLED) C("ProgressBar FILLED mode only works when barSprite's Type is FILLED!"); else { + this._reverse && (a *= -1); + this._barSprite.fillRange = a; + } else if (this._barSprite.type !== cL.Type.FILLED) { + const s = r.x - i.x; + const o = r.y - i.y; + const a = new Pi(h * s, c * o, 0); + t.setPosition(n.x + a.x, n.y + a.y, n.z); + e.setAnchorPoint(r); + e.setContentSize(l); + } else C("ProgressBar non-FILLED mode only works when barSprite's Type is non-FILLED!"); + } + } + }, gGt.Mode = bGt, yGt), Bl(uGt.prototype, "barSprite", [ iGt, sGt ], Object.getOwnPropertyDescriptor(uGt.prototype, "barSprite"), uGt.prototype), + Bl(uGt.prototype, "mode", [ nGt, rGt ], Object.getOwnPropertyDescriptor(uGt.prototype, "mode"), uGt.prototype), + Bl(uGt.prototype, "totalLength", [ oGt ], Object.getOwnPropertyDescriptor(uGt.prototype, "totalLength"), uGt.prototype), + Bl(uGt.prototype, "progress", [ aGt, dh, lGt ], Object.getOwnPropertyDescriptor(uGt.prototype, "progress"), uGt.prototype), + Bl(uGt.prototype, "reverse", [ hGt ], Object.getOwnPropertyDescriptor(uGt.prototype, "reverse"), uGt.prototype), + _Gt = Bl(uGt.prototype, "_barSprite", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), dGt = Bl(uGt.prototype, "_mode", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return bGt.HORIZONTAL; + } + }), pGt = Bl(uGt.prototype, "_totalLength", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), mGt = Bl(uGt.prototype, "_progress", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .1; + } + }), fGt = Bl(uGt.prototype, "_reverse", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), uGt)) || cGt) || cGt) || cGt) || cGt) || cGt)); + m.ProgressBar = SGt; + var AGt, TGt, vGt, EGt, CGt, xGt, wGt, RGt, IGt, MGt, BGt, DGt, PGt, OGt, NGt, LGt, FGt, VGt, kGt, UGt, GGt, zGt, HGt, jGt; + const XGt = new Pi; + const WGt = new Pi; + const YGt = new Pi; + const qGt = new Qi; + const KGt = new Bi; + const JGt = new Qi; + var ZGt; + !function(t) { + t[t.HORIZONTAL = 0] = "HORIZONTAL"; + t[t.VERTICAL = 1] = "VERTICAL"; + }(ZGt || (ZGt = {})); + he(ZGt); + let QGt = function(e) { + return t({ + ScrollBar: e, + ScrollBarComponent: e + }), e; + }((AGt = Ul("cc.ScrollBar"), TGt = sh(), vGt = zl(110), EGt = $l(), CGt = Gl(jB), + xGt = Th(cL), wGt = ph(), RGt = lh(), IGt = Th(ZGt), MGt = ph(), BGt = lh(), DGt = ph(), + PGt = lh(), OGt = ph(), NGt = lh(), AGt(LGt = TGt(LGt = vGt(LGt = EGt(LGt = CGt(LGt = (FGt = (jGt = HGt = class extends Qc { + constructor(...t) { + super(...t); + Ml(this, "_scrollView", VGt, this); + Ml(this, "_handle", kGt, this); + Ml(this, "_direction", UGt, this); + Ml(this, "_enableAutoHide", GGt, this); + Ml(this, "_autoHideTime", zGt, this); + this._touching = !1; + this._opacity = 255; + this._autoHideRemainingTime = 0; + } + get handle() { + return this._handle; + } + set handle(t) { + if (this._handle !== t) { + this._handle = t; + this.onScroll(Qi.ZERO); + } + } + get direction() { + return this._direction; + } + set direction(t) { + if (this._direction !== t) { + this._direction = t; + this.onScroll(Qi.ZERO); + } + } + get enableAutoHide() { + return this._enableAutoHide; + } + set enableAutoHide(t) { + if (this._enableAutoHide !== t) { + this._enableAutoHide = t; + this._enableAutoHide && this._setOpacity(0); + } + } + get autoHideTime() { + return this._autoHideTime; + } + set autoHideTime(t) { + this._autoHideTime !== t && (this._autoHideTime = t); + } + hide() { + this._autoHideRemainingTime = 0; + this._setOpacity(0); + } + show() { + this._autoHideRemainingTime = this._autoHideTime; + this._setOpacity(this._opacity); + } + onScroll(t) { + if (!this._scrollView) return; + const e = this._scrollView.content; + if (!e) return; + const i = e._uiProps.uiTransformComp.contentSize; + const s = this._scrollView.node._uiProps.uiTransformComp.contentSize; + const n = this.node._uiProps.uiTransformComp.contentSize; + if (this._conditionalDisableScrollBar(i, s)) return; + if (this._enableAutoHide) { + this._autoHideRemainingTime = this._autoHideTime; + this._setOpacity(this._opacity); + } + let r = 0; + let o = 0; + let a = 0; + let l = 0; + let h = 0; + const c = JGt; + c.set(0, 0); + if (this._direction === ZGt.HORIZONTAL) { + r = i.width; + o = s.width; + h = n.width; + a = t.x; + this._convertToScrollViewSpace(c, e); + l = -c.x; + } else if (this._direction === ZGt.VERTICAL) { + r = i.height; + o = s.height; + h = n.height; + a = t.y; + this._convertToScrollViewSpace(c, e); + l = -c.y; + } + const u = this._calculateLength(r, o, h, a); + const _ = JGt; + this._calculatePosition(_, r, o, h, l, a, u); + this._updateLength(u); + this._updateHandlerPosition(_); + } + setScrollView(t) { + this._scrollView = t; + } + onTouchBegan() { + this._enableAutoHide && (this._touching = !0); + } + onTouchEnded() { + if (this._enableAutoHide) { + this._touching = !1; + if (!(this._autoHideTime <= 0)) { + if (this._scrollView) { + const t = this._scrollView.content; + if (t) { + const e = t._uiProps.uiTransformComp.contentSize; + const i = this._scrollView.node._uiProps.uiTransformComp.contentSize; + if (this._conditionalDisableScrollBar(e, i)) return; + } + } + this._autoHideRemainingTime = this._autoHideTime; + } + } + } + onEnable() { + const t = this.node.getComponent(cL); + t && (this._opacity = t.color.a); + } + start() { + this._enableAutoHide && this._setOpacity(0); + } + update(t) { + this._processAutoHide(t); + } + _convertToScrollViewSpace(t, e) { + const i = this._scrollView && this._scrollView.node._uiProps.uiTransformComp; + const s = e._uiProps.uiTransformComp; + if (i && s) { + XGt.set(-s.anchorX * s.width, -s.anchorY * s.height, 0); + s.convertToWorldSpaceAR(XGt, WGt); + const e = i.convertToNodeSpaceAR(WGt); + e.x += i.anchorX * i.width; + e.y += i.anchorY * i.height; + t.set(e.x, e.y); + } else t.set(Qi.ZERO); + } + _setOpacity(t) { + if (this._handle) { + let e = this.node.getComponent(cL); + if (e) { + KGt.set(e.color); + KGt.a = t; + e.color = KGt; + } + e = this._handle.getComponent(cL); + if (e) { + KGt.set(e.color); + KGt.a = t; + e.color = KGt; + } + } + } + _updateHandlerPosition(t) { + if (this._handle) { + const e = YGt; + this._fixupHandlerPosition(e); + this._handle.node.setPosition(t.x + e.x, t.y + e.y, e.z); + } + } + _fixupHandlerPosition(t) { + const e = this.node._uiProps.uiTransformComp; + const i = e.contentSize; + const s = e.anchorPoint; + const n = this.handle.node._uiProps.uiTransformComp.contentSize; + const r = this.handle.node.parent; + Pi.set(XGt, -i.width * s.x, -i.height * s.y, 0); + const o = this.node._uiProps.uiTransformComp.convertToWorldSpaceAR(XGt, WGt); + const a = t; + a.set(0, 0, 0); + r._uiProps.uiTransformComp.convertToNodeSpaceAR(o, a); + this.direction === ZGt.HORIZONTAL ? a.set(a.x, a.y + (i.height - n.height) / 2, a.z) : this.direction === ZGt.VERTICAL && a.set(a.x + (i.width - n.width) / 2, a.y, a.z); + this.handle.node.setPosition(a); + } + _conditionalDisableScrollBar(t, e) { + return t.width <= e.width && this._direction === ZGt.HORIZONTAL || t.height <= e.height && this._direction === ZGt.VERTICAL; + } + _calculateLength(t, e, i, s) { + let n = t; + s && (n += 20 * (s > 0 ? s : -s)); + return i * (e / n); + } + _calculatePosition(t, e, i, s, n, r, o) { + let a = e - i; + r && (a += Math.abs(r)); + let l = 0; + if (a) { + l = n / a; + l = di(l); + } + const h = (s - o) * l; + this._direction === ZGt.VERTICAL ? t.set(0, h) : t.set(h, 0); + } + _updateLength(t) { + if (this._handle) { + const e = this._handle.node._uiProps.uiTransformComp; + const i = e.contentSize; + const s = e.anchorPoint; + s.x === qGt.x && s.y === qGt.y || e.setAnchorPoint(qGt); + this._direction === ZGt.HORIZONTAL ? e.setContentSize(t, i.height) : e.setContentSize(i.width, t); + } + } + _processAutoHide(t) { + if (this._enableAutoHide && !(this._autoHideRemainingTime <= 0) && !this._touching) { + this._autoHideRemainingTime -= t; + if (this._autoHideRemainingTime <= this._autoHideTime) { + this._autoHideRemainingTime = Math.max(0, this._autoHideRemainingTime); + const t = this._opacity * (this._autoHideRemainingTime / this._autoHideTime); + this._setOpacity(t); + } + } + } + }, HGt.Direction = ZGt, jGt), Bl(FGt.prototype, "handle", [ xGt, wGt, RGt ], Object.getOwnPropertyDescriptor(FGt.prototype, "handle"), FGt.prototype), + Bl(FGt.prototype, "direction", [ IGt, MGt, BGt ], Object.getOwnPropertyDescriptor(FGt.prototype, "direction"), FGt.prototype), + Bl(FGt.prototype, "enableAutoHide", [ DGt, PGt ], Object.getOwnPropertyDescriptor(FGt.prototype, "enableAutoHide"), FGt.prototype), + Bl(FGt.prototype, "autoHideTime", [ OGt, NGt ], Object.getOwnPropertyDescriptor(FGt.prototype, "autoHideTime"), FGt.prototype), + VGt = Bl(FGt.prototype, "_scrollView", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), kGt = Bl(FGt.prototype, "_handle", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), UGt = Bl(FGt.prototype, "_direction", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ZGt.HORIZONTAL; + } + }), GGt = Bl(FGt.prototype, "_enableAutoHide", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), zGt = Bl(FGt.prototype, "_autoHideTime", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), FGt)) || LGt) || LGt) || LGt) || LGt) || LGt)); + m.ScrollBar = QGt; + var $Gt; + let tzt = t("ViewGroup", Ul("cc.ViewGroup")($Gt = zl(110)($Gt = class extends Qc {}) || $Gt) || $Gt); + m.ViewGroup = tzt; + var ezt, izt, szt, nzt, rzt, ozt, azt, lzt, hzt, czt, uzt, _zt, dzt, pzt, mzt, fzt, gzt, yzt, bzt, Szt, Azt, Tzt, vzt, Ezt, Czt, xzt, wzt, Rzt, Izt, Mzt, Bzt, Dzt, Pzt, Ozt, Nzt, Lzt, Fzt, Vzt, kzt, Uzt, Gzt, zzt, Hzt, jzt, Xzt, Wzt, Yzt, qzt; + const Kzt = 1e-4; + const Jzt = new Pi; + const Zzt = new Pi; + const Qzt = new Qi; + const $zt = new Qi; + const tHt = () => (new Date).getMilliseconds(); + const eHt = { + "scroll-to-top": 0, + "scroll-to-bottom": 1, + "scroll-to-left": 2, + "scroll-to-right": 3, + scrolling: 4, + "bounce-bottom": 6, + "bounce-left": 7, + "bounce-right": 8, + "bounce-top": 5, + "scroll-ended": 9, + "touch-up": 10, + "scroll-ended-with-threshold": 11, + "scroll-began": 12 + }; + let iHt; + !function(t) { + t.SCROLL_TO_TOP = "scroll-to-top"; + t.SCROLL_TO_BOTTOM = "scroll-to-bottom"; + t.SCROLL_TO_LEFT = "scroll-to-left"; + t.SCROLL_TO_RIGHT = "scroll-to-right"; + t.SCROLL_BEGAN = "scroll-began"; + t.SCROLL_ENDED = "scroll-ended"; + t.BOUNCE_TOP = "bounce-top"; + t.BOUNCE_BOTTOM = "bounce-bottom"; + t.BOUNCE_LEFT = "bounce-left"; + t.BOUNCE_RIGHT = "bounce-right"; + t.SCROLLING = "scrolling"; + t.SCROLL_ENG_WITH_THRESHOLD = "scroll-ended-with-threshold"; + t.TOUCH_UP = "touch-up"; + }(iHt || (iHt = {})); + var sHt; + !function(t) { + t[t.NONE = 0] = "NONE"; + t[t.LEFT = 1] = "LEFT"; + t[t.RIGHT = 2] = "RIGHT"; + }(sHt || (sHt = {})); + let nHt = function(e) { + return t({ + ScrollView: e, + ScrollViewComponent: e + }), e; + }((ezt = Ul("cc.ScrollView"), izt = sh(), szt = zl(110), nzt = $l(), rzt = Gl(jB), + ozt = hh(), azt = ph(), lzt = lh(), hzt = hh(), czt = ph(), uzt = lh(), _zt = ph(), + dzt = lh(), pzt = ph(), mzt = lh(), fzt = Th(_y), gzt = ph(), yzt = lh(), bzt = ph(), + Szt = lh(), Azt = Th(QGt), Tzt = ph(), vzt = lh(), Ezt = ph(), Czt = lh(), xzt = Th(QGt), + wzt = ph(), Rzt = lh(), Izt = ph(), Mzt = lh(), Bzt = Th([ Vc ]), Dzt = ph(), Pzt = lh(), + ezt(Ozt = izt(Ozt = szt(Ozt = nzt(Ozt = rzt(Ozt = (Nzt = (qzt = Yzt = class extends tzt { + constructor(...t) { + super(...t); + Ml(this, "bounceDuration", Lzt, this); + Ml(this, "brake", Fzt, this); + Ml(this, "elastic", Vzt, this); + Ml(this, "inertia", kzt, this); + Ml(this, "horizontal", Uzt, this); + Ml(this, "vertical", Gzt, this); + Ml(this, "cancelInnerEvents", zzt, this); + Ml(this, "scrollEvents", Hzt, this); + this._autoScrolling = !1; + this._scrolling = !1; + Ml(this, "_content", jzt, this); + Ml(this, "_horizontalScrollBar", Xzt, this); + Ml(this, "_verticalScrollBar", Wzt, this); + this._topBoundary = 0; + this._bottomBoundary = 0; + this._leftBoundary = 0; + this._rightBoundary = 0; + this._touchMoveDisplacements = []; + this._touchMoveTimeDeltas = []; + this._touchMovePreviousTimestamp = 0; + this._touchMoved = !1; + this._autoScrollAttenuate = !1; + this._autoScrollStartPosition = new Pi; + this._autoScrollTargetDelta = new Pi; + this._autoScrollTotalTime = 0; + this._autoScrollAccumulatedTime = 0; + this._autoScrollCurrentlyOutOfBoundary = !1; + this._autoScrollBraking = !1; + this._autoScrollBrakingStartPosition = new Pi; + this._outOfBoundaryAmount = new Pi; + this._outOfBoundaryAmountDirty = !0; + this._stopMouseWheel = !1; + this._mouseWheelEventElapsedTime = 0; + this._isScrollEndedWithThresholdEventFired = !1; + this._scrollEventEmitMask = 0; + this._isBouncing = !1; + this._contentPos = new Pi; + this._deltaPos = new Pi; + this._hoverIn = sHt.NONE; + this._scrollState = new Qi(0, 0); + } + get content() { + return this._content; + } + set content(t) { + if (this._content === t) return; + const e = t && t.parent && t.parent._uiProps.uiTransformComp; + if (!t || t && e) { + this._content = t; + this._calculateBoundary(); + } else P(4302); + } + get horizontalScrollBar() { + return this._horizontalScrollBar; + } + set horizontalScrollBar(t) { + if (this._horizontalScrollBar !== t) { + this._horizontalScrollBar = t; + if (this._horizontalScrollBar) { + this._horizontalScrollBar.setScrollView(this); + this._updateScrollBar(Qi.ZERO); + } + } + } + get verticalScrollBar() { + return this._verticalScrollBar; + } + set verticalScrollBar(t) { + if (this._verticalScrollBar !== t) { + this._verticalScrollBar = t; + if (this._verticalScrollBar) { + this._verticalScrollBar.setScrollView(this); + this._updateScrollBar(Qi.ZERO); + } + } + } + get view() { + const t = this._content && this._content.parent; + return t ? t._uiProps.uiTransformComp : null; + } + scrollToBottom(t, e = !0) { + const i = this._calculateMovePercentDelta({ + anchor: new Qi(0, 0), + applyToHorizontal: !1, + applyToVertical: !0 + }); + t ? this._startAutoScroll(i, t, !1 !== e) : this._moveContent(i, !0); + } + scrollToTop(t, e = !0) { + const i = this._calculateMovePercentDelta({ + anchor: new Qi(0, 1), + applyToHorizontal: !1, + applyToVertical: !0 + }); + t ? this._startAutoScroll(i, t, !1 !== e) : this._moveContent(i); + } + scrollToLeft(t, e = !0) { + const i = this._calculateMovePercentDelta({ + anchor: new Qi(0, 0), + applyToHorizontal: !0, + applyToVertical: !1 + }); + t ? this._startAutoScroll(i, t, !1 !== e) : this._moveContent(i); + } + scrollToRight(t, e = !0) { + const i = this._calculateMovePercentDelta({ + anchor: new Qi(1, 0), + applyToHorizontal: !0, + applyToVertical: !1 + }); + t ? this._startAutoScroll(i, t, !1 !== e) : this._moveContent(i); + } + scrollToTopLeft(t, e = !0) { + const i = this._calculateMovePercentDelta({ + anchor: new Qi(0, 1), + applyToHorizontal: !0, + applyToVertical: !0 + }); + t ? this._startAutoScroll(i, t, !1 !== e) : this._moveContent(i); + } + scrollToTopRight(t, e = !0) { + const i = this._calculateMovePercentDelta({ + anchor: new Qi(1, 1), + applyToHorizontal: !0, + applyToVertical: !0 + }); + t ? this._startAutoScroll(i, t, !1 !== e) : this._moveContent(i); + } + scrollToBottomLeft(t, e = !0) { + const i = this._calculateMovePercentDelta({ + anchor: new Qi(0, 0), + applyToHorizontal: !0, + applyToVertical: !0 + }); + t ? this._startAutoScroll(i, t, !1 !== e) : this._moveContent(i); + } + scrollToBottomRight(t, e = !0) { + const i = this._calculateMovePercentDelta({ + anchor: new Qi(1, 0), + applyToHorizontal: !0, + applyToVertical: !0 + }); + t ? this._startAutoScroll(i, t, !1 !== e) : this._moveContent(i); + } + scrollToOffset(t, e, i = !0) { + const s = this.getMaxScrollOffset(); + const n = new Qi(0, 0); + 0 === s.x ? n.x = 0 : n.x = t.x / s.x; + 0 === s.y ? n.y = 1 : n.y = (s.y - t.y) / s.y; + this.scrollTo(n, e, i); + } + getScrollOffset() { + const t = this._getContentTopBoundary() - this._topBoundary; + const e = this._getContentLeftBoundary() - this._leftBoundary; + return new Qi(e, t); + } + getMaxScrollOffset() { + if (!this._content || !this.view) return Qi.ZERO; + const t = this._content._uiProps.uiTransformComp.contentSize; + let e = t.width - this.view.width; + let i = t.height - this.view.height; + e = e >= 0 ? e : 0; + i = i >= 0 ? i : 0; + return new Qi(e, i); + } + scrollToPercentHorizontal(t, e, i) { + const s = this._calculateMovePercentDelta({ + anchor: new Qi(t, 0), + applyToHorizontal: !0, + applyToVertical: !1 + }); + e ? this._startAutoScroll(s, e, !1 !== i) : this._moveContent(s); + } + scrollTo(t, e, i) { + const s = this._calculateMovePercentDelta({ + anchor: new Qi(t), + applyToHorizontal: !0, + applyToVertical: !0 + }); + e ? this._startAutoScroll(s, e, i) : this._moveContent(s); + } + scrollToPercentVertical(t, e, i) { + const s = this._calculateMovePercentDelta({ + anchor: new Qi(0, t), + applyToHorizontal: !1, + applyToVertical: !0 + }); + e ? this._startAutoScroll(s, e, i) : this._moveContent(s); + } + stopAutoScroll() { + this._autoScrolling = !1; + this._autoScrollAccumulatedTime = this._autoScrollTotalTime; + } + setContentPosition(t) { + this._setContentPosition(t); + } + _setContentPosition(t) { + if (!this._content) return; + const e = this._getContentPosition(); + if (!(Math.abs(t.x - e.x) < Kzt && Math.abs(t.y - e.y) < Kzt)) { + this._content.setPosition(t); + this._outOfBoundaryAmountDirty = !0; + } + } + getContentPosition() { + return this._getContentPosition(); + } + _getContentPosition() { + if (!this._content) return Pi.ZERO.clone(); + this._contentPos.set(this._content.position); + return this._contentPos; + } + isScrolling() { + return this._scrolling; + } + isAutoScrolling() { + return this._autoScrolling; + } + getScrollEndedEventTiming() { + return Kzt; + } + start() { + this._calculateBoundary(); + this._content && IR.once(RR.EVENT_BEFORE_DRAW, this._adjustContentOutOfBoundary, this); + } + onEnable() { + this._registerEvent(); + if (this._content) { + this._content.on(ny.SIZE_CHANGED, this._calculateBoundary, this); + this._content.on(ny.TRANSFORM_CHANGED, this._scaleChanged, this); + if (this.view) { + this.view.node.on(ny.TRANSFORM_CHANGED, this._scaleChanged, this); + this.view.node.on(ny.SIZE_CHANGED, this._calculateBoundary, this); + } + } + this._calculateBoundary(); + this._updateScrollBarState(); + } + update(t) { + this._autoScrolling && this._processAutoScrolling(t); + } + onDisable() { + this._unregisterEvent(); + if (this._content) { + this._content.off(ny.SIZE_CHANGED, this._calculateBoundary, this); + this._content.off(ny.TRANSFORM_CHANGED, this._scaleChanged, this); + if (this.view) { + this.view.node.off(ny.TRANSFORM_CHANGED, this._scaleChanged, this); + this.view.node.off(ny.SIZE_CHANGED, this._calculateBoundary, this); + } + } + this._hideScrollBar(); + this.stopAutoScroll(); + } + _registerEvent() { + this.node.on(ny.TOUCH_START, this._onTouchBegan, this, !0); + this.node.on(ny.TOUCH_MOVE, this._onTouchMoved, this, !0); + this.node.on(ny.TOUCH_END, this._onTouchEnded, this, !0); + this.node.on(ny.TOUCH_CANCEL, this._onTouchCancelled, this, !0); + this.node.on(ny.MOUSE_WHEEL, this._onMouseWheel, this, !0); + this.node.on(fFt.XRUI_HOVER_ENTERED, this._xrHoverEnter, this); + this.node.on(fFt.XRUI_HOVER_EXITED, this._xrHoverExit, this); + lv.on(av.EventType.HANDLE_INPUT, this._dispatchEventHandleInput, this); + lv.on(av.EventType.GAMEPAD_INPUT, this._dispatchEventHandleInput, this); + } + _unregisterEvent() { + this.node.off(ny.TOUCH_START, this._onTouchBegan, this, !0); + this.node.off(ny.TOUCH_MOVE, this._onTouchMoved, this, !0); + this.node.off(ny.TOUCH_END, this._onTouchEnded, this, !0); + this.node.off(ny.TOUCH_CANCEL, this._onTouchCancelled, this, !0); + this.node.off(ny.MOUSE_WHEEL, this._onMouseWheel, this, !0); + this.node.off(fFt.XRUI_HOVER_ENTERED, this._xrHoverEnter, this); + this.node.off(fFt.XRUI_HOVER_EXITED, this._xrHoverExit, this); + lv.off(av.EventType.HANDLE_INPUT, this._dispatchEventHandleInput, this); + lv.off(av.EventType.GAMEPAD_INPUT, this._dispatchEventHandleInput, this); + } + _onMouseWheel(t, e) { + if (!this.enabledInHierarchy) return; + if (this._hasNestedViewGroup(t, e)) return; + const i = new Pi; + const s = t.getScrollY(); + this.vertical ? i.set(0, -.1 * s, 0) : this.horizontal && i.set(-.1 * s, 0, 0); + this._mouseWheelEventElapsedTime = 0; + this._processDeltaMove(i); + if (!this._stopMouseWheel) { + this._handlePressLogic(); + this.schedule(this._checkMouseWheel, 1 / 60, NaN, 0); + this._stopMouseWheel = !0; + } + this._stopPropagationIfTargetIsMe(t); + } + _onTouchBegan(t, e) { + if (this.enabledInHierarchy && this._content && !this._hasNestedViewGroup(t, e)) { + this._handlePressLogic(); + this._touchMoved = !1; + this._stopPropagationIfTargetIsMe(t); + } + } + _onTouchMoved(t, e) { + if (!this.enabledInHierarchy || !this._content) return; + if (this._hasNestedViewGroup(t, e)) return; + const i = t.touch; + this._handleMoveLogic(i); + if (!this.cancelInnerEvents) return; + const s = i.getUILocation(Qzt); + s.subtract(i.getUIStartLocation($zt)); + if (s.length() > 7 && !this._touchMoved && t.target !== this.node) { + const e = new NS(t.getTouches(), t.bubbles, IS.TOUCH_CANCEL); + e.touch = t.touch; + e.simulate = !0; + t.target.dispatchEvent(e); + this._touchMoved = !0; + } + this._stopPropagationIfTargetIsMe(t); + } + _onTouchEnded(t, e) { + if (!this.enabledInHierarchy || !this._content || !t) return; + if (this._hasNestedViewGroup(t, e)) return; + this._dispatchEvent(iHt.TOUCH_UP); + const i = t.touch; + this._handleReleaseLogic(i); + this._touchMoved ? t.propagationStopped = !0 : this._stopPropagationIfTargetIsMe(t); + } + _onTouchCancelled(t, e) { + if (this.enabledInHierarchy && this._content && !this._hasNestedViewGroup(t, e)) { + if (t && !t.simulate) { + const e = t.touch; + this._handleReleaseLogic(e); + } + this._stopPropagationIfTargetIsMe(t); + } + } + _calculateBoundary() { + if (this._content && this.view) { + const t = this._content.getComponent(JUt); + t && t.enabledInHierarchy && t.updateLayout(); + const e = this.view; + const i = e.width * e.anchorX; + const s = e.height * e.anchorY; + this._leftBoundary = -i; + this._bottomBoundary = -s; + this._rightBoundary = this._leftBoundary + e.width; + this._topBoundary = this._bottomBoundary + e.height; + this._moveContentToTopLeft(e.contentSize); + } + } + _hasNestedViewGroup(t, e) { + if (!t || t.eventPhase !== RS.CAPTURING_PHASE) return !1; + if (e) for (const i of e) { + const e = i; + if (this.node === e) return !(!t.target || !t.target.getComponent(tzt)); + if (e.getComponent(tzt)) return !0; + } + return !1; + } + _startInertiaScroll(t) { + const e = new Pi(t); + e.multiplyScalar(.7); + this._startAttenuatingAutoScroll(e, t); + } + _calculateAttenuatedFactor(t) { + return this.brake <= 0 ? 1 - this.brake : (1 - this.brake) * (1 / (1 + 14e-6 * t + t * t * 8e-9)); + } + _startAttenuatingAutoScroll(t, e) { + const i = t.clone(); + i.normalize(); + if (this._content && this.view) { + const t = this._content._uiProps.uiTransformComp.contentSize; + const e = this.view.contentSize; + const s = t.width - e.width; + const n = t.height - e.height; + const r = this._calculateAttenuatedFactor(s); + const o = this._calculateAttenuatedFactor(n); + i.x = i.x * s * (1 - this.brake) * r; + i.y = i.y * n * o * (1 - this.brake); + i.z = 0; + } + const s = t.length(); + let n = i.length() / s; + i.add(t); + if (this.brake > 0 && n > 7) { + n = Math.sqrt(n); + const e = t.clone(); + e.multiplyScalar(n); + i.set(e); + i.add(t); + } + let r = this._calculateAutoScrollTimeByInitialSpeed(e.length()); + if (this.brake > 0 && n > 3) { + n = 3; + r *= n; + } + 0 === this.brake && n > 1 && (r *= n); + this._startAutoScroll(i, r, !0); + } + _calculateAutoScrollTimeByInitialSpeed(t) { + return Math.sqrt(Math.sqrt(t / 5)); + } + _startAutoScroll(t, e, i = !1) { + const s = this._flattenVectorByDirection(t); + this._autoScrolling = !0; + this._autoScrollTargetDelta = s; + this._autoScrollAttenuate = i; + Pi.copy(this._autoScrollStartPosition, this._getContentPosition()); + this._autoScrollTotalTime = e; + this._autoScrollAccumulatedTime = 0; + this._autoScrollBraking = !1; + this._isScrollEndedWithThresholdEventFired = !1; + this._autoScrollBrakingStartPosition.set(0, 0, 0); + this._getHowMuchOutOfBoundary().equals(Pi.ZERO, Kzt) || (this._autoScrollCurrentlyOutOfBoundary = !0); + } + _calculateTouchMoveVelocity() { + const t = new Pi; + let e = 0; + e = this._touchMoveTimeDeltas.reduce(((t, e) => t + e), e); + if (e <= 0 || e >= .5) t.set(Pi.ZERO); else { + let i = new Pi; + i = this._touchMoveDisplacements.reduce(((t, e) => { + t.add(e); + return t; + }), i); + t.set(i.x * (1 - this.brake) / e, i.y * (1 - this.brake) / e, i.z); + } + return t; + } + _flattenVectorByDirection(t) { + const e = t; + e.x = this.horizontal ? e.x : 0; + e.y = this.vertical ? e.y : 0; + return e; + } + _moveContent(t, e) { + const i = this._flattenVectorByDirection(t); + Jzt.set(this._getContentPosition()); + Jzt.add(i); + Jzt.set(Math.round(1e4 * Jzt.x) * Kzt, Math.round(1e4 * Jzt.y) * Kzt, Jzt.z); + this._setContentPosition(Jzt); + const s = this._getHowMuchOutOfBoundary(); + Qzt.set(s.x, s.y); + this._updateScrollBar(Qzt); + this.elastic && e && this._startBounceBackIfNeeded(); + } + _getContentLeftBoundary() { + if (!this._content) return -1; + const t = this._getContentPosition(); + const e = this._content._uiProps.uiTransformComp; + return t.x - e.anchorX * e.width; + } + _getContentRightBoundary() { + if (!this._content) return -1; + const t = this._content._uiProps.uiTransformComp; + return this._getContentLeftBoundary() + t.width; + } + _getContentTopBoundary() { + if (!this._content) return -1; + const t = this._content._uiProps.uiTransformComp; + return this._getContentBottomBoundary() + t.height; + } + _getContentBottomBoundary() { + if (!this._content) return -1; + const t = this._getContentPosition(); + const e = this._content._uiProps.uiTransformComp; + return t.y - e.anchorY * e.height; + } + _getHowMuchOutOfBoundary(t) { + if ((t = t || new Pi).equals(Pi.ZERO, Kzt) && !this._outOfBoundaryAmountDirty) return this._outOfBoundaryAmount; + const e = new Pi; + const i = this._getContentLeftBoundary(); + const s = this._getContentRightBoundary(); + i + t.x > this._leftBoundary ? e.x = this._leftBoundary - (i + t.x) : s + t.x < this._rightBoundary && (e.x = this._rightBoundary - (s + t.x)); + const n = this._getContentTopBoundary(); + const r = this._getContentBottomBoundary(); + n + t.y < this._topBoundary ? e.y = this._topBoundary - (n + t.y) : r + t.y > this._bottomBoundary && (e.y = this._bottomBoundary - (r + t.y)); + if (t.equals(Pi.ZERO, Kzt)) { + this._outOfBoundaryAmount = e; + this._outOfBoundaryAmountDirty = !1; + } + this._clampDelta(e); + return e; + } + _updateScrollBar(t) { + this._horizontalScrollBar && this._horizontalScrollBar.onScroll(t); + this.verticalScrollBar && this.verticalScrollBar.onScroll(t); + } + _onScrollBarTouchBegan() { + this._horizontalScrollBar && this._horizontalScrollBar.onTouchBegan(); + this.verticalScrollBar && this.verticalScrollBar.onTouchBegan(); + } + _onScrollBarTouchEnded() { + this._horizontalScrollBar && this._horizontalScrollBar.onTouchEnded(); + this.verticalScrollBar && this.verticalScrollBar.onTouchEnded(); + } + _dispatchEvent(t) { + if (t === iHt.SCROLL_ENDED) this._scrollEventEmitMask = 0; else if (t === iHt.SCROLL_TO_TOP || t === iHt.SCROLL_TO_BOTTOM || t === iHt.SCROLL_TO_LEFT || t === iHt.SCROLL_TO_RIGHT) { + const e = 1 << eHt[t]; + if (this._scrollEventEmitMask & e) return; + this._scrollEventEmitMask |= e; + } + Vc.emitEvents(this.scrollEvents, this, eHt[t]); + this.node.emit(t, this); + } + _adjustContentOutOfBoundary() { + if (this._content) { + this._outOfBoundaryAmountDirty = !0; + if (this._isOutOfBoundary()) { + const t = this._getHowMuchOutOfBoundary(); + Jzt.set(this._getContentPosition()); + Jzt.add(t); + this._content.setPosition(Jzt); + this._updateScrollBar(Qi.ZERO); + } + } + } + _hideScrollBar() { + this._horizontalScrollBar && this._horizontalScrollBar.hide(); + this._verticalScrollBar && this._verticalScrollBar.hide(); + } + _updateScrollBarState() { + if (!this._content || !this.view) return; + const t = this.view; + const e = this._content._uiProps.uiTransformComp; + this.verticalScrollBar && (e.height < t.height ? this.verticalScrollBar.hide() : this.verticalScrollBar.show()); + this.horizontalScrollBar && (e.width < t.width ? this.horizontalScrollBar.hide() : this.horizontalScrollBar.show()); + } + _stopPropagationIfTargetIsMe(t) { + t.eventPhase === RS.AT_TARGET && t.target === this.node && (t.propagationStopped = !0); + } + _processDeltaMove(t) { + this._scrollChildren(t); + this._gatherTouchMove(t); + } + _handleMoveLogic(t) { + this._getLocalAxisAlignDelta(this._deltaPos, t); + this._processDeltaMove(this._deltaPos); + } + _handleReleaseLogic(t) { + this._getLocalAxisAlignDelta(this._deltaPos, t); + this._gatherTouchMove(this._deltaPos); + this._processInertiaScroll(); + if (this._scrolling) { + this._scrolling = !1; + this._autoScrolling || this._dispatchEvent(iHt.SCROLL_ENDED); + } + } + _getLocalAxisAlignDelta(t, e) { + const i = this.node._uiProps.uiTransformComp; + const s = new Pi; + if (i) { + e.getUILocation(Qzt); + e.getUIPreviousLocation($zt); + Jzt.set(Qzt.x, Qzt.y, 0); + Zzt.set($zt.x, $zt.y, 0); + i.convertToNodeSpaceAR(Jzt, Jzt); + i.convertToNodeSpaceAR(Zzt, Zzt); + Pi.subtract(s, Jzt, Zzt); + } + t.set(s); + } + _scrollChildren(t) { + this._clampDelta(t); + const e = t; + let i; + if (this.elastic) { + i = this._getHowMuchOutOfBoundary(); + e.x *= 0 === i.x ? 1 : .5; + e.y *= 0 === i.y ? 1 : .5; + } + if (!this.elastic) { + i = this._getHowMuchOutOfBoundary(e); + e.add(i); + } + let s = ""; + let n = ""; + if (this._content) { + const {anchorX: t, anchorY: i, width: r, height: o} = this._content._uiProps.uiTransformComp; + const a = this._content.position || Pi.ZERO; + if (this.vertical) if (e.y > 0) { + a.y - i * o + e.y >= this._bottomBoundary && (s = iHt.SCROLL_TO_BOTTOM); + } else if (e.y < 0) { + a.y - i * o + o + e.y <= this._topBoundary && (s = iHt.SCROLL_TO_TOP); + } + if (this.horizontal) if (e.x < 0) { + a.x - t * r + r + e.x <= this._rightBoundary && (n = iHt.SCROLL_TO_RIGHT); + } else if (e.x > 0) { + a.x - t * r + e.x >= this._leftBoundary && (n = iHt.SCROLL_TO_LEFT); + } + } + this._moveContent(e, !1); + if (this.horizontal && 0 !== e.x || this.vertical && 0 !== e.y) { + if (!this._scrolling) { + this._scrolling = !0; + this._dispatchEvent(iHt.SCROLL_BEGAN); + } + this._dispatchEvent(iHt.SCROLLING); + } + "" !== s && this._dispatchEvent(s); + "" !== n && this._dispatchEvent(n); + } + _handlePressLogic() { + this._autoScrolling && this._dispatchEvent(iHt.SCROLL_ENDED); + this._autoScrolling = !1; + this._isBouncing = !1; + this._touchMovePreviousTimestamp = tHt(); + this._touchMoveDisplacements.length = 0; + this._touchMoveTimeDeltas.length = 0; + this._onScrollBarTouchBegan(); + } + _clampDelta(t) { + if (this._content && this.view) { + const e = this.view.contentSize; + const i = this._content._uiProps.uiTransformComp; + i.width < e.width && (t.x = 0); + i.height < e.height && (t.y = 0); + } + } + _gatherTouchMove(t) { + const e = t.clone(); + this._clampDelta(e); + for (;this._touchMoveDisplacements.length >= 5; ) { + this._touchMoveDisplacements.shift(); + this._touchMoveTimeDeltas.shift(); + } + this._touchMoveDisplacements.push(e); + const i = tHt(); + this._touchMoveTimeDeltas.push((i - this._touchMovePreviousTimestamp) / 1e3); + this._touchMovePreviousTimestamp = i; + } + _startBounceBackIfNeeded() { + if (!this.elastic) return !1; + const t = this._getHowMuchOutOfBoundary(); + this._clampDelta(t); + if (t.equals(Pi.ZERO, Kzt)) return !1; + const e = Math.max(this.bounceDuration, 0); + this._startAutoScroll(t, e, !0); + if (!this._isBouncing) { + t.y > 0 && this._dispatchEvent(iHt.BOUNCE_TOP); + t.y < 0 && this._dispatchEvent(iHt.BOUNCE_BOTTOM); + t.x > 0 && this._dispatchEvent(iHt.BOUNCE_RIGHT); + t.x < 0 && this._dispatchEvent(iHt.BOUNCE_LEFT); + this._isBouncing = !0; + } + return !0; + } + _processInertiaScroll() { + if (!this._startBounceBackIfNeeded() && this.inertia) { + const t = this._calculateTouchMoveVelocity(); + !t.equals(Jzt, Kzt) && this.brake < 1 && this._startInertiaScroll(t); + } + this._onScrollBarTouchEnded(); + } + _isOutOfBoundary() { + return !this._getHowMuchOutOfBoundary().equals(Pi.ZERO, Kzt); + } + _isNecessaryAutoScrollBrake() { + if (this._autoScrollBraking) return !0; + if (this._isOutOfBoundary()) { + if (!this._autoScrollCurrentlyOutOfBoundary) { + this._autoScrollCurrentlyOutOfBoundary = !0; + this._autoScrollBraking = !0; + Pi.copy(this._autoScrollBrakingStartPosition, this._getContentPosition()); + return !0; + } + } else this._autoScrollCurrentlyOutOfBoundary = !1; + return !1; + } + _processAutoScrolling(t) { + const e = this._isNecessaryAutoScrollBrake(); + const i = e ? .05 : 1; + this._autoScrollAccumulatedTime += t * (1 / i); + let s = Math.min(1, this._autoScrollAccumulatedTime / this._autoScrollTotalTime); + this._autoScrollAttenuate && (s = (n = s, (n -= 1) * n * n * n * n + 1)); + var n; + const r = this._autoScrollTargetDelta.clone(); + r.multiplyScalar(s); + const o = this._autoScrollStartPosition.clone(); + o.add(r); + let a = Math.abs(s - 1) <= Kzt; + if (Math.abs(s - 1) <= this.getScrollEndedEventTiming() && !this._isScrollEndedWithThresholdEventFired) { + this._dispatchEvent(iHt.SCROLL_ENG_WITH_THRESHOLD); + this._isScrollEndedWithThresholdEventFired = !0; + } + if (this.elastic) { + const t = o.clone(); + t.subtract(this._autoScrollBrakingStartPosition); + e && t.multiplyScalar(i); + o.set(this._autoScrollBrakingStartPosition); + o.add(t); + } else { + const t = o.clone(); + t.subtract(this.getContentPosition()); + const e = this._getHowMuchOutOfBoundary(t); + if (!e.equals(Pi.ZERO, Kzt)) { + o.add(e); + a = !0; + } + } + a && (this._autoScrolling = !1); + const l = o.clone(); + l.subtract(this._getContentPosition()); + this._clampDelta(l); + this._moveContent(l, a); + this._dispatchEvent(iHt.SCROLLING); + if (!this._autoScrolling) { + this._isBouncing = !1; + this._scrolling = !1; + this._dispatchEvent(iHt.SCROLL_ENDED); + } + } + _checkMouseWheel(t) { + if (this._getHowMuchOutOfBoundary().equals(Pi.ZERO, Kzt)) { + this._mouseWheelEventElapsedTime += t; + if (this._mouseWheelEventElapsedTime > .1) { + this._onScrollBarTouchEnded(); + this.unschedule(this._checkMouseWheel); + this._dispatchEvent(iHt.SCROLL_ENDED); + this._stopMouseWheel = !1; + } + } else { + this._processInertiaScroll(); + this.unschedule(this._checkMouseWheel); + this._dispatchEvent(iHt.SCROLL_ENDED); + this._stopMouseWheel = !1; + } + } + _calculateMovePercentDelta(t) { + const e = t.anchor; + const i = t.applyToHorizontal; + const s = t.applyToVertical; + this._calculateBoundary(); + e.clampf(Qi.ZERO, Qi.ONE); + let n = this._getContentBottomBoundary() - this._bottomBoundary; + n = -n; + let r = this._getContentLeftBoundary() - this._leftBoundary; + r = -r; + const o = new Pi; + if (this._content && this.view) { + let t = 0; + const a = this._content._uiProps.uiTransformComp.contentSize; + const l = this.view.contentSize; + if (i) { + t = a.width - l.width; + o.x = r - t * e.x; + } + if (s) { + t = a.height - l.height; + o.y = n - t * e.y; + } + } + return o; + } + _moveContentToTopLeft(t) { + let e = this._getContentBottomBoundary() - this._bottomBoundary; + e = -e; + const i = new Pi; + let s = 0; + let n = this._getContentLeftBoundary() - this._leftBoundary; + n = -n; + if (this._content) { + const r = this._content._uiProps.uiTransformComp.contentSize; + if (r.height < t.height) { + s = r.height - t.height; + i.y = e - s; + } + if (r.width < t.width) { + s = r.width - t.width; + i.x = n; + } + } + this._updateScrollBarState(); + this._moveContent(i); + this._adjustContentOutOfBoundary(); + } + _scaleChanged(t) { + t === ay.SCALE && this._calculateBoundary(); + } + _xrHoverEnter(t) { + t.deviceType === pFt.Left ? this._hoverIn = sHt.LEFT : t.deviceType === pFt.Right && (this._hoverIn = sHt.RIGHT); + this._autoScrolling = !1; + this._dispatchEvent(iHt.SCROLL_BEGAN); + } + _xrHoverExit() { + this._hoverIn = sHt.NONE; + this._autoScrolling = !0; + this._dispatchEvent(iHt.SCROLL_ENDED); + } + _dispatchEventHandleInput(t) { + let e; + t instanceof LS ? e = t.gamepad : t instanceof FS && (e = t.handleInputDevice); + let i; + if (this.enabledInHierarchy && this._hoverIn !== sHt.NONE) { + if (this._hoverIn === sHt.LEFT) { + i = e.leftStick.getValue(); + i.equals(Qi.ZERO) || this._xrThumbStickMove(i); + } else if (this._hoverIn === sHt.RIGHT) { + i = e.rightStick.getValue(); + i.equals(Qi.ZERO) || this._xrThumbStickMove(i); + } + if (!i && this._scrollState.equals(Qi.ZERO)) { + this._xrThumbStickMoveEnd(); + this._scrollState.set(i); + } + } + } + _xrThumbStickMove(t) { + const e = new Pi; + const i = t.y; + this.vertical ? e.set(0, -62.5 * i, 0) : this.horizontal && e.set(-62.5 * i, 0, 0); + this._mouseWheelEventElapsedTime = 0; + this._processDeltaMove(e); + this._dispatchEvent(iHt.SCROLLING); + } + _xrThumbStickMoveEnd() { + this._autoScrolling = !0; + this._dispatchEvent(iHt.TOUCH_UP); + } + }, Yzt.EventType = iHt, qzt), Lzt = Bl(Nzt.prototype, "bounceDuration", [ Yl, ozt, azt, lzt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), Fzt = Bl(Nzt.prototype, "brake", [ Yl, hzt, czt, uzt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .5; + } + }), Vzt = Bl(Nzt.prototype, "elastic", [ Yl, _zt, dzt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), kzt = Bl(Nzt.prototype, "inertia", [ Yl, pzt, mzt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), Bl(Nzt.prototype, "content", [ fzt, gzt, yzt ], Object.getOwnPropertyDescriptor(Nzt.prototype, "content"), Nzt.prototype), + Uzt = Bl(Nzt.prototype, "horizontal", [ Yl, bzt, Szt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), Bl(Nzt.prototype, "horizontalScrollBar", [ Azt, Tzt, vzt ], Object.getOwnPropertyDescriptor(Nzt.prototype, "horizontalScrollBar"), Nzt.prototype), + Gzt = Bl(Nzt.prototype, "vertical", [ Yl, Ezt, Czt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), Bl(Nzt.prototype, "verticalScrollBar", [ xzt, wzt, Rzt ], Object.getOwnPropertyDescriptor(Nzt.prototype, "verticalScrollBar"), Nzt.prototype), + zzt = Bl(Nzt.prototype, "cancelInnerEvents", [ Yl, Izt, Mzt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), Hzt = Bl(Nzt.prototype, "scrollEvents", [ Bzt, Yl, Dzt, Pzt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), jzt = Bl(Nzt.prototype, "_content", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Xzt = Bl(Nzt.prototype, "_horizontalScrollBar", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Wzt = Bl(Nzt.prototype, "_verticalScrollBar", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Nzt)) || Ozt) || Ozt) || Ozt) || Ozt) || Ozt)); + m.ScrollView = nHt; + var rHt, oHt, aHt, lHt, hHt, cHt, uHt, _Ht, dHt, pHt, mHt, fHt, gHt, yHt, bHt, SHt, AHt, THt, vHt, EHt, CHt; + const xHt = new Pi; + var wHt; + !function(t) { + t[t.Horizontal = 0] = "Horizontal"; + t[t.Vertical = 1] = "Vertical"; + }(wHt || (wHt = {})); + he(wHt); + let RHt = function(e) { + return t({ + Slider: e, + SliderComponent: e + }), e; + }((rHt = Ul("cc.Slider"), oHt = sh(), aHt = zl(110), lHt = $l(), hHt = Gl(jB), cHt = Th(cL), + uHt = lh(), _Ht = Th(wHt), dHt = lh(), pHt = hh(), mHt = lh(), fHt = Th([ Vc ]), + gHt = lh(), rHt(yHt = oHt(yHt = aHt(yHt = lHt(yHt = hHt(yHt = (bHt = (CHt = EHt = class extends Qc { + constructor(...t) { + super(...t); + Ml(this, "slideEvents", SHt, this); + Ml(this, "_handle", AHt, this); + Ml(this, "_direction", THt, this); + Ml(this, "_progress", vHt, this); + this._offset = new Pi; + this._dragging = !1; + this._touchHandle = !1; + this._handleLocalPos = new Pi; + this._touchPos = new Pi; + } + get handle() { + return this._handle; + } + set handle(t) { + this._handle !== t && (this._handle = t); + } + get direction() { + return this._direction; + } + set direction(t) { + if (this._direction !== t) { + this._direction = t; + this._changeLayout(); + } + } + get progress() { + return this._progress; + } + set progress(t) { + if (this._progress !== t) { + this._progress = t; + this._updateHandlePosition(); + } + } + __preload() { + this._updateHandlePosition(); + } + onEnable() { + this._updateHandlePosition(); + this.node.on(ny.TOUCH_START, this._onTouchBegan, this); + this.node.on(ny.TOUCH_MOVE, this._onTouchMoved, this); + this.node.on(ny.TOUCH_END, this._onTouchEnded, this); + this.node.on(ny.TOUCH_CANCEL, this._onTouchCancelled, this); + this.node.on(fFt.XRUI_HOVER_STAY, this._xrHoverStay, this); + this.node.on(fFt.XRUI_CLICK, this._xrClick, this); + this.node.on(fFt.XRUI_UNCLICK, this._xrUnClick, this); + if (this._handle && this._handle.isValid) { + this._handle.node.on(ny.TOUCH_START, this._onHandleDragStart, this); + this._handle.node.on(ny.TOUCH_MOVE, this._onTouchMoved, this); + this._handle.node.on(ny.TOUCH_END, this._onTouchEnded, this); + } + } + onDisable() { + this.node.off(ny.TOUCH_START, this._onTouchBegan, this); + this.node.off(ny.TOUCH_MOVE, this._onTouchMoved, this); + this.node.off(ny.TOUCH_END, this._onTouchEnded, this); + this.node.off(ny.TOUCH_CANCEL, this._onTouchCancelled, this); + this.node.off(fFt.XRUI_HOVER_STAY, this._xrHoverStay, this); + this.node.off(fFt.XRUI_CLICK, this._xrClick, this); + this.node.off(fFt.XRUI_UNCLICK, this._xrUnClick, this); + if (this._handle && this._handle.isValid) { + this._handle.node.off(ny.TOUCH_START, this._onHandleDragStart, this); + this._handle.node.off(ny.TOUCH_MOVE, this._onTouchMoved, this); + this._handle.node.off(ny.TOUCH_END, this._onTouchEnded, this); + } + } + _onHandleDragStart(t) { + if (!t || !this._handle || !this._handle.node._uiProps.uiTransformComp) return; + this._dragging = !0; + this._touchHandle = !0; + const e = t.touch.getUILocation(); + Pi.set(this._touchPos, e.x, e.y, 0); + this._handle.node._uiProps.uiTransformComp.convertToNodeSpaceAR(this._touchPos, this._offset); + t.propagationStopped = !0; + } + _onTouchBegan(t) { + if (this._handle && t) { + this._dragging = !0; + this._touchHandle || this._handleSliderLogic(t.touch); + t.propagationStopped = !0; + } + } + _onTouchMoved(t) { + if (this._dragging && t) { + this._handleSliderLogic(t.touch); + t.propagationStopped = !0; + } + } + _onTouchEnded(t) { + this._dragging = !1; + this._touchHandle = !1; + this._offset = new Pi; + t && (t.propagationStopped = !0); + } + _onTouchCancelled(t) { + this._dragging = !1; + t && (t.propagationStopped = !0); + } + _handleSliderLogic(t) { + this._updateProgress(t); + this._emitSlideEvent(); + } + _emitSlideEvent() { + Vc.emitEvents(this.slideEvents, this); + this.node.emit("slide", this); + } + _updateProgress(t) { + if (!this._handle || !t) return; + const e = t.getUILocation(); + Pi.set(this._touchPos, e.x, e.y, 0); + const i = this.node._uiProps.uiTransformComp; + const s = i.convertToNodeSpaceAR(this._touchPos, xHt); + this.direction === wHt.Horizontal ? this.progress = di(.5 + (s.x - this._offset.x) / i.width) : this.progress = di(.5 + (s.y - this._offset.y) / i.height); + } + _updateHandlePosition() { + if (!this._handle) return; + this._handleLocalPos.set(this._handle.node.getPosition()); + const t = this.node._uiProps.uiTransformComp; + this._direction === wHt.Horizontal ? this._handleLocalPos.x = -t.width * t.anchorX + this.progress * t.width : this._handleLocalPos.y = -t.height * t.anchorY + this.progress * t.height; + this._handle.node.setPosition(this._handleLocalPos); + } + _changeLayout() { + const t = this.node._uiProps.uiTransformComp; + const e = t.contentSize; + t.setContentSize(e.height, e.width); + if (this._handle) { + const t = this._handle.node.position; + this._direction === wHt.Horizontal ? this._handle.node.setPosition(t.x, 0, t.z) : this._handle.node.setPosition(0, t.y, t.z); + this._updateHandlePosition(); + } + } + _xrHandleProgress(t) { + if (!this._touchHandle) { + const e = this.node._uiProps.uiTransformComp; + e.convertToNodeSpaceAR(t, xHt); + this.direction === wHt.Horizontal ? this.progress = di(.5 + (xHt.x - this.node.position.x) / e.width) : this.progress = di(.5 + (xHt.y - this.node.position.y) / e.height); + } + } + _xrClick(t) { + if (this._handle) { + this._dragging = !0; + this._xrHandleProgress(t.hitPoint); + this._emitSlideEvent(); + } + } + _xrUnClick() { + this._dragging = !1; + this._touchHandle = !1; + } + _xrHoverStay(t) { + if (this._dragging) { + this._xrHandleProgress(t.hitPoint); + this._emitSlideEvent(); + } + } + }, EHt.Direction = wHt, CHt), Bl(bHt.prototype, "handle", [ cHt, uHt ], Object.getOwnPropertyDescriptor(bHt.prototype, "handle"), bHt.prototype), + Bl(bHt.prototype, "direction", [ _Ht, dHt ], Object.getOwnPropertyDescriptor(bHt.prototype, "direction"), bHt.prototype), + Bl(bHt.prototype, "progress", [ dh, pHt, mHt ], Object.getOwnPropertyDescriptor(bHt.prototype, "progress"), bHt.prototype), + SHt = Bl(bHt.prototype, "slideEvents", [ fHt, Yl, gHt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), AHt = Bl(bHt.prototype, "_handle", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), THt = Bl(bHt.prototype, "_direction", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return wHt.Horizontal; + } + }), vHt = Bl(bHt.prototype, "_progress", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .1; + } + }), bHt)) || yHt) || yHt) || yHt) || yHt) || yHt)); + m.Slider = RHt; + function IHt(...t) { + return Object.assign({}, ...t); + } + var MHt, BHt, DHt, PHt, OHt, NHt, LHt, FHt, VHt, kHt, UHt, GHt, zHt, HHt, jHt, XHt, WHt, YHt, qHt; + var KHt; + !function(t) { + t.TOGGLE = "toggle"; + }(KHt || (KHt = {})); + let JHt = function(e) { + return t({ + Toggle: e, + ToggleComponent: e + }), e; + }((MHt = Ul("cc.Toggle"), BHt = sh(), DHt = zl(110), PHt = $l(), OHt = Gl(jB), NHt = ph(), + LHt = lh(), FHt = Th(cL), VHt = ph(), kHt = lh(), UHt = Th([ Vc ]), GHt = lh(), + MHt(zHt = BHt(zHt = DHt(zHt = PHt(zHt = OHt(zHt = (HHt = (qHt = YHt = class t extends RVt { + constructor(...t) { + super(...t); + Ml(this, "checkEvents", jHt, this); + Ml(this, "_isChecked", XHt, this); + Ml(this, "_checkMark", WHt, this); + } + get isChecked() { + return this._isChecked; + } + set isChecked(t) { + this._set(t); + } + get checkMark() { + return this._checkMark; + } + set checkMark(t) { + this._checkMark !== t && (this._checkMark = t); + } + set _resizeToTarget(t) { + t && this._resizeNodeToTargetNode(); + } + get _toggleContainer() { + const t = this.node.parent; + return m.Node.isNode(t) ? t.getComponent("cc.ToggleContainer") : null; + } + _internalToggle() { + this.isChecked = !this.isChecked; + } + _set(t, e = !0) { + if (this._isChecked == t) return; + this._isChecked = t; + const i = this._toggleContainer; + if (i && i.enabled && this.enabled && (t || !i.anyTogglesChecked() && !i.allowSwitchOff)) { + this._isChecked = !0; + i.notifyToggleCheck(this, e); + } + this.playEffect(); + e && this._emitToggleEvents(); + } + playEffect() { + this._checkMark && (this._checkMark.node.active = this._isChecked); + } + setIsCheckedWithoutNotify(t) { + this._set(t, !1); + } + onEnable() { + super.onEnable(); + this.playEffect(); + this.node.on(t.EventType.CLICK, this._internalToggle, this); + } + onDisable() { + super.onDisable(); + this.node.off(t.EventType.CLICK, this._internalToggle, this); + } + OnDestroy() { + const t = this._toggleContainer; + t && t.ensureValidState(); + } + _emitToggleEvents() { + this.node.emit(t.EventType.TOGGLE, this); + this.checkEvents && Vc.emitEvents(this.checkEvents, this); + } + }, YHt.EventType = IHt(KHt, wVt), qHt), Bl(HHt.prototype, "isChecked", [ NHt, LHt ], Object.getOwnPropertyDescriptor(HHt.prototype, "isChecked"), HHt.prototype), + Bl(HHt.prototype, "checkMark", [ FHt, VHt, kHt ], Object.getOwnPropertyDescriptor(HHt.prototype, "checkMark"), HHt.prototype), + jHt = Bl(HHt.prototype, "checkEvents", [ UHt, Yl, GHt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), XHt = Bl(HHt.prototype, "_isChecked", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), WHt = Bl(HHt.prototype, "_checkMark", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), HHt)) || zHt) || zHt) || zHt) || zHt) || zHt)); + m.Toggle = JHt; + var ZHt, QHt, $Ht, tjt, ejt, ijt, sjt, njt, rjt, ojt, ajt, ljt; + let hjt = function(e) { + return t({ + ToggleContainer: e, + ToggleContainerComponent: e + }), e; + }((ZHt = Ul("cc.ToggleContainer"), QHt = sh(), $Ht = zl(110), tjt = $l(), ejt = lh(), + ijt = Th([ Vc ]), sjt = lh(), ZHt(njt = QHt(njt = $Ht(njt = tjt(njt = Ql(njt = (rjt = (ljt = class extends Qc { + constructor(...t) { + super(...t); + Ml(this, "_allowSwitchOff", ojt, this); + Ml(this, "checkEvents", ajt, this); + } + get allowSwitchOff() { + return this._allowSwitchOff; + } + set allowSwitchOff(t) { + this._allowSwitchOff = t; + } + get toggleItems() { + return this.node.children.map((t => { + const e = t.getComponent("cc.Toggle"); + return e && e.enabled ? e : null; + })).filter(Boolean); + } + onEnable() { + this.ensureValidState(); + this.node.on(ny.CHILD_ADDED, this.ensureValidState, this); + this.node.on(ny.CHILD_REMOVED, this.ensureValidState, this); + } + onDisable() { + this.node.off(ny.CHILD_ADDED, this.ensureValidState, this); + this.node.off(ny.CHILD_REMOVED, this.ensureValidState, this); + } + activeToggles() { + return this.toggleItems.filter((t => t.isChecked)); + } + anyTogglesChecked() { + return !!this.toggleItems.find((t => t.isChecked)); + } + notifyToggleCheck(t, e = !0) { + if (this.enabledInHierarchy) { + for (let i = 0; i < this.toggleItems.length; i++) { + const s = this.toggleItems[i]; + s !== t && (e ? s.isChecked = !1 : s.setIsCheckedWithoutNotify(!1)); + } + this.checkEvents && m.Component.EventHandler.emitEvents(this.checkEvents, t); + } + } + ensureValidState() { + const t = this.toggleItems; + if (!this._allowSwitchOff && !this.anyTogglesChecked() && 0 !== t.length) { + const e = t[0]; + e.isChecked = !0; + this.notifyToggleCheck(e); + } + const e = this.activeToggles(); + if (e.length > 1) { + const t = e[0]; + for (let i = 0; i < e.length; ++i) { + const s = e[i]; + s !== t && (s.isChecked = !1); + } + } + } + }, ljt), ojt = Bl(rjt.prototype, "_allowSwitchOff", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), Bl(rjt.prototype, "allowSwitchOff", [ ejt ], Object.getOwnPropertyDescriptor(rjt.prototype, "allowSwitchOff"), rjt.prototype), + ajt = Bl(rjt.prototype, "checkEvents", [ ijt, Yl, sjt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), rjt)) || njt) || njt) || njt) || njt) || njt)); + m.ToggleContainer = hjt; + var cjt, ujt, _jt, djt, pjt, mjt, fjt, gjt, yjt, bjt, Sjt, Ajt, Tjt, vjt, Ejt, Cjt, xjt, wjt, Rjt, Ijt, Mjt, Bjt, Djt, Pjt, Ojt, Njt, Ljt, Fjt, Vjt, kjt, Ujt, Gjt, zjt, Hjt, jjt, Xjt, Wjt, Yjt, qjt, Kjt, Jjt, Zjt, Qjt, $jt, tXt; + const eXt = new Qi; + function iXt(t) { + return t instanceof oA ? HR : t._uiProps.uiTransformComp ? t._uiProps.uiTransformComp.contentSize : rs.ZERO; + } + function sXt(t, e, i, s) { + t.parent ? eXt.set(t.parent.getScale().x, t.parent.getScale().y) : eXt.set(0, 0); + let n = eXt.x; + let r = eXt.y; + let o = 0; + let a = 0; + for (let l = t.parent; ;) { + if (!l) { + i.x = i.y = 0; + s.x = s.y = 1; + return; + } + const t = l.getPosition(); + o += t.x; + a += t.y; + l = l.parent; + if (l === e) break; + { + l ? eXt.set(l.getScale().x, l.getScale().y) : eXt.set(0, 0); + const t = eXt.x; + const e = eXt.y; + o *= t; + a *= e; + n *= t; + r *= e; + } + } + s.x = 0 !== n ? 1 / n : 1; + s.y = 0 !== r ? 1 / r : 1; + i.x = -o; + i.y = -a; + } + let nXt; + !function(t) { + t[t.ONCE = 0] = "ONCE"; + t[t.ALWAYS = 1] = "ALWAYS"; + t[t.ON_WINDOW_RESIZE = 2] = "ON_WINDOW_RESIZE"; + }(nXt || (nXt = {})); + he(nXt); + let rXt; + !function(t) { + t[t.TOP = 1] = "TOP"; + t[t.MID = 2] = "MID"; + t[t.BOT = 4] = "BOT"; + t[t.LEFT = 8] = "LEFT"; + t[t.CENTER = 16] = "CENTER"; + t[t.RIGHT = 32] = "RIGHT"; + t[t.HORIZONTAL = 56] = "HORIZONTAL"; + t[t.VERTICAL = 7] = "VERTICAL"; + }(rXt || (rXt = {})); + const oXt = rXt.TOP | rXt.BOT; + const aXt = rXt.LEFT | rXt.RIGHT; + let lXt = function(e) { + return t({ + Widget: e, + WidgetComponent: e + }), e; + }((cjt = Ul("cc.Widget"), ujt = sh(), _jt = zl(110), djt = $l(), pjt = Gl(jB), mjt = Th(_y), + fjt = lh(), gjt = lh(), yjt = lh(), bjt = lh(), Sjt = lh(), Ajt = lh(), Tjt = lh(), + vjt = rh(), Ejt = rh(), Cjt = lh(), xjt = lh(), wjt = lh(), Rjt = lh(), Ijt = lh(), + Mjt = lh(), Bjt = Th(nXt), Djt = lh(), cjt(Pjt = ujt(Pjt = _jt(Pjt = djt(Pjt = pjt(Pjt = Ql(Pjt = (Ojt = (tXt = $jt = class extends Qc { + constructor(...t) { + super(...t); + this._lastPos = new Pi; + this._lastSize = new rs; + this._dirty = !0; + this._hadAlignOnce = !1; + Ml(this, "_alignFlags", Njt, this); + Ml(this, "_target", Ljt, this); + Ml(this, "_left", Fjt, this); + Ml(this, "_right", Vjt, this); + Ml(this, "_top", kjt, this); + Ml(this, "_bottom", Ujt, this); + Ml(this, "_horizontalCenter", Gjt, this); + Ml(this, "_verticalCenter", zjt, this); + Ml(this, "_isAbsLeft", Hjt, this); + Ml(this, "_isAbsRight", jjt, this); + Ml(this, "_isAbsTop", Xjt, this); + Ml(this, "_isAbsBottom", Wjt, this); + Ml(this, "_isAbsHorizontalCenter", Yjt, this); + Ml(this, "_isAbsVerticalCenter", qjt, this); + Ml(this, "_originalWidth", Kjt, this); + Ml(this, "_originalHeight", Jjt, this); + Ml(this, "_alignMode", Zjt, this); + Ml(this, "_lockFlags", Qjt, this); + } + get target() { + return this._target; + } + set target(t) { + if (this._target !== t) { + this._unregisterTargetEvents(); + this._target = t; + this._registerTargetEvents(); + this._validateTargetInDEV(); + this._recursiveDirty(); + } + } + get isAlignTop() { + return (this._alignFlags & rXt.TOP) > 0; + } + set isAlignTop(t) { + this._setAlign(rXt.TOP, t); + this._recursiveDirty(); + } + get isAlignBottom() { + return (this._alignFlags & rXt.BOT) > 0; + } + set isAlignBottom(t) { + this._setAlign(rXt.BOT, t); + this._recursiveDirty(); + } + get isAlignLeft() { + return (this._alignFlags & rXt.LEFT) > 0; + } + set isAlignLeft(t) { + this._setAlign(rXt.LEFT, t); + this._recursiveDirty(); + } + get isAlignRight() { + return (this._alignFlags & rXt.RIGHT) > 0; + } + set isAlignRight(t) { + this._setAlign(rXt.RIGHT, t); + this._recursiveDirty(); + } + get isAlignVerticalCenter() { + return (this._alignFlags & rXt.MID) > 0; + } + set isAlignVerticalCenter(t) { + if (t) { + this.isAlignTop = !1; + this.isAlignBottom = !1; + this._alignFlags |= rXt.MID; + } else this._alignFlags &= ~rXt.MID; + this._recursiveDirty(); + } + get isAlignHorizontalCenter() { + return (this._alignFlags & rXt.CENTER) > 0; + } + set isAlignHorizontalCenter(t) { + if (t) { + this.isAlignLeft = !1; + this.isAlignRight = !1; + this._alignFlags |= rXt.CENTER; + } else this._alignFlags &= ~rXt.CENTER; + this._recursiveDirty(); + } + get isStretchWidth() { + return (this._alignFlags & aXt) === aXt; + } + get isStretchHeight() { + return (this._alignFlags & oXt) === oXt; + } + get top() { + return this._top; + } + set top(t) { + this._top = t; + this._recursiveDirty(); + } + get editorTop() { + return this._isAbsTop ? this._top : 100 * this._top; + } + set editorTop(t) { + this._top = this._isAbsTop ? t : t / 100; + this._recursiveDirty(); + } + get bottom() { + return this._bottom; + } + set bottom(t) { + this._bottom = t; + this._recursiveDirty(); + } + get editorBottom() { + return this._isAbsBottom ? this._bottom : 100 * this._bottom; + } + set editorBottom(t) { + this._bottom = this._isAbsBottom ? t : t / 100; + this._recursiveDirty(); + } + get left() { + return this._left; + } + set left(t) { + this._left = t; + this._recursiveDirty(); + } + get editorLeft() { + return this._isAbsLeft ? this._left : 100 * this._left; + } + set editorLeft(t) { + this._left = this._isAbsLeft ? t : t / 100; + this._recursiveDirty(); + } + get right() { + return this._right; + } + set right(t) { + this._right = t; + this._recursiveDirty(); + } + get editorRight() { + return this._isAbsRight ? this._right : 100 * this._right; + } + set editorRight(t) { + this._right = this._isAbsRight ? t : t / 100; + this._recursiveDirty(); + } + get horizontalCenter() { + return this._horizontalCenter; + } + set horizontalCenter(t) { + this._horizontalCenter = t; + this._recursiveDirty(); + } + get editorHorizontalCenter() { + return this._isAbsHorizontalCenter ? this._horizontalCenter : 100 * this._horizontalCenter; + } + set editorHorizontalCenter(t) { + this._horizontalCenter = this._isAbsHorizontalCenter ? t : t / 100; + this._recursiveDirty(); + } + get verticalCenter() { + return this._verticalCenter; + } + set verticalCenter(t) { + this._verticalCenter = t; + this._recursiveDirty(); + } + get editorVerticalCenter() { + return this._isAbsVerticalCenter ? this._verticalCenter : 100 * this._verticalCenter; + } + set editorVerticalCenter(t) { + this._verticalCenter = this._isAbsVerticalCenter ? t : t / 100; + this._recursiveDirty(); + } + get isAbsoluteTop() { + return this._isAbsTop; + } + set isAbsoluteTop(t) { + if (this._isAbsTop !== t) { + this._isAbsTop = t; + this._autoChangedValue(rXt.TOP, this._isAbsTop); + } + } + get isAbsoluteBottom() { + return this._isAbsBottom; + } + set isAbsoluteBottom(t) { + if (this._isAbsBottom !== t) { + this._isAbsBottom = t; + this._autoChangedValue(rXt.BOT, this._isAbsBottom); + } + } + get isAbsoluteLeft() { + return this._isAbsLeft; + } + set isAbsoluteLeft(t) { + if (this._isAbsLeft !== t) { + this._isAbsLeft = t; + this._autoChangedValue(rXt.LEFT, this._isAbsLeft); + } + } + get isAbsoluteRight() { + return this._isAbsRight; + } + set isAbsoluteRight(t) { + if (this._isAbsRight !== t) { + this._isAbsRight = t; + this._autoChangedValue(rXt.RIGHT, this._isAbsRight); + } + } + get isAbsoluteHorizontalCenter() { + return this._isAbsHorizontalCenter; + } + set isAbsoluteHorizontalCenter(t) { + if (this._isAbsHorizontalCenter !== t) { + this._isAbsHorizontalCenter = t; + this._autoChangedValue(rXt.CENTER, this._isAbsHorizontalCenter); + } + } + get isAbsoluteVerticalCenter() { + return this._isAbsVerticalCenter; + } + set isAbsoluteVerticalCenter(t) { + if (this._isAbsVerticalCenter !== t) { + this._isAbsVerticalCenter = t; + this._autoChangedValue(rXt.MID, this._isAbsVerticalCenter); + } + } + get alignMode() { + return this._alignMode; + } + set alignMode(t) { + this._alignMode = t; + this._recursiveDirty(); + } + get alignFlags() { + return this._alignFlags; + } + set alignFlags(t) { + if (this._alignFlags !== t) { + this._alignFlags = t; + this._recursiveDirty(); + } + } + updateAlignment() { + m._widgetManager.updateAlignment(this.node); + } + _validateTargetInDEV() {} + setDirty() { + this._recursiveDirty(); + } + onEnable() { + this.node.getPosition(this._lastPos); + this._lastSize.set(this.node._uiProps.uiTransformComp.contentSize); + m._widgetManager.add(this); + this._hadAlignOnce = !1; + this._registerEvent(); + this._registerTargetEvents(); + } + onDisable() { + m._widgetManager.remove(this); + this._unregisterEvent(); + this._unregisterTargetEvents(); + } + onDestroy() { + this._removeParentEvent(); + } + _adjustWidgetToAllowMovingInEditor(t) {} + _adjustWidgetToAllowResizingInEditor() {} + _adjustWidgetToAnchorChanged() { + this.setDirty(); + } + _adjustTargetToParentChanged(t) { + t && this._unregisterOldParentEvents(t); + this.node.getParent() && this._registerTargetEvents(); + this._setDirtyByMode(); + } + _registerEvent() { + this.node.on(ny.TRANSFORM_CHANGED, this._setDirtyByMode, this); + this.node.on(ny.SIZE_CHANGED, this._setDirtyByMode, this); + this.node.on(ny.ANCHOR_CHANGED, this._adjustWidgetToAnchorChanged, this); + this.node.on(ny.PARENT_CHANGED, this._adjustTargetToParentChanged, this); + } + _unregisterEvent() { + this.node.off(ny.TRANSFORM_CHANGED, this._setDirtyByMode, this); + this.node.off(ny.SIZE_CHANGED, this._setDirtyByMode, this); + this.node.off(ny.ANCHOR_CHANGED, this._adjustWidgetToAnchorChanged, this); + } + _removeParentEvent() { + this.node.off(ny.PARENT_CHANGED, this._adjustTargetToParentChanged, this); + } + _autoChangedValue(t, e) { + if (!((this._alignFlags & t) > 0)) return; + const i = this.node.parent && this.node.parent._uiProps; + const s = i && i.uiTransformComp; + const n = s ? s.contentSize : HR; + this.isAlignLeft && t === rXt.LEFT ? this._left = e ? this._left * n.width : this._left / n.width : this.isAlignRight && t === rXt.RIGHT ? this._right = e ? this._right * n.width : this._right / n.width : this.isAlignHorizontalCenter && t === rXt.CENTER ? this._horizontalCenter = e ? this._horizontalCenter * n.width : this._horizontalCenter / n.width : this.isAlignTop && t === rXt.TOP ? this._top = e ? this._top * n.height : this._top / n.height : this.isAlignBottom && t === rXt.BOT ? this._bottom = e ? this._bottom * n.height : this._bottom / n.height : this.isAbsoluteVerticalCenter && t === rXt.MID && (this._verticalCenter = this._verticalCenter / n.height); + this._recursiveDirty(); + } + _registerTargetEvents() { + const t = this._target || this.node.parent; + if (t && t.getComponent(jB)) { + t.on(ny.TRANSFORM_CHANGED, this._setDirtyByMode, this); + t.on(ny.SIZE_CHANGED, this._setDirtyByMode, this); + t.on(ny.ANCHOR_CHANGED, this._setDirtyByMode, this); + } + } + _unregisterTargetEvents() { + const t = this._target || this.node.parent; + if (t) { + t.off(ny.TRANSFORM_CHANGED, this._setDirtyByMode, this); + t.off(ny.SIZE_CHANGED, this._setDirtyByMode, this); + t.off(ny.ANCHOR_CHANGED, this._setDirtyByMode, this); + } + } + _unregisterOldParentEvents(t) { + const e = this._target || t; + if (e) { + e.off(ny.TRANSFORM_CHANGED, this._setDirtyByMode, this); + e.off(ny.SIZE_CHANGED, this._setDirtyByMode, this); + } + } + _setDirtyByMode() { + this.alignMode === nXt.ALWAYS && this._recursiveDirty(); + } + _setAlign(t, e) { + if (e === (this._alignFlags & t) > 0) return; + const i = (t & aXt) > 0; + const s = this.node._uiProps.uiTransformComp; + if (e) { + this._alignFlags |= t; + if (i) { + this.isAlignHorizontalCenter = !1; + this.isStretchWidth && (this._originalWidth = s.width); + } else { + this.isAlignVerticalCenter = !1; + this.isStretchHeight && (this._originalHeight = s.height); + } + } else { + i ? this.isStretchWidth && (s.width = this._originalWidth) : this.isStretchHeight && (s.height = this._originalHeight); + this._alignFlags &= ~t; + } + } + _recursiveDirty() { + this._dirty || (this._dirty = !0); + } + }, $jt.AlignMode = nXt, tXt), Bl(Ojt.prototype, "target", [ mjt, fjt ], Object.getOwnPropertyDescriptor(Ojt.prototype, "target"), Ojt.prototype), + Bl(Ojt.prototype, "isAlignTop", [ gjt ], Object.getOwnPropertyDescriptor(Ojt.prototype, "isAlignTop"), Ojt.prototype), + Bl(Ojt.prototype, "isAlignBottom", [ yjt ], Object.getOwnPropertyDescriptor(Ojt.prototype, "isAlignBottom"), Ojt.prototype), + Bl(Ojt.prototype, "isAlignLeft", [ bjt ], Object.getOwnPropertyDescriptor(Ojt.prototype, "isAlignLeft"), Ojt.prototype), + Bl(Ojt.prototype, "isAlignRight", [ Sjt ], Object.getOwnPropertyDescriptor(Ojt.prototype, "isAlignRight"), Ojt.prototype), + Bl(Ojt.prototype, "isAlignVerticalCenter", [ Ajt ], Object.getOwnPropertyDescriptor(Ojt.prototype, "isAlignVerticalCenter"), Ojt.prototype), + Bl(Ojt.prototype, "isAlignHorizontalCenter", [ Tjt ], Object.getOwnPropertyDescriptor(Ojt.prototype, "isAlignHorizontalCenter"), Ojt.prototype), + Bl(Ojt.prototype, "isStretchWidth", [ vjt ], Object.getOwnPropertyDescriptor(Ojt.prototype, "isStretchWidth"), Ojt.prototype), + Bl(Ojt.prototype, "isStretchHeight", [ Ejt ], Object.getOwnPropertyDescriptor(Ojt.prototype, "isStretchHeight"), Ojt.prototype), + Bl(Ojt.prototype, "top", [ Cjt ], Object.getOwnPropertyDescriptor(Ojt.prototype, "top"), Ojt.prototype), + Bl(Ojt.prototype, "editorTop", [ nh ], Object.getOwnPropertyDescriptor(Ojt.prototype, "editorTop"), Ojt.prototype), + Bl(Ojt.prototype, "bottom", [ xjt ], Object.getOwnPropertyDescriptor(Ojt.prototype, "bottom"), Ojt.prototype), + Bl(Ojt.prototype, "editorBottom", [ nh ], Object.getOwnPropertyDescriptor(Ojt.prototype, "editorBottom"), Ojt.prototype), + Bl(Ojt.prototype, "left", [ wjt ], Object.getOwnPropertyDescriptor(Ojt.prototype, "left"), Ojt.prototype), + Bl(Ojt.prototype, "editorLeft", [ nh ], Object.getOwnPropertyDescriptor(Ojt.prototype, "editorLeft"), Ojt.prototype), + Bl(Ojt.prototype, "right", [ Rjt ], Object.getOwnPropertyDescriptor(Ojt.prototype, "right"), Ojt.prototype), + Bl(Ojt.prototype, "editorRight", [ nh ], Object.getOwnPropertyDescriptor(Ojt.prototype, "editorRight"), Ojt.prototype), + Bl(Ojt.prototype, "horizontalCenter", [ Ijt ], Object.getOwnPropertyDescriptor(Ojt.prototype, "horizontalCenter"), Ojt.prototype), + Bl(Ojt.prototype, "editorHorizontalCenter", [ nh ], Object.getOwnPropertyDescriptor(Ojt.prototype, "editorHorizontalCenter"), Ojt.prototype), + Bl(Ojt.prototype, "verticalCenter", [ Mjt ], Object.getOwnPropertyDescriptor(Ojt.prototype, "verticalCenter"), Ojt.prototype), + Bl(Ojt.prototype, "editorVerticalCenter", [ nh ], Object.getOwnPropertyDescriptor(Ojt.prototype, "editorVerticalCenter"), Ojt.prototype), + Bl(Ojt.prototype, "isAbsoluteTop", [ nh ], Object.getOwnPropertyDescriptor(Ojt.prototype, "isAbsoluteTop"), Ojt.prototype), + Bl(Ojt.prototype, "isAbsoluteBottom", [ nh ], Object.getOwnPropertyDescriptor(Ojt.prototype, "isAbsoluteBottom"), Ojt.prototype), + Bl(Ojt.prototype, "isAbsoluteLeft", [ nh ], Object.getOwnPropertyDescriptor(Ojt.prototype, "isAbsoluteLeft"), Ojt.prototype), + Bl(Ojt.prototype, "isAbsoluteRight", [ nh ], Object.getOwnPropertyDescriptor(Ojt.prototype, "isAbsoluteRight"), Ojt.prototype), + Bl(Ojt.prototype, "isAbsoluteHorizontalCenter", [ nh ], Object.getOwnPropertyDescriptor(Ojt.prototype, "isAbsoluteHorizontalCenter"), Ojt.prototype), + Bl(Ojt.prototype, "isAbsoluteVerticalCenter", [ nh ], Object.getOwnPropertyDescriptor(Ojt.prototype, "isAbsoluteVerticalCenter"), Ojt.prototype), + Bl(Ojt.prototype, "alignMode", [ Bjt, Djt ], Object.getOwnPropertyDescriptor(Ojt.prototype, "alignMode"), Ojt.prototype), + Bl(Ojt.prototype, "alignFlags", [ nh ], Object.getOwnPropertyDescriptor(Ojt.prototype, "alignFlags"), Ojt.prototype), + Njt = Bl(Ojt.prototype, "_alignFlags", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Ljt = Bl(Ojt.prototype, "_target", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), Fjt = Bl(Ojt.prototype, "_left", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Vjt = Bl(Ojt.prototype, "_right", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), kjt = Bl(Ojt.prototype, "_top", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Ujt = Bl(Ojt.prototype, "_bottom", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Gjt = Bl(Ojt.prototype, "_horizontalCenter", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), zjt = Bl(Ojt.prototype, "_verticalCenter", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Hjt = Bl(Ojt.prototype, "_isAbsLeft", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), jjt = Bl(Ojt.prototype, "_isAbsRight", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), Xjt = Bl(Ojt.prototype, "_isAbsTop", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), Wjt = Bl(Ojt.prototype, "_isAbsBottom", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), Yjt = Bl(Ojt.prototype, "_isAbsHorizontalCenter", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), qjt = Bl(Ojt.prototype, "_isAbsVerticalCenter", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), Kjt = Bl(Ojt.prototype, "_originalWidth", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Jjt = Bl(Ojt.prototype, "_originalHeight", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Zjt = Bl(Ojt.prototype, "_alignMode", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return nXt.ON_WINDOW_RESIZE; + } + }), Qjt = Bl(Ojt.prototype, "_lockFlags", [ Yl, Kl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), Ojt)) || Pjt) || Pjt) || Pjt) || Pjt) || Pjt) || Pjt)); + m.internal.computeInverseTransForTarget = sXt; + m.internal.getReadonlyNodeSize = iXt; + m.Widget = lXt; + var hXt, cXt, uXt, _Xt, dXt, pXt, mXt, fXt, gXt, yXt, bXt, SXt, AXt, TXt, vXt, EXt, CXt, xXt, wXt; + const RXt = new Bi; + var IXt; + !function(t) { + t[t.HORIZONTAL = 0] = "HORIZONTAL"; + t[t.VERTICAL = 1] = "VERTICAL"; + }(IXt || (IXt = {})); + he(IXt); + let MXt = function(e) { + return t({ + PageViewIndicator: e, + PageViewIndicatorComponent: e + }), e; + }((hXt = Ul("cc.PageViewIndicator"), cXt = sh(), uXt = zl(110), _Xt = $l(), dXt = Th(GI), + pXt = lh(), mXt = Th(IXt), fXt = lh(), gXt = Th(rs), yXt = lh(), bXt = lh(), hXt(SXt = cXt(SXt = uXt(SXt = _Xt(SXt = (AXt = (wXt = xXt = class extends Qc { + constructor(...t) { + super(...t); + Ml(this, "spacing", TXt, this); + Ml(this, "_spriteFrame", vXt, this); + Ml(this, "_direction", EXt, this); + Ml(this, "_cellSize", CXt, this); + this._layout = null; + this._pageView = null; + this._indicators = []; + } + get spriteFrame() { + return this._spriteFrame; + } + set spriteFrame(t) { + this._spriteFrame !== t && (this._spriteFrame = t); + } + get direction() { + return this._direction; + } + set direction(t) { + this._direction !== t && (this._direction = t); + } + get cellSize() { + return this._cellSize; + } + set cellSize(t) { + this._cellSize !== t && (this._cellSize = t); + } + onLoad() { + this._updateLayout(); + } + setPageView(t) { + this._pageView = t; + this._refresh(); + } + _updateLayout() { + this._layout = this.getComponent(JUt); + this._layout || (this._layout = this.addComponent(JUt)); + const t = this._layout; + if (this.direction === IXt.HORIZONTAL) { + t.type = JUt.Type.HORIZONTAL; + t.spacingX = this.spacing; + } else if (this.direction === IXt.VERTICAL) { + t.type = JUt.Type.VERTICAL; + t.spacingY = this.spacing; + } + t.resizeMode = JUt.ResizeMode.CONTAINER; + } + _createIndicator() { + const t = new _y; + t.layer = this.node.layer; + const e = t.addComponent(cL); + e.spriteFrame = this.spriteFrame; + e.sizeMode = cL.SizeMode.CUSTOM; + t.parent = this.node; + t._uiProps.uiTransformComp.setContentSize(this._cellSize); + return t; + } + _changedState() { + const t = this._indicators; + if (0 === t.length || !this._pageView) return; + const e = this._pageView.curPageIdx; + if (!(e >= t.length)) { + for (let e = 0; e < t.length; ++e) { + const i = t[e]; + if (!i._uiProps.uiComp) continue; + const s = i._uiProps.uiComp; + RXt.set(s.color); + RXt.a = 127.5; + s.color = RXt; + } + if (t[e]._uiProps.uiComp) { + const i = t[e]._uiProps.uiComp; + RXt.set(i.color); + RXt.a = 255; + i.color = RXt; + } + } + } + _refresh() { + if (!this._pageView) return; + const t = this._indicators; + const e = this._pageView.getPages(); + if (e.length === t.length) return; + let i = 0; + if (e.length > t.length) for (i = 0; i < e.length; ++i) t[i] || (t[i] = this._createIndicator()); else { + for (i = t.length - e.length; i > 0; --i) { + const e = t[i - 1]; + this.node.removeChild(e); + t.splice(i - 1, 1); + } + } + this._layout && this._layout.enabledInHierarchy && this._layout.updateLayout(); + this._changedState(); + } + }, xXt.Direction = IXt, wXt), Bl(AXt.prototype, "spriteFrame", [ dXt, pXt ], Object.getOwnPropertyDescriptor(AXt.prototype, "spriteFrame"), AXt.prototype), + Bl(AXt.prototype, "direction", [ mXt, fXt ], Object.getOwnPropertyDescriptor(AXt.prototype, "direction"), AXt.prototype), + Bl(AXt.prototype, "cellSize", [ gXt, yXt ], Object.getOwnPropertyDescriptor(AXt.prototype, "cellSize"), AXt.prototype), + TXt = Bl(AXt.prototype, "spacing", [ Yl, bXt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), vXt = Bl(AXt.prototype, "_spriteFrame", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), EXt = Bl(AXt.prototype, "_direction", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return IXt.HORIZONTAL; + } + }), CXt = Bl(AXt.prototype, "_cellSize", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new rs(20, 20); + } + }), AXt)) || SXt) || SXt) || SXt) || SXt)); + m.PageViewIndicator = MXt; + var BXt, DXt, PXt, OXt, NXt, LXt, FXt, VXt, kXt, UXt, GXt, zXt, HXt, jXt, XXt, WXt, YXt, qXt, KXt, JXt, ZXt, QXt, $Xt, tWt, eWt, iWt, sWt, nWt, rWt, oWt, aWt, lWt, hWt, cWt, uWt, _Wt, dWt, pWt, mWt, fWt, gWt, yWt, bWt; + const SWt = new Qi; + var AWt; + !function(t) { + t[t.Unified = 0] = "Unified"; + t[t.Free = 1] = "Free"; + }(AWt || (AWt = {})); + he(AWt); + var TWt; + !function(t) { + t[t.Horizontal = 0] = "Horizontal"; + t[t.Vertical = 1] = "Vertical"; + }(TWt || (TWt = {})); + he(TWt); + var vWt; + !function(t) { + t.PAGE_TURNING = "page-turning"; + }(vWt || (vWt = {})); + let EWt = function(e) { + return t({ + PageView: e, + PageViewComponent: e + }), e; + }((BXt = Ul("cc.PageView"), DXt = sh(), PXt = zl(110), OXt = $l(), NXt = Th(AWt), + LXt = lh(), FXt = Th(TWt), VXt = lh(), kXt = hh(), UXt = lh(), GXt = hh(), zXt = lh(), + HXt = Th(MXt), jXt = lh(), XXt = lh(), WXt = Th(QGt), YXt = rh(), qXt = Th(QGt), + KXt = rh(), JXt = rh(), ZXt = rh(), QXt = rh(), $Xt = Th([ Vc ]), tWt = rh(), eWt = lh(), + iWt = Th([ Vc ]), sWt = lh(), BXt(nWt = DXt(nWt = PXt(nWt = OXt(nWt = (rWt = (bWt = yWt = class t extends nHt { + constructor(...t) { + super(...t); + Ml(this, "autoPageTurningThreshold", oWt, this); + Ml(this, "horizontal", aWt, this); + Ml(this, "vertical", lWt, this); + Ml(this, "cancelInnerEvents", hWt, this); + Ml(this, "scrollEvents", cWt, this); + Ml(this, "pageTurningSpeed", uWt, this); + Ml(this, "pageEvents", _Wt, this); + Ml(this, "_sizeMode", dWt, this); + Ml(this, "_direction", pWt, this); + Ml(this, "_scrollThreshold", mWt, this); + Ml(this, "_pageTurningEventTiming", fWt, this); + Ml(this, "_indicator", gWt, this); + this._curPageIdx = 0; + this._lastPageIdx = 0; + this._pages = []; + this._initContentPos = new Pi; + this._scrollCenterOffsetX = []; + this._scrollCenterOffsetY = []; + this._touchBeganPosition = new Qi; + this._touchEndPosition = new Qi; + } + get sizeMode() { + return this._sizeMode; + } + set sizeMode(t) { + if (this._sizeMode !== t) { + this._sizeMode = t; + this._syncSizeMode(); + } + } + get direction() { + return this._direction; + } + set direction(t) { + if (this._direction !== t) { + this._direction = t; + this._syncScrollDirection(); + } + } + get scrollThreshold() { + return this._scrollThreshold; + } + set scrollThreshold(t) { + this._scrollThreshold !== t && (this._scrollThreshold = t); + } + get pageTurningEventTiming() { + return this._pageTurningEventTiming; + } + set pageTurningEventTiming(t) { + this._pageTurningEventTiming !== t && (this._pageTurningEventTiming = t); + } + get indicator() { + return this._indicator; + } + set indicator(t) { + if (this._indicator !== t) { + this._indicator = t; + this.indicator && this.indicator.setPageView(this); + } + } + get curPageIdx() { + return this._curPageIdx; + } + get verticalScrollBar() { + return super.verticalScrollBar; + } + set verticalScrollBar(t) { + super.verticalScrollBar = t; + } + get horizontalScrollBar() { + return super.horizontalScrollBar; + } + set horizontalScrollBar(t) { + super.horizontalScrollBar = t; + } + onEnable() { + super.onEnable(); + this.node.on(ny.SIZE_CHANGED, this._updateAllPagesSize, this); + this.node.on(t.EventType.SCROLL_ENG_WITH_THRESHOLD, this._dispatchPageTurningEvent, this); + } + onDisable() { + super.onDisable(); + this.node.off(ny.SIZE_CHANGED, this._updateAllPagesSize, this); + this.node.off(t.EventType.SCROLL_ENG_WITH_THRESHOLD, this._dispatchPageTurningEvent, this); + } + onLoad() { + this._initPages(); + this.indicator && this.indicator.setPageView(this); + } + getCurrentPageIndex() { + return this._curPageIdx; + } + setCurrentPageIndex(t) { + this.scrollToPage(t, 1); + } + getPages() { + return this._pages; + } + addPage(t) { + if (t && -1 === this._pages.indexOf(t) && this.content) if (t._uiProps.uiTransformComp) { + this.content.addChild(t); + this._pages.push(t); + this._updatePageView(); + } else P(4301); + } + insertPage(t, e) { + if (e < 0 || !t || -1 !== this._pages.indexOf(t) || !this.content) return; + if (e >= this._pages.length) this.addPage(t); else { + if (!t._uiProps.uiTransformComp) { + P(4301); + return; + } + this._pages.splice(e, 0, t); + this.content.insertChild(t, e); + this._updatePageView(); + } + } + removePage(t) { + if (!t || !this.content) return; + const e = this._pages.indexOf(t); + -1 !== e ? this.removePageAtIndex(e) : N(4300, t.name); + } + removePageAtIndex(t) { + const e = this._pages; + if (t < 0 || t >= e.length) return; + const i = e[t]; + if (i && this.content) { + this.content.removeChild(i); + e.splice(t, 1); + this._updatePageView(); + } + } + removeAllPages() { + if (!this.content) return; + const t = this._pages; + for (let e = 0, i = t.length; e < i; e++) this.content.removeChild(t[e]); + this._pages.length = 0; + this._updatePageView(); + } + scrollToPage(t, e = .3) { + if (!(t < 0 || t >= this._pages.length)) { + this._curPageIdx = t; + this.scrollToOffset(this._moveOffsetValue(t), e, !0); + this.indicator && this.indicator._changedState(); + } + } + getScrollEndedEventTiming() { + return this.pageTurningEventTiming; + } + _updatePageView() { + if (!this.content) return; + const t = this.content.getComponent(JUt); + t && t.enabled && t.updateLayout(); + const e = this._pages.length; + if (this._curPageIdx >= e) { + this._curPageIdx = 0 === e ? 0 : e - 1; + this._lastPageIdx = this._curPageIdx; + } + const i = this._initContentPos; + for (let t = 0; t < e; ++t) { + const e = this._pages[t].position; + this.direction === TWt.Horizontal ? this._scrollCenterOffsetX[t] = Math.abs(i.x + e.x) : this._scrollCenterOffsetY[t] = Math.abs(i.y + e.y); + } + this.indicator && this.indicator._refresh(); + } + _updateAllPagesSize() { + const t = this.view; + if (!this.content || !t) return; + if (this._sizeMode !== AWt.Unified) return; + const e = this._pages; + const i = t.contentSize; + for (let t = 0, s = e.length; t < s; t++) e[t]._uiProps.uiTransformComp.setContentSize(i); + } + _handleReleaseLogic() { + this._autoScrollToPage(); + if (this._scrolling) { + this._scrolling = !1; + this._autoScrolling || this._dispatchEvent(t.EventType.SCROLL_ENDED); + } + } + _onTouchBegan(t, e) { + t.touch.getUILocation(SWt); + Qi.set(this._touchBeganPosition, SWt.x, SWt.y); + super._onTouchBegan(t, e); + } + _onTouchMoved(t, e) { + super._onTouchMoved(t, e); + } + _onTouchEnded(t, e) { + t.touch.getUILocation(SWt); + Qi.set(this._touchEndPosition, SWt.x, SWt.y); + super._onTouchEnded(t, e); + } + _onTouchCancelled(t, e) { + t.touch.getUILocation(SWt); + Qi.set(this._touchEndPosition, SWt.x, SWt.y); + super._onTouchCancelled(t, e); + } + _onMouseWheel() {} + _syncScrollDirection() { + this.horizontal = this.direction === TWt.Horizontal; + this.vertical = this.direction === TWt.Vertical; + } + _syncSizeMode() { + const t = this.view; + if (!this.content || !t) return; + const e = this.content.getComponent(JUt); + if (e) { + if (this._sizeMode === AWt.Free && this._pages.length > 0) { + const i = this._pages[0]._uiProps.uiTransformComp; + const s = this._pages[this._pages.length - 1]._uiProps.uiTransformComp; + if (this.direction === TWt.Horizontal) { + e.paddingLeft = (t.width - i.width) / 2; + e.paddingRight = (t.width - s.width) / 2; + } else if (this.direction === TWt.Vertical) { + e.paddingTop = (t.height - i.height) / 2; + e.paddingBottom = (t.height - s.height) / 2; + } + } + e.updateLayout(); + } + } + _initPages() { + if (!this.content) return; + this._initContentPos = this.content.position; + const t = this.content.children; + for (let e = 0; e < t.length; ++e) { + const i = t[e]; + this._pages.indexOf(i) >= 0 || this._pages.push(i); + } + this._syncScrollDirection(); + this._syncSizeMode(); + this._updatePageView(); + } + _dispatchPageTurningEvent() { + if (this._lastPageIdx !== this._curPageIdx) { + this._lastPageIdx = this._curPageIdx; + Vc.emitEvents(this.pageEvents, this, vWt.PAGE_TURNING); + this.node.emit(vWt.PAGE_TURNING, this); + } + } + _isQuicklyScrollable(t) { + if (this.direction === TWt.Horizontal) { + if (Math.abs(t.x) > this.autoPageTurningThreshold) return !0; + } else if (this.direction === TWt.Vertical && Math.abs(t.y) > this.autoPageTurningThreshold) return !0; + return !1; + } + _moveOffsetValue(t) { + const e = new Qi; + if (this._sizeMode === AWt.Free) this.direction === TWt.Horizontal ? e.x = this._scrollCenterOffsetX[t] : this.direction === TWt.Vertical && (e.y = this._scrollCenterOffsetY[t]); else { + const i = this.view; + if (!i) return e; + this.direction === TWt.Horizontal ? e.x = t * i.width : this.direction === TWt.Vertical && (e.y = t * i.height); + } + return e; + } + _getDragDirection(t) { + return this._direction === TWt.Horizontal ? 0 === t.x ? 0 : t.x > 0 ? 1 : -1 : 0 === t.y ? 0 : t.y < 0 ? 1 : -1; + } + _isScrollable(t, e, i) { + if (this._sizeMode === AWt.Free) { + let s = 0; + let n = 0; + if (this.direction === TWt.Horizontal) { + s = this._scrollCenterOffsetX[e]; + n = this._scrollCenterOffsetX[i]; + return Math.abs(t.x) >= Math.abs(s - n) * this.scrollThreshold; + } + if (this.direction === TWt.Vertical) { + s = this._scrollCenterOffsetY[e]; + n = this._scrollCenterOffsetY[i]; + return Math.abs(t.y) >= Math.abs(s - n) * this.scrollThreshold; + } + } else { + const e = this.view; + if (!e) return !1; + if (this.direction === TWt.Horizontal) return Math.abs(t.x) >= e.width * this.scrollThreshold; + if (this.direction === TWt.Vertical) return Math.abs(t.y) >= e.height * this.scrollThreshold; + } + return !1; + } + _autoScrollToPage() { + if (this._startBounceBackIfNeeded()) { + const t = this._getHowMuchOutOfBoundary(); + this._clampDelta(t); + (t.x > 0 || t.y < 0) && (this._curPageIdx = 0 === this._pages.length ? 0 : this._pages.length - 1); + (t.x < 0 || t.y > 0) && (this._curPageIdx = 0); + this.indicator && this.indicator._changedState(); + } else { + const t = new Qi; + Qi.subtract(t, this._touchBeganPosition, this._touchEndPosition); + const e = this._curPageIdx; + const i = e + this._getDragDirection(t); + const s = this.pageTurningSpeed * Math.abs(e - i); + if (i < this._pages.length) { + if (this._isScrollable(t, e, i)) { + this.scrollToPage(i, s); + return; + } + { + const t = this._calculateTouchMoveVelocity(); + if (this._isQuicklyScrollable(t)) { + this.scrollToPage(i, s); + return; + } + } + } + this.scrollToPage(e, s); + } + } + }, yWt.SizeMode = AWt, yWt.Direction = TWt, yWt.EventType = IHt(vWt, iHt), bWt), + Bl(rWt.prototype, "sizeMode", [ NXt, LXt ], Object.getOwnPropertyDescriptor(rWt.prototype, "sizeMode"), rWt.prototype), + Bl(rWt.prototype, "direction", [ FXt, VXt ], Object.getOwnPropertyDescriptor(rWt.prototype, "direction"), rWt.prototype), + Bl(rWt.prototype, "scrollThreshold", [ dh, kXt, UXt ], Object.getOwnPropertyDescriptor(rWt.prototype, "scrollThreshold"), rWt.prototype), + Bl(rWt.prototype, "pageTurningEventTiming", [ dh, GXt, zXt ], Object.getOwnPropertyDescriptor(rWt.prototype, "pageTurningEventTiming"), rWt.prototype), + Bl(rWt.prototype, "indicator", [ HXt, jXt ], Object.getOwnPropertyDescriptor(rWt.prototype, "indicator"), rWt.prototype), + oWt = Bl(rWt.prototype, "autoPageTurningThreshold", [ Yl, XXt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 100; + } + }), Bl(rWt.prototype, "verticalScrollBar", [ WXt, vh, YXt ], Object.getOwnPropertyDescriptor(rWt.prototype, "verticalScrollBar"), rWt.prototype), + Bl(rWt.prototype, "horizontalScrollBar", [ qXt, vh, KXt ], Object.getOwnPropertyDescriptor(rWt.prototype, "horizontalScrollBar"), rWt.prototype), + aWt = Bl(rWt.prototype, "horizontal", [ vh, Yl, JXt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), lWt = Bl(rWt.prototype, "vertical", [ vh, Yl, ZXt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), hWt = Bl(rWt.prototype, "cancelInnerEvents", [ vh, Yl, QXt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), cWt = Bl(rWt.prototype, "scrollEvents", [ $Xt, Yl, vh, tWt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), uWt = Bl(rWt.prototype, "pageTurningSpeed", [ Yl, nh, eWt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .3; + } + }), _Wt = Bl(rWt.prototype, "pageEvents", [ iWt, Yl, sWt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), dWt = Bl(rWt.prototype, "_sizeMode", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return AWt.Unified; + } + }), pWt = Bl(rWt.prototype, "_direction", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return TWt.Horizontal; + } + }), mWt = Bl(rWt.prototype, "_scrollThreshold", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .5; + } + }), fWt = Bl(rWt.prototype, "_pageTurningEventTiming", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return .1; + } + }), gWt = Bl(rWt.prototype, "_indicator", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), rWt)) || nWt) || nWt) || nWt) || nWt)); + m.PageView = EWt; + const CWt = new Pi; + const xWt = new Qi; + const wWt = new Qi; + const RWt = new Qi(1, 1); + const IWt = new Qi; + const MWt = new Qi; + function BWt(t, e) { + if (e._hadAlignOnce) return; + e.alignMode === nXt.ONCE && (e._hadAlignOnce = !0); + const i = e.target; + let s; + const n = wWt; + const r = RWt; + if (i) { + s = i; + sXt(t, s, n, r); + } else s = t.parent; + const o = iXt(s); + const a = s instanceof oA || !s.getComponent(jB); + const l = a ? xWt : s.getComponent(jB).anchorPoint; + const h = a; + t.getPosition(CWt); + const c = t._uiProps.uiTransformComp; + let u = CWt.x; + let _ = CWt.y; + const d = c.anchorPoint; + const p = t.getScale(); + if (e.alignFlags & rXt.HORIZONTAL) { + let t = 0; + let s = 0; + const a = o.width; + if (h) { + t = HR.left.x; + s = HR.right.x; + } else { + t = -l.x * a; + s = t + a; + } + t += e.isAbsoluteLeft ? e.left : e.left * a; + s -= e.isAbsoluteRight ? e.right : e.right * a; + if (i) { + t += n.x; + t *= r.x; + s += n.x; + s *= r.x; + } + let _ = 0; + let m = d.x; + let f = p.x; + if (f < 0) { + m = 1 - m; + f = -f; + } + if (e.isStretchWidth) { + _ = s - t; + 0 !== f && (c.width = _ / f); + u = t + m * _; + } else { + _ = c.width * f; + if (e.isAlignHorizontalCenter) { + let t = e.isAbsoluteHorizontalCenter ? e.horizontalCenter : e.horizontalCenter * a; + let s = (.5 - l.x) * o.width; + if (i) { + t *= r.x; + s += n.x; + s *= r.x; + } + u = s + (m - .5) * _ + t; + } else u = e.isAlignLeft ? t + m * _ : s + (m - 1) * _; + } + e._lastSize.width = _; + } + if (e.alignFlags & rXt.VERTICAL) { + let t = 0; + let s = 0; + const a = o.height; + if (h) { + s = HR.bottom.y; + t = HR.top.y; + } else { + s = -l.y * a; + t = s + a; + } + s += e.isAbsoluteBottom ? e.bottom : e.bottom * a; + t -= e.isAbsoluteTop ? e.top : e.top * a; + if (i) { + s += n.y; + s *= r.y; + t += n.y; + t *= r.y; + } + let u = 0; + let m = d.y; + let f = p.y; + if (f < 0) { + m = 1 - m; + f = -f; + } + if (e.isStretchHeight) { + u = t - s; + 0 !== f && (c.height = u / f); + _ = s + m * u; + } else { + u = c.height * f; + if (e.isAlignVerticalCenter) { + let t = e.isAbsoluteVerticalCenter ? e.verticalCenter : e.verticalCenter * a; + let s = (.5 - l.y) * o.height; + if (i) { + t *= r.y; + s += n.y; + s *= r.y; + } + _ = s + (m - .5) * u + t; + } else _ = e.isAlignBottom ? s + m * u : t + (m - 1) * u; + } + e._lastSize.height = u; + } + t.setPosition(u, _, CWt.z); + Pi.set(e._lastPos, u, _, CWt.z); + } + function DWt(t) { + const e = t.getComponent(lXt); + if (e && e.enabled) { + if (!m.isValid(t, !0)) return; + OWt.push(e); + } + const i = t.children; + for (const t of i) t.active && DWt(t); + } + function PWt() { + const t = IR.getScene(); + if (t) { + NWt.isAligning = !0; + if (NWt._nodesOrderDirty) { + OWt.length = 0; + DWt(t); + NWt._nodesOrderDirty = !1; + } + let e = null; + const i = NWt._activeWidgetsIterator; + for (i.i = 0; i.i < OWt.length; ++i.i) { + e = OWt[i.i]; + if (e._dirty) { + BWt(e.node, e); + e._dirty = !1; + } + } + NWt.isAligning = !1; + } + } + const OWt = []; + const NWt = t("widgetManager", m._widgetManager = { + isAligning: !1, + _nodesOrderDirty: !1, + _activeWidgetsIterator: new te.MutableForwardIterator(OWt), + animationState: null, + init() { + IR.on(RR.EVENT_AFTER_SCENE_LAUNCH, PWt); + IR.on(RR.EVENT_AFTER_UPDATE, PWt); + WR.instance.on("design-resolution-changed", this.onResized, this); + { + const t = this.onResized.bind(this); + WR.instance.on("canvas-resize", t); + Lo.on("orientation-change", t); + } + }, + add(t) { + this._nodesOrderDirty = !0; + }, + remove(t) { + this._activeWidgetsIterator.remove(t); + }, + onResized() { + const t = IR.getScene(); + t && this.refreshWidgetOnResized(t); + }, + refreshWidgetOnResized(t) { + const e = _y.isNode(t) && t.getComponent(lXt); + e && e.enabled && (e.alignMode === nXt.ON_WINDOW_RESIZE || e.alignMode === nXt.ALWAYS) && e.setDirty(); + const i = t.children; + for (const t of i) this.refreshWidgetOnResized(t); + }, + updateOffsetsToStayPut(t, e) { + function i(t, e) { + return Math.abs(t - e) > 1e-10 ? e : t; + } + const s = t.node; + let n = s.parent; + if (n) { + const r = IWt; + r.set(0, 0); + const o = MWt; + o.set(1, 1); + if (t.target) { + n = t.target; + sXt(s, n, r, o); + } + if (!e) return; + const a = n._uiProps && n._uiProps.uiTransformComp; + const l = a ? a.anchorPoint : xWt; + const h = s._uiProps.uiTransformComp; + const c = iXt(n); + const u = h.anchorPoint; + const _ = s.getPosition(); + const d = rXt; + const p = s.getScale(); + let m = 0; + if (e & d.LEFT) { + let e = -l.x * c.width; + e += r.x; + e *= o.x; + m = _.x - u.x * h.width * Math.abs(p.x) - e; + t.isAbsoluteLeft || (m /= c.width); + m /= o.x; + t.left = i(t.left, m); + } + if (e & d.RIGHT) { + let e = (1 - l.x) * c.width; + e += r.x; + m = (e *= o.x) - (_.x + (1 - u.x) * h.width * Math.abs(p.x)); + t.isAbsoluteRight || (m /= c.width); + m /= o.x; + t.right = i(t.right, m); + } + if (e & d.TOP) { + let e = (1 - l.y) * c.height; + e += r.y; + m = (e *= o.y) - (_.y + (1 - u.y) * h.height * Math.abs(p.y)); + t.isAbsoluteTop || (m /= c.height); + m /= o.y; + t.top = i(t.top, m); + } + if (e & d.BOT) { + let e = -l.y * c.height; + e += r.y; + e *= o.y; + m = _.y - u.y * h.height * Math.abs(p.y) - e; + t.isAbsoluteBottom || (m /= c.height); + m /= o.y; + t.bottom = i(t.bottom, m); + } + } + }, + updateAlignment: function t(e) { + const i = e.parent; + i && _y.isNode(i) && t(i); + const s = e.getComponent(lXt); + s && i && BWt(e, s); + }, + AlignMode: nXt, + AlignFlags: rXt + }); + IR.on(RR.EVENT_INIT, (() => { + NWt.init(); + })); + var LWt; + let FWt = function(e) { + return t({ + SafeArea: e, + SafeAreaComponent: e + }), e; + }(Ul("cc.SafeArea")(LWt = sh()(LWt = zl(110)(LWt = Ql(LWt = $l()(LWt = Gl(lXt)(LWt = class extends Qc { + onEnable() { + this.updateArea(); + Lo.on("window-resize", this.updateArea, this); + Lo.on("orientation-change", this.updateArea, this); + } + onDisable() { + Lo.off("window-resize", this.updateArea, this); + Lo.off("orientation-change", this.updateArea, this); + } + updateArea() { + const t = this.node.getComponent(lXt); + const e = this.node.getComponent(jB); + if (!t || !e) return; + t.updateAlignment(); + const i = this.node.position.clone(); + const s = e.anchorPoint.clone(); + t.isAlignTop = t.isAlignBottom = t.isAlignLeft = t.isAlignRight = !0; + const n = JR.getVisibleSize(); + const r = n.width; + const o = n.height; + const a = Vo.getSafeAreaRect(); + t.top = o - a.y - a.height; + t.bottom = a.y; + t.left = a.x; + t.right = r - a.x - a.width; + t.updateAlignment(); + const l = this.node.position.clone(); + const h = s.x - (l.x - i.x) / e.width; + const c = s.y - (l.y - i.y) / e.height; + e.setAnchorPoint(h, c); + NWt.add(t); + } + }) || LWt) || LWt) || LWt) || LWt) || LWt) || LWt); + m.SafeArea = FWt; + var VWt, kWt, UWt, GWt, zWt, HWt, jWt, XWt, WWt, YWt, qWt, KWt, JWt, ZWt, QWt, $Wt, tYt, eYt, iYt, sYt; + let nYt = function(e) { + return t({ + UICoordinateTracker: e, + UICoordinateTrackerComponent: e + }), e; + }((VWt = Ul("cc.UICoordinateTracker"), kWt = sh(), UWt = $l(), GWt = zl(110), zWt = Th(_y), + HWt = lh(), jWt = Th(hS), XWt = lh(), WWt = lh(), YWt = lh(), qWt = Th([ Vc ]), + KWt = lh(), VWt(JWt = kWt(JWt = UWt(JWt = GWt(JWt = (ZWt = (sYt = class extends Qc { + constructor(...t) { + super(...t); + Ml(this, "syncEvents", QWt, this); + Ml(this, "_target", $Wt, this); + Ml(this, "_camera", tYt, this); + Ml(this, "_useScale", eYt, this); + Ml(this, "_distance", iYt, this); + this._transformPos = new Pi; + this._viewPos = new Pi; + this._canMove = !0; + this._lastWPos = new Pi; + this._lastCameraPos = new Pi; + } + get target() { + return this._target; + } + set target(t) { + if (this._target !== t) { + this._target = t; + this._checkCanMove(); + } + } + get camera() { + return this._camera; + } + set camera(t) { + if (this._camera !== t) { + this._camera = t; + this._checkCanMove(); + } + } + get useScale() { + return this._useScale; + } + set useScale(t) { + this._useScale !== t && (this._useScale = t); + } + get distance() { + return this._distance; + } + set distance(t) { + this._distance !== t && (this._distance = t); + } + onEnable() { + this._checkCanMove(); + } + update() { + const t = this.node.worldPosition; + const e = this._camera; + if (this._canMove && e && e.camera && (!this._lastWPos.equals(t) || !this._lastCameraPos.equals(e.node.worldPosition))) { + this._lastWPos.set(t); + this._lastCameraPos.set(e.node.worldPosition); + e.camera.update(); + e.convertToUINode(t, this._target, this._transformPos); + this._useScale && Pi.transformMat4(this._viewPos, this.node.worldPosition, e.camera.matView); + if (this.syncEvents.length > 0) { + const t = this._distance / Math.abs(this._viewPos.z); + Vc.emitEvents(this.syncEvents, this._transformPos, t); + } + } + } + _checkCanMove() { + this._canMove = !(!this._camera || !this._target); + } + }, sYt), Bl(ZWt.prototype, "target", [ zWt, HWt ], Object.getOwnPropertyDescriptor(ZWt.prototype, "target"), ZWt.prototype), + Bl(ZWt.prototype, "camera", [ jWt, XWt ], Object.getOwnPropertyDescriptor(ZWt.prototype, "camera"), ZWt.prototype), + Bl(ZWt.prototype, "useScale", [ WWt ], Object.getOwnPropertyDescriptor(ZWt.prototype, "useScale"), ZWt.prototype), + Bl(ZWt.prototype, "distance", [ YWt ], Object.getOwnPropertyDescriptor(ZWt.prototype, "distance"), ZWt.prototype), + QWt = Bl(ZWt.prototype, "syncEvents", [ qWt, Yl, KWt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), $Wt = Bl(ZWt.prototype, "_target", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), tYt = Bl(ZWt.prototype, "_camera", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), eYt = Bl(ZWt.prototype, "_useScale", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), iYt = Bl(ZWt.prototype, "_distance", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), ZWt)) || JWt) || JWt) || JWt) || JWt)); + var rYt; + const oYt = [ ny.TOUCH_START, ny.TOUCH_END, ny.TOUCH_MOVE, ny.MOUSE_DOWN, ny.MOUSE_MOVE, ny.MOUSE_UP, ny.MOUSE_ENTER, ny.MOUSE_LEAVE, ny.MOUSE_WHEEL ]; + function aYt(t) { + t.propagationStopped = !0; + } + let lYt = function(e) { + return t({ + BlockInputEvents: e, + BlockInputEventsComponent: e + }), e; + }(Ul("cc.BlockInputEvents")(rYt = sh()(rYt = $l()(rYt = class extends Qc { + onEnable() { + for (let t = 0; t < oYt.length; t++) this.node.on(oYt[t], aYt, this); + } + onDisable() { + for (let t = 0; t < oYt.length; t++) this.node.off(oYt[t], aYt, this); + } + }) || rYt) || rYt) || rYt); + var hYt, cYt, uYt, _Yt, dYt, pYt, mYt, fYt, gYt, yYt, bYt, SYt; + let AYt = t("SubContextView", (hYt = Ul("cc.SubContextView"), cYt = sh(), uYt = zl(110), + _Yt = Gl(jB), dYt = $l(), pYt = lh(), mYt = lh(), hYt(fYt = cYt(fYt = uYt(fYt = _Yt(fYt = dYt(fYt = (gYt = (SYt = class extends Qc { + get designResolutionSize() { + return this._designResolutionSize; + } + set designResolutionSize(t) {} + get fps() { + return this._fps; + } + set fps(t) { + if (this._fps !== t) { + this._fps = t; + this._updateInterval = 1e3 / t; + } + } + constructor() { + super(); + Ml(this, "_fps", yYt, this); + this._sprite = void 0; + this._imageAsset = void 0; + this._texture = void 0; + this._updatedTime = 0; + this._updateInterval = 0; + this._openDataContext = void 0; + this._content = void 0; + Ml(this, "_designResolutionSize", bYt, this); + this._content = new _y("content"); + this._content.hideFlags |= co.Flags.DontSave | co.Flags.HideInHierarchy; + this._sprite = null; + this._imageAsset = new IC; + this._openDataContext = null; + this._updatedTime = performance.now(); + this._texture = new LC; + } + onLoad() { + if (SI.getOpenDataContext) { + this._updateInterval = 1e3 / this._fps; + this._openDataContext = SI.getOpenDataContext(); + this._initSharedCanvas(); + this._initContentNode(); + this._updateSubContextView(); + this._updateContentLayer(); + } else this.enabled = !1; + } + onEnable() { + this._registerNodeEvent(); + } + onDisable() { + this._unregisterNodeEvent(); + } + _initSharedCanvas() { + if (this._openDataContext) { + const t = this._openDataContext.canvas; + let e = this._designResolutionSize.width; + let i = this._designResolutionSize.height; + t.width = e; + t.height = i; + } + } + _initContentNode() { + if (this._openDataContext) { + const t = this._openDataContext.canvas; + const e = this._imageAsset; + e.reset(t); + this._texture.image = e; + this._texture.create(t.width, t.height); + this._sprite = this._content.getComponent(cL); + this._sprite || (this._sprite = this._content.addComponent(cL)); + if (this._sprite.spriteFrame) this._sprite.spriteFrame.texture = this._texture; else { + const t = new GI; + t.texture = this._texture; + this._sprite.spriteFrame = t; + } + this._content.parent = this.node; + } + } + _updateSubContextView() { + if (!this._openDataContext) return; + const t = this.node.getComponent(jB); + const e = this._content.getComponent(jB); + const i = t.width / e.width; + const s = t.height / e.height; + const n = i > s ? s : i; + e.width *= n; + e.height *= n; + const r = JR.getViewportRect(); + const o = e.getBoundingBoxToWorld(); + const a = JR.getVisibleSize(); + const l = Lo.devicePixelRatio; + const h = (r.width * (o.x / a.width) + r.x) / l; + const c = (r.height * (o.y / a.height) + r.y) / l; + const u = r.width * (o.width / a.width) / l; + const _ = r.height * (o.height / a.height) / l; + this._openDataContext.postMessage({ + fromEngine: !0, + type: "engine", + event: "viewport", + x: h, + y: c, + width: u, + height: _ + }); + } + _updateSubContextTexture() { + const t = this._imageAsset; + if (!t || !this._openDataContext) return; + if (t.width <= 0 || t.height <= 0) return; + const e = this._openDataContext.canvas; + t.reset(e); + (e.width > t.width || e.height > t.height) && this._texture.create(e.width, e.height); + this._texture.uploadData(e); + } + _registerNodeEvent() { + this.node.on(ny.TRANSFORM_CHANGED, this._updateSubContextView, this); + this.node.on(ny.SIZE_CHANGED, this._updateSubContextView, this); + this.node.on(ny.LAYER_CHANGED, this._updateContentLayer, this); + } + _unregisterNodeEvent() { + this.node.off(ny.TRANSFORM_CHANGED, this._updateSubContextView, this); + this.node.off(ny.SIZE_CHANGED, this._updateSubContextView, this); + this.node.off(ny.LAYER_CHANGED, this._updateContentLayer, this); + } + _updateContentLayer() { + this._content.layer = this.node.layer; + } + update(t) { + if (void 0 === t) { + this._updateSubContextTexture(); + return; + } + if (performance.now() - this._updatedTime >= this._updateInterval) { + this._updatedTime += this._updateInterval; + this._updateSubContextTexture(); + } + } + onDestroy() { + this._content.destroy(); + this._texture.destroy(); + this._sprite && this._sprite.destroy(); + this._imageAsset.destroy(); + this._openDataContext = null; + } + }, SYt), Bl(gYt.prototype, "designResolutionSize", [ pYt ], Object.getOwnPropertyDescriptor(gYt.prototype, "designResolutionSize"), gYt.prototype), + Bl(gYt.prototype, "fps", [ mYt ], Object.getOwnPropertyDescriptor(gYt.prototype, "fps"), gYt.prototype), + yYt = Bl(gYt.prototype, "_fps", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 60; + } + }), bYt = Bl(gYt.prototype, "_designResolutionSize", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return new rs(640, 960); + } + }), gYt)) || fYt) || fYt) || fYt) || fYt) || fYt)); + m.SubContextView = AYt; + et({ + ButtonComponent: { + newName: "Button", + since: "1.2.0", + removed: !1 + }, + EditBoxComponent: { + newName: "EditBox", + since: "1.2.0", + removed: !1 + }, + LayoutComponent: { + newName: "Layout", + since: "1.2.0", + removed: !1 + }, + ProgressBarComponent: { + newName: "ProgressBar", + since: "1.2.0", + removed: !1 + }, + ScrollViewComponent: { + newName: "ScrollView", + since: "1.2.0", + removed: !1 + }, + ScrollBarComponent: { + newName: "ScrollBar", + since: "1.2.0", + removed: !1 + }, + SliderComponent: { + newName: "Slider", + since: "1.2.0", + removed: !1 + }, + ToggleComponent: { + newName: "Toggle", + since: "1.2.0", + removed: !1 + }, + ToggleContainerComponent: { + newName: "ToggleContainer", + since: "1.2.0", + removed: !1 + }, + WidgetComponent: { + newName: "Widget", + since: "1.2.0", + removed: !1 + }, + PageViewComponent: { + newName: "PageView", + since: "1.2.0", + removed: !1 + }, + PageViewIndicatorComponent: { + newName: "PageViewIndicator", + since: "1.2.0", + removed: !1 + }, + SafeAreaComponent: { + newName: "SafeArea", + since: "1.2.0", + removed: !1 + }, + UICoordinateTrackerComponent: { + newName: "UICoordinateTracker", + since: "1.2.0", + removed: !1 + }, + BlockInputEventsComponent: { + newName: "BlockInputEvents", + since: "1.2.0", + removed: !1 + } + }); + var TYt; + let vYt = t("UIReorderComponent", Ul("cc.UIReorderComponent")(TYt = class { + constructor() { + N(1408, "UIReorderComponent"); + } + }) || TYt); + m.UIReorderComponent = vYt; + m.ButtonComponent = RVt; + ee.setClassAlias(RVt, "cc.ButtonComponent"); + m.EditBoxComponent = Gkt; + ee.setClassAlias(Gkt, "cc.EditBoxComponent"); + m.LayoutComponent = JUt; + ee.setClassAlias(JUt, "cc.LayoutComponent"); + m.ProgressBarComponent = SGt; + ee.setClassAlias(SGt, "cc.ProgressBarComponent"); + m.ScrollViewComponent = nHt; + ee.setClassAlias(nHt, "cc.ScrollViewComponent"); + m.ScrollBarComponent = QGt; + ee.setClassAlias(QGt, "cc.ScrollBarComponent"); + m.SliderComponent = RHt; + ee.setClassAlias(RHt, "cc.SliderComponent"); + m.ToggleComponent = JHt; + ee.setClassAlias(JHt, "cc.ToggleComponent"); + m.ToggleContainerComponent = hjt; + ee.setClassAlias(hjt, "cc.ToggleContainerComponent"); + m.WidgetComponent = lXt; + ee.setClassAlias(lXt, "cc.WidgetComponent"); + m.PageViewComponent = EWt; + ee.setClassAlias(EWt, "cc.PageViewComponent"); + m.PageViewIndicatorComponent = MXt; + ee.setClassAlias(MXt, "cc.PageViewIndicatorComponent"); + m.SafeAreaComponent = FWt; + ee.setClassAlias(FWt, "cc.SafeAreaComponent"); + ee.setClassAlias(nYt, "cc.UICoordinateTrackerComponent"); + m.BlockInputEventsComponent = lYt; + ee.setClassAlias(lYt, "cc.BlockInputEventsComponent"); + var EYt, CYt, xYt; + let wYt = t("VideoClip", Ul("cc.VideoClip")(EYt = (CYt = class extends gc { + constructor() { + super(); + Ml(this, "_duration", xYt, this); + this._video = null; + } + set _nativeAsset(t) { + this._video = t; + this._duration = t ? t.duration : 0; + } + get _nativeAsset() { + return this._video; + } + }, xYt = Bl(CYt.prototype, "_duration", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 0; + } + }), CYt)) || EYt); + function RYt(t, e, i) { + const s = document.createElement("video"); + const n = document.createElement("source"); + s.appendChild(n); + const r = new XMLHttpRequest; + r.open("GET", t, !0); + r.responseType = "blob"; + r.onload = function() { + if (200 === this.status || 0 === this.status) { + n.src = URL.createObjectURL(this.response); + i(null, s); + } else i(new Error(`${r.status}(no response)`)); + }; + r.onerror = function() { + const e = `load video failure - ${t}`; + E(e); + i(new Error(e)); + }; + r.send(); + } + function IYt(t, e, i, s) { + const n = new wYt; + n._nativeUrl = t; + n._nativeAsset = e; + s(null, n); + } + Jw.register({ + ".mp4": RYt, + ".avi": RYt, + ".mov": RYt, + ".mpg": RYt, + ".mpeg": RYt, + ".rm": RYt, + ".rmvb": RYt + }); + sR.register({ + ".mp4": IYt, + ".avi": IYt, + ".mov": IYt, + ".mpg": IYt, + ".mpeg": IYt, + ".rm": IYt, + ".rmvb": IYt + }); + const MYt = oe({ + REMOTE: 0, + LOCAL: 1 + }); + let BYt; + !function(t) { + t.NONE = "none"; + t.PLAYING = "playing"; + t.PAUSED = "paused"; + t.STOPPED = "stopped"; + t.COMPLETED = "completed"; + t.META_LOADED = "meta-loaded"; + t.READY_TO_PLAY = "ready-to-play"; + t.ERROR = "error"; + t.CLICKED = "clicked"; + }(BYt || (BYt = {})); + let DYt; + !function(t) { + t[t.HAVE_NOTHING = 0] = "HAVE_NOTHING"; + t[t.HAVE_METADATA = 1] = "HAVE_METADATA"; + t[t.HAVE_CURRENT_DATA = 2] = "HAVE_CURRENT_DATA"; + t[t.HAVE_FUTURE_DATA = 3] = "HAVE_FUTURE_DATA"; + t[t.HAVE_ENOUGH_DATA = 4] = "HAVE_ENOUGH_DATA"; + }(DYt || (DYt = {})); + class PYt { + constructor(t) { + this._componentEventList = new Map; + this._state = BYt.NONE; + this._video = null; + this._onHide = void 0; + this._onShow = void 0; + this._interrupted = !1; + this._loaded = !1; + this._loadedMeta = !1; + this._ignorePause = !1; + this._fullScreenOnAwake = !1; + this._visible = !0; + this._playing = !1; + this._cachedCurrentTime = -1; + this._waitingFullscreen = !1; + this._waitingPlay = !1; + this._keepAspectRatio = !1; + this._component = null; + this._uiTrans = null; + this._node = null; + this._stayOnBottom = !1; + this._dirty = !1; + this._forceUpdate = !1; + this._w = 0; + this._h = 0; + this._m00 = 0; + this._m01 = 0; + this._m04 = 0; + this._m05 = 0; + this._m12 = 0; + this._m13 = 0; + this._component = t; + this._node = t.node; + this._uiTrans = t.node.getComponent(jB); + this._onHide = () => { + if (this.video && this._state === BYt.PLAYING) { + this.video.pause(); + this._interrupted = !0; + } + }; + this._onShow = () => { + if (this._interrupted && this.video) { + this.video.play(); + this._interrupted = !1; + } + }; + m.game.on(m.Game.EVENT_HIDE, this._onHide); + m.game.on(m.Game.EVENT_SHOW, this._onShow); + } + get fullScreenOnAwake() { + return this._fullScreenOnAwake; + } + get loaded() { + return this._loaded; + } + get componentEventList() { + return this._componentEventList; + } + get video() { + return this._video; + } + get state() { + return this._state; + } + get isPlaying() { + return this._playing; + } + get UICamera() { + return IR.root.batcher2D.getFirstRenderCamera(this._node); + } + onLoadedMetadata(t) { + this._loadedMeta = !0; + this._forceUpdate = !0; + this._visible ? this.enable() : this.disable(); + this.dispatchEvent(BYt.META_LOADED); + const e = t.target; + this._keepAspectRatio && e && this.syncUITransform(e.videoWidth, e.videoHeight); + this.delayedFullScreen(); + this.delayedPlay(); + } + onCanPlay(t) { + this._loaded = !0; + this.dispatchEvent(BYt.READY_TO_PLAY); + } + onPlay(t) { + this._playing = !0; + this.dispatchEvent(BYt.PLAYING); + } + onPlaying(t) { + this.dispatchEvent(BYt.PLAYING); + } + onPause(t) { + if (this._ignorePause) this._ignorePause = !1; else { + this._playing = !1; + this.dispatchEvent(BYt.PAUSED); + } + } + onStoped(t) { + this._playing = !1; + this._ignorePause = !1; + this.dispatchEvent(BYt.STOPPED); + } + onEnded(t) { + this.dispatchEvent(BYt.COMPLETED); + } + onClick(t) { + this.dispatchEvent(BYt.CLICKED); + } + onError(t) { + this.dispatchEvent(BYt.ERROR); + const e = t.target; + e && e.error && x(`Error ${e.error.code}; details: ${e.error.message}`); + } + play() { + this._loadedMeta || this._loaded ? this.canPlay() : this._waitingPlay = !0; + } + delayedPlay() { + if (this._waitingPlay) { + this.canPlay(); + this._waitingPlay = !1; + } + } + syncFullScreenOnAwake(t) { + this._fullScreenOnAwake = t; + this._loadedMeta || this._loaded ? this.canFullScreen(t) : this._waitingFullscreen = !0; + } + delayedFullScreen() { + if (this._waitingFullscreen) { + this.canFullScreen(this._fullScreenOnAwake); + this._waitingFullscreen = !1; + } + } + dispatchEvent(t) { + const e = this._componentEventList.get(t); + if (e) { + this._state = t; + e.call(this); + } + } + syncUITransform(t, e) { + if (this._uiTrans) { + this._uiTrans.width = t; + this._uiTrans.height = e; + } + } + syncCurrentTime() { + if (this.video && -1 !== this._cachedCurrentTime && this.video.currentTime !== this._cachedCurrentTime) { + this.seekTo(this._cachedCurrentTime); + this._cachedCurrentTime = -1; + } + } + destroy() { + this.removeVideoPlayer(); + this._componentEventList.clear(); + m.game.off(m.Game.EVENT_HIDE, this._onHide); + m.game.off(m.Game.EVENT_SHOW, this._onShow); + } + } + m.internal.VideoPlayerImpl = PYt; + const OYt = Zi(); + class NYt extends PYt { + constructor(t) { + super(t); + this._eventList = new Map; + this._clearColorA = -1; + this._clearFlag = void 0; + } + addListener(t, e) { + if (this._video) { + this._eventList.set(t, e); + this._video.addEventListener(t, e); + } + } + removeAllListeners() { + this._eventList.forEach(((t, e) => { + this._video && this._video.removeEventListener(e, t); + })); + this._eventList.clear(); + } + canPlay() { + if (this.video) { + const t = this.video.play(); + window.Promise && t instanceof Promise && t.catch((t => {})).then((() => { + this.syncCurrentTime(); + })); + } + } + pause() { + if (this.video) { + this.video.pause(); + this._cachedCurrentTime = this.video.currentTime; + } + } + resume() { + this.play(); + } + stop() { + if (this.video) { + this._ignorePause = !0; + this.video.currentTime = 0; + this.video.pause(); + this._cachedCurrentTime = 0; + setTimeout((() => { + this._ignorePause = !1; + this.dispatchEvent(BYt.STOPPED); + }), 0); + } + } + syncClip(t) { + this.removeVideoPlayer(); + t && this.createVideoPlayer(t.nativeUrl); + } + syncURL(t) { + this.removeVideoPlayer(); + t && this.createVideoPlayer(t); + } + syncPlaybackRate(t) { + Vo.browserType !== Co.UC ? this.video && (this.video.playbackRate = t) : C("playbackRate is not supported by the uc mobile browser."); + } + syncVolume(t) { + this.video && (this.video.volume = t); + } + syncMute(t) { + this.video && (this.video.muted = t); + } + syncLoop(t) { + this.video && (this.video.loop = t); + } + getDuration() { + return this.video ? this.video.duration : 0; + } + getCurrentTime() { + return this.video ? this.video.currentTime : -1; + } + seekTo(t) { + this.video && (this.video.currentTime = t); + } + canFullScreen(t) { + const e = this._video; + if (e && e.readyState === DYt.HAVE_ENOUGH_DATA) if (Vo.os === Ro.IOS && Vo.isBrowser) { + t ? e.webkitEnterFullscreen && e.webkitEnterFullscreen() : e.webkitExitFullscreen && e.webkitExitFullscreen(); + this._fullScreenOnAwake = e.webkitDisplayingFullscreen; + } else if (Fo.supportsFullScreen) if (t) { + Vo.browserType === Co.IE && (e.style.transform = ""); + e.setAttribute("x5-video-player-fullscreen", "true"); + Fo.requestFullScreen(e, (t => { + const i = Vo.browserType === Co.IE ? t.msFullscreenElement : t.fullscreenElement; + this._fullScreenOnAwake = i === e; + }), (() => { + this._fullScreenOnAwake = !1; + })); + } else { + e.removeAttribute("x5-video-player-fullscreen"); + Fo.exitFullScreen(); + } else { + this._fullScreenOnAwake = t; + this._forceUpdate = !0; + this.syncMatrix(); + } + } + syncStayOnBottom(t) { + if (this._video) { + this._video.style["z-index"] = t ? -32768 : 0; + this._stayOnBottom = t; + } + this._dirty = !0; + } + syncKeepAspectRatio(t) { + this._keepAspectRatio = t; + t && this._loadedMeta && this._video && this.syncUITransform(this._video.videoWidth, this._video.videoHeight); + } + removeVideoPlayer() { + const t = this._video; + if (t && Se(BR.container, t)) { + BR.container.removeChild(t); + this.removeAllListeners(); + } + this._cachedCurrentTime = 0; + this._playing = !1; + this._loaded = !1; + this._loadedMeta = !1; + this._video = null; + } + createVideoPlayer(t) { + const e = this._video = document.createElement("video"); + e.className = "cocosVideo"; + e.style.visibility = "hidden"; + e.style.position = "absolute"; + e.style.bottom = "0px"; + e.style.left = "0px"; + e.style["transform-origin"] = "0px 100% 0px"; + e.style["-webkit-transform-origin"] = "0px 100% 0px"; + e.setAttribute("preload", "auto"); + e.setAttribute("webkit-playsinline", ""); + e.setAttribute("x5-playsinline", ""); + e.setAttribute("playsinline", ""); + this._bindDomEvent(); + BR.container.appendChild(e); + const i = document.createElement("source"); + e.appendChild(i); + i.src = t; + } + _bindDomEvent() { + this._video; + this.addListener("loadedmetadata", this.onLoadedMetadata.bind(this)); + this.addListener("canplay", this.onCanPlay.bind(this)); + this.addListener("canplaythrough", this.onCanPlay.bind(this)); + this.addListener("play", this.onPlay.bind(this)); + this.addListener("playing", this.onPlaying.bind(this)); + this.addListener("pause", this.onPause.bind(this)); + this.addListener("click", this.onClick.bind(this)); + this.addListener("ended", this.onEnded.bind(this)); + this.addListener("error", this.onError.bind(this)); + } + onCanPlay(t) { + const e = t.target; + if (!this._loaded || !e) switch (e.readyState) { + case DYt.HAVE_METADATA: + case DYt.HAVE_ENOUGH_DATA: + super.onCanPlay(t); + } + } + enable() { + if (this._video) { + this._visible = !0; + if ("visible" === this._video.style.visibility) return; + this._video.style.visibility = "visible"; + } + } + disable(t) { + if (this._video) { + !t && this._playing && this._video.pause(); + this._visible = !1; + if ("hidden" === this._video.style.visibility) return; + this._video.style.visibility = "hidden"; + } + } + syncMatrix() { + if (!this._video || !this._visible || !this._component) return; + const t = this.UICamera; + if (!t) return; + if (Fo.fullScreen()) return; + if (this._dirty) { + this._dirty = !1; + if (this._stayOnBottom) { + this._clearColorA = t.clearColor.w; + this._clearFlag = t.clearFlag; + t.clearColor.w = 0; + t.clearFlag = en.ALL; + } else if (this._clearFlag) { + t.clearColor.w = this._clearColorA; + t.clearFlag = this._clearFlag; + this._clearColorA = -1; + this._clearFlag = null; + } + } + this._component.node.getWorldMatrix(OYt); + t.update(!0); + t.worldMatrixToScreen(OYt, OYt, BR.canvas.width, BR.canvas.height); + let e = 0; + let i = 0; + if (this._fullScreenOnAwake) { + e = HR.width; + i = HR.height; + } else { + e = this._uiTrans.contentSize.width; + i = this._uiTrans.contentSize.height; + } + if (!this._forceUpdate && this._m00 === OYt.m00 && this._m01 === OYt.m01 && this._m04 === OYt.m04 && this._m05 === OYt.m05 && this._m12 === OYt.m12 && this._m13 === OYt.m13 && this._w === e && this._h === i) return; + this._m00 = OYt.m00; + this._m01 = OYt.m01; + this._m04 = OYt.m04; + this._m05 = OYt.m05; + this._m12 = OYt.m12; + this._m13 = OYt.m13; + this._w = e; + this._h = i; + const s = Lo.devicePixelRatio; + const n = 1 / s; + const r = 1 / s; + const o = BR.container; + const a = OYt.m00 * n; + const l = OYt.m01; + const h = OYt.m04; + const c = OYt.m05 * r; + this._video.style.width = `${this._w}px`; + this._video.style.height = `${this._h}px`; + Vo.browserType !== Co.MOBILE_QQ ? this._video.style.objectFit = this._keepAspectRatio ? "none" : "fill" : C("keepAspectRatio is not supported by the qq mobile browser."); + const u = this._w * n; + const _ = this._h * r; + const {x: d, y: p} = this._uiTrans.anchorPoint; + const m = u * OYt.m00 * d; + const f = _ * OYt.m05 * p; + const g = o && o.style.paddingLeft ? parseInt(o.style.paddingLeft) : 0; + const y = o && o.style.paddingBottom ? parseInt(o.style.paddingBottom) : 0; + const b = `matrix(${a},${-l},${-h},${c},${OYt.m12 * n - m + g},${-(OYt.m13 * r - f + y)})`; + this._video.style.transform = b; + this._video.style["-webkit-transform"] = b; + Vo.browserType !== Co.IE && (this._forceUpdate = !1); + } + } + class LYt { + static getImpl(t) { + return new NYt(t); + } + } + m.internal.VideoPlayerImplManager = LYt; + var FYt, VYt, kYt, UYt, GYt, zYt, HYt, jYt, XYt, WYt, YYt, qYt, KYt, JYt, ZYt, QYt, $Yt, tqt, eqt, iqt, sqt, nqt, rqt, oqt, aqt, lqt, hqt, cqt, uqt, _qt, dqt, pqt, mqt, fqt, gqt, yqt, bqt, Sqt, Aqt; + let Tqt = t("VideoPlayer", (FYt = Ul("cc.VideoPlayer"), VYt = sh(), kYt = $l(), + UYt = Gl(jB), GYt = Th(wYt), zYt = Th(MYt), HYt = lh(), jYt = lh(), XYt = Th(wYt), + WYt = lh(), YYt = lh(), qYt = hh(), KYt = lh(), JYt = hh(), ZYt = lh(), QYt = lh(), + $Yt = lh(), tqt = lh(), eqt = lh(), iqt = lh(), sqt = Th([ Vc ]), nqt = ph(), rqt = lh(), + FYt(oqt = VYt(oqt = kYt(oqt = UYt(oqt = Ql(oqt = (aqt = (Aqt = Sqt = class extends Qc { + constructor(...t) { + super(...t); + Ml(this, "_resourceType", lqt, this); + Ml(this, "_remoteURL", hqt, this); + Ml(this, "_clip", cqt, this); + Ml(this, "_playOnAwake", uqt, this); + Ml(this, "_volume", _qt, this); + Ml(this, "_mute", dqt, this); + Ml(this, "_playbackRate", pqt, this); + Ml(this, "_loop", mqt, this); + Ml(this, "_fullScreenOnAwake", fqt, this); + Ml(this, "_stayOnBottom", gqt, this); + Ml(this, "_keepAspectRatio", yqt, this); + this._impl = null; + this._cachedCurrentTime = 0; + Ml(this, "videoPlayerEvent", bqt, this); + } + get resourceType() { + return this._resourceType; + } + set resourceType(t) { + if (this._resourceType !== t) { + this._resourceType = t; + this.syncSource(); + } + } + get remoteURL() { + return this._remoteURL; + } + set remoteURL(t) { + if (this._remoteURL !== t) { + this._remoteURL = t; + this.syncSource(); + } + } + get clip() { + return this._clip; + } + set clip(t) { + if (this._clip !== t) { + this._clip = t; + this.syncSource(); + } + } + get playOnAwake() { + return this._playOnAwake; + } + set playOnAwake(t) { + this._playOnAwake = t; + } + get playbackRate() { + return this._playbackRate; + } + set playbackRate(t) { + this._playbackRate = t; + this._impl && this._impl.syncPlaybackRate(t); + } + get volume() { + return this._volume; + } + set volume(t) { + this._volume = t; + this._impl && this._impl.syncVolume(t); + } + get mute() { + return this._mute; + } + set mute(t) { + this._mute = t; + this._impl && this._impl.syncMute(t); + } + get loop() { + return this._loop; + } + set loop(t) { + this._loop = t; + this._impl && this._impl.syncLoop(t); + } + get keepAspectRatio() { + return this._keepAspectRatio; + } + set keepAspectRatio(t) { + if (this._keepAspectRatio !== t) { + this._keepAspectRatio = t; + this._impl && this._impl.syncKeepAspectRatio(t); + } + } + get fullScreenOnAwake() { + if (this._impl) { + this._fullScreenOnAwake = this._impl.fullScreenOnAwake; + return this._fullScreenOnAwake; + } + return this._fullScreenOnAwake; + } + set fullScreenOnAwake(t) { + if (this._fullScreenOnAwake !== t) { + this._fullScreenOnAwake = t; + this._impl && this._impl.syncFullScreenOnAwake(t); + } + } + get stayOnBottom() { + return this._stayOnBottom; + } + set stayOnBottom(t) { + if (this._stayOnBottom !== t) { + this._stayOnBottom = t; + this._impl && this._impl.syncStayOnBottom(t); + } + } + get nativeVideo() { + return this._impl && this._impl.video || null; + } + get currentTime() { + return this._impl ? this._impl.getCurrentTime() : this._cachedCurrentTime; + } + set currentTime(t) { + if (Number.isNaN(t)) C(`illegal video time! value:${t}`); else { + t = _i(t, 0, this.duration); + this._cachedCurrentTime = t; + this._impl && this._impl.seekTo(t); + } + } + get duration() { + return this._impl ? this._impl.getDuration() : 0; + } + get state() { + return this._impl ? this._impl.state : BYt.NONE; + } + get isPlaying() { + return !!this._impl && this._impl.isPlaying; + } + syncSource() { + this._impl && (this._resourceType === MYt.REMOTE ? this._impl.syncURL(this._remoteURL) : this._impl.syncClip(this._clip)); + } + __preload() { + this._impl = LYt.getImpl(this); + this.syncSource(); + this._impl.syncLoop(this._loop); + this._impl.syncVolume(this._volume); + this._impl.syncMute(this._mute); + this._impl.seekTo(this._cachedCurrentTime); + this._impl.syncPlaybackRate(this._playbackRate); + this._impl.syncStayOnBottom(this._stayOnBottom); + this._impl.syncKeepAspectRatio(this._keepAspectRatio); + this._impl.syncFullScreenOnAwake(this._fullScreenOnAwake); + this._impl.componentEventList.set(BYt.META_LOADED, this.onMetaLoaded.bind(this)); + this._impl.componentEventList.set(BYt.READY_TO_PLAY, this.onReadyToPlay.bind(this)); + this._impl.componentEventList.set(BYt.PLAYING, this.onPlaying.bind(this)); + this._impl.componentEventList.set(BYt.PAUSED, this.onPaused.bind(this)); + this._impl.componentEventList.set(BYt.STOPPED, this.onStopped.bind(this)); + this._impl.componentEventList.set(BYt.COMPLETED, this.onCompleted.bind(this)); + this._impl.componentEventList.set(BYt.ERROR, this.onError.bind(this)); + this._playOnAwake && this._impl.loaded && this.play(); + } + onEnable() { + this._impl && this._impl.enable(); + } + onDisable() { + this._impl && this._impl.disable(); + } + onDestroy() { + if (this._impl) { + this._impl.destroy(); + this._impl = null; + } + } + update(t) { + this._impl && this._impl.syncMatrix(); + } + onMetaLoaded() { + Vc.emitEvents(this.videoPlayerEvent, this, BYt.META_LOADED); + this.node.emit("meta-loaded", this); + } + onReadyToPlay() { + this._playOnAwake && !this.isPlaying && this.play(); + Vc.emitEvents(this.videoPlayerEvent, this, BYt.READY_TO_PLAY); + this.node.emit(BYt.READY_TO_PLAY, this); + } + onPlaying() { + Vc.emitEvents(this.videoPlayerEvent, this, BYt.PLAYING); + this.node.emit(BYt.PLAYING, this); + } + onPaused() { + Vc.emitEvents(this.videoPlayerEvent, this, BYt.PAUSED); + this.node.emit(BYt.PAUSED, this); + } + onStopped() { + Vc.emitEvents(this.videoPlayerEvent, this, BYt.STOPPED); + this.node.emit(BYt.STOPPED, this); + } + onCompleted() { + Vc.emitEvents(this.videoPlayerEvent, this, BYt.COMPLETED); + this.node.emit(BYt.COMPLETED, this); + } + onError() { + Vc.emitEvents(this.videoPlayerEvent, this, BYt.ERROR); + this.node.emit(BYt.ERROR, this); + } + play() { + this._impl && this._impl.play(); + } + resume() { + this._impl && this._impl.resume(); + } + pause() { + this._impl && this._impl.pause(); + } + stop() { + this._impl && this._impl.stop(); + } + }, Sqt.EventType = BYt, Sqt.ResourceType = MYt, Aqt), lqt = Bl(aqt.prototype, "_resourceType", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return MYt.LOCAL; + } + }), hqt = Bl(aqt.prototype, "_remoteURL", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return ""; + } + }), cqt = Bl(aqt.prototype, "_clip", [ GYt, Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return null; + } + }), uqt = Bl(aqt.prototype, "_playOnAwake", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), _qt = Bl(aqt.prototype, "_volume", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), dqt = Bl(aqt.prototype, "_mute", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), pqt = Bl(aqt.prototype, "_playbackRate", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return 1; + } + }), mqt = Bl(aqt.prototype, "_loop", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), fqt = Bl(aqt.prototype, "_fullScreenOnAwake", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), gqt = Bl(aqt.prototype, "_stayOnBottom", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !1; + } + }), yqt = Bl(aqt.prototype, "_keepAspectRatio", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return !0; + } + }), Bl(aqt.prototype, "resourceType", [ zYt, HYt ], Object.getOwnPropertyDescriptor(aqt.prototype, "resourceType"), aqt.prototype), + Bl(aqt.prototype, "remoteURL", [ jYt ], Object.getOwnPropertyDescriptor(aqt.prototype, "remoteURL"), aqt.prototype), + Bl(aqt.prototype, "clip", [ XYt, WYt ], Object.getOwnPropertyDescriptor(aqt.prototype, "clip"), aqt.prototype), + Bl(aqt.prototype, "playOnAwake", [ YYt ], Object.getOwnPropertyDescriptor(aqt.prototype, "playOnAwake"), aqt.prototype), + Bl(aqt.prototype, "playbackRate", [ dh, qYt, KYt ], Object.getOwnPropertyDescriptor(aqt.prototype, "playbackRate"), aqt.prototype), + Bl(aqt.prototype, "volume", [ dh, JYt, ZYt ], Object.getOwnPropertyDescriptor(aqt.prototype, "volume"), aqt.prototype), + Bl(aqt.prototype, "mute", [ QYt ], Object.getOwnPropertyDescriptor(aqt.prototype, "mute"), aqt.prototype), + Bl(aqt.prototype, "loop", [ $Yt ], Object.getOwnPropertyDescriptor(aqt.prototype, "loop"), aqt.prototype), + Bl(aqt.prototype, "keepAspectRatio", [ tqt ], Object.getOwnPropertyDescriptor(aqt.prototype, "keepAspectRatio"), aqt.prototype), + Bl(aqt.prototype, "fullScreenOnAwake", [ eqt ], Object.getOwnPropertyDescriptor(aqt.prototype, "fullScreenOnAwake"), aqt.prototype), + Bl(aqt.prototype, "stayOnBottom", [ iqt ], Object.getOwnPropertyDescriptor(aqt.prototype, "stayOnBottom"), aqt.prototype), + bqt = Bl(aqt.prototype, "videoPlayerEvent", [ Yl, sqt, nqt, rqt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), aqt)) || oqt) || oqt) || oqt) || oqt) || oqt)); + m.internal.VideoPlayer = Tqt; + W(Tqt.prototype, "VideoPlayer.prototype", [ { + name: "onPasued", + newName: "onPaused" + } ]); + let vqt; + !function(t) { + t.NONE = "none"; + t.LOADING = "loading"; + t.LOADED = "loaded"; + t.ERROR = "error"; + }(vqt || (vqt = {})); + class Eqt { + constructor(t) { + this._componentEventList = new Map; + this._state = vqt.NONE; + this._wrapper = void 0; + this._webview = null; + this._loaded = !1; + this._forceUpdate = !1; + this._component = null; + this._uiTrans = null; + this._node = null; + this._w = 0; + this._h = 0; + this._m00 = 0; + this._m01 = 0; + this._m04 = 0; + this._m05 = 0; + this._m12 = 0; + this._m13 = 0; + this._component = t; + this._node = t.node; + this._uiTrans = t.node.getComponent(jB); + this.reset(); + this.createWebView(); + } + reset() { + this._wrapper = null; + this._webview = null; + this._loaded = !1; + this._w = 0; + this._h = 0; + this._m00 = 0; + this._m01 = 0; + this._m04 = 0; + this._m05 = 0; + this._m12 = 0; + this._m13 = 0; + this._state = vqt.NONE; + this._forceUpdate = !1; + } + get loaded() { + return this._loaded; + } + get componentEventList() { + return this._componentEventList; + } + get webview() { + return this._webview; + } + get state() { + return this._state; + } + get UICamera() { + return IR.root.batcher2D.getFirstRenderCamera(this._node); + } + dispatchEvent(t, ...e) { + const i = this._componentEventList.get(t); + if (i) { + this._state = t; + i.call(this, e); + } + } + destroy() { + this.removeWebView(); + this._wrapper = null; + this._webview = null; + this._loaded = !1; + this._component = null; + this._uiTrans = null; + this._forceUpdate = !1; + this._componentEventList.clear(); + } + } + m.internal.WebViewImpl = Eqt; + const Cqt = Zi(); + class xqt extends Eqt { + constructor(t) { + super(t); + } + _bindDomEvent() { + if (!this.webview) return; + this.webview.addEventListener("load", (t => { + this._forceUpdate = !0; + this.dispatchEvent(vqt.LOADED); + const e = t.target; + const i = e.contentDocument && e.contentDocument.body; + i && i.innerHTML.includes("404") && this.dispatchEvent(vqt.ERROR, i.innerHTML); + })); + } + loadURL(t) { + if (this.webview) { + this.webview.src = t; + this.dispatchEvent(vqt.LOADING); + } + } + createWebView() { + const t = document.createElement("div"); + this._wrapper = t; + t.id = "webview-wrapper"; + t.style["-webkit-overflow"] = "auto"; + t.style["-webkit-overflow-scrolling"] = "touch"; + t.style.position = "absolute"; + t.style.bottom = "0px"; + t.style.left = "0px"; + t.style.transformOrigin = "0px 100% 0px"; + t.style["-webkit-transform-origin"] = "0px 100% 0px"; + BR.container.appendChild(t); + const e = document.createElement("iframe"); + this._webview = e; + e.id = "webview"; + e.style.border = "none"; + e.style.width = "100%"; + e.style.height = "100%"; + t.appendChild(e); + this._bindDomEvent(); + } + removeWebView() { + const t = this._wrapper; + Se(BR.container, t) && BR.container.removeChild(t); + this.reset(); + } + enable() { + this._wrapper && (this._wrapper.style.visibility = "visible"); + } + disable() { + this._wrapper && (this._wrapper.style.visibility = "hidden"); + } + evaluateJS(t) { + if (this.webview) { + const e = this.webview.contentWindow; + if (e) try { + e.eval(t); + } catch (t) { + this.dispatchEvent(vqt.ERROR, t); + x(t); + } + } + } + setOnJSCallback(t) { + C("The platform does not support"); + } + setJavascriptInterfaceScheme(t) { + C("The platform does not support"); + } + syncMatrix() { + if (!this._wrapper || !this._uiTrans || !this._component || "hidden" === this._wrapper.style.visibility) return; + const t = this.UICamera; + if (!t) return; + this._component.node.getWorldMatrix(Cqt); + t.update(!0); + t.worldMatrixToScreen(Cqt, Cqt, BR.canvas.width, BR.canvas.height); + const {width: e, height: i} = this._uiTrans.contentSize; + if (!this._forceUpdate && this._m00 === Cqt.m00 && this._m01 === Cqt.m01 && this._m04 === Cqt.m04 && this._m05 === Cqt.m05 && this._m12 === Cqt.m12 && this._m13 === Cqt.m13 && this._w === e && this._h === i) return; + this._m00 = Cqt.m00; + this._m01 = Cqt.m01; + this._m04 = Cqt.m04; + this._m05 = Cqt.m05; + this._m12 = Cqt.m12; + this._m13 = Cqt.m13; + this._w = e; + this._h = i; + const s = Lo.devicePixelRatio; + const n = 1 / s; + const r = 1 / s; + const o = BR.container; + const a = Cqt.m00 * n; + const l = Cqt.m01; + const h = Cqt.m04; + const c = Cqt.m05 * r; + this._wrapper.style.width = `${e}px`; + this._wrapper.style.height = `${i}px`; + const u = this._w * n; + const _ = this._h * r; + const d = u * Cqt.m00 * this._uiTrans.anchorX; + const p = _ * Cqt.m05 * this._uiTrans.anchorY; + const m = o && o.style.paddingLeft ? parseInt(o.style.paddingLeft) : 0; + const f = o && o.style.paddingBottom ? parseInt(o.style.paddingBottom) : 0; + const g = `matrix(${a},${-l},${-h},${c},${Cqt.m12 * n - d + m},${-(Cqt.m13 * r - p + f)})`; + this._wrapper.style.transform = g; + this._wrapper.style["-webkit-transform"] = g; + this._forceUpdate = !1; + } + } + class wqt { + static getImpl(t) { + return new xqt(t); + } + } + m.internal.WebViewImplManager = wqt; + var Rqt, Iqt, Mqt, Bqt, Dqt, Pqt, Oqt, Nqt, Lqt, Fqt, Vqt, kqt, Uqt, Gqt; + let zqt = t("WebView", (Rqt = Ul("cc.WebView"), Iqt = sh(), Mqt = $l(), Bqt = Gl(jB), + Dqt = lh(), Pqt = Th([ Vc ]), Oqt = ph(), Nqt = lh(), Rqt(Lqt = Iqt(Lqt = Mqt(Lqt = Bqt(Lqt = Ql(Lqt = (Fqt = (Gqt = Uqt = class extends Qc { + constructor(...t) { + super(...t); + Ml(this, "_url", Vqt, this); + this._impl = null; + Ml(this, "webviewEvents", kqt, this); + } + get url() { + return this._url; + } + set url(t) { + this._url = t; + this._impl && this._impl.loadURL(t); + } + get nativeWebView() { + return this._impl && this._impl.webview || null; + } + get state() { + return this._impl ? this._impl.state : vqt.NONE; + } + setJavascriptInterfaceScheme(t) { + this._impl && this._impl.setJavascriptInterfaceScheme(t); + } + setOnJSCallback(t) { + this._impl && this._impl.setOnJSCallback(t); + } + evaluateJS(t) { + this._impl && this._impl.evaluateJS(t); + } + __preload() { + this._impl = wqt.getImpl(this); + this._impl.componentEventList.set(vqt.LOADING, this.onLoading.bind(this)); + this._impl.componentEventList.set(vqt.LOADED, this.onLoaded.bind(this)); + this._impl.componentEventList.set(vqt.ERROR, this.onError.bind(this)); + this._impl.loadURL(this._url); + } + onLoading() { + Vc.emitEvents(this.webviewEvents, this, vqt.LOADING); + this.node.emit(vqt.LOADING, this); + } + onLoaded() { + Vc.emitEvents(this.webviewEvents, this, vqt.LOADED); + this.node.emit(vqt.LOADED, this); + } + onError(...t) { + Vc.emitEvents(this.webviewEvents, this, vqt.ERROR, t); + this.node.emit(vqt.ERROR, this, t); + } + onEnable() { + this._impl && this._impl.enable(); + } + onDisable() { + this._impl && this._impl.disable(); + } + onDestroy() { + if (this._impl) { + this._impl.destroy(); + this._impl = null; + } + } + update(t) { + this._impl && this._impl.syncMatrix(); + } + }, Uqt.EventType = vqt, Gqt), Vqt = Bl(Fqt.prototype, "_url", [ Yl ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return "https://cocos.com"; + } + }), Bl(Fqt.prototype, "url", [ Dqt ], Object.getOwnPropertyDescriptor(Fqt.prototype, "url"), Fqt.prototype), + kqt = Bl(Fqt.prototype, "webviewEvents", [ Yl, Pqt, Oqt, Nqt ], { + configurable: !0, + enumerable: !0, + writable: !0, + initializer: function() { + return []; + } + }), Fqt)) || Lqt) || Lqt) || Lqt) || Lqt) || Lqt)); + m.internal.WebView = zqt; + } + }; + })); + }, + 582: (t, e) => { + "use strict"; + Object.defineProperty(e, "__esModule", { + value: !0 + }); + e.default = void 0; + e.default = { + imports: { + cc: "./cocos-js/cc.js" + } + }; + }, + 457: () => { + "use strict"; + !function() { + function t(t, e) { + return (e || "") + " (SystemJS Error#" + t + " https://git.io/JvFET#" + t + ")"; + } + var e = "undefined" != typeof Symbol; + var i = "undefined" != typeof self; + var s = "undefined" != typeof document; + var n = i ? self : global; + var r; + if (s) { + var o = document.querySelector("base[href]"); + o && (r = o.href); + } + if (!r && "undefined" != typeof location) { + var a = (r = location.href.split("#")[0].split("?")[0]).lastIndexOf("/"); + -1 !== a && (r = r.slice(0, a + 1)); + } + var l = /\\/g; + function h(t, e) { + -1 !== t.indexOf("\\") && (t = t.replace(l, "/")); + if ("/" === t[0] && "/" === t[1]) return e.slice(0, e.indexOf(":") + 1) + t; + if ("." === t[0] && ("/" === t[1] || "." === t[1] && ("/" === t[2] || 2 === t.length && (t += "/")) || 1 === t.length && (t += "/")) || "/" === t[0]) { + var i = e.slice(0, e.indexOf(":") + 1); + var s; + s = "/" === e[i.length + 1] ? "file:" !== i ? (s = e.slice(i.length + 2)).slice(s.indexOf("/") + 1) : e.slice(8) : e.slice(i.length + ("/" === e[i.length])); + if ("/" === t[0]) return e.slice(0, e.length - s.length - 1) + t; + var n = s.slice(0, s.lastIndexOf("/") + 1) + t; + var r = []; + var o = -1; + for (var a = 0; a < n.length; a++) if (-1 !== o) { + if ("/" === n[a]) { + r.push(n.slice(o, a + 1)); + o = -1; + } + } else if ("." === n[a]) if ("." !== n[a + 1] || "/" !== n[a + 2] && a + 2 !== n.length) "/" === n[a + 1] || a + 1 === n.length ? a += 1 : o = a; else { + r.pop(); + a += 2; + } else o = a; + -1 !== o && r.push(n.slice(o)); + return e.slice(0, e.length - s.length) + r.join(""); + } + } + function c(t, e) { + return h(t, e) || (-1 !== t.indexOf(":") ? t : h("./" + t, e)); + } + function u(t, e, i, s, n) { + for (var r in t) { + var o = h(r, i) || r; + var a = t[r]; + if ("string" == typeof a) { + var l = m(s, h(a, i) || a, n); + l ? e[o] = l : p("W1", r, a, "bare specifier did not resolve"); + } + } + } + function _(t, e) { + if (e[t]) return t; + var i = t.length; + do { + var s = t.slice(0, i + 1); + if (s in e) return s; + } while (-1 !== (i = t.lastIndexOf("/", i - 1))); + } + function d(t, e) { + var i = _(t, e); + if (i) { + var s = e[i]; + if (null === s) return; + if (!(t.length > i.length && "/" !== s[s.length - 1])) return s + t.slice(i.length); + p("W2", i, s, "should have a trailing '/'"); + } + } + function p(e, i, s, n) { + console.warn(t(e, "Package target " + n + ", resolving target '" + s + "' for " + i)); + } + function m(t, e, i) { + var s = t.scopes; + var n = i && _(i, s); + for (;n; ) { + var r = d(e, s[n]); + if (r) return r; + n = _(n.slice(0, n.lastIndexOf("/")), s); + } + return d(e, t.imports) || -1 !== e.indexOf(":") && e; + } + var f = e && Symbol.toStringTag; + var g = e ? Symbol() : "@"; + function y() { + this[g] = {}; + } + var b = y.prototype; + b.import = function(t, e) { + var i = this; + return Promise.resolve(i.prepareImport()).then((function() { + return i.resolve(t, e); + })).then((function(t) { + var e = v(i, t); + return e.C || function(t, e) { + return e.C = E(t, e, e, {}).then((function() { + return w(t, e, {}); + })).then((function() { + return e.n; + })); + }(i, e); + })); + }; + b.createContext = function(t) { + var e = this; + return { + url: t, + resolve: function(i, s) { + return Promise.resolve(e.resolve(i, s || t)); + } + }; + }; + b.onload = function() {}; + function S(t) { + return t.id; + } + function A(t, e, i, s) { + t.onload(i, e.id, e.d && e.d.map(S), !!s); + if (i) throw i; + } + var T; + b.register = function(t, e) { + T = [ t, e ]; + }; + b.getRegister = function() { + var t = T; + T = void 0; + return t; + }; + function v(e, i, s) { + var n = e[g][i]; + if (n) return n; + var r = []; + var o = Object.create(null); + f && Object.defineProperty(o, f, { + value: "Module" + }); + var a = Promise.resolve().then((function() { + return e.instantiate(i, s); + })).then((function(s) { + if (!s) throw Error(t(2, "Module " + i + " did not instantiate")); + var a = s[1]((function(t, e) { + n.h = !0; + var i = !1; + if ("string" == typeof t) { + if (!(t in o) || o[t] !== e) { + o[t] = e; + i = !0; + } + } else { + for (var s in t) { + e = t[s]; + if (!(s in o) || o[s] !== e) { + o[s] = e; + i = !0; + } + } + t.__esModule && (o.__esModule = t.__esModule); + } + if (i) for (var a = 0; a < r.length; a++) { + var l = r[a]; + l && l(o); + } + return e; + }), 2 === s[1].length ? { + import: function(t) { + return e.import(t, i); + }, + meta: e.createContext(i) + } : void 0); + n.e = a.execute || function() {}; + return [ s[0], a.setters || [] ]; + }), (function(t) { + n.e = null; + n.er = t; + A(e, n, t, !0); + throw t; + })); + var l = a.then((function(t) { + return Promise.all(t[0].map((function(s, n) { + var r = t[1][n]; + return Promise.resolve(e.resolve(s, i)).then((function(t) { + var s = v(e, t, i); + return Promise.resolve(s.I).then((function() { + if (r) { + s.i.push(r); + !s.h && s.I || r(s.n); + } + return s; + })); + })); + }))).then((function(t) { + n.d = t; + })); + })); + return n = e[g][i] = { + id: i, + i: r, + n: o, + I: a, + L: l, + h: !1, + d: void 0, + e: void 0, + er: void 0, + E: void 0, + C: void 0, + p: void 0 + }; + } + function E(t, e, i, s) { + if (!s[e.id]) { + s[e.id] = !0; + return Promise.resolve(e.L).then((function() { + e.p && null !== e.p.e || (e.p = i); + return Promise.all(e.d.map((function(e) { + return E(t, e, i, s); + }))); + })).catch((function(i) { + if (e.er) throw i; + e.e = null; + A(t, e, i, !1); + throw i; + })); + } + } + var C = Object.freeze(Object.create(null)); + var x = Promise.prototype.finally || function(t) { + if ("function" != typeof t) return this.then(t, t); + const e = this.constructor || Promise; + return this.then((i => e.resolve(t()).then((() => i))), (i => e.resolve(t()).then((() => { + throw i; + })))); + }; + function w(t, e, i) { + if (i[e.id]) return e.E; + i[e.id] = !0; + if (!e.e) { + if (e.er) throw e.er; + return e.E ? e.E : void 0; + } + const s = e.e; + e.e = null; + var n; + e.d.forEach((function(s) { + try { + var r = w(t, s, i); + r && (n = n || []).push(r); + } catch (i) { + e.er = i; + A(t, e, i, !1); + throw i; + } + })); + if (n) return e.E = x.call(Promise.all(n).then(o), (function() { + e.E = null; + })); + var r = o(); + if (r) return e.E = x.call(r, (function() { + e.E = null; + })); + function o() { + try { + var i = s.call(C); + if (i) return i = i.then((function() { + e.C = e.n; + A(t, e, null, !0); + }), (function(i) { + e.er = i; + A(t, e, i, !0); + throw i; + })); + e.C = e.n; + e.L = e.I = void 0; + } catch (t) { + e.er = t; + throw t; + } finally { + A(t, e, e.er, !0); + } + } + } + n.System = new y; + b.instantiate = function(t, e) { + throw new Error(`Unable to instantiate ${t} from ${e}`); + }; + let R = r; + const I = { + imports: {}, + scopes: {} + }; + function M(t, e) { + !function(t, e, i) { + t.imports && u(t.imports, i.imports, e, i, null); + var s; + for (s in t.scopes || {}) { + var n = c(s, e); + u(t.scopes[s], i.scopes[n] || (i.scopes[n] = {}), e, i, n); + } + for (s in t.depcache || {}) i.depcache[c(s, e)] = t.depcache[s]; + for (s in t.integrity || {}) i.integrity[c(s, e)] = t.integrity[s]; + }(t, e || R, I); + } + b.resolve = function(t, e) { + return m(I, h(t, e = e || R) || t, e) || function(t, e) { + throw new Error(`Unresolved id: ${t} from parentUrl: ${e}`); + }(t, e); + }; + function B(t) { + return function(e) { + const i = this; + let s; + try { + s = t(e); + } catch (t) { + return Promise.reject(t); + } + return function(t) { + return Boolean(t && "function" == typeof t.then); + }(s) ? new Promise((t => s.then((() => { + t(i.getRegister()); + })))) : i.getRegister(); + }; + } + function D(t, e) { + const i = b.instantiate; + b.instantiate = function(s, n) { + const r = s.substr(0, t.length) === t ? s.substr(t.length) : null; + return null === r ? i.call(this, s, n) : e.call(this, r, n); + }; + } + !function(t) { + var e = t.System; + o(e); + var i = e.constructor.prototype; + var s = e.constructor; + var n = function() { + s.call(this); + o(this); + }; + n.prototype = i; + e.constructor = n; + var r; + function o(t) { + t.registerRegistry = Object.create(null); + } + var a = i.register; + i.register = function(t, e, i) { + if ("string" != typeof t) return a.apply(this, arguments); + var s = [ e, i ]; + this.registerRegistry[t] = s; + if (!r) { + r = s; + Promise.resolve().then((function() { + r = null; + })); + } + return a.apply(this, arguments); + }; + var l = i.resolve; + i.resolve = function(t, e) { + try { + return l.call(this, t, e); + } catch (e) { + if (t in this.registerRegistry) return t; + throw e; + } + }; + var h = i.instantiate; + i.instantiate = function(t, e) { + var i = this.registerRegistry[t]; + if (i) { + this.registerRegistry[t] = null; + return i; + } + return h.call(this, t, e); + }; + var c = i.getRegister; + i.getRegister = function() { + var t = c.call(this); + var e = r || t; + r = null; + return e; + }; + }("undefined" != typeof self ? self : global); + b.prepareImport = function(t) {}; + b.warmup = function({pathname: t = "/", importMap: e, importMapUrl: i, defaultHandler: s, handlers: n}) { + if (function(t) { + R = t; + }(`no-schema:${t}`), M(e, `no-schema:/${i}`), s && D("no-schema:", B(s)), n) for (const t of Object.keys(n)) D(t, B(n[t])); + }; + }(); + }, + 260: t => { + function e(t) { + var e = new Error("Cannot find module '" + t + "'"); + e.code = "MODULE_NOT_FOUND"; + throw e; + } + e.keys = () => []; + e.resolve = e; + e.id = 260; + t.exports = e; + }, + 266: t => { + "use strict"; + t.exports = JSON.parse('{"CocosEngine":"3.6.1-oh","engine":{"debug":true,"platform":"openharmony","customLayers":[],"macros":{},"builtinAssets":["60f7195c-ec2a-45eb-ba94-8955f60e81d0","1c02ae6f-4492-4915-b8f8-7492a3b1e4cd","810e96e4-e456-4468-9b59-f4e8f39732c0","efe8e2a3-eace-427b-b4f1-cb8a937ec77d","e9aa9a3e-5b2b-4ac7-a2c7-073de2b2b24f","8bbdbcdd-5cd4-4100-b6d5-b7c9625b6107","50f4348b-c883-4e2f-8f11-ce233b859fa1","fda095cb-831d-4601-ad94-846013963de8","f92806d7-1768-443f-afe8-12bcde84d0f0","dd3a144d-ab7f-41f0-82b8-2e43a090d496","f0416e68-0200-4b77-a926-4f9d16e494da","1baf0fc9-befa-459c-8bdd-af1a450a0319","511d2633-09a7-4bdd-ac42-f778032124b3","5d45aa00-e064-4938-b314-4265f0c2258c","28d6d6b8-3f66-4a73-9795-17a0852ba2d4","ec8106fe-05bf-4e94-943c-e0d3b7bb5e45","620b6bf3-0369-4560-837f-2a2c00b73c26","ff9be190-20a4-4e48-b68c-76e3c7cff085","970b0598-bcb0-4714-91fb-2e81440dccd8","bcd64cc6-2dd9-43f6-abbe-66318d332032","d930590d-bb92-4cc8-8bd1-23cd027f9edf","a3cd009f-0ab0-420d-9278-b9fdab939bbc","9361fd90-ba52-4f84-aa93-6e878fd576ca","d1346436-ac96-4271-b863-1f4fdead95b0","971bdb23-3ff6-43eb-b422-1c30165a3663","17debcc3-0a6b-4b8a-b00b-dc58b885581e","711ebe11-f673-4cd9-9a83-63c60ba54c5b","c0143906-9aed-447e-9436-2ae8512d1b6e","14da1725-c4c2-42b4-ab08-ee0aeb6898b3","081cab31-dccd-428e-8652-f2404cc81c47","78e0584a-4343-4727-8f37-e14e65c2a2db","ba21476f-2866-4f81-9c4d-6e359316e448","871c3b6c-7379-419d-bda3-794b239ab90d","c27215d8-6835-4b68-bfbb-bdeac6100c04","b5d6115f-0370-4d7c-aad3-c194cc71cf98","1d08ef62-a503-4ce2-8b9a-46c90873f7d3"]},"animation":{"customJointTextureLayouts":[]},"assets":{"server":"","remoteBundles":[],"subpackages":[],"preloadBundles":[{"bundle":"main"}],"bundleVers":{},"preloadAssets":[],"projectBundles":["internal","main"]},"plugins":{"jsList":[]},"scripting":{"scriptPackages":["../chunks/bundle.js"]},"launch":{"launchScene":"db://assets/scene/airplane.scene"},"screen":{"exactFitScreen":true,"designResolution":{"width":720,"height":1280,"policy":4}},"physics":{"physicsEngine":"physics-physx","gravity":{"x":0,"y":-10,"z":0},"allowSleep":true,"sleepThreshold":0.1,"autoSimulation":true,"fixedTimeStep":0.0166667,"maxSubSteps":1,"defaultMaterial":{"friction":0.5,"rollingFriction":0.1,"spinningFriction":0.1,"restitution":0.1},"collisionGroups":[{"index":1,"name":"SELF_PLAYER"},{"index":2,"name":"ENEMY_PLAYER"},{"index":3,"name":"SELF_BULLET"},{"index":4,"name":"ENEMY_BULET"},{"index":5,"name":"BULLET_PROP"}],"collisionMatrix":{"0":1,"1":52,"2":10,"3":4,"4":2,"5":2}},"rendering":{"renderPipeline":""},"splashScreen":{"displayRatio":0.4,"totalTime":3000,"effect":"","clearColor":{"x":0.88,"y":0.88,"z":0.88,"w":1},"displayWatermark":true,"base64src":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADqCAYAAADnPAqjAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAWdVJREFUeNrsvQecHNWVLn6quydnSaNRzjkHRJIBg8E2YIMT2CY4vrdvf+tdJ4y9+wzGGOw1a7C9+3b3+f9/G946G2zAZAQIhEAgBBIo55xmNJqce7rqne/cuj3V1VXdPaOZnp5WX7jqMN3VdcO5J3/HqDtTT+lohmHgX5KH6OvY54Z64fvciLuefiFX9vg9/WVy/NVwfCfmGzFvGAnHkbAVO3oZ94n8nbH8WMMdj5Xcq+y/ldrPy7kXcA/Z1+jl3s29jXuj/djKvcl+fYZ7rWVZtfx4gnsL9w67tye7Qf5e/HtxLyyflxZ5vOQHK+Yica8t9/UsxzW8n8d8x35u2TfjNYahaCHKtXNpRdxncR/HfYb9fBr3Sdwn20QRGuLFNEEs3I/b/Qj3A9z32e/vtwks13IEMuStkPti7gu5L+U+j/t8myCCw3RPAe7j7b7K9Tdwl13cd3Pfyn0H9202N8q1HIEMSpvN/XLul4EomBuAW4wZtLlzihdeIp1D1BxAm2j3q23JBqJZnU0kr3N/mfvO3BInmP+cDhKng5TgNOanH+DHW7kvs/WJYIr7ve9nLCtOvjf0OPQjCMSPAPhvchn8XROSg6CMvov2CfeGv/7kIZp12ATyB/7qs7aI1prTQXIE4t5IrCAbi/gNcIpruL/f1i8SUELsVsF6qZ9UdxIIBuSZGrbRN0Z7HIZzkyUgEHJ81rmxZIPguaU2o2ma6h7k75bjmpogky5RmPtr3Nfw15mzWDu07pJT0s/fBrkdnOITPOlX8rxXJhB0YhYFG5ECNjEEmBiMgDwGXARBycSnxKdKzGcTiVtOgjHNCJl4DqLBf6YVe63o85hNlsf9SruDs7zC/VHuL3E/nBOxzi8OchE/fJYfr+K+IJn4JBvMvh0jYBOCdMPmEkZGLq4iaIsipuIwpmkTjeZMgZTue7dwFot+q3SWnIiVrQQCC9RqfvYtfryEe4W/9GRFFyog3CBAwWBQuhBJhhJEcopRG603ElFcBoRjmY75TTguWL7e4Sv8nB9fsBSXyRFIFhAInHOX8qu/svWLBOK+pfVcCoaYIALoAeEa2djAGSNCKKYQTZSzONbJp23gT/6rcBSLTuZ0kJHZYHmCGPVFcA4rgRgiyi2IAlwipIgikKVEEXOIsIgVCqgtEOJJiDCRoPf2mqzIWPx3X255qd2Zo9Cvuf+Se0NOBxk5HORWfvklW8fwNXLirJJNwoQRCoYowMRhUK71RkwmlF4mlF7hMjK3ic+Ljdz/k6fz3/gxkhOxMpdAQBDftU+3Qj9RymK5G9wilBeiUCgkesaQbLTeiCjyI5UbYRNGeAw94bBwloCwFP/h2hzl77k/Ybk8oCOVQLJFjoC3+59JObuuchOH9hNA3gbHKCwspKKiQsrPyxsy4lCLadJ723dRR0fnyBQveG5wiGCu0DF3pq2zePj/Q2IdJPoT9/8iFZIz4ttIJxD4Lb4DZZEX7Cvc85WbrO8/IYyI4hhFTBjFvNB5vOjpsETlMQFCnn/sqRcoHO4duXI4CCWkCAWHC+bSjJi2c9I941aQ++38tbXcf0QqkHPEtuCd3/72SBWxrrK5xn8nFS4er3yz/BwMBqigoIB7vm2mNdInv/JvVVWU0wsvb6D2jg6aPXNanOgw0ggFc5gnnDcgzkgQibZ8eRhJLrM7YsD25AgkPQSCif8H7j8k5eSL17950SAOFOTny4kXCqWXMJzjwmaC/L7+jbflFJ46ecLI9aM4N04oKJwYOpY2Ffv4URDp/BHu07m/Sdp/khOxhqTBwYd4oa9zH+VFGCACbMqS4mLhHFFuMgyntv7NWTOn0uiqKlr3+iZ6e8u2eCPDCFXg0fL5EMJc5+fly3uao7haqc3pQSAfynGQwecgxfz8a7byN9lrscDuwSnAMQoLC8gOgM0IsQQn7eFjJ8SqdeT4SSotLaGa6tGULU1zymAwJOsAjkmO9XM0ZE/CN4XQHuSnZLz1YiRwEFiofs27/SfcC207bbSb8ADzqVVYoE4ybEZFNJkzABgHIFrB3AvL2ZqX1tO+A4dVZK+RPZ4XHFClJUVyQOm1ca8X9yD37/HH/8h9RY5Azq19jPszPK0f1+HeuuOk6mXCCLJcjxMZnEPrGZmkBOt7mTJpgjzH5inIL6DnXnqNjhw7mTXE0TfvBh9WBVRSUiI6F5yOpg7Rj+2IGv4z99tzBDIA0Y/7HTzjv+U+K45rQNfgXsQLUVpSLAuRaYThbhPGVVNVZQX1dId58xSJ9PHEMy/RyVNnsoqL6HUANynhtYFpWK+ZBzeZxB3e9x9DnckRSGoNwvn/5ul7kHuR++SJwFrCGwonlDivhsE6NZBNAxl9xrRJ1NnVLZsF4iCCOJ5e8zI1NrdkFZE4OWdRoeImCPiUKOJ4TpJvKV8Wwukn5AgkcZvL/WHb4uGecVH+oGOUl5VQfn5exnMNd5s/ZyYV4r7t/Iyy0mJqa++gx558gVpa27KOSPoOB16z0lKxKpqOqGFX+yT3xzJNL8kkAlnF0/YoT95VeuNHu4SJaJGqhJXd4Ih0to0eVUlja8ZQR2enhLiASCoryqmhsZmeeu4V6uruzloigb8E4nBxUZGdvBWhuHW2rAt5VR8nleWZIxBHu477U+Th+DNtE65Mbkmxbb61RuQmQZs2eSKFe3ujQX94f/SoCjpVWydEAjEkW4kEHWJxGUsAlmX4+Uxgxkc81+dzBKLaR3nifst9rPtE0fb0sjLFnnXuxkhu06ZOkniwnp5wdOMgs6+qspwOHTlOz65ZJ+PORiLR44VTsZzXFGOEb8iDk1Rw/3f++JfPdwL5iq1zxKW/YpMg7qeyvEx8B9ZIpwy7VZaX0pjRo0RZDzhywjG8UVWVtHvfIXpx3RsqdGMEGCDORS+BeAldEsGkHg2WTFi47h7Oex02Tzo//wtYq8iV1Yi/gzhCoTwqZ+KAcy1bNgnGAaLvYuI4cuyEhGm45wgOz0OHj8ummTZlohIzvUWRET8XGC/mAGIlop2R++/R4C/BBLx6PhHIV7n/lDxSfuFYKihg4igrk9TXbDtBMQ+Qw/fsPySbQnv+oyydxwwiOXjoqORiTJowThT67OMjsYcCDoFwuCeGqzraFTZHWXc+iFhQvoCMUeBJHPmKOEBI2XhyosHkOWl8DYVFD7HiTlY42cA9X3vjHXpv++6UcbZGKieROWGdBFEG0El89inCU76R7Rzki7Zc6SJMS0QKhChUlJfFTFw2NXCH9o5OOlPfQDOmT2Z946AcAsiJj900NoBEMEB7WSeBrF49ZhRleysUQ4xJ3d1hckDlORsigVHeYUM2cpDreOn/f+5Bty8VpwbEqory0qwlDs0Btu7YQ909PaKQL1+ygFrbOog8xApl7cmTRK/n174mFi4jyzkJelmp4iQAjSCvCC6ykAv0pWwjkNU89l9CenCH4wA5AzJoRXm5iBLZSByaQHbs3k+na+slshfjXLl8EesYNdTGROIF7IDPFBcXCTd56vlX6PjJ2qwlECeRQMQuKiqyTcBxIVxAff0n/viNaSEQQdcbgq59FtwRPvIHfjbafRrglECMEogD2WjZqnNg8ze3tNGzL7xKy5bMiwZX5vHj6otXyiGB7tUwJ3CS4vNPPfcyNTQ2ZTVml4ZLhagNE7CalzguAgT+33FfOdI5SDX3/+AxT4w9BQxRyJFgA/la0DKs7CUOLPqTz66lcWPH0PQpkxwQNjwxzEHmzp5Ozc2tfhYcO26rhEWzsABANLe0Zj+RcK8QP0m+AF9gz7g4SRH3X3Gfop2tQ9GHcpZB5axzCEZVTIuYvSJ2V1WVy0JnK+fQ4tCGjVvowKGjdPWVl8boWOIX4fG/j7lIaVkxdXb6x2JhjhCk2dTcRn9+Zq3taMxeIkF4EczbiDAIBg1bJ4lrqO71G/sgHlkchMd3F2+Aj7nDCFReAMnpADTD7NU5FIFAuX7h5ddp6eL5wkHc48VriBOrli8WAkk0H5i7UbxhztSfpaeff5m6u3uynpNgfJUVFTKXEQ0zFNvfxw8A8AiOJAL5FPc7/RYZGwImvWzlHIpAAtTW3s4beZ0YIVYuX+hpodMLvWzJAho3boyYgRPp4cjNQ+IVCO/pF9ZFN1HWchLeI9BFIIonSG9AzNZXhkhJN2nQuhoASpb9SxxF87jC4TCVFBeJZSZbOYfWO6BcPvfiempsaqZZM6bS+LHVCU9KiFqXXLBMghh1GIYPZ7YjgCvp4KFjkrorsKBZTiQw/ZazHhbRee7xB/1DPC+XayllsPpgzyrKlv3CKzI3zAOTQTL3cBZxyVa9Y/2Gt1nvOCah3cuXLhDveCKOib/Bebhi6XxqbE6ePGWJmFpGW7fvorXr34wSVbbOq1jzSkvE/BuOeEYAI2bn3wZbHwne8a07B3N3ILf4Jq/BwSs8elSVShTKcu6x79ARWvf620IUUyaOp0suXOEpXnl9t3r0KNqz76A4E2EC9zeFquI+sPIcOnxMLIKTJ40XIslm0RWieWd3twQ4ioUw9s9I155CCjFlcAjkm4NEIHzefYEUsrfhXkylXFYI0mE2Lx4cemfONNATz74sQYhIL33fJRfQmNFVKY0b+x5cFtcBkWAzuMG13YjnOHjy8vJp7/5D4l+ZPHEcZXPDeDFOAIL7iKKLuLfxLL0xGMlDgyViTbGV8rjrRWxHFyJYs504cKq98MoG6g0rPWI0E8ZMFptSF3vU5xbOnyXcAPnqWmN3K6j6OWz14FTwk7z6+lu0a89+u5hodnrcdcweghvFquUNd/pNUuW7B4FAPHz5/epKGb+Pny1w+jrRsGHykRhTXh6FBc1mvWMdb9CTtWckVAL55SuWLFBI6P04GCIyZ3l0GXMelXHXm/QgFEsPz3MJy+dPr1lHu/ceEBSRbA1LEcepRP8W8vyEvSK2gI5yPw0ClFDAQ9npV+d/bub+ORfRRHGQlA2bstrfgRN72469tHnLTqoqL6PWtjYaVz1aPOQ0gEwOzN3E8TU0b84Mam5tI22g8l0Dm1NrBPunnn+Zjp04lbWWLT3mqoqyKPiFw8Sn+/X8zl+f6/4+1xms5os85HVhcI8yPkmxaJEsFq2AsFJ75iy98tpGMV+D42O8SxepmCufdNKkGwB9NSv3ZSUl4jVPhRmIOFtaLKE7jz/5Ap04WSsEk61cROL4+ADGHFveTsR7+KNzhoeDqO/DajXepaxThMUClfhUkvV6R2dnF61Z+7rAoJaUFMpmhiN0+rTJg2DWLKbLL72A2ts7o/PopYtEQ1dk7iNUXlJK3eEe+tMTz1NTU0tWEwmwgIsL8/0SrVA35mfWOezzc+Eg1/IPfyoe+VARDyJ0A1mYMtvHOdTY1q7fyBykniqgNEZMCf+YP3emOETP9XDA9VF0Z/rUSRINbCSyaGkRw+YkyFrs6uqiR59cI8p+NhKJtmKVS8Ar+WEAX80Pn0u3FauK7+773MvdSntvpFdgbWC1isLgZ6lijnTY7bv2SUAdFqs7HBa5ePGCOYOC+qjEiBBdcuEy4c09PT1RIom7totYQCSIdztVd4b+8OjTwumykUiwx+A+AKBgBGXu4g1JKFzyHbekk7qIRT55W4n7J7lf4MU94LBCrFA2N2y0YydOi7ccnMMglenX2dFFC+fPFrP2YImWWmFfsXSBJFb11QWkOJHXYThRCPi2/+nkqVoJt+/lDZStnASxWnn5+bbpN26/zuP+uYHs9YHIZuP5m98miGeuq0H+xYZRymkka4kDlqXnXlovBwKMEGiIoQJhLFowZ9AXH8S3+qIVVMmcCuZjN8fwe625DPwxQFF5/OkXotBD2aaLQOStqCiV4qI+u/3bPPYZ6dBB/pK/Ottd2xR16vLyQxJ7lL2ZgSrW6bU332GdoIXlfMUpYGpsZzl/zqxpg6J7eG0AEOLFq5axPtEZNYZoccqtizhfm3Yx09FVFbR993569oV10Q2VTfqhUthLZJ567dwR1x4F6sVd/ddB+sdzgGTmAYOiUEkAupCNirkeD0LYN23eSjt5o6F6rYbjgeWqkHWuJQvn2J8ffAJBh24zgxX2JiZOQ8+z27vusGi5X4NIcP8vrdsQ5YbZslZa9FRh8eSXoQpUnX552INf//o3+6GZ0gOkCmnGKkq9Cnl91KjKrPSYK6yqEB05epKeZ9EKYQ4he3OBQJD3sWzxPJo3Z6Ztjx+ae8CGrh5TRTt27ReugBATtwXL8lDY9WscXlD69+w7JOEauupVNnF8cBDABqFQUSDoeVjXkGAkDLKSzm0JP7nJ/QfLVAwModfZGm4NhxSK3Dy/dr1Ez4JYTJs4YNZFgOHCebNUJO0Qjh963bix1XTh8sXirXcr5W5Ccb/WzjVY3V585XXatGWbEF22eNz1fFRWlNpSTcRrM3+Y+wdTjaRKdWYM/uxXuY/xqviEjC+YdbOROHQs1YuvbKBW1jOcyV5i2mWlefqUiQJIbQ6xYUL/LtJ3YcJtb2vv8424xC3P1w4iwTiefm4tbd+1V8aYLXFbSl8rkDgt09uihaplf0kesLfeOkhqysdS7td6/U2l0JaqgvKR7GHVWnxC37Bxs6S4Vtqoj87FgC6weMFcdcKn4YDAqVjO8/3+1RdST29vNE87RkmP0Q7jlXit9KPeyuNPvSgVd8+FSDKJuNS6EVVWlikJxzK99vPV/IfLU2EhgRRZzUe5T3C/D7NuYUGhctJEsstyhUXHptl/8Ci9+fZWCR9xipBK9+ikOTOn0qSJ4/xSQYdIjDDFnDxr5jRqsSGAYpRyh1+EHNwuxkcSUXojpKvfP/o0HTt+csDmX/x+JpmOsRdRyaqoqFj0Y4/9XGZXTs5L6gdJgTom8D9f9vp6hBeqvLwkarnKpuhq6Bl19Q3i70AhyrxQLAKLmEpZCVy2eEEfN0nTBOi4oytXXyT3Bbwsw8U14hR1j+cqbLxM9Eh42+vOnJVx9+cQgYm7vqFR4sUyRZfpA8QuIct/+3/errKbmIOk8HvX8vWmuq+PEyg/lEelsPtnkVNQW4uQiPTSy69LPBOUcNMRLYqNAK/2VOYc42uqZfzpFDMEAifSS9XVowS+tLmpWaUUJDD1xijtjtcILK1icaS9s4t+88iTwpH6RSQ8F4cOHafTdXUZpeyDoxcXF0gYCiQdDxqBvJy0glUyKxYUmv8ZZ9FCIg9vGMGNtS062dK0uLL21Tfo2MnTYld3mkGxEVFjEGNesmiueOyGY/wa3eTSC1fQRCZUAMo5swjdXIQSvAbKJcbZ1NREv374CUln7Q+RoL7i8RO1GaWPiETDa4la7Yh4wEJ57O+vcK9MLGIlbtdwn+FFnUFEUZaVZpXlCmsL7rF95156a/M2QRq3XDK86B7MPSZPGEdTJk0c1vFHbKSY9118gWTWoSAP6WI7Ccy9cX4T0UkiVFVVScdPnabf/+lpCWlJ5kiUjEf+3lkWsU7w99IpZqZEJKYlqcjwWfkgM1ZyvyUxB0kci/I/vN4XJYi5R2FhdoEwINAStTtefvVNCRmBU80ZlSt+D8j7hkUrlikon+GOOcPvz545lebOniG11j2V9BRfYy2rR1XR3gOH6I9/fk5Ek1DIH/0SlksQJebk7NkmAb3LJDFLg84hr8YHlRH9cwONxZrL07Iyju3Yk1Vamj21PLSnHKfmk8+tFRGq2BWurycMjsHx48ZK/cBMGLvWma667GI5sAAXRF5KeiqvbUJBsZ5tO/bQ48+8KIeCP5EYwj1gNED8U23dmUxcXCplZZ3s1FyvSF9+WD0QDvIx/qfGrdWLeBUKiGXHNLNDvNKiBDB0T9XWi+jozOBznkiI2l00f7Z8J1MilnEf1dWjBX8LXCSaM5KCeKVfOw9ACGkgkre3bKUnn30pZo7c7cSJ0wIsgZD/k6cyj0CgHxayog5QC42T4OooOf3x/nIQJHR81JMgwT2Ki5MiBY40xXzL1p1S/WlUVXn0pHGbDcE9xoyuFChRXQMlU0QJ9ItXLpVQFBAJTND2jo/jEl6vyclFLBUtjFySVzdskuBG7euwXJ9vaFQWNGUWP5txWMEatBC+ugTb9Truk/vDQS7mfkEcMrt0pX84xY6R3LGwJ06eFvhOwOYYDiXXmYyEDSNQPksXSqCf5h6ZMAblG+mlPJa3r7zsIrlPVVbZh2u4TL1er2WjM0EgbuuFl1+jDRvfkY2vkRsFf5h10abmFinZjRi1xqYWamtrj/rFMqbzYQbHoY788PjMPO6X9oeDoJBFgZc8l88bCuKVNcIL3qhi9nmSr/3EMy9RJBxR8WRm32aJniK80aCAjh0zWsQrRRyZJV4q30iE5s+dRRcsWyxgDRZZcX4Pt/Uq0WtEJsOPAGveY0+/QO9s2SYHijgIeVKQE4NcebyHU7qVOdep2kwUs1Rp8UJ/tQDnny41HctBfExfV3tdBacUWNVA4WwyiTj69I4NVM9iAqKRY3QKB5FgzyDnY9G82RmdLalF3ksuWiFGBqQAx5hdUxS33AAQUP7LSorpsafWCCSqwgxmBZ3nrbOri4J2ZSz8PmqX6B2XOfNiiam3TKxZvmt3jRfoupeINZX7hX6sXItXI13nAIGsf+Nt2r5zd1TviIpMjg2FDQbugXTX+fNmJixNkAkNh9hYVrChsLd1dOiSFLFcxKFP+r22YnwkKrYJotQvf/cY7T94RN4/e7ZBHZQ2MCCiaI+fqBOrViDD0noxD0WFheJMhfTjsb9n8cdmJeUgPCmXcw95ATKE8vJHfOEbrXcgOnfd+o0CqQ8LTAzelwuxsJu5x7JF85RXNsPDarA2uMeLVi2lSRPGsU7QFqNXkWuc5DHuGP+I/TdcExhU2Fy/f/RJOl1bRx0dyplItsEiLxSQ9xHTlWk5JlJjhPdufoGqeUiGp+c8riJawIwq39Ihd3wpru4uJqg3TEUsx+Vpc9kIJQ4ok7C8oIQZnEhxiPMu/QOxWJXMYRZH02kz27StdRFshmuvuYKfK5TLVHQPy8NiGcOd+DqVlRXU1dlNv3n4CUFLgSjXh0elCgfBN6LuJbPWHpY9RDCLmGWRl8n3NghJiTjIdP7YIjdlqQkwRMkZyRG74BxYwGfWvEL1Z5vE2RkVrTw2C8bdxdxj4ZxZonv5lWrORCLBvU6bMknC4hsbmpTO5RqfJ3FYVsLXmC9EGcC4IebkQF/Cljzlf2rr6u37CGTYvJAYmBCj5QMyV819hSvcPeYTH+AeikurjagSYajuM1I958ryEhBEkv0HD0sJM5FFE2wMmEpxKCxYMDtG7BoJTRM+POyl5aXU2t6ughm9/B4pWLTIIYIJkTDngFnZPSeY45On6+RgyTgxC6UT+L6DTLhmryc8EGTRq53vuTMKr4z7lqEgfULMniR0eJisVwNVjPUCgnsgcw56h0p+sqNw3RtfByVKSHs7zZ8zk8aMqlJiygg7EMBFgIkFImlv6xDl2XL6eTy4SCpcBo8h3gvkYcQJ8OZrbmqJ8ehnkqKO0hJQE5Q1yzOG9wonWJAzo7AYEdxeeSOmbaHQKBrDsdiwsw90wmGWBNt/7Mk1VMAcIcSvddiB5SCkqFOQf6enu4eKWSm9+MLlIxb5w7JDg1YuW0wzpk0WLmIkUdKTvdYRu3m2mdwdp4c90hMOU31DwzkdbEM1HxA1+xzdnn0GD2acFwdZyH2sm6LgLMKZAwvOcCipGkEdUP669nh/Gk4MrXcgKai4uFBCu91iA7lMuzgBFzD3AP4VkopGKqiBxve9grkIqgyHtR6VotLuxUEkV9+Jy+UgJIjiyBU6fuK0HdeVeYcGDAvKNO2Zrz6K+0r92slBFqOmfRz3sJNNFMRm+mVwyLEIp966Yx91dPZPrpXP8mK+uG4DHTh0NFpr28tq41x8yM+obb508TxPa85I5CJzZ00XTtLSohKrUhWnvJT4gA1m4a4oFuX43GHqBTEamQYpJNJQnpj2VTxdHAcp5b4oCvujZS0C7pUHFIo+FXASD4uOCgcPUzw8tMh97g+BgPu8t32X1O5DMlDQ0DheHhvDIUoA3gcBiWPHjBnxGMPa7IuxXXv15YJAAwdiVGFPBePXxW2RRWqo0zMulAV/h2HjzNlGMfdmnKIOK1QwJKJgAmloYZ+ZV42sgD8818t7Dv0jmKdibUz/pJMh66bETIUkpGHvvkOx+kKCDr2j7kw9Pf38OqnSBCNDxO0Qc1tyRPfoltDolSsWy5gj3jW5R1RHg3gFp+j7WdSC8UF0KicncaLEu3QyciHIh2yTsenSP/TnMH9dHZ109NjJqJiXSYGLqAoGf1iCz83nXu0MVoSLfb7fCY54+mBg+FATLRtFHd5vKIAqjiqxUg4w6Ycfe5Z6erqpSANKe5g13RsEYhxqC06ZOGHE+D1SbVphnz1jmiBFGg4ukkgns1wWwahPxUMHceIWnDhVl3Hh7xp9BxXQEmAJzNH0oGOxJvG/E9yI7fjPtGU2GkZYUdyHsO36BglNVxhMlufgdUj2mrXr6Th/FibdGKXcQ2yIPhVuoeoLihk4y1DqJSSeT/cPX3OFiM1dnV19YSgp6B5km78DroSsuO+Yypza1NQsvxnjpMwYAsm3JRTTY9db5Sjz4eQgU/jdPC/cXTzq6M3hHZmSp4GsrvUiL6Uc/g4gmG/avI1GV1bEignkgxElGUIG6x6dNHXKJJo+dbJdfjm7oFQxfxC1pk6eSKtWLqHmtjbbF+QK0iSP13YP2oaPmOw8D1tQgGX8ru4esUAabgdlBjS1pykRGPUcxUHU61k+gNXRiw3rZrH6lL8DB4+K8hf0gKXBfR49doL1jrXiwwjlBWMjWZ2igFssgOe8N0yrli8SQoukGesqnWZfjPXKyy6hctZJsIH7io3E6i3u15KdZ3NoT31Fz6n9OcRstbEukmnzqP01WvTzoZGpFs4D/jSyn6Z52btMO6sslAGhy0p8Mqirp4cOHj4Rxc3VfwNxdLDe8ccnnpfIY4RC6IKinolCjucQGVBzAwUzgQ7SO4L9HqlyEYie1159BetcnTFVcslH3IrqHzh5XRG/XpxEnK38OwDYzsSWxwQiRhjL9PMYTudeBg5Syn2SJxUJgRh8WgeH1RtgRaWggBDrvgOHZBPr1E4NcvbEcy8Jsgace70R0xfh3G29QhgJYnMuWLYoo8AYhvKwwfytWrlUDoSGhqZYRdpDF9HEFbSB9Tx1EFcEOLC6kEuTeVxU6VIw91qmLzgpaKIEswIX+QQ/61E+6keApQ4zgolOcoFoVXvmrDiidG0LPALLavO7OyQIMZov7mOtcm4AjK2VTzmgE86YNkVFDmQp93D7RvD4wasukzntYk6ifSNeAZyWdhCSt/HCSzzHdxDeon8zg44IkUbEXO1vh0F1oWJYsUoEoNqDzcikhIJRz+vwn3ym2NhRkwOo61rvOHD4KK15eT2VlRULl0kFSVA/D0d6qbcnTCuXLBRTcjjLTLuJiKTXVtgBX9rQ1KJCwA2PQ4U0WHdQupVAxIq1FhkCap15HFQdjJCMTCviJ2IB+G0sOEgNv8z3YjOmpbyOEj8/nCbP6IKohQWiOaxZqBuOmKk/Pf6ssH6EMjuDEOMqMLmUdHiDuzq6aPyEGsmbMLNctIoTNexSCtdcudrOPnQFMzrn0LYSktvA4aOs6wSlNpuDZBoUEG9qSZizt5Vfnxzw4x7aGhE6hyjaQddD4JfhTYzc4ua2Vtp/6Cg998IrdLquXoFMR8w4jkEJOAg8653dPXThiiViIes9zwgEDTkviG79wPsvpY6ODp6DWAuWs/npH17cREzCzG2AYwyjQCaWeQNCT5LyB2MDdhaVJwWBZ6A4u9OKMVzkoTmI3JuhwOvWvPQa7dxzQFAAe8XJ561v+CnpENWqR1fRgrmzsrL4aH8U9hUsYs6dM0ugfNwidZSD2OXovHwacTqIrbMg8xBhQpmo1yHkxDKMRBykBmRd7Suncg8FM4R7WORZNUl8NG6Y0ESh244aHy0sUgAIDqH8OOWyXTlPpLDD+XfDdVeL4goHX8BR+1CDyAWc/o8E+oeee4jmLa2t1NjYkpFzi/ApwyVtuFp1iAc6KskU9p3gw6VR4S48gucQTwPQZHCCgG1atGyveN+dk6pnronG9p9AnBg9qoqWM4Gcr9zD2aDPQQ+56vJL6ek1a6mmenRM6YeAPZ/uzEJyFhH12Dm9LMKBiwy/FBK7paB7GSAQQ/n7fMh3FESsUd4+EO3wGWbZ0d7lpu3QMRzcIWJXbJU4MSdydxIOgmcIab/0wuUCVI3NcT5yD/eJj4PisktX0YTxNdTQ3KrCShwcV0JMPPQPKwkn6WARSy9lpnFPjVviI2JVQesq9fpLX02MDFtElzVK+0JMDzNjjJnXMSkwPaLsGIISMx0ILp3nEMRMiJvXvH+1YIH1hHuiXvFkxXS8CMaQ67IegrolInIZmTfovjPTq5fiiCj1+6uhqczKDOIgr/p7wI+1A8/8qro6+KpwGpxoSxctYO5Rxpuih3LNYdljkXX5kkWimzU2tUbf1zVCknEMcotf/H9TS6u9H43MIQxL3Y86G30ppBSie3kiS1dmEIcKoVY6SKz93bTNiYazQIqDSExXQlQn6ytF+fmyATTUf671tXBPWPwX133oSnGcQr8znEF9SXwfbiJSJevaRRcxMtDUq2s9+uz/InCQisSVojMmkj9WOXRwBLLD3MlFHLqZTu7R2UUrVy6lsdVjzhuveb8OV55LiFrja8bS+993ETU0tohjVg5ah7PYK2vRQ8iX78FZ2JWxep7pFhKdPT9gw/34c5AM0a4sGyDZWZ4gWhHJgdbuRyQSVsIEAXHsohVL+sybuRa/ZWx832uufB9NnjiOWlvbo9V//U9if4JBlqYyhGSeacKyjES+wjzwvHz/QZvDzz8sG43dCHhyEL2gIJCghqJxchhHJCqCEhctnEs1Y8ect36PVK07mB9goX3ihg8JgiKQZVLiGi6CweEKjDFU58oYKFK7IpIVI5d4tiCCFQ1vGVJAu4c/itfWMYKCQmHGKuLUFzMmxSY1IBzFw2Xq6NWLL1gWfZ1riYkEYT2zZkynieOqVZyW60DxA4hw/j0YCErYe1dXpgUtMueIAI40SQUyPx1DGSBUzu5wy1iQZMWza8aLTU4i0Mq6Biyz7AXFdxuammjJgnk0ZfLEHPfohz7S2twiIlZefsiXczjnMh6r1xC42pbWvrD34XcYqrx0EyBAsr/9OVuI77UnoSxqZsJgjL66d07zg+teQQgBu7i9EIsNMgD2HuKT7KrLL7ZNmZEcgaTIRU6fPiMhOfCP+HmcExGNcCL+O0q1ZaKuZQoMkO9HIvhTRyITGOziw22GwykkMVcUH2vljt4NOu31Nu+DFWXO7Bk0rqZGmRtzxJFyq62vF44b1MlUbnifZDoIqQy+FvGFZBIUqQ08QQkdxb0QsVr8r2HJ6UvD7G12chCvOnr6NWRmBNsJbiwyAwEc0N0tf7tk1TJJ1AesaI4+UptzIZC6s8qE6FU6wU0kRrwrUHEQU4IWgS7viJAbxkNXVwaORInEp3VDxGpORGXIFzDd0bJpHowQiBF7KnlWZbUXBMjjOPUkDqijk6ZPnkAzZ0yzgeByzsFU5hzIgwDfQ62PoqIC74BOx0njDmSM3UXMxds6ZUMiOny4DT+GXadQHf4JAwI6EazY5usehLmPN5WZAfFKeTY2sA3V5V3e2O4CCSS6SK+ANwDZXKO851pqDSZzAGA0NjZJXT9PFEIfVEXL41odXZ2iGxqB4UfI0YaC7p4esgIJ80E6ILe0+nlJVLhyZFhh7KMFcAA9JBG9pm9SlBNcACIZwqynTZlAC+fPURwlxzr6s4sEgFr8Fw5LYcL4Ch+CMXjturtV6YVMySxUOGi9ffkg3r0dd9voL2AR9bCIhWo8RmB4gRsQH2RSAsJwLaIk/nR20+qLL7Bt8TnlPOW5tjdxXf3ZeH3NTQSJFHbtjua1Q515QJFmwhpo0zP2dpK7aYCjsNEfFRwiVo+qe20EhgU+UmcLlqKAj6niqSwXKIPlQkjEoLEgM6dPoSUL5+WIo58nq8IGM6murl5EW090drcF0Q+dH7gGISDRdFFtbV1GjE+QM01TgO0A3pDAUdiAo+JMAi4rIhYU9eGSsTRJFhYWepYv8MNwgvVq1YolEi4hE5FrqesfQZUqe+bMWQG79uQQCfQPy0PmB8E1NbdSJgS/wtaGQxOwR0m29Rko6WcSx/Ja1NMT7ssNGTbSp3iQZReKRh9ItTIq1J9tiCqJudYf9SNAjSwOAdzaICM1QkhQCkHvo7b2zsywIBpKdehFpVsjYRx7HfjL6cTQJyS+g+F28Qj8qdMU78fmScWPoZb3jt37qbGx0a6OlVPQU7XwiPDd0CROVXJnAXrA+/gq7tHPmeJobGtvG/YMTsF05v+QMWmZZjLYn1ocrSf5adiLggw7I6y9owtRWcNqgYCTT4EymPHo7K4kHalpkp9PjbzIO/YcEIdhTgXpr4JeLzJ2FMnE8sGwdWUYelcJg9gWEr+KirwODNuBpRJkLZUnHzBiqmx59ONQ0tv8uIgeRGdnp0Q9DjflW2T5+j/c3ARKWH5hPu3ctc9WFHNcJDX9Iyim3SPHTtrFiLzBqd0pt8k4CQ44HLTAAwgMoy9EsLCYYjvauxAoktDEy389DR2k01JcxDeXsLOnR5nEhpFAlB5h+BIGeVizCllBB27viVO1AqGaa6lxkMbmZjp1us5GNSFPUSoZ0bg/G5Q6k91MJO3DfNCSOI/BQazE+sdp3kMd2HUIszye6OSOhBX21HAMTJ/6Ou3TchOGQx9xn1rwf8AC9+7WnSIqBnLKekqcurm5VZKcgs66MCkQQdxnqc/4CR0EewhJa8Ywj687HLYNTwnvBDTRjjQ9KBiH/cgIFg2EvKuEGRpWytdxVKaTg3jB9etIXpYx8/NDtGXbDl70luGvlDVCFPSTzHHDvSrw03TijSVQ1r2KeDo/qwvqSF7IMOWE6PqEAA2M9Eb6EHu8+yHAp4Xs7XXAn+VK2hSz3VaaOGGcqg+RxsFpjhGQZKhAjHJOPvKuE5kcFiyciIeOHqdlixcoMS1HJL6HEAji5OlaicA1dGVjBzewfL5oeAQuutcH1261K04Zw7AOyoIV4P2gajPmBYxEKbdHuPcGoi8s6vWjpgAp6BbJxBsG8C/LFrFCdtqtZ0FOD26isXuRIPXetp3ymJOyEm0glVwmISZa40ugiPuJVX7WLgGRa9Mgcv73gbXO10U2B5lAEDDZ2NRCKjfFSATks1cYhL2xWEm3ar3LQJsSByX15pg1BYfJAuEuHOkWqdwL5eYiB48co5aWNiaY/Bwl+DSEhACJXc1THplWYkVcuQFiS0L7WkNhMoaHvkUTSCBOUoCOWFRUJEBzR6NWtME7kGGyxvi6e7rs/CLPEtD4r11owlEGeg/3nYlMYz3hiKRNYpDpb6pkVjAQiK9O6+IY7oUCWy8pKRLHF3SRQCCQE7ESWLDq6s6IvwLA4ImsV4aLayTiMiKa2ZVvUfBIMhQDwZj8HoDUISxo95799KfHnpFIWxS4GewDoIXFq56eiJJG/D+6z8FBZIydfKO7/YMW1WSA+ocj2cWSWu0hIU43wrvlVdbZBdEPVorvb353uyxOTln3bydPn5E4NuTUmK49YDi4hpez0BOa1LEeiIZo6+gQc68+qGApA9eAj+T5F9fRr37/GI0fXyMp0hD3BnWdAIPKBKoQbYxEQYq7NAcJOU6A7VBKQGjxG9SkvCBTX6saHOoEhpH8kmb5OOCIvIyhHkpcwhhOw7KSEjp2/JTUWZ83Z4YQSq7FG0RO1dbFFMkxHBYpZ5qz4W9q9DSeGCKuBKTiFDACykqLqbi4WH7rnXe30Tubt0p679jq0XTlFZfw+yoddrBELBAkTLutTCBivk5cUnCHHmDAcRJs497ip7MEQgFxriAJKahLV6VTxLLDXuKK3JNHyLWHjgLjAtj29l17lDyc09ZjmkamPNvQyEpyXtRS6cQ6TiZKJfO0Y/1Ql13hAgTo7NkGeuyJ52nNi69ST3eYQnlBwUwuKy21geaMQSN8iFTYu+h4bpJ/FiH3Hfr2nbhY4CAIfR+VSNY5y7I8Sp6l02koN8pECeuGZ260h6PQioMFsiSnZOfufWKRKyoqHDbnZyZyDoigp2vP8Clezyd7YZxJ1z2fXvNmxUs0MUQCogOwRiuL6lve20HrXntT0inGjB4lyvOoykpaunihhKIPdlAjjAJNzS1y7XwJ4fc94BEC/naU8zhIp5XvaWei4EZQHkyAXTyYUJrleF0P3TLJNyjOVx/RKHnYBKyE7jt4OAoyl2t9IuzR4yfFgoR5MhMgJqY6b86TOSw1JE0aM6qK3ty0hV5Z/4asaUVFmQIV7+ikC1cto/LywS1opIkfuR8Q4UIhZZ1LsM/h8jgedXG4NtXLib6JAXV2wgzYLhGZ6dtg6jRRAYtmSiJVnE4ioSeKyDa+/a6IWzGhFOc1cah1RIKU7B6HIcZwOQGJElSVcopUjoxCuAgw1zVjRtO4sdUS/oM4OVQrRoPiPq6mmubNnjkkqJdBW38W/SNgJAtxfzWmlLXrWmv19Pia9/jmwUU0waRVxAJrNE3vWCy/91w+EViwYEo8fbpOoG1y4pWSz9FQThtA1aZro/vpm3FWLMe84xFOOSDLVLBOMWlcjRhK8B7Cf6QqmI0iH+7ppeXLFonYO9jIM+JL4cd61q0ifiH7sXv8pZjvu663R9t/E502ZxubBe07fYquJZQP2zl0Ca8021R0EhXhmy/3vnP3/n6JC9mtoIeota1NctDh/4jjGC5TbiIDjWlbDUEIKDUxoaaGddbR8rewrVvor6tiql00fvxYmjNzmoBcD4Vojnupr28Uf16S9W7iW9sUY5wy7QQju/fyAP4zkWyPH0F+SCMTiT550qOEGCouLJmjEONwEYVThtYnCpyGwEXKiVlqTmB8aWhuVvkSKZRX89L3wBHCwJri/1BBeAJzDYhREJsiHmZV5KmDY1xy4UrxhQj2wSA37FHEXiEGTO+fBP33/JUYpFGvJIkXE582CDsxBHFvXM2YaIXZoRSvwDWAyBcS55U3yqPl4dH1+xw86ydPnqajx07QbD65cj4RorM2Bla+HYrjhnYlLwuVYgOqnASAoPnjMNFWVpQLp1YEENGlCuMkkc6uTpo2bRLNmD5ZLIqDbfQJ2PoTfDu4v4JgfrLf+GMcOr0HFR3hvtlKAOOSx1QJUDGU58oPDW0ikkQkmyq5Pi8vqOo5UGLiiFEkPbgJQhraOzrFs54JWLHDzT2U/nFGlZkI9M9CJVyDDxic1OPHjmElfIzEvmnIWj+JBusA7nHB8iViPBkK1Esc5nBMQrcKBYPJuMdRW8WgRDqIHCbc1yT+YZWIhB9OX2yToTzpCrPEU3xK9F4sa49QeVkJvbttl9jG8/MLztvQE60snzxV1y/LpGUr4fhuZUUFTRo/jkqhhDPHSFacCL8JkWfG9Ck0fdoU6uruGnRdUBtksEcR/QHTdZI1fpH/XhunUvh8+HXoVIl+HKdEbe0ZcfCEhpiL6IGJ8tcbj4bnV93Ij3jQYTE5dbqWtry3fcjvP9MJBI5TgDQYKUTPGvYBg3UoLiikiUwYSgk3UoJ3NezMQnCN1RetFN8IRLHB5x5BMS+fOn3Ghq1NegC+4rXnAz7sZgP3LQlLU4UU9m1tfYOYS4fyBNZmx4ryMqlSiwl1c4ukjkPXZ3ANEMm2nXtEhDtfAxixkVra2qR+RyCFU7wH/iPe3NWjR9H4mmoq5LV3VgBIRhxiKmpqoQXzZ9N4VuKHIppBodPnUT2rAUiWy88PJdsfB7i/4WmU8vmNBt4qTyeyF0MhA9s6euyUeCl1ofmhavCuXnPlZXTRBcuoqUUZGpyQmP3hJroVFxXR3v2H6OiJk0OSoJPpTTsBjxw9LhG8QHH3W0PNNcpZCZ/AXKOivEIMJj1iuk2dA8BaNm/uLLry8kv4hO8Z9D1j2boHOMbR46fF+mnDuyXqz/LDfk8OmyBU43Hu9Ym8jmBdQOBDiHRBwdBuMLBvWJ8+f8snxePa1t4V5VyqlJaZVB+JFy8MCZvZtefAeRnAqJPQEOWsLIXxJm+8D8JAHNy46mqqGTNGTMHh3rD8zXBZDRMRYkNjM02ZPJ4+et3VMtdDYj0U7lEgRiQ4tPPzgnHh964O2Ks/+7o1EvzUVrsnHDicd4ePnRDlLG8IZXn8FhJ5YFe/7dMf41OsRnIIysrKoh5xL0JJJl4gUQehJ7h23nnGRUQfYM5ce6Y+ajF0K+HY+lDCx48bR8XFRXLqm/2sEIzfQZrr+HFj6caPfFBO+KEKFIXTE2acg0eOq6Ta5KWn4Rhf63uIJiYu+j9J/i6iFQZ/uu7skG8wsZ13dlJVZQV98bZPUnlZqRSYhPWkpKQ0qmz3h0gK+LQ5fvKUiFrnm7KuS9JBJ5DDzeoTp9CLCgpo3NixNKqqQgglHDXF+uTgeITzCs5WYxONHTOKPnHjh+SAG8ooaojKDQ3NdOZMo4wp2f7l/gfbT+7592Tk9RR/7GQi6S0YNOTkOXj4mMADDbWYosITOqimegz9xRc+Q/m8yA0C6RNkIimhUpaR4efQhJKKMoeZ2PzeNhvU4fwRs3Da1tc3iE8Ic2baXAOcFZ5wzDHCRRArFTeXlpdoFeuhCgiCSKs4DsE5EIs1lMShrsvc4/BRilgK4jSJ9tHO/T8SfSZgUcL/UJ7tJ4mVdeV4g8wHuMrCwqH3KWgiAcv+8u03S7Ya/Bm62CfCFjShJNNFDOEi+bRn/0Gx5JxvyjogfmCqD9gJZaXFxTS+Zqx4xFE4KewSp5KurK0QB+z885LSYvr4jR+mUaMqBfRjKF0B2Hunas/QidP14sm3kgcn/js/1Cc0g6fw23/iK9Ul+hV4YHGSg4tApg2lKb4JRDJt6mT6wq2fFDhJhDNLVVVTAW2jpgi4ihb9vAjFlNCTYokt27lnn+BvnS9NUmxP11EXQkyYk9aMHk1jqqqi9TPUVFmJKcGDiygPdpsEPt54/TU0ZnQV63hDCzmqi/4cOHhMMKn7YFN9ewf3f00mggVSENKO8z//nuiXYO6DotzMJ/DhIyeogDdmunwKIJJ5c2bRrTd9VEQFdRoGogq75ihOQnHrKFqs2vzejqh1K5ubQlhXka0IManm0x3iVBFzD3AMd2Chm06sBCxFOIeg3wTpBharYExBxO5QEgfGg8Pw+Mk6qmto5Of59hgSUggCEw8nJbxbP/fFVO6hna95Iz+WJLCuycZCFSEkv8A6lI6qsvhd/M6UyZPE2rLlXeUZd/plNOYSCERvDDeR4H6Rcjp3zkxJAYXfJVu5BsYKU+j2nXto3/4jNKqi0gZ1jkTxao3oP1oUNfpk0pg/9b0huFOdXfIbN1z/QZo+dZJwjqFueXYF481bd9rEH0omCzLF0vf5cXdSArnl9i+kJKpyX8Z9cUJ5jTdhO5LymWVPnTS+X9akgesjZHvGIzR92mTKL8ijd5gTgKO5RT2d54wJBQE5CQWE09TUKt71xVLXMJx1hIExA0kEcVBPr3mZ1r++ScYbsDF4+w55w59AfIgEoBhwNoZ7wvSR666mObOmC3FYNLTV+7CGGMP2XfvoxKk6KiosSEVTeoH7D4koqYczeGtqBAJt5xQ/fop7YaLNCicSFOaqqgqqLC93mAaHdpJEpGIimT1rhry3dcduUdQUXCnFORE1R3ESCu4fVZBWrVwW5YAjPaFKjxUiJsaIAM0nnnmRjh8/JaE7Gs0kliD6x0VwfYTKg0Cu/9BVtGDebBF901FNCoo53Axbt+8VNBblRU/4FWzIv+Ob35GSbpMigaAd4w7056UJLwgPKW+sZlaYp0yaIJsOytNQT5STG8xnMQkLtm3nbiouKvb9bb2AWiTD5J6uraeZ06bQxAnjo2LWSCSSPsTCApHPDx85Rk89/zK99fZ7IgqVV5TFwf/HDtNw04vne4I3xXPdyfrfh6+5gpYsmi/EMZiYVokkFqRhv81idWtbB+u++alkLiDf6bspK/+33Pr5pIEqjh9FAsVXEnFNsBo4aJqb2wUoGkraUGSK+RGJPvXnMZHAaLBv/yGpV+gJU+PQUTShkI3fiu/D1In3hwJIYKiVcHBOeL67unrotQ2b6NkX11FDY5P4JMAdTTvHxp9IDPJgKjHil8wNzzeiga/5wGW0YtliVY0sDcSBNcP4Dh46RnsPHKFiAECkltoDjnA0dQK57Qv9uS9gBiG2+aJkGxWs+/SZeoF5KWdWnq5NpokE4tOiBXOpju/hwKEjYsr1Ig53K0YYPCvrW7fvkiBMJAApQqEhCcseigauIUo4y+V/fvpF2rV7PxUWFVFZWUlUZ9Ob3kUGDiJxqeFuUcueD9RdufLyi+niVSskrg26YDqIA1wRfqs339kmvisV0p70q49x/0m/zMf9JBC0nXwfn+bHMn8uoiwaWtSaPmWiyhpLw+Q5iQQOwPlzZ9GRYyfoKMvcpTaRJDIcaBwlsGyUTNixe69YRZDzADk+IDW/I8NerdXL0or7hkkb3utnX3iV1r66gfUyU7CmtC4WP1nJuYhb/BJxNmJJiMplq1fR5asvEuJIh86mjQ0Y66bN22V/iVMw+VfhpcS+re8XgXwWIlb/WrOt6Fyb1PzGShNC08PhCE2cOF6VFU5T06IRNsyCeXPo0JHjEnMFT7GVguyOBSgrLRHn45atO8WJCFGxqqqSldvyKEcZbkJBLguItsTO5tu46V166rmX6BiPVYtTblZgxBGIHxeJV9i1rofI3NUXraCr3r9aiANznY4wHeXXKuT1OEgHDh9j8bkw1a8+wDf/SH9/L/jZ2z4/kPs8xP2D3MclFbV4QICzRGAhPKqDiZqXCpHg9xDMCJ1ix+59AlkEnSQZ6IN6T4kryBs5y/I7kqu2bt8tn60ZO5ZKSxVH0f6edBOKFjUKRAk/Tn9+5kV6652tEmFdWVEaU1feSEokyRV2XWkYOR0rly9ipfz9Mr/o6SAOlQlaxGJzA23cvFVM+cHUynFgv37VPtzTQiDtfLfQRz6CwzbBiFQdCD5x6s420OQJNWKnDqfRfKo5SQWfposXzqXtO/eKGRr4s04lPdGiiEKIjcgLgizKHbv2ipMNaOFjWfSCCINLRNIkQlp2Lg483zAovPTKG/TcS6+Kk7aqUivhlluSitn9hoeJnlIQtQBuvXzpQrrug1fKwYDgw3QRBw4rcO3XN74jAZQQrVJIpcUHvs+DWTOQ3x0ogWhdZJlt+qWEVq38kORuYAGnTZ2YNtOvm5OASABQtmnze1KvG6dRKhG/TksXCBwnF8JaoMhvYT0FNVNgrdMcRZubhyKVFNcER4Nzb9ee/fTwo8/Qvv2HxaKDhDKdBGXEyk9JOYYnF3GIVRowcO7s6fTxj35IQYqmkXPA6IN4sY3MIWvPnBWjS4pO6PU8hL/hAQzIwhL8zK2fO5d7f4s7LlCUeIAkgWs4fSDHwz8SsWOl0s1JRo2qomlTJtG7vLGR316cIG7MT+xSJuGgiGoIrXiPCWU7c5Xurm4aPXqUWO0Gk1D0fYAwQdSnautZCX+FXln/lqS74veCro1qeMhKCbmIjy6C8CEN3Tl31nT61Meuk3GlDxnfPhSYW4Jz79l/KGpsSaF1cr+ZVCTIgNpAlPQYhZ0Xr9kWtZIuMkyvJ2vPUCErWQrEOP3hHPjNcTVjaerkibThrc12oFtBSjqJV8OphgVD6jGIZOuOXeILwG+Usd6lrHe9UcLqb9OBhdggOFRef+NteuKZtQJ8V2Er4bpAJsWZYxNxEcOHs7itVwEBP5g6eQLd9PHrxLeVzrIRlmUIZz524hS9tWW7cPBgMJBqeZoH+D5/ey6/H/zMLZ871zG8y30J3/G8pD9mqBTI47y4o1lWxmnePQxBgRANgKiBakab39su94SNniyH3Z+rWOI/QbYcciBQgwRWry6bo8DqpeLFevu5OSxBQS8sKKT9B4/Q40+/QO/wJoGFDcQRhWJ1KdODRSQQn2CtmjRhHBPH9TJHIP50GiMgOsIo8Nob78j9CA5BKmUADeNlUk7t8LkRyK3nTCC4W1SnAhepTPZBKJfI3ThxqpYmjhtL5aXIMgunuSCPAiKYNmWybOCNm7bYkx/ql7jlPunRQCTgSPAuI9QFohyeKySQ8mgt8mQECFs/TLcQ25589iV6/qX1YiCoKCtjgsmLgnjHKdsUj/Np+IlaXhYt+/2gEaSGpiZx9N5y0w1UzPoNQkhSyPEelCZ5OogE6O6hl197SwwiEIfN1FhHE++nv+DHA+d6H4NBIGioTIXUs2tToSZsxC4mCqDeiWWruIB6wum1bKEpIpkkot/mrdvFb5OXd27wRVrnwGkr+dfMrbbt2C0mZpQZq64eHdUZ3JWU9HN47rFL3922g/70xBo6cPioeMFh/zeiplvDwxybgIsYho+OEk8kKJaKMB0Em978yevFSofI3HSlI+MAwVghUq5nzgHwaRgg+rEu8Jb/12DcS/DTt9w+WON6iwcwlR+Xp6aPKMj92jMNNHXKRMl9TieRqIWwpFgkfCR5zNneeZdl3KKCuFrwAxG7NCGCE8AHBIcjlPn3eNMDQaV69GiqrKwQ/QKEojcFlPDjJ07TE8w1XmV9AxHKyHMx4jIwvL3c/lzE8BC94gkERNDE+hQ25C033yC56eAc6SMOZc4Fp3p1w9sS9lNaWtQfvfAZnve/IeXMPncCGQQdxNle5f5R7tUpKbhMFPBJoP76ZFYCAbzQm1YfiZ1dyH3unNlSBgz6QzEr3dCXzCT+kVSJRtvwsenaWpUfZcfOPdQd7qFRTCRVlZVyYHT39NKGNzeLww+I5FVASYeVTUQyr1Dz1IkkoS5iXwA1WFpb20VEvOkT10vOf9sQp8q65wz4ajhUYM4FxgEOF8NIuWYsUjI+wfd7drDuabAJpAtKOw/mFkrkQHQ0ON/qzjZKTvg05iShYLqJxLBjxEiCG3Fa7tyzXyxtgUG8B8uG98PmA6dA2TF45WEkwHjDvRH6Myvhm7bsEAcYcjUMhxLuTliK4ycpcRF/IglIHnmnWIg+/amPiCkeeeVpK7JnWzlRQ/DNTe/S/oPHxArYD+JAu1VJMkSD1YM3f+b2QbuY3ZA3Us/vXEcpJpPBRwI7OzLdJk8az0QSsOtKpI9I4AWHbwPJPqdO1dLeA4ckROVcuYefjgKOgXHDYHH46Enas/eQmE/Lykv6cIItJ8dIEiuVqi7iobAHJRO0S1BMPnHDByUfBoljlCbyAIcE7CnG/faWbbTvwBGpox4IpEwcMKJ/nx//z2DfW/DTn719KMb8Dvca7qtS3KJyakIfUfCUE0XJheUirZzEDpNfOH+OoIIfPHpMsJwGkzi0EqryGYpZvKpS6JChgJ3dSAlNr4PNRYQ4WCfCAfGpGz8s+hh0Q6cxY6gV8kLxbYToDeEcR8Xv0U9r2SN8t985V5NuOgkElL+R/72Qn05LzVJMUoznTH2DpFBOYU4CuT2dyUo6JAUmzUVMJPuYi5xkbgILUqohKYn+rnGEIUaAKIqKi+xN4uCWXtl7XkTiA57QH6uWIFUy10I81w3XXS0ipuSRpylCWQUfFouhYsPGzUIciKCO9+8kbNt4MF/k+60finscMgIh5eZfy+O8hh/HpkBQ0gDZAhA6QJlOmjiWSviUTTcnQQopgOeWLJxPu/fupzPM2YqLiwbsI9GgEjpkAv4NQV2JxIJauC1L8e8l10XimUY8gYjOYQSkfkZndxd99MNX0Ypli6izsyNtMXLi5ygqErEOfg6ImUCON/pHHMf5Vq/nwR0aMrTGRx5/bqjnAgGNr1ECyKB42doQfaSivJSuuvwiOVVgYUpn7gV+C6c84sd+9i//LumqqInhxIxKhTC0OCVh88Ulclo60V48s/ccrMAjoLbfCrt8w/GeVH7lQwec+toPXUGrL75AiCMdep8eNw4++IjWvrpRwtf7sh1TvhRCMJg4EtfUPGcOcvNnbhvqvXaah/0eP94AKSrFaZQYI8jGhw6foMqKMqoeM0p8AukKcNSVkBDSMXvGNNqydQe18P1oTpKKZ11jNAFYG5xDJxvF6QQJvNzeXIT6b/bVBGfrWtAzrrlyNV126YViuUtXqiysZODOSH9AmD5M/GVlxdTPOpGwlv4lj+bRod4H6SAQtH08N4iovDFV0wj2HxRmhKEgcww+E4SUGzbKeLqIBDrJ2OoxNHfWDNq0eatA2xQliQDWRACiwGaAzpEII8w/B3zwuIhhY1chcPLs2SbJI0cRm66uzrRwDowfa4gclgOHjtK61zdJGEk/wtad7e/4dv81HVa2dBEIGnMRq5UfP9SPMyeKvo4aJGDJEyeME3NsuiKBsXjgJDVjq8U3gLgteHsLPaoxKeKAuTifCaOM9SnNbVIvT5aUSKIEkTgD0EsXwW0gj/zSi1fQNVddJuOCfhewqzAN5RxCxIRZe8t7u+itzdvEKanCR/qdpvEjHsvfS3JjlhEI2hs8Vy39IRKdLAMHIrBXgVtVUz1KHGk4DaXK0RCefvra4CSTJo6PEgmUy8KCvjD5iO1sVOJUiV39N3VkSX9dxNuilZiLxOodOokKFsKLL1hG13/4SgrzeIY6G1CD1hVL5mM3vcpcA/kc4MBSbsHsN3Hcz0O5h0cU8cqAzAYCQXvTHtnl/RkhFhl6CRRLIJSgjPMY1kvQICJ4ncKDTSTYVJMnTZQQEFSlwuKDm8HygzDskpJyFgvz+0UYqekiAzf7gjtokIXlS+aLI7DHRkEcauKAiAwRCpjHr6zfJCXRxIwbHFDp8H/mfhfy3vqIPw1idhqsWCIqaSh9x7wA3e7+gWxW5FmgRt7cWdPoguWLJAq3PQ1Ql/pEhF6xdt3r9JuH/yxEW1ZarvIUIGujnsYAF09JDQEPIhEgJU8uokrE9L0wXEIZ7hlZjyuXL6SbP3Ydc92woK0PFXHojQ+ugcXesnUX7di9XwhVdLeBXfZn3O8Eo9aEkS4CGbaaYzyRP7TX9wf9XQDI/8FQgHbuPkj1Dc20ctlCmsQKPArSQ6kfqvIF2goFZ9pVV6yWE7IO+dEsUkHkiokNGehWID9dhDx1EUvzFstbYUeKM8JarnjfhWLc6OzsHlLiUADZRTIvb7+7g8XiWsmhL8gPxQFJ9IM4/pbnPjIc+3TYOEgUDIHoy/zw/0Hc6+9mRQwP8spxmiBEYvmiuRLTo30m6eAkmV1bXcdzwWTdNaQOV9G/mDDCLG5u37GPtu3aKwGYeE/pYwOap7/jyz4IKbrPTJ1eDpIJBIIXSIz/J+7lAznVoYMgOnZMVSVduHKxmIMh6kDOHiqxSxPJSMHsHYBCnNIcYPyKo4cE/2zTlu0CKgEv+TkknyEK43t88QcNlx54vhII/kVIyn9wnzSggQRQt7BbzKzTJk+gpYvnC1AdLDXoQ6nEn2/NsivagjAKCgsE6vTd7bvpwKFjsp7gGudgN0Yux19xf9iJvDJcBDIcViy/dtBCwpVlreDnEwZkNcnPE/2jtu4sHTl6Qk7NUVXloiPoPPQckZw7JwJnwJz28mG0d98heu2Nt+nEyToxewN1xBo4t9rFC3Q7r9AzmhpyBBLbkBH2LHdUwZk3gKNNwrdxskEhPXb8FB09cZqwXqj1jfgfcJjM1hsyl2vAH4VAS0zf/kNHacPGd2kPE4jFuxXQR8Fg4FzmFigkt/HO3+yMR8sRSHyDI/FxS4HRreqv8q7LmQgCeCgo9TEOHTkmKCp4PXpUpaSxKnHPyiiU9kwkCu3rgSXK4OdHj5+k1zdultIK0P2Qw68TvAZIGmA3/2UoY82JGEC7DCCQTNJBYp+rxy+QqiU34VzvAHE/4CrVY6pozsypAhRRCqtLuFd6ROqBG5SjlT7CQOwUxKmOrm7hxnv2HxZFHJwESU6DMFX19vr+vC8fJkcg/SEQvAcu8hD3y85poHa4BczCkKPh0Z09YyrNmjGFKspK5LcVUnk4ikV7/inelp0KXGDXa+ykg0eO0+59B6mlRVWrRTJZwDAGQ0wF4OA3+GdeiTGg5Aik3wSCVs2vv8GPf3uus4JEoYhgy/YI14CIMHXSBIHWRIwXrDKaUM6nls+Ekc9KNsJQAKJx9NgpOnz0OLV1dFEoEBS0kWBIIfUPggb3v3nD/5gfj7oJIEcgAyMQ/RqQQv/CffI5D9z2isOyBTwuzHX1qCqaMnE8TZ82UVAQ4ZBH1h1irXS4+kjWWfScQnzSHYSB3QbcrkNHT4qOAWwACU/PV6XNdCXcQWjAcf5r7r/TnvEcgQwugaBN5Dfv48fPUBJU+X7cnfxQNxMD0A+RwIPswYnjx9K4mjGqXLId9AcUEnAepbO4FjdDCUKsMfZGxzhgbUK5RWBenTpdTydP10lWH3CFIWIhriwwuBsQk/UoX+77/LgzZsPnCGTQCcSOoLBu4mdAslg5mHcKP0pPT6+EZweDhtj2qyrKJGlq0oQasYIBlgibDKFFsOSAC6kCn9awEU3M/BgKrUSXt8adIAccoiXwx2DRA2E0NrcKYAPuHUGXgvmr4YYGr+3i/iBv6f8gV53DHIEMLYHgGbzuX+enMBFWDtqkGIaNumiJiBW2S6zB3FlRWiqWsJqxirPAEobNFcoLRcU2WMUETtSx2QabXmLowVDZlzBjB6Taq8q6BDds7+yUwkUAnkCaa1NLq9SK1EDiEKOCgYCNbTaolIFwkf/iPfxTftwXh/SYI5C0EIh+vZxfI3z+E4M9a1FgaSaWMBK0IgqqNGJaQjCwhoFQqirLBAmwrKRYSiEA+AybVtfu1jnqZhT+x4qbI9cvx3E2nTar9Ic+Sxs2PKrywkIHBHiISk1NrUIMAL8AscA4AesTcjFw3zqid4icpi/x3d3Njxv5lk17S+cIZBgJBK/5GJQyv3/HfdFQzp5lE4z8B44hYlbEPslD4iOoFO5SLBCmxUUqBEOlnYZsiM2QiGnRjR+z4GqecH0B2GaiBHGCM4GjwafTxcSA0PUOFpFQTg5cQufJmHYNQ/wGCEObrdMg9R3k/vc8jP/Lv9brpIAcgQw/gegPF/PDfyPlZFxO6Wo2p1AYWKbkzOu68CACiDGiJIeCfc/BCUAkOknKcCR1gMuA25iWEB9CZHpNbSDgR7xncyNcRxFdcLgMBtAzfm2otIWzMTnzI5xAhi1haggbCsb/E++wR3jDfokUoPH8NJwBffpAiDdsqDC6fpa90cUKBs+9/dyKzbCkmKwnopgNASITMYkf80IK1zeGGHSoR3rjzA5z/w3f3n/yPR7Iwr2UlQSiGwIfEcbwa+4ftgRHSUDshpxQrNgn0Z0uXONcT74oh6XhDLrcR3D2ET3Jj/uzeA9lNYHodoQU6/8Nbyngcn3V1lGK030jVuw/I60hqWaPPZd86Bgt58HeOS8IRLc2RSTcLfHIo4YJwLVnUK4laihn8Tb33zPj+xMpp99500Ln6aI/aSnxYAH3D3D/FPf3kQKRyDXVNnL/I/e13Defr0HOofN8E+y0++9YnofYdTX0FRpk7/wIatu5P8/9RcMw3rP1uPO6ne8EohvyEl6xO1A0ZnH/GHeEs0waDn0lTQ3e7lruj9vcAubaxpGqJOUIJD2tyZa50e+zucnldp9JqtZJ5QgdG7CR67gf5b7OPhAwzvbcsucIZCANlpsN6CyCIX9hPPcl3BdyX0zKGjYrgwkGhokDtui0jfsO+/FILs04RyBD0U7Z/Xn79UTuU20xbA736aSsYpPsvxWlkZBRXgIWJ5i1D9ni0gmbWxzJLV2OQIajnbC7bih9XWrrLKioNcEmlBq7QzyrsjlOmf25ArsDnEJb0aADIJapx978HTY3aLRFwDO27nDaJowT9t87bHGpO7c0g9OMHAROruWaf8vZ/XMt13It13It13It13It13ItrUp6bgpybThaJhiHUvEF5ZT0XMu1HIHkWq4NrGWso/Ce+/9hmUmBBwwPFEXLMsJtxXRxeUtLxMorv4/fudY9FiDfMAd91Ai33nfvvfead/3gZ/ONQAQVi6bHX48iJXll7+vsPNluhsq/x2/daBhWnutjvZZBTwV6Wr/H1+v97n3/MDNIwYfIsOb4ihER4yv33XPHy8nGeve9P1llBAM/4m9M9BAEuoxwywVmXtm/8b1f7HOJHv7cH+797jd/fNf9D00KkPEc37+RWLwIfebe73596/fue/ArLOx8iefK7fU3yTJe78zv/dZPvvOd1rvvf2idQVZ1Ynnd+PG9d93xy7t/+OA1/N3v8edHe3xqnxGgO1i82c+//Y/8pWu8RTCD1896YtGcKd+/6aabhiQHxS3meYlcGUkgDz30UFFTh8WLbNR4Ly5ReUugwMor+xq//LaXKmWPdYkVLGt6+OGH/3n73mNP87vT/a7X0tteHAyVfZmf3+2nnhkWLTZDpR333HPPj0wKPsEfWZBIjTMC1rhkY73zgQfKjJ4AaqKM9rvWzp07jflLLl7Af06UW7/0nvt/Wh8KWG/w5lqQVL00w2Puvv+nN/I2+WfDf8cvLOoJ5fOzL/LnlvEbCUvkmRZNuefHP59ihnufRNVun3uYb0ZoFtIL+H7nkg9egJ2Lv4TXreUmop/kOIijNbbTrEDAJg7L+rVpWEdj5UKDT8ymNovKLjcUB9hrGeYfnXIjb5LbmMCm8Bpd9t6eI08EjYAmjodNMve7rtdbUxZqONtiXm6fLIctw/pt7GcCCH2fbRiBywoKxlR1mT0L7D89ztfbGU9MASsQNDYlG2txODSfz3o5aS2y/pN7TA5GwDS6HnnkEfN7S6LMYxP/3guO+8L4v8AbagJ/F/PxhoMz/hvPS53XvfUawV38zW8Z6ocb+bu/4DFbfZ8xrub5uxDXVBej+0zDrLI5xQruH+Y3u5nNPKQ2NI+XaI3ZG1nF3yuwb+DnvHYd0Xu1jPn8wY/zvS74/vd/XtG3+6xtfJ0nY+/R+AxfZwbfEX4/RyDOFgwEgpbCG+NTOPTA/d/9+nZP0eT+hwL2bK6//647v+v8G7NvnE5TFL3kB1RoE8SeyM/vv+fbb/hcL2ifeW/FX++hCbwzZvNGCbZaZkDLX7yp/vX+7975wkDHakYiQSOoagTlW9a9d99955EkcsEb998dd29LScV9xeiUPI3/697v3rHV71I8RwE5qg06eN9d3/qfMXNx3086+Q8XYufj9X13f+vBvnn66V/yjQAIoztunu5/aKqiJzIDva133M/ibfR7P3zoSubCH8fz7oLOYH6kwB4TbXGP6e77HpxGCPw0rGHVkwf9xzUC+rn0XMu1rLRi5TZ3ruUIJNdiJ9AMZICzVYkhBgWasmZijSh24rCOKZSGMSbkNO7PjAQulN9jhs2QZfG9sy5p/YLl7tOxY6CzrFz8+L57vv36oJMC0c38e6tc7y3nf5sCAfNfnIeeZfX+kj/b4fjo8R/cdcfN8etB8/hzG1xvT0rjlF7r/n0e02K+r/aAYfxjjoOMsHbvvd9oYtr4s/0S1rFLnJ1p/iMUCD5/zz0PTBiCQ2ec+/d4N0VY+f2re797p8uaZix1fo433BXe15TkrktcfXLaJtQwquN/3wqxgv7Ne++6462s5SDZ3Ixwy2etYNn/sALGbMPqc8rxsxKDjM9j01l5odX81iODq+fRVoOs12LPOPMmPnF/dc99P0GWYZ3jFP4D39tZx13X+lz0TNx9GgbAKi5Kk4i4h2/2JdebN3D/xT0/fBDjeTxHICOOi9zbxQ9x7P9v/uYfCyprem83SBwUgz6/TByv/ODub33N+d737ntoKv/heqbTWw0yfxYlHSP4o3vv+vrWFE7woyx6fcX51t33/eQuwwikh0As2shjcv3+g5XMLW/hA+H24SSQnIiVRc0iqzA3phyB5Fqu5Qgk13ItRyC5lms5Asm1XBu5LSOtWBHTtOwirKjNd/NdP3wopjJUwLTCRm/rIxa8inA0WrSYP3Ob/jtC//hP8+SFYVihYMSydEZBKPBx/uxM1/Uicj2yIyTJmHcPXy8mCcEUmFEEJ1oPP/xwcMe+Y0hSiJu/gBku08HapmUk9XpGgsGoqStsGLfxvcUEKwYs6v7BXXcMyFRsmr0f4estib9Hw+rO63mKwoO/dqasXQAe8ICVX/7f+ffbHRr3BfppQXfBENj4zhMCCeeHD+f3htoMMkqRnxG3zWT/VT5vGeZWfnYlwrL5M7/qWwf5kHpu0bbG4uCJqpbwWf7eaMMy7ozz7/P1wnkVr4TI3MovbuCXS/h7v4phr7reIBlbt+w7NSrPot95sl9dNpr3SjBoJjWx5oWt/WYedfFYUdTw/oAHSd10000DWieelx96kii/WRgOfmBoYhZCO1CBUZm56Reec2RZJ3bu3Ng8f8nFORFrIO2Bv/3bZp7FW3gBj3t/wuKzL683EA58nxfhaauPP7g+Q49UFtMD/+trX+s2KPAZSxWd9FgvK5IX5qO/wPoxE8ajlo6Nd35GvfdEMBy61wp09Hp9xnG9RmY0X433bMe3e+/9Vj3v2Nv4S6d8rtW9YMECuCI75YQ2jC6PT3XZRNwZiZjdVgrxOmYw1Gmp8gekH2M3htGhLml1etBXp/PR2e7/3jd28dj/2iKrwWd2DjCL+ewjjzwS0WPSj7E/4v8b6Ww56NFcy7Wckp5ruZYjkFzLtRyB5FqupbP9PwEGAP2cyyUfLndgAAAAAElFTkSuQmCC"}}'); + } + }; + var e = {}; + function i(s) { + var n = globalThis.__common_module_cache___050c3e31727995d1749ba30b8ad948d6 ? globalThis.__common_module_cache___050c3e31727995d1749ba30b8ad948d6[s] : null; + if (n) return n.exports; + var r = e[s]; + if (void 0 !== r) return r.exports; + var o = e[s] = { + exports: {} + }; + globalThis.__common_module_cache___050c3e31727995d1749ba30b8ad948d6 && String(s).indexOf("?name=") < 0 && function(t) { + if (globalThis.webpackChunk_050c3e31727995d1749ba30b8ad948d6) { + switch (globalThis.webpackChunk_050c3e31727995d1749ba30b8ad948d6.length) { + case 1: + return globalThis.webpackChunk_050c3e31727995d1749ba30b8ad948d6[0][1][t]; + + case 2: + return globalThis.webpackChunk_050c3e31727995d1749ba30b8ad948d6[0][1][t] || globalThis.webpackChunk_050c3e31727995d1749ba30b8ad948d6[1][1][t]; + } + } + }(s) && (globalThis.__common_module_cache___050c3e31727995d1749ba30b8ad948d6[s] = o); + t[s].call(o.exports, o, o.exports, i); + return o.exports; + } + i.o = (t, e) => Object.prototype.hasOwnProperty.call(t, e); + var s = i(565); + _050c3e31727995d1749ba30b8ad948d6 = s; +}; + +print("compiling done"); \ No newline at end of file diff --git a/es2panda/test/compiler/js/regAllocator/test-spill-fill-with-env-args-expected.txt b/es2panda/test/compiler/js/regAllocator/test-spill-fill-with-env-args-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..9daeafb9864cf43055ae93beb0afd6c7d144bfa4 --- /dev/null +++ b/es2panda/test/compiler/js/regAllocator/test-spill-fill-with-env-args-expected.txt @@ -0,0 +1 @@ +test diff --git a/es2panda/test/compiler/js/regAllocator/test-spill-fill-with-env-args.js b/es2panda/test/compiler/js/regAllocator/test-spill-fill-with-env-args.js new file mode 100644 index 0000000000000000000000000000000000000000..8f579eec8a12b9503027e3627586aacbf4a7934e --- /dev/null +++ b/es2panda/test/compiler/js/regAllocator/test-spill-fill-with-env-args.js @@ -0,0 +1,269 @@ +function xx(arg) { + let a = undefined; + let aa = undefined; + let aaa = undefined; + let aaaa = undefined; + let aaaaa = undefined; + let aaaaaa = undefined; + let aaaaaaa = undefined; + let aaaaaaaa = undefined; + let b = undefined; + let bb = undefined; + let bbb = undefined; + let aaabab = undefined; + let aaaabab = undefined; + let aaaabaab = undefined; + let aaaaabaab = undefined; + let aaaaaabaab = undefined; + let ab = undefined; + let aba = undefined; + let abaa = undefined; + let abaaa = undefined; + let abaaaa = undefined; + let aabaaaa = undefined; + let aabaaaaa = undefined; + let aaabaaaaa = undefined; + let bbbbb = undefined; + let bbbbbb = undefined; + let bbbb = undefined; + let aaaba = undefined; + let aaaaba = undefined; + let aaaabaa = undefined; + let aaaaabaa = undefined; + let aaaaaabaa = undefined; + let c = undefined; + let ac = undefined; + let aac = undefined; + let aaac = undefined; + let aaaac = undefined; + let aaaaac = undefined; + let aaaaaac = undefined; + let aaaaaaac = undefined; + let aaaaaaaca = undefined; + let bc = undefined; + let bbc = undefined; + let bbbc = undefined; + let aaabcab = undefined; + let aaaababc = undefined; + let aaaabaabc = undefined; + let aaaaabaabc = undefined; + let aaaaaabaabc = undefined; + let abc = undefined; + let abca = undefined; + let abcaa = undefined; + let abacaa = undefined; + let abacaaa = undefined; + let aabaacaa = undefined; + let aabaacaaa = undefined; + let aaabcaaaaa = undefined; + let bbbbcb = undefined; + let bbbbcbb = undefined; + let bbbcb = undefined; + let aacaba = undefined; + let aaaabca = undefined; + let aaaacbaa = undefined; + let aaaaabcaa = undefined; + let aaaaacabaa = undefined; + let add = undefined; + let aadd = undefined; + let aaadd = undefined; + let aaaadd = undefined; + let aaaaadd = undefined; + let aaaaaadd = undefined; + let aaaaaadda = undefined; + let aaaaaaadda = undefined; + let bdd = undefined; + let bbdd = undefined; + let bbbdd = undefined; + let aaababdd = undefined; + let aaaabddab = undefined; + let aaaabddaab = undefined; + let aaaaaddbaab = undefined; + let aaaaaabddaab = undefined; + let ddab = undefined; + let abdda = undefined; + let abadda = undefined; + let abaddaa = undefined; + let abaaddaa = undefined; + let aabaaddaa = undefined; + let aabaaaddaa = undefined; + let aaabaaaddaa = undefined; + let bbbddbb = undefined; + let bbbddbbb = undefined; + let bbddbb = undefined; + let aaaddba = undefined; + let aaaddaba = undefined; + let aaaabaadd = undefined; + let aaaaabaadd = undefined; + let aaaaaabaadd = undefined; + let cdd = undefined; + let acdd = undefined; + let aacdd = undefined; + let aaacdd = undefined; + let aaaacddd = undefined; + let aaaaacddd = undefined; + let aaaaaacddd = undefined; + let aaaaaaacdd = undefined; + let aaaaaaacadd = undefined; + let bcdd = undefined; + let bbcdd = undefined; + let bbbcdd = undefined; + let aaabcabdd = undefined; + let aaaababcdd = undefined; + let aaaabaabcdd = undefined; + let aaaaabaabcdd = undefined; + let aaaaaabaabcdd = undefined; + let abcdd = undefined; + let abcdda = undefined; + let abcaddda = undefined; + let abacaddda = undefined; + let abacaadda = undefined; + let aabaacddaa = undefined; + let aabaacaaadd = undefined; + let aaabcaaaaadd = undefined; + let bbbbcbdd = undefined; + let bbbbcbbdd = undefined; + let bbbcbdd = undefined; + let aacabdda = undefined; + let aaaabcadd = undefined; + let aaaacbadda = undefined; + let aaaaabcaadd = undefined; + let aaaaacabddaa = undefined; + let ae = undefined; + let aaee = undefined; + let aaaee = undefined; + let aaaae = undefined; + let aaaaea = undefined; + let aaaaaea = undefined; + let aaaaaeaa = undefined; + let aaaaaaeaa = undefined; + let be = undefined; + let bbe = undefined; + let bbeb = undefined; + let aaabeab = undefined; + let aaaaebab = undefined; + let aaaabaeab = undefined; + let aaaaaebaab = undefined; + let aaaaaaebaab = undefined; + let abe = undefined; + let aeba = undefined; + let abeaa = undefined; + let abaeaa = undefined; + let abaeaaa = undefined; + let aabaeaaa = undefined; + let aabaaeaaa = undefined; + let aaabeaaaaa = undefined; + let bbbbeb = undefined; + let bbbbebb = undefined; + let bbbeb = undefined; + let aaaeba = undefined; + let aaaeaba = undefined; + let aaaeabaa = undefined; + let aaaeaabaa = undefined; + let aaaaeaabaa = undefined; + let ce = undefined; + let aec = undefined; + let aaec = undefined; + let aaaec = undefined; + let aaaeac = undefined; + let aaaaeac = undefined; + let aaaaeaac = undefined; + let aaaaaeaac = undefined; + let aaaaaeaaca = undefined; + let bce = undefined; + let bbce = undefined; + let bbbec = undefined; + let aaabceab = undefined; + let aaaabaebc = undefined; + let aaaabaeabc = undefined; + let aaaaabaeabc = undefined; + let aaaaaabeaabc = undefined; + let abce = undefined; + let abcea = undefined; + let abcaea = undefined; + let abacaea = undefined; + let abacaeaa = undefined; + let aabaeacaa = undefined; + let aabaaceaaa = undefined; + let aaabcaaeaaa = undefined; + let bbbbecb = undefined; + let bbbbcbeb = undefined; + let bbbceb = undefined; + let aacaeba = undefined; + let aaaaebca = undefined; + let aaaacbaea = undefined; + let aaaaabecaa = undefined; + let aaaaaceabaa = undefined; + let adde = undefined; + let aaded = undefined; + let aaaedd = undefined; + let aaaaedd = undefined; + let aaaaeadd = undefined; + let aaaaeaadd = undefined; + let aaaaaeadda = undefined; + let aaaaaaeadda = undefined; + let bded = undefined; + let bbedd = undefined; + let bbbded = undefined; + let aaababedd = undefined; + let aaaabdedab = undefined; + let aaaabddaeab = undefined; + let aaaaaeddbaab = undefined; + let aaaaaabeddaab = undefined; + let ddabe = undefined; + let abdeda = undefined; + let abadeda = undefined; + let abadedaa = undefined; + let abaaddeaa = undefined; + let aabaadedaa = undefined; + let aabaaaeddaa = undefined; + let aaabaaadedaa = undefined; + let bbbddebb = undefined; + let bbbddbebb = undefined; + let bbddebb = undefined; + let aaaddeba = undefined; + let aaaddaeba = undefined; + let aaaabeaadd = undefined; + let aaaaabaeadd = undefined; + let aaaaaabaeadd = undefined; + let cdde = undefined; + let acdde = undefined; + let aacdde = undefined; + let aaacdde = undefined; + let aaaacdded = undefined; + let aaaaacdded = undefined; + let aaaaaacdded = undefined; + let aaaaaaacdde = undefined; + let aaaaaaacadde = undefined; + let bcedd = undefined; + let bbcedd = undefined; + let bbbcedd = undefined; + let aaabceabdd = undefined; + let aaaabaebcdd = undefined; + let aaaabaaebcdd = undefined; + let aaaaabaaebcdd = undefined; + let aaaaaabaaebcdd = undefined; + let abcdde = undefined; + let abcddae = undefined; + let abcadddea = undefined; + let abacadddea = undefined; + let abacaaddae = undefined; + let aabaacddaae = undefined; + let aabaacaaadde = undefined; + let aaabcaaaaadde = undefined; + let bbbbcbdde = undefined; + let bbbbcbbdde = undefined; + let bbbcbdde = undefined; + let aacabddae = undefined; + let aaaabcadde = undefined; + let aaaacbaddae = undefined; + let aaaaabcaadde = undefined; + let aaaaacabddaae = undefined; + + function bar() { + print(arg); + } + bar(); +} + +xx("test");