(function() {
(function(t, e, i) {
function n(i, r) {
var s = e[i];
if (!s) {
var o = t[i];
if (!o) return;
var a = {};
s = e[i] = {
exports: a
};
o[0]((function(t) {
return n(o[1][t] || t);
}), s, a);
}
return s.exports;
}
for (var r = 0; r < i.length; r++) n(i[r]);
})({
1: [ (function(t, e, i) {
t("../core/platform/CCClass");
var n = t("../core/utils/misc");
cc.Action = cc.Class({
name: "cc.Action",
ctor: function() {
this.originalTarget = null;
this.target = null;
this.tag = cc.Action.TAG_INVALID;
},
clone: function() {
var t = new cc.Action();
t.originalTarget = null;
t.target = null;
t.tag = this.tag;
return t;
},
isDone: function() {
return !0;
},
startWithTarget: function(t) {
this.originalTarget = t;
this.target = t;
},
stop: function() {
this.target = null;
},
step: function(t) {
cc.logID(1006);
},
update: function(t) {
cc.logID(1007);
},
getTarget: function() {
return this.target;
},
setTarget: function(t) {
this.target = t;
},
getOriginalTarget: function() {
return this.originalTarget;
},
setOriginalTarget: function(t) {
this.originalTarget = t;
},
getTag: function() {
return this.tag;
},
setTag: function(t) {
this.tag = t;
},
retain: function() {},
release: function() {}
});
cc.Action.TAG_INVALID = -1;
cc.FiniteTimeAction = cc.Class({
name: "cc.FiniteTimeAction",
extends: cc.Action,
ctor: function() {
this._duration = 0;
},
getDuration: function() {
return this._duration * (this._timesForRepeat || 1);
},
setDuration: function(t) {
this._duration = t;
},
reverse: function() {
cc.logID(1008);
return null;
},
clone: function() {
return new cc.FiniteTimeAction();
}
});
cc.Speed = cc.Class({
name: "cc.Speed",
extends: cc.Action,
ctor: function(t, e) {
this._speed = 0;
this._innerAction = null;
t && this.initWithAction(t, e);
},
getSpeed: function() {
return this._speed;
},
setSpeed: function(t) {
this._speed = t;
},
initWithAction: function(t, e) {
if (!t) {
cc.errorID(1021);
return !1;
}
this._innerAction = t;
this._speed = e;
return !0;
},
clone: function() {
var t = new cc.Speed();
t.initWithAction(this._innerAction.clone(), this._speed);
return t;
},
startWithTarget: function(t) {
cc.Action.prototype.startWithTarget.call(this, t);
this._innerAction.startWithTarget(t);
},
stop: function() {
this._innerAction.stop();
cc.Action.prototype.stop.call(this);
},
step: function(t) {
this._innerAction.step(t * this._speed);
},
isDone: function() {
return this._innerAction.isDone();
},
reverse: function() {
return new cc.Speed(this._innerAction.reverse(), this._speed);
},
setInnerAction: function(t) {
this._innerAction !== t && (this._innerAction = t);
},
getInnerAction: function() {
return this._innerAction;
}
});
cc.speed = function(t, e) {
return new cc.Speed(t, e);
};
cc.Follow = cc.Class({
name: "cc.Follow",
extends: cc.Action,
ctor: function(t, e) {
this._followedNode = null;
this._boundarySet = !1;
this._boundaryFullyCovered = !1;
this._halfScreenSize = null;
this._fullScreenSize = null;
this.leftBoundary = 0;
this.rightBoundary = 0;
this.topBoundary = 0;
this.bottomBoundary = 0;
this._worldRect = cc.rect(0, 0, 0, 0);
t && (e ? this.initWithTarget(t, e) : this.initWithTarget(t));
},
clone: function() {
var t = new cc.Follow(), e = this._worldRect, i = new cc.Rect(e.x, e.y, e.width, e.height);
t.initWithTarget(this._followedNode, i);
return t;
},
isBoundarySet: function() {
return this._boundarySet;
},
setBoudarySet: function(t) {
this._boundarySet = t;
},
initWithTarget: function(t, e) {
if (!t) {
cc.errorID(1022);
return !1;
}
e = e || cc.rect(0, 0, 0, 0);
this._followedNode = t;
this._worldRect = e;
this._boundarySet = !(0 === e.width && 0 === e.height);
this._boundaryFullyCovered = !1;
var i = cc.winSize;
this._fullScreenSize = cc.v2(i.width, i.height);
this._halfScreenSize = this._fullScreenSize.mul(.5);
if (this._boundarySet) {
this.leftBoundary = -(e.x + e.width - this._fullScreenSize.x);
this.rightBoundary = -e.x;
this.topBoundary = -e.y;
this.bottomBoundary = -(e.y + e.height - this._fullScreenSize.y);
this.rightBoundary < this.leftBoundary && (this.rightBoundary = this.leftBoundary = (this.leftBoundary + this.rightBoundary) / 2);
this.topBoundary < this.bottomBoundary && (this.topBoundary = this.bottomBoundary = (this.topBoundary + this.bottomBoundary) / 2);
this.topBoundary === this.bottomBoundary && this.leftBoundary === this.rightBoundary && (this._boundaryFullyCovered = !0);
}
return !0;
},
step: function(t) {
var e = this.target.convertToWorldSpaceAR(cc.Vec2.ZERO), i = this._followedNode.convertToWorldSpaceAR(cc.Vec2.ZERO), r = e.sub(i), s = this.target.parent.convertToNodeSpaceAR(r.add(this._halfScreenSize));
if (this._boundarySet) {
if (this._boundaryFullyCovered) return;
this.target.setPosition(n.clampf(s.x, this.leftBoundary, this.rightBoundary), n.clampf(s.y, this.bottomBoundary, this.topBoundary));
} else this.target.setPosition(s.x, s.y);
},
isDone: function() {
return !this._followedNode.activeInHierarchy;
},
stop: function() {
this.target = null;
cc.Action.prototype.stop.call(this);
}
});
cc.follow = function(t, e) {
return new cc.Follow(t, e);
};
}), {
"../core/platform/CCClass": 160,
"../core/utils/misc": 242
} ],
2: [ (function(t, e, i) {
function n(t, e) {
return t[Math.min(t.length - 1, Math.max(e, 0))];
}
function r(t) {
for (var e = [], i = t.length - 1; i >= 0; i--) e.push(cc.v2(t[i].x, t[i].y));
return e;
}
function s(t) {
for (var e = [], i = 0; i < t.length; i++) e.push(cc.v2(t[i].x, t[i].y));
return e;
}
cc.CardinalSplineTo = cc.Class({
name: "cc.CardinalSplineTo",
extends: cc.ActionInterval,
ctor: function(t, e, i) {
this._points = [];
this._deltaT = 0;
this._tension = 0;
this._previousPosition = null;
this._accumulatedDiff = null;
void 0 !== i && cc.CardinalSplineTo.prototype.initWithDuration.call(this, t, e, i);
},
initWithDuration: function(t, e, i) {
if (!e || 0 === e.length) {
cc.errorID(1024);
return !1;
}
if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) {
this.setPoints(e);
this._tension = i;
return !0;
}
return !1;
},
clone: function() {
var t = new cc.CardinalSplineTo();
t.initWithDuration(this._duration, s(this._points), this._tension);
return t;
},
startWithTarget: function(t) {
cc.ActionInterval.prototype.startWithTarget.call(this, t);
this._deltaT = 1 / (this._points.length - 1);
this._previousPosition = cc.v2(this.target.x, this.target.y);
this._accumulatedDiff = cc.v2(0, 0);
},
update: function(t) {
t = this._computeEaseTime(t);
var e, i, r = this._points;
if (1 === t) {
e = r.length - 1;
i = 1;
} else {
var s = this._deltaT;
i = (t - s * (e = 0 | t / s)) / s;
}
var o = (function(t, e, i, n, r, s) {
var o = s * s, a = o * s, c = (1 - r) / 2, h = c * (2 * o - a - s), l = c * (-a + o) + (2 * a - 3 * o + 1), u = c * (a - 2 * o + s) + (-2 * a + 3 * o), _ = c * (a - o), f = t.x * h + e.x * l + i.x * u + n.x * _, d = t.y * h + e.y * l + i.y * u + n.y * _;
return cc.v2(f, d);
})(n(r, e - 1), n(r, e - 0), n(r, e + 1), n(r, e + 2), this._tension, i);
if (cc.macro.ENABLE_STACKABLE_ACTIONS) {
var a, c;
a = this.target.x - this._previousPosition.x;
c = this.target.y - this._previousPosition.y;
if (0 !== a || 0 !== c) {
var h = this._accumulatedDiff;
a = h.x + a;
c = h.y + c;
h.x = a;
h.y = c;
o.x += a;
o.y += c;
}
}
this.updatePosition(o);
},
reverse: function() {
var t = r(this._points);
return cc.cardinalSplineTo(this._duration, t, this._tension);
},
updatePosition: function(t) {
this.target.setPosition(t);
this._previousPosition = t;
},
getPoints: function() {
return this._points;
},
setPoints: function(t) {
this._points = t;
}
});
cc.cardinalSplineTo = function(t, e, i) {
return new cc.CardinalSplineTo(t, e, i);
};
cc.CardinalSplineBy = cc.Class({
name: "cc.CardinalSplineBy",
extends: cc.CardinalSplineTo,
ctor: function(t, e, i) {
this._startPosition = cc.v2(0, 0);
void 0 !== i && this.initWithDuration(t, e, i);
},
startWithTarget: function(t) {
cc.CardinalSplineTo.prototype.startWithTarget.call(this, t);
this._startPosition.x = t.x;
this._startPosition.y = t.y;
},
reverse: function() {
for (var t, e = this._points.slice(), i = e[0], n = 1; n < e.length; ++n) {
t = e[n];
e[n] = t.sub(i);
i = t;
}
var s = r(e);
i = s[s.length - 1];
s.pop();
i.x = -i.x;
i.y = -i.y;
s.unshift(i);
for (n = 1; n < s.length; ++n) {
(t = s[n]).x = -t.x;
t.y = -t.y;
t.x += i.x;
t.y += i.y;
s[n] = t;
i = t;
}
return cc.cardinalSplineBy(this._duration, s, this._tension);
},
updatePosition: function(t) {
var e = this._startPosition, i = t.x + e.x, n = t.y + e.y;
this._previousPosition.x = i;
this._previousPosition.y = n;
this.target.setPosition(i, n);
},
clone: function() {
var t = new cc.CardinalSplineBy();
t.initWithDuration(this._duration, s(this._points), this._tension);
return t;
}
});
cc.cardinalSplineBy = function(t, e, i) {
return new cc.CardinalSplineBy(t, e, i);
};
cc.CatmullRomTo = cc.Class({
name: "cc.CatmullRomTo",
extends: cc.CardinalSplineTo,
ctor: function(t, e) {
e && this.initWithDuration(t, e);
},
initWithDuration: function(t, e) {
return cc.CardinalSplineTo.prototype.initWithDuration.call(this, t, e, .5);
},
clone: function() {
var t = new cc.CatmullRomTo();
t.initWithDuration(this._duration, s(this._points));
return t;
}
});
cc.catmullRomTo = function(t, e) {
return new cc.CatmullRomTo(t, e);
};
cc.CatmullRomBy = cc.Class({
name: "cc.CatmullRomBy",
extends: cc.CardinalSplineBy,
ctor: function(t, e) {
e && this.initWithDuration(t, e);
},
initWithDuration: function(t, e) {
return cc.CardinalSplineTo.prototype.initWithDuration.call(this, t, e, .5);
},
clone: function() {
var t = new cc.CatmullRomBy();
t.initWithDuration(this._duration, s(this._points));
return t;
}
});
cc.catmullRomBy = function(t, e) {
return new cc.CatmullRomBy(t, e);
};
}), {} ],
3: [ (function(t, e, i) {
cc.easeIn = function(t) {
return {
_rate: t,
easing: function(t) {
return Math.pow(t, this._rate);
},
reverse: function() {
return cc.easeIn(1 / this._rate);
}
};
};
cc.easeOut = function(t) {
return {
_rate: t,
easing: function(t) {
return Math.pow(t, 1 / this._rate);
},
reverse: function() {
return cc.easeOut(1 / this._rate);
}
};
};
cc.easeInOut = function(t) {
return {
_rate: t,
easing: function(t) {
return (t *= 2) < 1 ? .5 * Math.pow(t, this._rate) : 1 - .5 * Math.pow(2 - t, this._rate);
},
reverse: function() {
return cc.easeInOut(this._rate);
}
};
};
var n = {
easing: function(t) {
return 0 === t ? 0 : Math.pow(2, 10 * (t - 1));
},
reverse: function() {
return r;
}
};
cc.easeExponentialIn = function() {
return n;
};
var r = {
easing: function(t) {
return 1 === t ? 1 : 1 - Math.pow(2, -10 * t);
},
reverse: function() {
return n;
}
};
cc.easeExponentialOut = function() {
return r;
};
var s = {
easing: function(t) {
return 1 !== t && 0 !== t ? (t *= 2) < 1 ? .5 * Math.pow(2, 10 * (t - 1)) : .5 * (2 - Math.pow(2, -10 * (t - 1))) : t;
},
reverse: function() {
return s;
}
};
cc.easeExponentialInOut = function() {
return s;
};
var o = {
easing: function(t) {
return 0 === t || 1 === t ? t : -1 * Math.cos(t * Math.PI / 2) + 1;
},
reverse: function() {
return a;
}
};
cc.easeSineIn = function() {
return o;
};
var a = {
easing: function(t) {
return 0 === t || 1 === t ? t : Math.sin(t * Math.PI / 2);
},
reverse: function() {
return o;
}
};
cc.easeSineOut = function() {
return a;
};
var c = {
easing: function(t) {
return 0 === t || 1 === t ? t : -.5 * (Math.cos(Math.PI * t) - 1);
},
reverse: function() {
return c;
}
};
cc.easeSineInOut = function() {
return c;
};
var h = {
easing: function(t) {
if (0 === t || 1 === t) return t;
t -= 1;
return -Math.pow(2, 10 * t) * Math.sin((t - .075) * Math.PI * 2 / .3);
},
reverse: function() {
return l;
}
};
cc.easeElasticIn = function(t) {
return t && .3 !== t ? {
_period: t,
easing: function(t) {
if (0 === t || 1 === t) return t;
t -= 1;
return -Math.pow(2, 10 * t) * Math.sin((t - this._period / 4) * Math.PI * 2 / this._period);
},
reverse: function() {
return cc.easeElasticOut(this._period);
}
} : h;
};
var l = {
easing: function(t) {
return 0 === t || 1 === t ? t : Math.pow(2, -10 * t) * Math.sin((t - .075) * Math.PI * 2 / .3) + 1;
},
reverse: function() {
return h;
}
};
cc.easeElasticOut = function(t) {
return t && .3 !== t ? {
_period: t,
easing: function(t) {
return 0 === t || 1 === t ? t : Math.pow(2, -10 * t) * Math.sin((t - this._period / 4) * Math.PI * 2 / this._period) + 1;
},
reverse: function() {
return cc.easeElasticIn(this._period);
}
} : l;
};
cc.easeElasticInOut = function(t) {
return {
_period: t = t || .3,
easing: function(t) {
var e = 0, i = this._period;
if (0 === t || 1 === t) e = t; else {
t *= 2;
i || (i = this._period = .3 * 1.5);
var n = i / 4;
e = (t -= 1) < 0 ? -.5 * Math.pow(2, 10 * t) * Math.sin((t - n) * Math.PI * 2 / i) : Math.pow(2, -10 * t) * Math.sin((t - n) * Math.PI * 2 / i) * .5 + 1;
}
return e;
},
reverse: function() {
return cc.easeElasticInOut(this._period);
}
};
};
function u(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;
}
var _ = {
easing: function(t) {
return 1 - u(1 - t);
},
reverse: function() {
return f;
}
};
cc.easeBounceIn = function() {
return _;
};
var f = {
easing: function(t) {
return u(t);
},
reverse: function() {
return _;
}
};
cc.easeBounceOut = function() {
return f;
};
var d = {
easing: function(t) {
return t < .5 ? .5 * (1 - u(1 - (t *= 2))) : .5 * u(2 * t - 1) + .5;
},
reverse: function() {
return d;
}
};
cc.easeBounceInOut = function() {
return d;
};
var m = {
easing: function(t) {
return 0 === t || 1 === t ? t : t * t * (2.70158 * t - 1.70158);
},
reverse: function() {
return p;
}
};
cc.easeBackIn = function() {
return m;
};
var p = {
easing: function(t) {
return (t -= 1) * t * (2.70158 * t + 1.70158) + 1;
},
reverse: function() {
return m;
}
};
cc.easeBackOut = function() {
return p;
};
var v = {
easing: function(t) {
return (t *= 2) < 1 ? t * t * (3.5949095 * t - 2.5949095) / 2 : (t -= 2) * t * (3.5949095 * t + 2.5949095) / 2 + 1;
},
reverse: function() {
return v;
}
};
cc.easeBackInOut = function() {
return v;
};
cc.easeBezierAction = function(t, e, i, n) {
return {
easing: function(r) {
return Math.pow(1 - r, 3) * t + 3 * r * Math.pow(1 - r, 2) * e + 3 * Math.pow(r, 2) * (1 - r) * i + Math.pow(r, 3) * n;
},
reverse: function() {
return cc.easeBezierAction(n, i, e, t);
}
};
};
var y = {
easing: function(t) {
return Math.pow(t, 2);
},
reverse: function() {
return y;
}
};
cc.easeQuadraticActionIn = function() {
return y;
};
var g = {
easing: function(t) {
return -t * (t - 2);
},
reverse: function() {
return g;
}
};
cc.easeQuadraticActionOut = function() {
return g;
};
var x = {
easing: function(t) {
return (t *= 2) < 1 ? t * t * .5 : -.5 * (--t * (t - 2) - 1);
},
reverse: function() {
return x;
}
};
cc.easeQuadraticActionInOut = function() {
return x;
};
var C = {
easing: function(t) {
return t * t * t * t;
},
reverse: function() {
return C;
}
};
cc.easeQuarticActionIn = function() {
return C;
};
var A = {
easing: function(t) {
return -((t -= 1) * t * t * t - 1);
},
reverse: function() {
return A;
}
};
cc.easeQuarticActionOut = function() {
return A;
};
var b = {
easing: function(t) {
return (t *= 2) < 1 ? .5 * t * t * t * t : -.5 * ((t -= 2) * t * t * t - 2);
},
reverse: function() {
return b;
}
};
cc.easeQuarticActionInOut = function() {
return b;
};
var S = {
easing: function(t) {
return t * t * t * t * t;
},
reverse: function() {
return S;
}
};
cc.easeQuinticActionIn = function() {
return S;
};
var T = {
easing: function(t) {
return (t -= 1) * t * t * t * t + 1;
},
reverse: function() {
return T;
}
};
cc.easeQuinticActionOut = function() {
return T;
};
var w = {
easing: function(t) {
return (t *= 2) < 1 ? .5 * t * t * t * t * t : .5 * ((t -= 2) * t * t * t * t + 2);
},
reverse: function() {
return w;
}
};
cc.easeQuinticActionInOut = function() {
return w;
};
var E = {
easing: function(t) {
return -1 * (Math.sqrt(1 - t * t) - 1);
},
reverse: function() {
return E;
}
};
cc.easeCircleActionIn = function() {
return E;
};
var B = {
easing: function(t) {
t -= 1;
return Math.sqrt(1 - t * t);
},
reverse: function() {
return B;
}
};
cc.easeCircleActionOut = function() {
return B;
};
var M = {
easing: function(t) {
if ((t *= 2) < 1) return -.5 * (Math.sqrt(1 - t * t) - 1);
t -= 2;
return .5 * (Math.sqrt(1 - t * t) + 1);
},
reverse: function() {
return M;
}
};
cc.easeCircleActionInOut = function() {
return M;
};
var D = {
easing: function(t) {
return t * t * t;
},
reverse: function() {
return D;
}
};
cc.easeCubicActionIn = function() {
return D;
};
var I = {
easing: function(t) {
return (t -= 1) * t * t + 1;
},
reverse: function() {
return I;
}
};
cc.easeCubicActionOut = function() {
return I;
};
var P = {
easing: function(t) {
return (t *= 2) < 1 ? .5 * t * t * t : .5 * ((t -= 2) * t * t + 2);
},
reverse: function() {
return P;
}
};
cc.easeCubicActionInOut = function() {
return P;
};
}), {} ],
4: [ (function(t, e, i) {
cc.ActionInstant = cc.Class({
name: "cc.ActionInstant",
extends: cc.FiniteTimeAction,
isDone: function() {
return !0;
},
step: function(t) {
this.update(1);
},
update: function(t) {},
reverse: function() {
return this.clone();
},
clone: function() {
return new cc.ActionInstant();
}
});
cc.Show = cc.Class({
name: "cc.Show",
extends: cc.ActionInstant,
update: function(t) {
for (var e = this.target.getComponentsInChildren(cc.RenderComponent), i = 0; i < e.length; ++i) {
e[i].enabled = !0;
}
},
reverse: function() {
return new cc.Hide();
},
clone: function() {
return new cc.Show();
}
});
cc.show = function() {
return new cc.Show();
};
cc.Hide = cc.Class({
name: "cc.Hide",
extends: cc.ActionInstant,
update: function(t) {
for (var e = this.target.getComponentsInChildren(cc.RenderComponent), i = 0; i < e.length; ++i) {
e[i].enabled = !1;
}
},
reverse: function() {
return new cc.Show();
},
clone: function() {
return new cc.Hide();
}
});
cc.hide = function() {
return new cc.Hide();
};
cc.ToggleVisibility = cc.Class({
name: "cc.ToggleVisibility",
extends: cc.ActionInstant,
update: function(t) {
for (var e = this.target.getComponentsInChildren(cc.RenderComponent), i = 0; i < e.length; ++i) {
var n = e[i];
n.enabled = !n.enabled;
}
},
reverse: function() {
return new cc.ToggleVisibility();
},
clone: function() {
return new cc.ToggleVisibility();
}
});
cc.toggleVisibility = function() {
return new cc.ToggleVisibility();
};
cc.RemoveSelf = cc.Class({
name: "cc.RemoveSelf",
extends: cc.ActionInstant,
ctor: function(t) {
this._isNeedCleanUp = !0;
void 0 !== t && this.init(t);
},
update: function(t) {
this.target.removeFromParent(this._isNeedCleanUp);
},
init: function(t) {
this._isNeedCleanUp = t;
return !0;
},
reverse: function() {
return new cc.RemoveSelf(this._isNeedCleanUp);
},
clone: function() {
return new cc.RemoveSelf(this._isNeedCleanUp);
}
});
cc.removeSelf = function(t) {
return new cc.RemoveSelf(t);
};
cc.FlipX = cc.Class({
name: "cc.FlipX",
extends: cc.ActionInstant,
ctor: function(t) {
this._flippedX = !1;
void 0 !== t && this.initWithFlipX(t);
},
initWithFlipX: function(t) {
this._flippedX = t;
return !0;
},
update: function(t) {
this.target.scaleX = Math.abs(this.target.scaleX) * (this._flippedX ? -1 : 1);
},
reverse: function() {
return new cc.FlipX(!this._flippedX);
},
clone: function() {
var t = new cc.FlipX();
t.initWithFlipX(this._flippedX);
return t;
}
});
cc.flipX = function(t) {
return new cc.FlipX(t);
};
cc.FlipY = cc.Class({
name: "cc.FlipY",
extends: cc.ActionInstant,
ctor: function(t) {
this._flippedY = !1;
void 0 !== t && this.initWithFlipY(t);
},
initWithFlipY: function(t) {
this._flippedY = t;
return !0;
},
update: function(t) {
this.target.scaleY = Math.abs(this.target.scaleY) * (this._flippedY ? -1 : 1);
},
reverse: function() {
return new cc.FlipY(!this._flippedY);
},
clone: function() {
var t = new cc.FlipY();
t.initWithFlipY(this._flippedY);
return t;
}
});
cc.flipY = function(t) {
return new cc.FlipY(t);
};
cc.Place = cc.Class({
name: "cc.Place",
extends: cc.ActionInstant,
ctor: function(t, e) {
this._x = 0;
this._y = 0;
if (void 0 !== t) {
if (void 0 !== t.x) {
e = t.y;
t = t.x;
}
this.initWithPosition(t, e);
}
},
initWithPosition: function(t, e) {
this._x = t;
this._y = e;
return !0;
},
update: function(t) {
this.target.setPosition(this._x, this._y);
},
clone: function() {
var t = new cc.Place();
t.initWithPosition(this._x, this._y);
return t;
}
});
cc.place = function(t, e) {
return new cc.Place(t, e);
};
cc.CallFunc = cc.Class({
name: "cc.CallFunc",
extends: cc.ActionInstant,
ctor: function(t, e, i) {
this._selectorTarget = null;
this._function = null;
this._data = null;
this.initWithFunction(t, e, i);
},
initWithFunction: function(t, e, i) {
t && (this._function = t);
e && (this._selectorTarget = e);
void 0 !== i && (this._data = i);
return !0;
},
execute: function() {
this._function && this._function.call(this._selectorTarget, this.target, this._data);
},
update: function(t) {
this.execute();
},
getTargetCallback: function() {
return this._selectorTarget;
},
setTargetCallback: function(t) {
if (t !== this._selectorTarget) {
this._selectorTarget && (this._selectorTarget = null);
this._selectorTarget = t;
}
},
clone: function() {
var t = new cc.CallFunc();
t.initWithFunction(this._function, this._selectorTarget, this._data);
return t;
}
});
cc.callFunc = function(t, e, i) {
return new cc.CallFunc(t, e, i);
};
}), {} ],
5: [ (function(t, e, i) {
cc.ActionInterval = cc.Class({
name: "cc.ActionInterval",
extends: cc.FiniteTimeAction,
ctor: function(t) {
this.MAX_VALUE = 2;
this._elapsed = 0;
this._firstTick = !1;
this._easeList = null;
this._speed = 1;
this._timesForRepeat = 1;
this._repeatForever = !1;
this._repeatMethod = !1;
this._speedMethod = !1;
void 0 !== t && cc.ActionInterval.prototype.initWithDuration.call(this, t);
},
getElapsed: function() {
return this._elapsed;
},
initWithDuration: function(t) {
this._duration = 0 === t ? cc.macro.FLT_EPSILON : t;
this._elapsed = 0;
this._firstTick = !0;
return !0;
},
isDone: function() {
return this._elapsed >= this._duration;
},
_cloneDecoration: function(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: function(t) {
if (this._easeList) {
t._easeList = [];
for (var e = 0; e < this._easeList.length; e++) t._easeList.push(this._easeList[e].reverse());
}
},
clone: function() {
var t = new cc.ActionInterval(this._duration);
this._cloneDecoration(t);
return t;
},
easing: function(t) {
this._easeList ? this._easeList.length = 0 : this._easeList = [];
for (var e = 0; e < arguments.length; e++) this._easeList.push(arguments[e]);
return this;
},
_computeEaseTime: function(t) {
var e = this._easeList;
if (!e || 0 === e.length) return t;
for (var i = 0, n = e.length; i < n; i++) t = e[i].easing(t);
return t;
},
step: function(t) {
if (this._firstTick) {
this._firstTick = !1;
this._elapsed = 0;
} else this._elapsed += t;
var e = this._elapsed / (this._duration > 1.192092896e-7 ? this._duration : 1.192092896e-7);
e = 1 > e ? 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: function(t) {
cc.Action.prototype.startWithTarget.call(this, t);
this._elapsed = 0;
this._firstTick = !0;
},
reverse: function() {
cc.logID(1010);
return null;
},
setAmplitudeRate: function(t) {
cc.logID(1011);
},
getAmplitudeRate: function() {
cc.logID(1012);
return 0;
},
speed: function(t) {
if (t <= 0) {
cc.logID(1013);
return this;
}
this._speedMethod = !0;
this._speed *= t;
return this;
},
getSpeed: function() {
return this._speed;
},
setSpeed: function(t) {
this._speed = t;
return this;
},
repeat: function(t) {
t = Math.round(t);
if (isNaN(t) || t < 1) {
cc.logID(1014);
return this;
}
this._repeatMethod = !0;
this._timesForRepeat *= t;
return this;
},
repeatForever: function() {
this._repeatMethod = !0;
this._timesForRepeat = this.MAX_VALUE;
this._repeatForever = !0;
return this;
}
});
cc.actionInterval = function(t) {
return new cc.ActionInterval(t);
};
cc.Sequence = cc.Class({
name: "cc.Sequence",
extends: cc.ActionInterval,
ctor: function(t) {
this._actions = [];
this._split = null;
this._last = 0;
this._reversed = !1;
var e = t instanceof Array ? t : arguments;
if (1 !== e.length) {
var i = e.length - 1;
i >= 0 && null == e[i] && cc.logID(1015);
if (i >= 0) {
for (var n, r = e[0], s = 1; s < i; s++) if (e[s]) {
n = r;
r = cc.Sequence._actionOneTwo(n, e[s]);
}
this.initWithTwoActions(r, e[i]);
}
} else cc.errorID(1019);
},
initWithTwoActions: function(t, e) {
if (!t || !e) {
cc.errorID(1025);
return !1;
}
var i = t._duration, n = e._duration, r = (i *= t._repeatMethod ? t._timesForRepeat : 1) + (n *= e._repeatMethod ? e._timesForRepeat : 1);
this.initWithDuration(r);
this._actions[0] = t;
this._actions[1] = e;
return !0;
},
clone: function() {
var t = new cc.Sequence();
this._cloneDecoration(t);
t.initWithTwoActions(this._actions[0].clone(), this._actions[1].clone());
return t;
},
startWithTarget: function(t) {
cc.ActionInterval.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: function() {
-1 !== this._last && this._actions[this._last].stop();
cc.Action.prototype.stop.call(this);
},
update: function(t) {
var e, i, n = 0, r = this._split, s = this._actions, o = this._last;
if ((t = this._computeEaseTime(t)) < r) {
e = 0 !== r ? t / r : 1;
if (0 === n && 1 === o && this._reversed) {
s[1].update(0);
s[1].stop();
}
} else {
n = 1;
e = 1 === r ? 1 : (t - r) / (1 - r);
if (-1 === o) {
s[0].startWithTarget(this.target);
s[0].update(1);
s[0].stop();
}
if (0 === o) {
s[0].update(1);
s[0].stop();
}
}
i = s[n];
if (o !== n || !i.isDone()) {
o !== n && i.startWithTarget(this.target);
e *= i._timesForRepeat;
i.update(e > 1 ? e % 1 : e);
this._last = n;
}
},
reverse: function() {
var t = cc.Sequence._actionOneTwo(this._actions[1].reverse(), this._actions[0].reverse());
this._cloneDecoration(t);
this._reverseEaseList(t);
t._reversed = !0;
return t;
}
});
cc.sequence = function(t) {
var e = t instanceof Array ? t : arguments;
if (1 === e.length) {
cc.errorID(1019);
return null;
}
var i = e.length - 1;
i >= 0 && null == e[i] && cc.logID(1015);
var n = null;
if (i >= 0) {
n = e[0];
for (var r = 1; r <= i; r++) e[r] && (n = cc.Sequence._actionOneTwo(n, e[r]));
}
return n;
};
cc.Sequence._actionOneTwo = function(t, e) {
var i = new cc.Sequence();
i.initWithTwoActions(t, e);
return i;
};
cc.Repeat = cc.Class({
name: "cc.Repeat",
extends: cc.ActionInterval,
ctor: function(t, e) {
this._times = 0;
this._total = 0;
this._nextDt = 0;
this._actionInstant = !1;
this._innerAction = null;
void 0 !== e && this.initWithAction(t, e);
},
initWithAction: function(t, e) {
var i = t._duration * e;
if (this.initWithDuration(i)) {
this._times = e;
this._innerAction = t;
if (t instanceof cc.ActionInstant) {
this._actionInstant = !0;
this._times -= 1;
}
this._total = 0;
return !0;
}
return !1;
},
clone: function() {
var t = new cc.Repeat();
this._cloneDecoration(t);
t.initWithAction(this._innerAction.clone(), this._times);
return t;
},
startWithTarget: function(t) {
this._total = 0;
this._nextDt = this._innerAction._duration / this._duration;
cc.ActionInterval.prototype.startWithTarget.call(this, t);
this._innerAction.startWithTarget(t);
},
stop: function() {
this._innerAction.stop();
cc.Action.prototype.stop.call(this);
},
update: function(t) {
t = this._computeEaseTime(t);
var e = this._innerAction, i = this._duration, n = this._times, r = this._nextDt;
if (t >= r) {
for (;t > r && this._total < n; ) {
e.update(1);
this._total++;
e.stop();
e.startWithTarget(this.target);
r += e._duration / i;
this._nextDt = r > 1 ? 1 : r;
}
if (t >= 1 && this._total < n) {
e.update(1);
this._total++;
}
this._actionInstant || (this._total === n ? e.stop() : e.update(t - (r - e._duration / i)));
} else e.update(t * n % 1);
},
isDone: function() {
return this._total === this._times;
},
reverse: function() {
var t = new cc.Repeat(this._innerAction.reverse(), this._times);
this._cloneDecoration(t);
this._reverseEaseList(t);
return t;
},
setInnerAction: function(t) {
this._innerAction !== t && (this._innerAction = t);
},
getInnerAction: function() {
return this._innerAction;
}
});
cc.repeat = function(t, e) {
return new cc.Repeat(t, e);
};
cc.RepeatForever = cc.Class({
name: "cc.RepeatForever",
extends: cc.ActionInterval,
ctor: function(t) {
this._innerAction = null;
t && this.initWithAction(t);
},
initWithAction: function(t) {
if (!t) {
cc.errorID(1026);
return !1;
}
this._innerAction = t;
return !0;
},
clone: function() {
var t = new cc.RepeatForever();
this._cloneDecoration(t);
t.initWithAction(this._innerAction.clone());
return t;
},
startWithTarget: function(t) {
cc.ActionInterval.prototype.startWithTarget.call(this, t);
this._innerAction.startWithTarget(t);
},
step: function(t) {
var e = this._innerAction;
e.step(t);
if (e.isDone()) {
e.startWithTarget(this.target);
e.step(e.getElapsed() - e._duration);
}
},
isDone: function() {
return !1;
},
reverse: function() {
var t = new cc.RepeatForever(this._innerAction.reverse());
this._cloneDecoration(t);
this._reverseEaseList(t);
return t;
},
setInnerAction: function(t) {
this._innerAction !== t && (this._innerAction = t);
},
getInnerAction: function() {
return this._innerAction;
}
});
cc.repeatForever = function(t) {
return new cc.RepeatForever(t);
};
cc.Spawn = cc.Class({
name: "cc.Spawn",
extends: cc.ActionInterval,
ctor: function(t) {
this._one = null;
this._two = null;
var e = t instanceof Array ? t : arguments;
if (1 !== e.length) {
var i = e.length - 1;
i >= 0 && null == e[i] && cc.logID(1015);
if (i >= 0) {
for (var n, r = e[0], s = 1; s < i; s++) if (e[s]) {
n = r;
r = cc.Spawn._actionOneTwo(n, e[s]);
}
this.initWithTwoActions(r, e[i]);
}
} else cc.errorID(1020);
},
initWithTwoActions: function(t, e) {
if (!t || !e) {
cc.errorID(1027);
return !1;
}
var i = !1, n = t._duration, r = e._duration;
if (this.initWithDuration(Math.max(n, r))) {
this._one = t;
this._two = e;
n > r ? this._two = cc.Sequence._actionOneTwo(e, cc.delayTime(n - r)) : n < r && (this._one = cc.Sequence._actionOneTwo(t, cc.delayTime(r - n)));
i = !0;
}
return i;
},
clone: function() {
var t = new cc.Spawn();
this._cloneDecoration(t);
t.initWithTwoActions(this._one.clone(), this._two.clone());
return t;
},
startWithTarget: function(t) {
cc.ActionInterval.prototype.startWithTarget.call(this, t);
this._one.startWithTarget(t);
this._two.startWithTarget(t);
},
stop: function() {
this._one.stop();
this._two.stop();
cc.Action.prototype.stop.call(this);
},
update: function(t) {
t = this._computeEaseTime(t);
this._one && this._one.update(t);
this._two && this._two.update(t);
},
reverse: function() {
var t = cc.Spawn._actionOneTwo(this._one.reverse(), this._two.reverse());
this._cloneDecoration(t);
this._reverseEaseList(t);
return t;
}
});
cc.spawn = function(t) {
var e = t instanceof Array ? t : arguments;
if (1 === e.length) {
cc.errorID(1020);
return null;
}
e.length > 0 && null == e[e.length - 1] && cc.logID(1015);
for (var i = e[0], n = 1; n < e.length; n++) null != e[n] && (i = cc.Spawn._actionOneTwo(i, e[n]));
return i;
};
cc.Spawn._actionOneTwo = function(t, e) {
var i = new cc.Spawn();
i.initWithTwoActions(t, e);
return i;
};
cc.RotateTo = cc.Class({
name: "cc.RotateTo",
extends: cc.ActionInterval,
ctor: function(t, e, i) {
this._dstAngleX = 0;
this._startAngleX = 0;
this._diffAngleX = 0;
this._dstAngleY = 0;
this._startAngleY = 0;
this._diffAngleY = 0;
void 0 !== e && this.initWithDuration(t, e, i);
},
initWithDuration: function(t, e, i) {
if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) {
this._dstAngleX = e || 0;
this._dstAngleY = void 0 !== i ? i : this._dstAngleX;
return !0;
}
return !1;
},
clone: function() {
var t = new cc.RotateTo();
this._cloneDecoration(t);
t.initWithDuration(this._duration, this._dstAngleX, this._dstAngleY);
return t;
},
startWithTarget: function(t) {
cc.ActionInterval.prototype.startWithTarget.call(this, t);
var e = t.rotationX % 360, i = this._dstAngleX - e;
i > 180 && (i -= 360);
i < -180 && (i += 360);
this._startAngleX = e;
this._diffAngleX = i;
this._startAngleY = t.rotationY % 360;
var n = this._dstAngleY - this._startAngleY;
n > 180 && (n -= 360);
n < -180 && (n += 360);
this._diffAngleY = n;
},
reverse: function() {
cc.logID(1016);
},
update: function(t) {
t = this._computeEaseTime(t);
if (this.target) {
this.target.rotationX = this._startAngleX + this._diffAngleX * t;
this.target.rotationY = this._startAngleY + this._diffAngleY * t;
}
}
});
cc.rotateTo = function(t, e, i) {
return new cc.RotateTo(t, e, i);
};
cc.RotateBy = cc.Class({
name: "cc.RotateBy",
extends: cc.ActionInterval,
ctor: function(t, e, i) {
this._angleX = 0;
this._startAngleX = 0;
this._angleY = 0;
this._startAngleY = 0;
void 0 !== e && this.initWithDuration(t, e, i);
},
initWithDuration: function(t, e, i) {
if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) {
this._angleX = e || 0;
this._angleY = void 0 !== i ? i : this._angleX;
return !0;
}
return !1;
},
clone: function() {
var t = new cc.RotateBy();
this._cloneDecoration(t);
t.initWithDuration(this._duration, this._angleX, this._angleY);
return t;
},
startWithTarget: function(t) {
cc.ActionInterval.prototype.startWithTarget.call(this, t);
this._startAngleX = t.rotationX;
this._startAngleY = t.rotationY;
},
update: function(t) {
t = this._computeEaseTime(t);
if (this.target) {
this.target.rotationX = this._startAngleX + this._angleX * t;
this.target.rotationY = this._startAngleY + this._angleY * t;
}
},
reverse: function() {
var t = new cc.RotateBy(this._duration, -this._angleX, -this._angleY);
this._cloneDecoration(t);
this._reverseEaseList(t);
return t;
}
});
cc.rotateBy = function(t, e, i) {
return new cc.RotateBy(t, e, i);
};
cc.MoveBy = cc.Class({
name: "cc.MoveBy",
extends: cc.ActionInterval,
ctor: function(t, e, i) {
this._positionDelta = cc.v2(0, 0);
this._startPosition = cc.v2(0, 0);
this._previousPosition = cc.v2(0, 0);
void 0 !== e && cc.MoveBy.prototype.initWithDuration.call(this, t, e, i);
},
initWithDuration: function(t, e, i) {
if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) {
if (void 0 !== e.x) {
i = e.y;
e = e.x;
}
this._positionDelta.x = e;
this._positionDelta.y = i;
return !0;
}
return !1;
},
clone: function() {
var t = new cc.MoveBy();
this._cloneDecoration(t);
t.initWithDuration(this._duration, this._positionDelta);
return t;
},
startWithTarget: function(t) {
cc.ActionInterval.prototype.startWithTarget.call(this, t);
var e = t.x, i = t.y;
this._previousPosition.x = e;
this._previousPosition.y = i;
this._startPosition.x = e;
this._startPosition.y = i;
},
update: function(t) {
t = this._computeEaseTime(t);
if (this.target) {
var e = this._positionDelta.x * t, i = this._positionDelta.y * t, n = this._startPosition;
if (cc.macro.ENABLE_STACKABLE_ACTIONS) {
var r = this.target.x, s = this.target.y, o = this._previousPosition;
n.x = n.x + r - o.x;
n.y = n.y + s - o.y;
e += n.x;
i += n.y;
o.x = e;
o.y = i;
this.target.setPosition(e, i);
} else this.target.setPosition(n.x + e, n.y + i);
}
},
reverse: function() {
var t = new cc.MoveBy(this._duration, cc.v2(-this._positionDelta.x, -this._positionDelta.y));
this._cloneDecoration(t);
this._reverseEaseList(t);
return t;
}
});
cc.moveBy = function(t, e, i) {
return new cc.MoveBy(t, e, i);
};
cc.MoveTo = cc.Class({
name: "cc.MoveTo",
extends: cc.MoveBy,
ctor: function(t, e, i) {
this._endPosition = cc.v2(0, 0);
void 0 !== e && this.initWithDuration(t, e, i);
},
initWithDuration: function(t, e, i) {
if (cc.MoveBy.prototype.initWithDuration.call(this, t, e, i)) {
if (void 0 !== e.x) {
i = e.y;
e = e.x;
}
this._endPosition.x = e;
this._endPosition.y = i;
return !0;
}
return !1;
},
clone: function() {
var t = new cc.MoveTo();
this._cloneDecoration(t);
t.initWithDuration(this._duration, this._endPosition);
return t;
},
startWithTarget: function(t) {
cc.MoveBy.prototype.startWithTarget.call(this, t);
this._positionDelta.x = this._endPosition.x - t.x;
this._positionDelta.y = this._endPosition.y - t.y;
}
});
cc.moveTo = function(t, e, i) {
return new cc.MoveTo(t, e, i);
};
cc.SkewTo = cc.Class({
name: "cc.SkewTo",
extends: cc.ActionInterval,
ctor: function(t, e, i) {
this._skewX = 0;
this._skewY = 0;
this._startSkewX = 0;
this._startSkewY = 0;
this._endSkewX = 0;
this._endSkewY = 0;
this._deltaX = 0;
this._deltaY = 0;
void 0 !== i && cc.SkewTo.prototype.initWithDuration.call(this, t, e, i);
},
initWithDuration: function(t, e, i) {
var n = !1;
if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) {
this._endSkewX = e;
this._endSkewY = i;
n = !0;
}
return n;
},
clone: function() {
var t = new cc.SkewTo();
this._cloneDecoration(t);
t.initWithDuration(this._duration, this._endSkewX, this._endSkewY);
return t;
},
startWithTarget: function(t) {
cc.ActionInterval.prototype.startWithTarget.call(this, t);
this._startSkewX = t.skewX % 180;
this._deltaX = this._endSkewX - this._startSkewX;
this._deltaX > 180 && (this._deltaX -= 360);
this._deltaX < -180 && (this._deltaX += 360);
this._startSkewY = t.skewY % 360;
this._deltaY = this._endSkewY - this._startSkewY;
this._deltaY > 180 && (this._deltaY -= 360);
this._deltaY < -180 && (this._deltaY += 360);
},
update: function(t) {
t = this._computeEaseTime(t);
this.target.skewX = this._startSkewX + this._deltaX * t;
this.target.skewY = this._startSkewY + this._deltaY * t;
}
});
cc.skewTo = function(t, e, i) {
return new cc.SkewTo(t, e, i);
};
cc.SkewBy = cc.Class({
name: "cc.SkewBy",
extends: cc.SkewTo,
ctor: function(t, e, i) {
void 0 !== i && this.initWithDuration(t, e, i);
},
initWithDuration: function(t, e, i) {
var n = !1;
if (cc.SkewTo.prototype.initWithDuration.call(this, t, e, i)) {
this._skewX = e;
this._skewY = i;
n = !0;
}
return n;
},
clone: function() {
var t = new cc.SkewBy();
this._cloneDecoration(t);
t.initWithDuration(this._duration, this._skewX, this._skewY);
return t;
},
startWithTarget: function(t) {
cc.SkewTo.prototype.startWithTarget.call(this, t);
this._deltaX = this._skewX;
this._deltaY = this._skewY;
this._endSkewX = this._startSkewX + this._deltaX;
this._endSkewY = this._startSkewY + this._deltaY;
},
reverse: function() {
var t = new cc.SkewBy(this._duration, -this._skewX, -this._skewY);
this._cloneDecoration(t);
this._reverseEaseList(t);
return t;
}
});
cc.skewBy = function(t, e, i) {
return new cc.SkewBy(t, e, i);
};
cc.JumpBy = cc.Class({
name: "cc.JumpBy",
extends: cc.ActionInterval,
ctor: function(t, e, i, n, r) {
this._startPosition = cc.v2(0, 0);
this._previousPosition = cc.v2(0, 0);
this._delta = cc.v2(0, 0);
this._height = 0;
this._jumps = 0;
void 0 !== n && cc.JumpBy.prototype.initWithDuration.call(this, t, e, i, n, r);
},
initWithDuration: function(t, e, i, n, r) {
if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) {
if (void 0 === r) {
r = n;
n = i;
i = e.y;
e = e.x;
}
this._delta.x = e;
this._delta.y = i;
this._height = n;
this._jumps = r;
return !0;
}
return !1;
},
clone: function() {
var t = new cc.JumpBy();
this._cloneDecoration(t);
t.initWithDuration(this._duration, this._delta, this._height, this._jumps);
return t;
},
startWithTarget: function(t) {
cc.ActionInterval.prototype.startWithTarget.call(this, t);
var e = t.x, i = t.y;
this._previousPosition.x = e;
this._previousPosition.y = i;
this._startPosition.x = e;
this._startPosition.y = i;
},
update: function(t) {
t = this._computeEaseTime(t);
if (this.target) {
var e = t * this._jumps % 1, i = 4 * this._height * e * (1 - e);
i += this._delta.y * t;
var n = this._delta.x * t, r = this._startPosition;
if (cc.macro.ENABLE_STACKABLE_ACTIONS) {
var s = this.target.x, o = this.target.y, a = this._previousPosition;
r.x = r.x + s - a.x;
r.y = r.y + o - a.y;
n += r.x;
i += r.y;
a.x = n;
a.y = i;
this.target.setPosition(n, i);
} else this.target.setPosition(r.x + n, r.y + i);
}
},
reverse: function() {
var t = new cc.JumpBy(this._duration, cc.v2(-this._delta.x, -this._delta.y), this._height, this._jumps);
this._cloneDecoration(t);
this._reverseEaseList(t);
return t;
}
});
cc.jumpBy = function(t, e, i, n, r) {
return new cc.JumpBy(t, e, i, n, r);
};
cc.JumpTo = cc.Class({
name: "cc.JumpTo",
extends: cc.JumpBy,
ctor: function(t, e, i, n, r) {
this._endPosition = cc.v2(0, 0);
void 0 !== n && this.initWithDuration(t, e, i, n, r);
},
initWithDuration: function(t, e, i, n, r) {
if (cc.JumpBy.prototype.initWithDuration.call(this, t, e, i, n, r)) {
if (void 0 === r) {
i = e.y;
e = e.x;
}
this._endPosition.x = e;
this._endPosition.y = i;
return !0;
}
return !1;
},
startWithTarget: function(t) {
cc.JumpBy.prototype.startWithTarget.call(this, t);
this._delta.x = this._endPosition.x - this._startPosition.x;
this._delta.y = this._endPosition.y - this._startPosition.y;
},
clone: function() {
var t = new cc.JumpTo();
this._cloneDecoration(t);
t.initWithDuration(this._duration, this._endPosition, this._height, this._jumps);
return t;
}
});
cc.jumpTo = function(t, e, i, n, r) {
return new cc.JumpTo(t, e, i, n, r);
};
function n(t, e, i, n, r) {
return Math.pow(1 - r, 3) * t + 3 * r * Math.pow(1 - r, 2) * e + 3 * Math.pow(r, 2) * (1 - r) * i + Math.pow(r, 3) * n;
}
cc.BezierBy = cc.Class({
name: "cc.BezierBy",
extends: cc.ActionInterval,
ctor: function(t, e) {
this._config = [];
this._startPosition = cc.v2(0, 0);
this._previousPosition = cc.v2(0, 0);
e && cc.BezierBy.prototype.initWithDuration.call(this, t, e);
},
initWithDuration: function(t, e) {
if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) {
this._config = e;
return !0;
}
return !1;
},
clone: function() {
var t = new cc.BezierBy();
this._cloneDecoration(t);
for (var e = [], i = 0; i < this._config.length; i++) {
var n = this._config[i];
e.push(cc.v2(n.x, n.y));
}
t.initWithDuration(this._duration, e);
return t;
},
startWithTarget: function(t) {
cc.ActionInterval.prototype.startWithTarget.call(this, t);
var e = t.x, i = t.y;
this._previousPosition.x = e;
this._previousPosition.y = i;
this._startPosition.x = e;
this._startPosition.y = i;
},
update: function(t) {
t = this._computeEaseTime(t);
if (this.target) {
var e = this._config, i = e[0].x, r = e[1].x, s = e[2].x, o = e[0].y, a = e[1].y, c = e[2].y, h = n(0, i, r, s, t), l = n(0, o, a, c, t), u = this._startPosition;
if (cc.macro.ENABLE_STACKABLE_ACTIONS) {
var _ = this.target.x, f = this.target.y, d = this._previousPosition;
u.x = u.x + _ - d.x;
u.y = u.y + f - d.y;
h += u.x;
l += u.y;
d.x = h;
d.y = l;
this.target.setPosition(h, l);
} else this.target.setPosition(u.x + h, u.y + l);
}
},
reverse: function() {
var t = this._config, e = t[0].x, i = t[0].y, n = t[1].x, r = t[1].y, s = t[2].x, o = t[2].y, a = [ cc.v2(n - s, r - o), cc.v2(e - s, i - o), cc.v2(-s, -o) ], c = new cc.BezierBy(this._duration, a);
this._cloneDecoration(c);
this._reverseEaseList(c);
return c;
}
});
cc.bezierBy = function(t, e) {
return new cc.BezierBy(t, e);
};
cc.BezierTo = cc.Class({
name: "cc.BezierTo",
extends: cc.BezierBy,
ctor: function(t, e) {
this._toConfig = [];
e && this.initWithDuration(t, e);
},
initWithDuration: function(t, e) {
if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) {
this._toConfig = e;
return !0;
}
return !1;
},
clone: function() {
var t = new cc.BezierTo();
this._cloneDecoration(t);
t.initWithDuration(this._duration, this._toConfig);
return t;
},
startWithTarget: function(t) {
cc.BezierBy.prototype.startWithTarget.call(this, t);
var e = this._startPosition, i = this._toConfig, n = this._config;
n[0] = i[0].sub(e);
n[1] = i[1].sub(e);
n[2] = i[2].sub(e);
}
});
cc.bezierTo = function(t, e) {
return new cc.BezierTo(t, e);
};
cc.ScaleTo = cc.Class({
name: "cc.ScaleTo",
extends: cc.ActionInterval,
ctor: function(t, e, i) {
this._scaleX = 1;
this._scaleY = 1;
this._startScaleX = 1;
this._startScaleY = 1;
this._endScaleX = 0;
this._endScaleY = 0;
this._deltaX = 0;
this._deltaY = 0;
void 0 !== e && cc.ScaleTo.prototype.initWithDuration.call(this, t, e, i);
},
initWithDuration: function(t, e, i) {
if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) {
this._endScaleX = e;
this._endScaleY = null != i ? i : e;
return !0;
}
return !1;
},
clone: function() {
var t = new cc.ScaleTo();
this._cloneDecoration(t);
t.initWithDuration(this._duration, this._endScaleX, this._endScaleY);
return t;
},
startWithTarget: function(t) {
cc.ActionInterval.prototype.startWithTarget.call(this, t);
this._startScaleX = t.scaleX;
this._startScaleY = t.scaleY;
this._deltaX = this._endScaleX - this._startScaleX;
this._deltaY = this._endScaleY - this._startScaleY;
},
update: function(t) {
t = this._computeEaseTime(t);
if (this.target) {
this.target.scaleX = this._startScaleX + this._deltaX * t;
this.target.scaleY = this._startScaleY + this._deltaY * t;
}
}
});
cc.scaleTo = function(t, e, i) {
return new cc.ScaleTo(t, e, i);
};
cc.ScaleBy = cc.Class({
name: "cc.ScaleBy",
extends: cc.ScaleTo,
startWithTarget: function(t) {
cc.ScaleTo.prototype.startWithTarget.call(this, t);
this._deltaX = this._startScaleX * this._endScaleX - this._startScaleX;
this._deltaY = this._startScaleY * this._endScaleY - this._startScaleY;
},
reverse: function() {
var t = new cc.ScaleBy(this._duration, 1 / this._endScaleX, 1 / this._endScaleY);
this._cloneDecoration(t);
this._reverseEaseList(t);
return t;
},
clone: function() {
var t = new cc.ScaleBy();
this._cloneDecoration(t);
t.initWithDuration(this._duration, this._endScaleX, this._endScaleY);
return t;
}
});
cc.scaleBy = function(t, e, i) {
return new cc.ScaleBy(t, e, i);
};
cc.Blink = cc.Class({
name: "cc.Blink",
extends: cc.ActionInterval,
ctor: function(t, e) {
this._times = 0;
this._originalState = !1;
void 0 !== e && this.initWithDuration(t, e);
},
initWithDuration: function(t, e) {
if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) {
this._times = e;
return !0;
}
return !1;
},
clone: function() {
var t = new cc.Blink();
this._cloneDecoration(t);
t.initWithDuration(this._duration, this._times);
return t;
},
update: function(t) {
t = this._computeEaseTime(t);
if (this.target && !this.isDone()) {
var e = 1 / this._times, i = t % e;
this.target.opacity = i > e / 2 ? 255 : 0;
}
},
startWithTarget: function(t) {
cc.ActionInterval.prototype.startWithTarget.call(this, t);
this._originalState = t.opacity;
},
stop: function() {
this.target.opacity = this._originalState;
cc.ActionInterval.prototype.stop.call(this);
},
reverse: function() {
var t = new cc.Blink(this._duration, this._times);
this._cloneDecoration(t);
this._reverseEaseList(t);
return t;
}
});
cc.blink = function(t, e) {
return new cc.Blink(t, e);
};
cc.FadeTo = cc.Class({
name: "cc.FadeTo",
extends: cc.ActionInterval,
ctor: function(t, e) {
this._toOpacity = 0;
this._fromOpacity = 0;
void 0 !== e && cc.FadeTo.prototype.initWithDuration.call(this, t, e);
},
initWithDuration: function(t, e) {
if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) {
this._toOpacity = e;
return !0;
}
return !1;
},
clone: function() {
var t = new cc.FadeTo();
this._cloneDecoration(t);
t.initWithDuration(this._duration, this._toOpacity);
return t;
},
update: function(t) {
t = this._computeEaseTime(t);
var e = void 0 !== this._fromOpacity ? this._fromOpacity : 255;
this.target.opacity = e + (this._toOpacity - e) * t;
},
startWithTarget: function(t) {
cc.ActionInterval.prototype.startWithTarget.call(this, t);
this._fromOpacity = t.opacity;
}
});
cc.fadeTo = function(t, e) {
return new cc.FadeTo(t, e);
};
cc.FadeIn = cc.Class({
name: "cc.FadeIn",
extends: cc.FadeTo,
ctor: function(t) {
null == t && (t = 0);
this._reverseAction = null;
this.initWithDuration(t, 255);
},
reverse: function() {
var t = new cc.FadeOut();
t.initWithDuration(this._duration, 0);
this._cloneDecoration(t);
this._reverseEaseList(t);
return t;
},
clone: function() {
var t = new cc.FadeIn();
this._cloneDecoration(t);
t.initWithDuration(this._duration, this._toOpacity);
return t;
},
startWithTarget: function(t) {
this._reverseAction && (this._toOpacity = this._reverseAction._fromOpacity);
cc.FadeTo.prototype.startWithTarget.call(this, t);
}
});
cc.fadeIn = function(t) {
return new cc.FadeIn(t);
};
cc.FadeOut = cc.Class({
name: "cc.FadeOut",
extends: cc.FadeTo,
ctor: function(t) {
null == t && (t = 0);
this._reverseAction = null;
this.initWithDuration(t, 0);
},
reverse: function() {
var t = new cc.FadeIn();
t._reverseAction = this;
t.initWithDuration(this._duration, 255);
this._cloneDecoration(t);
this._reverseEaseList(t);
return t;
},
clone: function() {
var t = new cc.FadeOut();
this._cloneDecoration(t);
t.initWithDuration(this._duration, this._toOpacity);
return t;
}
});
cc.fadeOut = function(t) {
return new cc.FadeOut(t);
};
cc.TintTo = cc.Class({
name: "cc.TintTo",
extends: cc.ActionInterval,
ctor: function(t, e, i, n) {
this._to = cc.color(0, 0, 0);
this._from = cc.color(0, 0, 0);
if (e instanceof cc.Color) {
n = e.b;
i = e.g;
e = e.r;
}
void 0 !== n && this.initWithDuration(t, e, i, n);
},
initWithDuration: function(t, e, i, n) {
if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) {
this._to = cc.color(e, i, n);
return !0;
}
return !1;
},
clone: function() {
var t = new cc.TintTo();
this._cloneDecoration(t);
var e = this._to;
t.initWithDuration(this._duration, e.r, e.g, e.b);
return t;
},
startWithTarget: function(t) {
cc.ActionInterval.prototype.startWithTarget.call(this, t);
this._from = this.target.color;
},
update: function(t) {
t = this._computeEaseTime(t);
var e = this._from, i = this._to;
e && (this.target.color = cc.color(e.r + (i.r - e.r) * t, e.g + (i.g - e.g) * t, e.b + (i.b - e.b) * t));
}
});
cc.tintTo = function(t, e, i, n) {
return new cc.TintTo(t, e, i, n);
};
cc.TintBy = cc.Class({
name: "cc.TintBy",
extends: cc.ActionInterval,
ctor: function(t, e, i, n) {
this._deltaR = 0;
this._deltaG = 0;
this._deltaB = 0;
this._fromR = 0;
this._fromG = 0;
this._fromB = 0;
void 0 !== n && this.initWithDuration(t, e, i, n);
},
initWithDuration: function(t, e, i, n) {
if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) {
this._deltaR = e;
this._deltaG = i;
this._deltaB = n;
return !0;
}
return !1;
},
clone: function() {
var t = new cc.TintBy();
this._cloneDecoration(t);
t.initWithDuration(this._duration, this._deltaR, this._deltaG, this._deltaB);
return t;
},
startWithTarget: function(t) {
cc.ActionInterval.prototype.startWithTarget.call(this, t);
var e = t.color;
this._fromR = e.r;
this._fromG = e.g;
this._fromB = e.b;
},
update: function(t) {
t = this._computeEaseTime(t);
this.target.color = cc.color(this._fromR + this._deltaR * t, this._fromG + this._deltaG * t, this._fromB + this._deltaB * t);
},
reverse: function() {
var t = new cc.TintBy(this._duration, -this._deltaR, -this._deltaG, -this._deltaB);
this._cloneDecoration(t);
this._reverseEaseList(t);
return t;
}
});
cc.tintBy = function(t, e, i, n) {
return new cc.TintBy(t, e, i, n);
};
cc.DelayTime = cc.Class({
name: "cc.DelayTime",
extends: cc.ActionInterval,
update: function(t) {},
reverse: function() {
var t = new cc.DelayTime(this._duration);
this._cloneDecoration(t);
this._reverseEaseList(t);
return t;
},
clone: function() {
var t = new cc.DelayTime();
this._cloneDecoration(t);
t.initWithDuration(this._duration);
return t;
}
});
cc.delayTime = function(t) {
return new cc.DelayTime(t);
};
cc.ReverseTime = cc.Class({
name: "cc.ReverseTime",
extends: cc.ActionInterval,
ctor: function(t) {
this._other = null;
t && this.initWithAction(t);
},
initWithAction: function(t) {
if (!t) {
cc.errorID(1028);
return !1;
}
if (t === this._other) {
cc.errorID(1029);
return !1;
}
if (cc.ActionInterval.prototype.initWithDuration.call(this, t._duration)) {
this._other = t;
return !0;
}
return !1;
},
clone: function() {
var t = new cc.ReverseTime();
this._cloneDecoration(t);
t.initWithAction(this._other.clone());
return t;
},
startWithTarget: function(t) {
cc.ActionInterval.prototype.startWithTarget.call(this, t);
this._other.startWithTarget(t);
},
update: function(t) {
t = this._computeEaseTime(t);
this._other && this._other.update(1 - t);
},
reverse: function() {
return this._other.clone();
},
stop: function() {
this._other.stop();
cc.Action.prototype.stop.call(this);
}
});
cc.reverseTime = function(t) {
return new cc.ReverseTime(t);
};
cc.TargetedAction = cc.Class({
name: "cc.TargetedAction",
extends: cc.ActionInterval,
ctor: function(t, e) {
this._action = null;
this._forcedTarget = null;
e && this.initWithTarget(t, e);
},
initWithTarget: function(t, e) {
if (this.initWithDuration(e._duration)) {
this._forcedTarget = t;
this._action = e;
return !0;
}
return !1;
},
clone: function() {
var t = new cc.TargetedAction();
this._cloneDecoration(t);
t.initWithTarget(this._forcedTarget, this._action.clone());
return t;
},
startWithTarget: function(t) {
cc.ActionInterval.prototype.startWithTarget.call(this, t);
this._action.startWithTarget(this._forcedTarget);
},
stop: function() {
this._action.stop();
},
update: function(t) {
t = this._computeEaseTime(t);
this._action.update(t);
},
getForcedTarget: function() {
return this._forcedTarget;
},
setForcedTarget: function(t) {
this._forcedTarget !== t && (this._forcedTarget = t);
}
});
cc.targetedAction = function(t, e) {
return new cc.TargetedAction(t, e);
};
}), {} ],
6: [ (function(t, e, i) {
t("../core/platform/CCClass");
var n = t("../core/platform/js");
cc.ActionManager = function() {
this._hashTargets = n.createMap(!0);
this._arrayTargets = [];
this._currentTarget = null;
cc.director._scheduler && cc.director._scheduler.enableForTarget(this);
};
cc.ActionManager.prototype = {
constructor: cc.ActionManager,
_elementPool: [],
_searchElementByTarget: function(t, e) {
for (var i = 0; i < t.length; i++) if (e === t[i].target) return t[i];
return null;
},
_getElement: function(t, e) {
var i = this._elementPool.pop();
i || (i = new function() {
this.actions = [];
this.target = null;
this.actionIndex = 0;
this.currentAction = null;
this.paused = !1;
this.lock = !1;
}());
i.target = t;
i.paused = !!e;
return i;
},
_putElement: function(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: function(t, e, i) {
if (t && e) {
var n = this._hashTargets[e._id];
if (n) n.actions || (n.actions = []); else {
n = this._getElement(e, i);
this._hashTargets[e._id] = n;
this._arrayTargets.push(n);
}
n.actions.push(t);
t.startWithTarget(e);
} else cc.errorID(1e3);
},
removeAllActions: function() {
for (var t = this._arrayTargets, e = 0; e < t.length; e++) {
var i = t[e];
i && this._putElement(i);
}
this._arrayTargets.length = 0;
this._hashTargets = n.createMap(!0);
},
removeAllActionsFromTarget: function(t, e) {
if (null != t) {
var i = this._hashTargets[t._id];
if (i) {
i.actions.length = 0;
this._deleteHashElement(i);
}
}
},
removeAction: function(t) {
if (null != t) {
var e = t.getOriginalTarget(), i = this._hashTargets[e._id];
if (i) {
for (var n = 0; n < i.actions.length; n++) if (i.actions[n] === t) {
i.actions.splice(n, 1);
i.actionIndex >= n && i.actionIndex--;
break;
}
} else cc.logID(1001);
}
},
removeActionByTag: function(t, e) {
t === cc.Action.TAG_INVALID && cc.logID(1002);
cc.assertID(e, 1003);
var i = this._hashTargets[e._id];
if (i) for (var n = i.actions.length, r = 0; r < n; ++r) {
var s = i.actions[r];
if (s && s.getTag() === t && s.getOriginalTarget() === e) {
this._removeActionAtIndex(r, i);
break;
}
}
},
getActionByTag: function(t, e) {
t === cc.Action.TAG_INVALID && cc.logID(1004);
var i = this._hashTargets[e._id];
if (i) {
if (null != i.actions) for (var n = 0; n < i.actions.length; ++n) {
var r = i.actions[n];
if (r && r.getTag() === t) return r;
}
cc.logID(1005, t);
}
return null;
},
getNumberOfRunningActionsInTarget: function(t) {
var e = this._hashTargets[t._id];
return e && e.actions ? e.actions.length : 0;
},
pauseTarget: function(t) {
var e = this._hashTargets[t._id];
e && (e.paused = !0);
},
resumeTarget: function(t) {
var e = this._hashTargets[t._id];
e && (e.paused = !1);
},
pauseAllRunningActions: function() {
for (var t = [], e = this._arrayTargets, i = 0; i < e.length; i++) {
var n = e[i];
if (n && !n.paused) {
n.paused = !0;
t.push(n.target);
}
}
return t;
},
resumeTargets: function(t) {
if (t) for (var e = 0; e < t.length; e++) t[e] && this.resumeTarget(t[e]);
},
pauseTargets: function(t) {
if (t) for (var e = 0; e < t.length; e++) t[e] && this.pauseTarget(t[e]);
},
purgeSharedManager: function() {
cc.director.getScheduler().unscheduleUpdate(this);
},
_removeActionAtIndex: function(t, e) {
e.actions[t];
e.actions.splice(t, 1);
e.actionIndex >= t && e.actionIndex--;
0 === e.actions.length && this._deleteHashElement(e);
},
_deleteHashElement: function(t) {
var e = !1;
if (t && !t.lock && this._hashTargets[t.target._id]) {
delete this._hashTargets[t.target._id];
for (var i = this._arrayTargets, n = 0, r = i.length; n < r; n++) if (i[n] === t) {
i.splice(n, 1);
break;
}
this._putElement(t);
e = !0;
}
return e;
},
update: function(t) {
for (var e, i = this._arrayTargets, n = 0; n < i.length; n++) {
this._currentTarget = i[n];
if (!(e = this._currentTarget).paused && e.actions) {
e.lock = !0;
for (e.actionIndex = 0; e.actionIndex < e.actions.length; e.actionIndex++) {
e.currentAction = e.actions[e.actionIndex];
if (e.currentAction) {
e.currentAction.step(t * (e.currentAction._speedMethod ? e.currentAction._speed : 1));
if (e.currentAction && e.currentAction.isDone()) {
e.currentAction.stop();
var r = e.currentAction;
e.currentAction = null;
this.removeAction(r);
}
e.currentAction = null;
}
}
e.lock = !1;
}
0 === e.actions.length && this._deleteHashElement(e) && n--;
}
}
};
0;
}), {
"../core/platform/CCClass": 160,
"../core/platform/js": 180
} ],
7: [ (function(t, e, i) {
t("./CCActionManager");
t("./CCAction");
t("./CCActionInterval");
t("./CCActionInstant");
t("./CCActionEase");
t("./CCActionCatmullRom");
t("./tween");
}), {
"./CCAction": 1,
"./CCActionCatmullRom": 2,
"./CCActionEase": 3,
"./CCActionInstant": 4,
"./CCActionInterval": 5,
"./CCActionManager": 6,
"./tween": 8
} ],
8: [ (function(i, n, r) {
var s = cc.Class({
name: "cc.TweenAction",
extends: cc.ActionInterval,
ctor: function(i, n, r) {
this._opts = r = r || Object.create(null);
this._props = Object.create(null);
r.progress = r.progress || this.progress;
r.easing && "string" === ("object" === (e = typeof r.easing) ? t(r.easing) : e) && (r.easing = cc.easing[r.easing]);
for (var s in n) {
var o = n[s], a = void 0, c = void 0;
if (o.value && (o.easing || o.progress)) {
a = "string" === ("object" === (e = typeof o.easing) ? t(o.easing) : e) ? cc.easing[o.easing] : o.easing;
c = o.progress;
o = o.value;
}
if ("number" === ("object" === (e = typeof o) ? t(o) : e) || o.lerp && (o.add || o.mul) && o.clone) {
var h = Object.create(null);
h.value = o;
h.easing = a;
h.progress = c;
this._props[s] = h;
} else cc.warn("Can not animate " + s + " property, because it do not have [lerp, (add|mul), clone] function.");
}
this._originProps = n;
this.initWithDuration(i);
},
clone: function() {
var t = new s(this._duration, this._originProps, this._opts);
this._cloneDecoration(t);
return t;
},
startWithTarget: function(i) {
cc.ActionInterval.prototype.startWithTarget.call(this, i);
var n = !!this._opts.relative, r = this._props;
for (var s in r) {
var o = i[s], a = r[s];
if ("number" === ("object" === (e = typeof o) ? t(o) : e)) {
a.start = o;
a.current = o;
a.end = n ? o + a.value : a.value;
} else {
a.start = o.clone();
a.current = o.clone();
a.end = n ? (o.add || o.mul).call(o, a.value) : a.value;
}
}
},
update: function(t) {
var e = this._opts, i = t;
e.easing && (i = e.easing(t));
var n = this.target;
if (n) {
var r = this._props, s = this._opts.progress;
for (var o in r) {
var a = r[o], c = a.easing ? a.easing(t) : i, h = a.current = (a.progress || s)(a.start, a.end, a.current, c);
n[o] = h;
}
}
},
progress: function(i, n, r, s) {
"number" === ("object" === (e = typeof i) ? t(i) : e) ? r = i + (n - i) * s : i.lerp(n, s, r);
return r;
}
});
function o(t) {
this._actions = [];
this._finalAction = null;
this._target = t;
}
o.prototype.then = function(t) {
if (t instanceof cc.Action) this._actions.push(t.clone()); else for (var e = t._actions, i = 0; i < e.length; i++) this._actions.push(e[i].clone());
return this;
};
o.prototype.target = function(t) {
this._target = t;
return this;
};
o.prototype.start = function() {
if (!this._target) {
cc.warn("Please set target to tween first");
return this;
}
this._finalAction || (this._finalAction = this._get());
cc.director.getActionManager().addAction(this._finalAction, this._target, !1);
return this;
};
o.prototype.stop = function() {
this._finalAction && cc.director.getActionManager().removeAction(this._finalAction);
return this;
};
o.prototype.clone = function(t) {
var e = this._get();
return cc.tween(t).then(e.clone());
};
o.prototype._get = function() {
var t = this._actions;
return t = 1 === t.length ? t[0] : cc.sequence(t);
};
for (var a = {
to: function(t, e, i) {
(i = i || Object.create(null)).relative = !1;
return new s(t, e, i);
},
by: function(t, e, i) {
(i = i || Object.create(null)).relative = !0;
return new s(t, e, i);
},
delay: cc.delayTime,
call: cc.callFunc,
hide: cc.hide,
show: cc.show,
removeSelf: cc.removeSelf,
sequence: cc.sequence
}, c = {
repeat: cc.repeat,
repeatForever: cc.repeatForever,
reverseTime: cc.reverseTime
}, h = Object.keys(a), l = function(t) {
var e = h[t];
o.prototype[e] = function() {
var t = a[e].apply(a, arguments);
this._actions.push(t);
this._finalAction = null;
return this;
};
}, u = 0; u < h.length; u++) l(u);
h = Object.keys(c);
var _ = function(t) {
var e = h[t];
o.prototype[e] = function() {
for (var t = [], i = arguments.length, n = 0; n < i; n++) t[n] = arguments[n];
var r = arguments[0];
r instanceof cc.Action || (r = this._get());
r = c[e].apply(c, [ r ].concat(t));
this._actions.length = 0;
this._actions.push(r);
this._finalAction = null;
return this;
};
};
for (u = 0; u < h.length; u++) _(u);
cc.tween = function(t) {
return new o(t);
};
cc.Tween = o;
}), {} ],
9: [ (function(i, n, r) {
var s = cc.js, o = i("./playable"), a = i("./animation-curves").DynamicAnimCurve, c = i("./animation-curves").quickFindIndex, h = i("./motion-path-helper").sampleMotionPaths, l = i("./animation-curves").EventAnimCurve, u = i("./animation-curves").EventInfo, _ = i("./types").WrapModeMask, f = i("../core/utils/binary-search").binarySearchEpsilon;
function d(t, e) {
o.call(this);
this.target = t;
this.animation = e;
this._anims = new s.array.MutableForwardIterator([]);
}
s.extend(d, o);
var m = d.prototype;
m.playState = function(i, n) {
if (i.clip) {
i.curveLoaded || p(this.target, i);
i.animator = this;
i.play();
"number" === ("object" === (e = typeof n) ? t(n) : e) && i.setTime(n);
this.play();
}
};
m.stopStatesExcept = function(t) {
var e = this._anims, i = e.array;
for (e.i = 0; e.i < i.length; ++e.i) {
var n = i[e.i];
n !== t && this.stopState(n);
}
};
m.addAnimation = function(t) {
-1 === this._anims.array.indexOf(t) && this._anims.push(t);
t._setEventTarget(this.animation);
};
m.removeAnimation = function(t) {
var e = this._anims.array.indexOf(t);
if (e >= 0) {
this._anims.fastRemoveAt(e);
0 === this._anims.array.length && this.stop();
} else cc.errorID(3908);
t.animator = null;
};
m.sample = function() {
var t = this._anims, e = t.array;
for (t.i = 0; t.i < e.length; ++t.i) {
e[t.i].sample();
}
};
m.stopState = function(t) {
t && t.stop();
};
m.pauseState = function(t) {
t && t.pause();
};
m.resumeState = function(t) {
t && t.resume();
this.isPaused && this.resume();
};
m.setStateTime = function(t, e) {
if (void 0 !== e) {
if (t) {
t.setTime(e);
t.sample();
}
} else {
e = t;
for (var i = this._anims.array, n = 0; n < i.length; ++n) {
var r = i[n];
r.setTime(e);
r.sample();
}
}
};
m.onStop = function() {
var t = this._anims, e = t.array;
for (t.i = 0; t.i < e.length; ++t.i) {
e[t.i].stop();
}
};
m.onPause = function() {
for (var t = this._anims.array, e = 0; e < t.length; ++e) {
var i = t[e];
i.pause();
i.animator = null;
}
};
m.onResume = function() {
for (var t = this._anims.array, e = 0; e < t.length; ++e) {
var i = t[e];
i.animator = this;
i.resume();
}
};
m._reloadClip = function(t) {
p(this.target, t);
};
0;
function p(i, n) {
var r = n.clip, s = n.curves;
s.length = 0;
n.duration = r.duration;
n.speed = r.speed;
n.wrapMode = r.wrapMode;
n.frameRate = r.sample;
(n.wrapMode & _.Loop) === _.Loop ? n.repeatCount = Infinity : n.repeatCount = 1;
function o(t) {
if (!Array.isArray(t)) return !1;
for (var e = 0, i = t.length; e < i; e++) {
var n = t[e];
if (!Array.isArray(n) || 6 !== n.length) return !1;
}
return !0;
}
function d(i, s, l) {
var u, _ = i instanceof cc.Node && "position" === s && l[0] && Array.isArray(l[0].value), d = [], m = new a();
m.target = i;
var p = s.indexOf(".");
-1 !== p ? i[u = s.slice(0, p)] : u = s;
m.prop = u;
m.subProps = (function(t) {
var e = t.split(".");
e.shift();
return e.length > 0 ? e : null;
})(s);
for (var v = 0, y = l.length; v < y; v++) {
var g = l[v], x = g.frame / n.duration;
m.ratios.push(x);
if (_) {
var C = g.motionPath;
if (C && !o(C)) {
cc.errorID(3904, i.name, s, v);
C = null;
}
d.push(C);
}
var A = g.value;
m.values.push(A);
var b = g.curve;
if (b) {
if ("string" === ("object" === (e = typeof b) ? t(b) : e)) {
m.types.push(b);
continue;
}
if (Array.isArray(b)) {
b[0] === b[1] && b[2] === b[3] ? m.types.push(a.Linear) : m.types.push(a.Bezier(b));
continue;
}
}
m.types.push(a.Linear);
}
_ && h(d, m, r.duration, r.sample);
for (var S, T, w = m.ratios, E = !0, B = 1, M = w.length; B < M; B++) {
S = w[B] - w[B - 1];
if (1 === B) T = S; else if (Math.abs(S - T) > 1e-6) {
E = !1;
break;
}
}
m._findFrameIndex = E ? c : f;
return m;
}
function m(t, e) {
var i = e.props, n = e.comps;
if (i) for (var r in i) {
var o = d(t, r, i[r]);
s.push(o);
}
if (n) for (var a in n) {
var c = t.getComponent(a);
if (c) {
var h = n[a];
for (var r in h) {
o = d(c, r, h[r]);
s.push(o);
}
}
}
}
var p = r.curveData, v = p.paths;
m(i, p);
for (var y in v) {
var g = cc.find(y, i);
if (g) {
m(g, v[y]);
}
}
var x = r.events;
if (x) for (var C, A = 0, b = x.length; A < b; A++) {
if (!C) {
(C = new l()).target = i;
s.push(C);
}
var S, T = x[A], w = T.frame / n.duration, E = f(C.ratios, w);
if (E >= 0) S = C.events[E]; else {
S = new u();
C.ratios.push(w);
C.events.push(S);
}
S.add(T.func, T.params);
}
}
0;
n.exports = d;
}), {
"../core/utils/binary-search": 236,
"./animation-curves": 11,
"./motion-path-helper": 17,
"./playable": 18,
"./types": 19
} ],
10: [ (function(t, e, i) {
var n = cc.Class({
name: "cc.AnimationClip",
extends: cc.Asset,
properties: {
_duration: {
default: 0,
type: "Float"
},
duration: {
get: function() {
return this._duration;
}
},
sample: {
default: 60
},
speed: {
default: 1
},
wrapMode: {
default: cc.WrapMode.Normal
},
curveData: {
default: {},
visible: !1
},
events: {
default: [],
visible: !1
}
},
statics: {
createWithSpriteFrames: function(t, e) {
if (!Array.isArray(t)) {
cc.errorID(3905);
return null;
}
var i = new n();
i.sample = e || i.sample;
i._duration = t.length / i.sample;
for (var r = [], s = 1 / i.sample, o = 0, a = t.length; o < a; o++) r[o] = {
frame: o * s,
value: t[o]
};
i.curveData = {
comps: {
"cc.Sprite": {
spriteFrame: r
}
}
};
return i;
}
}
});
cc.AnimationClip = e.exports = n;
}), {} ],
11: [ (function(i, n, r) {
var s = i("./bezier").bezierByTime, o = i("../core/utils/binary-search").binarySearchEpsilon, a = i("./types").WrapModeMask, c = i("./types").WrappedInfo;
function h(i, n) {
if ("string" === ("object" === (e = typeof n) ? t(n) : e)) {
var r = cc.easing[n];
r ? i = r(i) : cc.errorID(3906, n);
} else Array.isArray(n) && (i = s(n, i));
return i;
}
var l = cc.Class({
name: "cc.AnimCurve",
sample: function(t, e, i) {},
onTimeChangedManually: void 0
});
function u(t, e) {
var i = t.length - 1;
if (0 === i) return 0;
var n = t[0];
if (e < n) return 0;
var r = t[i];
if (e > r) return i;
var s = (e = (e - n) / (r - n)) / (1 / i), o = 0 | s;
return s - o < 1e-6 ? o : o + 1 - s < 1e-6 ? o + 1 : ~(o + 1);
}
var _ = cc.Class({
name: "cc.DynamicAnimCurve",
extends: l,
properties: {
target: null,
prop: "",
values: [],
ratios: [],
types: [],
subProps: null
},
_findFrameIndex: o,
sample: function(i, n, r) {
var s = this.values, o = this.ratios, a = o.length;
if (0 !== a) {
var c, l = this._findFrameIndex(o, n);
if (l < 0) if ((l = ~l) <= 0) c = s[0]; else if (l >= a) c = s[a - 1]; else {
var u = s[l - 1], _ = "number" === ("object" === (e = typeof u) ? t(u) : e), f = u && u.lerp;
if (_ || f) {
var d = o[l - 1], m = o[l], p = this.types[l - 1], v = (n - d) / (m - d);
p && (v = h(v, p));
var y = s[l];
_ ? c = u + (y - u) * v : f && (c = u.lerp(y, v));
} else c = u;
} else c = s[l];
var g = this.subProps;
if (g) {
for (var x = this.target[this.prop], C = x, A = 0; A < g.length - 1; A++) {
var b = g[A];
if (!C) return;
C = C[b];
}
var S = g[g.length - 1];
if (!C) return;
C[S] = c;
c = x;
}
this.target[this.prop] = c;
}
}
});
_.Linear = null;
_.Bezier = function(t) {
return t;
};
var f = function() {
this.events = [];
};
f.prototype.add = function(t, e) {
this.events.push({
func: t || "",
params: e || []
});
};
var d = cc.Class({
name: "cc.EventAnimCurve",
extends: l,
properties: {
target: null,
ratios: [],
events: [],
_wrappedInfo: {
default: function() {
return new c();
}
},
_lastWrappedInfo: null,
_ignoreIndex: NaN
},
_wrapIterations: function(t) {
t - (0 | t) == 0 && (t -= 1);
return 0 | t;
},
sample: function(t, e, i) {
var n = this.ratios.length, r = i.getWrappedInfo(i.time, this._wrappedInfo), s = r.direction, h = o(this.ratios, r.ratio);
if (h < 0) {
h = ~h - 1;
s < 0 && (h += 1);
}
this._ignoreIndex !== h && (this._ignoreIndex = NaN);
r.frameIndex = h;
if (this._lastWrappedInfo) {
var l = i.wrapMode, u = this._wrapIterations(r.iterations), _ = this._lastWrappedInfo, f = this._wrapIterations(_.iterations), d = _.frameIndex, m = _.direction, p = -1 !== f && u !== f;
if (d === h && p && 1 === n) this._fireEvent(0); else if (d !== h || p) {
s = m;
do {
if (d !== h) {
if (-1 === s && 0 === d && h > 0) {
(l & a.PingPong) === a.PingPong ? s *= -1 : d = n;
f++;
} else if (1 === s && d === n - 1 && h < n - 1) {
(l & a.PingPong) === a.PingPong ? s *= -1 : d = -1;
f++;
}
if (d === h) break;
if (f > u) break;
}
d += s;
cc.director.getAnimationManager().pushDelayEvent(this, "_fireEvent", [ d ]);
} while (d !== h && d > -1 && d < n);
}
this._lastWrappedInfo.set(r);
} else {
this._fireEvent(h);
this._lastWrappedInfo = new c(r);
}
},
_fireEvent: function(t) {
if (!(t < 0 || t >= this.events.length || this._ignoreIndex === t)) {
var e = this.events[t].events;
if (this.target.isValid) for (var i = this.target._components, n = 0; n < e.length; n++) for (var r = e[n], s = r.func, o = 0; o < i.length; o++) {
var a = i[o], c = a[s];
c && c.apply(a, r.params);
}
}
},
onTimeChangedManually: function(t, e) {
this._lastWrappedInfo = null;
this._ignoreIndex = NaN;
var i = e.getWrappedInfo(t, this._wrappedInfo), n = i.direction, r = o(this.ratios, i.ratio);
if (r < 0) {
r = ~r - 1;
n < 0 && (r += 1);
this._ignoreIndex = r;
}
}
});
0;
n.exports = {
AnimCurve: l,
DynamicAnimCurve: _,
EventAnimCurve: d,
EventInfo: f,
computeRatioByType: h,
quickFindIndex: u
};
}), {
"../core/utils/binary-search": 236,
"./bezier": 14,
"./types": 19
} ],
12: [ (function(t, e, i) {
var n = cc.js, r = cc.Class({
ctor: function() {
this._anims = new n.array.MutableForwardIterator([]);
this._delayEvents = [];
cc.director._scheduler && cc.director._scheduler.enableForTarget(this);
},
update: function(t) {
var e = this._anims, i = e.array;
for (e.i = 0; e.i < i.length; ++e.i) {
var n = i[e.i];
n._isPlaying && !n._isPaused && n.update(t);
}
for (var r = this._delayEvents, s = 0, o = r.length; s < o; s++) {
var a = r[s];
a.target[a.func].apply(a.target, a.args);
}
r.length = 0;
},
destruct: function() {},
addAnimation: function(t) {
-1 === this._anims.array.indexOf(t) && this._anims.push(t);
},
removeAnimation: function(t) {
var e = this._anims.array.indexOf(t);
e >= 0 ? this._anims.fastRemoveAt(e) : cc.errorID(3907);
},
pushDelayEvent: function(t, e, i) {
this._delayEvents.push({
target: t,
func: e,
args: i
});
}
});
cc.AnimationManager = e.exports = r;
}), {} ],
13: [ (function(i, n, r) {
var s = cc.js, o = i("./playable"), a = i("./types"), c = a.WrappedInfo, h = a.WrapMode, l = a.WrapModeMask;
function u(t, e) {
o.call(this);
this._currentFramePlayed = !1;
this._delay = 0;
this._delayTime = 0;
this._wrappedInfo = new c();
this._lastWrappedInfo = null;
this._process = f;
this._clip = t;
this._name = e || t && t.name;
this.animator = null;
this.curves = [];
this.delay = 0;
this.repeatCount = 1;
this.duration = 1;
this.speed = 1;
this.wrapMode = h.Normal;
this.time = 0;
this._target = null;
this._lastframeEventOn = !1;
this.emit = function() {
for (var t = new Array(arguments.length), e = 0, i = t.length; e < i; e++) t[e] = arguments[e];
cc.director.getAnimationManager().pushDelayEvent(this, "_emit", t);
};
}
s.extend(u, o);
var _ = u.prototype;
_._emit = function(t, e) {
this._target && this._target.isValid && this._target.emit(t, t, e);
};
_.on = function(t, e, i) {
if (this._target && this._target.isValid) {
"lastframe" === t && (this._lastframeEventOn = !0);
return this._target.on(t, e, i);
}
return null;
};
_.once = function(i, n, r) {
var s = this;
if (!this._target || !this._target.isValid) return null;
var o = (function() {
"lastframe" === i && (s._lastframeEventOn = !0);
var t = s;
return {
v: s._target.once(i, (function(e) {
n.call(r, e);
t._lastframeEventOn = !1;
}))
};
})();
return "object" === ("object" === (e = typeof o) ? t(o) : e) ? o.v : void 0;
};
_.off = function(t, e, i) {
if (this._target && this._target.isValid) {
"lastframe" === t && (this._target.hasEventListener(t) || (this._lastframeEventOn = !1));
this._target.off(t, e, i);
}
};
_._setEventTarget = function(t) {
this._target = t;
};
_.onPlay = function() {
this.setTime(0);
this._delayTime = this._delay;
cc.director.getAnimationManager().addAnimation(this);
this.animator && this.animator.addAnimation(this);
this.emit("play", this);
};
_.onStop = function() {
this.isPaused || cc.director.getAnimationManager().removeAnimation(this);
this.animator && this.animator.removeAnimation(this);
this.emit("stop", this);
};
_.onResume = function() {
cc.director.getAnimationManager().addAnimation(this);
this.emit("resume", this);
};
_.onPause = function() {
cc.director.getAnimationManager().removeAnimation(this);
this.emit("pause", this);
};
_.setTime = function(t) {
this._currentFramePlayed = !1;
this.time = t || 0;
for (var e = this.curves, i = 0, n = e.length; i < n; i++) {
var r = e[i];
r.onTimeChangedManually && r.onTimeChangedManually(t, this);
}
};
function f() {
var t = this.sample();
if (this._lastframeEventOn) {
var e;
e = this._lastWrappedInfo ? this._lastWrappedInfo : this._lastWrappedInfo = new c(t);
this.repeatCount > 1 && (0 | t.iterations) > (0 | e.iterations) && this.emit("lastframe", this);
e.set(t);
}
if (t.stopped) {
this.stop();
this.emit("finished", this);
}
}
function d() {
var t = this.time, e = this.duration;
t > e ? 0 === (t %= e) && (t = e) : t < 0 && 0 !== (t %= e) && (t += e);
for (var i = t / e, n = this.curves, r = 0, s = n.length; r < s; r++) {
n[r].sample(t, i, this);
}
if (this._lastframeEventOn) {
void 0 === this._lastIterations && (this._lastIterations = i);
(this.time > 0 && this._lastIterations > i || this.time < 0 && this._lastIterations < i) && this.emit("lastframe", this);
this._lastIterations = i;
}
}
_.update = function(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();
};
_._needRevers = function(t) {
var e = this.wrapMode, i = !1;
if ((e & l.PingPong) === l.PingPong) {
t - (0 | t) == 0 && t > 0 && (t -= 1);
1 & t && (i = !i);
}
(e & l.Reverse) === l.Reverse && (i = !i);
return i;
};
_.getWrappedInfo = function(t, e) {
e = e || new c();
var i = !1, n = this.duration, r = this.repeatCount, s = t > 0 ? t / n : -t / n;
if (s >= r) {
s = r;
i = !0;
var o = r - (0 | r);
0 === o && (o = 1);
t = o * n * (t > 0 ? 1 : -1);
}
if (t > n) {
var a = t % n;
t = 0 === a ? n : a;
} else t < 0 && 0 !== (t %= n) && (t += n);
var h = !1, u = this._wrapMode & l.ShouldWrap;
u && (h = this._needRevers(s));
var _ = h ? -1 : 1;
this.speed < 0 && (_ *= -1);
u && h && (t = n - t);
e.ratio = t / n;
e.time = t;
e.direction = _;
e.stopped = i;
e.iterations = s;
return e;
};
_.sample = function() {
for (var t = this.getWrappedInfo(this.time, this._wrappedInfo), e = this.curves, i = 0, n = e.length; i < n; i++) {
e[i].sample(t.time, t.ratio, this);
}
return t;
};
s.get(_, "clip", (function() {
return this._clip;
}));
s.get(_, "name", (function() {
return this._name;
}));
s.obsolete(_, "AnimationState.length", "duration");
s.getset(_, "curveLoaded", (function() {
return this.curves.length > 0;
}), (function() {
this.curves.length = 0;
}));
s.getset(_, "wrapMode", (function() {
return this._wrapMode;
}), (function(t) {
this._wrapMode = t;
0;
this.time = 0;
t & l.Loop ? this.repeatCount = Infinity : this.repeatCount = 1;
}));
s.getset(_, "repeatCount", (function() {
return this._repeatCount;
}), (function(t) {
this._repeatCount = t;
var e = this._wrapMode & l.ShouldWrap, i = (this.wrapMode & l.Reverse) === l.Reverse;
this._process = Infinity !== t || e || i ? f : d;
}));
s.getset(_, "delay", (function() {
return this._delay;
}), (function(t) {
this._delayTime = this._delay = t;
}));
cc.AnimationState = n.exports = u;
}), {
"./playable": 18,
"./types": 19
} ],
14: [ (function(t, e, i) {
function n(t, e, i, n, r) {
var s = 1 - r;
return t * s * s * s + 3 * e * s * s * r + 3 * i * s * r * r + n * r * r * r;
}
var r = Math.cos, s = Math.acos, o = Math.max, a = 2 * Math.PI, c = Math.sqrt;
function h(t) {
return t < 0 ? -Math.pow(-t, 1 / 3) : Math.pow(t, 1 / 3);
}
function l(t, e) {
var i = (function(t, e) {
var i, n, l, u, _ = e - 0, f = e - t[0], d = 3 * _, m = 3 * f, p = 3 * (e - t[2]), v = 1 / (-_ + m - p + (e - 1)), y = (d - 6 * f + p) * v, g = y * (1 / 3), x = (-d + m) * v, C = 1 / 3 * (3 * x - y * y), A = C * (1 / 3), b = (2 * y * y * y - 9 * y * x + _ * v * 27) / 27, S = b / 2, T = S * S + A * A * A;
if (T < 0) {
var w = 1 / 3 * -C, E = c(w * w * w), B = -b / (2 * E), M = s(B < -1 ? -1 : B > 1 ? 1 : B), D = 2 * h(E);
n = D * r(M * (1 / 3)) - g;
l = D * r((M + a) * (1 / 3)) - g;
u = D * r((M + 2 * a) * (1 / 3)) - g;
return 0 <= n && n <= 1 ? 0 <= l && l <= 1 ? 0 <= u && u <= 1 ? o(n, l, u) : o(n, l) : 0 <= u && u <= 1 ? o(n, u) : n : 0 <= l && l <= 1 ? 0 <= u && u <= 1 ? o(l, u) : l : u;
}
if (0 === T) {
l = -(i = S < 0 ? h(-S) : -h(S)) - g;
return 0 <= (n = 2 * i - g) && n <= 1 ? 0 <= l && l <= 1 ? o(n, l) : n : l;
}
var I = c(T);
return n = (i = h(-S + I)) - h(S + I) - g;
})(t, e), n = 1 - i;
return 0 * n * n * n + 3 * t[1] * i * n * n + 3 * t[3] * i * i * n + 1 * i * i * i;
}
0;
e.exports = {
bezier: n,
bezierByTime: l
};
}), {} ],
15: [ (function(t, e, i) {
var n = {
constant: function() {
return 0;
},
linear: function(t) {
return t;
},
quadIn: function(t) {
return t * t;
},
quadOut: function(t) {
return t * (2 - t);
},
quadInOut: function(t) {
return (t *= 2) < 1 ? .5 * t * t : -.5 * (--t * (t - 2) - 1);
},
cubicIn: function(t) {
return t * t * t;
},
cubicOut: function(t) {
return --t * t * t + 1;
},
cubicInOut: function(t) {
return (t *= 2) < 1 ? .5 * t * t * t : .5 * ((t -= 2) * t * t + 2);
},
quartIn: function(t) {
return t * t * t * t;
},
quartOut: function(t) {
return 1 - --t * t * t * t;
},
quartInOut: function(t) {
return (t *= 2) < 1 ? .5 * t * t * t * t : -.5 * ((t -= 2) * t * t * t - 2);
},
quintIn: function(t) {
return t * t * t * t * t;
},
quintOut: function(t) {
return --t * t * t * t * t + 1;
},
quintInOut: function(t) {
return (t *= 2) < 1 ? .5 * t * t * t * t * t : .5 * ((t -= 2) * t * t * t * t + 2);
},
sineIn: function(t) {
return 1 - Math.cos(t * Math.PI / 2);
},
sineOut: function(t) {
return Math.sin(t * Math.PI / 2);
},
sineInOut: function(t) {
return .5 * (1 - Math.cos(Math.PI * t));
},
expoIn: function(t) {
return 0 === t ? 0 : Math.pow(1024, t - 1);
},
expoOut: function(t) {
return 1 === t ? 1 : 1 - Math.pow(2, -10 * t);
},
expoInOut: function(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)));
},
circIn: function(t) {
return 1 - Math.sqrt(1 - t * t);
},
circOut: function(t) {
return Math.sqrt(1 - --t * t);
},
circInOut: function(t) {
return (t *= 2) < 1 ? -.5 * (Math.sqrt(1 - t * t) - 1) : .5 * (Math.sqrt(1 - (t -= 2) * t) + 1);
},
elasticIn: function(t) {
var e, 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);
},
elasticOut: function(t) {
var e, 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;
},
elasticInOut: function(t) {
var e, 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 (t *= 2) < 1 ? i * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - e) * (2 * Math.PI) / .4) * -.5 : i * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - e) * (2 * Math.PI) / .4) * .5 + 1;
},
backIn: function(t) {
var e = 1.70158;
return t * t * ((e + 1) * t - e);
},
backOut: function(t) {
var e = 1.70158;
return --t * t * ((e + 1) * t + e) + 1;
},
backInOut: function(t) {
var e = 2.5949095;
return (t *= 2) < 1 ? t * t * ((e + 1) * t - e) * .5 : .5 * ((t -= 2) * t * ((e + 1) * t + e) + 2);
},
bounceOut: function(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;
},
smooth: function(t) {
return t <= 0 ? 0 : t >= 1 ? 1 : t * t * (3 - 2 * t);
},
fade: function(t) {
return t <= 0 ? 0 : t >= 1 ? 1 : t * t * t * (t * (6 * t - 15) + 10);
}
};
function r(t, e) {
return function(i) {
return i < .5 ? e(2 * i) / 2 : t(2 * i - 1) / 2 + .5;
};
}
n.quadOutIn = r(n.quadIn, n.quadOut);
n.cubicOutIn = r(n.cubicIn, n.cubicOut);
n.quartOutIn = r(n.quartIn, n.quartOut);
n.quintOutIn = r(n.quintIn, n.quintOut);
n.sineOutIn = r(n.sineIn, n.sineOut);
n.expoOutIn = r(n.expoIn, n.expoOut);
n.circOutIn = r(n.circIn, n.circOut);
n.backOutIn = r(n.backIn, n.backOut);
n.backOutIn = r(n.backIn, n.backOut);
n.bounceIn = function(t) {
return 1 - n.bounceOut(1 - t);
};
n.bounceInOut = function(t) {
return t < .5 ? .5 * n.bounceIn(2 * t) : .5 * n.bounceOut(2 * t - 1) + .5;
};
n.bounceOutIn = r(n.bounceIn, n.bounceOut);
cc.easing = e.exports = n;
}), {} ],
16: [ (function(t, e, i) {
t("./bezier");
t("./easing");
t("./types");
t("./motion-path-helper");
t("./animation-curves");
t("./animation-clip");
t("./animation-manager");
t("./animation-state");
t("./animation-animator");
}), {
"./animation-animator": 9,
"./animation-clip": 10,
"./animation-curves": 11,
"./animation-manager": 12,
"./animation-state": 13,
"./bezier": 14,
"./easing": 15,
"./motion-path-helper": 17,
"./types": 19
} ],
17: [ (function(t, e, i) {
var n = t("./animation-curves").DynamicAnimCurve, r = t("./animation-curves").computeRatioByType, s = t("./bezier").bezier, o = t("../core/utils/binary-search").binarySearchEpsilon, a = cc.v2;
function c(t) {
this.points = t || [];
this.beziers = [];
this.ratios = [];
this.progresses = [];
this.length = 0;
this.computeBeziers();
}
c.prototype.computeBeziers = function() {
this.beziers.length = 0;
this.ratios.length = 0;
this.progresses.length = 0;
this.length = 0;
for (var t, e = 1; e < this.points.length; e++) {
var i = this.points[e - 1], n = this.points[e];
(t = new h()).start = i.pos;
t.startCtrlPoint = i.out;
t.end = n.pos;
t.endCtrlPoint = n.in;
this.beziers.push(t);
this.length += t.getLength();
}
var r = 0;
for (e = 0; e < this.beziers.length; e++) {
t = this.beziers[e];
this.ratios[e] = t.getLength() / this.length;
this.progresses[e] = r += this.ratios[e];
}
return this.beziers;
};
function h() {
this.start = a();
this.end = a();
this.startCtrlPoint = a();
this.endCtrlPoint = a();
}
h.prototype.getPointAt = function(t) {
var e = this.getUtoTmapping(t);
return this.getPoint(e);
};
h.prototype.getPoint = function(t) {
var e = s(this.start.x, this.startCtrlPoint.x, this.endCtrlPoint.x, this.end.x, t), i = s(this.start.y, this.startCtrlPoint.y, this.endCtrlPoint.y, this.end.y, t);
return new a(e, i);
};
h.prototype.getLength = function() {
var t = this.getLengths();
return t[t.length - 1];
};
h.prototype.getLengths = function(t) {
t || (t = this.__arcLengthDivisions ? this.__arcLengthDivisions : 200);
if (this.cacheArcLengths && this.cacheArcLengths.length === t + 1) return this.cacheArcLengths;
var e, i, n = [], r = this.getPoint(0), s = a(), o = 0;
n.push(0);
for (i = 1; i <= t; i++) {
e = this.getPoint(i / t);
s.x = r.x - e.x;
s.y = r.y - e.y;
o += s.mag();
n.push(o);
r = e;
}
this.cacheArcLengths = n;
return n;
};
h.prototype.getUtoTmapping = function(t, e) {
var i, n = this.getLengths(), r = 0, s = n.length;
i = e || t * n[s - 1];
for (var o, a = 0, c = s - 1; a <= c; ) if ((o = n[r = Math.floor(a + (c - a) / 2)] - i) < 0) a = r + 1; else {
if (!(o > 0)) {
c = r;
break;
}
c = r - 1;
}
if (n[r = c] === i) {
return r / (s - 1);
}
var h = n[r];
return (r + (i - h) / (n[r + 1] - h)) / (s - 1);
};
function l(t, e, i, s) {
function h(t) {
return t instanceof cc.Vec2 ? {
in: t,
pos: t,
out: t
} : Array.isArray(t) && 6 === t.length ? {
in: a(t[2], t[3]),
pos: a(t[0], t[1]),
out: a(t[4], t[5])
} : {
in: cc.Vec2.ZERO,
pos: cc.Vec2.ZERO,
out: cc.Vec2.ZERO
};
}
var l = e.values;
if (0 !== t.length && 0 !== l.length) if (1 !== (l = l.map((function(t) {
return a(t[0], t[1]);
}))).length) {
for (var u = e.types, _ = e.ratios, f = e.values = [], d = e.types = [], m = e.ratios = [], p = 0, v = n.Linear, y = 0, g = t.length; y < g - 1; y++) {
var x, C = t[y], A = _[y], b = _[y + 1] - A, S = l[y], T = l[y + 1], w = u[y], E = [], B = p / b, M = 1 / (b * i * s);
if (C && C.length > 0) {
var D = [];
D.push(h(S));
for (var I = 0, P = C.length; I < P; I++) {
var R = h(C[I]);
D.push(R);
}
D.push(h(T));
var L = new c(D);
L.computeBeziers();
for (var F = L.progresses; 1 - B > 1e-6; ) {
var V, O, N, k;
if ((x = r(x = B, w)) < 0) {
k = (0 - x) * (O = L.beziers[0]).getLength();
N = O.start.sub(O.endCtrlPoint).normalize();
V = O.start.add(N.mul(k));
} else if (x > 1) {
k = (x - 1) * (O = L.beziers[L.beziers.length - 1]).getLength();
N = O.end.sub(O.startCtrlPoint).normalize();
V = O.end.add(N.mul(k));
} else {
var G = o(F, x);
G < 0 && (G = ~G);
x -= G > 0 ? F[G - 1] : 0;
x /= L.ratios[G];
V = L.beziers[G].getPointAt(x);
}
E.push(V);
B += M;
}
} else for (;1 - B > 1e-6; ) {
x = r(x = B, w);
E.push(S.lerp(T, x));
B += M;
}
v = "constant" === w ? w : n.Linear;
for (I = 0, P = E.length; I < P; I++) {
var z = A + p + M * I * b;
U(E[I], v, z);
}
p = Math.abs(B - 1) > 1e-6 ? (B - 1) * b : 0;
}
_[_.length - 1] !== m[m.length - 1] && U(l[l.length - 1], v, _[_.length - 1]);
} else e.values = l;
function U(t, e, i) {
f.push(t);
d.push(e);
m.push(i);
}
}
0;
e.exports = {
sampleMotionPaths: l,
Curve: c,
Bezier: h
};
}), {
"../core/utils/binary-search": 236,
"./animation-curves": 11,
"./bezier": 14
} ],
18: [ (function(t, e, i) {
var n = cc.js, r = t("../core/CCDebug");
function s() {
this._isPlaying = !1;
this._isPaused = !1;
this._stepOnce = !1;
}
var o = s.prototype;
n.get(o, "isPlaying", (function() {
return this._isPlaying;
}), !0);
n.get(o, "isPaused", (function() {
return this._isPaused;
}), !0);
var a = function() {};
o.onPlay = a;
o.onPause = a;
o.onResume = a;
o.onStop = a;
o.onError = a;
o.play = function() {
if (this._isPlaying) if (this._isPaused) {
this._isPaused = !1;
this.onResume();
} else this.onError(r.getError(3912)); else {
this._isPlaying = !0;
this.onPlay();
}
};
o.stop = function() {
if (this._isPlaying) {
this._isPlaying = !1;
this.onStop();
this._isPaused = !1;
}
};
o.pause = function() {
if (this._isPlaying && !this._isPaused) {
this._isPaused = !0;
this.onPause();
}
};
o.resume = function() {
if (this._isPlaying && this._isPaused) {
this._isPaused = !1;
this.onResume();
}
};
o.step = function() {
this.pause();
this._stepOnce = !0;
this._isPlaying || this.play();
};
e.exports = s;
}), {
"../core/CCDebug": 26
} ],
19: [ (function(t, e, i) {
var n = {
Loop: 2,
ShouldWrap: 4,
PingPong: 22,
Reverse: 36
}, r = cc.Enum({
Default: 0,
Normal: 1,
Reverse: n.Reverse,
Loop: n.Loop,
LoopReverse: n.Loop | n.Reverse,
PingPong: n.PingPong,
PingPongReverse: n.PingPong | n.Reverse
});
cc.WrapMode = r;
function s(t) {
if (t) this.set(t); else {
this.ratio = 0;
this.time = 0;
this.direction = 1;
this.stopped = !0;
this.iterations = 0;
this.frameIndex = void 0;
}
}
s.prototype.set = function(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;
};
e.exports = {
WrapModeMask: n,
WrapMode: r,
WrappedInfo: s
};
}), {} ],
20: [ (function(t, e, i) {
var n = t("../core/event/event-target"), r = t("../core/platform/CCSys"), s = t("../core/assets/CCAudioClip").LoadMode, o = !1, a = [], c = function(t) {
n.call(this);
this._src = t;
this._element = null;
this.id = 0;
this._volume = 1;
this._loop = !1;
this._nextTime = 0;
this._state = c.State.INITIALZING;
this._onended = function() {
this._state = c.State.STOPPED;
this.emit("ended");
}.bind(this);
};
cc.js.extend(c, n);
c.State = {
ERROR: -1,
INITIALZING: 0,
PLAYING: 1,
PAUSED: 2,
STOPPED: 3
};
(function(t) {
t._bindEnded = function(t) {
t = t || this._onended;
var e = this._element;
this._src && e instanceof HTMLAudioElement ? e.addEventListener("ended", t) : e.onended = t;
};
t._unbindEnded = function() {
var t = this._element;
t instanceof HTMLAudioElement ? t.removeEventListener("ended", this._onended) : t && (t.onended = null);
};
t._onLoaded = function() {
var t = this._src._nativeAsset;
if (t instanceof HTMLAudioElement) {
this._element || (this._element = document.createElement("audio"));
this._element.src = t.src;
} else this._element = new h(t, this);
this.setVolume(this._volume);
this.setLoop(this._loop);
0 !== this._nextTime && this.setCurrentTime(this._nextTime);
this._state === c.State.PLAYING ? this.play() : this._state = c.State.INITIALZING;
};
t.play = function() {
this._state = c.State.PLAYING;
if (this._element) {
this._bindEnded();
this._element.play();
this._src && this._src.loadMode === s.DOM_AUDIO && this._element.paused && a.push({
instance: this,
offset: 0,
audio: this._element
});
if (!o) {
o = !0;
cc.game.canvas.addEventListener("touchstart", (function() {
for (var t = void 0; t = a.pop(); ) t.audio.play(t.offset);
}));
}
}
};
t.destroy = function() {
0;
this._element = null;
};
t.pause = function() {
if (this._element && this._state === c.State.PLAYING) {
this._unbindEnded();
this._element.pause();
this._state = c.State.PAUSED;
}
};
t.resume = function() {
if (this._element && this._state === c.State.PAUSED) {
this._bindEnded();
this._element.play();
this._state = c.State.PLAYING;
}
};
t.stop = function() {
if (this._element) {
this._element.pause();
try {
this._element.currentTime = 0;
} catch (t) {}
for (var t = 0; t < a.length; t++) if (a[t].instance === this) {
a.splice(t, 1);
break;
}
this._unbindEnded();
this.emit("stop");
this._state = c.State.STOPPED;
}
};
t.setLoop = function(t) {
this._loop = t;
this._element && (this._element.loop = t);
};
t.getLoop = function() {
return this._loop;
};
t.setVolume = function(t) {
this._volume = t;
this._element && (this._element.volume = t);
};
t.getVolume = function() {
return this._volume;
};
t.setCurrentTime = function(t) {
var e = this;
if (this._element) {
this._nextTime = 0;
this._unbindEnded();
this._bindEnded(function() {
this._bindEnded();
}.bind(this));
try {
this._element.currentTime = t;
} catch (i) {
(function() {
var i = e._element;
i.addEventListener && (function() {
var e = function() {
i.removeEventListener("loadedmetadata", e);
i.currentTime = t;
};
i.addEventListener("loadedmetadata", e);
})();
})();
}
} else this._nextTime = t;
};
t.getCurrentTime = function() {
return this._element ? this._element.currentTime : 0;
};
t.getDuration = function() {
return this._element ? this._element.duration : 0;
};
t.getState = function() {
var t = this._element;
t && c.State.PLAYING === this._state && t.paused && (this._state = c.State.STOPPED);
return this._state;
};
t.__defineGetter__("src", (function() {
return this._src;
}));
t.__defineSetter__("src", (function(t) {
var e = this;
this._unbindEnded();
if (t) {
this._src = t;
t.loaded ? this._onLoaded() : (function() {
var i = e;
t.once("load", (function() {
t === i._src && i._onLoaded();
}));
cc.loader.load({
url: t.nativeUrl,
skips: [ "Loader" ]
}, (function(e, i) {
e ? cc.error(e) : t.loaded || (t._nativeAsset = i);
}));
})();
} else {
this._src = null;
this._element instanceof HTMLAudioElement ? this._element.src = "" : this._element = null;
this._state = c.State.INITIALZING;
}
return t;
}));
t.__defineGetter__("paused", (function() {
return !this._element || this._element.paused;
}));
})(c.prototype);
var h = function(t, e) {
this._audio = e;
this._context = r.__audioSupport.context;
this._buffer = t;
this._gainObj = this._context.createGain();
this._volume = 1;
this._gainObj.gain.setTargetAtTime ? this._gainObj.gain.setTargetAtTime(this._volume, this._context.currentTime, .01) : this._gainObj.gain.value = 1;
this._gainObj.connect(this._context.destination);
this._loop = !1;
this._startTime = -1;
this._currentSource = null;
this.playedLength = 0;
this._currextTimer = null;
this._endCallback = function() {
this.onended && this.onended(this);
}.bind(this);
};
(function(t) {
t.play = function(t) {
var e = this;
if (this._currentSource && !this.paused) {
this._currentSource.onended = null;
this._currentSource.stop(0);
this.playedLength = 0;
}
var i = this._context.createBufferSource();
i.buffer = this._buffer;
i.connect(this._gainObj);
i.loop = this._loop;
this._startTime = this._context.currentTime;
(t = t || this.playedLength) && (this._startTime -= t);
var n = this._buffer.duration, r = t, s = void 0;
if (this._loop) i.start ? i.start(0, r) : i.notoGrainOn ? i.noteGrainOn(0, r) : i.noteOn(0, r); else {
s = n - t;
i.start ? i.start(0, r, s) : i.notoGrainOn ? i.noteGrainOn(0, r, s) : i.noteOn(0, r, s);
}
this._currentSource = i;
i.onended = this._endCallback;
i.context.state && "suspended" !== i.context.state || 0 !== this._context.currentTime || (function() {
var i = e;
clearTimeout(e._currextTimer);
e._currextTimer = setTimeout((function() {
0 === i._context.currentTime && a.push({
instance: i._audio,
offset: t,
audio: i
});
}), 10);
})();
};
t.pause = function() {
clearTimeout(this._currextTimer);
if (!this.paused) {
this.playedLength = this._context.currentTime - this._startTime;
this.playedLength %= this._buffer.duration;
var t = this._currentSource;
this._currentSource = null;
this._startTime = -1;
t && t.stop(0);
}
};
t.__defineGetter__("paused", (function() {
return (!this._currentSource || !this._currentSource.loop) && (-1 === this._startTime || this._context.currentTime - this._startTime > this._buffer.duration);
}));
t.__defineGetter__("loop", (function() {
return this._loop;
}));
t.__defineSetter__("loop", (function(t) {
this._currentSource && (this._currentSource.loop = t);
return this._loop = t;
}));
t.__defineGetter__("volume", (function() {
return this._volume;
}));
t.__defineSetter__("volume", (function(t) {
this._volume = t;
this._gainObj.gain.setTargetAtTime ? this._gainObj.gain.setTargetAtTime(this._volume, this._context.currentTime, .01) : this._volume.gain.value = t;
if (r.os === r.OS_IOS && !this.paused && this._currentSource) {
this._currentSource.onended = null;
this.pause();
this.play();
}
return t;
}));
t.__defineGetter__("currentTime", (function() {
if (this.paused) return this.playedLength;
this.playedLength = this._context.currentTime - this._startTime;
this.playedLength %= this._buffer.duration;
return this.playedLength;
}));
t.__defineSetter__("currentTime", (function(t) {
if (this.paused) this.playedLength = t; else {
this.pause();
this.playedLength = t;
this.play();
}
return t;
}));
t.__defineGetter__("duration", (function() {
return this._buffer.duration;
}));
})(h.prototype);
e.exports = cc.Audio = c;
}), {
"../core/assets/CCAudioClip": 34,
"../core/event/event-target": 102,
"../core/platform/CCSys": 169
} ],
21: [ (function(i, n, r) {
var s = i("./CCAudio"), o = i("../core/assets/CCAudioClip"), a = cc.js, c = 0, h = a.createMap(!0), l = {}, u = [], _ = function(t) {
var e = c++, i = l[t];
i || (i = l[t] = []);
if (m._maxAudioInstance <= i.length) {
var n = i.shift();
f(n).stop();
}
var r = u.pop() || new s(), o = function() {
if (f(this.id)) {
delete h[this.id];
var t = i.indexOf(this.id);
cc.js.array.fastRemoveAt(i, t);
}
(function(t) {
t._finishCallback = null;
if (u.length < 32) {
t.off("ended");
t.off("stop");
t.src = null;
u.push(t);
} else t.destroy();
})(this);
};
r.on("ended", (function() {
this._finishCallback && this._finishCallback();
o.call(this);
}), r);
r.on("stop", o, r);
r.id = e;
h[e] = r;
i.push(e);
return r;
}, f = function(t) {
return h[t];
}, d = function(i) {
void 0 === i ? i = 1 : "string" === ("object" === (e = typeof i) ? t(i) : e) && (i = Number.parseFloat(i));
return i;
}, m = {
AudioState: s.State,
_maxWebAudioSize: 2097152,
_maxAudioInstance: 24,
_id2audio: h,
play: function(i, n, r) {
var s, a = i;
if ("string" === ("object" === (e = typeof i) ? t(i) : e)) {
cc.warnID(8401, "cc.audioEngine", "cc.AudioClip", "AudioClip", "cc.AudioClip", "audio");
s = _(a = i);
o._loadByUrl(a, (function(t, e) {
e && (s.src = e);
}));
} else {
if (!i) return;
a = i.nativeUrl;
(s = _(a)).src = i;
}
s.setLoop(n || !1);
r = d(r);
s.setVolume(r);
s.play();
return s.id;
},
setLoop: function(t, e) {
var i = f(t);
i && i.setLoop && i.setLoop(e);
},
isLoop: function(t) {
var e = f(t);
return !(!e || !e.getLoop) && e.getLoop();
},
setVolume: function(t, e) {
var i = f(t);
i && i.setVolume(e);
},
getVolume: function(t) {
var e = f(t);
return e ? e.getVolume() : 1;
},
setCurrentTime: function(t, e) {
var i = f(t);
if (i) {
i.setCurrentTime(e);
return !0;
}
return !1;
},
getCurrentTime: function(t) {
var e = f(t);
return e ? e.getCurrentTime() : 0;
},
getDuration: function(t) {
var e = f(t);
return e ? e.getDuration() : 0;
},
getState: function(t) {
var e = f(t);
return e ? e.getState() : this.AudioState.ERROR;
},
setFinishCallback: function(t, e) {
var i = f(t);
i && (i._finishCallback = e);
},
pause: function(t) {
var e = f(t);
if (e) {
e.pause();
return !0;
}
return !1;
},
_pauseIDCache: [],
pauseAll: function() {
for (var t in h) {
var e = h[t];
if (e.getState() === s.State.PLAYING) {
this._pauseIDCache.push(t);
e.pause();
}
}
},
resume: function(t) {
var e = f(t);
e && e.resume();
},
resumeAll: function() {
for (var t = 0; t < this._pauseIDCache.length; ++t) {
var e = this._pauseIDCache[t], i = f(e);
i && i.resume();
}
this._pauseIDCache.length = 0;
},
stop: function(t) {
var e = f(t);
if (e) {
e.stop();
return !0;
}
return !1;
},
stopAll: function() {
for (var t in h) {
var e = h[t];
e && e.stop();
}
},
setMaxAudioInstance: function(t) {
this._maxAudioInstance = t;
},
getMaxAudioInstance: function() {
return this._maxAudioInstance;
},
uncache: function(i) {
var n = i;
if ("string" === ("object" === (e = typeof i) ? t(i) : e)) {
cc.warnID(8401, "cc.audioEngine", "cc.AudioClip", "AudioClip", "cc.AudioClip", "audio");
n = i;
} else {
if (!i) return;
n = i.nativeUrl;
}
var r = l[n];
if (r) for (;r.length > 0; ) {
var s = r.pop(), o = h[s];
if (o) {
o.stop();
delete h[s];
}
}
},
uncacheAll: function() {
this.stopAll();
var t = void 0;
for (var e in h) (t = h[e]) && t.destroy();
for (;t = u.pop(); ) t.destroy();
h = a.createMap(!0);
l = {};
},
getProfile: function(t) {},
preload: function(t, e) {
0;
cc.loader.load(t, e && function(t) {
t || e();
});
},
setMaxWebAudioSize: function(t) {
this._maxWebAudioSize = 1024 * t;
},
_breakCache: null,
_break: function() {
this._breakCache = [];
for (var t in h) {
var e = h[t];
if (e.getState() === s.State.PLAYING) {
this._breakCache.push(t);
e.pause();
}
}
},
_restore: function() {
if (this._breakCache) {
for (;this._breakCache.length > 0; ) {
var t = this._breakCache.pop(), e = f(t);
e && e.resume && e.resume();
}
this._breakCache = null;
}
},
_music: {
id: -1,
loop: !1,
volume: 1
},
_effect: {
volume: 1,
pauseCache: []
},
playMusic: function(t, e) {
var i = this._music;
this.stop(i.id);
i.id = this.play(t, e, i.volume);
i.loop = e;
return i.id;
},
stopMusic: function() {
this.stop(this._music.id);
},
pauseMusic: function() {
this.pause(this._music.id);
return this._music.id;
},
resumeMusic: function() {
this.resume(this._music.id);
return this._music.id;
},
getMusicVolume: function() {
return this._music.volume;
},
setMusicVolume: function(t) {
t = d(t);
var e = this._music;
e.volume = t;
this.setVolume(e.id, e.volume);
return e.volume;
},
isMusicPlaying: function() {
return this.getState(this._music.id) === this.AudioState.PLAYING;
},
playEffect: function(t, e) {
return this.play(t, e || !1, this._effect.volume);
},
setEffectsVolume: function(t) {
t = d(t);
var e = this._music.id;
this._effect.volume = t;
for (var i in h) {
var n = h[i];
n && n.id !== e && m.setVolume(i, t);
}
},
getEffectsVolume: function() {
return this._effect.volume;
},
pauseEffect: function(t) {
return this.pause(t);
},
pauseAllEffects: function() {
var t = this._music.id, e = this._effect;
e.pauseCache.length = 0;
for (var i in h) {
var n = h[i];
if (n && n.id !== t) {
if (n.getState() === this.AudioState.PLAYING) {
e.pauseCache.push(i);
n.pause();
}
}
}
},
resumeEffect: function(t) {
this.resume(t);
},
resumeAllEffects: function() {
for (var t = this._effect.pauseCache, e = 0; e < t.length; ++e) {
var i = t[e], n = h[i];
n && n.resume();
}
},
stopEffect: function(t) {
return this.stop(t);
},
stopAllEffects: function() {
var t = this._music.id;
for (var e in h) {
var i = h[e];
if (i && i.id !== t) {
i.getState() === m.AudioState.PLAYING && i.stop();
}
}
}
};
n.exports = cc.audioEngine = m;
}), {
"../core/assets/CCAudioClip": 34,
"./CCAudio": 20
} ],
22: [ (function(t, e, i) {
var n = {
name: "Jacob__Codec"
};
n.Base64 = t("./base64");
n.GZip = t("./gzip");
n.unzip = function() {
return n.GZip.gunzip.apply(n.GZip, arguments);
};
n.unzipBase64 = function() {
var t = n.Base64.decode.apply(n.Base64, arguments);
try {
return n.GZip.gunzip.call(n.GZip, t);
} catch (e) {
return t.slice(7);
}
};
n.unzipBase64AsArray = function(t, e) {
e = e || 1;
var i, n, r, s = this.unzipBase64(t), o = [];
for (i = 0, r = s.length / e; i < r; i++) {
o[i] = 0;
for (n = e - 1; n >= 0; --n) o[i] += s.charCodeAt(i * e + n) << 8 * n;
}
return o;
};
n.unzipAsArray = function(t, e) {
e = e || 1;
var i, n, r, s = this.unzip(t), o = [];
for (i = 0, r = s.length / e; i < r; i++) {
o[i] = 0;
for (n = e - 1; n >= 0; --n) o[i] += s.charCodeAt(i * e + n) << 8 * n;
}
return o;
};
cc.codec = e.exports = n;
}), {
"./base64": 23,
"./gzip": 24
} ],
23: [ (function(t, e, i) {
var n = t("../core/utils/misc").BASE64_VALUES, r = {
name: "Jacob__Codec__Base64",
decode: function(t) {
var e, i, r, s, o, a, c, h = [], l = 0;
t = t.replace(/[^A-Za-z0-9\+\/\=]/g, "");
for (;l < t.length; ) {
s = n[t.charCodeAt(l++)];
o = n[t.charCodeAt(l++)];
a = n[t.charCodeAt(l++)];
c = n[t.charCodeAt(l++)];
e = s << 2 | o >> 4;
i = (15 & o) << 4 | a >> 2;
r = (3 & a) << 6 | c;
h.push(String.fromCharCode(e));
64 !== a && h.push(String.fromCharCode(i));
64 !== c && h.push(String.fromCharCode(r));
}
return h = h.join("");
},
decodeAsArray: function(t, e) {
var i, n, r, s = this.decode(t), o = [];
for (i = 0, r = s.length / e; i < r; i++) {
o[i] = 0;
for (n = e - 1; n >= 0; --n) o[i] += s.charCodeAt(i * e + n) << 8 * n;
}
return o;
}
};
e.exports = r;
}), {
"../core/utils/misc": 242
} ],
24: [ (function(t, e, i) {
var n = 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(n.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;
};
n.gunzip = function(t) {
t.constructor === Array || (t.constructor, String);
return new n(t).gunzip()[0][0];
};
n.HufNode = function() {
this.b0 = 0;
this.b1 = 0;
this.jump = null;
this.jumppos = -1;
};
n.LITERALS = 288;
n.NAMEMAX = 256;
n.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 ];
n.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 ];
n.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 ];
n.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 ];
n.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 ];
n.border = [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];
n.prototype.gunzip = function() {
this.outputArr = [];
this.nextFile();
return this.unzipped;
};
n.prototype.readByte = function() {
this.bits += 8;
return this.bytepos < this.data.length ? this.data.charCodeAt(this.bytepos++) : -1;
};
n.prototype.byteAlign = function() {
this.bb = 1;
};
n.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;
};
n.prototype.readBits = function(t) {
for (var e = 0, i = t; i--; ) e = e << 1 | this.readBit();
t && (e = n.bitReverse[e] >> 8 - t);
return e;
};
n.prototype.flushBuffer = function() {
this.bIdx = 0;
};
n.prototype.addBuffer = function(t) {
this.buf32k[this.bIdx++] = t;
this.outputArr.push(String.fromCharCode(t));
32768 === this.bIdx && (this.bIdx = 0);
};
n.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]++;
}
};
n.prototype.Rec = function() {
var t, e = this.Places[this.treepos];
if (17 === this.len) return -1;
this.treepos++;
this.len++;
if ((t = this.IsPat()) >= 0) e.b0 = t; else {
e.b0 = 32768;
if (this.Rec()) return -1;
}
if ((t = this.IsPat()) >= 0) {
e.b1 = t;
e.jump = null;
} else {
e.b1 = 32768;
e.jump = this.Places[this.treepos];
e.jumppos = this.treepos;
if (this.Rec()) return -1;
}
this.len--;
return 0;
};
n.prototype.CreateTree = function(t, e, i, n) {
var r;
this.Places = t;
this.treepos = 0;
this.flens = i;
this.fmax = e;
for (r = 0; r < 17; r++) this.fpos[r] = 0;
this.len = 0;
return this.Rec() ? -1 : 0;
};
n.prototype.DecodeValue = function(t) {
for (var e, i, n = 0, r = t[n]; ;) if (this.readBit()) {
if (!(32768 & r.b1)) return r.b1;
r = r.jump;
e = t.length;
for (i = 0; i < e; i++) if (t[i] === r) {
n = i;
break;
}
} else {
if (!(32768 & r.b0)) return r.b0;
r = t[++n];
}
return -1;
};
n.prototype.DeflateLoop = function() {
var t, e, i;
do {
t = this.readBit();
if (0 === (e = this.readBits(2))) {
var r, s;
this.byteAlign();
r = this.readByte();
r |= this.readByte() << 8;
s = this.readByte();
65535 & (r ^ ~(s |= this.readByte() << 8)) && document.write("BlockLen checksum mismatch\n");
for (;r--; ) {
o = this.readByte();
this.addBuffer(o);
}
} else if (1 === e) for (;;) {
(a = n.bitReverse[this.readBits(7)] >> 1) > 23 ? (a = a << 1 | this.readBit()) > 199 ? a = (a -= 128) << 1 | this.readBit() : (a -= 48) > 143 && (a += 136) : a += 256;
if (a < 256) this.addBuffer(a); else {
if (256 === a) break;
a -= 257;
m = this.readBits(n.cplext[a]) + n.cplens[a];
a = n.bitReverse[this.readBits(5)] >> 3;
if (n.cpdext[a] > 8) {
p = this.readBits(8);
p |= this.readBits(n.cpdext[a] - 8) << 8;
} else p = this.readBits(n.cpdext[a]);
p += n.cpdist[a];
for (a = 0; a < m; a++) {
var o = this.buf32k[this.bIdx - p & 32767];
this.addBuffer(o);
}
}
} else if (2 === e) {
var a, c, h, l, u, _ = new Array(320);
h = 257 + this.readBits(5);
l = 1 + this.readBits(5);
u = 4 + this.readBits(4);
for (a = 0; a < 19; a++) _[a] = 0;
for (a = 0; a < u; a++) _[n.border[a]] = this.readBits(3);
m = this.distanceTree.length;
for (i = 0; i < m; i++) this.distanceTree[i] = new n.HufNode();
if (this.CreateTree(this.distanceTree, 19, _, 0)) {
this.flushBuffer();
return 1;
}
c = h + l;
i = 0;
for (;i < c; ) {
0;
if ((a = this.DecodeValue(this.distanceTree)) < 16) _[i++] = a; else if (16 === a) {
var f;
if (i + (a = 3 + this.readBits(2)) > c) {
this.flushBuffer();
return 1;
}
f = i ? _[i - 1] : 0;
for (;a--; ) _[i++] = f;
} else {
if (i + (a = 17 === a ? 3 + this.readBits(3) : 11 + this.readBits(7)) > c) {
this.flushBuffer();
return 1;
}
for (;a--; ) _[i++] = 0;
}
}
m = this.literalTree.length;
for (i = 0; i < m; i++) this.literalTree[i] = new n.HufNode();
if (this.CreateTree(this.literalTree, h, _, 0)) {
this.flushBuffer();
return 1;
}
m = this.literalTree.length;
for (i = 0; i < m; i++) this.distanceTree[i] = new n.HufNode();
var d = new Array();
for (i = h; i < _.length; i++) d[i - h] = _[i];
if (this.CreateTree(this.distanceTree, l, d, 0)) {
this.flushBuffer();
return 1;
}
for (;;) if ((a = this.DecodeValue(this.literalTree)) >= 256) {
var m, p;
if (0 === (a -= 256)) break;
a--;
m = this.readBits(n.cplext[a]) + n.cplens[a];
a = this.DecodeValue(this.distanceTree);
if (n.cpdext[a] > 8) {
p = this.readBits(8);
p |= this.readBits(n.cpdext[a] - 8) << 8;
} else p = this.readBits(n.cpdext[a]);
p += n.cpdist[a];
for (;m--; ) {
o = this.buf32k[this.bIdx - p & 32767];
this.addBuffer(o);
}
} else this.addBuffer(a);
}
} while (!t);
this.flushBuffer();
this.byteAlign();
return 0;
};
n.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];
};
n.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 r = this.readByte();
r |= this.readByte() << 8;
o = 0;
this.nameBuf = [];
for (;i--; ) {
var s = this.readByte();
"/" === s | ":" === s ? o = 0 : o < n.NAMEMAX - 1 && (this.nameBuf[o++] = String.fromCharCode(s));
}
this.fileout || (this.fileout = this.nameBuf);
for (var o = 0; o < r; ) {
s = this.readByte();
o++;
}
if (8 === e) {
this.DeflateLoop();
this.unzipped[this.files] = [ this.outputArr.join(""), this.nameBuf.join("") ];
this.files++;
}
this.skipdir();
}
}
};
n.prototype.skipdir = function() {
var t, e, i = [];
if (8 & this.gpflags) {
i[0] = this.readByte();
i[1] = this.readByte();
i[2] = this.readByte();
i[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();
i[0] = this.readByte();
if (8 !== i[0]) return 0;
this.gpflags = this.readByte();
this.readByte();
this.readByte();
this.readByte();
this.readByte();
this.readByte();
this.readByte();
if (4 & this.gpflags) {
i[0] = this.readByte();
i[2] = this.readByte();
this.len = i[0] + 256 * i[1];
for (t = 0; t < this.len; t++) this.readByte();
}
if (8 & this.gpflags) {
t = 0;
this.nameBuf = [];
for (;e = this.readByte(); ) {
"7" !== e && ":" !== e || (t = 0);
t < n.NAMEMAX - 1 && (this.nameBuf[t++] = e);
}
}
if (16 & this.gpflags) for (;e = 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();
};
e.exports = n;
}), {} ],
25: [ (function(i, n, r) {
(function() {
"use strict";
function i(t) {
throw t;
}
var n = void 0, r = !0, s = this;
function o(t, e) {
var i, r = t.split("."), o = s;
!(r[0] in o) && o.execScript && o.execScript("var " + r[0]);
for (;r.length && (i = r.shift()); ) r.length || e === n ? o = o[i] ? o[i] : o[i] = {} : o[i] = e;
}
var a = "undefined" !== ("object" === (e = typeof Uint8Array) ? t(Uint8Array) : e) && "undefined" !== ("object" === (e = typeof Uint16Array) ? t(Uint16Array) : e) && "undefined" !== ("object" === (e = typeof Uint32Array) ? t(Uint32Array) : e);
function c(i) {
if ("string" === ("object" === (e = typeof i) ? t(i) : e)) {
var n, r, s = i.split("");
n = 0;
for (r = s.length; n < r; n++) s[n] = (255 & s[n].charCodeAt(0)) >>> 0;
i = s;
}
for (var o, a = 1, c = 0, h = i.length, l = 0; 0 < h; ) {
h -= o = 1024 < h ? 1024 : h;
do {
c += a += i[l++];
} while (--o);
a %= 65521;
c %= 65521;
}
return (c << 16 | a) >>> 0;
}
function h(n, r) {
this.index = "number" === ("object" === (e = typeof r) ? t(r) : e) ? r : 0;
this.i = 0;
this.buffer = n instanceof (a ? Uint8Array : Array) ? n : new (a ? Uint8Array : Array)(32768);
2 * this.buffer.length <= this.index && i(Error("invalid index"));
this.buffer.length <= this.index && this.f();
}
h.prototype.f = function() {
var t, e = this.buffer, i = e.length, n = new (a ? Uint8Array : Array)(i << 1);
if (a) n.set(e); else for (t = 0; t < i; ++t) n[t] = e[t];
return this.buffer = n;
};
h.prototype.d = function(t, e, i) {
var n, r = this.buffer, s = this.index, o = this.i, a = r[s];
i && 1 < e && (t = 8 < e ? (m[255 & t] << 24 | m[t >>> 8 & 255] << 16 | m[t >>> 16 & 255] << 8 | m[t >>> 24 & 255]) >> 32 - e : m[t] >> 8 - e);
if (8 > e + o) a = a << e | t, o += e; else for (n = 0; n < e; ++n) a = a << 1 | t >> e - n - 1 & 1, 
8 == ++o && (o = 0, r[s++] = m[a], a = 0, s === r.length && (r = this.f()));
r[s] = a;
this.buffer = r;
this.i = o;
this.index = s;
};
h.prototype.finish = function() {
var t, e = this.buffer, i = this.index;
0 < this.i && (e[i] <<= 8 - this.i, e[i] = m[e[i]], i++);
a ? t = e.subarray(0, i) : (e.length = i, t = e);
return t;
};
var l, u = new (a ? Uint8Array : Array)(256);
for (l = 0; 256 > l; ++l) {
for (var _ = d = l, f = 7, d = d >>> 1; d; d >>>= 1) _ <<= 1, _ |= 1 & d, --f;
u[l] = (_ << f & 255) >>> 0;
}
var m = u;
a && new Uint32Array([ 0, 1996959894, 3993919788, 2567524794, 124634137, 1886057615, 3915621685, 2657392035, 249268274, 2044508324, 3772115230, 2547177864, 162941995, 2125561021, 3887607047, 2428444049, 498536548, 1789927666, 4089016648, 2227061214, 450548861, 1843258603, 4107580753, 2211677639, 325883990, 1684777152, 4251122042, 2321926636, 335633487, 1661365465, 4195302755, 2366115317, 997073096, 1281953886, 3579855332, 2724688242, 1006888145, 1258607687, 3524101629, 2768942443, 901097722, 1119000684, 3686517206, 2898065728, 853044451, 1172266101, 3705015759, 2882616665, 651767980, 1373503546, 3369554304, 3218104598, 565507253, 1454621731, 3485111705, 3099436303, 671266974, 1594198024, 3322730930, 2970347812, 795835527, 1483230225, 3244367275, 3060149565, 1994146192, 31158534, 2563907772, 4023717930, 1907459465, 112637215, 2680153253, 3904427059, 2013776290, 251722036, 2517215374, 3775830040, 2137656763, 141376813, 2439277719, 3865271297, 1802195444, 476864866, 2238001368, 4066508878, 1812370925, 453092731, 2181625025, 4111451223, 1706088902, 314042704, 2344532202, 4240017532, 1658658271, 366619977, 2362670323, 4224994405, 1303535960, 984961486, 2747007092, 3569037538, 1256170817, 1037604311, 2765210733, 3554079995, 1131014506, 879679996, 2909243462, 3663771856, 1141124467, 855842277, 2852801631, 3708648649, 1342533948, 654459306, 3188396048, 3373015174, 1466479909, 544179635, 3110523913, 3462522015, 1591671054, 702138776, 2966460450, 3352799412, 1504918807, 783551873, 3082640443, 3233442989, 3988292384, 2596254646, 62317068, 1957810842, 3939845945, 2647816111, 81470997, 1943803523, 3814918930, 2489596804, 225274430, 2053790376, 3826175755, 2466906013, 167816743, 2097651377, 4027552580, 2265490386, 503444072, 1762050814, 4150417245, 2154129355, 426522225, 1852507879, 4275313526, 2312317920, 282753626, 1742555852, 4189708143, 2394877945, 397917763, 1622183637, 3604390888, 2714866558, 953729732, 1340076626, 3518719985, 2797360999, 1068828381, 1219638859, 3624741850, 2936675148, 906185462, 1090812512, 3747672003, 2825379669, 829329135, 1181335161, 3412177804, 3160834842, 628085408, 1382605366, 3423369109, 3138078467, 570562233, 1426400815, 3317316542, 2998733608, 733239954, 1555261956, 3268935591, 3050360625, 752459403, 1541320221, 2607071920, 3965973030, 1969922972, 40735498, 2617837225, 3943577151, 1913087877, 83908371, 2512341634, 3803740692, 2075208622, 213261112, 2463272603, 3855990285, 2094854071, 198958881, 2262029012, 4057260610, 1759359992, 534414190, 2176718541, 4139329115, 1873836001, 414664567, 2282248934, 4279200368, 1711684554, 285281116, 2405801727, 4167216745, 1634467795, 376229701, 2685067896, 3608007406, 1308918612, 956543938, 2808555105, 3495958263, 1231636301, 1047427035, 2932959818, 3654703836, 1088359270, 936918e3, 2847714899, 3736837829, 1202900863, 817233897, 3183342108, 3401237130, 1404277552, 615818150, 3134207493, 3453421203, 1423857449, 601450431, 3009837614, 3294710456, 1567103746, 711928724, 3020668471, 3272380065, 1510334235, 755167117 ]);
function p(t) {
this.buffer = new (a ? 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, n, r, s = this.buffer;
i = this.length;
s[this.length++] = e;
for (s[this.length++] = t; 0 < i && (n = this.getParent(i), s[i] > s[n]); ) r = s[i], 
s[i] = s[n], s[n] = r, r = s[i + 1], s[i + 1] = s[n + 1], s[n + 1] = r, i = n;
return this.length;
};
p.prototype.pop = function() {
var t, e, i, n, r, s = this.buffer;
e = s[0];
t = s[1];
this.length -= 2;
s[0] = s[this.length];
s[1] = s[this.length + 1];
for (r = 0; !((n = 2 * r + 2) >= this.length); ) {
n + 2 < this.length && s[n + 2] > s[n] && (n += 2);
if (!(s[n] > s[r])) break;
i = s[r], s[r] = s[n], s[n] = i, i = s[r + 1], s[r + 1] = s[n + 1], s[n + 1] = i;
r = n;
}
return {
index: t,
value: e,
length: this.length
};
};
function v(t) {
var e, i, n, r, s, o, c, h, l, u = t.length, _ = 0, f = Number.POSITIVE_INFINITY;
for (h = 0; h < u; ++h) t[h] > _ && (_ = t[h]), t[h] < f && (f = t[h]);
e = 1 << _;
i = new (a ? Uint32Array : Array)(e);
n = 1;
r = 0;
for (s = 2; n <= _; ) {
for (h = 0; h < u; ++h) if (t[h] === n) {
o = 0;
c = r;
for (l = 0; l < n; ++l) o = o << 1 | 1 & c, c >>= 1;
for (l = o; l < e; l += s) i[l] = n << 16 | h;
++r;
}
++n;
r <<= 1;
s <<= 1;
}
return [ i, _, f ];
}
function y(i, n) {
this.h = x;
this.w = 0;
this.input = i;
this.b = 0;
n && (n.lazy && (this.w = n.lazy), "number" === ("object" === (e = typeof n.compressionType) ? t(n.compressionType) : e) && (this.h = n.compressionType), 
n.outputBuffer && (this.a = a && n.outputBuffer instanceof Array ? new Uint8Array(n.outputBuffer) : n.outputBuffer), 
"number" === ("object" === (e = typeof n.outputIndex) ? t(n.outputIndex) : e) && (this.b = n.outputIndex));
this.a || (this.a = new (a ? Uint8Array : Array)(32768));
}
var g, x = 2, C = {
NONE: 0,
r: 1,
j: x,
N: 3
}, A = [];
for (g = 0; 288 > g; g++) switch (r) {
case 143 >= g:
A.push([ g + 48, 8 ]);
break;

case 255 >= g:
A.push([ g - 144 + 400, 9 ]);
break;

case 279 >= g:
A.push([ g - 256 + 0, 7 ]);
break;

case 287 >= g:
A.push([ g - 280 + 192, 8 ]);
break;

default:
i("invalid literal: " + g);
}
y.prototype.n = function() {
var t, e, s, o, c = this.input;
switch (this.h) {
case 0:
s = 0;
for (o = c.length; s < o; ) {
var l, u, _, f = e = a ? c.subarray(s, s + 65535) : c.slice(s, s + 65535), d = (s += e.length) === o, m = n, p = n, v = this.a, y = this.b;
if (a) {
for (v = new Uint8Array(this.a.buffer); v.length <= y + f.length + 5; ) v = new Uint8Array(v.length << 1);
v.set(this.a);
}
l = d ? 1 : 0;
v[y++] = 0 | l;
_ = 65536 + ~(u = f.length) & 65535;
v[y++] = 255 & u;
v[y++] = u >>> 8 & 255;
v[y++] = 255 & _;
v[y++] = _ >>> 8 & 255;
if (a) v.set(f, y), y += f.length, v = v.subarray(0, y); else {
m = 0;
for (p = f.length; m < p; ++m) v[y++] = f[m];
v.length = y;
}
this.b = y;
this.a = v;
}
break;

case 1:
var g = new h(new Uint8Array(this.a.buffer), this.b);
g.d(1, 1, r);
g.d(1, 2, r);
var C, b, S, T = M(this, c);
C = 0;
for (b = T.length; C < b; C++) if (S = T[C], h.prototype.d.apply(g, A[S]), 256 < S) g.d(T[++C], T[++C], r), 
g.d(T[++C], 5), g.d(T[++C], T[++C], r); else if (256 === S) break;
this.a = g.finish();
this.b = this.a.length;
break;

case x:
var w, E, B, P, R, L, F, V, O, N, k, G, z, U, j, H = new h(new Uint8Array(this.a), this.b), W = [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ], q = Array(19);
w = x;
H.d(1, 1, r);
H.d(w, 2, r);
E = M(this, c);
F = I(L = D(this.L, 15));
O = I(V = D(this.K, 7));
for (B = 286; 257 < B && 0 === L[B - 1]; B--) ;
for (P = 30; 1 < P && 0 === V[P - 1]; P--) ;
var X, Y, J, Z, K, Q, $ = B, tt = P, et = new (a ? Uint32Array : Array)($ + tt), it = new (a ? Uint32Array : Array)(316), nt = new (a ? Uint8Array : Array)(19);
for (X = Y = 0; X < $; X++) et[Y++] = L[X];
for (X = 0; X < tt; X++) et[Y++] = V[X];
if (!a) {
X = 0;
for (Z = nt.length; X < Z; ++X) nt[X] = 0;
}
X = K = 0;
for (Z = et.length; X < Z; X += Y) {
for (Y = 1; X + Y < Z && et[X + Y] === et[X]; ++Y) ;
J = Y;
if (0 === et[X]) if (3 > J) for (;0 < J--; ) it[K++] = 0, nt[0]++; else for (;0 < J; ) (Q = 138 > J ? J : 138) > J - 3 && Q < J && (Q = J - 3), 
10 >= Q ? (it[K++] = 17, it[K++] = Q - 3, nt[17]++) : (it[K++] = 18, it[K++] = Q - 11, 
nt[18]++), J -= Q; else if (it[K++] = et[X], nt[et[X]]++, 3 > --J) for (;0 < J--; ) it[K++] = et[X], 
nt[et[X]]++; else for (;0 < J; ) (Q = 6 > J ? J : 6) > J - 3 && Q < J && (Q = J - 3), 
it[K++] = 16, it[K++] = Q - 3, nt[16]++, J -= Q;
}
t = a ? it.subarray(0, K) : it.slice(0, K);
N = D(nt, 7);
for (U = 0; 19 > U; U++) q[U] = N[W[U]];
for (R = 19; 4 < R && 0 === q[R - 1]; R--) ;
k = I(N);
H.d(B - 257, 5, r);
H.d(P - 1, 5, r);
H.d(R - 4, 4, r);
for (U = 0; U < R; U++) H.d(q[U], 3, r);
U = 0;
for (j = t.length; U < j; U++) if (G = t[U], H.d(k[G], N[G], r), 16 <= G) {
U++;
switch (G) {
case 16:
z = 2;
break;

case 17:
z = 3;
break;

case 18:
z = 7;
break;

default:
i("invalid code: " + G);
}
H.d(t[U], z, r);
}
var rt, st, ot, at, ct, ht, lt, ut, _t = [ F, L ], ft = [ O, V ];
ct = _t[0];
ht = _t[1];
lt = ft[0];
ut = ft[1];
rt = 0;
for (st = E.length; rt < st; ++rt) if (ot = E[rt], H.d(ct[ot], ht[ot], r), 256 < ot) H.d(E[++rt], E[++rt], r), 
at = E[++rt], H.d(lt[at], ut[at], r), H.d(E[++rt], E[++rt], r); else if (256 === ot) break;
this.a = H.finish();
this.b = this.a.length;
break;

default:
i("invalid compression type");
}
return this.a;
};
function b(t, e) {
this.length = t;
this.G = e;
}
function S() {
var t = T;
switch (r) {
case 3 === t:
return [ 257, t - 3, 0 ];

case 4 === t:
return [ 258, t - 4, 0 ];

case 5 === t:
return [ 259, t - 5, 0 ];

case 6 === t:
return [ 260, t - 6, 0 ];

case 7 === t:
return [ 261, t - 7, 0 ];

case 8 === t:
return [ 262, t - 8, 0 ];

case 9 === t:
return [ 263, t - 9, 0 ];

case 10 === t:
return [ 264, t - 10, 0 ];

case 12 >= t:
return [ 265, t - 11, 1 ];

case 14 >= t:
return [ 266, t - 13, 1 ];

case 16 >= t:
return [ 267, t - 15, 1 ];

case 18 >= t:
return [ 268, t - 17, 1 ];

case 22 >= t:
return [ 269, t - 19, 2 ];

case 26 >= t:
return [ 270, t - 23, 2 ];

case 30 >= t:
return [ 271, t - 27, 2 ];

case 34 >= t:
return [ 272, t - 31, 2 ];

case 42 >= t:
return [ 273, t - 35, 3 ];

case 50 >= t:
return [ 274, t - 43, 3 ];

case 58 >= t:
return [ 275, t - 51, 3 ];

case 66 >= t:
return [ 276, t - 59, 3 ];

case 82 >= t:
return [ 277, t - 67, 4 ];

case 98 >= t:
return [ 278, t - 83, 4 ];

case 114 >= t:
return [ 279, t - 99, 4 ];

case 130 >= t:
return [ 280, t - 115, 4 ];

case 162 >= t:
return [ 281, t - 131, 5 ];

case 194 >= t:
return [ 282, t - 163, 5 ];

case 226 >= t:
return [ 283, t - 195, 5 ];

case 257 >= t:
return [ 284, t - 227, 5 ];

case 258 === t:
return [ 285, t - 258, 0 ];

default:
i("invalid length: " + t);
}
}
var T, w, E = [];
for (T = 3; 258 >= T; T++) w = S(), E[T] = w[2] << 24 | w[1] << 16 | w[0];
var B = a ? new Uint32Array(E) : E;
function M(t, e) {
function s(t, e) {
var n, s, o, a, c = t.G, h = [], l = 0;
n = B[t.length];
h[l++] = 65535 & n;
h[l++] = n >> 16 & 255;
h[l++] = n >> 24;
switch (r) {
case 1 === c:
s = [ 0, c - 1, 0 ];
break;

case 2 === c:
s = [ 1, c - 2, 0 ];
break;

case 3 === c:
s = [ 2, c - 3, 0 ];
break;

case 4 === c:
s = [ 3, c - 4, 0 ];
break;

case 6 >= c:
s = [ 4, c - 5, 1 ];
break;

case 8 >= c:
s = [ 5, c - 7, 1 ];
break;

case 12 >= c:
s = [ 6, c - 9, 2 ];
break;

case 16 >= c:
s = [ 7, c - 13, 2 ];
break;

case 24 >= c:
s = [ 8, c - 17, 3 ];
break;

case 32 >= c:
s = [ 9, c - 25, 3 ];
break;

case 48 >= c:
s = [ 10, c - 33, 4 ];
break;

case 64 >= c:
s = [ 11, c - 49, 4 ];
break;

case 96 >= c:
s = [ 12, c - 65, 5 ];
break;

case 128 >= c:
s = [ 13, c - 97, 5 ];
break;

case 192 >= c:
s = [ 14, c - 129, 6 ];
break;

case 256 >= c:
s = [ 15, c - 193, 6 ];
break;

case 384 >= c:
s = [ 16, c - 257, 7 ];
break;

case 512 >= c:
s = [ 17, c - 385, 7 ];
break;

case 768 >= c:
s = [ 18, c - 513, 8 ];
break;

case 1024 >= c:
s = [ 19, c - 769, 8 ];
break;

case 1536 >= c:
s = [ 20, c - 1025, 9 ];
break;

case 2048 >= c:
s = [ 21, c - 1537, 9 ];
break;

case 3072 >= c:
s = [ 22, c - 2049, 10 ];
break;

case 4096 >= c:
s = [ 23, c - 3073, 10 ];
break;

case 6144 >= c:
s = [ 24, c - 4097, 11 ];
break;

case 8192 >= c:
s = [ 25, c - 6145, 11 ];
break;

case 12288 >= c:
s = [ 26, c - 8193, 12 ];
break;

case 16384 >= c:
s = [ 27, c - 12289, 12 ];
break;

case 24576 >= c:
s = [ 28, c - 16385, 13 ];
break;

case 32768 >= c:
s = [ 29, c - 24577, 13 ];
break;

default:
i("invalid distance");
}
n = s;
h[l++] = n[0];
h[l++] = n[1];
h[l++] = n[2];
o = 0;
for (a = h.length; o < a; ++o) v[y++] = h[o];
x[h[0]]++;
C[h[3]]++;
g = t.length + e - 1;
d = null;
}
var o, c, h, l, u, _, f, d, m, p = {}, v = a ? new Uint16Array(2 * e.length) : [], y = 0, g = 0, x = new (a ? Uint32Array : Array)(286), C = new (a ? Uint32Array : Array)(30), A = t.w;
if (!a) {
for (h = 0; 285 >= h; ) x[h++] = 0;
for (h = 0; 29 >= h; ) C[h++] = 0;
}
x[256] = 1;
o = 0;
for (c = e.length; o < c; ++o) {
h = u = 0;
for (l = 3; h < l && o + h !== c; ++h) u = u << 8 | e[o + h];
p[u] === n && (p[u] = []);
_ = p[u];
if (!(0 < g--)) {
for (;0 < _.length && 32768 < o - _[0]; ) _.shift();
if (o + 3 >= c) {
d && s(d, -1);
h = 0;
for (l = c - o; h < l; ++h) m = e[o + h], v[y++] = m, ++x[m];
break;
}
if (0 < _.length) {
var S = n, T = n, w = 0, E = n, M = n, D = n, I = e.length, P = (M = 0, _.length);
t: for (;M < P; M++) {
S = _[P - M - 1];
E = 3;
if (3 < w) {
for (D = w; 3 < D; D--) if (e[S + D - 1] !== e[o + D - 1]) continue t;
E = w;
}
for (;258 > E && o + E < I && e[S + E] === e[o + E]; ) ++E;
E > w && (T = S, w = E);
if (258 === E) break;
}
f = new b(w, o - T);
d ? d.length < f.length ? (m = e[o - 1], v[y++] = m, ++x[m], s(f, 0)) : s(d, -1) : f.length < A ? d = f : s(f, 0);
} else d ? s(d, -1) : (m = e[o], v[y++] = m, ++x[m]);
}
_.push(o);
}
v[y++] = 256;
x[256]++;
t.L = x;
t.K = C;
return a ? v.subarray(0, y) : v;
}
function D(t, e) {
function i(t) {
var e = b[t][S[t]];
e === y ? (i(t + 1), i(t + 1)) : --C[e];
++S[t];
}
var n, r, s, o, c, h = t.length, l = new p(572), u = new (a ? Uint8Array : Array)(h);
if (!a) for (o = 0; o < h; o++) u[o] = 0;
for (o = 0; o < h; ++o) 0 < t[o] && l.push(o, t[o]);
n = Array(l.length / 2);
r = new (a ? Uint32Array : Array)(l.length / 2);
if (1 === n.length) return u[l.pop().index] = 1, u;
o = 0;
for (c = l.length / 2; o < c; ++o) n[o] = l.pop(), r[o] = n[o].value;
var _, f, d, m, v, y = r.length, g = new (a ? Uint16Array : Array)(e), x = new (a ? Uint8Array : Array)(e), C = new (a ? Uint8Array : Array)(y), A = Array(e), b = Array(e), S = Array(e), T = (1 << e) - y, w = 1 << e - 1;
g[e - 1] = y;
for (f = 0; f < e; ++f) T < w ? x[f] = 0 : (x[f] = 1, T -= w), T <<= 1, g[e - 2 - f] = (g[e - 1 - f] / 2 | 0) + y;
g[0] = x[0];
A[0] = Array(g[0]);
b[0] = Array(g[0]);
for (f = 1; f < e; ++f) g[f] > 2 * g[f - 1] + x[f] && (g[f] = 2 * g[f - 1] + x[f]), 
A[f] = Array(g[f]), b[f] = Array(g[f]);
for (_ = 0; _ < y; ++_) C[_] = e;
for (d = 0; d < g[e - 1]; ++d) A[e - 1][d] = r[d], b[e - 1][d] = d;
for (_ = 0; _ < e; ++_) S[_] = 0;
1 === x[e - 1] && (--C[0], ++S[e - 1]);
for (f = e - 2; 0 <= f; --f) {
m = _ = 0;
v = S[f + 1];
for (d = 0; d < g[f]; d++) (m = A[f + 1][v] + A[f + 1][v + 1]) > r[_] ? (A[f][d] = m, 
b[f][d] = y, v += 2) : (A[f][d] = r[_], b[f][d] = _, ++_);
S[f] = 0;
1 === x[f] && i(f);
}
s = C;
o = 0;
for (c = n.length; o < c; ++o) u[n[o].index] = s[o];
return u;
}
function I(t) {
var e, n, r, s, o = new (a ? Uint16Array : Array)(t.length), c = [], h = [], l = 0;
e = 0;
for (n = t.length; e < n; e++) c[t[e]] = 1 + (0 | c[t[e]]);
e = 1;
for (n = 16; e <= n; e++) h[e] = l, (l += 0 | c[e]) > 1 << e && i("overcommitted"), 
l <<= 1;
65536 > l && i("undercommitted");
e = 0;
for (n = t.length; e < n; e++) {
l = h[t[e]];
h[t[e]] += 1;
r = o[e] = 0;
for (s = t[e]; r < s; r++) o[e] = o[e] << 1 | 1 & l, l >>>= 1;
}
return o;
}
function P(i, n) {
this.input = i;
this.a = new (a ? Uint8Array : Array)(32768);
this.h = R.j;
var r, s = {};
!n && (n = {}) || "number" !== ("object" === (e = typeof n.compressionType) ? t(n.compressionType) : e) || (this.h = n.compressionType);
for (r in n) s[r] = n[r];
s.outputBuffer = this.a;
this.z = new y(this.input, s);
}
var R = C;
P.prototype.n = function() {
var t, e, n, r, s, o, h, l = 0;
h = this.a;
switch (t = _t) {
case _t:
e = Math.LOG2E * Math.log(32768) - 8;
break;

default:
i(Error("invalid compression method"));
}
n = e << 4 | t;
h[l++] = n;
switch (t) {
case _t:
switch (this.h) {
case R.NONE:
s = 0;
break;

case R.r:
s = 1;
break;

case R.j:
s = 2;
break;

default:
i(Error("unsupported compression type"));
}
break;

default:
i(Error("invalid compression method"));
}
r = s << 6 | 0;
h[l++] = r | 31 - (256 * n + r) % 31;
o = c(this.input);
this.z.b = l;
l = (h = this.z.n()).length;
a && ((h = new Uint8Array(h.buffer)).length <= l + 4 && (this.a = new Uint8Array(h.length + 4), 
this.a.set(h), h = this.a), h = h.subarray(0, l + 4));
h[l++] = o >> 24 & 255;
h[l++] = o >> 16 & 255;
h[l++] = o >> 8 & 255;
h[l++] = 255 & o;
return h;
};
o("Zlib.Deflate", P);
o("Zlib.Deflate.compress", (function(t, e) {
return new P(t, e).n();
}));
o("Zlib.Deflate.CompressionType", R);
o("Zlib.Deflate.CompressionType.NONE", R.NONE);
o("Zlib.Deflate.CompressionType.FIXED", R.r);
o("Zlib.Deflate.CompressionType.DYNAMIC", R.j);
function L(t, e) {
this.k = [];
this.l = 32768;
this.e = this.g = this.c = this.q = 0;
this.input = a ? new Uint8Array(t) : t;
this.s = !1;
this.m = V;
this.B = !1;
!e && (e = {}) || (e.index && (this.c = e.index), e.bufferSize && (this.l = e.bufferSize), 
e.bufferType && (this.m = e.bufferType), e.resize && (this.B = e.resize));
switch (this.m) {
case F:
this.b = 32768;
this.a = new (a ? Uint8Array : Array)(32768 + this.l + 258);
break;

case V:
this.b = 0;
this.a = new (a ? Uint8Array : Array)(this.l);
this.f = this.J;
this.t = this.H;
this.o = this.I;
break;

default:
i(Error("invalid inflate mode"));
}
}
var F = 0, V = 1, O = {
D: F,
C: V
};
L.prototype.p = function() {
for (;!this.s; ) {
var t = it(this, 3);
1 & t && (this.s = r);
switch (t >>>= 1) {
case 0:
var e = this.input, s = this.c, o = this.a, c = this.b, h = n, l = n, u = n, _ = o.length, f = n;
this.e = this.g = 0;
(h = e[s++]) === n && i(Error("invalid uncompressed block header: LEN (first byte)"));
l = h;
(h = e[s++]) === n && i(Error("invalid uncompressed block header: LEN (second byte)"));
l |= h << 8;
(h = e[s++]) === n && i(Error("invalid uncompressed block header: NLEN (first byte)"));
u = h;
(h = e[s++]) === n && i(Error("invalid uncompressed block header: NLEN (second byte)"));
l === ~(u |= h << 8) && i(Error("invalid uncompressed block header: length verify"));
s + l > e.length && i(Error("input buffer is broken"));
switch (this.m) {
case F:
for (;c + l > o.length; ) {
l -= f = _ - c;
if (a) o.set(e.subarray(s, s + f), c), c += f, s += f; else for (;f--; ) o[c++] = e[s++];
this.b = c;
o = this.f();
c = this.b;
}
break;

case V:
for (;c + l > o.length; ) o = this.f({
v: 2
});
break;

default:
i(Error("invalid inflate mode"));
}
if (a) o.set(e.subarray(s, s + l), c), c += l, s += l; else for (;l--; ) o[c++] = e[s++];
this.c = s;
this.b = c;
this.a = o;
break;

case 1:
this.o($, et);
break;

case 2:
rt(this);
break;

default:
i(Error("unknown BTYPE: " + t));
}
}
return this.t();
};
var N, k, G = [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ], z = a ? new Uint16Array(G) : G, 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 ], j = a ? new Uint16Array(U) : U, H = [ 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 ], W = a ? new Uint8Array(H) : H, q = [ 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 = a ? new Uint16Array(q) : q, Y = [ 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 ], J = a ? new Uint8Array(Y) : Y, Z = new (a ? Uint8Array : Array)(288);
N = 0;
for (k = Z.length; N < k; ++N) Z[N] = 143 >= N ? 8 : 255 >= N ? 9 : 279 >= N ? 7 : 8;
var K, Q, $ = v(Z), tt = new (a ? Uint8Array : Array)(30);
K = 0;
for (Q = tt.length; K < Q; ++K) tt[K] = 5;
var et = v(tt);
function it(t, e) {
for (var r, s = t.g, o = t.e, a = t.input, c = t.c; o < e; ) (r = a[c++]) === n && i(Error("input buffer is broken")), 
s |= r << o, o += 8;
r = s & (1 << e) - 1;
t.g = s >>> e;
t.e = o - e;
t.c = c;
return r;
}
function nt(t, e) {
for (var r, s, o, a = t.g, c = t.e, h = t.input, l = t.c, u = e[0], _ = e[1]; c < _; ) (r = h[l++]) === n && i(Error("input buffer is broken")), 
a |= r << c, c += 8;
o = (s = u[a & (1 << _) - 1]) >>> 16;
t.g = a >> o;
t.e = c - o;
t.c = l;
return 65535 & s;
}
function rt(t) {
function e(t, e, i) {
var n, r, s, o;
for (o = 0; o < t; ) switch (n = nt(this, e)) {
case 16:
for (s = 3 + it(this, 2); s--; ) i[o++] = r;
break;

case 17:
for (s = 3 + it(this, 3); s--; ) i[o++] = 0;
r = 0;
break;

case 18:
for (s = 11 + it(this, 7); s--; ) i[o++] = 0;
r = 0;
break;

default:
r = i[o++] = n;
}
return i;
}
var i, n, r, s, o = it(t, 5) + 257, c = it(t, 5) + 1, h = it(t, 4) + 4, l = new (a ? Uint8Array : Array)(z.length);
for (s = 0; s < h; ++s) l[z[s]] = it(t, 3);
i = v(l);
n = new (a ? Uint8Array : Array)(o);
r = new (a ? Uint8Array : Array)(c);
t.o(v(e.call(t, o, i, n)), v(e.call(t, c, i, r)));
}
L.prototype.o = function(t, e) {
var i = this.a, n = this.b;
this.u = t;
for (var r, s, o, a, c = i.length - 258; 256 !== (r = nt(this, t)); ) if (256 > r) n >= c && (this.b = n, 
i = this.f(), n = this.b), i[n++] = r; else {
a = j[s = r - 257];
0 < W[s] && (a += it(this, W[s]));
r = nt(this, e);
o = X[r];
0 < J[r] && (o += it(this, J[r]));
n >= c && (this.b = n, i = this.f(), n = this.b);
for (;a--; ) i[n] = i[n++ - o];
}
for (;8 <= this.e; ) this.e -= 8, this.c--;
this.b = n;
};
L.prototype.I = function(t, e) {
var i = this.a, n = this.b;
this.u = t;
for (var r, s, o, a, c = i.length; 256 !== (r = nt(this, t)); ) if (256 > r) n >= c && (c = (i = this.f()).length), 
i[n++] = r; else {
a = j[s = r - 257];
0 < W[s] && (a += it(this, W[s]));
r = nt(this, e);
o = X[r];
0 < J[r] && (o += it(this, J[r]));
n + a > c && (c = (i = this.f()).length);
for (;a--; ) i[n] = i[n++ - o];
}
for (;8 <= this.e; ) this.e -= 8, this.c--;
this.b = n;
};
L.prototype.f = function() {
var t, e, i = new (a ? Uint8Array : Array)(this.b - 32768), n = this.b - 32768, r = this.a;
if (a) i.set(r.subarray(32768, i.length)); else {
t = 0;
for (e = i.length; t < e; ++t) i[t] = r[t + 32768];
}
this.k.push(i);
this.q += i.length;
if (a) r.set(r.subarray(n, n + 32768)); else for (t = 0; 32768 > t; ++t) r[t] = r[n + t];
this.b = 32768;
return r;
};
L.prototype.J = function(i) {
var n, r, s, o = this.input.length / this.c + 1 | 0, c = this.input, h = this.a;
i && ("number" === ("object" === (e = typeof i.v) ? t(i.v) : e) && (o = i.v), "number" === ("object" === (e = typeof i.F) ? t(i.F) : e) && (o += i.F));
2 > o ? r = (s = (c.length - this.c) / this.u[2] / 2 * 258 | 0) < h.length ? h.length + s : h.length << 1 : r = h.length * o;
a ? (n = new Uint8Array(r)).set(h) : n = h;
return this.a = n;
};
L.prototype.t = function() {
var t, e, i, n, r, s = 0, o = this.a, c = this.k, h = new (a ? Uint8Array : Array)(this.q + (this.b - 32768));
if (0 === c.length) return a ? this.a.subarray(32768, this.b) : this.a.slice(32768, this.b);
e = 0;
for (i = c.length; e < i; ++e) {
t = c[e];
n = 0;
for (r = t.length; n < r; ++n) h[s++] = t[n];
}
e = 32768;
for (i = this.b; e < i; ++e) h[s++] = o[e];
this.k = [];
return this.buffer = h;
};
L.prototype.H = function() {
var t, e = this.b;
a ? 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(t, e) {
var n, r;
this.input = t;
this.c = 0;
!e && (e = {}) || (e.index && (this.c = e.index), e.verify && (this.M = e.verify));
n = t[this.c++];
r = t[this.c++];
switch (15 & n) {
case _t:
this.method = _t;
break;

default:
i(Error("unsupported compression method"));
}
0 != ((n << 8) + r) % 31 && i(Error("invalid fcheck flag:" + ((n << 8) + r) % 31));
32 & r && i(Error("fdict flag is not supported"));
this.A = new L(t, {
index: this.c,
bufferSize: e.bufferSize,
bufferType: e.bufferType,
resize: e.resize
});
}
st.prototype.p = function() {
var t, e = this.input;
t = this.A.p();
this.c = this.A.c;
this.M && ((e[this.c++] << 24 | e[this.c++] << 16 | e[this.c++] << 8 | e[this.c++]) >>> 0 !== c(t) && i(Error("invalid adler-32 checksum")));
return t;
};
o("Zlib.Inflate", st);
o("Zlib.Inflate.BufferType", O);
O.ADAPTIVE = O.C;
O.BLOCK = O.D;
o("Zlib.Inflate.prototype.decompress", st.prototype.p);
a && new Uint16Array([ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]);
a && new Uint16Array([ 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 ]);
a && new Uint8Array([ 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 ]);
a && new Uint16Array([ 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 ]);
a && new Uint8Array([ 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 ]);
var ot, at, ct = new (a ? Uint8Array : Array)(288);
ot = 0;
for (at = ct.length; ot < at; ++ot) ct[ot] = 143 >= ot ? 8 : 255 >= ot ? 9 : 279 >= ot ? 7 : 8;
v(ct);
var ht, lt, ut = new (a ? Uint8Array : Array)(30);
ht = 0;
for (lt = ut.length; ht < lt; ++ht) ut[ht] = 5;
v(ut);
var _t = 8;
}).call(window);
var s = window.Zlib;
s.Deflate = s.Deflate;
s.Deflate.compress = s.Deflate.compress;
s.Inflate = s.Inflate;
s.Inflate.BufferType = s.Inflate.BufferType;
s.Inflate.prototype.decompress = s.Inflate.prototype.decompress;
n.exports = s;
}), {} ],
26: [ (function(t, e, i) {
t("../../DebugInfos");
var n = "https://github.com/cocos-creator/engine/blob/master/EngineErrorMap.md", r = void 0;
cc.log = cc.warn = cc.error = cc.assert = console.log;
cc._throw = function(t) {
var e = t.stack;
e ? cc.error(t + "\n" + e) : cc.error(t);
};
function s(t) {
return function() {
var e = arguments[0], i = t + " " + e + ", please go to " + n + "#" + e + " to see details.";
if (1 === arguments.length) return i;
if (2 === arguments.length) return i + " Arguments: " + arguments[1];
var r = cc.js.shiftArguments.apply(null, arguments);
return i + " Arguments: " + r.join(", ");
};
}
var o = s("Log");
cc.logID = function() {
cc.log(o.apply(null, arguments));
};
var a = s("Warning");
cc.warnID = function() {
cc.warn(a.apply(null, arguments));
};
var c = s("Error");
cc.errorID = function() {
cc.error(c.apply(null, arguments));
};
var h = s("Assert");
cc.assertID = function(t) {
"use strict";
t || cc.assert(!1, h.apply(null, cc.js.shiftArguments.apply(null, arguments)));
};
var l = cc.Enum({
NONE: 0,
INFO: 1,
WARN: 2,
ERROR: 3,
INFO_FOR_WEB_PAGE: 4,
WARN_FOR_WEB_PAGE: 5,
ERROR_FOR_WEB_PAGE: 6
});
e.exports = cc.debug = {
DebugMode: l,
_resetDebugSetting: function(t) {
cc.log = cc.warn = cc.error = cc.assert = function() {};
if (t !== l.NONE) {
if (t > l.ERROR) (function() {
function e(t) {
if (cc.game.canvas) {
if (!r) {
var e = document.createElement("Div");
e.setAttribute("id", "logInfoDiv");
e.setAttribute("width", "200");
e.setAttribute("height", cc.game.canvas.height);
var i = e.style;
i.zIndex = "99999";
i.position = "absolute";
i.top = i.left = "0";
(r = document.createElement("textarea")).setAttribute("rows", "20");
r.setAttribute("cols", "30");
r.setAttribute("disabled", "true");
var n = r.style;
n.backgroundColor = "transparent";
n.borderBottom = "1px solid #cccccc";
n.borderTopWidth = n.borderLeftWidth = n.borderRightWidth = "0px";
n.borderTopStyle = n.borderLeftStyle = n.borderRightStyle = "none";
n.padding = "0px";
n.margin = 0;
e.appendChild(r);
cc.game.canvas.parentNode.appendChild(e);
}
r.value = r.value + t + "\r\n";
r.scrollTop = r.scrollHeight;
}
}
cc.error = function() {
e("ERROR :  " + cc.js.formatStr.apply(null, arguments));
};
cc.assert = function(t, i) {
"use strict";
!t && i && e("ASSERT: " + (i = cc.js.formatStr.apply(null, cc.js.shiftArguments.apply(null, arguments))));
};
t !== l.ERROR_FOR_WEB_PAGE && (cc.warn = function() {
e("WARN :  " + cc.js.formatStr.apply(null, arguments));
});
t === l.INFO_FOR_WEB_PAGE && (cc.log = function() {
e(cc.js.formatStr.apply(null, arguments));
});
})(); else if (console && console.log.apply) {
console.error || (console.error = console.log);
console.warn || (console.warn = console.log);
console.error.bind ? cc.error = console.error.bind(console) : cc.error = console.error;
cc.assert = function(t, e) {
if (!t) {
e && (e = cc.js.formatStr.apply(null, cc.js.shiftArguments.apply(null, arguments)));
throw new Error(e);
}
};
}
t !== l.ERROR && (console.warn.bind ? cc.warn = console.warn.bind(console) : cc.warn = console.warn);
t === l.INFO && ("JavaScriptCore" === scriptEngineType ? cc.log = function() {
return console.log.apply(console, arguments);
} : cc.log = console.log);
}
},
getError: s("ERROR"),
isDisplayStats: function() {
return !!cc.profiler && cc.profiler.isShowingStats();
},
setDisplayStats: function(t) {
if (cc.profiler) {
t ? cc.profiler.showStats() : cc.profiler.hideStats();
cc.game.config.showFPS = !!t;
}
}
};
}), {
"../../DebugInfos": void 0
} ],
27: [ (function(i, n, r) {
var s = i("./event/event-target"), o = i("./load-pipeline/auto-release-utils"), a = i("./component-scheduler"), c = i("./node-activator"), h = i("./platform/CCObject"), l = i("./CCGame"), u = i("./renderer"), _ = i("./event-manager"), f = i("./CCScheduler");
cc.Director = function() {
s.call(this);
this.invalid = !1;
this._paused = !1;
this._purgeDirectorInNextLoop = !1;
this._winSizeInPoints = null;
this._loadingScene = "";
this._scene = null;
this._totalFrames = 0;
this._lastUpdate = 0;
this._deltaTime = 0;
this._scheduler = null;
this._compScheduler = null;
this._nodeActivator = null;
this._actionManager = null;
var t = this;
l.on(l.EVENT_SHOW, (function() {
t._lastUpdate = performance.now();
}));
l.once(l.EVENT_ENGINE_INITED, this.init, this);
};
cc.Director.prototype = {
constructor: cc.Director,
init: function() {
this._totalFrames = 0;
this._lastUpdate = performance.now();
this._paused = !1;
this._purgeDirectorInNextLoop = !1;
this._winSizeInPoints = cc.size(0, 0);
this._scheduler = new f();
if (cc.ActionManager) {
this._actionManager = new cc.ActionManager();
this._scheduler.scheduleUpdate(this._actionManager, f.PRIORITY_SYSTEM, !1);
} else this._actionManager = null;
this.sharedInit();
return !0;
},
sharedInit: function() {
this._compScheduler = new a();
this._nodeActivator = new c();
_ && _.setEnabled(!0);
if (cc.AnimationManager) {
this._animationManager = new cc.AnimationManager();
this._scheduler.scheduleUpdate(this._animationManager, f.PRIORITY_SYSTEM, !1);
} else this._animationManager = null;
if (cc.CollisionManager) {
this._collisionManager = new cc.CollisionManager();
this._scheduler.scheduleUpdate(this._collisionManager, f.PRIORITY_SYSTEM, !1);
} else this._collisionManager = null;
if (cc.PhysicsManager) {
this._physicsManager = new cc.PhysicsManager();
this._scheduler.scheduleUpdate(this._physicsManager, f.PRIORITY_SYSTEM, !1);
} else this._physicsManager = null;
cc._widgetManager && cc._widgetManager.init(this);
cc.loader.init(this);
},
calculateDeltaTime: function() {
var t = performance.now();
this._deltaTime = (t - this._lastUpdate) / 1e3;
0;
this._lastUpdate = t;
},
convertToGL: function(t) {
var e = l.container, i = cc.view, n = e.getBoundingClientRect(), r = n.left + window.pageXOffset - e.clientLeft, s = n.top + window.pageYOffset - e.clientTop, o = i._devicePixelRatio * (t.x - r), a = i._devicePixelRatio * (s + n.height - t.y);
return i._isRotated ? cc.v2(i._viewportRect.width - a, o) : cc.v2(o, a);
},
convertToUI: function(t) {
var e = l.container, i = cc.view, n = e.getBoundingClientRect(), r = n.left + window.pageXOffset - e.clientLeft, s = n.top + window.pageYOffset - e.clientTop, o = cc.v2(0, 0);
if (i._isRotated) {
o.x = r + t.y / i._devicePixelRatio;
o.y = s + n.height - (i._viewportRect.width - t.x) / i._devicePixelRatio;
} else {
o.x = r + t.x * i._devicePixelRatio;
o.y = s + n.height - t.y * i._devicePixelRatio;
}
return o;
},
end: function() {
this._purgeDirectorInNextLoop = !0;
},
getWinSize: function() {
return cc.size(cc.winSize);
},
getWinSizeInPixels: function() {
return cc.size(cc.winSize);
},
pause: function() {
this._paused || (this._paused = !0);
},
purgeCachedData: function() {
cc.loader.releaseAll();
},
purgeDirector: function() {
this._scheduler.unscheduleAll();
this._compScheduler.unscheduleAll();
this._nodeActivator.reset();
_ && _.setEnabled(!1);
cc.renderer.clear();
cc.isValid(this._scene) && this._scene.destroy();
this._scene = null;
this.stopAnimation();
cc.loader.releaseAll();
},
reset: function() {
this.purgeDirector();
_ && _.setEnabled(!0);
this._actionManager && this._scheduler.scheduleUpdate(this._actionManager, cc.Scheduler.PRIORITY_SYSTEM, !1);
this._animationManager && this._scheduler.scheduleUpdate(this._animationManager, cc.Scheduler.PRIORITY_SYSTEM, !1);
this._collisionManager && this._scheduler.scheduleUpdate(this._collisionManager, cc.Scheduler.PRIORITY_SYSTEM, !1);
this._physicsManager && this._scheduler.scheduleUpdate(this._physicsManager, cc.Scheduler.PRIORITY_SYSTEM, !1);
this.startAnimation();
},
runSceneImmediate: function(t, e, i) {
cc.assertID(t instanceof cc.Scene, 1216);
t._load();
for (var n = Object.keys(l._persistRootNodes).map((function(t) {
return l._persistRootNodes[t];
})), r = 0; r < n.length; r++) {
var s = n[r], a = t.getChildByUuid(s.uuid);
if (a) {
var c = a.getSiblingIndex();
a._destroyImmediate();
t.insertChild(s, c);
} else s.parent = t;
}
var u = this._scene, _ = u && u.autoReleaseAssets && u.dependAssets;
o.autoRelease(_, t.dependAssets, n);
cc.isValid(u) && u.destroy();
this._scene = null;
h._deferredDestroy();
e && e();
this.emit(cc.Director.EVENT_BEFORE_SCENE_LAUNCH, t);
this._scene = t;
t._activate();
this.startAnimation();
i && i(null, t);
this.emit(cc.Director.EVENT_AFTER_SCENE_LAUNCH, t);
},
runScene: function(t, e, i) {
cc.assertID(t, 1205);
cc.assertID(t instanceof cc.Scene, 1216);
t._load();
this.once(cc.Director.EVENT_AFTER_UPDATE, (function() {
this.runSceneImmediate(t, e, i);
}), this);
},
_getSceneUuid: function(i) {
var n = l._sceneInfos;
if ("string" === ("object" === (e = typeof i) ? t(i) : e)) {
i.endsWith(".fire") || (i += ".fire");
"/" === i[0] || i.startsWith("db://") || (i = "/" + i);
for (var r = 0; r < n.length; r++) {
var s = n[r];
if (s.url.endsWith(i)) return s;
}
} else if ("number" === ("object" === (e = typeof i) ? t(i) : e)) {
if (0 <= i && i < n.length) return n[i];
cc.errorID(1206, i);
} else cc.errorID(1207, i);
return null;
},
loadScene: function(t, e, i) {
if (this._loadingScene) {
cc.errorID(1208, t, this._loadingScene);
return !1;
}
var n = this._getSceneUuid(t);
if (n) {
var r = n.uuid;
this.emit(cc.Director.EVENT_BEFORE_SCENE_LOADING, t);
this._loadingScene = t;
this._loadSceneByUuid(r, e, i);
return !0;
}
cc.errorID(1209, t);
return !1;
},
preloadScene: function(t, e, i) {
if (void 0 === i) {
i = e;
e = null;
}
var n = this._getSceneUuid(t);
if (n) {
this.emit(cc.Director.EVENT_BEFORE_SCENE_LOADING, t);
cc.loader.load({
uuid: n.uuid,
type: "uuid"
}, e, (function(e, n) {
e && cc.errorID(1210, t, e.message);
i && i(e, n);
}));
} else {
var r = 'Can not preload the scene "' + t + '" because it is not in the build settings.';
i(new Error(r));
cc.error("preloadScene: " + r);
}
},
_loadSceneByUuid: function(t, e, i, n) {
0;
console.time("LoadScene " + t);
cc.AssetLibrary.loadAsset(t, (function(n, r) {
console.timeEnd("LoadScene " + t);
var s = cc.director;
s._loadingScene = "";
if (n) {
n = "Failed to load scene: " + n;
cc.error(n);
} else {
if (r instanceof cc.SceneAsset) {
var o = r.scene;
o._id = r._uuid;
o._name = r._name;
s.runSceneImmediate(o, i, e);
return;
}
n = "The asset " + t + " is not a scene";
cc.error(n);
}
e && e(n);
}));
},
resume: function() {
if (this._paused) {
this._lastUpdate = performance.now();
this._lastUpdate || cc.logID(1200);
this._paused = !1;
this._deltaTime = 0;
}
},
setDepthTest: function(t) {
cc.Camera.main && (cc.Camera.main.depth = !!t);
},
setClearColor: function(t) {
cc.Camera.main && (cc.Camera.main.backgroundColor = t);
},
getRunningScene: function() {
return this._scene;
},
getScene: function() {
return this._scene;
},
getAnimationInterval: function() {
return 1e3 / l.getFrameRate();
},
setAnimationInterval: function(t) {
l.setFrameRate(Math.round(1e3 / t));
},
getDeltaTime: function() {
return this._deltaTime;
},
getTotalFrames: function() {
return this._totalFrames;
},
isPaused: function() {
return this._paused;
},
getScheduler: function() {
return this._scheduler;
},
setScheduler: function(t) {
this._scheduler !== t && (this._scheduler = t);
},
getActionManager: function() {
return this._actionManager;
},
setActionManager: function(t) {
if (this._actionManager !== t) {
this._actionManager && this._scheduler.unscheduleUpdate(this._actionManager);
this._actionManager = t;
this._scheduler.scheduleUpdate(this._actionManager, cc.Scheduler.PRIORITY_SYSTEM, !1);
}
},
getAnimationManager: function() {
return this._animationManager;
},
getCollisionManager: function() {
return this._collisionManager;
},
getPhysicsManager: function() {
return this._physicsManager;
},
startAnimation: function() {
this.invalid = !1;
this._lastUpdate = performance.now();
},
stopAnimation: function() {
this.invalid = !0;
},
mainLoop: function() {
if (this._purgeDirectorInNextLoop) {
this._purgeDirectorInNextLoop = !1;
this.purgeDirector();
} else if (!this.invalid) {
this.calculateDeltaTime();
if (!this._paused) {
this.emit(cc.Director.EVENT_BEFORE_UPDATE);
this._compScheduler.startPhase();
this._compScheduler.updatePhase(this._deltaTime);
this._scheduler.update(this._deltaTime);
this._compScheduler.lateUpdatePhase(this._deltaTime);
this.emit(cc.Director.EVENT_AFTER_UPDATE);
h._deferredDestroy();
}
this.emit(cc.Director.EVENT_BEFORE_DRAW);
u.render(this._scene);
this.emit(cc.Director.EVENT_AFTER_DRAW);
_.frameUpdateListeners();
this._totalFrames++;
}
},
__fastOn: function(t, e, i) {
this.add(t, e, i);
},
__fastOff: function(t, e, i) {
this.remove(t, e, i);
}
};
cc.js.addon(cc.Director.prototype, s.prototype);
cc.Director.EVENT_PROJECTION_CHANGED = "director_projection_changed";
cc.Director.EVENT_BEFORE_SCENE_LOADING = "director_before_scene_loading";
cc.Director.EVENT_BEFORE_SCENE_LAUNCH = "director_before_scene_launch";
cc.Director.EVENT_AFTER_SCENE_LAUNCH = "director_after_scene_launch";
cc.Director.EVENT_BEFORE_UPDATE = "director_before_update";
cc.Director.EVENT_AFTER_UPDATE = "director_after_update";
cc.Director.EVENT_BEFORE_VISIT = "director_before_draw";
cc.Director.EVENT_AFTER_VISIT = "director_before_draw";
cc.Director.EVENT_BEFORE_DRAW = "director_before_draw";
cc.Director.EVENT_AFTER_DRAW = "director_after_draw";
cc.Director.PROJECTION_2D = 0;
cc.Director.PROJECTION_3D = 1;
cc.Director.PROJECTION_CUSTOM = 3;
cc.Director.PROJECTION_DEFAULT = cc.Director.PROJECTION_2D;
cc.director = new cc.Director();
n.exports = cc.director;
}), {
"./CCGame": 28,
"./CCScheduler": 32,
"./component-scheduler": 61,
"./event-manager": 100,
"./event/event-target": 102,
"./load-pipeline/auto-release-utils": 115,
"./node-activator": 131,
"./platform/CCObject": 166,
"./renderer": 201
} ],
28: [ (function(i, n, r) {
var s = i("./event/event-target");
i("../audio/CCAudioEngine");
var o = i("./CCDebug"), a = i("./renderer/index.js"), c = i("./platform/CCInputManager"), h = i("../core/renderer/utils/dynamic-atlas/manager"), l = {
EVENT_HIDE: "game_on_hide",
EVENT_SHOW: "game_on_show",
EVENT_RESTART: "game_on_restart",
EVENT_GAME_INITED: "game_inited",
EVENT_ENGINE_INITED: "engine_inited",
EVENT_RENDERER_INITED: "engine_inited",
RENDER_TYPE_CANVAS: 0,
RENDER_TYPE_WEBGL: 1,
RENDER_TYPE_OPENGL: 2,
_persistRootNodes: {},
_paused: !0,
_configLoaded: !1,
_isCloning: !1,
_prepared: !1,
_rendererInitialized: !1,
_renderContext: null,
_intervalId: null,
_lastTime: null,
_frameTime: null,
_sceneInfos: [],
frame: null,
container: null,
canvas: null,
renderType: -1,
config: null,
onStart: null,
setFrameRate: function(t) {
this.config.frameRate = t;
this._intervalId && window.cancelAnimFrame(this._intervalId);
this._intervalId = 0;
this._paused = !0;
this._setAnimFrame();
this._runMainLoop();
},
getFrameRate: function() {
return this.config.frameRate;
},
step: function() {
cc.director.mainLoop();
},
pause: function() {
if (!this._paused) {
this._paused = !0;
cc.audioEngine && cc.audioEngine._break();
cc.director.stopAnimation();
this._intervalId && window.cancelAnimFrame(this._intervalId);
this._intervalId = 0;
}
},
resume: function() {
if (this._paused) {
this._paused = !1;
cc.audioEngine && cc.audioEngine._restore();
cc.director.startAnimation();
this._runMainLoop();
}
},
isPaused: function() {
return this._paused;
},
restart: function() {
cc.director.once(cc.Director.EVENT_AFTER_DRAW, (function() {
for (var t in l._persistRootNodes) l.removePersistRootNode(l._persistRootNodes[t]);
cc.director.getScene().destroy();
cc.Object._deferredDestroy();
cc.director.purgeDirector();
cc.audioEngine && cc.audioEngine.uncacheAll();
cc.director.reset();
l.onStart();
l.emit(l.EVENT_RESTART);
}));
},
end: function() {
close();
},
_initEngine: function() {
if (!this._rendererInitialized) {
this._initRenderer();
this._initEvents();
this.emit(this.EVENT_ENGINE_INITED);
}
},
_prepareFinished: function(t) {
0;
this._prepared = !0;
this._initEngine();
console.log("Cocos Creator v" + cc.ENGINE_VERSION);
this._setAnimFrame();
this._runMainLoop();
this.emit(this.EVENT_GAME_INITED);
t && t();
},
eventTargetOn: s.prototype.on,
eventTargetOnce: s.prototype.once,
on: function(t, e, i) {
this._prepared && t === this.EVENT_ENGINE_INITED || !this._pause && t === this.EVENT_GAME_INITED ? e.call(i) : this.eventTargetOn(t, e, i);
},
once: function(t, e, i) {
this._prepared && t === this.EVENT_ENGINE_INITED || !this._pause && t === this.EVENT_GAME_INITED ? e.call(i) : this.eventTargetOnce(t, e, i);
},
prepare: function(t) {
if (this._prepared) t && t(); else {
var e = this.config.jsList;
if (e && e.length > 0) {
var i = this;
cc.loader.load(e, (function(e) {
if (e) throw new Error(JSON.stringify(e));
i._prepareFinished(t);
}));
} else this._prepareFinished(t);
}
},
run: function(t, e) {
this._initConfig(t);
this.onStart = e;
this.prepare(l.onStart && l.onStart.bind(l));
},
addPersistRootNode: function(t) {
if (cc.Node.isNode(t) && t.uuid) {
var e = t.uuid;
if (!this._persistRootNodes[e]) {
var i = cc.director._scene;
if (cc.isValid(i)) if (t.parent) {
if (!(t.parent instanceof cc.Scene)) {
cc.warnID(3801);
return;
}
if (t.parent !== i) {
cc.warnID(3802);
return;
}
} else t.parent = i;
this._persistRootNodes[e] = t;
t._persistNode = !0;
}
} else cc.warnID(3800);
},
removePersistRootNode: function(t) {
var e = t.uuid || "";
if (t === this._persistRootNodes[e]) {
delete this._persistRootNodes[e];
t._persistNode = !1;
}
},
isPersistRootNode: function(t) {
return t._persistNode;
},
_setAnimFrame: function() {
this._lastTime = new Date();
var t = l.config.frameRate;
this._frameTime = 1e3 / t;
jsb.setPreferredFramesPerSecond(t);
window.requestAnimFrame = window.requestAnimationFrame;
window.cancelAnimFrame = window.cancelAnimationFrame;
},
_stTime: function(t) {
var e = new Date().getTime(), i = Math.max(0, l._frameTime - (e - l._lastTime)), n = window.setTimeout((function() {
t();
}), i);
l._lastTime = e + i;
return n;
},
_ctTime: function(t) {
window.clearTimeout(t);
},
_runMainLoop: function() {
var t, e = this, i = e.config, n = cc.director;
i.frameRate;
o.setDisplayStats(i.showFPS);
t = function() {
if (!e._paused) {
e._intervalId = window.requestAnimFrame(t);
0;
n.mainLoop();
}
};
e._intervalId = window.requestAnimFrame(t);
e._paused = !1;
},
_initConfig: function(i) {
"number" !== ("object" === (e = typeof i.debugMode) ? t(i.debugMode) : e) && (i.debugMode = 0);
i.exposeClassName = !!i.exposeClassName;
"number" !== ("object" === (e = typeof i.frameRate) ? t(i.frameRate) : e) && (i.frameRate = 60);
var n = i.renderMode;
("number" !== ("object" === (e = typeof n) ? t(n) : e) || n > 2 || n < 0) && (i.renderMode = 0);
"boolean" !== ("object" === (e = typeof i.registerSystemEvent) ? t(i.registerSystemEvent) : e) && (i.registerSystemEvent = !0);
i.showFPS = !!i.showFPS;
this._sceneInfos = i.scenes || [];
this.collisionMatrix = i.collisionMatrix || [];
this.groupList = i.groupList || [];
o._resetDebugSetting(i.debugMode);
this.config = i;
this._configLoaded = !0;
},
_determineRenderType: function() {
var t = this.config, e = parseInt(t.renderMode) || 0;
this.renderType = this.RENDER_TYPE_CANVAS;
var i = !1;
if (0 === e) {
if (cc.sys.capabilities.opengl) {
this.renderType = this.RENDER_TYPE_WEBGL;
i = !0;
} else if (cc.sys.capabilities.canvas) {
this.renderType = this.RENDER_TYPE_CANVAS;
i = !0;
}
} else if (1 === e && cc.sys.capabilities.canvas) {
this.renderType = this.RENDER_TYPE_CANVAS;
i = !0;
} else if (2 === e && cc.sys.capabilities.opengl) {
this.renderType = this.RENDER_TYPE_WEBGL;
i = !0;
}
if (!i) throw new Error(o.getError(3820, e));
},
_initRenderer: function() {
if (!this._rendererInitialized) {
this.config.id;
var t = void 0, e = void 0;
this.container = e = document.createElement("DIV");
this.frame = e.parentNode === document.body ? document.documentElement : e.parentNode;
if (cc.sys.browserType === cc.sys.BROWSER_TYPE_WECHAT_GAME_SUB) t = window.sharedCanvas || wx.getSharedCanvas(); else {
t = window.__canvas;
}
this.canvas = t;
this._determineRenderType();
if (this.renderType === this.RENDER_TYPE_WEBGL) {
var i = {
stencil: !0,
antialias: cc.macro.ENABLE_WEBGL_ANTIALIAS,
alpha: cc.macro.ENABLE_TRANSPARENT_CANVAS
};
0;
a.initWebGL(t, i);
this._renderContext = a.device._gl;
!cc.macro.CLEANUP_IMAGE_CACHE && h && (h.enabled = !0);
}
if (!this._renderContext) {
this.renderType = this.RENDER_TYPE_CANVAS;
a.initCanvas(t);
this._renderContext = a.device._ctx;
}
this.canvas.oncontextmenu = function() {
if (!cc._isContextMenuEnable) return !1;
};
this._rendererInitialized = !0;
}
},
_initEvents: function() {
var i, n = window;
this.config.registerSystemEvent && c.registerSystemEvent(this.canvas);
"undefined" !== ("object" === (e = typeof document.hidden) ? t(document.hidden) : e) ? i = "hidden" : "undefined" !== ("object" === (e = typeof document.mozHidden) ? t(document.mozHidden) : e) ? i = "mozHidden" : "undefined" !== ("object" === (e = typeof document.msHidden) ? t(document.msHidden) : e) ? i = "msHidden" : "undefined" !== ("object" === (e = typeof document.webkitHidden) ? t(document.webkitHidden) : e) && (i = "webkitHidden");
var r = !1;
function s() {
if (!r) {
r = !0;
l.emit(l.EVENT_HIDE);
}
}
function o(t, e, i, n, s) {
if (r) {
r = !1;
l.emit(l.EVENT_SHOW, t, e, i, n, s);
}
}
if (i) for (var a = [ "visibilitychange", "mozvisibilitychange", "msvisibilitychange", "webkitvisibilitychange", "qbrowserVisibilityChange" ], h = 0; h < a.length; h++) document.addEventListener(a[h], (function(t) {
var e = document[i];
(e = e || t.hidden) ? s() : o();
})); else {
n.addEventListener("blur", s);
n.addEventListener("focus", o);
}
navigator.userAgent.indexOf("MicroMessenger") > -1 && (n.onfocus = o);
0;
if ("onpageshow" in window && "onpagehide" in window) {
n.addEventListener("pagehide", s);
n.addEventListener("pageshow", o);
document.addEventListener("pagehide", s);
document.addEventListener("pageshow", o);
}
this.on(l.EVENT_HIDE, (function() {
l.pause();
}));
this.on(l.EVENT_SHOW, (function() {
l.resume();
}));
}
};
s.call(l);
cc.js.addon(l, s.prototype);
cc.game = n.exports = l;
}), {
"../audio/CCAudioEngine": 21,
"../core/renderer/utils/dynamic-atlas/manager": 205,
"./CCDebug": 26,
"./event/event-target": 102,
"./platform/BKInputManager": 158,
"./platform/CCInputManager": 164,
"./renderer/index.js": 201
} ],
29: [ (function(i, n, r) {
"use strict";
var s = i("./utils/base-node"), o = i("./utils/prefab-helper"), a = i("./utils/math-pools"), c = i("./renderer/render-engine").math, h = i("./utils/affine-transform"), l = i("./event-manager"), u = i("./platform/CCMacro"), _ = i("./utils/misc"), f = i("./platform/js"), d = (i("./event/event"), 
i("./event/event-target")), m = i("./renderer/render-flow"), p = cc.Object.Flags.Destroying, v = Math.PI / 180, y = !!cc.ActionManager, g = function() {}, x = cc.v2(), C = cc.v2(), A = c.mat4.create(), b = c.vec3.create(), S = c.quat.create(), T = new Array(16);
T.length = 0;
var w = cc.Enum({
DEBUG: 31
}), E = cc.Enum({
POSITION: 1,
SCALE: 2,
ROTATION: 4,
SKEW: 8,
RT: 7,
ALL: 65535
}), B = cc.Enum({
TOUCH_START: "touchstart",
TOUCH_MOVE: "touchmove",
TOUCH_END: "touchend",
TOUCH_CANCEL: "touchcancel",
MOUSE_DOWN: "mousedown",
MOUSE_MOVE: "mousemove",
MOUSE_ENTER: "mouseenter",
MOUSE_LEAVE: "mouseleave",
MOUSE_UP: "mouseup",
MOUSE_WHEEL: "mousewheel",
POSITION_CHANGED: "position-changed",
ROTATION_CHANGED: "rotation-changed",
SCALE_CHANGED: "scale-changed",
SIZE_CHANGED: "size-changed",
ANCHOR_CHANGED: "anchor-changed",
COLOR_CHANGED: "color-changed",
CHILD_ADDED: "child-added",
CHILD_REMOVED: "child-removed",
CHILD_REORDER: "child-reorder",
GROUP_CHANGED: "group-changed"
}), M = [ B.TOUCH_START, B.TOUCH_MOVE, B.TOUCH_END, B.TOUCH_CANCEL ], D = [ B.MOUSE_DOWN, B.MOUSE_ENTER, B.MOUSE_MOVE, B.MOUSE_LEAVE, B.MOUSE_UP, B.MOUSE_WHEEL ], I = null, P = function(t, e) {
var i = t.getLocation(), n = this.owner;
if (n._hitTest(i, this)) {
e.type = B.TOUCH_START;
e.touch = t;
e.bubbles = !0;
n.dispatchEvent(e);
return !0;
}
return !1;
}, R = function(t, e) {
var i = this.owner;
e.type = B.TOUCH_MOVE;
e.touch = t;
e.bubbles = !0;
i.dispatchEvent(e);
}, L = function(t, e) {
var i = t.getLocation(), n = this.owner;
n._hitTest(i, this) ? e.type = B.TOUCH_END : e.type = B.TOUCH_CANCEL;
e.touch = t;
e.bubbles = !0;
n.dispatchEvent(e);
}, F = function(t, e) {
t.getLocation();
var i = this.owner;
e.type = B.TOUCH_CANCEL;
e.touch = t;
e.bubbles = !0;
i.dispatchEvent(e);
}, V = function(t) {
var e = t.getLocation(), i = this.owner;
if (i._hitTest(e, this)) {
t.type = B.MOUSE_DOWN;
t.bubbles = !0;
i.dispatchEvent(t);
}
}, O = function(t) {
var e = t.getLocation(), i = this.owner;
if (i._hitTest(e, this)) {
if (!this._previousIn) {
if (I && I._mouseListener) {
t.type = B.MOUSE_LEAVE;
I.dispatchEvent(t);
I._mouseListener._previousIn = !1;
}
I = this.owner;
t.type = B.MOUSE_ENTER;
i.dispatchEvent(t);
this._previousIn = !0;
}
t.type = B.MOUSE_MOVE;
t.bubbles = !0;
i.dispatchEvent(t);
} else {
if (!this._previousIn) return;
t.type = B.MOUSE_LEAVE;
i.dispatchEvent(t);
this._previousIn = !1;
I = null;
}
t.stopPropagation();
}, N = function(t) {
var e = t.getLocation(), i = this.owner;
if (i._hitTest(e, this)) {
t.type = B.MOUSE_UP;
t.bubbles = !0;
i.dispatchEvent(t);
t.stopPropagation();
}
}, k = function(t) {
var e = t.getLocation(), i = this.owner;
if (i._hitTest(e, this)) {
t.type = B.MOUSE_WHEEL;
t.bubbles = !0;
i.dispatchEvent(t);
t.stopPropagation();
}
};
function G(t) {
var e = cc.Mask;
if (e) for (var i = 0, n = t; n && cc.Node.isNode(n); n = n._parent, ++i) if (n.getComponent(e)) return {
index: i,
node: n
};
return null;
}
function z(t, e) {
if (!(t._objFlags & p)) {
var i = 0;
if (t._bubblingListeners) for (;i < e.length; ++i) if (t._bubblingListeners.hasEventListener(e[i])) return !0;
if (t._capturingListeners) for (;i < e.length; ++i) if (t._capturingListeners.hasEventListener(e[i])) return !0;
return !1;
}
return !0;
}
function U(t) {
var e = t.groupIndex;
0 === e && t.parent && (e = U(t.parent));
return e;
}
function j(t) {
var e = U(t);
t._cullingMask = 1 << e;
for (var i = 0; i < t._children.length; i++) j(t._children[i]);
}
var H = cc.Class({
name: "cc.Node",
extends: s,
properties: {
_opacity: 255,
_color: cc.Color.WHITE,
_contentSize: cc.Size,
_anchorPoint: cc.v2(.5, .5),
_position: cc.Vec3,
_scaleX: {
default: void 0,
type: cc.Float
},
_scaleY: {
default: void 0,
type: cc.Float
},
_scale: cc.Vec3,
_rotationX: 0,
_rotationY: 0,
_quat: cc.Quat,
_skewX: 0,
_skewY: 0,
_zIndex: {
default: void 0,
type: cc.Integer
},
_localZOrder: {
default: 0,
serializable: !1
},
groupIndex: {
default: 0,
type: cc.Integer
},
group: {
get: function() {
return cc.game.groupList[this.groupIndex] || "";
},
set: function(t) {
this.groupIndex = cc.game.groupList.indexOf(t);
j(this);
this.emit(B.GROUP_CHANGED, this);
}
},
x: {
get: function() {
return this._position.x;
},
set: function(t) {
var e = this._position;
if (t !== e.x) {
e.x = t;
this.setLocalDirty(E.POSITION);
this._renderFlag |= m.FLAG_WORLD_TRANSFORM;
1 & this._eventMask && this.emit(B.POSITION_CHANGED);
}
}
},
y: {
get: function() {
return this._position.y;
},
set: function(t) {
var e = this._position;
if (t !== e.y) {
e.y = t;
this.setLocalDirty(E.POSITION);
this._renderFlag |= m.FLAG_WORLD_TRANSFORM;
1 & this._eventMask && this.emit(B.POSITION_CHANGED);
}
}
},
z: {
get: function() {
return this._position.z;
},
set: function(t) {
var e = this._position;
if (t !== e.z) {
e.z = t;
this.setLocalDirty(E.POSITION);
this._renderFlag |= m.FLAG_WORLD_TRANSFORM;
1 & this._eventMask && this.emit(B.POSITION_CHANGED);
}
}
},
rotation: {
get: function() {
return this._rotationX;
},
set: function(t) {
if (this._rotationX !== t || this._rotationY !== t) {
this._rotationX = this._rotationY = t;
c.quat.fromEuler(this._quat, 0, 0, -t);
this.setLocalDirty(E.ROTATION);
this._renderFlag |= m.FLAG_TRANSFORM;
4 & this._eventMask && this.emit(B.ROTATION_CHANGED);
}
}
},
rotationX: {
get: function() {
return this._rotationX;
},
set: function(t) {
if (this._rotationX !== t) {
this._rotationX = t;
this._rotationX === this._rotationY ? c.quat.fromEuler(this._quat, 0, 0, -t) : c.quat.fromEuler(this._quat, t, this._rotationY, 0);
this.setLocalDirty(E.ROTATION);
this._renderFlag |= m.FLAG_TRANSFORM;
4 & this._eventMask && this.emit(B.ROTATION_CHANGED);
}
}
},
rotationY: {
get: function() {
return this._rotationY;
},
set: function(t) {
if (this._rotationY !== t) {
this._rotationY = t;
this._rotationX === this._rotationY ? c.quat.fromEuler(this._quat, 0, 0, -t) : c.quat.fromEuler(this._quat, this._rotationX, t, 0);
this.setLocalDirty(E.ROTATION);
this._renderFlag |= m.FLAG_TRANSFORM;
4 & this._eventMask && this.emit(B.ROTATION_CHANGED);
}
}
},
scaleX: {
get: function() {
return this._scale.x;
},
set: function(t) {
if (this._scale.x !== t) {
this._scale.x = t;
this.setLocalDirty(E.SCALE);
this._renderFlag |= m.FLAG_TRANSFORM;
2 & this._eventMask && this.emit(B.SCALE_CHANGED);
}
}
},
scaleY: {
get: function() {
return this._scale.y;
},
set: function(t) {
if (this._scale.y !== t) {
this._scale.y = t;
this.setLocalDirty(E.SCALE);
this._renderFlag |= m.FLAG_TRANSFORM;
2 & this._eventMask && this.emit(B.SCALE_CHANGED);
}
}
},
skewX: {
get: function() {
return this._skewX;
},
set: function(t) {
this._skewX = t;
this.setLocalDirty(E.SKEW);
this._renderFlag |= m.FLAG_TRANSFORM;
}
},
skewY: {
get: function() {
return this._skewY;
},
set: function(t) {
this._skewY = t;
this.setLocalDirty(E.SKEW);
this._renderFlag |= m.FLAG_TRANSFORM;
}
},
opacity: {
get: function() {
return this._opacity;
},
set: function(t) {
if (this._opacity !== t) {
this._opacity = t;
this._renderFlag |= m.FLAG_OPACITY | m.FLAG_COLOR;
}
},
range: [ 0, 255 ]
},
color: {
get: function() {
return this._color.clone();
},
set: function(t) {
if (!this._color.equals(t)) {
this._color.set(t);
0;
this._renderComponent && (this._renderFlag |= m.FLAG_COLOR);
32 & this._eventMask && this.emit(B.COLOR_CHANGED, t);
}
}
},
anchorX: {
get: function() {
return this._anchorPoint.x;
},
set: function(t) {
var e = this._anchorPoint;
if (e.x !== t) {
e.x = t;
16 & this._eventMask && this.emit(B.ANCHOR_CHANGED);
}
}
},
anchorY: {
get: function() {
return this._anchorPoint.y;
},
set: function(t) {
var e = this._anchorPoint;
if (e.y !== t) {
e.y = t;
16 & this._eventMask && this.emit(B.ANCHOR_CHANGED);
}
}
},
width: {
get: function() {
return this._contentSize.width;
},
set: function(t) {
if (t !== this._contentSize.width) {
this._contentSize.width = t;
8 & this._eventMask && this.emit(B.SIZE_CHANGED);
}
}
},
height: {
get: function() {
return this._contentSize.height;
},
set: function(t) {
if (t !== this._contentSize.height) {
this._contentSize.height = t;
8 & this._eventMask && this.emit(B.SIZE_CHANGED);
}
}
},
zIndex: {
get: function() {
return this._localZOrder >> 16;
},
set: function(t) {
if (t > u.MAX_ZINDEX) {
cc.warnID(1636);
t = u.MAX_ZINDEX;
} else if (t < u.MIN_ZINDEX) {
cc.warnID(1637);
t = u.MIN_ZINDEX;
}
if (this.zIndex !== t) {
this._localZOrder = 65535 & this._localZOrder | t << 16;
this._parent && this._onSiblingIndexChanged();
}
}
}
},
ctor: function() {
this._reorderChildDirty = !1;
this._widget = null;
this._renderComponent = null;
this._capturingListeners = null;
this._bubblingListeners = null;
this._touchListener = null;
this._mouseListener = null;
this._scale.x = 1;
this._scale.y = 1;
this._scale.z = 1;
this._matrix = a.mat4.get();
this._worldMatrix = a.mat4.get();
this._localMatDirty = E.ALL;
this._worldMatDirty = !0;
this._eventMask = 0;
this._cullingMask = 1;
this._childArrivalOrder = 1;
},
statics: {
EventType: B,
_LocalDirtyFlag: E,
isNode: function(t) {
return t instanceof H && (t.constructor === H || !(t instanceof cc.Scene));
},
BuiltinGroupIndex: w
},
_onSiblingIndexChanged: function() {
for (var t, e = this._parent, i = e._children, n = 0, r = i.length; n < r; n++) {
(t = i[n])._updateOrderOfArrival();
l._setDirtyForNode(t);
}
e._delaySort();
},
_onPreDestroy: function() {
this._onPreDestroyBase();
y && cc.director.getActionManager().removeAllActionsFromTarget(this);
I === this && (I = null);
if (this._touchListener || this._mouseListener) {
l.removeListeners(this);
if (this._touchListener) {
this._touchListener.owner = null;
this._touchListener.mask = null;
this._touchListener = null;
}
if (this._mouseListener) {
this._mouseListener.owner = null;
this._mouseListener.mask = null;
this._mouseListener = null;
}
}
a.mat4.put(this._matrix);
a.mat4.put(this._worldMatrix);
this._matrix = this._worldMatrix = null;
this._reorderChildDirty && cc.director.__fastOff(cc.Director.EVENT_AFTER_UPDATE, this.sortAllChildren, this);
},
_onPostActivated: function(t) {
var e = y ? cc.director.getActionManager() : null;
if (t) {
this._renderFlag |= m.FLAG_WORLD_TRANSFORM;
e && e.resumeTarget(this);
l.resumeTarget(this);
if (this._touchListener) {
var i = this._touchListener.mask = G(this);
this._mouseListener && (this._mouseListener.mask = i);
} else this._mouseListener && (this._mouseListener.mask = G(this));
} else {
e && e.pauseTarget(this);
l.pauseTarget(this);
}
},
_onHierarchyChanged: function(t) {
this._updateOrderOfArrival();
j(this);
this._parent && this._parent._delaySort();
this._renderFlag |= m.FLAG_WORLD_TRANSFORM;
this._onHierarchyChangedBase(t);
cc._widgetManager && (cc._widgetManager._nodesOrderDirty = !0);
},
_upgrade_1x_to_2x: function() {
if (void 0 !== this._scaleX) {
this._scale.x = this._scaleX;
this._scaleX = void 0;
}
if (void 0 !== this._scaleY) {
this._scale.y = this._scaleY;
this._scaleY = void 0;
}
if (void 0 !== this._zIndex) {
this._localZOrder = this._zIndex << 16;
this._zIndex = void 0;
}
if (0 !== this._rotationX || 0 !== this._rotationY) this._rotationX === this._rotationY ? c.quat.fromEuler(this._quat, 0, 0, -this._rotationX) : c.quat.fromEuler(this._quat, this._rotationX, this._rotationY, 0); else {
var t = this._quat.getRoll(), e = this._quat.getPitch();
if (0 === t && 0 === e) this._rotationX = this._rotationY = -this._quat.getYaw(); else {
this._rotationX = t;
this._rotationY = e;
}
}
if (this._color.a < 255 && 255 === this._opacity) {
this._opacity = this._color.a;
this._color.a = 255;
}
},
_onBatchCreated: function() {
this._upgrade_1x_to_2x();
this._updateOrderOfArrival();
this._cullingMask = 1 << U(this);
var t = this._prefab;
if (t && t.sync && t.root === this) {
0;
o.syncWithPrefab(this);
}
if (!this._activeInHierarchy) {
y && cc.director.getActionManager().pauseTarget(this);
l.pauseTarget(this);
}
for (var e = this._children, i = 0, n = e.length; i < n; i++) e[i]._onBatchCreated();
e.length > 0 && (this._renderFlag |= m.FLAG_CHILDREN);
},
_onBatchRestored: function() {
this._upgrade_1x_to_2x();
this._cullingMask = 1 << U(this);
if (!this._activeInHierarchy) {
y && cc.director.getActionManager().pauseTarget(this);
l.pauseTarget(this);
}
for (var t = this._children, e = 0, i = t.length; e < i; e++) t[e]._onBatchRestored();
t.length > 0 && (this._renderFlag |= m.FLAG_CHILDREN);
},
_checknSetupSysEvent: function(t) {
var e = !1, i = !1;
if (-1 !== M.indexOf(t)) {
if (!this._touchListener) {
this._touchListener = cc.EventListener.create({
event: cc.EventListener.TOUCH_ONE_BY_ONE,
swallowTouches: !0,
owner: this,
mask: G(this),
onTouchBegan: P,
onTouchMoved: R,
onTouchEnded: L,
onTouchCancelled: F
});
l.addListener(this._touchListener, this);
e = !0;
}
i = !0;
} else if (-1 !== D.indexOf(t)) {
if (!this._mouseListener) {
this._mouseListener = cc.EventListener.create({
event: cc.EventListener.MOUSE,
_previousIn: !1,
owner: this,
mask: G(this),
onMouseDown: V,
onMouseMove: O,
onMouseUp: N,
onMouseScroll: k
});
l.addListener(this._mouseListener, this);
e = !0;
}
i = !0;
}
e && !this._activeInHierarchy && cc.director.getScheduler().schedule((function() {
this._activeInHierarchy || l.pauseTarget(this);
}), this, 0, 0, 0, !1);
return i;
},
on: function(t, e, i, n) {
if (this._checknSetupSysEvent(t)) return this._onDispatch(t, e, i, n);
switch (t) {
case B.POSITION_CHANGED:
this._eventMask |= 1;
break;

case B.SCALE_CHANGED:
this._eventMask |= 2;
break;

case B.ROTATION_CHANGED:
this._eventMask |= 4;
break;

case B.SIZE_CHANGED:
this._eventMask |= 8;
break;

case B.ANCHOR_CHANGED:
this._eventMask |= 16;
break;

case B.COLOR_CHANGED:
this._eventMask |= 32;
}
this._bubblingListeners || (this._bubblingListeners = new d());
return this._bubblingListeners.on(t, e, i);
},
once: function(t, e, i, n) {
var r = this, s = this._checknSetupSysEvent(t), o = "__ONCE_FLAG:" + t, a = null;
(a = s && n ? this._capturingListeners = this._capturingListeners || new d() : this._bubblingListeners = this._bubblingListeners || new d()).hasEventListener(o, e, i) || (function() {
var n = r, s = function(r, c, h, l, u) {
n.off(t, s, i);
a.remove(o, e, i);
e.call(this, r, c, h, l, u);
};
r.on(t, s, i);
a.add(o, e, i);
})();
},
_onDispatch: function(i, n, r, s) {
if ("boolean" === ("object" === (e = typeof r) ? t(r) : e)) {
s = r;
r = void 0;
} else s = !!s;
if (n) {
var o = null;
if (!(o = s ? this._capturingListeners = this._capturingListeners || new d() : this._bubblingListeners = this._bubblingListeners || new d()).hasEventListener(i, n, r)) {
o.add(i, n, r);
r && r.__eventTargets && r.__eventTargets.push(this);
}
return n;
}
cc.errorID(6800);
},
off: function(t, e, i, n) {
var r = -1 !== M.indexOf(t), s = !r && -1 !== D.indexOf(t);
if (r || s) {
this._offDispatch(t, e, i, n);
if (r) {
if (this._touchListener && !z(this, M)) {
l.removeListener(this._touchListener);
this._touchListener = null;
}
} else if (s && this._mouseListener && !z(this, D)) {
l.removeListener(this._mouseListener);
this._mouseListener = null;
}
} else if (this._bubblingListeners) {
this._bubblingListeners.off(t, e, i);
if (!this._bubblingListeners.hasEventListener(t)) switch (t) {
case B.POSITION_CHANGED:
this._eventMask &= -2;
break;

case B.SCALE_CHANGED:
this._eventMask &= -3;
break;

case B.ROTATION_CHANGED:
this._eventMask &= -5;
break;

case B.SIZE_CHANGED:
this._eventMask &= -9;
break;

case B.ANCHOR_CHANGED:
this._eventMask &= -17;
break;

case B.COLOR_CHANGED:
this._eventMask &= -33;
}
}
},
_offDispatch: function(i, n, r, s) {
if ("boolean" === ("object" === (e = typeof r) ? t(r) : e)) {
s = r;
r = void 0;
} else s = !!s;
if (n) {
var o = s ? this._capturingListeners : this._bubblingListeners;
if (o) {
o.remove(i, n, r);
r && r.__eventTargets && f.array.fastRemove(r.__eventTargets, this);
}
} else {
this._capturingListeners && this._capturingListeners.removeAll(i);
this._bubblingListeners && this._bubblingListeners.removeAll(i);
}
},
targetOff: function(t) {
var e = this._bubblingListeners;
if (e) {
e.targetOff(t);
1 & this._eventMask && !e.hasEventListener(B.POSITION_CHANGED) && (this._eventMask &= -2);
2 & this._eventMask && !e.hasEventListener(B.SCALE_CHANGED) && (this._eventMask &= -3);
4 & this._eventMask && !e.hasEventListener(B.ROTATION_CHANGED) && (this._eventMask &= -5);
8 & this._eventMask && !e.hasEventListener(B.SIZE_CHANGED) && (this._eventMask &= -9);
16 & this._eventMask && !e.hasEventListener(B.ANCHOR_CHANGED) && (this._eventMask &= -17);
32 & this._eventMask && !e.hasEventListener(B.COLOR_CHANGED) && (this._eventMask &= -33);
}
this._capturingListeners && this._capturingListeners.targetOff(t);
if (this._touchListener && !z(this, M)) {
l.removeListener(this._touchListener);
this._touchListener = null;
}
if (this._mouseListener && !z(this, D)) {
l.removeListener(this._mouseListener);
this._mouseListener = null;
}
},
hasEventListener: function(t) {
var e = !1;
this._bubblingListeners && (e = this._bubblingListeners.hasEventListener(t));
!e && this._capturingListeners && (e = this._capturingListeners.hasEventListener(t));
return e;
},
emit: function(t, e, i, n, r, s) {
this._bubblingListeners && this._bubblingListeners.emit(t, e, i, n, r, s);
},
dispatchEvent: function(t) {
(function(t, e) {
var i, n;
e.target = t;
T.length = 0;
t._getCapturingTargets(e.type, T);
e.eventPhase = 1;
for (n = T.length - 1; n >= 0; --n) if ((i = T[n])._capturingListeners) {
e.currentTarget = i;
i._capturingListeners.emit(e.type, e, T);
if (e._propagationStopped) {
T.length = 0;
return;
}
}
T.length = 0;
e.eventPhase = 2;
e.currentTarget = t;
t._capturingListeners && t._capturingListeners.emit(e.type, e);
!e._propagationImmediateStopped && t._bubblingListeners && t._bubblingListeners.emit(e.type, e);
if (!e._propagationStopped && e.bubbles) {
t._getBubblingTargets(e.type, T);
e.eventPhase = 3;
for (n = 0; n < T.length; ++n) if ((i = T[n])._bubblingListeners) {
e.currentTarget = i;
i._bubblingListeners.emit(e.type, e);
if (e._propagationStopped) {
T.length = 0;
return;
}
}
}
T.length = 0;
})(this, t);
T.length = 0;
},
pauseSystemEvents: function(t) {
l.pauseTarget(this, t);
},
resumeSystemEvents: function(t) {
l.resumeTarget(this, t);
},
_hitTest: function(t, e) {
var i = this._contentSize.width, n = this._contentSize.height, r = x, s = C, o = cc.Camera.findCamera(this);
o ? o.getCameraToWorldPoint(t, r) : r.set(t);
this._updateWorldMatrix();
c.mat4.invert(A, this._worldMatrix);
c.vec2.transformMat4(s, r, A);
s.x += this._anchorPoint.x * i;
s.y += this._anchorPoint.y * n;
if (s.x >= 0 && s.y >= 0 && s.x <= i && s.y <= n) {
if (e && e.mask) {
for (var a = e.mask, h = this, l = 0; h && l < a.index; ++l, h = h.parent) ;
if (h === a.node) {
var u = h.getComponent(cc.Mask);
return !u || !u.enabledInHierarchy || u._hitTest(r);
}
e.mask = null;
return !0;
}
return !0;
}
return !1;
},
_getCapturingTargets: function(t, e) {
for (var i = this.parent; i; ) {
i._capturingListeners && i._capturingListeners.hasEventListener(t) && e.push(i);
i = i.parent;
}
},
_getBubblingTargets: function(t, e) {
for (var i = this.parent; i; ) {
i._bubblingListeners && i._bubblingListeners.hasEventListener(t) && e.push(i);
i = i.parent;
}
},
runAction: y ? function(t) {
if (this.active) {
cc.assertID(t, 1618);
cc.director.getActionManager().addAction(t, this, !1);
return t;
}
} : g,
pauseAllActions: y ? function() {
cc.director.getActionManager().pauseTarget(this);
} : g,
resumeAllActions: y ? function() {
cc.director.getActionManager().resumeTarget(this);
} : g,
stopAllActions: y ? function() {
cc.director.getActionManager().removeAllActionsFromTarget(this);
} : g,
stopAction: y ? function(t) {
cc.director.getActionManager().removeAction(t);
} : g,
stopActionByTag: y ? function(t) {
t !== cc.Action.TAG_INVALID ? cc.director.getActionManager().removeActionByTag(t, this) : cc.logID(1612);
} : g,
getActionByTag: y ? function(t) {
if (t === cc.Action.TAG_INVALID) {
cc.logID(1613);
return null;
}
return cc.director.getActionManager().getActionByTag(t, this);
} : function() {
return null;
},
getNumberOfRunningActions: y ? function() {
return cc.director.getActionManager().getNumberOfRunningActionsInTarget(this);
} : function() {
return 0;
},
getPosition: function() {
return new cc.Vec2(this._position);
},
setPosition: function(t, e) {
var i;
if (void 0 === e) {
i = t.x;
e = t.y;
} else i = t;
var n = this._position;
if (n.x !== i || n.y !== e) {
n.x = i;
n.y = e;
this.setLocalDirty(E.POSITION);
this._renderFlag |= m.FLAG_WORLD_TRANSFORM;
1 & this._eventMask && this.emit(B.POSITION_CHANGED);
}
},
getScale: function() {
this._scale.x !== this._scale.y && cc.logID(1603);
return this._scale.x;
},
setScale: function(i, n) {
if (i && "number" !== ("object" === (e = typeof i) ? t(i) : e)) {
n = i.y;
i = i.x;
} else void 0 === n && (n = i);
if (this._scale.x !== i || this._scale.y !== n) {
this._scale.x = i;
this._scale.y = n;
this.setLocalDirty(E.SCALE);
this._renderFlag |= m.FLAG_TRANSFORM;
2 & this._eventMask && this.emit(B.SCALE_CHANGED);
}
},
getContentSize: function() {
return cc.size(this._contentSize.width, this._contentSize.height);
},
setContentSize: function(t, e) {
var i = this._contentSize;
if (void 0 === e) {
if (t.width === i.width && t.height === i.height) return;
0;
i.width = t.width;
i.height = t.height;
} else {
if (t === i.width && e === i.height) return;
0;
i.width = t;
i.height = e;
}
8 & this._eventMask && this.emit(B.SIZE_CHANGED);
},
getAnchorPoint: function() {
return cc.v2(this._anchorPoint);
},
setAnchorPoint: function(t, e) {
var 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.setLocalDirty(E.POSITION);
16 & this._eventMask && this.emit(B.ANCHOR_CHANGED);
},
_invTransformPoint: function(t, e) {
this._parent ? this._parent._invTransformPoint(t, e) : c.vec3.copy(t, e);
c.vec3.sub(t, t, this._position);
c.quat.conjugate(S, this._quat);
c.vec3.transformQuat(t, t, S);
c.vec3.inverseSafe(b, this._scale);
c.vec3.mul(t, t, b);
return t;
},
getWorldPos: function(t) {
c.vec3.copy(t, this._position);
for (var e = this._parent; e; ) {
c.vec3.mul(t, t, e._scale);
c.vec3.transformQuat(t, t, e._quat);
c.vec3.add(t, t, e._position);
e = e._parent;
}
return t;
},
setWorldPos: function(t) {
this._parent ? this._parent._invTransformPoint(this._position, t) : c.vec3.copy(this._position, t);
this.setLocalDirty(E.POSITION);
1 & this._eventMask && this.emit(B.POSITION_CHANGED);
},
getWorldRot: function(t) {
c.quat.copy(t, this._quat);
for (var e = this._parent; e; ) {
c.quat.mul(t, e._quat, t);
e = e._parent;
}
return t;
},
setWorldRot: function(t) {
if (this._parent) {
this._parent.getWorldRot(this._quat);
c.quat.conjugate(this._quat, this._quat);
c.quat.mul(this._quat, this._quat, t);
} else c.quat.copy(this._quat, t);
this.setLocalDirty(E.ROTATION);
},
getWorldRT: function(t) {
var e = b, i = S;
c.vec3.copy(e, this._position);
c.quat.copy(i, this._quat);
for (var n = this._parent; n; ) {
c.vec3.mul(e, e, n._scale);
c.vec3.transformQuat(e, e, n._quat);
c.vec3.add(e, e, n._position);
c.quat.mul(i, n._quat, i);
n = n._parent;
}
c.mat4.fromRT(t, i, e);
return t;
},
lookAt: function(t, e) {
this.getWorldPos(b);
c.vec3.sub(b, b, t);
c.vec3.normalize(b, b);
c.quat.fromViewUp(S, b, e);
this.setWorldRot(S);
},
_updateLocalMatrix: function() {
var t = this._localMatDirty;
if (t) {
var e = this._matrix;
if (t & (E.RT | E.SKEW)) {
var i = this._rotationX || this._rotationY, n = this._skewX || this._skewY, r = this._scale.x, s = this._scale.y;
if (i || n) {
var o = 1, a = 0, c = 0, h = 1;
if (i) {
var l = this._rotationX * v;
c = Math.sin(l);
h = Math.cos(l);
if (this._rotationY === this._rotationX) {
o = h;
a = -c;
} else {
var u = this._rotationY * v;
o = Math.cos(u);
a = -Math.sin(u);
}
}
e.m00 = o *= r;
e.m01 = a *= r;
e.m04 = c *= s;
e.m05 = h *= s;
if (n) {
var _ = e.m00, f = e.m01, d = e.m04, m = e.m05, p = Math.tan(this._skewX * v), y = Math.tan(this._skewY * v);
Infinity === p && (p = 99999999);
Infinity === y && (y = 99999999);
e.m00 = _ + d * y;
e.m01 = f + m * y;
e.m04 = d + _ * p;
e.m05 = m + f * p;
}
} else {
e.m00 = r;
e.m01 = 0;
e.m04 = 0;
e.m05 = s;
}
}
e.m12 = this._position.x;
e.m13 = this._position.y;
this._localMatDirty = 0;
this._worldMatDirty = !0;
}
},
_calculWorldMatrix: function() {
this._localMatDirty && this._updateLocalMatrix();
var t = this._parent;
if (t) {
var e = t._worldMatrix, i = this._matrix, n = this._worldMatrix, r = i.m00, s = i.m01, o = i.m04, a = i.m05, h = i.m12, l = i.m13, u = e.m00, _ = e.m01, f = e.m04, d = e.m05, m = e.m12, p = e.m13;
if (0 !== _ || 0 !== f) {
n.m00 = r * u + s * f;
n.m01 = r * _ + s * d;
n.m04 = o * u + a * f;
n.m05 = o * _ + a * d;
n.m12 = u * h + f * l + m;
n.m13 = _ * h + d * l + p;
} else {
n.m00 = r * u;
n.m01 = s * d;
n.m04 = o * u;
n.m05 = a * d;
n.m12 = u * h + m;
n.m13 = d * l + p;
}
} else c.mat4.copy(this._worldMatrix, this._matrix);
this._worldMatDirty = !1;
},
_updateWorldMatrix: function() {
this._parent && this._parent._updateWorldMatrix();
if (this._worldMatDirty) {
this._calculWorldMatrix();
for (var t = this._children, e = 0, i = t.length; e < i; e++) t[e]._worldMatDirty = !0;
}
},
setLocalDirty: function(t) {
this._localMatDirty = this._localMatDirty | t;
this._worldMatDirty = !0;
},
setWorldDirty: function() {
this._worldMatDirty = !0;
},
getLocalMatrix: function(t) {
this._updateLocalMatrix();
return c.mat4.copy(t, this._matrix);
},
getWorldMatrix: function(t) {
this._updateWorldMatrix();
return c.mat4.copy(t, this._worldMatrix);
},
convertToNodeSpace: function(t) {
this._updateWorldMatrix();
c.mat4.invert(A, this._worldMatrix);
var e = new cc.Vec2();
c.vec2.transformMat4(e, t, A);
e.x += this._anchorPoint.x * this._contentSize.width;
e.y += this._anchorPoint.y * this._contentSize.height;
return e;
},
convertToWorldSpace: function(t) {
this._updateWorldMatrix();
var e = new cc.Vec2(t.x - this._anchorPoint.x * this._contentSize.width, t.y - this._anchorPoint.y * this._contentSize.height);
return c.vec2.transformMat4(e, e, this._worldMatrix);
},
convertToNodeSpaceAR: function(t) {
this._updateWorldMatrix();
c.mat4.invert(A, this._worldMatrix);
var e = new cc.Vec2();
return c.vec2.transformMat4(e, t, A);
},
convertToWorldSpaceAR: function(t) {
this._updateWorldMatrix();
var e = new cc.Vec2();
return c.vec2.transformMat4(e, t, this._worldMatrix);
},
getNodeToParentTransform: function(t) {
t || (t = h.identity());
this._updateLocalMatrix();
var e = this._contentSize;
b.x = -this._anchorPoint.x * e.width;
b.y = -this._anchorPoint.y * e.height;
c.mat4.copy(A, this._matrix);
c.mat4.translate(A, A, b);
return h.fromMat4(t, A);
},
getNodeToParentTransformAR: function(t) {
t || (t = h.identity());
this._updateLocalMatrix();
return h.fromMat4(t, this._matrix);
},
getNodeToWorldTransform: function(t) {
t || (t = h.identity());
this._updateWorldMatrix();
var e = this._contentSize;
b.x = -this._anchorPoint.x * e.width;
b.y = -this._anchorPoint.y * e.height;
c.mat4.copy(A, this._worldMatrix);
c.mat4.translate(A, A, b);
return h.fromMat4(t, A);
},
getNodeToWorldTransformAR: function(t) {
t || (t = h.identity());
this._updateWorldMatrix();
return h.fromMat4(t, this._worldMatrix);
},
getParentToNodeTransform: function(t) {
t || (t = h.identity());
this._updateLocalMatrix();
c.mat4.invert(A, this._matrix);
return h.fromMat4(t, A);
},
getWorldToNodeTransform: function(t) {
t || (t = h.identity());
this._updateWorldMatrix();
c.mat4.invert(A, this._worldMatrix);
return h.fromMat4(t, A);
},
convertTouchToNodeSpace: function(t) {
return this.convertToNodeSpace(t.getLocation());
},
convertTouchToNodeSpaceAR: function(t) {
return this.convertToNodeSpaceAR(t.getLocation());
},
getBoundingBox: function() {
this._updateLocalMatrix();
var t = this._contentSize.width, e = this._contentSize.height, i = cc.rect(-this._anchorPoint.x * t, -this._anchorPoint.y * e, t, e);
return i.transformMat4(i, this._matrix);
},
getBoundingBoxToWorld: function() {
if (this._parent) {
this._parent._updateWorldMatrix();
return this._getBoundingBoxTo(this._parent._worldMatrix);
}
return this.getBoundingBox();
},
_getBoundingBoxTo: function(t) {
this._updateLocalMatrix();
var e = this._contentSize.width, i = this._contentSize.height, n = cc.rect(-this._anchorPoint.x * e, -this._anchorPoint.y * i, e, i);
t = c.mat4.mul(this._worldMatrix, t, this._matrix);
n.transformMat4(n, t);
if (!this._children) return n;
for (var r = this._children, s = 0; s < r.length; s++) {
var o = r[s];
if (o && o.active) {
var a = o._getBoundingBoxTo(t);
a && n.union(n, a);
}
}
return n;
},
_updateOrderOfArrival: function() {
var t = this._parent ? ++this._parent._childArrivalOrder : 0;
this._localZOrder = 4294901760 & this._localZOrder | t;
if (65535 === t) {
var e = this._parent._children;
e.forEach((function(t, e) {
t._localZOrder = 4294901760 & t._localZOrder | e + 1;
}));
this._parent._childArrivalOrder = e.length;
}
},
addChild: function(t, e, i) {
0;
cc.assertID(t, 1606);
cc.assertID(null === t._parent, 1605);
t.parent = this;
void 0 !== e && (t.zIndex = e);
void 0 !== i && (t.name = i);
},
cleanup: function() {
y && cc.director.getActionManager().removeAllActionsFromTarget(this);
l.removeListeners(this);
var t, e, i = this._children.length;
for (t = 0; t < i; ++t) (e = this._children[t]) && e.cleanup();
},
sortAllChildren: function() {
if (this._reorderChildDirty) {
this._reorderChildDirty = !1;
var t = this._children;
if (t.length > 1) {
var e, i, n, r = t.length;
for (e = 1; e < r; e++) {
n = t[e];
i = e - 1;
for (;i >= 0 && n._localZOrder < t[i]._localZOrder; ) {
t[i + 1] = t[i];
i--;
}
t[i + 1] = n;
}
this.emit(B.CHILD_REORDER, this);
}
cc.director.__fastOff(cc.Director.EVENT_AFTER_UPDATE, this.sortAllChildren, this);
}
},
_delaySort: function() {
if (!this._reorderChildDirty) {
this._reorderChildDirty = !0;
cc.director.__fastOn(cc.Director.EVENT_AFTER_UPDATE, this.sortAllChildren, this);
}
},
_restoreProperties: !1,
onRestore: !1
});
_.propertyDefine(H, [ "position", "scale", "rotation" ]);
cc.Node = n.exports = H;
}), {
"./event-manager": 100,
"./event/event": 103,
"./event/event-target": 102,
"./platform/CCMacro": 165,
"./platform/js": 180,
"./renderer/render-engine": 202,
"./renderer/render-flow": 203,
"./utils/affine-transform": 234,
"./utils/base-node": 235,
"./utils/math-pools": 241,
"./utils/misc": 242,
"./utils/prefab-helper": 245
} ],
30: [ (function(t, e, i) {
"use strict";
var n = t("./CCNode"), r = t("./renderer/render-flow"), s = t("./renderer/render-engine").math, o = n._LocalDirtyFlag, a = (s.vec3.create(), 
cc.Class({
name: "cc.PrivateNode",
extends: n,
properties: {
x: {
get: function() {
return this._originPos.x;
},
set: function(t) {
var e = this._originPos;
if (t !== e.x) {
e.x = t;
this._posDirty(!0);
}
},
override: !0
},
y: {
get: function() {
return this._originPos.y;
},
set: function(t) {
var e = this._originPos;
if (t !== e.y) {
e.y = t;
this._posDirty(!0);
}
},
override: !0
},
zIndex: {
get: function() {
return cc.macro.MIN_ZINDEX;
},
set: function() {
cc.warnID(1638);
},
override: !0
}
},
ctor: function(t) {
this._localZOrder = cc.macro.MIN_ZINDEX << 16;
this._originPos = cc.v2();
},
_posDirty: function(t) {
this.setLocalDirty(o.POSITION);
this._renderFlag |= r.FLAG_TRANSFORM;
!0 === t && 1 & this._eventMask && this.emit(n.EventType.POSITION_CHANGED);
},
_updateLocalMatrix: function() {
if (this._localMatDirty) {
var t = this.parent;
if (t) {
this._position.x = this._originPos.x - (t._anchorPoint.x - .5) * t._contentSize.width;
this._position.y = this._originPos.y - (t._anchorPoint.y - .5) * t._contentSize.height;
}
this._super();
}
},
getPosition: function() {
return new cc.Vec2(this._originPos);
},
setPosition: function(t, e) {
void 0 === e && (e = (t = t.x).y);
var i = this._originPos;
if (i.x !== t || i.y !== e) {
i.x = t;
i.y = e;
this._posDirty(!0);
}
},
setParent: function(t) {
var e = this._parent;
this._super(t);
if (e !== t) {
e && e.off(n.EventType.ANCHOR_CHANGED, this._posDirty, this);
t && t.on(n.EventType.ANCHOR_CHANGED, this._posDirty, this);
}
},
_updateOrderOfArrival: function() {}
}));
cc.js.getset(a.prototype, "parent", a.prototype.getParent, a.prototype.setParent);
cc.js.getset(a.prototype, "position", a.prototype.getPosition, a.prototype.setPosition);
cc.PrivateNode = e.exports = a;
}), {
"./CCNode": 29,
"./renderer/render-engine": 202,
"./renderer/render-flow": 203
} ],
31: [ (function(t, e, i) {
cc.Scene = cc.Class({
name: "cc.Scene",
extends: t("./CCNode"),
properties: {
autoReleaseAssets: {
default: void 0,
type: cc.Boolean
}
},
ctor: function() {
this._anchorPoint.x = 0;
this._anchorPoint.y = 0;
this._activeInHierarchy = !1;
this._inited = !cc.game._isCloning;
0;
this.dependAssets = null;
},
destroy: function() {
if (cc.Object.prototype.destroy.call(this)) for (var t = this._children, e = 0; e < t.length; ++e) t[e].active = !1;
this._active = !1;
this._activeInHierarchy = !1;
},
_onHierarchyChanged: function() {},
_instantiate: null,
_load: function() {
if (!this._inited) {
0;
this._onBatchCreated();
this._inited = !0;
}
},
_activate: function(t) {
t = !1 !== t;
0;
cc.director._nodeActivator.activateNode(this, t);
}
});
e.exports = cc.Scene;
}), {
"./CCNode": 29
} ],
32: [ (function(i, n, r) {
var s = i("./platform/js"), o = new (i("./platform/id-generater"))("Scheduler"), a = function(t, e, i, n) {
this.target = t;
this.priority = e;
this.paused = i;
this.markedForDeletion = n;
}, c = [];
a.get = function(t, e, i, n) {
var r = c.pop();
if (r) {
r.target = t;
r.priority = e;
r.paused = i;
r.markedForDeletion = n;
} else r = new a(t, e, i, n);
return r;
};
a.put = function(t) {
if (c.length < 20) {
t.target = null;
c.push(t);
}
};
var h = function(t, e, i, n) {
this.list = t;
this.entry = e;
this.target = i;
this.callback = n;
}, l = [];
h.get = function(t, e, i, n) {
var r = l.pop();
if (r) {
r.list = t;
r.entry = e;
r.target = i;
r.callback = n;
} else r = new h(t, e, i, n);
return r;
};
h.put = function(t) {
if (l.length < 20) {
t.list = t.entry = t.target = t.callback = null;
l.push(t);
}
};
var u = function(t, e, i, n, r, s) {
var o = this;
o.timers = t;
o.target = e;
o.timerIndex = i;
o.currentTimer = n;
o.currentTimerSalvaged = r;
o.paused = s;
}, _ = [];
u.get = function(t, e, i, n, r, s) {
var o = _.pop();
if (o) {
o.timers = t;
o.target = e;
o.timerIndex = i;
o.currentTimer = n;
o.currentTimerSalvaged = r;
o.paused = s;
} else o = new u(t, e, i, n, r, s);
return o;
};
u.put = function(t) {
if (_.length < 20) {
t.timers = t.target = t.currentTimer = null;
_.push(t);
}
};
function f() {
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;
}
var d = f.prototype;
d.initWithCallback = function(t, e, i, n, r, s) {
this._lock = !1;
this._scheduler = t;
this._target = i;
this._callback = e;
this._elapsed = -1;
this._interval = n;
this._delay = s;
this._useDelay = this._delay > 0;
this._repeat = r;
this._runForever = this._repeat === cc.macro.REPEAT_FOREVER;
return !0;
};
d.getInterval = function() {
return this._interval;
};
d.setInterval = function(t) {
this._interval = t;
};
d.update = function(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();
}
}
};
d.getCallback = function() {
return this._callback;
};
d.trigger = function() {
if (this._target && this._callback) {
this._lock = !0;
this._callback.call(this._target, this._elapsed);
this._lock = !1;
}
};
d.cancel = function() {
this._scheduler.unschedule(this._callback, this._target);
};
var m = [];
f.get = function() {
return m.pop() || new f();
};
f.put = function(t) {
if (m.length < 20 && !t._lock) {
t._scheduler = t._target = t._callback = null;
m.push(t);
}
};
cc.Scheduler = function() {
this._timeScale = 1;
this._updatesNegList = [];
this._updates0List = [];
this._updatesPosList = [];
this._hashForUpdates = s.createMap(!0);
this._hashForTimers = s.createMap(!0);
this._currentTarget = null;
this._currentTargetSalvaged = !1;
this._updateHashLocked = !1;
this._arrayForTimers = [];
};
cc.Scheduler.prototype = {
constructor: cc.Scheduler,
_removeHashElement: function(t) {
delete this._hashForTimers[t.target._id];
for (var e = this._arrayForTimers, i = 0, n = e.length; i < n; i++) if (e[i] === t) {
e.splice(i, 1);
break;
}
u.put(t);
},
_removeUpdateFromHash: function(t) {
var e = t.target._id, i = this._hashForUpdates[e];
if (i) {
for (var n = i.list, r = i.entry, s = 0, o = n.length; s < o; s++) if (n[s] === r) {
n.splice(s, 1);
break;
}
delete this._hashForUpdates[e];
a.put(r);
h.put(i);
}
},
_priorityIn: function(t, e, i) {
for (var n = 0; n < t.length; n++) if (i < t[n].priority) {
t.splice(n, 0, e);
return;
}
t.push(e);
},
_appendIn: function(t, e) {
t.push(e);
},
enableForTarget: function(t) {
t._id || (t.__instanceId ? cc.warnID(1513) : t._id = o.getNewId());
},
setTimeScale: function(t) {
this._timeScale = t;
},
getTimeScale: function() {
return this._timeScale;
},
update: function(t) {
this._updateHashLocked = !0;
1 !== this._timeScale && (t *= this._timeScale);
var e, i, n, r;
for (e = 0, n = (i = this._updatesNegList).length; e < n; e++) (r = i[e]).paused || r.markedForDeletion || r.target.update(t);
for (e = 0, n = (i = this._updates0List).length; e < n; e++) (r = i[e]).paused || r.markedForDeletion || r.target.update(t);
for (e = 0, n = (i = this._updatesPosList).length; e < n; e++) (r = i[e]).paused || r.markedForDeletion || r.target.update(t);
var s, o = this._arrayForTimers;
for (e = 0; e < o.length; e++) {
s = o[e];
this._currentTarget = s;
this._currentTargetSalvaged = !1;
if (!s.paused) for (s.timerIndex = 0; s.timerIndex < s.timers.length; ++s.timerIndex) {
s.currentTimer = s.timers[s.timerIndex];
s.currentTimerSalvaged = !1;
s.currentTimer.update(t);
s.currentTimer = null;
}
if (this._currentTargetSalvaged && 0 === this._currentTarget.timers.length) {
this._removeHashElement(this._currentTarget);
--e;
}
}
for (e = 0, i = this._updatesNegList; e < i.length; ) (r = i[e]).markedForDeletion ? this._removeUpdateFromHash(r) : e++;
for (e = 0, i = this._updates0List; e < i.length; ) (r = i[e]).markedForDeletion ? this._removeUpdateFromHash(r) : e++;
for (e = 0, i = this._updatesPosList; e < i.length; ) (r = i[e]).markedForDeletion ? this._removeUpdateFromHash(r) : e++;
this._updateHashLocked = !1;
this._currentTarget = null;
},
schedule: function(i, n, r, s, o, a) {
"use strict";
if ("function" !== ("object" === (e = typeof i) ? t(i) : e)) {
var c = i;
i = n;
n = c;
}
if (4 === arguments.length || 5 === arguments.length) {
a = !!s;
s = cc.macro.REPEAT_FOREVER;
o = 0;
}
cc.assertID(n, 1502);
var h = n._id;
if (!h) if (n.__instanceId) {
cc.warnID(1513);
h = n._id = n.__instanceId;
} else cc.errorID(1510);
var l, _, d = this._hashForTimers[h];
if (d) d.paused !== a && cc.warnID(1511); else {
d = u.get(null, n, 0, null, null, a);
this._arrayForTimers.push(d);
this._hashForTimers[h] = d;
}
if (null == d.timers) d.timers = []; else for (_ = 0; _ < d.timers.length; ++_) if ((l = d.timers[_]) && i === l._callback) {
cc.logID(1507, l.getInterval(), r);
l._interval = r;
return;
}
(l = f.get()).initWithCallback(this, i, n, r, s, o);
d.timers.push(l);
this._currentTarget === d && this._currentTargetSalvaged && (this._currentTargetSalvaged = !1);
},
scheduleUpdate: function(t, e, i) {
var n = t._id;
if (!n) if (t.__instanceId) {
cc.warnID(1513);
n = t._id = t.__instanceId;
} else cc.errorID(1510);
var r = this._hashForUpdates[n];
if (r && r.entry) {
if (r.entry.priority === e) {
r.entry.markedForDeletion = !1;
r.entry.paused = i;
return;
}
if (this._updateHashLocked) {
cc.logID(1506);
r.entry.markedForDeletion = !1;
r.entry.paused = i;
return;
}
this.unscheduleUpdate(t);
}
var s, o = a.get(t, e, i, !1);
if (0 === e) {
s = this._updates0List;
this._appendIn(s, o);
} else {
s = e < 0 ? this._updatesNegList : this._updatesPosList;
this._priorityIn(s, o, e);
}
this._hashForUpdates[n] = h.get(s, o, t, null);
},
unschedule: function(t, e) {
if (e && t) {
var i = e._id;
if (!i) if (e.__instanceId) {
cc.warnID(1513);
i = e._id = e.__instanceId;
} else cc.errorID(1510);
var n = this._hashForTimers[i];
if (n) for (var r = n.timers, s = 0, o = r.length; s < o; s++) {
var a = r[s];
if (t === a._callback) {
a !== n.currentTimer || n.currentTimerSalvaged || (n.currentTimerSalvaged = !0);
r.splice(s, 1);
f.put(a);
n.timerIndex >= s && n.timerIndex--;
0 === r.length && (this._currentTarget === n ? this._currentTargetSalvaged = !0 : this._removeHashElement(n));
return;
}
}
}
},
unscheduleUpdate: function(t) {
if (t) {
var e = t._id;
if (!e) if (t.__instanceId) {
cc.warnID(1513);
e = t._id = t.__instanceId;
} else cc.errorID(1510);
var i = this._hashForUpdates[e];
i && (this._updateHashLocked ? i.entry.markedForDeletion = !0 : this._removeUpdateFromHash(i.entry));
}
},
unscheduleAllForTarget: function(t) {
if (t) {
var e = t._id;
if (!e) if (t.__instanceId) {
cc.warnID(1513);
e = t._id = t.__instanceId;
} else cc.errorID(1510);
var i = this._hashForTimers[e];
if (i) {
var n = i.timers;
n.indexOf(i.currentTimer) > -1 && !i.currentTimerSalvaged && (i.currentTimerSalvaged = !0);
for (var r = 0, s = n.length; r < s; r++) f.put(n[r]);
n.length = 0;
this._currentTarget === i ? this._currentTargetSalvaged = !0 : this._removeHashElement(i);
}
this.unscheduleUpdate(t);
}
},
unscheduleAll: function() {
this.unscheduleAllWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM);
},
unscheduleAllWithMinPriority: function(t) {
var e, i, n, r = this._arrayForTimers;
for (e = r.length - 1; e >= 0; e--) {
i = r[e];
this.unscheduleAllForTarget(i.target);
}
var s = 0;
if (t < 0) for (e = 0; e < this._updatesNegList.length; ) {
s = this._updatesNegList.length;
(n = this._updatesNegList[e]) && n.priority >= t && this.unscheduleUpdate(n.target);
s == this._updatesNegList.length && e++;
}
if (t <= 0) for (e = 0; e < this._updates0List.length; ) {
s = this._updates0List.length;
(n = this._updates0List[e]) && this.unscheduleUpdate(n.target);
s == this._updates0List.length && e++;
}
for (e = 0; e < this._updatesPosList.length; ) {
s = this._updatesPosList.length;
(n = this._updatesPosList[e]) && n.priority >= t && this.unscheduleUpdate(n.target);
s == this._updatesPosList.length && e++;
}
},
isScheduled: function(t, e) {
cc.assertID(t, 1508);
cc.assertID(e, 1509);
var i = e._id;
if (!i) if (e.__instanceId) {
cc.warnID(1513);
i = e._id = e.__instanceId;
} else cc.errorID(1510);
var n = this._hashForTimers[i];
if (!n) return !1;
if (null == n.timers) return !1;
for (var r = n.timers, s = 0; s < r.length; ++s) {
if (t === r[s]._callback) return !0;
}
return !1;
},
pauseAllTargets: function() {
return this.pauseAllTargetsWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM);
},
pauseAllTargetsWithMinPriority: function(t) {
var e, i, n, r, s = [], o = this._arrayForTimers;
for (i = 0, n = o.length; i < n; i++) if (e = o[i]) {
e.paused = !0;
s.push(e.target);
}
if (t < 0) for (i = 0; i < this._updatesNegList.length; i++) if ((r = this._updatesNegList[i]) && r.priority >= t) {
r.paused = !0;
s.push(r.target);
}
if (t <= 0) for (i = 0; i < this._updates0List.length; i++) if (r = this._updates0List[i]) {
r.paused = !0;
s.push(r.target);
}
for (i = 0; i < this._updatesPosList.length; i++) if ((r = this._updatesPosList[i]) && r.priority >= t) {
r.paused = !0;
s.push(r.target);
}
return s;
},
resumeTargets: function(t) {
if (t) for (var e = 0; e < t.length; e++) this.resumeTarget(t[e]);
},
pauseTarget: function(t) {
cc.assertID(t, 1503);
var e = t._id;
if (!e) if (t.__instanceId) {
cc.warnID(1513);
e = t._id = t.__instanceId;
} else cc.errorID(1510);
var i = this._hashForTimers[e];
i && (i.paused = !0);
var n = this._hashForUpdates[e];
n && (n.entry.paused = !0);
},
resumeTarget: function(t) {
cc.assertID(t, 1504);
var e = t._id;
if (!e) if (t.__instanceId) {
cc.warnID(1513);
e = t._id = t.__instanceId;
} else cc.errorID(1510);
var i = this._hashForTimers[e];
i && (i.paused = !1);
var n = this._hashForUpdates[e];
n && (n.entry.paused = !1);
},
isTargetPaused: function(t) {
cc.assertID(t, 1505);
var e = t._id;
if (!e) if (t.__instanceId) {
cc.warnID(1513);
e = t._id = t.__instanceId;
} else cc.errorID(1510);
var i = this._hashForTimers[e];
if (i) return i.paused;
var n = this._hashForUpdates[e];
return !!n && n.entry.paused;
}
};
cc.Scheduler.PRIORITY_SYSTEM = 1 << 31;
cc.Scheduler.PRIORITY_NON_SYSTEM = cc.Scheduler.PRIORITY_SYSTEM + 1;
n.exports = cc.Scheduler;
}), {
"./platform/id-generater": 176,
"./platform/js": 180
} ],
33: [ (function(t, e, i) {
var n = t("./CCRawAsset");
cc.Asset = cc.Class({
name: "cc.Asset",
extends: n,
ctor: function() {
this.loaded = !0;
},
properties: {
nativeUrl: {
get: function() {
if (this._native) {
var t = this._native;
if (47 === t.charCodeAt(0)) return t.slice(1);
if (cc.AssetLibrary) {
var e = cc.AssetLibrary.getLibUrlNoExt(this._uuid, !0);
return 46 === t.charCodeAt(0) ? e + t : e + "/" + t;
}
cc.errorID(6400);
}
return "";
},
visible: !1
},
_native: "",
_nativeAsset: {
get: function() {},
set: function(t) {}
}
},
statics: {
deserialize: !1,
preventDeferredLoadDependents: !1,
preventPreloadNativeObject: !1
},
toString: function() {
return this.nativeUrl;
},
serialize: !1,
createNode: null,
_setRawAsset: function(t, e) {
this._native = !1 !== e ? t || void 0 : "/" + t;
}
});
e.exports = cc.Asset;
}), {
"./CCRawAsset": 41
} ],
34: [ (function(t, e, i) {
var n = t("./CCAsset"), r = t("../event/event-target"), s = cc.Enum({
WEB_AUDIO: 0,
DOM_AUDIO: 1
}), o = cc.Class({
name: "cc.AudioClip",
extends: n,
mixins: [ r ],
ctor: function() {
this.loaded = !1;
this._audio = null;
},
properties: {
loadMode: {
default: s.WEB_AUDIO,
type: s
},
_nativeAsset: {
get: function() {
return this._audio;
},
set: function(t) {
t instanceof cc.AudioClip ? this._audio = t._nativeAsset : this._audio = t;
if (this._audio) {
this.loaded = !0;
this.emit("load");
}
},
override: !0
}
},
statics: {
LoadMode: s,
_loadByUrl: function(t, e) {
var i = cc.loader.getItem(t) || cc.loader.getItem(t + "?useDom=1");
i && i.complete ? i._owner instanceof o ? e(null, i._owner) : e(null, i.content) : cc.loader.load(t, (function(n, r) {
if (n) return e(n);
i = cc.loader.getItem(t) || cc.loader.getItem(t + "?useDom=1");
e(null, i.content);
}));
}
},
destroy: function() {
cc.audioEngine.uncache(this);
this._super();
}
});
cc.AudioClip = o;
e.exports = o;
}), {
"../event/event-target": 102,
"./CCAsset": 33
} ],
35: [ (function(t, e, i) {
var n = cc.Class({
name: "cc.BitmapFont",
extends: cc.Font,
properties: {
fntDataStr: {
default: ""
},
spriteFrame: {
default: null,
type: cc.SpriteFrame
},
fontSize: {
default: -1
},
_fntConfig: null
}
});
cc.BitmapFont = n;
e.exports = n;
}), {} ],
36: [ (function(t, e, i) {
var n = cc.Class({
name: "cc.BufferAsset",
extends: cc.Asset,
ctor: function() {
this._buffer = null;
},
properties: {
_nativeAsset: {
get: function() {
return this._buffer;
},
set: function(t) {
this._buffer = t.buffer || t;
},
override: !0
}
}
});
cc.BufferAsset = e.exports = n;
}), {} ],
37: [ (function(t, e, i) {
var n = cc.Class({
name: "cc.Font",
extends: cc.Asset
});
cc.Font = e.exports = n;
}), {} ],
38: [ (function(t, e, i) {
var n = cc.Class({
name: "cc.JsonAsset",
extends: cc.Asset,
properties: {
json: null
}
});
e.exports = cc.JsonAsset = n;
}), {} ],
39: [ (function(t, e, i) {
var n = cc.Class({
name: "cc.LabelAtlas",
extends: cc.BitmapFont
});
cc.LabelAtlas = n;
e.exports = n;
}), {} ],
40: [ (function(t, e, i) {
var n = cc.Enum({
AUTO: 0,
SINGLE_INSTANCE: 1,
MULTI_INSTANCE: 2
}), r = cc.Class({
name: "cc.Prefab",
extends: cc.Asset,
ctor: function() {
this._createFunction = null;
this._instantiatedTimes = 0;
},
properties: {
data: null,
optimizationPolicy: n.AUTO,
asyncLoadAssets: !1
},
statics: {
OptimizationPolicy: n,
OptimizationPolicyThreshold: 3
},
createNode: !1,
compileCreateFunction: function() {
var e = t("../platform/instantiate-jit");
this._createFunction = e.compile(this.data);
},
_doInstantiate: function(t) {
this.data._prefab ? this.data._prefab._synced = !0 : cc.warnID(3700);
this._createFunction || this.compileCreateFunction();
return this._createFunction(t);
},
_instantiate: function() {
var t;
if (this.optimizationPolicy !== n.SINGLE_INSTANCE && (this.optimizationPolicy === n.MULTI_INSTANCE || this._instantiatedTimes + 1 >= r.OptimizationPolicyThreshold)) {
t = this._doInstantiate();
this.data._instantiate(t);
} else {
this.data._prefab._synced = !0;
t = this.data._instantiate();
}
++this._instantiatedTimes;
return t;
}
});
cc.Prefab = e.exports = r;
cc.js.obsolete(cc, "cc._Prefab", "Prefab");
}), {
"../platform/instantiate-jit": 178
} ],
41: [ (function(t, e, i) {
var n = t("../platform/CCObject"), r = t("../platform/js");
cc.RawAsset = cc.Class({
name: "cc.RawAsset",
extends: n,
ctor: function() {
Object.defineProperty(this, "_uuid", {
value: "",
writable: !0
});
}
});
r.value(cc.RawAsset, "isRawAssetType", (function(t) {
return r.isChildClassOf(t, cc.RawAsset) && !r.isChildClassOf(t, cc.Asset);
}));
r.value(cc.RawAsset, "wasRawAssetType", (function(t) {
return t === cc.Texture2D || t === cc.AudioClip || t === cc.ParticleAsset || t === cc.Asset;
}));
e.exports = cc.RawAsset;
}), {
"../platform/CCObject": 166,
"../platform/js": 180
} ],
42: [ (function(t, e, i) {
var n = t("../renderer"), r = t("../renderer/render-engine"), s = r.gfx, o = t("./CCTexture2D"), a = cc.Class({
name: "cc.RenderTexture",
extends: o,
ctor: function() {
this._framebuffer = null;
},
initWithSize: function(t, e, i) {
this.width = Math.floor(t || cc.visibleRect.width);
this.height = Math.floor(e || cc.visibleRect.height);
var a = {};
a.format = this._format;
a.width = t;
a.height = e;
a.images = void 0;
a.wrapS = this._wrapS;
a.wrapT = this._wrapT;
a.premultiplyAlpha = this._premultiplyAlpha;
a.minFilter = o._FilterIndex[this._minFilter];
a.magFilter = o._FilterIndex[this._magFilter];
this._texture ? this._texture.update(a) : this._texture = new n.Texture2D(n.device, a);
a = {
colors: [ this._texture ]
};
if (i) {
var c = new s.RenderBuffer(n.device, i, t, e);
i === s.RB_FMT_D24S8 ? a.depth = a.stencil = c : i === s.RB_FMT_S8 ? a.stencil = c : i === gl.RB_FMT_D16 && (a.depth = c);
}
this._framebuffer && this._framebuffer.destroy();
this._framebuffer = new r.gfx.FrameBuffer(n.device, t, e, a);
this.loaded = !0;
this.emit("load");
},
drawTextureAt: function(t, e, i) {
t._image && this._texture.updateSubImage({
x: e,
y: i,
image: t._image,
width: t.width,
height: t.height,
level: 0,
flipY: !1,
premultiplyAlpha: t._premultiplyAlpha
});
},
readPixels: function(t, e, i, r, s) {
if (!this._framebuffer || !this._texture) return t;
e = e || 0;
i = i || 0;
var o = r || this.width, a = s || this.height;
t = t || new Uint8Array(o * a * 4);
var c = n._forward._device._gl, h = c.getParameter(c.FRAMEBUFFER_BINDING);
c.bindFramebuffer(c.FRAMEBUFFER, this._framebuffer._glID);
c.framebufferTexture2D(c.FRAMEBUFFER, c.COLOR_ATTACHMENT0, c.TEXTURE_2D, this._texture._glID, 0);
c.readPixels(e, i, o, a, c.RGBA, c.UNSIGNED_BYTE, t);
c.bindFramebuffer(c.FRAMEBUFFER, h);
return t;
},
destroy: function() {
this._super();
this._framebuffer && this._framebuffer.destroy();
}
});
cc.RenderTexture = e.exports = a;
}), {
"../renderer": 201,
"../renderer/render-engine": 202,
"./CCTexture2D": 49
} ],
43: [ (function(t, e, i) {
var n = cc.Class({
name: "cc.SceneAsset",
extends: cc.Asset,
properties: {
scene: null,
asyncLoadAssets: void 0
}
});
cc.SceneAsset = n;
e.exports = n;
}), {} ],
44: [ (function(t, e, i) {
var n = cc.Class({
name: "cc.Script",
extends: cc.Asset
});
cc._Script = n;
var r = cc.Class({
name: "cc.JavaScript",
extends: n
});
cc._JavaScript = r;
var s = cc.Class({
name: "cc.CoffeeScript",
extends: n
});
cc._CoffeeScript = s;
var o = cc.Class({
name: "cc.TypeScript",
extends: n
});
cc._TypeScript = o;
}), {} ],
45: [ (function(t, e, i) {
var n = cc.Class({
name: "cc.SpriteAtlas",
extends: cc.Asset,
properties: {
_spriteFrames: {
default: {}
}
},
getTexture: function() {
var t = Object.keys(this._spriteFrames);
if (t.length > 0) {
var e = this._spriteFrames[t[0]];
return e ? e.getTexture() : null;
}
return null;
},
getSpriteFrame: function(t) {
var e = this._spriteFrames[t];
if (!e) return null;
e.name || (e.name = t);
return e;
},
getSpriteFrames: function() {
var t = [], e = this._spriteFrames;
for (var i in e) t.push(this.getSpriteFrame(i));
return t;
}
});
cc.SpriteAtlas = n;
e.exports = n;
}), {} ],
46: [ (function(i, n, r) {
var s = i("../event/event-target"), o = i("../utils/texture-util"), a = [ {
u: 0,
v: 0
}, {
u: 0,
v: 0
}, {
u: 0,
v: 0
}, {
u: 0,
v: 0
} ], c = cc.Class({
name: "cc.SpriteFrame",
extends: i("../assets/CCAsset"),
mixins: [ s ],
properties: {
_textureSetter: {
set: function(t) {
if (t) {
0;
this._texture !== t && this._refreshTexture(t);
this._textureFilename = t.url;
}
}
},
insetTop: {
get: function() {
return this._capInsets[1];
},
set: function(t) {
this._capInsets[1] = t;
this._texture && this._calculateSlicedUV();
}
},
insetBottom: {
get: function() {
return this._capInsets[3];
},
set: function(t) {
this._capInsets[3] = t;
this._texture && this._calculateSlicedUV();
}
},
insetLeft: {
get: function() {
return this._capInsets[0];
},
set: function(t) {
this._capInsets[0] = t;
this._texture && this._calculateSlicedUV();
}
},
insetRight: {
get: function() {
return this._capInsets[2];
},
set: function(t) {
this._capInsets[2] = t;
this._texture && this._calculateSlicedUV();
}
}
},
ctor: function() {
s.call(this);
var t = arguments[0], e = arguments[1], i = arguments[2], n = arguments[3], r = arguments[4];
this._rect = null;
this.uv = [];
this._texture = null;
this._original = null;
this._offset = null;
this._originalSize = null;
this._rotated = !1;
this.vertices = null;
this._capInsets = [ 0, 0, 0, 0 ];
this.uvSliced = [];
this._textureFilename = "";
0;
void 0 !== t && this.setTexture(t, e, i, n, r);
},
textureLoaded: function() {
return this._texture && this._texture.loaded;
},
isRotated: function() {
return this._rotated;
},
setRotated: function(t) {
this._rotated = t;
this._texture && this._calculateUV();
},
getRect: function() {
return cc.rect(this._rect);
},
setRect: function(t) {
this._rect = t;
this._texture && this._calculateUV();
},
getOriginalSize: function() {
return cc.size(this._originalSize);
},
setOriginalSize: function(t) {
if (this._originalSize) {
this._originalSize.width = t.width;
this._originalSize.height = t.height;
} else this._originalSize = cc.size(t);
},
getTexture: function() {
return this._texture;
},
_textureLoadedCallback: function() {
var t = this._texture;
if (t) {
var e = t.width, i = t.height;
if (this._rotated && cc.game.renderType === cc.game.RENDER_TYPE_CANVAS) {
this._rotated = !1;
e = this._texture.width;
i = this._texture.height;
this._rect = cc.rect(0, 0, e, i);
}
this._rect ? this._checkRect(this._texture) : this._rect = cc.rect(0, 0, e, i);
this._originalSize || this.setOriginalSize(cc.size(e, i));
this._offset || this.setOffset(cc.v2(0, 0));
this._calculateUV();
this.emit("load");
}
},
_refreshTexture: function(t) {
this._texture = t;
t.loaded ? this._textureLoadedCallback() : t.once("load", this._textureLoadedCallback, this);
},
getOffset: function() {
return cc.v2(this._offset);
},
setOffset: function(t) {
this._offset = cc.v2(t);
},
clone: function() {
return new c(this._texture || this._textureFilename, this._rect, this._rotated, this._offset, this._originalSize);
},
setTexture: function(i, n, r, s, o) {
this._rect = n || null;
s ? this.setOffset(s) : this._offset = null;
o ? this.setOriginalSize(o) : this._originalSize = null;
this._rotated = r || !1;
var a = i;
if ("string" === ("object" === (e = typeof a) ? t(a) : e) && a) {
this._textureFilename = a;
this._loadTexture();
}
a instanceof cc.Texture2D && this._texture !== a && this._refreshTexture(a);
return !0;
},
_loadTexture: function() {
if (this._textureFilename) {
var t = o.loadImage(this._textureFilename);
this._refreshTexture(t);
}
},
ensureLoadTexture: function() {
if (this._texture) {
if (!this._texture.loaded) {
this._refreshTexture(this._texture);
o.postLoadTexture(this._texture);
}
} else this._textureFilename && this._loadTexture();
},
clearTexture: function() {
this._texture = null;
},
_checkRect: function(t) {
var e = this._rect, i = e.x, n = e.y;
if (this._rotated) {
i += e.height;
n += e.width;
} else {
i += e.width;
n += e.height;
}
i > t.width && cc.errorID(3300, t.url + "/" + this.name, i, t.width);
n > t.height && cc.errorID(3400, t.url + "/" + this.name, n, t.height);
},
_calculateSlicedUV: function() {
var t = this._rect, e = this._texture.width, i = this._texture.height, n = this._capInsets[0], r = this._capInsets[2], s = t.width - n - r, o = this._capInsets[1], c = this._capInsets[3], h = t.height - o - c, l = this.uvSliced;
l.length = 0;
if (this._rotated) {
a[0].u = t.x / e;
a[1].u = (t.x + c) / e;
a[2].u = (t.x + c + h) / e;
a[3].u = (t.x + t.height) / e;
a[3].v = t.y / i;
a[2].v = (t.y + n) / i;
a[1].v = (t.y + n + s) / i;
a[0].v = (t.y + t.width) / i;
for (var u = 0; u < 4; ++u) for (var _ = a[u], f = 0; f < 4; ++f) {
var d = a[3 - f];
l.push({
u: _.u,
v: d.v
});
}
} else {
a[0].u = t.x / e;
a[1].u = (t.x + n) / e;
a[2].u = (t.x + n + s) / e;
a[3].u = (t.x + t.width) / e;
a[3].v = t.y / i;
a[2].v = (t.y + o) / i;
a[1].v = (t.y + o + h) / i;
a[0].v = (t.y + t.height) / i;
for (var m = 0; m < 4; ++m) for (var p = a[m], v = 0; v < 4; ++v) {
var y = a[v];
l.push({
u: y.u,
v: p.v
});
}
}
},
_setDynamicAtlasFrame: function(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: function() {
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();
}
},
_calculateUV: function() {
var t = this._rect, e = this._texture, i = this.uv, n = e.width, r = e.height;
if (this._rotated) {
var s = 0 === n ? 0 : t.x / n, o = 0 === n ? 0 : (t.x + t.height) / n, a = 0 === r ? 0 : (t.y + t.width) / r, c = 0 === r ? 0 : t.y / r;
i[0] = s;
i[1] = c;
i[2] = s;
i[3] = a;
i[4] = o;
i[5] = c;
i[6] = o;
i[7] = a;
} else {
var h = 0 === n ? 0 : t.x / n, l = 0 === n ? 0 : (t.x + t.width) / n, u = 0 === r ? 0 : (t.y + t.height) / r, _ = 0 === r ? 0 : t.y / r;
i[0] = h;
i[1] = u;
i[2] = l;
i[3] = u;
i[4] = h;
i[5] = _;
i[6] = l;
i[7] = _;
}
var f = this.vertices;
if (f) {
f.nu.length = 0;
f.nv.length = 0;
for (var d = 0; d < f.u.length; d++) {
f.nu[d] = f.u[d] / n;
f.nv[d] = f.v[d] / r;
}
}
this._calculateSlicedUV();
},
_serialize: !1,
_deserialize: function(t, e) {
var i = t.rect;
i && (this._rect = new cc.Rect(i[0], i[1], i[2], i[3]));
t.offset && this.setOffset(new cc.Vec2(t.offset[0], t.offset[1]));
t.originalSize && this.setOriginalSize(new cc.Size(t.originalSize[0], t.originalSize[1]));
this._rotated = 1 === t.rotated;
this._name = t.name;
var n = t.capInsets;
if (n) {
this._capInsets[0] = n[0];
this._capInsets[1] = n[1];
this._capInsets[2] = n[2];
this._capInsets[3] = n[3];
}
0;
this.vertices = t.vertices;
if (this.vertices) {
this.vertices.nu = [];
this.vertices.nv = [];
}
var r = t.texture;
r && e.result.push(this, "_textureSetter", r);
}
}), h = c.prototype;
h.copyWithZone = h.clone;
h.copy = h.clone;
h.initWithTexture = h.setTexture;
cc.SpriteFrame = c;
n.exports = c;
}), {
"../assets/CCAsset": 33,
"../event/event-target": 102,
"../utils/texture-util": 250
} ],
47: [ (function(t, e, i) {
var n = t("./CCFont"), r = cc.Class({
name: "cc.TTFFont",
extends: n,
properties: {
_fontFamily: null,
_nativeAsset: {
type: cc.String,
get: function() {
return this._fontFamily;
},
set: function(t) {
this._fontFamily = t || "Arial";
},
override: !0
}
}
});
cc.TTFFont = e.exports = r;
}), {
"./CCFont": 37
} ],
48: [ (function(t, e, i) {
var n = cc.Class({
name: "cc.TextAsset",
extends: cc.Asset,
properties: {
text: ""
},
toString: function() {
return this.text;
}
});
e.exports = cc.TextAsset = n;
}), {} ],
49: [ (function(t, e, i) {
var n = t("../event/event-target"), r = t("../renderer/render-engine"), s = t("../renderer");
t("../platform/CCClass");
var o = r.gfx, a = new (t("../platform/id-generater"))("Tex"), c = cc.Enum({
RGB565: o.TEXTURE_FMT_R5_G6_B5,
RGB5A1: o.TEXTURE_FMT_R5_G5_B5_A1,
RGBA4444: o.TEXTURE_FMT_R4_G4_B4_A4,
RGB888: o.TEXTURE_FMT_RGB8,
RGBA8888: o.TEXTURE_FMT_RGBA8,
A8: o.TEXTURE_FMT_A8,
I8: o.TEXTURE_FMT_L8,
AI8: o.TEXTURE_FMT_L8_A8
}), h = cc.Enum({
REPEAT: 10497,
CLAMP_TO_EDGE: 33071,
MIRRORED_REPEAT: 33648
}), l = cc.Enum({
LINEAR: 9729,
NEAREST: 9728
}), u = {
9728: 0,
9729: 1
}, _ = [], f = {
width: void 0,
height: void 0,
minFilter: void 0,
magFilter: void 0,
wrapS: void 0,
wrapT: void 0,
format: void 0,
mipmap: void 0,
images: void 0,
image: void 0,
flipY: void 0,
premultiplyAlpha: void 0
};
function d() {
for (var t in f) f[t] = void 0;
_.length = 0;
f.images = _;
f.flipY = !1;
return f;
}
var m = cc.Class({
name: "cc.Texture2D",
extends: t("../assets/CCAsset"),
mixins: [ n ],
properties: {
_nativeAsset: {
get: function() {
return this._image;
},
set: function(t) {
this.initWithElement(t);
},
override: !0
},
_hasMipmap: !1,
_format: c.RGBA8888,
_premultiplyAlpha: !1,
_flipY: !1,
_minFilter: l.LINEAR,
_magFilter: l.LINEAR,
_wrapS: h.CLAMP_TO_EDGE,
_wrapT: h.CLAMP_TO_EDGE
},
statics: {
PixelFormat: c,
WrapMode: h,
Filter: l,
_FilterIndex: u,
extnames: [ ".png", ".jpg", ".jpeg", ".bmp", ".webp" ]
},
ctor: function() {
this._id = a.getNewId();
this.url = "";
this.loaded = !1;
this.width = 0;
this.height = 0;
this._hashDirty = !0;
this._hash = 0;
this._texture = null;
},
getImpl: function() {
return this._texture;
},
getId: function() {
return this._id;
},
toString: function() {
return this.url || "";
},
update: function(t) {
if (t) {
var e = !1;
void 0 !== t.width && (this.width = t.width);
void 0 !== t.height && (this.height = t.height);
if (void 0 !== t.minFilter) {
this._minFilter = t.minFilter;
t.minFilter = u[t.minFilter];
}
if (void 0 !== t.magFilter) {
this._magFilter = t.magFilter;
t.magFilter = u[t.magFilter];
}
void 0 !== t.wrapS && (this._wrapS = t.wrapS);
void 0 !== t.wrapT && (this._wrapT = t.wrapT);
void 0 !== t.format && (this._format = t.format);
if (void 0 !== t.flipY) {
this._flipY = t.flipY;
e = !0;
}
if (void 0 !== t.premultiplyAlpha) {
this._premultiplyAlpha = t.premultiplyAlpha;
e = !0;
}
void 0 !== t.mipmap && (this._hasMipmap = t.mipmap);
e && this._image && (t.image = this._image);
if (t.images && t.images.length > 0) this._image = t.images[0]; else if (void 0 !== t.image) {
this._image = t.image;
if (!t.images) {
_.length = 0;
t.images = _;
}
t.images.push(t.image);
}
t.images && t.images.length > 0 && this._texture.update(t);
this._hashDirty = !0;
}
},
initWithElement: function(t) {
if (t) {
this._image = t;
if (t.complete || t instanceof HTMLCanvasElement) this.handleLoadedTexture(); else {
var e = this;
t.addEventListener("load", (function() {
e.handleLoadedTexture();
}));
t.addEventListener("error", (function(t) {
cc.warnID(3119, t.message);
}));
}
}
},
initWithData: function(t, e, i, n) {
var r = d();
r.image = t;
r.images = [ r.image ];
r.hasMipmap = this._hasMipmap;
r.premultiplyAlpha = this._premultiplyAlpha;
r.flipY = this._flipY;
r.minFilter = u[this._minFilter];
r.magFilter = u[this._magFilter];
r.wrapS = this._wrapS;
r.wrapT = this._wrapT;
r.format = e;
r.width = i;
r.height = n;
this._texture ? this.update(r) : this._texture = new s.Texture2D(s.device, r);
this.width = i;
this.height = n;
this.loaded = !0;
this.emit("load");
return !0;
},
getHtmlElementObj: function() {
return this._image;
},
destroy: function() {
this._image = null;
this._texture && this._texture.destroy();
this._super();
},
getPixelFormat: function() {
return this._format;
},
hasPremultipliedAlpha: function() {
return this._premultiplyAlpha || !1;
},
hasMipmap: function() {
return this._hasMipmap || !1;
},
handleLoadedTexture: function() {
if (this._image && this._image.width && this._image.height) {
this.width = this._image.width;
this.height = this._image.height;
var t = d();
t.image = this._image;
t.images = [ t.image ];
t.width = this.width;
t.height = this.height;
t.hasMipmap = this._hasMipmap;
t.format = this._format;
t.premultiplyAlpha = this._premultiplyAlpha;
t.flipY = this._flipY;
t.minFilter = u[this._minFilter];
t.magFilter = u[this._magFilter];
t.wrapS = this._wrapS;
t.wrapT = this._wrapT;
this._texture ? this._texture.update(t) : this._texture = new s.Texture2D(s.device, t);
this.loaded = !0;
this.emit("load");
cc.macro.CLEANUP_IMAGE_CACHE && this._image instanceof HTMLImageElement && this._clearImage();
}
},
description: function() {
return "<cc.Texture2D | Name = " + this.url + " | Dimensions = " + this.width + " x " + this.height + ">";
},
releaseTexture: function() {
this._image = null;
this._texture && this._texture.destroy();
},
setWrapMode: function(t, e) {
if (this._wrapS !== t || this._wrapT !== e) {
var i = d();
i.wrapS = t;
i.wrapT = e;
this.update(i);
}
},
setFilters: function(t, e) {
if (this._minFilter !== t || this._magFilter !== e) {
var i = d();
i.minFilter = t;
i.magFilter = e;
this.update(i);
}
},
setFlipY: function(t) {
if (this._flipY !== t) {
var e = d();
e.flipY = t;
this.update(e);
}
},
setPremultiplyAlpha: function(t) {
if (this._premultiplyAlpha !== t) {
var e = d();
e.premultiplyAlpha = t;
this.update(e);
}
},
setMipmap: function(t) {
if (this._hasMipmap !== t) {
var e = d();
e.hasMipmap = t;
this.update(e);
}
},
_serialize: !1,
_deserialize: function(t, e) {
var i = t.split(","), n = i[0];
if (n) {
var r = n.charCodeAt(0) - 48, s = m.extnames[r];
this._setRawAsset(s || n);
var o = e.customEnv, a = o && o.uuid;
if (a) {
this._uuid = a;
var c = this.nativeUrl;
this.url = c;
}
}
if (6 === i.length) {
this._minFilter = parseInt(i[1]);
this._magFilter = parseInt(i[2]);
this._wrapS = parseInt(i[3]);
this._wrapT = parseInt(i[4]);
this._premultiplyAlpha = 49 === i[5].charCodeAt(0);
}
},
_getHash: function() {
if (!this._hashDirty) return this._hash;
var t = this._hasMipmap ? 1 : 0, e = this._premultiplyAlpha ? 1 : 0, i = this._flipY ? 1 : 0, n = this._minFilter === l.LINEAR ? 1 : 2, r = this._magFilter === l.LINEAR ? 1 : 2, s = this._wrapS === h.REPEAT ? 1 : this._wrapS === h.CLAMP_TO_EDGE ? 2 : 3, o = this._wrapT === h.REPEAT ? 1 : this._wrapT === h.CLAMP_TO_EDGE ? 2 : 3, a = this._format;
this._hash = parseInt("" + n + r + a + s + o + t + e + i);
this._hashDirty = !1;
return this._hash;
},
_clearImage: function() {
this._image.src = "";
cc.loader.removeItem(this._image.id);
}
});
cc.Texture2D = e.exports = m;
}), {
"../assets/CCAsset": 33,
"../event/event-target": 102,
"../platform/CCClass": 160,
"../platform/id-generater": 176,
"../renderer": 201,
"../renderer/render-engine": 202
} ],
50: [ (function(t, e, i) {
t("./CCRawAsset");
t("./CCAsset");
t("./CCFont");
t("./CCPrefab");
t("./CCAudioClip");
t("./CCScripts");
t("./CCSceneAsset");
t("./CCSpriteFrame");
t("./CCTexture2D");
t("./CCRenderTexture");
t("./CCTTFFont");
t("./CCSpriteAtlas");
t("./CCBitmapFont");
t("./CCLabelAtlas");
t("./CCTextAsset");
t("./CCJsonAsset");
t("./CCBufferAsset");
}), {
"./CCAsset": 33,
"./CCAudioClip": 34,
"./CCBitmapFont": 35,
"./CCBufferAsset": 36,
"./CCFont": 37,
"./CCJsonAsset": 38,
"./CCLabelAtlas": 39,
"./CCPrefab": 40,
"./CCRawAsset": 41,
"./CCRenderTexture": 42,
"./CCSceneAsset": 43,
"./CCScripts": 44,
"./CCSpriteAtlas": 45,
"./CCSpriteFrame": 46,
"./CCTTFFont": 47,
"./CCTextAsset": 48,
"./CCTexture2D": 49
} ],
51: [ (function(t, e, i) {
t("../CCNode").EventType;
var n = 56, r = 7, s = cc.Enum({
ONCE: 0,
ON_WINDOW_RESIZE: 1,
ALWAYS: 2
});
function o(t) {
return t instanceof cc.Scene ? cc.visibleRect : t._contentSize;
}
function a(t, e, i, n) {
for (var r = t._parent._scale.x, s = t._parent._scale.y, o = 0, a = 0, c = t._parent; ;) {
var h = c._position;
o += h.x;
a += h.y;
if (!(c = c._parent)) {
i.x = i.y = 0;
n.x = n.y = 1;
return;
}
if (c === e) break;
var l = c._scale.x, u = c._scale.y;
o *= l;
a *= u;
r *= l;
s *= u;
}
n.x = 0 !== r ? 1 / r : 1;
n.y = 0 !== s ? 1 / s : 1;
i.x = -o;
i.y = -a;
}
var c = cc.Vec2.ZERO, h = cc.Vec2.ONE;
function l(t, e) {
var i, s, l, u = e._target;
u ? a(t, i = u, s = c, l = h) : i = t._parent;
var _ = o(i), f = i._anchorPoint, d = i instanceof cc.Scene, m = t._position.x, p = t._position.y, v = t._anchorPoint;
if (e._alignFlags & n) {
var y, g, x = _.width;
if (d) {
y = cc.visibleRect.left.x;
g = cc.visibleRect.right.x;
} else g = (y = -f.x * x) + x;
y += e._isAbsLeft ? e._left : e._left * x;
g -= e._isAbsRight ? e._right : e._right * x;
if (u) {
y += s.x;
y *= l.x;
g += s.x;
g *= l.x;
}
var C, A = v.x, b = t._scale.x;
if (b < 0) {
A = 1 - A;
b = -b;
}
if (e.isStretchWidth) {
C = g - y;
0 !== b && (t.width = C / b);
m = y + A * C;
} else {
C = t.width * b;
if (e.isAlignHorizontalCenter) {
var S = e._isAbsHorizontalCenter ? e._horizontalCenter : e._horizontalCenter * x, T = (.5 - f.x) * _.width;
if (u) {
S *= l.x;
T += s.x;
T *= l.x;
}
m = T + (A - .5) * C + S;
} else m = e.isAlignLeft ? y + A * C : g + (A - 1) * C;
}
}
if (e._alignFlags & r) {
var w, E, B = _.height;
if (d) {
E = cc.visibleRect.bottom.y;
w = cc.visibleRect.top.y;
} else w = (E = -f.y * B) + B;
E += e._isAbsBottom ? e._bottom : e._bottom * B;
w -= e._isAbsTop ? e._top : e._top * B;
if (u) {
E += s.y;
E *= l.y;
w += s.y;
w *= l.y;
}
var M, D = v.y, I = t._scale.y;
if (I < 0) {
D = 1 - D;
I = -I;
}
if (e.isStretchHeight) {
M = w - E;
0 !== I && (t.height = M / I);
p = E + D * M;
} else {
M = t.height * I;
if (e.isAlignVerticalCenter) {
var P = e._isAbsVerticalCenter ? e._verticalCenter : e._verticalCenter * B, R = (.5 - f.y) * _.height;
if (u) {
P *= l.y;
R += s.y;
R *= l.y;
}
p = R + (D - .5) * M + P;
} else p = e.isAlignBottom ? E + D * M : w + (D - 1) * M;
}
}
t.setPosition(m, p);
}
function u() {
var t = cc.director.getScene();
if (t) {
f.isAligning = !0;
if (f._nodesOrderDirty) {
_.length = 0;
(function t(e) {
var i = e._widget;
if (i) {
l(e, i);
i.alignMode !== s.ALWAYS ? i.enabled = !1 : _.push(i);
}
for (var n = e._children, r = 0; r < n.length; r++) {
var o = n[r];
o._active && t(o);
}
})(t);
f._nodesOrderDirty = !1;
} else {
var e, i = f._activeWidgetsIterator;
for (i.i = 0; i.i < _.length; ++i.i) l((e = _[i.i]).node, e);
}
f.isAligning = !1;
}
0;
}
var _ = [];
var f = cc._widgetManager = e.exports = {
_AlignFlags: {
TOP: 1,
MID: 2,
BOT: 4,
LEFT: 8,
CENTER: 16,
RIGHT: 32
},
isAligning: !1,
_nodesOrderDirty: !1,
_activeWidgetsIterator: new cc.js.array.MutableForwardIterator(_),
init: function(t) {
t.on(cc.Director.EVENT_AFTER_UPDATE, u);
cc.sys.isMobile ? window.addEventListener("resize", this.onResized.bind(this)) : cc.view.on("canvas-resize", this.onResized, this);
},
add: function(t) {
t.node._widget = t;
this._nodesOrderDirty = !0;
0;
},
remove: function(t) {
t.node._widget = null;
this._activeWidgetsIterator.remove(t);
0;
},
onResized: function() {
var t = cc.director.getScene();
t && this.refreshWidgetOnResized(t);
},
refreshWidgetOnResized: function(t) {
var e = cc.Node.isNode(t) && t.getComponent(cc.Widget);
e && e.alignMode === s.ON_WINDOW_RESIZE && (e.enabled = !0);
for (var i = t._children, n = 0; n < i.length; n++) {
var r = i[n];
this.refreshWidgetOnResized(r);
}
},
updateAlignment: function t(e) {
var i = e._parent;
cc.Node.isNode(i) && t(i);
var n = e._widget || e.getComponent(cc.Widget);
n && i && l(e, n);
},
AlignMode: s
};
0;
}), {
"../CCNode": 29
} ],
52: [ (function(t, e, i) {
var n = t("../utils/affine-transform"), r = t("../renderer/render-engine"), s = t("../renderer/index"), o = t("../renderer/render-flow"), a = t("../CCGame"), c = cc.vmath.mat4, h = cc.vmath.vec2, l = cc.vmath.vec3, u = c.create(), _ = c.create(), f = l.create(), d = [], m = null;
function p() {
if (m) {
var t = m._node, e = cc.visibleRect;
t.z = e.height / 1.1566;
t.x = f.x = e.width / 2;
t.y = f.y = e.height / 2;
f.z = 0;
t.lookAt(f);
}
}
var v = cc.Enum({
COLOR: 1,
DEPTH: 2,
STENCIL: 4
}), y = cc.Class({
name: "cc.Camera",
extends: cc.Component,
ctor: function() {
if (a.renderType !== a.RENDER_TYPE_CANVAS) {
var t = new r.Camera();
t.setStages([ "transparent" ]);
this._fov = 60 * Math.PI / 180;
t.setFov(this._fov);
t.setNear(.1);
t.setFar(4096);
var e = new r.View();
t.view = e;
t.dirty = !0;
this._matrixDirty = !0;
this._inited = !1;
this._camera = t;
} else this._inited = !0;
},
editor: !1,
properties: {
_cullingMask: 4294967295,
_clearFlags: v.DEPTH | v.STENCIL,
_backgroundColor: cc.color(0, 0, 0, 255),
_depth: 0,
_zoomRatio: 1,
_targetTexture: null,
zoomRatio: {
get: function() {
return this._zoomRatio;
},
set: function(t) {
this._zoomRatio = t;
this._matrixDirty = !0;
}
},
cullingMask: {
get: function() {
return this._cullingMask;
},
set: function(t) {
this._cullingMask = t;
this._updateCameraMask();
}
},
clearFlags: {
get: function() {
return this._clearFlags;
},
set: function(t) {
this._clearFlags = t;
this._camera && this._camera.setClearFlags(t);
}
},
backgroundColor: {
get: function() {
return this._backgroundColor;
},
set: function(t) {
this._backgroundColor = t;
this._updateBackgroundColor();
}
},
depth: {
get: function() {
return this._depth;
},
set: function(t) {
this._depth = t;
this._camera && this._camera.setDepth(t);
}
},
targetTexture: {
get: function() {
return this._targetTexture;
},
set: function(t) {
this._targetTexture = t;
this._updateTargetTexture();
}
}
},
statics: {
main: null,
cameras: d,
ClearFlags: v,
findCamera: function(t) {
for (var e = 0, i = d.length; e < i; e++) {
var n = d[e];
if (n.containsNode(t)) return n;
}
return null;
},
_setupDebugCamera: function() {
if (!m && a.renderType !== a.RENDER_TYPE_CANVAS) {
var t = new r.Camera();
m = t;
t.setStages([ "transparent" ]);
t.setFov(60 * Math.PI / 180);
t.setNear(.1);
t.setFar(4096);
var e = new r.View();
t.view = e;
t.dirty = !0;
t._cullingMask = t.view._cullingMask = 1 << cc.Node.BuiltinGroupIndex.DEBUG;
t.setDepth(cc.macro.MAX_ZINDEX);
t.setClearFlags(0);
t.setColor(0, 0, 0, 0);
var i = new cc.Node();
t.setNode(i);
p();
cc.view.on("design-resolution-changed", p);
s.scene.addCamera(t);
}
}
},
_updateCameraMask: function() {
if (this._camera) {
var t = this._cullingMask & ~(1 << cc.Node.BuiltinGroupIndex.DEBUG);
this._camera._cullingMask = t;
this._camera.view._cullingMask = t;
}
},
_updateBackgroundColor: function() {
if (this._camera) {
var t = this._backgroundColor;
this._camera.setColor(t.r / 255, t.g / 255, t.b / 255, t.a / 255);
}
},
_updateTargetTexture: function() {
var t = this._targetTexture;
this._camera && (this._camera._framebuffer = t ? t._framebuffer : null);
},
_onMatrixDirty: function() {
this._matrixDirty = !0;
},
_init: function() {
if (!this._inited) {
this._inited = !0;
if (this._camera) {
this._camera.setNode(this.node);
this._camera.setClearFlags(this._clearFlags);
this._camera.setDepth(this._depth);
this._updateBackgroundColor();
this._updateCameraMask();
this._updateTargetTexture();
}
}
},
onLoad: function() {
this._init();
},
onEnable: function() {
this._matrixDirty = !0;
if (a.renderType !== a.RENDER_TYPE_CANVAS) {
cc.director.on(cc.Director.EVENT_BEFORE_DRAW, this.beforeDraw, this);
s.scene.addCamera(this._camera);
}
d.push(this);
},
onDisable: function() {
if (a.renderType !== a.RENDER_TYPE_CANVAS) {
cc.director.off(cc.Director.EVENT_BEFORE_DRAW, this.beforeDraw, this);
s.scene.removeCamera(this._camera);
}
cc.js.array.remove(d, this);
},
getNodeToCameraTransform: function(t) {
var e = n.identity();
t.getWorldMatrix(_);
if (this.containsNode(t)) {
this.getWorldToCameraMatrix(u);
c.mul(_, _, u);
}
n.fromMat4(e, _);
return e;
},
getCameraToWorldPoint: function(t, e) {
e = e || cc.v2();
this.getCameraToWorldMatrix(u);
h.transformMat4(e, t, u);
return e;
},
getWorldToCameraPoint: function(t, e) {
e = e || cc.v2();
this.getWorldToCameraMatrix(u);
h.transformMat4(e, t, u);
return e;
},
getCameraToWorldMatrix: function(t) {
this.getWorldToCameraMatrix(t);
c.invert(t, t);
return t;
},
getWorldToCameraMatrix: function(t) {
this.node.getWorldRT(u);
var e = this.zoomRatio;
u.m00 *= e;
u.m01 *= e;
u.m04 *= e;
u.m05 *= e;
var i = u.m12, n = u.m13, r = cc.visibleRect.center;
u.m12 = r.x - (u.m00 * i + u.m04 * n);
u.m13 = r.y - (u.m01 * i + u.m05 * n);
t !== u && c.copy(t, u);
return t;
},
containsNode: function(t) {
return t._cullingMask & this.cullingMask;
},
render: function(t) {
if (!(t = t || cc.director.getScene())) return null;
this.node.getWorldMatrix(u);
this.beforeDraw();
o.visit(t);
s._forward.renderCamera(this._camera, s.scene);
},
beforeDraw: function() {
var t = this.node;
if (this._matrixDirty || t._worldMatDirty) {
var e = this._camera, i = 2 * Math.atan(Math.tan(this._fov / 2) / this.zoomRatio);
e.setFov(i);
var n = cc.game.canvas.height / cc.view._scaleY, r = this._targetTexture;
r && (n = r.height);
t._updateWorldMatrix();
f.x = t._worldMatrix.m12;
f.y = t._worldMatrix.m13;
f.z = 0;
t.z = n / (2 * Math.tan(this._fov / 2));
t.lookAt(f);
this._matrixDirty = !1;
e.dirty = !0;
}
}
});
e.exports = cc.Camera = y;
}), {
"../CCGame": 28,
"../renderer/index": 201,
"../renderer/render-engine": 202,
"../renderer/render-flow": 203,
"../utils/affine-transform": 234
} ],
53: [ (function(t, e, i) {
cc.Collider.Box = cc.Class({
properties: {
_offset: cc.v2(0, 0),
_size: cc.size(100, 100),
offset: {
tooltip: !1,
get: function() {
return this._offset;
},
set: function(t) {
this._offset = t;
},
type: cc.Vec2
},
size: {
tooltip: !1,
get: function() {
return this._size;
},
set: function(t) {
this._size.width = t.width < 0 ? 0 : t.width;
this._size.height = t.height < 0 ? 0 : t.height;
},
type: cc.Size
}
},
resetInEditor: !1
});
var n = cc.Class({
name: "cc.BoxCollider",
extends: cc.Collider,
mixins: [ cc.Collider.Box ],
editor: !1
});
cc.BoxCollider = e.exports = n;
}), {} ],
54: [ (function(t, e, i) {
cc.Collider.Circle = cc.Class({
properties: {
_offset: cc.v2(0, 0),
_radius: 50,
offset: {
get: function() {
return this._offset;
},
set: function(t) {
this._offset = t;
},
type: cc.Vec2
},
radius: {
tooltip: !1,
get: function() {
return this._radius;
},
set: function(t) {
this._radius = t < 0 ? 0 : t;
}
}
},
resetInEditor: !1
});
var n = cc.Class({
name: "cc.CircleCollider",
extends: cc.Collider,
mixins: [ cc.Collider.Circle ],
editor: !1
});
cc.CircleCollider = e.exports = n;
}), {} ],
55: [ (function(t, e, i) {
var n = cc.Class({
name: "cc.Collider",
extends: cc.Component,
properties: {
editing: {
default: !1,
serializable: !1,
tooltip: !1
},
tag: {
tooltip: !1,
default: 0,
range: [ 0, 1e7 ],
type: cc.Integer
}
},
onDisable: function() {
cc.director.getCollisionManager().removeCollider(this);
},
onEnable: function() {
cc.director.getCollisionManager().addCollider(this);
}
});
cc.Collider = e.exports = n;
}), {} ],
56: [ (function(t, e, i) {
var n = t("./CCContact"), r = n.CollisionType, s = t("../CCNode").EventType, o = cc.vmath, a = cc.v2();
var c = cc.Class({
mixins: [ cc.EventTarget ],
properties: {
enabled: !1,
enabledDrawBoundingBox: !1
},
ctor: function() {
this._contacts = [];
this._colliders = [];
this._debugDrawer = null;
this._enabledDebugDraw = !1;
cc.director._scheduler && cc.director._scheduler.enableForTarget(this);
},
update: function(t) {
if (this.enabled) {
var e = void 0, i = void 0, n = this._colliders;
for (e = 0, i = n.length; e < i; e++) this.updateCollider(n[e]);
var s = this._contacts, o = [];
for (e = 0, i = s.length; e < i; e++) {
var a = s[e].updateState();
a !== r.None && o.push([ a, s[e] ]);
}
for (e = 0, i = o.length; e < i; e++) {
var c = o[e];
this._doCollide(c[0], c[1]);
}
this.drawColliders();
}
},
_doCollide: function(t, e) {
var i = void 0;
switch (t) {
case r.CollisionEnter:
i = "onCollisionEnter";
break;

case r.CollisionStay:
i = "onCollisionStay";
break;

case r.CollisionExit:
i = "onCollisionExit";
}
var n = e.collider1, s = e.collider2, o = n.node._components, a = s.node._components, c = void 0, h = void 0, l = void 0;
for (c = 0, h = o.length; c < h; c++) (l = o[c])[i] && l[i](s, n);
for (c = 0, h = a.length; c < h; c++) (l = a[c])[i] && l[i](n, s);
},
shouldCollide: function(t, e) {
var i = t.node, n = e.node, r = cc.game.collisionMatrix;
return i !== n && r[i.groupIndex][n.groupIndex];
},
initCollider: function(t) {
if (!t.world) {
var e = t.world = {};
e.aabb = cc.rect();
e.preAabb = cc.rect();
e.matrix = o.mat4.create();
e.radius = 0;
if (t instanceof cc.BoxCollider) {
e.position = null;
e.points = [ cc.v2(), cc.v2(), cc.v2(), cc.v2() ];
} else if (t instanceof cc.PolygonCollider) {
e.position = null;
e.points = t.points.map((function(t) {
return cc.v2(t.x, t.y);
}));
} else if (t instanceof cc.CircleCollider) {
e.position = cc.v2();
e.points = null;
}
}
},
updateCollider: function(t) {
var e = t.offset, i = t.world, n = i.aabb, r = i.matrix;
t.node.getWorldMatrix(r);
var s = i.preAabb;
s.x = n.x;
s.y = n.y;
s.width = n.width;
s.height = n.height;
if (t instanceof cc.BoxCollider) {
var c = t.size;
n.x = e.x - c.width / 2;
n.y = e.y - c.height / 2;
n.width = c.width;
n.height = c.height;
var h = i.points, l = h[0], u = h[1], _ = h[2], f = h[3];
(function(t, e, i, n, r, s) {
var o = t.x, a = t.y, c = t.width, h = t.height, l = e.m00, u = e.m01, _ = e.m04, f = e.m05, d = l * o + _ * a + e.m12, m = u * o + f * a + e.m13, p = l * c, v = u * c, y = _ * h, g = f * h;
n.x = d;
n.y = m;
r.x = p + d;
r.y = v + m;
i.x = y + d;
i.y = g + m;
s.x = p + y + d;
s.y = v + g + m;
})(n, r, l, u, _, f);
var d = Math.min(l.x, u.x, _.x, f.x), m = Math.min(l.y, u.y, _.y, f.y), p = Math.max(l.x, u.x, _.x, f.x), v = Math.max(l.y, u.y, _.y, f.y);
n.x = d;
n.y = m;
n.width = p - d;
n.height = v - m;
} else if (t instanceof cc.CircleCollider) {
o.vec2.transformMat4(a, t.offset, r);
i.position.x = a.x;
i.position.y = a.y;
var y = r.m12, g = r.m13;
r.m12 = r.m13 = 0;
a.x = t.radius;
a.y = 0;
o.vec2.transformMat4(a, a, r);
var x = Math.sqrt(a.x * a.x + a.y * a.y);
i.radius = x;
n.x = i.position.x - x;
n.y = i.position.y - x;
n.width = 2 * x;
n.height = 2 * x;
r.m12 = y;
r.m13 = g;
} else if (t instanceof cc.PolygonCollider) {
var C = t.points, A = i.points;
A.length = C.length;
for (var b = 1e6, S = 1e6, T = -1e6, w = -1e6, E = 0, B = C.length; E < B; E++) {
A[E] || (A[E] = cc.v2());
a.x = C[E].x + e.x;
a.y = C[E].y + e.y;
o.vec2.transformMat4(a, a, r);
var M = a.x, D = a.y;
A[E].x = M;
A[E].y = D;
M > T && (T = M);
M < b && (b = M);
D > w && (w = D);
D < S && (S = D);
}
n.x = b;
n.y = S;
n.width = T - b;
n.height = w - S;
}
},
addCollider: function(t) {
var e = this._colliders;
if (-1 === e.indexOf(t)) {
for (var i = 0, r = e.length; i < r; i++) {
var o = e[i];
if (this.shouldCollide(t, o)) {
var a = new n(t, o);
this._contacts.push(a);
}
}
e.push(t);
this.initCollider(t);
}
t.node.on(s.GROUP_CHANGED, this.onNodeGroupChanged, this);
},
removeCollider: function(t) {
var e = this._colliders, i = e.indexOf(t);
if (i >= 0) {
e.splice(i, 1);
for (var n = this._contacts, o = n.length - 1; o >= 0; o--) {
var a = n[o];
if (a.collider1 === t || a.collider2 === t) {
a.touching && this._doCollide(r.CollisionExit, a);
n.splice(o, 1);
}
}
t.node.off(s.GROUP_CHANGED, this.onNodeGroupChanged, this);
} else cc.errorID(6600);
},
onNodeGroupChanged: function(t) {
for (var e = t.getComponents(cc.Collider), i = 0, n = e.length; i < n; i++) {
this.removeCollider(e[i]);
this.addCollider(e[i]);
}
},
drawColliders: function() {
if (this._enabledDebugDraw) {
this._checkDebugDrawValid();
var t = this._debugDrawer;
t.clear();
for (var e = this._colliders, i = 0, n = e.length; i < n; i++) {
var r = e[i];
t.strokeColor = cc.Color.WHITE;
if (r instanceof cc.BoxCollider || r instanceof cc.PolygonCollider) {
var s = r.world.points;
if (s.length > 0) {
t.moveTo(s[0].x, s[0].y);
for (var o = 1; o < s.length; o++) t.lineTo(s[o].x, s[o].y);
t.close();
t.stroke();
}
} else if (r instanceof cc.CircleCollider) {
t.circle(r.world.position.x, r.world.position.y, r.world.radius);
t.stroke();
}
if (this.enabledDrawBoundingBox) {
var a = r.world.aabb;
t.strokeColor = cc.Color.BLUE;
t.moveTo(a.xMin, a.yMin);
t.lineTo(a.xMin, a.yMax);
t.lineTo(a.xMax, a.yMax);
t.lineTo(a.xMax, a.yMin);
t.close();
t.stroke();
}
}
}
},
_checkDebugDrawValid: function() {
if (!this._debugDrawer || !this._debugDrawer.isValid) {
var t = new cc.Node("COLLISION_MANAGER_DEBUG_DRAW");
t.zIndex = cc.macro.MAX_ZINDEX;
cc.game.addPersistRootNode(t);
this._debugDrawer = t.addComponent(cc.Graphics);
}
}
});
cc.js.getset(c.prototype, "enabledDebugDraw", (function() {
return this._enabledDebugDraw;
}), (function(t) {
if (t && !this._enabledDebugDraw) {
this._checkDebugDrawValid();
this._debugDrawer.node.active = !0;
} else if (!t && this._enabledDebugDraw) {
this._debugDrawer.clear(!0);
this._debugDrawer.node.active = !1;
}
this._enabledDebugDraw = t;
}));
cc.CollisionManager = e.exports = c;
}), {
"../CCNode": 29,
"./CCContact": 57
} ],
57: [ (function(t, e, i) {
var n = t("./CCIntersection"), r = cc.Enum({
None: 0,
CollisionEnter: 1,
CollisionStay: 2,
CollisionExit: 3
});
function s(t, e) {
this.collider1 = t;
this.collider2 = e;
this.touching = !1;
var i = t instanceof cc.BoxCollider || t instanceof cc.PolygonCollider, r = e instanceof cc.BoxCollider || e instanceof cc.PolygonCollider, s = t instanceof cc.CircleCollider, o = e instanceof cc.CircleCollider;
if (i && r) this.testFunc = n.polygonPolygon; else if (s && o) this.testFunc = n.circleCircle; else if (i && o) this.testFunc = n.polygonCircle; else if (s && r) {
this.testFunc = n.polygonCircle;
this.collider1 = e;
this.collider2 = t;
} else cc.errorID(6601, cc.js.getClassName(t), cc.js.getClassName(e));
}
s.prototype.test = function() {
var t = this.collider1.world, e = this.collider2.world;
return !!t.aabb.intersects(e.aabb) && (this.testFunc === n.polygonPolygon ? this.testFunc(t.points, e.points) : this.testFunc === n.circleCircle ? this.testFunc(t, e) : this.testFunc === n.polygonCircle && this.testFunc(t.points, e));
};
s.prototype.updateState = function() {
var t = this.test(), e = r.None;
if (t && !this.touching) {
this.touching = !0;
e = r.CollisionEnter;
} else if (t && this.touching) e = r.CollisionStay; else if (!t && this.touching) {
this.touching = !1;
e = r.CollisionExit;
}
return e;
};
s.CollisionType = r;
e.exports = s;
}), {
"./CCIntersection": 58
} ],
58: [ (function(t, e, i) {
var n = {};
function r(t, e, i, n) {
var r = (n.x - i.x) * (t.y - i.y) - (n.y - i.y) * (t.x - i.x), s = (e.x - t.x) * (t.y - i.y) - (e.y - t.y) * (t.x - i.x), o = (n.y - i.y) * (e.x - t.x) - (n.x - i.x) * (e.y - t.y);
if (0 !== o) {
var a = r / o, c = s / o;
if (0 <= a && a <= 1 && 0 <= c && c <= 1) return !0;
}
return !1;
}
n.lineLine = r;
n.lineRect = function(t, e, i) {
var n = new cc.Vec2(i.x, i.y), s = new cc.Vec2(i.x, i.yMax), o = new cc.Vec2(i.xMax, i.yMax), a = new cc.Vec2(i.xMax, i.y);
return !!(r(t, e, n, s) || r(t, e, s, o) || r(t, e, o, a) || r(t, e, a, n));
};
function s(t, e, i) {
for (var n = i.length, s = 0; s < n; ++s) {
if (r(t, e, i[s], i[(s + 1) % n])) return !0;
}
return !1;
}
n.linePolygon = s;
n.rectRect = function(t, e) {
var i = t.x, n = t.y, r = t.x + t.width, s = t.y + t.height, o = e.x, a = e.y, c = e.x + e.width, h = e.y + e.height;
return i <= c && r >= o && n <= h && s >= a;
};
n.rectPolygon = function(t, e) {
var i, n, r = new cc.Vec2(t.x, t.y), a = new cc.Vec2(t.x, t.yMax), c = new cc.Vec2(t.xMax, t.yMax), h = new cc.Vec2(t.xMax, t.y);
if (s(r, a, e)) return !0;
if (s(a, c, e)) return !0;
if (s(c, h, e)) return !0;
if (s(h, r, e)) return !0;
for (i = 0, n = e.length; i < n; ++i) if (o(e[i], t)) return !0;
return !!(o(r, e) || o(a, e) || o(c, e) || o(h, e));
};
n.polygonPolygon = function(t, e) {
var i, n;
for (i = 0, n = t.length; i < n; ++i) if (s(t[i], t[(i + 1) % n], e)) return !0;
for (i = 0, n = e.length; i < n; ++i) if (o(e[i], t)) return !0;
for (i = 0, n = t.length; i < n; ++i) if (o(t[i], e)) return !0;
return !1;
};
n.circleCircle = function(t, e) {
return t.position.sub(e.position).mag() < t.radius + e.radius;
};
n.polygonCircle = function(t, e) {
var i = e.position;
if (o(i, t)) return !0;
for (var n = 0, r = t.length; n < r; n++) if (a(i, 0 === n ? t[t.length - 1] : t[n - 1], t[n], !0) < e.radius) return !0;
return !1;
};
function o(t, e) {
for (var i = !1, n = t.x, r = t.y, s = e.length, o = 0, a = s - 1; o < s; a = o++) {
var c = e[o].x, h = e[o].y, l = e[a].x, u = e[a].y;
h > r != u > r && n < (l - c) * (r - h) / (u - h) + c && (i = !i);
}
return i;
}
n.pointInPolygon = o;
function a(t, e, i, n) {
var r, s = i.x - e.x, o = i.y - e.y, a = s * s + o * o, c = ((t.x - e.x) * s + (t.y - e.y) * o) / a;
r = n ? a ? c < 0 ? e : c > 1 ? i : cc.v2(e.x + c * s, e.y + c * o) : e : cc.v2(e.x + c * s, e.y + c * o);
s = t.x - r.x;
o = t.y - r.y;
return Math.sqrt(s * s + o * o);
}
n.pointLineDistance = a;
cc.Intersection = e.exports = n;
}), {} ],
59: [ (function(t, e, i) {
cc.Collider.Polygon = cc.Class({
properties: {
threshold: {
default: 1,
serializable: !1,
visible: !1
},
_offset: cc.v2(0, 0),
offset: {
get: function() {
return this._offset;
},
set: function(t) {
this._offset = t;
},
type: cc.Vec2
},
points: {
tooltip: !1,
default: function() {
return [ cc.v2(-50, -50), cc.v2(50, -50), cc.v2(50, 50), cc.v2(-50, 50) ];
},
type: [ cc.Vec2 ]
}
},
resetPointsByContour: !1
});
var n = cc.Class({
name: "cc.PolygonCollider",
extends: cc.Collider,
mixins: [ cc.Collider.Polygon ],
editor: !1
});
cc.PolygonCollider = e.exports = n;
}), {} ],
60: [ (function(t, e, i) {
t("./CCCollisionManager");
t("./CCCollider");
t("./CCBoxCollider");
t("./CCCircleCollider");
t("./CCPolygonCollider");
}), {
"./CCBoxCollider": 53,
"./CCCircleCollider": 54,
"./CCCollider": 55,
"./CCCollisionManager": 56,
"./CCPolygonCollider": 59
} ],
61: [ (function(i, n, r) {
i("./platform/CCClass");
var s = i("./platform/CCObject").Flags, o = i("./platform/js").array, a = s.IsStartCalled, c = s.IsOnEnableCalled, h = (s.IsEditorOnEnableCalled, 
"c.start();c._objFlags|=" + a), l = "c.update(dt)", u = "c.lateUpdate(dt)";
function _(t, e) {
for (var i = e.constructor._executionOrder, n = e._id, r = 0, s = t.length - 1, o = s >>> 1; r <= s; o = r + s >>> 1) {
var a = t[o], c = a.constructor._executionOrder;
if (c > i) s = o - 1; else if (c < i) r = o + 1; else {
var h = a._id;
if (h > n) s = o - 1; else {
if (!(h < n)) return o;
r = o + 1;
}
}
}
return ~r;
}
function f(t, e) {
for (var i = t.array, n = t.i + 1; n < i.length; ) {
var r = i[n];
if (r._enabled && r.node._activeInHierarchy) ++n; else {
t.removeAt(n);
e && (r._objFlags &= ~e);
}
}
}
var d = cc.Class({
__ctor__: function(t) {
var e = o.MutableForwardIterator;
this._zero = new e([]);
this._neg = new e([]);
this._pos = new e([]);
0;
this._invoke = t;
},
statics: {
stableRemoveInactive: f
},
add: null,
remove: null,
invoke: null
});
function m(t, e) {
return t.constructor._executionOrder - e.constructor._executionOrder;
}
var p = cc.Class({
extends: d,
add: function(t) {
var e = t.constructor._executionOrder;
(0 === e ? this._zero : e < 0 ? this._neg : this._pos).array.push(t);
},
remove: function(t) {
var e = t.constructor._executionOrder;
(0 === e ? this._zero : e < 0 ? this._neg : this._pos).fastRemove(t);
},
cancelInactive: function(t) {
f(this._zero, t);
f(this._neg, t);
f(this._pos, t);
},
invoke: function() {
var t = this._neg;
if (t.array.length > 0) {
t.array.sort(m);
this._invoke(t);
t.array.length = 0;
}
this._invoke(this._zero);
this._zero.array.length = 0;
var e = this._pos;
if (e.array.length > 0) {
e.array.sort(m);
this._invoke(e);
e.array.length = 0;
}
}
}), v = cc.Class({
extends: d,
add: function(t) {
var e = t.constructor._executionOrder;
if (0 === e) this._zero.array.push(t); else {
var i = e < 0 ? this._neg.array : this._pos.array, n = _(i, t);
n < 0 && i.splice(~n, 0, t);
}
},
remove: function(t) {
var e = t.constructor._executionOrder;
if (0 === e) this._zero.fastRemove(t); else {
var i = e < 0 ? this._neg : this._pos, n = _(i.array, t);
n >= 0 && i.removeAt(n);
}
},
invoke: function(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 y(i, n) {
if ("function" === ("object" === (e = typeof i) ? t(i) : e)) return n ? function(t, e) {
var n = t.array;
for (t.i = 0; t.i < n.length; ++t.i) {
var r = n[t.i];
i(r, e);
}
} : function(t) {
var e = t.array;
for (t.i = 0; t.i < e.length; ++t.i) {
var n = e[t.i];
i(n);
}
};
var r = "var a=it.array;for(it.i=0;it.i<a.length;++it.i){var c=a[it.i];" + i + "}";
return n ? Function("it", "dt", r) : Function("it", r);
}
function g() {
this.startInvoker = new p(y(h));
this.updateInvoker = new v(y(l, !0));
this.lateUpdateInvoker = new v(y(u, !0));
this.scheduleInNextFrame = [];
this._updating = !1;
}
var x = cc.Class({
ctor: g,
unscheduleAll: g,
statics: {
LifeCycleInvoker: d,
OneOffInvoker: p,
createInvokeImpl: y,
invokeOnEnable: function(t) {
var e = cc.director._compScheduler, i = t.array;
for (t.i = 0; t.i < i.length; ++t.i) {
var n = i[t.i];
if (n._enabled) {
n.onEnable();
!n.node._activeInHierarchy || e._onEnabled(n);
}
}
}
},
_onEnabled: function(t) {
cc.director.getScheduler().resumeTarget(t);
t._objFlags |= c;
this._updating ? this.scheduleInNextFrame.push(t) : this._scheduleImmediate(t);
},
_onDisabled: function(t) {
cc.director.getScheduler().pauseTarget(t);
t._objFlags &= ~c;
var e = this.scheduleInNextFrame.indexOf(t);
if (e >= 0) o.fastRemoveAt(this.scheduleInNextFrame, e); else {
!t.start || t._objFlags & a || this.startInvoker.remove(t);
t.update && this.updateInvoker.remove(t);
t.lateUpdate && this.lateUpdateInvoker.remove(t);
}
},
enableComp: function(t, e) {
if (!(t._objFlags & c)) {
if (t.onEnable) {
if (e) {
e.add(t);
return;
}
t.onEnable();
if (!t.node._activeInHierarchy) return;
}
this._onEnabled(t);
}
},
disableComp: function(t) {
if (t._objFlags & c) {
t.onDisable && t.onDisable();
this._onDisabled(t);
}
},
_scheduleImmediate: function(t) {
!t.start || t._objFlags & a || this.startInvoker.add(t);
t.update && this.updateInvoker.add(t);
t.lateUpdate && this.lateUpdateInvoker.add(t);
},
_deferredSchedule: function() {
for (var t = this.scheduleInNextFrame, e = 0, i = t.length; e < i; e++) {
var n = t[e];
this._scheduleImmediate(n);
}
t.length = 0;
},
startPhase: function() {
this._updating = !0;
this.scheduleInNextFrame.length > 0 && this._deferredSchedule();
this.startInvoker.invoke();
},
updatePhase: function(t) {
this.updateInvoker.invoke(t);
},
lateUpdatePhase: function(t) {
this.lateUpdateInvoker.invoke(t);
this._updating = !1;
}
});
n.exports = x;
}), {
"./platform/CCClass": 160,
"./platform/CCObject": 166,
"./platform/js": 180,
"./utils/misc": 242
} ],
62: [ (function(t, e, i) {
var n = t("../../animation/animation-animator"), r = t("../../animation/animation-clip"), s = t("../event/event-target"), o = t("../platform/js");
function a(t, e) {
return t === e || t && e && (t.name === e.name || t._uuid === e._uuid);
}
var c = cc.Enum({
PLAY: "play",
STOP: "stop",
PAUSE: "pause",
RESUME: "resume",
LASTFRAME: "lastframe",
FINISHED: "finished"
}), h = cc.Class({
name: "cc.Animation",
extends: t("./CCComponent"),
mixins: [ s ],
editor: !1,
statics: {
EventType: c
},
ctor: function() {
cc.EventTarget.call(this);
this._animator = null;
this._nameToState = o.createMap(!0);
this._didInit = !1;
this._currentClip = null;
},
properties: {
_defaultClip: {
default: null,
type: r
},
defaultClip: {
type: r,
get: function() {
return this._defaultClip;
},
set: function(t) {},
tooltip: !1
},
currentClip: {
get: function() {
return this._currentClip;
},
set: function(t) {
this._currentClip = t;
},
type: r,
visible: !1
},
_clips: {
default: [],
type: [ r ],
tooltip: !1,
visible: !0
},
playOnLoad: {
default: !1,
tooltip: !1
}
},
start: function() {
if (this.playOnLoad && this._defaultClip) {
if (!(this._animator && this._animator.isPlaying)) {
var t = this.getAnimationState(this._defaultClip.name);
this._animator.playState(t);
}
}
},
onEnable: function() {
this._animator && this._animator.resume();
},
onDisable: function() {
this._animator && this._animator.pause();
},
onDestroy: function() {
this.stop();
},
getClips: function() {
return this._clips;
},
play: function(t, e) {
var i = this.playAdditive(t, e);
this._animator.stopStatesExcept(i);
return i;
},
playAdditive: function(t, e) {
this._init();
var i = this.getAnimationState(t || this._defaultClip && this._defaultClip.name);
if (i) {
this.enabled = !0;
var n = this._animator;
if (n.isPlaying && i.isPlaying) if (i.isPaused) n.resumeState(i); else {
n.stopState(i);
n.playState(i, e);
} else n.playState(i, e);
this.enabledInHierarchy || n.pause();
this.currentClip = i.clip;
}
return i;
},
stop: function(t) {
if (this._didInit) if (t) {
var e = this._nameToState[t];
e && this._animator.stopState(e);
} else this._animator.stop();
},
pause: function(t) {
if (this._didInit) if (t) {
var e = this._nameToState[t];
e && this._animator.pauseState(e);
} else this.enabled = !1;
},
resume: function(t) {
if (this._didInit) if (t) {
var e = this._nameToState[t];
e && this._animator.resumeState(e);
} else this.enabled = !0;
},
setCurrentTime: function(t, e) {
this._init();
if (e) {
var i = this._nameToState[e];
i && this._animator.setStateTime(i, t);
} else this._animator.setStateTime(t);
},
getAnimationState: function(t) {
this._init();
var e = this._nameToState[t];
0;
e && !e.curveLoaded && this._animator._reloadClip(e);
return e || null;
},
addClip: function(t, e) {
if (t) {
this._init();
cc.js.array.contains(this._clips, t) || this._clips.push(t);
e = e || t.name;
var i = this._nameToState[e];
if (i) {
if (i.clip === t) return i;
var n = this._clips.indexOf(i.clip);
-1 !== n && this._clips.splice(n, 1);
}
var r = new cc.AnimationState(t, e);
this._nameToState[e] = r;
return r;
}
cc.warnID(3900);
},
removeClip: function(t, e) {
if (t) {
this._init();
var i = void 0;
for (var n in this._nameToState) {
if ((i = this._nameToState[n]).clip === t) break;
}
if (t === this._defaultClip) {
if (!e) {
cc.warnID(3902);
return;
}
this._defaultClip = null;
}
if (i && i.isPlaying) {
if (!e) {
cc.warnID(3903);
return;
}
this.stop(i.name);
}
this._clips = this._clips.filter((function(e) {
return e !== t;
}));
i && delete this._nameToState[i.name];
} else cc.warnID(3901);
},
sample: function(t) {
this._init();
if (t) {
var e = this._nameToState[t];
e && e.sample();
} else this._animator.sample();
},
on: function(t, e, i, n) {
this._init();
var r = this._EventTargetOn(t, e, i, n);
if ("lastframe" === t) for (var s = this._animator._anims.array, o = 0; o < s.length; ++o) {
s[o]._lastframeEventOn = !0;
}
return r;
},
off: function(t, e, i, n) {
this._init();
if ("lastframe" === t) {
var r = this._nameToState;
for (var s in r) {
r[s]._lastframeEventOn = !1;
}
}
this._EventTargetOff(t, e, i, n);
},
_init: function() {
if (!this._didInit) {
this._didInit = !0;
this._animator = new n(this.node, this);
this._createStates();
}
},
_createStates: function() {
this._nameToState = o.createMap(!0);
for (var t = null, e = !1, i = 0; i < this._clips.length; ++i) {
var n = this._clips[i];
if (n) {
t = new cc.AnimationState(n);
0;
this._nameToState[t.name] = t;
a(this._defaultClip, n) && (e = t);
}
}
if (this._defaultClip && !e) {
t = new cc.AnimationState(this._defaultClip);
0;
this._nameToState[t.name] = t;
}
}
});
h.prototype._EventTargetOn = s.prototype.on;
h.prototype._EventTargetOff = s.prototype.off;
cc.Animation = e.exports = h;
}), {
"../../animation/animation-animator": 9,
"../../animation/animation-clip": 10,
"../event/event-target": 102,
"../platform/js": 180,
"./CCComponent": 67
} ],
63: [ (function(i, n, r) {
var s = i("../utils/misc"), o = i("./CCComponent"), a = i("../assets/CCAudioClip"), c = cc.Class({
name: "cc.AudioSource",
extends: o,
editor: !1,
ctor: function() {
this.audio = new cc.Audio();
},
properties: {
_clip: {
default: null,
type: a
},
_volume: 1,
_mute: !1,
_loop: !1,
_pausedFlag: {
default: !1,
serializable: !1
},
isPlaying: {
get: function() {
return this.audio.getState() === cc.Audio.State.PLAYING;
},
visible: !1
},
clip: {
get: function() {
return this._clip;
},
set: function(i) {
var n = this;
if ("string" === ("object" === (e = typeof i) ? t(i) : e)) {
var r = (function() {
cc.warnID(8401, "cc.AudioSource", "cc.AudioClip", "AudioClip", "cc.AudioClip", "audio");
var t = n;
a._loadByUrl(i, (function(e, i) {
i && (t.clip = i);
}));
return {
v: void 0
};
})();
if ("object" === ("object" === (e = typeof r) ? t(r) : e)) return r.v;
}
if (i !== this._clip) {
this._clip = i;
this.audio.stop();
this.preload && (this.audio.src = this._clip);
}
},
type: a,
tooltip: !1,
animatable: !1
},
volume: {
get: function() {
return this._volume;
},
set: function(t) {
t = s.clamp01(t);
this._volume = t;
this._mute || this.audio.setVolume(t);
return t;
},
tooltip: !1
},
mute: {
get: function() {
return this._mute;
},
set: function(t) {
this._mute = t;
this.audio.setVolume(t ? 0 : this._volume);
return t;
},
animatable: !1,
tooltip: !1
},
loop: {
get: function() {
return this._loop;
},
set: function(t) {
this._loop = t;
this.audio.setLoop(t);
return t;
},
animatable: !1,
tooltip: !1
},
playOnLoad: {
default: !1,
tooltip: !1,
animatable: !1
},
preload: {
default: !1,
animatable: !1
}
},
_ensureDataLoaded: function() {
this.audio.src !== this._clip && (this.audio.src = this._clip);
},
_pausedCallback: function() {
if (this.audio.getState() === cc.Audio.State.PLAYING) {
this.audio.pause();
this._pausedFlag = !0;
}
},
_restoreCallback: function() {
this._pausedFlag && this.audio.resume();
this._pausedFlag = !1;
},
onLoad: function() {
this.audio.setVolume(this._mute ? 0 : this._volume);
this.audio.setLoop(this._loop);
},
onEnable: function() {
this.preload && (this.audio.src = this._clip);
this.playOnLoad && this.play();
cc.game.on(cc.game.EVENT_HIDE, this._pausedCallback, this);
cc.game.on(cc.game.EVENT_SHOW, this._restoreCallback, this);
},
onDisable: function() {
this.stop();
cc.game.off(cc.game.EVENT_HIDE, this._pausedCallback, this);
cc.game.off(cc.game.EVENT_SHOW, this._restoreCallback, this);
},
onDestroy: function() {
this.stop();
this.audio.destroy();
cc.audioEngine.uncache(this._clip);
},
play: function() {
if (this._clip) {
var t = this.audio;
this._clip.loaded && t.stop();
this._ensureDataLoaded();
t.setCurrentTime(0);
t.play();
}
},
stop: function() {
this.audio.stop();
},
pause: function() {
this.audio.pause();
},
resume: function() {
this._ensureDataLoaded();
this.audio.resume();
},
rewind: function() {
this.audio.setCurrentTime(0);
},
getCurrentTime: function() {
return this.audio.getCurrentTime();
},
setCurrentTime: function(t) {
this.audio.setCurrentTime(t);
return t;
},
getDuration: function() {
return this.audio.getDuration();
}
});
cc.AudioSource = n.exports = c;
}), {
"../assets/CCAudioClip": 34,
"../utils/misc": 242,
"./CCComponent": 67
} ],
64: [ (function(t, e, i) {
var n = [ "touchstart", "touchmove", "touchend", "mousedown", "mousemove", "mouseup", "mouseenter", "mouseleave", "mousewheel" ];
function r(t) {
t.stopPropagation();
}
var s = cc.Class({
name: "cc.BlockInputEvents",
extends: t("./CCComponent"),
editor: {
menu: "i18n:MAIN_MENU.component.ui/Block Input Events",
inspector: "packages://inspector/inspectors/comps/block-input-events.js",
help: "i18n:COMPONENT.help_url.block_input_events"
},
onEnable: function() {
for (var t = 0; t < n.length; t++) this.node.on(n[t], r, this);
},
onDisable: function() {
for (var t = 0; t < n.length; t++) this.node.off(n[t], r, this);
}
});
cc.BlockInputEvents = e.exports = s;
}), {
"./CCComponent": 67
} ],
65: [ (function(t, e, i) {
var n = t("./CCComponent"), r = cc.Enum({
NONE: 0,
COLOR: 1,
SPRITE: 2,
SCALE: 3
}), s = cc.Enum({
NORMAL: 0,
HOVER: 1,
PRESSED: 2,
DISABLED: 3
}), o = cc.Class({
name: "cc.Button",
extends: n,
ctor: function() {
this._pressed = !1;
this._hovered = !1;
this._fromColor = null;
this._toColor = null;
this._time = 0;
this._transitionFinished = !0;
this._fromScale = cc.Vec2.ZERO;
this._toScale = cc.Vec2.ZERO;
this._originalScale = null;
this._sprite = null;
},
editor: !1,
properties: {
interactable: {
default: !0,
tooltip: !1,
notify: function() {
this._updateState();
this.interactable || this._resetState();
},
animatable: !1
},
_resizeToTarget: {
animatable: !1,
set: function(t) {
t && this._resizeNodeToTargetNode();
}
},
enableAutoGrayEffect: {
default: !1,
tooltip: !1,
notify: function() {
this._updateDisabledState();
}
},
transition: {
default: r.NONE,
tooltip: !1,
type: r,
animatable: !1,
notify: function(t) {
this._updateTransition(t);
},
formerlySerializedAs: "transition"
},
normalColor: {
default: cc.color(214, 214, 214),
displayName: "Normal",
tooltip: !1,
notify: function() {
this.transition === r.Color && this._getButtonState() === s.NORMAL && (this._getTarget().opacity = this.normalColor.a);
this._updateState();
}
},
pressedColor: {
default: cc.color(211, 211, 211),
displayName: "Pressed",
tooltip: !1,
notify: function() {
this.transition === r.Color && this._getButtonState() === s.PRESSED && (this._getTarget().opacity = this.pressedColor.a);
this._updateState();
},
formerlySerializedAs: "pressedColor"
},
hoverColor: {
default: cc.Color.WHITE,
displayName: "Hover",
tooltip: !1,
notify: function() {
this.transition === r.Color && this._getButtonState() === s.HOVER && (this._getTarget().opacity = this.hoverColor.a);
this._updateState();
},
formerlySerializedAs: "hoverColor"
},
disabledColor: {
default: cc.color(124, 124, 124),
displayName: "Disabled",
tooltip: !1,
notify: function() {
this.transition === r.Color && this._getButtonState() === s.DISABLED && (this._getTarget().opacity = this.disabledColor.a);
this._updateState();
}
},
duration: {
default: .1,
range: [ 0, 10 ],
tooltip: !1
},
zoomScale: {
default: 1.2,
tooltip: !1
},
normalSprite: {
default: null,
type: cc.SpriteFrame,
displayName: "Normal",
tooltip: !1,
notify: function() {
this._updateState();
}
},
pressedSprite: {
default: null,
type: cc.SpriteFrame,
displayName: "Pressed",
tooltip: !1,
formerlySerializedAs: "pressedSprite",
notify: function() {
this._updateState();
}
},
hoverSprite: {
default: null,
type: cc.SpriteFrame,
displayName: "Hover",
tooltip: !1,
formerlySerializedAs: "hoverSprite",
notify: function() {
this._updateState();
}
},
disabledSprite: {
default: null,
type: cc.SpriteFrame,
displayName: "Disabled",
tooltip: !1,
notify: function() {
this._updateState();
}
},
target: {
default: null,
type: cc.Node,
tooltip: !1,
notify: function(t) {
this._applyTarget();
this.target !== t && this._unregisterTargetEvent(t);
}
},
clickEvents: {
default: [],
type: cc.Component.EventHandler,
tooltip: !1
}
},
statics: {
Transition: r
},
__preload: function() {
this._applyTarget();
this._updateState();
},
_resetState: function() {
this._pressed = !1;
this._hovered = !1;
var t = this._getTarget(), e = this.transition, i = this._originalScale;
e === r.COLOR && this.interactable ? this._setTargetColor(this.normalColor) : e === r.SCALE && i && t.setScale(i.x, i.y);
this._transitionFinished = !0;
},
onEnable: function() {
this.normalSprite && this.normalSprite.ensureLoadTexture();
this.hoverSprite && this.hoverSprite.ensureLoadTexture();
this.pressedSprite && this.pressedSprite.ensureLoadTexture();
this.disabledSprite && this.disabledSprite.ensureLoadTexture();
this._registerNodeEvent();
},
onDisable: function() {
this._resetState();
this._unregisterNodeEvent();
},
_getTarget: function() {
return this.target ? this.target : this.node;
},
_onTargetSpriteFrameChanged: function(t) {
this.transition === r.SPRITE && this._setCurrentStateSprite(t.spriteFrame);
},
_onTargetColorChanged: function(t) {
this.transition === r.COLOR && this._setCurrentStateColor(t);
},
_onTargetScaleChanged: function() {
var t = this._getTarget();
if (this._originalScale && (this.transition !== r.SCALE || this._transitionFinished)) {
this._originalScale.x = t.scaleX;
this._originalScale.y = t.scaleY;
}
},
_setTargetColor: function(t) {
var e = this._getTarget();
e.color = t;
e.opacity = t.a;
},
_getStateColor: function(t) {
switch (t) {
case s.NORMAL:
return this.normalColor;

case s.HOVER:
return this.hoverColor;

case s.PRESSED:
return this.pressedColor;

case s.DISABLED:
return this.disabledColor;
}
},
_getStateSprite: function(t) {
switch (t) {
case s.NORMAL:
return this.normalSprite;

case s.HOVER:
return this.hoverSprite;

case s.PRESSED:
return this.pressedSprite;

case s.DISABLED:
return this.disabledSprite;
}
},
_setCurrentStateColor: function(t) {
switch (this._getButtonState()) {
case s.NORMAL:
this.normalColor = t;
break;

case s.HOVER:
this.hoverColor = t;
break;

case s.PRESSED:
this.pressedColor = t;
break;

case s.DISABLED:
this.disabledColor = t;
}
},
_setCurrentStateSprite: function(t) {
switch (this._getButtonState()) {
case s.NORMAL:
this.normalSprite = t;
break;

case s.HOVER:
this.hoverSprite = t;
break;

case s.PRESSED:
this.pressedSprite = t;
break;

case s.DISABLED:
this.disabledSprite = t;
}
},
update: function(t) {
var e = this._getTarget();
if (!this._transitionFinished && (this.transition === r.COLOR || this.transition === r.SCALE)) {
this.time += t;
var i = 1;
this.duration > 0 && (i = this.time / this.duration);
i >= 1 && (i = 1);
if (this.transition === r.COLOR) {
var n = this._fromColor.lerp(this._toColor, i);
this._setTargetColor(n);
} else this.transition === r.SCALE && this._originalScale && (e.scale = this._fromScale.lerp(this._toScale, i));
1 === i && (this._transitionFinished = !0);
}
},
_registerNodeEvent: function() {
this.node.on(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this);
this.node.on(cc.Node.EventType.TOUCH_MOVE, this._onTouchMove, this);
this.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this);
this.node.on(cc.Node.EventType.TOUCH_CANCEL, this._onTouchCancel, this);
this.node.on(cc.Node.EventType.MOUSE_ENTER, this._onMouseMoveIn, this);
this.node.on(cc.Node.EventType.MOUSE_LEAVE, this._onMouseMoveOut, this);
},
_unregisterNodeEvent: function() {
this.node.off(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this);
this.node.off(cc.Node.EventType.TOUCH_MOVE, this._onTouchMove, this);
this.node.off(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this);
this.node.off(cc.Node.EventType.TOUCH_CANCEL, this._onTouchCancel, this);
this.node.off(cc.Node.EventType.MOUSE_ENTER, this._onMouseMoveIn, this);
this.node.off(cc.Node.EventType.MOUSE_LEAVE, this._onMouseMoveOut, this);
},
_registerTargetEvent: function(t) {
0;
t.on(cc.Node.EventType.SCALE_CHANGED, this._onTargetScaleChanged, this);
},
_unregisterTargetEvent: function(t) {
0;
t.off(cc.Node.EventType.SCALE_CHANGED, this._onTargetScaleChanged, this);
},
_getTargetSprite: function(t) {
var e = null;
t && (e = t.getComponent(cc.Sprite));
return e;
},
_applyTarget: function() {
var t = this._getTarget();
this._sprite = this._getTargetSprite(t);
this._originalScale || (this._originalScale = cc.Vec2.ZERO);
this._originalScale.x = t.scaleX;
this._originalScale.y = t.scaleY;
this._registerTargetEvent(t);
},
_onTouchBegan: function(t) {
if (this.interactable && this.enabledInHierarchy) {
this._pressed = !0;
this._updateState();
t.stopPropagation();
}
},
_onTouchMove: function(t) {
if (this.interactable && this.enabledInHierarchy && this._pressed) {
var e = t.touch, i = this.node._hitTest(e.getLocation()), n = this._getTarget(), o = this._originalScale;
if (this.transition === r.SCALE && o) if (i) {
this._fromScale.x = o.x;
this._fromScale.y = o.y;
this._toScale.x = o.x * this.zoomScale;
this._toScale.y = o.y * this.zoomScale;
this._transitionFinished = !1;
} else {
this.time = 0;
this._transitionFinished = !0;
n.setScale(o.x, o.y);
} else {
var a = void 0;
a = i ? s.PRESSED : s.NORMAL;
this._applyTransition(a);
}
t.stopPropagation();
}
},
_onTouchEnded: function(t) {
if (this.interactable && this.enabledInHierarchy) {
if (this._pressed) {
cc.Component.EventHandler.emitEvents(this.clickEvents, t);
this.node.emit("click", this);
}
this._pressed = !1;
this._updateState();
t.stopPropagation();
}
},
_onTouchCancel: function() {
if (this.interactable && this.enabledInHierarchy) {
this._pressed = !1;
this._updateState();
}
},
_onMouseMoveIn: function() {
if (!this._pressed && this.interactable && this.enabledInHierarchy && (this.transition !== r.SPRITE || this.hoverSprite) && !this._hovered) {
this._hovered = !0;
this._updateState();
}
},
_onMouseMoveOut: function() {
if (this._hovered) {
this._hovered = !1;
this._updateState();
}
},
_updateState: function() {
var t = this._getButtonState();
this._applyTransition(t);
this._updateDisabledState();
},
_getButtonState: function() {
return this.interactable ? this._pressed ? s.PRESSED : this._hovered ? s.HOVER : s.NORMAL : s.DISABLED;
},
_updateColorTransitionImmediately: function(t) {
var e = this._getStateColor(t);
this._setTargetColor(e);
},
_updateColorTransition: function(t) {
if (t === s.DISABLED) this._updateColorTransitionImmediately(t); else {
var e = this._getTarget(), i = this._getStateColor(t);
this._fromColor = e.color.clone();
this._toColor = i;
this.time = 0;
this._transitionFinished = !1;
}
},
_updateSpriteTransition: function(t) {
var e = this._getStateSprite(t);
this._sprite && e && (this._sprite.spriteFrame = e);
},
_updateScaleTransition: function(t) {
t === s.PRESSED ? this._zoomUp() : this._zoomBack();
},
_zoomUp: function() {
if (this._originalScale) {
this._fromScale.x = this._originalScale.x;
this._fromScale.y = this._originalScale.y;
this._toScale.x = this._originalScale.x * this.zoomScale;
this._toScale.y = this._originalScale.y * this.zoomScale;
this.time = 0;
this._transitionFinished = !1;
}
},
_zoomBack: function() {
if (this._originalScale) {
var t = this._getTarget();
this._fromScale.x = t.scaleX;
this._fromScale.y = t.scaleY;
this._toScale.x = this._originalScale.x;
this._toScale.y = this._originalScale.y;
this.time = 0;
this._transitionFinished = !1;
}
},
_updateTransition: function(t) {
t === r.COLOR ? this._updateColorTransitionImmediately(s.NORMAL) : t === r.SPRITE && this._updateSpriteTransition(s.NORMAL);
this._updateState();
},
_applyTransition: function(t) {
var e = this.transition;
e === r.COLOR ? this._updateColorTransition(t) : e === r.SPRITE ? this._updateSpriteTransition(t) : e === r.SCALE && this._updateScaleTransition(t);
},
_resizeNodeToTargetNode: !1,
_updateDisabledState: function() {
if (this._sprite) {
if (this.enableAutoGrayEffect && !(this.transition === r.SPRITE && this.disabledSprite || this.interactable)) {
this._sprite.setState(cc.Sprite.State.GRAY);
return;
}
this._sprite.setState(cc.Sprite.State.NORMAL);
}
}
});
cc.Button = e.exports = o;
}), {
"./CCComponent": 67
} ],
66: [ (function(t, e, i) {
var n = t("../camera/CCCamera"), r = t("./CCComponent"), s = cc.Class({
name: "cc.Canvas",
extends: r,
editor: !1,
resetInEditor: !1,
statics: {
instance: null
},
properties: {
_designResolution: cc.size(960, 640),
designResolution: {
get: function() {
return cc.size(this._designResolution);
},
set: function(t) {
this._designResolution.width = t.width;
this._designResolution.height = t.height;
this.applySettings();
this.alignWithScreen();
},
tooltip: !1
},
_fitWidth: !1,
_fitHeight: !0,
fitHeight: {
get: function() {
return this._fitHeight;
},
set: function(t) {
if (this._fitHeight !== t) {
this._fitHeight = t;
this.applySettings();
this.alignWithScreen();
}
},
tooltip: !1
},
fitWidth: {
get: function() {
return this._fitWidth;
},
set: function(t) {
if (this._fitWidth !== t) {
this._fitWidth = t;
this.applySettings();
this.alignWithScreen();
}
},
tooltip: !1
}
},
ctor: function() {
this._thisOnResized = this.alignWithScreen.bind(this);
},
__preload: function() {
if (s.instance) return cc.errorID(6700, this.node.name, s.instance.node.name);
s.instance = this;
cc.sys.isMobile ? window.addEventListener("resize", this._thisOnResized) : cc.view.on("canvas-resize", this._thisOnResized);
this.applySettings();
this.alignWithScreen();
var t = cc.find("Main Camera", this.node);
if (!t) {
(t = new cc.Node("Main Camera")).parent = this.node;
t.setSiblingIndex(0);
}
var e = t.getComponent(n);
if (!e) {
e = t.addComponent(n);
var i = n.ClearFlags;
e.clearFlags = i.COLOR | i.DEPTH | i.STENCIL;
e.depth = -1;
}
n.main = e;
},
onDestroy: function() {
cc.sys.isMobile ? window.removeEventListener("resize", this._thisOnResized) : cc.view.off("canvas-resize", this._thisOnResized);
s.instance === this && (s.instance = null);
},
alignWithScreen: function() {
var t, e, i = e = cc.visibleRect;
t = cc.view.getDesignResolutionSize();
var n = 0, r = 0;
if (!this.fitHeight && !this.fitWidth) {
n = .5 * (t.width - i.width);
r = .5 * (t.height - i.height);
}
this.node.setPosition(.5 * i.width + n, .5 * i.height + r);
this.node.width = e.width;
this.node.height = e.height;
},
applySettings: function() {
var t, e = cc.ResolutionPolicy;
t = this.fitHeight && this.fitWidth ? e.SHOW_ALL : this.fitHeight || this.fitWidth ? this.fitWidth ? e.FIXED_WIDTH : e.FIXED_HEIGHT : e.NO_BORDER;
var i = this._designResolution;
cc.view.setDesignResolutionSize(i.width, i.height, t);
}
});
cc.Canvas = e.exports = s;
}), {
"../camera/CCCamera": 52,
"./CCComponent": 67
} ],
67: [ (function(i, n, r) {
var s = i("../platform/CCObject"), o = i("../platform/js"), a = new (i("../platform/id-generater"))("Comp"), c = (s.Flags.IsOnEnableCalled, 
s.Flags.IsOnLoadCalled), h = cc.Class({
name: "cc.Component",
extends: s,
ctor: function() {
this._id = a.getNewId();
this.__eventTargets = [];
},
properties: {
node: {
default: null,
visible: !1
},
name: {
get: function() {
if (this._name) return this._name;
var t = cc.js.getClassName(this), e = t.lastIndexOf(".");
e >= 0 && (t = t.slice(e + 1));
return this.node.name + "<" + t + ">";
},
set: function(t) {
this._name = t;
},
visible: !1
},
uuid: {
get: function() {
return this._id;
},
visible: !1
},
__scriptAsset: !1,
_enabled: !0,
enabled: {
get: function() {
return this._enabled;
},
set: function(t) {
if (this._enabled !== t) {
this._enabled = t;
if (this.node._activeInHierarchy) {
var e = cc.director._compScheduler;
t ? e.enableComp(this) : e.disableComp(this);
}
}
},
visible: !1,
animatable: !0
},
enabledInHierarchy: {
get: function() {
return this._enabled && this.node._activeInHierarchy;
},
visible: !1
},
_isOnLoadCalled: {
get: function() {
return this._objFlags & c;
}
}
},
update: null,
lateUpdate: null,
__preload: null,
onLoad: null,
start: null,
onEnable: null,
onDisable: null,
onDestroy: null,
onFocusInEditor: null,
onLostFocusInEditor: null,
resetInEditor: null,
addComponent: function(t) {
return this.node.addComponent(t);
},
getComponent: function(t) {
return this.node.getComponent(t);
},
getComponents: function(t) {
return this.node.getComponents(t);
},
getComponentInChildren: function(t) {
return this.node.getComponentInChildren(t);
},
getComponentsInChildren: function(t) {
return this.node.getComponentsInChildren(t);
},
_getLocalBounds: null,
onRestore: null,
destroy: function() {
this._super() && this._enabled && this.node._activeInHierarchy && cc.director._compScheduler.disableComp(this);
},
_onPreDestroy: function() {
this.unscheduleAllCallbacks();
for (var t = this.__eventTargets, e = 0, i = t.length; e < i; ++e) {
var n = t[e];
n && n.targetOff(this);
}
t.length = 0;
0;
cc.director._nodeActivator.destroyComp(this);
this.node._removeComponent(this);
},
_instantiate: function(t) {
t || (t = cc.instantiate._clone(this, this));
t.node = null;
return t;
},
schedule: function(t, e, i, n) {
cc.assertID(t, 1619);
cc.assertID(e >= 0, 1620);
e = e || 0;
i = isNaN(i) ? cc.macro.REPEAT_FOREVER : i;
n = n || 0;
var r = cc.director.getScheduler(), s = r.isTargetPaused(this);
r.schedule(t, this, e, i, n, s);
},
scheduleOnce: function(t, e) {
this.schedule(t, 0, 0, e);
},
unschedule: function(t) {
t && cc.director.getScheduler().unschedule(t, this);
},
unscheduleAllCallbacks: function() {
cc.director.getScheduler().unscheduleAllForTarget(this);
}
});
h._requireComponent = null;
h._executionOrder = 0;
0;
o.value(h, "_registerEditorProps", (function(i, n) {
var r = n.requireComponent;
r && (i._requireComponent = r);
var s = n.executionOrder;
s && "number" === ("object" === (e = typeof s) ? t(s) : e) && (i._executionOrder = s);
}));
h.prototype.__scriptUuid = "";
cc.Component = n.exports = h;
}), {
"../platform/CCObject": 166,
"../platform/id-generater": 176,
"../platform/js": 180
} ],
68: [ (function(i, n, r) {
cc.Component.EventHandler = cc.Class({
name: "cc.ClickEvent",
properties: {
target: {
default: null,
type: cc.Node
},
component: "",
_componentId: "",
_componentName: {
get: function() {
this._genCompIdIfNeeded();
return this._compId2Name(this._componentId);
},
set: function(t) {
this._componentId = this._compName2Id(t);
}
},
handler: {
default: ""
},
customEventData: {
default: ""
}
},
statics: {
emitEvents: function(t) {
"use strict";
var e = void 0;
if (arguments.length > 0) for (var i = 0, n = (e = new Array(arguments.length - 1)).length; i < n; i++) e[i] = arguments[i + 1];
for (var r = 0, s = t.length; r < s; r++) {
var o = t[r];
o instanceof cc.Component.EventHandler && o.emit(e);
}
}
},
emit: function(i) {
var n = this.target;
if (cc.isValid(n)) {
this._genCompIdIfNeeded();
var r = cc.js._getClassById(this._componentId), s = n.getComponent(r);
if (cc.isValid(s)) {
var o = s[this.handler];
if ("function" === ("object" === (e = typeof o) ? t(o) : e)) {
null != this.customEventData && "" !== this.customEventData && (i = i.slice()).push(this.customEventData);
o.apply(s, i);
}
}
}
},
_compName2Id: function(t) {
var e = cc.js.getClassByName(t);
return cc.js._getClassId(e);
},
_compId2Name: function(t) {
var e = cc.js._getClassById(t);
return cc.js.getClassName(e);
},
_genCompIdIfNeeded: function() {
if (!this._componentId) {
this._componentName = this.component;
this.component = "";
}
}
});
}), {} ],
69: [ (function(i, n, r) {
var s = i("../platform/CCMacro"), o = i("./CCRenderComponent"), a = i("../renderer/render-engine"), c = i("../renderer/render-flow"), h = a.SpriteMaterial, l = i("../renderer/utils/dynamic-atlas/manager"), u = i("../renderer/utils/label/label-frame"), _ = s.TextAlignment, f = s.VerticalTextAlignment, d = cc.Enum({
NONE: 0,
CLAMP: 1,
SHRINK: 2,
RESIZE_HEIGHT: 3
}), m = cc.Enum({
NONE: 0,
BITMAP: 1,
CHAR: 2
}), p = cc.Class({
name: "cc.Label",
extends: o,
ctor: function() {
0;
this._actualFontSize = 0;
this._assemblerData = null;
this._frame = null;
this._ttfTexture = null;
this._letterTexture = null;
},
editor: !1,
properties: {
_useOriginalSize: !0,
_string: {
default: "",
formerlySerializedAs: "_N$string"
},
string: {
get: function() {
return this._string;
},
set: function(t) {
var e = this._string;
this._string = t.toString();
this.string !== e && this._updateRenderData();
this._checkStringEmpty();
},
multiline: !0,
tooltip: !1
},
horizontalAlign: {
default: _.LEFT,
type: _,
tooltip: !1,
notify: function(t) {
this.horizontalAlign !== t && this._updateRenderData();
},
animatable: !1
},
verticalAlign: {
default: f.TOP,
type: f,
tooltip: !1,
notify: function(t) {
this.verticalAlign !== t && this._updateRenderData();
},
animatable: !1
},
actualFontSize: {
displayName: "Actual Font Size",
animatable: !1,
readonly: !0,
get: function() {
return this._actualFontSize;
}
},
_fontSize: 40,
fontSize: {
get: function() {
return this._fontSize;
},
set: function(t) {
if (this._fontSize !== t) {
this._fontSize = t;
this._updateRenderData();
}
},
range: [ 0, 512 ],
tooltip: !1
},
fontFamily: {
default: "Arial",
tooltip: !1,
notify: function(t) {
this.fontFamily !== t && this._updateRenderData();
},
animatable: !1
},
_lineHeight: 40,
lineHeight: {
get: function() {
return this._lineHeight;
},
set: function(t) {
if (this._lineHeight !== t) {
this._lineHeight = t;
this._updateRenderData();
}
},
tooltip: !1
},
overflow: {
default: d.NONE,
type: d,
tooltip: !1,
notify: function(t) {
this.overflow !== t && this._updateRenderData();
},
animatable: !1
},
_enableWrapText: !0,
enableWrapText: {
get: function() {
return this._enableWrapText;
},
set: function(t) {
if (this._enableWrapText !== t) {
this._enableWrapText = t;
this._updateRenderData();
}
},
animatable: !1,
tooltip: !1
},
_N$file: null,
font: {
get: function() {
return this._N$file;
},
set: function(i) {
if (this.font !== i) {
i || (this._isSystemFontUsed = !0);
0;
this._N$file = i;
i && this._isSystemFontUsed && (this._isSystemFontUsed = !1);
"string" === ("object" === (e = typeof i) ? t(i) : e) && cc.warnID(4e3);
if (this._renderData) {
this.destroyRenderData(this._renderData);
this._renderData = null;
}
this._fontAtlas = null;
this._updateAssembler();
this._applyFontTexture(!0);
this._updateRenderData();
}
},
type: cc.Font,
tooltip: !1,
animatable: !1
},
_isSystemFontUsed: !0,
useSystemFont: {
get: function() {
return this._isSystemFontUsed;
},
set: function(t) {
if (this._isSystemFontUsed !== t) {
this.destroyRenderData(this._renderData);
this._renderData = null;
0;
this._isSystemFontUsed = !!t;
if (t) {
this.font = null;
this._updateAssembler();
this._updateRenderData();
this._checkStringEmpty();
} else this._userDefinedFont || this.disableRender();
}
},
animatable: !1,
tooltip: !1
},
_bmFontOriginalSize: {
displayName: "BMFont Original Size",
get: function() {
return this._N$file instanceof cc.BitmapFont ? this._N$file.fontSize : -1;
},
visible: !0,
animatable: !1
},
_spacingX: 0,
spacingX: {
get: function() {
return this._spacingX;
},
set: function(t) {
this._spacingX = t;
this._updateRenderData();
}
},
_batchAsBitmap: !1,
cacheMode: {
default: m.NONE,
type: m,
tooltip: !1,
notify: function(t) {
if (this.cacheMode !== t) {
t !== m.BITMAP || this.font instanceof cc.BitmapFont || this._frame._resetDynamicAtlasFrame();
t === m.CHAR && (this._ttfTexture = null);
this._updateRenderData(!0);
}
},
animatable: !1
},
_isBold: {
default: !1,
serializable: !1
},
_isItalic: {
default: !1,
serializable: !1
},
_isUnderline: {
default: !1,
serializable: !1
}
},
statics: {
HorizontalAlign: _,
VerticalAlign: f,
Overflow: d,
CacheMode: m
},
onLoad: function() {
if (this._batchAsBitmap && this.cacheMode === m.NONE) {
this.cacheMode = m.BITMAP;
this._batchAsBitmap = !1;
}
},
onEnable: function() {
this._super();
this.font || this._isSystemFontUsed || (this.useSystemFont = !0);
this.useSystemFont && !this.fontFamily && (this.fontFamily = "Arial");
this.node.on(cc.Node.EventType.SIZE_CHANGED, this._updateRenderData, this);
this.node.on(cc.Node.EventType.ANCHOR_CHANGED, this._updateRenderData, this);
this._checkStringEmpty();
this._updateRenderData(!0);
},
onDisable: function() {
this._super();
this.node.off(cc.Node.EventType.SIZE_CHANGED, this._updateRenderData, this);
this.node.off(cc.Node.EventType.ANCHOR_CHANGED, this._updateRenderData, this);
},
onDestroy: function() {
this._assembler && this._assembler._resetAssemblerData && this._assembler._resetAssemblerData(this._assemblerData);
this._assemblerData = null;
this._letterTexture = null;
if (this._ttfTexture) {
this._ttfTexture.destroy();
this._ttfTexture = null;
}
this._super();
},
_canRender: function() {
var t = this._super(), e = this.font;
if (e instanceof cc.BitmapFont) {
var i = e.spriteFrame;
i && i.textureLoaded() || (t = !1);
}
return t;
},
_checkStringEmpty: function() {
this.markForRender(!!this.string);
},
_updateAssembler: function() {
var t = p._assembler.getAssembler(this);
if (this._assembler !== t) {
this._assembler = t;
this._renderData = null;
this._frame = null;
}
this._renderData || (this._renderData = this._assembler.createData(this));
},
_applyFontTexture: function(t) {
var e = this, i = this.font;
if (i instanceof cc.BitmapFont) (function() {
var n = i.spriteFrame;
e._frame = n;
var r = e, s = function() {
r._frame._texture = n._texture;
r._activateMaterial(t);
t && r._assembler && r._assembler.updateRenderData(r);
};
if (n && n.textureLoaded()) s(); else {
e.disableRender();
if (n) {
n.once("load", s, e);
n.ensureLoadTexture();
}
}
})(); else {
this._frame || (this._frame = new u());
if (this.cacheMode === m.CHAR && cc.sys.browserType !== cc.sys.BROWSER_TYPE_WECHAT_GAME_SUB) {
this._letterTexture = this._assembler._getAssemblerData();
this._frame._refreshTexture(this._letterTexture);
} else if (!this._ttfTexture) {
this._ttfTexture = new cc.Texture2D();
this._assemblerData = this._assembler._getAssemblerData();
this._ttfTexture.initWithElement(this._assemblerData.canvas);
}
this.cacheMode !== m.CHAR && this._frame._refreshTexture(this._ttfTexture);
this._activateMaterial(t);
t && this._assembler && this._assembler.updateRenderData(this);
}
},
_updateColor: function() {
if (this.font instanceof cc.BitmapFont) this._super(); else {
this._updateRenderData();
this.node._renderFlag &= ~c.FLAG_COLOR;
}
},
_activateMaterial: function(t) {
var e = this._material;
if (!e || t) {
if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS) this._frame._texture.url = this.uuid + "_texture"; else {
e || (e = new h());
e.texture = this._frame._texture;
e.useColor = !1;
this._updateMaterial(e);
}
this.markForUpdateRenderData(!0);
this.markForRender(!0);
}
},
_updateRenderData: function(t) {
var e = this._renderData;
if (e) {
e.vertDirty = !0;
e.uvDirty = !0;
this.markForUpdateRenderData(!0);
}
if (t) {
this._updateAssembler();
this._applyFontTexture(t);
}
},
_calDynamicAtlas: function() {
if (l) {
if (!this._frame._original) {
var t = l.insertSpriteFrame(this._frame);
t && this._frame._setDynamicAtlasFrame(t);
}
this._material._texture !== this._frame._texture && this._activateMaterial(!0);
}
},
_enableBold: function(t) {
this._isBold = !!t;
},
_enableItalics: function(t) {
this._isItalic = !!t;
},
_enableUnderline: function(t) {
this._isUnderline = !!t;
}
});
cc.Label = n.exports = p;
}), {
"../platform/CCMacro": 165,
"../renderer/render-engine": 202,
"../renderer/render-flow": 203,
"../renderer/utils/dynamic-atlas/manager": 205,
"../renderer/utils/label/label-frame": 207,
"./CCRenderComponent": 77
} ],
70: [ (function(t, e, i) {
var n = cc.Class({
name: "cc.LabelOutline",
extends: t("./CCComponent"),
editor: !1,
properties: {
_color: cc.color(255, 255, 255, 255),
_width: 1,
color: {
get: function() {
return this._color;
},
set: function(t) {
this._color = cc.color(t);
this._updateRenderData();
}
},
width: {
get: function() {
return this._width;
},
set: function(t) {
this._width = t;
this._updateRenderData();
}
}
},
onEnable: function() {
this._updateRenderData();
},
onDisable: function() {
this._updateRenderData();
},
_updateRenderData: function() {
var t = this.node.getComponent(cc.Label);
t && t._updateRenderData(!0);
}
});
cc.LabelOutline = e.exports = n;
}), {
"./CCComponent": 67
} ],
71: [ (function(t, e, i) {
var n = t("../CCNode").EventType, r = cc.Enum({
NONE: 0,
HORIZONTAL: 1,
VERTICAL: 2,
GRID: 3
}), s = cc.Enum({
NONE: 0,
CONTAINER: 1,
CHILDREN: 2
}), o = cc.Enum({
HORIZONTAL: 0,
VERTICAL: 1
}), a = cc.Enum({
BOTTOM_TO_TOP: 0,
TOP_TO_BOTTOM: 1
}), c = cc.Enum({
LEFT_TO_RIGHT: 0,
RIGHT_TO_LEFT: 1
}), h = cc.Class({
name: "cc.Layout",
extends: t("./CCComponent"),
editor: !1,
properties: {
_layoutSize: cc.size(300, 200),
_layoutDirty: {
default: !0,
serializable: !1
},
_resize: s.NONE,
_N$layoutType: r.NONE,
type: {
type: r,
get: function() {
return this._N$layoutType;
},
set: function(t) {
this._N$layoutType = t;
this._doLayoutDirty();
},
tooltip: !1,
animatable: !1
},
resizeMode: {
type: s,
tooltip: !1,
animatable: !1,
get: function() {
return this._resize;
},
set: function(t) {
if (this.type !== r.NONE || t !== s.CHILDREN) {
this._resize = t;
this._doLayoutDirty();
}
}
},
cellSize: {
default: cc.size(40, 40),
tooltip: !1,
type: cc.Size,
notify: function() {
this._doLayoutDirty();
}
},
startAxis: {
default: o.HORIZONTAL,
tooltip: !1,
type: o,
notify: function() {
this._doLayoutDirty();
},
animatable: !1
},
_N$padding: {
default: 0
},
paddingLeft: {
default: 0,
tooltip: !1,
notify: function() {
this._doLayoutDirty();
}
},
paddingRight: {
default: 0,
tooltip: !1,
notify: function() {
this._doLayoutDirty();
}
},
paddingTop: {
default: 0,
tooltip: !1,
notify: function() {
this._doLayoutDirty();
}
},
paddingBottom: {
default: 0,
tooltip: !1,
notify: function() {
this._doLayoutDirty();
}
},
spacingX: {
default: 0,
notify: function() {
this._doLayoutDirty();
},
tooltip: !1
},
spacingY: {
default: 0,
notify: function() {
this._doLayoutDirty();
},
tooltip: !1
},
verticalDirection: {
default: a.TOP_TO_BOTTOM,
type: a,
notify: function() {
this._doLayoutDirty();
},
tooltip: !1,
animatable: !1
},
horizontalDirection: {
default: c.LEFT_TO_RIGHT,
type: c,
notify: function() {
this._doLayoutDirty();
},
tooltip: !1,
animatable: !1
},
affectedByScale: {
default: !1,
notify: function() {
this._doLayoutDirty();
},
animatable: !1,
tooltip: !1
}
},
statics: {
Type: r,
VerticalDirection: a,
HorizontalDirection: c,
ResizeMode: s,
AxisDirection: o
},
_migratePaddingData: function() {
this.paddingLeft = this._N$padding;
this.paddingRight = this._N$padding;
this.paddingTop = this._N$padding;
this.paddingBottom = this._N$padding;
this._N$padding = 0;
},
onEnable: function() {
this._addEventListeners();
this.node.getContentSize().equals(cc.size(0, 0)) && this.node.setContentSize(this._layoutSize);
0 !== this._N$padding && this._migratePaddingData();
this._doLayoutDirty();
},
onDisable: function() {
this._removeEventListeners();
},
_doLayoutDirty: function() {
this._layoutDirty = !0;
},
_doScaleDirty: function() {
this._layoutDirty = this._layoutDirty || this.affectedByScale;
},
_addEventListeners: function() {
cc.director.on(cc.Director.EVENT_AFTER_UPDATE, this.updateLayout, this);
this.node.on(n.SIZE_CHANGED, this._resized, this);
this.node.on(n.ANCHOR_CHANGED, this._doLayoutDirty, this);
this.node.on(n.CHILD_ADDED, this._childAdded, this);
this.node.on(n.CHILD_REMOVED, this._childRemoved, this);
this.node.on(n.CHILD_REORDER, this._doLayoutDirty, this);
this._addChildrenEventListeners();
},
_removeEventListeners: function() {
cc.director.off(cc.Director.EVENT_AFTER_UPDATE, this.updateLayout, this);
this.node.off(n.SIZE_CHANGED, this._resized, this);
this.node.off(n.ANCHOR_CHANGED, this._doLayoutDirty, this);
this.node.off(n.CHILD_ADDED, this._childAdded, this);
this.node.off(n.CHILD_REMOVED, this._childRemoved, this);
this.node.off(n.CHILD_REORDER, this._doLayoutDirty, this);
this._removeChildrenEventListeners();
},
_addChildrenEventListeners: function() {
for (var t = this.node.children, e = 0; e < t.length; ++e) {
var i = t[e];
i.on(n.SCALE_CHANGED, this._doScaleDirty, this);
i.on(n.SIZE_CHANGED, this._doLayoutDirty, this);
i.on(n.POSITION_CHANGED, this._doLayoutDirty, this);
i.on(n.ANCHOR_CHANGED, this._doLayoutDirty, this);
i.on("active-in-hierarchy-changed", this._doLayoutDirty, this);
}
},
_removeChildrenEventListeners: function() {
for (var t = this.node.children, e = 0; e < t.length; ++e) {
var i = t[e];
i.off(n.SCALE_CHANGED, this._doScaleDirty, this);
i.off(n.SIZE_CHANGED, this._doLayoutDirty, this);
i.off(n.POSITION_CHANGED, this._doLayoutDirty, this);
i.off(n.ANCHOR_CHANGED, this._doLayoutDirty, this);
i.off("active-in-hierarchy-changed", this._doLayoutDirty, this);
}
},
_childAdded: function(t) {
t.on(n.SCALE_CHANGED, this._doScaleDirty, this);
t.on(n.SIZE_CHANGED, this._doLayoutDirty, this);
t.on(n.POSITION_CHANGED, this._doLayoutDirty, this);
t.on(n.ANCHOR_CHANGED, this._doLayoutDirty, this);
t.on("active-in-hierarchy-changed", this._doLayoutDirty, this);
this._doLayoutDirty();
},
_childRemoved: function(t) {
t.off(n.SCALE_CHANGED, this._doScaleDirty, this);
t.off(n.SIZE_CHANGED, this._doLayoutDirty, this);
t.off(n.POSITION_CHANGED, this._doLayoutDirty, this);
t.off(n.ANCHOR_CHANGED, this._doLayoutDirty, this);
t.off("active-in-hierarchy-changed", this._doLayoutDirty, this);
this._doLayoutDirty();
},
_resized: function() {
this._layoutSize = this.node.getContentSize();
this._doLayoutDirty();
},
_doLayoutHorizontally: function(t, e, i, n) {
var o = this.node.getAnchorPoint(), h = this.node.children, l = 1, u = this.paddingLeft, _ = -o.x * t;
if (this.horizontalDirection === c.RIGHT_TO_LEFT) {
l = -1;
_ = (1 - o.x) * t;
u = this.paddingRight;
}
for (var f = _ + l * u - l * this.spacingX, d = 0, m = 0, p = 0, v = 0, y = 0, g = 0, x = 0, C = 0; C < h.length; ++C) {
(b = h[C]).activeInHierarchy && x++;
}
var A = this.cellSize.width;
this.type !== r.GRID && this.resizeMode === s.CHILDREN && (A = (t - (this.paddingLeft + this.paddingRight) - (x - 1) * this.spacingX) / x);
for (C = 0; C < h.length; ++C) {
var b = h[C], S = this._getUsedScaleValue(b.scaleX), T = this._getUsedScaleValue(b.scaleY);
if (b.activeInHierarchy) {
if (this._resize === s.CHILDREN) {
b.width = A / S;
this.type === r.GRID && (b.height = this.cellSize.height / T);
}
var w = b.anchorX, E = b.width * S, B = b.height * T;
p > m && (m = p);
if (B >= m) {
p = m;
m = B;
g = b.getAnchorPoint().y;
}
this.horizontalDirection === c.RIGHT_TO_LEFT && (w = 1 - b.anchorX);
f = f + l * w * E + l * this.spacingX;
var M = l * (1 - w) * E;
if (e) {
var D = f + M + l * (l > 0 ? this.paddingRight : this.paddingLeft), I = this.horizontalDirection === c.LEFT_TO_RIGHT && D > (1 - o.x) * t, P = this.horizontalDirection === c.RIGHT_TO_LEFT && D < -o.x * t;
if (I || P) {
if (B >= m) {
0 === p && (p = m);
d += p;
p = m;
} else {
d += m;
p = B;
m = 0;
}
f = _ + l * (u + w * E);
v++;
}
}
var R = i(b, d, v);
t >= E + this.paddingLeft + this.paddingRight && n && b.setPosition(cc.v2(f, R));
var L, F = 1, V = 0 === m ? B : m;
if (this.verticalDirection === a.TOP_TO_BOTTOM) {
y = y || this.node._contentSize.height;
(L = R + (F = -1) * (V * g + this.paddingBottom)) < y && (y = L);
} else {
y = y || -this.node._contentSize.height;
(L = R + F * (V * g + this.paddingTop)) > y && (y = L);
}
f += M;
}
}
return y;
},
_getVerticalBaseHeight: function(t) {
var e = 0, i = 0;
if (this.resizeMode === s.CONTAINER) {
for (var n = 0; n < t.length; ++n) {
var r = t[n];
if (r.activeInHierarchy) {
i++;
e += r.height * this._getUsedScaleValue(r.scaleY);
}
}
e += (i - 1) * this.spacingY + this.paddingBottom + this.paddingTop;
} else e = this.node.getContentSize().height;
return e;
},
_doLayoutVertically: function(t, e, i, n) {
var o = this.node.getAnchorPoint(), h = this.node.children, l = 1, u = this.paddingBottom, _ = -o.y * t;
if (this.verticalDirection === a.TOP_TO_BOTTOM) {
l = -1;
_ = (1 - o.y) * t;
u = this.paddingTop;
}
for (var f = _ + l * u - l * this.spacingY, d = 0, m = 0, p = 0, v = 0, y = 0, g = 0, x = 0, C = 0; C < h.length; ++C) {
(b = h[C]).activeInHierarchy && x++;
}
var A = this.cellSize.height;
this.type !== r.GRID && this.resizeMode === s.CHILDREN && (A = (t - (this.paddingTop + this.paddingBottom) - (x - 1) * this.spacingY) / x);
for (C = 0; C < h.length; ++C) {
var b = h[C], S = this._getUsedScaleValue(b.scaleX), T = this._getUsedScaleValue(b.scaleY);
if (b.activeInHierarchy) {
if (this.resizeMode === s.CHILDREN) {
b.height = A / T;
this.type === r.GRID && (b.width = this.cellSize.width / S);
}
var w = b.anchorY, E = b.width * S, B = b.height * T;
p > m && (m = p);
if (E >= m) {
p = m;
m = E;
g = b.getAnchorPoint().x;
}
this.verticalDirection === a.TOP_TO_BOTTOM && (w = 1 - b.anchorY);
f = f + l * w * B + l * this.spacingY;
var M = l * (1 - w) * B;
if (e) {
var D = f + M + l * (l > 0 ? this.paddingTop : this.paddingBottom), I = this.verticalDirection === a.BOTTOM_TO_TOP && D > (1 - o.y) * t, P = this.verticalDirection === a.TOP_TO_BOTTOM && D < -o.y * t;
if (I || P) {
if (E >= m) {
0 === p && (p = m);
d += p;
p = m;
} else {
d += m;
p = E;
m = 0;
}
f = _ + l * (u + w * B);
v++;
}
}
var R = i(b, d, v);
t >= B + (this.paddingTop + this.paddingBottom) && n && b.setPosition(cc.v2(R, f));
var L, F = 1, V = 0 === m ? E : m;
if (this.horizontalDirection === c.RIGHT_TO_LEFT) {
F = -1;
y = y || this.node._contentSize.width;
(L = R + F * (V * g + this.paddingLeft)) < y && (y = L);
} else {
y = y || -this.node._contentSize.width;
(L = R + F * (V * g + this.paddingRight)) > y && (y = L);
}
f += M;
}
}
return y;
},
_doLayoutBasic: function() {
for (var t = this.node.children, e = null, i = 0; i < t.length; ++i) {
var n = t[i];
n.activeInHierarchy && (e ? e.union(e, n.getBoundingBoxToWorld()) : e = n.getBoundingBoxToWorld());
}
if (e) {
var r = this.node.parent.convertToNodeSpaceAR(cc.v2(e.x, e.y));
r = cc.v2(r.x - this.paddingLeft, r.y - this.paddingBottom);
var s = this.node.parent.convertToNodeSpaceAR(cc.v2(e.x + e.width, e.y + e.height));
s = cc.v2(s.x + this.paddingRight, s.y + this.paddingTop);
var o = cc.size(parseFloat((s.x - r.x).toFixed(2)), parseFloat((s.y - r.y).toFixed(2))), a = this.node.getPosition();
if (0 !== o.width) {
var c = (a.x - r.x) / o.width;
this.node.anchorX = parseFloat(c.toFixed(2));
}
if (0 !== o.height) {
var h = (a.y - r.y) / o.height;
this.node.anchorY = parseFloat(h.toFixed(2));
}
this.node.setContentSize(o);
}
},
_doLayoutGridAxisHorizontal: function(t, e) {
var i = e.width, n = 1, r = -t.y * e.height, o = this.paddingBottom;
if (this.verticalDirection === a.TOP_TO_BOTTOM) {
n = -1;
r = (1 - t.y) * e.height;
o = this.paddingTop;
}
var c = function(t, e, i) {
return r + n * (e + t.anchorY * t.height * this._getUsedScaleValue(t.scaleY) + o + i * this.spacingY);
}.bind(this), h = 0;
if (this.resizeMode === s.CONTAINER) {
var l = this._doLayoutHorizontally(i, !0, c, !1);
(h = r - l) < 0 && (h *= -1);
r = -t.y * h;
if (this.verticalDirection === a.TOP_TO_BOTTOM) {
n = -1;
r = (1 - t.y) * h;
}
}
this._doLayoutHorizontally(i, !0, c, !0);
this.resizeMode === s.CONTAINER && this.node.setContentSize(i, h);
},
_doLayoutGridAxisVertical: function(t, e) {
var i = e.height, n = 1, r = -t.x * e.width, o = this.paddingLeft;
if (this.horizontalDirection === c.RIGHT_TO_LEFT) {
n = -1;
r = (1 - t.x) * e.width;
o = this.paddingRight;
}
var a = function(t, e, i) {
return r + n * (e + t.anchorX * t.width * this._getUsedScaleValue(t.scaleX) + o + i * this.spacingX);
}.bind(this), h = 0;
if (this.resizeMode === s.CONTAINER) {
var l = this._doLayoutVertically(i, !0, a, !1);
(h = r - l) < 0 && (h *= -1);
r = -t.x * h;
if (this.horizontalDirection === c.RIGHT_TO_LEFT) {
n = -1;
r = (1 - t.x) * h;
}
}
this._doLayoutVertically(i, !0, a, !0);
this.resizeMode === s.CONTAINER && this.node.setContentSize(h, i);
},
_doLayoutGrid: function() {
var t = this.node.getAnchorPoint(), e = this.node.getContentSize();
this.startAxis === o.HORIZONTAL ? this._doLayoutGridAxisHorizontal(t, e) : this.startAxis === o.VERTICAL && this._doLayoutGridAxisVertical(t, e);
},
_getHorizontalBaseWidth: function(t) {
var e = 0, i = 0;
if (this.resizeMode === s.CONTAINER) {
for (var n = 0; n < t.length; ++n) {
var r = t[n];
if (r.activeInHierarchy) {
i++;
e += r.width * this._getUsedScaleValue(r.scaleX);
}
}
e += (i - 1) * this.spacingX + this.paddingLeft + this.paddingRight;
} else e = this.node.getContentSize().width;
return e;
},
_doLayout: function() {
if (this.type === r.HORIZONTAL) {
var t = this._getHorizontalBaseWidth(this.node.children);
this._doLayoutHorizontally(t, !1, (function(t) {
return t.y;
}), !0);
this.node.width = t;
} else if (this.type === r.VERTICAL) {
var e = this._getVerticalBaseHeight(this.node.children);
this._doLayoutVertically(e, !1, (function(t) {
return t.x;
}), !0);
this.node.height = e;
} else this.type === r.NONE ? this.resizeMode === s.CONTAINER && this._doLayoutBasic() : this.type === r.GRID && this._doLayoutGrid();
},
_getUsedScaleValue: function(t) {
return this.affectedByScale ? Math.abs(t) : 1;
},
updateLayout: function() {
if (this._layoutDirty && this.node.children.length > 0) {
this._doLayout();
this._layoutDirty = !1;
}
}
});
Object.defineProperty(h.prototype, "padding", {
get: function() {
cc.warnID(4100);
return this.paddingLeft;
},
set: function(t) {
this._N$padding = t;
this._migratePaddingData();
this._doLayoutDirty();
}
});
cc.Layout = e.exports = h;
}), {
"../CCNode": 29,
"./CCComponent": 67
} ],
72: [ (function(t, e, i) {
var n = t("../utils/misc"), r = t("../renderer/render-engine"), s = r.math, o = r.StencilMaterial, a = t("./CCRenderComponent"), c = t("../renderer/render-flow"), h = t("../graphics/graphics"), l = t("../CCNode"), u = t("../renderer/utils/dynamic-atlas/manager"), _ = cc.v2(), f = s.mat4.create(), d = [];
var m = cc.Enum({
RECT: 0,
ELLIPSE: 1,
IMAGE_STENCIL: 2
}), p = cc.Class({
name: "cc.Mask",
extends: a,
editor: !1,
ctor: function() {
this._graphics = null;
this._clearGraphics = null;
},
properties: {
_spriteFrame: {
default: null,
type: cc.SpriteFrame
},
_type: m.RECT,
type: {
get: function() {
return this._type;
},
set: function(t) {
this._type = t;
if (this._type !== m.IMAGE_STENCIL) {
this.spriteFrame = null;
this.alphaThreshold = 0;
this._updateGraphics();
}
if (this._renderData) {
this.destroyRenderData(this._renderData);
this._renderData = null;
}
this._activateMaterial();
},
type: m,
tooltip: !1
},
spriteFrame: {
type: cc.SpriteFrame,
tooltip: !1,
get: function() {
return this._spriteFrame;
},
set: function(t) {
var e = this._spriteFrame;
if (e !== t) {
this._spriteFrame = t;
this._applySpriteFrame(e);
}
}
},
alphaThreshold: {
default: 0,
type: cc.Float,
range: [ 0, 1, .1 ],
slide: !0,
tooltip: !1,
notify: function() {
if (cc.game.renderType !== cc.game.RENDER_TYPE_CANVAS) {
if (this._material) {
this._material.alphaThreshold = this.alphaThreshold;
this._material.updateHash();
}
} else cc.warnID(4201);
}
},
inverted: {
default: !1,
type: cc.Boolean,
tooltip: !1,
notify: function() {
cc.game.renderType !== cc.game.RENDER_TYPE_CANVAS || cc.warnID(4202);
}
},
_segments: 64,
segements: {
get: function() {
return this._segments;
},
set: function(t) {
this._segments = n.clampf(t, 3, 1e4);
this._updateGraphics();
},
type: cc.Integer,
tooltip: !1
},
_resizeToTarget: {
animatable: !1,
set: function(t) {
t && this._resizeNodeToTargetNode();
}
}
},
statics: {
Type: m
},
onLoad: function() {
this._createGraphics();
},
onRestore: function() {
this._createGraphics();
this._type !== m.IMAGE_STENCIL ? this._updateGraphics() : this._applySpriteFrame();
},
onEnable: function() {
this._super();
if (this._type === m.IMAGE_STENCIL) {
if (!this._spriteFrame || !this._spriteFrame.textureLoaded()) {
this.markForRender(!1);
if (this._spriteFrame) {
this.markForUpdateRenderData(!1);
this._spriteFrame.once("load", this._onTextureLoaded, this);
this._spriteFrame.ensureLoadTexture();
}
}
} else this._updateGraphics();
this.node.on(cc.Node.EventType.POSITION_CHANGED, this._updateGraphics, this);
this.node.on(cc.Node.EventType.ROTATION_CHANGED, this._updateGraphics, this);
this.node.on(cc.Node.EventType.SCALE_CHANGED, this._updateGraphics, this);
this.node.on(cc.Node.EventType.SIZE_CHANGED, this._updateGraphics, this);
this.node.on(cc.Node.EventType.ANCHOR_CHANGED, this._updateGraphics, this);
this.node._renderFlag |= c.FLAG_POST_RENDER;
this._activateMaterial();
},
onDisable: function() {
this._super();
this.node.off(cc.Node.EventType.POSITION_CHANGED, this._updateGraphics, this);
this.node.off(cc.Node.EventType.ROTATION_CHANGED, this._updateGraphics, this);
this.node.off(cc.Node.EventType.SCALE_CHANGED, this._updateGraphics, this);
this.node.off(cc.Node.EventType.SIZE_CHANGED, this._updateGraphics, this);
this.node.off(cc.Node.EventType.ANCHOR_CHANGED, this._updateGraphics, this);
this.node._renderFlag &= ~c.FLAG_POST_RENDER;
},
onDestroy: function() {
this._super();
this._removeGraphics();
},
_resizeNodeToTargetNode: !1,
_onTextureLoaded: function() {
if (this._renderData) {
this._renderData.uvDirty = !0;
this._renderData.vertDirty = !0;
this.markForUpdateRenderData(!0);
}
this.enabledInHierarchy && this._activateMaterial();
},
_applySpriteFrame: function(t) {
t && t.off && t.off("load", this._onTextureLoaded, this);
var e = this._spriteFrame;
if (e) if (e.textureLoaded()) this._onTextureLoaded(null); else {
e.once("load", this._onTextureLoaded, this);
e.ensureLoadTexture();
} else this.disableRender();
},
_activateMaterial: function() {
if (this._type !== m.IMAGE_STENCIL || this.spriteFrame && this.spriteFrame.textureLoaded()) {
if (cc.game.renderType !== cc.game.RENDER_TYPE_CANVAS) {
this._material || (this._material = new o());
if (this._type === m.IMAGE_STENCIL) {
var t = this.spriteFrame.getTexture();
this._material.useModel = !1;
this._material.useTexture = !0;
this._material.useColor = !0;
this._material.texture = t;
this._material.alphaThreshold = this.alphaThreshold;
} else {
this._material.useModel = !0;
this._material.useTexture = !1;
this._material.useColor = !1;
}
}
this.markForRender(!0);
} else this.markForRender(!1);
},
_createGraphics: function() {
if (!this._graphics) {
this._graphics = new h();
this._graphics.node = this.node;
this._graphics.lineWidth = 0;
this._graphics.strokeColor = cc.color(0, 0, 0, 0);
}
if (!this._clearGraphics) {
this._clearGraphics = new h();
this._clearGraphics.node = new l();
this._clearGraphics._activateMaterial();
this._clearGraphics.lineWidth = 0;
this._clearGraphics.rect(0, 0, cc.visibleRect.width, cc.visibleRect.height);
this._clearGraphics.fill();
}
},
_updateGraphics: function() {
var t = this.node, e = this._graphics;
e.clear(!1);
var i = t._contentSize.width, n = t._contentSize.height, r = -i * t._anchorPoint.x, s = -n * t._anchorPoint.y;
if (this._type === m.RECT) e.rect(r, s, i, n); else if (this._type === m.ELLIPSE) {
for (var o = (function(t, e, i) {
d.length = 0;
for (var n = 2 * Math.PI / i, r = 0; r < i; ++r) d.push(cc.v2(e.x * Math.cos(n * r) + t.x, e.y * Math.sin(n * r) + t.y));
return d;
})(cc.v2(r + i / 2, s + n / 2), {
x: i / 2,
y: n / 2
}, this._segments), a = 0; a < o.length; ++a) {
var c = o[a];
0 === a ? e.moveTo(c.x, c.y) : e.lineTo(c.x, c.y);
}
e.close();
}
cc.game.renderType === cc.game.RENDER_TYPE_CANVAS ? e.stroke() : e.fill();
},
_removeGraphics: function() {
this._graphics && this._graphics.destroy();
this._clearGraphics && this._clearGraphics.destroy();
},
_hitTest: function(t) {
var e = this.node, i = e.getContentSize(), n = i.width, r = i.height, o = _;
e._updateWorldMatrix();
s.mat4.invert(f, e._worldMatrix);
s.vec2.transformMat4(o, t, f);
o.x += e._anchorPoint.x * n;
o.y += e._anchorPoint.y * r;
var a = !1;
if (this.type === m.RECT || this.type === m.IMAGE_STENCIL) a = o.x >= 0 && o.y >= 0 && o.x <= n && o.y <= r; else if (this.type === m.ELLIPSE) {
var c = n / 2, h = r / 2, l = o.x - .5 * n, u = o.y - .5 * r;
a = l * l / (c * c) + u * u / (h * h) < 1;
}
this.inverted && (a = !a);
return a;
},
markForUpdateRenderData: function(t) {
t && this.enabledInHierarchy ? this.node._renderFlag |= c.FLAG_UPDATE_RENDER_DATA : t || (this.node._renderFlag &= ~c.FLAG_UPDATE_RENDER_DATA);
},
markForRender: function(t) {
t && this.enabledInHierarchy ? this.node._renderFlag |= c.FLAG_RENDER | c.FLAG_UPDATE_RENDER_DATA | c.FLAG_POST_RENDER : t || (this.node._renderFlag &= ~(c.FLAG_RENDER | c.FLAG_POST_RENDER));
},
disableRender: function() {
this.node._renderFlag &= ~(c.FLAG_RENDER | c.FLAG_UPDATE_RENDER_DATA | c.FLAG_POST_RENDER);
},
_calDynamicAtlas: function() {
if (this._spriteFrame) {
if (!this._spriteFrame._original && u) {
var t = u.insertSpriteFrame(this._spriteFrame);
t && this._spriteFrame._setDynamicAtlasFrame(t);
}
this._material._texture !== this._spriteFrame._texture && this._activateMaterial();
}
}
});
cc.Mask = e.exports = p;
}), {
"../CCNode": 29,
"../graphics/graphics": 106,
"../renderer/render-engine": 202,
"../renderer/render-flow": 203,
"../renderer/utils/dynamic-atlas/manager": 205,
"../utils/misc": 242,
"./CCRenderComponent": 77
} ],
73: [ (function(t, e, i) {
var n = t("../components/CCRenderComponent"), r = t("../renderer/render-engine").SpriteMaterial, s = t("../utils/texture-util"), o = cc.Class({
name: "cc.MotionStreak",
extends: n,
editor: !1,
ctor: function() {
this._points = [];
},
properties: {
preview: {
default: !1,
editorOnly: !0,
notify: !1,
animatable: !1
},
_fadeTime: 1,
fadeTime: {
get: function() {
return this._fadeTime;
},
set: function(t) {
this._fadeTime = t;
this.reset();
},
animatable: !1,
tooltip: !1
},
_minSeg: 1,
minSeg: {
get: function() {
return this._minSeg;
},
set: function(t) {
this._minSeg = t;
},
animatable: !1,
tooltip: !1
},
_stroke: 64,
stroke: {
get: function() {
return this._stroke;
},
set: function(t) {
this._stroke = t;
},
animatable: !1,
tooltip: !1
},
_texture: {
default: null,
type: cc.Texture2D
},
texture: {
get: function() {
return this._texture;
},
set: function(t) {
if (this._texture !== t) {
this._texture = t;
if (t && t.loaded) this._activateMaterial(); else {
this.disableRender();
this._ensureLoadTexture();
}
}
},
type: cc.Texture2D,
animatable: !1,
tooltip: !1
},
_color: cc.Color.WHITE,
color: {
get: function() {
return this._color;
},
set: function(t) {
this._color = t;
},
type: cc.Color,
tooltip: !1
},
_fastMode: !1,
fastMode: {
get: function() {
return this._fastMode;
},
set: function(t) {
this._fastMode = t;
},
animatable: !1,
tooltip: !1
}
},
onEnable: function() {
this._super();
if (this._texture && this._texture.loaded) this._activateMaterial(); else {
this.disableRender();
this._ensureLoadTexture();
}
this.reset();
},
_ensureLoadTexture: function() {
var t = this;
this._texture && !this._texture.loaded && (function() {
var e = t;
s.postLoadTexture(t._texture, (function() {
e._activateMaterial();
}));
})();
},
_activateMaterial: function() {
var t = this._material;
t || ((t = this._material = new r()).useColor = !1);
if (this._texture && this._texture.loaded) {
t.texture = this._texture;
this._updateMaterial(t);
this.markForRender(!0);
this.markForUpdateRenderData(!0);
}
},
onFocusInEditor: !1,
onLostFocusInEditor: !1,
reset: function() {
this._points.length = 0;
var t = this._renderData;
if (t) {
t.dataLength = 0;
t.vertexCount = 0;
t.indiceCount = 0;
}
0;
}
});
cc.MotionStreak = e.exports = o;
}), {
"../components/CCRenderComponent": 77,
"../renderer/render-engine": 202,
"../utils/texture-util": 250
} ],
74: [ (function(t, e, i) {
var n = cc.Enum({
Unified: 0,
Free: 1
}), r = cc.Enum({
Horizontal: 0,
Vertical: 1
}), s = cc.Enum({
PAGE_TURNING: 0
}), o = cc.Class({
name: "cc.PageView",
extends: cc.ScrollView,
editor: !1,
ctor: function() {
this._curPageIdx = 0;
this._lastPageIdx = 0;
this._pages = [];
this._scrollCenterOffsetX = [];
this._scrollCenterOffsetY = [];
},
properties: {
sizeMode: {
default: n.Unified,
type: n,
tooltip: !1,
notify: function() {
this._syncSizeMode();
}
},
direction: {
default: r.Horizontal,
type: r,
tooltip: !1,
notify: function() {
this._syncScrollDirection();
}
},
scrollThreshold: {
default: .5,
type: cc.Float,
slide: !0,
range: [ 0, 1, .01 ],
tooltip: !1
},
autoPageTurningThreshold: {
default: 100,
type: cc.Float,
tooltip: !1
},
pageTurningEventTiming: {
default: .1,
type: cc.Float,
range: [ 0, 1, .01 ],
tooltip: !1
},
indicator: {
default: null,
type: cc.PageViewIndicator,
tooltip: !1,
notify: function() {
this.indicator && this.indicator.setPageView(this);
}
},
pageTurningSpeed: {
default: .3,
type: cc.Float,
tooltip: !1
},
pageEvents: {
default: [],
type: cc.Component.EventHandler,
tooltip: !1
}
},
statics: {
SizeMode: n,
Direction: r,
EventType: s
},
__preload: function() {
this.node.on(cc.Node.EventType.SIZE_CHANGED, this._updateAllPagesSize, this);
},
onEnable: function() {
this._super();
this.node.on("scroll-ended-with-threshold", this._dispatchPageTurningEvent, this);
},
onDisable: function() {
this._super();
this.node.off("scroll-ended-with-threshold", this._dispatchPageTurningEvent, this);
},
onLoad: function() {
this._initPages();
this.indicator && this.indicator.setPageView(this);
},
onDestroy: function() {
this.node.off(cc.Node.EventType.SIZE_CHANGED, this._updateAllPagesSize, this);
},
getCurrentPageIndex: function() {
return this._curPageIdx;
},
setCurrentPageIndex: function(t) {
this.scrollToPage(t, !0);
},
getPages: function() {
return this._pages;
},
addPage: function(t) {
if (t && -1 === this._pages.indexOf(t) && this.content) {
this.content.addChild(t);
this._pages.push(t);
this._updatePageView();
}
},
insertPage: function(t, e) {
if (!(e < 0) && t && -1 === this._pages.indexOf(t) && this.content) {
if (e >= this._pages.length) this.addPage(t); else {
this._pages.splice(e, 0, t);
this.content.addChild(t);
this._updatePageView();
}
}
},
removePage: function(t) {
if (t && this.content) {
var e = this._pages.indexOf(t);
-1 !== e ? this.removePageAtIndex(e) : cc.warnID(4300, t.name);
}
},
removePageAtIndex: function(t) {
var e = this._pages;
if (!(t < 0 || t >= e.length)) {
var i = e[t];
if (i) {
this.content.removeChild(i);
e.splice(t, 1);
this._updatePageView();
}
}
},
removeAllPages: function() {
if (this.content) {
for (var t = this._pages, e = 0, i = t.length; e < i; e++) this.content.removeChild(t[e]);
this._pages.length = 0;
this._updatePageView();
}
},
scrollToPage: function(t, e) {
if (!(t < 0 || t >= this._pages.length)) {
e = void 0 !== e ? e : .3;
this._curPageIdx = t;
this.scrollToOffset(this._moveOffsetValue(t), e, !0);
this.indicator && this.indicator._changedState();
}
},
getScrollEndedEventTiming: function() {
return this.pageTurningEventTiming;
},
_syncScrollDirection: function() {
this.horizontal = this.direction === r.Horizontal;
this.vertical = this.direction === r.Vertical;
},
_syncSizeMode: function() {
if (this.content) {
var t = this.content.getComponent(cc.Layout);
if (t) {
if (0 === this._pages.length) t.padding = 0; else {
var e = this._pages[this._pages.length - 1];
if (this.sizeMode === n.Free) if (this.direction === r.Horizontal) {
t.paddingLeft = (this._view.width - this._pages[0].width) / 2;
t.paddingRight = (this._view.width - e.width) / 2;
} else if (this.direction === r.Vertical) {
t.paddingTop = (this._view.height - this._pages[0].height) / 2;
t.paddingBottom = (this._view.height - e.height) / 2;
}
}
t.updateLayout();
}
}
},
_updatePageView: function() {
var t = this._pages.length;
if (this._curPageIdx >= t) {
this._curPageIdx = 0 === t ? 0 : t - 1;
this._lastPageIdx = this._curPageIdx;
}
for (var e = 0; e < t; ++e) {
this._pages[e].setSiblingIndex(e);
this.direction === r.Horizontal ? this._scrollCenterOffsetX[e] = Math.abs(this.content.x + this._pages[e].x) : this._scrollCenterOffsetY[e] = Math.abs(this.content.y + this._pages[e].y);
}
var i = this.content.getComponent(cc.Layout);
i && i.enabled && i.updateLayout();
this.indicator && this.indicator._refresh();
},
_updateAllPagesSize: function() {
if (this.sizeMode === n.Unified) for (var t = this._pages, e = this._view.getContentSize(), i = 0, r = t.length; i < r; i++) t[i].setContentSize(e);
},
_initPages: function() {
if (this.content) {
for (var t = this.content.children, e = 0; e < t.length; ++e) {
var i = t[e];
this._pages.indexOf(i) >= 0 || this._pages.push(i);
}
this._syncScrollDirection();
this._syncSizeMode();
this._updatePageView();
}
},
_dispatchPageTurningEvent: function() {
if (this._lastPageIdx !== this._curPageIdx) {
this._lastPageIdx = this._curPageIdx;
cc.Component.EventHandler.emitEvents(this.pageEvents, this, s.PAGE_TURNING);
this.node.emit("page-turning", this);
}
},
_isScrollable: function(t, e, i) {
if (this.sizeMode === n.Free) {
var s, o;
if (this.direction === r.Horizontal) {
s = this._scrollCenterOffsetX[e];
o = this._scrollCenterOffsetX[i];
return Math.abs(t.x) >= Math.abs(s - o) * this.scrollThreshold;
}
if (this.direction === r.Vertical) {
s = this._scrollCenterOffsetY[e];
o = this._scrollCenterOffsetY[i];
return Math.abs(t.y) >= Math.abs(s - o) * this.scrollThreshold;
}
} else {
if (this.direction === r.Horizontal) return Math.abs(t.x) >= this._view.width * this.scrollThreshold;
if (this.direction === r.Vertical) return Math.abs(t.y) >= this._view.height * this.scrollThreshold;
}
},
_isQuicklyScrollable: function(t) {
if (this.direction === r.Horizontal) {
if (Math.abs(t.x) > this.autoPageTurningThreshold) return !0;
} else if (this.direction === r.Vertical && Math.abs(t.y) > this.autoPageTurningThreshold) return !0;
return !1;
},
_moveOffsetValue: function(t) {
var e = cc.v2(0, 0);
this.sizeMode === n.Free ? this.direction === r.Horizontal ? e.x = this._scrollCenterOffsetX[t] : this.direction === r.Vertical && (e.y = this._scrollCenterOffsetY[t]) : this.direction === r.Horizontal ? e.x = t * this._view.width : this.direction === r.Vertical && (e.y = t * this._view.height);
return e;
},
_getDragDirection: function(t) {
return this.direction === r.Horizontal ? 0 === t.x ? 0 : t.x > 0 ? 1 : -1 : this.direction === r.Vertical ? 0 === t.y ? 0 : t.y < 0 ? 1 : -1 : void 0;
},
_handleReleaseLogic: function(t) {
this._autoScrollToPage();
if (this._scrolling) {
this._scrolling = !1;
this._autoScrolling || this._dispatchEvent("scroll-ended");
}
},
_autoScrollToPage: function() {
var t = this._startBounceBackIfNeeded(), e = this._touchBeganPosition.sub(this._touchEndPosition);
if (t) {
var i = this._getDragDirection(e);
if (0 === i) return;
this._curPageIdx = i > 0 ? this._pages.length - 1 : 0;
this.indicator && this.indicator._changedState();
} else {
var n = this._curPageIdx, r = n + this._getDragDirection(e), s = this.pageTurningSpeed * Math.abs(n - r);
if (r < this._pages.length) {
if (this._isScrollable(e, n, r)) {
this.scrollToPage(r, s);
return;
}
var o = this._calculateTouchMoveVelocity();
if (this._isQuicklyScrollable(o)) {
this.scrollToPage(r, s);
return;
}
}
this.scrollToPage(n, s);
}
},
_onTouchBegan: function(t, e) {
this._touchBeganPosition = t.touch.getLocation();
this._super(t, e);
},
_onTouchMoved: function(t, e) {
this._super(t, e);
},
_onTouchEnded: function(t, e) {
this._touchEndPosition = t.touch.getLocation();
this._super(t, e);
},
_onTouchCancelled: function(t, e) {
this._touchEndPosition = t.touch.getLocation();
this._super(t, e);
},
_onMouseWheel: function() {}
});
cc.PageView = e.exports = o;
}), {} ],
75: [ (function(t, e, i) {
var n = cc.Enum({
HORIZONTAL: 0,
VERTICAL: 1
}), r = cc.Class({
name: "cc.PageViewIndicator",
extends: t("./CCComponent"),
editor: !1,
properties: {
_layout: null,
_pageView: null,
_indicators: [],
spriteFrame: {
default: null,
type: cc.SpriteFrame,
tooltip: !1
},
direction: {
default: n.HORIZONTAL,
type: n,
tooltip: !1
},
cellSize: {
default: cc.size(20, 20),
tooltip: !1
},
spacing: {
default: 0,
tooltip: !1
}
},
statics: {
Direction: n
},
onLoad: function() {
this._updateLayout();
},
setPageView: function(t) {
this._pageView = t;
this._refresh();
},
_updateLayout: function() {
this._layout = this.getComponent(cc.Layout);
this._layout || (this._layout = this.addComponent(cc.Layout));
if (this.direction === n.HORIZONTAL) {
this._layout.type = cc.Layout.Type.HORIZONTAL;
this._layout.spacingX = this.spacing;
} else if (this.direction === n.VERTICAL) {
this._layout.type = cc.Layout.Type.VERTICAL;
this._layout.spacingY = this.spacing;
}
this._layout.resizeMode = cc.Layout.ResizeMode.CONTAINER;
},
_createIndicator: function() {
var t = new cc.Node();
t.addComponent(cc.Sprite).spriteFrame = this.spriteFrame;
t.parent = this.node;
t.width = this.cellSize.width;
t.height = this.cellSize.height;
return t;
},
_changedState: function() {
var t = this._indicators;
if (0 !== t.length) {
var e = this._pageView._curPageIdx;
if (!(e >= t.length)) {
for (var i = 0; i < t.length; ++i) {
t[i].opacity = 127.5;
}
t[e].opacity = 255;
}
}
},
_refresh: function() {
if (this._pageView) {
var t = this._indicators, e = this._pageView.getPages();
if (e.length !== t.length) {
var 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) {
var n = t[i - 1];
this.node.removeChild(n);
t.splice(i - 1, 1);
}
}
this._layout && this._layout.enabledInHierarchy && this._layout.updateLayout();
this._changedState();
}
}
}
});
cc.PageViewIndicator = e.exports = r;
}), {
"./CCComponent": 67
} ],
76: [ (function(t, e, i) {
var n = t("../utils/misc"), r = t("./CCComponent"), s = cc.Enum({
HORIZONTAL: 0,
VERTICAL: 1,
FILLED: 2
}), o = cc.Class({
name: "cc.ProgressBar",
extends: r,
editor: !1,
_initBarSprite: function() {
if (this.barSprite) {
var t = this.barSprite.node;
if (!t) return;
var e = this.node.getContentSize(), i = this.node.getAnchorPoint(), n = t.getContentSize();
t.parent === this.node && this.node.setContentSize(n);
this.barSprite.fillType === cc.Sprite.FillType.RADIAL && (this.mode = s.FILLED);
var r = t.getContentSize();
this.mode === s.HORIZONTAL ? this.totalLength = r.width : this.mode === s.VERTICAL ? this.totalLength = r.height : this.totalLength = this.barSprite.fillRange;
if (t.parent === this.node) {
var o = -e.width * i.x;
t.setPosition(cc.v2(o, 0));
}
}
},
_updateBarStatus: function() {
if (this.barSprite) {
var t = this.barSprite.node;
if (!t) return;
var e, i, r, o = t.getAnchorPoint(), a = t.getContentSize(), c = t.getPosition(), h = cc.v2(0, .5), l = n.clamp01(this.progress), u = this.totalLength * l;
switch (this.mode) {
case s.HORIZONTAL:
this.reverse && (h = cc.v2(1, .5));
e = cc.size(u, a.height);
i = this.totalLength;
r = a.height;
break;

case s.VERTICAL:
h = this.reverse ? cc.v2(.5, 1) : cc.v2(.5, 0);
e = cc.size(a.width, u);
i = a.width;
r = this.totalLength;
}
if (this.mode === s.FILLED) if (this.barSprite.type !== cc.Sprite.Type.FILLED) cc.warn("ProgressBar FILLED mode only works when barSprite's Type is FILLED!"); else {
this.reverse && (u *= -1);
this.barSprite.fillRange = u;
} else if (this.barSprite.type !== cc.Sprite.Type.FILLED) {
var _ = h.x - o.x, f = h.y - o.y, d = cc.v2(i * _, r * f);
t.setPosition(c.x + d.x, c.y + d.y);
t.setAnchorPoint(h);
t.setContentSize(e);
} else cc.warn("ProgressBar non-FILLED mode only works when barSprite's Type is non-FILLED!");
}
},
properties: {
barSprite: {
default: null,
type: cc.Sprite,
tooltip: !1,
notify: function() {
this._initBarSprite();
},
animatable: !1
},
mode: {
default: s.HORIZONTAL,
type: s,
tooltip: !1,
notify: function() {
if (this.barSprite) {
var t = this.barSprite.node;
if (!t) return;
var e = t.getContentSize();
this.mode === s.HORIZONTAL ? this.totalLength = e.width : this.mode === s.VERTICAL ? this.totalLength = e.height : this.mode === s.FILLED && (this.totalLength = this.barSprite.fillRange);
}
},
animatable: !1
},
_N$totalLength: 1,
totalLength: {
range: [ 0, Number.MAX_VALUE ],
tooltip: !1,
get: function() {
return this._N$totalLength;
},
set: function(t) {
this.mode === s.FILLED && (t = n.clamp01(t));
this._N$totalLength = t;
this._updateBarStatus();
}
},
progress: {
default: 1,
type: "Float",
range: [ 0, 1, .1 ],
slide: !0,
tooltip: !1,
notify: function() {
this._updateBarStatus();
}
},
reverse: {
default: !1,
tooltip: !1,
notify: function() {
this.barSprite && (this.barSprite.fillStart = 1 - this.barSprite.fillStart);
this._updateBarStatus();
},
animatable: !1
}
},
statics: {
Mode: s
}
});
cc.ProgressBar = e.exports = o;
}), {
"../utils/misc": 242,
"./CCComponent": 67
} ],
77: [ (function(t, e, i) {
var n = t("./CCComponent"), r = t("../renderer/render-engine"), s = t("../renderer/render-flow"), o = r.RenderData, a = cc.Class({
name: "RenderComponent",
extends: n,
editor: !1,
properties: {},
ctor: function() {
this._material = null;
this._renderData = null;
this.__allocedDatas = [];
this._vertexFormat = null;
this._toPostHandle = !1;
this._assembler = this.constructor._assembler;
this._postAssembler = this.constructor._postAssembler;
},
onEnable: function() {
this.node._renderComponent && (this.node._renderComponent.enabled = !1);
this.node._renderComponent = this;
this.node._renderFlag |= s.FLAG_RENDER | s.FLAG_UPDATE_RENDER_DATA | s.FLAG_COLOR;
},
onDisable: function() {
this.node._renderComponent = null;
this.disableRender();
},
onDestroy: function() {
for (var t = 0, e = this.__allocedDatas.length; t < e; t++) o.free(this.__allocedDatas[t]);
this.__allocedDatas.length = 0;
this._material = null;
this._renderData = null;
},
_canRender: function() {
return this._enabled && this.node._activeInHierarchy;
},
markForUpdateRenderData: function(t) {
t && this._canRender() ? this.node._renderFlag |= s.FLAG_UPDATE_RENDER_DATA : t || (this.node._renderFlag &= ~s.FLAG_UPDATE_RENDER_DATA);
},
markForRender: function(t) {
t && this._canRender() ? this.node._renderFlag |= s.FLAG_RENDER : t || (this.node._renderFlag &= ~s.FLAG_RENDER);
},
markForCustomIARender: function(t) {
t && this._canRender() ? this.node._renderFlag |= s.FLAG_CUSTOM_IA_RENDER : t || (this.node._renderFlag &= ~s.FLAG_CUSTOM_IA_RENDER);
},
disableRender: function() {
this.node._renderFlag &= ~(s.FLAG_RENDER | s.FLAG_CUSTOM_IA_RENDER | s.FLAG_UPDATE_RENDER_DATA | s.FLAG_COLOR);
},
requestRenderData: function() {
var t = o.alloc();
this.__allocedDatas.push(t);
return t;
},
destroyRenderData: function(t) {
var e = this.__allocedDatas.indexOf(t);
if (-1 !== e) {
this.__allocedDatas.splice(e, 1);
o.free(t);
}
},
_updateColor: function() {
var t = this._material;
if (t) {
if (t.useColor) {
t.color = this.node.color;
t.updateHash();
}
this.node._renderFlag &= ~s.FLAG_COLOR;
}
},
getMaterial: function() {
return this._material;
},
_updateMaterial: function(t) {
this._material = t;
t.updateHash();
}
});
a._assembler = null;
a._postAssembler = null;
cc.RenderComponent = e.exports = a;
}), {
"../renderer/render-engine": 202,
"../renderer/render-flow": 203,
"./CCComponent": 67
} ],
78: [ (function(i, n, r) {
var s = i("../platform/js"), o = i("../platform/CCMacro"), a = i("../utils/text-utils"), c = new (i("../utils/html-text-parser"))(), h = o.TextAlignment, l = o.VerticalTextAlignment;
var u = new s.Pool(function(t) {
0;
0;
return !!cc.isValid(t) && !t.getComponent(cc.LabelOutline);
}, 20);
u.get = function(i, n) {
var r = this._get();
r || (r = new cc.PrivateNode("RICHTEXT_CHILD"));
var s = r.getComponent(cc.Label);
s || (s = r.addComponent(cc.Label));
r.setPosition(0, 0);
r.setAnchorPoint(.5, .5);
r.setContentSize(128, 128);
r.skewX = 0;
"string" !== ("object" === (e = typeof i) ? t(i) : e) && (i = "" + i);
n.font instanceof cc.Font ? s.font = n.font : s.fontFamily = n.fontFamily;
s.string = i;
s.horizontalAlign = h.LEFT;
s.verticalAlign = l.TOP;
s.fontSize = n.fontSize || 40;
s.overflow = 0;
s.enableWrapText = !0;
s.lineHeight = 40;
s._enableBold(!1);
s._enableItalics(!1);
s._enableUnderline(!1);
return r;
};
var _ = cc.Class({
name: "cc.RichText",
extends: cc.Component,
ctor: function() {
this._textArray = null;
this._labelSegments = [];
this._labelSegmentsCache = [];
this._linesWidth = [];
this._updateRichTextStatus = this._updateRichText;
},
editor: !1,
properties: {
string: {
default: "<color=#00ff00>Rich</c><color=#0fffff>Text</color>",
multiline: !0,
tooltip: !1,
notify: function() {
this._updateRichTextStatus();
}
},
horizontalAlign: {
default: h.LEFT,
type: h,
tooltip: !1,
animatable: !1,
notify: function(t) {
if (this.horizontalAlign !== t) {
this._layoutDirty = !0;
this._updateRichTextStatus();
}
}
},
fontSize: {
default: 40,
tooltip: !1,
notify: function(t) {
if (this.fontSize !== t) {
this._layoutDirty = !0;
this._updateRichTextStatus();
}
}
},
_fontFamily: "Arial",
fontFamily: {
tooltip: !1,
get: function() {
return this._fontFamily;
},
set: function(t) {
if (this._fontFamily !== t) {
this._fontFamily = t;
this._layoutDirty = !0;
this._updateRichTextStatus();
}
},
animatable: !1
},
font: {
default: null,
type: cc.TTFFont,
tooltip: !1,
notify: function(t) {
if (this.font !== t) {
this._layoutDirty = !0;
if (this.font) {
this.useSystemFont = !1;
this._onTTFLoaded();
} else this.useSystemFont = !0;
this._updateRichTextStatus();
}
}
},
_isSystemFontUsed: !0,
useSystemFont: {
get: function() {
return this._isSystemFontUsed;
},
set: function(t) {
if ((t || this.font) && this._isSystemFontUsed !== t) {
this._isSystemFontUsed = t;
this._layoutDirty = !0;
this._updateRichTextStatus();
}
},
animatable: !1,
tooltip: !1
},
maxWidth: {
default: 0,
tooltip: !1,
notify: function(t) {
if (this.maxWidth !== t) {
this._layoutDirty = !0;
this._updateRichTextStatus();
}
}
},
lineHeight: {
default: 40,
tooltip: !1,
notify: function(t) {
if (this.lineHeight !== t) {
this._layoutDirty = !0;
this._updateRichTextStatus();
}
}
},
imageAtlas: {
default: null,
type: cc.SpriteAtlas,
tooltip: !1,
notify: function(t) {
if (this.imageAtlas !== t) {
this._layoutDirty = !0;
this._updateRichTextStatus();
}
}
},
handleTouchEvent: {
default: !0,
tooltip: !1,
notify: function(t) {
this.handleTouchEvent !== t && this.enabledInHierarchy && (this.handleTouchEvent ? this._addEventListeners() : this._removeEventListeners());
}
}
},
statics: {
HorizontalAlign: h,
VerticalAlign: l
},
onEnable: function() {
this.handleTouchEvent && this._addEventListeners();
this._updateRichText();
this._activateChildren(!0);
},
onDisable: function() {
this.handleTouchEvent && this._removeEventListeners();
this._activateChildren(!1);
},
start: function() {
this._onTTFLoaded();
},
_onColorChanged: function(t) {
this.node.children.forEach((function(e) {
e.color = t;
}));
},
_addEventListeners: function() {
this.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this);
this.node.on(cc.Node.EventType.COLOR_CHANGED, this._onColorChanged, this);
},
_removeEventListeners: function() {
this.node.off(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this);
this.node.off(cc.Node.EventType.COLOR_CHANGED, this._onColorChanged, this);
},
_updateLabelSegmentTextAttributes: function() {
this._labelSegments.forEach(function(t) {
this._applyTextAttribute(t);
}.bind(this));
},
_createFontLabel: function(t) {
return u.get(t, this);
},
_onTTFLoaded: function() {
var t = this;
if (this.font instanceof cc.TTFFont) if (this.font._nativeAsset) {
this._layoutDirty = !0;
this._updateRichText();
} else (function() {
var e = t;
cc.loader.load(t.font.nativeUrl, (function(t, i) {
e._layoutDirty = !0;
e._updateRichText();
}));
})(); else {
this._layoutDirty = !0;
this._updateRichText();
}
},
_measureText: function(t, e) {
var i = this, n = function(e) {
var n = void 0;
if (0 === i._labelSegmentsCache.length) {
n = i._createFontLabel(e);
i._labelSegmentsCache.push(n);
} else (n = i._labelSegmentsCache[0]).getComponent(cc.Label).string = e;
n._styleIndex = t;
i._applyTextAttribute(n);
return n.getContentSize().width;
};
return e ? n(e) : n;
},
_onTouchEnded: function(t) {
for (var e = this, i = this.node.getComponents(cc.Component), n = function(n) {
var r = e._labelSegments[n], s = r._clickHandler, o = r._clickParam;
if (s && e._containsTouchLocation(r, t.touch.getLocation())) {
i.forEach((function(e) {
e.enabledInHierarchy && e[s] && e[s](t, o);
}));
t.stopPropagation();
}
}, r = 0; r < this._labelSegments.length; ++r) n(r);
},
_containsTouchLocation: function(t, e) {
return t.getBoundingBoxToWorld().contains(e);
},
_resetState: function() {
for (var t = this.node.children, e = t.length - 1; e >= 0; e--) {
var i = t[e];
if ("RICHTEXT_CHILD" === i.name || "RICHTEXT_Image_CHILD" === i.name) {
i.parent === this.node ? i.parent = null : t.splice(e, 1);
"RICHTEXT_CHILD" === i.name && u.put(i);
}
}
this._labelSegments.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;
},
onRestore: !1,
_activateChildren: function(t) {
for (var e = this.node.children.length - 1; e >= 0; e--) {
var i = this.node.children[e];
"RICHTEXT_CHILD" !== i.name && "RICHTEXT_Image_CHILD" !== i.name || (i.active = t);
}
},
_addLabelSegment: function(t, e) {
var i = void 0;
0 === this._labelSegmentsCache.length ? i = this._createFontLabel(t) : (i = this._labelSegmentsCache.pop()).getComponent(cc.Label).string = t;
i._styleIndex = e;
i._lineCount = this._lineCount;
i.active = this.node.active;
i.setAnchorPoint(0, 0);
this._applyTextAttribute(i);
this.node.addChild(i);
this._labelSegments.push(i);
return i;
},
_updateRichTextWithMaxWidth: function(t, e, i) {
var n = e;
if (this._lineOffsetX > 0 && n + this._lineOffsetX > this.maxWidth) for (var r = 0; this._lineOffsetX <= this.maxWidth; ) {
var s = this._getFirstWordLen(t, r, t.length), o = t.substr(r, s), c = this._measureText(i, o);
if (!(this._lineOffsetX + c <= this.maxWidth)) {
if (r > 0) {
var h = t.substr(0, r);
this._addLabelSegment(h, i);
t = t.substr(r, t.length);
n = this._measureText(i, t);
}
this._updateLineInfo();
break;
}
this._lineOffsetX += c;
r += s;
}
if (n > this.maxWidth) for (var l = a.fragmentText(t, n, this.maxWidth, this._measureText(i)), u = 0; u < l.length; ++u) {
var _ = l[u], f = this._addLabelSegment(_, i).getContentSize();
this._lineOffsetX += f.width;
l.length > 1 && u < l.length - 1 && this._updateLineInfo();
} else {
this._lineOffsetX += n;
this._addLabelSegment(t, i);
}
},
_isLastComponentCR: function(t) {
return t.length - 1 === t.lastIndexOf("\n");
},
_updateLineInfo: function() {
this._linesWidth.push(this._lineOffsetX);
this._lineOffsetX = 0;
this._lineCount++;
},
_needsUpdateTextLayout: function(t) {
if (this._layoutDirty || !this._textArray || !t) return !0;
if (this._textArray.length !== t.length) return !0;
for (var e = 0; e < this._textArray.length; ++e) {
var i = this._textArray[e], n = t[e];
if (i.text !== n.text) return !0;
if (i.style) {
if (n.style) {
if (!!n.style.outline != !!i.style.outline) return !0;
if (i.style.size !== n.style.size || i.style.italic !== n.style.italic || i.style.isImage !== n.style.isImage) return !0;
if (i.style.isImage === n.style.isImage && i.style.src !== n.style.src) return !0;
} else if (i.style.size || i.style.italic || i.style.isImage || i.style.outline) return !0;
} else if (n.style && (n.style.size || n.style.italic || n.style.isImage || n.style.outline)) return !0;
}
return !1;
},
_addRichTextImageElement: function(t) {
var e = t.style.src, i = this.imageAtlas.getSpriteFrame(e);
if (i) {
var n = new cc.PrivateNode("RICHTEXT_Image_CHILD"), r = n.addComponent(cc.Sprite);
n.setAnchorPoint(0, 0);
r.type = cc.Sprite.Type.SLICED;
r.sizeMode = cc.Sprite.SizeMode.CUSTOM;
this.node.addChild(n);
this._labelSegments.push(n);
var s = i.getRect(), o = 1, a = s.width, c = s.height, h = t.style.imageWidth, l = t.style.imageHeight;
if (l > 0 && l < this.lineHeight) {
a *= o = l / c;
c *= o;
} else {
a *= o = this.lineHeight / c;
c *= o;
}
h > 0 && (a = h);
if (this.maxWidth > 0) {
this._lineOffsetX + a > this.maxWidth && this._updateLineInfo();
this._lineOffsetX += a;
} else {
this._lineOffsetX += a;
this._lineOffsetX > this._labelWidth && (this._labelWidth = this._lineOffsetX);
}
r.spriteFrame = i;
n.setContentSize(a, c);
n._lineCount = this._lineCount;
if (t.style.event) {
t.style.event.click && (n._clickHandler = t.style.event.click);
t.style.event.param && (n._clickParam = t.style.event.param);
}
} else cc.warnID(4400);
},
_updateRichText: function() {
if (this.enabled) {
var t = c.parse(this.string);
if (this._needsUpdateTextLayout(t)) {
this._textArray = t;
this._resetState();
for (var e = !1, i = void 0, n = 0; n < this._textArray.length; ++n) {
var r = this._textArray[n], s = r.text;
if ("" === s) {
if (r.style && r.style.newline) {
this._updateLineInfo();
continue;
}
if (r.style && r.style.isImage && this.imageAtlas) {
this._addRichTextImageElement(r);
continue;
}
}
for (var o = s.split("\n"), a = 0; a < o.length; ++a) {
var h = o[a];
if ("" !== h) {
e = !1;
if (this.maxWidth > 0) {
var l = this._measureText(n, h);
this._updateRichTextWithMaxWidth(h, l, n);
o.length > 1 && a < o.length - 1 && this._updateLineInfo();
} else {
i = this._addLabelSegment(h, n).getContentSize();
this._lineOffsetX += i.width;
this._lineOffsetX > this._labelWidth && (this._labelWidth = this._lineOffsetX);
o.length > 1 && a < o.length - 1 && this._updateLineInfo();
}
} else {
if (this._isLastComponentCR(s) && a === o.length - 1) continue;
this._updateLineInfo();
e = !0;
}
}
}
e || this._linesWidth.push(this._lineOffsetX);
this.maxWidth > 0 && (this._labelWidth = this.maxWidth);
this._labelHeight = this._lineCount * this.lineHeight;
this.node.setContentSize(this._labelWidth, this._labelHeight);
this._updateRichTextPosition();
this._layoutDirty = !1;
} else {
this._textArray = t;
this._updateLabelSegmentTextAttributes();
}
}
},
_getFirstWordLen: function(t, e, i) {
var n = t.charAt(e);
if (a.isUnicodeCJK(n) || a.isUnicodeSpace(n)) return 1;
for (var r = 1, s = e + 1; s < i; ++s) {
n = t.charAt(s);
if (a.isUnicodeSpace(n) || a.isUnicodeCJK(n)) break;
r++;
}
return r;
},
_updateRichTextPosition: function() {
for (var t = 0, e = 1, i = this._lineCount, n = 0; n < this._labelSegments.length; ++n) {
var r = this._labelSegments[n], s = r._lineCount;
if (s > e) {
t = 0;
e = s;
}
var o = 0;
switch (this.horizontalAlign) {
case h.LEFT:
o = -this._labelWidth / 2;
break;

case h.CENTER:
o = -this._linesWidth[s - 1] / 2;
break;

case h.RIGHT:
o = this._labelWidth / 2 - this._linesWidth[s - 1];
}
r.x = t + o;
var a = r.getContentSize();
r.y = this.lineHeight * (i - s) - this._labelHeight / 2;
s === e && (t += a.width);
}
},
_convertLiteralColorValue: function(t) {
var e = t.toUpperCase();
return cc.Color[e] ? cc.Color[e] : cc.color().fromHEX(t);
},
_applyTextAttribute: function(t) {
var e = t.getComponent(cc.Label);
if (e) {
var i = t._styleIndex;
this._isSystemFontUsed && (e.fontFamily = this._fontFamily);
e.useSystemFont = this._isSystemFontUsed;
e.lineHeight = this.lineHeight;
e.horizontalAlign = h.LEFT;
e.verticalAlign = l.CENTER;
var n = null;
this._textArray[i] && (n = this._textArray[i].style);
n && n.color ? t.color = this._convertLiteralColorValue(n.color) : t.color = this.node.color;
e._enableBold(n && n.bold);
e._enableItalics(n && n.italic);
n && n.italic && (t.skewX = 12);
e._enableUnderline(n && n.underline);
if (n && n.outline) {
var r = t.getComponent(cc.LabelOutline);
r || (r = t.addComponent(cc.LabelOutline));
r.color = this._convertLiteralColorValue(n.outline.color);
r.width = n.outline.width;
}
n && n.size ? e.fontSize = n.size : e.fontSize = this.fontSize;
e._updateRenderData(!0);
if (n && n.event) {
n.event.click && (t._clickHandler = n.event.click);
n.event.param && (t._clickParam = n.event.param);
}
}
},
onDestroy: function() {
for (var t = 0; t < this._labelSegments.length; ++t) {
this._labelSegments[t].removeFromParent();
u.put(this._labelSegments[t]);
}
}
});
cc.RichText = n.exports = _;
}), {
"../platform/CCMacro": 165,
"../platform/js": 180,
"../utils/html-text-parser": 239,
"../utils/text-utils": 249
} ],
79: [ (function(t, e, i) {
var n = t("../utils/misc"), r = (t("./CCComponent"), cc.Enum({
HORIZONTAL: 0,
VERTICAL: 1
})), s = cc.Class({
name: "cc.Scrollbar",
extends: t("./CCComponent"),
editor: !1,
properties: {
_scrollView: null,
_touching: !1,
_autoHideRemainingTime: {
default: 0,
serializable: !1
},
_opacity: 255,
handle: {
default: null,
type: cc.Sprite,
tooltip: !1,
notify: function() {
this._onScroll(cc.v2(0, 0));
},
animatable: !1
},
direction: {
default: r.HORIZONTAL,
type: r,
tooltip: !1,
notify: function() {
this._onScroll(cc.v2(0, 0));
},
animatable: !1
},
enableAutoHide: {
default: !0,
animatable: !1,
tooltip: !1
},
autoHideTime: {
default: 1,
animatable: !1,
tooltip: !1
}
},
statics: {
Direction: r
},
setTargetScrollView: function(t) {
this._scrollView = t;
},
_convertToScrollViewSpace: function(t) {
var e = t.convertToWorldSpace(cc.v2(0, 0));
return this._scrollView.node.convertToNodeSpace(e);
},
_setOpacity: function(t) {
if (this.handle) {
this.node.opacity = t;
this.handle.node.opacity = t;
}
},
_onScroll: function(t) {
if (this._scrollView) {
var e = this._scrollView.content;
if (e) {
var i = e.getContentSize(), n = this._scrollView.node.getContentSize(), s = this.node.getContentSize();
if (this._conditionalDisableScrollBar(i, n)) return;
if (this.enableAutoHide) {
this._autoHideRemainingTime = this.autoHideTime;
this._setOpacity(this._opacity);
}
var o = 0, a = 0, c = 0, h = 0, l = 0;
if (this.direction === r.HORIZONTAL) {
o = i.width;
a = n.width;
l = s.width;
c = t.x;
h = -this._convertToScrollViewSpace(e).x;
} else if (this.direction === r.VERTICAL) {
o = i.height;
a = n.height;
l = s.height;
c = t.y;
h = -this._convertToScrollViewSpace(e).y;
}
var u = this._calculateLength(o, a, l, c), _ = this._calculatePosition(o, a, l, h, c, u);
this._updateLength(u);
this._updateHanlderPosition(_);
}
}
},
_updateHanlderPosition: function(t) {
if (this.handle) {
var e = this._fixupHandlerPosition();
this.handle.node.setPosition(t.x + e.x, t.y + e.y);
}
},
_fixupHandlerPosition: function() {
var t = this.node.getContentSize(), e = this.node.getAnchorPoint(), i = this.handle.node.getContentSize(), n = this.handle.node.parent, s = this.node.convertToWorldSpaceAR(cc.v2(-t.width * e.x, -t.height * e.y)), o = n.convertToNodeSpaceAR(s);
this.direction === r.HORIZONTAL ? o = cc.v2(o.x, o.y + (t.height - i.height) / 2) : this.direction === r.VERTICAL && (o = cc.v2(o.x + (t.width - i.width) / 2, o.y));
this.handle.node.setPosition(o);
return o;
},
_onTouchBegan: function() {
this.enableAutoHide && (this._touching = !0);
},
_conditionalDisableScrollBar: function(t, e) {
return t.width <= e.width && this.direction === r.HORIZONTAL || t.height <= e.height && this.direction === r.VERTICAL;
},
_onTouchEnded: function() {
if (this.enableAutoHide) {
this._touching = !1;
if (!(this.autoHideTime <= 0)) {
if (this._scrollView) {
var t = this._scrollView.content;
if (t) {
var e = t.getContentSize(), i = this._scrollView.node.getContentSize();
if (this._conditionalDisableScrollBar(e, i)) return;
}
}
this._autoHideRemainingTime = this.autoHideTime;
}
}
},
_calculateLength: function(t, e, i, n) {
var r = t;
n && (r += 20 * (n > 0 ? n : -n));
return i * (e / r);
},
_calculatePosition: function(t, e, i, s, o, a) {
var c = t - e;
o && (c += Math.abs(o));
var h = 0;
if (c) {
h = s / c;
h = n.clamp01(h);
}
var l = (i - a) * h;
return this.direction === r.VERTICAL ? cc.v2(0, l) : cc.v2(l, 0);
},
_updateLength: function(t) {
if (this.handle) {
var e = this.handle.node, i = e.getContentSize();
e.setAnchorPoint(cc.v2(0, 0));
this.direction === r.HORIZONTAL ? e.setContentSize(t, i.height) : e.setContentSize(i.width, t);
}
},
_processAutoHide: function(t) {
if (this.enableAutoHide && !(this._autoHideRemainingTime <= 0) && !this._touching) {
this._autoHideRemainingTime -= t;
if (this._autoHideRemainingTime <= this.autoHideTime) {
this._autoHideRemainingTime = Math.max(0, this._autoHideRemainingTime);
var e = this._opacity * (this._autoHideRemainingTime / this.autoHideTime);
this._setOpacity(e);
}
}
},
start: function() {
this.enableAutoHide && this._setOpacity(0);
},
hide: function() {
this._autoHideRemainingTime = 0;
this._setOpacity(0);
},
show: function() {
this._autoHideRemainingTime = this.autoHideTime;
this._setOpacity(this._opacity);
},
update: function(t) {
this._processAutoHide(t);
}
});
cc.Scrollbar = e.exports = s;
}), {
"../utils/misc": 242,
"./CCComponent": 67
} ],
80: [ (function(t, e, i) {
var n = t("../CCNode").EventType, r = function() {
return new Date().getMilliseconds();
}, s = cc.Enum({
SCROLL_TO_TOP: 0,
SCROLL_TO_BOTTOM: 1,
SCROLL_TO_LEFT: 2,
SCROLL_TO_RIGHT: 3,
SCROLLING: 4,
BOUNCE_TOP: 5,
BOUNCE_BOTTOM: 6,
BOUNCE_LEFT: 7,
BOUNCE_RIGHT: 8,
SCROLL_ENDED: 9,
TOUCH_UP: 10,
AUTOSCROLL_ENDED_WITH_THRESHOLD: 11,
SCROLL_BEGAN: 12
}), o = {
"scroll-to-top": s.SCROLL_TO_TOP,
"scroll-to-bottom": s.SCROLL_TO_BOTTOM,
"scroll-to-left": s.SCROLL_TO_LEFT,
"scroll-to-right": s.SCROLL_TO_RIGHT,
scrolling: s.SCROLLING,
"bounce-bottom": s.BOUNCE_BOTTOM,
"bounce-left": s.BOUNCE_LEFT,
"bounce-right": s.BOUNCE_RIGHT,
"bounce-top": s.BOUNCE_TOP,
"scroll-ended": s.SCROLL_ENDED,
"touch-up": s.TOUCH_UP,
"scroll-ended-with-threshold": s.AUTOSCROLL_ENDED_WITH_THRESHOLD,
"scroll-began": s.SCROLL_BEGAN
}, a = cc.Class({
name: "cc.ScrollView",
extends: t("./CCViewGroup"),
editor: !1,
ctor: function() {
this._topBoundary = 0;
this._bottomBoundary = 0;
this._leftBoundary = 0;
this._rightBoundary = 0;
this._touchMoveDisplacements = [];
this._touchMoveTimeDeltas = [];
this._touchMovePreviousTimestamp = 0;
this._touchMoved = !1;
this._autoScrolling = !1;
this._autoScrollAttenuate = !1;
this._autoScrollStartPosition = cc.v2(0, 0);
this._autoScrollTargetDelta = cc.v2(0, 0);
this._autoScrollTotalTime = 0;
this._autoScrollAccumulatedTime = 0;
this._autoScrollCurrentlyOutOfBoundary = !1;
this._autoScrollBraking = !1;
this._autoScrollBrakingStartPosition = cc.v2(0, 0);
this._outOfBoundaryAmount = cc.v2(0, 0);
this._outOfBoundaryAmountDirty = !0;
this._stopMouseWheel = !1;
this._mouseWheelEventElapsedTime = 0;
this._isScrollEndedWithThresholdEventFired = !1;
this._scrollEventEmitMask = 0;
this._isBouncing = !1;
this._scrolling = !1;
},
properties: {
content: {
default: void 0,
type: cc.Node,
tooltip: !1,
formerlySerializedAs: "content",
notify: function(t) {
this._calculateBoundary();
}
},
horizontal: {
default: !0,
animatable: !1,
tooltip: !1
},
vertical: {
default: !0,
animatable: !1,
tooltip: !1
},
inertia: {
default: !0,
tooltip: !1
},
brake: {
default: .5,
type: "Float",
range: [ 0, 1, .1 ],
tooltip: !1
},
elastic: {
default: !0,
animatable: !1,
tooltip: !1
},
bounceDuration: {
default: 1,
range: [ 0, 10 ],
tooltip: !1
},
horizontalScrollBar: {
default: void 0,
type: cc.Scrollbar,
tooltip: !1,
notify: function() {
if (this.horizontalScrollBar) {
this.horizontalScrollBar.setTargetScrollView(this);
this._updateScrollBar(0);
}
},
animatable: !1
},
verticalScrollBar: {
default: void 0,
type: cc.Scrollbar,
tooltip: !1,
notify: function() {
if (this.verticalScrollBar) {
this.verticalScrollBar.setTargetScrollView(this);
this._updateScrollBar(0);
}
},
animatable: !1
},
scrollEvents: {
default: [],
type: cc.Component.EventHandler,
tooltip: !1
},
cancelInnerEvents: {
default: !0,
animatable: !1,
tooltip: !1
},
_view: {
get: function() {
if (this.content) return this.content.parent;
}
}
},
statics: {
EventType: s
},
scrollToBottom: function(t, e) {
var i = this._calculateMovePercentDelta({
anchor: cc.v2(0, 0),
applyToHorizontal: !1,
applyToVertical: !0
});
t ? this._startAutoScroll(i, t, !1 !== e) : this._moveContent(i, !0);
},
scrollToTop: function(t, e) {
var i = this._calculateMovePercentDelta({
anchor: cc.v2(0, 1),
applyToHorizontal: !1,
applyToVertical: !0
});
t ? this._startAutoScroll(i, t, !1 !== e) : this._moveContent(i);
},
scrollToLeft: function(t, e) {
var i = this._calculateMovePercentDelta({
anchor: cc.v2(0, 0),
applyToHorizontal: !0,
applyToVertical: !1
});
t ? this._startAutoScroll(i, t, !1 !== e) : this._moveContent(i);
},
scrollToRight: function(t, e) {
var i = this._calculateMovePercentDelta({
anchor: cc.v2(1, 0),
applyToHorizontal: !0,
applyToVertical: !1
});
t ? this._startAutoScroll(i, t, !1 !== e) : this._moveContent(i);
},
scrollToTopLeft: function(t, e) {
var i = this._calculateMovePercentDelta({
anchor: cc.v2(0, 1),
applyToHorizontal: !0,
applyToVertical: !0
});
t ? this._startAutoScroll(i, t, !1 !== e) : this._moveContent(i);
},
scrollToTopRight: function(t, e) {
var i = this._calculateMovePercentDelta({
anchor: cc.v2(1, 1),
applyToHorizontal: !0,
applyToVertical: !0
});
t ? this._startAutoScroll(i, t, !1 !== e) : this._moveContent(i);
},
scrollToBottomLeft: function(t, e) {
var i = this._calculateMovePercentDelta({
anchor: cc.v2(0, 0),
applyToHorizontal: !0,
applyToVertical: !0
});
t ? this._startAutoScroll(i, t, !1 !== e) : this._moveContent(i);
},
scrollToBottomRight: function(t, e) {
var i = this._calculateMovePercentDelta({
anchor: cc.v2(1, 0),
applyToHorizontal: !0,
applyToVertical: !0
});
t ? this._startAutoScroll(i, t, !1 !== e) : this._moveContent(i);
},
scrollToOffset: function(t, e, i) {
var n = this.getMaxScrollOffset(), r = cc.v2(0, 0);
0 === n.x ? r.x = 0 : r.x = t.x / n.x;
0 === n.y ? r.y = 1 : r.y = (n.y - t.y) / n.y;
this.scrollTo(r, e, i);
},
getScrollOffset: function() {
var t = this._getContentTopBoundary() - this._topBoundary, e = this._getContentLeftBoundary() - this._leftBoundary;
return cc.v2(e, t);
},
getMaxScrollOffset: function() {
var t = this._view.getContentSize(), e = this.content.getContentSize(), i = e.width - t.width, n = e.height - t.height;
i = i >= 0 ? i : 0;
n = n >= 0 ? n : 0;
return cc.v2(i, n);
},
scrollToPercentHorizontal: function(t, e, i) {
var n = this._calculateMovePercentDelta({
anchor: cc.v2(t, 0),
applyToHorizontal: !0,
applyToVertical: !1
});
e ? this._startAutoScroll(n, e, !1 !== i) : this._moveContent(n);
},
scrollTo: function(t, e, i) {
var n = this._calculateMovePercentDelta({
anchor: cc.v2(t),
applyToHorizontal: !0,
applyToVertical: !0
});
e ? this._startAutoScroll(n, e, !1 !== i) : this._moveContent(n);
},
scrollToPercentVertical: function(t, e, i) {
var n = this._calculateMovePercentDelta({
anchor: cc.v2(0, t),
applyToHorizontal: !1,
applyToVertical: !0
});
e ? this._startAutoScroll(n, e, !1 !== i) : this._moveContent(n);
},
stopAutoScroll: function() {
this._autoScrolling = !1;
this._autoScrollAccumulatedTime = this._autoScrollTotalTime;
},
setContentPosition: function(t) {
if (!t.fuzzyEquals(this.getContentPosition(), 1e-4)) {
this.content.setPosition(t);
this._outOfBoundaryAmountDirty = !0;
}
},
getContentPosition: function() {
return this.content.getPosition();
},
isScrolling: function() {
return this._scrolling;
},
isAutoScrolling: function() {
return this._autoScrolling;
},
_registerEvent: function() {
this.node.on(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this, !0);
this.node.on(cc.Node.EventType.TOUCH_MOVE, this._onTouchMoved, this, !0);
this.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this, !0);
this.node.on(cc.Node.EventType.TOUCH_CANCEL, this._onTouchCancelled, this, !0);
this.node.on(cc.Node.EventType.MOUSE_WHEEL, this._onMouseWheel, this, !0);
},
_unregisterEvent: function() {
this.node.off(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this, !0);
this.node.off(cc.Node.EventType.TOUCH_MOVE, this._onTouchMoved, this, !0);
this.node.off(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this, !0);
this.node.off(cc.Node.EventType.TOUCH_CANCEL, this._onTouchCancelled, this, !0);
this.node.off(cc.Node.EventType.MOUSE_WHEEL, this._onMouseWheel, this, !0);
},
_onMouseWheel: function(t, e) {
if (this.enabledInHierarchy && !this._hasNestedViewGroup(t, e)) {
var i = cc.v2(0, 0), n = -.1;
n = -7;
this.vertical ? i = cc.v2(0, t.getScrollY() * n) : this.horizontal && (i = cc.v2(t.getScrollY() * n, 0));
this._mouseWheelEventElapsedTime = 0;
this._processDeltaMove(i);
if (!this._stopMouseWheel) {
this._handlePressLogic();
this.schedule(this._checkMouseWheel, 1 / 60);
this._stopMouseWheel = !0;
}
this._stopPropagationIfTargetIsMe(t);
}
},
_checkMouseWheel: function(t) {
if (this._getHowMuchOutOfBoundary().fuzzyEquals(cc.v2(0, 0), 1e-4)) {
this._mouseWheelEventElapsedTime += t;
if (this._mouseWheelEventElapsedTime > .1) {
this._onScrollBarTouchEnded();
this.unschedule(this._checkMouseWheel);
this._stopMouseWheel = !1;
}
} else {
this._processInertiaScroll();
this.unschedule(this._checkMouseWheel);
this._stopMouseWheel = !1;
}
},
_calculateMovePercentDelta: function(t) {
var e = t.anchor, i = t.applyToHorizontal, n = t.applyToVertical;
this._calculateBoundary();
e = e.clampf(cc.v2(0, 0), cc.v2(1, 1));
var r = this._view.getContentSize(), s = this.content.getContentSize(), o = this._getContentBottomBoundary() - this._bottomBoundary;
o = -o;
var a = this._getContentLeftBoundary() - this._leftBoundary;
a = -a;
var c = cc.v2(0, 0), h = 0;
if (i) {
h = s.width - r.width;
c.x = a - h * e.x;
}
if (n) {
h = s.height - r.height;
c.y = o - h * e.y;
}
return c;
},
_moveContentToTopLeft: function(t) {
var e = this.content.getContentSize(), i = this._getContentBottomBoundary() - this._bottomBoundary;
i = -i;
var n = cc.v2(0, 0), r = 0, s = this._getContentLeftBoundary() - this._leftBoundary;
s = -s;
if (e.height < t.height) {
r = e.height - t.height;
n.y = i - r;
this.verticalScrollBar && this.verticalScrollBar.hide();
} else this.verticalScrollBar && this.verticalScrollBar.show();
if (e.width < t.width) {
r = e.width - t.width;
n.x = s;
this.horizontalScrollBar && this.horizontalScrollBar.hide();
} else this.horizontalScrollBar && this.horizontalScrollBar.show();
this._moveContent(n);
this._adjustContentOutOfBoundary();
},
_calculateBoundary: function() {
if (this.content) {
var t = this.content.getComponent(cc.Layout);
t && t.enabledInHierarchy && t.updateLayout();
var e = this._view.getContentSize(), i = e.width * this._view.anchorX, n = e.height * this._view.anchorY;
this._leftBoundary = -i;
this._bottomBoundary = -n;
this._rightBoundary = this._leftBoundary + e.width;
this._topBoundary = this._bottomBoundary + e.height;
this._moveContentToTopLeft(e);
}
},
_hasNestedViewGroup: function(t, e) {
if (t.eventPhase === cc.Event.CAPTURING_PHASE) {
if (e) for (var i = 0; i < e.length; ++i) {
var n = e[i];
if (this.node === n) return !!t.target.getComponent(cc.ViewGroup);
if (n.getComponent(cc.ViewGroup)) return !0;
}
return !1;
}
},
_stopPropagationIfTargetIsMe: function(t) {
t.eventPhase === cc.Event.AT_TARGET && t.target === this.node && t.stopPropagation();
},
_onTouchBegan: function(t, e) {
if (this.enabledInHierarchy && !this._hasNestedViewGroup(t, e)) {
var i = t.touch;
this.content && this._handlePressLogic(i);
this._touchMoved = !1;
this._stopPropagationIfTargetIsMe(t);
}
},
_onTouchMoved: function(t, e) {
if (this.enabledInHierarchy && !this._hasNestedViewGroup(t, e)) {
var i = t.touch;
this.content && this._handleMoveLogic(i);
if (this.cancelInnerEvents) {
if (i.getLocation().sub(i.getStartLocation()).mag() > 7 && !this._touchMoved && t.target !== this.node) {
var n = new cc.Event.EventTouch(t.getTouches(), t.bubbles);
n.type = cc.Node.EventType.TOUCH_CANCEL;
n.touch = t.touch;
n.simulate = !0;
t.target.dispatchEvent(n);
this._touchMoved = !0;
}
this._stopPropagationIfTargetIsMe(t);
}
}
},
_onTouchEnded: function(t, e) {
if (this.enabledInHierarchy && !this._hasNestedViewGroup(t, e)) {
this._dispatchEvent("touch-up");
var i = t.touch;
this.content && this._handleReleaseLogic(i);
this._touchMoved ? t.stopPropagation() : this._stopPropagationIfTargetIsMe(t);
}
},
_onTouchCancelled: function(t, e) {
if (this.enabledInHierarchy && !this._hasNestedViewGroup(t, e)) {
if (!t.simulate) {
var i = t.touch;
this.content && this._handleReleaseLogic(i);
}
this._stopPropagationIfTargetIsMe(t);
}
},
_processDeltaMove: function(t) {
this._scrollChildren(t);
this._gatherTouchMove(t);
},
_handleMoveLogic: function(t) {
var e = t.getDelta();
this._processDeltaMove(e);
},
_scrollChildren: function(t) {
var e = t = this._clampDelta(t), i = void 0;
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 = e.add(i);
}
var n = -1;
if (e.y > 0) {
this.content.y - this.content.anchorY * this.content.height + e.y > this._bottomBoundary && (n = "scroll-to-bottom");
} else if (e.y < 0) {
this.content.y - this.content.anchorY * this.content.height + this.content.height + e.y <= this._topBoundary && (n = "scroll-to-top");
} else if (e.x < 0) {
this.content.x - this.content.anchorX * this.content.width + this.content.width + e.x <= this._rightBoundary && (n = "scroll-to-right");
} else if (e.x > 0) {
this.content.x - this.content.anchorX * this.content.width + e.x >= this._leftBoundary && (n = "scroll-to-left");
}
this._moveContent(e, !1);
if (0 !== e.x || 0 !== e.y) {
if (!this._scrolling) {
this._scrolling = !0;
this._dispatchEvent("scroll-began");
}
this._dispatchEvent("scrolling");
}
-1 !== n && this._dispatchEvent(n);
},
_handlePressLogic: function() {
this._autoScrolling && this._dispatchEvent("scroll-ended");
this._autoScrolling = !1;
this._isBouncing = !1;
this._touchMovePreviousTimestamp = r();
this._touchMoveDisplacements.length = 0;
this._touchMoveTimeDeltas.length = 0;
this._onScrollBarTouchBegan();
},
_clampDelta: function(t) {
var e = this.content.getContentSize(), i = this.node.getContentSize();
e.width < i.width && (t.x = 0);
e.height < i.height && (t.y = 0);
return t;
},
_gatherTouchMove: function(t) {
t = this._clampDelta(t);
for (;this._touchMoveDisplacements.length >= 5; ) {
this._touchMoveDisplacements.shift();
this._touchMoveTimeDeltas.shift();
}
this._touchMoveDisplacements.push(t);
var e = r();
this._touchMoveTimeDeltas.push((e - this._touchMovePreviousTimestamp) / 1e3);
this._touchMovePreviousTimestamp = e;
},
_startBounceBackIfNeeded: function() {
if (!this.elastic) return !1;
var t = this._getHowMuchOutOfBoundary();
if ((t = this._clampDelta(t)).fuzzyEquals(cc.v2(0, 0), 1e-4)) return !1;
var e = Math.max(this.bounceDuration, 0);
this._startAutoScroll(t, e, !0);
if (!this._isBouncing) {
t.y > 0 && this._dispatchEvent("bounce-top");
t.y < 0 && this._dispatchEvent("bounce-bottom");
t.x > 0 && this._dispatchEvent("bounce-right");
t.x < 0 && this._dispatchEvent("bounce-left");
this._isBouncing = !0;
}
return !0;
},
_processInertiaScroll: function() {
if (!this._startBounceBackIfNeeded() && this.inertia) {
var t = this._calculateTouchMoveVelocity();
!t.fuzzyEquals(cc.v2(0, 0), 1e-4) && this.brake < 1 && this._startInertiaScroll(t);
}
this._onScrollBarTouchEnded();
},
_handleReleaseLogic: function(t) {
var e = t.getDelta();
this._gatherTouchMove(e);
this._processInertiaScroll();
if (this._scrolling) {
this._scrolling = !1;
this._autoScrolling || this._dispatchEvent("scroll-ended");
}
},
_isOutOfBoundary: function() {
return !this._getHowMuchOutOfBoundary().fuzzyEquals(cc.v2(0, 0), 1e-4);
},
_isNecessaryAutoScrollBrake: function() {
if (this._autoScrollBraking) return !0;
if (this._isOutOfBoundary()) {
if (!this._autoScrollCurrentlyOutOfBoundary) {
this._autoScrollCurrentlyOutOfBoundary = !0;
this._autoScrollBraking = !0;
this._autoScrollBrakingStartPosition = this.getContentPosition();
return !0;
}
} else this._autoScrollCurrentlyOutOfBoundary = !1;
return !1;
},
getScrollEndedEventTiming: function() {
return 1e-4;
},
_processAutoScrolling: function(t) {
var e = this._isNecessaryAutoScrollBrake(), i = e ? .05 : 1;
this._autoScrollAccumulatedTime += t * (1 / i);
var n = Math.min(1, this._autoScrollAccumulatedTime / this._autoScrollTotalTime);
this._autoScrollAttenuate && (n = (function(t) {
return (t -= 1) * t * t * t * t + 1;
})(n));
var r = this._autoScrollStartPosition.add(this._autoScrollTargetDelta.mul(n)), s = Math.abs(n - 1) <= 1e-4;
if (Math.abs(n - 1) <= this.getScrollEndedEventTiming() && !this._isScrollEndedWithThresholdEventFired) {
this._dispatchEvent("scroll-ended-with-threshold");
this._isScrollEndedWithThresholdEventFired = !0;
}
if (this.elastic) {
var o = r.sub(this._autoScrollBrakingStartPosition);
e && (o = o.mul(i));
r = this._autoScrollBrakingStartPosition.add(o);
} else {
var a = r.sub(this.getContentPosition()), c = this._getHowMuchOutOfBoundary(a);
if (!c.fuzzyEquals(cc.v2(0, 0), 1e-4)) {
r = r.add(c);
s = !0;
}
}
s && (this._autoScrolling = !1);
var h = r.sub(this.getContentPosition());
this._moveContent(this._clampDelta(h), s);
this._dispatchEvent("scrolling");
if (!this._autoScrolling) {
this._isBouncing = !1;
this._scrolling = !1;
this._dispatchEvent("scroll-ended");
}
},
_startInertiaScroll: function(t) {
var e = t.mul(.7);
this._startAttenuatingAutoScroll(e, t);
},
_calculateAttenuatedFactor: function(t) {
return this.brake <= 0 ? 1 - this.brake : (1 - this.brake) * (1 / (1 + 14e-6 * t + t * t * 8e-9));
},
_startAttenuatingAutoScroll: function(t, e) {
var i = this._calculateAutoScrollTimeByInitalSpeed(e.mag()), n = t.normalize(), r = this.content.getContentSize(), s = this.node.getContentSize(), o = r.width - s.width, a = r.height - s.height, c = this._calculateAttenuatedFactor(o), h = this._calculateAttenuatedFactor(a);
n = cc.v2(n.x * o * (1 - this.brake) * c, n.y * a * h * (1 - this.brake));
var l = t.mag(), u = n.mag() / l;
n = n.add(t);
if (this.brake > 0 && u > 7) {
u = Math.sqrt(u);
n = t.mul(u).add(t);
}
this.brake > 0 && u > 3 && (i *= u = 3);
0 === this.brake && u > 1 && (i *= u);
this._startAutoScroll(n, i, !0);
},
_calculateAutoScrollTimeByInitalSpeed: function(t) {
return Math.sqrt(Math.sqrt(t / 5));
},
_startAutoScroll: function(t, e, i) {
var n = this._flattenVectorByDirection(t);
this._autoScrolling = !0;
this._autoScrollTargetDelta = n;
this._autoScrollAttenuate = i;
this._autoScrollStartPosition = this.getContentPosition();
this._autoScrollTotalTime = e;
this._autoScrollAccumulatedTime = 0;
this._autoScrollBraking = !1;
this._isScrollEndedWithThresholdEventFired = !1;
this._autoScrollBrakingStartPosition = cc.v2(0, 0);
this._getHowMuchOutOfBoundary().fuzzyEquals(cc.v2(0, 0), 1e-4) || (this._autoScrollCurrentlyOutOfBoundary = !0);
},
_calculateTouchMoveVelocity: function() {
var t = 0;
if ((t = this._touchMoveTimeDeltas.reduce((function(t, e) {
return t + e;
}), t)) <= 0 || t >= .5) return cc.v2(0, 0);
var e = cc.v2(0, 0);
e = this._touchMoveDisplacements.reduce((function(t, e) {
return t.add(e);
}), e);
return cc.v2(e.x * (1 - this.brake) / t, e.y * (1 - this.brake) / t);
},
_flattenVectorByDirection: function(t) {
var e = t;
e.x = this.horizontal ? e.x : 0;
e.y = this.vertical ? e.y : 0;
return e;
},
_moveContent: function(t, e) {
var i = this._flattenVectorByDirection(t), n = this.getContentPosition().add(i);
this.setContentPosition(n);
var r = this._getHowMuchOutOfBoundary();
this._updateScrollBar(r);
this.elastic && e && this._startBounceBackIfNeeded();
},
_getContentLeftBoundary: function() {
return this.getContentPosition().x - this.content.getAnchorPoint().x * this.content.getContentSize().width;
},
_getContentRightBoundary: function() {
var t = this.content.getContentSize();
return this._getContentLeftBoundary() + t.width;
},
_getContentTopBoundary: function() {
var t = this.content.getContentSize();
return this._getContentBottomBoundary() + t.height;
},
_getContentBottomBoundary: function() {
return this.getContentPosition().y - this.content.getAnchorPoint().y * this.content.getContentSize().height;
},
_getHowMuchOutOfBoundary: function(t) {
if ((t = t || cc.v2(0, 0)).fuzzyEquals(cc.v2(0, 0), 1e-4) && !this._outOfBoundaryAmountDirty) return this._outOfBoundaryAmount;
var e = cc.v2(0, 0);
this._getContentLeftBoundary() + t.x > this._leftBoundary ? e.x = this._leftBoundary - (this._getContentLeftBoundary() + t.x) : this._getContentRightBoundary() + t.x < this._rightBoundary && (e.x = this._rightBoundary - (this._getContentRightBoundary() + t.x));
this._getContentTopBoundary() + t.y < this._topBoundary ? e.y = this._topBoundary - (this._getContentTopBoundary() + t.y) : this._getContentBottomBoundary() + t.y > this._bottomBoundary && (e.y = this._bottomBoundary - (this._getContentBottomBoundary() + t.y));
if (t.fuzzyEquals(cc.v2(0, 0), 1e-4)) {
this._outOfBoundaryAmount = e;
this._outOfBoundaryAmountDirty = !1;
}
return e = this._clampDelta(e);
},
_updateScrollBar: function(t) {
this.horizontalScrollBar && this.horizontalScrollBar._onScroll(t);
this.verticalScrollBar && this.verticalScrollBar._onScroll(t);
},
_onScrollBarTouchBegan: function() {
this.horizontalScrollBar && this.horizontalScrollBar._onTouchBegan();
this.verticalScrollBar && this.verticalScrollBar._onTouchBegan();
},
_onScrollBarTouchEnded: function() {
this.horizontalScrollBar && this.horizontalScrollBar._onTouchEnded();
this.verticalScrollBar && this.verticalScrollBar._onTouchEnded();
},
_dispatchEvent: function(t) {
if ("scroll-ended" === t) this._scrollEventEmitMask = 0; else if ("scroll-to-top" === t || "scroll-to-bottom" === t || "scroll-to-left" === t || "scroll-to-right" === t) {
var e = 1 << o[t];
if (this._scrollEventEmitMask & e) return;
this._scrollEventEmitMask |= e;
}
cc.Component.EventHandler.emitEvents(this.scrollEvents, this, o[t]);
this.node.emit(t, this);
},
_adjustContentOutOfBoundary: function() {
this._outOfBoundaryAmountDirty = !0;
if (this._isOutOfBoundary()) {
var t = this._getHowMuchOutOfBoundary(cc.v2(0, 0)), e = this.getContentPosition().add(t);
if (this.content) {
this.content.setPosition(e);
this._updateScrollBar(0);
}
}
},
start: function() {
this._calculateBoundary();
this.content && cc.director.once(cc.Director.EVENT_BEFORE_DRAW, this._adjustContentOutOfBoundary, this);
},
_hideScrollbar: function() {
this.horizontalScrollBar && this.horizontalScrollBar.hide();
this.verticalScrollBar && this.verticalScrollBar.hide();
},
_showScrollbar: function() {
this.horizontalScrollBar && this.horizontalScrollBar.show();
this.verticalScrollBar && this.verticalScrollBar.show();
},
onDisable: function() {
this._unregisterEvent();
if (this.content) {
this.content.off(n.SIZE_CHANGED, this._calculateBoundary, this);
this.content.off(n.SCALE_CHANGED, this._calculateBoundary, this);
if (this._view) {
this._view.off(n.POSITION_CHANGED, this._calculateBoundary, this);
this._view.off(n.SCALE_CHANGED, this._calculateBoundary, this);
this._view.off(n.SIZE_CHANGED, this._calculateBoundary, this);
}
}
this._hideScrollbar();
this.stopAutoScroll();
},
onEnable: function() {
this._registerEvent();
if (this.content) {
this.content.on(n.SIZE_CHANGED, this._calculateBoundary, this);
this.content.on(n.SCALE_CHANGED, this._calculateBoundary, this);
if (this._view) {
this._view.on(n.POSITION_CHANGED, this._calculateBoundary, this);
this._view.on(n.SCALE_CHANGED, this._calculateBoundary, this);
this._view.on(n.SIZE_CHANGED, this._calculateBoundary, this);
}
}
this._showScrollbar();
},
update: function(t) {
this._autoScrolling && this._processAutoScrolling(t);
}
});
cc.ScrollView = e.exports = a;
}), {
"../CCNode": 29,
"./CCViewGroup": 87
} ],
81: [ (function(t, e, i) {
var n = t("../utils/misc"), r = t("./CCComponent"), s = cc.Enum({
Horizontal: 0,
Vertical: 1
}), o = cc.Class({
name: "cc.Slider",
extends: r,
editor: !1,
ctor: function() {
this._offset = cc.v2();
this._touchHandle = !1;
this._dragging = !1;
},
properties: {
handle: {
default: null,
type: cc.Button,
tooltip: !1,
notify: function() {
0;
}
},
direction: {
default: s.Horizontal,
type: s,
tooltip: !1
},
progress: {
default: .5,
type: cc.Float,
range: [ 0, 1, .1 ],
slide: !0,
tooltip: !1,
notify: function() {
this._updateHandlePosition();
}
},
slideEvents: {
default: [],
type: cc.Component.EventHandler,
tooltip: !1
}
},
statics: {
Direction: s
},
__preload: function() {
this._updateHandlePosition();
},
onEnable: function() {
this.node.on(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this);
this.node.on(cc.Node.EventType.TOUCH_MOVE, this._onTouchMoved, this);
this.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this);
this.node.on(cc.Node.EventType.TOUCH_CANCEL, this._onTouchCancelled, this);
if (this.handle && this.handle.isValid) {
this.handle.node.on(cc.Node.EventType.TOUCH_START, this._onHandleDragStart, this);
this.handle.node.on(cc.Node.EventType.TOUCH_MOVE, this._onTouchMoved, this);
this.handle.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this);
}
},
onDisable: function() {
this.node.off(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this);
this.node.off(cc.Node.EventType.TOUCH_MOVE, this._onTouchMoved, this);
this.node.off(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this);
this.node.off(cc.Node.EventType.TOUCH_CANCEL, this._onTouchCancelled, this);
if (this.handle && this.handle.isValid) {
this.handle.node.off(cc.Node.EventType.TOUCH_START, this._onHandleDragStart, this);
this.handle.node.off(cc.Node.EventType.TOUCH_MOVE, this._onTouchMoved, this);
this.handle.node.off(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this);
}
},
_onHandleDragStart: function(t) {
this._dragging = !0;
this._touchHandle = !0;
this._offset = this.handle.node.convertToNodeSpaceAR(t.touch.getLocation());
t.stopPropagation();
},
_onTouchBegan: function(t) {
if (this.handle) {
this._dragging = !0;
this._touchHandle || this._handleSliderLogic(t.touch);
t.stopPropagation();
}
},
_onTouchMoved: function(t) {
if (this._dragging) {
this._handleSliderLogic(t.touch);
t.stopPropagation();
}
},
_onTouchEnded: function(t) {
this._dragging = !1;
this._touchHandle = !1;
this._offset = cc.v2();
t.stopPropagation();
},
_onTouchCancelled: function(t) {
this._dragging = !1;
t.stopPropagation();
},
_handleSliderLogic: function(t) {
this._updateProgress(t);
this._emitSlideEvent();
},
_emitSlideEvent: function() {
cc.Component.EventHandler.emitEvents(this.slideEvents, this);
this.node.emit("slide", this);
},
_updateProgress: function(t) {
if (this.handle) {
var e = this.node.convertToNodeSpaceAR(t.getLocation());
this.direction === s.Horizontal ? this.progress = n.clamp01(.5 + (e.x - this._offset.x) / this.node.width) : this.progress = n.clamp01(.5 + (e.y - this._offset.y) / this.node.height);
}
},
_updateHandlePosition: function() {
if (this.handle) {
var t;
t = this.direction === s.Horizontal ? cc.v2(-this.node.width * this.node.anchorX + this.progress * this.node.width, 0) : cc.v2(0, -this.node.height * this.node.anchorY + this.progress * this.node.height);
var e = this.node.convertToWorldSpaceAR(t);
this.handle.node.position = this.handle.node.parent.convertToNodeSpaceAR(e);
}
}
});
cc.Slider = e.exports = o;
}), {
"../utils/misc": 242,
"./CCComponent": 67
} ],
82: [ (function(t, e, i) {
var n = t("../utils/misc"), r = t("../CCNode").EventType, s = t("./CCRenderComponent"), o = t("../renderer/render-flow"), a = t("../renderer/render-engine"), c = a.gfx, h = a.SpriteMaterial, l = a.GraySpriteMaterial, u = t("../renderer/utils/dynamic-atlas/manager"), _ = t("../platform/CCMacro").BlendFactor, f = cc.Enum({
SIMPLE: 0,
SLICED: 1,
TILED: 2,
FILLED: 3,
MESH: 4
}), d = cc.Enum({
HORIZONTAL: 0,
VERTICAL: 1,
RADIAL: 2
}), m = cc.Enum({
CUSTOM: 0,
TRIMMED: 1,
RAW: 2
}), p = cc.Enum({
NORMAL: 0,
GRAY: 1
}), v = cc.Class({
name: "cc.Sprite",
extends: s,
ctor: function() {
this._assembler = null;
this._graySpriteMaterial = null;
this._spriteMaterial = null;
},
editor: !1,
properties: {
_spriteFrame: {
default: null,
type: cc.SpriteFrame
},
_type: f.SIMPLE,
_sizeMode: m.TRIMMED,
_fillType: 0,
_fillCenter: cc.v2(0, 0),
_fillStart: 0,
_fillRange: 0,
_isTrimmedMode: !0,
_state: 0,
_atlas: {
default: null,
type: cc.SpriteAtlas,
tooltip: !1,
editorOnly: !0,
visible: !0,
animatable: !1
},
_srcBlendFactor: _.SRC_ALPHA,
_dstBlendFactor: _.ONE_MINUS_SRC_ALPHA,
srcBlendFactor: {
get: function() {
return this._srcBlendFactor;
},
set: function(t) {
if (this._srcBlendFactor !== t) {
this._srcBlendFactor = t;
this._updateBlendFunc(!0);
}
},
animatable: !1,
type: _,
tooltip: !1
},
dstBlendFactor: {
get: function() {
return this._dstBlendFactor;
},
set: function(t) {
if (this._dstBlendFactor !== t) {
this._dstBlendFactor = t;
this._updateBlendFunc(!0);
}
},
animatable: !1,
type: _,
tooltip: !1
},
spriteFrame: {
get: function() {
return this._spriteFrame;
},
set: function(t, e) {
var i = this._spriteFrame;
if (i !== t) {
this._spriteFrame = t;
this.markForUpdateRenderData(!1);
this._applySpriteFrame(i);
0;
}
},
type: cc.SpriteFrame
},
type: {
get: function() {
return this._type;
},
set: function(t) {
if (this._type !== t) {
this.destroyRenderData(this._renderData);
this._renderData = null;
this._type = t;
this._updateAssembler();
}
},
type: f,
animatable: !1,
tooltip: !1
},
fillType: {
get: function() {
return this._fillType;
},
set: function(t) {
if (t !== this._fillType) {
if (t === d.RADIAL || this._fillType === d.RADIAL) {
this.destroyRenderData(this._renderData);
this._renderData = null;
} else this._renderData && this.markForUpdateRenderData(!0);
this._fillType = t;
this._updateAssembler();
}
},
type: d,
tooltip: !1
},
fillCenter: {
get: function() {
return this._fillCenter;
},
set: function(t) {
this._fillCenter.x = t.x;
this._fillCenter.y = t.y;
this._type === f.FILLED && this._renderData && this.markForUpdateRenderData(!0);
},
tooltip: !1
},
fillStart: {
get: function() {
return this._fillStart;
},
set: function(t) {
this._fillStart = n.clampf(t, -1, 1);
this._type === f.FILLED && this._renderData && this.markForUpdateRenderData(!0);
},
tooltip: !1
},
fillRange: {
get: function() {
return this._fillRange;
},
set: function(t) {
this._fillRange = n.clampf(t, -1, 1);
this._type === f.FILLED && this._renderData && this.markForUpdateRenderData(!0);
},
tooltip: !1
},
trim: {
get: function() {
return this._isTrimmedMode;
},
set: function(t) {
if (this._isTrimmedMode !== t) {
this._isTrimmedMode = t;
this._type !== f.SIMPLE && this._type !== f.MESH || !this._renderData || this.markForUpdateRenderData(!0);
}
},
animatable: !1,
tooltip: !1
},
sizeMode: {
get: function() {
return this._sizeMode;
},
set: function(t) {
this._sizeMode = t;
t !== m.CUSTOM && this._applySpriteSize();
},
animatable: !1,
type: m,
tooltip: !1
}
},
statics: {
FillType: d,
Type: f,
SizeMode: m,
State: p
},
setVisible: function(t) {
this.enabled = t;
},
setState: function(t) {
if (this._state !== t) {
this._state = t;
this._activateMaterial();
}
},
getState: function() {
return this._state;
},
onEnable: function() {
this._super();
if (!this._spriteFrame || !this._spriteFrame.textureLoaded()) {
this.disableRender();
if (this._spriteFrame) {
this._spriteFrame.once("load", this._onTextureLoaded, this);
this._spriteFrame.ensureLoadTexture();
}
}
this._updateAssembler();
this._activateMaterial();
this.node.on(r.SIZE_CHANGED, this._onNodeSizeDirty, this);
this.node.on(r.ANCHOR_CHANGED, this._onNodeSizeDirty, this);
},
onDisable: function() {
this._super();
this.node.off(r.SIZE_CHANGED, this._onNodeSizeDirty, this);
this.node.off(r.ANCHOR_CHANGED, this._onNodeSizeDirty, this);
},
_onNodeSizeDirty: function() {
this._renderData && this.markForUpdateRenderData(!0);
},
_updateAssembler: function() {
var t = v._assembler.getAssembler(this);
if (this._assembler !== t) {
this._assembler = t;
this._renderData = null;
}
if (!this._renderData) {
this._renderData = this._assembler.createData(this);
this._renderData.material = this._material;
this.markForUpdateRenderData(!0);
}
},
_activateMaterial: function() {
var t = this._spriteFrame;
if (cc.game.renderType !== cc.game.RENDER_TYPE_CANVAS) {
var e = void 0;
if (this._state === p.GRAY) {
this._graySpriteMaterial || (this._graySpriteMaterial = new l());
e = this._graySpriteMaterial;
} else {
this._spriteMaterial || (this._spriteMaterial = new h());
e = this._spriteMaterial;
}
e.useColor = !1;
if (t && t.textureLoaded()) {
var i = t.getTexture();
if (e.texture !== i) {
e.texture = i;
this._updateMaterial(e);
} else e !== this._material && this._updateMaterial(e);
this._renderData && (this._renderData.material = e);
this.node._renderFlag |= o.FLAG_COLOR;
this.markForUpdateRenderData(!0);
this.markForRender(!0);
} else this.disableRender();
} else {
this.markForUpdateRenderData(!0);
this.markForRender(!0);
}
},
_updateMaterial: function(t) {
this._material = t;
this._updateBlendFunc();
t.updateHash();
},
_updateBlendFunc: function(t) {
if (this._material) {
this._material._mainTech.passes[0].setBlend(c.BLEND_FUNC_ADD, this._srcBlendFactor, this._dstBlendFactor, c.BLEND_FUNC_ADD, this._srcBlendFactor, this._dstBlendFactor);
t && this._material.updateHash();
}
},
_applyAtlas: !1,
_canRender: function() {
if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS) {
if (!this._enabled) return !1;
} else if (!this._enabled || !this._material || !this.node._activeInHierarchy) return !1;
var t = this._spriteFrame;
return !(!t || !t.textureLoaded());
},
markForUpdateRenderData: function(t) {
if (t && this._canRender()) {
this.node._renderFlag |= o.FLAG_UPDATE_RENDER_DATA;
var e = this._renderData;
if (e) {
e.uvDirty = !0;
e.vertDirty = !0;
}
} else t || (this.node._renderFlag &= ~o.FLAG_UPDATE_RENDER_DATA);
},
_applySpriteSize: function() {
if (this._spriteFrame) {
if (m.RAW === this._sizeMode) {
var t = this._spriteFrame.getOriginalSize();
this.node.setContentSize(t);
} else if (m.TRIMMED === this._sizeMode) {
var e = this._spriteFrame.getRect();
this.node.setContentSize(e.width, e.height);
}
this._activateMaterial();
}
},
_onTextureLoaded: function() {
this.isValid && this._applySpriteSize();
},
_applySpriteFrame: function(t) {
t && t.off && t.off("load", this._onTextureLoaded, this);
var e = this._spriteFrame;
e && (this._material && this._material._texture) === (e && e._texture) || this.markForRender(!1);
if (e) if (t && e._texture === t._texture) this._applySpriteSize(); else if (e.textureLoaded()) this._onTextureLoaded(null); else {
e.once("load", this._onTextureLoaded, this);
e.ensureLoadTexture();
}
0;
},
_resized: !1,
_calDynamicAtlas: function() {
if (this._spriteFrame) {
if (!this._spriteFrame._original && u) {
var t = u.insertSpriteFrame(this._spriteFrame);
t && this._spriteFrame._setDynamicAtlasFrame(t);
}
this._material._texture !== this._spriteFrame._texture && this._activateMaterial();
}
}
});
0;
cc.Sprite = e.exports = v;
}), {
"../CCNode": 29,
"../platform/CCMacro": 165,
"../renderer/render-engine": 202,
"../renderer/render-flow": 203,
"../renderer/utils/dynamic-atlas/manager": 205,
"../utils/misc": 242,
"./CCRenderComponent": 77
} ],
83: [ (function(t, e, i) {
var n = cc.Enum({
NONE: 0,
CHECKBOX: 1,
TEXT_ATLAS: 2,
SLIDER_BAR: 3,
LIST_VIEW: 4,
PAGE_VIEW: 5
}), r = cc.Enum({
VERTICAL: 0,
HORIZONTAL: 1
}), s = cc.Enum({
TOP: 0,
CENTER: 1,
BOTTOM: 2
}), o = cc.Enum({
LEFT: 0,
CENTER: 1,
RIGHT: 2
}), a = cc.Class({
name: "cc.StudioComponent",
extends: cc.Component,
editor: !1,
properties: !1,
statics: {
ComponentType: n,
ListDirection: r,
VerticalAlign: s,
HorizontalAlign: o
}
}), c = t("../utils/prefab-helper");
a.PlaceHolder = cc.Class({
name: "cc.StudioComponent.PlaceHolder",
extends: cc.Component,
properties: {
_baseUrl: "",
nestedPrefab: cc.Prefab
},
onLoad: function() {
this.nestedPrefab && this._replaceWithNestedPrefab();
},
_replaceWithNestedPrefab: function() {
var t = this.node, e = t._prefab;
e.root = t;
e.asset = this.nestedPrefab;
c.syncWithPrefab(t);
}
});
cc.StudioComponent = e.exports = a;
var h = cc.Class({
name: "cc.StudioWidget",
extends: cc.Widget,
editor: !1,
_validateTargetInDEV: function() {}
});
cc.StudioWidget = e.exports = h;
}), {
"../utils/prefab-helper": 245
} ],
84: [ (function(t, e, i) {
var n = cc.Class({
name: "cc.Toggle",
extends: t("./CCButton"),
editor: !1,
properties: {
_N$isChecked: !0,
isChecked: {
get: function() {
return this._N$isChecked;
},
set: function(t) {
if (t !== this._N$isChecked) {
var e = this.toggleGroup || this._toggleContainer;
if (!(e && e.enabled && this._N$isChecked) || e.allowSwitchOff) {
this._N$isChecked = t;
this._updateCheckMark();
e && e.enabled && e.updateToggles(this);
this._emitToggleEvents();
}
}
},
tooltip: !1
},
toggleGroup: {
default: null,
tooltip: !1,
type: t("./CCToggleGroup")
},
checkMark: {
default: null,
type: cc.Sprite,
tooltip: !1
},
checkEvents: {
default: [],
type: cc.Component.EventHandler
},
_resizeToTarget: {
animatable: !1,
set: function(t) {
t && this._resizeNodeToTargetNode();
}
}
},
onEnable: function() {
this._super();
this._registerToggleEvent();
this.toggleGroup && this.toggleGroup.enabledInHierarchy && this.toggleGroup.addToggle(this);
},
onDisable: function() {
this._super();
this._unregisterToggleEvent();
this.toggleGroup && this.toggleGroup.enabledInHierarchy && this.toggleGroup.removeToggle(this);
},
_hideCheckMark: function() {
this._N$isChecked = !1;
this._updateCheckMark();
},
toggle: function(t) {
this.isChecked = !this.isChecked;
},
check: function() {
this.isChecked = !0;
},
uncheck: function() {
this.isChecked = !1;
},
_updateCheckMark: function() {
this.checkMark && (this.checkMark.node.active = !!this.isChecked);
},
_updateDisabledState: function() {
this._super();
this.checkMark && this.checkMark.setState(0);
this.enableAutoGrayEffect && this.checkMark && !this.interactable && this.checkMark.setState(1);
},
_registerToggleEvent: function() {
this.node.on("click", this.toggle, this);
},
_unregisterToggleEvent: function() {
this.node.off("click", this.toggle, this);
},
_emitToggleEvents: function() {
this.node.emit("toggle", this);
this.checkEvents && cc.Component.EventHandler.emitEvents(this.checkEvents, this);
}
});
cc.Toggle = e.exports = n;
t("../platform/js").get(n.prototype, "_toggleContainer", (function() {
var t = this.node.parent;
return cc.Node.isNode(t) ? t.getComponent(cc.ToggleContainer) : null;
}));
}), {
"../platform/js": 180,
"./CCButton": 65,
"./CCToggleGroup": 86
} ],
85: [ (function(t, e, i) {
var n = cc.Class({
name: "cc.ToggleContainer",
extends: cc.Component,
editor: !1,
properties: {
allowSwitchOff: {
tooltip: !1,
default: !1
},
checkEvents: {
default: [],
type: cc.Component.EventHandler
}
},
updateToggles: function(t) {
if (this.enabledInHierarchy && t.isChecked) {
this.toggleItems.forEach((function(e) {
e !== t && e.isChecked && e.enabled && e._hideCheckMark();
}));
this.checkEvents && cc.Component.EventHandler.emitEvents(this.checkEvents, t);
}
},
_allowOnlyOneToggleChecked: function() {
var t = !1;
this.toggleItems.forEach((function(e) {
t ? e._hideCheckMark() : e.isChecked && (t = !0);
}));
return t;
},
_makeAtLeastOneToggleChecked: function() {
if (!this._allowOnlyOneToggleChecked() && !this.allowSwitchOff) {
var t = this.toggleItems;
t.length > 0 && t[0].check();
}
},
onEnable: function() {
this.node.on("child-added", this._allowOnlyOneToggleChecked, this);
this.node.on("child-removed", this._makeAtLeastOneToggleChecked, this);
},
onDisable: function() {
this.node.off("child-added", this._allowOnlyOneToggleChecked, this);
this.node.off("child-removed", this._makeAtLeastOneToggleChecked, this);
},
start: function() {
this._makeAtLeastOneToggleChecked();
}
});
t("../platform/js").get(n.prototype, "toggleItems", (function() {
return this.node.getComponentsInChildren(cc.Toggle);
}));
cc.ToggleContainer = e.exports = n;
}), {
"../platform/js": 180
} ],
86: [ (function(t, e, i) {
var n = cc.Class({
name: "cc.ToggleGroup",
extends: cc.Component,
ctor: function() {
this._toggleItems = [];
},
editor: !1,
properties: {
allowSwitchOff: {
tooltip: !1,
default: !1
},
toggleItems: {
get: function() {
return this._toggleItems;
}
}
},
updateToggles: function(t) {
this.enabledInHierarchy && this._toggleItems.forEach((function(e) {
t.isChecked && e !== t && e.isChecked && e.enabled && e._hideCheckMark();
}));
},
addToggle: function(t) {
-1 === this._toggleItems.indexOf(t) && this._toggleItems.push(t);
this._allowOnlyOneToggleChecked();
},
removeToggle: function(t) {
var e = this._toggleItems.indexOf(t);
e > -1 && this._toggleItems.splice(e, 1);
this._makeAtLeastOneToggleChecked();
},
_allowOnlyOneToggleChecked: function() {
var t = !1;
this._toggleItems.forEach((function(e) {
t && e.enabled && e._hideCheckMark();
e.isChecked && e.enabled && (t = !0);
}));
return t;
},
_makeAtLeastOneToggleChecked: function() {
this._allowOnlyOneToggleChecked() || this.allowSwitchOff || this._toggleItems.length > 0 && (this._toggleItems[0].isChecked = !0);
},
start: function() {
this._makeAtLeastOneToggleChecked();
}
}), r = !1;
t("../platform/js").get(cc, "ToggleGroup", (function() {
if (!r) {
cc.logID(1405, "cc.ToggleGroup", "cc.ToggleContainer");
r = !0;
}
return n;
}));
e.exports = n;
}), {
"../platform/js": 180
} ],
87: [ (function(t, e, i) {
var n = cc.Class({
name: "cc.ViewGroup",
extends: t("./CCComponent")
});
cc.ViewGroup = e.exports = n;
}), {
"./CCComponent": 67
} ],
88: [ (function(t, e, i) {
var n = t("../base-ui/CCWidgetManager"), r = n.AlignMode, s = n._AlignFlags, o = s.TOP, a = s.MID, c = s.BOT, h = s.LEFT, l = s.CENTER, u = s.RIGHT, _ = o | c, f = h | u, d = cc.Class({
name: "cc.Widget",
extends: t("./CCComponent"),
editor: !1,
properties: {
target: {
get: function() {
return this._target;
},
set: function(t) {
this._target = t;
0;
},
type: cc.Node,
tooltip: !1
},
isAlignTop: {
get: function() {
return (this._alignFlags & o) > 0;
},
set: function(t) {
this._setAlign(o, t);
},
animatable: !1,
tooltip: !1
},
isAlignVerticalCenter: {
get: function() {
return (this._alignFlags & a) > 0;
},
set: function(t) {
if (t) {
this.isAlignTop = !1;
this.isAlignBottom = !1;
this._alignFlags |= a;
} else this._alignFlags &= ~a;
},
animatable: !1,
tooltip: !1
},
isAlignBottom: {
get: function() {
return (this._alignFlags & c) > 0;
},
set: function(t) {
this._setAlign(c, t);
},
animatable: !1,
tooltip: !1
},
isAlignLeft: {
get: function() {
return (this._alignFlags & h) > 0;
},
set: function(t) {
this._setAlign(h, t);
},
animatable: !1,
tooltip: !1
},
isAlignHorizontalCenter: {
get: function() {
return (this._alignFlags & l) > 0;
},
set: function(t) {
if (t) {
this.isAlignLeft = !1;
this.isAlignRight = !1;
this._alignFlags |= l;
} else this._alignFlags &= ~l;
},
animatable: !1,
tooltip: !1
},
isAlignRight: {
get: function() {
return (this._alignFlags & u) > 0;
},
set: function(t) {
this._setAlign(u, t);
},
animatable: !1,
tooltip: !1
},
isStretchWidth: {
get: function() {
return (this._alignFlags & f) === f;
},
visible: !1
},
isStretchHeight: {
get: function() {
return (this._alignFlags & _) === _;
},
visible: !1
},
top: {
get: function() {
return this._top;
},
set: function(t) {
this._top = t;
},
tooltip: !1
},
bottom: {
get: function() {
return this._bottom;
},
set: function(t) {
this._bottom = t;
},
tooltip: !1
},
left: {
get: function() {
return this._left;
},
set: function(t) {
this._left = t;
},
tooltip: !1
},
right: {
get: function() {
return this._right;
},
set: function(t) {
this._right = t;
},
tooltip: !1
},
horizontalCenter: {
get: function() {
return this._horizontalCenter;
},
set: function(t) {
this._horizontalCenter = t;
},
tooltip: !1
},
verticalCenter: {
get: function() {
return this._verticalCenter;
},
set: function(t) {
this._verticalCenter = t;
},
tooltip: !1
},
isAbsoluteHorizontalCenter: {
get: function() {
return this._isAbsHorizontalCenter;
},
set: function(t) {
this._isAbsHorizontalCenter = t;
},
animatable: !1
},
isAbsoluteVerticalCenter: {
get: function() {
return this._isAbsVerticalCenter;
},
set: function(t) {
this._isAbsVerticalCenter = t;
},
animatable: !1
},
isAbsoluteTop: {
get: function() {
return this._isAbsTop;
},
set: function(t) {
this._isAbsTop = t;
},
animatable: !1
},
isAbsoluteBottom: {
get: function() {
return this._isAbsBottom;
},
set: function(t) {
this._isAbsBottom = t;
},
animatable: !1
},
isAbsoluteLeft: {
get: function() {
return this._isAbsLeft;
},
set: function(t) {
this._isAbsLeft = t;
},
animatable: !1
},
isAbsoluteRight: {
get: function() {
return this._isAbsRight;
},
set: function(t) {
this._isAbsRight = t;
},
animatable: !1
},
alignMode: {
default: r.ON_WINDOW_RESIZE,
type: r,
tooltip: !1
},
_wasAlignOnce: {
default: void 0,
formerlySerializedAs: "isAlignOnce"
},
_target: null,
_alignFlags: 0,
_left: 0,
_right: 0,
_top: 0,
_bottom: 0,
_verticalCenter: 0,
_horizontalCenter: 0,
_isAbsLeft: !0,
_isAbsRight: !0,
_isAbsTop: !0,
_isAbsBottom: !0,
_isAbsHorizontalCenter: !0,
_isAbsVerticalCenter: !0,
_originalWidth: 0,
_originalHeight: 0
},
statics: {
AlignMode: r
},
onLoad: function() {
if (void 0 !== this._wasAlignOnce) {
this.alignMode = this._wasAlignOnce ? r.ONCE : r.ALWAYS;
this._wasAlignOnce = void 0;
}
},
onEnable: function() {
n.add(this);
},
onDisable: function() {
n.remove(this);
},
_validateTargetInDEV: !1,
_setAlign: function(t, e) {
if (e !== (this._alignFlags & t) > 0) {
var i = (t & f) > 0;
if (e) {
this._alignFlags |= t;
if (i) {
this.isAlignHorizontalCenter = !1;
if (this.isStretchWidth) {
this._originalWidth = this.node.width;
0;
}
} else {
this.isAlignVerticalCenter = !1;
if (this.isStretchHeight) {
this._originalHeight = this.node.height;
0;
}
}
0;
} else {
i ? this.isStretchWidth && (this.node.width = this._originalWidth) : this.isStretchHeight && (this.node.height = this._originalHeight);
this._alignFlags &= ~t;
}
}
},
updateAlignment: function() {
n.updateAlignment(this.node);
}
});
Object.defineProperty(d.prototype, "isAlignOnce", {
get: function() {
0;
return this.alignMode === r.ONCE;
},
set: function(t) {
0;
this.alignMode = t ? r.ONCE : r.ALWAYS;
}
});
cc.Widget = e.exports = d;
}), {
"../base-ui/CCWidgetManager": 51,
"./CCComponent": 67
} ],
89: [ (function(t, e, i) {
var n = t("./CCComponent"), r = void 0;
r = cc.sys.platform === cc.sys.BAIDU_GAME ? cc.Class({
name: "cc.SwanSubContextView",
extends: n,
editor: !1,
ctor: function() {
this._sprite = null;
this._tex = new cc.Texture2D();
this._context = null;
},
onLoad: function() {
if (swan.getOpenDataContext) {
this._context = swan.getOpenDataContext();
var t = this._context.canvas;
if (t) {
t.width = this.node.width;
t.height = this.node.height;
}
this._tex.setPremultiplyAlpha(!0);
this._tex.initWithElement(t);
this._sprite = this.node.getComponent(cc.Sprite);
if (!this._sprite) {
this._sprite = this.node.addComponent(cc.Sprite);
this._sprite.srcBlendFactor = cc.macro.BlendFactor.ONE;
}
this._sprite.spriteFrame = new cc.SpriteFrame(this._tex);
} else this.enabled = !1;
},
onEnable: function() {
this.updateSubContextViewport();
},
update: function() {
if (this._tex && this._context) {
this._tex.initWithElement(this._context.canvas);
this._sprite._activateMaterial();
}
},
updateSubContextViewport: function() {
if (this._context) {
var t = this.node.getBoundingBoxToWorld(), e = cc.view._scaleX, i = cc.view._scaleY;
this._context.postMessage({
fromEngine: !0,
event: "viewport",
x: t.x * e + cc.view._viewportRect.x,
y: t.y * i + cc.view._viewportRect.y,
width: t.width * e,
height: t.height * i
});
}
}
}) : cc.Class({
name: "cc.SwanSubContextView",
extends: n
});
cc.SwanSubContextView = e.exports = r;
}), {
"./CCComponent": 67
} ],
90: [ (function(t, e, i) {
var n = t("./CCComponent"), r = void 0;
r = cc.Class({
name: "cc.WXSubContextView",
extends: n
});
cc.WXSubContextView = e.exports = r;
}), {
"./CCComponent": 67
} ],
91: [ (function(t, e, i) {
var n = t("../../platform/CCMacro"), r = t("../editbox/CCEditBoxImpl"), s = t("../CCLabel"), o = t("./types"), a = o.InputMode, c = o.InputFlag, h = o.KeyboardReturnType;
var l = cc.Class({
name: "cc.EditBox",
extends: cc.Component,
editor: !1,
properties: {
_useOriginalSize: !0,
_string: "",
string: {
tooltip: !1,
get: function() {
return this._string;
},
set: function(t) {
this.maxLength >= 0 && t.length >= this.maxLength && (t = t.slice(0, this.maxLength));
this._string = t;
this._impl && this._updateString(t);
}
},
backgroundImage: {
tooltip: !1,
default: null,
type: cc.SpriteFrame,
notify: function() {
this._createBackgroundSprite();
}
},
returnType: {
default: h.DEFAULT,
tooltip: !1,
displayName: "KeyboardReturnType",
type: h,
notify: function() {
this._impl && (this._impl.returnType = this.returnType);
}
},
inputFlag: {
tooltip: !1,
default: c.DEFAULT,
type: c,
notify: function() {
if (this._impl) {
this._impl.setInputFlag(this.inputFlag);
this._updateString(this._string);
}
}
},
inputMode: {
tooltip: !1,
default: a.ANY,
type: a,
notify: function() {
this._impl && this._impl.setInputMode(this.inputMode);
}
},
fontSize: {
tooltip: !1,
default: 20,
notify: function() {
this._textLabel && (this._textLabel.fontSize = this.fontSize);
this._impl && this._impl.setFontSize(this.fontSize);
}
},
lineHeight: {
tooltip: !1,
default: 40,
notify: function() {
this._textLabel && (this._textLabel.lineHeight = this.lineHeight);
}
},
fontColor: {
tooltip: !1,
default: cc.Color.WHITE,
notify: function() {
if (this._textLabel) {
this._textLabel.node.opacity = this.fontColor.a;
this._textLabel.node.color = this.fontColor;
}
this._impl && this._impl.setFontColor(this.fontColor);
}
},
placeholder: {
tooltip: !1,
default: "Enter text here...",
notify: function() {
this._placeholderLabel && (this._placeholderLabel.string = this.placeholder);
this._impl && this._impl.setPlaceholderText(this.placeholder);
}
},
placeholderFontSize: {
tooltip: !1,
default: 20,
notify: function() {
this._placeholderLabel && (this._placeholderLabel.fontSize = this.placeholderFontSize);
}
},
placeholderFontColor: {
tooltip: !1,
default: cc.Color.GRAY,
notify: function() {
if (this._placeholderLabel) {
this._placeholderLabel.node.color = this.placeholderFontColor;
this._placeholderLabel.node.opacity = this.placeholderFontColor.a;
}
}
},
maxLength: {
tooltip: !1,
default: 20,
notify: function() {
this._impl && this._impl.setMaxLength(this.maxLength);
}
},
stayOnTop: {
tooltip: !1,
default: !1,
notify: function() {
this._impl && this._updateStayOnTop();
}
},
_tabIndex: 0,
tabIndex: {
tooltip: !1,
get: function() {
return this._tabIndex;
},
set: function(t) {
this._tabIndex = t;
this._impl && this._impl.setTabIndex(t);
}
},
editingDidBegan: {
default: [],
type: cc.Component.EventHandler
},
textChanged: {
default: [],
type: cc.Component.EventHandler
},
editingDidEnded: {
default: [],
type: cc.Component.EventHandler
},
editingReturn: {
default: [],
type: cc.Component.EventHandler
}
},
statics: {
_EditBoxImpl: r,
KeyboardReturnType: h,
InputFlag: c,
InputMode: a
},
_init: function() {
this._createBackgroundSprite();
this._createLabels();
this.node.on(cc.Node.EventType.SIZE_CHANGED, this._resizeChildNodes, this);
var t = this._impl = new r();
t.setDelegate(this);
t.setNode(this.node);
t.setInputMode(this.inputMode);
t.setMaxLength(this.maxLength);
t.setInputFlag(this.inputFlag);
t.setReturnType(this.returnType);
t.setTabIndex(this.tabIndex);
t.setFontColor(this.fontColor);
t.setFontSize(this.fontSize);
t.setPlaceholderText(this.placeholder);
this._updateStayOnTop();
this._updateString(this.string);
this._syncSize();
},
_updateStayOnTop: function() {
this.stayOnTop ? this._hideLabels() : this._showLabels();
this._impl.stayOnTop(this.stayOnTop);
},
_syncSize: function() {
var t = this.node.getContentSize();
this._background.node.setAnchorPoint(this.node.getAnchorPoint());
this._background.node.setContentSize(t);
this._updateLabelPosition(t);
this._impl.setSize(t.width, t.height);
},
_updateLabelPosition: function(t) {
var e = this.node, i = -e.anchorX * e.width, r = -e.anchorY * e.height, s = this._placeholderLabel, o = this._textLabel;
o.node.setContentSize(t.width - 2, t.height);
s.node.setContentSize(t.width - 2, t.height);
s.lineHeight = t.height;
s.node.setPosition(i + 2, r + t.height);
o.node.setPosition(i + 2, r + t.height);
if (this.inputMode === a.ANY) {
s.verticalAlign = n.VerticalTextAlignment.TOP;
s.enableWrapText = !0;
o.verticalAlign = n.VerticalTextAlignment.TOP;
o.enableWrapText = !0;
} else {
s.verticalAlign = n.VerticalTextAlignment.CENTER;
s.enableWrapText = !1;
o.verticalAlign = n.VerticalTextAlignment.CENTER;
o.enableWrapText = !1;
}
},
_createBackgroundSprite: function() {
var t = this._background;
if (!t) {
var e = this.node.getChildByName("BACKGROUND_SPRITE");
e || (e = new cc.Node("BACKGROUND_SPRITE"));
(t = e.getComponent(cc.Sprite)) || (t = e.addComponent(cc.Sprite));
t.type = cc.Sprite.Type.SLICED;
e.parent = this.node;
this._background = t;
}
t.spriteFrame = this.backgroundImage;
},
_createLabels: function() {
if (!this._textLabel) {
var t = this.node.getChildByName("TEXT_LABEL");
t || (t = new cc.Node("TEXT_LABEL"));
t.color = this.fontColor;
t.parent = this.node;
t.setAnchorPoint(0, 1);
var e = t.getComponent(s);
e || (e = t.addComponent(s));
e.overflow = s.Overflow.CLAMP;
e.fontSize = this.fontSize;
e.lineHeight = this.lineHeight;
this._textLabel = e;
}
if (!this._placeholderLabel) {
var i = this.node.getChildByName("PLACEHOLDER_LABEL");
i || (i = new cc.Node("PLACEHOLDER_LABEL"));
i.color = this.placeholderFontColor;
i.parent = this.node;
i.setAnchorPoint(0, 1);
var n = i.getComponent(s);
n || (n = i.addComponent(s));
n.overflow = s.Overflow.CLAMP;
n.fontSize = this.placeholderFontSize;
n.string = this.placeholder;
this._placeholderLabel = n;
}
},
_resizeChildNodes: function() {
var t = this._textLabel.node, e = this._placeholderLabel.node, i = this._background.node;
t.x = -this.node.width / 2;
t.y = this.node.height / 2;
t.width = this.node.width;
t.height = this.node.height;
e.x = -this.node.width / 2;
e.y = this.node.height / 2;
e.width = this.node.width;
e.height = this.node.height;
i.width = this.node.width;
i.height = this.node.height;
},
_showLabels: function() {
var t = this._textLabel.string;
this._textLabel.node.active = "" !== t;
this._placeholderLabel.node.active = "" === t;
},
_hideLabels: function() {
this._textLabel.node.active = !1;
this._placeholderLabel.node.active = !1;
},
_updateString: function(t) {
var e = this._textLabel;
if (e) {
var i = t;
i && (i = this._updateLabelStringStyle(i));
e.string = i;
this._impl.setString(t);
this._impl._editing || this.stayOnTop || this._showLabels();
}
},
_updateLabelStringStyle: function(t, e) {
var i = this.inputFlag;
if (e || i !== c.PASSWORD) i === c.INITIAL_CAPS_ALL_CHARACTERS ? t = t.toUpperCase() : i === c.INITIAL_CAPS_WORD ? t = (function(t) {
return t.replace(/(?:^|\s)\S/g, (function(t) {
return t.toUpperCase();
}));
})(t) : i === c.INITIAL_CAPS_SENTENCE && (t = (function(t) {
return t.charAt(0).toUpperCase() + t.slice(1);
})(t)); else {
for (var n = "", r = t.length, s = 0; s < r; ++s) n += "●";
t = n;
}
return t;
},
editBoxEditingDidBegan: function() {
this._hideLabels();
cc.Component.EventHandler.emitEvents(this.editingDidBegan, this);
this.node.emit("editing-did-began", this);
},
editBoxEditingDidEnded: function() {
this.stayOnTop || this._showLabels();
cc.Component.EventHandler.emitEvents(this.editingDidEnded, this);
this.node.emit("editing-did-ended", this);
},
editBoxTextChanged: function(t) {
t = this._updateLabelStringStyle(t, !0);
this.string = t;
cc.Component.EventHandler.emitEvents(this.textChanged, t, this);
this.node.emit("text-changed", this);
},
editBoxEditingReturn: function() {
cc.Component.EventHandler.emitEvents(this.editingReturn, this);
this.node.emit("editing-return", this);
},
onDestroy: function() {
this._impl.clear();
},
onEnable: function() {
this._impl && this._impl.onEnable();
},
onDisable: function() {
this._impl && this._impl.onDisable();
},
__preload: function() {
this._registerEvent();
this._init();
},
_registerEvent: function() {
this.node.on(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this);
this.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this);
},
_onTouchBegan: function(t) {
this._impl && this._impl._onTouchBegan(t.touch);
t.stopPropagation();
},
_onTouchCancel: function(t) {
this._impl && this._impl._onTouchCancel();
t.stopPropagation();
},
_onTouchEnded: function(t) {
this._impl && this._impl._onTouchEnded();
t.stopPropagation();
},
setFocus: function() {
this._impl && this._impl.setFocus();
},
isFocused: function() {
var t = !1;
this._impl && (t = this._impl.isFocused());
return t;
},
update: function() {
this._impl && this._impl.update();
}
});
cc.EditBox = e.exports = l;
}), {
"../../platform/CCMacro": 165,
"../CCLabel": 69,
"../editbox/CCEditBoxImpl": 92,
"./types": 93
} ],
92: [ (function(t, e, i) {
var n = t("../../platform/utils"), r = t("../../platform/CCMacro"), s = t("./types"), o = s.InputMode, a = s.InputFlag, c = s.KeyboardReturnType, h = cc.vmath, l = h.mat4.create(), u = h.mat4.create(), _ = cc.v3(), f = null, d = {
zoomInvalid: !1
};
cc.sys.OS_ANDROID !== cc.sys.os || cc.sys.browserType !== cc.sys.BROWSER_TYPE_SOUGOU && cc.sys.browserType !== cc.sys.BROWSER_TYPE_360 || (d.zoomInvalid = !0);
var m = cc.Class({
ctor: function() {
this._delegate = null;
this._inputMode = -1;
this._inputFlag = -1;
this._returnType = c.DEFAULT;
this._maxLength = 50;
this._text = "";
this._placeholderText = "";
this._alwaysOnTop = !1;
this._size = cc.size();
this._node = null;
this._editing = !1;
this.__eventListeners = {};
this.__fullscreen = !1;
this.__autoResize = !1;
this.__rotateScreen = !1;
this.__orientationChanged = null;
this._m00 = 0;
this._m01 = 0;
this._m04 = 0;
this._m05 = 0;
this._m12 = 0;
this._m13 = 0;
this._w = 0;
this._h = 0;
},
onEnable: function() {
this._edTxt && (this._alwaysOnTop ? this._edTxt.style.display = "" : this._edTxt.style.display = "none");
},
onDisable: function() {
this._edTxt && (this._edTxt.style.display = "none");
},
setTabIndex: function(t) {
this._edTxt && (this._edTxt.tabIndex = t);
},
setFocus: function() {
this._beginEditing();
},
isFocused: function() {
if (this._edTxt) return document.activeElement === this._edTxt;
cc.warnID(4700);
return !1;
},
stayOnTop: function(t) {
if (this._alwaysOnTop !== t && this._edTxt) {
this._alwaysOnTop = t;
this._edTxt.style.display = t ? "" : "none";
}
},
setMaxLength: function(t) {
if (!isNaN(t)) {
t < 0 && (t = 65535);
this._maxLength = t;
this._edTxt && (this._edTxt.maxLength = t);
}
},
setString: function(t) {
this._text = t;
this._edTxt && (this._edTxt.value = t);
},
getString: function() {
return this._text;
},
setPlaceholderText: function(t) {
this._placeholderText = t;
},
getPlaceholderText: function() {
return this._placeholderText;
},
setDelegate: function(t) {
this._delegate = t;
},
setInputMode: function(t) {
if (this._inputMode !== t) {
this._inputMode = t;
this.createInput();
this._updateDomInputType();
this._updateSize(this._size.width, this._size.height);
}
},
setInputFlag: function(t) {
if (this._inputFlag !== t) {
this._inputFlag = t;
this._updateDomInputType();
var e = "none";
t === a.INITIAL_CAPS_ALL_CHARACTERS ? e = "uppercase" : t === a.INITIAL_CAPS_WORD && (e = "capitalize");
if (this._edTxt) {
this._edTxt.style.textTransform = e;
this._edTxt.value = this._text;
}
}
},
setReturnType: function(t) {
this._returnType = t;
this._updateDomInputType();
},
setFontSize: function(t) {
this._edFontSize = t || this._edFontSize;
this._edTxt && (this._edTxt.style.fontSize = this._edFontSize + "px");
},
setFontColor: function(t) {
this._textColor = t;
this._edTxt && (this._edTxt.style.color = t.toCSS("rgba"));
},
setSize: function(t, e) {
this._size.width = t;
this._size.height = e;
this._updateSize(t, e);
},
setNode: function(t) {
this._node = t;
},
update: function() {
this._updateMatrix();
},
clear: function() {
this._node = null;
this.setDelegate(null);
this.removeDom();
this.removeOrientationchangeEvent();
},
_onTouchBegan: function(t) {},
_onTouchEnded: function() {
this._beginEditing();
},
_beginEditing: function() {
var t = this;
cc.sys.isMobile && !this._editing && this.addOrientationchangeEvent();
this._edTxt && (function() {
t._edTxt.style.display = "";
var e = t;
function i() {
e._edTxt.focus();
}
cc.sys.browserType === cc.sys.BROWSER_TYPE_UC ? setTimeout(i, 400) : cc.sys.browserType === cc.sys.BROWSER_TYPE_FIREFOX ? setTimeout(i, 0) : i();
})();
this._editing = !0;
},
_endEditing: function() {
var t = this, e = function() {
!t._alwaysOnTop && t._edTxt && (t._edTxt.style.display = "none");
t._delegate && t._delegate.editBoxEditingDidEnded && t._delegate.editBoxEditingDidEnded();
};
this._editing && (cc.sys.isMobile ? setTimeout((function() {
t._endEditingOnMobile();
e();
}), 400) : e());
this._editing = !1;
},
_updateDomInputType: function() {
var t = this._inputMode, e = this._edTxt;
if (e) if (this._inputFlag !== a.PASSWORD) {
var i = e.type;
if (t === o.EMAIL_ADDR) i = "email"; else if (t === o.NUMERIC || t === o.DECIMAL) i = "number"; else if (t === o.PHONE_NUMBER) {
i = "number";
e.pattern = "[0-9]*";
} else if (t === o.URL) i = "url"; else {
i = "text";
this._returnType === c.SEARCH && (i = "search");
}
e.type = i;
} else e.type = "password";
},
_updateSize: function(t, e) {
var i = this._edTxt;
if (i) {
i.style.width = t + "px";
i.style.height = e + "px";
}
},
_updateMatrix: function() {
if (this._edTxt) {
var t = this._node;
t.getWorldMatrix(l);
if (this._m00 !== l.m00 || this._m01 !== l.m01 || this._m04 !== l.m04 || this._m05 !== l.m05 || this._m12 !== l.m12 || this._m13 !== l.m13 || this._w !== t._contentSize.width || this._h !== t._contentSize.height) {
this._m00 = l.m00;
this._m01 = l.m01;
this._m04 = l.m04;
this._m05 = l.m05;
this._m12 = l.m12;
this._m13 = l.m13;
this._w = t._contentSize.width;
this._h = t._contentSize.height;
var e = cc.view._scaleX, i = cc.view._scaleY, n = cc.view._viewportRect, r = cc.view._devicePixelRatio;
_.x = -t._anchorPoint.x * this._w;
_.y = -t._anchorPoint.y * this._h;
h.mat4.translate(l, l, _);
cc.Camera.findCamera(t).getWorldToCameraMatrix(u);
h.mat4.mul(u, u, l);
e /= r;
i /= r;
var s = cc.game.container, o = u.m00 * e, a = u.m01, c = u.m04, f = u.m05 * i, m = s && s.style.paddingLeft && parseInt(s.style.paddingLeft);
m += n.x / r;
var p = s && s.style.paddingBottom && parseInt(s.style.paddingBottom);
p += n.y / r;
var v = u.m12 * e + m, y = u.m13 * i + p;
if (d.zoomInvalid) {
this._updateSize(this._size.width * o, this._size.height * f);
o = 1;
f = 1;
}
var g = "matrix(" + o + "," + -a + "," + -c + "," + f + "," + v + "," + -y + ")";
this._edTxt.style.transform = g;
this._edTxt.style["-webkit-transform"] = g;
this._edTxt.style["transform-origin"] = "0px 100% 0px";
this._edTxt.style["-webkit-transform-origin"] = "0px 100% 0px";
}
}
},
_adjustEditBoxPosition: function() {
this._node.getWorldMatrix(l);
var t = l.m13, e = cc.visibleRect.height, i = .5;
cc.visibleRect.width > e && (i = .7);
setTimeout((function() {
if (window.scrollY < 40 && t < e * i) {
var n = e * i - t - window.scrollY;
n < 35 && (n = 35);
n > 320 && (n = 320);
window.scrollTo(0, n);
}
}), 400);
}
}), p = m.prototype;
p.createInput = function() {
this._inputMode === o.ANY ? this._createDomTextArea() : this._createDomInput();
};
p._beginEditingOnMobile = function() {
this.addOrientationchangeEvent();
if (cc.view.isAutoFullScreenEnabled()) {
this.__fullscreen = !0;
cc.view.enableAutoFullScreen(!1);
cc.screen.exitFullScreen();
} else this.__fullscreen = !1;
this.__autoResize = cc.view._resizeWithBrowserSize;
cc.view.resizeWithBrowserSize(!1);
f = this;
};
p._endEditingOnMobile = function() {
if (this.__rotateScreen) {
cc.game.container.style["-webkit-transform"] = "rotate(90deg)";
cc.game.container.style.transform = "rotate(90deg)";
var t = cc.view, e = t._originalDesignResolutionSize.width, i = t._originalDesignResolutionSize.height;
e > 0 && t.setDesignResolutionSize(e, i, t._resolutionPolicy);
this.__rotateScreen = !1;
}
this.removeOrientationchangeEvent();
this.__fullscreen && cc.view.enableAutoFullScreen(!0);
this.__autoResize && f === this && cc.view.resizeWithBrowserSize(!0);
};
function v(t, e) {
t.value.length > e._maxLength && (t.value = t.value.slice(0, e._maxLength));
if (e._delegate && e._delegate.editBoxTextChanged && e._text !== t.value) {
e._text = t.value;
e._delegate.editBoxTextChanged(e._text);
}
}
function y(t, e, i) {
var n = !1, s = !1, o = e.__eventListeners;
o.compositionstart = function() {
n = !0;
};
t.addEventListener("compositionstart", o.compositionstart);
o.compositionend = function() {
n = !1;
if (s) {
this.value = e._text;
s = !1;
}
v(this, e);
};
t.addEventListener("compositionend", o.compositionend);
o.input = function() {
n || v(this, e);
};
t.addEventListener("input", o.input);
o.focus = function() {
this.style.fontSize = e._edFontSize + "px";
this.style.color = e._textColor.toCSS("rgba");
e._alwaysOnTop && (e._editing = !0);
cc.sys.isMobile && e._beginEditingOnMobile();
e._delegate && e._delegate.editBoxEditingDidBegan && e._delegate.editBoxEditingDidBegan();
};
t.addEventListener("focus", o.focus);
o.keypress = function(t) {
if (t.keyCode === r.KEY.enter) {
t.stopPropagation();
e._delegate && e._delegate.editBoxEditingReturn && e._delegate.editBoxEditingReturn();
if (!i) {
e._text = this.value;
e._endEditing();
cc.game.canvas.focus();
}
}
};
t.addEventListener("keypress", o.keypress);
o.blur = function() {
n ? s = !0 : e._text = this.value;
e._endEditing();
};
t.addEventListener("blur", o.blur);
e._addDomToGameContainer();
}
p._createDomInput = function() {
this.removeDom();
var t = this._edTxt = document.createElement("input");
t.type = "text";
t.style.fontSize = this._edFontSize + "px";
t.style.color = "#000000";
t.style.border = 0;
t.style.background = "transparent";
t.style.width = "100%";
t.style.height = "100%";
t.style.active = 0;
t.style.outline = "medium";
t.style.padding = "0";
t.style.textTransform = "uppercase";
t.style.display = "none";
t.style.position = "absolute";
t.style.bottom = "0px";
t.style.left = "2px";
t.style["-moz-appearance"] = "textfield";
t.style.fontFamily = "Arial";
t.className = "cocosEditBox";
y(t, this);
return t;
};
p._createDomTextArea = function() {
this.removeDom();
var t = this._edTxt = document.createElement("textarea");
t.style.fontSize = this._edFontSize + "px";
t.style.color = "#000000";
t.style.border = 0;
t.style.background = "transparent";
t.style.width = "100%";
t.style.height = "100%";
t.style.active = 0;
t.style.outline = "medium";
t.style.padding = "0";
t.style.resize = "none";
t.style.textTransform = "uppercase";
t.style.overflow_y = "scroll";
t.style.display = "none";
t.style.position = "absolute";
t.style.bottom = "0px";
t.style.left = "2px";
t.style.fontFamily = "Arial";
t.className = "cocosEditBox";
y(t, this, !0);
return t;
};
p._addDomToGameContainer = function() {
cc.game.container.appendChild(this._edTxt);
};
p.removeDom = function() {
var t = this._edTxt;
if (t) {
var e = this.__eventListeners;
t.removeEventListener("compositionstart", e.compositionstart);
t.removeEventListener("compositionend", e.compositionend);
t.removeEventListener("input", e.input);
t.removeEventListener("focus", e.focus);
t.removeEventListener("keypress", e.keypress);
t.removeEventListener("blur", e.blur);
e.compositionstart = null;
e.compositionend = null;
e.input = null;
e.focus = null;
e.keypress = null;
e.blur = null;
n.contains(cc.game.container, t) && cc.game.container.removeChild(t);
}
this._edTxt = null;
};
p.addOrientationchangeEvent = function() {
var t = this;
t.__orientationChanged || (t.__orientationChanged = function() {
t._adjustEditBoxPosition();
});
window.addEventListener("orientationchange", t.__orientationChanged);
};
p.removeOrientationchangeEvent = function() {
if (this.__orientationChanged) {
window.removeEventListener("orientationchange", this.__orientationChanged);
this.__orientationChanged = null;
}
};
e.exports = m;
}), {
"../../platform/CCMacro": 165,
"../../platform/utils": 184,
"./types": 93
} ],
93: [ (function(t, e, i) {
var n = cc.Enum({
DEFAULT: 0,
DONE: 1,
SEND: 2,
SEARCH: 3,
GO: 4,
NEXT: 5
}), r = cc.Enum({
ANY: 0,
EMAIL_ADDR: 1,
NUMERIC: 2,
PHONE_NUMBER: 3,
URL: 4,
DECIMAL: 5,
SINGLE_LINE: 6
}), s = cc.Enum({
PASSWORD: 0,
SENSITIVE: 1,
INITIAL_CAPS_WORD: 2,
INITIAL_CAPS_SENTENCE: 3,
INITIAL_CAPS_ALL_CHARACTERS: 4,
DEFAULT: 5
});
e.exports = {
KeyboardReturnType: n,
InputMode: r,
InputFlag: s
};
}), {} ],
94: [ (function(t, e, i) {
t("./CCComponent");
t("./CCComponentEventHandler");
t("./missing-script");
var n = [ t("./CCSprite"), t("./CCWidget"), t("./CCCanvas"), t("./CCAudioSource"), t("./CCAnimation"), t("./CCButton"), t("./CCLabel"), t("./CCProgressBar"), t("./CCMask"), t("./CCScrollBar"), t("./CCScrollView"), t("./CCPageViewIndicator"), t("./CCPageView"), t("./CCSlider"), t("./CCLayout"), t("./editbox/CCEditBox"), t("./CCLabelOutline"), t("./CCRichText"), t("./CCToggleContainer"), t("./CCToggleGroup"), t("./CCToggle"), t("./CCBlockInputEvents"), t("./CCMotionStreak"), t("./WXSubContextView"), t("./SwanSubContextView") ];
e.exports = n;
}), {
"./CCAnimation": 62,
"./CCAudioSource": 63,
"./CCBlockInputEvents": 64,
"./CCButton": 65,
"./CCCanvas": 66,
"./CCComponent": 67,
"./CCComponentEventHandler": 68,
"./CCLabel": 69,
"./CCLabelOutline": 70,
"./CCLayout": 71,
"./CCMask": 72,
"./CCMotionStreak": 73,
"./CCPageView": 74,
"./CCPageViewIndicator": 75,
"./CCProgressBar": 76,
"./CCRichText": 78,
"./CCScrollBar": 79,
"./CCScrollView": 80,
"./CCSlider": 81,
"./CCSprite": 82,
"./CCToggle": 84,
"./CCToggleContainer": 85,
"./CCToggleGroup": 86,
"./CCWidget": 88,
"./SwanSubContextView": 89,
"./WXSubContextView": 90,
"./editbox/CCEditBox": 91,
"./missing-script": 95
} ],
95: [ (function(t, e, i) {
var n = cc.js, r = t("../utils/misc").BUILTIN_CLASSID_RE, s = cc.Class({
name: "cc.MissingClass",
properties: {
_$erialized: {
default: null,
visible: !1,
editorOnly: !0
}
}
}), o = cc.Class({
name: "cc.MissingScript",
extends: cc.Component,
editor: {
inspector: "packages://inspector/inspectors/comps/missing-script.js"
},
properties: {
compiled: {
default: !1,
serializable: !1
},
_$erialized: {
default: null,
visible: !1,
editorOnly: !0
}
},
ctor: !1,
statics: {
safeFindClass: function(t, e) {
var i = n._getClassById(t);
if (i) return i;
if (t) {
cc.deserialize.reportMissingClass(t);
return o.getMissingWrapper(t, e);
}
return null;
},
getMissingWrapper: function(t, e) {
return e.node && (/^[0-9a-zA-Z+/]{23}$/.test(t) || r.test(t)) ? o : s;
}
},
onLoad: function() {
cc.warnID(4600, this.node.name);
}
});
cc._MissingScript = e.exports = o;
}), {
"../utils/misc": 242
} ],
96: [ (function(t, e, i) {
var n = cc.js;
t("../event/event");
var r = function(t, e) {
cc.Event.call(this, cc.Event.MOUSE, e);
this._eventType = t;
this._button = 0;
this._x = 0;
this._y = 0;
this._prevX = 0;
this._prevY = 0;
this._scrollX = 0;
this._scrollY = 0;
};
n.extend(r, cc.Event);
var s = r.prototype;
s.setScrollData = function(t, e) {
this._scrollX = t;
this._scrollY = e;
};
s.getScrollX = function() {
return this._scrollX;
};
s.getScrollY = function() {
return this._scrollY;
};
s.setLocation = function(t, e) {
this._x = t;
this._y = e;
};
s.getLocation = function() {
return cc.v2(this._x, this._y);
};
s.getLocationInView = function() {
return cc.v2(this._x, cc.view._designResolutionSize.height - this._y);
};
s._setPrevCursor = function(t, e) {
this._prevX = t;
this._prevY = e;
};
s.getPreviousLocation = function() {
return cc.v2(this._prevX, this._prevY);
};
s.getDelta = function() {
return cc.v2(this._x - this._prevX, this._y - this._prevY);
};
s.getDeltaX = function() {
return this._x - this._prevX;
};
s.getDeltaY = function() {
return this._y - this._prevY;
};
s.setButton = function(t) {
this._button = t;
};
s.getButton = function() {
return this._button;
};
s.getLocationX = function() {
return this._x;
};
s.getLocationY = function() {
return this._y;
};
r.NONE = 0;
r.DOWN = 1;
r.UP = 2;
r.MOVE = 3;
r.SCROLL = 4;
r.BUTTON_LEFT = 0;
r.BUTTON_RIGHT = 2;
r.BUTTON_MIDDLE = 1;
r.BUTTON_4 = 3;
r.BUTTON_5 = 4;
r.BUTTON_6 = 5;
r.BUTTON_7 = 6;
r.BUTTON_8 = 7;
var o = function(t, e) {
cc.Event.call(this, cc.Event.TOUCH, e);
this._eventCode = 0;
this._touches = t || [];
this.touch = null;
this.currentTouch = null;
};
n.extend(o, cc.Event);
(s = o.prototype).getEventCode = function() {
return this._eventCode;
};
s.getTouches = function() {
return this._touches;
};
s._setEventCode = function(t) {
this._eventCode = t;
};
s._setTouches = function(t) {
this._touches = t;
};
s.setLocation = function(t, e) {
this.touch && this.touch.setTouchInfo(this.touch.getID(), t, e);
};
s.getLocation = function() {
return this.touch ? this.touch.getLocation() : cc.v2();
};
s.getLocationInView = function() {
return this.touch ? this.touch.getLocationInView() : cc.v2();
};
s.getPreviousLocation = function() {
return this.touch ? this.touch.getPreviousLocation() : cc.v2();
};
s.getStartLocation = function() {
return this.touch ? this.touch.getStartLocation() : cc.v2();
};
s.getID = function() {
return this.touch ? this.touch.getID() : null;
};
s.getDelta = function() {
return this.touch ? this.touch.getDelta() : cc.v2();
};
s.getDeltaX = function() {
return this.touch ? this.touch.getDelta().x : 0;
};
s.getDeltaY = function() {
return this.touch ? this.touch.getDelta().y : 0;
};
s.getLocationX = function() {
return this.touch ? this.touch.getLocationX() : 0;
};
s.getLocationY = function() {
return this.touch ? this.touch.getLocationY() : 0;
};
o.MAX_TOUCHES = 5;
o.BEGAN = 0;
o.MOVED = 1;
o.ENDED = 2;
o.CANCELED = 3;
var a = function(t, e) {
cc.Event.call(this, cc.Event.ACCELERATION, e);
this.acc = t;
};
n.extend(a, cc.Event);
var c = function(t, e, i) {
cc.Event.call(this, cc.Event.KEYBOARD, i);
this.keyCode = t;
this.isPressed = e;
};
n.extend(c, cc.Event);
cc.Event.EventMouse = r;
cc.Event.EventTouch = o;
cc.Event.EventAcceleration = a;
cc.Event.EventKeyboard = c;
e.exports = cc.Event;
}), {
"../event/event": 103
} ],
97: [ (function(t, e, i) {
var n = t("../platform/js");
cc.EventListener = function(t, e, i) {
this._onEvent = i;
this._type = t || 0;
this._listenerID = e || "";
this._registered = !1;
this._fixedPriority = 0;
this._node = null;
this._target = null;
this._paused = !0;
this._isEnabled = !0;
};
cc.EventListener.prototype = {
constructor: cc.EventListener,
_setPaused: function(t) {
this._paused = t;
},
_isPaused: function() {
return this._paused;
},
_setRegistered: function(t) {
this._registered = t;
},
_isRegistered: function() {
return this._registered;
},
_getType: function() {
return this._type;
},
_getListenerID: function() {
return this._listenerID;
},
_setFixedPriority: function(t) {
this._fixedPriority = t;
},
_getFixedPriority: function() {
return this._fixedPriority;
},
_setSceneGraphPriority: function(t) {
this._target = t;
this._node = t;
},
_getSceneGraphPriority: function() {
return this._node;
},
checkAvailable: function() {
return null !== this._onEvent;
},
clone: function() {
return null;
},
setEnabled: function(t) {
this._isEnabled = t;
},
isEnabled: function() {
return this._isEnabled;
},
retain: function() {},
release: function() {}
};
cc.EventListener.UNKNOWN = 0;
cc.EventListener.TOUCH_ONE_BY_ONE = 1;
cc.EventListener.TOUCH_ALL_AT_ONCE = 2;
cc.EventListener.KEYBOARD = 3;
cc.EventListener.MOUSE = 4;
cc.EventListener.ACCELERATION = 6;
cc.EventListener.CUSTOM = 8;
var r = cc.EventListener.ListenerID = {
MOUSE: "__cc_mouse",
TOUCH_ONE_BY_ONE: "__cc_touch_one_by_one",
TOUCH_ALL_AT_ONCE: "__cc_touch_all_at_once",
KEYBOARD: "__cc_keyboard",
ACCELERATION: "__cc_acceleration"
}, s = function(t, e) {
this._onCustomEvent = e;
cc.EventListener.call(this, cc.EventListener.CUSTOM, t, this._callback);
};
n.extend(s, cc.EventListener);
n.mixin(s.prototype, {
_onCustomEvent: null,
_callback: function(t) {
null !== this._onCustomEvent && this._onCustomEvent(t);
},
checkAvailable: function() {
return cc.EventListener.prototype.checkAvailable.call(this) && null !== this._onCustomEvent;
},
clone: function() {
return new s(this._listenerID, this._onCustomEvent);
}
});
var o = function() {
cc.EventListener.call(this, cc.EventListener.MOUSE, r.MOUSE, this._callback);
};
n.extend(o, cc.EventListener);
n.mixin(o.prototype, {
onMouseDown: null,
onMouseUp: null,
onMouseMove: null,
onMouseScroll: null,
_callback: function(t) {
var e = cc.Event.EventMouse;
switch (t._eventType) {
case e.DOWN:
this.onMouseDown && this.onMouseDown(t);
break;

case e.UP:
this.onMouseUp && this.onMouseUp(t);
break;

case e.MOVE:
this.onMouseMove && this.onMouseMove(t);
break;

case e.SCROLL:
this.onMouseScroll && this.onMouseScroll(t);
}
},
clone: function() {
var t = new o();
t.onMouseDown = this.onMouseDown;
t.onMouseUp = this.onMouseUp;
t.onMouseMove = this.onMouseMove;
t.onMouseScroll = this.onMouseScroll;
return t;
},
checkAvailable: function() {
return !0;
}
});
var a = function() {
cc.EventListener.call(this, cc.EventListener.TOUCH_ONE_BY_ONE, r.TOUCH_ONE_BY_ONE, null);
this._claimedTouches = [];
};
n.extend(a, cc.EventListener);
n.mixin(a.prototype, {
constructor: a,
_claimedTouches: null,
swallowTouches: !1,
onTouchBegan: null,
onTouchMoved: null,
onTouchEnded: null,
onTouchCancelled: null,
setSwallowTouches: function(t) {
this.swallowTouches = t;
},
isSwallowTouches: function() {
return this.swallowTouches;
},
clone: function() {
var t = new a();
t.onTouchBegan = this.onTouchBegan;
t.onTouchMoved = this.onTouchMoved;
t.onTouchEnded = this.onTouchEnded;
t.onTouchCancelled = this.onTouchCancelled;
t.swallowTouches = this.swallowTouches;
return t;
},
checkAvailable: function() {
if (!this.onTouchBegan) {
cc.logID(1801);
return !1;
}
return !0;
}
});
var c = function() {
cc.EventListener.call(this, cc.EventListener.TOUCH_ALL_AT_ONCE, r.TOUCH_ALL_AT_ONCE, null);
};
n.extend(c, cc.EventListener);
n.mixin(c.prototype, {
constructor: c,
onTouchesBegan: null,
onTouchesMoved: null,
onTouchesEnded: null,
onTouchesCancelled: null,
clone: function() {
var t = new c();
t.onTouchesBegan = this.onTouchesBegan;
t.onTouchesMoved = this.onTouchesMoved;
t.onTouchesEnded = this.onTouchesEnded;
t.onTouchesCancelled = this.onTouchesCancelled;
return t;
},
checkAvailable: function() {
if (null === this.onTouchesBegan && null === this.onTouchesMoved && null === this.onTouchesEnded && null === this.onTouchesCancelled) {
cc.logID(1802);
return !1;
}
return !0;
}
});
var h = function(t) {
this._onAccelerationEvent = t;
cc.EventListener.call(this, cc.EventListener.ACCELERATION, r.ACCELERATION, this._callback);
};
n.extend(h, cc.EventListener);
n.mixin(h.prototype, {
constructor: h,
_onAccelerationEvent: null,
_callback: function(t) {
this._onAccelerationEvent(t.acc, t);
},
checkAvailable: function() {
cc.assertID(this._onAccelerationEvent, 1803);
return !0;
},
clone: function() {
return new h(this._onAccelerationEvent);
}
});
var l = function() {
cc.EventListener.call(this, cc.EventListener.KEYBOARD, r.KEYBOARD, this._callback);
};
n.extend(l, cc.EventListener);
n.mixin(l.prototype, {
constructor: l,
onKeyPressed: null,
onKeyReleased: null,
_callback: function(t) {
t.isPressed ? this.onKeyPressed && this.onKeyPressed(t.keyCode, t) : this.onKeyReleased && this.onKeyReleased(t.keyCode, t);
},
clone: function() {
var t = new l();
t.onKeyPressed = this.onKeyPressed;
t.onKeyReleased = this.onKeyReleased;
return t;
},
checkAvailable: function() {
if (null === this.onKeyPressed && null === this.onKeyReleased) {
cc.logID(1800);
return !1;
}
return !0;
}
});
cc.EventListener.create = function(t) {
cc.assertID(t && t.event, 1900);
var e = t.event;
delete t.event;
var i = null;
if (e === cc.EventListener.TOUCH_ONE_BY_ONE) i = new a(); else if (e === cc.EventListener.TOUCH_ALL_AT_ONCE) i = new c(); else if (e === cc.EventListener.MOUSE) i = new o(); else if (e === cc.EventListener.CUSTOM) {
i = new s(t.eventName, t.callback);
delete t.eventName;
delete t.callback;
} else if (e === cc.EventListener.KEYBOARD) i = new l(); else if (e === cc.EventListener.ACCELERATION) {
i = new h(t.callback);
delete t.callback;
}
for (var n in t) i[n] = t[n];
return i;
};
e.exports = cc.EventListener;
}), {
"../platform/js": 180
} ],
98: [ (function(t, e, i) {
var n = t("../platform/js");
t("./CCEventListener");
var r = cc.EventListener.ListenerID, s = function() {
this._fixedListeners = [];
this._sceneGraphListeners = [];
this.gt0Index = 0;
};
s.prototype = {
constructor: s,
size: function() {
return this._fixedListeners.length + this._sceneGraphListeners.length;
},
empty: function() {
return 0 === this._fixedListeners.length && 0 === this._sceneGraphListeners.length;
},
push: function(t) {
0 === t._getFixedPriority() ? this._sceneGraphListeners.push(t) : this._fixedListeners.push(t);
},
clearSceneGraphListeners: function() {
this._sceneGraphListeners.length = 0;
},
clearFixedListeners: function() {
this._fixedListeners.length = 0;
},
clear: function() {
this._sceneGraphListeners.length = 0;
this._fixedListeners.length = 0;
},
getFixedPriorityListeners: function() {
return this._fixedListeners;
},
getSceneGraphPriorityListeners: function() {
return this._sceneGraphListeners;
}
};
var o = {
DIRTY_NONE: 0,
DIRTY_FIXED_PRIORITY: 1,
DIRTY_SCENE_GRAPH_PRIORITY: 2,
DIRTY_ALL: 3,
_listenersMap: {},
_priorityDirtyFlagMap: {},
_nodeListenersMap: {},
_nodePriorityMap: n.createMap(!0),
_globalZOrderNodeMap: [],
_toAddedListeners: [],
_toRemovedListeners: [],
_dirtyNodes: [],
_inDispatch: 0,
_isEnabled: !1,
_nodePriorityIndex: 0,
_internalCustomListenerIDs: [],
_setDirtyForNode: function(t) {
void 0 !== this._nodeListenersMap[t._id] && this._dirtyNodes.push(t);
if (t.getChildren) for (var e = t.getChildren(), i = 0, n = e ? e.length : 0; i < n; i++) this._setDirtyForNode(e[i]);
},
pauseTarget: function(t, e) {
if (t instanceof cc._BaseNode) {
var i, n, r = this._nodeListenersMap[t._id];
if (r) for (i = 0, n = r.length; i < n; i++) r[i]._setPaused(!0);
if (!0 === e) {
var s = t.getChildren();
for (i = 0, n = s ? s.length : 0; i < n; i++) this.pauseTarget(s[i], !0);
}
} else cc.warnID(3506);
},
resumeTarget: function(t, e) {
if (t instanceof cc._BaseNode) {
var i, n, r = this._nodeListenersMap[t._id];
if (r) for (i = 0, n = r.length; i < n; i++) r[i]._setPaused(!1);
this._setDirtyForNode(t);
if (!0 === e && t.getChildren) {
var s = t.getChildren();
for (i = 0, n = s ? s.length : 0; i < n; i++) this.resumeTarget(s[i], !0);
}
} else cc.warnID(3506);
},
_addListener: function(t) {
0 === this._inDispatch ? this._forceAddEventListener(t) : this._toAddedListeners.push(t);
},
_forceAddEventListener: function(t) {
var e = t._getListenerID(), i = this._listenersMap[e];
if (!i) {
i = new s();
this._listenersMap[e] = i;
}
i.push(t);
if (0 === t._getFixedPriority()) {
this._setDirty(e, this.DIRTY_SCENE_GRAPH_PRIORITY);
var n = t._getSceneGraphPriority();
null === n && cc.logID(3507);
this._associateNodeAndEventListener(n, t);
n.activeInHierarchy && this.resumeTarget(n);
} else this._setDirty(e, this.DIRTY_FIXED_PRIORITY);
},
_getListeners: function(t) {
return this._listenersMap[t];
},
_updateDirtyFlagForSceneGraph: function() {
if (0 !== this._dirtyNodes.length) {
for (var t, e, i = this._dirtyNodes, n = this._nodeListenersMap, r = 0, s = i.length; r < s; r++) if (t = n[i[r]._id]) for (var o = 0, a = t.length; o < a; o++) (e = t[o]) && this._setDirty(e._getListenerID(), this.DIRTY_SCENE_GRAPH_PRIORITY);
this._dirtyNodes.length = 0;
}
},
_removeAllListenersInVector: function(t) {
if (t) for (var e, i = 0; i < t.length; ) {
(e = t[i])._setRegistered(!1);
if (null != e._getSceneGraphPriority()) {
this._dissociateNodeAndEventListener(e._getSceneGraphPriority(), e);
e._setSceneGraphPriority(null);
}
0 === this._inDispatch ? cc.js.array.remove(t, e) : ++i;
}
},
_removeListenersForListenerID: function(t) {
var e, i = this._listenersMap[t];
if (i) {
var n = i.getFixedPriorityListeners(), r = i.getSceneGraphPriorityListeners();
this._removeAllListenersInVector(r);
this._removeAllListenersInVector(n);
delete this._priorityDirtyFlagMap[t];
if (!this._inDispatch) {
i.clear();
delete this._listenersMap[t];
}
}
var s, o = this._toAddedListeners;
for (e = 0; e < o.length; ) (s = o[e]) && s._getListenerID() === t ? cc.js.array.remove(o, s) : ++e;
},
_sortEventListeners: function(t) {
var e = this.DIRTY_NONE, i = this._priorityDirtyFlagMap;
i[t] && (e = i[t]);
if (e !== this.DIRTY_NONE) {
i[t] = this.DIRTY_NONE;
e & this.DIRTY_FIXED_PRIORITY && this._sortListenersOfFixedPriority(t);
if (e & this.DIRTY_SCENE_GRAPH_PRIORITY) {
var n = cc.director.getScene();
n && this._sortListenersOfSceneGraphPriority(t, n);
}
}
},
_sortListenersOfSceneGraphPriority: function(t, e) {
var i = this._getListeners(t);
if (i) {
var r = i.getSceneGraphPriorityListeners();
if (r && 0 !== r.length) {
this._nodePriorityIndex = 0;
this._nodePriorityMap = n.createMap(!0);
this._visitTarget(e, !0);
i.getSceneGraphPriorityListeners().sort(this._sortEventListenersOfSceneGraphPriorityDes);
}
}
},
_sortEventListenersOfSceneGraphPriorityDes: function(t, e) {
var i = o._nodePriorityMap, n = t._getSceneGraphPriority(), r = e._getSceneGraphPriority();
return e && r && i[r._id] ? t && n && i[n._id] ? i[r._id] - i[n._id] : 1 : -1;
},
_sortListenersOfFixedPriority: function(t) {
var e = this._listenersMap[t];
if (e) {
var i = e.getFixedPriorityListeners();
if (i && 0 !== i.length) {
i.sort(this._sortListenersOfFixedPriorityAsc);
for (var n = 0, r = i.length; n < r && !(i[n]._getFixedPriority() >= 0); ) ++n;
e.gt0Index = n;
}
}
},
_sortListenersOfFixedPriorityAsc: function(t, e) {
return t._getFixedPriority() - e._getFixedPriority();
},
_onUpdateListeners: function(t) {
var e, i, n, r = t.getFixedPriorityListeners(), s = t.getSceneGraphPriorityListeners(), o = this._toRemovedListeners;
if (s) for (e = 0; e < s.length; ) if ((i = s[e])._isRegistered()) ++e; else {
cc.js.array.remove(s, i);
-1 !== (n = o.indexOf(i)) && o.splice(n, 1);
}
if (r) for (e = 0; e < r.length; ) if ((i = r[e])._isRegistered()) ++e; else {
cc.js.array.remove(r, i);
-1 !== (n = o.indexOf(i)) && o.splice(n, 1);
}
s && 0 === s.length && t.clearSceneGraphListeners();
r && 0 === r.length && t.clearFixedListeners();
},
frameUpdateListeners: function() {
var t = this._listenersMap, e = this._priorityDirtyFlagMap;
for (var i in t) if (t[i].empty()) {
delete e[i];
delete t[i];
}
var n = this._toAddedListeners;
if (0 !== n.length) {
for (var r = 0, s = n.length; r < s; r++) this._forceAddEventListener(n[r]);
n.length = 0;
}
0 !== this._toRemovedListeners.length && this._cleanToRemovedListeners();
},
_updateTouchListeners: function(t) {
var e = this._inDispatch;
cc.assertID(e > 0, 3508);
if (!(e > 1)) {
var i;
(i = this._listenersMap[r.TOUCH_ONE_BY_ONE]) && this._onUpdateListeners(i);
(i = this._listenersMap[r.TOUCH_ALL_AT_ONCE]) && this._onUpdateListeners(i);
cc.assertID(1 === e, 3509);
var n = this._toAddedListeners;
if (0 !== n.length) {
for (var s = 0, o = n.length; s < o; s++) this._forceAddEventListener(n[s]);
this._toAddedListeners.length = 0;
}
0 !== this._toRemovedListeners.length && this._cleanToRemovedListeners();
}
},
_cleanToRemovedListeners: function() {
for (var t = this._toRemovedListeners, e = 0; e < t.length; e++) {
var i = t[e], n = this._listenersMap[i._getListenerID()];
if (n) {
var r, s = n.getFixedPriorityListeners(), o = n.getSceneGraphPriorityListeners();
o && -1 !== (r = o.indexOf(i)) && o.splice(r, 1);
s && -1 !== (r = s.indexOf(i)) && s.splice(r, 1);
}
}
t.length = 0;
},
_onTouchEventCallback: function(t, e) {
if (!t._isRegistered()) return !1;
var i = e.event, n = i.currentTouch;
i.currentTarget = t._node;
var r, s = !1, a = i.getEventCode(), c = cc.Event.EventTouch;
if (a === c.BEGAN) t.onTouchBegan && (s = t.onTouchBegan(n, i)) && t._registered && t._claimedTouches.push(n); else if (t._claimedTouches.length > 0 && -1 !== (r = t._claimedTouches.indexOf(n))) {
s = !0;
if (a === c.MOVED && t.onTouchMoved) t.onTouchMoved(n, i); else if (a === c.ENDED) {
t.onTouchEnded && t.onTouchEnded(n, i);
t._registered && t._claimedTouches.splice(r, 1);
} else if (a === c.CANCELLED) {
t.onTouchCancelled && t.onTouchCancelled(n, i);
t._registered && t._claimedTouches.splice(r, 1);
}
}
if (i.isStopped()) {
o._updateTouchListeners(i);
return !0;
}
if (s && t.swallowTouches) {
e.needsMutableSet && e.touches.splice(n, 1);
return !0;
}
return !1;
},
_dispatchTouchEvent: function(t) {
this._sortEventListeners(r.TOUCH_ONE_BY_ONE);
this._sortEventListeners(r.TOUCH_ALL_AT_ONCE);
var e = this._getListeners(r.TOUCH_ONE_BY_ONE), i = this._getListeners(r.TOUCH_ALL_AT_ONCE);
if (null !== e || null !== i) {
var n = t.getTouches(), s = cc.js.array.copy(n), o = {
event: t,
needsMutableSet: e && i,
touches: s,
selTouch: null
};
if (e) for (var a = 0; a < n.length; a++) {
t.currentTouch = n[a];
t._propagationStopped = t._propagationImmediateStopped = !1;
this._dispatchEventToListeners(e, this._onTouchEventCallback, o);
}
if (i && s.length > 0) {
this._dispatchEventToListeners(i, this._onTouchesEventCallback, {
event: t,
touches: s
});
if (t.isStopped()) return;
}
this._updateTouchListeners(t);
}
},
_onTouchesEventCallback: function(t, e) {
if (!t._registered) return !1;
var i = cc.Event.EventTouch, n = e.event, r = e.touches, s = n.getEventCode();
n.currentTarget = t._node;
s === i.BEGAN && t.onTouchesBegan ? t.onTouchesBegan(r, n) : s === i.MOVED && t.onTouchesMoved ? t.onTouchesMoved(r, n) : s === i.ENDED && t.onTouchesEnded ? t.onTouchesEnded(r, n) : s === i.CANCELLED && t.onTouchesCancelled && t.onTouchesCancelled(r, n);
if (n.isStopped()) {
o._updateTouchListeners(n);
return !0;
}
return !1;
},
_associateNodeAndEventListener: function(t, e) {
var i = this._nodeListenersMap[t._id];
if (!i) {
i = [];
this._nodeListenersMap[t._id] = i;
}
i.push(e);
},
_dissociateNodeAndEventListener: function(t, e) {
var i = this._nodeListenersMap[t._id];
if (i) {
cc.js.array.remove(i, e);
0 === i.length && delete this._nodeListenersMap[t._id];
}
},
_dispatchEventToListeners: function(t, e, i) {
var n, r, s = !1, o = t.getFixedPriorityListeners(), a = t.getSceneGraphPriorityListeners(), c = 0;
if (o && 0 !== o.length) for (;c < t.gt0Index; ++c) if ((r = o[c]).isEnabled() && !r._isPaused() && r._isRegistered() && e(r, i)) {
s = !0;
break;
}
if (a && !s) for (n = 0; n < a.length; n++) if ((r = a[n]).isEnabled() && !r._isPaused() && r._isRegistered() && e(r, i)) {
s = !0;
break;
}
if (o && !s) for (;c < o.length; ++c) if ((r = o[c]).isEnabled() && !r._isPaused() && r._isRegistered() && e(r, i)) {
s = !0;
break;
}
},
_setDirty: function(t, e) {
var i = this._priorityDirtyFlagMap;
null == i[t] ? i[t] = e : i[t] = e | i[t];
},
_visitTarget: function(t, e) {
t._reorderChildDirty && t.sortAllChildren();
var i = t.getChildren(), n = 0, r = i.length, s = this._globalZOrderNodeMap, o = this._nodeListenersMap;
if (r > 0) {
if (void 0 !== o[t._id]) {
s || (s = []);
s.push(t._id);
}
for (var a; n < r; n++) (a = i[n]) && this._visitTarget(a, !1);
} else if (void 0 !== o[t._id]) {
s || (s = []);
s.push(t._id);
}
if (e) {
for (var c = this._nodePriorityMap, h = 0; h < s.length; h++) c[s[h]] = ++this._nodePriorityIndex;
this._globalZOrderNodeMap.length = 0;
}
},
_sortNumberAsc: function(t, e) {
return t - e;
},
hasEventListener: function(t) {
return !!this._getListeners(t);
},
addListener: function(t, e) {
cc.assertID(t && e, 3503);
if (cc.js.isNumber(e) || e instanceof cc._BaseNode) {
if (t instanceof cc.EventListener) {
if (t._isRegistered()) {
cc.logID(3505);
return;
}
} else {
cc.assertID(!cc.js.isNumber(e), 3504);
t = cc.EventListener.create(t);
}
if (t.checkAvailable()) {
if (cc.js.isNumber(e)) {
if (0 === e) {
cc.logID(3500);
return;
}
t._setSceneGraphPriority(null);
t._setFixedPriority(e);
t._setRegistered(!0);
t._setPaused(!1);
this._addListener(t);
} else {
t._setSceneGraphPriority(e);
t._setFixedPriority(0);
t._setRegistered(!0);
this._addListener(t);
}
return t;
}
} else cc.warnID(3506);
},
addCustomListener: function(t, e) {
var i = new cc.EventListener.create({
event: cc.EventListener.CUSTOM,
eventName: t,
callback: e
});
this.addListener(i, 1);
return i;
},
removeListener: function(t) {
if (null != t) {
var e, i = this._listenersMap;
for (var n in i) {
var r = i[n], s = r.getFixedPriorityListeners(), o = r.getSceneGraphPriorityListeners();
(e = this._removeListenerInVector(o, t)) ? this._setDirty(t._getListenerID(), this.DIRTY_SCENE_GRAPH_PRIORITY) : (e = this._removeListenerInVector(s, t)) && this._setDirty(t._getListenerID(), this.DIRTY_FIXED_PRIORITY);
if (r.empty()) {
delete this._priorityDirtyFlagMap[t._getListenerID()];
delete i[n];
}
if (e) break;
}
if (!e) for (var a = this._toAddedListeners, c = 0, h = a.length; c < h; c++) {
var l = a[c];
if (l === t) {
cc.js.array.remove(a, l);
l._setRegistered(!1);
break;
}
}
}
},
_removeListenerInCallback: function(t, e) {
if (null == t) return !1;
for (var i = 0, n = t.length; i < n; i++) {
var r = t[i];
if (r._onCustomEvent === e || r._onEvent === e) {
r._setRegistered(!1);
if (null != r._getSceneGraphPriority()) {
this._dissociateNodeAndEventListener(r._getSceneGraphPriority(), r);
r._setSceneGraphPriority(null);
}
0 === this._inDispatch ? cc.js.array.remove(t, r) : this._toRemovedListeners.push(r);
return !0;
}
}
return !1;
},
_removeListenerInVector: function(t, e) {
if (null == t) return !1;
for (var i = 0, n = t.length; i < n; i++) {
var r = t[i];
if (r === e) {
r._setRegistered(!1);
if (null != r._getSceneGraphPriority()) {
this._dissociateNodeAndEventListener(r._getSceneGraphPriority(), r);
r._setSceneGraphPriority(null);
}
0 === this._inDispatch ? cc.js.array.remove(t, r) : this._toRemovedListeners.push(r);
return !0;
}
}
return !1;
},
removeListeners: function(t, e) {
var i = this;
if (cc.js.isNumber(t) || t instanceof cc._BaseNode) if (void 0 !== t._id) {
delete i._nodePriorityMap[t._id];
cc.js.array.remove(i._dirtyNodes, t);
var n, s = i._nodeListenersMap[t._id];
if (s) {
var o = cc.js.array.copy(s);
for (n = 0; n < o.length; n++) i.removeListener(o[n]);
delete i._nodeListenersMap[t._id];
}
var a = i._toAddedListeners;
for (n = 0; n < a.length; ) {
var c = a[n];
if (c._getSceneGraphPriority() === t) {
c._setSceneGraphPriority(null);
c._setRegistered(!1);
a.splice(n, 1);
} else ++n;
}
if (!0 === e) {
var h, l = t.getChildren();
for (n = 0, h = l.length; n < h; n++) i.removeListeners(l[n], !0);
}
} else t === cc.EventListener.TOUCH_ONE_BY_ONE ? i._removeListenersForListenerID(r.TOUCH_ONE_BY_ONE) : t === cc.EventListener.TOUCH_ALL_AT_ONCE ? i._removeListenersForListenerID(r.TOUCH_ALL_AT_ONCE) : t === cc.EventListener.MOUSE ? i._removeListenersForListenerID(r.MOUSE) : t === cc.EventListener.ACCELERATION ? i._removeListenersForListenerID(r.ACCELERATION) : t === cc.EventListener.KEYBOARD ? i._removeListenersForListenerID(r.KEYBOARD) : cc.logID(3501); else cc.warnID(3506);
},
removeCustomListeners: function(t) {
this._removeListenersForListenerID(t);
},
removeAllListeners: function() {
var t = this._listenersMap, e = this._internalCustomListenerIDs;
for (var i in t) -1 === e.indexOf(i) && this._removeListenersForListenerID(i);
},
setPriority: function(t, e) {
if (null != t) {
var i = this._listenersMap;
for (var n in i) {
var r = i[n].getFixedPriorityListeners();
if (r) {
if (-1 !== r.indexOf(t)) {
null != t._getSceneGraphPriority() && cc.logID(3502);
if (t._getFixedPriority() !== e) {
t._setFixedPriority(e);
this._setDirty(t._getListenerID(), this.DIRTY_FIXED_PRIORITY);
}
return;
}
}
}
}
},
setEnabled: function(t) {
this._isEnabled = t;
},
isEnabled: function() {
return this._isEnabled;
},
dispatchEvent: function(t) {
if (this._isEnabled) {
this._updateDirtyFlagForSceneGraph();
this._inDispatch++;
if (t && t.getType) if (t.getType().startsWith(cc.Event.TOUCH)) {
this._dispatchTouchEvent(t);
this._inDispatch--;
} else {
var e = (function(t) {
var e = cc.Event, i = t.type;
if (i === e.ACCELERATION) return r.ACCELERATION;
if (i === e.KEYBOARD) return r.KEYBOARD;
if (i.startsWith(e.MOUSE)) return r.MOUSE;
i.startsWith(e.TOUCH) && cc.logID(2e3);
return "";
})(t);
this._sortEventListeners(e);
var i = this._listenersMap[e];
if (null != i) {
this._dispatchEventToListeners(i, this._onListenerCallback, t);
this._onUpdateListeners(i);
}
this._inDispatch--;
} else cc.errorID(3511);
}
},
_onListenerCallback: function(t, e) {
e.currentTarget = t._target;
t._onEvent(e);
return e.isStopped();
},
dispatchCustomEvent: function(t, e) {
var i = new cc.Event.EventCustom(t);
i.setUserData(e);
this.dispatchEvent(i);
}
};
n.get(cc, "eventManager", (function() {
cc.warnID(1405, "cc.eventManager", "cc.EventTarget or cc.systemEvent");
return o;
}));
e.exports = o;
}), {
"../platform/js": 180,
"./CCEventListener": 97
} ],
99: [ (function(t, e, i) {
cc.Touch = function(t, e, i) {
this._lastModified = 0;
this.setTouchInfo(i, t, e);
};
cc.Touch.prototype = {
constructor: cc.Touch,
getLocation: function() {
return cc.v2(this._point.x, this._point.y);
},
getLocationX: function() {
return this._point.x;
},
getLocationY: function() {
return this._point.y;
},
getPreviousLocation: function() {
return cc.v2(this._prevPoint.x, this._prevPoint.y);
},
getStartLocation: function() {
return cc.v2(this._startPoint.x, this._startPoint.y);
},
getDelta: function() {
return this._point.sub(this._prevPoint);
},
getLocationInView: function() {
return cc.v2(this._point.x, cc.view._designResolutionSize.height - this._point.y);
},
getPreviousLocationInView: function() {
return cc.v2(this._prevPoint.x, cc.view._designResolutionSize.height - this._prevPoint.y);
},
getStartLocationInView: function() {
return cc.v2(this._startPoint.x, cc.view._designResolutionSize.height - this._startPoint.y);
},
getID: function() {
return this._id;
},
setTouchInfo: function(t, e, i) {
this._prevPoint = this._point;
this._point = cc.v2(e || 0, i || 0);
this._id = t;
if (!this._startPointCaptured) {
this._startPoint = cc.v2(this._point);
cc.view._convertPointWithScale(this._startPoint);
this._startPointCaptured = !0;
}
},
_setPoint: function(t, e) {
if (void 0 === e) {
this._point.x = t.x;
this._point.y = t.y;
} else {
this._point.x = t;
this._point.y = e;
}
},
_setPrevPoint: function(t, e) {
this._prevPoint = void 0 === e ? cc.v2(t.x, t.y) : cc.v2(t || 0, e || 0);
}
};
}), {} ],
100: [ (function(t, e, i) {
t("./CCEvent");
t("./CCTouch");
t("./CCEventListener");
var n = t("./CCEventManager");
e.exports = n;
0;
}), {
"./CCEvent": 96,
"./CCEventListener": 97,
"./CCEventManager": 98,
"./CCTouch": 99
} ],
101: [ (function(t, e, i) {
var n = cc.js, r = t("../platform/callbacks-invoker").CallbacksHandler;
function s() {
r.call(this);
}
n.extend(s, r);
s.prototype.invoke = function(t, e) {
var i = t.type, n = this._callbackTable[i];
if (n) {
var r = !n.isInvoking;
n.isInvoking = !0;
for (var s = n.callbacks, o = n.targets, a = 0, c = s.length; a < c; ++a) {
var h = s[a];
if (h) {
var l = o[a] || t.currentTarget;
h.call(l, t, e);
if (t._propagationImmediateStopped) break;
}
}
if (r) {
n.isInvoking = !1;
n.containCanceled && n.purgeCanceled();
}
}
};
e.exports = s;
0;
}), {
"../platform/callbacks-invoker": 173
} ],
102: [ (function(t, e, i) {
var n = t("../platform/js"), r = t("../platform/callbacks-invoker"), s = n.array.fastRemove;
function o() {
r.call(this);
}
n.extend(o, r);
var a = o.prototype;
a.on = function(t, e, i) {
if (e) {
if (!this.hasEventListener(t, e, i)) {
this.add(t, e, i);
i && i.__eventTargets && i.__eventTargets.push(this);
}
return e;
}
cc.errorID(6800);
};
a.off = function(t, e, i) {
if (e) {
this.remove(t, e, i);
i && i.__eventTargets && s(i.__eventTargets, this);
} else this.removeAll(t);
};
a.targetOff = a.removeAll;
a.once = function(t, e, i) {
var n = "__ONCE_FLAG:" + t;
if (!this.hasEventListener(n, e, i)) {
var r = this, s = function(o, a, c, h, l) {
r.off(t, s, i);
r.remove(n, e, i);
e.call(this, o, a, c, h, l);
};
this.on(t, s, i);
this.add(n, e, i);
}
};
a.emit = r.prototype.invoke;
a.dispatchEvent = function(t) {
this.invoke(t.type, t);
};
cc.EventTarget = e.exports = o;
}), {
"../platform/callbacks-invoker": 173,
"../platform/js": 180
} ],
103: [ (function(t, e, i) {
var n = t("../platform/js");
cc.Event = function(t, e) {
this.type = t;
this.bubbles = !!e;
this.target = null;
this.currentTarget = null;
this.eventPhase = 0;
this._propagationStopped = !1;
this._propagationImmediateStopped = !1;
};
cc.Event.prototype = {
constructor: cc.Event,
unuse: function() {
this.type = cc.Event.NO_TYPE;
this.target = null;
this.currentTarget = null;
this.eventPhase = cc.Event.NONE;
this._propagationStopped = !1;
this._propagationImmediateStopped = !1;
},
reuse: function(t, e) {
this.type = t;
this.bubbles = e || !1;
},
stopPropagation: function() {
this._propagationStopped = !0;
},
stopPropagationImmediate: function() {
this._propagationImmediateStopped = !0;
},
isStopped: function() {
return this._propagationStopped || this._propagationImmediateStopped;
},
getCurrentTarget: function() {
return this.currentTarget;
},
getType: function() {
return this.type;
}
};
cc.Event.NO_TYPE = "no_type";
cc.Event.TOUCH = "touch";
cc.Event.MOUSE = "mouse";
cc.Event.KEYBOARD = "keyboard";
cc.Event.ACCELERATION = "acceleration";
cc.Event.NONE = 0;
cc.Event.CAPTURING_PHASE = 1;
cc.Event.AT_TARGET = 2;
cc.Event.BUBBLING_PHASE = 3;
var r = function(t, e) {
cc.Event.call(this, t, e);
this.detail = null;
};
n.extend(r, cc.Event);
r.prototype.reset = r;
r.prototype.setUserData = function(t) {
this.detail = t;
};
r.prototype.getUserData = function() {
return this.detail;
};
r.prototype.getEventName = cc.Event.prototype.getType;
var s = new n.Pool(10);
r.put = function(t) {
s.put(t);
};
r.get = function(t, e) {
var i = s._get();
i ? i.reset(t, e) : i = new r(t, e);
return i;
};
cc.Event.EventCustom = r;
e.exports = cc.Event;
}), {
"../platform/js": 180
} ],
104: [ (function(t, e, i) {
t("./event");
t("./event-listeners");
t("./event-target");
t("./system-event");
}), {
"./event": 103,
"./event-listeners": 101,
"./event-target": 102,
"./system-event": 105
} ],
105: [ (function(t, e, i) {
var n = t("../event/event-target"), r = t("../event-manager"), s = t("../platform/CCInputManager"), o = cc.Enum({
KEY_DOWN: "keydown",
KEY_UP: "keyup",
DEVICEMOTION: "devicemotion"
}), a = null, c = null, h = cc.Class({
name: "SystemEvent",
extends: n,
statics: {
EventType: o
},
setAccelerometerEnabled: function(t) {
0;
s.setAccelerometerEnabled(t);
},
setAccelerometerInterval: function(t) {
0;
s.setAccelerometerInterval(t);
},
on: function(t, e, i) {
0;
this._super(t, e, i);
if (t === o.KEY_DOWN || t === o.KEY_UP) {
a || (a = cc.EventListener.create({
event: cc.EventListener.KEYBOARD,
onKeyPressed: function(t, e) {
e.type = o.KEY_DOWN;
cc.systemEvent.dispatchEvent(e);
},
onKeyReleased: function(t, e) {
e.type = o.KEY_UP;
cc.systemEvent.dispatchEvent(e);
}
}));
r.hasEventListener(cc.EventListener.ListenerID.KEYBOARD) || r.addListener(a, 1);
}
if (t === o.DEVICEMOTION) {
c || (c = cc.EventListener.create({
event: cc.EventListener.ACCELERATION,
callback: function(t, e) {
e.type = o.DEVICEMOTION;
cc.systemEvent.dispatchEvent(e);
}
}));
r.hasEventListener(cc.EventListener.ListenerID.ACCELERATION) || r.addListener(c, 1);
}
},
off: function(t, e, i) {
0;
this._super(t, e, i);
if (a && (t === o.KEY_DOWN || t === o.KEY_UP)) {
var n = this.hasEventListener(o.KEY_DOWN), s = this.hasEventListener(o.KEY_UP);
n || s || r.removeListener(a);
}
c && t === o.DEVICEMOTION && r.removeListener(c);
}
});
cc.SystemEvent = e.exports = h;
cc.systemEvent = new cc.SystemEvent();
}), {
"../event-manager": 100,
"../event/event-target": 102,
"../platform/CCInputManager": 164
} ],
106: [ (function(t, e, i) {
var n = t("../components/CCRenderComponent"), r = t("../renderer/render-engine").SpriteMaterial, s = t("./types"), o = s.LineCap, a = s.LineJoin, c = cc.Class({
name: "cc.Graphics",
extends: n,
editor: !1,
ctor: function() {
this._impl = c._assembler.createImpl(this);
},
properties: {
_lineWidth: 1,
_strokeColor: cc.Color.BLACK,
_lineJoin: a.MITER,
_lineCap: o.BUTT,
_fillColor: cc.Color.WHITE,
_miterLimit: 10,
lineWidth: {
get: function() {
return this._lineWidth;
},
set: function(t) {
this._lineWidth = t;
this._impl.lineWidth = t;
}
},
lineJoin: {
get: function() {
return this._lineJoin;
},
set: function(t) {
this._lineJoin = t;
this._impl.lineJoin = t;
},
type: a
},
lineCap: {
get: function() {
return this._lineCap;
},
set: function(t) {
this._lineCap = t;
this._impl.lineCap = t;
},
type: o
},
strokeColor: {
get: function() {
return this._strokeColor;
},
set: function(t) {
this._impl.strokeColor = this._strokeColor = cc.color(t);
}
},
fillColor: {
get: function() {
return this._fillColor;
},
set: function(t) {
this._impl.fillColor = this._fillColor = cc.color(t);
}
},
miterLimit: {
get: function() {
return this._miterLimit;
},
set: function(t) {
this._miterLimit = t;
this._impl.miterLimit = t;
}
}
},
statics: {
LineJoin: a,
LineCap: o
},
onRestore: function() {
this._impl || (this._impl = c._assembler.createImpl());
},
onEnable: function() {
this._super();
this._activateMaterial();
},
onDestroy: function() {
this._super();
this._impl.clear(this, !0);
this._impl = null;
},
_activateMaterial: function() {
if (cc.game.renderType !== cc.game.RENDER_TYPE_CANVAS) {
this.node._renderFlag &= ~cc.RenderFlow.FLAG_RENDER;
this.node._renderFlag |= cc.RenderFlow.FLAG_CUSTOM_IA_RENDER;
if (!this._material) {
var t = new r();
t.useColor = !1;
t.useTexture = !1;
t.useModel = !0;
this._updateMaterial(t);
}
}
},
moveTo: function(t, e) {
0;
this._impl.moveTo(t, e);
},
lineTo: function(t, e) {
0;
this._impl.lineTo(t, e);
},
bezierCurveTo: function(t, e, i, n, r, s) {
this._impl.bezierCurveTo(t, e, i, n, r, s);
},
quadraticCurveTo: function(t, e, i, n) {
this._impl.quadraticCurveTo(t, e, i, n);
},
arc: function(t, e, i, n, r, s) {
this._impl.arc(t, e, i, n, r, s);
},
ellipse: function(t, e, i, n) {
this._impl.ellipse(t, e, i, n);
},
circle: function(t, e, i) {
this._impl.circle(t, e, i);
},
rect: function(t, e, i, n) {
this._impl.rect(t, e, i, n);
},
roundRect: function(t, e, i, n, r) {
this._impl.roundRect(t, e, i, n, r);
},
fillRect: function(t, e, i, n) {
this.rect(t, e, i, n);
this.fill();
},
clear: function(t) {
this._impl.clear(this, t);
},
close: function() {
this._impl.close();
},
stroke: function() {
c._assembler.stroke(this);
},
fill: function() {
c._assembler.fill(this);
}
});
cc.Graphics = e.exports = c;
}), {
"../components/CCRenderComponent": 77,
"../renderer/render-engine": 202,
"./types": 109
} ],
107: [ (function(t, e, i) {
var n = t("./types").PointFlags, r = Math.PI, s = Math.min, o = Math.max, a = Math.cos, c = Math.sin, h = Math.abs, l = Math.sign, u = .5522847493;
e.exports = {
arc: function(t, e, i, n, l, u, _) {
var f, d, m, p = 0, v = 0, y = 0, g = 0, x = 0, C = 0, A = 0, b = 0, S = 0, T = 0, w = 0, E = 0, B = 0;
v = u - l;
if (_ = _ || !1) if (h(v) >= 2 * r) v = 2 * r; else for (;v < 0; ) v += 2 * r; else if (h(v) >= 2 * r) v = 2 * -r; else for (;v > 0; ) v -= 2 * r;
m = 0 | o(1, s(h(v) / (.5 * r) + .5, 5));
y = h(4 / 3 * (1 - a(f = v / m / 2)) / c(f));
_ || (y = -y);
for (d = 0; d <= m; d++) {
g = a(p = l + v * (d / m));
x = c(p);
C = e + g * n;
A = i + x * n;
b = -x * n * y;
S = g * n * y;
0 === d ? t.moveTo(C, A) : t.bezierCurveTo(T + E, w + B, C - b, A - S, C, A);
T = C;
w = A;
E = b;
B = S;
}
},
ellipse: function(t, e, i, n, r) {
t.moveTo(e - n, i);
t.bezierCurveTo(e - n, i + r * u, e - n * u, i + r, e, i + r);
t.bezierCurveTo(e + n * u, i + r, e + n, i + r * u, e + n, i);
t.bezierCurveTo(e + n, i - r * u, e + n * u, i - r, e, i - r);
t.bezierCurveTo(e - n * u, i - r, e - n, i - r * u, e - n, i);
t.close();
},
roundRect: function(t, e, i, n, r, o) {
if (o < .1) t.rect(e, i, n, r); else {
var a = s(o, .5 * h(n)) * l(n), c = s(o, .5 * h(r)) * l(r);
t.moveTo(e, i + c);
t.lineTo(e, i + r - c);
t.bezierCurveTo(e, i + r - c * (1 - u), e + a * (1 - u), i + r, e + a, i + r);
t.lineTo(e + n - a, i + r);
t.bezierCurveTo(e + n - a * (1 - u), i + r, e + n, i + r - c * (1 - u), e + n, i + r - c);
t.lineTo(e + n, i + c);
t.bezierCurveTo(e + n, i + c * (1 - u), e + n - a * (1 - u), i, e + n - a, i);
t.lineTo(e + a, i);
t.bezierCurveTo(e + a * (1 - u), i, e, i + c * (1 - u), e, i + c);
t.close();
}
},
tesselateBezier: function t(e, i, r, s, o, a, c, l, u, _, f) {
var d, m, p, v, y, g, x, C, A, b, S, T, w, E, B, M;
if (!(_ > 10)) {
y = .5 * (a + l);
g = .5 * (c + u);
x = .5 * ((d = .5 * (i + s)) + (p = .5 * (s + a)));
C = .5 * ((m = .5 * (r + o)) + (v = .5 * (o + c)));
if (((B = h((s - l) * (E = u - r) - (o - u) * (w = l - i))) + (M = h((a - l) * E - (c - u) * w))) * (B + M) < e._tessTol * (w * w + E * E)) e._addPoint(l, u, 0 === f ? f | n.PT_BEVEL : f); else {
t(e, i, r, d, m, x, C, S = .5 * (x + (A = .5 * (p + y))), T = .5 * (C + (b = .5 * (v + g))), _ + 1, 0);
t(e, S, T, A, b, y, g, l, u, _ + 1, f);
}
}
}
};
}), {
"./types": 109
} ],
108: [ (function(t, e, i) {
"use strict";
t("./graphics");
}), {
"./graphics": 106
} ],
109: [ (function(t, e, i) {
"use strict";
var n = cc.Enum({
BUTT: 0,
ROUND: 1,
SQUARE: 2
}), r = cc.Enum({
BEVEL: 0,
ROUND: 1,
MITER: 2
}), s = cc.Enum({
PT_CORNER: 1,
PT_LEFT: 2,
PT_BEVEL: 4,
PT_INNERBEVEL: 8
});
e.exports = {
LineCap: n,
LineJoin: r,
PointFlags: s
};
}), {} ],
110: [ (function(t, e, i) {
t("./platform");
t("./assets");
t("./CCNode");
t("./CCPrivateNode");
t("./CCScene");
t("./components");
t("./graphics");
t("./collider");
t("./collider/CCIntersection");
t("./physics");
t("./camera/CCCamera");
t("./utils/polyfill-3d");
t("./base-ui/CCWidgetManager");
}), {
"./CCNode": 29,
"./CCPrivateNode": 30,
"./CCScene": 31,
"./assets": 50,
"./base-ui/CCWidgetManager": 51,
"./camera/CCCamera": 52,
"./collider": 60,
"./collider/CCIntersection": 58,
"./components": 94,
"./graphics": 108,
"./physics": 143,
"./platform": 177,
"./utils/polyfill-3d": 244
} ],
111: [ (function(i, n, r) {
var s = i("../platform/js"), o = i("./pipeline"), a = i("./loading-items"), c = i("./asset-loader"), h = i("./downloader"), l = i("./loader"), u = i("./asset-table"), _ = i("../platform/utils").callInNextTick, f = i("./auto-release-utils"), d = new u();
var m = {
url: null,
raw: !1
};
function p(i) {
var n, r, s;
if ("object" === ("object" === (e = typeof i) ? t(i) : e)) {
r = i;
if (i.url) return r;
n = i.uuid;
} else {
r = {};
n = i;
}
s = r.type ? "uuid" === r.type : cc.AssetLibrary._uuidInSettings(n);
cc.AssetLibrary._getAssetInfoInRuntime(n, m);
r.url = s ? m.url : n;
if (m.url && "uuid" === r.type && m.raw) {
r.type = null;
r.isRawAsset = !0;
} else s || (r.isRawAsset = !0);
return r;
}
var v = [], y = [];
function g() {
var t = new c(), e = new h(), i = new l();
o.call(this, [ t, e, i ]);
this.assetLoader = t;
this.md5Pipe = null;
this.downloader = e;
this.loader = i;
this.onProgress = null;
this._autoReleaseSetting = s.createMap(!0);
0;
}
s.extend(g, o);
var x = g.prototype;
x.init = function(t) {};
x.getXMLHttpRequest = function() {
return window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP");
};
x.addDownloadHandlers = function(t) {
this.downloader.addHandlers(t);
};
x.addLoadHandlers = function(t) {
this.loader.addHandlers(t);
};
x.load = function(t, e, i) {
0;
if (void 0 === i) {
i = e;
e = this.onProgress || null;
}
var n, r = this, s = !1;
if (!(t instanceof Array)) if (t) {
s = !0;
t = [ t ];
} else t = [];
v.length = 0;
for (var o = 0; o < t.length; ++o) {
var c = t[o];
if (c && c.id) {
cc.warnID(4920, c.id);
c.uuid || c.url || (c.url = c.id);
}
if ((n = p(c)).url || n.uuid) {
var h = this._cache[n.url];
v.push(h || n);
}
}
var l = a.create(this, e, (function(t, e) {
_((function() {
if (i) {
if (s) {
var o = n.url;
i.call(r, t, e.getContent(o));
} else i.call(r, t, e);
i = null;
}
e.destroy();
}));
}));
a.initQueueDeps(l);
l.append(v);
v.length = 0;
};
x.flowInDeps = function(t, e, i) {
y.length = 0;
for (var n = 0; n < e.length; ++n) {
var r = p(e[n]);
if (r.url || r.uuid) {
var s = this._cache[r.url];
s ? y.push(s) : y.push(r);
}
}
var o = a.create(this, t ? function(t, e, i) {
this._ownerQueue && this._ownerQueue.onProgress && this._ownerQueue._childOnProgress(i);
} : null, (function(e, n) {
i(e, n);
t && t.deps && (t.deps.length = 0);
n.destroy();
}));
if (t) {
var c = a.getQueue(t);
o._ownerQueue = c._ownerQueue || c;
}
var h = o.append(y, t);
y.length = 0;
return h;
};
x._resources = d;
x._getResUuid = function(t, e, i) {
if (!t) return null;
var n = t.indexOf("?");
-1 !== n && (t = t.substr(0, n));
var r = d.getUuid(t, e);
if (!r) {
var s = cc.path.extname(t);
if (s) {
t = t.slice(0, -s.length);
(r = d.getUuid(t, e)) && !i && cc.warnID(4901, t, s);
}
}
return r;
};
x._getReferenceKey = function(i) {
var n;
"object" === ("object" === (e = typeof i) ? t(i) : e) ? n = i._uuid || null : "string" === ("object" === (e = typeof i) ? t(i) : e) && (n = this._getResUuid(i, null, !0) || i);
if (!n) {
cc.warnID(4800, i);
return n;
}
cc.AssetLibrary._getAssetInfoInRuntime(n, m);
return this._cache[m.url] ? m.url : n;
};
x._urlNotFound = function(t, e, i) {
_((function() {
t = cc.url.normalize(t);
var n = (e ? s.getClassName(e) : "Asset") + ' in "resources/' + t + '" does not exist.';
i && i(new Error(n), []);
}));
};
x._parseLoadResArgs = function(t, e, i) {
if (void 0 === i) {
var n = t instanceof Array || s.isChildClassOf(t, cc.RawAsset);
if (e) {
i = e;
n && (e = this.onProgress || null);
} else if (void 0 === e && !n) {
i = t;
e = this.onProgress || null;
t = null;
}
if (void 0 !== e && !n) {
e = t;
t = null;
}
}
return {
type: t,
onProgress: e,
onComplete: i
};
};
x.loadRes = function(t, e, i, n) {
var r = this._parseLoadResArgs(e, i, n);
e = r.type;
i = r.onProgress;
n = r.onComplete;
var s = this, o = s._getResUuid(t, e);
o ? this.load({
type: "uuid",
uuid: o
}, i, (function(t, e) {
e && s.setAutoReleaseRecursively(o, !1);
n && n(t, e);
})) : s._urlNotFound(t, e, n);
};
x._loadResUuids = function(t, e, i, n) {
if (t.length > 0) {
var r = this, s = t.map((function(t) {
return {
type: "uuid",
uuid: t
};
}));
this.load(s, e, (function(t, e) {
if (i) {
for (var o = [], a = n && [], c = 0; c < s.length; ++c) {
var h = s[c].uuid, l = this._getReferenceKey(h), u = e.getContent(l);
if (u) {
r.setAutoReleaseRecursively(h, !1);
o.push(u);
a && a.push(n[c]);
}
}
n ? i(t, o, a) : i(t, o);
}
}));
} else i && _((function() {
n ? i(null, [], []) : i(null, []);
}));
};
x.loadResArray = function(t, e, i, n) {
var r = this._parseLoadResArgs(e, i, n);
e = r.type;
i = r.onProgress;
n = r.onComplete;
for (var s = [], o = e instanceof Array, a = 0; a < t.length; a++) {
var c = t[a], h = o ? e[a] : e, l = this._getResUuid(c, h);
if (!l) {
this._urlNotFound(c, h, n);
return;
}
s.push(l);
}
this._loadResUuids(s, i, n);
};
x.loadResDir = function(t, e, i, n) {
var r = this._parseLoadResArgs(e, i, n);
e = r.type;
i = r.onProgress;
n = r.onComplete;
var s = [], o = d.getUuidArray(t, e, s);
this._loadResUuids(o, i, (function(t, e, i) {
for (var r = e.length, s = 0; s < r; ++s) if (e[s] instanceof cc.SpriteAtlas) {
var o = e[s].getSpriteFrames();
for (var a in o) {
var c = o[a];
e.push(c);
i && i.push(i[s] + "/" + c.name);
}
}
n && n(t, e, i);
}), s);
};
x.getRes = function(t, e) {
var i = this._cache[t];
if (!i) {
var n = this._getResUuid(t, e, !0);
if (!n) return null;
var r = this._getReferenceKey(n);
i = this._cache[r];
}
i && i.alias && (i = i.alias);
return i && i.complete ? i.content : null;
};
x.getResCount = function() {
return Object.keys(this._cache).length;
};
x.getDependsRecursively = function(t) {
if (t) {
var e = this._getReferenceKey(t), i = f.getDependsRecursively(e);
i.push(e);
return i;
}
return [];
};
x.release = function(t) {
if (Array.isArray(t)) for (var e = 0; e < t.length; e++) {
var i = t[e];
this.release(i);
} else if (t) {
var n = this._getReferenceKey(t), r = this.getItem(n);
if (r) {
this.removeItem(n);
if ((t = r.content) instanceof cc.Asset) {
var s = t.nativeUrl;
s && this.release(s);
t.destroy();
}
0;
}
}
};
x.releaseAsset = function(t) {
var e = t._uuid;
e && this.release(e);
};
x.releaseRes = function(t, e) {
var i = this._getResUuid(t, e);
i ? this.release(i) : cc.errorID(4914, t);
};
x.releaseResDir = function(t, e) {
for (var i = d.getUuidArray(t, e), n = 0; n < i.length; n++) {
var r = i[n];
this.release(r);
}
};
x.releaseAll = function() {
for (var t in this._cache) this.release(t);
};
x.removeItem = function(t) {
var e = o.prototype.removeItem.call(this, t);
delete this._autoReleaseSetting[t];
return e;
};
x.setAutoRelease = function(t, e) {
var i = this._getReferenceKey(t);
i && (this._autoReleaseSetting[i] = !!e);
};
x.setAutoReleaseRecursively = function(t, e) {
e = !!e;
var i = this._getReferenceKey(t);
if (i) {
this._autoReleaseSetting[i] = e;
for (var n = f.getDependsRecursively(i), r = 0; r < n.length; r++) {
var s = n[r];
this._autoReleaseSetting[s] = e;
}
} else 0;
};
x.isAutoRelease = function(t) {
var e = this._getReferenceKey(t);
return !!e && !!this._autoReleaseSetting[e];
};
cc.loader = new g();
0;
n.exports = cc.loader;
}), {
"../platform/js": 180,
"../platform/utils": 184,
"./asset-loader": 112,
"./asset-table": 113,
"./auto-release-utils": 115,
"./downloader": 117,
"./loader": 120,
"./loading-items": 121,
"./pipeline": 124,
"./released-asset-checker": 125
} ],
112: [ (function(t, e, i) {
t("../utils/CCPath");
var n = t("../CCDebug"), r = t("./pipeline"), s = t("./loading-items"), o = "AssetLoader", a = function(t) {
this.id = o;
this.async = !0;
this.pipeline = null;
};
a.ID = o;
var c = [];
a.prototype.handle = function(t, e) {
var i = t.uuid;
if (!i) return t.content || null;
cc.AssetLibrary.queryAssetInfo(i, (function(r, o, a) {
if (r) e(r); else {
t.url = t.rawUrl = o;
t.isRawAsset = a;
if (a) {
var h = cc.path.extname(o).toLowerCase();
if (!h) {
e(new Error(n.getError(4931, i, o)));
return;
}
h = h.substr(1);
var l = s.getQueue(t);
c[0] = {
queueId: t.queueId,
id: o,
url: o,
type: h,
error: null,
alias: t,
complete: !0
};
0;
l.append(c);
t.type = h;
e(null, t.content);
} else {
t.type = "uuid";
e(null, t.content);
}
}
}));
};
r.AssetLoader = e.exports = a;
}), {
"../CCDebug": 26,
"../utils/CCPath": 233,
"./loading-items": 121,
"./pipeline": 124
} ],
113: [ (function(t, e, i) {
var n = t("../utils/misc").pushToMap, r = t("../platform/js");
function s() {
this._pathToUuid = r.createMap(!0);
}
function o(t, e) {
if (t.length > e.length) {
var i = t.charCodeAt(e.length);
return 46 === i || 47 === i;
}
return !0;
}
var a = s.prototype;
a.getUuid = function(t, e) {
t = cc.url.normalize(t);
var i = this._pathToUuid[t];
if (i) if (Array.isArray(i)) {
if (!e) return i[0].uuid;
for (var n = 0; n < i.length; n++) {
var s = i[n];
if (r.isChildClassOf(s.type, e)) return s.uuid;
}
} else {
if (!e || r.isChildClassOf(i.type, e)) return i.uuid;
0;
}
return "";
};
a.getUuidArray = function(t, e, i) {
"/" === (t = cc.url.normalize(t))[t.length - 1] && (t = t.slice(0, -1));
var n = this._pathToUuid, s = [], a = r.isChildClassOf;
for (var c in n) if (c.startsWith(t) && o(c, t) || !t) {
var h = n[c];
if (Array.isArray(h)) for (var l = 0; l < h.length; l++) {
var u = h[l];
if (!e || a(u.type, e)) {
s.push(u.uuid);
i && i.push(c);
} else 0;
} else if (!e || a(h.type, e)) {
s.push(h.uuid);
i && i.push(c);
} else 0;
}
0;
return s;
};
a.add = function(t, e, i, r) {
t = t.substring(0, t.length - cc.path.extname(t).length);
var s = new function(t, e) {
this.uuid = t;
this.type = e;
}(e, i);
n(this._pathToUuid, t, s, r);
};
a._getInfo_DEBUG = !1;
a.reset = function() {
this._pathToUuid = r.createMap(!0);
};
e.exports = s;
}), {
"../platform/js": 180,
"../utils/misc": 242
} ],
114: [ (function(t, e, i) {
var n = t("../platform/CCSys"), r = t("../CCDebug"), s = n.__audioSupport, o = s.format, a = s.context;
function c(t, e) {
var i = document.createElement("audio");
i.src = t.url;
if (cc.sys.platform === cc.sys.BAIDU_GAME) e(null, i); else {
var n = function() {
clearTimeout(r);
i.removeEventListener("canplaythrough", o, !1);
i.removeEventListener("error", a, !1);
s.USE_LOADER_EVENT && i.removeEventListener(s.USE_LOADER_EVENT, o, !1);
}, r = setTimeout((function() {
0 === i.readyState ? a() : o();
}), 8e3), o = function() {
n();
e(null, i);
}, a = function() {
n();
var i = "load audio failure - " + t.url;
cc.log(i);
e(i);
};
i.addEventListener("canplaythrough", o, !1);
i.addEventListener("error", a, !1);
s.USE_LOADER_EVENT && i.addEventListener(s.USE_LOADER_EVENT, o, !1);
}
}
function h(t, e) {
a || e(new Error(r.getError(4926)));
var i = cc.loader.getXMLHttpRequest();
i.open("GET", t.url, !0);
i.responseType = "arraybuffer";
i.onload = function() {
a.decodeAudioData(i.response, (function(t) {
e(null, t);
}), (function() {
e("decode error - " + t.id, null);
}));
};
i.onerror = function() {
e("request error - " + t.id, null);
};
i.send();
}
e.exports = function(t, e) {
if (0 === o.length) return new Error(r.getError(4927));
var i;
i = s.WEB_AUDIO ? t._owner instanceof cc.AudioClip ? t._owner.loadMode === cc.AudioClip.LoadMode.WEB_AUDIO ? h : c : t.urlParam && t.urlParam.useDom ? c : h : c;
i(t, e);
};
}), {
"../CCDebug": 26,
"../platform/CCSys": 169
} ],
115: [ (function(i, n, r) {
var s = i("../platform/js");
function o(t, e) {
var i = cc.loader.getItem(t);
if (i) {
var n = i.dependKeys;
if (n) for (var r = 0; r < n.length; r++) {
var s = n[r];
if (!e[s]) {
e[s] = !0;
o(s, e);
}
}
}
}
function a(t, e) {
if (t._uuid) {
var i = cc.loader._getReferenceKey(t);
if (!e[i]) {
e[i] = !0;
o(i, e);
}
}
}
function c(i, n) {
for (var r = Object.getOwnPropertyNames(i), s = 0; s < r.length; s++) {
var o = i[r[s]];
if ("object" === ("object" === (e = typeof o) ? t(o) : e) && o) if (Array.isArray(o)) for (var c = 0; c < o.length; c++) {
var h = o[c];
h instanceof cc.RawAsset && a(h, n);
} else if (o.constructor && o.constructor !== Object) o instanceof cc.RawAsset && a(o, n); else for (var l = Object.getOwnPropertyNames(o), u = 0; u < l.length; u++) {
var _ = o[l[u]];
_ instanceof cc.RawAsset && a(_, n);
}
}
}
function h(t, e) {
for (var i = 0; i < t._components.length; i++) c(t._components[i], e);
for (var n = 0; n < t._children.length; n++) h(t._children[n], e);
}
n.exports = {
autoRelease: function(t, e, i) {
var n = cc.loader._autoReleaseSetting, r = s.createMap();
if (e) for (var o = 0; o < e.length; o++) r[e[o]] = !0;
for (var a = 0; a < i.length; a++) h(i[a], r);
if (t) for (var c = 0; c < t.length; c++) {
var l = t[c];
!1 === n[l] || r[l] || cc.loader.release(l);
}
for (var u = Object.keys(n), _ = 0; _ < u.length; _++) {
var f = u[_];
!0 !== n[f] || r[f] || cc.loader.release(f);
}
},
getDependsRecursively: function(t) {
var e = {};
o(t, e);
return Object.keys(e);
}
};
}), {
"../platform/js": 180
} ],
116: [ (function(t, e, i) {
e.exports = function(t, e) {
var i = t.url, n = cc.loader.getXMLHttpRequest(), r = "Load binary data failed: " + i;
n.open("GET", i, !0);
n.responseType = "arraybuffer";
n.onload = function() {
var t = n.response;
if (t) {
var i = new Uint8Array(t);
e(null, i);
} else e({
status: n.status,
errorMessage: r + "(no response)"
});
};
n.onerror = function() {
e({
status: n.status,
errorMessage: r + "(error)"
});
};
n.ontimeout = function() {
e({
status: n.status,
errorMessage: r + "(time out)"
});
};
n.send(null);
};
}), {} ],
117: [ (function(t, e, i) {
var n = t("../platform/js"), r = t("../CCDebug");
t("../utils/CCPath");
var s, o = t("./pipeline"), a = t("./pack-downloader"), c = t("./binary-downloader"), h = t("./text-downloader"), l = t("./utils").urlAppendTimestamp;
function u() {
return null;
}
function _(t, e, i) {
var n = t.url, s = document, o = document.createElement("script");
"file:" !== window.location.protocol && (o.crossOrigin = "anonymous");
o.async = i;
o.src = l(n);
function a() {
o.parentNode.removeChild(o);
o.removeEventListener("load", a, !1);
o.removeEventListener("error", c, !1);
e(null, n);
}
function c() {
o.parentNode.removeChild(o);
o.removeEventListener("load", a, !1);
o.removeEventListener("error", c, !1);
e(new Error(r.getError(4928, n)));
}
o.addEventListener("load", a, !1);
o.addEventListener("error", c, !1);
s.body.appendChild(o);
}
function f(t, e, i, n) {
void 0 === i && (i = !0);
var s = l(t.url);
n = n || new Image();
i && "file:" !== window.location.protocol ? n.crossOrigin = "anonymous" : n.crossOrigin = null;
if (n.complete && n.naturalWidth > 0 && n.src === s) return n;
(function() {
function i() {
n.removeEventListener("load", i);
n.removeEventListener("error", o);
n.id = t.id;
e(null, n);
}
function o() {
n.removeEventListener("load", i);
n.removeEventListener("error", o);
"https:" !== window.location.protocol && n.crossOrigin && "anonymous" === n.crossOrigin.toLowerCase() ? f(t, e, !1, n) : e(new Error(r.getError(4930, s)));
}
n.addEventListener("load", i);
n.addEventListener("error", o);
n.src = s;
})();
}
var d = {
js: _,
png: f,
jpg: f,
bmp: f,
jpeg: f,
gif: f,
ico: f,
tiff: f,
webp: function(t, e, i, n) {
return cc.sys.capabilities.webp ? f(t, e, i, n) : new Error(r.getError(4929, t.url));
},
image: f,
mp3: s = t("./audio-downloader"),
ogg: s,
wav: s,
m4a: s,
txt: h,
xml: h,
vsh: h,
fsh: h,
atlas: h,
tmx: h,
tsx: h,
json: h,
ExportJson: h,
plist: h,
fnt: h,
font: u,
eot: u,
ttf: u,
woff: u,
svg: u,
ttc: u,
uuid: function(t, e) {
var i = a.load(t, e);
return void 0 === i ? this.extMap.json(t, e) : i || void 0;
},
binary: c,
dbbin: c,
default: h
}, m = "Downloader", p = function(t) {
this.id = m;
this.async = !0;
this.pipeline = null;
this._curConcurrent = 0;
this._loadQueue = [];
this._subpackages = {};
this.extMap = n.mixin(t, d);
};
p.ID = m;
p.PackDownloader = a;
p.prototype.addHandlers = function(t) {
n.mixin(this.extMap, t);
};
p.prototype._handleLoadQueue = function() {
for (;this._curConcurrent < cc.macro.DOWNLOAD_MAX_CONCURRENT; ) {
var t = this._loadQueue.shift();
if (!t) break;
var e = this.handle(t.item, t.callback);
void 0 !== e && (e instanceof Error ? t.callback(e) : t.callback(null, e));
}
};
p.prototype.handle = function(t, e) {
var i = this, n = this.extMap[t.type] || this.extMap.default, r = void 0;
if (this._curConcurrent < cc.macro.DOWNLOAD_MAX_CONCURRENT) {
this._curConcurrent++;
if (void 0 !== (r = n.call(this, t, (function(t, n) {
i._curConcurrent = Math.max(0, i._curConcurrent - 1);
i._handleLoadQueue();
e && e(t, n);
})))) {
this._curConcurrent = Math.max(0, this._curConcurrent - 1);
this._handleLoadQueue();
return r;
}
} else if (t.ignoreMaxConcurrency) {
if (void 0 !== (r = n.call(this, t, e))) return r;
} else this._loadQueue.push({
item: t,
callback: e
});
};
p.prototype.loadSubpackage = function(t, e) {
var i = this._subpackages[t];
i ? i.loaded ? e && e() : _({
url: i.path + "index.js"
}, (function(t) {
t || (i.loaded = !0);
e && e(t);
})) : e && e(new Error("Can't find subpackage " + t));
};
o.Downloader = e.exports = p;
}), {
"../CCDebug": 26,
"../platform/js": 180,
"../utils/CCPath": 233,
"./audio-downloader": 114,
"./binary-downloader": 116,
"./pack-downloader": 123,
"./pipeline": 124,
"./text-downloader": 127,
"./utils": 129
} ],
118: [ (function(t, e, i) {
var n = t("../utils/text-utils"), r = null, s = "BES bswy:->@123丁ぁᄁ", o = {}, a = -1, c = [], h = 6e4, l = (function() {
var t = void 0;
return function() {
if (void 0 === t) if (window.FontFace) {
var e = /Gecko.*Firefox\/(\d+)/.exec(window.navigator.userAgent), 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 u() {
for (var t = !0, e = Date.now(), i = c.length - 1; i >= 0; i--) {
var o = c[i], l = o.fontFamilyName;
if (e - o.startTime > h) {
cc.warnID(4933, l);
o.callback(null, l);
c.splice(i, 1);
} else {
var u = o.refWidth;
r.font = "40px " + l;
if (u !== n.safeMeasureText(r, s)) {
c.splice(i, 1);
o.callback(null, l);
} else t = !1;
}
}
if (t) {
clearInterval(a);
a = -1;
}
}
var _ = {
loadFont: function(t, e) {
var i = t.url, f = _._getFontFamily(i);
if (o[f]) return f;
if (!r) {
var d = document.createElement("canvas");
d.width = 100;
d.height = 100;
r = d.getContext("2d");
}
var m = "40px " + f;
r.font = m;
var p = n.safeMeasureText(r, s), v = document.createElement("style");
v.type = "text/css";
var y = "";
isNaN(f - 0) ? y += "@font-face { font-family:" + f + "; src:" : y += "@font-face { font-family:'" + f + "'; src:";
y += "url('" + i + "');";
v.textContent = y + "}";
document.body.appendChild(v);
var g = document.createElement("div"), x = g.style;
x.fontFamily = f;
g.innerHTML = ".";
x.position = "absolute";
x.left = "-100px";
x.top = "-100px";
document.body.appendChild(g);
if (l()) (function(t, e, i) {
var n = new Promise(function(i, n) {
var r = function() {
Date.now() - t >= h ? n() : document.fonts.load("40px " + e).then((function(t) {
t.length >= 1 ? i() : setTimeout(r, 100);
}), (function() {
n();
}));
};
r();
}), r = null, s = new Promise(function(t, e) {
r = setTimeout(e, h);
});
Promise.race([ s, n ]).then((function() {
if (r) {
clearTimeout(r);
r = null;
}
i(null, e);
}), (function() {
cc.warnID(4933, e);
i(null, e);
}));
})(Date.now(), f, e); else {
var C = {
fontFamilyName: f,
refWidth: p,
callback: e,
startTime: Date.now()
};
c.push(C);
-1 === a && (a = setInterval(u, 100));
}
o[f] = v;
},
_getFontFamily: function(t) {
var e = t.lastIndexOf(".ttf");
if (-1 === e) return t;
var i, n = t.lastIndexOf("/");
-1 !== (i = -1 === n ? t.substring(0, e) + "_LABEL" : t.substring(n + 1, e) + "_LABEL").indexOf(" ") && (i = '"' + i + '"');
return i;
}
};
e.exports = _;
}), {
"../utils/text-utils": 249
} ],
119: [ (function(t, e, i) {
t("./downloader");
t("./loader");
t("./loading-items");
t("./pipeline");
t("./CCLoader");
}), {
"./CCLoader": 111,
"./downloader": 117,
"./loader": 120,
"./loading-items": 121,
"./pipeline": 124
} ],
120: [ (function(i, n, r) {
var s = i("../platform/js"), o = i("../platform/CCSAXParser").plistParser, a = i("./pipeline"), c = i("../assets/CCTexture2D"), h = i("./uuid-loader"), l = i("./font-loader");
function u(i) {
if ("string" !== ("object" === (e = typeof i.content) ? t(i.content) : e)) return new Error("JSON Loader: Input item doesn't contain string content");
try {
return JSON.parse(i.content);
} catch (t) {
return new Error("JSON Loader: Parse json [" + i.id + "] failed : " + t);
}
}
function _(t) {
if (t._owner instanceof cc.Asset) return null;
var e = t.content;
if (cc.sys.platform !== cc.sys.FB_PLAYABLE_ADS && !(e instanceof Image)) return new Error("Image Loader: Input item doesn't contain Image content");
var i = t.rawUrl, n = t.texture || new c();
n._uuid = t.uuid;
n.url = i;
n._setRawAsset(i, !1);
n._nativeAsset = e;
return n;
}
function f(t, e) {
if (t._owner instanceof cc.Asset) return null;
var i = new cc.AudioClip();
i._setRawAsset(t.rawUrl, !1);
i._nativeAsset = t.content;
return i;
}
function d(t) {
return t.load ? t.load(t.content) : null;
}
var m = {
png: _,
jpg: _,
bmp: _,
jpeg: _,
gif: _,
ico: _,
tiff: _,
webp: _,
image: _,
mp3: f,
ogg: f,
wav: f,
m4a: f,
json: u,
ExportJson: u,
plist: function(i) {
if ("string" !== ("object" == (e = typeof i.content) ? t(i.content) : e)) return new Error("Plist Loader: Input item doesn't contain string content");
var n = o.parse(i.content);
return n || new Error("Plist Loader: Parse [" + i.id + "] failed");
},
uuid: h,
prefab: h,
fire: h,
scene: h,
binary: d,
dbbin: d,
font: l.loadFont,
eot: l.loadFont,
ttf: l.loadFont,
woff: l.loadFont,
svg: l.loadFont,
ttc: l.loadFont,
default: function() {
return null;
}
}, p = function(t) {
this.id = "Loader";
this.async = !0;
this.pipeline = null;
this.extMap = s.mixin(t, m);
};
p.ID = "Loader";
p.prototype.addHandlers = function(t) {
this.extMap = s.mixin(this.extMap, t);
};
p.prototype.handle = function(t, e) {
return (this.extMap[t.type] || this.extMap.default).call(this, t, e);
};
a.Loader = n.exports = p;
}), {
"../assets/CCTexture2D": 49,
"../platform/CCSAXParser": 167,
"../platform/js": 180,
"./font-loader": 118,
"./pipeline": 124,
"./uuid-loader": 130
} ],
121: [ (function(i, n, r) {
var s = i("../platform/callbacks-invoker");
i("../utils/CCPath");
var o = i("../platform/js"), a = 0 | 998 * Math.random(), c = o.createMap(!0), h = [], l = {
WORKING: 1,
COMPLETE: 2,
ERROR: 3
}, u = o.createMap(!0);
function _(i) {
var n = i.url || i;
return "string" === ("object" === (e = typeof n) ? t(n) : e);
}
function f(i, n) {
var r = "object" === ("object" === (e = typeof i) ? t(i) : e) ? i.url : i, s = {
queueId: n,
id: r,
url: r,
rawUrl: void 0,
urlParam: (function(t) {
if (t) {
var e = t.split("?");
if (e && e[0] && e[1]) {
var i = {};
e[1].split("&").forEach((function(t) {
var e = t.split("=");
i[e[0]] = e[1];
}));
return i;
}
}
})(r),
type: "",
error: null,
content: null,
complete: !1,
states: {},
deps: null
};
if ("object" === ("object" === (e = typeof i) ? t(i) : e)) {
o.mixin(s, i);
if (i.skips) for (var a = 0; a < i.skips.length; a++) {
var c = i.skips[a];
s.states[c] = l.COMPLETE;
}
}
s.rawUrl = s.url;
r && !s.type && (s.type = cc.path.extname(r).toLowerCase().substr(1));
return s;
}
var d = [];
function m(t, e, i) {
if (!t || !e) return !1;
var n = !1;
d.push(e.id);
if (e.deps) {
var r, s, o = e.deps;
for (r = 0; r < o.length; r++) {
if ((s = o[r]).id === t.id) {
n = !0;
break;
}
if (!(d.indexOf(s.id) >= 0) && (s.deps && m(t, s, !0))) {
n = !0;
break;
}
}
}
i || (d.length = 0);
return n;
}
var p = function(t, e, i, n) {
s.call(this);
this._id = ++a;
c[this._id] = this;
this._pipeline = t;
this._errorUrls = o.createMap(!0);
this._appending = !1;
this._ownerQueue = null;
this.onProgress = i;
this.onComplete = n;
this.map = o.createMap(!0);
this.completed = {};
this.totalCount = 0;
this.completedCount = 0;
this._pipeline ? this.active = !0 : this.active = !1;
e && (e.length > 0 ? this.append(e) : this.allComplete());
};
p.ItemState = new cc.Enum(l);
p.create = function(i, n, r, s) {
if (void 0 === r) {
if ("function" === ("object" === (e = typeof n) ? t(n) : e)) {
s = n;
n = r = null;
}
} else if (void 0 === s) if ("function" === ("object" === (e = typeof n) ? t(n) : e)) {
s = r;
r = n;
n = null;
} else {
s = r;
r = null;
}
var o = h.pop();
if (o) {
o._pipeline = i;
o.onProgress = r;
o.onComplete = s;
c[o._id] = o;
o._pipeline && (o.active = !0);
n && o.append(n);
} else o = new p(i, n, r, s);
return o;
};
p.getQueue = function(t) {
return t.queueId ? c[t.queueId] : null;
};
p.itemComplete = function(t) {
var e = c[t.queueId];
e && e.itemComplete(t.id);
};
p.initQueueDeps = function(t) {
var e = u[t._id];
if (e) {
e.completed.length = 0;
e.deps.length = 0;
} else e = u[t._id] = {
completed: [],
deps: []
};
};
p.registerQueueDep = function(t, e) {
var i = t.queueId || t;
if (!i) return !1;
var n = u[i];
if (n) -1 === n.deps.indexOf(e) && n.deps.push(e); else if (t.id) for (var r in u) {
var s = u[r];
-1 !== s.deps.indexOf(t.id) && -1 === s.deps.indexOf(e) && s.deps.push(e);
}
};
p.finishDep = function(t) {
for (var e in u) {
var i = u[e];
-1 !== i.deps.indexOf(t) && -1 === i.completed.indexOf(t) && i.completed.push(t);
}
};
var v = p.prototype;
o.mixin(v, s.prototype);
v.append = function(t, e) {
if (!this.active) return [];
e && !e.deps && (e.deps = []);
this._appending = !0;
var i, n, r, s = [];
for (i = 0; i < t.length; ++i) if (!(n = t[i]).queueId || this.map[n.id]) {
if (_(n)) {
var o = (r = f(n, this._id)).id;
if (!this.map[o]) {
this.map[o] = r;
this.totalCount++;
e && e.deps.push(r);
p.registerQueueDep(e || this._id, o);
s.push(r);
}
}
} else {
this.map[n.id] = n;
e && e.deps.push(n);
if (n.complete || m(e, n)) {
this.totalCount++;
this.itemComplete(n.id);
continue;
}
var a = this, h = c[n.queueId];
if (h) {
this.totalCount++;
p.registerQueueDep(e || this._id, n.id);
h.addListener(n.id, (function(t) {
a.itemComplete(t.id);
}));
}
}
this._appending = !1;
this.completedCount === this.totalCount ? this.allComplete() : this._pipeline.flowIn(s);
return s;
};
v._childOnProgress = function(t) {
if (this.onProgress) {
var e = u[this._id];
this.onProgress(e ? e.completed.length : this.completedCount, e ? e.deps.length : this.totalCount, t);
}
};
v.allComplete = function() {
var t = o.isEmptyObject(this._errorUrls) ? null : this._errorUrls;
this.onComplete && this.onComplete(t, this);
};
v.isCompleted = function() {
return this.completedCount >= this.totalCount;
};
v.isItemCompleted = function(t) {
return !!this.completed[t];
};
v.exists = function(t) {
return !!this.map[t];
};
v.getContent = function(t) {
var e = this.map[t], i = null;
e && (e.content ? i = e.content : e.alias && (i = e.alias.content));
return i;
};
v.getError = function(t) {
var e = this.map[t], i = null;
e && (e.error ? i = e.error : e.alias && (i = e.alias.error));
return i;
};
v.addListener = s.prototype.add;
v.hasListener = s.prototype.has;
v.removeListener = s.prototype.remove;
v.removeAllListeners = s.prototype.removeAll;
v.removeItem = function(t) {
var e = this.map[t];
if (e && this.completed[e.alias || t]) {
delete this.completed[t];
delete this.map[t];
if (e.alias) {
delete this.completed[e.alias.id];
delete this.map[e.alias.id];
}
this.completedCount--;
this.totalCount--;
}
};
v.itemComplete = function(t) {
var e = this.map[t];
if (e) {
var i = t in this._errorUrls;
e.error instanceof Error || o.isString(e.error) ? this._errorUrls[t] = e.error : e.error ? o.mixin(this._errorUrls, e.error) : !e.error && i && delete this._errorUrls[t];
this.completed[t] = e;
this.completedCount++;
p.finishDep(e.id);
if (this.onProgress) {
var n = u[this._id];
this.onProgress(n ? n.completed.length : this.completedCount, n ? n.deps.length : this.totalCount, e);
}
this.invoke(t, e);
this.removeAll(t);
!this._appending && this.completedCount >= this.totalCount && this.allComplete();
}
};
v.destroy = function() {
this.active = !1;
this._appending = !1;
this._pipeline = null;
this._ownerQueue = null;
o.clear(this._errorUrls);
this.onProgress = null;
this.onComplete = null;
this.map = o.createMap(!0);
this.completed = {};
this.totalCount = 0;
this.completedCount = 0;
s.call(this);
if (u[this._id]) {
u[this._id].completed.length = 0;
u[this._id].deps.length = 0;
}
delete c[this._id];
delete u[this._id];
-1 === h.indexOf(this) && h.length < 10 && h.push(this);
};
cc.LoadingItems = n.exports = p;
}), {
"../platform/callbacks-invoker": 173,
"../platform/js": 180,
"../utils/CCPath": 233
} ],
122: [ (function(t, e, i) {
var n = t("./pipeline"), r = "MD5Pipe", s = /(\.[^.\n\\/]*)$/, o = /.*[/\\][0-9a-fA-F]{2}[/\\]([0-9a-fA-F-]{8,})/;
var a = function(t, e, i) {
this.id = r;
this.async = !1;
this.pipeline = null;
this.md5AssetsMap = t;
this.md5NativeAssetsMap = e;
this.libraryBase = i;
};
a.ID = r;
a.prototype.handle = function(t) {
var e = !1;
"ttf" === t.type && (e = !0);
t.url = this.transformURL(t.url, e);
return null;
};
a.prototype.transformURL = function(t, e) {
var i = this, n = (function(t) {
var e = t.match(o);
return e ? e[1] : "";
})(t);
if (n) {
var r, a, c, h;
(function() {
r = !t.startsWith(i.libraryBase);
var o = (r ? i.md5NativeAssetsMap : i.md5AssetsMap)[n];
if (o) if (e) {
a = cc.path.dirname(t);
c = cc.path.basename(t);
t = a + "." + o + "/" + c;
} else {
h = !1;
t = t.replace(s, (function(t, e) {
h = !0;
return "." + o + e;
}));
h || (t = t + "." + o);
}
})();
}
return t;
};
n.MD5Pipe = e.exports = a;
}), {
"./pipeline": 124
} ],
123: [ (function(i, n, r) {
var s = i("./unpackers"), o = i("../utils/misc").pushToMap, a = {
Invalid: 0,
Removed: 1,
Downloading: 2,
Loaded: 3
};
function c() {
this.unpacker = null;
this.state = a.Invalid;
}
var h = {}, l = {}, u = {};
function _(t, e) {
return new Error("Can not retrieve " + t + " from packer " + e);
}
n.exports = {
initPacks: function(t) {
l = t;
for (var e in t) for (var i = t[e], n = 0; n < i.length; n++) {
var r = i[n], s = 1 === i.length;
o(h, r, e, s);
}
},
_loadNewPack: function(t, e, i) {
var n = this, r = cc.AssetLibrary.getLibUrlNoExt(e) + ".json";
cc.loader.load({
url: r,
ignoreMaxConcurrency: !0
}, (function(r, s) {
if (r) {
cc.errorID(4916, t);
return i(r);
}
var o = n._doLoadNewPack(t, e, s);
o ? i(null, o) : i(_(t, e));
}));
},
_doPreload: function(t, e) {
var i = u[t];
i || ((i = u[t] = new c()).state = a.Downloading);
if (i.state !== a.Loaded) {
i.unpacker = new s.JsonUnpacker();
i.unpacker.load(l[t], e);
i.state = a.Loaded;
}
},
_doLoadNewPack: function(i, n, r) {
var o = u[n];
if (o.state !== a.Loaded) {
"string" === ("object" === (e = typeof r) ? t(r) : e) && (r = JSON.parse(r));
Array.isArray(r) ? o.unpacker = new s.JsonUnpacker() : r.type === s.TextureUnpacker.ID && (o.unpacker = new s.TextureUnpacker());
o.unpacker.load(l[n], r);
o.state = a.Loaded;
}
return o.unpacker.retrieve(i);
},
_selectLoadedPack: function(t) {
for (var e = a.Invalid, i = "", n = 0; n < t.length; n++) {
var r = t[n], s = u[r];
if (s) {
var o = s.state;
if (o === a.Loaded) return r;
if (o > e) {
e = o;
i = r;
}
}
}
return e !== a.Invalid ? i : t[0];
},
load: function(t, e) {
var i = t.uuid, n = h[i];
if (n) {
Array.isArray(n) && (n = this._selectLoadedPack(n));
var r = u[n];
if (r && r.state === a.Loaded) {
var s = r.unpacker.retrieve(i);
return s || _(i, n);
}
if (!r) {
console.log("Create unpacker %s for %s", n, i);
(r = u[n] = new c()).state = a.Downloading;
}
this._loadNewPack(i, n, e);
return null;
}
}
};
0;
}), {
"../utils/misc": 242,
"./unpackers": 128
} ],
124: [ (function(t, e, i) {
var n = t("../platform/js"), r = t("./loading-items"), s = r.ItemState;
function o(t, e) {
var i = t.id, n = e.states[i], r = t.next, a = t.pipeline;
if (!e.error && n !== s.WORKING && n !== s.ERROR) if (n === s.COMPLETE) r ? o(r, e) : a.flowOut(e); else {
e.states[i] = s.WORKING;
var c = t.handle(e, (function(t, n) {
if (t) {
e.error = t;
e.states[i] = s.ERROR;
a.flowOut(e);
} else {
n && (e.content = n);
e.states[i] = s.COMPLETE;
r ? o(r, e) : a.flowOut(e);
}
}));
if (c instanceof Error) {
e.error = c;
e.states[i] = s.ERROR;
a.flowOut(e);
} else if (void 0 !== c) {
null !== c && (e.content = c);
e.states[i] = s.COMPLETE;
r ? o(r, e) : a.flowOut(e);
}
}
}
var a = function(t) {
this._pipes = t;
this._cache = n.createMap(!0);
for (var e = 0; e < t.length; ++e) {
var i = t[e];
if (i.handle && i.id) {
i.pipeline = this;
i.next = e < t.length - 1 ? t[e + 1] : null;
}
}
};
a.ItemState = s;
var c = a.prototype;
c.insertPipe = function(t, e) {
if (!t.handle || !t.id || e > this._pipes.length) cc.warnID(4921); else if (this._pipes.indexOf(t) > 0) cc.warnID(4922); else {
t.pipeline = this;
var i = null;
e < this._pipes.length && (i = this._pipes[e]);
var n = null;
e > 0 && (n = this._pipes[e - 1]);
n && (n.next = t);
t.next = i;
this._pipes.splice(e, 0, t);
}
};
c.insertPipeAfter = function(t, e) {
var i = this._pipes.indexOf(t);
i < 0 || this.insertPipe(e, i + 1);
};
c.appendPipe = function(t) {
if (t.handle && t.id) {
t.pipeline = this;
t.next = null;
this._pipes.length > 0 && (this._pipes[this._pipes.length - 1].next = t);
this._pipes.push(t);
}
};
c.flowIn = function(t) {
var e, i, n = this._pipes[0];
if (n) {
for (e = 0; e < t.length; e++) {
i = t[e];
this._cache[i.id] = i;
}
for (e = 0; e < t.length; e++) o(n, i = t[e]);
} else for (e = 0; e < t.length; e++) this.flowOut(t[e]);
};
c.flowInDeps = function(t, e, i) {
return r.create(this, (function(t, e) {
i(t, e);
e.destroy();
})).append(e, t);
};
c.flowOut = function(t) {
t.error ? delete this._cache[t.id] : this._cache[t.id] || (this._cache[t.id] = t);
t.complete = !0;
r.itemComplete(t);
};
c.copyItemStates = function(t, e) {
if (e instanceof Array) for (var i = 0; i < e.length; ++i) e[i].states = t.states; else e.states = t.states;
};
c.getItem = function(t) {
var e = this._cache[t];
if (!e) return e;
e.alias && (e = e.alias);
return e;
};
c.removeItem = function(t) {
var e = this._cache[t];
e && e.complete && delete this._cache[t];
return e;
};
c.clear = function() {
for (var t in this._cache) {
var e = this._cache[t];
delete this._cache[t];
if (!e.complete) {
e.error = new Error("Canceled manually");
this.flowOut(e);
}
}
};
cc.Pipeline = e.exports = a;
}), {
"../platform/js": 180,
"./loading-items": 121
} ],
125: [ (function(t, e, i) {}), {
"../platform/js": 180
} ],
126: [ (function(t, e, i) {
var n = t("./pipeline"), r = "SubPackPipe", s = /.*[/\\][0-9a-fA-F]{2}[/\\]([0-9a-fA-F-]{8,})/;
var o = Object.create(null), a = function(t) {
this.id = r;
this.async = !1;
this.pipeline = null;
for (var e in t) {
var i = t[e];
i.uuids && i.uuids.forEach((function(t) {
o[t] = i.path;
}));
}
};
a.ID = r;
a.prototype.handle = function(t) {
t.url = this.transformURL(t.url);
return null;
};
a.prototype.transformURL = function(t) {
var e = (function(t) {
var e = t.match(s);
return e ? e[1] : "";
})(t);
if (e) {
var i = o[e];
if (i) return t.replace("res/raw-assets/", i + "raw-assets/");
}
return t;
};
n.SubPackPipe = e.exports = a;
}), {
"./pipeline": 124
} ],
127: [ (function(t, e, i) {
var n = t("./utils").urlAppendTimestamp;
e.exports = function(t, e) {
var i = t.url;
i = n(i);
var r = cc.loader.getXMLHttpRequest(), s = "Load text file failed: " + i;
r.open("GET", i, !0);
r.overrideMimeType && r.overrideMimeType("text/plain; charset=utf-8");
r.onload = function() {
4 === r.readyState ? 200 === r.status || 0 === r.status ? e(null, r.responseText) : e({
status: r.status,
errorMessage: s + "(wrong status)"
}) : e({
status: r.status,
errorMessage: s + "(wrong readyState)"
});
};
r.onerror = function() {
e({
status: r.status,
errorMessage: s + "(error)"
});
};
r.ontimeout = function() {
e({
status: r.status,
errorMessage: s + "(time out)"
});
};
r.send(null);
};
}), {
"./utils": 129
} ],
128: [ (function(t, e, i) {
var n = t("../assets/CCTexture2D"), r = t("../platform/js");
function s() {
this.jsons = {};
}
s.prototype.load = function(t, e) {
e.length !== t.length && cc.errorID(4915);
for (var i = 0; i < t.length; i++) {
var n = t[i], r = e[i];
this.jsons[n] = r;
}
};
s.prototype.retrieve = function(t) {
return this.jsons[t] || null;
};
function o() {
this.contents = {};
}
o.ID = r._getClassId(n);
o.prototype.load = function(t, e) {
var i = e.data.split("|");
i.length !== t.length && cc.errorID(4915);
for (var n = 0; n < t.length; n++) this.contents[t[n]] = i[n];
};
o.prototype.retrieve = function(t) {
var e = this.contents[t];
return e ? {
__type__: o.ID,
content: e
} : null;
};
0;
e.exports = {
JsonUnpacker: s,
TextureUnpacker: o
};
}), {
"../assets/CCTexture2D": 49,
"../platform/js": 180
} ],
129: [ (function(i, n, r) {
var s = /\?/;
n.exports = {
urlAppendTimestamp: function(i) {
cc.game.config.noCache && "string" === ("object" === (e = typeof i) ? t(i) : e) && (s.test(i) ? i += "&_t=" + (new Date() - 0) : i += "?_t=" + (new Date() - 0));
return i;
}
};
}), {} ],
130: [ (function(i, n, r) {
var s = i("../platform/js"), o = i("../CCDebug");
i("../platform/deserialize");
var a = i("./loading-items");
function c(t) {
return t && (t[0] && "cc.Scene" === t[0].__type__ || t[1] && "cc.Scene" === t[1].__type__ || t[0] && "cc.Prefab" === t[0].__type__);
}
function h(i, n) {
0;
var r, h;
if ("string" === ("object" === (e = typeof i.content) ? t(i.content) : e)) try {
r = JSON.parse(i.content);
} catch (t) {
return new Error(o.getError(4923, i.id, t.stack));
} else {
if ("object" !== ("object" === (e = typeof i.content) ? t(i.content) : e)) return new Error(o.getError(4924));
r = i.content;
}
var l = c(r);
h = l ? cc._MissingScript.safeFindClass : function(t) {
var e = s._getClassById(t);
if (e) return e;
cc.warnID(4903, t);
return Object;
};
var u, _ = cc.deserialize.Details.pool.get();
try {
u = cc.deserialize(r, _, {
classFinder: h,
target: i.existingAsset,
customEnv: i
});
} catch (t) {
cc.deserialize.Details.pool.put(_);
var f = t + "\n" + t.stack;
return new Error(o.getError(4925, i.id, f));
}
u._uuid = i.uuid;
0;
var d = (function(t, e, i, n) {
var r, s, o, a = i.uuidList, c = i.uuidObjList, h = i.uuidPropList, l = i._stillUseUrl, u = t.dependKeys = [];
if (n) {
r = [];
for (s = 0; s < a.length; s++) {
o = a[s];
var _ = c[s], f = h[s], d = cc.AssetLibrary._getAssetInfoInRuntime(o);
if (d.raw) {
var m = d.url;
_[f] = m;
u.push(m);
} else r.push({
type: "uuid",
uuid: o,
deferredLoadRaw: !0,
_owner: _,
_ownerProp: f,
_stillUseUrl: l[s]
});
}
} else {
r = new Array(a.length);
for (s = 0; s < a.length; s++) {
o = a[s];
r[s] = {
type: "uuid",
uuid: o,
_owner: c[s],
_ownerProp: h[s],
_stillUseUrl: l[s]
};
}
e._native && !e.constructor.preventPreloadNativeObject && r.push({
url: e.nativeUrl,
_owner: e,
_ownerProp: "_nativeAsset"
});
}
return r;
})(i, u, _, (function(t, e, i) {
var n = e.deferredLoadRaw;
n ? t instanceof cc.Asset && t.constructor.preventDeferredLoadDependents && (n = !1) : i && (t instanceof cc.SceneAsset || t instanceof cc.Prefab) && (n = t.asyncLoadAssets);
return n;
})(u, i, l));
cc.deserialize.Details.pool.put(_);
if (0 === d.length) return n(null, u);
(function(t, e, i, n, r) {
e.content = i;
var s = e.dependKeys;
t.flowInDeps(e, n, (function(t, e) {
var o, c = e.map;
for (var h in c) (o = c[h]).uuid && o.content && (o.content._uuid = o.uuid);
for (var l = 0; l < n.length; l++) {
var u = n[l], _ = u.uuid, f = u.url;
u._owner, u._ownerProp;
if (o = c[f]) {
var d = u;
if (o.complete || o.content) o.error ? cc._throw(o.error) : v.call(d, o); else {
var m = a.getQueue(o), p = m._callbackTable[_];
p ? p.unshift(v, d) : m.addListener(_, v, d);
}
}
function v(t) {
var e = t.content;
this._stillUseUrl && (e = e && cc.RawAsset.wasRawAssetType(e.constructor) ? e.nativeUrl : t.rawUrl);
this._owner[this._ownerProp] = e;
t.uuid !== i._uuid && s.indexOf(t.id) < 0 && s.push(t.id);
}
}
r(t, i);
}));
})(this.pipeline, i, u, d, n);
}
n.exports = h;
h.isSceneObj = c;
}), {
"../CCDebug": 26,
"../platform/deserialize": 175,
"../platform/js": 180,
"./loading-items": 121
} ],
131: [ (function(t, e, i) {
var n = t("./component-scheduler"), r = t("./platform/CCObject").Flags, s = t("./platform/js"), o = r.IsPreloadStarted, a = r.IsOnLoadStarted, c = r.IsOnLoadCalled, h = r.Deactivating, l = "c.onLoad();c._objFlags|=" + c, u = cc.Class({
extends: n.LifeCycleInvoker,
add: function(t) {
this._zero.array.push(t);
},
remove: function(t) {
this._zero.fastRemove(t);
},
cancelInactive: function(t) {
n.LifeCycleInvoker.stableRemoveInactive(this._zero, t);
},
invoke: function() {
this._invoke(this._zero);
this._zero.array.length = 0;
}
}), _ = n.createInvokeImpl("c.__preload();"), f = n.createInvokeImpl(l), d = new s.Pool(4);
d.get = function() {
var t = this._get() || {
preload: new u(_),
onLoad: new n.OneOffInvoker(f),
onEnable: new n.OneOffInvoker(n.invokeOnEnable)
};
t.preload._zero.i = -1;
var e = t.onLoad;
e._zero.i = -1;
e._neg.i = -1;
e._pos.i = -1;
(e = t.onEnable)._zero.i = -1;
e._neg.i = -1;
e._pos.i = -1;
return t;
};
function m(t, e, i) {
0;
e ? t._removeComponent(e) : s.array.removeAt(t._components, i);
}
function p() {
this._activatingStack = [];
}
var v = cc.Class({
ctor: p,
reset: p,
_activateNodeRecursively: function(t, e, i, n) {
if (t._objFlags & h) cc.errorID(3816, t.name); else {
t._activeInHierarchy = !0;
for (var r = t._components.length, s = 0; s < r; ++s) {
var o = t._components[s];
if (o instanceof cc.Component) this.activateComp(o, e, i, n); else {
m(t, o, s);
--s;
--r;
}
}
for (var a = 0, c = t._children.length; a < c; ++a) {
var l = t._children[a];
l._active && this._activateNodeRecursively(l, e, i, n);
}
t._onPostActivated(!0);
}
},
_deactivateNodeRecursively: function(t) {
0;
t._objFlags |= h;
t._activeInHierarchy = !1;
for (var e = t._components.length, i = 0; i < e; ++i) {
var n = t._components[i];
if (n._enabled) {
cc.director._compScheduler.disableComp(n);
if (t._activeInHierarchy) {
t._objFlags &= ~h;
return;
}
}
}
for (var r = 0, s = t._children.length; r < s; ++r) {
var o = t._children[r];
if (o._activeInHierarchy) {
this._deactivateNodeRecursively(o);
if (t._activeInHierarchy) {
t._objFlags &= ~h;
return;
}
}
}
t._onPostActivated(!1);
t._objFlags &= ~h;
},
activateNode: function(t, e) {
if (e) {
var i = d.get();
this._activatingStack.push(i);
this._activateNodeRecursively(t, i.preload, i.onLoad, i.onEnable);
i.preload.invoke();
i.onLoad.invoke();
i.onEnable.invoke();
this._activatingStack.pop();
d.put(i);
} else {
this._deactivateNodeRecursively(t);
for (var n = this._activatingStack, r = 0; r < n.length; r++) {
var s = n[r];
s.preload.cancelInactive(o);
s.onLoad.cancelInactive(a);
s.onEnable.cancelInactive();
}
}
t.emit("active-in-hierarchy-changed", t);
},
activateComp: function(t, e, i, n) {
if (cc.isValid(t, !0)) {
if (!(t._objFlags & o)) {
t._objFlags |= o;
t.__preload && (e ? e.add(t) : t.__preload());
}
if (!(t._objFlags & a)) {
t._objFlags |= a;
if (t.onLoad) if (i) i.add(t); else {
t.onLoad();
t._objFlags |= c;
} else t._objFlags |= c;
}
if (t._enabled) {
if (!t.node._activeInHierarchy) return;
cc.director._compScheduler.enableComp(t, n);
}
}
},
destroyComp: function(t) {
cc.director._compScheduler.disableComp(t);
t.onDestroy && t._objFlags & c && t.onDestroy();
},
resetComp: !1
});
e.exports = v;
}), {
"./component-scheduler": 61,
"./platform/CCObject": 166,
"./platform/js": 180,
"./utils/misc": 242
} ],
132: [ (function(t, e, i) {
var n = t("./CCPhysicsTypes").PTM_RATIO, r = t("./CCPhysicsTypes").ContactType, s = [], o = [ cc.v2(), cc.v2() ], a = new b2.WorldManifold(), c = {
points: [],
separations: [],
normal: cc.v2()
};
function h() {
this.localPoint = cc.v2();
this.normalImpulse = 0;
this.tangentImpulse = 0;
}
var l = [ new h(), new h() ], u = (new b2.Manifold(), {
type: 0,
localPoint: cc.v2(),
localNormal: cc.v2(),
points: []
}), _ = {
normalImpulses: [],
tangentImpulses: []
};
function f() {}
f.prototype.init = function(t) {
this.colliderA = t.GetFixtureA().collider;
this.colliderB = t.GetFixtureB().collider;
this.disabled = !1;
this.disabledOnce = !1;
this._impulse = null;
this._inverted = !1;
this._b2contact = t;
t._contact = this;
};
f.prototype.reset = function() {
this.setTangentSpeed(0);
this.resetFriction();
this.resetRestitution();
this.colliderA = null;
this.colliderB = null;
this.disabled = !1;
this._impulse = null;
this._b2contact._contact = null;
this._b2contact = null;
};
f.prototype.getWorldManifold = function() {
var t = c.points, e = c.separations, i = c.normal;
this._b2contact.GetWorldManifold(a);
var r = a.points, s = a.separations, h = this._b2contact.GetManifold().pointCount;
t.length = e.length = h;
for (var l = 0; l < h; l++) {
var u = o[l];
u.x = r[l].x * n;
u.y = r[l].y * n;
t[l] = u;
e[l] = s[l] * n;
}
i.x = a.normal.x;
i.y = a.normal.y;
if (this._inverted) {
i.x *= -1;
i.y *= -1;
}
return c;
};
f.prototype.getManifold = function() {
for (var t = u.points, e = u.localNormal, i = u.localPoint, r = this._b2contact.GetManifold(), s = r.points, o = t.length = r.pointCount, a = 0; a < o; a++) {
var c = l[a], h = s[a];
c.localPoint.x = h.localPoint.x * n;
c.localPoint.Y = h.localPoint.Y * n;
c.normalImpulse = h.normalImpulse * n;
c.tangentImpulse = h.tangentImpulse;
t[a] = c;
}
i.x = r.localPoint.x * n;
i.y = r.localPoint.y * n;
e.x = r.localNormal.x;
e.y = r.localNormal.y;
u.type = r.type;
if (this._inverted) {
e.x *= -1;
e.y *= -1;
}
return u;
};
f.prototype.getImpulse = function() {
var t = this._impulse;
if (!t) return null;
for (var e = _.normalImpulses, i = _.tangentImpulses, r = t.count, s = 0; s < r; s++) {
e[s] = t.normalImpulses[s] * n;
i[s] = t.tangentImpulses[s];
}
i.length = e.length = r;
return _;
};
f.prototype.emit = function(t) {
var e;
switch (t) {
case r.BEGIN_CONTACT:
e = "onBeginContact";
break;

case r.END_CONTACT:
e = "onEndContact";
break;

case r.PRE_SOLVE:
e = "onPreSolve";
break;

case r.POST_SOLVE:
e = "onPostSolve";
}
var i, n, s, o, a = this.colliderA, c = this.colliderB, h = a.body, l = c.body;
if (h.enabledContactListener) {
i = h.node._components;
this._inverted = !1;
for (n = 0, s = i.length; n < s; n++) (o = i[n])[e] && o[e](this, a, c);
}
if (l.enabledContactListener) {
i = l.node._components;
this._inverted = !0;
for (n = 0, s = i.length; n < s; n++) (o = i[n])[e] && o[e](this, c, a);
}
if (this.disabled || this.disabledOnce) {
this.setEnabled(!1);
this.disabledOnce = !1;
}
};
f.get = function(t) {
var e;
(e = 0 === s.length ? new cc.PhysicsContact() : s.pop()).init(t);
return e;
};
f.put = function(t) {
var e = t._contact;
if (e) {
s.push(e);
e.reset();
}
};
var d = f.prototype;
d.setEnabled = function(t) {
this._b2contact.SetEnabled(t);
};
d.isTouching = function() {
return this._b2contact.IsTouching();
};
d.setTangentSpeed = function(t) {
this._b2contact.SetTangentSpeed(t / n);
};
d.getTangentSpeed = function() {
return this._b2contact.GetTangentSpeed() * n;
};
d.setFriction = function(t) {
this._b2contact.SetFriction(t);
};
d.getFriction = function() {
return this._b2contact.GetFriction();
};
d.resetFriction = function() {
return this._b2contact.ResetFriction();
};
d.setRestitution = function(t) {
this._b2contact.SetRestitution(t);
};
d.getRestitution = function() {
return this._b2contact.GetRestitution();
};
d.resetRestitution = function() {
return this._b2contact.ResetRestitution();
};
f.ContactType = r;
cc.PhysicsContact = e.exports = f;
}), {
"./CCPhysicsTypes": 134
} ],
133: [ (function(t, e, i) {
var n = t("./CCPhysicsTypes"), r = n.ContactType, s = n.BodyType, o = n.RayCastType, a = n.DrawBits, c = n.PTM_RATIO, h = (n.ANGLE_TO_PHYSICS_ANGLE, 
n.PHYSICS_ANGLE_TO_ANGLE), l = t("./utils").convertToNodeRotation, u = t("./platform/CCPhysicsDebugDraw"), _ = new b2.AABB(), f = new b2.Vec2(), d = new b2.Vec2(), m = cc.v2(), p = cc.Class({
mixins: [ cc.EventTarget ],
statics: {
DrawBits: a,
PTM_RATIO: c,
VELOCITY_ITERATIONS: 10,
POSITION_ITERATIONS: 10,
FIXED_TIME_STEP: 1 / 60,
MAX_ACCUMULATOR: .2
},
ctor: function() {
this._debugDrawFlags = 0;
this._debugDrawer = null;
this._world = null;
this._bodies = [];
this._joints = [];
this._contactMap = {};
this._contactID = 0;
this._delayEvents = [];
this._accumulator = 0;
cc.director._scheduler && cc.director._scheduler.enableForTarget(this);
this.enabledAccumulator = !1;
},
pushDelayEvent: function(t, e, i) {
this._steping ? this._delayEvents.push({
target: t,
func: e,
args: i
}) : t[e].apply(t, i);
},
update: function(t) {
var e = this._world;
if (e && this.enabled) {
this.emit("before-step");
this._steping = !0;
var i = p.VELOCITY_ITERATIONS, n = p.POSITION_ITERATIONS;
if (this.enabledAccumulator) {
this._accumulator += t;
var r = p.FIXED_TIME_STEP, s = p.MAX_ACCUMULATOR;
this._accumulator > s && (this._accumulator = s);
for (;this._accumulator > r; ) {
e.Step(r, i, n);
this._accumulator -= r;
}
} else {
var o = 1 / cc.game.config.frameRate;
e.Step(o, i, n);
}
if (this.debugDrawFlags) {
this._checkDebugDrawValid();
this._debugDrawer.clear();
e.DrawDebugData();
}
this._steping = !1;
for (var a = this._delayEvents, c = 0, h = a.length; c < h; c++) {
var l = a[c];
l.target[l.func].apply(l.target, l.args);
}
a.length = 0;
this._syncNode();
}
},
testPoint: function(t) {
var e = f.x = t.x / c, i = f.y = t.y / c, n = .2 / c;
_.lowerBound.x = e - n;
_.lowerBound.y = i - n;
_.upperBound.x = e + n;
_.upperBound.y = i + n;
var r = this._aabbQueryCallback;
r.init(f);
this._world.QueryAABB(r, _);
var s = r.getFixture();
return s ? s.collider : null;
},
testAABB: function(t) {
_.lowerBound.x = t.xMin / c;
_.lowerBound.y = t.yMin / c;
_.upperBound.x = t.xMax / c;
_.upperBound.y = t.yMax / c;
var e = this._aabbQueryCallback;
e.init();
this._world.QueryAABB(e, _);
return e.getFixtures().map((function(t) {
return t.collider;
}));
},
rayCast: function(t, e, i) {
if (t.equals(e)) return [];
i = i || o.Closest;
f.x = t.x / c;
f.y = t.y / c;
d.x = e.x / c;
d.y = e.y / c;
var n = this._raycastQueryCallback;
n.init(i);
this._world.RayCast(n, f, d);
var r = n.getFixtures();
if (r.length > 0) {
for (var s = n.getPoints(), a = n.getNormals(), h = n.getFractions(), l = [], u = 0, _ = r.length; u < _; u++) {
var m = r[u], p = m.collider;
if (i === o.AllClosest) {
var v = l.find((function(t) {
return t.collider === p;
}));
if (v) {
if (h[u] < v.fraction) {
v.fixtureIndex = p._getFixtureIndex(m);
v.point.x = s[u].x * c;
v.point.y = s[u].y * c;
v.normal.x = a[u].x;
v.normal.y = a[u].y;
v.fraction = h[u];
}
continue;
}
}
l.push({
collider: p,
fixtureIndex: p._getFixtureIndex(m),
point: cc.v2(s[u].x * c, s[u].y * c),
normal: cc.v2(a[u]),
fraction: h[u]
});
}
return l;
}
return [];
},
syncPosition: function() {
for (var t = this._bodies, e = 0; e < t.length; e++) t[e].syncPosition();
},
syncRotation: function() {
for (var t = this._bodies, e = 0; e < t.length; e++) t[e].syncRotation();
},
_registerContactFixture: function(t) {
this._contactListener.registerContactFixture(t);
},
_unregisterContactFixture: function(t) {
this._contactListener.unregisterContactFixture(t);
},
_addBody: function(t, e) {
var i = this._world, n = t.node;
if (i && n) {
t._b2Body = i.CreateBody(e);
t._b2Body.body = t;
this._bodies.push(t);
}
},
_removeBody: function(t) {
var e = this._world;
if (e) {
t._b2Body.body = null;
e.DestroyBody(t._b2Body);
t._b2Body = null;
cc.js.array.remove(this._bodies, t);
}
},
_addJoint: function(t, e) {
var i = this._world.CreateJoint(e);
if (i) {
i._joint = t;
t._joint = i;
this._joints.push(t);
}
},
_removeJoint: function(t) {
t._isValid() && this._world.DestroyJoint(t._joint);
t._joint && (t._joint._joint = null);
cc.js.array.remove(this._joints, t);
},
_initCallback: function() {
if (this._world) {
if (!this._contactListener) {
var t = new cc.PhysicsContactListener();
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 cc.PhysicsAABBQueryCallback();
this._raycastQueryCallback = new cc.PhysicsRayCastCallback();
}
} else cc.warn("Please init PhysicsManager first");
},
_init: function() {
this.enabled = !0;
this.debugDrawFlags = a.e_shapeBit;
},
_getWorld: function() {
return this._world;
},
_syncNode: function() {
for (var t = this._bodies, e = 0, i = t.length; e < i; e++) {
var n = t[e], r = n.node, o = n._b2Body, a = o.GetPosition();
m.x = a.x * c;
m.y = a.y * c;
var u = o.GetAngle() * h;
if (null !== r.parent.parent) {
m = r.parent.convertToNodeSpaceAR(m);
u = l(r.parent, u);
}
var _ = r._eventMask;
r._eventMask = 0;
r.position = m;
r.rotation = u;
r._eventMask = _;
n.type === s.Animated && n.resetVelocity();
}
},
_onBeginContact: function(t) {
cc.PhysicsContact.get(t).emit(r.BEGIN_CONTACT);
},
_onEndContact: function(t) {
var e = t._contact;
if (e) {
e.emit(r.END_CONTACT);
cc.PhysicsContact.put(t);
}
},
_onPreSolve: function(t) {
var e = t._contact;
e && e.emit(r.PRE_SOLVE);
},
_onPostSolve: function(t, e) {
var i = t._contact;
if (i) {
i._impulse = e;
i.emit(r.POST_SOLVE);
i._impulse = null;
}
},
_checkDebugDrawValid: function() {
if (!this._debugDrawer || !this._debugDrawer.isValid) {
var t = new cc.Node("PHYSICS_MANAGER_DEBUG_DRAW");
t.zIndex = cc.macro.MAX_ZINDEX;
cc.game.addPersistRootNode(t);
this._debugDrawer = t.addComponent(cc.Graphics);
var e = new u(this._debugDrawer);
e.SetFlags(this.debugDrawFlags);
this._world.SetDebugDraw(e);
}
}
});
cc.js.getset(p.prototype, "enabled", (function() {
return this._enabled;
}), (function(t) {
0;
if (t && !this._world) {
var e = new b2.World(new b2.Vec2(0, -10));
e.SetAllowSleeping(!0);
this._world = e;
this._initCallback();
}
this._enabled = t;
}));
cc.js.getset(p.prototype, "debugDrawFlags", (function() {
return this._debugDrawFlags;
}), (function(t) {
0;
t && !this._debugDrawFlags ? this._debugDrawer && this._debugDrawer.node && (this._debugDrawer.node.active = !0) : !t && this._debugDrawFlags && this._debugDrawer && this._debugDrawer.node && (this._debugDrawer.node.active = !1);
if (t) {
this._checkDebugDrawValid();
this._world.m_debugDraw.SetFlags(t);
}
this._debugDrawFlags = t;
if (t) {
this._checkDebugDrawValid();
this._world.m_debugDraw.SetFlags(t);
}
}));
cc.js.getset(p.prototype, "gravity", (function() {
if (this._world) {
var t = this._world.GetGravity();
return cc.v2(t.x * c, t.y * c);
}
return cc.v2();
}), (function(t) {
this._world && this._world.SetGravity(new b2.Vec2(t.x / c, t.y / c));
}));
cc.PhysicsManager = e.exports = p;
}), {
"./CCPhysicsTypes": 134,
"./platform/CCPhysicsDebugDraw": 155,
"./utils": 157
} ],
134: [ (function(t, e, i) {
var n = cc.Enum({
Static: 0,
Kinematic: 1,
Dynamic: 2,
Animated: 3
});
cc.RigidBodyType = n;
var r = cc.Enum({
Closest: 0,
Any: 1,
AllClosest: 2,
All: 3
});
cc.RayCastType = r;
e.exports = {
BodyType: n,
ContactType: {
BEGIN_CONTACT: "begin-contact",
END_CONTACT: "end-contact",
PRE_SOLVE: "pre-solve",
POST_SOLVE: "post-solve"
},
RayCastType: r,
DrawBits: b2.DrawFlags,
PTM_RATIO: 32,
ANGLE_TO_PHYSICS_ANGLE: -Math.PI / 180,
PHYSICS_ANGLE_TO_ANGLE: -180 / Math.PI
};
}), {} ],
135: [ (function(i, n, r) {
function s(t, e) {
var i = e.length;
return e[t < 0 ? i - -t % i : t % i];
}
function o(t, e, i) {
for (var n = []; e < t; ) e += i.length;
for (;t <= e; ++t) n.push(s(t, i));
return n;
}
function a(t, e, i) {
if (c(t, i)) {
if (u(s(t, i), s(t - 1, i), s(e, i)) && _(s(t, i), s(t + 1, i), s(e, i))) return !1;
} else if (_(s(t, i), s(t + 1, i), s(e, i)) || u(s(t, i), s(t - 1, i), s(e, i))) return !1;
if (c(e, i)) {
if (u(s(e, i), s(e - 1, i), s(t, i)) && _(s(e, i), s(e + 1, i), s(t, i))) return !1;
} else if (_(s(e, i), s(e + 1, i), s(t, i)) || u(s(e, i), s(e - 1, i), s(t, i))) return !1;
for (var n = 0; n < i.length; ++n) if ((n + 1) % i.length != t && n != t && (n + 1) % i.length != e && n != e) {
var r = cc.v2();
if (v(s(t, i), s(e, i), s(n, i), s(n + 1, i), r)) return !1;
}
return !0;
}
function c(t, e) {
return h(t, e);
}
function h(i, n, r) {
if ("undefined" === ("object" === (e = typeof r) ? t(r) : e)) {
var o = i, a = n;
i = s(o - 1, a);
n = s(o, a);
r = s(o + 1, a);
}
return y(i, n, r) < 0;
}
function l(t, e, i) {
return y(t, e, i) > 0;
}
function u(t, e, i) {
return y(t, e, i) >= 0;
}
function _(t, e, i) {
return y(t, e, i) <= 0;
}
function f(t, e) {
var i = e.x - t.x, n = e.y - t.y;
return i * i + n * n;
}
function d(t) {
m(t) || t.reverse();
}
function m(t) {
return t.length < 3 || (function(t) {
var e, i = 0;
for (e = 0; e < t.length; e++) {
var n = (e + 1) % t.length;
i += t[e].x * t[n].y;
i -= t[e].y * t[n].x;
}
return i /= 2;
})(t) > 0;
}
function p(t, e, i, n) {
var r = cc.v2(), s = e.y - t.y, o = t.x - e.x, a = s * t.x + o * t.y, c = n.y - i.y, h = i.x - n.x, l = c * i.x + h * i.y, u = s * h - c * o;
if (!(function(t, e) {
return Math.abs(t - e) <= 1e-6;
})(u, 0)) {
r.x = (h * a - o * l) / u;
r.y = (s * l - c * a) / u;
}
return r;
}
function v(t, e, i, n, r) {
if (t == i || t == n || e == i || e == n) return !1;
var s = t.x, o = t.y, a = e.x, c = e.y, h = i.x, l = i.y, u = n.x, _ = n.y;
if (Math.max(s, a) < Math.min(h, u) || Math.max(h, u) < Math.min(s, a)) return !1;
if (Math.max(o, c) < Math.min(l, _) || Math.max(l, _) < Math.min(o, c)) return !1;
var f = (u - h) * (o - l) - (_ - l) * (s - h), d = (a - s) * (o - l) - (c - o) * (s - h), m = (_ - l) * (a - s) - (u - h) * (c - o);
if (Math.abs(m) < 1e-6) return !1;
d /= m;
if (0 < (f /= m) && f < 1 && 0 < d && d < 1) {
r.x = s + f * (a - s);
r.y = o + f * (c - o);
return !0;
}
return !1;
}
function y(t, e, i) {
return t.x * (e.y - i.y) + e.x * (i.y - t.y) + i.x * (t.y - e.y);
}
n.exports = {
ConvexPartition: function t(e) {
d(e);
for (var i, n, r, m, v, y, g = [], x = cc.v2(), C = cc.v2(), A = 0, b = 0, S = 0; S < e.length; ++S) if (c(S, e)) {
n = r = 1e8;
for (var T = 0; T < e.length; ++T) {
if (l(s(S - 1, e), s(S, e), s(T, e)) && _(s(S - 1, e), s(S, e), s(T - 1, e))) {
m = p(s(S - 1, e), s(S, e), s(T, e), s(T - 1, e));
if (h(s(S + 1, e), s(S, e), m) && (i = f(s(S, e), m)) < n) {
n = i;
x = m;
A = T;
}
}
if (l(s(S + 1, e), s(S, e), s(T + 1, e)) && _(s(S + 1, e), s(S, e), s(T, e))) {
m = p(s(S + 1, e), s(S, e), s(T, e), s(T + 1, e));
if (l(s(S - 1, e), s(S, e), m) && (i = f(s(S, e), m)) < r) {
r = i;
b = T;
C = m;
}
}
}
if (A == (b + 1) % e.length) {
var w = x.add(C).div(2);
(v = o(S, b, e)).push(w);
(y = o(A, S, e)).push(w);
} else {
for (var E = 0, B = A; b < A; ) b += e.length;
for (T = A; T <= b; ++T) if (a(S, T, e)) {
var M = 1 / (f(s(S, e), s(T, e)) + 1);
c(T, e) ? _(s(T - 1, e), s(T, e), s(S, e)) && u(s(T + 1, e), s(T, e), s(S, e)) ? M += 3 : M += 2 : M += 1;
if (M > E) {
B = T;
E = M;
}
}
v = o(S, B, e);
y = o(B, S, e);
}
return g = (g = g.concat(t(v))).concat(t(y));
}
g.push(e);
for (S = g.length - 1; S >= 0; S--) 0 == g[S].length && g.splice(S, 0);
return g;
},
ForceCounterClockWise: d,
IsCounterClockWise: m
};
}), {} ],
136: [ (function(t, e, i) {
var n = t("../CCNode").EventType, r = t("./CCPhysicsTypes").PTM_RATIO, s = t("./CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE, o = t("./CCPhysicsTypes").PHYSICS_ANGLE_TO_ANGLE, a = t("./utils").getWorldRotation, c = t("./CCPhysicsTypes").BodyType, h = new b2.Vec2(), l = new b2.Vec2(), u = cc.Vec2.ZERO, _ = cc.Class({
name: "cc.RigidBody",
extends: cc.Component,
editor: !1,
properties: {
_type: c.Dynamic,
_allowSleep: !0,
_gravityScale: 1,
_linearDamping: 0,
_angularDamping: 0,
_linearVelocity: cc.v2(0, 0),
_angularVelocity: 0,
_fixedRotation: !1,
enabled: {
get: function() {
return this._enabled;
},
set: function() {
cc.warnID(8200);
},
visible: !1,
override: !0
},
enabledContactListener: {
default: !1,
tooltip: !1
},
bullet: {
default: !1,
tooltip: !1
},
type: {
type: c,
tooltip: !1,
get: function() {
return this._type;
},
set: function(t) {
this._type = t;
this._b2Body && (t === c.Animated ? this._b2Body.SetType(c.Kinematic) : this._b2Body.SetType(t));
}
},
allowSleep: {
tooltip: !1,
get: function() {
return this._b2Body ? this._b2Body.IsSleepingAllowed() : this._allowSleep;
},
set: function(t) {
this._allowSleep = t;
this._b2Body && this._b2Body.SetSleepingAllowed(t);
}
},
gravityScale: {
tooltip: !1,
get: function() {
return this._gravityScale;
},
set: function(t) {
this._gravityScale = t;
this._b2Body && this._b2Body.SetGravityScale(t);
}
},
linearDamping: {
tooltip: !1,
get: function() {
return this._linearDamping;
},
set: function(t) {
this._linearDamping = t;
this._b2Body && this._b2Body.SetLinearDamping(this._linearDamping);
}
},
angularDamping: {
tooltip: !1,
get: function() {
return this._angularDamping;
},
set: function(t) {
this._angularDamping = t;
this._b2Body && this._b2Body.SetAngularDamping(t);
}
},
linearVelocity: {
tooltip: !1,
type: cc.Vec2,
get: function() {
var t = this._linearVelocity;
if (this._b2Body) {
var e = this._b2Body.GetLinearVelocity();
t.x = e.x * r;
t.y = e.y * r;
}
return t;
},
set: function(t) {
this._linearVelocity = t;
var e = this._b2Body;
if (e) {
var i = e.m_linearVelocity;
i.Set(t.x / r, t.y / r);
e.SetLinearVelocity(i);
}
}
},
angularVelocity: {
tooltip: !1,
get: function() {
return this._b2Body ? this._b2Body.GetAngularVelocity() * o : this._angularVelocity;
},
set: function(t) {
this._angularVelocity = t;
this._b2Body && this._b2Body.SetAngularVelocity(t * s);
}
},
fixedRotation: {
tooltip: !1,
get: function() {
return this._fixedRotation;
},
set: function(t) {
this._fixedRotation = t;
this._b2Body && this._b2Body.SetFixedRotation(t);
}
},
awake: {
visible: !1,
tooltip: !1,
get: function() {
return !!this._b2Body && this._b2Body.IsAwake();
},
set: function(t) {
this._b2Body && this._b2Body.SetAwake(t);
}
},
awakeOnLoad: {
default: !0,
tooltip: !1,
animatable: !1
},
active: {
visible: !1,
get: function() {
return !!this._b2Body && this._b2Body.IsActive();
},
set: function(t) {
this._b2Body && this._b2Body.SetActive(t);
}
}
},
getLocalPoint: function(t, e) {
e = e || cc.v2();
if (this._b2Body) {
h.Set(t.x / r, t.y / r);
var i = this._b2Body.GetLocalPoint(h, e);
e.x = i.x * r;
e.y = i.y * r;
}
return e;
},
getWorldPoint: function(t, e) {
e = e || cc.v2();
if (this._b2Body) {
h.Set(t.x / r, t.y / r);
var i = this._b2Body.GetWorldPoint(h, e);
e.x = i.x * r;
e.y = i.y * r;
}
return e;
},
getWorldVector: function(t, e) {
e = e || cc.v2();
if (this._b2Body) {
h.Set(t.x / r, t.y / r);
var i = this._b2Body.GetWorldVector(h, e);
e.x = i.x * r;
e.y = i.y * r;
}
return e;
},
getLocalVector: function(t, e) {
e = e || cc.v2();
if (this._b2Body) {
h.Set(t.x / r, t.y / r);
var i = this._b2Body.GetLocalVector(h, e);
e.x = i.x * r;
e.y = i.y * r;
}
return e;
},
getWorldPosition: function(t) {
t = t || cc.v2();
if (this._b2Body) {
var e = this._b2Body.GetPosition();
t.x = e.x * r;
t.y = e.y * r;
}
return t;
},
getWorldRotation: function() {
return this._b2Body ? this._b2Body.GetAngle() * o : 0;
},
getLocalCenter: function(t) {
t = t || cc.v2();
if (this._b2Body) {
var e = this._b2Body.GetLocalCenter();
t.x = e.x * r;
t.y = e.y * r;
}
return t;
},
getWorldCenter: function(t) {
t = t || cc.v2();
if (this._b2Body) {
var e = this._b2Body.GetWorldCenter();
t.x = e.x * r;
t.y = e.y * r;
}
return t;
},
getLinearVelocityFromWorldPoint: function(t, e) {
e = e || cc.v2();
if (this._b2Body) {
h.Set(t.x / r, t.y / r);
var i = this._b2Body.GetLinearVelocityFromWorldPoint(h, e);
e.x = i.x * r;
e.y = i.y * r;
}
return e;
},
getMass: function() {
return this._b2Body ? this._b2Body.GetMass() : 0;
},
getInertia: function() {
return this._b2Body ? this._b2Body.GetInertia() * r * r : 0;
},
getJointList: function() {
if (!this._b2Body) return [];
var t = [], e = this._b2Body.GetJointList();
if (!e) return [];
t.push(e.joint._joint);
for (var i = e.prev; i; ) {
t.push(i.joint._joint);
i = i.prev;
}
for (var n = e.next; n; ) {
t.push(n.joint._joint);
n = n.next;
}
return t;
},
applyForce: function(t, e, i) {
if (this._b2Body) {
h.Set(t.x / r, t.y / r);
l.Set(e.x / r, e.y / r);
this._b2Body.ApplyForce(h, l, i);
}
},
applyForceToCenter: function(t, e) {
if (this._b2Body) {
h.Set(t.x / r, t.y / r);
this._b2Body.ApplyForceToCenter(h, e);
}
},
applyTorque: function(t, e) {
this._b2Body && this._b2Body.ApplyTorque(t / r, e);
},
applyLinearImpulse: function(t, e, i) {
if (this._b2Body) {
h.Set(t.x / r, t.y / r);
l.Set(e.x / r, e.y / r);
this._b2Body.ApplyLinearImpulse(h, l, i);
}
},
applyAngularImpulse: function(t, e) {
this._b2Body && this._b2Body.ApplyAngularImpulse(t / r / r, e);
},
syncPosition: function(t) {
var e = this._b2Body;
if (e) {
var i, n = this.node.convertToWorldSpaceAR(u);
(i = this.type === c.Animated ? e.GetLinearVelocity() : e.GetPosition()).x = n.x / r;
i.y = n.y / r;
if (this.type === c.Animated && t) {
var s = e.GetPosition(), o = cc.game.config.frameRate;
i.x = (i.x - s.x) * o;
i.y = (i.y - s.y) * o;
e.SetAwake(!0);
e.SetLinearVelocity(i);
} else e.SetTransformVec(i, e.GetAngle());
}
},
syncRotation: function(t) {
var e = this._b2Body;
if (e) {
var i = s * a(this.node);
if (this.type === c.Animated && t) {
var n = e.GetAngle(), r = cc.game.config.frameRate;
e.SetAwake(!0);
e.SetAngularVelocity((i - n) * r);
} else e.SetTransformVec(e.GetPosition(), i);
}
},
resetVelocity: function() {
var t = this._b2Body;
if (t) {
var e = t.m_linearVelocity;
e.Set(0, 0);
t.SetLinearVelocity(e);
t.SetAngularVelocity(0);
}
},
onEnable: function() {
this._init();
},
onDisable: function() {
this._destroy();
},
_registerNodeEvents: function() {
var t = this.node;
t.on(n.POSITION_CHANGED, this._onNodePositionChanged, this);
t.on(n.ROTATION_CHANGED, this._onNodeRotationChanged, this);
t.on(n.SCALE_CHANGED, this._onNodeScaleChanged, this);
},
_unregisterNodeEvents: function() {
var t = this.node;
t.off(n.POSITION_CHANGED, this._onNodePositionChanged, this);
t.off(n.ROTATION_CHANGED, this._onNodeRotationChanged, this);
t.off(n.SCALE_CHANGED, this._onNodeScaleChanged, this);
},
_onNodePositionChanged: function() {
this.syncPosition(!0);
},
_onNodeRotationChanged: function(t) {
this.syncRotation(!0);
},
_onNodeScaleChanged: function(t) {
if (this._b2Body) for (var e = this.getComponents(cc.PhysicsCollider), i = 0; i < e.length; i++) e[i].apply();
},
_init: function() {
cc.director.getPhysicsManager().pushDelayEvent(this, "__init", []);
},
_destroy: function() {
cc.director.getPhysicsManager().pushDelayEvent(this, "__destroy", []);
},
__init: function() {
if (!this._inited) {
this._registerNodeEvents();
var t = new b2.BodyDef();
this.type === c.Animated ? t.type = c.Kinematic : t.type = this.type;
t.allowSleep = this.allowSleep;
t.gravityScale = this.gravityScale;
t.linearDamping = this.linearDamping;
t.angularDamping = this.angularDamping;
var e = this.linearVelocity;
t.linearVelocity = new b2.Vec2(e.x / r, e.y / r);
t.angularVelocity = this.angularVelocity * s;
t.fixedRotation = this.fixedRotation;
t.bullet = this.bullet;
var i = this.node, n = i.convertToWorldSpaceAR(u);
t.position = new b2.Vec2(n.x / r, n.y / r);
t.angle = -Math.PI / 180 * a(i);
t.awake = this.awakeOnLoad;
cc.director.getPhysicsManager()._addBody(this, t);
this._inited = !0;
}
},
__destroy: function() {
if (this._inited) {
cc.director.getPhysicsManager()._removeBody(this);
this._unregisterNodeEvents();
this._inited = !1;
}
},
_getBody: function() {
return this._b2Body;
}
});
cc.RigidBody = e.exports = _;
}), {
"../CCNode": 29,
"./CCPhysicsTypes": 134,
"./utils": 157
} ],
137: [ (function(t, e, i) {
var n = t("../../../external/box2d/box2d");
window.b2 = {};
0;
for (var r in n) if (-1 === r.indexOf("b2_")) {
var s = r.replace("b2", "");
b2[s] = n[r];
}
b2.maxPolygonVertices = 8;
}), {
"../../../external/box2d/box2d": 294
} ],
138: [ (function(t, e, i) {
var n = t("../CCPhysicsTypes").PTM_RATIO, r = cc.Class({
name: "cc.PhysicsBoxCollider",
extends: cc.PhysicsCollider,
mixins: [ cc.Collider.Box ],
editor: {
menu: !1,
requireComponent: cc.RigidBody
},
_createShape: function(t) {
var e = Math.abs(t.x), i = Math.abs(t.y), r = this.size.width / 2 / n * e, s = this.size.height / 2 / n * i, o = this.offset.x / n * e, a = this.offset.y / n * i, c = new b2.PolygonShape();
c.SetAsBox(r, s, new b2.Vec2(o, a), 0);
return c;
}
});
cc.PhysicsBoxCollider = e.exports = r;
}), {
"../CCPhysicsTypes": 134
} ],
139: [ (function(t, e, i) {
var n = t("../CCPhysicsTypes").PTM_RATIO, r = cc.Class({
name: "cc.PhysicsChainCollider",
extends: cc.PhysicsCollider,
editor: {
menu: !1,
inspector: !1,
requireComponent: cc.RigidBody
},
properties: {
loop: !1,
points: {
default: function() {
return [ cc.v2(-50, 0), cc.v2(50, 0) ];
},
type: [ cc.Vec2 ]
},
threshold: {
default: 1,
serializable: !1,
visible: !1
}
},
_createShape: function(t) {
for (var e = new b2.ChainShape(), i = this.points, r = [], s = 0; s < i.length; s++) {
var o = i[s];
r.push(new b2.Vec2(o.x / n * t.x, o.y / n * t.y));
}
this.loop ? e.CreateLoop(r, r.length) : e.CreateChain(r, r.length);
return e;
},
resetInEditor: !1,
resetPointsByContour: !1
});
cc.PhysicsChainCollider = e.exports = r;
}), {
"../CCPhysicsTypes": 134
} ],
140: [ (function(t, e, i) {
var n = t("../CCPhysicsTypes").PTM_RATIO, r = cc.Class({
name: "cc.PhysicsCircleCollider",
extends: cc.PhysicsCollider,
mixins: [ cc.Collider.Circle ],
editor: {
menu: !1,
requireComponent: cc.RigidBody
},
_createShape: function(t) {
var e = Math.abs(t.x), i = Math.abs(t.y), r = this.offset.x / n * e, s = this.offset.y / n * i, o = new b2.CircleShape();
o.m_radius = this.radius / n * e;
o.m_p = new b2.Vec2(r, s);
return o;
}
});
cc.PhysicsCircleCollider = e.exports = r;
}), {
"../CCPhysicsTypes": 134
} ],
141: [ (function(t, e, i) {
var n = t("../CCPhysicsTypes").PTM_RATIO, r = t("../utils").getWorldScale, s = cc.Class({
name: "cc.PhysicsCollider",
extends: cc.Collider,
ctor: function() {
this._fixtures = [];
this._shapes = [];
this._inited = !1;
this._rect = cc.rect();
},
properties: {
_density: 1,
_sensor: !1,
_friction: .2,
_restitution: 0,
density: {
tooltip: !1,
get: function() {
return this._density;
},
set: function(t) {
this._density = t;
}
},
sensor: {
tooltip: !1,
get: function() {
return this._sensor;
},
set: function(t) {
this._sensor = t;
}
},
friction: {
tooltip: !1,
get: function() {
return this._friction;
},
set: function(t) {
this._friction = t;
}
},
restitution: {
tooltip: !1,
get: function() {
return this._restitution;
},
set: function(t) {
this._restitution = t;
}
},
body: {
default: null,
type: cc.RigidBody,
visible: !1
}
},
onDisable: function() {
this._destroy();
},
onEnable: function() {
this._init();
},
start: function() {
this._init();
},
_getFixtureIndex: function(t) {
return this._fixtures.indexOf(t);
},
_init: function() {
cc.director.getPhysicsManager().pushDelayEvent(this, "__init", []);
},
_destroy: function() {
cc.director.getPhysicsManager().pushDelayEvent(this, "__destroy", []);
},
__init: function() {
if (!this._inited) {
var t = this.body || this.getComponent(cc.RigidBody);
if (t) {
var e = t._getBody();
if (e) {
var i = t.node, n = r(i);
this._scale = n;
var s = 0 === n.x && 0 === n.y ? [] : this._createShape(n);
s instanceof Array || (s = [ s ]);
for (var o = 1 << i.groupIndex, a = 0, c = cc.game.collisionMatrix[i.groupIndex], h = 0; h < c.length; h++) c[h] && (a |= 1 << h);
for (var l = {
categoryBits: o,
maskBits: a,
groupIndex: 0
}, u = cc.director.getPhysicsManager(), _ = 0; _ < s.length; _++) {
var f = s[_], d = new b2.FixtureDef();
d.density = this.density;
d.isSensor = this.sensor;
d.friction = this.friction;
d.restitution = this.restitution;
d.shape = f;
d.filter = l;
var m = e.CreateFixture(d);
m.collider = this;
t.enabledContactListener && u._registerContactFixture(m);
this._shapes.push(f);
this._fixtures.push(m);
}
this.body = t;
this._inited = !0;
}
}
}
},
__destroy: function() {
if (this._inited) {
for (var t = this._fixtures, e = this.body._getBody(), i = cc.director.getPhysicsManager(), n = t.length - 1; n >= 0; n--) {
var r = t[n];
r.collider = null;
i._unregisterContactFixture(r);
e && e.DestroyFixture(r);
}
this.body = null;
this._fixtures.length = 0;
this._shapes.length = 0;
this._inited = !1;
}
},
_createShape: function() {},
apply: function() {
this._destroy();
this._init();
},
getAABB: function() {
for (var t = 1e7, e = 1e7, i = -1e7, r = -1e7, s = this._fixtures, o = 0; o < s.length; o++) for (var a = s[o], c = a.GetShape().GetChildCount(), h = 0; h < c; h++) {
var l = a.GetAABB(h);
l.lowerBound.x < t && (t = l.lowerBound.x);
l.lowerBound.y < e && (e = l.lowerBound.y);
l.upperBound.x > i && (i = l.upperBound.x);
l.upperBound.y > r && (r = l.upperBound.y);
}
t *= n;
e *= n;
i *= n;
r *= n;
var u = this._rect;
u.x = t;
u.y = e;
u.width = i - t;
u.height = r - e;
return u;
}
});
cc.PhysicsCollider = e.exports = s;
}), {
"../CCPhysicsTypes": 134,
"../utils": 157
} ],
142: [ (function(t, e, i) {
var n = t("../CCPhysicsTypes").PTM_RATIO, r = t("../CCPolygonSeparator"), s = cc.Class({
name: "cc.PhysicsPolygonCollider",
extends: cc.PhysicsCollider,
mixins: [ cc.Collider.Polygon ],
editor: {
menu: !1,
inspector: !1,
requireComponent: cc.RigidBody
},
_createShape: function(t) {
var e = [], i = this.points;
i.length > 0 && i[0].equals(i[i.length - 1]) && (i.length -= 1);
for (var s = r.ConvexPartition(i), o = this.offset, a = 0; a < s.length; a++) {
for (var c = s[a], h = null, l = [], u = null, _ = 0, f = c.length; _ < f; _++) {
h || (h = new b2.PolygonShape());
var d = c[_], m = (d.x + o.x) / n * t.x, p = (d.y + o.y) / n * t.y, v = new b2.Vec2(m, p);
l.push(v);
u || (u = v);
if (l.length === b2.maxPolygonVertices) {
h.Set(l, l.length);
e.push(h);
h = null;
_ < f - 1 && (l = [ u, l[l.length - 1] ]);
}
}
if (h) {
h.Set(l, l.length);
e.push(h);
}
}
return e;
}
});
cc.PhysicsPolygonCollider = e.exports = s;
}), {
"../CCPhysicsTypes": 134,
"../CCPolygonSeparator": 135
} ],
143: [ (function(t, e, i) {
t("./box2d-adapter");
t("./CCPhysicsManager");
t("./CCRigidBody");
t("./CCPhysicsContact");
t("./collider/CCPhysicsCollider");
t("./collider/CCPhysicsChainCollider");
t("./collider/CCPhysicsCircleCollider");
t("./collider/CCPhysicsBoxCollider");
t("./collider/CCPhysicsPolygonCollider");
t("./joint/CCJoint");
t("./joint/CCDistanceJoint");
t("./joint/CCRevoluteJoint");
t("./joint/CCMouseJoint");
t("./joint/CCMotorJoint");
t("./joint/CCPrismaticJoint");
t("./joint/CCWeldJoint");
t("./joint/CCWheelJoint");
t("./joint/CCRopeJoint");
t("./platform/CCPhysicsContactListner");
t("./platform/CCPhysicsAABBQueryCallback");
t("./platform/CCPhysicsRayCastCallback");
}), {
"./CCPhysicsContact": 132,
"./CCPhysicsManager": 133,
"./CCRigidBody": 136,
"./box2d-adapter": 137,
"./collider/CCPhysicsBoxCollider": 138,
"./collider/CCPhysicsChainCollider": 139,
"./collider/CCPhysicsCircleCollider": 140,
"./collider/CCPhysicsCollider": 141,
"./collider/CCPhysicsPolygonCollider": 142,
"./joint/CCDistanceJoint": 144,
"./joint/CCJoint": 145,
"./joint/CCMotorJoint": 146,
"./joint/CCMouseJoint": 147,
"./joint/CCPrismaticJoint": 148,
"./joint/CCRevoluteJoint": 149,
"./joint/CCRopeJoint": 150,
"./joint/CCWeldJoint": 151,
"./joint/CCWheelJoint": 152,
"./platform/CCPhysicsAABBQueryCallback": 153,
"./platform/CCPhysicsContactListner": 154,
"./platform/CCPhysicsRayCastCallback": 156
} ],
144: [ (function(t, e, i) {
var n = t("../CCPhysicsTypes").PTM_RATIO, r = cc.Class({
name: "cc.DistanceJoint",
extends: cc.Joint,
editor: !1,
properties: {
_distance: 1,
_frequency: 0,
_dampingRatio: 0,
distance: {
tooltip: !1,
get: function() {
return this._distance;
},
set: function(t) {
this._distance = t;
this._joint && this._joint.SetLength(t);
}
},
frequency: {
tooltip: !1,
get: function() {
return this._frequency;
},
set: function(t) {
this._frequency = t;
this._joint && this._joint.SetFrequency(t);
}
},
dampingRatio: {
tooltip: !1,
get: function() {
return this._dampingRatio;
},
set: function(t) {
this._dampingRatio = t;
this._joint && this._joint.SetDampingRatio(t);
}
}
},
_createJointDef: function() {
var t = new b2.DistanceJointDef();
t.localAnchorA = new b2.Vec2(this.anchor.x / n, this.anchor.y / n);
t.localAnchorB = new b2.Vec2(this.connectedAnchor.x / n, this.connectedAnchor.y / n);
t.length = this.distance / n;
t.dampingRatio = this.dampingRatio;
t.frequencyHz = this.frequency;
return t;
}
});
cc.DistanceJoint = e.exports = r;
}), {
"../CCPhysicsTypes": 134
} ],
145: [ (function(t, e, i) {
var n = t("../CCPhysicsTypes").PTM_RATIO, r = cc.Class({
name: "cc.Joint",
extends: cc.Component,
editor: {
requireComponent: cc.RigidBody
},
properties: {
anchor: {
default: cc.v2(0, 0),
tooltip: !1
},
connectedAnchor: {
default: cc.v2(0, 0),
tooltip: !1
},
connectedBody: {
default: null,
type: cc.RigidBody,
tooltip: !1
},
collideConnected: {
default: !1,
tooltip: !1
}
},
onDisable: function() {
this._destroy();
},
onEnable: function() {
this._init();
},
start: function() {
this._init();
},
apply: function() {
this._destroy();
this._init();
},
getWorldAnchor: function() {
if (this._joint) {
var t = this._joint.GetAnchorA();
return cc.v2(t.x * n, t.y * n);
}
return cc.Vec2.ZERO;
},
getWorldConnectedAnchor: function() {
if (this._joint) {
var t = this._joint.GetAnchorB();
return cc.v2(t.x * n, t.y * n);
}
return cc.Vec2.ZERO;
},
getReactionForce: function(t) {
var e = cc.v2();
return this._joint ? this._joint.GetReactionForce(t, e) : e;
},
getReactionTorque: function(t) {
return this._joint ? this._joint.GetReactionTorque(t) : 0;
},
_init: function() {
cc.director.getPhysicsManager().pushDelayEvent(this, "__init", []);
},
_destroy: function() {
cc.director.getPhysicsManager().pushDelayEvent(this, "__destroy", []);
},
__init: function() {
if (!this._inited) {
this.body = this.getComponent(cc.RigidBody);
if (this._isValid()) {
var t = this._createJointDef();
if (!t) return;
t.bodyA = this.body._getBody();
t.bodyB = this.connectedBody._getBody();
t.collideConnected = this.collideConnected;
cc.director.getPhysicsManager()._addJoint(this, t);
this._inited = !0;
}
}
},
__destroy: function() {
if (this._inited) {
cc.director.getPhysicsManager()._removeJoint(this);
this._joint = null;
this._inited = !1;
}
},
_createJointDef: function() {
return null;
},
_isValid: function() {
return this.body && this.body._getBody() && this.connectedBody && this.connectedBody._getBody();
}
});
cc.Joint = e.exports = r;
}), {
"../CCPhysicsTypes": 134
} ],
146: [ (function(t, e, i) {
var n = t("../CCPhysicsTypes").PTM_RATIO, r = t("../CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE, s = cc.Class({
name: "cc.MotorJoint",
extends: cc.Joint,
editor: !1,
properties: {
_linearOffset: cc.v2(0, 0),
_angularOffset: 0,
_maxForce: 1,
_maxTorque: 1,
_correctionFactor: .3,
anchor: {
tooltip: !1,
default: cc.v2(0, 0),
override: !0,
visible: !1
},
connectedAnchor: {
tooltip: !1,
default: cc.v2(0, 0),
override: !0,
visible: !1
},
linearOffset: {
tooltip: !1,
get: function() {
return this._linearOffset;
},
set: function(t) {
this._linearOffset = t;
this._joint && this._joint.SetLinearOffset(new b2.Vec2(t.x / n, t.y / n));
}
},
angularOffset: {
tooltip: !1,
get: function() {
return this._angularOffset;
},
set: function(t) {
this._angularOffset = t;
this._joint && this._joint.SetAngularOffset(t);
}
},
maxForce: {
tooltip: !1,
get: function() {
return this._maxForce;
},
set: function(t) {
this._maxForce = t;
this._joint && this._joint.SetMaxForce(t);
}
},
maxTorque: {
tooltip: !1,
get: function() {
return this._maxTorque;
},
set: function(t) {
this._maxTorque = t;
this._joint && this._joint.SetMaxTorque(t);
}
},
correctionFactor: {
tooltip: !1,
get: function() {
return this._correctionFactor;
},
set: function(t) {
this._correctionFactor = t;
this._joint && this._joint.SetCorrectionFactor(t);
}
}
},
_createJointDef: function() {
var t = new b2.MotorJointDef();
t.linearOffset = new b2.Vec2(this.linearOffset.x / n, this.linearOffset.y / n);
t.angularOffset = this.angularOffset * r;
t.maxForce = this.maxForce;
t.maxTorque = this.maxTorque;
t.correctionFactor = this.correctionFactor;
return t;
}
});
cc.MotorJoint = e.exports = s;
}), {
"../CCPhysicsTypes": 134
} ],
147: [ (function(t, e, i) {
var n = t("../CCPhysicsTypes").PTM_RATIO, r = new b2.Vec2(), s = cc.Class({
name: "cc.MouseJoint",
extends: cc.Joint,
editor: !1,
properties: {
_target: 1,
_frequency: 5,
_dampingRatio: .7,
_maxForce: 0,
connectedBody: {
default: null,
type: cc.RigidBody,
visible: !1,
override: !0
},
collideConnected: {
default: !0,
visible: !1,
override: !0
},
anchor: {
tooltip: !1,
default: cc.v2(0, 0),
override: !0,
visible: !1
},
connectedAnchor: {
tooltip: !1,
default: cc.v2(0, 0),
override: !0,
visible: !1
},
mouseRegion: {
tooltip: !1,
default: null,
type: cc.Node
},
target: {
tooltip: !1,
visible: !1,
get: function() {
return this._target;
},
set: function(t) {
this._target = t;
if (this._joint) {
r.x = t.x / n;
r.y = t.y / n;
this._joint.SetTarget(r);
}
}
},
frequency: {
tooltip: !1,
get: function() {
return this._frequency;
},
set: function(t) {
this._frequency = t;
this._joint && this._joint.SetFrequency(t);
}
},
dampingRatio: {
tooltip: !1,
get: function() {
return this._dampingRatio;
},
set: function(t) {
this._dampingRatio = t;
this._joint && this._joint.SetDampingRatio(t);
}
},
maxForce: {
tooltip: !1,
visible: !1,
get: function() {
return this._maxForce;
},
set: function(t) {
this._maxForce = t;
this._joint && this._joint.SetMaxForce(t);
}
}
},
onLoad: function() {
var t = this.mouseRegion || this.node;
t.on(cc.Node.EventType.TOUCH_START, this.onTouchBegan, this);
t.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
t.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
t.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this);
},
onEnable: function() {},
start: function() {},
onTouchBegan: function(t) {
var e = cc.director.getPhysicsManager(), i = this._pressPoint = t.touch.getLocation();
cc.Camera && cc.Camera.main && (i = cc.Camera.main.getCameraToWorldPoint(i));
var n = e.testPoint(i);
if (n) {
(this.connectedBody = n.body).awake = !0;
this.maxForce = 1e3 * this.connectedBody.getMass();
this.target = i;
this._init();
}
},
onTouchMove: function(t) {
this._pressPoint = t.touch.getLocation();
},
onTouchEnd: function(t) {
this._destroy();
this._pressPoint = null;
},
_createJointDef: function() {
var t = new b2.MouseJointDef();
r.x = this.target.x / n;
r.y = this.target.y / n;
t.target = r;
t.maxForce = this.maxForce;
t.dampingRatio = this.dampingRatio;
t.frequencyHz = this.frequency;
return t;
},
update: function() {
if (this._pressPoint && this._isValid()) {
var t = cc.Camera.findCamera(this.node);
this.target = t ? t.getCameraToWorldPoint(this._pressPoint) : this._pressPoint;
}
}
});
cc.MouseJoint = e.exports = s;
}), {
"../CCPhysicsTypes": 134
} ],
148: [ (function(t, e, i) {
var n = t("../CCPhysicsTypes").PTM_RATIO, r = t("../CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE, s = cc.Class({
name: "cc.PrismaticJoint",
extends: cc.Joint,
editor: !1,
properties: {
localAxisA: {
default: cc.v2(1, 0),
tooltip: !1
},
referenceAngle: {
default: 0,
tooltip: !1
},
enableLimit: {
default: !1,
tooltip: !1
},
enableMotor: {
default: !1,
tooltip: !1
},
lowerLimit: {
default: 0,
tooltip: !1
},
upperLimit: {
default: 0,
tooltip: !1
},
_maxMotorForce: 0,
_motorSpeed: 0,
maxMotorForce: {
tooltip: !1,
get: function() {
return this._maxMotorForce;
},
set: function(t) {
this._maxMotorForce = t;
this._joint && this._joint.SetMaxMotorForce(t);
}
},
motorSpeed: {
tooltip: !1,
get: function() {
return this._motorSpeed;
},
set: function(t) {
this._motorSpeed = t;
this._joint && this._joint.SetMotorSpeed(t);
}
}
},
_createJointDef: function() {
var t = new b2.PrismaticJointDef();
t.localAnchorA = new b2.Vec2(this.anchor.x / n, this.anchor.y / n);
t.localAnchorB = new b2.Vec2(this.connectedAnchor.x / n, this.connectedAnchor.y / n);
t.localAxisA = new b2.Vec2(this.localAxisA.x, this.localAxisA.y);
t.referenceAngle = this.referenceAngle * r;
t.enableLimit = this.enableLimit;
t.lowerTranslation = this.lowerLimit / n;
t.upperTranslation = this.upperLimit / n;
t.enableMotor = this.enableMotor;
t.maxMotorForce = this.maxMotorForce;
t.motorSpeed = this.motorSpeed;
return t;
}
});
cc.PrismaticJoint = e.exports = s;
}), {
"../CCPhysicsTypes": 134
} ],
149: [ (function(t, e, i) {
var n = t("../CCPhysicsTypes").PTM_RATIO, r = t("../CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE, s = t("../CCPhysicsTypes").PHYSICS_ANGLE_TO_ANGLE, o = cc.Class({
name: "cc.RevoluteJoint",
extends: cc.Joint,
editor: !1,
properties: {
_maxMotorTorque: 0,
_motorSpeed: 0,
_enableLimit: !1,
_enableMotor: !1,
referenceAngle: {
default: 0,
tooltip: !1
},
lowerAngle: {
default: 0,
tooltip: !1
},
upperAngle: {
default: 0,
tooltip: !1
},
maxMotorTorque: {
tooltip: !1,
get: function() {
return this._maxMotorTorque;
},
set: function(t) {
this._maxMotorTorque = t;
this._joint && this._joint.SetMaxMotorTorque(t);
}
},
motorSpeed: {
tooltip: !1,
get: function() {
return this._motorSpeed;
},
set: function(t) {
this._motorSpeed = t;
this._joint && this._joint.SetMotorSpeed(t * r);
}
},
enableLimit: {
tooltip: !1,
get: function() {
return this._enableLimit;
},
set: function(t) {
this._enableLimit = t;
this._joint && this._joint.EnableLimit(t);
}
},
enableMotor: {
tooltip: !1,
get: function() {
return this._enableMotor;
},
set: function(t) {
this._enableMotor = t;
this._joint && this._joint.EnableMotor(t);
}
}
},
getJointAngle: function() {
return this._joint ? this._joint.GetJointAngle() * s : 0;
},
setLimits: function(t, e) {
if (this._joint) return this._joint.SetLimits(t * r, e * r);
},
_createJointDef: function() {
var t = new b2.RevoluteJointDef();
t.localAnchorA = new b2.Vec2(this.anchor.x / n, this.anchor.y / n);
t.localAnchorB = new b2.Vec2(this.connectedAnchor.x / n, this.connectedAnchor.y / n);
t.lowerAngle = this.upperAngle * r;
t.upperAngle = this.lowerAngle * r;
t.maxMotorTorque = this.maxMotorTorque;
t.motorSpeed = this.motorSpeed * r;
t.enableLimit = this.enableLimit;
t.enableMotor = this.enableMotor;
t.referenceAngle = this.referenceAngle * r;
return t;
}
});
cc.RevoluteJoint = e.exports = o;
}), {
"../CCPhysicsTypes": 134
} ],
150: [ (function(t, e, i) {
var n = t("../CCPhysicsTypes").PTM_RATIO, r = cc.Class({
name: "cc.RopeJoint",
extends: cc.Joint,
editor: !1,
properties: {
_maxLength: 1,
maxLength: {
tooltip: !1,
get: function() {
return this._maxLength;
},
set: function(t) {
this._maxLength = t;
this._joint && this._joint.SetMaxLength(t);
}
}
},
_createJointDef: function() {
var t = new b2.RopeJointDef();
t.localAnchorA = new b2.Vec2(this.anchor.x / n, this.anchor.y / n);
t.localAnchorB = new b2.Vec2(this.connectedAnchor.x / n, this.connectedAnchor.y / n);
t.maxLength = this.maxLength / n;
return t;
}
});
cc.RopeJoint = e.exports = r;
}), {
"../CCPhysicsTypes": 134
} ],
151: [ (function(t, e, i) {
var n = t("../CCPhysicsTypes").PTM_RATIO, r = t("../CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE, s = cc.Class({
name: "cc.WeldJoint",
extends: cc.Joint,
editor: !1,
properties: {
referenceAngle: {
default: 0,
tooltip: !1
},
_frequency: 0,
_dampingRatio: 0,
frequency: {
tooltip: !1,
get: function() {
return this._frequency;
},
set: function(t) {
this._frequency = t;
this._joint && this._joint.SetFrequency(t);
}
},
dampingRatio: {
tooltip: !1,
get: function() {
return this._dampingRatio;
},
set: function(t) {
this._dampingRatio = t;
this._joint && this._joint.SetDampingRatio(t);
}
}
},
_createJointDef: function() {
var t = new b2.WeldJointDef();
t.localAnchorA = new b2.Vec2(this.anchor.x / n, this.anchor.y / n);
t.localAnchorB = new b2.Vec2(this.connectedAnchor.x / n, this.connectedAnchor.y / n);
t.referenceAngle = this.referenceAngle * r;
t.frequencyHz = this.frequency;
t.dampingRatio = this.dampingRatio;
return t;
}
});
cc.WeldJoint = e.exports = s;
}), {
"../CCPhysicsTypes": 134
} ],
152: [ (function(t, e, i) {
var n = t("../CCPhysicsTypes").PTM_RATIO, r = t("../CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE, s = cc.Class({
name: "cc.WheelJoint",
extends: cc.Joint,
editor: !1,
properties: {
_maxMotorTorque: 0,
_motorSpeed: 0,
_enableMotor: !1,
_frequency: 2,
_dampingRatio: .7,
localAxisA: {
default: cc.v2(1, 0),
tooltip: !1
},
maxMotorTorque: {
tooltip: !1,
get: function() {
return this._maxMotorTorque;
},
set: function(t) {
this._maxMotorTorque = t;
this._joint && this._joint.SetMaxMotorTorque(t);
}
},
motorSpeed: {
tooltip: !1,
get: function() {
return this._motorSpeed;
},
set: function(t) {
this._motorSpeed = t;
this._joint && this._joint.SetMotorSpeed(t * r);
}
},
enableMotor: {
tooltip: !1,
get: function() {
return this._enableMotor;
},
set: function(t) {
this._enableMotor = t;
this._joint && this._joint.EnableMotor(t);
}
},
frequency: {
tooltip: !1,
get: function() {
return this._frequency;
},
set: function(t) {
this._frequency = t;
this._joint && this._joint.SetFrequency(t);
}
},
dampingRatio: {
tooltip: !1,
get: function() {
return this._dampingRatio;
},
set: function(t) {
this._dampingRatio = t;
this._joint && this._joint.SetDampingRatio(t);
}
}
},
_createJointDef: function() {
var t = new b2.WheelJointDef();
t.localAnchorA = new b2.Vec2(this.anchor.x / n, this.anchor.y / n);
t.localAnchorB = new b2.Vec2(this.connectedAnchor.x / n, this.connectedAnchor.y / n);
t.localAxisA = new b2.Vec2(this.localAxisA.x, this.localAxisA.y);
t.maxMotorTorque = this.maxMotorTorque;
t.motorSpeed = this.motorSpeed * r;
t.enableMotor = this.enableMotor;
t.dampingRatio = this.dampingRatio;
t.frequencyHz = this.frequency;
return t;
}
});
cc.WheelJoint = e.exports = s;
}), {
"../CCPhysicsTypes": 134
} ],
153: [ (function(t, e, i) {
var n = t("../CCPhysicsTypes").BodyType;
function r() {
this._point = new b2.Vec2();
this._isPoint = !1;
this._fixtures = [];
}
r.prototype.init = function(t) {
if (t) {
this._isPoint = !0;
this._point.x = t.x;
this._point.y = t.y;
} else this._isPoint = !1;
this._fixtures.length = 0;
};
r.prototype.ReportFixture = function(t) {
if (t.GetBody().GetType() === n.Dynamic) if (this._isPoint) {
if (t.TestPoint(this._point)) {
this._fixtures.push(t);
return !1;
}
} else this._fixtures.push(t);
return !0;
};
r.prototype.getFixture = function() {
return this._fixtures[0];
};
r.prototype.getFixtures = function() {
return this._fixtures;
};
cc.PhysicsAABBQueryCallback = e.exports = r;
}), {
"../CCPhysicsTypes": 134
} ],
154: [ (function(t, e, i) {
function n() {
this._contactFixtures = [];
}
n.prototype.setBeginContact = function(t) {
this._BeginContact = t;
};
n.prototype.setEndContact = function(t) {
this._EndContact = t;
};
n.prototype.setPreSolve = function(t) {
this._PreSolve = t;
};
n.prototype.setPostSolve = function(t) {
this._PostSolve = t;
};
n.prototype.BeginContact = function(t) {
if (this._BeginContact) {
var e = t.GetFixtureA(), i = t.GetFixtureB(), n = this._contactFixtures;
t._shouldReport = !1;
if (-1 !== n.indexOf(e) || -1 !== n.indexOf(i)) {
t._shouldReport = !0;
this._BeginContact(t);
}
}
};
n.prototype.EndContact = function(t) {
if (this._EndContact && t._shouldReport) {
t._shouldReport = !1;
this._EndContact(t);
}
};
n.prototype.PreSolve = function(t, e) {
this._PreSolve && t._shouldReport && this._PreSolve(t, e);
};
n.prototype.PostSolve = function(t, e) {
this._PostSolve && t._shouldReport && this._PostSolve(t, e);
};
n.prototype.registerContactFixture = function(t) {
this._contactFixtures.push(t);
};
n.prototype.unregisterContactFixture = function(t) {
cc.js.array.remove(this._contactFixtures, t);
};
cc.PhysicsContactListener = e.exports = n;
}), {} ],
155: [ (function(t, e, i) {
var n = t("../CCPhysicsTypes").PTM_RATIO, r = cc.v2(), s = cc.Color.GREEN, o = cc.Color.RED;
function a(t) {
b2.Draw.call(this);
this._drawer = t;
this._xf = this._dxf = new b2.Transform();
}
cc.js.extend(a, b2.Draw);
cc.js.mixin(a.prototype, {
_DrawPolygon: function(t, e) {
for (var i = this._drawer, s = 0; s < e; s++) {
b2.Transform.MulXV(this._xf, t[s], r);
var o = r.x * n, a = r.y * n;
0 === s ? i.moveTo(o, a) : i.lineTo(o, a);
}
i.close();
},
DrawPolygon: function(t, e, i) {
this._applyStrokeColor(i);
this._DrawPolygon(t, e);
this._drawer.stroke();
},
DrawSolidPolygon: function(t, e, i) {
this._applyFillColor(i);
this._DrawPolygon(t, e);
this._drawer.fill();
this._drawer.stroke();
},
_DrawCircle: function(t, e) {
var i = this._xf.p;
this._drawer.circle((t.x + i.x) * n, (t.y + i.y) * n, e * n);
},
DrawCircle: function(t, e, i) {
this._applyStrokeColor(i);
this._DrawCircle(t, e);
this._drawer.stroke();
},
DrawSolidCircle: function(t, e, i, n) {
this._applyFillColor(n);
this._DrawCircle(t, e);
this._drawer.fill();
},
DrawSegment: function(t, e, i) {
var s = this._drawer;
if (t.x !== e.x || t.y !== e.y) {
this._applyStrokeColor(i);
b2.Transform.MulXV(this._xf, t, r);
s.moveTo(r.x * n, r.y * n);
b2.Transform.MulXV(this._xf, e, r);
s.lineTo(r.x * n, r.y * n);
s.stroke();
} else {
this._applyFillColor(i);
this._DrawCircle(t, 2 / n);
s.fill();
}
},
DrawTransform: function(t) {
var e = this._drawer;
e.strokeColor = o;
r.x = r.y = 0;
b2.Transform.MulXV(t, r, r);
e.moveTo(r.x * n, r.y * n);
r.x = 1;
r.y = 0;
b2.Transform.MulXV(t, r, r);
e.lineTo(r.x * n, r.y * n);
e.stroke();
e.strokeColor = s;
r.x = r.y = 0;
b2.Transform.MulXV(t, r, r);
e.moveTo(r.x * n, r.y * n);
r.x = 0;
r.y = 1;
b2.Transform.MulXV(t, r, r);
e.lineTo(r.x * n, r.y * n);
e.stroke();
},
DrawPoint: function(t, e, i) {},
_applyStrokeColor: function(t) {
var e = this._drawer.strokeColor;
e.r = 255 * t.r;
e.g = 255 * t.g;
e.b = 255 * t.b;
e.a = 150;
this._drawer.strokeColor = e;
},
_applyFillColor: function(t) {
var e = this._drawer.fillColor;
e.r = 255 * t.r;
e.g = 255 * t.g;
e.b = 255 * t.b;
e.a = 150;
this._drawer.fillColor = e;
},
PushTransform: function(t) {
this._xf = t;
},
PopTransform: function() {
this._xf = this._dxf;
}
});
e.exports = a;
}), {
"../CCPhysicsTypes": 134
} ],
156: [ (function(t, e, i) {
function n() {
this._type = 0;
this._fixtures = [];
this._points = [];
this._normals = [];
this._fractions = [];
}
n.prototype.init = function(t) {
this._type = t;
this._fixtures.length = 0;
this._points.length = 0;
this._normals.length = 0;
this._fractions.length = 0;
};
n.prototype.ReportFixture = function(t, e, i, n) {
if (0 === this._type) {
this._fixtures[0] = t;
this._points[0] = e;
this._normals[0] = i;
this._fractions[0] = n;
return n;
}
this._fixtures.push(t);
this._points.push(cc.v2(e));
this._normals.push(cc.v2(i));
this._fractions.push(n);
return 1 === this._type ? 0 : this._type >= 2 ? 1 : n;
};
n.prototype.getFixtures = function() {
return this._fixtures;
};
n.prototype.getPoints = function() {
return this._points;
};
n.prototype.getNormals = function() {
return this._normals;
};
n.prototype.getFractions = function() {
return this._fractions;
};
cc.PhysicsRayCastCallback = e.exports = n;
}), {} ],
157: [ (function(t, e, i) {
e.exports = {
getWorldRotation: function(t) {
for (var e = t.rotationX, i = t.parent; i.parent; ) {
e += i.rotationX;
i = i.parent;
}
return e;
},
getWorldScale: function(t) {
for (var e = t.scaleX, i = t.scaleY, n = t.parent; n.parent; ) {
e *= n.scaleX;
i *= n.scaleY;
n = n.parent;
}
return cc.v2(e, i);
},
convertToNodeRotation: function(t, e) {
e -= t.rotationX;
for (var i = t.parent; i.parent; ) {
e -= i.rotationX;
i = i.parent;
}
return e;
}
};
}), {} ],
158: [ (function(t, e, i) {}), {
"../event-manager": 100,
"../platform/js": 180,
"./CCMacro": 165,
"./CCSys": 169
} ],
159: [ (function(i, n, r) {
i("../assets/CCAsset");
var s = i("./utils").callInNextTick, o = i("../load-pipeline/CCLoader"), a = i("../load-pipeline/pack-downloader"), c = i("../load-pipeline/auto-release-utils"), h = i("../utils/decode-uuid"), l = i("../load-pipeline/md5-pipe"), u = i("../load-pipeline/subpackage-pipe"), _ = i("./js"), f = "", d = "", m = _.createMap(!0);
function p(t) {
return t && (t.constructor === cc.SceneAsset || t instanceof cc.Scene);
}
function v(t, e) {
this.url = t;
this.type = e;
}
var y = {
loadAsset: function(i, n, r) {
if ("string" !== ("object" === (e = typeof i) ? t(i) : e)) return s(n, new Error("[AssetLibrary] uuid must be string"), null);
var a = {
uuid: i,
type: "uuid"
};
r && r.existingAsset && (a.existingAsset = r.existingAsset);
o.load(a, (function(t, e) {
if (t || !e) t = new Error("[AssetLibrary] loading JSON or dependencies failed: " + (t ? t.message : "Unknown error")); else {
if (e.constructor === cc.SceneAsset) {
var r = cc.loader._getReferenceKey(i);
e.scene.dependAssets = c.getDependsRecursively(r);
}
if (p(e)) {
var s = cc.loader._getReferenceKey(i);
o.removeItem(s);
}
}
n && n(t, e);
}));
},
getLibUrlNoExt: function(t, e) {
t = h(t);
return (e ? d + "assets/" : f) + t.slice(0, 2) + "/" + t;
},
_queryAssetInfoInEditor: function(t, e) {
0;
},
_getAssetInfoInRuntime: function(t, e) {
e = e || {
url: null,
raw: !1
};
var i = m[t];
if (i && !_.isChildClassOf(i.type, cc.Asset)) {
e.url = d + i.url;
e.raw = !0;
} else {
e.url = this.getLibUrlNoExt(t) + ".json";
e.raw = !1;
}
return e;
},
_uuidInSettings: function(t) {
return t in m;
},
queryAssetInfo: function(t, e) {
var i = this._getAssetInfoInRuntime(t);
e(null, i.url, i.raw);
},
parseUuidInEditor: function(t) {},
loadJson: function(t, e) {
var i = "" + (new Date().getTime() + Math.random()), n = {
uuid: i,
type: "uuid",
content: t,
skips: [ o.assetLoader.id, o.downloader.id ]
};
o.load(n, (function(t, n) {
if (t) t = new Error("[AssetLibrary] loading JSON or dependencies failed: " + t.message); else {
if (n.constructor === cc.SceneAsset) {
var r = cc.loader._getReferenceKey(i);
n.scene.dependAssets = c.getDependsRecursively(r);
}
if (p(n)) {
var s = cc.loader._getReferenceKey(i);
o.removeItem(s);
}
}
n._uuid = "";
e && e(t, n);
}));
},
getAssetByUuid: function(t) {
return y._uuidToAsset[t] || null;
},
init: function(t) {
0;
var e = t.libraryPath;
e = e.replace(/\\/g, "/");
f = cc.path.stripSep(e) + "/";
d = t.rawAssetsBase;
if (t.subpackages) {
var i = new u(t.subpackages);
cc.loader.insertPipeAfter(cc.loader.assetLoader, i);
cc.loader.subPackPipe = i;
}
var n = t.md5AssetsMap;
if (n && n.import) {
var r = 0, s = 0, c = _.createMap(!0), p = n.import;
for (r = 0; r < p.length; r += 2) c[s = h(p[r])] = p[r + 1];
var y = _.createMap(!0);
p = n["raw-assets"];
for (r = 0; r < p.length; r += 2) y[s = h(p[r])] = p[r + 1];
var g = new l(c, y, f);
cc.loader.insertPipeAfter(cc.loader.assetLoader, g);
cc.loader.md5Pipe = g;
}
var x = o._resources;
x.reset();
var C = t.rawAssets;
if (C) for (var A in C) {
var b = C[A];
for (var s in b) {
var S = b[s], T = S[0], w = S[1], E = cc.js._getClassById(w);
if (E) {
m[s] = new v(A + "/" + T, E);
if ("assets" === A) {
var B = cc.path.extname(T);
B && (T = T.slice(0, -B.length));
var M = 1 === S[2];
x.add(T, s, E, !M);
}
} else cc.error("Cannot get", w);
}
}
t.packedAssets && a.initPacks(t.packedAssets);
cc.url._init(t.mountPaths && t.mountPaths.assets || d + "assets");
},
_uuidToAsset: {}
};
n.exports = cc.AssetLibrary = y;
}), {
"../assets/CCAsset": 33,
"../load-pipeline/CCLoader": 111,
"../load-pipeline/auto-release-utils": 115,
"../load-pipeline/md5-pipe": 122,
"../load-pipeline/pack-downloader": 123,
"../load-pipeline/subpackage-pipe": 126,
"../utils/decode-uuid": 237,
"./js": 180,
"./utils": 184
} ],
160: [ (function(i, n, r) {
var s = i("./js"), o = i("./CCEnum"), a = i("./utils"), c = (a.isPlainEmptyObj_DEV, 
a.cloneable_DEV, i("./attribute")), h = c.DELIMETER, l = c.getTypeChecker, u = i("./preprocess-class");
i("./requiring-frame");
var _ = [ "name", "extends", "mixins", "ctor", "__ctor__", "properties", "statics", "editor", "__ES6__" ];
function f(t, e) {
t.indexOf(e) < 0 && t.push(e);
}
var d = {
datas: null,
push: function(t) {
if (this.datas) this.datas.push(t); else {
this.datas = [ t ];
var e = this;
setTimeout((function() {
e.init();
}), 0);
}
},
init: function() {
var i = this.datas;
if (i) {
for (var n = 0; n < i.length; ++n) {
var r = i[n], o = r.cls, a = r.props;
"function" === ("object" === (e = typeof a) ? t(a) : e) && (a = a());
var c = s.getClassName(o);
a ? M(o, c, a, o.$super, r.mixins) : cc.errorID(3633, c);
}
this.datas = null;
}
}
};
function m(t, e) {
0;
f(t.__props__, e);
}
var p = [];
function v(t, e, i, n, r) {
var s = n.default;
0;
c.setClassAttr(t, i, "default", s);
m(t, i);
var o = R(t, n, e, i, !1);
if (o) {
for (var a = p, h = 0; h < o.length; h++) {
var l = o[h];
c.attr(t, i, l);
l._onAfterProp && a.push(l._onAfterProp);
}
for (var u = 0; u < a.length; u++) a[u](t, i);
p.length = 0;
o.length = 0;
}
}
function y(t, e, i, n, r) {
var o = n.get, a = n.set, h = t.prototype, l = Object.getOwnPropertyDescriptor(h, i), u = !l;
if (o) {
0;
for (var _ = R(t, n, e, i, !0), f = 0; f < _.length; f++) c.attr(t, i, _[f]);
_.length = 0;
c.setClassAttr(t, i, "serializable", !1);
0;
r || s.get(h, i, o, u, u);
0;
}
if (a) {
if (!r) {
0;
s.set(h, i, a, u, u);
}
0;
}
}
function g(i) {
return "function" === ("object" === (e = typeof i) ? t(i) : e) ? i() : i;
}
function x(t, e, i) {
for (var n in e) t.hasOwnProperty(n) || i && !i(n) || Object.defineProperty(t, n, s.getPropertyDescriptor(e, n));
}
function C(t, e, i, n) {
var r, o, a = n.__ctor__, h = n.ctor, l = n.__ES6__;
if (l) {
r = [ h ];
o = h;
} else {
r = a ? [ a ] : (function(t, e, i) {
function n(t) {
return D._isCCClass(t) ? t.__ctors__ || [] : [ t ];
}
for (var r = [], s = [ t ].concat(e), o = 0; o < s.length; o++) {
var a = s[o];
if (a) for (var c = n(a), h = 0; h < c.length; h++) f(r, c[h]);
}
var l = i.ctor;
l && r.push(l);
return r;
})(e, i, n);
o = w(r, e, t, n);
s.value(o, "extend", (function(t) {
t.extends = this;
return D(t);
}), !0);
}
s.value(o, "__ctors__", r.length > 0 ? r : null, !0);
var u = o.prototype;
if (e) {
if (!l) {
s.extend(o, e);
u = o.prototype;
}
o.$super = e;
0;
}
if (i) {
for (var _ = i.length - 1; _ >= 0; _--) {
var d = i[_];
x(u, d.prototype);
x(o, d, (function(t) {
return d.hasOwnProperty(t) && !0;
}));
D._isCCClass(d) && x(c.getClassAttrs(o).constructor.prototype, c.getClassAttrs(d).constructor.prototype);
}
u.constructor = o;
}
l || (u.__initProps__ = T);
s.setClassName(t, o);
return o;
}
function A(t) {
for (var e = s.getClassName(t), i = t.constructor, n = "new " + e + "(", r = 0; r < i.__props__.length; r++) {
var o = t[i.__props__[r]];
0;
n += o;
r < i.__props__.length - 1 && (n += ",");
}
return n + ")";
}
function b(t) {
return JSON.stringify(t).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
}
var S = /^[A-Za-z_$][0-9A-Za-z_$]*$/;
function T(i) {
var n = c.getClassAttrs(i), r = i.__props__;
if (null === r) {
d.init();
r = i.__props__;
}
var s = (function(i, n) {
for (var r = [], s = "", o = 0; o < n.length; o++) {
var a = n[o], c = a + h + "default";
if (c in i) {
var l, u;
l = S.test(a) ? "this." + a + "=" : "this[" + b(a) + "]=";
var _ = i[c];
if ("object" === ("object" == (e = typeof _) ? t(_) : e) && _) u = _ instanceof cc.ValueType ? A(_) : Array.isArray(_) ? "[]" : "{}"; else if ("function" === ("object" == (e = typeof _) ? t(_) : e)) {
var f = r.length;
r.push(_);
u = "F[" + f + "]()";
} else u = "string" === ("object" == (e = typeof _) ? t(_) : e) ? b(_) : _;
s += l = l + u + ";\n";
}
}
return 0 === r.length ? Function(s) : Function("F", "return (function(){\n" + s + "})")(r);
})(n, r);
i.prototype.__initProps__ = s;
s.call(this);
}
var w = function(t, e, i, n) {
var r = "return function CCClass(){\n";
e && B(e, n, i) && (r += "this._super=null;\n");
r += "this.__initProps__(CCClass);\n";
var s = t.length;
if (s > 0) {
0;
var o = "].apply(this,arguments);\n";
if (1 === s) r += "CCClass.__ctors__[0" + o; else {
r += "var cs=CCClass.__ctors__;\n";
for (var a = 0; a < s; a++) r += "cs[" + a + o;
}
0;
}
r += "}";
return Function(r)();
};
var E = /xyz/.test((function() {
xyz;
})) ? /\b\._super\b/ : /.*/;
/xyz/.test((function() {
xyz;
}));
function B(i, n, r) {
var o = !1;
for (var a in n) if (!(_.indexOf(a) >= 0)) {
var c = n[a];
if ("function" === ("object" === (e = typeof c) ? t(c) : e)) {
var h = s.getPropertyDescriptor(i.prototype, a);
if (h) {
var l = h.value;
if ("function" === ("object" === (e = typeof l) ? t(l) : e)) {
if (E.test(c)) {
o = !0;
n[a] = (function(t, e) {
return function() {
var i = this._super;
this._super = t;
var n = e.apply(this, arguments);
this._super = i;
return n;
};
})(l, c);
}
continue;
}
}
0;
}
}
return o;
}
function M(t, e, i, n, r, s) {
t.__props__ = [];
n && n.__props__ && (t.__props__ = n.__props__.slice());
if (r) for (var o = 0; o < r.length; ++o) {
var a = r[o];
a.__props__ && (t.__props__ = t.__props__.concat(a.__props__.filter((function(e) {
return t.__props__.indexOf(e) < 0;
}))));
}
if (i) {
u.preprocessAttrs(i, e, t, s);
for (var l in i) {
var _ = i[l];
"default" in _ ? v(t, e, l, _) : y(t, e, l, _, s);
}
}
var f = c.getClassAttrs(t);
t.__values__ = t.__props__.filter((function(t) {
return !1 !== f[t + h + "serializable"];
}));
}
function D(i) {
var n = (i = i || {}).name, r = i.extends, o = i.mixins, a = (function(t, e, i, n) {
var r = cc.Component, o = cc._RF.peek();
if (o && s.isChildClassOf(e, r)) {
if (s.isChildClassOf(o.cls, r)) {
cc.errorID(3615);
return null;
}
t = t || o.script;
}
var a = C(t, e, i, n);
if (o) if (s.isChildClassOf(e, r)) {
var c = o.uuid;
c && s._setClassId(c, a);
o.cls = a;
} else s.isChildClassOf(o.cls, r) || (o.cls = a);
return a;
})(n, r, o, i);
n || (n = cc.js.getClassName(a));
a._sealed = !0;
r && (r._sealed = !1);
var c = i.properties;
if ("function" === ("object" === (e = typeof c) ? t(c) : e) || r && null === r.__props__ || o && o.some((function(t) {
return null === t.__props__;
}))) {
d.push({
cls: a,
props: c,
mixins: o
});
a.__props__ = a.__values__ = null;
} else M(a, n, c, r, i.mixins, i.__ES6__);
var h = i.statics;
if (h) {
var l;
0;
for (l in h) a[l] = h[l];
}
for (var f in i) if (!(_.indexOf(f) >= 0)) {
var m = i[f];
u.validateMethodWithProps(m, f, n, a, r) && s.value(a.prototype, f, m, !0, !0);
}
var p = i.editor;
p && s.isChildClassOf(r, cc.Component) && cc.Component._registerEditorProps(a, p);
return a;
}
D._isCCClass = function(t) {
return t && t.hasOwnProperty("__ctors__");
};
D._fastDefine = function(t, e, i) {
s.setClassName(t, e);
for (var n = e.__props__ = e.__values__ = Object.keys(i), r = c.getClassAttrsProto(e), o = 0; o < n.length; o++) {
var a = n[o];
r[a + h + "visible"] = !1;
r[a + h + "default"] = i[a];
}
};
D.Attr = c;
D.attr = c.attr;
D.getInheritanceChain = function(t) {
for (var e = []; t = s.getSuper(t); ) t !== Object && e.push(t);
return e;
};
var I = {
Integer: "Number",
Float: "Number",
Boolean: "Boolean",
String: "String"
}, P = [];
function R(i, n, r, s, a) {
var u = null, _ = "";
function f() {
_ = s + h;
return u = c.getClassAttrsProto(i);
}
P.length = 0;
var d = P, m = n.type;
if (m) {
var p = I[m];
if (p) d.push({
type: m,
_onAfterProp: l(p, "cc." + m)
}); else if ("Object" === m) 0; else if (m === c.ScriptUuid) {
var v = c.ObjectType(cc.ScriptAsset);
v.type = "Script";
d.push(v);
} else "object" === ("object" === (e = typeof m) ? t(m) : e) ? o.isEnum(m) && d.push({
type: "Enum",
enumList: o.getList(m)
}) : "function" === ("object" === (e = typeof m) ? t(m) : e) && (n.url ? d.push({
type: "Object",
ctor: m,
_onAfterProp: l("String", "cc.String")
}) : d.push(n._short ? {
type: "Object",
ctor: m
} : c.ObjectType(m)));
}
function y(i, r) {
if (i in n) {
var s = n[i];
("object" === (e = typeof s) ? t(s) : e) === r && ((u || f())[_ + i] = s);
}
}
n.editorOnly && ((u || f())[_ + "editorOnly"] = !0);
0;
n.url && ((u || f())[_ + "saveUrlAsAsset"] = !0);
!1 === n.serializable && ((u || f())[_ + "serializable"] = !1);
y("formerlySerializedAs", "string");
0;
var g = n.range;
if (g) if (Array.isArray(g)) if (g.length >= 2) {
(u || f())[_ + "min"] = g[0];
u[_ + "max"] = g[1];
g.length > 2 && (u[_ + "step"] = g[2]);
} else 0; else 0;
y("min", "number");
y("max", "number");
y("step", "number");
return d;
}
cc.Class = D;
n.exports = {
isArray: function(t) {
t = g(t);
return Array.isArray(t);
},
fastDefine: D._fastDefine,
getNewValueTypeCode: A,
IDENTIFIER_RE: S,
escapeForJS: b,
getDefault: g
};
0;
}), {
"./CCEnum": 162,
"./attribute": 172,
"./js": 180,
"./preprocess-class": 181,
"./requiring-frame": 182,
"./utils": 184
} ],
161: [ (function(i, n, r) {
i("./CCClass");
var s = i("./preprocess-class"), o = i("./js"), a = "__ccclassCache__";
function c(t) {
return t;
}
function h(t, e) {
return t[e] || (t[e] = {});
}
function l(i) {
return function(n) {
return "function" === ("object" === (e = typeof n) ? t(n) : e) ? i(n) : function(t) {
return i(t, n);
};
};
}
function u(t, e, i) {
return function(t) {
0;
return function(i) {
return e(i, t);
};
};
}
var _ = u.bind(null, !1);
function f(t) {
return u.bind(null, !1);
}
var d = f(), m = f();
function p(t, e) {
0;
return h(t, a);
}
function v(i, n, r, a, c, h) {
var l;
a && (l = (l = s.getFullFormOfProperty(a)) || a);
var u = n[r], _ = o.mixin(u || {}, l || {});
if (c && (c.get || c.set)) {
c.get && (_.get = c.get);
c.set && (_.set = c.set);
} else {
0;
var f = void 0;
if (c) {
if (c.initializer) {
f = (function(i) {
var n;
try {
n = i();
} catch (t) {
return i;
}
return "object" !== ("object" == (e = typeof n) ? t(n) : e) || null === n ? n : i;
})(c.initializer);
!0;
}
} else {
var d = h.default || (h.default = (function(t) {
var e;
try {
e = new t();
} catch (t) {
return {};
}
return e;
})(i));
if (d.hasOwnProperty(r)) {
f = d[r];
!0;
}
}
0;
_.default = f;
}
n[r] = _;
}
var y = l((function(t, e) {
var i = o.getSuper(t);
i === Object && (i = null);
var n = {
name: e,
extends: i,
ctor: t,
__ES6__: !0
}, r = t[a];
if (r) {
var s = r.proto;
s && o.mixin(n, s);
t[a] = void 0;
}
return cc.Class(n);
}));
function g(t, e, i) {
return t((function(t, n) {
var r = p(t);
if (r) {
var s = void 0 !== i ? i : n;
h(h(r, "proto"), "editor")[e] = s;
}
}), e);
}
function x(t) {
return t(c);
}
var C = x(l), A = g(_, "requireComponent"), b = x(d), S = g(m, "executionOrder"), T = x(l), w = x(l), E = x(d), B = x(d), M = x(d);
cc._decorator = n.exports = {
ccclass: y,
property: function(i, n, r) {
var s = null;
function o(t, e, i) {
var n = p(t.constructor);
if (n) {
var r = h(h(n, "proto"), "properties");
v(t.constructor, r, e, s, i, n);
}
}
if ("undefined" === ("object" == (e = typeof n) ? t(n) : e)) {
s = i;
return o;
}
o(i, n, r);
},
executeInEditMode: C,
requireComponent: A,
menu: b,
executionOrder: S,
disallowMultiple: T,
playOnFocus: w,
inspector: E,
icon: B,
help: M,
mixins: function() {
for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
return function(e) {
var i = p(e);
i && (h(i, "proto").mixins = t);
};
}
};
}), {
"./CCClass": 160,
"./js": 180,
"./preprocess-class": 181,
"./utils": 184
} ],
162: [ (function(i, n, r) {
var s = i("./js");
function o(i) {
if ("__enums__" in i) return i;
s.value(i, "__enums__", null, !0);
for (var n = -1, r = Object.keys(i), o = 0; o < r.length; o++) {
var a = r[o], c = i[a];
if (-1 === c) {
c = ++n;
i[a] = c;
} else if ("number" === ("object" === (e = typeof c) ? t(c) : e)) n = c; else if ("string" === ("object" === (e = typeof c) ? t(c) : e) && Number.isInteger(parseFloat(a))) continue;
var h = "" + c;
if (a !== h) {
0;
s.value(i, h, a);
}
}
return i;
}
o.isEnum = function(t) {
return t && t.hasOwnProperty("__enums__");
};
o.getList = function(t) {
if (t.__enums__) return t.__enums__;
var e = t.__enums__ = [];
for (var i in t) {
var n = t[i];
Number.isInteger(n) && e.push({
name: i,
value: n
});
}
e.sort((function(t, e) {
return t.value - e.value;
}));
return e;
};
n.exports = cc.Enum = o;
}), {
"./js": 180
} ],
163: [ (function(t, e, i) {
var n = t("../event-manager"), r = t("./CCInputManager"), s = void 0;
cc.Acceleration = function(t, e, i, n) {
this.x = t || 0;
this.y = e || 0;
this.z = i || 0;
this.timestamp = n || 0;
};
r.setAccelerometerEnabled = function(t) {
var e = this;
if (e._accelEnabled !== t) {
e._accelEnabled = t;
var i = cc.director.getScheduler();
i.enableForTarget(e);
if (e._accelEnabled) {
e._registerAccelerometerEvent();
e._accelCurTime = 0;
i.scheduleUpdate(e);
} else {
e._unregisterAccelerometerEvent();
e._accelCurTime = 0;
i.unscheduleUpdate(e);
}
jsb.device.setMotionEnabled(t);
}
};
r.setAccelerometerInterval = function(t) {
if (this._accelInterval !== t) {
this._accelInterval = t;
jsb.device.setMotionInterval(t);
}
};
r._registerKeyboardEvent = function() {
cc.game.canvas.addEventListener("keydown", (function(t) {
n.dispatchEvent(new cc.Event.EventKeyboard(t.keyCode, !0));
t.stopPropagation();
t.preventDefault();
}), !1);
cc.game.canvas.addEventListener("keyup", (function(t) {
n.dispatchEvent(new cc.Event.EventKeyboard(t.keyCode, !1));
t.stopPropagation();
t.preventDefault();
}), !1);
};
r._registerAccelerometerEvent = function() {
var t = window, e = this;
e._acceleration = new cc.Acceleration();
e._accelDeviceEvent = t.DeviceMotionEvent || t.DeviceOrientationEvent;
cc.sys.browserType === cc.sys.BROWSER_TYPE_MOBILE_QQ && (e._accelDeviceEvent = window.DeviceOrientationEvent);
var i = e._accelDeviceEvent === t.DeviceMotionEvent ? "devicemotion" : "deviceorientation", n = navigator.userAgent;
(/Android/.test(n) || /Adr/.test(n) && cc.sys.browserType === cc.BROWSER_TYPE_UC) && (e._minus = -1);
s = e.didAccelerate.bind(e);
t.addEventListener(i, s, !1);
};
r._unregisterAccelerometerEvent = function() {
var t = window, e = this._accelDeviceEvent === t.DeviceMotionEvent ? "devicemotion" : "deviceorientation";
s && t.removeEventListener(e, s, !1);
};
r.didAccelerate = function(t) {
var e = this, i = window;
if (e._accelEnabled) {
var n = e._acceleration, r = void 0, s = void 0, o = void 0;
if (e._accelDeviceEvent === window.DeviceMotionEvent) {
var a = t.accelerationIncludingGravity;
r = e._accelMinus * a.x * .1;
s = e._accelMinus * a.y * .1;
o = .1 * a.z;
} else {
r = t.gamma / 90 * .981;
s = -t.beta / 90 * .981;
o = t.alpha / 90 * .981;
}
if (cc.view._isRotated) {
var c = r;
r = -s;
s = c;
}
n.x = r;
n.y = s;
n.z = o;
n.timestamp = t.timeStamp || Date.now();
var h = n.x;
if (90 === i.orientation) {
n.x = -n.y;
n.y = h;
} else if (-90 === i.orientation) {
n.x = n.y;
n.y = -h;
} else if (180 === i.orientation) {
n.x = -n.x;
n.y = -n.y;
}
if (cc.sys.os === cc.sys.OS_ANDROID && cc.sys.browserType !== cc.sys.BROWSER_TYPE_MOBILE_QQ) {
n.x = -n.x;
n.y = -n.y;
}
}
};
}), {
"../event-manager": 100,
"./CCInputManager": 164
} ],
164: [ (function(t, e, i) {
var n = t("./CCMacro"), r = t("./CCSys"), s = t("../event-manager"), o = n.TOUCH_TIMEOUT, a = cc.v2(), c = {
_mousePressed: !1,
_isRegisterEvent: !1,
_preTouchPoint: cc.v2(0, 0),
_prevMousePoint: cc.v2(0, 0),
_preTouchPool: [],
_preTouchPoolPointer: 0,
_touches: [],
_touchesIntegerDict: {},
_indexBitsUsed: 0,
_maxTouches: 8,
_accelEnabled: !1,
_accelInterval: .2,
_accelMinus: 1,
_accelCurTime: 0,
_acceleration: null,
_accelDeviceEvent: null,
_getUnUsedIndex: function() {
for (var t = this._indexBitsUsed, e = cc.sys.now(), i = 0; i < this._maxTouches; i++) {
if (!(1 & t)) {
this._indexBitsUsed |= 1 << i;
return i;
}
var n = this._touches[i];
if (e - n._lastModified > o) {
this._removeUsedIndexBit(i);
delete this._touchesIntegerDict[n.getID()];
return i;
}
t >>= 1;
}
return -1;
},
_removeUsedIndexBit: function(t) {
if (!(t < 0 || t >= this._maxTouches)) {
var e = 1 << t;
e = ~e;
this._indexBitsUsed &= e;
}
},
_glView: null,
handleTouchesBegin: function(t) {
for (var e = void 0, i = void 0, n = void 0, o = [], a = this._touchesIntegerDict, c = r.now(), h = 0, l = t.length; h < l; h++) if (null == a[n = (e = t[h]).getID()]) {
var u = this._getUnUsedIndex();
if (-1 === u) {
cc.logID(2300, u);
continue;
}
(i = this._touches[u] = new cc.Touch(e._point.x, e._point.y, e.getID()))._lastModified = c;
i._setPrevPoint(e._prevPoint);
a[n] = u;
o.push(i);
}
if (o.length > 0) {
this._glView._convertTouchesWithScale(o);
var _ = new cc.Event.EventTouch(o);
_._eventCode = cc.Event.EventTouch.BEGAN;
s.dispatchEvent(_);
}
},
handleTouchesMove: function(t) {
for (var e = void 0, i = void 0, n = void 0, o = [], a = this._touches, c = r.now(), h = 0, l = t.length; h < l; h++) {
n = (e = t[h]).getID();
if (null != (i = this._touchesIntegerDict[n]) && a[i]) {
a[i]._setPoint(e._point);
a[i]._setPrevPoint(e._prevPoint);
a[i]._lastModified = c;
o.push(a[i]);
}
}
if (o.length > 0) {
this._glView._convertTouchesWithScale(o);
var u = new cc.Event.EventTouch(o);
u._eventCode = cc.Event.EventTouch.MOVED;
s.dispatchEvent(u);
}
},
handleTouchesEnd: function(t) {
var e = this.getSetOfTouchesEndOrCancel(t);
if (e.length > 0) {
this._glView._convertTouchesWithScale(e);
var i = new cc.Event.EventTouch(e);
i._eventCode = cc.Event.EventTouch.ENDED;
s.dispatchEvent(i);
}
this._preTouchPool.length = 0;
},
handleTouchesCancel: function(t) {
var e = this.getSetOfTouchesEndOrCancel(t);
if (e.length > 0) {
this._glView._convertTouchesWithScale(e);
var i = new cc.Event.EventTouch(e);
i._eventCode = cc.Event.EventTouch.CANCELLED;
s.dispatchEvent(i);
}
this._preTouchPool.length = 0;
},
getSetOfTouchesEndOrCancel: function(t) {
for (var e = void 0, i = void 0, n = void 0, r = [], s = this._touches, o = this._touchesIntegerDict, a = 0, c = t.length; a < c; a++) if (null != (i = o[n = (e = t[a]).getID()]) && s[i]) {
s[i]._setPoint(e._point);
s[i]._setPrevPoint(e._prevPoint);
r.push(s[i]);
this._removeUsedIndexBit(i);
delete o[n];
}
return r;
},
getHTMLElementPosition: function(t) {
0;
var e = document.documentElement, i = window.pageXOffset - e.clientLeft, n = window.pageYOffset - e.clientTop;
if (t.getBoundingClientRect) {
var r = t.getBoundingClientRect();
return {
left: r.left + i,
top: r.top + n,
width: r.width,
height: r.height
};
}
return t instanceof HTMLCanvasElement ? {
left: i,
top: n,
width: t.width,
height: t.height
} : {
left: i,
top: n,
width: parseInt(t.style.width),
height: parseInt(t.style.height)
};
},
getPreTouch: function(t) {
for (var e = null, i = this._preTouchPool, n = t.getID(), r = i.length - 1; r >= 0; r--) if (i[r].getID() === n) {
e = i[r];
break;
}
e || (e = t);
return e;
},
setPreTouch: function(t) {
for (var e = !1, i = this._preTouchPool, n = t.getID(), r = i.length - 1; r >= 0; r--) if (i[r].getID() === n) {
i[r] = t;
e = !0;
break;
}
if (!e) if (i.length <= 50) i.push(t); else {
i[this._preTouchPoolPointer] = t;
this._preTouchPoolPointer = (this._preTouchPoolPointer + 1) % 50;
}
},
getTouchByXY: function(t, e, i) {
var n = this._preTouchPoint, r = this._glView.convertToLocationInView(t, e, i), s = new cc.Touch(r.x, r.y, 0);
s._setPrevPoint(n.x, n.y);
n.x = r.x;
n.y = r.y;
return s;
},
getMouseEvent: function(t, e, i) {
var n = this._prevMousePoint, r = new cc.Event.EventMouse(i);
r._setPrevCursor(n.x, n.y);
n.x = t.x;
n.y = t.y;
this._glView._convertMouseToLocationInView(n, e);
r.setLocation(n.x, n.y);
return r;
},
getPointByEvent: function(t, e) {
if (null != t.pageX) return {
x: t.pageX,
y: t.pageY
};
e.left -= document.body.scrollLeft;
e.top -= document.body.scrollTop;
return {
x: t.clientX,
y: t.clientY
};
},
getTouchesByEvent: function(t, e) {
for (var i = [], n = this._glView, s = void 0, o = void 0, c = void 0, h = this._preTouchPoint, l = t.changedTouches.length, u = 0; u < l; u++) if (s = t.changedTouches[u]) {
var _ = void 0;
_ = r.BROWSER_TYPE_FIREFOX === r.browserType ? n.convertToLocationInView(s.pageX, s.pageY, e, a) : n.convertToLocationInView(s.clientX, s.clientY, e, a);
if (null != s.identifier) {
o = new cc.Touch(_.x, _.y, s.identifier);
c = this.getPreTouch(o).getLocation();
o._setPrevPoint(c.x, c.y);
this.setPreTouch(o);
} else (o = new cc.Touch(_.x, _.y))._setPrevPoint(h.x, h.y);
h.x = _.x;
h.y = _.y;
i.push(o);
}
return i;
},
registerSystemEvent: function(t) {
if (!this._isRegisterEvent) {
this._glView = cc.view;
var e = this, i = r.isMobile, n = "mouse" in r.capabilities, o = "touches" in r.capabilities;
0;
if (n) {
if (!i) {
window.addEventListener("mousedown", (function() {
e._mousePressed = !0;
}), !1);
window.addEventListener("mouseup", (function(i) {
if (e._mousePressed) {
e._mousePressed = !1;
var n = e.getHTMLElementPosition(t), r = e.getPointByEvent(i, n);
if (!cc.rect(n.left, n.top, n.width, n.height).contains(r)) {
e.handleTouchesEnd([ e.getTouchByXY(r.x, r.y, n) ]);
var o = e.getMouseEvent(r, n, cc.Event.EventMouse.UP);
o.setButton(i.button);
s.dispatchEvent(o);
}
}
}), !1);
}
for (var a = cc.Event.EventMouse, c = [ !i && [ "mousedown", a.DOWN, function(i, n, r, s) {
e._mousePressed = !0;
e.handleTouchesBegin([ e.getTouchByXY(r.x, r.y, s) ]);
t.focus();
} ], !i && [ "mouseup", a.UP, function(t, i, n, r) {
e._mousePressed = !1;
e.handleTouchesEnd([ e.getTouchByXY(n.x, n.y, r) ]);
} ], !i && [ "mousemove", a.MOVE, function(t, i, n, r) {
e.handleTouchesMove([ e.getTouchByXY(n.x, n.y, r) ]);
e._mousePressed || i.setButton(null);
} ], [ "mousewheel", a.SCROLL, function(t, e) {
e.setScrollData(0, t.wheelDelta);
} ], [ "DOMMouseScroll", a.SCROLL, function(t, e) {
e.setScrollData(0, -120 * t.detail);
} ] ], h = 0; h < c.length; ++h) {
var l = c[h];
l && (function() {
var i = l[0], n = l[1], r = l[2];
t.addEventListener(i, (function(i) {
var o = e.getHTMLElementPosition(t), a = e.getPointByEvent(i, o), c = e.getMouseEvent(a, o, n);
c.setButton(i.button);
r(i, c, a, o);
s.dispatchEvent(c);
i.stopPropagation();
i.preventDefault();
}), !1);
})();
}
}
if (window.navigator.msPointerEnabled) {
var u = {
MSPointerDown: e.handleTouchesBegin,
MSPointerMove: e.handleTouchesMove,
MSPointerUp: e.handleTouchesEnd,
MSPointerCancel: e.handleTouchesCancel
}, _ = function(i) {
var n = u[i];
t.addEventListener(i, (function(i) {
var r = e.getHTMLElementPosition(t);
r.left -= document.documentElement.scrollLeft;
r.top -= document.documentElement.scrollTop;
n.call(e, [ e.getTouchByXY(i.clientX, i.clientY, r) ]);
i.stopPropagation();
}), !1);
};
for (var f in u) _(f);
}
o && (function() {
var i = {
touchstart: function(i) {
e.handleTouchesBegin(i);
t.focus();
},
touchmove: function(t) {
e.handleTouchesMove(t);
},
touchend: function(t) {
e.handleTouchesEnd(t);
},
touchcancel: function(t) {
e.handleTouchesCancel(t);
}
}, n = void 0;
if (cc.sys.browserType === cc.sys.BROWSER_TYPE_WECHAT_GAME_SUB) {
i = {
onTouchStart: i.touchstart,
onTouchMove: i.touchmove,
onTouchEnd: i.touchend,
onTouchCancel: i.touchcancel
};
n = function(n) {
var r = i[n];
wx[n]((function(i) {
if (i.changedTouches) {
var n = e.getHTMLElementPosition(t), s = document.body;
n.left -= s.scrollLeft || 0;
n.top -= s.scrollTop || 0;
r(e.getTouchesByEvent(i, n));
}
}));
};
} else n = function(n) {
var r = i[n];
t.addEventListener(n, (function(i) {
if (i.changedTouches) {
var n = e.getHTMLElementPosition(t), s = document.body;
n.left -= s.scrollLeft || 0;
n.top -= s.scrollTop || 0;
r(e.getTouchesByEvent(i, n));
i.stopPropagation();
i.preventDefault();
}
}), !1);
};
for (var r in i) n(r);
})();
cc.sys.browserType !== cc.sys.BROWSER_TYPE_WECHAT_GAME_SUB && this._registerKeyboardEvent();
this._isRegisterEvent = !0;
}
},
_registerKeyboardEvent: function() {},
_registerAccelerometerEvent: function() {},
update: function(t) {
if (this._accelCurTime > this._accelInterval) {
this._accelCurTime -= this._accelInterval;
s.dispatchEvent(new cc.Event.EventAcceleration(this._acceleration));
}
this._accelCurTime += t;
}
};
e.exports = _cc.inputManager = c;
}), {
"../event-manager": 100,
"./CCMacro": 165,
"./CCSys": 169
} ],
165: [ (function(t, e, i) {
var n = t("./js");
cc.macro = {
RAD: Math.PI / 180,
DEG: 180 / Math.PI,
REPEAT_FOREVER: Number.MAX_VALUE - 1,
FLT_EPSILON: 1.192092896e-7,
MIN_ZINDEX: -Math.pow(2, 15),
MAX_ZINDEX: Math.pow(2, 15) - 1,
ONE: 1,
ZERO: 0,
SRC_ALPHA: 770,
SRC_ALPHA_SATURATE: 776,
SRC_COLOR: 768,
DST_ALPHA: 772,
DST_COLOR: 774,
ONE_MINUS_SRC_ALPHA: 771,
ONE_MINUS_SRC_COLOR: 769,
ONE_MINUS_DST_ALPHA: 773,
ONE_MINUS_DST_COLOR: 775,
ONE_MINUS_CONSTANT_ALPHA: 32772,
ONE_MINUS_CONSTANT_COLOR: 32770,
ORIENTATION_PORTRAIT: 1,
ORIENTATION_LANDSCAPE: 2,
ORIENTATION_AUTO: 3,
DENSITYDPI_DEVICE: "device-dpi",
DENSITYDPI_HIGH: "high-dpi",
DENSITYDPI_MEDIUM: "medium-dpi",
DENSITYDPI_LOW: "low-dpi",
FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX: !0,
DIRECTOR_STATS_POSITION: cc.v2(0, 0),
ENABLE_STACKABLE_ACTIONS: !0,
TOUCH_TIMEOUT: 5e3,
BATCH_VERTEX_COUNT: 2e4,
ENABLE_TILEDMAP_CULLING: !0,
DOWNLOAD_MAX_CONCURRENT: 64,
ENABLE_TRANSPARENT_CANVAS: !1,
ENABLE_WEBGL_ANTIALIAS: !1,
ENABLE_CULLING: !1,
CLEANUP_IMAGE_CACHE: !1
};
n.getset(cc.macro, "ENABLE_3D", (function() {
return cc._polyfill3D.enabled;
}), (function(t) {
t ? cc._polyfill3D.enable() : cc._polyfill3D.disable();
}));
cc.macro.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
};
cc.macro.ImageFormat = cc.Enum({
JPG: 0,
PNG: 1,
TIFF: 2,
WEBP: 3,
PVR: 4,
ETC: 5,
S3TC: 6,
ATITC: 7,
TGA: 8,
RAWDATA: 9,
UNKNOWN: 10
});
cc.macro.BlendFactor = cc.Enum({
ONE: 1,
ZERO: 0,
SRC_ALPHA: 770,
SRC_COLOR: 768,
DST_ALPHA: 772,
DST_COLOR: 774,
ONE_MINUS_SRC_ALPHA: 771,
ONE_MINUS_SRC_COLOR: 769,
ONE_MINUS_DST_ALPHA: 773,
ONE_MINUS_DST_COLOR: 775
});
cc.macro.TextAlignment = cc.Enum({
LEFT: 0,
CENTER: 1,
RIGHT: 2
});
cc.macro.VerticalTextAlignment = cc.Enum({
TOP: 0,
CENTER: 1,
BOTTOM: 2
});
e.exports = cc.macro;
}), {
"./js": 180
} ],
166: [ (function(i, n, r) {
var s = i("./js"), o = i("./CCClass"), a = 1;
function c() {
this._name = "";
this._objFlags = 0;
}
o.fastDefine("cc.Object", c, {
_name: "",
_objFlags: 0
});
s.value(c, "Flags", {
Destroyed: a,
DontSave: 8,
EditorOnly: 16,
Dirty: 32,
DontDestroy: 64,
PersistentMask: -4192741,
Destroying: 128,
Deactivating: 256,
LockedInEditor: 512,
IsPreloadStarted: 8192,
IsOnLoadStarted: 32768,
IsOnLoadCalled: 16384,
IsOnEnableCalled: 2048,
IsStartCalled: 65536,
IsEditorOnEnableCalled: 4096,
IsPositionLocked: 1 << 21,
IsRotationLocked: 1 << 17,
IsScaleLocked: 1 << 18,
IsAnchorLocked: 1 << 19,
IsSizeLocked: 1 << 20
});
var h = [];
function l() {
for (var t = h.length, e = 0; e < t; ++e) {
var i = h[e];
i._objFlags & a || i._destroyImmediate();
}
t === h.length ? h.length = 0 : h.splice(0, t);
0;
}
s.value(c, "_deferredDestroy", l);
0;
var u = c.prototype;
s.getset(u, "name", (function() {
return this._name;
}), (function(t) {
this._name = t;
}), !0);
s.get(u, "isValid", (function() {
return !(this._objFlags & a);
}), !0);
0;
u.destroy = function() {
if (this._objFlags & a) {
cc.warnID(5e3);
return !1;
}
if (4 & this._objFlags) return !1;
this._objFlags |= 4;
h.push(this);
0;
return !0;
};
0;
u._destruct = function() {
var i = this.constructor, n = i.__destruct__;
if (!n) {
n = (function(i, n) {
var r, s = i instanceof cc._BaseNode || i instanceof cc.Component, a = s ? "_id" : null, c = {};
for (r in i) if (i.hasOwnProperty(r)) {
if (r === a) continue;
switch ("object" == (e = typeof i[r]) ? t(i[r]) : e) {
case "string":
c[r] = "";
break;

case "object":
case "function":
c[r] = null;
}
}
if (cc.Class._isCCClass(n)) for (var h = cc.Class.Attr.getClassAttrs(n), l = n.__props__, u = 0; u < l.length; u++) {
var _ = (r = l[u]) + cc.Class.Attr.DELIMETER + "default";
if (_ in h) {
if (s && "_id" === r) continue;
switch ("object" == (e = typeof h[_]) ? t(h[_]) : e) {
case "string":
c[r] = "";
break;

case "object":
case "function":
c[r] = null;
break;

case "undefined":
c[r] = void 0;
}
}
}
var f = "";
for (r in c) {
var d;
d = o.IDENTIFIER_RE.test(r) ? "o." + r + "=" : "o[" + o.escapeForJS(r) + "]=";
var m = c[r];
"" === m && (m = '""');
f += d + m + ";\n";
}
return Function("o", f);
})(this, i);
s.value(i, "__destruct__", n, !0);
}
n(this);
};
u._onPreDestroy = null;
u._destroyImmediate = function() {
if (this._objFlags & a) cc.errorID(5e3); else {
this._onPreDestroy && this._onPreDestroy();
this._destruct();
this._objFlags |= a;
}
};
0;
u._deserialize = null;
cc.isValid = function(i, n) {
return "object" === ("object" === (e = typeof i) ? t(i) : e) ? !(!i || i._objFlags & (n ? 4 | a : a)) : "undefined" !== ("object" === (e = typeof i) ? t(i) : e);
};
0;
cc.Object = n.exports = c;
}), {
"./CCClass": 160,
"./js": 180
} ],
167: [ (function(t, e, i) {
var n = t("../platform/js");
cc.SAXParser = function() {
if (window.DOMParser) {
this._isSupportDOMParser = !0;
this._parser = new DOMParser();
} else {
this._isSupportDOMParser = !1;
this._parser = null;
}
};
cc.SAXParser.prototype = {
constructor: cc.SAXParser,
parse: function(t) {
return this._parseXML(t);
},
_parseXML: function(t) {
var e;
if (this._isSupportDOMParser) e = this._parser.parseFromString(t, "text/xml"); else {
(e = new ActiveXObject("Microsoft.XMLDOM")).async = "false";
e.loadXML(t);
}
return e;
}
};
cc.PlistParser = function() {
cc.SAXParser.call(this);
};
n.extend(cc.PlistParser, cc.SAXParser);
n.mixin(cc.PlistParser.prototype, {
parse: function(t) {
var e = this._parseXML(t), i = e.documentElement;
if ("plist" !== i.tagName) {
cc.warnID(5100);
return {};
}
for (var n = null, r = 0, s = i.childNodes.length; r < s && 1 !== (n = i.childNodes[r]).nodeType; r++) ;
e = null;
return this._parseNode(n);
},
_parseNode: function(t) {
var e = null, 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 (var n = 0; n < t.childNodes.length; n++) e += t.childNodes[n].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: function(t) {
for (var e = [], i = 0, n = t.childNodes.length; i < n; i++) {
var r = t.childNodes[i];
1 === r.nodeType && e.push(this._parseNode(r));
}
return e;
},
_parseDict: function(t) {
for (var e = {}, i = null, n = 0, r = t.childNodes.length; n < r; n++) {
var s = t.childNodes[n];
1 === s.nodeType && ("key" === s.tagName ? i = s.firstChild.nodeValue : e[i] = this._parseNode(s));
}
return e;
}
});
cc.saxParser = new cc.SAXParser();
cc.plistParser = new cc.PlistParser();
e.exports = {
saxParser: cc.saxParser,
plistParser: cc.plistParser
};
}), {
"../platform/js": 180
} ],
168: [ (function(i, n, r) {
cc.screen = {
_supportsFullScreen: !1,
_preOnFullScreenChange: null,
_touchEvent: "",
_fn: null,
_fnMap: [ [ "requestFullscreen", "exitFullscreen", "fullscreenchange", "fullscreenEnabled", "fullscreenElement" ], [ "requestFullScreen", "exitFullScreen", "fullScreenchange", "fullScreenEnabled", "fullScreenElement" ], [ "webkitRequestFullScreen", "webkitCancelFullScreen", "webkitfullscreenchange", "webkitIsFullScreen", "webkitCurrentFullScreenElement" ], [ "mozRequestFullScreen", "mozCancelFullScreen", "mozfullscreenchange", "mozFullScreen", "mozFullScreenElement" ], [ "msRequestFullscreen", "msExitFullscreen", "MSFullscreenChange", "msFullscreenEnabled", "msFullscreenElement" ] ],
init: function() {
this._fn = {};
var i, n, r, s, o = this._fnMap;
for (i = 0, n = o.length; i < n; i++) if ((r = o[i]) && "undefined" !== ("object" === (e = typeof document[r[1]]) ? t(document[r[1]]) : e)) {
for (i = 0, s = r.length; i < s; i++) this._fn[o[0][i]] = r[i];
break;
}
this._supportsFullScreen = void 0 !== this._fn.requestFullscreen;
this._touchEvent = "ontouchstart" in window ? "touchstart" : "mousedown";
},
fullScreen: function() {
return !!this._supportsFullScreen && !!(document[this._fn.fullscreenElement] || document[this._fn.webkitFullscreenElement] || document[this._fn.mozFullScreenElement]);
},
requestFullScreen: function(t, e) {
if (t && "video" === t.tagName.toLowerCase()) {
if (cc.sys.os === cc.sys.OS_IOS && cc.sys.isBrowser && t.readyState > 0) {
t.webkitEnterFullscreen && t.webkitEnterFullscreen();
return;
}
t.setAttribute("x5-video-player-fullscreen", "true");
}
if (this._supportsFullScreen) {
t = t || document.documentElement;
if (e) {
var i = this._fn.fullscreenchange;
this._preOnFullScreenChange && document.removeEventListener(i, this._preOnFullScreenChange);
this._preOnFullScreenChange = e;
document.addEventListener(i, e, !1);
}
return t[this._fn.requestFullscreen]();
}
},
exitFullScreen: function(t) {
if (t && "video" === t.tagName.toLowerCase()) {
if (cc.sys.os === cc.sys.OS_IOS && cc.sys.isBrowser) {
t.webkitExitFullscreen && t.webkitExitFullscreen();
return;
}
t.setAttribute("x5-video-player-fullscreen", "false");
}
return !this._supportsFullScreen || document[this._fn.exitFullscreen]();
},
autoFullScreen: function(t, e) {
t = t || document.body;
var i = cc.game.canvas || t, n = this;
this.requestFullScreen(t, e);
i.addEventListener(this._touchEvent, (function r() {
i.removeEventListener(n._touchEvent, r);
n.requestFullScreen(t, e);
}));
}
};
cc.screen.init();
}), {} ],
169: [ (function(i, n, r) {
var s = void 0, o = (s = window._CCSettings ? _CCSettings.platform : void 0, "qgame" === s), a = "quickgame" === s;
var c = cc && cc.sys ? cc.sys : (function() {
cc.sys = {};
var i = cc.sys;
i.LANGUAGE_ENGLISH = "en";
i.LANGUAGE_CHINESE = "zh";
i.LANGUAGE_FRENCH = "fr";
i.LANGUAGE_ITALIAN = "it";
i.LANGUAGE_GERMAN = "de";
i.LANGUAGE_SPANISH = "es";
i.LANGUAGE_DUTCH = "du";
i.LANGUAGE_RUSSIAN = "ru";
i.LANGUAGE_KOREAN = "ko";
i.LANGUAGE_JAPANESE = "ja";
i.LANGUAGE_HUNGARIAN = "hu";
i.LANGUAGE_PORTUGUESE = "pt";
i.LANGUAGE_ARABIC = "ar";
i.LANGUAGE_NORWEGIAN = "no";
i.LANGUAGE_POLISH = "pl";
i.LANGUAGE_TURKISH = "tr";
i.LANGUAGE_UKRAINIAN = "uk";
i.LANGUAGE_ROMANIAN = "ro";
i.LANGUAGE_BULGARIAN = "bg";
i.LANGUAGE_UNKNOWN = "unknown";
i.OS_IOS = "iOS";
i.OS_ANDROID = "Android";
i.OS_WINDOWS = "Windows";
i.OS_MARMALADE = "Marmalade";
i.OS_LINUX = "Linux";
i.OS_BADA = "Bada";
i.OS_BLACKBERRY = "Blackberry";
i.OS_OSX = "OS X";
i.OS_WP8 = "WP8";
i.OS_WINRT = "WINRT";
i.OS_UNKNOWN = "Unknown";
i.UNKNOWN = -1;
i.WIN32 = 0;
i.LINUX = 1;
i.MACOS = 2;
i.ANDROID = 3;
i.IPHONE = 4;
i.IPAD = 5;
i.BLACKBERRY = 6;
i.NACL = 7;
i.EMSCRIPTEN = 8;
i.TIZEN = 9;
i.WINRT = 10;
i.WP8 = 11;
i.MOBILE_BROWSER = 100;
i.DESKTOP_BROWSER = 101;
i.EDITOR_PAGE = 102;
i.EDITOR_CORE = 103;
i.WECHAT_GAME = 104;
i.QQ_PLAY = 105;
i.FB_PLAYABLE_ADS = 106;
i.BAIDU_GAME = 107;
i.VIVO_GAME = 108;
i.OPPO_GAME = 109;
i.BROWSER_TYPE_WECHAT = "wechat";
i.BROWSER_TYPE_WECHAT_GAME = "wechatgame";
i.BROWSER_TYPE_WECHAT_GAME_SUB = "wechatgamesub";
i.BROWSER_TYPE_BAIDU_GAME = "baidugame";
i.BROWSER_TYPE_BAIDU_GAME_SUB = "baidugamesub";
i.BROWSER_TYPE_QQ_PLAY = "qqplay";
i.BROWSER_TYPE_ANDROID = "androidbrowser";
i.BROWSER_TYPE_IE = "ie";
i.BROWSER_TYPE_QQ = "qqbrowser";
i.BROWSER_TYPE_MOBILE_QQ = "mqqbrowser";
i.BROWSER_TYPE_UC = "ucbrowser";
i.BROWSER_TYPE_UCBS = "ucbs";
i.BROWSER_TYPE_360 = "360browser";
i.BROWSER_TYPE_BAIDU_APP = "baiduboxapp";
i.BROWSER_TYPE_BAIDU = "baidubrowser";
i.BROWSER_TYPE_MAXTHON = "maxthon";
i.BROWSER_TYPE_OPERA = "opera";
i.BROWSER_TYPE_OUPENG = "oupeng";
i.BROWSER_TYPE_MIUI = "miuibrowser";
i.BROWSER_TYPE_FIREFOX = "firefox";
i.BROWSER_TYPE_SAFARI = "safari";
i.BROWSER_TYPE_CHROME = "chrome";
i.BROWSER_TYPE_LIEBAO = "liebao";
i.BROWSER_TYPE_QZONE = "qzone";
i.BROWSER_TYPE_SOUGOU = "sogou";
i.BROWSER_TYPE_UNKNOWN = "unknown";
i.isNative = !0;
i.isBrowser = "object" === ("object" == (e = typeof window) ? t(window) : e) && "object" === ("object" == (e = typeof document) ? t(document) : e) && !1;
var n, r = void 0;
r = o ? i.VIVO_GAME : a ? i.OPPO_GAME : __getPlatform();
i.platform = r;
i.isMobile = r === i.ANDROID || r === i.IPAD || r === i.IPHONE || r === i.WP8 || r === i.TIZEN || r === i.BLACKBERRY || r === i.VIVO_GAME || r === i.OPPO_GAME;
i.os = __getOS();
i.language = __getCurrentLanguage();
n = __getCurrentLanguageCode();
i.languageCode = n ? n.toLowerCase() : void 0;
i.osVersion = __getOSVersion();
i.osMainVersion = parseInt(i.osVersion);
i.browserType = null;
i.browserVersion = null;
var s, c = window.innerWidth, h = window.innerHeight, l = window.devicePixelRatio || 1;
i.windowPixelResolution = {
width: l * c,
height: l * h
};
i.localStorage = window.localStorage;
s = i.capabilities = {
canvas: !1,
opengl: !0,
webp: !0
};
if (i.isMobile) {
s.accelerometer = !0;
s.touches = !0;
} else {
s.keyboard = !0;
s.mouse = !0;
s.touches = !1;
}
i.__audioSupport = {
ONLY_ONE: !1,
WEB_AUDIO: !1,
DELAY_CREATE_CTX: !1,
format: [ ".mp3" ]
};
i.NetworkType = {
NONE: 0,
LAN: 1,
WWAN: 2
};
i.getNetworkType = function() {
return i.NetworkType.LAN;
};
i.getBatteryLevel = function() {
return 1;
};
i.garbageCollect = function() {};
i.restartVM = function() {};
i.getSafeAreaRect = function() {
var t = cc.view.getVisibleSize();
return cc.rect(0, 0, t.width, t.height);
};
i.isObjectValid = function(t) {
return !!t;
};
i.dump = function() {
var 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 " + (cc.game.renderType === cc.game.RENDER_TYPE_WEBGL ? "WEBGL" : "CANVAS") + " renderer.\r\n";
cc.log(t);
};
i.openURL = function(t) {
jsb.openURL(t);
};
i.now = function() {
return Date.now ? Date.now() : +new Date();
};
return i;
})();
n.exports = c;
}), {} ],
170: [ (function(i, n, r) {
var s = i("../event/event-target"), o = i("../platform/js"), a = i("../renderer");
i("../platform/CCClass");
var c = cc.sys.platform === cc.sys.BAIDU_GAME, h = {
init: function() {
c || (this.html = document.getElementsByTagName("html")[0]);
},
availWidth: function(t) {
return t && t !== this.html ? t.clientWidth : window.innerWidth;
},
availHeight: function(t) {
return t && t !== this.html ? t.clientHeight : window.innerHeight;
},
meta: {
width: "device-width"
},
adaptationType: cc.sys.browserType
};
cc.sys.os === cc.sys.OS_IOS && (h.adaptationType = cc.sys.BROWSER_TYPE_SAFARI);
c && (cc.sys.browserType === cc.sys.BROWSER_TYPE_BAIDU_GAME_SUB ? h.adaptationType = cc.sys.BROWSER_TYPE_BAIDU_GAME_SUB : h.adaptationType = cc.sys.BROWSER_TYPE_BAIDU_GAME);
0;
0;
switch (h.adaptationType) {
case cc.sys.BROWSER_TYPE_SAFARI:
h.meta["minimal-ui"] = "true";

case cc.sys.BROWSER_TYPE_SOUGOU:
case cc.sys.BROWSER_TYPE_UC:
h.availWidth = function(t) {
return t.clientWidth;
};
h.availHeight = function(t) {
return t.clientHeight;
};
break;

case cc.sys.BROWSER_TYPE_WECHAT_GAME:
h.availWidth = function() {
return window.innerWidth;
};
h.availHeight = function() {
return window.innerHeight;
};
break;

case cc.sys.BROWSER_TYPE_WECHAT_GAME_SUB:
var l = window.sharedCanvas || wx.getSharedCanvas();
h.availWidth = function() {
return l.width;
};
h.availHeight = function() {
return l.height;
};
}
var u = null, _ = function() {
s.call(this);
var t = this, e = cc.ContainerStrategy, i = cc.ContentStrategy;
h.init(this);
t._frameSize = cc.size(0, 0);
t._designResolutionSize = cc.size(0, 0);
t._originalDesignResolutionSize = cc.size(0, 0);
t._scaleX = 1;
t._scaleY = 1;
t._viewportRect = cc.rect(0, 0, 0, 0);
t._visibleRect = cc.rect(0, 0, 0, 0);
t._autoFullScreen = !1;
t._devicePixelRatio = 1;
t._maxPixelRatio = 2;
t._retinaEnabled = !1;
t._resizeCallback = null;
t._resizing = !1;
t._resizeWithBrowserSize = !1;
t._orientationChanging = !0;
t._isRotated = !1;
t._orientation = cc.macro.ORIENTATION_AUTO;
t._isAdjustViewport = !0;
t._antiAliasEnabled = !1;
t._resolutionPolicy = null;
t._rpExactFit = new cc.ResolutionPolicy(e.EQUAL_TO_FRAME, i.EXACT_FIT);
t._rpShowAll = new cc.ResolutionPolicy(e.EQUAL_TO_FRAME, i.SHOW_ALL);
t._rpNoBorder = new cc.ResolutionPolicy(e.EQUAL_TO_FRAME, i.NO_BORDER);
t._rpFixedHeight = new cc.ResolutionPolicy(e.EQUAL_TO_FRAME, i.FIXED_HEIGHT);
t._rpFixedWidth = new cc.ResolutionPolicy(e.EQUAL_TO_FRAME, i.FIXED_WIDTH);
cc.game.once(cc.game.EVENT_ENGINE_INITED, this.init, this);
};
cc.js.extend(_, s);
cc.js.mixin(_.prototype, {
init: function() {
this._initFrameSize();
this.enableAntiAlias(!0);
var t = cc.game.canvas.width, e = cc.game.canvas.height;
this._designResolutionSize.width = t;
this._designResolutionSize.height = e;
this._originalDesignResolutionSize.width = t;
this._originalDesignResolutionSize.height = e;
this._viewportRect.width = t;
this._viewportRect.height = e;
this._visibleRect.width = t;
this._visibleRect.height = e;
cc.winSize.width = this._visibleRect.width;
cc.winSize.height = this._visibleRect.height;
cc.visibleRect && cc.visibleRect.init(this._visibleRect);
},
_resizeEvent: function(t) {
var e, i = (e = this.setDesignResolutionSize ? this : cc.view)._frameSize.width, n = e._frameSize.height, r = e._isRotated;
if (cc.sys.isMobile) {
var s = cc.game.container.style, o = s.margin;
s.margin = "0";
s.display = "none";
e._initFrameSize();
s.margin = o;
s.display = "block";
} else e._initFrameSize();
if (!0 === t || e._isRotated !== r || e._frameSize.width !== i || e._frameSize.height !== n) {
var a = e._originalDesignResolutionSize.width, c = e._originalDesignResolutionSize.height;
e._resizing = !0;
a > 0 && e.setDesignResolutionSize(a, c, e._resolutionPolicy);
e._resizing = !1;
e.emit("canvas-resize");
e._resizeCallback && e._resizeCallback.call();
}
},
_orientationChange: function() {
cc.view._orientationChanging = !0;
cc.view._resizeEvent();
},
resizeWithBrowserSize: function(t) {
if (t) {
if (!this._resizeWithBrowserSize) {
this._resizeWithBrowserSize = !0;
window.addEventListener("resize", this._resizeEvent);
window.addEventListener("orientationchange", this._orientationChange);
}
} else if (this._resizeWithBrowserSize) {
this._resizeWithBrowserSize = !1;
window.removeEventListener("resize", this._resizeEvent);
window.removeEventListener("orientationchange", this._orientationChange);
}
},
setResizeCallback: function(i) {
0;
"function" !== ("object" === (e = typeof i) ? t(i) : e) && null != i || (this._resizeCallback = i);
},
setOrientation: function(t) {
if ((t &= cc.macro.ORIENTATION_AUTO) && this._orientation !== t) {
this._orientation = t;
var e = this._originalDesignResolutionSize.width, i = this._originalDesignResolutionSize.height;
this.setDesignResolutionSize(e, i, this._resolutionPolicy);
}
},
_initFrameSize: function() {
var t = this._frameSize, e = h.availWidth(cc.game.frame), i = h.availHeight(cc.game.frame), n = e >= i;
if (!cc.sys.isMobile || n && this._orientation & cc.macro.ORIENTATION_LANDSCAPE || !n && this._orientation & cc.macro.ORIENTATION_PORTRAIT) {
t.width = e;
t.height = i;
cc.game.container.style["-webkit-transform"] = "rotate(0deg)";
cc.game.container.style.transform = "rotate(0deg)";
this._isRotated = !1;
} else {
t.width = i;
t.height = e;
cc.game.container.style["-webkit-transform"] = "rotate(90deg)";
cc.game.container.style.transform = "rotate(90deg)";
cc.game.container.style["-webkit-transform-origin"] = "0px 0px 0px";
cc.game.container.style.transformOrigin = "0px 0px 0px";
this._isRotated = !0;
}
this._orientationChanging && setTimeout((function() {
cc.view._orientationChanging = !1;
}), 1e3);
},
_adjustSizeKeepCanvasSize: function() {
var t = this._originalDesignResolutionSize.width, e = this._originalDesignResolutionSize.height;
t > 0 && this.setDesignResolutionSize(t, e, this._resolutionPolicy);
},
_setViewportMeta: function(t, e) {
var i = document.getElementById("cocosMetaElement");
i && e && document.head.removeChild(i);
var n, r, s, o = document.getElementsByName("viewport"), a = o ? o[0] : null;
n = a ? a.content : "";
(i = i || document.createElement("meta")).id = "cocosMetaElement";
i.name = "viewport";
i.content = "";
for (r in t) if (-1 == n.indexOf(r)) n += "," + r + "=" + t[r]; else if (e) {
s = new RegExp(r + "s*=s*[^,]+");
n.replace(s, r + "=" + t[r]);
}
/^,/.test(n) && (n = n.substr(1));
i.content = n;
a && (a.content = n);
document.head.appendChild(i);
},
_adjustViewportMeta: function() {
if ((this._isAdjustViewport, 0) && !c) {
this._setViewportMeta(h.meta, !1);
this._isAdjustViewport = !1;
}
},
adjustViewportMeta: function(t) {
this._isAdjustViewport = t;
},
enableRetina: function(t) {
this._retinaEnabled = !!t;
},
isRetinaEnabled: function() {
return this._retinaEnabled;
},
enableAntiAlias: function(t) {
if (this._antiAliasEnabled !== t) {
this._antiAliasEnabled = t;
if (cc.game.renderType === cc.game.RENDER_TYPE_WEBGL) {
var e = cc.loader._cache;
for (var i in e) {
var n = e[i], r = n && n.content instanceof cc.Texture2D ? n.content : null;
if (r) {
var s = cc.Texture2D.Filter;
t ? r.setFilters(s.LINEAR, s.LINEAR) : r.setFilters(s.NEAREST, s.NEAREST);
}
}
} else if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS) {
var o = cc.game.canvas.getContext("2d");
o.imageSmoothingEnabled = t;
o.mozImageSmoothingEnabled = t;
}
}
},
isAntiAliasEnabled: function() {
return this._antiAliasEnabled;
},
enableAutoFullScreen: function(t) {
if (t && t !== this._autoFullScreen && cc.sys.isMobile && cc.sys.browserType !== cc.sys.BROWSER_TYPE_WECHAT) {
this._autoFullScreen = !0;
cc.screen.autoFullScreen(cc.game.frame);
} else this._autoFullScreen = !1;
},
isAutoFullScreenEnabled: function() {
return this._autoFullScreen;
},
setCanvasSize: function(t, e) {
var i = cc.game.canvas, n = cc.game.container;
i.width = t * this._devicePixelRatio;
i.height = e * this._devicePixelRatio;
i.style.width = t + "px";
i.style.height = e + "px";
n.style.width = t + "px";
n.style.height = e + "px";
this._resizeEvent();
},
getCanvasSize: function() {
return cc.size(cc.game.canvas.width, cc.game.canvas.height);
},
getFrameSize: function() {
return cc.size(this._frameSize.width, this._frameSize.height);
},
setFrameSize: function(t, e) {
this._frameSize.width = t;
this._frameSize.height = e;
cc.game.frame.style.width = t + "px";
cc.game.frame.style.height = e + "px";
this._resizeEvent(!0);
},
getVisibleSize: function() {
return cc.size(this._visibleRect.width, this._visibleRect.height);
},
getVisibleSizeInPixel: function() {
return cc.size(this._visibleRect.width * this._scaleX, this._visibleRect.height * this._scaleY);
},
getVisibleOrigin: function() {
return cc.v2(this._visibleRect.x, this._visibleRect.y);
},
getVisibleOriginInPixel: function() {
return cc.v2(this._visibleRect.x * this._scaleX, this._visibleRect.y * this._scaleY);
},
getResolutionPolicy: function() {
return this._resolutionPolicy;
},
setResolutionPolicy: function(t) {
var e = this;
if (t instanceof cc.ResolutionPolicy) e._resolutionPolicy = t; else {
var i = cc.ResolutionPolicy;
t === i.EXACT_FIT && (e._resolutionPolicy = e._rpExactFit);
t === i.SHOW_ALL && (e._resolutionPolicy = e._rpShowAll);
t === i.NO_BORDER && (e._resolutionPolicy = e._rpNoBorder);
t === i.FIXED_HEIGHT && (e._resolutionPolicy = e._rpFixedHeight);
t === i.FIXED_WIDTH && (e._resolutionPolicy = e._rpFixedWidth);
}
},
setDesignResolutionSize: function(t, e, i) {
if (t > 0 || e > 0) {
this.setResolutionPolicy(i);
var n = this._resolutionPolicy;
n && n.preApply(this);
cc.sys.isMobile && this._adjustViewportMeta();
this._orientationChanging = !0;
this._resizing || this._initFrameSize();
if (n) {
this._originalDesignResolutionSize.width = this._designResolutionSize.width = t;
this._originalDesignResolutionSize.height = this._designResolutionSize.height = e;
var r = n.apply(this, this._designResolutionSize);
if (r.scale && 2 === r.scale.length) {
this._scaleX = r.scale[0];
this._scaleY = r.scale[1];
}
if (r.viewport) {
var s = this._viewportRect, o = this._visibleRect, c = r.viewport;
s.x = c.x;
s.y = c.y;
s.width = c.width;
s.height = c.height;
o.x = 0;
o.y = 0;
o.width = c.width / this._scaleX;
o.height = c.height / this._scaleY;
}
n.postApply(this);
cc.winSize.width = this._visibleRect.width;
cc.winSize.height = this._visibleRect.height;
cc.visibleRect && cc.visibleRect.init(this._visibleRect);
a.updateCameraViewport();
this.emit("design-resolution-changed");
} else cc.logID(2201);
} else cc.logID(2200);
},
getDesignResolutionSize: function() {
return cc.size(this._designResolutionSize.width, this._designResolutionSize.height);
},
setRealPixelResolution: function(t, e, i) {
0;
this.setDesignResolutionSize(t, e, i);
},
setViewportInPoints: function(t, e, i, n) {
var r = this._scaleX, s = this._scaleY;
cc.game._renderContext.viewport(t * r + this._viewportRect.x, e * s + this._viewportRect.y, i * r, n * s);
},
setScissorInPoints: function(t, e, i, n) {
var r = this._scaleX, s = this._scaleY, o = Math.ceil(t * r + this._viewportRect.x), a = Math.ceil(e * s + this._viewportRect.y), c = Math.ceil(i * r), h = Math.ceil(n * s), l = cc.game._renderContext;
if (!u) {
var _ = l.getParameter(l.SCISSOR_BOX);
u = cc.rect(_[0], _[1], _[2], _[3]);
}
if (u.x !== o || u.y !== a || u.width !== c || u.height !== h) {
u.x = o;
u.y = a;
u.width = c;
u.height = h;
l.scissor(o, a, c, h);
}
},
isScissorEnabled: function() {
return cc.game._renderContext.isEnabled(gl.SCISSOR_TEST);
},
getScissorRect: function() {
if (!u) {
var t = gl.getParameter(gl.SCISSOR_BOX);
u = cc.rect(t[0], t[1], t[2], t[3]);
}
var e = 1 / this._scaleX, i = 1 / this._scaleY;
return cc.rect((u.x - this._viewportRect.x) * e, (u.y - this._viewportRect.y) * i, u.width * e, u.height * i);
},
getViewportRect: function() {
return this._viewportRect;
},
getScaleX: function() {
return this._scaleX;
},
getScaleY: function() {
return this._scaleY;
},
getDevicePixelRatio: function() {
return this._devicePixelRatio;
},
convertToLocationInView: function(t, e, i, n) {
var r = n || cc.v2(), s = this._devicePixelRatio * (t - i.left), o = this._devicePixelRatio * (i.top + i.height - e);
if (this._isRotated) {
r.x = cc.game.canvas.width - o;
r.y = s;
} else {
r.x = s;
r.y = o;
}
return r;
},
_convertMouseToLocationInView: function(t, e) {
var i = this._viewportRect;
t.x = (this._devicePixelRatio * (t.x - e.left) - i.x) / this._scaleX;
t.y = (this._devicePixelRatio * (e.top + e.height - t.y) - i.y) / this._scaleY;
},
_convertPointWithScale: function(t) {
var e = this._viewportRect;
t.x = (t.x - e.x) / this._scaleX;
t.y = (t.y - e.y) / this._scaleY;
},
_convertTouchesWithScale: function(t) {
for (var e, i, n, r = this._viewportRect, s = this._scaleX, o = this._scaleY, a = 0; a < t.length; a++) {
i = (e = t[a])._point;
n = e._prevPoint;
i.x = (i.x - r.x) / s;
i.y = (i.y - r.y) / o;
n.x = (n.x - r.x) / s;
n.y = (n.y - r.y) / o;
}
}
});
cc.ContainerStrategy = cc.Class({
name: "ContainerStrategy",
preApply: function(t) {},
apply: function(t, e) {},
postApply: function(t) {},
_setupContainer: function(t, e, i) {
var n = cc.game.canvas, r = cc.game.container;
if (!c) {
if (cc.sys.os === cc.sys.OS_ANDROID) {
document.body.style.width = (t._isRotated ? i : e) + "px";
document.body.style.height = (t._isRotated ? e : i) + "px";
}
r.style.width = n.style.width = e + "px";
r.style.height = n.style.height = i + "px";
}
var s = t._devicePixelRatio = 1;
t.isRetinaEnabled() && (s = t._devicePixelRatio = Math.min(t._maxPixelRatio, window.devicePixelRatio || 1));
n.width = e * s;
n.height = i * s;
},
_fixContainer: function() {
document.body.insertBefore(cc.game.container, document.body.firstChild);
var t = document.body.style;
t.width = window.innerWidth + "px";
t.height = window.innerHeight + "px";
t.overflow = "hidden";
var e = cc.game.container.style;
e.position = "fixed";
e.left = e.top = "0px";
document.body.scrollTop = 0;
}
});
cc.ContentStrategy = cc.Class({
name: "ContentStrategy",
ctor: function() {
this._result = {
scale: [ 1, 1 ],
viewport: null
};
},
_buildResult: function(t, e, i, n, r, s) {
Math.abs(t - i) < 2 && (i = t);
Math.abs(e - n) < 2 && (n = e);
var o = cc.rect((t - i) / 2, (e - n) / 2, i, n);
cc.game.renderType, cc.game.RENDER_TYPE_CANVAS;
this._result.scale = [ r, s ];
this._result.viewport = o;
return this._result;
},
preApply: function(t) {},
apply: function(t, e) {
return {
scale: [ 1, 1 ]
};
},
postApply: function(t) {}
});
(function() {
var t = cc.Class({
name: "EqualToFrame",
extends: cc.ContainerStrategy,
apply: function(t) {
var e = t._frameSize.height, i = cc.game.container.style;
this._setupContainer(t, t._frameSize.width, t._frameSize.height);
t._isRotated ? i.margin = "0 0 0 " + e + "px" : i.margin = "0px";
i.padding = "0px";
}
}), e = cc.Class({
name: "ProportionalToFrame",
extends: cc.ContainerStrategy,
apply: function(t, e) {
var i, n, r = t._frameSize.width, s = t._frameSize.height, o = cc.game.container.style, a = e.width, c = e.height, h = r / a, l = s / c;
h < l ? (i = r, n = c * h) : (i = a * l, n = s);
var u = Math.round((r - i) / 2), _ = Math.round((s - n) / 2);
i = r - 2 * u;
n = s - 2 * _;
this._setupContainer(t, i, n);
t._isRotated ? o.margin = "0 0 0 " + s + "px" : o.margin = "0px";
o.paddingLeft = u + "px";
o.paddingRight = u + "px";
o.paddingTop = _ + "px";
o.paddingBottom = _ + "px";
}
}), i = (cc.Class({
name: "EqualToWindow",
extends: t,
preApply: function(t) {
this._super(t);
cc.game.frame = document.documentElement;
},
apply: function(t) {
this._super(t);
this._fixContainer();
}
}), cc.Class({
name: "ProportionalToWindow",
extends: e,
preApply: function(t) {
this._super(t);
cc.game.frame = document.documentElement;
},
apply: function(t, e) {
this._super(t, e);
this._fixContainer();
}
}), cc.Class({
name: "OriginalContainer",
extends: cc.ContainerStrategy,
apply: function(t) {
this._setupContainer(t, cc.game.canvas.width, cc.game.canvas.height);
}
}));
cc.ContainerStrategy.EQUAL_TO_FRAME = new t();
cc.ContainerStrategy.PROPORTION_TO_FRAME = new e();
cc.ContainerStrategy.ORIGINAL_CONTAINER = new i();
var n = cc.Class({
name: "ExactFit",
extends: cc.ContentStrategy,
apply: function(t, e) {
var i = cc.game.canvas.width, n = cc.game.canvas.height, r = i / e.width, s = n / e.height;
return this._buildResult(i, n, i, n, r, s);
}
}), r = cc.Class({
name: "ShowAll",
extends: cc.ContentStrategy,
apply: function(t, e) {
var i, n, r = cc.game.canvas.width, s = cc.game.canvas.height, o = e.width, a = e.height, c = r / o, h = s / a, l = 0;
c < h ? (i = r, n = a * (l = c)) : (i = o * (l = h), n = s);
return this._buildResult(r, s, i, n, l, l);
}
}), s = cc.Class({
name: "NoBorder",
extends: cc.ContentStrategy,
apply: function(t, e) {
var i, n, r, s = cc.game.canvas.width, o = cc.game.canvas.height, a = e.width, c = e.height, h = s / a, l = o / c;
h < l ? (n = a * (i = l), r = o) : (n = s, r = c * (i = h));
return this._buildResult(s, o, n, r, i, i);
}
}), o = cc.Class({
name: "FixedHeight",
extends: cc.ContentStrategy,
apply: function(t, e) {
var i = cc.game.canvas.width, n = cc.game.canvas.height, r = n / e.height, s = i, o = n;
return this._buildResult(i, n, s, o, r, r);
}
}), a = cc.Class({
name: "FixedWidth",
extends: cc.ContentStrategy,
apply: function(t, e) {
var i = cc.game.canvas.width, n = cc.game.canvas.height, r = i / e.width, s = i, o = n;
return this._buildResult(i, n, s, o, r, r);
}
});
cc.ContentStrategy.EXACT_FIT = new n();
cc.ContentStrategy.SHOW_ALL = new r();
cc.ContentStrategy.NO_BORDER = new s();
cc.ContentStrategy.FIXED_HEIGHT = new o();
cc.ContentStrategy.FIXED_WIDTH = new a();
})();
cc.ResolutionPolicy = cc.Class({
name: "cc.ResolutionPolicy",
ctor: function(t, e) {
this._containerStrategy = null;
this._contentStrategy = null;
this.setContainerStrategy(t);
this.setContentStrategy(e);
},
preApply: function(t) {
this._containerStrategy.preApply(t);
this._contentStrategy.preApply(t);
},
apply: function(t, e) {
this._containerStrategy.apply(t, e);
return this._contentStrategy.apply(t, e);
},
postApply: function(t) {
this._containerStrategy.postApply(t);
this._contentStrategy.postApply(t);
},
setContainerStrategy: function(t) {
t instanceof cc.ContainerStrategy && (this._containerStrategy = t);
},
setContentStrategy: function(t) {
t instanceof cc.ContentStrategy && (this._contentStrategy = t);
}
});
o.get(cc.ResolutionPolicy.prototype, "canvasSize", (function() {
return cc.v2(cc.game.canvas.width, cc.game.canvas.height);
}));
cc.ResolutionPolicy.EXACT_FIT = 0;
cc.ResolutionPolicy.NO_BORDER = 1;
cc.ResolutionPolicy.SHOW_ALL = 2;
cc.ResolutionPolicy.FIXED_HEIGHT = 3;
cc.ResolutionPolicy.FIXED_WIDTH = 4;
cc.ResolutionPolicy.UNKNOWN = 5;
cc.view = new _();
cc.winSize = cc.v2();
n.exports = cc.view;
}), {
"../event/event-target": 102,
"../platform/CCClass": 160,
"../platform/js": 180,
"../renderer": 201
} ],
171: [ (function(t, e, i) {
cc.visibleRect = {
topLeft: cc.v2(0, 0),
topRight: cc.v2(0, 0),
top: cc.v2(0, 0),
bottomLeft: cc.v2(0, 0),
bottomRight: cc.v2(0, 0),
bottom: cc.v2(0, 0),
center: cc.v2(0, 0),
left: cc.v2(0, 0),
right: cc.v2(0, 0),
width: 0,
height: 0,
init: function(t) {
var e = this.width = t.width, i = this.height = t.height, n = t.x, r = t.y, s = r + i, o = n + e;
this.topLeft.x = n;
this.topLeft.y = s;
this.topRight.x = o;
this.topRight.y = s;
this.top.x = n + e / 2;
this.top.y = s;
this.bottomLeft.x = n;
this.bottomLeft.y = r;
this.bottomRight.x = o;
this.bottomRight.y = r;
this.bottom.x = n + e / 2;
this.bottom.y = r;
this.center.x = n + e / 2;
this.center.y = r + i / 2;
this.left.x = n;
this.left.y = r + i / 2;
this.right.x = o;
this.right.y = r + i / 2;
}
};
}), {} ],
172: [ (function(i, n, r) {
var s = i("./js"), o = (i("./utils").isPlainEmptyObj_DEV, "$_$");
function a(t, e, i) {
var n;
n = function() {};
i && s.extend(n, i.constructor);
var r = new n();
s.value(t, "__attrs__", r);
return r;
}
function c(i, n, r) {
var s, c, l;
if ("function" === ("object" === (e = typeof i) ? t(i) : e)) c = (s = h(i)).constructor.prototype; else {
var u = i;
if (!(s = u.__attrs__)) {
s = a(u, 0, h(i = u.constructor));
}
c = s;
}
if ("undefined" === ("object" === (e = typeof r) ? t(r) : e)) {
var _ = n + o, f = {};
for (l in s) l.startsWith(_) && (f[l.slice(_.length)] = s[l]);
return f;
}
if ("object" === ("object" === (e = typeof r) ? t(r) : e)) for (l in r) 95 !== l.charCodeAt(0) && (c[n + o + l] = r[l]); else 0;
}
function h(t) {
return t.hasOwnProperty("__attrs__") && t.__attrs__ || (function(t) {
for (var e, i = cc.Class.getInheritanceChain(t), n = i.length - 1; n >= 0; n--) {
var r = i[n];
r.hasOwnProperty("__attrs__") && r.__attrs__ || a(r, 0, (e = i[n + 1]) && e.__attrs__);
}
a(t, 0, (e = i[0]) && e.__attrs__);
return t.__attrs__;
})(t);
}
function l(t) {
return h(t).constructor.prototype;
}
cc.Integer = "Integer";
cc.Float = "Float";
0;
cc.Boolean = "Boolean";
cc.String = "String";
function u(t, e) {
0;
}
n.exports = {
attr: c,
getClassAttrs: h,
getClassAttrsProto: l,
setClassAttr: function(t, e, i, n) {
l(t)[e + o + i] = n;
},
DELIMETER: o,
getTypeChecker: u,
ObjectType: function(t) {
return {
type: "Object",
ctor: t,
_onAfterProp: !1
};
},
ScriptUuid: {}
};
}), {
"./CCClass": 160,
"./js": 180,
"./utils": 184
} ],
173: [ (function(i, n, r) {
var s = i("./js"), o = s.array.fastRemoveAt;
function a() {
this.callbacks = [];
this.targets = [];
this.isInvoking = !1;
this.containCanceled = !1;
}
var c = a.prototype;
c.removeBy = function(t, e) {
for (var i = this.callbacks, n = this.targets, r = 0; r < t.length; ++r) if (t[r] === e) {
o(i, r);
o(n, r);
--r;
}
};
c.cancel = function(t) {
this.callbacks[t] = this.targets[t] = null;
this.containCanceled = !0;
};
c.cancelAll = function() {
for (var t = this.callbacks, e = this.targets, i = 0; i < t.length; i++) t[i] = e[i] = null;
this.containCanceled = !0;
};
c.purgeCanceled = function() {
this.removeBy(this.callbacks, null);
this.containCanceled = !1;
};
var h = new s.Pool(function(t) {
t.callbacks.length = 0;
t.targets.length = 0;
t.isInvoking = !1;
t.containCanceled = !1;
}, 16);
h.get = function() {
return this._get() || new a();
};
function l() {
this._callbackTable = s.createMap(!0);
}
(c = l.prototype).add = function(t, e, i) {
var n = this._callbackTable[t];
n || (n = this._callbackTable[t] = h.get());
n.callbacks.push(e);
n.targets.push(i || null);
};
c.hasEventListener = function(t, e, i) {
var n = this._callbackTable[t];
if (!n) return !1;
var r = n.callbacks;
if (!e) {
if (n.isInvoking) {
for (var s = 0; s < r.length; s++) if (r[s]) return !0;
return !1;
}
return r.length > 0;
}
i = i || null;
for (var o = n.targets, a = 0; a < r.length; ++a) if (r[a] === e && o[a] === i) return !0;
return !1;
};
c.removeAll = function(i) {
if ("string" === ("object" === (e = typeof i) ? t(i) : e)) {
var n = this._callbackTable[i];
if (n) if (n.isInvoking) n.cancelAll(); else {
h.put(n);
delete this._callbackTable[i];
}
} else if (i) for (var r in this._callbackTable) {
var s = this._callbackTable[r];
if (s.isInvoking) for (var o = s.targets, a = 0; a < o.length; ++a) o[a] === i && s.cancel(a); else s.removeBy(s.targets, i);
}
};
c.remove = function(t, e, i) {
var n = this._callbackTable[t];
if (n) {
i = i || null;
for (var r = n.callbacks, s = n.targets, a = 0; a < r.length; ++a) if (r[a] === e && s[a] === i) {
if (n.isInvoking) n.cancel(a); else {
o(r, a);
o(s, a);
}
break;
}
}
};
var u = function() {
l.call(this);
};
s.extend(u, l);
0;
u.prototype.invoke = function(t, e, i, n, r, s) {
var o = this._callbackTable[t];
if (o) {
var a = !o.isInvoking;
o.isInvoking = !0;
for (var c = o.callbacks, h = o.targets, l = 0, u = c.length; l < u; ++l) {
var _ = c[l];
if (_) {
var f = h[l];
f ? _.call(f, e, i, n, r, s) : _(e, i, n, r, s);
}
}
if (a) {
o.isInvoking = !1;
o.containCanceled && o.purgeCanceled();
}
}
};
u.CallbacksHandler = l;
n.exports = u;
}), {
"./js": 180
} ],
174: [ (function(t, e, i) {
e.exports = {
flattenCodeArray: function(t) {
var e = [];
(function t(e, i) {
for (var n = 0; n < i.length; n++) {
var r = i[n];
Array.isArray(r) ? t(e, r) : e.push(r);
}
})(e, t);
return e.join("");
}
};
}), {} ],
175: [ (function(i, n, r) {
var s = i("./js"), o = i("./attribute"), a = i("./CCClass"), c = i("../utils/misc"), h = function() {
this.uuidList = [];
this.uuidObjList = [];
this.uuidPropList = [];
this._stillUseUrl = s.createMap(!0);
};
h.prototype.reset = function() {
this.uuidList.length = 0;
this.uuidObjList.length = 0;
this.uuidPropList.length = 0;
s.clear(this._stillUseUrl);
};
0;
h.prototype.push = function(t, e, i, n) {
n && (this._stillUseUrl[this.uuidList.length] = !0);
this.uuidList.push(i);
this.uuidObjList.push(t);
this.uuidPropList.push(e);
};
(h.pool = new s.Pool(function(t) {
t.reset();
}, 10)).get = function() {
return this._get() || new h();
};
var l = (function() {
function i(t, e, i, n, r) {
this.result = t;
this.customEnv = n;
this.deserializedList = [];
this.deserializedData = null;
this._classFinder = i;
0;
this._idList = [];
this._idObjList = [];
this._idPropList = [];
}
var n = i.prototype;
n.deserialize = function(t) {
if (Array.isArray(t)) {
var e = t, i = e.length;
this.deserializedList.length = i;
for (var n = 0; n < i; n++) if (e[n]) {
this.deserializedList[n] = this._deserializeObject(e[n], !1);
}
this.deserializedData = i > 0 ? this.deserializedList[0] : [];
} else {
this.deserializedList.length = 1;
this.deserializedData = t ? this._deserializeObject(t, !1) : null;
this.deserializedList[0] = this.deserializedData;
}
(function(t) {
var e, i, n, r = t.deserializedList, s = t._idPropList, o = t._idList, a = t._idObjList;
t._classFinder && t._classFinder.onDereferenced;
for (e = 0; e < o.length; e++) {
i = s[e];
n = o[e];
a[e][i] = r[n];
}
})(this);
return this.deserializedData;
};
n._deserializeObject = function(i, n, r, o, a) {
var c, l = null, u = null, _ = i.__type__;
if (_) {
if (!(u = this._classFinder(_, i, o, a))) {
this._classFinder === s._getClassById && cc.deserialize.reportMissingClass(_);
return null;
}
if ((l = new u())._deserialize) {
l._deserialize(i.content, this);
return l;
}
cc.Class._isCCClass(u) ? (function(t, e, i, n, r) {
var o;
if (n.hasOwnProperty("__deserialize__")) o = n.__deserialize__; else {
o = h(t, n);
s.value(n, "__deserialize__", o, !0);
}
o(t, e, i, n, r);
0;
})(this, l, i, u, r) : this._deserializeTypedObject(l, i, u);
} else if (Array.isArray(i)) {
l = new Array(i.length);
for (var f = 0; f < i.length; f++) {
c = i[f];
"object" === ("object" === (e = typeof c) ? t(c) : e) && c ? this._deserializeObjField(l, c, "" + f, null, n) : l[f] = c;
}
} else {
l = {};
this._deserializePrimitiveObject(l, i);
}
return l;
};
n._deserializeObjField = function(t, e, i, n, r) {
var s = e.__id__;
if (void 0 === s) {
var o = e.__uuid__;
o ? this.result.push(t, i, o, r) : t[i] = this._deserializeObject(e, r);
} else {
var a = this.deserializedList[s];
if (a) t[i] = a; else {
this._idList.push(s);
this._idObjList.push(t);
this._idPropList.push(i);
}
}
};
n._deserializePrimitiveObject = function(i, n) {
for (var r in n) if (n.hasOwnProperty(r)) {
var s = n[r];
"object" !== ("object" === (e = typeof s) ? t(s) : e) ? "__type__" !== r && (i[r] = s) : s ? this._deserializeObjField(i, s, r) : i[r] = null;
}
};
n._deserializeTypedObject = function(i, n, r) {
if (r !== cc.Vec2) if (r !== cc.Vec3) if (r !== cc.Color) if (r !== cc.Size) for (var s = o.DELIMETER + "default", c = o.getClassAttrs(r), h = r.__props__ || Object.keys(i), l = 0; l < h.length; l++) {
var u = h[l], _ = n[u];
void 0 !== _ && n.hasOwnProperty(u) || (_ = a.getDefault(c[u + s]));
"object" !== ("object" === (e = typeof _) ? t(_) : e) ? i[u] = _ : _ ? this._deserializeObjField(i, _, u) : i[u] = null;
} else {
i.width = n.width || 0;
i.height = n.height || 0;
} else {
i.r = n.r || 0;
i.g = n.g || 0;
i.b = n.b || 0;
var f = n.a;
i.a = void 0 === f ? 255 : f;
} else {
i.x = n.x || 0;
i.y = n.y || 0;
i.z = n.z || 0;
} else {
i.x = n.x || 0;
i.y = n.y || 0;
}
};
function r(t, e, i, n, r, o) {
if (e instanceof cc.ValueType) {
r || t.push("if(prop){");
var a = s.getClassName(e);
t.push("s._deserializeTypedObject(o" + i + ",prop," + a + ");");
r || t.push("}else o" + i + "=null;");
} else {
t.push("if(prop){");
t.push("s._deserializeObjField(o,prop," + n + ",null," + !!o + ");");
t.push("}else o" + i + "=null;");
}
}
var h = function(i, n) {
for (var h = o.DELIMETER + "type", l = (o.DELIMETER, o.DELIMETER + "default"), u = o.DELIMETER + "saveUrlAsAsset", _ = o.DELIMETER + "formerlySerializedAs", f = o.getClassAttrs(n), d = n.__values__, m = [ "var prop;" ], p = c.BUILTIN_CLASSID_RE.test(s._getClassId(n)), v = 0; v < d.length; v++) {
var y, g, x = d[v];
0;
if (a.IDENTIFIER_RE.test(x)) {
g = '"' + x + '"';
y = "." + x;
} else y = "[" + (g = a.escapeForJS(x)) + "]";
var C = y;
if (f[x + _]) {
var A = f[x + _];
C = a.IDENTIFIER_RE.test(A) ? "." + A : "[" + a.escapeForJS(A) + "]";
}
m.push("prop=d" + C + ";");
m.push('if(typeof (prop)!=="undefined"){');
var b = f[x + u], S = a.getDefault(f[x + l]);
if (p) {
var T, w = f[x + h];
if (void 0 === S && w) T = w === cc.String || w === cc.Integer || w === cc.Float || w === cc.Boolean; else {
var E = "object" === (e = typeof S) ? t(S) : e;
T = "string" === E && !b || "number" === E || "boolean" === E;
}
T ? m.push("o" + y + "=prop;") : r(m, S, y, g, !0, b);
} else {
m.push('if(typeof (prop)!=="object"){o' + y + "=prop;}else{");
r(m, S, y, g, !1, b);
m.push("}");
}
m.push("}");
}
if (cc.js.isChildClassOf(n, cc._BaseNode) || cc.js.isChildClassOf(n, cc.Component)) {
m.push("d._id&&(o._id=d._id);");
}
if ("_$erialized" === d[d.length - 1]) {
m.push("o._$erialized=JSON.parse(JSON.stringify(d));");
m.push("s._deserializePrimitiveObject(o._$erialized,d);");
}
return Function("s", "o", "d", "k", "t", m.join(""));
};
i.pool = new s.Pool(function(t) {
t.result = null;
t.customEnv = null;
t.deserializedList.length = 0;
t.deserializedData = null;
t._classFinder = null;
0;
t._idList.length = 0;
t._idObjList.length = 0;
t._idPropList.length = 0;
}, 1);
i.pool.get = function(t, e, n, r, s) {
var o = this._get();
if (o) {
o.result = t;
o.customEnv = r;
o._classFinder = n;
0;
return o;
}
return new i(t, e, n, r, s);
};
return i;
})();
cc.deserialize = function(i, n, r) {
var o = (r = r || {}).classFinder || s._getClassById, a = r.createAssetRefs || cc.sys.platform === cc.sys.EDITOR_CORE, c = r.customEnv, u = r.ignoreEditorOnly;
0;
"string" === ("object" === (e = typeof i) ? t(i) : e) && (i = JSON.parse(i));
var _ = !n;
n = n || h.pool.get();
var f = l.pool.get(n, !1, o, c, u);
cc.game._isCloning = !0;
var d = f.deserialize(i);
cc.game._isCloning = !1;
l.pool.put(f);
a && n.assignAssetsBy(Editor.serialize.asAsset);
_ && h.pool.put(n);
return d;
};
cc.deserialize.Details = h;
cc.deserialize.reportMissingClass = function(t) {
cc.warnID(5302, t);
};
}), {
"../utils/misc": 242,
"./CCClass": 160,
"./attribute": 172,
"./js": 180
} ],
176: [ (function(t, e, i) {
var n = ".";
function r(t) {
this.id = 0 | 998 * Math.random();
this.prefix = t ? t + n : "";
}
r.prototype.getNewId = function() {
return this.prefix + ++this.id;
};
r.global = new r("global");
e.exports = r;
}), {} ],
177: [ (function(t, e, i) {
t("./js");
t("./CCClass");
t("./CCClassDecorator");
t("./CCEnum");
t("./CCObject");
t("./callbacks-invoker");
t("./url");
t("./deserialize");
t("./instantiate");
t("./instantiate-jit");
t("./requiring-frame");
t("./CCSys");
t("./CCMacro");
t("./CCAssetLibrary");
t("./CCVisibleRect");
}), {
"./CCAssetLibrary": 159,
"./CCClass": 160,
"./CCClassDecorator": 161,
"./CCEnum": 162,
"./CCMacro": 165,
"./CCObject": 166,
"./CCSys": 169,
"./CCVisibleRect": 171,
"./callbacks-invoker": 173,
"./deserialize": 175,
"./instantiate": 179,
"./instantiate-jit": 178,
"./js": 180,
"./requiring-frame": 182,
"./url": 183
} ],
178: [ (function(i, n, r) {
var s = i("./CCObject"), o = s.Flags.Destroyed, a = s.Flags.PersistentMask, c = i("./attribute"), h = i("./js"), l = i("./CCClass"), u = i("./compiler"), _ = c.DELIMETER + "default", f = l.IDENTIFIER_RE, d = l.escapeForJS, m = "var ", p = "o", v = "t", y = {
"cc.Node": "cc.Node",
"cc.Sprite": "cc.Sprite",
"cc.Label": "cc.Label",
"cc.Button": "cc.Button",
"cc.Widget": "cc.Widget",
"cc.Animation": "cc.Animation",
"cc.ClickEvent": !1,
"cc.PrefabInfo": !1
};
function g(t, e) {
this.varName = t;
this.expression = e;
}
g.prototype.toString = function() {
return m + this.varName + "=" + this.expression + ";";
};
function x(t, e) {
return e instanceof g ? new g(e.varName, t + e.expression) : t + e;
}
function C(t, e, i) {
if (Array.isArray(i)) {
i[0] = x(e, i[0]);
t.push(i);
} else t.push(x(e, i) + ";");
}
function A(t) {
this._exps = [];
this._targetExp = t;
}
A.prototype.append = function(t, e) {
this._exps.push([ t, e ]);
};
A.prototype.writeCode = function(t) {
var e;
if (this._exps.length > 1) {
t.push(v + "=" + this._targetExp + ";");
e = v;
} else {
if (1 !== this._exps.length) return;
e = this._targetExp;
}
for (var i = 0; i < this._exps.length; i++) {
var n = this._exps[i];
C(t, e + S(n[0]) + "=", n[1]);
}
};
A.pool = new h.Pool(function(t) {
t._exps.length = 0;
t._targetExp = null;
}, 1);
A.pool.get = function(t) {
var e = this._get() || new A();
e._targetExp = t;
return e;
};
function b(i, n) {
if ("function" === ("object" === (e = typeof i) ? t(i) : e)) try {
i = i();
} catch (t) {
return !1;
}
if (i === n) return !0;
if (i && n) {
if (i instanceof cc.ValueType && i.equals(n)) return !0;
if (Array.isArray(i) && Array.isArray(n) || i.constructor === Object && n.constructor === Object) try {
return Array.isArray(i) && Array.isArray(n) && 0 === i.length && 0 === n.length;
} catch (t) {}
}
return !1;
}
function S(t) {
return f.test(t) ? "." + t : "[" + d(t) + "]";
}
function T(t, e) {
this.parent = e;
this.objsToClear_iN$t = [];
this.codeArray = [];
this.objs = [];
this.funcs = [];
this.funcModuleCache = h.createMap();
h.mixin(this.funcModuleCache, y);
this.globalVariables = [];
this.globalVariableId = 0;
this.localVariableId = 0;
this.codeArray.push(m + p + "," + v + ";", "if(R){", p + "=R;", "}else{", p + "=R=new " + this.getFuncModule(t.constructor, !0) + "();", "}");
h.value(t, "_iN$t", {
globalVar: "R"
}, !0);
this.objsToClear_iN$t.push(t);
this.enumerateObject(this.codeArray, t);
var i;
this.globalVariables.length > 0 && (i = m + this.globalVariables.join(",") + ";");
var n = u.flattenCodeArray([ "return (function(R){", i || [], this.codeArray, "return o;", "})" ]);
this.result = Function("O", "F", n)(this.objs, this.funcs);
for (var r = 0, s = this.objsToClear_iN$t.length; r < s; ++r) this.objsToClear_iN$t[r]._iN$t = null;
this.objsToClear_iN$t.length = 0;
}
var w = T.prototype;
w.getFuncModule = function(t, e) {
var i = h.getClassName(t);
if (i) {
var n = this.funcModuleCache[i];
if (n) return n;
if (void 0 === n) {
var r = -1 !== i.indexOf(".");
if (r) try {
if (r = t === Function("return " + i)()) {
this.funcModuleCache[i] = i;
return i;
}
} catch (t) {}
}
}
var s = this.funcs.indexOf(t);
if (s < 0) {
s = this.funcs.length;
this.funcs.push(t);
}
var o = "F[" + s + "]";
e && (o = "(" + o + ")");
this.funcModuleCache[i] = o;
return o;
};
w.getObjRef = function(t) {
var e = this.objs.indexOf(t);
if (e < 0) {
e = this.objs.length;
this.objs.push(t);
}
return "O[" + e + "]";
};
w.setValueType = function(t, e, i, n) {
var r = A.pool.get(n), s = e.constructor.__props__;
s || (s = Object.keys(e));
for (var o = 0; o < s.length; o++) {
var a = s[o], c = i[a];
if (e[a] !== c) {
var h = this.enumerateField(i, a, c);
r.append(a, h);
}
}
r.writeCode(t);
A.pool.put(r);
};
w.enumerateCCClass = function(i, n, r) {
for (var s = r.__values__, o = c.getClassAttrs(r), a = 0; a < s.length; a++) {
var h = s[a], u = n[h], f = o[h + _];
if (!b(f, u)) if ("object" === ("object" === (e = typeof u) ? t(u) : e) && u instanceof cc.ValueType && (f = l.getDefault(f)) && f.constructor === u.constructor) {
var d = p + S(h);
this.setValueType(i, f, u, d);
} else this.setObjProp(i, n, h, u);
}
};
w.instantiateArray = function(t) {
if (0 === t.length) return "[]";
var e = "a" + ++this.localVariableId, i = [ new g(e, "new Array(" + t.length + ")") ];
h.value(t, "_iN$t", {
globalVar: "",
source: i
}, !0);
this.objsToClear_iN$t.push(t);
for (var n = 0; n < t.length; ++n) {
C(i, e + "[" + n + "]=", this.enumerateField(t, n, t[n]));
}
return i;
};
w.enumerateField = function(i, n, r) {
if ("object" === ("object" === (e = typeof r) ? t(r) : e) && r) {
var o = r._iN$t;
if (o) {
var c = o.globalVar;
if (!c) {
c = o.globalVar = "v" + ++this.globalVariableId;
this.globalVariables.push(c);
var h = o.source[0];
o.source[0] = x(c + "=", h);
}
return c;
}
return Array.isArray(r) ? this.instantiateArray(r) : this.instantiateObj(r);
}
if ("function" === ("object" === (e = typeof r) ? t(r) : e)) return this.getFuncModule(r);
if ("string" === ("object" === (e = typeof r) ? t(r) : e)) return d(r);
"_objFlags" === n && i instanceof s && (r &= a);
return r;
};
w.setObjProp = function(t, e, i, n) {
C(t, p + S(i) + "=", this.enumerateField(e, i, n));
};
w.enumerateObject = function(i, n) {
var r = n.constructor;
if (cc.Class._isCCClass(r)) this.enumerateCCClass(i, n, r); else for (var s in n) if (n.hasOwnProperty(s) && (95 !== s.charCodeAt(0) || 95 !== s.charCodeAt(1) || "__type__" === s)) {
var o = n[s];
"object" === ("object" === (e = typeof o) ? t(o) : e) && o && o === n._iN$t || this.setObjProp(i, n, s, o);
}
};
w.instantiateObj = function(t) {
if (t instanceof cc.ValueType) return l.getNewValueTypeCode(t);
if (t instanceof cc.Asset) return this.getObjRef(t);
if (t._objFlags & o) return null;
var e, i = t.constructor;
if (cc.Class._isCCClass(i)) {
if (this.parent) if (this.parent instanceof cc.Component) {
if (t instanceof cc._BaseNode || t instanceof cc.Component) return this.getObjRef(t);
} else if (this.parent instanceof cc._BaseNode) if (t instanceof cc._BaseNode) {
if (!t.isChildOf(this.parent)) return this.getObjRef(t);
} else if (t instanceof cc.Component && !t.node.isChildOf(this.parent)) return this.getObjRef(t);
e = new g(p, "new " + this.getFuncModule(i, !0) + "()");
} else if (i === Object) e = new g(p, "{}"); else {
if (i) return this.getObjRef(t);
e = new g(p, "Object.create(null)");
}
var n = [ e ];
h.value(t, "_iN$t", {
globalVar: "",
source: n
}, !0);
this.objsToClear_iN$t.push(t);
this.enumerateObject(n, t);
return [ "(function(){", n, "return o;})();" ];
};
n.exports = {
compile: function(t) {
return new T(t, t instanceof cc._BaseNode && t).result;
},
equalsToDefault: b
};
0;
}), {
"./CCClass": 160,
"./CCObject": 166,
"./attribute": 172,
"./compiler": 174,
"./js": 180
} ],
179: [ (function(i, n, r) {
var s = i("./CCObject"), o = i("../value-types/value-type"), a = s.Flags.Destroyed, c = s.Flags.PersistentMask, h = i("./utils").isDomNode, l = i("./js");
function u(i, n) {
if (!n) {
if ("object" !== ("object" === (e = typeof i) ? t(i) : e) || Array.isArray(i)) {
0;
return null;
}
if (!i) {
0;
return null;
}
if (!cc.isValid(i)) {
0;
return null;
}
0;
}
var r;
if (i instanceof s) {
if (i._instantiate) {
cc.game._isCloning = !0;
r = i._instantiate();
cc.game._isCloning = !1;
return r;
}
if (i instanceof cc.Asset) {
0;
return null;
}
}
cc.game._isCloning = !0;
r = f(i);
cc.game._isCloning = !1;
return r;
}
var _ = [];
function f(t, e) {
if (Array.isArray(t)) {
0;
return null;
}
if (h && h(t)) {
0;
return null;
}
var i;
if (t._iN$t) i = t._iN$t; else if (t.constructor) {
i = new (0, t.constructor)();
} else i = Object.create(null);
d(t, i, e);
for (var n = 0, r = _.length; n < r; ++n) _[n]._iN$t = null;
_.length = 0;
return i;
}
function d(i, n, r) {
l.value(i, "_iN$t", n, !0);
_.push(i);
var a = i.constructor;
if (cc.Class._isCCClass(a)) (function(i, n, r, s) {
for (var a = i.__values__, c = 0; c < a.length; c++) {
var h = a[c], l = n[h];
if ("object" === ("object" == (e = typeof l) ? t(l) : e) && l) {
var u = r[h];
u instanceof o && u.constructor === l.constructor ? u.set(l) : r[h] = l._iN$t || m(l, s);
} else r[h] = l;
}
})(a, i, n, r); else for (var h in i) if (i.hasOwnProperty(h) && (95 !== h.charCodeAt(0) || 95 !== h.charCodeAt(1) || "__type__" === h)) {
var u = i[h];
if ("object" === ("object" === (e = typeof u) ? t(u) : e) && u) {
if (u === n) continue;
n[h] = u._iN$t || m(u, r);
} else n[h] = u;
}
i instanceof s && (n._objFlags &= c);
}
function m(i, n) {
if (i instanceof o) return i.clone();
if (i instanceof cc.Asset) return i;
var r;
if (Array.isArray(i)) {
var s = i.length;
r = new Array(s);
l.value(i, "_iN$t", r, !0);
for (var c = 0; c < s; ++c) {
var h = i[c];
"object" === ("object" === (e = typeof h) ? t(h) : e) && h ? r[c] = h._iN$t || m(h, n) : r[c] = h;
}
_.push(i);
return r;
}
if (i._objFlags & a) return null;
var u = i.constructor;
if (cc.Class._isCCClass(u)) {
if (n) if (n instanceof cc.Component) {
if (i instanceof cc._BaseNode || i instanceof cc.Component) return i;
} else if (n instanceof cc._BaseNode) if (i instanceof cc._BaseNode) {
if (!i.isChildOf(n)) return i;
} else if (i instanceof cc.Component && !i.node.isChildOf(n)) return i;
r = new u();
} else if (u === Object) r = {}; else {
if (u) return i;
r = Object.create(null);
}
d(i, r, n);
return r;
}
u._clone = f;
cc.instantiate = u;
n.exports = u;
}), {
"../value-types/value-type": 257,
"./CCObject": 166,
"./js": 180,
"./utils": 184
} ],
180: [ (function(i, n, r) {
var s = new (i("./id-generater"))("TmpCId.");
function o(t, e) {
for (;t; ) {
var i = Object.getOwnPropertyDescriptor(t, e);
if (i) return i;
t = Object.getPrototypeOf(t);
}
return null;
}
function a(t, e, i) {
var n = o(e, t);
Object.defineProperty(i, t, n);
}
var c = {
isNumber: function(i) {
return "number" === ("object" === (e = typeof i) ? t(i) : e) || i instanceof Number;
},
isString: function(i) {
return "string" === ("object" === (e = typeof i) ? t(i) : e) || i instanceof String;
},
addon: function(i) {
"use strict";
i = i || {};
for (var n = 1, r = arguments.length; n < r; n++) {
var s = arguments[n];
if (s) {
if ("object" !== ("object" === (e = typeof s) ? t(s) : e)) {
cc.errorID(5402, s);
continue;
}
for (var o in s) o in i || a(o, s, i);
}
}
return i;
},
mixin: function(i) {
"use strict";
i = i || {};
for (var n = 1, r = arguments.length; n < r; n++) {
var s = arguments[n];
if (s) {
if ("object" !== ("object" === (e = typeof s) ? t(s) : e)) {
cc.errorID(5403, s);
continue;
}
for (var o in s) a(o, s, i);
}
}
return i;
},
extend: function(t, e) {
0;
for (var 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;
},
getSuper: function(t) {
var e = t.prototype, i = e && Object.getPrototypeOf(e);
return i && i.constructor;
},
isChildClassOf: function(i, n) {
if (i && n) {
if ("function" !== ("object" === (e = typeof i) ? t(i) : e)) return !1;
if ("function" !== ("object" === (e = typeof n) ? t(n) : e)) {
0;
return !1;
}
if (i === n) return !0;
for (;;) {
if (!(i = c.getSuper(i))) return !1;
if (i === n) return !0;
}
}
return !1;
},
clear: function(t) {
for (var e = Object.keys(t), i = 0; i < e.length; i++) delete t[e[i]];
},
isEmptyObject: function(t) {
for (var e in t) return !1;
return !0;
},
getPropertyDescriptor: o
}, h = {
value: void 0,
enumerable: !1,
writable: !1,
configurable: !0
};
c.value = function(t, e, i, n, r) {
h.value = i;
h.writable = n;
h.enumerable = r;
Object.defineProperty(t, e, h);
h.value = void 0;
};
var l = {
get: null,
set: null,
enumerable: !1
};
c.getset = function(i, n, r, s, o) {
if ("function" !== ("object" === (e = typeof s) ? t(s) : e)) {
o = s;
s = void 0;
}
l.get = r;
l.set = s;
l.enumerable = o;
Object.defineProperty(i, n, l);
l.get = null;
l.set = null;
};
var u = {
get: null,
enumerable: !1,
configurable: !1
};
c.get = function(t, e, i, n, r) {
u.get = i;
u.enumerable = n;
u.configurable = r;
Object.defineProperty(t, e, u);
u.get = null;
};
var _ = {
set: null,
enumerable: !1,
configurable: !1
};
c.set = function(t, e, i, n, r) {
_.set = i;
_.enumerable = n;
_.configurable = r;
Object.defineProperty(t, e, _);
_.set = null;
};
c.getClassName = function(i) {
if ("function" === ("object" === (e = typeof i) ? t(i) : e)) {
var n = i.prototype;
if (n && n.hasOwnProperty("__classname__") && n.__classname__) return n.__classname__;
var r = "";
i.name && (r = i.name);
if (i.toString) {
var s, o = i.toString();
(s = "[" === o.charAt(0) ? o.match(/\[\w+\s*(\w+)\]/) : o.match(/function\s*(\w+)/)) && 2 === s.length && (r = s[1]);
}
return "Object" !== r ? r : "";
}
return i && i.constructor ? c.getClassName(i.constructor) : "";
};
(function() {
var i = {}, n = {};
function r(t, e, i) {
c.getset(c, e, (function() {
return Object.assign({}, i);
}), (function(t) {
c.clear(i);
Object.assign(i, t);
}));
return function(e, n) {
n.prototype.hasOwnProperty(t) && delete i[n.prototype[t]];
c.value(n.prototype, t, e);
if (e) {
var r = i[e];
if (r && r !== n) {
var s = "A Class already exists with the same " + t + ' : "' + e + '".';
0;
cc.error(s);
} else i[e] = n;
}
};
}
c._setClassId = r("__cid__", "_registeredClassIds", i);
var o = r("__classname__", "_registeredClassNames", n);
c.setClassName = function(t, e) {
o(t, e);
if (!e.prototype.hasOwnProperty("__cid__")) {
var i = t || s.getNewId();
i && c._setClassId(i, e);
}
};
c.unregisterClass = function() {
for (var t = 0; t < arguments.length; t++) {
var e = arguments[t].prototype, r = e.__cid__;
r && delete i[r];
var s = e.__classname__;
s && delete n[s];
}
};
c._getClassById = function(t) {
return i[t];
};
c.getClassByName = function(t) {
return n[t];
};
c._getClassId = function(i, n) {
n = "undefined" === ("object" === (e = typeof n) ? t(n) : e) || n;
if ("function" === ("object" === (e = typeof i) ? t(i) : e) && i.prototype.hasOwnProperty("__cid__")) {
0;
return i.prototype.__cid__;
}
if (i && i.constructor) {
var r = i.constructor.prototype;
if (r && r.hasOwnProperty("__cid__")) {
0;
return i.__cid__;
}
}
return "";
};
})();
c.obsolete = function(t, e, i, n) {
var r = /([^.]+)$/, s = r.exec(e)[0], o = r.exec(i)[0];
function a() {
0;
return this[o];
}
n ? c.getset(t, s, a, (function(t) {
0;
this[o] = t;
})) : c.get(t, s, a);
};
c.obsoletes = function(t, e, i, n) {
for (var r in i) {
var s = i[r];
c.obsolete(t, e + "." + r, s, n);
}
};
var f = /(%d)|(%s)/, d = /%s/;
c.formatStr = function() {
var i = arguments.length;
if (0 === i) return "";
var n = arguments[0];
if (1 === i) return "" + n;
if ("string" === ("object" === (e = typeof n) ? t(n) : e) && f.test(n)) for (var r = 1; r < i; ++r) {
var s = arguments[r], o = "number" === ("object" === (e = typeof s) ? t(s) : e) ? f : d;
o.test(n) ? n = n.replace(o, s) : n += " " + s;
} else for (var a = 1; a < i; ++a) n += " " + arguments[a];
return n;
};
c.shiftArguments = function() {
for (var t = arguments.length - 1, e = new Array(t), i = 0; i < t; ++i) e[i] = arguments[i + 1];
return e;
};
c.createMap = function(t) {
var e = Object.create(null);
if (t) {
e["."] = !0;
e["/"] = !0;
delete e["."];
delete e["/"];
}
return e;
};
function m(t, e) {
t.splice(e, 1);
}
function p(t, e) {
var i = t.indexOf(e);
if (i >= 0) {
m(t, i);
return !0;
}
return !1;
}
var v = Array.prototype.indexOf;
c.array = {
remove: p,
fastRemove: function(t, e) {
var i = t.indexOf(e);
if (i >= 0) {
t[i] = t[t.length - 1];
--t.length;
}
},
removeAt: m,
fastRemoveAt: function(t, e) {
var i = t.length;
if (!(e < 0 || e >= i)) {
t[e] = t[i - 1];
t.length = i - 1;
}
},
contains: function(t, e) {
return t.indexOf(e) >= 0;
},
verifyType: function(t, e) {
if (t && t.length > 0) for (var i = 0; i < t.length; i++) if (!(t[i] instanceof e)) {
cc.logID(1300);
return !1;
}
return !0;
},
removeArray: function(t, e) {
for (var i = 0, n = e.length; i < n; i++) p(t, e[i]);
},
appendObjectsAt: function(t, e, i) {
t.splice.apply(t, [ i, 0 ].concat(e));
return t;
},
copy: function(t) {
var e, i = t.length, n = new Array(i);
for (e = 0; e < i; e += 1) n[e] = t[e];
return n;
},
indexOf: v,
MutableForwardIterator: i("../utils/mutable-forward-iterator")
};
function y(t, e) {
if (void 0 === e) {
e = t;
t = null;
}
this.get = null;
this.count = 0;
this._pool = new Array(e);
this._cleanup = t;
}
y.prototype._get = function() {
if (this.count > 0) {
--this.count;
var t = this._pool[this.count];
this._pool[this.count] = null;
return t;
}
return null;
};
y.prototype.put = function(t) {
var e = this._pool;
if (this.count < e.length) {
if (this._cleanup && !1 === this._cleanup(t)) return;
e[this.count] = t;
++this.count;
}
};
y.prototype.resize = function(t) {
if (t >= 0) {
this._pool.length = t;
this.count > t && (this.count = t);
}
};
c.Pool = y;
cc.js = c;
n.exports = c;
}), {
"../utils/mutable-forward-iterator": 243,
"./id-generater": 176
} ],
181: [ (function(i, n, r) {
var s = i("./js"), o = {
url: {
canUsedInGet: !0
},
default: {},
serializable: {},
editorOnly: {},
formerlySerializedAs: {}
};
function a(t, e, i, n) {
if (t.get || t.set) 0; else if (t.hasOwnProperty("default")) {
var r = "_N$" + e;
t.get = function() {
return this[r];
};
t.set = function(t) {
var e = this[r];
this[r] = t;
i.call(this, e);
};
0;
var s = {};
n[r] = s;
for (var a in o) {
var c = o[a];
if (t.hasOwnProperty(a)) {
s[a] = t[a];
c.canUsedInGet || delete t[a];
}
}
} else 0;
}
function c(t, e, i, n) {
Array.isArray(n) && n.length > 0 && (n = n[0]);
0;
t.type = n;
}
function h(t, e, i, n) {
if (Array.isArray(e)) {
if (!(e.length > 0)) return cc.errorID(5508, i, n);
if (cc.RawAsset.isRawAssetType(e[0])) {
t.url = e[0];
delete t.type;
return;
}
t.type = e = e[0];
}
0;
}
r.getFullFormOfProperty = function(i, n, r) {
if (!(i && i.constructor === Object)) {
if (Array.isArray(i) && i.length > 0) {
var o = i[0];
0;
return {
default: [],
type: i,
_short: !0
};
}
if ("function" === ("object" === (e = typeof i) ? t(i) : e)) {
o = i;
if (!cc.RawAsset.isRawAssetType(o)) {
if (!cc.RawAsset.wasRawAssetType(o)) return {
default: s.isChildClassOf(o, cc.ValueType) ? new o() : null,
type: o,
_short: !0
};
0;
}
return {
default: "",
url: o,
_short: !0
};
}
return {
default: i,
_short: !0
};
}
return null;
};
r.preprocessAttrs = function(t, e, i, n) {
for (var s in t) {
var o = t[s], l = r.getFullFormOfProperty(o, s, e);
l && (o = t[s] = l);
if (o) {
var u = o.notify;
u && a(o, s, u, t);
"type" in o && h(o, o.type, e, s);
"url" in o && c(o, 0, 0, o.url);
"type" in o && o.type;
}
}
};
0;
r.validateMethodWithProps = function(i, n, r, s, o) {
0;
if ("function" !== ("object" === (e = typeof i) ? t(i) : e) && null !== i) {
return !1;
}
0;
return !0;
};
}), {
"./CCClass": 160,
"./js": 180
} ],
182: [ (function(t, e, i) {
var n = [];
cc._RF = {
push: function(t, e, i) {
if (void 0 === i) {
i = e;
e = "";
}
n.push({
uuid: e,
script: i,
module: t,
exports: t.exports,
beh: null
});
},
pop: function() {
var t = n.pop(), e = t.module, i = e.exports;
if (i === t.exports) {
for (var r in i) return;
e.exports = i = t.cls;
}
},
peek: function() {
return n[n.length - 1];
}
};
0;
}), {} ],
183: [ (function(t, e, i) {
cc.url = {
_rawAssets: "",
normalize: function(t) {
t && (46 === t.charCodeAt(0) && 47 === t.charCodeAt(1) ? t = t.slice(2) : 47 === t.charCodeAt(0) && (t = t.slice(1)));
return t;
},
raw: function(t) {
0;
if ((t = this.normalize(t)).startsWith("resources/")) {
var e = cc.loader._getResUuid(t.slice(10), cc.Asset, !0);
if (e) return cc.AssetLibrary.getLibUrlNoExt(e, !0) + cc.path.extname(t);
} else cc.errorID(7002, t);
return this._rawAssets + t;
},
_init: function(t) {
this._rawAssets = cc.path.stripSep(t) + "/";
}
};
e.exports = cc.url;
}), {} ],
184: [ (function(i, n, r) {
i("./js");
n.exports = {
contains: function(i, n) {
if ("function" == ("object" === (e = typeof i.contains) ? t(i.contains) : e)) return i.contains(n);
if ("function" == ("object" === (e = typeof i.compareDocumentPosition) ? t(i.compareDocumentPosition) : e)) return !!(16 & i.compareDocumentPosition(n));
var r = n.parentNode;
if (r) do {
if (r === i) return !0;
r = r.parentNode;
} while (null !== r);
return !1;
},
isDomNode: "object" === (e = typeof window, "object" === e ? t(window) : e) && ("function" === (e = typeof Node, 
"object" === e ? t(Node) : e) ? function(t) {
return t instanceof Node;
} : function(i) {
return i && "object" === ("object" === (e = typeof i) ? t(i) : e) && "number" === ("object" === (e = typeof i.nodeType) ? t(i.nodeType) : e) && "string" === ("object" === (e = typeof i.nodeName) ? t(i.nodeName) : e);
}),
callInNextTick: function(t, e, i) {
t && setTimeout((function() {
t(e, i);
}), 0);
}
};
0;
0;
}), {
"./js": 180
} ],
185: [ (function(t, e, i) {
t("./platform/js");
t("./value-types");
t("./utils");
t("./platform/CCInputManager");
t("./platform/CCInputExtension");
t("./event");
t("./platform/CCSys");
t("./platform/CCMacro");
t("./load-pipeline");
t("./CCDirector");
t("./renderer");
t("./platform/CCView");
t("./platform/CCScreen");
t("./CCScheduler");
t("./event-manager");
}), {
"./CCDirector": 27,
"./CCScheduler": 32,
"./event": 104,
"./event-manager": 100,
"./load-pipeline": 119,
"./platform/CCInputExtension": 163,
"./platform/CCInputManager": 164,
"./platform/CCMacro": 165,
"./platform/CCScreen": 168,
"./platform/CCSys": 169,
"./platform/CCView": 170,
"./platform/js": 180,
"./renderer": 201,
"./utils": 240,
"./value-types": 252
} ],
186: [ (function(t, e, i) {
var n = function() {};
n.prototype = {
constructor: n,
_reset: function() {},
render: function() {}
};
e.exports = n;
}), {} ],
187: [ (function(t, e, i) {
e.exports = {
ForwardRenderer: t("./forward-renderer"),
RenderComponentHandle: t("./render-component-handle"),
_renderers: t("./renderers")
};
}), {
"./forward-renderer": 186,
"./render-component-handle": 188,
"./renderers": 191
} ],
188: [ (function(t, e, i) {
t("./renderers");
var n = function(t, e) {
this._device = t;
this._camera = e;
this.parentOpacity = 1;
this.parentOpacityDirty = 0;
this.worldMatDirty = 0;
this.walking = !1;
};
n.prototype = {
constructor: n,
reset: function() {
var t = this._device._ctx, e = this._device._canvas, i = cc.Camera.main ? cc.Camera.main.backgroundColor : cc.color(), n = "rgba(" + i.r + ", " + i.g + ", " + i.b + ", " + i.a / 255 + ")";
t.fillStyle = n;
t.setTransform(1, 0, 0, 1, 0, 0);
t.clearRect(0, 0, e.width, e.height);
t.fillRect(0, 0, e.width, e.height);
this._device._stats.drawcalls = 0;
},
terminate: function() {
this.walking = !1;
},
_commitComp: function(t, e) {
var i = this._device._ctx, n = this._camera;
i.setTransform(n.a, n.b, n.c, n.d, n.tx, n.ty);
i.scale(1, -1);
e.draw(i, t);
}
};
e.exports = n;
}), {
"./renderers": 191
} ],
189: [ (function(t, e, i) {
var n = t("../../../../graphics/helper"), r = t("../../../../graphics/types"), s = t("../../../../platform/js"), o = (r.PointFlags, 
r.LineJoin), a = r.LineCap;
function c() {
this.cmds = [];
this.style = {
strokeStyle: "black",
fillStyle: "white",
lineCap: "butt",
lineJoin: "miter",
miterLimit: 10
};
}
var h = c.prototype;
s.mixin(h, {
moveTo: function(t, e) {
this.cmds.push([ "moveTo", [ t, e ] ]);
},
lineTo: function(t, e) {
this.cmds.push([ "lineTo", [ t, e ] ]);
},
bezierCurveTo: function(t, e, i, n, r, s) {
this.cmds.push([ "bezierCurveTo", [ t, e, i, n, r, s ] ]);
},
quadraticCurveTo: function(t, e, i, n) {
this.cmds.push([ "quadraticCurveTo", [ t, e, i, n ] ]);
},
arc: function(t, e, i, r, s, o) {
n.arc(this, t, e, i, r, s, o);
},
ellipse: function(t, e, i, r) {
n.ellipse(this, t, e, i, r);
},
circle: function(t, e, i) {
n.ellipse(this, t, e, i, i);
},
rect: function(t, e, i, n) {
this.moveTo(t, e);
this.lineTo(t, e + n);
this.lineTo(t + i, e + n);
this.lineTo(t + i, e);
this.close();
},
roundRect: function(t, e, i, r, s) {
n.roundRect(this, t, e, i, r, s);
},
clear: function(t, e) {
this.cmds.length = 0;
},
close: function() {
this.cmds.push([ "closePath", [] ]);
},
stroke: function() {
this.cmds.push([ "stroke", [] ]);
},
fill: function() {
this.cmds.push([ "fill", [] ]);
}
});
s.set(h, "strokeColor", (function(t) {
var e = "rgba(" + (0 | t.r) + "," + (0 | t.g) + "," + (0 | t.b) + "," + t.a / 255 + ")";
this.cmds.push([ "strokeStyle", e ]);
this.style.strokeStyle = e;
}));
s.set(h, "fillColor", (function(t) {
var e = "rgba(" + (0 | t.r) + "," + (0 | t.g) + "," + (0 | t.b) + "," + t.a / 255 + ")";
this.cmds.push([ "fillStyle", e ]);
this.style.fillStyle = e;
}));
s.set(h, "lineWidth", (function(t) {
this.cmds.push([ "lineWidth", t ]);
this.style.lineWidth = t;
}));
s.set(h, "lineCap", (function(t) {
var e = "butt";
t === a.BUTT ? e = "butt" : t === a.ROUND ? e = "round" : t === a.SQUARE && (e = "square");
this.cmds.push([ "lineCap", e ]);
this.style.lineCap = e;
}));
s.set(h, "lineJoin", (function(t) {
var e = "bevel";
t === o.BEVEL ? e = "bevel" : t === o.ROUND ? e = "round" : t === o.MITER && (e = "miter");
this.cmds.push([ "lineJoin", e ]);
this.style.lineJoin = e;
}));
s.set(h, "miterLimit", (function(t) {
this.cmds.push([ "miterLimit", t ]);
this.style.miterLimit = t;
}));
e.exports = c;
}), {
"../../../../graphics/helper": 107,
"../../../../graphics/types": 109,
"../../../../platform/js": 180
} ],
190: [ (function(i, n, r) {
var s = i("./impl");
n.exports = {
createImpl: function() {
return new s();
},
draw: function(i, n) {
var r = n.node, s = r._worldMatrix, o = s.m00, a = s.m01, c = s.m04, h = s.m05, l = s.m12, u = s.m13;
i.transform(o, a, c, h, l, u);
i.save();
i.globalAlpha = r.opacity / 255;
var _ = n._impl.style;
i.strokeStyle = _.strokeStyle;
i.fillStyle = _.fillStyle;
i.lineWidth = _.lineWidth;
i.lineJoin = _.lineJoin;
i.miterLimit = _.miterLimit;
for (var f = !0, d = n._impl.cmds, m = 0, p = d.length; m < p; m++) {
var v = d[m], y = v[0], g = v[1];
if ("moveTo" === y && f) {
i.beginPath();
f = !1;
} else "fill" !== y && "stroke" !== y && "fillRect" !== y || (f = !0);
"function" === ("object" === (e = typeof i[y]) ? t(i[y]) : e) ? i[y].apply(i, g) : i[y] = g;
}
i.restore();
return 1;
},
stroke: function(t) {
t._impl.stroke();
},
fill: function(t) {
t._impl.fill();
}
};
}), {
"./impl": 189
} ],
191: [ (function(t, e, i) {
var n = t("../../../platform/js"), r = t("../../../components/CCSprite"), s = t("../../../components/CCLabel"), o = t("../../../components/CCMask"), a = t("../../../graphics/graphics"), c = t("./sprite"), h = t("./label"), l = t("./graphics"), u = t("./mask"), _ = {}, f = {};
function d(t, e, i) {
var r = n.getClassName(t);
_[r] = e;
i && (f[r] = i);
t._assembler = e;
t._postAssembler = i;
}
d(r, c);
d(s, h);
o && d(o, u.beforeHandler, u.afterHandler);
a && d(a, l);
e.exports = {
map: _,
postMap: f,
addRenderer: d
};
}), {
"../../../components/CCLabel": 69,
"../../../components/CCMask": 72,
"../../../components/CCSprite": 82,
"../../../graphics/graphics": 106,
"../../../platform/js": 180,
"./graphics": 190,
"./label": 193,
"./mask": 195,
"./sprite": 196
} ],
192: [ (function(t, e, i) {
var n = t("../../../utils/label/bmfont"), r = t("../../../../platform/js"), s = t("../utils");
e.exports = r.addon({
createData: function(t) {
return t.requestRenderData();
},
appendQuad: function(t, e, i, n, r, s, o) {
var a = t.dataLength;
t.dataLength += 2;
var c = t._data, h = (e.width, e.height, i.width), l = i.height, u = void 0, _ = void 0, f = void 0, d = void 0;
if (n) {
u = i.x;
f = i.x + l;
_ = i.y;
d = i.y + h;
c[a].u = u;
c[a].v = d;
c[a + 1].u = u;
c[a + 1].v = _;
} else {
u = i.x;
f = i.x + h;
_ = i.y;
d = i.y + l;
c[a].u = u;
c[a].v = _;
c[a + 1].u = f;
c[a + 1].v = d;
}
c[a].x = r;
c[a].y = s - l * o;
c[a + 1].x = r + h * o;
c[a + 1].y = s;
},
draw: function(t, e) {
var i = e.node, n = i._worldMatrix, r = n.m00, o = n.m01, a = n.m04, c = n.m05, h = n.m12, l = n.m13;
t.transform(r, o, a, c, h, l);
t.scale(1, -1);
t.globalAlpha = i.opacity / 255;
for (var u = e._frame._texture, _ = e._renderData._data, f = s.getColorizedImage(u, i._color), d = 0, m = _.length; d < m; d += 2) {
var p = _[d].x, v = _[d].y, y = _[d + 1].x - p, g = _[d + 1].y - v;
v = -v - g;
var x = _[d].u, C = _[d].v, A = _[d + 1].u - x, b = _[d + 1].v - C;
t.drawImage(f, x, C, A, b, p, v, y, g);
}
return 1;
}
}, n);
}), {
"../../../../platform/js": 180,
"../../../utils/label/bmfont": 206,
"../utils": 200
} ],
193: [ (function(t, e, i) {
var n = t("../../../../components/CCLabel"), r = t("./ttf"), s = t("./bmfont"), o = {
pool: [],
get: function() {
var t = this.pool.pop();
if (!t) {
var e = document.createElement("canvas");
t = {
canvas: e,
context: e.getContext("2d")
};
}
return t;
},
put: function(t) {
this.pool.length >= 32 || this.pool.push(t);
}
};
n._canvasPool = o;
e.exports = {
getAssembler: function(t) {
var e = r;
t.font instanceof cc.BitmapFont && (e = s);
return e;
},
createData: function(t) {
return t._assembler.createData(t);
},
draw: function(t, e) {
if (!e._texture) return 0;
var i = e._assembler;
if (!i) return 0;
i.updateRenderData(e);
return i.draw(t, e);
}
};
}), {
"../../../../components/CCLabel": 69,
"./bmfont": 192,
"./ttf": 194
} ],
194: [ (function(t, e, i) {
var n = t("../../../utils/label/ttf"), r = t("../../../../platform/js"), s = t("../utils");
e.exports = r.addon({
createData: function(t) {
var e = t.requestRenderData();
e.dataLength = 2;
return e;
},
_updateVerts: function(t) {
var e = t._renderData, i = t.node, n = i.width, r = i.height, s = i.anchorX * n, o = i.anchorY * r, a = e._data;
a[0].x = -s;
a[0].y = -o;
a[1].x = n - s;
a[1].y = r - o;
},
_updateTexture: function(t) {
n._updateTexture(t);
var e = t._frame._texture;
s.dropColorizedImage(e, t.node.color);
},
draw: function(t, e) {
var i = e.node, n = i._worldMatrix, r = n.m00, s = n.m01, o = n.m04, a = n.m05, c = n.m12, h = n.m13;
t.transform(r, s, o, a, c, h);
t.scale(1, -1);
t.globalAlpha = i.opacity / 255;
var l = e._frame._texture, u = e._renderData._data, _ = l.getHtmlElementObj(), f = u[0].x, d = u[0].y, m = u[1].x - f, p = u[1].y - d;
d = -d - p;
t.drawImage(_, f, d, m, p);
return 1;
}
}, n);
}), {
"../../../../platform/js": 180,
"../../../utils/label/ttf": 209,
"../utils": 200
} ],
195: [ (function(t, e, i) {
t("../../../components/CCMask");
var n = t("./graphics"), r = {
updateRenderData: function(t) {},
draw: function(t, e) {
t.save();
n.draw(t, e._graphics);
t.clip();
}
};
e.exports = {
beforeHandler: r,
afterHandler: {
updateRenderData: function(t) {},
draw: function(t, e) {
t.restore();
}
}
};
}), {
"../../../components/CCMask": 72,
"./graphics": 190
} ],
196: [ (function(t, e, i) {
var n = t("../../../../components/CCSprite"), r = n.Type, s = n.FillType, o = t("./simple"), a = t("./sliced"), c = t("./tiled");
0;
e.exports = {
getAssembler: function(t) {
switch (t.type) {
case r.SIMPLE:
return o;

case r.SLICED:
return a;

case r.TILED:
return c;

case r.FILLED:
return t._fillType, s.RADIAL, null;
}
},
createData: function(t) {
return t._assembler.createData(t);
}
};
}), {
"../../../../components/CCSprite": 82,
"../../../webgl/assemblers/sprite/index.js": 221,
"./simple": 197,
"./sliced": 198,
"./tiled": 199
} ],
197: [ (function(t, e, i) {
var n = t("../utils"), r = {
createData: function(t) {
var e = t.requestRenderData();
e.dataLength = 2;
return e;
},
updateRenderData: function(t) {
t._material || t._activateMaterial();
var e = t._renderData;
e.uvDirty && this.updateUVs(t);
e.vertDirty && this.updateVerts(t);
},
updateUVs: function(t) {
var e = t.spriteFrame, i = t._renderData, n = i._data, r = e._rect;
e._texture;
if (e._rotated) {
var s = r.x, o = r.height, a = r.y, c = r.width;
n[0].u = s;
n[0].v = c;
n[1].u = o;
n[1].v = a;
} else {
var h = r.x, l = r.width, u = r.y, _ = r.height;
n[0].u = h;
n[0].v = u;
n[1].u = l;
n[1].v = _;
}
i.uvDirty = !1;
},
updateVerts: function(t) {
var e = t._renderData, i = t.node, n = e._data, r = i.width, s = i.height, o = i.anchorX * r, a = i.anchorY * s, c = void 0, h = void 0, l = void 0, u = void 0;
if (t.trim) {
c = -o;
h = -a;
l = r;
u = s;
} else {
var _ = t.spriteFrame, f = _._originalSize.width, d = _._originalSize.height, m = _._rect.width, p = _._rect.height, v = _._offset, y = r / f, g = s / d, x = v.x + (f - m) / 2, C = (v.x, 
v.y + (d - p) / 2);
v.y;
c = x * y - o;
h = C * g - a;
l = r;
u = s;
}
n[0].x = c;
n[0].y = h;
n[1].x = l;
n[1].y = u;
e.vertDirty = !1;
},
draw: function(t, e) {
var i = e.node, r = i._worldMatrix, s = r.m00, o = r.m01, a = r.m04, c = r.m05, h = r.m12, l = r.m13;
t.transform(s, o, a, c, h, l);
t.scale(1, -1);
t.globalAlpha = i.opacity / 255;
var u = e._spriteFrame._texture, _ = e._renderData._data, f = n.getColorizedImage(u, i._color), d = _[0].x, m = _[0].y, p = _[1].x, v = _[1].y;
m = -m - v;
var y = _[0].u, g = _[0].v, x = _[1].u, C = _[1].v;
t.drawImage(f, y, g, x, C, d, m, p, v);
return 1;
}
};
e.exports = r;
}), {
"../utils": 200
} ],
198: [ (function(t, e, i) {
var n = t("../utils"), r = {
createData: function(t) {
var e = t.requestRenderData();
e.dataLength = 4;
return e;
},
updateRenderData: t("./simple").updateRenderData,
updateUVs: function(t) {
var e = t.spriteFrame, i = t._renderData, n = e._rect, r = (e._texture, e.insetLeft), s = e.insetRight, o = n.width - r - s, a = e.insetTop, c = e.insetBottom, h = n.height - a - c, l = i._data;
if (e._rotated) {
l[0].u = n.x;
l[1].u = c + n.x;
l[2].u = c + h + n.x;
l[3].u = n.x + n.height;
l[3].v = n.y;
l[2].v = r + n.y;
l[1].v = r + o + n.y;
l[0].v = n.y + n.width;
} else {
l[0].u = n.x;
l[1].u = r + n.x;
l[2].u = r + o + n.x;
l[3].u = n.x + n.width;
l[3].v = n.y;
l[2].v = a + n.y;
l[1].v = a + h + n.y;
l[0].v = n.y + n.height;
}
i.uvDirty = !1;
},
updateVerts: function(t) {
var e = t._renderData, i = e._data, n = t.node, r = n.width, s = n.height, o = n.anchorX * r, a = n.anchorY * s, c = t.spriteFrame, h = (c._rect, 
c.insetLeft), l = c.insetRight, u = c.insetTop, _ = c.insetBottom, f = r - h - l, d = s - u - _, m = r / (h + l), p = s / (u + _);
m = isNaN(m) || m > 1 ? 1 : m;
p = isNaN(p) || p > 1 ? 1 : p;
f = f < 0 ? 0 : f;
d = d < 0 ? 0 : d;
i[0].x = -o;
i[0].y = -a;
i[1].x = h * m - o;
i[1].y = _ * p - a;
i[2].x = i[1].x + f;
i[2].y = i[1].y + d;
i[3].x = r - o;
i[3].y = s - a;
e.vertDirty = !1;
},
draw: function(t, e) {
var i = e.node, r = i._worldMatrix, s = r.m00, o = r.m01, a = r.m04, c = r.m05, h = r.m12, l = r.m13;
t.transform(s, o, a, c, h, l);
t.scale(1, -1);
t.globalAlpha = i.opacity / 255;
for (var u = e._spriteFrame._texture, _ = e._renderData._data, f = n.getColorizedImage(u, i._color), d = 0, m = void 0, p = void 0, v = void 0, y = void 0, g = void 0, x = void 0, C = void 0, A = void 0, b = void 0, S = void 0, T = void 0, w = void 0, E = 0; E < 3; ++E) {
y = _[E];
v = _[E + 1];
for (var B = 0; B < 3; ++B) {
m = _[B];
p = _[B + 1];
g = m.x;
x = y.y;
C = p.x - g;
x = -x - (A = v.y - x);
b = m.u;
S = v.v;
T = p.u - b;
w = y.v - S;
if (T > 0 && w > 0 && C > 0 && A > 0) {
t.drawImage(f, b, S, T, w, g, x, C, A);
d++;
}
}
}
return d;
}
};
e.exports = r;
}), {
"../utils": 200,
"./simple": 197
} ],
199: [ (function(t, e, i) {
var n = t("../utils"), r = (t("./simple"), {
createData: function(t) {
return t.requestRenderData();
},
updateRenderData: function(t) {
t._material || t._activateMaterial();
},
draw: function(t, e) {
var i = e.node, r = i._worldMatrix, s = r.m00, o = r.m01, a = r.m04, c = r.m05, h = r.m12, l = r.m13;
t.transform(s, o, a, c, h, l);
t.scale(1, -1);
t.globalAlpha = i.opacity / 255;
var u = e.spriteFrame, _ = u._rect, f = u._texture, d = _.x, m = _.y, p = u._rotated ? _.height : _.width, v = u._rotated ? _.width : _.height, y = n.getFrameCache(f, i._color, d, m, p, v), g = i.width, x = i.height, C = -i.anchorX * g, A = -i.anchorY * x;
A = -A - x;
t.translate(C, A);
t.fillStyle = t.createPattern(y, "repeat");
t.fillRect(0, 0, g, x);
return 1;
}
});
e.exports = r;
}), {
"../utils": 200,
"./simple": 197
} ],
200: [ (function(t, e, i) {
function n(t, e, i, n, r, s, o) {
var a = e._image, c = t.getContext("2d");
t.width = s;
t.height = o;
c.globalCompositeOperation = "source-over";
c.fillStyle = "rgb(" + i.r + "," + i.g + "," + i.b + ")";
c.fillRect(0, 0, s, o);
c.globalCompositeOperation = "multiply";
c.drawImage(a, n, r, s, o, 0, 0, s, o);
c.globalCompositeOperation = "destination-atop";
c.drawImage(a, n, r, s, o, 0, 0, s, o);
return t;
}
var r = {
canvasMap: {},
canvasUsed: {},
canvasPool: [],
checking: !1,
check: function() {
var t = !1;
for (var e in this.canvasUsed) {
t = !0;
if (this.canvasUsed[e]) this.canvasUsed[e] = !1; else {
var i = this.canvasMap[e];
i.width = 0;
i.height = 0;
this.canvasPool.length < 32 && this.canvasPool.push(i);
delete this.canvasMap[e];
delete this.canvasUsed[e];
}
}
if (!t) {
cc.director.off(cc.Director.EVENT_AFTER_DRAW, this.check, this);
this.checking = !1;
}
},
startCheck: function() {
cc.director.on(cc.Director.EVENT_AFTER_DRAW, this.check, this);
this.checking = !0;
},
getCanvas: function(t) {
this.canvasUsed[t] = !0;
return this.canvasMap[t];
},
cacheCanvas: function(t, e) {
this.canvasMap[e] = t;
this.canvasUsed[e] = !0;
this.checking || this.startCheck();
},
dropImage: function(t) {
this.canvasMap[t] && delete this.canvasMap[t];
}
};
e.exports = {
getColorizedImage: function(t, e) {
if (!t) return null;
if (0 === t.width || 0 === t.height) return t._image;
var i = 16777215 & e._val;
if (16777215 === i) return t._image;
var s = t.url + i, o = r.getCanvas(s);
if (!o) {
n(o = r.canvasPool.pop() || document.createElement("canvas"), t, e, 0, 0, t.width, t.height);
r.cacheCanvas(o, s);
}
return o;
},
getFrameCache: function(t, e, i, s, o, a) {
if (!t || !t.url || i < 0 || s < 0 || o <= 0 || a <= 0) return null;
var c = t.url, h = !1, l = 16777215 & e._val;
if (16777215 !== l) {
c += l;
h = !0;
}
if (0 !== i || 0 !== s && o !== t.width && a !== t.height) {
c += "_" + i + "_" + s + "_" + o + "_" + a;
h = !0;
}
if (!h) return t._image;
var u = r.getCanvas(c);
if (!u) {
n(u = r.canvasPool.pop() || document.createElement("canvas"), t, e, i, s, o, a);
r.cacheCanvas(u, c);
}
return u;
},
dropColorizedImage: function(t, e) {
var i = t.url + (16777215 & e._val);
r.dropImage(i);
}
};
}), {} ],
201: [ (function(t, e, i) {
var n = t("./render-engine"), r = t("./render-flow");
cc.vmath.vec3.create();
cc.renderer = e.exports = {
renderEngine: n,
Texture2D: null,
canvas: null,
device: null,
scene: null,
drawCalls: 0,
_handle: null,
_cameraNode: null,
_camera: null,
_forward: null,
initWebGL: function(e, i) {
t("./webgl/assemblers");
var s = t("./webgl/model-batcher");
this.Texture2D = n.Texture2D;
this.canvas = e;
this.device = new n.Device(e, i);
this.scene = new n.Scene();
this._handle = new s(this.device, this.scene);
r.init(this._handle);
var o = (function(t) {
return {
defaultTexture: new n.Texture2D(t, {
images: [],
width: 128,
height: 128,
wrapS: n.gfx.WRAP_REPEAT,
wrapT: n.gfx.WRAP_REPEAT,
format: n.gfx.TEXTURE_FMT_RGB8,
mipmap: !1
}),
programTemplates: n.shaders.templates,
programChunks: n.shaders.chunks
};
})(this.device);
this._forward = new n.ForwardRenderer(this.device, o);
},
initCanvas: function(e) {
var i = t("./canvas");
n.Texture2D = n.canvas.Texture2D;
n.Device = n.canvas.Device;
this.Texture2D = n.Texture2D;
this.canvas = e;
this.device = new n.Device(e);
this._camera = {
a: 1,
b: 0,
c: 0,
d: 1,
tx: 0,
ty: 0
};
this._handle = new i.RenderComponentHandle(this.device, this._camera);
r.init(this._handle);
this._forward = new i.ForwardRenderer();
},
updateCameraViewport: function() {
if (cc.director) {
var t = cc.director.getScene();
t.scaleX = t.scaleY = 1;
}
if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS) {
var e = cc.view.getViewportRect();
this.device.setViewport(e.x, e.y, e.width, e.height);
this._camera.a = cc.view.getScaleX();
this._camera.d = cc.view.getScaleY();
this._camera.tx = e.x;
this._camera.ty = e.y + e.height;
} else {
}
},
render: function(t) {
this.device._stats.drawcalls = 0;
if (t) {
r.visit(t);
this._forward.render(this.scene);
this.drawCalls = this.device._stats.drawcalls;
}
},
clear: function() {
this._handle.reset();
this._forward._reset();
}
};
}), {
"./canvas": 187,
"./render-engine": 202,
"./render-flow": 203,
"./webgl/assemblers": 213,
"./webgl/model-batcher": 228
} ],
202: [ (function(t, e, i) {
"use strict";
var n = Math.PI / 180, r = 180 / Math.PI, s = 1e-6;
function o(t) {
return t * n;
}
var a = Math.random;
function c(t, e) {
return Math.random() * (e - t) + t;
}
var h = 32, l = -1 << h - 1;
function u(t) {
var 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;
}
var _ = new Array(256);
(function(t) {
for (var e = 0; e < 256; ++e) {
var i = e, n = e, r = 7;
for (i >>>= 1; i; i >>>= 1) {
n <<= 1;
n |= 1 & i;
--r;
}
t[e] = n << r & 255;
}
})(_);
var f = Object.freeze({
INT_BITS: h,
INT_MAX: 2147483647,
INT_MIN: l,
sign: function(t) {
return (t > 0) - (t < 0);
},
abs: function(t) {
var e = t >> h - 1;
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: function(t) {
var e, i;
e = (t > 65535) << 4;
e |= i = ((t >>>= e) > 255) << 3;
e |= i = ((t >>>= i) > 15) << 2;
return (e |= i = ((t >>>= i) > 3) << 1) | (t >>>= i) >> 1;
},
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: function(t) {
return 16843009 * ((t = (858993459 & (t -= t >>> 1 & 1431655765)) + (t >>> 2 & 858993459)) + (t >>> 4) & 252645135) >>> 24;
},
countTrailingZeros: u,
nextPow2: function(t) {
t += 0 === t;
--t;
t |= t >>> 1;
t |= t >>> 2;
t |= t >>> 4;
t |= t >>> 8;
return 1 + (t |= t >>> 16);
},
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 _[255 & t] << 24 | _[t >>> 8 & 255] << 16 | _[t >>> 16 & 255] << 8 | _[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) {
var e = t | t - 1;
return e + 1 | (~e & -~e) - 1 >>> u(t) + 1;
}
}), d = new Array(2), m = function(t, e) {
this.x = t;
this.y = e;
};
m.prototype.toJSON = function() {
d[0] = this.x;
d[1] = this.y;
return d;
};
var p = {
create: function() {
return new m(0, 0);
},
new: function(t, e) {
return new m(t, e);
},
clone: function(t) {
return new m(t.x, t.y);
},
copy: function(t, e) {
t.x = e.x;
t.y = e.y;
return t;
},
set: function(t, e, i) {
t.x = e;
t.y = i;
return t;
},
add: function(t, e, i) {
t.x = e.x + i.x;
t.y = e.y + i.y;
return t;
},
subtract: function(t, e, i) {
t.x = e.x - i.x;
t.y = e.y - i.y;
return t;
}
};
p.sub = p.subtract;
p.multiply = function(t, e, i) {
t.x = e.x * i.x;
t.y = e.y * i.y;
return t;
};
p.mul = p.multiply;
p.divide = function(t, e, i) {
t.x = e.x / i.x;
t.y = e.y / i.y;
return t;
};
p.div = p.divide;
p.ceil = function(t, e) {
t.x = Math.ceil(e.x);
t.y = Math.ceil(e.y);
return t;
};
p.floor = function(t, e) {
t.x = Math.floor(e.x);
t.y = Math.floor(e.y);
return t;
};
p.min = function(t, e, i) {
t.x = Math.min(e.x, i.x);
t.y = Math.min(e.y, i.y);
return t;
};
p.max = function(t, e, i) {
t.x = Math.max(e.x, i.x);
t.y = Math.max(e.y, i.y);
return t;
};
p.round = function(t, e) {
t.x = Math.round(e.x);
t.y = Math.round(e.y);
return t;
};
p.scale = function(t, e, i) {
t.x = e.x * i;
t.y = e.y * i;
return t;
};
p.scaleAndAdd = function(t, e, i, n) {
t.x = e.x + i.x * n;
t.y = e.y + i.y * n;
return t;
};
p.distance = function(t, e) {
var i = e.x - t.x, n = e.y - t.y;
return Math.sqrt(i * i + n * n);
};
p.dist = p.distance;
p.squaredDistance = function(t, e) {
var i = e.x - t.x, n = e.y - t.y;
return i * i + n * n;
};
p.sqrDist = p.squaredDistance;
p.length = function(t) {
var e = t.x, i = t.y;
return Math.sqrt(e * e + i * i);
};
p.len = p.length;
p.squaredLength = function(t) {
var e = t.x, i = t.y;
return e * e + i * i;
};
p.sqrLen = p.squaredLength;
p.negate = function(t, e) {
t.x = -e.x;
t.y = -e.y;
return t;
};
p.inverse = function(t, e) {
t.x = 1 / e.x;
t.y = 1 / e.y;
return t;
};
p.inverseSafe = function(t, e) {
var i = e.x, n = e.y;
Math.abs(i) < s ? t.x = 0 : t.x = 1 / i;
Math.abs(n) < s ? t.y = 0 : t.y = 1 / e.y;
return t;
};
p.normalize = function(t, e) {
var i = e.x, n = e.y, r = i * i + n * n;
if (r > 0) {
r = 1 / Math.sqrt(r);
t.x = e.x * r;
t.y = e.y * r;
}
return t;
};
p.dot = function(t, e) {
return t.x * e.x + t.y * e.y;
};
p.cross = function(t, e, i) {
var n = e.x * i.y - e.y * i.x;
t.x = t.y = 0;
t.z = n;
return t;
};
p.lerp = function(t, e, i, n) {
var r = e.x, s = e.y;
t.x = r + n * (i.x - r);
t.y = s + n * (i.y - s);
return t;
};
p.random = function(t, e) {
e = e || 1;
var i = 2 * a() * Math.PI;
t.x = Math.cos(i) * e;
t.y = Math.sin(i) * e;
return t;
};
p.transformMat2 = function(t, e, i) {
var n = e.x, r = e.y;
t.x = i.m00 * n + i.m02 * r;
t.y = i.m01 * n + i.m03 * r;
return t;
};
p.transformMat23 = function(t, e, i) {
var n = e.x, r = e.y;
t.x = i.m00 * n + i.m02 * r + i.m04;
t.y = i.m01 * n + i.m03 * r + i.m05;
return t;
};
p.transformMat3 = function(t, e, i) {
var n = e.x, r = e.y;
t.x = i.m00 * n + i.m03 * r + i.m06;
t.y = i.m01 * n + i.m04 * r + i.m07;
return t;
};
p.transformMat4 = function(t, e, i) {
var n = e.x, r = e.y;
t.x = i.m00 * n + i.m04 * r + i.m12;
t.y = i.m01 * n + i.m05 * r + i.m13;
return t;
};
p.forEach = (function() {
var t = p.create();
return function(e, i, n, r, s, o) {
var a, c;
i || (i = 2);
n || (n = 0);
c = r ? Math.min(r * i + n, e.length) : e.length;
for (a = n; a < c; a += i) {
t.x = e[a];
t.y = e[a + 1];
s(t, t, o);
e[a] = t.x;
e[a + 1] = t.y;
}
return e;
};
})();
p.str = function(t) {
return "vec2(" + t.x + ", " + t.y + ")";
};
p.array = function(t, e) {
t[0] = e.x;
t[1] = e.y;
return t;
};
p.exactEquals = function(t, e) {
return t.x === e.x && t.y === e.y;
};
p.equals = function(t, e) {
var i = t.x, n = t.y, r = e.x, o = e.y;
return Math.abs(i - r) <= s * Math.max(1, Math.abs(i), Math.abs(r)) && Math.abs(n - o) <= s * Math.max(1, Math.abs(n), Math.abs(o));
};
var v = new Array(3), y = function(t, e, i) {
this.x = t;
this.y = e;
this.z = i;
};
y.prototype.toJSON = function() {
v[0] = this.x;
v[1] = this.y;
v[2] = this.z;
return v;
};
var g = {
create: function() {
return new y(0, 0, 0);
},
new: function(t, e, i) {
return new y(t, e, i);
},
clone: function(t) {
return new y(t.x, t.y, t.z);
},
copy: function(t, e) {
t.x = e.x;
t.y = e.y;
t.z = e.z;
return t;
},
set: function(t, e, i, n) {
t.x = e;
t.y = i;
t.z = n;
return t;
},
add: function(t, e, i) {
t.x = e.x + i.x;
t.y = e.y + i.y;
t.z = e.z + i.z;
return t;
},
subtract: function(t, e, i) {
t.x = e.x - i.x;
t.y = e.y - i.y;
t.z = e.z - i.z;
return t;
}
};
g.sub = g.subtract;
g.multiply = function(t, e, i) {
t.x = e.x * i.x;
t.y = e.y * i.y;
t.z = e.z * i.z;
return t;
};
g.mul = g.multiply;
g.divide = function(t, e, i) {
t.x = e.x / i.x;
t.y = e.y / i.y;
t.z = e.z / i.z;
return t;
};
g.div = g.divide;
g.ceil = function(t, e) {
t.x = Math.ceil(e.x);
t.y = Math.ceil(e.y);
t.z = Math.ceil(e.z);
return t;
};
g.floor = function(t, e) {
t.x = Math.floor(e.x);
t.y = Math.floor(e.y);
t.z = Math.floor(e.z);
return t;
};
g.min = function(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;
};
g.max = function(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;
};
g.round = function(t, e) {
t.x = Math.round(e.x);
t.y = Math.round(e.y);
t.z = Math.round(e.z);
return t;
};
g.scale = function(t, e, i) {
t.x = e.x * i;
t.y = e.y * i;
t.z = e.z * i;
return t;
};
g.scaleAndAdd = function(t, e, i, n) {
t.x = e.x + i.x * n;
t.y = e.y + i.y * n;
t.z = e.z + i.z * n;
return t;
};
g.distance = function(t, e) {
var i = e.x - t.x, n = e.y - t.y, r = e.z - t.z;
return Math.sqrt(i * i + n * n + r * r);
};
g.dist = g.distance;
g.squaredDistance = function(t, e) {
var i = e.x - t.x, n = e.y - t.y, r = e.z - t.z;
return i * i + n * n + r * r;
};
g.sqrDist = g.squaredDistance;
g.length = function(t) {
var e = t.x, i = t.y, n = t.z;
return Math.sqrt(e * e + i * i + n * n);
};
g.len = g.length;
g.squaredLength = function(t) {
var e = t.x, i = t.y, n = t.z;
return e * e + i * i + n * n;
};
g.sqrLen = g.squaredLength;
g.negate = function(t, e) {
t.x = -e.x;
t.y = -e.y;
t.z = -e.z;
return t;
};
g.inverse = function(t, e) {
t.x = 1 / e.x;
t.y = 1 / e.y;
t.z = 1 / e.z;
return t;
};
g.inverseSafe = function(t, e) {
var i = e.x, n = e.y, r = e.z;
Math.abs(i) < s ? t.x = 0 : t.x = 1 / i;
Math.abs(n) < s ? t.y = 0 : t.y = 1 / n;
Math.abs(r) < s ? t.z = 0 : t.z = 1 / r;
return t;
};
g.normalize = function(t, e) {
var i = e.x, n = e.y, r = e.z, s = i * i + n * n + r * r;
if (s > 0) {
s = 1 / Math.sqrt(s);
t.x = i * s;
t.y = n * s;
t.z = r * s;
}
return t;
};
g.dot = function(t, e) {
return t.x * e.x + t.y * e.y + t.z * e.z;
};
g.cross = function(t, e, i) {
var n = e.x, r = e.y, s = e.z, o = i.x, a = i.y, c = i.z;
t.x = r * c - s * a;
t.y = s * o - n * c;
t.z = n * a - r * o;
return t;
};
g.lerp = function(t, e, i, n) {
var r = e.x, s = e.y, o = e.z;
t.x = r + n * (i.x - r);
t.y = s + n * (i.y - s);
t.z = o + n * (i.z - o);
return t;
};
g.hermite = function(t, e, i, n, r, s) {
var o = s * s, a = o * (2 * s - 3) + 1, c = o * (s - 2) + s, h = o * (s - 1), l = o * (3 - 2 * s);
t.x = e.x * a + i.x * c + n.x * h + r.x * l;
t.y = e.y * a + i.y * c + n.y * h + r.y * l;
t.z = e.z * a + i.z * c + n.z * h + r.z * l;
return t;
};
g.bezier = function(t, e, i, n, r, s) {
var o = 1 - s, a = o * o, c = s * s, h = a * o, l = 3 * s * a, u = 3 * c * o, _ = c * s;
t.x = e.x * h + i.x * l + n.x * u + r.x * _;
t.y = e.y * h + i.y * l + n.y * u + r.y * _;
t.z = e.z * h + i.z * l + n.z * u + r.z * _;
return t;
};
g.random = function(t, e) {
e = e || 1;
var i = 2 * a() * Math.PI, n = 2 * a() - 1, r = Math.sqrt(1 - n * n) * e;
t.x = Math.cos(i) * r;
t.y = Math.sin(i) * r;
t.z = n * e;
return t;
};
g.transformMat4 = function(t, e, i) {
var n = e.x, r = e.y, s = e.z, o = i.m03 * n + i.m07 * r + i.m11 * s + i.m15;
o = o || 1;
t.x = (i.m00 * n + i.m04 * r + i.m08 * s + i.m12) / o;
t.y = (i.m01 * n + i.m05 * r + i.m09 * s + i.m13) / o;
t.z = (i.m02 * n + i.m06 * r + i.m10 * s + i.m14) / o;
return t;
};
g.transformMat3 = function(t, e, i) {
var n = e.x, r = e.y, s = e.z;
t.x = n * i.m00 + r * i.m03 + s * i.m06;
t.y = n * i.m01 + r * i.m04 + s * i.m07;
t.z = n * i.m02 + r * i.m05 + s * i.m08;
return t;
};
g.transformQuat = function(t, e, i) {
var n = e.x, r = e.y, s = e.z, o = i.x, a = i.y, c = i.z, h = i.w, l = h * n + a * s - c * r, u = h * r + c * n - o * s, _ = h * s + o * r - a * n, f = -o * n - a * r - c * s;
t.x = l * h + f * -o + u * -c - _ * -a;
t.y = u * h + f * -a + _ * -o - l * -c;
t.z = _ * h + f * -c + l * -a - u * -o;
return t;
};
g.rotateX = function(t, e, i, n) {
var r = [], s = [];
r.x = e.x - i.x;
r.y = e.y - i.y;
r.z = e.z - i.z;
s.x = r.x;
s.y = r.y * Math.cos(n) - r.z * Math.sin(n);
s.z = r.y * Math.sin(n) + r.z * Math.cos(n);
t.x = s.x + i.x;
t.y = s.y + i.y;
t.z = s.z + i.z;
return t;
};
g.rotateY = function(t, e, i, n) {
var r = [], s = [];
r.x = e.x - i.x;
r.y = e.y - i.y;
r.z = e.z - i.z;
s.x = r.z * Math.sin(n) + r.x * Math.cos(n);
s.y = r.y;
s.z = r.z * Math.cos(n) - r.x * Math.sin(n);
t.x = s.x + i.x;
t.y = s.y + i.y;
t.z = s.z + i.z;
return t;
};
g.rotateZ = function(t, e, i, n) {
var r = [], s = [];
r.x = e.x - i.x;
r.y = e.y - i.y;
r.z = e.z - i.z;
s.x = r.x * Math.cos(n) - r.y * Math.sin(n);
s.y = r.x * Math.sin(n) + r.y * Math.cos(n);
s.z = r.z;
t.x = s.x + i.x;
t.y = s.y + i.y;
t.z = s.z + i.z;
return t;
};
g.forEach = (function() {
var t = g.create();
return function(e, i, n, r, s, o) {
var a, c;
i || (i = 3);
n || (n = 0);
c = r ? Math.min(r * i + n, e.length) : e.length;
for (a = n; a < c; a += i) {
t.x = e[a];
t.y = e[a + 1];
t.z = e[a + 2];
s(t, t, o);
e[a] = t.x;
e[a + 1] = t.y;
e[a + 2] = t.z;
}
return e;
};
})();
g.angle = (function() {
var t = g.create(), e = g.create();
return function(i, n) {
g.copy(t, i);
g.copy(e, n);
g.normalize(t, t);
g.normalize(e, e);
var r = g.dot(t, e);
return r > 1 ? 0 : r < -1 ? Math.PI : Math.acos(r);
};
})();
g.str = function(t) {
return "vec3(" + t.x + ", " + t.y + ", " + t.z + ")";
};
g.array = function(t, e) {
t[0] = e.x;
t[1] = e.y;
t[2] = e.z;
return t;
};
g.exactEquals = function(t, e) {
return t.x === e.x && t.y === e.y && t.z === e.z;
};
g.equals = function(t, e) {
var i = t.x, n = t.y, r = t.z, o = e.x, a = e.y, c = e.z;
return Math.abs(i - o) <= s * Math.max(1, Math.abs(i), Math.abs(o)) && Math.abs(n - a) <= s * Math.max(1, Math.abs(n), Math.abs(a)) && Math.abs(r - c) <= s * Math.max(1, Math.abs(r), Math.abs(c));
};
var x = new Array(4), C = function(t, e, i, n) {
this.x = t;
this.y = e;
this.z = i;
this.w = n;
};
C.prototype.toJSON = function() {
x[0] = this.x;
x[1] = this.y;
x[2] = this.z;
x[3] = this.w;
return x;
};
var A = {
create: function() {
return new C(0, 0, 0, 0);
},
new: function(t, e, i, n) {
return new C(t, e, i, n);
},
clone: function(t) {
return new C(t.x, t.y, t.z, t.w);
},
copy: function(t, e) {
t.x = e.x;
t.y = e.y;
t.z = e.z;
t.w = e.w;
return t;
},
set: function(t, e, i, n, r) {
t.x = e;
t.y = i;
t.z = n;
t.w = r;
return t;
},
add: function(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;
},
subtract: function(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;
}
};
A.sub = A.subtract;
A.multiply = function(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;
};
A.mul = A.multiply;
A.divide = function(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;
};
A.div = A.divide;
A.ceil = function(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;
};
A.floor = function(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;
};
A.min = function(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;
};
A.max = function(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;
};
A.round = function(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;
};
A.scale = function(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;
};
A.scaleAndAdd = function(t, e, i, n) {
t.x = e.x + i.x * n;
t.y = e.y + i.y * n;
t.z = e.z + i.z * n;
t.w = e.w + i.w * n;
return t;
};
A.distance = function(t, e) {
var i = e.x - t.x, n = e.y - t.y, r = e.z - t.z, s = e.w - t.w;
return Math.sqrt(i * i + n * n + r * r + s * s);
};
A.dist = A.distance;
A.squaredDistance = function(t, e) {
var i = e.x - t.x, n = e.y - t.y, r = e.z - t.z, s = e.w - t.w;
return i * i + n * n + r * r + s * s;
};
A.sqrDist = A.squaredDistance;
A.length = function(t) {
var e = t.x, i = t.y, n = t.z, r = t.w;
return Math.sqrt(e * e + i * i + n * n + r * r);
};
A.len = A.length;
A.squaredLength = function(t) {
var e = t.x, i = t.y, n = t.z, r = t.w;
return e * e + i * i + n * n + r * r;
};
A.sqrLen = A.squaredLength;
A.negate = function(t, e) {
t.x = -e.x;
t.y = -e.y;
t.z = -e.z;
t.w = -e.w;
return t;
};
A.inverse = function(t, e) {
t.x = 1 / e.x;
t.y = 1 / e.y;
t.z = 1 / e.z;
t.w = 1 / e.w;
return t;
};
A.inverseSafe = function(t, e) {
var i = e.x, n = e.y, r = e.z, o = e.w;
Math.abs(i) < s ? t.x = 0 : t.x = 1 / i;
Math.abs(n) < s ? t.y = 0 : t.y = 1 / n;
Math.abs(r) < s ? t.z = 0 : t.z = 1 / r;
Math.abs(o) < s ? t.w = 0 : t.w = 1 / o;
return t;
};
A.normalize = function(t, e) {
var i = e.x, n = e.y, r = e.z, s = e.w, o = i * i + n * n + r * r + s * s;
if (o > 0) {
o = 1 / Math.sqrt(o);
t.x = i * o;
t.y = n * o;
t.z = r * o;
t.w = s * o;
}
return t;
};
A.dot = function(t, e) {
return t.x * e.x + t.y * e.y + t.z * e.z + t.w * e.w;
};
A.lerp = function(t, e, i, n) {
var r = e.x, s = e.y, o = e.z, a = e.w;
t.x = r + n * (i.x - r);
t.y = s + n * (i.y - s);
t.z = o + n * (i.z - o);
t.w = a + n * (i.w - a);
return t;
};
A.random = function(t, e) {
e = e || 1;
t.x = a();
t.y = a();
t.z = a();
t.w = a();
A.normalize(t, t);
A.scale(t, t, e);
return t;
};
A.transformMat4 = function(t, e, i) {
var n = e.x, r = e.y, s = e.z, o = e.w;
t.x = i.m00 * n + i.m04 * r + i.m08 * s + i.m12 * o;
t.y = i.m01 * n + i.m05 * r + i.m09 * s + i.m13 * o;
t.z = i.m02 * n + i.m06 * r + i.m10 * s + i.m14 * o;
t.w = i.m03 * n + i.m07 * r + i.m11 * s + i.m15 * o;
return t;
};
A.transformQuat = function(t, e, i) {
var n = e.x, r = e.y, s = e.z, o = i.x, a = i.y, c = i.z, h = i.w, l = h * n + a * s - c * r, u = h * r + c * n - o * s, _ = h * s + o * r - a * n, f = -o * n - a * r - c * s;
t.x = l * h + f * -o + u * -c - _ * -a;
t.y = u * h + f * -a + _ * -o - l * -c;
t.z = _ * h + f * -c + l * -a - u * -o;
t.w = e.w;
return t;
};
A.forEach = (function() {
var t = A.create();
return function(e, i, n, r, s, o) {
var a, c;
i || (i = 4);
n || (n = 0);
c = r ? Math.min(r * i + n, e.length) : e.length;
for (a = n; a < c; a += i) {
t.x = e[a];
t.y = e[a + 1];
t.z = e[a + 2];
t.w = e[a + 3];
s(t, t, o);
e[a] = t.x;
e[a + 1] = t.y;
e[a + 2] = t.z;
e[a + 3] = t.w;
}
return e;
};
})();
A.str = function(t) {
return "vec4(" + t.x + ", " + t.y + ", " + t.z + ", " + t.w + ")";
};
A.array = function(t, e) {
t[0] = e.x;
t[1] = e.y;
t[2] = e.z;
t[3] = e.w;
return t;
};
A.exactEquals = function(t, e) {
return t.x === e.x && t.y === e.y && t.z === e.z && t.w === e.w;
};
A.equals = function(t, e) {
var i = t.x, n = t.y, r = t.z, o = t.w, a = e.x, c = e.y, h = e.z, l = e.w;
return Math.abs(i - a) <= s * Math.max(1, Math.abs(i), Math.abs(a)) && Math.abs(n - c) <= s * Math.max(1, Math.abs(n), Math.abs(c)) && Math.abs(r - h) <= s * Math.max(1, Math.abs(r), Math.abs(h)) && Math.abs(o - l) <= s * Math.max(1, Math.abs(o), Math.abs(l));
};
var b = new Array(9), S = function(t, e, i, n, r, s, o, a, c) {
this.m00 = t;
this.m01 = e;
this.m02 = i;
this.m03 = n;
this.m04 = r;
this.m05 = s;
this.m06 = o;
this.m07 = a;
this.m08 = c;
};
S.prototype.toJSON = function() {
b[0] = this.m00;
b[1] = this.m01;
b[2] = this.m02;
b[3] = this.m03;
b[4] = this.m04;
b[5] = this.m05;
b[6] = this.m06;
b[7] = this.m07;
b[8] = this.m08;
return b;
};
var T = {
create: function() {
return new S(1, 0, 0, 0, 1, 0, 0, 0, 1);
},
new: function(t, e, i, n, r, s, o, a, c) {
return new S(t, e, i, n, r, s, o, a, c);
},
clone: function(t) {
return new S(t.m00, t.m01, t.m02, t.m03, t.m04, t.m05, t.m06, t.m07, t.m08);
},
copy: function(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;
},
set: function(t, e, i, n, r, s, o, a, c, h) {
t.m00 = e;
t.m01 = i;
t.m02 = n;
t.m03 = r;
t.m04 = s;
t.m05 = o;
t.m06 = a;
t.m07 = c;
t.m08 = h;
return t;
},
identity: function(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;
},
transpose: function(t, e) {
if (t === e) {
var i = e.m01, n = e.m02, r = e.m05;
t.m01 = e.m03;
t.m02 = e.m06;
t.m03 = i;
t.m05 = e.m07;
t.m06 = n;
t.m07 = r;
} 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;
},
invert: function(t, e) {
var i = e.m00, n = e.m01, r = e.m02, s = e.m03, o = e.m04, a = e.m05, c = e.m06, h = e.m07, l = e.m08, u = l * o - a * h, _ = -l * s + a * c, f = h * s - o * c, d = i * u + n * _ + r * f;
if (!d) return null;
d = 1 / d;
t.m00 = u * d;
t.m01 = (-l * n + r * h) * d;
t.m02 = (a * n - r * o) * d;
t.m03 = _ * d;
t.m04 = (l * i - r * c) * d;
t.m05 = (-a * i + r * s) * d;
t.m06 = f * d;
t.m07 = (-h * i + n * c) * d;
t.m08 = (o * i - n * s) * d;
return t;
},
adjoint: function(t, e) {
var i = e.m00, n = e.m01, r = e.m02, s = e.m03, o = e.m04, a = e.m05, c = e.m06, h = e.m07, l = e.m08;
t.m00 = o * l - a * h;
t.m01 = r * h - n * l;
t.m02 = n * a - r * o;
t.m03 = a * c - s * l;
t.m04 = i * l - r * c;
t.m05 = r * s - i * a;
t.m06 = s * h - o * c;
t.m07 = n * c - i * h;
t.m08 = i * o - n * s;
return t;
},
determinant: function(t) {
var e = t.m00, i = t.m01, n = t.m02, r = t.m03, s = t.m04, o = t.m05, a = t.m06, c = t.m07, h = t.m08;
return e * (h * s - o * c) + i * (-h * r + o * a) + n * (c * r - s * a);
},
multiply: function(t, e, i) {
var n = e.m00, r = e.m01, s = e.m02, o = e.m03, a = e.m04, c = e.m05, h = e.m06, l = e.m07, u = e.m08, _ = i.m00, f = i.m01, d = i.m02, m = i.m03, p = i.m04, v = i.m05, y = i.m06, g = i.m07, x = i.m08;
t.m00 = _ * n + f * o + d * h;
t.m01 = _ * r + f * a + d * l;
t.m02 = _ * s + f * c + d * u;
t.m03 = m * n + p * o + v * h;
t.m04 = m * r + p * a + v * l;
t.m05 = m * s + p * c + v * u;
t.m06 = y * n + g * o + x * h;
t.m07 = y * r + g * a + x * l;
t.m08 = y * s + g * c + x * u;
return t;
}
};
T.mul = T.multiply;
T.translate = function(t, e, i) {
var n = e.m00, r = e.m01, s = e.m02, o = e.m03, a = e.m04, c = e.m05, h = e.m06, l = e.m07, u = e.m08, _ = i.x, f = i.y;
t.m00 = n;
t.m01 = r;
t.m02 = s;
t.m03 = o;
t.m04 = a;
t.m05 = c;
t.m06 = _ * n + f * o + h;
t.m07 = _ * r + f * a + l;
t.m08 = _ * s + f * c + u;
return t;
};
T.rotate = function(t, e, i) {
var n = e.m00, r = e.m01, s = e.m02, o = e.m03, a = e.m04, c = e.m05, h = e.m06, l = e.m07, u = e.m08, _ = Math.sin(i), f = Math.cos(i);
t.m00 = f * n + _ * o;
t.m01 = f * r + _ * a;
t.m02 = f * s + _ * c;
t.m03 = f * o - _ * n;
t.m04 = f * a - _ * r;
t.m05 = f * c - _ * s;
t.m06 = h;
t.m07 = l;
t.m08 = u;
return t;
};
T.scale = function(t, e, i) {
var n = i.x, r = i.y;
t.m00 = n * e.m00;
t.m01 = n * e.m01;
t.m02 = n * e.m02;
t.m03 = r * e.m03;
t.m04 = r * e.m04;
t.m05 = r * e.m05;
t.m06 = e.m06;
t.m07 = e.m07;
t.m08 = e.m08;
return t;
};
T.fromMat4 = function(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;
};
T.fromTranslation = function(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;
};
T.fromRotation = function(t, e) {
var i = Math.sin(e), n = Math.cos(e);
t.m00 = n;
t.m01 = i;
t.m02 = 0;
t.m03 = -i;
t.m04 = n;
t.m05 = 0;
t.m06 = 0;
t.m07 = 0;
t.m08 = 1;
return t;
};
T.fromScaling = function(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;
};
T.fromMat2d = function(t, e) {
t.m00 = e.m00;
t.m01 = e.m01;
t.m02 = 0;
t.m03 = e.m02;
t.m04 = e.m03;
t.m05 = 0;
t.m06 = e.m04;
t.m07 = e.m05;
t.m08 = 1;
return t;
};
T.fromQuat = function(t, e) {
var i = e.x, n = e.y, r = e.z, s = e.w, o = i + i, a = n + n, c = r + r, h = i * o, l = n * o, u = n * a, _ = r * o, f = r * a, d = r * c, m = s * o, p = s * a, v = s * c;
t.m00 = 1 - u - d;
t.m03 = l - v;
t.m06 = _ + p;
t.m01 = l + v;
t.m04 = 1 - h - d;
t.m07 = f - m;
t.m02 = _ - p;
t.m05 = f + m;
t.m08 = 1 - h - u;
return t;
};
T.fromViewUp = (function() {
var t = g.new(0, 1, 0), e = g.create(), i = g.create();
return function(n, r, o) {
if (g.sqrLen(r) < s * s) {
T.identity(n);
return n;
}
o = o || t;
g.cross(e, o, r);
if (g.sqrLen(e) < s * s) {
T.identity(n);
return n;
}
g.cross(i, r, e);
T.set(n, e.x, e.y, e.z, i.x, i.y, i.z, r.x, r.y, r.z);
return n;
};
})();
T.normalFromMat4 = function(t, e) {
var i = e.m00, n = e.m01, r = e.m02, s = e.m03, o = e.m04, a = e.m05, c = e.m06, h = e.m07, l = e.m08, u = e.m09, _ = e.m10, f = e.m11, d = e.m12, m = e.m13, p = e.m14, v = e.m15, y = i * a - n * o, g = i * c - r * o, x = i * h - s * o, C = n * c - r * a, A = n * h - s * a, b = r * h - s * c, S = l * m - u * d, T = l * p - _ * d, w = l * v - f * d, E = u * p - _ * m, B = u * v - f * m, M = _ * v - f * p, D = y * M - g * B + x * E + C * w - A * T + b * S;
if (!D) return null;
D = 1 / D;
t.m00 = (a * M - c * B + h * E) * D;
t.m01 = (c * w - o * M - h * T) * D;
t.m02 = (o * B - a * w + h * S) * D;
t.m03 = (r * B - n * M - s * E) * D;
t.m04 = (i * M - r * w + s * T) * D;
t.m05 = (n * w - i * B - s * S) * D;
t.m06 = (m * b - p * A + v * C) * D;
t.m07 = (p * x - d * b - v * g) * D;
t.m08 = (d * A - m * x + v * y) * D;
return t;
};
T.str = function(t) {
return "mat3(" + t.m00 + ", " + t.m01 + ", " + t.m02 + ", " + t.m03 + ", " + t.m04 + ", " + t.m05 + ", " + t.m06 + ", " + t.m07 + ", " + t.m08 + ")";
};
T.array = function(t, e) {
t[0] = e.m00;
t[1] = e.m01;
t[2] = e.m02;
t[3] = e.m03;
t[4] = e.m04;
t[5] = e.m05;
t[6] = e.m06;
t[7] = e.m07;
t[8] = e.m08;
return t;
};
T.frob = function(t) {
return Math.sqrt(Math.pow(t.m00, 2) + Math.pow(t.m01, 2) + Math.pow(t.m02, 2) + Math.pow(t.m03, 2) + Math.pow(t.m04, 2) + Math.pow(t.m05, 2) + Math.pow(t.m06, 2) + Math.pow(t.m07, 2) + Math.pow(t.m08, 2));
};
T.add = function(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;
};
T.subtract = function(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;
};
T.sub = T.subtract;
T.multiplyScalar = function(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;
};
T.multiplyScalarAndAdd = function(t, e, i, n) {
t.m00 = e.m00 + i.m00 * n;
t.m01 = e.m01 + i.m01 * n;
t.m02 = e.m02 + i.m02 * n;
t.m03 = e.m03 + i.m03 * n;
t.m04 = e.m04 + i.m04 * n;
t.m05 = e.m05 + i.m05 * n;
t.m06 = e.m06 + i.m06 * n;
t.m07 = e.m07 + i.m07 * n;
t.m08 = e.m08 + i.m08 * n;
return t;
};
T.exactEquals = function(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.equals = function(t, e) {
var i = t.m00, n = t.m01, r = t.m02, o = t.m03, a = t.m04, c = t.m05, h = t.m06, l = t.m07, u = t.m08, _ = e.m00, f = e.m01, d = e.m02, m = e.m03, p = e.m04, v = e.m05, y = e.m06, g = e.m07, x = e.m08;
return Math.abs(i - _) <= s * Math.max(1, Math.abs(i), Math.abs(_)) && Math.abs(n - f) <= s * Math.max(1, Math.abs(n), Math.abs(f)) && Math.abs(r - d) <= s * Math.max(1, Math.abs(r), Math.abs(d)) && Math.abs(o - m) <= s * Math.max(1, Math.abs(o), Math.abs(m)) && Math.abs(a - p) <= s * Math.max(1, Math.abs(a), Math.abs(p)) && Math.abs(c - v) <= s * Math.max(1, Math.abs(c), Math.abs(v)) && Math.abs(h - y) <= s * Math.max(1, Math.abs(h), Math.abs(y)) && Math.abs(l - g) <= s * Math.max(1, Math.abs(l), Math.abs(g)) && Math.abs(u - x) <= s * Math.max(1, Math.abs(u), Math.abs(x));
};
var w = new Array(4), E = function(t, e, i, n) {
this.x = t;
this.y = e;
this.z = i;
this.w = n;
};
E.prototype.toJSON = function() {
w[0] = this.x;
w[1] = this.y;
w[2] = this.z;
w[3] = this.w;
return w;
};
var B = {
create: function() {
return new E(0, 0, 0, 1);
},
new: function(t, e, i, n) {
return new E(t, e, i, n);
},
clone: function(t) {
return new E(t.x, t.y, t.z, t.w);
}
};
B.copy = A.copy;
B.set = A.set;
B.identity = function(t) {
t.x = 0;
t.y = 0;
t.z = 0;
t.w = 1;
return t;
};
B.rotationTo = (function() {
var t = g.create(), e = g.new(1, 0, 0), i = g.new(0, 1, 0);
return function(n, r, s) {
var o = g.dot(r, s);
if (o < -.999999) {
g.cross(t, e, r);
g.length(t) < 1e-6 && g.cross(t, i, r);
g.normalize(t, t);
B.fromAxisAngle(n, t, Math.PI);
return n;
}
if (o > .999999) {
n.x = 0;
n.y = 0;
n.z = 0;
n.w = 1;
return n;
}
g.cross(t, r, s);
n.x = t.x;
n.y = t.y;
n.z = t.z;
n.w = 1 + o;
return B.normalize(n, n);
};
})();
B.getAxisAngle = function(t, e) {
var i = 2 * Math.acos(e.w), n = Math.sin(i / 2);
if (0 != n) {
t.x = e.x / n;
t.y = e.y / n;
t.z = e.z / n;
} else {
t.x = 1;
t.y = 0;
t.z = 0;
}
return i;
};
B.multiply = function(t, e, i) {
var n = e.x, r = e.y, s = e.z, o = e.w, a = i.x, c = i.y, h = i.z, l = i.w;
t.x = n * l + o * a + r * h - s * c;
t.y = r * l + o * c + s * a - n * h;
t.z = s * l + o * h + n * c - r * a;
t.w = o * l - n * a - r * c - s * h;
return t;
};
B.mul = B.multiply;
B.scale = A.scale;
B.rotateX = function(t, e, i) {
i *= .5;
var n = e.x, r = e.y, s = e.z, o = e.w, a = Math.sin(i), c = Math.cos(i);
t.x = n * c + o * a;
t.y = r * c + s * a;
t.z = s * c - r * a;
t.w = o * c - n * a;
return t;
};
B.rotateY = function(t, e, i) {
i *= .5;
var n = e.x, r = e.y, s = e.z, o = e.w, a = Math.sin(i), c = Math.cos(i);
t.x = n * c - s * a;
t.y = r * c + o * a;
t.z = s * c + n * a;
t.w = o * c - r * a;
return t;
};
B.rotateZ = function(t, e, i) {
i *= .5;
var n = e.x, r = e.y, s = e.z, o = e.w, a = Math.sin(i), c = Math.cos(i);
t.x = n * c + r * a;
t.y = r * c - n * a;
t.z = s * c + o * a;
t.w = o * c - s * a;
return t;
};
B.rotateAround = (function() {
var t = g.create(), e = B.create();
return function(i, n, r, s) {
B.invert(e, n);
g.transformQuat(t, r, e);
B.fromAxisAngle(e, t, s);
B.mul(i, n, e);
return i;
};
})();
B.rotateAroundLocal = (function() {
var t = B.create();
return function(e, i, n, r) {
B.fromAxisAngle(t, n, r);
B.mul(e, i, t);
return e;
};
})();
B.calculateW = function(t, e) {
var i = e.x, n = e.y, r = e.z;
t.x = i;
t.y = n;
t.z = r;
t.w = Math.sqrt(Math.abs(1 - i * i - n * n - r * r));
return t;
};
B.dot = A.dot;
B.lerp = A.lerp;
B.slerp = function(t, e, i, n) {
var r, s, o, a, c, h = e.x, l = e.y, u = e.z, _ = e.w, f = i.x, d = i.y, m = i.z, p = i.w;
if ((s = h * f + l * d + u * m + _ * p) < 0) {
s = -s;
f = -f;
d = -d;
m = -m;
p = -p;
}
if (1 - s > 1e-6) {
r = Math.acos(s);
o = Math.sin(r);
a = Math.sin((1 - n) * r) / o;
c = Math.sin(n * r) / o;
} else {
a = 1 - n;
c = n;
}
t.x = a * h + c * f;
t.y = a * l + c * d;
t.z = a * u + c * m;
t.w = a * _ + c * p;
return t;
};
B.sqlerp = (function() {
var t = B.create(), e = B.create();
return function(i, n, r, s, o, a) {
B.slerp(t, n, o, a);
B.slerp(e, r, s, a);
B.slerp(i, t, e, 2 * a * (1 - a));
return i;
};
})();
B.invert = function(t, e) {
var i = e.x, n = e.y, r = e.z, s = e.w, o = i * i + n * n + r * r + s * s, a = o ? 1 / o : 0;
t.x = -i * a;
t.y = -n * a;
t.z = -r * a;
t.w = s * a;
return t;
};
B.conjugate = function(t, e) {
t.x = -e.x;
t.y = -e.y;
t.z = -e.z;
t.w = e.w;
return t;
};
B.length = A.length;
B.len = B.length;
B.squaredLength = A.squaredLength;
B.sqrLen = B.squaredLength;
B.normalize = A.normalize;
B.fromAxes = (function() {
var t = T.create();
return function(e, i, n, r) {
T.set(t, i.x, i.y, i.z, n.x, n.y, n.z, r.x, r.y, r.z);
return B.normalize(e, B.fromMat3(e, t));
};
})();
B.fromViewUp = (function() {
var t = T.create();
return function(e, i, n) {
T.fromViewUp(t, i, n);
return t ? B.normalize(e, B.fromMat3(e, t)) : null;
};
})();
B.fromAxisAngle = function(t, e, i) {
i *= .5;
var n = Math.sin(i);
t.x = n * e.x;
t.y = n * e.y;
t.z = n * e.z;
t.w = Math.cos(i);
return t;
};
B.fromMat3 = function(t, e) {
var i = e.m00, n = e.m03, r = e.m06, s = e.m01, o = e.m04, a = e.m07, c = e.m02, h = e.m05, l = e.m08, u = i + o + l;
if (u > 0) {
var _ = .5 / Math.sqrt(u + 1);
t.w = .25 / _;
t.x = (h - a) * _;
t.y = (r - c) * _;
t.z = (s - n) * _;
} else if (i > o && i > l) {
var f = 2 * Math.sqrt(1 + i - o - l);
t.w = (h - a) / f;
t.x = .25 * f;
t.y = (n + s) / f;
t.z = (r + c) / f;
} else if (o > l) {
var d = 2 * Math.sqrt(1 + o - i - l);
t.w = (r - c) / d;
t.x = (n + s) / d;
t.y = .25 * d;
t.z = (a + h) / d;
} else {
var m = 2 * Math.sqrt(1 + l - i - o);
t.w = (s - n) / m;
t.x = (r + c) / m;
t.y = (a + h) / m;
t.z = .25 * m;
}
return t;
};
B.fromEuler = function(t, e, i, n) {
var r = .5 * Math.PI / 180;
e *= r;
i *= r;
n *= r;
var s = Math.sin(e), o = Math.cos(e), a = Math.sin(i), c = Math.cos(i), h = Math.sin(n), l = Math.cos(n);
t.x = s * c * l - o * a * h;
t.y = o * a * l + s * c * h;
t.z = o * c * h - s * a * l;
t.w = o * c * l + s * a * h;
return t;
};
B.str = function(t) {
return "quat(" + t.x + ", " + t.y + ", " + t.z + ", " + t.w + ")";
};
B.array = function(t, e) {
t[0] = e.x;
t[1] = e.y;
t[2] = e.z;
t[3] = e.w;
return t;
};
B.exactEquals = A.exactEquals;
B.equals = A.equals;
var M = new Array(4), D = function(t, e, i, n) {
this.m00 = t;
this.m01 = e;
this.m02 = i;
this.m03 = n;
};
D.prototype.toJSON = function() {
M[0] = this.m00;
M[1] = this.m01;
M[2] = this.m02;
M[3] = this.m03;
return M;
};
var I = {
create: function() {
return new D(1, 0, 0, 1);
},
new: function(t, e, i, n) {
return new D(t, e, i, n);
},
clone: function(t) {
return new D(t.m00, t.m01, t.m02, t.m03);
},
copy: function(t, e) {
t.m00 = e.m00;
t.m01 = e.m01;
t.m02 = e.m02;
t.m03 = e.m03;
return t;
},
identity: function(t) {
t.m00 = 1;
t.m01 = 0;
t.m02 = 0;
t.m03 = 1;
return t;
},
set: function(t, e, i, n, r) {
t.m00 = e;
t.m01 = i;
t.m02 = n;
t.m03 = r;
return t;
},
transpose: function(t, e) {
if (t === e) {
var i = e.m01;
t.m01 = e.m02;
t.m02 = i;
} else {
t.m00 = e.m00;
t.m01 = e.m02;
t.m02 = e.m01;
t.m03 = e.m03;
}
return t;
},
invert: function(t, e) {
var i = e.m00, n = e.m01, r = e.m02, s = e.m03, o = i * s - r * n;
if (!o) return null;
o = 1 / o;
t.m00 = s * o;
t.m01 = -n * o;
t.m02 = -r * o;
t.m03 = i * o;
return t;
},
adjoint: function(t, e) {
var i = e.m00;
t.m00 = e.m03;
t.m01 = -e.m01;
t.m02 = -e.m02;
t.m03 = i;
return t;
},
determinant: function(t) {
return t.m00 * t.m03 - t.m02 * t.m01;
},
multiply: function(t, e, i) {
var n = e.m00, r = e.m01, s = e.m02, o = e.m03, a = i.m00, c = i.m01, h = i.m02, l = i.m03;
t.m00 = n * a + s * c;
t.m01 = r * a + o * c;
t.m02 = n * h + s * l;
t.m03 = r * h + o * l;
return t;
}
};
I.mul = I.multiply;
I.rotate = function(t, e, i) {
var n = e.m00, r = e.m01, s = e.m02, o = e.m03, a = Math.sin(i), c = Math.cos(i);
t.m00 = n * c + s * a;
t.m01 = r * c + o * a;
t.m02 = n * -a + s * c;
t.m03 = r * -a + o * c;
return t;
};
I.scale = function(t, e, i) {
var n = e.m00, r = e.m01, s = e.m02, o = e.m03, a = i.x, c = i.y;
t.m00 = n * a;
t.m01 = r * a;
t.m02 = s * c;
t.m03 = o * c;
return t;
};
I.fromRotation = function(t, e) {
var i = Math.sin(e), n = Math.cos(e);
t.m00 = n;
t.m01 = i;
t.m02 = -i;
t.m03 = n;
return t;
};
I.fromScaling = function(t, e) {
t.m00 = e.x;
t.m01 = 0;
t.m02 = 0;
t.m03 = e.y;
return t;
};
I.str = function(t) {
return "mat2(" + t.m00 + ", " + t.m01 + ", " + t.m02 + ", " + t.m03 + ")";
};
I.array = function(t, e) {
t[0] = e.m00;
t[1] = e.m01;
t[2] = e.m02;
t[3] = e.m03;
return t;
};
I.frob = function(t) {
return Math.sqrt(Math.pow(t.m00, 2) + Math.pow(t.m01, 2) + Math.pow(t.m02, 2) + Math.pow(t.m03, 2));
};
I.LDU = function(t, e, i, n) {
t.m02 = n.m02 / n.m00;
i.m00 = n.m00;
i.m01 = n.m01;
i.m03 = n.m03 - t.m02 * i.m01;
};
I.add = function(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;
return t;
};
I.subtract = function(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;
return t;
};
I.sub = I.subtract;
I.exactEquals = function(t, e) {
return t.m00 === e.m00 && t.m01 === e.m01 && t.m02 === e.m02 && t.m03 === e.m03;
};
I.equals = function(t, e) {
var i = t.m00, n = t.m01, r = t.m02, o = t.m03, a = e.m00, c = e.m01, h = e.m02, l = e.m03;
return Math.abs(i - a) <= s * Math.max(1, Math.abs(i), Math.abs(a)) && Math.abs(n - c) <= s * Math.max(1, Math.abs(n), Math.abs(c)) && Math.abs(r - h) <= s * Math.max(1, Math.abs(r), Math.abs(h)) && Math.abs(o - l) <= s * Math.max(1, Math.abs(o), Math.abs(l));
};
I.multiplyScalar = function(t, e, i) {
t.m00 = e.m00 * i;
t.m01 = e.m01 * i;
t.m02 = e.m02 * i;
t.m03 = e.m03 * i;
return t;
};
I.multiplyScalarAndAdd = function(t, e, i, n) {
t.m00 = e.m00 + i.m00 * n;
t.m01 = e.m01 + i.m01 * n;
t.m02 = e.m02 + i.m02 * n;
t.m03 = e.m03 + i.m03 * n;
return t;
};
var P = new Array(6), R = function(t, e, i, n, r, s) {
this.m00 = t;
this.m01 = e;
this.m02 = i;
this.m03 = n;
this.m04 = r;
this.m05 = s;
};
R.prototype.toJSON = function() {
P[0] = this.m00;
P[1] = this.m01;
P[2] = this.m02;
P[3] = this.m03;
P[4] = this.m04;
P[5] = this.m05;
return P;
};
var L = {
create: function() {
return new R(1, 0, 0, 1, 0, 0);
},
new: function(t, e, i, n, r, s) {
return new R(t, e, i, n, r, s);
},
clone: function(t) {
return new R(t.m00, t.m01, t.m02, t.m03, t.m04, t.m05);
},
copy: function(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;
return t;
},
identity: function(t) {
t.m00 = 1;
t.m01 = 0;
t.m02 = 0;
t.m03 = 1;
t.m04 = 0;
t.m05 = 0;
return t;
},
set: function(t, e, i, n, r, s, o) {
t.m00 = e;
t.m01 = i;
t.m02 = n;
t.m03 = r;
t.m04 = s;
t.m05 = o;
return t;
},
invert: function(t, e) {
var i = e.m00, n = e.m01, r = e.m02, s = e.m03, o = e.m04, a = e.m05, c = i * s - n * r;
if (!c) return null;
c = 1 / c;
t.m00 = s * c;
t.m01 = -n * c;
t.m02 = -r * c;
t.m03 = i * c;
t.m04 = (r * a - s * o) * c;
t.m05 = (n * o - i * a) * c;
return t;
},
determinant: function(t) {
return t.m00 * t.m03 - t.m01 * t.m02;
},
multiply: function(t, e, i) {
var n = e.m00, r = e.m01, s = e.m02, o = e.m03, a = e.m04, c = e.m05, h = i.m00, l = i.m01, u = i.m02, _ = i.m03, f = i.m04, d = i.m05;
t.m00 = n * h + s * l;
t.m01 = r * h + o * l;
t.m02 = n * u + s * _;
t.m03 = r * u + o * _;
t.m04 = n * f + s * d + a;
t.m05 = r * f + o * d + c;
return t;
}
};
L.mul = L.multiply;
L.rotate = function(t, e, i) {
var n = e.m00, r = e.m01, s = e.m02, o = e.m03, a = e.m04, c = e.m05, h = Math.sin(i), l = Math.cos(i);
t.m00 = n * l + s * h;
t.m01 = r * l + o * h;
t.m02 = n * -h + s * l;
t.m03 = r * -h + o * l;
t.m04 = a;
t.m05 = c;
return t;
};
L.scale = function(t, e, i) {
var n = e.m00, r = e.m01, s = e.m02, o = e.m03, a = e.m04, c = e.m05, h = i.x, l = i.y;
t.m00 = n * h;
t.m01 = r * h;
t.m02 = s * l;
t.m03 = o * l;
t.m04 = a;
t.m05 = c;
return t;
};
L.translate = function(t, e, i) {
var n = e.m00, r = e.m01, s = e.m02, o = e.m03, a = e.m04, c = e.m05, h = i.x, l = i.y;
t.m00 = n;
t.m01 = r;
t.m02 = s;
t.m03 = o;
t.m04 = n * h + s * l + a;
t.m05 = r * h + o * l + c;
return t;
};
L.fromRotation = function(t, e) {
var i = Math.sin(e), n = Math.cos(e);
t.m00 = n;
t.m01 = i;
t.m02 = -i;
t.m03 = n;
t.m04 = 0;
t.m05 = 0;
return t;
};
L.fromScaling = function(t, e) {
t.m00 = e.m00;
t.m01 = 0;
t.m02 = 0;
t.m03 = e.m01;
t.m04 = 0;
t.m05 = 0;
return t;
};
L.fromTranslation = function(t, e) {
t.m00 = 1;
t.m01 = 0;
t.m02 = 0;
t.m03 = 1;
t.m04 = e.x;
t.m05 = e.y;
return t;
};
L.str = function(t) {
return "mat23(" + t.m00 + ", " + t.m01 + ", " + t.m02 + ", " + t.m03 + ", " + t.m04 + ", " + t.m05 + ")";
};
L.array = function(t, e) {
t[0] = e.m00;
t[1] = e.m01;
t[2] = e.m02;
t[3] = e.m03;
t[4] = e.m04;
t[5] = e.m05;
return t;
};
L.array4x4 = function(t, e) {
t[0] = e.m00;
t[1] = e.m01;
t[2] = 0;
t[3] = 0;
t[4] = e.m02;
t[5] = e.m03;
t[6] = 0;
t[7] = 0;
t[8] = 0;
t[9] = 0;
t[10] = 1;
t[11] = 0;
t[12] = e.m04;
t[13] = e.m05;
t[14] = 0;
t[15] = 1;
return t;
};
L.frob = function(t) {
return Math.sqrt(Math.pow(t.m00, 2) + Math.pow(t.m01, 2) + Math.pow(t.m02, 2) + Math.pow(t.m03, 2) + Math.pow(t.m04, 2) + Math.pow(t.m05, 2) + 1);
};
L.add = function(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;
return t;
};
L.subtract = function(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;
return t;
};
L.sub = L.subtract;
L.multiplyScalar = function(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;
return t;
};
L.multiplyScalarAndAdd = function(t, e, i, n) {
t.m00 = e.m00 + i.m00 * n;
t.m01 = e.m01 + i.m01 * n;
t.m02 = e.m02 + i.m02 * n;
t.m03 = e.m03 + i.m03 * n;
t.m04 = e.m04 + i.m04 * n;
t.m05 = e.m05 + i.m05 * n;
return t;
};
L.exactEquals = function(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;
};
L.equals = function(t, e) {
var i = t.m00, n = t.m01, r = t.m02, o = t.m03, a = t.m04, c = t.m05, h = e.m00, l = e.m01, u = e.m02, _ = e.m03, f = e.m04, d = e.m05;
return Math.abs(i - h) <= s * Math.max(1, Math.abs(i), Math.abs(h)) && Math.abs(n - l) <= s * Math.max(1, Math.abs(n), Math.abs(l)) && Math.abs(r - u) <= s * Math.max(1, Math.abs(r), Math.abs(u)) && Math.abs(o - _) <= s * Math.max(1, Math.abs(o), Math.abs(_)) && Math.abs(a - f) <= s * Math.max(1, Math.abs(a), Math.abs(f)) && Math.abs(c - d) <= s * Math.max(1, Math.abs(c), Math.abs(d));
};
var F = new Array(16), V = function(t, e, i, n, r, s, o, a, c, h, l, u, _, f, d, m) {
this.m00 = t;
this.m01 = e;
this.m02 = i;
this.m03 = n;
this.m04 = r;
this.m05 = s;
this.m06 = o;
this.m07 = a;
this.m08 = c;
this.m09 = h;
this.m10 = l;
this.m11 = u;
this.m12 = _;
this.m13 = f;
this.m14 = d;
this.m15 = m;
};
V.prototype.toJSON = function() {
F[0] = this.m00;
F[1] = this.m01;
F[2] = this.m02;
F[3] = this.m03;
F[4] = this.m04;
F[5] = this.m05;
F[6] = this.m06;
F[7] = this.m07;
F[8] = this.m08;
F[9] = this.m09;
F[10] = this.m10;
F[11] = this.m11;
F[12] = this.m12;
F[13] = this.m13;
F[14] = this.m14;
F[15] = this.m15;
return F;
};
var O = {
create: function() {
return new V(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
},
new: function(t, e, i, n, r, s, o, a, c, h, l, u, _, f, d, m) {
return new V(t, e, i, n, r, s, o, a, c, h, l, u, _, f, d, m);
},
clone: function(t) {
return new V(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);
},
copy: function(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;
},
set: function(t, e, i, n, r, s, o, a, c, h, l, u, _, f, d, m, p) {
t.m00 = e;
t.m01 = i;
t.m02 = n;
t.m03 = r;
t.m04 = s;
t.m05 = o;
t.m06 = a;
t.m07 = c;
t.m08 = h;
t.m09 = l;
t.m10 = u;
t.m11 = _;
t.m12 = f;
t.m13 = d;
t.m14 = m;
t.m15 = p;
return t;
},
identity: function(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;
},
transpose: function(t, e) {
if (t === e) {
var i = e.m01, n = e.m02, r = e.m03, s = e.m06, o = e.m07, 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 = n;
t.m09 = s;
t.m11 = e.m14;
t.m12 = r;
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;
},
invert: function(t, e) {
var i = e.m00, n = e.m01, r = e.m02, s = e.m03, o = e.m04, a = e.m05, c = e.m06, h = e.m07, l = e.m08, u = e.m09, _ = e.m10, f = e.m11, d = e.m12, m = e.m13, p = e.m14, v = e.m15, y = i * a - n * o, g = i * c - r * o, x = i * h - s * o, C = n * c - r * a, A = n * h - s * a, b = r * h - s * c, S = l * m - u * d, T = l * p - _ * d, w = l * v - f * d, E = u * p - _ * m, B = u * v - f * m, M = _ * v - f * p, D = y * M - g * B + x * E + C * w - A * T + b * S;
if (!D) return null;
D = 1 / D;
t.m00 = (a * M - c * B + h * E) * D;
t.m01 = (r * B - n * M - s * E) * D;
t.m02 = (m * b - p * A + v * C) * D;
t.m03 = (_ * A - u * b - f * C) * D;
t.m04 = (c * w - o * M - h * T) * D;
t.m05 = (i * M - r * w + s * T) * D;
t.m06 = (p * x - d * b - v * g) * D;
t.m07 = (l * b - _ * x + f * g) * D;
t.m08 = (o * B - a * w + h * S) * D;
t.m09 = (n * w - i * B - s * S) * D;
t.m10 = (d * A - m * x + v * y) * D;
t.m11 = (u * x - l * A - f * y) * D;
t.m12 = (a * T - o * E - c * S) * D;
t.m13 = (i * E - n * T + r * S) * D;
t.m14 = (m * g - d * C - p * y) * D;
t.m15 = (l * C - u * g + _ * y) * D;
return t;
},
adjoint: function(t, e) {
var i = e.m00, n = e.m01, r = e.m02, s = e.m03, o = e.m04, a = e.m05, c = e.m06, h = e.m07, l = e.m08, u = e.m09, _ = e.m10, f = e.m11, d = e.m12, m = e.m13, p = e.m14, v = e.m15;
t.m00 = a * (_ * v - f * p) - u * (c * v - h * p) + m * (c * f - h * _);
t.m01 = -(n * (_ * v - f * p) - u * (r * v - s * p) + m * (r * f - s * _));
t.m02 = n * (c * v - h * p) - a * (r * v - s * p) + m * (r * h - s * c);
t.m03 = -(n * (c * f - h * _) - a * (r * f - s * _) + u * (r * h - s * c));
t.m04 = -(o * (_ * v - f * p) - l * (c * v - h * p) + d * (c * f - h * _));
t.m05 = i * (_ * v - f * p) - l * (r * v - s * p) + d * (r * f - s * _);
t.m06 = -(i * (c * v - h * p) - o * (r * v - s * p) + d * (r * h - s * c));
t.m07 = i * (c * f - h * _) - o * (r * f - s * _) + l * (r * h - s * c);
t.m08 = o * (u * v - f * m) - l * (a * v - h * m) + d * (a * f - h * u);
t.m09 = -(i * (u * v - f * m) - l * (n * v - s * m) + d * (n * f - s * u));
t.m10 = i * (a * v - h * m) - o * (n * v - s * m) + d * (n * h - s * a);
t.m11 = -(i * (a * f - h * u) - o * (n * f - s * u) + l * (n * h - s * a));
t.m12 = -(o * (u * p - _ * m) - l * (a * p - c * m) + d * (a * _ - c * u));
t.m13 = i * (u * p - _ * m) - l * (n * p - r * m) + d * (n * _ - r * u);
t.m14 = -(i * (a * p - c * m) - o * (n * p - r * m) + d * (n * c - r * a));
t.m15 = i * (a * _ - c * u) - o * (n * _ - r * u) + l * (n * c - r * a);
return t;
},
determinant: function(t) {
var e = t.m00, i = t.m01, n = t.m02, r = t.m03, s = t.m04, o = t.m05, a = t.m06, c = t.m07, h = t.m08, l = t.m09, u = t.m10, _ = t.m11, f = t.m12, d = t.m13, m = t.m14, p = t.m15;
return (e * o - i * s) * (u * p - _ * m) - (e * a - n * s) * (l * p - _ * d) + (e * c - r * s) * (l * m - u * d) + (i * a - n * o) * (h * p - _ * f) - (i * c - r * o) * (h * m - u * f) + (n * c - r * a) * (h * d - l * f);
},
multiply: function(t, e, i) {
var n = e.m00, r = e.m01, s = e.m02, o = e.m03, a = e.m04, c = e.m05, h = e.m06, l = e.m07, u = e.m08, _ = e.m09, f = e.m10, d = e.m11, m = e.m12, p = e.m13, v = e.m14, y = e.m15, g = i.m00, x = i.m01, C = i.m02, A = i.m03;
t.m00 = g * n + x * a + C * u + A * m;
t.m01 = g * r + x * c + C * _ + A * p;
t.m02 = g * s + x * h + C * f + A * v;
t.m03 = g * o + x * l + C * d + A * y;
g = i.m04;
x = i.m05;
C = i.m06;
A = i.m07;
t.m04 = g * n + x * a + C * u + A * m;
t.m05 = g * r + x * c + C * _ + A * p;
t.m06 = g * s + x * h + C * f + A * v;
t.m07 = g * o + x * l + C * d + A * y;
g = i.m08;
x = i.m09;
C = i.m10;
A = i.m11;
t.m08 = g * n + x * a + C * u + A * m;
t.m09 = g * r + x * c + C * _ + A * p;
t.m10 = g * s + x * h + C * f + A * v;
t.m11 = g * o + x * l + C * d + A * y;
g = i.m12;
x = i.m13;
C = i.m14;
A = i.m15;
t.m12 = g * n + x * a + C * u + A * m;
t.m13 = g * r + x * c + C * _ + A * p;
t.m14 = g * s + x * h + C * f + A * v;
t.m15 = g * o + x * l + C * d + A * y;
return t;
}
};
O.mul = O.multiply;
O.translate = function(t, e, i) {
var n, r, s, o, a, c, h, l, u, _, f, d, m = i.x, p = i.y, v = i.z;
if (e === t) {
t.m12 = e.m00 * m + e.m04 * p + e.m08 * v + e.m12;
t.m13 = e.m01 * m + e.m05 * p + e.m09 * v + e.m13;
t.m14 = e.m02 * m + e.m06 * p + e.m10 * v + e.m14;
t.m15 = e.m03 * m + e.m07 * p + e.m11 * v + e.m15;
} else {
n = e.m00;
r = e.m01;
s = e.m02;
o = e.m03;
a = e.m04;
c = e.m05;
h = e.m06;
l = e.m07;
u = e.m08;
_ = e.m09;
f = e.m10;
d = e.m11;
t.m00 = n;
t.m01 = r;
t.m02 = s;
t.m03 = o;
t.m04 = a;
t.m05 = c;
t.m06 = h;
t.m07 = l;
t.m08 = u;
t.m09 = _;
t.m10 = f;
t.m11 = d;
t.m12 = n * m + a * p + u * v + e.m12;
t.m13 = r * m + c * p + _ * v + e.m13;
t.m14 = s * m + h * p + f * v + e.m14;
t.m15 = o * m + l * p + d * v + e.m15;
}
return t;
};
O.scale = function(t, e, i) {
var n = i.x, r = i.y, s = i.z;
t.m00 = e.m00 * n;
t.m01 = e.m01 * n;
t.m02 = e.m02 * n;
t.m03 = e.m03 * n;
t.m04 = e.m04 * r;
t.m05 = e.m05 * r;
t.m06 = e.m06 * r;
t.m07 = e.m07 * r;
t.m08 = e.m08 * s;
t.m09 = e.m09 * s;
t.m10 = e.m10 * s;
t.m11 = e.m11 * s;
t.m12 = e.m12;
t.m13 = e.m13;
t.m14 = e.m14;
t.m15 = e.m15;
return t;
};
O.rotate = function(t, e, i, n) {
var r, o, a, c, h, l, u, _, f, d, m, p, v, y, g, x, C, A, b, S, T, w, E, B, M = n.x, D = n.y, I = n.z, P = Math.sqrt(M * M + D * D + I * I);
if (Math.abs(P) < s) return null;
M *= P = 1 / P;
D *= P;
I *= P;
r = Math.sin(i);
a = 1 - (o = Math.cos(i));
c = e.m00;
h = e.m01;
l = e.m02;
u = e.m03;
_ = e.m04;
f = e.m05;
d = e.m06;
m = e.m07;
p = e.m08;
v = e.m09;
y = e.m10;
g = e.m11;
x = M * M * a + o;
C = D * M * a + I * r;
A = I * M * a - D * r;
b = M * D * a - I * r;
S = D * D * a + o;
T = I * D * a + M * r;
w = M * I * a + D * r;
E = D * I * a - M * r;
B = I * I * a + o;
t.m00 = c * x + _ * C + p * A;
t.m01 = h * x + f * C + v * A;
t.m02 = l * x + d * C + y * A;
t.m03 = u * x + m * C + g * A;
t.m04 = c * b + _ * S + p * T;
t.m05 = h * b + f * S + v * T;
t.m06 = l * b + d * S + y * T;
t.m07 = u * b + m * S + g * T;
t.m08 = c * w + _ * E + p * B;
t.m09 = h * w + f * E + v * B;
t.m10 = l * w + d * E + y * B;
t.m11 = u * w + m * E + g * B;
if (e !== t) {
t.m12 = e.m12;
t.m13 = e.m13;
t.m14 = e.m14;
t.m15 = e.m15;
}
return t;
};
O.rotateX = function(t, e, i) {
var n = Math.sin(i), r = Math.cos(i), s = e.m04, o = e.m05, a = e.m06, c = e.m07, h = e.m08, l = e.m09, u = e.m10, _ = 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 = s * r + h * n;
t.m05 = o * r + l * n;
t.m06 = a * r + u * n;
t.m07 = c * r + _ * n;
t.m08 = h * r - s * n;
t.m09 = l * r - o * n;
t.m10 = u * r - a * n;
t.m11 = _ * r - c * n;
return t;
};
O.rotateY = function(t, e, i) {
var n = Math.sin(i), r = Math.cos(i), s = e.m00, o = e.m01, a = e.m02, c = e.m03, h = e.m08, l = e.m09, u = e.m10, _ = 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 = s * r - h * n;
t.m01 = o * r - l * n;
t.m02 = a * r - u * n;
t.m03 = c * r - _ * n;
t.m08 = s * n + h * r;
t.m09 = o * n + l * r;
t.m10 = a * n + u * r;
t.m11 = c * n + _ * r;
return t;
};
O.rotateZ = function(t, e, i) {
var n = Math.sin(i), r = Math.cos(i), s = e.m00, o = e.m01, a = e.m02, c = e.m03, h = e.m04, l = e.m05, u = e.m06, _ = 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 = s * r + h * n;
t.m01 = o * r + l * n;
t.m02 = a * r + u * n;
t.m03 = c * r + _ * n;
t.m04 = h * r - s * n;
t.m05 = l * r - o * n;
t.m06 = u * r - a * n;
t.m07 = _ * r - c * n;
return t;
};
O.fromTranslation = function(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;
};
O.fromScaling = function(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;
};
O.fromRotation = function(t, e, i) {
var n, r, o, a = i.x, c = i.y, h = i.z, l = Math.sqrt(a * a + c * c + h * h);
if (Math.abs(l) < s) return null;
a *= l = 1 / l;
c *= l;
h *= l;
n = Math.sin(e);
o = 1 - (r = Math.cos(e));
t.m00 = a * a * o + r;
t.m01 = c * a * o + h * n;
t.m02 = h * a * o - c * n;
t.m03 = 0;
t.m04 = a * c * o - h * n;
t.m05 = c * c * o + r;
t.m06 = h * c * o + a * n;
t.m07 = 0;
t.m08 = a * h * o + c * n;
t.m09 = c * h * o - a * n;
t.m10 = h * h * o + r;
t.m11 = 0;
t.m12 = 0;
t.m13 = 0;
t.m14 = 0;
t.m15 = 1;
return t;
};
O.fromXRotation = function(t, e) {
var i = Math.sin(e), n = Math.cos(e);
t.m00 = 1;
t.m01 = 0;
t.m02 = 0;
t.m03 = 0;
t.m04 = 0;
t.m05 = n;
t.m06 = i;
t.m07 = 0;
t.m08 = 0;
t.m09 = -i;
t.m10 = n;
t.m11 = 0;
t.m12 = 0;
t.m13 = 0;
t.m14 = 0;
t.m15 = 1;
return t;
};
O.fromYRotation = function(t, e) {
var i = Math.sin(e), n = Math.cos(e);
t.m00 = n;
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 = n;
t.m11 = 0;
t.m12 = 0;
t.m13 = 0;
t.m14 = 0;
t.m15 = 1;
return t;
};
O.fromZRotation = function(t, e) {
var i = Math.sin(e), n = Math.cos(e);
t.m00 = n;
t.m01 = i;
t.m02 = 0;
t.m03 = 0;
t.m04 = -i;
t.m05 = n;
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;
};
O.fromRT = function(t, e, i) {
var n = e.x, r = e.y, s = e.z, o = e.w, a = n + n, c = r + r, h = s + s, l = n * a, u = n * c, _ = n * h, f = r * c, d = r * h, m = s * h, p = o * a, v = o * c, y = o * h;
t.m00 = 1 - (f + m);
t.m01 = u + y;
t.m02 = _ - v;
t.m03 = 0;
t.m04 = u - y;
t.m05 = 1 - (l + m);
t.m06 = d + p;
t.m07 = 0;
t.m08 = _ + v;
t.m09 = d - p;
t.m10 = 1 - (l + f);
t.m11 = 0;
t.m12 = i.x;
t.m13 = i.y;
t.m14 = i.z;
t.m15 = 1;
return t;
};
O.getTranslation = function(t, e) {
t.x = e.m12;
t.y = e.m13;
t.z = e.m14;
return t;
};
O.getScaling = function(t, e) {
var i = e.m00, n = e.m01, r = e.m02, s = e.m04, o = e.m05, a = e.m06, c = e.m08, h = e.m09, l = e.m10;
t.x = Math.sqrt(i * i + n * n + r * r);
t.y = Math.sqrt(s * s + o * o + a * a);
t.z = Math.sqrt(c * c + h * h + l * l);
return t;
};
O.getRotation = function(t, e) {
var i = e.m00 + e.m05 + e.m10, n = 0;
if (i > 0) {
n = 2 * Math.sqrt(i + 1);
t.w = .25 * n;
t.x = (e.m06 - e.m09) / n;
t.y = (e.m08 - e.m02) / n;
t.z = (e.m01 - e.m04) / n;
} else if (e.m00 > e.m05 & e.m00 > e.m10) {
n = 2 * Math.sqrt(1 + e.m00 - e.m05 - e.m10);
t.w = (e.m06 - e.m09) / n;
t.x = .25 * n;
t.y = (e.m01 + e.m04) / n;
t.z = (e.m08 + e.m02) / n;
} else if (e.m05 > e.m10) {
n = 2 * Math.sqrt(1 + e.m05 - e.m00 - e.m10);
t.w = (e.m08 - e.m02) / n;
t.x = (e.m01 + e.m04) / n;
t.y = .25 * n;
t.z = (e.m06 + e.m09) / n;
} else {
n = 2 * Math.sqrt(1 + e.m10 - e.m00 - e.m05);
t.w = (e.m01 - e.m04) / n;
t.x = (e.m08 + e.m02) / n;
t.y = (e.m06 + e.m09) / n;
t.z = .25 * n;
}
return t;
};
O.fromRTS = function(t, e, i, n) {
var r = e.x, s = e.y, o = e.z, a = e.w, c = r + r, h = s + s, l = o + o, u = r * c, _ = r * h, f = r * l, d = s * h, m = s * l, p = o * l, v = a * c, y = a * h, g = a * l, x = n.x, C = n.y, A = n.z;
t.m00 = (1 - (d + p)) * x;
t.m01 = (_ + g) * x;
t.m02 = (f - y) * x;
t.m03 = 0;
t.m04 = (_ - g) * C;
t.m05 = (1 - (u + p)) * C;
t.m06 = (m + v) * C;
t.m07 = 0;
t.m08 = (f + y) * A;
t.m09 = (m - v) * A;
t.m10 = (1 - (u + d)) * A;
t.m11 = 0;
t.m12 = i.x;
t.m13 = i.y;
t.m14 = i.z;
t.m15 = 1;
return t;
};
O.fromRTSOrigin = function(t, e, i, n, r) {
var s = e.x, o = e.y, a = e.z, c = e.w, h = s + s, l = o + o, u = a + a, _ = s * h, f = s * l, d = s * u, m = o * l, p = o * u, v = a * u, y = c * h, g = c * l, x = c * u, C = n.x, A = n.y, b = n.z, S = r.x, T = r.y, w = r.z;
t.m00 = (1 - (m + v)) * C;
t.m01 = (f + x) * C;
t.m02 = (d - g) * C;
t.m03 = 0;
t.m04 = (f - x) * A;
t.m05 = (1 - (_ + v)) * A;
t.m06 = (p + y) * A;
t.m07 = 0;
t.m08 = (d + g) * b;
t.m09 = (p - y) * b;
t.m10 = (1 - (_ + m)) * b;
t.m11 = 0;
t.m12 = i.x + S - (t.m00 * S + t.m04 * T + t.m08 * w);
t.m13 = i.y + T - (t.m01 * S + t.m05 * T + t.m09 * w);
t.m14 = i.z + w - (t.m02 * S + t.m06 * T + t.m10 * w);
t.m15 = 1;
return t;
};
O.fromQuat = function(t, e) {
var i = e.x, n = e.y, r = e.z, s = e.w, o = i + i, a = n + n, c = r + r, h = i * o, l = n * o, u = n * a, _ = r * o, f = r * a, d = r * c, m = s * o, p = s * a, v = s * c;
t.m00 = 1 - u - d;
t.m01 = l + v;
t.m02 = _ - p;
t.m03 = 0;
t.m04 = l - v;
t.m05 = 1 - h - d;
t.m06 = f + m;
t.m07 = 0;
t.m08 = _ + p;
t.m09 = f - m;
t.m10 = 1 - h - u;
t.m11 = 0;
t.m12 = 0;
t.m13 = 0;
t.m14 = 0;
t.m15 = 1;
return t;
};
O.frustum = function(t, e, i, n, r, s, o) {
var a = 1 / (i - e), c = 1 / (r - n), h = 1 / (s - o);
t.m00 = 2 * s * a;
t.m01 = 0;
t.m02 = 0;
t.m03 = 0;
t.m04 = 0;
t.m05 = 2 * s * c;
t.m06 = 0;
t.m07 = 0;
t.m08 = (i + e) * a;
t.m09 = (r + n) * c;
t.m10 = (o + s) * h;
t.m11 = -1;
t.m12 = 0;
t.m13 = 0;
t.m14 = o * s * 2 * h;
t.m15 = 0;
return t;
};
O.perspective = function(t, e, i, n, r) {
var s = 1 / Math.tan(e / 2), o = 1 / (n - r);
t.m00 = s / i;
t.m01 = 0;
t.m02 = 0;
t.m03 = 0;
t.m04 = 0;
t.m05 = s;
t.m06 = 0;
t.m07 = 0;
t.m08 = 0;
t.m09 = 0;
t.m10 = (r + n) * o;
t.m11 = -1;
t.m12 = 0;
t.m13 = 0;
t.m14 = 2 * r * n * o;
t.m15 = 0;
return t;
};
O.perspectiveFromFieldOfView = function(t, e, i, n) {
var r = Math.tan(e.upDegrees * Math.PI / 180), s = Math.tan(e.downDegrees * Math.PI / 180), o = Math.tan(e.leftDegrees * Math.PI / 180), a = Math.tan(e.rightDegrees * Math.PI / 180), c = 2 / (o + a), h = 2 / (r + s);
t.m00 = c;
t.m01 = 0;
t.m02 = 0;
t.m03 = 0;
t.m04 = 0;
t.m05 = h;
t.m06 = 0;
t.m07 = 0;
t.m08 = -(o - a) * c * .5;
t.m09 = (r - s) * h * .5;
t.m10 = n / (i - n);
t.m11 = -1;
t.m12 = 0;
t.m13 = 0;
t.m14 = n * i / (i - n);
t.m15 = 0;
return t;
};
O.ortho = function(t, e, i, n, r, s, o) {
var a = 1 / (e - i), c = 1 / (n - r), h = 1 / (s - o);
t.m00 = -2 * a;
t.m01 = 0;
t.m02 = 0;
t.m03 = 0;
t.m04 = 0;
t.m05 = -2 * c;
t.m06 = 0;
t.m07 = 0;
t.m08 = 0;
t.m09 = 0;
t.m10 = 2 * h;
t.m11 = 0;
t.m12 = (e + i) * a;
t.m13 = (r + n) * c;
t.m14 = (o + s) * h;
t.m15 = 1;
return t;
};
O.lookAt = function(t, e, i, n) {
var r, o, a, c, h, l, u, _, f, d, m = e.x, p = e.y, v = e.z, y = n.x, g = n.y, x = n.z, C = i.x, A = i.y, b = i.z;
if (Math.abs(m - C) < s && Math.abs(p - A) < s && Math.abs(v - b) < s) return O.identity(t);
u = m - C;
_ = p - A;
f = v - b;
r = g * (f *= d = 1 / Math.sqrt(u * u + _ * _ + f * f)) - x * (_ *= d);
o = x * (u *= d) - y * f;
a = y * _ - g * u;
if (d = Math.sqrt(r * r + o * o + a * a)) {
r *= d = 1 / d;
o *= d;
a *= d;
} else {
r = 0;
o = 0;
a = 0;
}
c = _ * a - f * o;
h = f * r - u * a;
l = u * o - _ * r;
if (d = Math.sqrt(c * c + h * h + l * l)) {
c *= d = 1 / d;
h *= d;
l *= d;
} else {
c = 0;
h = 0;
l = 0;
}
t.m00 = r;
t.m01 = c;
t.m02 = u;
t.m03 = 0;
t.m04 = o;
t.m05 = h;
t.m06 = _;
t.m07 = 0;
t.m08 = a;
t.m09 = l;
t.m10 = f;
t.m11 = 0;
t.m12 = -(r * m + o * p + a * v);
t.m13 = -(c * m + h * p + l * v);
t.m14 = -(u * m + _ * p + f * v);
t.m15 = 1;
return t;
};
O.str = function(t) {
return "mat4(" + 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 + ")";
};
O.array = function(t, e) {
t[0] = e.m00;
t[1] = e.m01;
t[2] = e.m02;
t[3] = e.m03;
t[4] = e.m04;
t[5] = e.m05;
t[6] = e.m06;
t[7] = e.m07;
t[8] = e.m08;
t[9] = e.m09;
t[10] = e.m10;
t[11] = e.m11;
t[12] = e.m12;
t[13] = e.m13;
t[14] = e.m14;
t[15] = e.m15;
return t;
};
O.frob = function(t) {
return Math.sqrt(Math.pow(t.m00, 2) + Math.pow(t.m01, 2) + Math.pow(t.m02, 2) + Math.pow(t.m03, 2) + Math.pow(t.m04, 2) + Math.pow(t.m05, 2) + Math.pow(t.m06, 2) + Math.pow(t.m07, 2) + Math.pow(t.m08, 2) + Math.pow(t.m09, 2) + Math.pow(t.m10, 2) + Math.pow(t.m11, 2) + Math.pow(t.m12, 2) + Math.pow(t.m13, 2) + Math.pow(t.m14, 2) + Math.pow(t.m15, 2));
};
O.add = function(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;
};
O.subtract = function(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;
};
O.sub = O.subtract;
O.multiplyScalar = function(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;
};
O.multiplyScalarAndAdd = function(t, e, i, n) {
t.m00 = e.m00 + i.m00 * n;
t.m01 = e.m01 + i.m01 * n;
t.m02 = e.m02 + i.m02 * n;
t.m03 = e.m03 + i.m03 * n;
t.m04 = e.m04 + i.m04 * n;
t.m05 = e.m05 + i.m05 * n;
t.m06 = e.m06 + i.m06 * n;
t.m07 = e.m07 + i.m07 * n;
t.m08 = e.m08 + i.m08 * n;
t.m09 = e.m09 + i.m09 * n;
t.m10 = e.m10 + i.m10 * n;
t.m11 = e.m11 + i.m11 * n;
t.m12 = e.m12 + i.m12 * n;
t.m13 = e.m13 + i.m13 * n;
t.m14 = e.m14 + i.m14 * n;
t.m15 = e.m15 + i.m15 * n;
return t;
};
O.exactEquals = function(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;
};
O.equals = function(t, e) {
var i = t.m00, n = t.m01, r = t.m02, o = t.m03, a = t.m04, c = t.m05, h = t.m06, l = t.m07, u = t.m08, _ = t.m09, f = t.m10, d = t.m11, m = t.m12, p = t.m13, v = t.m14, y = t.m15, g = e.m00, x = e.m01, C = e.m02, A = e.m03, b = e.m04, S = e.m05, T = e.m06, w = e.m07, E = e.m08, B = e.m09, M = e.m10, D = e.m11, I = e.m12, P = e.m13, R = e.m14, L = e.m15;
return Math.abs(i - g) <= s * Math.max(1, Math.abs(i), Math.abs(g)) && Math.abs(n - x) <= s * Math.max(1, Math.abs(n), Math.abs(x)) && Math.abs(r - C) <= s * Math.max(1, Math.abs(r), Math.abs(C)) && Math.abs(o - A) <= s * Math.max(1, Math.abs(o), Math.abs(A)) && Math.abs(a - b) <= s * Math.max(1, Math.abs(a), Math.abs(b)) && Math.abs(c - S) <= s * Math.max(1, Math.abs(c), Math.abs(S)) && Math.abs(h - T) <= s * Math.max(1, Math.abs(h), Math.abs(T)) && Math.abs(l - w) <= s * Math.max(1, Math.abs(l), Math.abs(w)) && Math.abs(u - E) <= s * Math.max(1, Math.abs(u), Math.abs(E)) && Math.abs(_ - B) <= s * Math.max(1, Math.abs(_), Math.abs(B)) && Math.abs(f - M) <= s * Math.max(1, Math.abs(f), Math.abs(M)) && Math.abs(d - D) <= s * Math.max(1, Math.abs(d), Math.abs(D)) && Math.abs(m - I) <= s * Math.max(1, Math.abs(m), Math.abs(I)) && Math.abs(p - P) <= s * Math.max(1, Math.abs(p), Math.abs(P)) && Math.abs(v - R) <= s * Math.max(1, Math.abs(v), Math.abs(R)) && Math.abs(y - L) <= s * Math.max(1, Math.abs(y), Math.abs(L));
};
var N = new Array(3), k = function(t, e, i) {
this.r = t;
this.g = e;
this.b = i;
};
k.prototype.toJSON = function() {
N[0] = this.r;
N[1] = this.g;
N[2] = this.b;
return N;
};
var G = {
create: function() {
return new k(1, 1, 1);
},
new: function(t, e, i) {
return new k(t, e, i);
},
clone: function(t) {
return new k(t.r, t.g, t.b, t.a);
},
copy: function(t, e) {
t.r = e.r;
t.g = e.g;
t.b = e.b;
return t;
},
set: function(t, e, i, n) {
t.r = e;
t.g = i;
t.b = n;
return t;
},
fromHex: function(t, e) {
var i = (e >> 16) / 255, n = (e >> 8 & 255) / 255, r = (255 & e) / 255;
t.r = i;
t.g = n;
t.b = r;
return t;
},
add: function(t, e, i) {
t.r = e.r + i.r;
t.g = e.g + i.g;
t.b = e.b + i.b;
return t;
},
subtract: function(t, e, i) {
t.r = e.r - i.r;
t.g = e.g - i.g;
t.b = e.b - i.b;
return t;
}
};
G.sub = G.subtract;
G.multiply = function(t, e, i) {
t.r = e.r * i.r;
t.g = e.g * i.g;
t.b = e.b * i.b;
return t;
};
G.mul = G.multiply;
G.divide = function(t, e, i) {
t.r = e.r / i.r;
t.g = e.g / i.g;
t.b = e.b / i.b;
return t;
};
G.div = G.divide;
G.scale = function(t, e, i) {
t.r = e.r * i;
t.g = e.g * i;
t.b = e.b * i;
return t;
};
G.lerp = function(t, e, i, n) {
var r = e.r, s = e.g, o = e.b;
t.r = r + n * (i.r - r);
t.g = s + n * (i.g - s);
t.b = o + n * (i.b - o);
return t;
};
G.str = function(t) {
return "color3(" + t.r + ", " + t.g + ", " + t.b + ")";
};
G.array = function(t, e) {
t[0] = e.r;
t[1] = e.g;
t[2] = e.b;
return t;
};
G.exactEquals = function(t, e) {
return t.r === e.r && t.g === e.g && t.b === e.b;
};
G.equals = function(t, e) {
var i = t.r, n = t.g, r = t.b, o = e.r, a = e.g, c = e.b;
return Math.abs(i - o) <= s * Math.max(1, Math.abs(i), Math.abs(o)) && Math.abs(n - a) <= s * Math.max(1, Math.abs(n), Math.abs(a)) && Math.abs(r - c) <= s * Math.max(1, Math.abs(r), Math.abs(c));
};
G.hex = function(t) {
return 255 * t.r << 16 | 255 * t.g << 8 | 255 * t.b;
};
var z = new Array(4), U = function(t, e, i, n) {
this.r = t;
this.g = e;
this.b = i;
this.a = n;
};
U.prototype.toJSON = function() {
z[0] = this.r;
z[1] = this.g;
z[2] = this.b;
z[3] = this.a;
return z;
};
var j = {
create: function() {
return new U(1, 1, 1, 1);
},
new: function(t, e, i, n) {
return new U(t, e, i, n);
},
clone: function(t) {
return new U(t.r, t.g, t.b, t.a);
},
copy: function(t, e) {
t.r = e.r;
t.g = e.g;
t.b = e.b;
t.a = e.a;
return t;
},
set: function(t, e, i, n, r) {
t.r = e;
t.g = i;
t.b = n;
t.a = r;
return t;
},
fromHex: function(t, e) {
var i = (e >> 24) / 255, n = (e >> 16 & 255) / 255, r = (e >> 8 & 255) / 255, s = (255 & e) / 255;
t.r = i;
t.g = n;
t.b = r;
t.a = s;
return t;
},
add: function(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;
},
subtract: function(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;
}
};
j.sub = j.subtract;
j.multiply = function(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;
};
j.mul = j.multiply;
j.divide = function(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;
};
j.div = j.divide;
j.scale = function(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;
};
j.lerp = function(t, e, i, n) {
var r = e.r, s = e.g, o = e.b, a = e.a;
t.r = r + n * (i.r - r);
t.g = s + n * (i.g - s);
t.b = o + n * (i.b - o);
t.a = a + n * (i.a - a);
return t;
};
j.str = function(t) {
return "color4(" + t.r + ", " + t.g + ", " + t.b + ", " + t.a + ")";
};
j.array = function(t, e) {
t[0] = e.r;
t[1] = e.g;
t[2] = e.b;
t[3] = e.a;
return t;
};
j.exactEquals = function(t, e) {
return t.r === e.r && t.g === e.g && t.b === e.b && t.a === e.a;
};
j.equals = function(t, e) {
var i = t.r, n = t.g, r = t.b, o = t.a, a = e.r, c = e.g, h = e.b, l = e.a;
return Math.abs(i - a) <= s * Math.max(1, Math.abs(i), Math.abs(a)) && Math.abs(n - c) <= s * Math.max(1, Math.abs(n), Math.abs(c)) && Math.abs(r - h) <= s * Math.max(1, Math.abs(r), Math.abs(h)) && Math.abs(o - l) <= s * Math.max(1, Math.abs(o), Math.abs(l));
};
j.hex = function(t) {
return (255 * t.r << 24 | 255 * t.g << 16 | 255 * t.b << 8 | 255 * t.a) >>> 0;
};
var H = f, W = Object.freeze({
bits: H,
vec2: p,
vec3: g,
vec4: A,
quat: B,
mat2: I,
mat23: L,
mat3: T,
mat4: O,
color3: G,
color4: j,
EPSILON: s,
equals: function(t, e) {
return Math.abs(t - e) <= s * Math.max(1, Math.abs(t), Math.abs(e));
},
approx: function(t, e, i) {
i = i || s;
return Math.abs(t - e) <= i;
},
clamp: function(t, e, i) {
return t < e ? e : t > i ? i : t;
},
clamp01: function(t) {
return t < 0 ? 0 : t > 1 ? 1 : t;
},
lerp: function(t, e, i) {
return t + (e - t) * i;
},
toRadian: o,
toDegree: function(t) {
return t * r;
},
random: a,
randomRange: c,
randomRangeInt: function(t, e) {
return Math.floor(c(t, e));
},
nextPow2: function(t) {
--t;
t |= t >> 1;
t |= t >> 2;
t |= t >> 4;
t |= t >> 8;
t |= t >> 16;
return ++t;
}
}), q = {
PROJ_PERSPECTIVE: 0,
PROJ_ORTHO: 1,
LIGHT_DIRECTIONAL: 0,
LIGHT_POINT: 1,
LIGHT_SPOT: 2,
SHADOW_NONE: 0,
SHADOW_HARD: 1,
SHADOW_SOFT: 2,
PARAM_INT: 0,
PARAM_INT2: 1,
PARAM_INT3: 2,
PARAM_INT4: 3,
PARAM_FLOAT: 4,
PARAM_FLOAT2: 5,
PARAM_FLOAT3: 6,
PARAM_FLOAT4: 7,
PARAM_COLOR3: 8,
PARAM_COLOR4: 9,
PARAM_MAT2: 10,
PARAM_MAT3: 11,
PARAM_MAT4: 12,
PARAM_TEXTURE_2D: 13,
PARAM_TEXTURE_CUBE: 14,
CLEAR_COLOR: 1,
CLEAR_DEPTH: 2,
CLEAR_STENCIL: 4
}, X = [ [ 9728, 9984, 9986 ], [ 9729, 9985, 9987 ] ], Y = [ {
format: 6407,
internalFormat: 33776,
pixelType: null
}, {
format: 6408,
internalFormat: 33777,
pixelType: null
}, {
format: 6408,
internalFormat: 33778,
pixelType: null
}, {
format: 6408,
internalFormat: 33779,
pixelType: null
}, {
format: 6407,
internalFormat: 36196,
pixelType: null
}, {
format: 6407,
internalFormat: 35841,
pixelType: null
}, {
format: 6408,
internalFormat: 35843,
pixelType: null
}, {
format: 6407,
internalFormat: 35840,
pixelType: null
}, {
format: 6408,
internalFormat: 35842,
pixelType: null
}, {
format: 6406,
internalFormat: 6406,
pixelType: 5121
}, {
format: 6409,
internalFormat: 6409,
pixelType: 5121
}, {
format: 6410,
internalFormat: 6410,
pixelType: 5121
}, {
format: 6407,
internalFormat: 6407,
pixelType: 33635
}, {
format: 6408,
internalFormat: 6408,
pixelType: 32820
}, {
format: 6408,
internalFormat: 6408,
pixelType: 32819
}, {
format: 6407,
internalFormat: 6407,
pixelType: 5121
}, {
format: 6408,
internalFormat: 6408,
pixelType: 5121
}, {
format: 6407,
internalFormat: 6407,
pixelType: 36193
}, {
format: 6408,
internalFormat: 6408,
pixelType: 36193
}, {
format: 6407,
internalFormat: 6407,
pixelType: 5126
}, {
format: 6408,
internalFormat: 6408,
pixelType: 5126
}, {
format: null,
internalFormat: null,
pixelType: null
}, {
format: null,
internalFormat: null,
pixelType: null
}, {
format: null,
internalFormat: null,
pixelType: null
}, {
format: null,
internalFormat: null,
pixelType: null
}, {
format: 6402,
internalFormat: 6402,
pixelType: 5123
}, {
format: 6402,
internalFormat: 6402,
pixelType: 5125
}, {
format: null,
internalFormat: null,
pixelType: null
} ], J = {
USAGE_STATIC: 35044,
USAGE_DYNAMIC: 35048,
USAGE_STREAM: 35040,
INDEX_FMT_UINT8: 5121,
INDEX_FMT_UINT16: 5123,
INDEX_FMT_UINT32: 5125,
ATTR_POSITION: "a_position",
ATTR_NORMAL: "a_normal",
ATTR_TANGENT: "a_tangent",
ATTR_BITANGENT: "a_bitangent",
ATTR_WEIGHTS: "a_weights",
ATTR_JOINTS: "a_joints",
ATTR_COLOR: "a_color",
ATTR_COLOR0: "a_color0",
ATTR_COLOR1: "a_color1",
ATTR_UV: "a_uv",
ATTR_UV0: "a_uv0",
ATTR_UV1: "a_uv1",
ATTR_UV2: "a_uv2",
ATTR_UV3: "a_uv3",
ATTR_UV4: "a_uv4",
ATTR_UV5: "a_uv5",
ATTR_UV6: "a_uv6",
ATTR_UV7: "a_uv7",
ATTR_TYPE_INT8: 5120,
ATTR_TYPE_UINT8: 5121,
ATTR_TYPE_INT16: 5122,
ATTR_TYPE_UINT16: 5123,
ATTR_TYPE_INT32: 5124,
ATTR_TYPE_UINT32: 5125,
ATTR_TYPE_FLOAT32: 5126,
FILTER_NEAREST: 0,
FILTER_LINEAR: 1,
WRAP_REPEAT: 10497,
WRAP_CLAMP: 33071,
WRAP_MIRROR: 33648,
TEXTURE_FMT_RGB_DXT1: 0,
TEXTURE_FMT_RGBA_DXT1: 1,
TEXTURE_FMT_RGBA_DXT3: 2,
TEXTURE_FMT_RGBA_DXT5: 3,
TEXTURE_FMT_RGB_ETC1: 4,
TEXTURE_FMT_RGB_PVRTC_2BPPV1: 5,
TEXTURE_FMT_RGBA_PVRTC_2BPPV1: 6,
TEXTURE_FMT_RGB_PVRTC_4BPPV1: 7,
TEXTURE_FMT_RGBA_PVRTC_4BPPV1: 8,
TEXTURE_FMT_A8: 9,
TEXTURE_FMT_L8: 10,
TEXTURE_FMT_L8_A8: 11,
TEXTURE_FMT_R5_G6_B5: 12,
TEXTURE_FMT_R5_G5_B5_A1: 13,
TEXTURE_FMT_R4_G4_B4_A4: 14,
TEXTURE_FMT_RGB8: 15,
TEXTURE_FMT_RGBA8: 16,
TEXTURE_FMT_RGB16F: 17,
TEXTURE_FMT_RGBA16F: 18,
TEXTURE_FMT_RGB32F: 19,
TEXTURE_FMT_RGBA32F: 20,
TEXTURE_FMT_R32F: 21,
TEXTURE_FMT_111110F: 22,
TEXTURE_FMT_SRGB: 23,
TEXTURE_FMT_SRGBA: 24,
TEXTURE_FMT_D16: 25,
TEXTURE_FMT_D32: 26,
TEXTURE_FMT_D24S8: 27,
DS_FUNC_NEVER: 512,
DS_FUNC_LESS: 513,
DS_FUNC_EQUAL: 514,
DS_FUNC_LEQUAL: 515,
DS_FUNC_GREATER: 516,
DS_FUNC_NOTEQUAL: 517,
DS_FUNC_GEQUAL: 518,
DS_FUNC_ALWAYS: 519,
RB_FMT_RGBA4: 32854,
RB_FMT_RGB5_A1: 32855,
RB_FMT_RGB565: 36194,
RB_FMT_D16: 33189,
RB_FMT_S8: 36168,
RB_FMT_D24S8: 34041,
BLEND_FUNC_ADD: 32774,
BLEND_FUNC_SUBTRACT: 32778,
BLEND_FUNC_REVERSE_SUBTRACT: 32779,
BLEND_ZERO: 0,
BLEND_ONE: 1,
BLEND_SRC_COLOR: 768,
BLEND_ONE_MINUS_SRC_COLOR: 769,
BLEND_DST_COLOR: 774,
BLEND_ONE_MINUS_DST_COLOR: 775,
BLEND_SRC_ALPHA: 770,
BLEND_ONE_MINUS_SRC_ALPHA: 771,
BLEND_DST_ALPHA: 772,
BLEND_ONE_MINUS_DST_ALPHA: 773,
BLEND_CONSTANT_COLOR: 32769,
BLEND_ONE_MINUS_CONSTANT_COLOR: 32770,
BLEND_CONSTANT_ALPHA: 32771,
BLEND_ONE_MINUS_CONSTANT_ALPHA: 32772,
BLEND_SRC_ALPHA_SATURATE: 776,
STENCIL_OP_KEEP: 7680,
STENCIL_OP_ZERO: 0,
STENCIL_OP_REPLACE: 7681,
STENCIL_OP_INCR: 7682,
STENCIL_OP_INCR_WRAP: 34055,
STENCIL_OP_DECR: 7683,
STENCIL_OP_DECR_WRAP: 34056,
STENCIL_OP_INVERT: 5386,
CULL_NONE: 0,
CULL_FRONT: 1028,
CULL_BACK: 1029,
CULL_FRONT_AND_BACK: 1032,
PT_POINTS: 0,
PT_LINES: 1,
PT_LINE_LOOP: 2,
PT_LINE_STRIP: 3,
PT_TRIANGLES: 4,
PT_TRIANGLE_STRIP: 5,
PT_TRIANGLE_FAN: 6
};
function Z(t) {
if (t === J.ATTR_TYPE_INT8) return 1;
if (t === J.ATTR_TYPE_UINT8) return 1;
if (t === J.ATTR_TYPE_INT16) return 2;
if (t === J.ATTR_TYPE_UINT16) return 2;
if (t === J.ATTR_TYPE_INT32) return 4;
if (t === J.ATTR_TYPE_UINT32) return 4;
if (t === J.ATTR_TYPE_FLOAT32) return 4;
console.warn("Unknown ATTR_TYPE: " + t);
return 0;
}
function K(t, e, i) {
void 0 === i && (i = -1);
var n = X[e][i + 1];
if (void 0 === n) {
console.warn("Unknown FILTER: " + e);
return -1 === i ? t.LINEAR : t.LINEAR_MIPMAP_LINEAR;
}
return n;
}
function Q(t) {
var e = Y[t];
if (void 0 === e) {
console.warn("Unknown TEXTURE_FMT: " + t);
return Y[J.TEXTURE_FMT_RGBA8];
}
return e;
}
var $ = function(t) {
this._attr2el = {};
this._elements = [];
this._bytes = 0;
for (var e = 0, i = 0, n = t.length; i < n; ++i) {
var r = t[i], s = {
name: r.name,
offset: e,
stride: 0,
stream: -1,
type: r.type,
num: r.num,
normalize: void 0 !== r.normalize && r.normalize,
bytes: r.num * Z(r.type)
};
this._attr2el[s.name] = s;
this._elements.push(s);
this._bytes += s.bytes;
e += s.bytes;
}
for (var o = 0, a = this._elements.length; o < a; ++o) {
this._elements[o].stride = this._bytes;
}
};
$.prototype.element = function(t) {
return this._attr2el[t];
};
var tt = function(t, e, i, n, r) {
this._device = t;
this._format = e;
this._usage = i;
this._numIndices = r;
this._bytesPerIndex = 0;
e === J.INDEX_FMT_UINT8 ? this._bytesPerIndex = 1 : e === J.INDEX_FMT_UINT16 ? this._bytesPerIndex = 2 : e === J.INDEX_FMT_UINT32 && (this._bytesPerIndex = 4);
this._bytes = this._bytesPerIndex * r;
this._glID = t._gl.createBuffer();
this.update(0, n);
t._stats.ib += this._bytes;
}, et = {
count: {
configurable: !0
}
};
tt.prototype.destroy = function() {
if (-1 !== this._glID) {
this._device._gl.deleteBuffer(this._glID);
this._device._stats.ib -= this.bytes;
this._glID = -1;
} else console.error("The buffer already destroyed");
};
tt.prototype.update = function(t, e) {
if (-1 !== this._glID) if (e && e.byteLength + t > this._bytes) console.error("Failed to update data, bytes exceed."); else {
var i = this._device._gl, n = this._usage;
i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, this._glID);
e ? t ? i.bufferSubData(i.ELEMENT_ARRAY_BUFFER, t, e) : i.bufferData(i.ELEMENT_ARRAY_BUFFER, e, n) : this._bytes ? i.bufferData(i.ELEMENT_ARRAY_BUFFER, this._bytes, n) : console.warn("bufferData should not submit 0 bytes data");
this._device._restoreIndexBuffer();
} else console.error("The buffer is destroyed");
};
et.count.get = function() {
return this._numIndices;
};
Object.defineProperties(tt.prototype, et);
var it = function(t, e, i, n, r) {
this._device = t;
this._format = e;
this._usage = i;
this._numVertices = r;
this._bytes = this._format._bytes * r;
this._glID = t._gl.createBuffer();
this.update(0, n);
t._stats.vb += this._bytes;
}, nt = {
count: {
configurable: !0
}
};
it.prototype.destroy = function() {
if (-1 !== this._glID) {
this._device._gl.deleteBuffer(this._glID);
this._device._stats.vb -= this.bytes;
this._glID = -1;
} else console.error("The buffer already destroyed");
};
it.prototype.update = function(t, e) {
if (-1 !== this._glID) if (e && e.byteLength + t > this._bytes) console.error("Failed to update data, bytes exceed."); else {
var i = this._device._gl, n = this._usage;
i.bindBuffer(i.ARRAY_BUFFER, this._glID);
e ? t ? i.bufferSubData(i.ARRAY_BUFFER, t, e) : i.bufferData(i.ARRAY_BUFFER, e, n) : this._bytes ? i.bufferData(i.ARRAY_BUFFER, this._bytes, n) : console.warn("bufferData should not submit 0 bytes data");
i.bindBuffer(i.ARRAY_BUFFER, null);
} else console.error("The buffer is destroyed");
};
nt.count.get = function() {
return this._numVertices;
};
Object.defineProperties(it.prototype, nt);
var rt = 0;
function st(t, e, i) {
i.split("\n").forEach((function(i) {
if (!(i.length < 5)) {
var n = /^ERROR\:\s+(\d+)\:(\d+)\:\s*(.*)$/.exec(i);
n ? t.push({
type: e,
fileID: 0 | n[1],
line: 0 | n[2],
message: n[3].trim()
}) : i.length > 0 && t.push({
type: e,
fileID: -1,
line: 0,
message: i
});
}
}));
}
var ot = function(t, e) {
this._device = t;
this._attributes = [];
this._uniforms = [];
this._samplers = [];
this._errors = [];
this._linked = !1;
this._vertSource = e.vert;
this._fragSource = e.frag;
this._glID = null;
this._id = rt++;
}, at = {
id: {
configurable: !0
}
};
at.id.get = function() {
return this._id;
};
ot.prototype.link = function() {
if (!this._linked) {
var t = this._device._gl, e = ct(t, t.VERTEX_SHADER, this._vertSource), i = ct(t, t.FRAGMENT_SHADER, this._fragSource), n = t.createProgram();
t.attachShader(n, e);
t.attachShader(n, i);
t.linkProgram(n);
var r = !1, s = this._errors;
if (!t.getShaderParameter(e, t.COMPILE_STATUS)) {
st(s, "vs", t.getShaderInfoLog(e));
r = !0;
}
if (!t.getShaderParameter(i, t.COMPILE_STATUS)) {
st(s, "fs", t.getShaderInfoLog(i));
r = !0;
}
t.deleteShader(e);
t.deleteShader(i);
if (r) s.forEach((function(t) {
console.error("Failed to compile " + t.type + " " + t.fileID + " (ln " + t.line + "): " + t.message);
})); else {
if (!t.getProgramParameter(n, t.LINK_STATUS)) {
console.error("Failed to link shader program: " + t.getProgramInfoLog(n));
r = !0;
}
if (!r) {
this._glID = n;
for (var o = t.getProgramParameter(n, t.ACTIVE_ATTRIBUTES), a = 0; a < o; ++a) {
var c = t.getActiveAttrib(n, a), h = t.getAttribLocation(n, c.name);
this._attributes.push({
name: c.name,
location: h,
type: c.type
});
}
for (var l = t.getProgramParameter(n, t.ACTIVE_UNIFORMS), u = 0; u < l; ++u) {
var _ = t.getActiveUniform(n, u), f = _.name, d = t.getUniformLocation(n, f), m = "[0]" === f.substr(f.length - 3);
m && (f = f.substr(0, f.length - 3));
this._uniforms.push({
name: f,
location: d,
type: _.type,
size: m ? _.size : void 0
});
}
this._linked = !0;
}
}
}
};
ot.prototype.destroy = function() {
this._device._gl.deleteProgram(this._glID);
this._linked = !1;
this._glID = null;
this._attributes = [];
this._uniforms = [];
this._samplers = [];
};
Object.defineProperties(ot.prototype, at);
function ct(t, e, i) {
var n = t.createShader(e);
t.shaderSource(n, i);
t.compileShader(n);
return n;
}
var ht = function(t) {
this._device = t;
this._width = 4;
this._height = 4;
this._hasMipmap = !1;
this._compressed = !1;
this._anisotropy = 1;
this._minFilter = J.FILTER_LINEAR;
this._magFilter = J.FILTER_LINEAR;
this._mipFilter = J.FILTER_LINEAR;
this._wrapS = J.WRAP_REPEAT;
this._wrapT = J.WRAP_REPEAT;
this._format = J.TEXTURE_FMT_RGBA8;
this._target = -1;
};
ht.prototype.destroy = function() {
if (-1 !== this._glID) {
this._device._gl.deleteTexture(this._glID);
this._device._stats.tex -= this.bytes;
this._glID = -1;
} else console.error("The texture already destroyed");
};
function lt(t) {
return !(t & t - 1 || !t);
}
var ut = (function(t) {
function e(e, i) {
t.call(this, e);
var n = this._device._gl;
this._target = n.TEXTURE_2D;
this._glID = n.createTexture();
i.images = i.images || [ null ];
this.update(i);
}
t && (e.__proto__ = t);
e.prototype = Object.create(t && t.prototype);
e.prototype.constructor = e;
e.prototype.update = function(t) {
var e = this._device._gl, i = this._hasMipmap;
if (t) {
void 0 !== t.width && (this._width = t.width);
void 0 !== t.height && (this._height = t.height);
void 0 !== t.anisotropy && (this._anisotropy = t.anisotropy);
void 0 !== t.minFilter && (this._minFilter = t.minFilter);
void 0 !== t.magFilter && (this._magFilter = t.magFilter);
void 0 !== t.mipFilter && (this._mipFilter = t.mipFilter);
void 0 !== t.wrapS && (this._wrapS = t.wrapS);
void 0 !== t.wrapT && (this._wrapT = t.wrapT);
if (void 0 !== t.format) {
this._format = t.format;
this._compressed = this._format >= J.TEXTURE_FMT_RGB_DXT1 && this._format <= J.TEXTURE_FMT_RGBA_PVRTC_4BPPV1;
}
if (void 0 !== t.mipmap) {
this._hasMipmap = t.mipmap;
i = t.mipmap;
}
if (void 0 !== t.images && t.images.length > 1) {
i = !1;
(t.width > t.height ? t.width : t.height) >> t.images.length - 1 != 1 && console.error("texture-2d mipmap is invalid, should have a 1x1 mipmap.");
}
}
lt(this._width) && lt(this._height) || (i = !1);
e.activeTexture(e.TEXTURE0);
e.bindTexture(e.TEXTURE_2D, this._glID);
void 0 !== t.images && t.images.length > 0 && this._setMipmap(t.images, t.flipY, t.premultiplyAlpha);
this._setTexInfo();
if (i) {
e.hint(e.GENERATE_MIPMAP_HINT, e.NICEST);
e.generateMipmap(e.TEXTURE_2D);
}
this._device._restoreTexture(0);
};
e.prototype.updateSubImage = function(t) {
var e = this._device._gl, i = Q(this._format);
e.activeTexture(e.TEXTURE0);
e.bindTexture(e.TEXTURE_2D, this._glID);
this._setSubImage(i, t);
this._device._restoreTexture(0);
};
e.prototype.updateImage = function(t) {
var e = this._device._gl, i = Q(this._format);
e.activeTexture(e.TEXTURE0);
e.bindTexture(e.TEXTURE_2D, this._glID);
this._setImage(i, t);
this._device._restoreTexture(0);
};
e.prototype._setSubImage = function(t, e) {
var i = this._device._gl, n = e.flipY, r = e.premultiplyAlpha, s = e.image;
if (!s || ArrayBuffer.isView(s) || s instanceof ArrayBuffer) {
void 0 === n ? i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, !1) : i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, n);
void 0 === r ? i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1) : i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, r);
this._compressed ? i.compressedTexSubImage2D(i.TEXTURE_2D, e.level, e.x, e.y, e.width, e.height, t.format, s) : i.texSubImage2D(i.TEXTURE_2D, e.level, e.x, e.y, e.width, e.height, t.format, t.pixelType, s);
} else {
void 0 === n ? i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, !0) : i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, n);
void 0 === r ? i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1) : i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, r);
i.texSubImage2D(i.TEXTURE_2D, e.level, e.x, e.y, t.format, t.pixelType, s);
}
};
e.prototype._setImage = function(t, e) {
var i = this._device._gl, n = e.flipY, r = e.premultiplyAlpha, s = e.image;
if (!s || ArrayBuffer.isView(s) || s instanceof ArrayBuffer) {
void 0 === n ? i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, !1) : i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, n);
void 0 === r ? i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1) : i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, r);
this._compressed ? i.compressedTexImage2D(i.TEXTURE_2D, e.level, t.internalFormat, e.width, e.height, 0, s) : i.texImage2D(i.TEXTURE_2D, e.level, t.internalFormat, e.width, e.height, 0, t.format, t.pixelType, s);
} else {
void 0 === n ? i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, !0) : i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, n);
void 0 === r ? i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1) : i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, r);
i.texImage2D(i.TEXTURE_2D, e.level, t.internalFormat, t.format, t.pixelType, s);
}
};
e.prototype._setMipmap = function(t, e, i) {
for (var n = Q(this._format), r = {
width: this._width,
height: this._height,
flipY: e,
premultiplyAlpha: i,
level: 0,
image: null
}, s = 0; s < t.length; ++s) {
r.level = s;
r.width = this._width >> s;
r.height = this._height >> s;
r.image = t[s];
this._setImage(n, r);
}
};
e.prototype._setTexInfo = function() {
var t = this._device._gl, e = lt(this._width) && lt(this._height);
if (!e && (this._wrapS !== J.WRAP_CLAMP || this._wrapT !== J.WRAP_CLAMP)) {
console.warn("WebGL1 doesn't support all wrap modes with NPOT textures");
this._wrapS = J.WRAP_CLAMP;
this._wrapT = J.WRAP_CLAMP;
}
var i = this._hasMipmap ? this._mipFilter : -1;
if (!e && -1 !== i) {
console.warn("NPOT textures do not support mipmap filter");
i = -1;
}
t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, K(t, this._minFilter, i));
t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, K(t, this._magFilter, -1));
t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, this._wrapS);
t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, this._wrapT);
var n = this._device.ext("EXT_texture_filter_anisotropic");
n && n.TEXTURE_MAX_ANISOTROPY_EXT && t.texParameteri(t.TEXTURE_2D, n.TEXTURE_MAX_ANISOTROPY_EXT, this._anisotropy);
};
return e;
})(ht), _t = (function(t) {
function e(e, i) {
t.call(this, e);
var n = this._device._gl;
this._target = n.TEXTURE_CUBE_MAP;
this._glID = n.createTexture();
this.update(i);
}
t && (e.__proto__ = t);
e.prototype = Object.create(t && t.prototype);
e.prototype.constructor = e;
e.prototype.update = function(t) {
var e = this._device._gl, i = this._hasMipmap;
if (t) {
void 0 !== t.width && (this._width = t.width);
void 0 !== t.height && (this._height = t.height);
void 0 !== t.anisotropy && (this._anisotropy = t.anisotropy);
void 0 !== t.minFilter && (this._minFilter = t.minFilter);
void 0 !== t.magFilter && (this._magFilter = t.magFilter);
void 0 !== t.mipFilter && (this._mipFilter = t.mipFilter);
void 0 !== t.wrapS && (this._wrapS = t.wrapS);
void 0 !== t.wrapT && (this._wrapT = t.wrapT);
if (void 0 !== t.format) {
this._format = t.format;
this._compressed = this._format >= J.TEXTURE_FMT_RGB_DXT1 && this._format <= J.TEXTURE_FMT_RGBA_PVRTC_4BPPV1;
}
if (void 0 !== t.mipmap) {
this._hasMipmap = t.mipmap;
i = t.mipmap;
}
if (void 0 !== t.images && t.images.length > 1) {
i = !1;
t.width !== t.height && console.warn("texture-cube width and height should be identical.");
t.width >> t.images.length - 1 != 1 && console.error("texture-cube mipmap is invalid. please set mipmap as 1x1, 2x2, 4x4 ... nxn");
}
}
lt(this._width) && lt(this._height) || (i = !1);
e.activeTexture(e.TEXTURE0);
e.bindTexture(e.TEXTURE_CUBE_MAP, this._glID);
void 0 !== t.images && t.images.length > 0 && this._setMipmap(t.images, t.flipY, t.premultiplyAlpha);
this._setTexInfo();
if (i) {
e.hint(e.GENERATE_MIPMAP_HINT, e.NICEST);
e.generateMipmap(e.TEXTURE_CUBE_MAP);
}
this._device._restoreTexture(0);
};
e.prototype.updateSubImage = function(t) {
var e = this._device._gl, i = Q(this._format);
e.activeTexture(e.TEXTURE0);
e.bindTexture(e.TEXTURE_CUBE_MAP, this._glID);
this._setSubImage(i, t);
this._device._restoreTexture(0);
};
e.prototype.updateImage = function(t) {
var e = this._device._gl, i = Q(this._format);
e.activeTexture(e.TEXTURE0);
e.bindTexture(e.TEXTURE_CUBE_MAP, this._glID);
this._setImage(i, t);
this._device._restoreTexture(0);
};
e.prototype._setSubImage = function(t, e) {
var i = this._device._gl, n = e.flipY, r = e.premultiplyAlpha, s = e.faceIndex, o = e.image;
void 0 === n ? i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, !1) : i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, n);
void 0 === r ? i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1) : i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, r);
!o || ArrayBuffer.isView(o) || o instanceof ArrayBuffer ? this._compressed ? i.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + s, e.level, e.x, e.y, e.width, e.height, t.format, o) : i.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + s, e.level, e.x, e.y, e.width, e.height, t.format, t.pixelType, o) : i.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + s, e.level, e.x, e.y, t.format, t.pixelType, o);
};
e.prototype._setImage = function(t, e) {
var i = this._device._gl, n = e.flipY, r = e.premultiplyAlpha, s = e.faceIndex, o = e.image;
void 0 === n ? i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, !1) : i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, n);
void 0 === r ? i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1) : i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, r);
!o || ArrayBuffer.isView(o) || o instanceof ArrayBuffer ? this._compressed ? i.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + s, e.level, t.internalFormat, e.width, e.height, 0, o) : i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + s, e.level, t.internalFormat, e.width, e.height, 0, t.format, t.pixelType, o) : i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + s, e.level, t.internalFormat, t.format, t.pixelType, o);
};
e.prototype._setMipmap = function(t, e, i) {
for (var n = Q(this._format), r = {
width: this._width,
height: this._height,
faceIndex: 0,
flipY: e,
premultiplyAlpha: i,
level: 0,
image: null
}, s = 0; s < t.length; ++s) {
var o = t[s];
r.level = s;
r.width = this._width >> s;
r.height = this._height >> s;
for (var a = 0; a < 6; ++a) {
r.faceIndex = a;
r.image = o[a];
this._setImage(n, r);
}
}
};
e.prototype._setTexInfo = function() {
var t = this._device._gl, e = lt(this._width) && lt(this._height);
if (!e && (this._wrapS !== J.WRAP_CLAMP || this._wrapT !== J.WRAP_CLAMP)) {
console.warn("WebGL1 doesn't support all wrap modes with NPOT textures");
this._wrapS = J.WRAP_CLAMP;
this._wrapT = J.WRAP_CLAMP;
}
var i = this._hasMipmap ? this._mipFilter : -1;
if (!e && -1 !== i) {
console.warn("NPOT textures do not support mipmap filter");
i = -1;
}
t.texParameteri(t.TEXTURE_CUBE_MAP, t.TEXTURE_MIN_FILTER, K(t, this._minFilter, i));
t.texParameteri(t.TEXTURE_CUBE_MAP, t.TEXTURE_MAG_FILTER, K(t, this._magFilter, -1));
t.texParameteri(t.TEXTURE_CUBE_MAP, t.TEXTURE_WRAP_S, this._wrapS);
t.texParameteri(t.TEXTURE_CUBE_MAP, t.TEXTURE_WRAP_T, this._wrapT);
var n = this._device.ext("EXT_texture_filter_anisotropic");
n && n.TEXTURE_MAX_ANISOTROPY_EXT && t.texParameteri(t.TEXTURE_CUBE_MAP, n.TEXTURE_MAX_ANISOTROPY_EXT, this._anisotropy);
};
return e;
})(ht), ft = function(t, e, i, n) {
this._device = t;
this._format = e;
this._width = i;
this._height = n;
var r = t._gl;
this._glID = r.createRenderbuffer();
r.bindRenderbuffer(r.RENDERBUFFER, this._glID);
r.renderbufferStorage(r.RENDERBUFFER, e, i, n);
r.bindRenderbuffer(r.RENDERBUFFER, null);
};
ft.prototype.destroy = function() {
if (null !== this._glID) {
var t = this._device._gl;
t.bindRenderbuffer(t.RENDERBUFFER, null);
t.deleteRenderbuffer(this._glID);
this._glID = null;
} else console.error("The render-buffer already destroyed");
};
var dt = function(t, e, i, n) {
this._device = t;
this._width = e;
this._height = i;
this._colors = n.colors || [];
this._depth = n.depth || null;
this._stencil = n.stencil || null;
this._depthStencil = n.depthStencil || null;
this._glID = t._gl.createFramebuffer();
};
dt.prototype.destroy = function() {
if (null !== this._glID) {
this._device._gl.deleteFramebuffer(this._glID);
this._glID = null;
} else console.error("The frame-buffer already destroyed");
};
var mt = {
blend: !1,
blendSep: !1,
blendColor: 4294967295,
blendEq: J.BLEND_FUNC_ADD,
blendAlphaEq: J.BLEND_FUNC_ADD,
blendSrc: J.BLEND_ONE,
blendDst: J.BLEND_ZERO,
blendSrcAlpha: J.BLEND_ONE,
blendDstAlpha: J.BLEND_ZERO,
depthTest: !1,
depthWrite: !1,
depthFunc: J.DS_FUNC_LESS,
stencilTest: !1,
stencilSep: !1,
stencilFuncFront: J.DS_FUNC_ALWAYS,
stencilRefFront: 0,
stencilMaskFront: 255,
stencilFailOpFront: J.STENCIL_OP_KEEP,
stencilZFailOpFront: J.STENCIL_OP_KEEP,
stencilZPassOpFront: J.STENCIL_OP_KEEP,
stencilWriteMaskFront: 255,
stencilFuncBack: J.DS_FUNC_ALWAYS,
stencilRefBack: 0,
stencilMaskBack: 255,
stencilFailOpBack: J.STENCIL_OP_KEEP,
stencilZFailOpBack: J.STENCIL_OP_KEEP,
stencilZPassOpBack: J.STENCIL_OP_KEEP,
stencilWriteMaskBack: 255,
cullMode: J.CULL_BACK,
primitiveType: J.PT_TRIANGLES,
maxStream: -1,
vertexBuffers: [],
vertexBufferOffsets: [],
indexBuffer: null,
maxTextureSlot: -1,
textureUnits: [],
program: null
}, pt = function(t) {
this.vertexBuffers = new Array(t._caps.maxVertexStreams);
this.vertexBufferOffsets = new Array(t._caps.maxVertexStreams);
this.textureUnits = new Array(t._caps.maxTextureUnits);
this.set(mt);
};
pt.initDefault = function(t) {
mt.vertexBuffers = new Array(t._caps.maxVertexStreams);
mt.vertexBufferOffsets = new Array(t._caps.maxVertexStreams);
mt.textureUnits = new Array(t._caps.maxTextureUnits);
};
pt.prototype.reset = function() {
this.set(mt);
};
pt.prototype.set = function(t) {
this.blend = t.blend;
this.blendSep = t.blendSep;
this.blendColor = t.blendColor;
this.blendEq = t.blendEq;
this.blendAlphaEq = t.blendAlphaEq;
this.blendSrc = t.blendSrc;
this.blendDst = t.blendDst;
this.blendSrcAlpha = t.blendSrcAlpha;
this.blendDstAlpha = t.blendDstAlpha;
this.depthTest = t.depthTest;
this.depthWrite = t.depthWrite;
this.depthFunc = t.depthFunc;
this.stencilTest = t.stencilTest;
this.stencilSep = t.stencilSep;
this.stencilFuncFront = t.stencilFuncFront;
this.stencilRefFront = t.stencilRefFront;
this.stencilMaskFront = t.stencilMaskFront;
this.stencilFailOpFront = t.stencilFailOpFront;
this.stencilZFailOpFront = t.stencilZFailOpFront;
this.stencilZPassOpFront = t.stencilZPassOpFront;
this.stencilWriteMaskFront = t.stencilWriteMaskFront;
this.stencilFuncBack = t.stencilFuncBack;
this.stencilRefBack = t.stencilRefBack;
this.stencilMaskBack = t.stencilMaskBack;
this.stencilFailOpBack = t.stencilFailOpBack;
this.stencilZFailOpBack = t.stencilZFailOpBack;
this.stencilZPassOpBack = t.stencilZPassOpBack;
this.stencilWriteMaskBack = t.stencilWriteMaskBack;
this.cullMode = t.cullMode;
this.primitiveType = t.primitiveType;
this.maxStream = t.maxStream;
for (var e = 0; e < t.vertexBuffers.length; ++e) this.vertexBuffers[e] = t.vertexBuffers[e];
for (var i = 0; i < t.vertexBufferOffsets.length; ++i) this.vertexBufferOffsets[i] = t.vertexBufferOffsets[i];
this.indexBuffer = t.indexBuffer;
this.maxTextureSlot = t.maxTextureSlot;
for (var n = 0; n < t.textureUnits.length; ++n) this.textureUnits[n] = t.textureUnits[n];
this.program = t.program;
};
var vt = {
5124: function(t, e, i) {
t.uniform1i(e, i);
},
5126: function(t, e, i) {
t.uniform1f(e, i);
},
35664: function(t, e, i) {
t.uniform2fv(e, i);
},
35665: function(t, e, i) {
t.uniform3fv(e, i);
},
35666: function(t, e, i) {
t.uniform4fv(e, i);
},
35667: function(t, e, i) {
t.uniform2iv(e, i);
},
35668: function(t, e, i) {
t.uniform3iv(e, i);
},
35669: function(t, e, i) {
t.uniform4iv(e, i);
},
35670: function(t, e, i) {
t.uniform1i(e, i);
},
35671: function(t, e, i) {
t.uniform2iv(e, i);
},
35672: function(t, e, i) {
t.uniform3iv(e, i);
},
35673: function(t, e, i) {
t.uniform4iv(e, i);
},
35674: function(t, e, i) {
t.uniformMatrix2fv(e, !1, i);
},
35675: function(t, e, i) {
t.uniformMatrix3fv(e, !1, i);
},
35676: function(t, e, i) {
t.uniformMatrix4fv(e, !1, i);
},
35678: function(t, e, i) {
t.uniform1i(e, i);
},
35680: function(t, e, i) {
t.uniform1i(e, i);
}
}, yt = {
5124: function(t, e, i) {
t.uniform1iv(e, i);
},
5126: function(t, e, i) {
t.uniform1fv(e, i);
},
35664: function(t, e, i) {
t.uniform2fv(e, i);
},
35665: function(t, e, i) {
t.uniform3fv(e, i);
},
35666: function(t, e, i) {
t.uniform4fv(e, i);
},
35667: function(t, e, i) {
t.uniform2iv(e, i);
},
35668: function(t, e, i) {
t.uniform3iv(e, i);
},
35669: function(t, e, i) {
t.uniform4iv(e, i);
},
35670: function(t, e, i) {
t.uniform1iv(e, i);
},
35671: function(t, e, i) {
t.uniform2iv(e, i);
},
35672: function(t, e, i) {
t.uniform3iv(e, i);
},
35673: function(t, e, i) {
t.uniform4iv(e, i);
},
35674: function(t, e, i) {
t.uniformMatrix2fv(e, !1, i);
},
35675: function(t, e, i) {
t.uniformMatrix3fv(e, !1, i);
},
35676: function(t, e, i) {
t.uniformMatrix4fv(e, !1, i);
},
35678: function(t, e, i) {
t.uniform1iv(e, i);
},
35680: function(t, e, i) {
t.uniform1iv(e, i);
}
};
function gt(t, e, i, n) {
void 0 === n && (n = 0);
i instanceof ut ? t.framebufferTexture2D(t.FRAMEBUFFER, e, t.TEXTURE_2D, i._glID, 0) : i instanceof _t ? t.framebufferTexture2D(t.FRAMEBUFFER, e, t.TEXTURE_CUBE_MAP_POSITIVE_X + n, i._glID, 0) : t.framebufferRenderbuffer(t.FRAMEBUFFER, e, t.RENDERBUFFER, i._glID);
}
var xt = function(t, e) {
var i;
void 0 === (e = e || {}).alpha && (e.alpha = !1);
void 0 === e.stencil && (e.stencil = !0);
void 0 === e.depth && (e.depth = !0);
void 0 === e.antialias && (e.antialias = !1);
void 0 === e.preserveDrawingBuffer && (e.preserveDrawingBuffer = !1);
try {
i = t.getContext("webgl", e) || t.getContext("experimental-webgl", e) || t.getContext("webkit-3d", e) || t.getContext("moz-webgl", e);
} catch (t) {
console.error(t);
return;
}
this._gl = i;
this._extensions = {};
this._caps = {};
this._stats = {
texture: 0,
vb: 0,
ib: 0,
drawcalls: 0
};
this._initExtensions([ "EXT_texture_filter_anisotropic", "EXT_shader_texture_lod", "OES_standard_derivatives", "OES_texture_float", "OES_texture_float_linear", "OES_texture_half_float", "OES_texture_half_float_linear", "OES_vertex_array_object", "WEBGL_compressed_texture_atc", "WEBGL_compressed_texture_etc1", "WEBGL_compressed_texture_pvrtc", "WEBGL_compressed_texture_s3tc", "WEBGL_depth_texture", "WEBGL_draw_buffers" ]);
this._initCaps();
this._initStates();
pt.initDefault(this);
this._current = new pt(this);
this._next = new pt(this);
this._uniforms = {};
this._vx = this._vy = this._vw = this._vh = 0;
this._sx = this._sy = this._sw = this._sh = 0;
this._framebuffer = null;
this._enabledAttributes = new Array(this._caps.maxVertexAttribs);
this._newAttributes = new Array(this._caps.maxVertexAttribs);
for (var n = 0; n < this._caps.maxVertexAttribs; ++n) {
this._enabledAttributes[n] = 0;
this._newAttributes[n] = 0;
}
};
xt.prototype._initExtensions = function(t) {
for (var e = this._gl, i = 0; i < t.length; ++i) for (var n = t[i], r = [ "", "WEBKIT_", "MOZ_" ], s = 0; s < r.length; s++) try {
var o = e.getExtension(r[s] + n);
o && (this._extensions[n] = o);
} catch (t) {
console.error(t);
}
};
xt.prototype._initCaps = function() {
var t = this._gl, e = this.ext("WEBGL_draw_buffers");
this._caps.maxVertexStreams = 4;
this._caps.maxVertexTextures = t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
this._caps.maxFragUniforms = t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS);
this._caps.maxTextureUnits = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);
this._caps.maxVertexAttribs = t.getParameter(t.MAX_VERTEX_ATTRIBS);
this._caps.maxDrawBuffers = e ? t.getParameter(e.MAX_DRAW_BUFFERS_WEBGL) : 1;
this._caps.maxColorAttachments = e ? t.getParameter(e.MAX_COLOR_ATTACHMENTS_WEBGL) : 1;
};
xt.prototype._initStates = function() {
var t = this._gl;
t.disable(t.BLEND);
t.blendFunc(t.ONE, t.ZERO);
t.blendEquation(t.FUNC_ADD);
t.blendColor(1, 1, 1, 1);
t.colorMask(!0, !0, !0, !0);
t.enable(t.CULL_FACE);
t.cullFace(t.BACK);
t.disable(t.DEPTH_TEST);
t.depthFunc(t.LESS);
t.depthMask(!1);
t.disable(t.POLYGON_OFFSET_FILL);
t.depthRange(0, 1);
t.disable(t.STENCIL_TEST);
t.stencilFunc(t.ALWAYS, 0, 255);
t.stencilMask(255);
t.stencilOp(t.KEEP, t.KEEP, t.KEEP);
t.clearDepth(1);
t.clearColor(0, 0, 0, 0);
t.clearStencil(0);
t.disable(t.SCISSOR_TEST);
};
xt.prototype._restoreTexture = function(t) {
var e = this._gl, i = this._current.textureUnits[t];
i && -1 !== i._glID ? e.bindTexture(i._target, i._glID) : e.bindTexture(e.TEXTURE_2D, null);
};
xt.prototype._restoreIndexBuffer = function() {
var t = this._gl, e = this._current.indexBuffer;
e && -1 !== e._glID ? t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, e._glID) : t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, null);
};
xt.prototype.ext = function(t) {
return this._extensions[t];
};
xt.prototype.setFrameBuffer = function(t) {
if (this._framebuffer !== t) {
this._framebuffer = t;
var e = this._gl;
if (null !== t) {
e.bindFramebuffer(e.FRAMEBUFFER, t._glID);
for (var i = this._framebuffer._colors.length, n = 0; n < i; ++n) {
var r = this._framebuffer._colors[n];
gt(e, e.COLOR_ATTACHMENT0 + n, r);
}
for (var s = i; s < this._caps.maxColorAttachments; ++s) e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0 + s, e.TEXTURE_2D, null, 0);
this._framebuffer._depth && gt(e, e.DEPTH_ATTACHMENT, this._framebuffer._depth);
this._framebuffer._stencil && gt(e, e.STENCIL_ATTACHMENT, t._stencil);
this._framebuffer._depthStencil && gt(e, e.DEPTH_STENCIL_ATTACHMENT, t._depthStencil);
} else e.bindFramebuffer(e.FRAMEBUFFER, null);
}
};
xt.prototype.setViewport = function(t, e, i, n) {
if (this._vx !== t || this._vy !== e || this._vw !== i || this._vh !== n) {
this._gl.viewport(t, e, i, n);
this._vx = t;
this._vy = e;
this._vw = i;
this._vh = n;
}
};
xt.prototype.setScissor = function(t, e, i, n) {
if (this._sx !== t || this._sy !== e || this._sw !== i || this._sh !== n) {
this._gl.scissor(t, e, i, n);
this._sx = t;
this._sy = e;
this._sw = i;
this._sh = n;
}
};
xt.prototype.clear = function(t) {
if (void 0 !== t.color || void 0 !== t.depth || void 0 !== t.stencil) {
var e = this._gl, i = 0;
if (void 0 !== t.color) {
i |= e.COLOR_BUFFER_BIT;
e.clearColor(t.color[0], t.color[1], t.color[2], t.color[3]);
}
if (void 0 !== t.depth) {
i |= e.DEPTH_BUFFER_BIT;
e.clearDepth(t.depth);
e.enable(e.DEPTH_TEST);
e.depthMask(!0);
e.depthFunc(e.ALWAYS);
}
if (void 0 !== t.stencil) {
i |= e.STENCIL_BUFFER_BIT;
e.clearStencil(t.stencil);
}
e.clear(i);
if (void 0 !== t.depth) if (!1 === this._current.depthTest) e.disable(e.DEPTH_TEST); else {
!1 === this._current.depthWrite && e.depthMask(!1);
this._current.depthFunc !== J.DS_FUNC_ALWAYS && e.depthFunc(this._current.depthFunc);
}
}
};
xt.prototype.enableBlend = function() {
this._next.blend = !0;
};
xt.prototype.enableDepthTest = function() {
this._next.depthTest = !0;
};
xt.prototype.enableDepthWrite = function() {
this._next.depthWrite = !0;
};
xt.prototype.enableStencilTest = function() {
this._next.stencilTest = !0;
};
xt.prototype.setStencilFunc = function(t, e, i) {
this._next.stencilSep = !1;
this._next.stencilFuncFront = this._next.stencilFuncBack = t;
this._next.stencilRefFront = this._next.stencilRefBack = e;
this._next.stencilMaskFront = this._next.stencilMaskBack = i;
};
xt.prototype.setStencilFuncFront = function(t, e, i) {
this._next.stencilSep = !0;
this._next.stencilFuncFront = t;
this._next.stencilRefFront = e;
this._next.stencilMaskFront = i;
};
xt.prototype.setStencilFuncBack = function(t, e, i) {
this._next.stencilSep = !0;
this._next.stencilFuncBack = t;
this._next.stencilRefBack = e;
this._next.stencilMaskBack = i;
};
xt.prototype.setStencilOp = function(t, e, i, n) {
this._next.stencilFailOpFront = this._next.stencilFailOpBack = t;
this._next.stencilZFailOpFront = this._next.stencilZFailOpBack = e;
this._next.stencilZPassOpFront = this._next.stencilZPassOpBack = i;
this._next.stencilWriteMaskFront = this._next.stencilWriteMaskBack = n;
};
xt.prototype.setStencilOpFront = function(t, e, i, n) {
this._next.stencilSep = !0;
this._next.stencilFailOpFront = t;
this._next.stencilZFailOpFront = e;
this._next.stencilZPassOpFront = i;
this._next.stencilWriteMaskFront = n;
};
xt.prototype.setStencilOpBack = function(t, e, i, n) {
this._next.stencilSep = !0;
this._next.stencilFailOpBack = t;
this._next.stencilZFailOpBack = e;
this._next.stencilZPassOpBack = i;
this._next.stencilWriteMaskBack = n;
};
xt.prototype.setDepthFunc = function(t) {
this._next.depthFunc = t;
};
xt.prototype.setBlendColor32 = function(t) {
this._next.blendColor = t;
};
xt.prototype.setBlendColor = function(t, e, i, n) {
this._next.blendColor = (255 * t << 24 | 255 * e << 16 | 255 * i << 8 | 255 * n) >>> 0;
};
xt.prototype.setBlendFunc = function(t, e) {
this._next.blendSep = !1;
this._next.blendSrc = t;
this._next.blendDst = e;
};
xt.prototype.setBlendFuncSep = function(t, e, i, n) {
this._next.blendSep = !0;
this._next.blendSrc = t;
this._next.blendDst = e;
this._next.blendSrcAlpha = i;
this._next.blendDstAlpha = n;
};
xt.prototype.setBlendEq = function(t) {
this._next.blendSep = !1;
this._next.blendEq = t;
};
xt.prototype.setBlendEqSep = function(t, e) {
this._next.blendSep = !0;
this._next.blendEq = t;
this._next.blendAlphaEq = e;
};
xt.prototype.setCullMode = function(t) {
this._next.cullMode = t;
};
xt.prototype.setVertexBuffer = function(t, e, i) {
void 0 === i && (i = 0);
this._next.vertexBuffers[t] = e;
this._next.vertexBufferOffsets[t] = i;
this._next.maxStream < t && (this._next.maxStream = t);
};
xt.prototype.setIndexBuffer = function(t) {
this._next.indexBuffer = t;
};
xt.prototype.setProgram = function(t) {
this._next.program = t;
};
xt.prototype.setTexture = function(t, e, i) {
if (i >= this._caps.maxTextureUnits) console.warn("Can not set texture " + t + " at stage " + i + ", max texture exceed: " + this._caps.maxTextureUnits); else {
this._next.textureUnits[i] = e;
this.setUniform(t, i);
this._next.maxTextureSlot < i && (this._next.maxTextureSlot = i);
}
};
xt.prototype.setTextureArray = function(t, e, i) {
var n = e.length;
if (n >= this._caps.maxTextureUnits) console.warn("Can not set " + n + " textures for " + t + ", max texture exceed: " + this._caps.maxTextureUnits); else {
for (var r = 0; r < n; ++r) {
var s = i[r];
this._next.textureUnits[s] = e[r];
}
this.setUniform(t, i);
}
};
xt.prototype.setUniform = function(t, e) {
var i = this._uniforms[t], n = !1;
do {
if (!i) break;
if (i.isArray !== Array.isArray(e)) break;
if (i.isArray && i.value.length !== e.length) break;
n = !0;
} while (0);
if (n) {
var r = i.value, s = !1;
if (i.isArray) {
for (var o = 0, a = r.length; o < a; o++) if (r[o] !== e[o]) {
s = !0;
r[o] = e[o];
}
} else if (r !== e) {
s = !0;
i.value = e;
}
s && (i.dirty = !0);
} else {
var c = e, h = !1;
if (e instanceof Float32Array || Array.isArray(e)) {
c = new Float32Array(e);
h = !0;
} else if (e instanceof Int32Array) {
c = new Int32Array(e);
h = !0;
}
i = {
dirty: !0,
value: c,
isArray: h
};
}
this._uniforms[t] = i;
};
xt.prototype.setPrimitiveType = function(t) {
this._next.primitiveType = t;
};
xt.prototype.draw = function(t, e) {
var i = this._gl, n = this._current, r = this._next;
(function(t, e, i) {
if (e.blend === i.blend) {
if (!1 !== i.blend) {
e.blendColor !== i.blendColor && t.blendColor((i.blendColor >> 24) / 255, (i.blendColor >> 16 & 255) / 255, (i.blendColor >> 8 & 255) / 255, (255 & i.blendColor) / 255);
if (e.blendSep === i.blendSep) if (i.blendSep) {
e.blendSrc === i.blendSrc && e.blendDst === i.blendDst && e.blendSrcAlpha === i.blendSrcAlpha && e.blendDstAlpha === i.blendDstAlpha || t.blendFuncSeparate(i.blendSrc, i.blendDst, i.blendSrcAlpha, i.blendDstAlpha);
e.blendEq === i.blendEq && e.blendAlphaEq === i.blendAlphaEq || t.blendEquationSeparate(i.blendEq, i.blendAlphaEq);
} else {
e.blendSrc === i.blendSrc && e.blendDst === i.blendDst || t.blendFunc(i.blendSrc, i.blendDst);
e.blendEq !== i.blendEq && t.blendEquation(i.blendEq);
} else if (i.blendSep) {
t.blendFuncSeparate(i.blendSrc, i.blendDst, i.blendSrcAlpha, i.blendDstAlpha);
t.blendEquationSeparate(i.blendEq, i.blendAlphaEq);
} else {
t.blendFunc(i.blendSrc, i.blendDst);
t.blendEquation(i.blendEq);
}
}
} else {
if (!i.blend) {
t.disable(t.BLEND);
return;
}
t.enable(t.BLEND);
i.blendSrc !== J.BLEND_CONSTANT_COLOR && i.blendSrc !== J.BLEND_ONE_MINUS_CONSTANT_COLOR && i.blendDst !== J.BLEND_CONSTANT_COLOR && i.blendDst !== J.BLEND_ONE_MINUS_CONSTANT_COLOR || t.blendColor((i.blendColor >> 24) / 255, (i.blendColor >> 16 & 255) / 255, (i.blendColor >> 8 & 255) / 255, (255 & i.blendColor) / 255);
if (i.blendSep) {
t.blendFuncSeparate(i.blendSrc, i.blendDst, i.blendSrcAlpha, i.blendDstAlpha);
t.blendEquationSeparate(i.blendEq, i.blendAlphaEq);
} else {
t.blendFunc(i.blendSrc, i.blendDst);
t.blendEquation(i.blendEq);
}
}
})(i, n, r);
(function(t, e, i) {
if (e.depthTest === i.depthTest) {
e.depthWrite !== i.depthWrite && t.depthMask(i.depthWrite);
if (!1 !== i.depthTest) e.depthFunc !== i.depthFunc && t.depthFunc(i.depthFunc); else if (i.depthWrite) {
i.depthTest = !0;
i.depthFunc = J.DS_FUNC_ALWAYS;
t.enable(t.DEPTH_TEST);
t.depthFunc(i.depthFunc);
}
} else {
if (!i.depthTest) {
t.disable(t.DEPTH_TEST);
return;
}
t.enable(t.DEPTH_TEST);
t.depthFunc(i.depthFunc);
t.depthMask(i.depthWrite);
}
})(i, n, r);
(function(t, e, i) {
if (i.stencilTest === e.stencilTest) {
if (i.stencilTest) if (e.stencilSep === i.stencilSep) if (i.stencilSep) {
e.stencilFuncFront === i.stencilFuncFront && e.stencilRefFront === i.stencilRefFront && e.stencilMaskFront === i.stencilMaskFront || t.stencilFuncSeparate(t.FRONT, i.stencilFuncFront, i.stencilRefFront, i.stencilMaskFront);
e.stencilWriteMaskFront !== i.stencilWriteMaskFront && t.stencilMaskSeparate(t.FRONT, i.stencilWriteMaskFront);
e.stencilFailOpFront === i.stencilFailOpFront && e.stencilZFailOpFront === i.stencilZFailOpFront && e.stencilZPassOpFront === i.stencilZPassOpFront || t.stencilOpSeparate(t.FRONT, i.stencilFailOpFront, i.stencilZFailOpFront, i.stencilZPassOpFront);
e.stencilFuncBack === i.stencilFuncBack && e.stencilRefBack === i.stencilRefBack && e.stencilMaskBack === i.stencilMaskBack || t.stencilFuncSeparate(t.BACK, i.stencilFuncBack, i.stencilRefBack, i.stencilMaskBack);
e.stencilWriteMaskBack !== i.stencilWriteMaskBack && t.stencilMaskSeparate(t.BACK, i.stencilWriteMaskBack);
e.stencilFailOpBack === i.stencilFailOpBack && e.stencilZFailOpBack === i.stencilZFailOpBack && e.stencilZPassOpBack === i.stencilZPassOpBack || t.stencilOpSeparate(t.BACK, i.stencilFailOpBack, i.stencilZFailOpBack, i.stencilZPassOpBack);
} else {
e.stencilFuncFront === i.stencilFuncFront && e.stencilRefFront === i.stencilRefFront && e.stencilMaskFront === i.stencilMaskFront || t.stencilFunc(i.stencilFuncFront, i.stencilRefFront, i.stencilMaskFront);
e.stencilWriteMaskFront !== i.stencilWriteMaskFront && t.stencilMask(i.stencilWriteMaskFront);
e.stencilFailOpFront === i.stencilFailOpFront && e.stencilZFailOpFront === i.stencilZFailOpFront && e.stencilZPassOpFront === i.stencilZPassOpFront || t.stencilOp(i.stencilFailOpFront, i.stencilZFailOpFront, i.stencilZPassOpFront);
} else if (i.stencilSep) {
t.stencilFuncSeparate(t.FRONT, i.stencilFuncFront, i.stencilRefFront, i.stencilMaskFront);
t.stencilMaskSeparate(t.FRONT, i.stencilWriteMaskFront);
t.stencilOpSeparate(t.FRONT, i.stencilFailOpFront, i.stencilZFailOpFront, i.stencilZPassOpFront);
t.stencilFuncSeparate(t.BACK, i.stencilFuncBack, i.stencilRefBack, i.stencilMaskBack);
t.stencilMaskSeparate(t.BACK, i.stencilWriteMaskBack);
t.stencilOpSeparate(t.BACK, i.stencilFailOpBack, i.stencilZFailOpBack, i.stencilZPassOpBack);
} else {
t.stencilFunc(i.stencilFuncFront, i.stencilRefFront, i.stencilMaskFront);
t.stencilMask(i.stencilWriteMaskFront);
t.stencilOp(i.stencilFailOpFront, i.stencilZFailOpFront, i.stencilZPassOpFront);
}
} else {
if (!i.stencilTest) {
t.disable(t.STENCIL_TEST);
return;
}
t.enable(t.STENCIL_TEST);
if (i.stencilSep) {
t.stencilFuncSeparate(t.FRONT, i.stencilFuncFront, i.stencilRefFront, i.stencilMaskFront);
t.stencilMaskSeparate(t.FRONT, i.stencilWriteMaskFront);
t.stencilOpSeparate(t.FRONT, i.stencilFailOpFront, i.stencilZFailOpFront, i.stencilZPassOpFront);
t.stencilFuncSeparate(t.BACK, i.stencilFuncBack, i.stencilRefBack, i.stencilMaskBack);
t.stencilMaskSeparate(t.BACK, i.stencilWriteMaskBack);
t.stencilOpSeparate(t.BACK, i.stencilFailOpBack, i.stencilZFailOpBack, i.stencilZPassOpBack);
} else {
t.stencilFunc(i.stencilFuncFront, i.stencilRefFront, i.stencilMaskFront);
t.stencilMask(i.stencilWriteMaskFront);
t.stencilOp(i.stencilFailOpFront, i.stencilZFailOpFront, i.stencilZPassOpFront);
}
}
})(i, n, r);
(function(t, e, i) {
if (e.cullMode !== i.cullMode) if (i.cullMode !== J.CULL_NONE) {
t.enable(t.CULL_FACE);
t.cullFace(i.cullMode);
} else t.disable(t.CULL_FACE);
})(i, n, r);
(function(t, e, i, n) {
var r = !1;
if (-1 !== n.maxStream) {
if (i.maxStream !== n.maxStream) r = !0; else if (i.program !== n.program) r = !0; else for (var s = 0; s < n.maxStream + 1; ++s) if (i.vertexBuffers[s] !== n.vertexBuffers[s] || i.vertexBufferOffsets[s] !== n.vertexBufferOffsets[s]) {
r = !0;
break;
}
if (r) {
for (var o = 0; o < t._caps.maxVertexAttribs; ++o) t._newAttributes[o] = 0;
for (var a = 0; a < n.maxStream + 1; ++a) {
var c = n.vertexBuffers[a], h = n.vertexBufferOffsets[a];
if (c) {
e.bindBuffer(e.ARRAY_BUFFER, c._glID);
for (var l = 0; l < n.program._attributes.length; ++l) {
var u = n.program._attributes[l], _ = c._format.element(u.name);
if (_) {
if (0 === t._enabledAttributes[u.location]) {
e.enableVertexAttribArray(u.location);
t._enabledAttributes[u.location] = 1;
}
t._newAttributes[u.location] = 1;
e.vertexAttribPointer(u.location, _.num, _.type, _.normalize, _.stride, _.offset + h * _.stride);
} else console.warn("Can not find vertex attribute: " + u.name);
}
}
}
for (var f = 0; f < t._caps.maxVertexAttribs; ++f) if (t._enabledAttributes[f] !== t._newAttributes[f]) {
e.disableVertexAttribArray(f);
t._enabledAttributes[f] = 0;
}
}
} else console.warn("VertexBuffer not assigned, please call setVertexBuffer before every draw.");
})(this, i, n, r);
n.indexBuffer !== r.indexBuffer && i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, r.indexBuffer ? r.indexBuffer._glID : null);
var s = !1;
if (n.program !== r.program) {
r.program._linked ? i.useProgram(r.program._glID) : console.warn("Failed to use program: has not linked yet.");
s = !0;
}
(function(t, e, i) {
for (var n = 0; n < i.maxTextureSlot + 1; ++n) if (e.textureUnits[n] !== i.textureUnits[n]) {
var r = i.textureUnits[n];
if (r && -1 !== r._glID) {
t.activeTexture(t.TEXTURE0 + n);
t.bindTexture(r._target, r._glID);
}
}
})(i, n, r);
for (var o = 0; o < r.program._uniforms.length; ++o) {
var a = r.program._uniforms[o], c = this._uniforms[a.name];
if (c && (s || c.dirty)) {
c.dirty = !1;
var h = void 0 === a.size ? vt[a.type] : yt[a.type];
h ? h(i, a.location, c.value) : console.warn("Can not find commit function for uniform " + a.name);
}
}
r.indexBuffer ? i.drawElements(this._next.primitiveType, e, r.indexBuffer._format, t * r.indexBuffer._bytesPerIndex) : i.drawArrays(this._next.primitiveType, t, e);
this._stats.drawcalls += 1;
n.set(r);
r.reset();
};
var Ct = {
VertexFormat: $,
IndexBuffer: tt,
VertexBuffer: it,
Program: ot,
Texture: ht,
Texture2D: ut,
TextureCube: _t,
RenderBuffer: ft,
FrameBuffer: dt,
Device: xt,
attrTypeBytes: Z,
glFilter: K,
glTextureFmt: Q
};
Object.assign(Ct, J);
var At = function(t, e, i) {
void 0 === i && (i = Ct.PT_TRIANGLES);
this._vertexBuffer = t;
this._indexBuffer = e;
this._primitiveType = i;
this._start = 0;
this._count = -1;
};
At.prototype.getPrimitiveCount = function() {
return -1 !== this._count ? this._count : this._indexBuffer ? this._indexBuffer.count : this._vertexBuffer.count;
};
var bt = function(t) {
this._programName = t;
this._cullMode = Ct.CULL_BACK;
this._blend = !1;
this._blendEq = Ct.BLEND_FUNC_ADD;
this._blendAlphaEq = Ct.BLEND_FUNC_ADD;
this._blendSrc = Ct.BLEND_ONE;
this._blendDst = Ct.BLEND_ZERO;
this._blendSrcAlpha = Ct.BLEND_ONE;
this._blendDstAlpha = Ct.BLEND_ZERO;
this._blendColor = 4294967295;
this._depthTest = !1;
this._depthWrite = !1;
this._depthFunc = Ct.DS_FUNC_LESS;
this._stencilTest = !1;
this._stencilFuncFront = Ct.DS_FUNC_ALWAYS;
this._stencilRefFront = 0;
this._stencilMaskFront = 255;
this._stencilFailOpFront = Ct.STENCIL_OP_KEEP;
this._stencilZFailOpFront = Ct.STENCIL_OP_KEEP;
this._stencilZPassOpFront = Ct.STENCIL_OP_KEEP;
this._stencilWriteMaskFront = 255;
this._stencilFuncBack = Ct.DS_FUNC_ALWAYS;
this._stencilRefBack = 0;
this._stencilMaskBack = 255;
this._stencilFailOpBack = Ct.STENCIL_OP_KEEP;
this._stencilZFailOpBack = Ct.STENCIL_OP_KEEP;
this._stencilZPassOpBack = Ct.STENCIL_OP_KEEP;
this._stencilWriteMaskBack = 255;
};
bt.prototype.copy = function(t) {
this._programName = t._programName;
this._cullMode = t._cullMode;
this._blend = t._blend;
this._blendEq = t._blendEq;
this._blendAlphaEq = t._blendAlphaEq;
this._blendSrc = t._blendSrc;
this._blendDst = t._blendDst;
this._blendSrcAlpha = t._blendSrcAlpha;
this._blendDstAlpha = t._blendDstAlpha;
this._blendColor = t._blendColor;
this._depthTest = t._depthTest;
this._depthWrite = t._depthWrite;
this._depthFunc = t._depthFunc;
this._stencilTest = t._stencilTest;
this._stencilFuncFront = t._stencilFuncFront;
this._stencilRefFront = t._stencilRefFront;
this._stencilMaskFront = t._stencilMaskFront;
this._stencilFailOpFront = t._stencilFailOpFront;
this._stencilZFailOpFront = t._stencilZFailOpFront;
this._stencilZPassOpFront = t._stencilZPassOpFront;
this._stencilWriteMaskFront = t._stencilWriteMaskFront;
this._stencilFuncBack = t._stencilFuncBack;
this._stencilRefBack = t._stencilRefBack;
this._stencilMaskBack = t._stencilMaskBack;
this._stencilFailOpBack = t._stencilFailOpBack;
this._stencilZFailOpBack = t._stencilZFailOpBack;
this._stencilZPassOpBack = t._stencilZPassOpBack;
this._stencilWriteMaskBack = t._stencilWriteMaskBack;
};
bt.prototype.setCullMode = function(t) {
this._cullMode = t;
};
bt.prototype.setBlend = function(t, e, i, n, r, s, o) {
void 0 === t && (t = Ct.BLEND_FUNC_ADD);
void 0 === e && (e = Ct.BLEND_ONE);
void 0 === i && (i = Ct.BLEND_ZERO);
void 0 === n && (n = Ct.BLEND_FUNC_ADD);
void 0 === r && (r = Ct.BLEND_ONE);
void 0 === s && (s = Ct.BLEND_ZERO);
void 0 === o && (o = 4294967295);
this._blend = !0;
this._blendEq = t;
this._blendSrc = e;
this._blendDst = i;
this._blendAlphaEq = n;
this._blendSrcAlpha = r;
this._blendDstAlpha = s;
this._blendColor = o;
};
bt.prototype.setDepth = function(t, e, i) {
void 0 === t && (t = !1);
void 0 === e && (e = !1);
void 0 === i && (i = Ct.DS_FUNC_LESS);
this._depthTest = t;
this._depthWrite = e;
this._depthFunc = i;
};
bt.prototype.setStencilFront = function(t, e, i, n, r, s, o) {
void 0 === t && (t = Ct.DS_FUNC_ALWAYS);
void 0 === e && (e = 0);
void 0 === i && (i = 255);
void 0 === n && (n = Ct.STENCIL_OP_KEEP);
void 0 === r && (r = Ct.STENCIL_OP_KEEP);
void 0 === s && (s = Ct.STENCIL_OP_KEEP);
void 0 === o && (o = 255);
this._stencilTest = !0;
this._stencilFuncFront = t;
this._stencilRefFront = e;
this._stencilMaskFront = i;
this._stencilFailOpFront = n;
this._stencilZFailOpFront = r;
this._stencilZPassOpFront = s;
this._stencilWriteMaskFront = o;
};
bt.prototype.setStencilBack = function(t, e, i, n, r, s, o) {
void 0 === t && (t = Ct.DS_FUNC_ALWAYS);
void 0 === e && (e = 0);
void 0 === i && (i = 255);
void 0 === n && (n = Ct.STENCIL_OP_KEEP);
void 0 === r && (r = Ct.STENCIL_OP_KEEP);
void 0 === s && (s = Ct.STENCIL_OP_KEEP);
void 0 === o && (o = 255);
this._stencilTest = !0;
this._stencilFuncBack = t;
this._stencilRefBack = e;
this._stencilMaskBack = i;
this._stencilFailOpBack = n;
this._stencilZFailOpBack = r;
this._stencilZPassOpBack = s;
this._stencilWriteMaskBack = o;
};
bt.prototype.disableStencilTest = function() {
this._stencilTest = !1;
};
var St = 0, Tt = {}, wt = {
addStage: function(t) {
if (void 0 === Tt[t]) {
var e = 1 << St;
Tt[t] = e;
St += 1;
}
},
stageID: function(t) {
var e = Tt[t];
return void 0 === e ? -1 : e;
},
stageIDs: function(t) {
for (var e = 0, i = 0; i < t.length; ++i) {
var n = Tt[t[i]];
void 0 !== n && (e |= n);
}
return e;
}
}, Et = 0, Bt = function(t, e, i, n) {
void 0 === n && (n = 0);
this._id = Et++;
this._stageIDs = wt.stageIDs(t);
this._parameters = e;
this._passes = i;
this._layer = n;
}, Mt = {
passes: {
configurable: !0
},
stageIDs: {
configurable: !0
}
};
Bt.prototype.copy = function(t) {
this._id = t._id;
this._stageIDs = t._stageIDs;
this._parameters = [];
for (var e = 0; e < t._parameters.length; ++e) {
var i = t._parameters[e];
this._parameters.push({
name: i.name,
type: i.type
});
}
for (var n = 0; n < t._passes.length; ++n) {
var r = this._passes[n];
if (!r) {
r = new Fe.Pass();
this._passes.push(r);
}
r.copy(t._passes[n]);
}
this._passes.length = t._passes.length;
this._layer = t._layer;
};
Bt.prototype.setStages = function(t) {
this._stageIDs = wt.stageIDs(t);
};
Mt.passes.get = function() {
return this._passes;
};
Mt.stageIDs.get = function() {
return this._stageIDs;
};
Object.defineProperties(Bt.prototype, Mt);
var Dt = function(t, e, i) {
void 0 === e && (e = {});
void 0 === i && (i = []);
this._techniques = t;
this._properties = e;
this._defines = i;
};
Dt.prototype.clear = function() {
this._techniques.length = 0;
this._properties = null;
this._defines.length = 0;
};
Dt.prototype.getTechnique = function(t) {
for (var e = wt.stageID(t), i = 0; i < this._techniques.length; ++i) {
var n = this._techniques[i];
if (n.stageIDs & e) return n;
}
return null;
};
Dt.prototype.getProperty = function(t) {
return this._properties[t];
};
Dt.prototype.setProperty = function(t, e) {
this._properties[t] = e;
};
Dt.prototype.getDefine = function(t) {
for (var e = 0; e < this._defines.length; ++e) {
var i = this._defines[e];
if (i.name === t) return i.value;
}
console.warn("Failed to get define " + t + ", define not found.");
return null;
};
Dt.prototype.define = function(t, e) {
for (var i = 0; i < this._defines.length; ++i) {
var n = this._defines[i];
if (n.name === t) {
n.value = e;
return;
}
}
console.warn("Failed to set define " + t + ", define not found.");
};
Dt.prototype.extractDefines = function(t) {
void 0 === t && (t = {});
for (var e = 0; e < this._defines.length; ++e) {
var i = this._defines[e];
t[i.name] = i.value;
}
return t;
};
var It = O.create(), Pt = 0, Rt = function() {
this._id = Pt++;
this._rect = {
x: 0,
y: 0,
w: 1,
h: 1
};
this._color = j.new(.3, .3, .3, 1);
this._depth = 1;
this._stencil = 0;
this._clearFlags = q.CLEAR_COLOR | q.CLEAR_DEPTH;
this._matView = O.create();
this._matProj = O.create();
this._matViewProj = O.create();
this._matInvViewProj = O.create();
this._stages = [];
this._cullingMask = 1;
this._framebuffer = null;
this._shadowLight = null;
};
Rt.prototype.getForward = function(t) {
return g.set(t, -this._matView.m02, -this._matView.m06, -this._matView.m10);
};
Rt.prototype.getPosition = function(t) {
O.invert(It, this._matView);
return O.getTranslation(t, It);
};
var Lt = g.new(0, 0, -1), Ft = O.create(), Vt = T.create(), Ot = g.create();
var Nt = function() {
this._poolID = -1;
this._node = null;
this._type = q.LIGHT_DIRECTIONAL;
this._color = G.new(1, 1, 1);
this._intensity = 1;
this._range = 1;
this._spotAngle = o(60);
this._spotExp = 1;
this._directionUniform = new Float32Array(3);
this._positionUniform = new Float32Array(3);
this._colorUniform = new Float32Array([ this._color.r * this._intensity, this._color.g * this._intensity, this._color.b * this._intensity ]);
this._spotUniform = new Float32Array([ Math.cos(.5 * this._spotAngle), this._spotExp ]);
this._shadowType = q.SHADOW_NONE;
this._shadowFrameBuffer = null;
this._shadowMap = null;
this._shadowMapDirty = !1;
this._shadowDepthBuffer = null;
this._shadowResolution = 1024;
this._shadowBias = 5e-5;
this._shadowDarkness = 1;
this._shadowMinDepth = 1;
this._shadowMaxDepth = 1e3;
this._shadowDepthScale = 50;
this._frustumEdgeFalloff = 0;
this._viewProjMatrix = O.create();
this._spotAngleScale = 1;
this._shadowFustumSize = 80;
}, kt = {
color: {
configurable: !0
},
intensity: {
configurable: !0
},
type: {
configurable: !0
},
spotAngle: {
configurable: !0
},
spotExp: {
configurable: !0
},
range: {
configurable: !0
},
shadowType: {
configurable: !0
},
shadowMap: {
configurable: !0
},
viewProjMatrix: {
configurable: !0
},
shadowResolution: {
configurable: !0
},
shadowBias: {
configurable: !0
},
shadowDarkness: {
configurable: !0
},
shadowMinDepth: {
configurable: !0
},
shadowMaxDepth: {
configurable: !0
},
shadowDepthScale: {
configurable: !0
},
frustumEdgeFalloff: {
configurable: !0
}
};
Nt.prototype.setNode = function(t) {
this._node = t;
};
Nt.prototype.setColor = function(t, e, i) {
G.set(this._color, t, e, i);
this._colorUniform[0] = t * this._intensity;
this._colorUniform[1] = e * this._intensity;
this._colorUniform[2] = i * this._intensity;
};
kt.color.get = function() {
return this._color;
};
Nt.prototype.setIntensity = function(t) {
this._intensity = t;
this._colorUniform[0] = t * this._color.r;
this._colorUniform[1] = t * this._color.g;
this._colorUniform[2] = t * this._color.b;
};
kt.intensity.get = function() {
return this._intensity;
};
Nt.prototype.setType = function(t) {
this._type = t;
};
kt.type.get = function() {
return this._type;
};
Nt.prototype.setSpotAngle = function(t) {
this._spotAngle = t;
this._spotUniform[0] = Math.cos(.5 * this._spotAngle);
};
kt.spotAngle.get = function() {
return this._spotAngle;
};
Nt.prototype.setSpotExp = function(t) {
this._spotExp = t;
this._spotUniform[1] = t;
};
kt.spotExp.get = function() {
return this._spotExp;
};
Nt.prototype.setRange = function(t) {
this._range = t;
};
kt.range.get = function() {
return this._range;
};
Nt.prototype.setShadowType = function(t) {
this._shadowType === q.SHADOW_NONE && t !== q.SHADOW_NONE && (this._shadowMapDirty = !0);
this._shadowType = t;
};
kt.shadowType.get = function() {
return this._shadowType;
};
kt.shadowMap.get = function() {
return this._shadowMap;
};
kt.viewProjMatrix.get = function() {
return this._viewProjMatrix;
};
Nt.prototype.setShadowResolution = function(t) {
this._shadowResolution !== t && (this._shadowMapDirty = !0);
this._shadowResolution = t;
};
kt.shadowResolution.get = function() {
return this._shadowResolution;
};
Nt.prototype.setShadowBias = function(t) {
this._shadowBias = t;
};
kt.shadowBias.get = function() {
return this._shadowBias;
};
Nt.prototype.setShadowDarkness = function(t) {
this._shadowDarkness = t;
};
kt.shadowDarkness.get = function() {
return this._shadowDarkness;
};
Nt.prototype.setShadowMinDepth = function(t) {
this._shadowMinDepth = t;
};
kt.shadowMinDepth.get = function() {
return this._type === q.LIGHT_DIRECTIONAL ? 1 : this._shadowMinDepth;
};
Nt.prototype.setShadowMaxDepth = function(t) {
this._shadowMaxDepth = t;
};
kt.shadowMaxDepth.get = function() {
return this._type === q.LIGHT_DIRECTIONAL ? 1 : this._shadowMaxDepth;
};
Nt.prototype.setShadowDepthScale = function(t) {
this._shadowDepthScale = t;
};
kt.shadowDepthScale.get = function() {
return this._shadowDepthScale;
};
Nt.prototype.setFrustumEdgeFalloff = function(t) {
this._frustumEdgeFalloff = t;
};
kt.frustumEdgeFalloff.get = function() {
return this._frustumEdgeFalloff;
};
Nt.prototype.extractView = function(t, e) {
t._shadowLight = this;
t._rect.x = 0;
t._rect.y = 0;
t._rect.w = this._shadowResolution;
t._rect.h = this._shadowResolution;
j.set(t._color, 1, 1, 1, 1);
t._depth = 1;
t._stencil = 0;
t._clearFlags = q.CLEAR_COLOR | q.CLEAR_DEPTH;
t._stages = e;
t._framebuffer = this._shadowFrameBuffer;
switch (this._type) {
case q.LIGHT_SPOT:
(function(t, e, i) {
t._node.getWorldRT(e);
O.invert(e, e);
O.perspective(i, t._spotAngle * t._spotAngleScale, 1, t._shadowMinDepth, t._shadowMaxDepth);
})(this, t._matView, t._matProj);
break;

case q.LIGHT_DIRECTIONAL:
(function(t, e, i) {
t._node.getWorldRT(e);
O.invert(e, e);
var n = t._shadowFustumSize / 2;
O.ortho(i, -n, n, -n, n, t._shadowMinDepth, t._shadowMaxDepth);
})(this, t._matView, t._matProj);
break;

case q.LIGHT_POINT:
t._matView, t._matProj;
break;

default:
console.warn("shadow of this light type is not supported");
}
O.mul(t._matViewProj, t._matProj, t._matView);
this._viewProjMatrix = t._matViewProj;
O.invert(t._matInvViewProj, t._matViewProj);
};
Nt.prototype._updateLightPositionAndDirection = function() {
this._node.getWorldMatrix(Ft);
T.fromMat4(Vt, Ft);
g.transformMat3(Ot, Lt, Vt);
g.array(this._directionUniform, Ot);
var t = this._positionUniform;
t[0] = Ft.m12;
t[1] = Ft.m13;
t[2] = Ft.m14;
};
Nt.prototype._generateShadowMap = function(t) {
this._shadowMap = new Ct.Texture2D(t, {
width: this._shadowResolution,
height: this._shadowResolution,
format: Ct.TEXTURE_FMT_RGBA8,
wrapS: Ct.WRAP_CLAMP,
wrapT: Ct.WRAP_CLAMP
});
this._shadowDepthBuffer = new Ct.RenderBuffer(t, Ct.RB_FMT_D16, this._shadowResolution, this._shadowResolution);
this._shadowFrameBuffer = new Ct.FrameBuffer(t, this._shadowResolution, this._shadowResolution, {
colors: [ this._shadowMap ],
depth: this._shadowDepthBuffer
});
};
Nt.prototype._destroyShadowMap = function() {
if (this._shadowMap) {
this._shadowMap.destroy();
this._shadowDepthBuffer.destroy();
this._shadowFrameBuffer.destroy();
this._shadowMap = null;
this._shadowDepthBuffer = null;
this._shadowFrameBuffer = null;
}
};
Nt.prototype.update = function(t) {
this._updateLightPositionAndDirection();
if (this._shadowType === q.SHADOW_NONE) this._destroyShadowMap(); else if (this._shadowMapDirty) {
this._destroyShadowMap();
this._generateShadowMap(t);
this._shadowMapDirty = !1;
}
};
Object.defineProperties(Nt.prototype, kt);
var Gt = O.create(), zt = O.create(), Ut = O.create(), jt = O.create(), Ht = g.create(), Wt = function() {
this._poolID = -1;
this._node = null;
this._projection = q.PROJ_PERSPECTIVE;
this._color = j.new(.2, .3, .47, 1);
this._depth = 1;
this._stencil = 0;
this._clearFlags = q.CLEAR_COLOR | q.CLEAR_DEPTH;
this._cullingMask = 1;
this._stages = [];
this._framebuffer = null;
this._near = .01;
this._far = 1e3;
this._fov = Math.PI / 4;
this._rect = {
x: 0,
y: 0,
w: 1,
h: 1
};
this._orthoHeight = 10;
}, qt = {
cullingMask: {
configurable: !0
}
};
qt.cullingMask.get = function() {
return this._cullingMask;
};
qt.cullingMask.set = function(t) {
this._cullingMask = t;
};
Wt.prototype.getNode = function() {
return this._node;
};
Wt.prototype.setNode = function(t) {
this._node = t;
};
Wt.prototype.getType = function() {
return this._projection;
};
Wt.prototype.setType = function(t) {
this._projection = t;
};
Wt.prototype.getOrthoHeight = function() {
return this._orthoHeight;
};
Wt.prototype.setOrthoHeight = function(t) {
this._orthoHeight = t;
};
Wt.prototype.getFov = function() {
return this._fov;
};
Wt.prototype.setFov = function(t) {
this._fov = t;
};
Wt.prototype.getNear = function() {
return this._near;
};
Wt.prototype.setNear = function(t) {
this._near = t;
};
Wt.prototype.getFar = function() {
return this._far;
};
Wt.prototype.setFar = function(t) {
this._far = t;
};
Wt.prototype.getColor = function(t) {
return j.copy(t, this._color);
};
Wt.prototype.setColor = function(t, e, i, n) {
j.set(this._color, t, e, i, n);
};
Wt.prototype.getDepth = function() {
return this._depth;
};
Wt.prototype.setDepth = function(t) {
this._depth = t;
};
Wt.prototype.getStencil = function() {
return this._stencil;
};
Wt.prototype.setStencil = function(t) {
this._stencil = t;
};
Wt.prototype.getClearFlags = function() {
return this._clearFlags;
};
Wt.prototype.setClearFlags = function(t) {
this._clearFlags = t;
};
Wt.prototype.getRect = function(t) {
t.x = this._rect.x;
t.y = this._rect.y;
t.w = this._rect.w;
t.h = this._rect.h;
return t;
};
Wt.prototype.setRect = function(t, e, i, n) {
this._rect.x = t;
this._rect.y = e;
this._rect.w = i;
this._rect.h = n;
};
Wt.prototype.getStages = function() {
return this._stages;
};
Wt.prototype.setStages = function(t) {
this._stages = t;
};
Wt.prototype.getFramebuffer = function() {
return this._framebuffer;
};
Wt.prototype.setFramebuffer = function(t) {
this._framebuffer = t;
};
Wt.prototype.extractView = function(t, e, i) {
t._rect.x = this._rect.x * e;
t._rect.y = this._rect.y * i;
t._rect.w = this._rect.w * e;
t._rect.h = this._rect.h * i;
t._color = this._color;
t._depth = this._depth;
t._stencil = this._stencil;
t._clearFlags = this._clearFlags;
t._cullingMask = this._cullingMask;
t._stages = this._stages;
t._framebuffer = this._framebuffer;
this._node.getWorldRT(t._matView);
O.invert(t._matView, t._matView);
var n = e / i;
if (this._projection === q.PROJ_PERSPECTIVE) O.perspective(t._matProj, this._fov, n, this._near, this._far); else {
var r = this._orthoHeight * n, s = this._orthoHeight;
O.ortho(t._matProj, -r, r, -s, s, this._near, this._far);
}
O.mul(t._matViewProj, t._matProj, t._matView);
O.invert(t._matInvViewProj, t._matViewProj);
};
Wt.prototype.screenToWorld = function(t, e, i, n) {
var r = i / n, s = this._rect.x * i, o = this._rect.y * n, a = this._rect.w * i, c = this._rect.h * n;
this._node.getWorldRT(Gt);
O.invert(Gt, Gt);
if (this._projection === q.PROJ_PERSPECTIVE) O.perspective(zt, this._fov, r, this._near, this._far); else {
var h = this._orthoHeight * r, l = this._orthoHeight;
O.ortho(zt, -h, h, -l, l, this._near, this._far);
}
O.mul(Ut, zt, Gt);
O.invert(jt, Ut);
if (this._projection === q.PROJ_PERSPECTIVE) {
g.set(t, 2 * (e.x - s) / a - 1, 2 * (e.y - o) / c - 1, 1);
g.transformMat4(t, t, jt);
this._node.getWorldPos(Ht);
g.lerp(t, Ht, t, e.z / this._far);
} else {
var u = this._farClip - this._nearClip;
g.set(t, 2 * (e.x - s) / a - 1, 2 * (e.y - o) / c - 1, (this._far - e.z) / u * 2 - 1);
g.transformMat4(t, t, jt);
}
return t;
};
Wt.prototype.worldToScreen = function(t, e, i, n) {
var r = i / n, s = this._rect.x * i, o = this._rect.y * n, a = this._rect.w * i, c = this._rect.h * n;
this._node.getWorldRT(Gt);
O.invert(Gt, Gt);
if (this._projection === q.PROJ_PERSPECTIVE) O.perspective(zt, this._fov, r, this._near, this._far); else {
var h = this._orthoHeight * r, l = this._orthoHeight;
O.ortho(zt, -h, h, -l, l, this._near, this._far);
}
O.mul(Ut, zt, Gt);
var u = e.x * Ut.m03 + e.y * Ut.m07 + e.z * Ut.m11 + Ut.m15;
g.transformMat4(t, e, Ut);
t.x = s + .5 * (t.x / u + 1) * a;
t.y = o + .5 * (t.y / u + 1) * c;
return t;
};
Object.defineProperties(Wt.prototype, qt);
var Xt = function() {
this._poolID = -1;
this._node = null;
this._inputAssemblers = [];
this._effects = [];
this._defines = [];
this._dynamicIA = !1;
this._cullingMask = -1;
}, Yt = {
inputAssemblerCount: {
configurable: !0
},
dynamicIA: {
configurable: !0
},
drawItemCount: {
configurable: !0
},
cullingMask: {
configurable: !0
}
};
Yt.inputAssemblerCount.get = function() {
return this._inputAssemblers.length;
};
Yt.dynamicIA.get = function() {
return this._dynamicIA;
};
Yt.drawItemCount.get = function() {
return this._dynamicIA ? 1 : this._inputAssemblers.length;
};
Yt.cullingMask.get = function() {
return this._cullingMask;
};
Yt.cullingMask.set = function(t) {
this._cullingMask = t;
};
Xt.prototype.setNode = function(t) {
this._node = t;
};
Xt.prototype.setDynamicIA = function(t) {
this._dynamicIA = t;
};
Xt.prototype.addInputAssembler = function(t) {
-1 === this._inputAssemblers.indexOf(t) && this._inputAssemblers.push(t);
};
Xt.prototype.clearInputAssemblers = function() {
this._inputAssemblers.length = 0;
};
Xt.prototype.addEffect = function(t) {
if (-1 === this._effects.indexOf(t)) {
this._effects.push(t);
var e = Object.create(null);
t.extractDefines(e);
this._defines.push(e);
}
};
Xt.prototype.clearEffects = function() {
this._effects.length = 0;
this._defines.length = 0;
};
Xt.prototype.extractDrawItem = function(t, e) {
if (this._dynamicIA) {
t.model = this;
t.node = this._node;
t.ia = null;
t.effect = this._effects[0];
t.defines = t.effect.extractDefines(this._defines[0]);
} else if (e >= this._inputAssemblers.length) {
t.model = null;
t.node = null;
t.ia = null;
t.effect = null;
t.defines = null;
} else {
t.model = this;
t.node = this._node;
t.ia = this._inputAssemblers[e];
var i, n;
if (e < this._effects.length) {
i = this._effects[e];
n = this._defines[e];
} else {
i = this._effects[this._effects.length - 1];
n = this._defines[this._effects.length - 1];
}
t.effect = i;
t.defines = i.extractDefines(n);
}
};
Object.defineProperties(Xt.prototype, Yt);
var Jt = 32, Zt = [ 1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9 ];
function Kt(t) {
return t < 1e5 ? t < 100 ? t < 10 ? 0 : 1 : t < 1e4 ? t < 1e3 ? 2 : 3 : 4 : t < 1e7 ? t < 1e6 ? 5 : 6 : t < 1e9 ? t < 1e8 ? 7 : 8 : 9;
}
function Qt(t, e) {
if (t === e) return 0;
if (~~t === t && ~~e === e) {
if (0 === t || 0 === e) return t < e ? -1 : 1;
if (t < 0 || e < 0) {
if (e >= 0) return -1;
if (t >= 0) return 1;
t = -t;
e = -e;
}
var i = Kt(t), n = Kt(e), r = 0;
if (i < n) {
t *= Zt[n - i - 1];
e /= 10;
r = -1;
} else if (i > n) {
e *= Zt[i - n - 1];
t /= 10;
r = 1;
}
return t === e ? r : t < e ? -1 : 1;
}
var s = String(t), o = String(e);
return s === o ? 0 : s < o ? -1 : 1;
}
function $t(t, e, i, n) {
var r = e + 1;
if (r === i) return 1;
if (n(t[r++], t[e]) < 0) {
for (;r < i && n(t[r], t[r - 1]) < 0; ) r++;
(function(t, e, i) {
i--;
for (;e < i; ) {
var n = t[e];
t[e++] = t[i];
t[i--] = n;
}
})(t, e, r);
} else for (;r < i && n(t[r], t[r - 1]) >= 0; ) r++;
return r - e;
}
function te(t, e, i, n, r) {
n === e && n++;
for (;n < i; n++) {
for (var s = t[n], o = e, a = n; o < a; ) {
var c = o + a >>> 1;
r(s, t[c]) < 0 ? a = c : o = c + 1;
}
var h = n - o;
switch (h) {
case 3:
t[o + 3] = t[o + 2];

case 2:
t[o + 2] = t[o + 1];

case 1:
t[o + 1] = t[o];
break;

default:
for (;h > 0; ) {
t[o + h] = t[o + h - 1];
h--;
}
}
t[o] = s;
}
}
function ee(t, e, i, n, r, s) {
var o = 0, a = 0, c = 1;
if (s(t, e[i + r]) > 0) {
a = n - r;
for (;c < a && s(t, e[i + r + c]) > 0; ) {
o = c;
(c = 1 + (c << 1)) <= 0 && (c = a);
}
c > a && (c = a);
o += r;
c += r;
} else {
a = r + 1;
for (;c < a && s(t, e[i + r - c]) <= 0; ) {
o = c;
(c = 1 + (c << 1)) <= 0 && (c = a);
}
c > a && (c = a);
var h = o;
o = r - c;
c = r - h;
}
o++;
for (;o < c; ) {
var l = o + (c - o >>> 1);
s(t, e[i + l]) > 0 ? o = l + 1 : c = l;
}
return c;
}
function ie(t, e, i, n, r, s) {
var o = 0, a = 0, c = 1;
if (s(t, e[i + r]) < 0) {
a = r + 1;
for (;c < a && s(t, e[i + r - c]) < 0; ) {
o = c;
(c = 1 + (c << 1)) <= 0 && (c = a);
}
c > a && (c = a);
var h = o;
o = r - c;
c = r - h;
} else {
a = n - r;
for (;c < a && s(t, e[i + r + c]) >= 0; ) {
o = c;
(c = 1 + (c << 1)) <= 0 && (c = a);
}
c > a && (c = a);
o += r;
c += r;
}
o++;
for (;o < c; ) {
var l = o + (c - o >>> 1);
s(t, e[i + l]) < 0 ? c = l : o = l + 1;
}
return c;
}
var ne = function(t, e) {
this.array = t;
this.compare = e;
this.minGallop = 7;
this.length = t.length;
this.tmpStorageLength = 256;
this.length < 512 && (this.tmpStorageLength = this.length >>> 1);
this.tmp = new Array(this.tmpStorageLength);
this.stackLength = this.length < 120 ? 5 : this.length < 1542 ? 10 : this.length < 119151 ? 19 : 40;
this.runStart = new Array(this.stackLength);
this.runLength = new Array(this.stackLength);
this.stackSize = 0;
};
ne.prototype.pushRun = function(t, e) {
this.runStart[this.stackSize] = t;
this.runLength[this.stackSize] = e;
this.stackSize += 1;
};
ne.prototype.mergeRuns = function() {
for (;this.stackSize > 1; ) {
var t = this.stackSize - 2;
if (t >= 1 && this.runLength[t - 1] <= this.runLength[t] + this.runLength[t + 1] || t >= 2 && this.runLength[t - 2] <= this.runLength[t] + this.runLength[t - 1]) this.runLength[t - 1] < this.runLength[t + 1] && t--; else if (this.runLength[t] > this.runLength[t + 1]) break;
this.mergeAt(t);
}
};
ne.prototype.forceMergeRuns = function() {
for (;this.stackSize > 1; ) {
var t = this.stackSize - 2;
t > 0 && this.runLength[t - 1] < this.runLength[t + 1] && t--;
this.mergeAt(t);
}
};
ne.prototype.mergeAt = function(t) {
var e = this.compare, i = this.array, n = this.runStart[t], r = this.runLength[t], s = this.runStart[t + 1], o = this.runLength[t + 1];
this.runLength[t] = r + o;
if (t === this.stackSize - 3) {
this.runStart[t + 1] = this.runStart[t + 2];
this.runLength[t + 1] = this.runLength[t + 2];
}
this.stackSize--;
var a = ie(i[s], i, n, r, 0, e);
n += a;
0 !== (r -= a) && 0 !== (o = ee(i[n + r - 1], i, s, o, o - 1, e)) && (r <= o ? this.mergeLow(n, r, s, o) : this.mergeHigh(n, r, s, o));
};
ne.prototype.mergeLow = function(t, e, i, n) {
var r = this.compare, s = this.array, o = this.tmp, a = 0;
for (a = 0; a < e; a++) o[a] = s[t + a];
var c = 0, h = i, l = t;
s[l++] = s[h++];
if (0 != --n) if (1 !== e) {
for (var u = this.minGallop; ;) {
var _ = 0, f = 0, d = !1;
do {
if (r(s[h], o[c]) < 0) {
s[l++] = s[h++];
f++;
_ = 0;
if (0 == --n) {
d = !0;
break;
}
} else {
s[l++] = o[c++];
_++;
f = 0;
if (1 == --e) {
d = !0;
break;
}
}
} while ((_ | f) < u);
if (d) break;
do {
if (0 !== (_ = ie(s[h], o, c, e, 0, r))) {
for (a = 0; a < _; a++) s[l + a] = o[c + a];
l += _;
c += _;
if ((e -= _) <= 1) {
d = !0;
break;
}
}
s[l++] = s[h++];
if (0 == --n) {
d = !0;
break;
}
if (0 !== (f = ee(o[c], s, h, n, 0, r))) {
for (a = 0; a < f; a++) s[l + a] = s[h + a];
l += f;
h += f;
if (0 === (n -= f)) {
d = !0;
break;
}
}
s[l++] = o[c++];
if (1 == --e) {
d = !0;
break;
}
u--;
} while (_ >= 7 || f >= 7);
if (d) break;
u < 0 && (u = 0);
u += 2;
}
this.minGallop = u;
u < 1 && (this.minGallop = 1);
if (1 === e) {
for (a = 0; a < n; a++) s[l + a] = s[h + a];
s[l + n] = o[c];
} else {
if (0 === e) throw new Error("mergeLow preconditions were not respected");
for (a = 0; a < e; a++) s[l + a] = o[c + a];
}
} else {
for (a = 0; a < n; a++) s[l + a] = s[h + a];
s[l + n] = o[c];
} else for (a = 0; a < e; a++) s[l + a] = o[c + a];
};
ne.prototype.mergeHigh = function(t, e, i, n) {
var r = this.compare, s = this.array, o = this.tmp, a = 0;
for (a = 0; a < n; a++) o[a] = s[i + a];
var c = t + e - 1, h = n - 1, l = i + n - 1, u = 0, _ = 0;
s[l--] = s[c--];
if (0 != --e) if (1 !== n) {
for (var f = this.minGallop; ;) {
var d = 0, m = 0, p = !1;
do {
if (r(o[h], s[c]) < 0) {
s[l--] = s[c--];
d++;
m = 0;
if (0 == --e) {
p = !0;
break;
}
} else {
s[l--] = o[h--];
m++;
d = 0;
if (1 == --n) {
p = !0;
break;
}
}
} while ((d | m) < f);
if (p) break;
do {
if (0 !== (d = e - ie(o[h], s, t, e, e - 1, r))) {
e -= d;
_ = (l -= d) + 1;
u = (c -= d) + 1;
for (a = d - 1; a >= 0; a--) s[_ + a] = s[u + a];
if (0 === e) {
p = !0;
break;
}
}
s[l--] = o[h--];
if (1 == --n) {
p = !0;
break;
}
if (0 !== (m = n - ee(s[c], o, 0, n, n - 1, r))) {
n -= m;
_ = (l -= m) + 1;
u = (h -= m) + 1;
for (a = 0; a < m; a++) s[_ + a] = o[u + a];
if (n <= 1) {
p = !0;
break;
}
}
s[l--] = s[c--];
if (0 == --e) {
p = !0;
break;
}
f--;
} while (d >= 7 || m >= 7);
if (p) break;
f < 0 && (f = 0);
f += 2;
}
this.minGallop = f;
f < 1 && (this.minGallop = 1);
if (1 === n) {
_ = (l -= e) + 1;
u = (c -= e) + 1;
for (a = e - 1; a >= 0; a--) s[_ + a] = s[u + a];
s[l] = o[h];
} else {
if (0 === n) throw new Error("mergeHigh preconditions were not respected");
u = l - (n - 1);
for (a = 0; a < n; a++) s[u + a] = o[a];
}
} else {
_ = (l -= e) + 1;
u = (c -= e) + 1;
for (a = e - 1; a >= 0; a--) s[_ + a] = s[u + a];
s[l] = o[h];
} else {
u = l - (n - 1);
for (a = 0; a < n; a++) s[u + a] = o[a];
}
};
function re(t, e, i, n) {
if (!Array.isArray(t)) throw new TypeError("Can only sort arrays");
void 0 === e && (e = 0);
void 0 === i && (i = t.length);
void 0 === n && (n = Qt);
var r = i - e;
if (!(r < 2)) {
var s = 0;
if (r < Jt) te(t, e, i, e + (s = $t(t, e, i, n)), n); else {
var o = new ne(t, n), a = (function(t) {
for (var e = 0; t >= Jt; ) {
e |= 1 & t;
t >>= 1;
}
return t + e;
})(r);
do {
if ((s = $t(t, e, i, n)) < a) {
var c = r;
c > a && (c = a);
te(t, e, e + c, e + s, n);
s = c;
}
o.pushRun(e, s);
o.mergeRuns();
r -= s;
e += s;
} while (0 !== r);
o.forceMergeRuns();
}
}
}
var se = function(t) {
this._count = 0;
this._data = new Array(t);
}, oe = {
length: {
configurable: !0
},
data: {
configurable: !0
}
};
se.prototype._resize = function(t) {
if (t > this._data.length) for (var e = this._data.length; e < t; ++e) this._data[e] = void 0;
};
oe.length.get = function() {
return this._count;
};
oe.data.get = function() {
return this._data;
};
se.prototype.reset = function() {
for (var t = 0; t < this._count; ++t) this._data[t] = void 0;
this._count = 0;
};
se.prototype.push = function(t) {
this._count >= this._data.length && this._resize(2 * this._data.length);
this._data[this._count] = t;
++this._count;
};
se.prototype.pop = function() {
--this._count;
this._count < 0 && (this._count = 0);
var t = this._data[this._count];
this._data[this._count] = void 0;
return t;
};
se.prototype.fastRemove = function(t) {
if (!(t >= this._count)) {
var e = this._count - 1;
this._data[t] = this._data[e];
this._data[e] = void 0;
this._count -= 1;
}
};
se.prototype.indexOf = function(t) {
var e = this._data.indexOf(t);
return e >= this._count ? -1 : e;
};
se.prototype.sort = function(t) {
return re(this._data, 0, this._count, t);
};
Object.defineProperties(se.prototype, oe);
var ae = function(t, e) {
this._fn = t;
this._idx = e - 1;
this._frees = new Array(e);
for (var i = 0; i < e; ++i) this._frees[i] = t();
};
ae.prototype._expand = function(t) {
var e = this._frees;
this._frees = new Array(t);
for (var i = t - e.length, n = 0; n < i; ++n) this._frees[n] = this._fn();
for (var r = i, s = 0; r < t; ++r, ++s) this._frees[r] = e[s];
this._idx += i;
};
ae.prototype.alloc = function() {
this._idx < 0 && this._expand(Math.round(1.2 * this._frees.length) + 1);
var t = this._frees[this._idx];
this._frees[this._idx] = null;
--this._idx;
return t;
};
ae.prototype.free = function(t) {
++this._idx;
this._frees[this._idx] = t;
};
var ce = function(t, e) {
this._fn = t;
this._count = 0;
this._head = null;
this._tail = null;
this._pool = new ae(t, e);
}, he = {
head: {
configurable: !0
},
tail: {
configurable: !0
},
length: {
configurable: !0
}
};
he.head.get = function() {
return this._head;
};
he.tail.get = function() {
return this._tail;
};
he.length.get = function() {
return this._count;
};
ce.prototype.add = function() {
var t = this._pool.alloc();
if (this._tail) {
this._tail._next = t;
t._prev = this._tail;
} else this._head = t;
this._tail = t;
this._count += 1;
return t;
};
ce.prototype.remove = function(t) {
t._prev ? t._prev._next = t._next : this._head = t._next;
t._next ? t._next._prev = t._prev : this._tail = t._prev;
t._next = null;
t._prev = null;
this._pool.free(t);
this._count -= 1;
};
ce.prototype.forEach = function(t, e) {
var i = this._head;
if (i) {
e && (t = t.bind(e));
for (var n = 0, r = i; i; ) {
r = i._next;
t(i, n, this);
i = r;
++n;
}
}
};
Object.defineProperties(ce.prototype, he);
var le = function(t, e) {
this._fn = t;
this._count = 0;
this._data = new Array(e);
for (var i = 0; i < e; ++i) this._data[i] = t();
}, ue = {
length: {
configurable: !0
},
data: {
configurable: !0
}
};
ue.length.get = function() {
return this._count;
};
ue.data.get = function() {
return this._data;
};
le.prototype.reset = function() {
this._count = 0;
};
le.prototype.resize = function(t) {
if (t > this._data.length) for (var e = this._data.length; e < t; ++e) this._data[e] = this._fn();
};
le.prototype.add = function() {
this._count >= this._data.length && this.resize(2 * this._data.length);
return this._data[this._count++];
};
le.prototype.remove = function(t) {
if (!(t >= this._count)) {
var e = this._count - 1, i = this._data[t];
this._data[t] = this._data[e];
this._data[e] = i;
this._count -= 1;
}
};
le.prototype.sort = function(t) {
return re(this._data, 0, this._count, t);
};
Object.defineProperties(le.prototype, ue);
for (var _e = Array(8), fe = 0; fe < 8; ++fe) _e[fe] = [];
var de = function() {
this._lights = new se(16);
this._models = new se(16);
this._cameras = new se(16);
this._debugCamera = null;
this._views = [];
};
de.prototype._add = function(t, e) {
if (-1 === e._poolID) {
t.push(e);
e._poolID = t.length - 1;
}
};
de.prototype._remove = function(t, e) {
if (-1 !== e._poolID) {
t.data[t.length - 1]._poolID = e._poolID;
t.fastRemove(e._poolID);
e._poolID = -1;
}
};
de.prototype.reset = function() {
for (var t = 0; t < this._models.length; ++t) {
this._models.data[t]._cullingMask = -1;
}
};
de.prototype.setDebugCamera = function(t) {
this._debugCamera = t;
};
de.prototype.getCameraCount = function() {
return this._cameras.length;
};
de.prototype.getCamera = function(t) {
return this._cameras.data[t];
};
de.prototype.addCamera = function(t) {
this._add(this._cameras, t);
};
de.prototype.removeCamera = function(t) {
this._remove(this._cameras, t);
};
de.prototype.getModelCount = function() {
return this._models.length;
};
de.prototype.getModel = function(t) {
return this._models.data[t];
};
de.prototype.addModel = function(t) {
this._add(this._models, t);
};
de.prototype.removeModel = function(t) {
this._remove(this._models, t);
};
de.prototype.getLightCount = function() {
return this._lights.length;
};
de.prototype.getLight = function(t) {
return this._lights.data[t];
};
de.prototype.addLight = function(t) {
this._add(this._lights, t);
};
de.prototype.removeLight = function(t) {
this._remove(this._lights, t);
};
de.prototype.addView = function(t) {
-1 === this._views.indexOf(t) && this._views.push(t);
};
de.prototype.removeView = function(t) {
var e = this._views.indexOf(t);
-1 !== e && this._views.splice(e, 1);
};
var me = 0;
function pe(t, e) {
var i = {}, n = t;
for (var r in e) Number.isInteger(e[r]) && (i[r] = e[r]);
for (var s in i) {
var o = new RegExp(s, "g");
n = n.replace(o, i[s]);
}
return n;
}
function ve(t) {
return t.replace(/#pragma for (\w+) in range\(\s*(\d+)\s*,\s*(\d+)\s*\)([\s\S]+?)#pragma endFor/g, (function(t, e, i, n, r) {
var s = "", o = parseInt(i), a = parseInt(n);
(o.isNaN || a.isNaN) && console.error("Unroll For Loops Error: begin and end of range must be an int num.");
for (var c = o; c < a; ++c) s += r.replace(new RegExp("{" + e + "}", "g"), c);
return s;
}));
}
var ye = function(t, e, i) {
void 0 === e && (e = []);
void 0 === i && (i = {});
this._device = t;
this._precision = "precision highp float;\n";
this._templates = {};
for (var n = 0; n < e.length; ++n) {
var r = e[n];
this.define(r.name, r.vert, r.frag, r.defines);
}
this._chunks = {};
Object.assign(this._chunks, i);
this._cache = {};
};
ye.prototype.define = function(t, e, i, n) {
if (this._templates[t]) console.warn("Failed to define shader " + t + ": already exists."); else {
for (var r = ++me, s = 0, o = function(t) {
var e = n[t];
e._offset = s;
var i = 1;
if (void 0 !== e.min && void 0 !== e.max) {
i = Math.ceil(.5 * (e.max - e.min));
e._map = function(t) {
return t - this._min << e._offset;
}.bind(e);
} else e._map = function(t) {
return t ? 1 << e._offset : 0;
}.bind(e);
s += i;
e._offset = s;
}, a = 0; a < n.length; ++a) o(a);
e = this._precision + e;
i = this._precision + i;
this._templates[t] = {
id: r,
name: t,
vert: e,
frag: i,
defines: n
};
}
};
ye.prototype.getKey = function(t, e) {
for (var i = this._templates[t], n = 0, r = 0; r < i.defines.length; ++r) {
var s = i.defines[r], o = e[s.name];
void 0 !== o && (n |= s._map(o));
}
return n << 8 | i.id;
};
ye.prototype.getProgram = function(t, e) {
var i = this.getKey(t, e), n = this._cache[i];
if (n) return n;
var r = this._templates[t], s = (function(t) {
var e = [];
for (var i in t) !0 === t[i] && e.push("#define " + i);
return e.join("\n");
})(e) + "\n", o = pe(r.vert, e);
o = s + ve(o);
var a = pe(r.frag, e);
a = s + ve(a);
(n = new Ct.Program(this._device, {
vert: o,
frag: a
})).link();
this._cache[i] = n;
return n;
};
var ge = T.create(), xe = O.create(), Ce = new le(function() {
return {
stage: null,
items: null
};
}, 8), Ae = new le(function() {
return new Float32Array(2);
}, 8), be = new le(function() {
return new Float32Array(3);
}, 8), Se = new le(function() {
return new Float32Array(4);
}, 8), Te = new le(function() {
return new Float32Array(9);
}, 8), we = new le(function() {
return new Float32Array(16);
}, 8), Ee = new le(function() {
return new Float32Array(64);
}, 8), Be = new le(function() {
return new Int32Array(2);
}, 8), Me = new le(function() {
return new Int32Array(3);
}, 8), De = new le(function() {
return new Int32Array(4);
}, 8), Ie = new le(function() {
return new Int32Array(64);
}, 8), Pe = {};
Pe[q.PARAM_INT] = function(t) {
return t;
};
Pe[q.PARAM_INT2] = function(t) {
return p.array(Be.add(), t);
};
Pe[q.PARAM_INT3] = function(t) {
return g.array(Me.add(), t);
};
Pe[q.PARAM_INT4] = function(t) {
return A.array(De.add(), t);
};
Pe[q.PARAM_FLOAT] = function(t) {
return t;
};
Pe[q.PARAM_FLOAT2] = function(t) {
return p.array(Ae.add(), t);
};
Pe[q.PARAM_FLOAT3] = function(t) {
return g.array(be.add(), t);
};
Pe[q.PARAM_FLOAT4] = function(t) {
return A.array(Se.add(), t);
};
Pe[q.PARAM_COLOR3] = function(t) {
return G.array(be.add(), t);
};
Pe[q.PARAM_COLOR4] = function(t) {
return j.array(Se.add(), t);
};
Pe[q.PARAM_MAT2] = function(t) {
return I.array(Se.add(), t);
};
Pe[q.PARAM_MAT3] = function(t) {
return T.array(Te.add(), t);
};
Pe[q.PARAM_MAT4] = function(t) {
return O.array(we.add(), t);
};
var Re = {};
Re[q.PARAM_INT] = {
func: function(t) {
for (var e = Ie.add(), i = 0; i < t.length; ++i) e[i] = t[i];
return e;
},
size: 1
};
Re[q.PARAM_INT2] = {
func: function(t) {
for (var e = Ie.add(), i = 0; i < t.length; ++i) {
e[2 * i] = t[i].x;
e[2 * i + 1] = t[i].y;
}
return e;
},
size: 2
};
Re[q.PARAM_INT3] = {
func: void 0,
size: 3
};
Re[q.PARAM_INT4] = {
func: function(t) {
for (var e = Ie.add(), i = 0; i < t.length; ++i) {
var n = t[i];
e[4 * i] = n.x;
e[4 * i + 1] = n.y;
e[4 * i + 2] = n.z;
e[4 * i + 3] = n.w;
}
return e;
},
size: 4
};
Re[q.PARAM_FLOAT] = {
func: function(t) {
for (var e = Ee.add(), i = 0; i < t.length; ++i) e[i] = t[i];
return e;
},
size: 1
};
Re[q.PARAM_FLOAT2] = {
func: function(t) {
for (var e = Ee.add(), i = 0; i < t.length; ++i) {
e[2 * i] = t[i].x;
e[2 * i + 1] = t[i].y;
}
return e;
},
size: 2
};
Re[q.PARAM_FLOAT3] = {
func: void 0,
size: 3
};
Re[q.PARAM_FLOAT4] = {
func: function(t) {
for (var e = Ee.add(), i = 0; i < t.length; ++i) {
var n = t[i];
e[4 * i] = n.x;
e[4 * i + 1] = n.y;
e[4 * i + 2] = n.z;
e[4 * i + 3] = n.w;
}
return e;
},
size: 4
};
Re[q.PARAM_COLOR3] = {
func: void 0,
size: 3
};
Re[q.PARAM_COLOR4] = {
func: function(t) {
for (var e = Ee.add(), i = 0; i < t.length; ++i) {
var n = t[i];
e[4 * i] = n.r;
e[4 * i + 1] = n.g;
e[4 * i + 2] = n.b;
e[4 * i + 3] = n.a;
}
return e;
},
size: 4
};
Re[q.PARAM_MAT2] = {
func: function(t) {
for (var e = Ee.add(), i = 0; i < t.length; ++i) {
var n = t[i];
e[4 * i] = n.m00;
e[4 * i + 1] = n.m01;
e[4 * i + 2] = n.m02;
e[4 * i + 3] = n.m03;
}
return e;
},
size: 4
};
Re[q.PARAM_MAT3] = {
func: void 0,
size: 9
};
Re[q.PARAM_MAT4] = {
func: function(t) {
for (var e = Ee.add(), i = 0; i < t.length; ++i) {
var n = t[i];
e[16 * i] = n.m00;
e[16 * i + 1] = n.m01;
e[16 * i + 2] = n.m02;
e[16 * i + 3] = n.m03;
e[16 * i + 4] = n.m04;
e[16 * i + 5] = n.m05;
e[16 * i + 6] = n.m06;
e[16 * i + 7] = n.m07;
e[16 * i + 8] = n.m08;
e[16 * i + 9] = n.m09;
e[16 * i + 10] = n.m10;
e[16 * i + 11] = n.m11;
e[16 * i + 12] = n.m12;
e[16 * i + 13] = n.m13;
e[16 * i + 14] = n.m14;
e[16 * i + 15] = n.m15;
}
return e;
},
size: 16
};
var Le = function(t, e) {
var i;
this._device = t;
this._programLib = new ye(t, e.programTemplates, e.programChunks);
this._opts = e;
this._type2defaultValue = ((i = {})[q.PARAM_INT] = 0, i[q.PARAM_INT2] = p.new(0, 0), 
i[q.PARAM_INT3] = g.new(0, 0, 0), i[q.PARAM_INT4] = A.new(0, 0, 0, 0), i[q.PARAM_FLOAT] = 0, 
i[q.PARAM_FLOAT2] = p.new(0, 0), i[q.PARAM_FLOAT3] = g.new(0, 0, 0), i[q.PARAM_FLOAT4] = A.new(0, 0, 0, 0), 
i[q.PARAM_COLOR3] = G.new(0, 0, 0), i[q.PARAM_COLOR4] = j.new(0, 0, 0, 1), i[q.PARAM_MAT2] = I.create(), 
i[q.PARAM_MAT3] = T.create(), i[q.PARAM_MAT4] = O.create(), i[q.PARAM_TEXTURE_2D] = e.defaultTexture, 
i[q.PARAM_TEXTURE_CUBE] = e.defaultTextureCube, i);
this._stage2fn = {};
this._usedTextureUnits = 0;
this._viewPools = new le(function() {
return new Rt();
}, 8);
this._drawItemsPools = new le(function() {
return {
model: null,
node: null,
ia: null,
effect: null,
defines: null
};
}, 100);
this._stageItemsPools = new le(function() {
return new le(function() {
return {
model: null,
node: null,
ia: null,
effect: null,
defines: null,
technique: null,
sortKey: -1
};
}, 100);
}, 16);
};
Le.prototype._resetTextuerUnit = function() {
this._usedTextureUnits = 0;
};
Le.prototype._allocTextuerUnit = function() {
var t = this._device, e = this._usedTextureUnits;
e >= t._caps.maxTextureUnits && console.warn("Trying to use " + e + " texture units while this GPU supports only " + t._caps.maxTextureUnits);
this._usedTextureUnits += 1;
return e;
};
Le.prototype._registerStage = function(t, e) {
this._stage2fn[t] = e;
};
Le.prototype._reset = function() {
this._viewPools.reset();
this._stageItemsPools.reset();
};
Le.prototype._requestView = function() {
return this._viewPools.add();
};
Le.prototype._render = function(t, e) {
var i = this._device;
i.setFrameBuffer(t._framebuffer);
i.setViewport(t._rect.x, t._rect.y, t._rect.w, t._rect.h);
var n = {};
t._clearFlags & q.CLEAR_COLOR && (n.color = [ t._color.r, t._color.g, t._color.b, t._color.a ]);
t._clearFlags & q.CLEAR_DEPTH && (n.depth = t._depth);
t._clearFlags & q.CLEAR_STENCIL && (n.stencil = t._stencil);
i.clear(n);
this._drawItemsPools.reset();
for (var r = 0; r < e._models.length; ++r) {
var s = e._models.data[r];
if (0 != (s._cullingMask & t._cullingMask)) for (var o = 0; o < s.drawItemCount; ++o) {
var a = this._drawItemsPools.add();
s.extractDrawItem(a, o);
}
}
Ce.reset();
for (var c = 0; c < t._stages.length; ++c) {
var h = t._stages[c], l = this._stageItemsPools.add();
l.reset();
for (var u = 0; u < this._drawItemsPools.length; ++u) {
var _ = this._drawItemsPools.data[u], f = _.effect.getTechnique(h);
if (f) {
var d = l.add();
d.model = _.model;
d.node = _.node;
d.ia = _.ia;
d.effect = _.effect;
d.defines = _.defines;
d.technique = f;
d.sortKey = -1;
}
}
var m = Ce.add();
m.stage = h;
m.items = l;
}
for (var p = 0; p < Ce.length; ++p) {
var v = Ce.data[p];
(0, this._stage2fn[v.stage])(t, v.items);
}
};
Le.prototype._draw = function(t) {
var e = this._device, i = this._programLib, n = t.node, r = t.ia, s = t.effect, o = t.technique, a = t.defines;
Ae.reset();
be.reset();
Se.reset();
Te.reset();
we.reset();
Ee.reset();
Be.reset();
Me.reset();
De.reset();
Ie.reset();
n.getWorldMatrix(xe);
e.setUniform("model", O.array(we.add(), xe));
var c = T.invert(ge, T.fromMat4(ge, xe));
if (c) {
T.transpose(ge, c);
e.setUniform("normalMatrix", T.array(Te.add(), ge));
}
for (var h = 0; h < o._parameters.length; ++h) {
var l = o._parameters[h], u = s.getProperty(l.name);
void 0 === u && (u = l.val);
void 0 === u && (u = this._type2defaultValue[l.type]);
if (void 0 !== u) if (l.type === q.PARAM_TEXTURE_2D || l.type === q.PARAM_TEXTURE_CUBE) if (void 0 !== l.size) {
if (l.size !== u.length) {
console.error("The length of texture array (" + u.length + ") is not corrent(expect " + l.size + ").");
continue;
}
for (var _ = Ie.add(), f = 0; f < u.length; ++f) _[f] = this._allocTextuerUnit();
e.setTextureArray(l.name, u, _);
} else e.setTexture(l.name, u, this._allocTextuerUnit()); else {
var d = void 0;
if (void 0 !== l.size) {
var m = Re[l.type];
if (void 0 === m.func) {
console.error("Uniform array of color3/int3/float3/mat3 can not be supportted!");
continue;
}
if (l.size * m.size > 64) {
console.error("Uniform array is too long!");
continue;
}
d = m.func(u);
} else {
d = (0, Pe[l.type])(u);
}
e.setUniform(l.name, d);
} else console.warn("Failed to set technique property " + l.name + ", value not found.");
}
for (var p = 0; p < o._passes.length; ++p) {
var v = o._passes[p], y = r.getPrimitiveCount();
e.setVertexBuffer(0, r._vertexBuffer);
r._indexBuffer && e.setIndexBuffer(r._indexBuffer);
e.setPrimitiveType(r._primitiveType);
var g = i.getProgram(v._programName, a);
e.setProgram(g);
e.setCullMode(v._cullMode);
if (v._blend) {
e.enableBlend();
e.setBlendFuncSep(v._blendSrc, v._blendDst, v._blendSrcAlpha, v._blendDstAlpha);
e.setBlendEqSep(v._blendEq, v._blendAlphaEq);
e.setBlendColor32(v._blendColor);
}
if (v._depthTest) {
e.enableDepthTest();
e.setDepthFunc(v._depthFunc);
}
v._depthWrite && e.enableDepthWrite();
if (v._stencilTest) {
e.enableStencilTest();
e.setStencilFuncFront(v._stencilFuncFront, v._stencilRefFront, v._stencilMaskFront);
e.setStencilOpFront(v._stencilFailOpFront, v._stencilZFailOpFront, v._stencilZPassOpFront, v._stencilWriteMaskFront);
e.setStencilFuncBack(v._stencilFuncBack, v._stencilRefBack, v._stencilMaskBack);
e.setStencilOpBack(v._stencilFailOpBack, v._stencilZFailOpBack, v._stencilZPassOpBack, v._stencilWriteMaskBack);
}
e.draw(r._start, y);
this._resetTextuerUnit();
}
};
var Fe = {
addStage: wt.addStage,
createIA: function(t, e) {
if (!e.positions) {
console.error("The data must have positions field");
return null;
}
for (var i = [], n = e.positions.length / 3, r = 0; r < n; ++r) {
i.push(e.positions[3 * r], e.positions[3 * r + 1], e.positions[3 * r + 2]);
e.normals && i.push(e.normals[3 * r], e.normals[3 * r + 1], e.normals[3 * r + 2]);
e.uvs && i.push(e.uvs[2 * r], e.uvs[2 * r + 1]);
}
var s = [];
s.push({
name: Ct.ATTR_POSITION,
type: Ct.ATTR_TYPE_FLOAT32,
num: 3
});
e.normals && s.push({
name: Ct.ATTR_NORMAL,
type: Ct.ATTR_TYPE_FLOAT32,
num: 3
});
e.uvs && s.push({
name: Ct.ATTR_UV0,
type: Ct.ATTR_TYPE_FLOAT32,
num: 2
});
var o = new Ct.VertexBuffer(t, new Ct.VertexFormat(s), Ct.USAGE_STATIC, new Float32Array(i), n), a = null;
e.indices && (a = new Ct.IndexBuffer(t, Ct.INDEX_FMT_UINT16, Ct.USAGE_STATIC, new Uint16Array(e.indices), e.indices.length));
return new At(o, a);
},
Pass: bt,
Technique: Bt,
Effect: Dt,
InputAssembler: At,
View: Rt,
Light: Nt,
Camera: Wt,
Model: Xt,
Scene: de,
Base: Le,
ProgramLib: ye
};
Object.assign(Fe, q);
var Ve, Oe = new Float32Array(16), Ne = new Float32Array(16), ke = new Float32Array(16), Ge = (function(t) {
function e(e, i) {
t.call(this, e, i);
this._registerStage("transparent", this._transparentStage.bind(this));
}
t && (e.__proto__ = t);
e.prototype = Object.create(t && t.prototype);
e.prototype.constructor = e;
e.prototype.reset = function() {
this._reset();
};
e.prototype.render = function(t) {
this._reset();
t._cameras.sort((function(t, e) {
return t._depth > e._depth ? 1 : t._depth < e._depth ? -1 : 0;
}));
for (var e = 0; e < t._cameras.length; ++e) {
var i = t._cameras.data[e];
i._poolID = e;
this.renderCamera(i, t);
}
};
e.prototype.renderCamera = function(t, e) {
var i = this._device._gl.canvas, n = t.view, r = t.dirty;
if (!n) {
n = this._requestView();
r = !0;
}
if (r) {
var s = i.width, o = i.height;
if (t._framebuffer) {
s = t._framebuffer._width;
o = t._framebuffer._height;
}
t.extractView(n, s, o);
}
this._render(n, e);
};
e.prototype._transparentStage = function(t, e) {
this._device.setUniform("view", O.array(Oe, t._matView));
this._device.setUniform("proj", O.array(Ne, t._matProj));
this._device.setUniform("viewProj", O.array(ke, t._matViewProj));
for (var i = 0; i < e.length; ++i) {
var n = e.data[i];
this._draw(n);
}
};
return e;
})(Fe.Base), ze = {
chunks: {},
templates: [ {
name: "gray_sprite",
vert: "\n \nuniform mat4 viewProj;\nattribute vec3 a_position;\nattribute mediump vec2 a_uv0;\nvarying mediump vec2 uv0;\n#ifndef useColor\nattribute lowp vec4 a_color;\nvarying lowp vec4 v_fragmentColor;\n#endif\nvoid main () {\n  vec4 pos = viewProj * vec4(a_position, 1);\n  gl_Position = pos;\n  uv0 = a_uv0;\n #ifndef useColor\n  v_fragmentColor = a_color;\n #endif\n}",
frag: "\n \nuniform sampler2D texture;\nvarying mediump vec2 uv0;\n#ifdef useColor\n  uniform lowp vec4 color;\n#else\n  varying lowp vec4 v_fragmentColor;\n#endif\nvoid main () {\n  #ifdef useColor\n    vec4 o = color;\n  #else\n    vec4 o = v_fragmentColor;\n  #endif\n  vec4 c = o * texture2D(texture, uv0);\n  float gray = 0.2126*c.r + 0.7152*c.g + 0.0722*c.b;\n  gl_FragColor = vec4(gray, gray, gray, c.a);\n}",
defines: [ {
name: "useColor"
} ]
}, {
name: "sprite",
vert: "\n \nuniform mat4 viewProj;\n#ifdef use2DPos\nattribute vec2 a_position;\n#else\nattribute vec3 a_position;\n#endif\nattribute lowp vec4 a_color;\n#ifdef useModel\n  uniform mat4 model;\n#endif\n#ifdef useTexture\n  attribute mediump vec2 a_uv0;\n  varying mediump vec2 uv0;\n#endif\n#ifndef useColor\nvarying lowp vec4 v_fragmentColor;\n#endif\nvoid main () {\n  mat4 mvp;\n  #ifdef useModel\n    mvp = viewProj * model;\n  #else\n    mvp = viewProj;\n  #endif\n  #ifdef use2DPos\n  vec4 pos = mvp * vec4(a_position, 0, 1);\n  #else\n  vec4 pos = mvp * vec4(a_position, 1);\n  #endif\n  #ifndef useColor\n  v_fragmentColor = a_color;\n  #endif\n  #ifdef useTexture\n    uv0 = a_uv0;\n  #endif\n  gl_Position = pos;\n}",
frag: "\n \n#ifdef useTexture\n  uniform sampler2D texture;\n  varying mediump vec2 uv0;\n#endif\n#ifdef alphaTest\n  uniform lowp float alphaThreshold;\n#endif\n#ifdef useColor\n  uniform lowp vec4 color;\n#else\n  varying lowp vec4 v_fragmentColor;\n#endif\nvoid main () {\n  #ifdef useColor\n    vec4 o = color;\n  #else\n    vec4 o = v_fragmentColor;\n  #endif\n  #ifdef useTexture\n    o *= texture2D(texture, uv0);\n  #endif\n  #ifdef alphaTest\n    if (o.a <= alphaThreshold)\n      discard;\n  #endif\n  gl_FragColor = o;\n}",
defines: [ {
name: "useTexture"
}, {
name: "useModel"
}, {
name: "alphaTest"
}, {
name: "use2DPos"
}, {
name: "useColor"
} ]
}, {
name: "spine",
vert: "\n \nuniform mat4 viewProj;\n\n#ifdef use2DPos\n  attribute vec2 a_position;\n#else\n  attribute vec3 a_position;\n#endif\n\nattribute lowp vec4 a_color;\n#ifdef useTint\n  attribute lowp vec4 a_color0;\n#endif\n\n#ifdef useModel\n  uniform mat4 model;\n#endif\n\nattribute mediump vec2 a_uv0;\nvarying mediump vec2 uv0;\n\nvarying lowp vec4 v_light;\n#ifdef useTint\n  varying lowp vec4 v_dark;\n#endif\n\nvoid main () {\n  mat4 mvp;\n  #ifdef useModel\n    mvp = viewProj * model;\n  #else\n    mvp = viewProj;\n  #endif\n\n  #ifdef use2DPos\n  vec4 pos = mvp * vec4(a_position, 0, 1);\n  #else\n  vec4 pos = mvp * vec4(a_position, 1);\n  #endif\n\n  v_light = a_color;\n  #ifdef useTint\n    v_dark = a_color0;\n  #endif\n\n  uv0 = a_uv0;\n\n  gl_Position = pos;\n}",
frag: "\n \nuniform sampler2D texture;\nvarying mediump vec2 uv0;\n\n#ifdef alphaTest\n  uniform lowp float alphaThreshold;\n#endif\n\nvarying lowp vec4 v_light;\n#ifdef useTint\n  varying lowp vec4 v_dark;\n#endif\n\nvoid main () {\n  vec4 texColor = texture2D(texture, uv0);\n  vec4 finalColor;\n\n  #ifdef useTint\n    finalColor.a = v_light.a * texColor.a;\n    finalColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n  #else\n    finalColor = texColor * v_light;\n  #endif\n\n  #ifdef alphaTest\n    if (finalColor.a <= alphaThreshold)\n      discard;\n  #endif\n\n  gl_FragColor = finalColor;\n}",
defines: [ {
name: "useModel"
}, {
name: "alphaTest"
}, {
name: "use2DPos"
}, {
name: "useTint"
} ]
} ]
}, Ue = function() {
this.material = null;
this.vertexCount = 0;
this.indiceCount = 0;
}, je = new ae(function() {
return {
x: 0,
y: 0,
u: 0,
v: 0,
color: 0
};
}, 128), He = (function(t) {
function e() {
t.call(this);
this._data = [];
this._indices = [];
this._pivotX = 0;
this._pivotY = 0;
this._width = 0;
this._height = 0;
this.uvDirty = !0;
this.vertDirty = !0;
}
t && (e.__proto__ = t);
e.prototype = Object.create(t && t.prototype);
e.prototype.constructor = e;
var i = {
type: {
configurable: !0
},
dataLength: {
configurable: !0
}
};
i.type.get = function() {
return e.type;
};
i.dataLength.get = function() {
return this._data.length;
};
i.dataLength.set = function(t) {
var e = this._data;
if (e.length !== t) {
for (var i = t; i < e.length; i++) je.free(e[i]);
for (var n = e.length; n < t; n++) e[n] = je.alloc();
e.length = t;
}
};
e.prototype.updateSizeNPivot = function(t, e, i, n) {
if (t !== this._width || e !== this._height || i !== this._pivotX || n !== this._pivotY) {
this._width = t;
this._height = e;
this._pivotX = i;
this._pivotY = n;
this.vertDirty = !0;
}
};
e.alloc = function() {
return Ve.alloc();
};
e.free = function(t) {
if (t instanceof e) {
for (var i = t.length - 1; i > 0; i--) je.free(t._data[i]);
t._data.length = 0;
t._indices.length = 0;
t.material = null;
t.uvDirty = !0;
t.vertDirty = !0;
t.vertexCount = 0;
t.indiceCount = 0;
Ve.free(t);
}
};
Object.defineProperties(e.prototype, i);
return e;
})(Ue);
He.type = "RenderData";
Ve = new ae(function() {
return new He();
}, 32);
var We = (function(t) {
function e() {
t.call(this);
this.ia = null;
}
t && (e.__proto__ = t);
e.prototype = Object.create(t && t.prototype);
e.prototype.constructor = e;
var i = {
type: {
configurable: !0
}
};
i.type.get = function() {
return e.type;
};
Object.defineProperties(e.prototype, i);
return e;
})(Ue);
We.type = "IARenderData";
var qe = function(t) {
void 0 === t && (t = !0);
this._loaded = !1;
this._persist = t;
};
qe.prototype.unload = function() {
this._loaded = !1;
};
qe.prototype.reload = function() {};
var Xe = (function(t) {
function e(e) {
void 0 === e && (e = !0);
t.call(this, e);
this._texture = null;
}
t && (e.__proto__ = t);
e.prototype = Object.create(t && t.prototype);
e.prototype.constructor = e;
e.prototype.getImpl = function() {
return this._texture;
};
e.prototype.getId = function() {};
e.prototype.destroy = function() {
this._texture && this._texture.destroy();
};
return e;
})(qe);
function Ye(t) {
var e = t._programName + t._cullMode;
t._blend && (e += t._blendEq + t._blendAlphaEq + t._blendSrc + t._blendDst + t._blendSrcAlpha + t._blendDstAlpha + t._blendColor);
t._depthTest && (e += t._depthWrite + t._depthFunc);
t._stencilTest && (e += t._stencilFuncFront + t._stencilRefFront + t._stencilMaskFront + t._stencilFailOpFront + t._stencilZFailOpFront + t._stencilZPassOpFront + t._stencilWriteMaskFront + t._stencilFuncBack + t._stencilRefBack + t._stencilMaskBack + t._stencilFailOpBack + t._stencilZFailOpBack + t._stencilZPassOpBack + t._stencilWriteMaskBack);
return e;
}
var Je = (function(t) {
function e(e) {
void 0 === e && (e = !1);
t.call(this, e);
this._effect = null;
this._texIds = {};
this._hash = "";
}
t && (e.__proto__ = t);
e.prototype = Object.create(t && t.prototype);
e.prototype.constructor = e;
var i = {
hash: {
configurable: !0
}
};
i.hash.get = function() {
return this._hash;
};
e.prototype.updateHash = function(t) {
this._hash = t || (function(t) {
var e = t._effect, i = "";
if (e) {
var n, r, s, o, a, c;
i += (function(t) {
for (var e = "", i = 0; i < t.length; i++) e += t[i].name + t[i].value;
return e;
})(e._defines);
for (n = 0; n < e._techniques.length; n++) {
i += (s = e._techniques[n]).stageIDs;
for (r = 0; r < s.passes.length; r++) i += Ye(s.passes[r]);
for (r = 0; r < s._parameters.length; r++) {
c = (o = s._parameters[r]).name;
if (a = e._properties[c]) switch (o.type) {
case Fe.PARAM_INT:
case Fe.PARAM_FLOAT:
i += a + ";";
break;

case Fe.PARAM_INT2:
case Fe.PARAM_FLOAT2:
i += a.x + "," + a.y + ";";
break;

case Fe.PARAM_INT4:
case Fe.PARAM_FLOAT4:
i += a.x + "," + a.y + "," + a.z + "," + a.w + ";";
break;

case Fe.PARAM_COLOR4:
i += a.r + "," + a.g + "," + a.b + "," + a.a + ";";
break;

case Fe.PARAM_MAT2:
i += a.m00 + "," + a.m01 + "," + a.m02 + "," + a.m03 + ";";
break;

case Fe.PARAM_TEXTURE_2D:
case Fe.PARAM_TEXTURE_CUBE:
i += t._texIds[c] + ";";
break;

case Fe.PARAM_INT3:
case Fe.PARAM_FLOAT3:
case Fe.PARAM_COLOR3:
case Fe.PARAM_MAT3:
case Fe.PARAM_MAT4:
i += JSON.stringify(a) + ";";
}
}
}
}
return i ? (function(t, e) {
for (var i, n = t.length, r = e ^ n, s = 0; n >= 4; ) {
i = 1540483477 * (65535 & (i = 255 & t.charCodeAt(s) | (255 & t.charCodeAt(++s)) << 8 | (255 & t.charCodeAt(++s)) << 16 | (255 & t.charCodeAt(++s)) << 24)) + ((1540483477 * (i >>> 16) & 65535) << 16);
r = 1540483477 * (65535 & r) + ((1540483477 * (r >>> 16) & 65535) << 16) ^ (i = 1540483477 * (65535 & (i ^= i >>> 24)) + ((1540483477 * (i >>> 16) & 65535) << 16));
n -= 4;
++s;
}
switch (n) {
case 3:
r ^= (255 & t.charCodeAt(s + 2)) << 16;

case 2:
r ^= (255 & t.charCodeAt(s + 1)) << 8;

case 1:
r = 1540483477 * (65535 & (r ^= 255 & t.charCodeAt(s))) + ((1540483477 * (r >>> 16) & 65535) << 16);
}
r = 1540483477 * (65535 & (r ^= r >>> 13)) + ((1540483477 * (r >>> 16) & 65535) << 16);
return (r ^= r >>> 15) >>> 0;
})(i, 666) : i;
})(this);
};
Object.defineProperties(e.prototype, i);
return e;
})(qe), Ze = (function(t) {
function e() {
t.call(this, !1);
var e = new Fe.Pass("sprite");
e.setDepth(!1, !1);
e.setCullMode(Ct.CULL_NONE);
e.setBlend(Ct.BLEND_FUNC_ADD, Ct.BLEND_SRC_ALPHA, Ct.BLEND_ONE_MINUS_SRC_ALPHA, Ct.BLEND_FUNC_ADD, Ct.BLEND_SRC_ALPHA, Ct.BLEND_ONE_MINUS_SRC_ALPHA);
var i = new Fe.Technique([ "transparent" ], [ {
name: "texture",
type: Fe.PARAM_TEXTURE_2D
}, {
name: "color",
type: Fe.PARAM_COLOR4
} ], [ e ]);
this._color = {
r: 1,
g: 1,
b: 1,
a: 1
};
this._effect = new Fe.Effect([ i ], {
color: this._color
}, [ {
name: "useTexture",
value: !0
}, {
name: "useModel",
value: !1
}, {
name: "alphaTest",
value: !1
}, {
name: "use2DPos",
value: !0
}, {
name: "useColor",
value: !0
} ]);
this._mainTech = i;
this._texture = null;
}
t && (e.__proto__ = t);
e.prototype = Object.create(t && t.prototype);
e.prototype.constructor = e;
var i = {
effect: {
configurable: !0
},
useTexture: {
configurable: !0
},
useModel: {
configurable: !0
},
use2DPos: {
configurable: !0
},
useColor: {
configurable: !0
},
texture: {
configurable: !0
},
color: {
configurable: !0
}
};
i.effect.get = function() {
return this._effect;
};
i.useTexture.get = function() {
return this._effect.getDefine("useTexture");
};
i.useTexture.set = function(t) {
this._effect.define("useTexture", t);
};
i.useModel.get = function() {
return this._effect.getDefine("useModel");
};
i.useModel.set = function(t) {
this._effect.define("useModel", t);
};
i.use2DPos.get = function() {
return this._effect.getDefine("use2DPos");
};
i.use2DPos.set = function(t) {
this._effect.define("use2DPos", t);
};
i.useColor.get = function() {
return this._effect.getDefine("useColor");
};
i.useColor.set = function(t) {
this._effect.define("useColor", t);
};
i.texture.get = function() {
return this._texture;
};
i.texture.set = function(t) {
if (this._texture !== t) {
this._texture = t;
this._effect.setProperty("texture", t.getImpl());
this._texIds.texture = t.getId();
}
};
i.color.get = function() {
return this._color;
};
i.color.set = function(t) {
var e = this._color;
e.r = t.r / 255;
e.g = t.g / 255;
e.b = t.b / 255;
e.a = t.a / 255;
this._effect.setProperty("color", e);
};
e.prototype.clone = function() {
var t = new e();
t._mainTech.copy(this._mainTech);
t.texture = this.texture;
t.useTexture = this.useTexture;
t.useModel = this.useModel;
t.use2DPos = this.use2DPos;
t.useColor = this.useColor;
t.updateHash();
return t;
};
Object.defineProperties(e.prototype, i);
return e;
})(Je), Ke = (function(t) {
function e() {
t.call(this, !1);
var e = new Fe.Pass("spine");
e.setDepth(!1, !1);
e.setCullMode(Ct.CULL_NONE);
e.setBlend(Ct.BLEND_FUNC_ADD, Ct.BLEND_SRC_ALPHA, Ct.BLEND_ONE_MINUS_SRC_ALPHA, Ct.BLEND_FUNC_ADD, Ct.BLEND_SRC_ALPHA, Ct.BLEND_ONE_MINUS_SRC_ALPHA);
var i = new Fe.Technique([ "transparent" ], [ {
name: "texture",
type: Fe.PARAM_TEXTURE_2D
} ], [ e ]);
this._effect = new Fe.Effect([ i ], {}, [ {
name: "useModel",
value: !0
}, {
name: "alphaTest",
value: !1
}, {
name: "use2DPos",
value: !0
}, {
name: "useTint",
value: !1
} ]);
this._mainTech = i;
this._texture = null;
}
t && (e.__proto__ = t);
e.prototype = Object.create(t && t.prototype);
e.prototype.constructor = e;
var i = {
effect: {
configurable: !0
},
useModel: {
configurable: !0
},
use2DPos: {
configurable: !0
},
useTint: {
configurable: !1
},
texture: {
configurable: !0
}
};
i.effect.get = function() {
return this._effect;
};
i.useModel.get = function() {
return this._effect.getDefine("useModel");
};
i.useModel.set = function(t) {
this._effect.define("useModel", t);
};
i.use2DPos.get = function() {
return this._effect.getDefine("use2DPos");
};
i.use2DPos.set = function(t) {
this._effect.define("use2DPos", t);
};
i.useTint.get = function() {
return this._effect.getDefine("useTint");
};
i.useTint.set = function(t) {
this._effect.define("useTint", t);
};
i.texture.get = function() {
return this._texture;
};
i.texture.set = function(t) {
if (this._texture !== t) {
this._texture = t;
this._effect.setProperty("texture", t.getImpl());
this._texIds.texture = t.getId();
}
};
e.prototype.clone = function() {
var t = new e();
t._mainTech.copy(this._mainTech);
t.texture = this.texture;
t.useModel = this.useModel;
t.use2DPos = this.use2DPos;
t.useTint = this.useTint;
t._hash = this._hash;
return t;
};
Object.defineProperties(e.prototype, i);
return e;
})(Je), Qe = (function(t) {
function e() {
t.call(this, !1);
var e = new Fe.Pass("gray_sprite");
e.setDepth(!1, !1);
e.setCullMode(Ct.CULL_NONE);
e.setBlend(Ct.BLEND_FUNC_ADD, Ct.BLEND_SRC_ALPHA, Ct.BLEND_ONE_MINUS_SRC_ALPHA, Ct.BLEND_FUNC_ADD, Ct.BLEND_SRC_ALPHA, Ct.BLEND_ONE_MINUS_SRC_ALPHA);
var i = new Fe.Technique([ "transparent" ], [ {
name: "texture",
type: Fe.PARAM_TEXTURE_2D
}, {
name: "color",
type: Fe.PARAM_COLOR4
} ], [ e ]);
this._color = {
r: 1,
g: 1,
b: 1,
a: 1
};
this._effect = new Fe.Effect([ i ], {
color: this._color
}, [ {
name: "useColor",
value: !1
} ]);
this._mainTech = i;
this._texture = null;
}
t && (e.__proto__ = t);
e.prototype = Object.create(t && t.prototype);
e.prototype.constructor = e;
var i = {
effect: {
configurable: !0
},
texture: {
configurable: !0
},
color: {
configurable: !0
}
};
i.effect.get = function() {
return this._effect;
};
i.texture.get = function() {
return this._texture;
};
i.texture.set = function(t) {
if (this._texture !== t) {
this._texture = t;
this._effect.setProperty("texture", t.getImpl());
this._texIds.texture = t.getId();
}
};
i.color.get = function() {
return this._color;
};
i.color.set = function(t) {
var e = this._color;
e.r = t.r / 255;
e.g = t.g / 255;
e.b = t.b / 255;
e.a = t.a / 255;
this._effect.setProperty("color", e);
};
e.prototype.clone = function() {
var t = new e();
t._mainTech.copy(this._mainTech);
t.texture = this.texture;
t.color = this.color;
t.updateHash();
return t;
};
Object.defineProperties(e.prototype, i);
return e;
})(Je), $e = (function(t) {
function e() {
t.call(this, !1);
this._pass = new Fe.Pass("sprite");
this._pass.setDepth(!1, !1);
this._pass.setCullMode(Ct.CULL_NONE);
this._pass.setBlend(Ct.BLEND_FUNC_ADD, Ct.BLEND_SRC_ALPHA, Ct.BLEND_ONE_MINUS_SRC_ALPHA, Ct.BLEND_FUNC_ADD, Ct.BLEND_SRC_ALPHA, Ct.BLEND_ONE_MINUS_SRC_ALPHA);
var e = new Fe.Technique([ "transparent" ], [ {
name: "texture",
type: Fe.PARAM_TEXTURE_2D
}, {
name: "alphaThreshold",
type: Fe.PARAM_FLOAT
}, {
name: "color",
type: Fe.PARAM_COLOR4
} ], [ this._pass ]);
this._effect = new Fe.Effect([ e ], {
color: {
r: 1,
g: 1,
b: 1,
a: 1
}
}, [ {
name: "useTexture",
value: !0
}, {
name: "useModel",
value: !1
}, {
name: "alphaTest",
value: !0
}, {
name: "use2DPos",
value: !0
}, {
name: "useColor",
value: !0
} ]);
this._mainTech = e;
this._texture = null;
}
t && (e.__proto__ = t);
e.prototype = Object.create(t && t.prototype);
e.prototype.constructor = e;
var i = {
effect: {
configurable: !0
},
useTexture: {
configurable: !0
},
useModel: {
configurable: !0
},
useColor: {
configurable: !0
},
texture: {
configurable: !0
},
alphaThreshold: {
configurable: !0
}
};
i.effect.get = function() {
return this._effect;
};
i.useTexture.get = function() {
this._effect.getDefine("useTexture");
};
i.useTexture.set = function(t) {
this._effect.define("useTexture", t);
};
i.useModel.get = function() {
this._effect.getDefine("useModel");
};
i.useModel.set = function(t) {
this._effect.define("useModel", t);
};
i.useColor.get = function() {
this._effect.getDefine("useColor");
};
i.useColor.set = function(t) {
this._effect.define("useColor", t);
};
i.texture.get = function() {
return this._texture;
};
i.texture.set = function(t) {
if (this._texture !== t) {
this._texture = t;
this._effect.setProperty("texture", t.getImpl());
this._texIds.texture = t.getId();
}
};
i.alphaThreshold.get = function() {
return this._effect.getProperty("alphaThreshold");
};
i.alphaThreshold.set = function(t) {
this._effect.setProperty("alphaThreshold", t);
};
e.prototype.clone = function() {
var t = new e();
t._mainTech.copy(this._mainTech);
t.useTexture = this.useTexture;
t.useModel = this.useModel;
t.useColor = this.useColor;
t.texture = this.texture;
t.alphaThreshold = this.alphaThreshold;
t.updateHash();
return t;
};
Object.defineProperties(e.prototype, i);
return e;
})(Je), ti = function(t) {
var e;
try {
e = t.getContext("2d");
} catch (t) {
console.error(t);
return;
}
this._canvas = t;
this._ctx = e;
this._caps = {};
this._stats = {
drawcalls: 0
};
this._vx = this._vy = this._vw = this._vh = 0;
this._sx = this._sy = this._sw = this._sh = 0;
};
ti.prototype._restoreTexture = function(t) {};
ti.prototype.setViewport = function(t, e, i, n) {
if (this._vx !== t || this._vy !== e || this._vw !== i || this._vh !== n) {
this._vx = t;
this._vy = e;
this._vw = i;
this._vh = n;
}
};
ti.prototype.setScissor = function(t, e, i, n) {
if (this._sx !== t || this._sy !== e || this._sw !== i || this._sh !== n) {
this._sx = t;
this._sy = e;
this._sw = i;
this._sh = n;
}
};
ti.prototype.clear = function(t) {
var e = this._ctx;
e.clearRect(this._vx, this._vy, this._vw, this._vh);
if (t && (0 !== t[0] || 0 !== t[1] || 0 !== t[2])) {
e.fillStyle = "rgb(" + t[0] + "," + t[1] + "," + t[2] + ")";
e.globalAlpha = t[3];
e.fillRect(this._vx, this._vy, this._vw, this._vh);
}
};
var ei = function(t, e) {
this._device = t;
this._width = 4;
this._height = 4;
this._image = null;
if (e) {
void 0 !== e.width && (this._width = e.width);
void 0 !== e.height && (this._height = e.height);
this.updateImage(e);
}
};
ei.prototype.update = function(t) {
this.updateImage(t);
};
ei.prototype.updateImage = function(t) {
if (t.images && t.images[0]) {
var e = t.images[0];
e && e !== this._image && (this._image = e);
}
};
ei.prototype.destroy = function() {
this._image = null;
};
var ii = {
Device: ti,
Texture2D: ei
}, ni = Fe.Scene, ri = Fe.Camera, si = Fe.View, oi = Ct.Texture2D, ai = Ct.Device, ci = Fe.Model, hi = Fe.InputAssembler;
Fe.addStage("transparent");
var li = {
Device: ai,
ForwardRenderer: Ge,
Texture2D: oi,
canvas: ii,
Scene: ni,
Camera: ri,
View: si,
Model: ci,
RenderData: He,
IARenderData: We,
InputAssembler: hi,
Asset: qe,
TextureAsset: Xe,
Material: Je,
SpineMaterial: Ke,
SpriteMaterial: Ze,
GraySpriteMaterial: Qe,
StencilMaterial: $e,
shaders: ze,
RecyclePool: le,
Pool: ae,
math: W,
renderer: Fe,
gfx: Ct
};
e.exports = li;
}), {} ],
203: [ (function(t, e, i) {
var n = 0, r = 1, s = 2, o = r | s, a = 4, c = 8, h = 16, l = 32, u = 64, _ = 128, f = 256, d = 512, m = 1024, p = void 0;
function v() {
this._func = A;
this._next = null;
}
var y = v.prototype;
y._doNothing = function() {};
y._localTransform = function(t) {
t._updateLocalMatrix();
t._renderFlag &= ~r;
this._next._func(t);
};
y._worldTransform = function(t) {
p.worldMatDirty++;
var e = t._matrix, i = t._position;
e.m12 = i.x;
e.m13 = i.y;
(function(t, e, i) {
var n = e.m00, r = e.m01, s = e.m04, o = e.m05, a = e.m12, c = e.m13, h = i.m00, l = i.m01, u = i.m04, _ = i.m05, f = i.m12, d = i.m13;
if (0 !== l || 0 !== u) {
t.m00 = n * h + r * u;
t.m01 = n * l + r * _;
t.m04 = s * h + o * u;
t.m05 = s * l + o * _;
t.m12 = h * a + u * c + f;
t.m13 = l * a + _ * c + d;
} else {
t.m00 = n * h;
t.m01 = r * _;
t.m04 = s * h;
t.m05 = o * _;
t.m12 = h * a + f;
t.m13 = _ * c + d;
}
})(t._worldMatrix, e, t._parent._worldMatrix);
t._renderFlag &= ~s;
this._next._func(t);
p.worldMatDirty--;
};
y._color = function(t) {
var e = t._renderComponent;
e ? e._updateColor() : t._renderFlag &= ~h;
this._next._func(t);
};
y._opacity = function(t) {
p.parentOpacityDirty++;
t._renderFlag &= ~c;
this._next._func(t);
p.parentOpacityDirty--;
};
y._updateRenderData = function(t) {
var e = t._renderComponent;
e._assembler.updateRenderData(e);
t._renderFlag &= ~a;
this._next._func(t);
};
y._render = function(t) {
var e = t._renderComponent;
p._commitComp(e, e._assembler, t._cullingMask);
this._next._func(t);
};
y._customIARender = function(t) {
var e = t._renderComponent;
p._commitIA(e, e._assembler, t._cullingMask);
this._next._func(t);
};
y._children = function(t) {
for (var e = p, i = e.parentOpacity, n = e.parentOpacity *= t._opacity / 255, r = (e.worldMatDirty ? s : 0) | (e.parentOpacityDirty ? h : 0), o = t._children, a = 0, c = o.length; a < c; a++) {
var l = o[a];
l._renderFlag |= r;
if (l._activeInHierarchy && 0 !== l._opacity) {
var u = l._color._val;
l._color._fastSetA(l._opacity * n);
x[l._renderFlag]._func(l);
l._color._val = u;
}
}
e.parentOpacity = i;
this._next._func(t);
};
y._postUpdateRenderData = function(t) {
var e = t._renderComponent;
e._postAssembler && e._postAssembler.updateRenderData(e);
t._renderFlag &= ~f;
this._next._func(t);
};
y._postRender = function(t) {
var e = t._renderComponent;
p._commitComp(e, e._postAssembler, t._cullingMask);
this._next._func(t);
};
var g = new v();
g._func = g._doNothing;
g._next = g;
var x = {};
function C(t, e) {
var i = new v();
i._next = e || g;
switch (t) {
case n:
i._func = i._doNothing;
break;

case r:
i._func = i._localTransform;
break;

case s:
i._func = i._worldTransform;
break;

case h:
i._func = i._color;
break;

case c:
i._func = i._opacity;
break;

case a:
i._func = i._updateRenderData;
break;

case l:
i._func = i._render;
break;

case u:
i._func = i._customIARender;
break;

case _:
i._func = i._children;
break;

case f:
i._func = i._postUpdateRenderData;
break;

case d:
i._func = i._postRender;
}
return i;
}
function A(t) {
var e = t._renderFlag;
(x[e] = (function(t) {
for (var e = null, i = m; i > 0; ) {
i & t && (e = C(i, e));
i >>= 1;
}
return e;
})(e))._func(t);
}
v.flows = x;
v.createFlow = C;
v.visit = function(t) {
p.reset();
p.walking = !0;
1 << t.groupIndex;
if (t._renderFlag & s) {
p.worldMatDirty++;
t._calculWorldMatrix();
t._renderFlag &= ~s;
x[t._renderFlag]._func(t);
p.worldMatDirty--;
} else x[t._renderFlag]._func(t);
p.terminate();
};
v.init = function(t) {
p = t;
x[0] = g;
for (var e = 1; e < m; e++) x[e] = new v();
};
v.FLAG_DONOTHING = n;
v.FLAG_LOCAL_TRANSFORM = r;
v.FLAG_WORLD_TRANSFORM = s;
v.FLAG_TRANSFORM = o;
v.FLAG_COLOR = h;
v.FLAG_OPACITY = c;
v.FLAG_UPDATE_RENDER_DATA = a;
v.FLAG_RENDER = l;
v.FLAG_CUSTOM_IA_RENDER = u;
v.FLAG_CHILDREN = _;
v.FLAG_POST_UPDATE_RENDER_DATA = f;
v.FLAG_POST_RENDER = d;
v.FLAG_FINAL = m;
e.exports = cc.RenderFlow = v;
}), {} ],
204: [ (function(t, e, i) {
var n = t("../../../assets/CCRenderTexture"), r = 2;
function s(t, e) {
var i = new n();
i.initWithSize(t, e);
i.update();
this._texture = i;
this._x = r;
this._y = r;
this._nexty = r;
this._width = t;
this._height = e;
this._innerTextureInfos = {};
this._innerSpriteFrames = [];
}
s.DEFAULT_HASH = new n()._getHash();
cc.js.mixin(s.prototype, {
insertSpriteFrame: function(t) {
var e = t._rect, i = t._texture, n = this._innerTextureInfos[i._id], s = e.x, o = e.y;
if (n) {
s += n.x;
o += n.y;
} else {
var a = i.width, c = i.height;
if (this._x + a + r > this._width) {
this._x = r;
this._y = this._nexty;
}
this._y + c > this._nexty && (this._nexty = this._y + c + r);
if (this._nexty > this._height) return null;
this._texture.drawTextureAt(i, this._x - 1, this._y);
this._texture.drawTextureAt(i, this._x + 1, this._y);
this._texture.drawTextureAt(i, this._x, this._y - 1);
this._texture.drawTextureAt(i, this._x, this._y + 1);
this._texture.drawTextureAt(i, this._x, this._y);
this._innerTextureInfos[i._id] = {
x: this._x,
y: this._y,
texture: i
};
s += this._x;
o += this._y;
this._x += a + r;
this._dirty = !0;
}
var h = {
x: s,
y: o,
texture: this._texture
};
this._innerSpriteFrames.push(t);
return h;
},
update: function() {
if (this._dirty) {
this._texture.update();
this._dirty = !1;
}
},
reset: function() {
this._x = r;
this._y = r;
this._nexty = r;
for (var t = this._innerSpriteFrames, e = 0, i = t.length; e < i; e++) {
var n = t[e];
n.isValid && n._resetDynamicAtlasFrame();
}
this._innerSpriteFrames.length = 0;
this._innerTextureInfos = {};
},
destroy: function() {
this.reset();
this._texture.destroy();
}
});
e.exports = s;
}), {
"../../../assets/CCRenderTexture": 42
} ],
205: [ (function(t, e, i) {
var n = t("./atlas"), r = [], s = -1, o = 5, a = 2048, c = 512;
function h() {
var t = r[++s];
if (!t) {
t = new n(a, a);
r.push(t);
}
return t;
}
function l() {
_.reset();
}
var u = !1, _ = {
get enabled() {
return u;
},
set enabled(t) {
if (u !== t) {
if (t) {
this.reset();
cc.director.on(cc.Director.EVENT_BEFORE_SCENE_LAUNCH, l);
} else cc.director.off(cc.Director.EVENT_BEFORE_SCENE_LAUNCH, l);
u = t;
}
},
get maxAtlasCount() {
return o;
},
set maxAtlasCount(t) {
o = t;
},
get textureSize() {
return a;
},
set textureSize(t) {
a = t;
},
get maxFrameSize() {
return c;
},
set maxFrameSize(t) {
c = t;
},
insertSpriteFrame: function(t) {
0;
if (!u || s === o || !t || t._original) return null;
var e = t._texture;
if (e instanceof cc.RenderTexture) return null;
var i = e.width, a = e.height;
if (i > c || a > c || i <= 8 || a <= 8 || e._getHash() !== n.DEFAULT_HASH) return null;
var l = r[s];
l || (l = h());
var _ = l.insertSpriteFrame(t);
return _ || s === o ? _ : (l = h()).insertSpriteFrame(t);
},
reset: function() {
for (var t = 0, e = r.length; t < e; t++) r[t].destroy();
r.length = 0;
s = -1;
},
showDebug: !1,
update: function() {
if (this.enabled) for (var t = 0; t <= s; t++) r[t].update();
}
};
e.exports = cc.dynamicAtlasManager = _;
}), {
"./atlas": 204
} ],
206: [ (function(t, e, i) {
var n = t("../../../platform/CCMacro"), r = t("../../../components/CCLabel").Overflow, s = t("../../../utils/text-utils"), o = function() {
this._u = 0;
this._v = 0;
this._width = 0;
this._height = 0;
this._offsetX = 0;
this._offsetY = 0;
this._textureID = 0;
this._validDefinition = !1;
this._xAdvance = 0;
};
cc.FontAtlas = function(t) {
this._letterDefinitions = {};
};
cc.FontAtlas.prototype = {
constructor: cc.FontAtlas,
addLetterDefinitions: function(t, e) {
this._letterDefinitions[t] = e;
},
cloneLetterDefinition: function() {
var t = {};
for (var e in this._letterDefinitions) {
var i = new o();
cc.js.mixin(i, this._letterDefinitions[e]);
t[e] = i;
}
return t;
},
assignLetterDefinitions: function(t) {
for (var e in this._letterDefinitions) {
var i = t[e], n = this._letterDefinitions[e];
cc.js.mixin(n, i);
}
},
scaleFontLetterDefinition: function(t) {
for (var e in this._letterDefinitions) {
var i = this._letterDefinitions[e];
i._width *= t;
i._height *= t;
i._offsetX *= t;
i._offsetY *= t;
i._xAdvance *= t;
}
},
getLetterDefinitionForChar: function(t) {
return this._letterDefinitions.hasOwnProperty(t.charCodeAt(0)) ? this._letterDefinitions[t.charCodeAt(0)] : null;
}
};
var a = function() {
this._char = "";
this._valid = !0;
this._positionX = 0;
this._positionY = 0;
this._lineIndex = 0;
}, c = cc.rect(), h = null, l = [], u = [], _ = [], f = [], d = cc.size(), m = null, p = null, v = 0, y = 0, g = 0, x = 0, C = 0, A = 1, b = null, S = "", T = 0, w = 0, E = cc.size(), B = 0, M = 0, D = 0, I = 0, P = 0, R = !1, L = 0, F = 0, V = 0;
e.exports = {
updateRenderData: function(t) {
if (t._renderData.vertDirty && h !== t) {
h = t;
this._updateProperties();
this._updateContent();
h._actualFontSize = T;
h.node.setContentSize(E);
h._renderData.vertDirty = h._renderData.uvDirty = !1;
h = null;
this._resetProperties();
}
},
_updateFontScale: function() {
A = T / w;
},
_updateProperties: function() {
var t = h.font;
b = t.spriteFrame;
p = t._fntConfig;
if (!(m = h._fontAtlas)) {
m = new cc.FontAtlas(p);
var e = p.fontDefDictionary;
for (var i in e) {
var n = new o(), s = e[i].rect;
n._offsetX = e[i].xOffset;
n._offsetY = e[i].yOffset;
n._width = s.width;
n._height = s.height;
n._u = s.x;
n._v = s.y;
n._textureID = 0;
n._validDefinition = !0;
n._xAdvance = e[i].xAdvance;
m.addLetterDefinitions(i, n);
}
h._fontAtlas = m;
}
S = h.string.toString();
T = h.fontSize;
w = p.fontSize;
E.width = h.node._contentSize.width;
E.height = h.node._contentSize.height;
B = h.horizontalAlign;
M = h.verticalAlign;
D = h.spacingX;
P = h.overflow;
I = h._lineHeight;
R = P !== r.NONE && (P === r.RESIZE_HEIGHT || h.enableWrapText);
this._setupBMFontOverflowMetrics();
},
_resetProperties: function() {
m = null;
p = null;
b = null;
},
_updateContent: function() {
this._updateFontScale();
this._computeHorizontalKerningForText();
this._alignText();
},
_computeHorizontalKerningForText: function() {
for (var t = S, e = t.length, i = p.kerningDict, n = l, r = -1, s = 0; s < e; ++s) {
var o = t.charCodeAt(s), a = i[r << 16 | 65535 & o] || 0;
n[s] = s < e - 1 ? a : 0;
r = o;
}
},
_multilineTextWrap: function(t) {
var e = S.length, i = 0, n = 0, r = 0, o = 0, a = 0, c = 0, h = 0, u = null, f = cc.v2(0, 0);
this._updateFontScale();
for (var d = m._letterDefinitions, g = 0; g < e; ) {
var b = S.charAt(g);
if ("\n" !== b) {
for (var T = t(S, g, e), w = c, B = h, M = a, P = n, O = !1, N = 0; N < T; ++N) {
var k = g + N;
if ("\r" !== (b = S.charAt(k))) if (u = m.getLetterDefinitionForChar(b)) {
var G = P + u._offsetX * A;
if (R && V > 0 && n > 0 && G + u._width * A > V && !s.isUnicodeSpace(b)) {
_.push(a);
a = 0;
i++;
n = 0;
r -= I * A + 0;
O = !0;
break;
}
f.x = G;
f.y = r - u._offsetY * A;
this._recordLetterInfo(d, f, b, k, i);
k + 1 < l.length && k < e - 1 && (P += l[k + 1]);
P += u._xAdvance * A + D;
M = f.x + u._width * A;
w < f.y && (w = f.y);
B > f.y - u._height * A && (B = f.y - u._height * A);
} else {
this._recordPlaceholderInfo(k, b);
console.log("Can't find letter definition in texture atlas " + p.atlasName + " for letter:" + b);
} else this._recordPlaceholderInfo(k, b);
}
if (!O) {
n = P;
a = M;
c < w && (c = w);
h > B && (h = B);
o < a && (o = a);
g += T;
}
} else {
_.push(a);
a = 0;
i++;
n = 0;
r -= I * A + 0;
this._recordPlaceholderInfo(g, b);
g++;
}
}
_.push(a);
y = (v = i + 1) * I * A;
v > 1 && (y += 0 * (v - 1));
E.width = L;
E.height = F;
L <= 0 && (E.width = parseFloat(o.toFixed(2)));
F <= 0 && (E.height = parseFloat(y.toFixed(2)));
x = E.height;
C = 0;
c > 0 && (x = E.height + c);
h < -y && (C = y + h);
return !0;
},
_getFirstCharLen: function() {
return 1;
},
_getFirstWordLen: function(t, e, i) {
var n = t.charAt(e);
if (s.isUnicodeCJK(n) || "\n" === n || s.isUnicodeSpace(n)) return 1;
var r = 1, o = m.getLetterDefinitionForChar(n);
if (!o) return r;
for (var a = o._xAdvance * A + D, c = e + 1; c < i; ++c) {
n = t.charAt(c);
if (!(o = m.getLetterDefinitionForChar(n))) break;
if (a + o._offsetX * A + o._width * A > V && !s.isUnicodeSpace(n) && V > 0) return r;
a += o._xAdvance * A + D;
if ("\n" === n || s.isUnicodeSpace(n) || s.isUnicodeCJK(n)) break;
r++;
}
return r;
},
_multilineTextWrapByWord: function() {
return this._multilineTextWrap(this._getFirstWordLen);
},
_multilineTextWrapByChar: function() {
return this._multilineTextWrap(this._getFirstCharLen);
},
_recordPlaceholderInfo: function(t, e) {
if (t >= u.length) {
var i = new a();
u.push(i);
}
u[t]._char = e;
u[t]._valid = !1;
},
_recordLetterInfo: function(t, e, i, n, r) {
if (n >= u.length) {
var s = new a();
u.push(s);
}
i = i.charCodeAt(0);
u[n]._lineIndex = r;
u[n]._char = i;
u[n]._valid = t[i]._validDefinition;
u[n]._positionX = e.x;
u[n]._positionY = e.y;
},
_alignText: function() {
y = 0;
_.length = 0;
this._multilineTextWrapByWord();
this._computeAlignmentOffset();
P === r.SHRINK && T > 0 && this._isVerticalClamp() && this._shrinkLabelToContentSize(this._isVerticalClamp);
this._updateQuads() || P === r.SHRINK && this._shrinkLabelToContentSize(this._isHorizontalClamp);
},
_scaleFontSizeDown: function(t) {
var e = !0;
if (!t) {
t = .1;
e = !1;
}
T = t;
e && this._updateContent();
},
_shrinkLabelToContentSize: function(t) {
for (var e = T, i = I, n = m, r = 0, s = n.cloneLetterDefinition(), o = !0; t(); ) {
var a = e - ++r;
o = !1;
if (a <= 0) break;
var c = a / e;
n.assignLetterDefinitions(s);
n.scaleFontLetterDefinition(c);
I = i * c;
this._multilineTextWrapByWord();
this._computeAlignmentOffset();
}
I = i;
n.assignLetterDefinitions(s);
o || e - r >= 0 && this._scaleFontSizeDown(e - r);
},
_isVerticalClamp: function() {
return y > E.height;
},
_isHorizontalClamp: function() {
for (var t = m._letterDefinitions, e = !1, i = 0, n = S.length; i < n; ++i) {
var r = u[i];
if (r._valid) {
var s = t[r._char], o = r._positionX + s._width / 2 * A, a = r._lineIndex;
if (L > 0) if (R) {
if (_[a] > E.width && (o > E.width || o < 0)) {
e = !0;
break;
}
} else if (o > E.width) {
e = !0;
break;
}
}
}
return e;
},
_isHorizontalClamped: function(t, e) {
var i = _[e], n = t > E.width || t < 0;
return R ? i > E.width && n : n;
},
_updateQuads: function() {
var t = m._letterDefinitions, e = b._texture, i = h.node, n = h._renderData;
n.dataLength = n.vertexCount = n.indiceCount = 0;
for (var s = E, o = i._anchorPoint.x * s.width, a = i._anchorPoint.y * s.height, l = !0, _ = 0, d = S.length; _ < d; ++_) {
var p = u[_];
if (p._valid) {
var v = t[p._char];
c.height = v._height;
c.width = v._width;
c.x = v._u;
c.y = v._v;
var y = p._positionY + g;
if (F > 0) {
if (y > x) {
var T = y - x;
c.y += T;
c.height -= T;
y -= T;
}
y - v._height * A < C && (c.height = y < C ? 0 : y - C);
}
var w = p._lineIndex, B = p._positionX + v._width / 2 * A + f[w];
if (L > 0 && this._isHorizontalClamped(B, w)) if (P === r.CLAMP) c.width = 0; else if (P === r.SHRINK) {
if (E.width > v._width) {
l = !1;
break;
}
c.width = 0;
}
if (c.height > 0 && c.width > 0) {
var M = b.isRotated(), D = b._originalSize, I = b._rect, R = b._offset, V = R.x + (D.width - I.width) / 2, O = R.y - (D.height - I.height) / 2;
if (M) {
var N = c.x;
c.x = I.x + I.height - c.y - c.height - O;
c.y = N + I.y - V;
c.y < 0 && (c.height = c.height + O);
} else {
c.x += I.x - V;
c.y += I.y + O;
}
var k = p._positionX + f[p._lineIndex];
this.appendQuad(n, e, c, M, k - o, y - a, A);
}
}
}
return l;
},
appendQuad: function(t, e, i, n, r, s, o) {},
_computeAlignmentOffset: function() {
f.length = 0;
switch (B) {
case n.TextAlignment.LEFT:
for (var t = 0; t < v; ++t) f.push(0);
break;

case n.TextAlignment.CENTER:
for (var e = 0, i = _.length; e < i; e++) f.push((E.width - _[e]) / 2);
break;

case n.TextAlignment.RIGHT:
for (var r = 0, s = _.length; r < s; r++) f.push(E.width - _[r]);
}
switch (M) {
case n.VerticalTextAlignment.TOP:
g = E.height;
break;

case n.VerticalTextAlignment.CENTER:
g = (E.height + y) / 2;
break;

case n.VerticalTextAlignment.BOTTOM:
g = y;
}
},
_setupBMFontOverflowMetrics: function() {
var t = E.width, e = E.height;
P === r.RESIZE_HEIGHT && (e = 0);
if (P === r.NONE) {
t = 0;
e = 0;
}
L = t;
F = e;
d.width = t;
d.height = e;
V = t;
}
};
}), {
"../../../components/CCLabel": 69,
"../../../platform/CCMacro": 165,
"../../../utils/text-utils": 249
} ],
207: [ (function(t, e, i) {
function n() {
this._rect = null;
this.uv = [];
this._texture = null;
this._original = null;
}
n.prototype = {
constructor: n,
getRect: function() {
return cc.rect(this._rect);
},
setRect: function(t) {
this._rect = t;
this._texture && this._calculateUV();
},
_setDynamicAtlasFrame: function(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: function() {
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();
}
},
_refreshTexture: function(t) {
this._texture = t;
this._rect = cc.rect(0, 0, t.width, t.height);
this._calculateUV();
},
_calculateUV: function() {
var t = this._rect, e = this._texture, i = this.uv, n = e.width, r = e.height, s = 0 === n ? 0 : t.x / n, o = 0 === n ? 0 : (t.x + t.width) / n, a = 0 === r ? 0 : (t.y + t.height) / r, c = 0 === r ? 0 : t.y / r;
i[0] = s;
i[1] = a;
i[2] = o;
i[3] = a;
i[4] = s;
i[5] = c;
i[6] = o;
i[7] = c;
}
};
e.exports = n;
}), {} ],
208: [ (function(t, e, i) {
var n = t("../../../platform/CCMacro"), r = t("../../../components/CCLabel"), s = t("../../../components/CCLabelOutline"), o = t("../../../utils/text-utils"), a = t("../../../components/CCComponent"), c = t("../../../assets/CCRenderTexture"), h = cc.js.isChildClassOf(s, a), l = r.Overflow, u = cc.Color.WHITE, _ = 2, f = function() {
this.char = "";
this.valid = !0;
this.x = 0;
this.y = 0;
this.line = 0;
this.hash = "";
}, d = function() {
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;
};
function m(t, e) {
this._texture = null;
this._labelInfo = e;
this._char = t;
this._hash = null;
this._data = null;
this._canvas = null;
this._context = null;
this._width = 0;
this._height = 0;
this._hash = t.charCodeAt(0) + e.hash;
}
m.prototype = {
constructor: m,
updateRenderData: function() {
this._updateProperties();
this._updateTexture();
},
_updateProperties: function() {
this._texture = new cc.Texture2D();
this._data = r._canvasPool.get();
this._canvas = this._data.canvas;
this._context = this._data.context;
this._context.font = this._labelInfo.fontDesc;
var t = o.safeMeasureText(this._context, this._char);
this._width = parseFloat(t.toFixed(2)) + 2 * this._labelInfo.margin;
this._height = this._labelInfo.lineHeight;
this._canvas.width !== this._width && (this._canvas.width = this._width);
this._canvas.height !== this._height && (this._canvas.height = this._height);
this._texture.initWithElement(this._canvas);
},
_updateTexture: function() {
var t = this._context, e = this._labelInfo, i = this._canvas.width, n = this._canvas.height;
t.textAlign = "center";
t.textBaseline = "middle";
t.clearRect(0, 0, i, n);
t.fillStyle = "rgba(255, 255, 255, 0.005)";
t.fillRect(0, 0, i, n);
t.font = e.fontDesc;
var r = i / 2, s = n / 2, o = e.color;
t.lineJoin = "round";
t.fillStyle = "rgba(" + o.r + ", " + o.g + ", " + o.b + ", 1)";
if (e.isOutlined) {
var a = e.out || u;
t.strokeStyle = "rgba(" + a.r + ", " + a.g + ", " + a.b + ", " + a.a / 255 + ")";
t.lineWidth = 2 * e.margin;
t.strokeText(this._char, r, s);
}
t.fillText(this._char, r, s);
this._texture.handleLoadedTexture();
},
destroy: function() {
this._texture.destroy();
this._texture = null;
r._canvasPool.put(this._data);
}
};
function p(t, e) {
var i = new c();
i.initWithSize(t, e);
i.update();
this._texture = i;
this._x = _;
this._y = _;
this._nexty = _;
this._width = t;
this._height = e;
this._letterDefinitions = {};
cc.director.on(cc.Director.EVENT_BEFORE_SCENE_LAUNCH, this.beforeSceneLoad, this);
}
cc.js.mixin(p.prototype, {
insertLetterTexture: function(t) {
var e = t._texture, i = e.width, n = e.height;
if (this._x + i + _ > this._width) {
this._x = _;
this._y = this._nexty;
}
this._y + n > this._nexty && (this._nexty = this._y + n + _);
if (this._nexty > this._height) return null;
this._texture.drawTextureAt(e, this._x, this._y);
this._dirty = !0;
var r = new d();
r.u = this._x;
r.v = this._y;
r.texture = this._texture;
r.valid = !0;
r.w = t._width;
r.h = t._height;
r.xAdvance = t._width;
this._x += i + _;
this._letterDefinitions[t._hash] = r;
return r;
},
update: function() {
if (this._dirty) {
this._texture.update();
this._dirty = !1;
}
},
reset: function() {
this._x = _;
this._y = _;
this._nexty = _;
for (var t = this._letterDefinitions, e = 0, i = t.length; e < i; e++) {
var n = t[e];
n.isValid && n.destroy();
}
this._letterDefinitions = {};
},
destroy: function() {
this.reset();
this._texture.destroy();
},
beforeSceneLoad: function() {
this.destroy();
var t = new c();
t.initWithSize(this._width, this._height);
t.update();
this._texture = t;
},
getLetter: function(t) {
return this._letterDefinitions[t];
},
addLetterDefinitions: function(t, e) {
this._letterDefinitions[t] = e;
},
cloneLetterDefinition: function() {
var t = {};
for (var e in this._letterDefinitions) {
var i = new d();
cc.js.mixin(i, this._letterDefinitions[e]);
t[e] = i;
}
return t;
},
assignLetterDefinitions: function(t) {
for (var e in this._letterDefinitions) {
var i = t[e], n = this._letterDefinitions[e];
cc.js.mixin(n, i);
}
},
scaleFontLetterDefinition: function(t) {
for (var e in this._letterDefinitions) {
var i = this._letterDefinitions[e];
i.w *= t;
i.h *= t;
i.offsetX *= t;
i.offsetY *= t;
i.xAdvance *= t;
}
},
getLetterDefinitionForChar: function(t, e) {
var i = t.charCodeAt(0) + e.hash, n = this._letterDefinitions[i];
if (!n) {
var r = new m(t, e);
r.updateRenderData();
n = this.insertLetterTexture(r);
r.destroy();
}
return n;
}
});
var v = cc.rect(), y = null, g = [], x = [], C = [], A = [], b = cc.size(), S = null, T = 0, w = 0, E = 0, B = 0, M = 0, D = 1, I = "", P = 0, R = 0, L = cc.size(), F = 0, V = 0, O = 0, N = 0, k = 0, G = !1, z = 0, U = 0, j = 0, H = "", W = !1, q = {
fontSize: 0,
lineHeight: 0,
hash: "",
fontFamily: "",
fontDesc: "Arial",
hAlign: 0,
vAlign: 0,
color: u,
isOutlined: !1,
out: u,
margin: 0
};
e.exports = {
_getAssemblerData: function() {
S || (S = new p(2048, 2048));
return S._texture;
},
updateRenderData: function(t) {
if (t._renderData.vertDirty && y !== t) {
y = t;
this._updateFontFamily(t);
q.fontFamily = H;
this._updateProperties();
q.fontDesc = this._getFontDesc();
this._updateContent();
y._actualFontSize = P;
y.node.setContentSize(L);
y._renderData.vertDirty = y._renderData.uvDirty = !1;
y = null;
this._resetProperties();
}
},
_updateFontScale: function() {
D = P / R;
},
_updateProperties: function() {
I = y.string.toString();
P = y.fontSize;
R = P;
L.width = y.node._contentSize.width;
L.height = y.node._contentSize.height;
F = y.horizontalAlign;
V = y.verticalAlign;
O = y.spacingX;
k = y.overflow;
N = y._lineHeight;
W = y._isBold;
G = k !== l.NONE && (k === l.RESIZE_HEIGHT || y.enableWrapText);
var t = h && y.getComponent(s);
if (t && t.enabled) {
q.isOutlined = !0;
q.margin = t.width;
q.out = t.color;
q.out.a = t.color.a * y.node.color.a / 255;
} else {
q.isOutlined = !1;
q.margin = 0;
}
q.lineHeight = N;
q.fontSize = P;
q.fontFamily = H;
q.color = y.node.color;
q.hash = this._computeHash(q);
this._setupBMFontOverflowMetrics();
},
_updateFontFamily: function(t) {
t.useSystemFont ? H = t.fontFamily : t.font ? t.font._nativeAsset ? H = t.font._nativeAsset : (H = cc.loader.getRes(t.font.nativeUrl)) || cc.loader.load(t.font.nativeUrl, (function(e, i) {
H = i || "Arial";
t.font._nativeAsset = i;
t._updateRenderData(!0);
})) : H = "Arial";
},
_computeHash: function(t) {
var e = t.color.toHEX("#rrggbb"), i = "";
t.isOutlined && (i = t.out.toHEX("#rrggbb"));
return "" + t.fontSize + t.fontFamily + e + i;
},
_getFontDesc: function() {
var t = P.toString() + "px ";
t += H;
W && (t = "bold " + t);
return t;
},
_resetProperties: function() {},
_updateContent: function() {
this._updateFontScale();
this._alignText();
},
_computeHorizontalKerningForText: function() {
for (var t = I, e = t.length, i = null.kerningDict, n = g, r = -1, s = 0; s < e; ++s) {
var o = t.charCodeAt(s), a = i[r << 16 | 65535 & o] || 0;
n[s] = s < e - 1 ? a : 0;
r = o;
}
},
_multilineTextWrap: function(t) {
var e = I.length, i = 0, n = 0, r = 0, s = 0, a = 0, c = 0, h = 0, l = null, u = cc.v2(0, 0);
this._updateFontScale();
for (var _ = 0; _ < e; ) {
var f = I.charAt(_);
if ("\n" !== f) {
for (var d = t(I, _, e), m = c, p = h, v = a, y = n, x = !1, A = 0; A < d; ++A) {
var b = _ + A;
if ("\r" !== (f = I.charAt(b))) if (l = S.getLetterDefinitionForChar(f, q)) {
var E = y + l.offsetX * D;
if (G && j > 0 && n > 0 && E + l.w * D > j && !o.isUnicodeSpace(f)) {
C.push(a);
a = 0;
i++;
n = 0;
r -= N * D + 0;
x = !0;
break;
}
u.x = E;
u.y = r - l.offsetY * D;
this._recordLetterInfo(u, f, b, i);
b + 1 < g.length && b < e - 1 && (y += g[b + 1]);
y += l.xAdvance * D + O;
v = u.x + l.w * D;
m < u.y && (m = u.y);
p > u.y - l.h * D && (p = u.y - l.h * D);
} else this._recordPlaceholderInfo(b, f); else this._recordPlaceholderInfo(b, f);
}
if (!x) {
n = y;
a = v;
c < m && (c = m);
h > p && (h = p);
s < a && (s = a);
_ += d;
}
} else {
C.push(a);
a = 0;
i++;
n = 0;
r -= N * D + 0;
this._recordPlaceholderInfo(_, f);
_++;
}
}
C.push(a);
w = (T = i + 1) * N * D;
T > 1 && (w += 0 * (T - 1));
L.width = z;
L.height = U;
z <= 0 && (L.width = parseFloat(s.toFixed(2)));
U <= 0 && (L.height = parseFloat(w.toFixed(2)));
B = L.height;
M = 0;
c > 0 && (B = L.height + c);
h < -w && (M = w + h);
return !0;
},
_getFirstCharLen: function() {
return 1;
},
_getFirstWordLen: function(t, e, i) {
var n = t.charAt(e);
if (o.isUnicodeCJK(n) || "\n" === n || o.isUnicodeSpace(n)) return 1;
var r = 1, s = S.getLetterDefinitionForChar(n, q);
if (!s) return r;
for (var a = s.xAdvance * D + O, c = e + 1; c < i; ++c) {
n = t.charAt(c);
if (!(s = S.getLetterDefinitionForChar(n, q))) break;
if (a + s.offsetX * D + s.w * D > j && !o.isUnicodeSpace(n) && j > 0) return r;
a += s.xAdvance * D + O;
if ("\n" === n || o.isUnicodeSpace(n) || o.isUnicodeCJK(n)) break;
r++;
}
return r;
},
_multilineTextWrapByWord: function() {
return this._multilineTextWrap(this._getFirstWordLen);
},
_multilineTextWrapByChar: function() {
return this._multilineTextWrap(this._getFirstCharLen);
},
_recordPlaceholderInfo: function(t, e) {
if (t >= x.length) {
var i = new f();
x.push(i);
}
x[t].char = e;
x[t].hash = e.charCodeAt(0) + q.hash;
x[t].valid = !1;
},
_recordLetterInfo: function(t, e, i, n) {
if (i >= x.length) {
var r = new f();
x.push(r);
}
var s = e.charCodeAt(0) + q.hash;
x[i].line = n;
x[i].char = e;
x[i].hash = s;
x[i].valid = S.getLetter(s).valid;
x[i].x = t.x;
x[i].y = t.y;
},
_alignText: function() {
w = 0;
C.length = 0;
this._multilineTextWrapByWord();
this._computeAlignmentOffset();
this._updateQuads();
},
_scaleFontSizeDown: function(t) {
var e = !0;
if (!t) {
t = .1;
e = !1;
}
P = t;
e && this._updateContent();
},
_isVerticalClamp: function() {
return w > L.height;
},
_isHorizontalClamp: function() {
for (var t = !1, e = 0, i = I.length; e < i; ++e) {
var n = x[e];
if (n.valid) {
var r = S.getLetter(n.hash), s = n.x + r.w / 2 * D, o = n.line;
if (z > 0) if (G) {
if (C[o] > L.width && (s > L.width || s < 0)) {
t = !0;
break;
}
} else if (s > L.width) {
t = !0;
break;
}
}
}
return t;
},
_isHorizontalClamped: function(t, e) {
var i = C[e], n = t > L.width || t < 0;
return G ? i > L.width && n : n;
},
_updateQuads: function() {
var t = S._texture, e = y.node, i = y._renderData;
i.dataLength = i.vertexCount = i.indiceCount = 0;
for (var n = L, r = e._anchorPoint.x * n.width, s = e._anchorPoint.y * n.height, o = !0, a = 0, c = I.length; a < c; ++a) {
var h = x[a];
if (h.valid) {
var u = S.getLetter(h.hash);
v.height = u.h;
v.width = u.w;
v.x = u.u;
v.y = u.v;
var _ = h.y + E;
if (U > 0) {
if (_ > B) {
var f = _ - B;
v.y += f;
v.height -= f;
_ -= f;
}
_ - u.h * D < M && (v.height = _ < M ? 0 : _ - M);
}
var d = h.line, m = h.x + u.w / 2 * D + A[d];
if (z > 0 && this._isHorizontalClamped(m, d)) if (k === l.CLAMP) v.width = 0; else if (k === l.SHRINK) {
if (L.width > u.w) {
o = !1;
break;
}
v.width = 0;
}
if (v.height > 0 && v.width > 0) {
var p = h.x + A[h.line];
this.appendQuad(i, t, v, !1, p - r, _ - s, D);
}
}
}
return o;
},
appendQuad: function(t, e, i, n, r, s, o) {},
_computeAlignmentOffset: function() {
A.length = 0;
switch (F) {
case n.TextAlignment.LEFT:
for (var t = 0; t < T; ++t) A.push(0);
break;

case n.TextAlignment.CENTER:
for (var e = 0, i = C.length; e < i; e++) A.push((L.width - C[e]) / 2);
break;

case n.TextAlignment.RIGHT:
for (var r = 0, s = C.length; r < s; r++) A.push(L.width - C[r]);
}
switch (V) {
case n.VerticalTextAlignment.TOP:
E = L.height;
break;

case n.VerticalTextAlignment.CENTER:
E = (L.height + w) / 2;
break;

case n.VerticalTextAlignment.BOTTOM:
E = w;
}
},
_setupBMFontOverflowMetrics: function() {
var t = L.width, e = L.height;
k === l.RESIZE_HEIGHT && (e = 0);
if (k === l.NONE) {
t = 0;
e = 0;
}
z = t;
U = e;
b.width = t;
b.height = e;
j = t;
}
};
}), {
"../../../assets/CCRenderTexture": 42,
"../../../components/CCComponent": 67,
"../../../components/CCLabel": 69,
"../../../components/CCLabelOutline": 70,
"../../../platform/CCMacro": 165,
"../../../utils/text-utils": 249
} ],
209: [ (function(t, e, i) {
var n = t("../../../platform/CCMacro"), r = t("../../../utils/text-utils"), s = t("../../../components/CCComponent"), o = t("../../../components/CCLabel"), a = t("../../../components/CCLabelOutline"), c = o.Overflow, h = cc.Color.WHITE, l = cc.js.isChildClassOf(a, s), u = null, _ = null, f = null, d = "", m = "", p = 0, v = 0, y = [], g = cc.size(), x = 0, C = 0, A = 0, b = null, S = "", T = c.NONE, w = !1, E = (1 / 255).toFixed(3), B = !1, M = null, D = 0, I = 0, P = !1, R = !1, L = !1, F = void 0;
e.exports = {
_getAssemblerData: function() {
(F = o._canvasPool.get()).canvas.width = F.canvas.height = 1;
return F;
},
_resetAssemblerData: function(t) {
t && o._canvasPool.put(t);
},
updateRenderData: function(t) {
if (t._renderData.vertDirty) {
this._updateFontFamily(t);
this._updateProperties(t);
this._calculateLabelFont();
this._calculateSplitedStrings();
this._updateLabelDimensions();
this._calculateTextBaseline();
this._updateTexture(t);
this._calDynamicAtlas(t);
t._actualFontSize = p;
t.node.setContentSize(g);
this._updateVerts(t);
t._renderData.vertDirty = t._renderData.uvDirty = !1;
u = null;
_ = null;
f = null;
}
},
_updateVerts: function() {},
_updateFontFamily: function(t) {
t.useSystemFont ? S = t.fontFamily : t.font ? t.font._nativeAsset ? S = t.font._nativeAsset : (S = cc.loader.getRes(t.font.nativeUrl)) || cc.loader.load(t.font.nativeUrl, (function(e, i) {
S = i || "Arial";
t.font._nativeAsset = i;
t._updateRenderData(!0);
})) : S = "Arial";
},
_updateProperties: function(t) {
var e = t._assemblerData;
u = e.context;
_ = e.canvas;
f = t._frame._original ? t._frame._original._texture : t._frame._texture;
m = t.string.toString();
p = t._fontSize;
v = p;
T = t.overflow;
g.width = t.node.width;
g.height = t.node.height;
x = t._lineHeight;
C = t.horizontalAlign;
A = t.verticalAlign;
b = t.node.color;
P = t._isBold;
R = t._isItalic;
L = t._isUnderline;
w = T !== c.NONE && (T === c.RESIZE_HEIGHT || t.enableWrapText);
var i = l && t.getComponent(a);
if (i && i.enabled) {
B = !0;
I = D = i.width;
(M = cc.color(i.color)).a = M.a * t.node.color.a / 255;
} else {
B = !1;
I = 0;
}
},
_calculateFillTextStartPosition: function() {
var t = this._getLineHeight(), e = y.length, i = void 0, r = void 0;
i = C === n.TextAlignment.RIGHT ? g.width - I : C === n.TextAlignment.CENTER ? g.width / 2 : 0 + I;
r = A === n.VerticalTextAlignment.TOP ? 0 : A === n.VerticalTextAlignment.CENTER ? g.height / 2 - t * (e - 1) / 2 : g.height - t * (e - 1);
return cc.v2(i, r);
},
_updateTexture: function(t) {
u.clearRect(0, 0, _.width, _.height);
u.fillStyle = "rgba(" + b.r + ", " + b.g + ", " + b.b + ", " + E + ")";
u.fillRect(0, 0, _.width, _.height);
u.font = d;
var e = this._calculateFillTextStartPosition(), i = this._getLineHeight();
u.lineJoin = "round";
u.fillStyle = "rgba(" + b.r + ", " + b.g + ", " + b.b + ", 1)";
for (var n = void 0, r = 0; r < y.length; ++r) {
if (B) {
var s = M || h;
u.strokeStyle = "rgba(" + s.r + ", " + s.g + ", " + s.b + ", " + s.a / 255 + ")";
u.lineWidth = 2 * D;
u.strokeText(y[r], e.x, e.y + r * i);
}
u.fillText(y[r], e.x, e.y + r * i);
if (L) {
n = this._calculateUnderlineStartPosition();
u.save();
u.beginPath();
u.lineWidth = p / 8;
u.strokeStyle = "rgba(" + b.r + ", " + b.g + ", " + b.b + ", 1)";
u.moveTo(n.x, n.y + r * i - 1);
u.lineTo(n.x + _.width, n.y + r * i - 1);
u.stroke();
u.restore();
}
}
f.handleLoadedTexture();
},
_calDynamicAtlas: function(t) {
if (t.cacheMode === o.CacheMode.BITMAP) {
t._frame._original || t._frame.setRect(cc.rect(0, 0, _.width, _.height));
t._calDynamicAtlas();
}
},
_calculateUnderlineStartPosition: function() {
var t, e = this._getLineHeight(), i = y.length, r = void 0;
t = 0 + I;
r = A === n.VerticalTextAlignment.TOP ? p : A === n.VerticalTextAlignment.CENTER ? g.height / 2 - e * (i - 1) / 2 + p / 2 : g.height - e * (i - 1);
return cc.v2(t, r);
},
_updateLabelDimensions: function() {
var t = m.split("\n");
if (T === c.RESIZE_HEIGHT) g.height = y.length * this._getLineHeight(); else if (T === c.NONE) {
y = t;
for (var e = 0, i = 0, n = 0; n < t.length; ++n) {
var s = r.safeMeasureText(u, t[n]);
e = e > s ? e : s;
}
i = y.length * this._getLineHeight();
g.width = parseFloat(e.toFixed(2)) + 2 * I;
g.height = parseFloat(i.toFixed(2));
R && (g.width += v * Math.tan(.20943951));
}
_.width !== g.width && (_.width = g.width);
_.height !== g.height && (_.height = g.height);
},
_calculateTextBaseline: function() {
this._node;
var t = void 0, e = void 0;
t = C === n.TextAlignment.RIGHT ? "right" : C === n.TextAlignment.CENTER ? "center" : "left";
u.textAlign = t;
e = A === n.VerticalTextAlignment.TOP ? "top" : A === n.VerticalTextAlignment.CENTER ? "middle" : "bottom";
u.textBaseline = e;
},
_calculateSplitedStrings: function() {
var t = m.split("\n");
if (w) {
y = [];
for (var e = g.width - 2 * I, i = 0; i < t.length; ++i) {
var n = r.safeMeasureText(u, t[i]), s = r.fragmentText(t[i], n, e, this._measureText(u));
y = y.concat(s);
}
} else y = t;
},
_getFontDesc: function() {
var t = p.toString() + "px ";
t += S;
P && (t = "bold " + t);
return t;
},
_getLineHeight: function() {
var t = x;
return 0 | (t = 0 === t ? p : t * p / v);
},
_calculateParagraphLength: function(t, e) {
for (var i = [], n = 0; n < t.length; ++n) {
var s = r.safeMeasureText(e, t[n]);
i.push(s);
}
return i;
},
_measureText: function(t) {
return function(e) {
return r.safeMeasureText(t, e);
};
},
_calculateLabelFont: function() {
d = this._getFontDesc();
u.font = d;
if (T === c.SHRINK) {
var t = m.split("\n"), e = this._calculateParagraphLength(t, u), i = 0, n = 0, s = 0;
if (w) {
var o = g.width - 2 * I, a = g.height - 2 * I;
if (o < 0 || a < 0) {
d = this._getFontDesc();
u.font = d;
return;
}
n = a + 1;
s = o + 1;
for (var h = p + 1, l = "", _ = !0, f = 0 | h; n > a || s > o; ) {
_ ? h = f / 2 | 0 : f = h = f - 1;
if (h <= 0) {
cc.logID(4003);
break;
}
p = h;
d = this._getFontDesc();
u.font = d;
n = 0;
for (i = 0; i < t.length; ++i) {
var y = 0, x = r.safeMeasureText(u, t[i]);
l = r.fragmentText(t[i], x, o, this._measureText(u));
for (;y < l.length; ) {
s = r.safeMeasureText(u, l[y]);
n += this._getLineHeight();
++y;
}
}
if (_) if (n > a) f = 0 | h; else {
_ = !1;
n = a + 1;
}
}
} else {
n = t.length * this._getLineHeight();
for (i = 0; i < t.length; ++i) s < e[i] && (s = e[i]);
var C = (g.width - 2 * I) / s, A = g.height / n;
p = v * Math.min(1, C, A) | 0;
d = this._getFontDesc();
u.font = d;
}
}
}
};
}), {
"../../../components/CCComponent": 67,
"../../../components/CCLabel": 69,
"../../../components/CCLabelOutline": 70,
"../../../platform/CCMacro": 165,
"../../../utils/text-utils": 249
} ],
210: [ (function(t, e, i) {
"use strict";
e.exports = n;
function n(t, e, i) {
i = i || 2;
var n, a, c, h, l, f, m, p = e && e.length, v = p ? e[0] * i : t.length, y = r(t, 0, v, i, !0), g = [];
if (!y) return g;
p && (y = (function(t, e, i, n) {
var o, a, c, h, l, f = [];
for (o = 0, a = e.length; o < a; o++) {
c = e[o] * n;
h = o < a - 1 ? e[o + 1] * n : t.length;
(l = r(t, c, h, n, !1)) === l.next && (l.steiner = !0);
f.push(d(l));
}
f.sort(u);
for (o = 0; o < f.length; o++) {
_(f[o], i);
i = s(i, i.next);
}
return i;
})(t, e, y, i));
if (t.length > 80 * i) {
n = c = t[0];
a = h = t[1];
for (var x = i; x < v; x += i) {
l = t[x];
f = t[x + 1];
l < n && (n = l);
f < a && (a = f);
l > c && (c = l);
f > h && (h = f);
}
m = Math.max(c - n, h - a);
}
o(y, g, i, n, a, m);
return g;
}
function r(t, e, i, n, r) {
var s, o;
if (r === T(t, e, i, n) > 0) for (s = e; s < i; s += n) o = A(s, t[s], t[s + 1], o); else for (s = i - n; s >= e; s -= n) o = A(s, t[s], t[s + 1], o);
if (o && y(o, o.next)) {
b(o);
o = o.next;
}
return o;
}
function s(t, e) {
if (!t) return t;
e || (e = t);
var i, n = t;
do {
i = !1;
if (n.steiner || !y(n, n.next) && 0 !== v(n.prev, n, n.next)) n = n.next; else {
b(n);
if ((n = e = n.prev) === n.next) return null;
i = !0;
}
} while (i || n !== e);
return e;
}
function o(t, e, i, n, r, u, _) {
if (t) {
!_ && u && (function(t, e, i, n) {
var r = t;
do {
null === r.z && (r.z = f(r.x, r.y, e, i, n));
r.prevZ = r.prev;
r.nextZ = r.next;
r = r.next;
} while (r !== t);
r.prevZ.nextZ = null;
r.prevZ = null;
(function(t) {
var e, i, n, r, s, o, a, c, h = 1;
do {
i = t;
t = null;
s = null;
o = 0;
for (;i; ) {
o++;
n = i;
a = 0;
for (e = 0; e < h; e++) {
a++;
if (!(n = n.nextZ)) break;
}
c = h;
for (;a > 0 || c > 0 && n; ) {
if (0 === a) {
r = n;
n = n.nextZ;
c--;
} else if (0 !== c && n) if (i.z <= n.z) {
r = i;
i = i.nextZ;
a--;
} else {
r = n;
n = n.nextZ;
c--;
} else {
r = i;
i = i.nextZ;
a--;
}
s ? s.nextZ = r : t = r;
r.prevZ = s;
s = r;
}
i = n;
}
s.nextZ = null;
h *= 2;
} while (o > 1);
})(r);
})(t, n, r, u);
for (var d, m, p = t; t.prev !== t.next; ) {
d = t.prev;
m = t.next;
if (u ? c(t, n, r, u) : a(t)) {
e.push(d.i / i);
e.push(t.i / i);
e.push(m.i / i);
b(t);
t = m.next;
p = m.next;
} else if ((t = m) === p) {
_ ? 1 === _ ? o(t = h(t, e, i), e, i, n, r, u, 2) : 2 === _ && l(t, e, i, n, r, u) : o(s(t), e, i, n, r, u, 1);
break;
}
}
}
}
function a(t) {
var e = t.prev, i = t, n = t.next;
if (v(e, i, n) >= 0) return !1;
for (var r = t.next.next; r !== t.prev; ) {
if (m(e.x, e.y, i.x, i.y, n.x, n.y, r.x, r.y) && v(r.prev, r, r.next) >= 0) return !1;
r = r.next;
}
return !0;
}
function c(t, e, i, n) {
var r = t.prev, s = t, o = t.next;
if (v(r, s, o) >= 0) return !1;
for (var a = r.x < s.x ? r.x < o.x ? r.x : o.x : s.x < o.x ? s.x : o.x, c = r.y < s.y ? r.y < o.y ? r.y : o.y : s.y < o.y ? s.y : o.y, h = r.x > s.x ? r.x > o.x ? r.x : o.x : s.x > o.x ? s.x : o.x, l = r.y > s.y ? r.y > o.y ? r.y : o.y : s.y > o.y ? s.y : o.y, u = f(a, c, e, i, n), _ = f(h, l, e, i, n), d = t.nextZ; d && d.z <= _; ) {
if (d !== t.prev && d !== t.next && m(r.x, r.y, s.x, s.y, o.x, o.y, d.x, d.y) && v(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 && m(r.x, r.y, s.x, s.y, o.x, o.y, d.x, d.y) && v(d.prev, d, d.next) >= 0) return !1;
d = d.prevZ;
}
return !0;
}
function h(t, e, i) {
var n = t;
do {
var r = n.prev, s = n.next.next;
if (!y(r, s) && g(r, n, n.next, s) && x(r, s) && x(s, r)) {
e.push(r.i / i);
e.push(n.i / i);
e.push(s.i / i);
b(n);
b(n.next);
n = t = s;
}
n = n.next;
} while (n !== t);
return n;
}
function l(t, e, i, n, r, a) {
var c = t;
do {
for (var h = c.next.next; h !== c.prev; ) {
if (c.i !== h.i && p(c, h)) {
var l = C(c, h);
c = s(c, c.next);
l = s(l, l.next);
o(c, e, i, n, r, a);
o(l, e, i, n, r, a);
return;
}
h = h.next;
}
c = c.next;
} while (c !== t);
}
function u(t, e) {
return t.x - e.x;
}
function _(t, e) {
if (e = (function(t, e) {
var i, n = e, r = t.x, s = t.y, o = -Infinity;
do {
if (s <= n.y && s >= n.next.y) {
var a = n.x + (s - n.y) * (n.next.x - n.x) / (n.next.y - n.y);
if (a <= r && a > o) {
o = a;
if (a === r) {
if (s === n.y) return n;
if (s === n.next.y) return n.next;
}
i = n.x < n.next.x ? n : n.next;
}
}
n = n.next;
} while (n !== e);
if (!i) return null;
if (r === o) return i.prev;
var c, h = i, l = i.x, u = i.y, _ = Infinity;
n = i.next;
for (;n !== h; ) {
if (r >= n.x && n.x >= l && m(s < u ? r : o, s, l, u, s < u ? o : r, s, n.x, n.y) && ((c = Math.abs(s - n.y) / (r - n.x)) < _ || c === _ && n.x > i.x) && x(n, t)) {
i = n;
_ = c;
}
n = n.next;
}
return i;
})(t, e)) {
var i = C(e, t);
s(i, i.next);
}
}
function f(t, e, i, n, r) {
return (t = 1431655765 & ((t = 858993459 & ((t = 252645135 & ((t = 16711935 & ((t = 32767 * (t - i) / r) | t << 8)) | t << 4)) | t << 2)) | t << 1)) | (e = 1431655765 & ((e = 858993459 & ((e = 252645135 & ((e = 16711935 & ((e = 32767 * (e - n) / r) | e << 8)) | e << 4)) | e << 2)) | e << 1)) << 1;
}
function d(t) {
var e = t, i = t;
do {
e.x < i.x && (i = e);
e = e.next;
} while (e !== t);
return i;
}
function m(t, e, i, n, r, s, o, a) {
return (r - o) * (e - a) - (t - o) * (s - a) >= 0 && (t - o) * (n - a) - (i - o) * (e - a) >= 0 && (i - o) * (s - a) - (r - o) * (n - a) >= 0;
}
function p(t, e) {
return t.next.i !== e.i && t.prev.i !== e.i && !(function(t, e) {
var i = t;
do {
if (i.i !== t.i && i.next.i !== t.i && i.i !== e.i && i.next.i !== e.i && g(i, i.next, t, e)) return !0;
i = i.next;
} while (i !== t);
return !1;
})(t, e) && x(t, e) && x(e, t) && (function(t, e) {
var i = t, n = !1, r = (t.x + e.x) / 2, s = (t.y + e.y) / 2;
do {
i.y > s != i.next.y > s && r < (i.next.x - i.x) * (s - i.y) / (i.next.y - i.y) + i.x && (n = !n);
i = i.next;
} while (i !== t);
return n;
})(t, e);
}
function v(t, e, i) {
return (e.y - t.y) * (i.x - e.x) - (e.x - t.x) * (i.y - e.y);
}
function y(t, e) {
return t.x === e.x && t.y === e.y;
}
function g(t, e, i, n) {
return !!(y(t, e) && y(i, n) || y(t, n) && y(i, e)) || v(t, e, i) > 0 != v(t, e, n) > 0 && v(i, n, t) > 0 != v(i, n, e) > 0;
}
function x(t, e) {
return v(t.prev, t, t.next) < 0 ? v(t, e, t.next) >= 0 && v(t, t.prev, e) >= 0 : v(t, e, t.prev) < 0 || v(t, t.next, e) < 0;
}
function C(t, e) {
var i = new S(t.i, t.x, t.y), n = new S(e.i, e.x, e.y), r = t.next, s = e.prev;
t.next = e;
e.prev = t;
i.next = r;
r.prev = i;
n.next = i;
i.prev = n;
s.next = n;
n.prev = s;
return n;
}
function A(t, e, i, n) {
var r = new S(t, e, i);
if (n) {
r.next = n.next;
r.prev = n;
n.next.prev = r;
n.next = r;
} else {
r.prev = r;
r.next = r;
}
return r;
}
function b(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 S(t, e, i) {
this.i = t;
this.x = e;
this.y = i;
this.prev = null;
this.next = null;
this.z = null;
this.prevZ = null;
this.nextZ = null;
this.steiner = !1;
}
n.deviation = function(t, e, i, n) {
var r = e && e.length, s = r ? e[0] * i : t.length, o = Math.abs(T(t, 0, s, i));
if (r) for (var a = 0, c = e.length; a < c; a++) {
var h = e[a] * i, l = a < c - 1 ? e[a + 1] * i : t.length;
o -= Math.abs(T(t, h, l, i));
}
var u = 0;
for (a = 0; a < n.length; a += 3) {
var _ = n[a] * i, f = n[a + 1] * i, d = n[a + 2] * i;
u += Math.abs((t[_] - t[d]) * (t[f + 1] - t[_ + 1]) - (t[_] - t[f]) * (t[d + 1] - t[_ + 1]));
}
return 0 === o && 0 === u ? 0 : Math.abs((u - o) / o);
};
function T(t, e, i, n) {
for (var r = 0, s = e, o = i - n; s < i; s += n) {
r += (t[o] - t[s]) * (t[s + 1] + t[o + 1]);
o = s;
}
return r;
}
n.flatten = function(t) {
for (var e = t[0][0].length, i = {
vertices: [],
holes: [],
dimensions: e
}, n = 0, r = 0; r < t.length; r++) {
for (var s = 0; s < t[r].length; s++) for (var o = 0; o < e; o++) i.vertices.push(t[r][s][o]);
if (r > 0) {
n += t[r - 1].length;
i.holes.push(n);
}
}
return i;
};
}), {} ],
211: [ (function(t, e, i) {
var n = t("../../../../graphics/helper"), r = t("../../../../graphics/types").PointFlags, s = t("../../mesh-buffer"), o = t("../../vertex-format").vfmtPosColor, a = t("../../../index"), c = a.renderEngine, h = c.IARenderData, l = c.InputAssembler, u = cc.Class({
name: "cc.GraphicsPoint",
extends: cc.Vec2,
ctor: function(t, e) {
this.reset();
},
reset: function() {
this.dx = 0;
this.dy = 0;
this.dmx = 0;
this.dmy = 0;
this.flags = 0;
this.len = 0;
}
});
function _() {
this.reset();
}
cc.js.mixin(_.prototype, {
reset: function() {
this.closed = !1;
this.nbevel = 0;
this.complex = !0;
this.points ? this.points.length = 0 : this.points = [];
}
});
function f(t) {
this._tessTol = .25;
this._distTol = .01;
this._updatePathOffset = !1;
this._paths = null;
this._pathLength = 0;
this._pathOffset = 0;
this._points = null;
this._pointsOffset = 0;
this._commandx = 0;
this._commandy = 0;
this._paths = [];
this._points = [];
this._renderDatas = [];
this._dataOffset = 0;
}
cc.js.mixin(f.prototype, {
moveTo: function(t, e) {
if (this._updatePathOffset) {
this._pathOffset = this._pathLength;
this._updatePathOffset = !1;
}
this._addPath();
this._addPoint(t, e, r.PT_CORNER);
this._commandx = t;
this._commandy = e;
},
lineTo: function(t, e) {
this._addPoint(t, e, r.PT_CORNER);
this._commandx = t;
this._commandy = e;
},
bezierCurveTo: function(t, e, i, s, o, a) {
var c = this._curPath, h = c.points[c.points.length - 1];
if (h.x !== t || h.y !== e || i !== o || s !== a) {
n.tesselateBezier(this, h.x, h.y, t, e, i, s, o, a, 0, r.PT_CORNER);
this._commandx = o;
this._commandy = a;
} else this.lineTo(o, a);
},
quadraticCurveTo: function(t, e, i, n) {
var r = this._commandx, s = this._commandy;
this.bezierCurveTo(r + 2 / 3 * (t - r), s + 2 / 3 * (e - s), i + 2 / 3 * (t - i), n + 2 / 3 * (e - n), i, n);
},
arc: function(t, e, i, r, s, o) {
n.arc(this, t, e, i, r, s, o);
},
ellipse: function(t, e, i, r) {
n.ellipse(this, t, e, i, r);
this._curPath.complex = !1;
},
circle: function(t, e, i) {
n.ellipse(this, t, e, i, i);
this._curPath.complex = !1;
},
rect: function(t, e, i, n) {
this.moveTo(t, e);
this.lineTo(t, e + n);
this.lineTo(t + i, e + n);
this.lineTo(t + i, e);
this.close();
this._curPath.complex = !1;
},
roundRect: function(t, e, i, r, s) {
n.roundRect(this, t, e, i, r, s);
this._curPath.complex = !1;
},
clear: function(t, e) {
this._pathLength = 0;
this._pathOffset = 0;
this._pointsOffset = 0;
this._dataOffset = 0;
this._curPath = null;
var i = this._renderDatas;
if (e) {
this._paths.length = 0;
this._points.length = 0;
for (var n = 0, r = i.length; n < r; n++) {
var s = i[n];
s.meshbuffer.destroy();
s.meshbuffer = null;
}
i.length = 0;
} else for (var o = 0, a = i.length; o < a; o++) {
i[o].meshbuffer.reset();
}
},
close: function() {
this._curPath.closed = !0;
},
_addPath: function() {
var t = this._pathLength, e = this._paths[t];
if (e) e.reset(); else {
e = new _();
this._paths.push(e);
}
this._pathLength++;
this._curPath = e;
return e;
},
_addPoint: function(t, e, i) {
var n = this._curPath;
if (n) {
var r, s = this._points, o = n.points;
if (r = s[this._pointsOffset++]) {
r.x = t;
r.y = e;
} else {
r = new u(t, e);
s.push(r);
}
r.flags = i;
o.push(r);
}
},
requestRenderData: function() {
var t = new h(), e = new s(a._handle, o);
t.meshbuffer = e;
this._renderDatas.push(t);
var i = new l();
i._vertexBuffer = e._vb;
i._indexBuffer = e._ib;
i._start = 0;
t.ia = i;
return t;
},
getRenderDatas: function() {
0 === this._renderDatas.length && this.requestRenderData();
return this._renderDatas;
}
});
e.exports = f;
}), {
"../../../../graphics/helper": 107,
"../../../../graphics/types": 109,
"../../../index": 201,
"../../mesh-buffer": 227,
"../../vertex-format": 232
} ],
212: [ (function(t, e, i) {
var n = t("../../../../graphics/graphics"), r = t("../../../../graphics/types").PointFlags, s = n.LineJoin, o = n.LineCap, a = t("./earcut"), c = t("./impl"), h = Math.PI, l = Math.min, u = Math.max, _ = Math.ceil, f = Math.acos, d = Math.cos, m = Math.sin, p = Math.atan2, v = (Math.abs, 
null), y = null, g = 0;
function x(t, e, i) {
return t < e ? e : t > i ? i : t;
}
var C = {
useModel: !0,
createImpl: function(t) {
return new c(t);
},
updateRenderData: function(t) {
for (var e = t._impl.getRenderDatas(), i = 0, n = e.length; i < n; i++) e[i].material = t.getMaterial();
},
fillBuffers: function(t, e) {
e._flush();
var i = e.node;
e.node = t.node;
this.renderIA(t, e);
e.node = i;
},
renderIA: function(t, e) {
for (var i = t.node.color, n = (i.r, i.g, i.b, i.a, t._impl.getRenderDatas()), r = 0, s = n.length; r < s; r++) {
var o = n[r], a = o.meshbuffer;
o.ia._count = a.indiceStart;
e._flushIA(o);
a.uploadData();
}
},
genRenderData: function(t, e) {
var i = y.getRenderDatas(), n = i[y._dataOffset], r = n.meshbuffer, s = r.vertexStart + e;
if (s > 65535 || 3 * s > 131070) {
++y._dataOffset;
s = e;
if (y._dataOffset < i.length) n = i[y._dataOffset]; else {
n = y.requestRenderData(t);
i[y._dataOffset] = n;
}
n.material = t.getMaterial();
r = n.meshbuffer;
}
s > r.vertexOffset && r.requestStatic(e, 3 * e);
return n;
},
stroke: function(t) {
g = t._strokeColor._val;
this._flattenPaths(t._impl);
this._expandStroke(t);
t._impl._updatePathOffset = !0;
},
fill: function(t) {
g = t._fillColor._val;
this._expandFill(t);
t._impl._updatePathOffset = !0;
},
_expandStroke: function(t) {
var e = .5 * t.lineWidth, i = t.lineCap, n = t.lineJoin, a = t.miterLimit;
y = t._impl;
var c = (function(t, e, i) {
var n = 2 * f(t / (t + i));
return u(2, _(e / n));
})(e, h, y._tessTol);
this._calculateJoins(y, e, n, a);
for (var l = y._paths, d = 0, m = y._pathOffset, p = y._pathLength; m < p; m++) {
var g = l[m], x = g.points.length;
n === s.ROUND ? d += 2 * (x + g.nbevel * (c + 2) + 1) : d += 2 * (x + 5 * g.nbevel + 1);
g.closed || (i === o.ROUND ? d += 2 * (2 * c + 2) : d += 12);
}
for (var C = (v = this.genRenderData(t, d)).meshbuffer, A = C._vData, b = C._iData, S = y._pathOffset, T = y._pathLength; S < T; S++) {
var w, E = l[S], B = E.points, M = B.length, D = C.vertexStart, I = void 0, P = void 0, R = void 0, L = void 0;
if (w = E.closed) {
I = B[M - 1];
P = B[0];
R = 0;
L = M;
} else {
I = B[0];
P = B[1];
R = 1;
L = M - 1;
}
if (!w) {
var F = P.sub(I);
F.normalizeSelf();
var V = F.x, O = F.y;
i === o.BUTT ? this._buttCap(I, V, O, e, 0) : i === o.SQUARE ? this._buttCap(I, V, O, e, e) : i === o.ROUND && this._roundCapStart(I, V, O, e, c);
}
for (var N = R; N < L; ++N) {
if (n === s.ROUND) this._roundJoin(I, P, e, e, c); else if (0 != (P.flags & (r.PT_BEVEL | r.PT_INNERBEVEL))) this._bevelJoin(I, P, e, e); else {
this._vset(P.x + P.dmx * e, P.y + P.dmy * e);
this._vset(P.x - P.dmx * e, P.y - P.dmy * e);
}
I = P;
P = B[N + 1];
}
if (w) {
var k = 3 * D;
this._vset(A[k], A[k + 1]);
this._vset(A[k + 3], A[k + 4]);
} else {
var G = P.sub(I);
G.normalizeSelf();
var z = G.x, U = G.y;
i === o.BUTT ? this._buttCap(P, z, U, e, 0) : i === o.BUTT || i === o.SQUARE ? this._buttCap(P, z, U, e, e) : i === o.ROUND && this._roundCapEnd(P, z, U, e, c);
}
for (var j = C.indiceStart, H = D + 2, W = C.vertexStart; H < W; H++) {
b[j++] = H - 2;
b[j++] = H - 1;
b[j++] = H;
}
C.indiceStart = j;
}
v = null;
y = null;
},
_expandFill: function(t) {
for (var e = (y = t._impl)._paths, i = 0, n = y._pathOffset, r = y._pathLength; n < r; n++) {
i += e[n].points.length;
}
for (var s = (v = this.genRenderData(t, i)).meshbuffer, o = s._vData, c = s._iData, h = y._pathOffset, l = y._pathLength; h < l; h++) {
var u = e[h], _ = u.points, f = _.length;
if (0 !== f) {
for (var d = s.vertexStart, m = 0; m < f; ++m) this._vset(_[m].x, _[m].y);
var p = s.indiceStart;
if (u.complex) {
for (var g = [], x = d, C = s.vertexStart; x < C; x++) {
var A = 3 * x;
g.push(o[A]);
g.push(o[A + 1]);
}
var b = a(g, null, 2);
if (!b || 0 === b.length) continue;
for (var S = 0, T = b.length; S < T; S++) c[p++] = b[S] + d;
} else for (var w = d, E = d + 2, B = s.vertexStart; E < B; E++) {
c[p++] = w;
c[p++] = E - 1;
c[p++] = E;
}
s.indiceStart = p;
}
}
v = null;
y = null;
},
_calculateJoins: function(t, e, i, n) {
var o = 0;
e > 0 && (o = 1 / e);
for (var a = t._paths, c = t._pathOffset, h = t._pathLength; c < h; c++) {
var _ = a[c], f = _.points, d = f.length, m = f[d - 1], p = f[0];
_.nbevel = 0;
for (var v = 0; v < d; v++) {
var y, g, x = m.dy, C = -m.dx, A = p.dy, b = -p.dx;
p.dmx = .5 * (x + A);
p.dmy = .5 * (C + b);
if ((y = p.dmx * p.dmx + p.dmy * p.dmy) > 1e-6) {
var S = 1 / y;
S > 600 && (S = 600);
p.dmx *= S;
p.dmy *= S;
}
if (p.dx * m.dy - m.dx * p.dy > 0) {
0;
p.flags |= r.PT_LEFT;
}
y * (g = u(11, l(m.len, p.len) * o)) * g < 1 && (p.flags |= r.PT_INNERBEVEL);
p.flags & r.PT_CORNER && (y * n * n < 1 || i === s.BEVEL || i === s.ROUND) && (p.flags |= r.PT_BEVEL);
0 != (p.flags & (r.PT_BEVEL | r.PT_INNERBEVEL)) && _.nbevel++;
m = p;
p = f[v + 1];
}
}
},
_flattenPaths: function(t) {
for (var e = t._paths, i = t._pathOffset, n = t._pathLength; i < n; i++) {
var r = e[i], s = r.points, o = s[s.length - 1], a = s[0];
if (o.equals(a)) {
r.closed = !0;
s.pop();
o = s[s.length - 1];
}
for (var c = 0, h = s.length; c < h; c++) {
var l = a.sub(o);
o.len = l.mag();
(l.x || l.y) && l.normalizeSelf();
o.dx = l.x;
o.dy = l.y;
o = a;
a = s[c + 1];
}
}
},
_chooseBevel: function(t, e, i, n) {
var r = i.x, s = i.y, o = void 0, a = void 0, c = void 0, h = void 0;
if (0 !== t) {
o = r + e.dy * n;
a = s - e.dx * n;
c = r + i.dy * n;
h = s - i.dx * n;
} else {
o = c = r + i.dmx * n;
a = h = s + i.dmy * n;
}
return [ o, a, c, h ];
},
_buttCap: function(t, e, i, n, r) {
var s = t.x - e * r, o = t.y - i * r, a = i, c = -e;
this._vset(s + a * n, o + c * n);
this._vset(s - a * n, o - c * n);
},
_roundCapStart: function(t, e, i, n, r) {
for (var s = t.x, o = t.y, a = i, c = -e, l = 0; l < r; l++) {
var u = l / (r - 1) * h, _ = d(u) * n, f = m(u) * n;
this._vset(s - a * _ - e * f, o - c * _ - i * f);
this._vset(s, o);
}
this._vset(s + a * n, o + c * n);
this._vset(s - a * n, o - c * n);
},
_roundCapEnd: function(t, e, i, n, r) {
var s = t.x, o = t.y, a = i, c = -e;
this._vset(s + a * n, o + c * n);
this._vset(s - a * n, o - c * n);
for (var l = 0; l < r; l++) {
var u = l / (r - 1) * h, _ = d(u) * n, f = m(u) * n;
this._vset(s, o);
this._vset(s - a * _ + e * f, o - c * _ + i * f);
}
},
_roundJoin: function(t, e, i, n, s) {
var o = t.dy, a = -t.dx, c = e.dy, l = -e.dx, u = e.x, f = e.y;
if (0 != (e.flags & r.PT_LEFT)) {
var v = this._chooseBevel(e.flags & r.PT_INNERBEVEL, t, e, i), y = v[0], g = v[1], C = v[2], A = v[3], b = p(-a, -o), S = p(-l, -c);
S > b && (S -= 2 * h);
this._vset(y, g);
this._vset(u - o * n, e.y - a * n);
for (var T = x(_((b - S) / h) * s, 2, s), w = 0; w < T; w++) {
var E = b + w / (T - 1) * (S - b), B = u + d(E) * n, M = f + m(E) * n;
this._vset(u, f);
this._vset(B, M);
}
this._vset(C, A);
this._vset(u - c * n, f - l * n);
} else {
var D = this._chooseBevel(e.flags & r.PT_INNERBEVEL, t, e, -n), I = D[0], P = D[1], R = D[2], L = D[3], F = p(a, o), V = p(l, c);
V < F && (V += 2 * h);
this._vset(u + o * n, f + a * n);
this._vset(I, P);
for (var O = x(_((V - F) / h) * s, 2, s), N = 0; N < O; N++) {
var k = F + N / (O - 1) * (V - F), G = u + d(k) * i, z = f + m(k) * i;
this._vset(G, z);
this._vset(u, f);
}
this._vset(u + c * n, f + l * n);
this._vset(R, L);
}
},
_bevelJoin: function(t, e, i, n) {
var s = void 0, o = void 0, a = void 0, c = void 0, h = void 0, l = void 0, u = void 0, _ = void 0, f = t.dy, d = -t.dx, m = e.dy, p = -e.dx;
if (e.flags & r.PT_LEFT) {
var v = this._chooseBevel(e.flags & r.PT_INNERBEVEL, t, e, i);
h = v[0];
l = v[1];
u = v[2];
_ = v[3];
this._vset(h, l);
this._vset(e.x - f * n, e.y - d * n);
this._vset(u, _);
this._vset(e.x - m * n, e.y - p * n);
} else {
var y = this._chooseBevel(e.flags & r.PT_INNERBEVEL, t, e, -n);
s = y[0];
o = y[1];
a = y[2];
c = y[3];
this._vset(e.x + f * i, e.y + d * i);
this._vset(s, o);
this._vset(e.x + m * i, e.y + p * i);
this._vset(a, c);
}
},
_vset: function(t, e) {
var i = v.meshbuffer, n = 3 * i.vertexStart, r = i._vData, s = i._uintVData;
r[n] = t;
r[n + 1] = e;
s[n + 2] = g;
i.vertexStart++;
i._dirty = !0;
}
};
n._assembler = C;
e.exports = C;
}), {
"../../../../graphics/graphics": 106,
"../../../../graphics/types": 109,
"./earcut": 210,
"./impl": 211
} ],
213: [ (function(t, e, i) {
t("./sprite");
t("./mask-assembler");
t("./graphics");
t("./label");
t("./motion-streak");
}), {
"./graphics": 212,
"./label": 215,
"./mask-assembler": 218,
"./motion-streak": 219,
"./sprite": 221
} ],
214: [ (function(t, e, i) {
var n = t("../../../../platform/js"), r = t("../../../utils/label/bmfont");
e.exports = n.addon({
createData: function(t) {
return t.requestRenderData();
},
fillBuffers: function(t, e) {
for (var i = t.node, n = t._renderData, r = n._data, s = i.color._val, o = i._worldMatrix, a = o.m00, c = o.m01, h = o.m04, l = o.m05, u = o.m12, _ = o.m13, f = e._meshBuffer, d = n.vertexCount, m = f.request(d, n.indiceCount), p = m.indiceOffset, v = m.byteOffset >> 2, y = m.vertexOffset, g = f._vData, x = f._uintVData, C = f._iData, A = 0; A < d; A++) {
var b = r[A];
g[v++] = b.x * a + b.y * h + u;
g[v++] = b.x * c + b.y * l + _;
g[v++] = b.u;
g[v++] = b.v;
x[v++] = s;
}
for (var S = 0, T = d / 4; S < T; S++) {
var w = y + 4 * S;
C[p++] = w;
C[p++] = w + 1;
C[p++] = w + 2;
C[p++] = w + 1;
C[p++] = w + 3;
C[p++] = w + 2;
}
},
appendQuad: function(t, e, i, n, r, s, o) {
var a = t.dataLength;
t.dataLength += 4;
t.vertexCount = t.dataLength;
t.indiceCount = t.dataLength / 2 * 3;
var c = t._data, h = e.width, l = e.height, u = i.width, _ = i.height, f = void 0, d = void 0, m = void 0, p = void 0;
if (n) {
f = i.x / h;
m = (i.x + _) / h;
d = (i.y + u) / l;
p = i.y / l;
c[a].u = f;
c[a].v = p;
c[a + 1].u = f;
c[a + 1].v = d;
c[a + 2].u = m;
c[a + 2].v = p;
c[a + 3].u = m;
c[a + 3].v = d;
} else {
f = i.x / h;
m = (i.x + u) / h;
d = (i.y + _) / l;
p = i.y / l;
c[a].u = f;
c[a].v = d;
c[a + 1].u = m;
c[a + 1].v = d;
c[a + 2].u = f;
c[a + 2].v = p;
c[a + 3].u = m;
c[a + 3].v = p;
}
c[a].x = r;
c[a].y = s - _ * o;
c[a + 1].x = r + u * o;
c[a + 1].y = s - _ * o;
c[a + 2].x = r;
c[a + 2].y = s;
c[a + 3].x = r + u * o;
c[a + 3].y = s;
}
}, r);
}), {
"../../../../platform/js": 180,
"../../../utils/label/bmfont": 206
} ],
215: [ (function(t, e, i) {
var n = t("../../../../components/CCLabel"), r = t("./ttf"), s = t("./bmfont"), o = t("./letter-font"), a = {
pool: [],
get: function() {
var t = this.pool.pop();
if (!t) {
var e = document.createElement("canvas");
t = {
canvas: e,
context: e.getContext("2d")
};
}
return t;
},
put: function(t) {
this.pool.length >= 32 || this.pool.push(t);
}
}, c = {
getAssembler: function(t) {
var e = r;
t.font instanceof cc.BitmapFont ? e = s : t.cacheMode === n.CacheMode.CHAR && (cc.sys.browserType === cc.sys.BROWSER_TYPE_WECHAT_GAME_SUB ? cc.warn("sorry, subdomain does not support CHAR mode currently!") : e = o);
return e;
},
updateRenderData: function(t) {
return t.__allocedDatas;
}
};
n._assembler = c;
n._canvasPool = a;
e.exports = c;
}), {
"../../../../components/CCLabel": 69,
"./bmfont": 214,
"./letter-font": 216,
"./ttf": 217
} ],
216: [ (function(t, e, i) {
var n = t("../../../../platform/js"), r = t("../../../utils/label/letter-font"), s = cc.color(255, 255, 255, 255);
e.exports = n.addon({
createData: function(t) {
return t.requestRenderData();
},
fillBuffers: function(t, e) {
var i = t.node, n = t._renderData, r = n._data, o = i._worldMatrix, a = o.m00, c = o.m01, h = o.m04, l = o.m05, u = o.m12, _ = o.m13;
s._fastSetA(i.color.a);
for (var f = s._val, d = e._meshBuffer, m = n.vertexCount, p = d.request(m, n.indiceCount), v = p.indiceOffset, y = p.byteOffset >> 2, g = p.vertexOffset, x = d._vData, C = d._uintVData, A = d._iData, b = 0; b < m; b++) {
var S = r[b];
x[y++] = S.x * a + S.y * h + u;
x[y++] = S.x * c + S.y * l + _;
x[y++] = S.u;
x[y++] = S.v;
C[y++] = f;
}
for (var T = 0, w = m / 4; T < w; T++) {
var E = g + 4 * T;
A[v++] = E;
A[v++] = E + 1;
A[v++] = E + 2;
A[v++] = E + 1;
A[v++] = E + 3;
A[v++] = E + 2;
}
},
appendQuad: function(t, e, i, n, r, s, o) {
var a = t.dataLength;
t.dataLength += 4;
t.vertexCount = t.dataLength;
t.indiceCount = t.dataLength / 2 * 3;
var c = t._data, h = e.width, l = e.height, u = i.width, _ = i.height, f = void 0, d = void 0, m = void 0, p = void 0;
if (n) {
f = i.x / h;
m = (i.x + _) / h;
d = (i.y + u) / l;
p = i.y / l;
c[a].u = f;
c[a].v = p;
c[a + 1].u = f;
c[a + 1].v = d;
c[a + 2].u = m;
c[a + 2].v = p;
c[a + 3].u = m;
c[a + 3].v = d;
} else {
f = i.x / h;
m = (i.x + u) / h;
d = (i.y + _) / l;
p = i.y / l;
c[a].u = f;
c[a].v = d;
c[a + 1].u = m;
c[a + 1].v = d;
c[a + 2].u = f;
c[a + 2].v = p;
c[a + 3].u = m;
c[a + 3].v = p;
}
c[a].x = r;
c[a].y = s - _ * o;
c[a + 1].x = r + u * o;
c[a + 1].y = s - _ * o;
c[a + 2].x = r;
c[a + 2].y = s;
c[a + 3].x = r + u * o;
c[a + 3].y = s;
}
}, r);
}), {
"../../../../platform/js": 180,
"../../../utils/label/letter-font": 208
} ],
217: [ (function(t, e, i) {
var n = t("../../../../platform/js"), r = t("../../../utils/label/ttf"), s = cc.color(255, 255, 255, 255);
e.exports = n.addon({
createData: function(t) {
var e = t.requestRenderData();
e.dataLength = 4;
e.vertexCount = 4;
e.indiceCount = 6;
return e;
},
fillBuffers: function(t, e) {
var i = t._renderData._data, n = t.node, r = n._worldMatrix, o = r.m00, a = r.m01, c = r.m04, h = r.m05, l = r.m12, u = r.m13;
s._fastSetA(n.color.a);
for (var _ = s._val, f = e._meshBuffer, d = f.request(4, 6), m = d.indiceOffset, p = d.byteOffset >> 2, v = d.vertexOffset, y = f._vData, g = f._uintVData, x = f._iData, C = 0; C < 4; C++) {
var A = i[C];
y[p++] = A.x * o + A.y * c + l;
y[p++] = A.x * a + A.y * h + u;
y[p++] = A.u;
y[p++] = A.v;
g[p++] = _;
}
x[m++] = v;
x[m++] = v + 1;
x[m++] = v + 2;
x[m++] = v + 1;
x[m++] = v + 3;
x[m++] = v + 2;
},
_updateVerts: function(t) {
var e = t._renderData, i = t._frame.uv, n = t.node, r = n.width, s = n.height, o = n.anchorX * r, a = n.anchorY * s, c = e._data;
c[0].x = -o;
c[0].y = -a;
c[1].x = r - o;
c[1].y = -a;
c[2].x = -o;
c[2].y = s - a;
c[3].x = r - o;
c[3].y = s - a;
c[0].u = i[0];
c[0].v = i[1];
c[1].u = i[2];
c[1].v = i[3];
c[2].u = i[4];
c[2].v = i[5];
c[3].u = i[6];
c[3].v = i[7];
}
}, r);
}), {
"../../../../platform/js": 180,
"../../../utils/label/ttf": 209
} ],
218: [ (function(t, e, i) {
var n = t("../stencil-manager"), r = t("../../../components/CCMask"), s = t("../../render-flow"), o = t("./sprite/simple"), a = t("./graphics"), c = n.sharedManager, h = {
updateRenderData: function(t) {
if (!t._renderData) {
a.updateRenderData(t._clearGraphics);
t._type === r.Type.IMAGE_STENCIL ? t._renderData = o.createData(t) : t._renderData = t.requestRenderData();
}
var e = t._renderData;
if (t._type === r.Type.IMAGE_STENCIL) if (t.spriteFrame) {
var i = t.node._contentSize, n = t.node._anchorPoint;
e.updateSizeNPivot(i.width, i.height, n.x, n.y);
e.dataLength = 4;
o.updateRenderData(t);
e.material = t._material;
} else t._material = null; else {
t._graphics._material = t._material;
a.updateRenderData(t._graphics);
}
},
fillBuffers: function(t, e) {
if (t._type !== r.Type.IMAGE_STENCIL || t.spriteFrame) {
c.pushMask(t);
c.clear();
a.fillBuffers(t._clearGraphics, e);
c.enterLevel();
e.node = t.node;
e.material = t._material;
if (t._type === r.Type.IMAGE_STENCIL) {
o.fillBuffers(t, e);
e._flush();
} else a.fillBuffers(t._graphics, e);
c.enableMask();
}
t.node._renderFlag |= s.FLAG_UPDATE_RENDER_DATA;
}
}, l = {
fillBuffers: function(t, e) {
(t._type !== r.Type.IMAGE_STENCIL || t.spriteFrame) && c.exitMask();
t.node._renderFlag |= s.FLAG_UPDATE_RENDER_DATA;
}
};
r._assembler = h;
r._postAssembler = l;
e.exports = {
front: h,
end: l
};
}), {
"../../../components/CCMask": 72,
"../../render-flow": 203,
"../stencil-manager": 231,
"./graphics": 212,
"./sprite/simple": 224
} ],
219: [ (function(t, e, i) {
var n = t("../../../components/CCMotionStreak"), r = t("../../render-flow");
function s(t, e) {
this.point = t || cc.v2();
this.dir = e || cc.v2();
this.distance = 0;
this.time = 0;
}
s.prototype.setPoint = function(t, e) {
this.point.x = t;
this.point.y = e;
};
s.prototype.setDir = function(t, e) {
this.dir.x = t;
this.dir.y = e;
};
cc.v2(), cc.v2();
var o = cc.v2(), a = cc.v2();
function c(t, e) {
t.x = -e.y;
t.y = e.x;
return t;
}
var h = {
updateRenderData: function(t) {
var e = cc.director.getDeltaTime();
this.update(t, e);
var i = t._renderData, n = t.node._contentSize, r = t.node._anchorPoint;
i.updateSizeNPivot(n.width, n.height, r.x, r.y);
i.material = t.getMaterial();
},
update: function(t, e) {
var i = t._renderData;
i || (i = t._renderData = t.requestRenderData());
0;
var n = t._stroke / 2, r = t.node._worldMatrix, h = (r.m00, r.m01, r.m04, r.m05, 
r.m12), l = r.m13, u = t._points, _ = void 0;
if (u.length > 1) {
var f = u[0].point.x - h, d = u[0].point.y - l;
f * f + d * d < t.minSeg && (_ = u[0]);
}
if (!_) {
_ = new s();
u.splice(0, 0, _);
}
_.setPoint(h, l);
_.time = t._fadeTime + e;
i.dataLength = 0;
if (!(u.length < 2)) {
var m = i._data, p = t._color, v = p.r, y = p.g, g = p.b, x = p.a, C = u[1];
C.distance = _.point.sub(C.point, a).mag();
a.normalizeSelf();
C.setDir(a.x, a.y);
_.setDir(a.x, a.y);
for (var A = t._fadeTime, b = !1, S = u.length - 1; S >= 0; S--) {
var T = u[S], w = T.point, E = T.dir;
T.time -= e;
if (T.time < 0) u.splice(S, 1); else {
var B = T.time / A, M = u[S - 1];
if (!b) {
if (!M) {
u.splice(S, 1);
continue;
}
w.x = M.point.x - E.x * B;
w.y = M.point.y - E.y * B;
}
b = !0;
c(o, E);
i.dataLength += 2;
var D = (B * x << 24 >>> 0) + (g << 16) + (y << 8) + v, I = m.length - 1;
m[I].x = w.x - o.x * n;
m[I].y = w.y - o.y * n;
m[I].u = 0;
m[I].v = B;
m[I].color = D;
m[--I].x = w.x + o.x * n;
m[I].y = w.y + o.y * n;
m[I].u = 1;
m[I].v = B;
m[I].color = D;
}
}
i.vertexCount = i.dataLength;
i.indiceCount = i.vertexCount < 2 ? 0 : 3 * (i.vertexCount - 2);
}
},
fillBuffers: function(t, e) {
t.node;
for (var i = t._renderData, n = i._data, s = e._meshBuffer, o = i.vertexCount, a = s.request(o, i.indiceCount), c = a.indiceOffset, h = a.byteOffset >> 2, l = a.vertexOffset, u = s._vData, _ = s._uintVData, f = s._iData, d = void 0, m = 0, p = i.vertexCount; m < p; m++) {
d = n[m];
u[h++] = d.x;
u[h++] = d.y;
u[h++] = d.u;
u[h++] = d.v;
_[h++] = d.color;
}
for (var v = 0, y = i.vertexCount; v < y; v += 2) {
var g = l + v;
f[c++] = g;
f[c++] = g + 2;
f[c++] = g + 1;
f[c++] = g + 1;
f[c++] = g + 2;
f[c++] = g + 3;
}
t.node._renderFlag |= r.FLAG_UPDATE_RENDER_DATA;
}
};
e.exports = n._assembler = h;
}), {
"../../../components/CCMotionStreak": 73,
"../../render-flow": 203
} ],
220: [ (function(t, e, i) {
var n = t("../../../../components/CCSprite").FillType;
e.exports = {
useModel: !1,
updateRenderData: function(t) {
var e = t.spriteFrame;
t._calDynamicAtlas();
var i = t._renderData;
if (i && e) {
var n = i.uvDirty, r = i.vertDirty;
if (!n && !r) return t.__allocedDatas;
var s = t._fillStart, o = t._fillRange;
if (o < 0) {
s += o;
o = -o;
}
o = s + o;
s = (s = s > 1 ? 1 : s) < 0 ? 0 : s;
o = (o = o > 1 ? 1 : o) < 0 ? 0 : o;
var a = s + (o = (o -= s) < 0 ? 0 : o);
a = a > 1 ? 1 : a;
n && this.updateUVs(t, s, a);
if (r) {
this.updateVerts(t, s, a);
this.updateWorldVerts(t);
}
}
},
updateUVs: function(t, e, i) {
var r = t._spriteFrame, s = t._renderData, o = s._data, a = r._texture.width, c = r._texture.height, h = r._rect, l = void 0, u = void 0, _ = void 0, f = void 0, d = void 0, m = void 0, p = void 0, v = void 0, y = void 0, g = void 0, x = void 0, C = void 0;
if (r._rotated) {
l = h.x / a;
u = (h.y + h.width) / c;
_ = (h.x + h.height) / a;
f = h.y / c;
d = p = l;
y = x = _;
v = C = u;
m = g = f;
} else {
l = h.x / a;
u = (h.y + h.height) / c;
_ = (h.x + h.width) / a;
f = h.y / c;
d = y = l;
p = x = _;
m = v = u;
g = C = f;
}
switch (t._fillType) {
case n.HORIZONTAL:
o[0].u = d + (p - d) * e;
o[0].v = m + (v - m) * e;
o[1].u = d + (p - d) * i;
o[1].v = m + (v - m) * i;
o[2].u = y + (x - y) * e;
o[2].v = g + (C - g) * e;
o[3].u = y + (x - y) * i;
o[3].v = g + (C - g) * i;
break;

case n.VERTICAL:
o[0].u = d + (y - d) * e;
o[0].v = m + (g - m) * e;
o[1].u = p + (x - p) * e;
o[1].v = v + (C - v) * e;
o[2].u = d + (y - d) * i;
o[2].v = m + (g - m) * i;
o[3].u = p + (x - p) * i;
o[3].v = v + (C - v) * i;
break;

default:
cc.errorID(2626);
}
s.uvDirty = !1;
},
updateVerts: function(t, e, i) {
var r = t._renderData, s = r._data, o = t.node, a = o.width, c = o.height, h = o.anchorX * a, l = o.anchorY * c, u = -h, _ = -l, f = a - h, d = c - l, m = void 0;
switch (t._fillType) {
case n.HORIZONTAL:
m = u + (f - u) * i;
u = u + (f - u) * e;
f = m;
break;

case n.VERTICAL:
m = _ + (d - _) * i;
_ = _ + (d - _) * e;
d = m;
break;

default:
cc.errorID(2626);
}
s[4].x = u;
s[4].y = _;
s[5].x = f;
s[5].y = _;
s[6].x = u;
s[6].y = d;
s[7].x = f;
s[7].y = d;
r.vertDirty = !1;
},
createData: function(t) {
var e = t.requestRenderData();
e.dataLength = 8;
e.vertexCount = 4;
e.indiceCount = 6;
return e;
},
updateWorldVerts: function(t) {
for (var e = t.node, i = t._renderData._data, n = e._worldMatrix, r = n.m00, s = n.m01, o = n.m04, a = n.m05, c = n.m12, h = n.m13, l = 0; l < 4; l++) {
var u = i[l + 4], _ = i[l];
_.x = u.x * r + u.y * o + c;
_.y = u.x * s + u.y * a + h;
}
},
fillBuffers: function(t, e) {
e.worldMatDirty && this.updateWorldVerts(t);
for (var i = t._renderData._data, n = t.node, r = n._color._val, s = n._worldMatrix, o = (s.m00, 
s.m01, s.m04, s.m05, s.m12, s.m13, e._meshBuffer), a = o.request(4, 6), c = a.indiceOffset, h = a.byteOffset >> 2, l = a.vertexOffset, u = o._vData, _ = o._uintVData, f = 0; f < 4; f++) {
var d = i[f];
u[h++] = d.x;
u[h++] = d.y;
u[h++] = d.u;
u[h++] = d.v;
_[h++] = r;
}
var m = o._iData;
m[c++] = l;
m[c++] = l + 1;
m[c++] = l + 2;
m[c++] = l + 1;
m[c++] = l + 3;
m[c++] = l + 2;
}
};
}), {
"../../../../components/CCSprite": 82
} ],
221: [ (function(t, e, i) {
var n = t("../../../../components/CCSprite"), r = n.Type, s = n.FillType, o = t("./simple"), a = t("./sliced"), c = t("./tiled"), h = t("./radial-filled"), l = t("./bar-filled"), u = t("./mesh"), _ = {
getAssembler: function(t) {
var e = o;
switch (t.type) {
case r.SLICED:
e = a;
break;

case r.TILED:
e = c;
break;

case r.FILLED:
e = t._fillType === s.RADIAL ? h : l;
break;

case r.MESH:
e = u;
}
return e;
},
updateRenderData: function(t) {
return t.__allocedDatas;
}
};
n._assembler = _;
e.exports = _;
}), {
"../../../../components/CCSprite": 82,
"./bar-filled": 220,
"./mesh": 222,
"./radial-filled": 223,
"./simple": 224,
"./sliced": 225,
"./tiled": 226
} ],
222: [ (function(t, e, i) {
e.exports = {
useModel: !1,
createData: function(t) {
return t.requestRenderData();
},
updateRenderData: function(t) {
var e = t.spriteFrame;
t._calDynamicAtlas();
var i = t._renderData;
if (i && e) {
var n = e.vertices;
if (n) {
if (i.vertexCount !== n.x.length) {
i.vertexCount = n.x.length;
i.indiceCount = n.triangles.length;
i.dataLength = 2 * i.vertexCount;
i.uvDirty = i.vertDirty = !0;
}
i.uvDirty && this.updateUVs(t);
if (i.vertDirty) {
this.updateVerts(t);
this.updateWorldVerts(t);
}
}
}
},
updateUVs: function(t) {
for (var e = t.getMaterial().effect.getProperty("texture"), i = (e._width, e._height, 
t.spriteFrame.vertices), n = i.nu, r = i.nv, s = t._renderData, o = s._data, a = 0, c = n.length; a < c; a++) {
var h = o[a];
h.u = n[a];
h.v = r[a];
}
s.uvDirty = !1;
},
updateVerts: function(t) {
var e = t.node, i = Math.abs(e.width), n = Math.abs(e.height), r = e.anchorX * i, s = e.anchorY * n, o = t.spriteFrame, a = o.vertices, c = a.x, h = a.y, l = o._originalSize.width, u = o._originalSize.height, _ = o._rect.width, f = o._rect.height, d = o._offset.x + (l - _) / 2, m = o._offset.y + (u - f) / 2, p = i / (t.trim ? _ : l), v = n / (t.trim ? f : u), y = t._renderData, g = y._data;
if (t.trim) for (var x = 0, C = c.length; x < C; x++) {
var A = g[x + C];
A.x = (c[x] - d) * p - r;
A.y = (u - h[x] - m) * v - s;
} else for (var b = 0, S = c.length; b < S; b++) {
var T = g[b + S];
T.x = c[b] * p - r;
T.y = (u - h[b]) * v - s;
}
y.vertDirty = !1;
},
updateWorldVerts: function(t) {
for (var e = t.node, i = t._renderData, n = i._data, r = e._worldMatrix, s = r.m00, o = r.m01, a = r.m04, c = r.m05, h = r.m12, l = r.m13, u = 0, _ = i.vertexCount; u < _; u++) {
var f = n[u + _], d = n[u];
d.x = f.x * s + f.y * a + h;
d.y = f.x * o + f.y * c + l;
}
},
fillBuffers: function(t, e) {
var i = t.node._color._val, n = t._renderData, r = n._data, s = t.spriteFrame.vertices;
if (s) {
e.worldMatDirty && this.updateWorldVerts(t);
for (var o = e._meshBuffer, a = o.request(n.vertexCount, n.indiceCount), c = a.indiceOffset, h = a.byteOffset >> 2, l = a.vertexOffset, u = o._vData, _ = o._uintVData, f = o._iData, d = 0, m = n.vertexCount; d < m; d++) {
var p = r[d];
u[h++] = p.x;
u[h++] = p.y;
u[h++] = p.u;
u[h++] = p.v;
_[h++] = i;
}
for (var v = s.triangles, y = 0, g = v.length; y < g; y++) f[c++] = l + v[y];
}
}
};
}), {} ],
223: [ (function(t, e, i) {
var n = 2 * Math.PI;
e.exports = {
useModel: !1,
_vertPos: [ cc.v2(0, 0), cc.v2(0, 0), cc.v2(0, 0), cc.v2(0, 0) ],
_vertices: [ 0, 0, 0, 0 ],
_uvs: [ 0, 0, 0, 0, 0, 0, 0, 0 ],
_intersectPoint_1: [ cc.v2(0, 0), cc.v2(0, 0), cc.v2(0, 0), cc.v2(0, 0) ],
_intersectPoint_2: [ cc.v2(0, 0), cc.v2(0, 0), cc.v2(0, 0), cc.v2(0, 0) ],
_center: cc.v2(0, 0),
_triangles: [],
createData: function(t) {
return t.requestRenderData();
},
updateRenderData: function(t) {
var e = t.spriteFrame;
t._calDynamicAtlas();
var i = t._renderData;
if (i && e && (i.vertDirty || i.uvDirty)) {
var r = i._data, s = t._fillStart, o = t._fillRange;
if (o < 0) {
s += o;
o = -o;
}
for (;s >= 1; ) s -= 1;
for (;s < 0; ) s += 1;
var a = (s *= n) + (o *= n);
this._calculateVertices(t);
this._calculateUVs(e);
var c = this._center, h = this._vertPos, l = this._vertices, u = this._triangles;
this._calcInsectedPoints(l[0], l[2], l[1], l[3], c, s, this._intersectPoint_1);
this._calcInsectedPoints(l[0], l[2], l[1], l[3], c, s + o, this._intersectPoint_2);
for (var _ = 0, f = 0; f < 4; ++f) {
var d = u[f];
if (d) if (o >= n) {
i.dataLength = _ + 3;
this._generateTriangle(r, _, c, h[d[0]], h[d[1]]);
_ += 3;
} else {
var m = this._getVertAngle(c, h[d[0]]), p = this._getVertAngle(c, h[d[1]]);
p < m && (p += n);
m -= n;
p -= n;
for (var v = 0; v < 3; ++v) {
if (m >= a) ; else if (m >= s) {
i.dataLength = _ + 3;
p >= a ? this._generateTriangle(r, _, c, h[d[0]], this._intersectPoint_2[f]) : this._generateTriangle(r, _, c, h[d[0]], h[d[1]]);
_ += 3;
} else if (p <= s) ; else if (p <= a) {
i.dataLength = _ + 3;
this._generateTriangle(r, _, c, this._intersectPoint_1[f], h[d[1]]);
_ += 3;
} else {
i.dataLength = _ + 3;
this._generateTriangle(r, _, c, this._intersectPoint_1[f], this._intersectPoint_2[f]);
_ += 3;
}
m += n;
p += n;
}
}
}
i.indiceCount = i.vertexCount = _;
i.vertDirty = i.uvDirty = !1;
}
},
_getVertAngle: function(t, e) {
var i, n;
i = e.x - t.x;
n = e.y - t.y;
if (0 !== i || 0 !== n) {
if (0 === i) return n > 0 ? .5 * Math.PI : 1.5 * Math.PI;
var r = Math.atan(n / i);
i < 0 && (r += Math.PI);
return r;
}
},
_generateTriangle: function(t, e, i, n, r) {
var s = this._vertices, o = s[0], a = s[1], c = s[2], h = s[3];
t[e].x = i.x;
t[e].y = i.y;
t[e + 1].x = n.x;
t[e + 1].y = n.y;
t[e + 2].x = r.x;
t[e + 2].y = r.y;
var l = void 0, u = void 0;
l = (i.x - o) / (c - o);
u = (i.y - a) / (h - a);
this._generateUV(l, u, t, e);
l = (n.x - o) / (c - o);
u = (n.y - a) / (h - a);
this._generateUV(l, u, t, e + 1);
l = (r.x - o) / (c - o);
u = (r.y - a) / (h - a);
this._generateUV(l, u, t, e + 2);
},
_generateUV: function(t, e, i, n) {
var r = this._uvs, s = r[0] + (r[2] - r[0]) * t, o = r[4] + (r[6] - r[4]) * t, a = r[1] + (r[3] - r[1]) * t, c = r[5] + (r[7] - r[5]) * t, h = i[n];
h.u = s + (o - s) * e;
h.v = a + (c - a) * e;
},
_calcInsectedPoints: function(t, e, i, n, r, s, o) {
var a = Math.sin(s), c = Math.cos(s), h = void 0, l = void 0;
if (0 !== Math.cos(s)) {
h = a / c;
if ((t - r.x) * c > 0) {
var u = r.y + h * (t - r.x);
o[0].x = t;
o[0].y = u;
}
if ((e - r.x) * c > 0) {
var _ = r.y + h * (e - r.x);
o[2].x = e;
o[2].y = _;
}
}
if (0 !== Math.sin(s)) {
l = c / a;
if ((n - r.y) * a > 0) {
var f = r.x + l * (n - r.y);
o[3].x = f;
o[3].y = n;
}
if ((i - r.y) * a > 0) {
var d = r.x + l * (i - r.y);
o[1].x = d;
o[1].y = i;
}
}
},
_calculateVertices: function(t) {
var e = t.node, i = e.width, n = e.height, r = e.anchorX * i, s = e.anchorY * n, o = -r, a = -s, c = i - r, h = n - s, l = this._vertices;
l[0] = o;
l[1] = a;
l[2] = c;
l[3] = h;
var u = this._center, _ = t._fillCenter, f = u.x = Math.min(Math.max(0, _.x), 1) * (c - o) + o, d = u.y = Math.min(Math.max(0, _.y), 1) * (h - a) + a, m = this._vertPos;
m[0].x = m[3].x = o;
m[1].x = m[2].x = c;
m[0].y = m[1].y = a;
m[2].y = m[3].y = h;
var p = this._triangles;
p.length = 0;
f !== l[0] && (p[0] = [ 3, 0 ]);
f !== l[2] && (p[2] = [ 1, 2 ]);
d !== l[1] && (p[1] = [ 0, 1 ]);
d !== l[3] && (p[3] = [ 2, 3 ]);
},
_calculateUVs: function(t) {
var e = t._texture.width, i = t._texture.height, n = t._rect, r = void 0, s = void 0, o = void 0, a = void 0, c = this._uvs;
if (t._rotated) {
r = n.x / e;
s = (n.x + n.height) / e;
o = n.y / i;
a = (n.y + n.width) / i;
c[0] = c[2] = r;
c[4] = c[6] = s;
c[3] = c[7] = a;
c[1] = c[5] = o;
} else {
r = n.x / e;
s = (n.x + n.width) / e;
o = n.y / i;
a = (n.y + n.height) / i;
c[0] = c[4] = r;
c[2] = c[6] = s;
c[1] = c[3] = a;
c[5] = c[7] = o;
}
},
fillBuffers: function(t, e) {
for (var i = t._renderData, n = i._data, r = t.node, s = r._color._val, o = r._worldMatrix, a = o.m00, c = o.m01, h = o.m04, l = o.m05, u = o.m12, _ = o.m13, f = e._meshBuffer, d = f.request(i.vertexCount, i.indiceCount), m = d.indiceOffset, p = d.byteOffset >> 2, v = d.vertexOffset, y = f._iData, g = f._vData, x = f._uintVData, C = n.length, A = 0; A < C; A++) {
var b = n[A];
g[p++] = b.x * a + b.y * h + u;
g[p++] = b.x * c + b.y * l + _;
g[p++] = b.u;
g[p++] = b.v;
x[p++] = s;
}
for (var S = 0; S < C; S++) y[m + S] = v + S;
}
};
}), {} ],
224: [ (function(t, e, i) {
e.exports = {
useModel: !1,
updateRenderData: function(t) {
var e = t._spriteFrame;
t._calDynamicAtlas();
var i = t._renderData;
i && e && i.vertDirty && this.updateVerts(t);
},
fillBuffers: function(t, e) {
var i = t._renderData._data, n = t.node, r = n._color._val, s = n._worldMatrix, o = s.m00, a = s.m01, c = s.m04, h = s.m05, l = s.m12, u = s.m13, _ = e._meshBuffer, f = _.request(4, 6), d = f.indiceOffset, m = f.byteOffset >> 2, p = f.vertexOffset, v = _._vData, y = _._uintVData, g = _._iData, x = t._spriteFrame.uv;
v[m + 2] = x[0];
v[m + 3] = x[1];
v[m + 7] = x[2];
v[m + 8] = x[3];
v[m + 12] = x[4];
v[m + 13] = x[5];
v[m + 17] = x[6];
v[m + 18] = x[7];
var C = i[0], A = i[3], b = C.x, S = A.x, T = C.y, w = A.y, E = o * b, B = o * S, M = a * b, D = a * S, I = c * T, P = c * w, R = h * T, L = h * w;
v[m] = E + I + l;
v[m + 1] = M + R + u;
v[m + 5] = B + I + l;
v[m + 6] = D + R + u;
v[m + 10] = E + P + l;
v[m + 11] = M + L + u;
v[m + 15] = B + P + l;
v[m + 16] = D + L + u;
y[m + 4] = r;
y[m + 9] = r;
y[m + 14] = r;
y[m + 19] = r;
g[d++] = p;
g[d++] = p + 1;
g[d++] = p + 2;
g[d++] = p + 1;
g[d++] = p + 3;
g[d++] = p + 2;
},
createData: function(t) {
var e = t.requestRenderData();
e.dataLength = 4;
e.vertexCount = 4;
e.indiceCount = 6;
return e;
},
updateVerts: function(t) {
var e = t._renderData, i = t.node, n = e._data, r = i.width, s = i.height, o = i.anchorX * r, a = i.anchorY * s, c = void 0, h = void 0, l = void 0, u = void 0;
if (t.trim) {
c = -o;
h = -a;
l = r - o;
u = s - a;
} else {
var _ = t.spriteFrame, f = _._originalSize.width, d = _._originalSize.height, m = _._rect.width, p = _._rect.height, v = _._offset, y = r / f, g = s / d, x = v.x + (f - m) / 2, C = v.x - (f - m) / 2, A = v.y + (d - p) / 2, b = v.y - (d - p) / 2;
c = x * y - o;
h = A * g - a;
l = r + C * y - o;
u = s + b * g - a;
}
n[0].x = c;
n[0].y = h;
n[3].x = l;
n[3].y = u;
e.vertDirty = !1;
}
};
}), {} ],
225: [ (function(t, e, i) {
e.exports = {
useModel: !1,
createData: function(t) {
var e = t.requestRenderData();
e.dataLength = 20;
e.vertexCount = 16;
e.indiceCount = 54;
return e;
},
updateRenderData: function(t, e) {
var i = t.spriteFrame;
t._calDynamicAtlas();
var n = t._renderData;
if (n && i) {
if (n.vertDirty) {
this.updateVerts(t);
this.updateWorldVerts(t);
}
}
},
updateVerts: function(t) {
var e = t._renderData, i = e._data, n = t.node, r = n.width, s = n.height, o = n.anchorX * r, a = n.anchorY * s, c = t.spriteFrame, h = c.insetLeft, l = c.insetRight, u = c.insetTop, _ = c.insetBottom, f = r - h - l, d = s - u - _, m = r / (h + l), p = s / (u + _);
m = isNaN(m) || m > 1 ? 1 : m;
p = isNaN(p) || p > 1 ? 1 : p;
f = f < 0 ? 0 : f;
d = d < 0 ? 0 : d;
i[0].x = -o;
i[0].y = -a;
i[1].x = h * m - o;
i[1].y = _ * p - a;
i[2].x = i[1].x + f;
i[2].y = i[1].y + d;
i[3].x = r - o;
i[3].y = s - a;
e.vertDirty = !1;
},
fillBuffers: function(t, e) {
e.worldMatDirty && this.updateWorldVerts(t);
for (var i = t._renderData, n = t.node._color._val, r = i._data, s = e._meshBuffer, o = i.vertexCount, a = t.spriteFrame.uvSliced, c = s.request(o, i.indiceCount), h = c.indiceOffset, l = c.byteOffset >> 2, u = c.vertexOffset, _ = s._vData, f = s._uintVData, d = s._iData, m = 4; m < 20; ++m) {
var p = r[m], v = a[m - 4];
_[l++] = p.x;
_[l++] = p.y;
_[l++] = v.u;
_[l++] = v.v;
f[l++] = n;
}
for (var y = 0; y < 3; ++y) for (var g = 0; g < 3; ++g) {
var x = u + 4 * y + g;
d[h++] = x;
d[h++] = x + 1;
d[h++] = x + 4;
d[h++] = x + 1;
d[h++] = x + 5;
d[h++] = x + 4;
}
},
updateWorldVerts: function(t) {
for (var e = t.node, i = t._renderData._data, n = e._worldMatrix, r = n.m00, s = n.m01, o = n.m04, a = n.m05, c = n.m12, h = n.m13, l = 0; l < 4; ++l) for (var u = i[l], _ = 0; _ < 4; ++_) {
var f = i[_], d = i[4 + 4 * l + _];
d.x = f.x * r + u.y * o + c;
d.y = f.x * s + u.y * a + h;
}
}
};
}), {} ],
226: [ (function(t, e, i) {
e.exports = {
useModel: !1,
createData: function(t) {
return t.requestRenderData();
},
updateRenderData: function(t) {
var e = t.spriteFrame;
t._calDynamicAtlas();
var i = t._renderData;
if (e && i && (i.uvDirty || i.vertDirty)) {
var n = e._texture, r = (n.width, n.height, e._rect), s = t.node, o = Math.abs(s.width), a = Math.abs(s.height), c = s.anchorX * o, h = s.anchorY * a, l = r.width, u = r.height, _ = o / l, f = a / u, d = Math.ceil(f), m = Math.ceil(_), p = i._data;
i.dataLength = Math.max(8, d + 1, m + 1);
for (var v = 0; v <= m; ++v) p[v].x = Math.min(l * v, o) - c;
for (var y = 0; y <= d; ++y) p[y].y = Math.min(u * y, a) - h;
i.vertexCount = d * m * 4;
i.indiceCount = d * m * 6;
i.uvDirty = !1;
i.vertDirty = !1;
}
},
fillBuffers: function(t, e) {
for (var i = t.node, n = i._color._val, r = t._renderData, s = r._data, o = e._meshBuffer, a = o.request(r.vertexCount, r.indiceCount), c = a.indiceOffset, h = a.byteOffset >> 2, l = a.vertexOffset, u = o._vData, _ = o._uintVData, f = o._iData, d = t.spriteFrame._rotated, m = t.spriteFrame.uv, p = t.spriteFrame._rect, v = Math.abs(i.width), y = Math.abs(i.height), g = v / p.width, x = y / p.height, C = Math.ceil(x), A = Math.ceil(g), b = i._worldMatrix, S = b.m00, T = b.m01, w = b.m04, E = b.m05, B = b.m12, M = b.m13, D = void 0, I = void 0, P = void 0, R = void 0, L = void 0, F = void 0, V = 0, O = C; V < O; ++V) {
P = s[V].y;
R = s[V + 1].y;
F = Math.min(1, x - V);
for (var N = 0, k = A; N < k; ++N) {
L = Math.min(1, g - N);
D = s[N].x;
I = s[N + 1].x;
u[h] = D * S + P * w + B;
u[h + 1] = D * T + P * E + M;
u[h + 5] = I * S + P * w + B;
u[h + 6] = I * T + P * E + M;
u[h + 10] = D * S + R * w + B;
u[h + 11] = D * T + R * E + M;
u[h + 15] = I * S + R * w + B;
u[h + 16] = I * T + R * E + M;
if (d) {
u[h + 2] = m[0];
u[h + 3] = m[1];
u[h + 7] = m[0];
u[h + 8] = m[1] + (m[7] - m[1]) * L;
u[h + 12] = m[0] + (m[6] - m[0]) * F;
u[h + 13] = m[1];
u[h + 17] = u[h + 12];
u[h + 18] = u[h + 8];
} else {
u[h + 2] = m[0];
u[h + 3] = m[1];
u[h + 7] = m[0] + (m[6] - m[0]) * L;
u[h + 8] = m[1];
u[h + 12] = m[0];
u[h + 13] = m[1] + (m[7] - m[1]) * F;
u[h + 17] = u[h + 7];
u[h + 18] = u[h + 13];
}
_[h + 4] = n;
_[h + 9] = n;
_[h + 14] = n;
_[h + 19] = n;
h += 20;
}
}
for (var G = r.indiceCount, z = 0; z < G; z += 6) {
f[c++] = l;
f[c++] = l + 1;
f[c++] = l + 2;
f[c++] = l + 1;
f[c++] = l + 3;
f[c++] = l + 2;
l += 4;
}
}
};
}), {} ],
227: [ (function(t, e, i) {
var n = t("../render-engine").gfx, r = cc.Class({
name: "cc.MeshBuffer",
ctor: function(t, e) {
this.byteStart = 0;
this.byteOffset = 0;
this.indiceStart = 0;
this.indiceOffset = 0;
this.vertexStart = 0;
this.vertexOffset = 0;
this._vertexFormat = e;
this._vertexBytes = this._vertexFormat._bytes;
this._arrOffset = 0;
this._vbArr = [];
this._vb = new n.VertexBuffer(t._device, e, n.USAGE_DYNAMIC, new ArrayBuffer(), 0);
this._vbArr[0] = this._vb;
this._ibArr = [];
this._ib = new n.IndexBuffer(t._device, n.INDEX_FMT_UINT16, n.USAGE_STATIC, new ArrayBuffer(), 0);
this._ibArr[0] = this._ib;
this._vData = null;
this._uintVData = null;
this._iData = null;
this._batcher = t;
this._initVDataCount = 256 * e._bytes;
this._initIDataCount = 1536;
this._offsetInfo = {
byteOffset: 0,
vertexOffset: 0,
indiceOffset: 0
};
this._reallocBuffer();
},
uploadData: function() {
if (0 !== this.byteOffset && this._dirty) {
var t = new Float32Array(this._vData.buffer, 0, this.byteOffset >> 2), e = new Uint16Array(this._iData.buffer, 0, this.indiceOffset);
this._vb.update(0, t);
this._ib.update(0, e);
this._dirty = !1;
}
},
checkAndSwitchBuffer: function(t) {
if (this.vertexOffset + t > 65535) {
this.uploadData();
this._batcher._flush();
var e = ++this._arrOffset;
this.byteStart = 0;
this.byteOffset = 0;
this.vertexStart = 0;
this.vertexOffset = 0;
this.indiceStart = 0;
this.indiceOffset = 0;
if (e < this._vbArr.length) {
this._vb = this._vbArr[e];
this._ib = this._ibArr[e];
} else {
this._vb = new n.VertexBuffer(this._batcher._device, this._vertexFormat, n.USAGE_DYNAMIC, new ArrayBuffer(), 0);
this._vbArr[e] = this._vb;
this._vb._bytes = this._vData.byteLength;
this._ib = new n.IndexBuffer(this._batcher._device, n.INDEX_FMT_UINT16, n.USAGE_STATIC, new ArrayBuffer(), 0);
this._ibArr[e] = this._ib;
this._ib._bytes = this._iData.byteLength;
}
}
},
requestStatic: function(t, e) {
this.checkAndSwitchBuffer(t);
var i = this.byteOffset + t * this._vertexBytes, n = this.indiceOffset + e, r = this._vData.byteLength, s = this._iData.length;
if (i > r || n > s) {
for (;r < i || s < n; ) {
this._initVDataCount *= 2;
this._initIDataCount *= 2;
r = 4 * this._initVDataCount;
s = this._initIDataCount;
}
this._reallocBuffer();
}
var o = this._offsetInfo;
o.vertexOffset = this.vertexOffset;
this.vertexOffset += t;
o.indiceOffset = this.indiceOffset;
this.indiceOffset += e;
o.byteOffset = this.byteOffset;
this.byteOffset = i;
this._dirty = !0;
},
request: function(t, e) {
if (this._batcher._buffer !== this) {
this._batcher._flush();
this._batcher._buffer = this;
}
this.requestStatic(t, e);
return this._offsetInfo;
},
_reallocBuffer: function() {
this._reallocVData(!0);
this._reallocIData(!0);
},
_reallocVData: function(t) {
var e = void 0;
this._vData && (e = new Uint8Array(this._vData.buffer));
this._vData = new Float32Array(this._initVDataCount);
this._uintVData = new Uint32Array(this._vData.buffer);
var i = new Uint8Array(this._uintVData.buffer);
if (e && t) for (var n = 0, r = e.length; n < r; n++) i[n] = e[n];
this._vb._bytes = this._vData.byteLength;
},
_reallocIData: function(t) {
var e = this._iData;
this._iData = new Uint16Array(this._initIDataCount);
if (e && t) for (var i = this._iData, n = 0, r = e.length; n < r; n++) i[n] = e[n];
this._ib._bytes = this._iData.byteLength;
},
reset: function() {
this._arrOffset = 0;
this._vb = this._vbArr[0];
this._ib = this._ibArr[0];
this.byteStart = 0;
this.byteOffset = 0;
this.indiceStart = 0;
this.indiceOffset = 0;
this.vertexStart = 0;
this.vertexOffset = 0;
this._dirty = !1;
},
destroy: function() {
for (var t in this._vbArr) {
this._vbArr[t].destroy();
}
this._vbArr = void 0;
for (var e in this._ibArr) {
this._ibArr[e].destroy();
}
this._ibArr = void 0;
this._ib = void 0;
this._vb = void 0;
}
});
cc.MeshBuffer = e.exports = r;
}), {
"../render-engine": 202
} ],
228: [ (function(t, e, i) {
var n = t("../render-engine"), r = t("./vertex-format").vfmtPosUvColor, s = t("./stencil-manager"), o = t("./quad-buffer"), a = t("./mesh-buffer"), c = t("./spine-buffer"), h = new (t("../../platform/id-generater"))("VertextFormat"), l = n.RecyclePool, u = n.InputAssembler, _ = {}, f = new n.Material();
f.updateHash();
var d = function(t, e) {
this._renderScene = e;
this._device = t;
this._stencilMgr = s.sharedManager;
this.walking = !1;
this.material = f;
this.cullingMask = 1;
this._iaPool = new l(function() {
return new u();
}, 16);
this._modelPool = new l(function() {
return new n.Model();
}, 16);
this._quadBuffer = this.getBuffer("quad", r);
this._meshBuffer = this.getBuffer("mesh", r);
this._buffer = this._quadBuffer;
this._batchedModels = [];
this._dummyNode = new cc.Node();
this._sortKey = 0;
this.node = this._dummyNode;
this.parentOpacity = 1;
this.parentOpacityDirty = 0;
this.worldMatDirty = 0;
};
d.prototype = {
constructor: d,
reset: function() {
this._iaPool.reset();
for (var t = this._renderScene, e = this._batchedModels, i = 0; i < e.length; ++i) {
e[i].clearInputAssemblers();
e[i].clearEffects();
t.removeModel(e[i]);
}
this._modelPool.reset();
e.length = 0;
this._sortKey = 0;
for (var n in _) _[n].reset();
this._buffer = this._quadBuffer;
this.node = this._dummyNode;
this.material = f;
this.cullingMask = 1;
this.parentOpacity = 1;
this.parentOpacityDirty = 0;
this.worldMatDirty = 0;
this._stencilMgr.reset();
},
_flush: function() {
var t = this.material, e = this._buffer, i = e.indiceStart, n = e.indiceOffset - i;
if (this.walking && t && !(n <= 0)) {
var r = t.effect, s = this._iaPool.add();
s._vertexBuffer = e._vb;
s._indexBuffer = e._ib;
s._start = i;
s._count = n;
this._stencilMgr.handleEffect(r);
var o = this._modelPool.add();
this._batchedModels.push(o);
o.sortKey = this._sortKey++;
o._cullingMask = this.cullingMask;
o.setNode(this.node);
o.addEffect(r);
o.addInputAssembler(s);
this._renderScene.addModel(o);
e.byteStart = e.byteOffset;
e.indiceStart = e.indiceOffset;
e.vertexStart = e.vertexOffset;
}
},
_flushIA: function(t) {
var e = t.material;
if (t.ia && e) {
this.material = e;
var i = this._stencilMgr.handleEffect(e.effect), n = this._modelPool.add();
this._batchedModels.push(n);
n.sortKey = this._sortKey++;
n._cullingMask = this.cullingMask;
n.setNode(this.node);
n.addEffect(i);
n.addInputAssembler(t.ia);
this._renderScene.addModel(n);
}
},
_commitComp: function(t, e, i) {
if (this.material._hash !== t._material._hash || this.cullingMask !== i) {
this._flush();
this.node = e.useModel ? t.node : this._dummyNode;
this.material = t._material;
this.cullingMask = i;
}
e.fillBuffers(t, this);
},
_commitIA: function(t, e, i) {
this._flush();
this.cullingMask = i;
this.material = t._material;
this.node = e.useModel ? t.node : this._dummyNode;
e.renderIA(t, this);
},
terminate: function() {
cc.dynamicAtlasManager && cc.dynamicAtlasManager.enabled && cc.dynamicAtlasManager.update();
this._flush();
for (var t in _) _[t].uploadData();
this.walking = !1;
},
getBuffer: function(t, e) {
e.name || (e.name = h.getNewId());
var i = t + e.name, n = _[i];
if (!n) {
if ("mesh" === t) n = new a(this, e); else if ("quad" === t) n = new o(this, e); else {
if ("spine" !== t) {
cc.error("Not support buffer type [" + t + "]");
return null;
}
n = new c(this, e);
}
_[i] = n;
}
return n;
}
};
e.exports = d;
}), {
"../../platform/id-generater": 176,
"../render-engine": 202,
"./mesh-buffer": 227,
"./quad-buffer": 229,
"./spine-buffer": 230,
"./stencil-manager": 231,
"./vertex-format": 232
} ],
229: [ (function(t, e, i) {
var n = t("./mesh-buffer"), r = cc.Class({
name: "cc.QuadBuffer",
extends: n,
_fillQuadBuffer: function() {
for (var t = this._initIDataCount / 6, e = this._iData, i = 0, n = 0; i < t; i++) {
var r = 4 * i;
e[n++] = r;
e[n++] = r + 1;
e[n++] = r + 2;
e[n++] = r + 1;
e[n++] = r + 3;
e[n++] = r + 2;
}
var s = new Uint16Array(this._iData.buffer, 0, 6 * t);
this._ib.update(0, s);
},
uploadData: function() {
if (0 !== this.byteOffset && this._dirty) {
var t = new Float32Array(this._vData.buffer, 0, this.byteOffset >> 2);
this._vb.update(0, t);
this._dirty = !1;
}
},
_reallocBuffer: function() {
this._reallocVData(!0);
this._reallocIData();
this._fillQuadBuffer();
}
});
cc.QuadBuffer = e.exports = r;
}), {
"./mesh-buffer": 227
} ],
230: [ (function(t, e, i) {
var n = cc.Class({
name: "cc.SpineBuffer",
extends: t("./mesh-buffer"),
requestStatic: function(t, e) {
this.checkAndSwitchBuffer(t);
var i = this.byteOffset + t * this._vertexBytes, n = this.indiceOffset + e, r = this._vData.byteLength, s = this._iData.length;
if (i > r || n > s) {
for (;r < i || s < n; ) {
this._initVDataCount *= 2;
this._initIDataCount *= 2;
r = 4 * this._initVDataCount;
s = this._initIDataCount;
}
this._reallocBuffer();
}
var o = this._offsetInfo;
o.vertexOffset = this.vertexOffset;
o.indiceOffset = this.indiceOffset;
o.byteOffset = this.byteOffset;
},
adjust: function(t, e) {
this.vertexOffset += t;
this.indiceOffset += e;
this.byteOffset = this.byteOffset + t * this._vertexBytes;
this._dirty = !0;
}
});
cc.SpineBuffer = e.exports = n;
}), {
"./mesh-buffer": 227
} ],
231: [ (function(t, e, i) {
var n = t("../render-engine").gfx, r = cc.Enum({
DISABLED: 0,
CLEAR: 1,
ENTER_LEVEL: 2,
ENABLED: 3,
EXIT_LEVEL: 4
});
function s() {
this._maxLevel = 8;
this._maskStack = [];
this.stage = r.DISABLED;
}
s.prototype = {
constructor: s,
reset: function() {
this._maskStack.length = 0;
this.stage = r.DISABLED;
},
handleEffect: function(t) {
var e = t.getTechnique("transparent").passes;
if (this.stage === r.DISABLED) {
this.stage = r.DISABLED;
for (var i = 0; i < e.length; ++i) {
var s = e[i];
s._stencilTest && s.disableStencilTest();
}
return t;
}
var o = void 0, a = void 0, c = void 0, h = void 0, l = void 0, u = void 0, _ = n.STENCIL_OP_KEEP, f = n.STENCIL_OP_KEEP;
if (this.stage === r.ENABLED) {
o = this._maskStack[this._maskStack.length - 1];
a = n.DS_FUNC_EQUAL;
u = n.STENCIL_OP_KEEP;
h = c = this.getStencilRef();
l = this.getWriteMask();
} else if (this.stage === r.CLEAR) {
o = this._maskStack[this._maskStack.length - 1];
a = n.DS_FUNC_NEVER;
u = o.inverted ? n.STENCIL_OP_REPLACE : n.STENCIL_OP_ZERO;
h = c = this.getWriteMask();
l = c;
} else if (this.stage === r.ENTER_LEVEL) {
o = this._maskStack[this._maskStack.length - 1];
a = n.DS_FUNC_NEVER;
u = o.inverted ? n.STENCIL_OP_ZERO : n.STENCIL_OP_REPLACE;
h = c = this.getWriteMask();
l = c;
}
for (var d = 0; d < e.length; ++d) {
var m = e[d];
m.setStencilFront(a, c, h, u, _, f, l);
m.setStencilBack(a, c, h, u, _, f, l);
}
return t;
},
pushMask: function(t) {
this._maskStack.length + 1 > this._maxLevel && cc.errorID(9e3, this._maxLevel);
this._maskStack.push(t);
},
clear: function() {
this.stage = r.CLEAR;
},
enterLevel: function() {
this.stage = r.ENTER_LEVEL;
},
enableMask: function() {
this.stage = r.ENABLED;
},
exitMask: function() {
0 === this._maskStack.length && cc.errorID(9001);
this._maskStack.pop();
0 === this._maskStack.length ? this.stage = r.DISABLED : this.stage = r.ENABLED;
},
getWriteMask: function() {
return 1 << this._maskStack.length - 1;
},
getExitWriteMask: function() {
return 1 << this._maskStack.length;
},
getStencilRef: function() {
for (var t = 0, e = 0; e < this._maskStack.length; ++e) t += 1 << e;
return t;
},
getInvertedRef: function() {
for (var t = 0, e = 0; e < this._maskStack.length - 1; ++e) t += 1 << e;
return t;
}
};
s.sharedManager = new s();
s.Stage = r;
e.exports = cc.StencilManager = s;
}), {
"../render-engine": 202
} ],
232: [ (function(t, e, i) {
var n = t("../render-engine").gfx, r = new n.VertexFormat([ {
name: n.ATTR_POSITION,
type: n.ATTR_TYPE_FLOAT32,
num: 3
}, {
name: n.ATTR_UV0,
type: n.ATTR_TYPE_FLOAT32,
num: 2
}, {
name: n.ATTR_COLOR,
type: n.ATTR_TYPE_UINT8,
num: 4,
normalize: !0
} ]);
r.name = "vfmt3D";
n.VertexFormat.XYZ_UV_Color = r;
var s = new n.VertexFormat([ {
name: n.ATTR_POSITION,
type: n.ATTR_TYPE_FLOAT32,
num: 2
}, {
name: n.ATTR_UV0,
type: n.ATTR_TYPE_FLOAT32,
num: 2
}, {
name: n.ATTR_COLOR,
type: n.ATTR_TYPE_UINT8,
num: 4,
normalize: !0
} ]);
s.name = "vfmtPosUvColor";
n.VertexFormat.XY_UV_Color = s;
var o = new n.VertexFormat([ {
name: n.ATTR_POSITION,
type: n.ATTR_TYPE_FLOAT32,
num: 2
}, {
name: n.ATTR_UV0,
type: n.ATTR_TYPE_FLOAT32,
num: 2
}, {
name: n.ATTR_COLOR,
type: n.ATTR_TYPE_UINT8,
num: 4,
normalize: !0
}, {
name: n.ATTR_COLOR0,
type: n.ATTR_TYPE_UINT8,
num: 4,
normalize: !0
} ]);
o.name = "vfmtPosUvTwoColor";
n.VertexFormat.XY_UV_Two_Color = o;
var a = new n.VertexFormat([ {
name: n.ATTR_POSITION,
type: n.ATTR_TYPE_FLOAT32,
num: 2
}, {
name: n.ATTR_UV0,
type: n.ATTR_TYPE_FLOAT32,
num: 2
} ]);
a.name = "vfmtPosUv";
n.VertexFormat.XY_UV = a;
var c = new n.VertexFormat([ {
name: n.ATTR_POSITION,
type: n.ATTR_TYPE_FLOAT32,
num: 2
}, {
name: n.ATTR_COLOR,
type: n.ATTR_TYPE_UINT8,
num: 4,
normalize: !0
} ]);
c.name = "vfmtPosColor";
n.VertexFormat.XY_Color = c;
e.exports = {
vfmt3D: r,
vfmtPosUvColor: s,
vfmtPosUvTwoColor: o,
vfmtPosUv: a,
vfmtPosColor: c
};
}), {
"../render-engine": 202
} ],
233: [ (function(t, e, i) {
t("../platform/CCSys");
var n = /(\.[^\.\/\?\\]*)(\?.*)?$/, r = /((.*)(\/|\\|\\\\))?(.*?\..*$)?/, s = /[^\.\/]+\/\.\.\//;
cc.path = {
join: function() {
for (var t = arguments.length, e = "", i = 0; i < t; i++) e = (e + ("" === e ? "" : "/") + arguments[i]).replace(/(\/|\\\\)$/, "");
return e;
},
extname: function(t) {
var e = n.exec(t);
return e ? e[1] : "";
},
mainFileName: function(t) {
if (t) {
var e = t.lastIndexOf(".");
if (-1 !== e) return t.substring(0, e);
}
return t;
},
basename: function(t, e) {
var i = t.indexOf("?");
i > 0 && (t = t.substring(0, i));
var n = /(\/|\\)([^\/\\]+)$/g.exec(t.replace(/(\/|\\)$/, ""));
if (!n) return null;
var r = n[2];
return e && t.substring(t.length - e.length).toLowerCase() === e.toLowerCase() ? r.substring(0, r.length - e.length) : r;
},
dirname: function(t) {
var e = r.exec(t);
return e ? e[2] : "";
},
changeExtname: function(t, e) {
e = e || "";
var i = t.indexOf("?"), n = "";
if (i > 0) {
n = t.substring(i);
t = t.substring(0, i);
}
return (i = t.lastIndexOf(".")) < 0 ? t + e + n : t.substring(0, i) + e + n;
},
changeBasename: function(t, e, i) {
if (0 === e.indexOf(".")) return this.changeExtname(t, e);
var n = t.indexOf("?"), r = "", s = i ? this.extname(t) : "";
if (n > 0) {
r = t.substring(n);
t = t.substring(0, n);
}
n = (n = t.lastIndexOf("/")) <= 0 ? 0 : n + 1;
return t.substring(0, n) + e + s + r;
},
_normalize: function(t) {
var e = t = String(t);
do {
e = t;
t = t.replace(s, "");
} while (e.length !== t.length);
return t;
},
sep: cc.sys.os === cc.sys.OS_WINDOWS ? "\\" : "/",
stripSep: function(t) {
return t.replace(/[\/\\]$/, "");
}
};
e.exports = cc.path;
}), {
"../platform/CCSys": 169
} ],
234: [ (function(t, e, i) {
var n = function(t, e, i, n, r, s) {
this.a = t;
this.b = e;
this.c = i;
this.d = n;
this.tx = r;
this.ty = s;
};
n.create = function(t, e, i, n, r, s) {
return {
a: t,
b: e,
c: i,
d: n,
tx: r,
ty: s
};
};
n.identity = function() {
return {
a: 1,
b: 0,
c: 0,
d: 1,
tx: 0,
ty: 0
};
};
n.clone = function(t) {
return {
a: t.a,
b: t.b,
c: t.c,
d: t.d,
tx: t.tx,
ty: t.ty
};
};
n.concat = function(t, e, i) {
var n = e.a, r = e.b, s = e.c, o = e.d, a = e.tx, c = e.ty;
t.a = n * i.a + r * i.c;
t.b = n * i.b + r * i.d;
t.c = s * i.a + o * i.c;
t.d = s * i.b + o * i.d;
t.tx = a * i.a + c * i.c + i.tx;
t.ty = a * i.b + c * i.d + i.ty;
return t;
};
n.invert = function(t, e) {
var i = e.a, n = e.b, r = e.c, s = e.d, o = 1 / (i * s - n * r), a = e.tx, c = e.ty;
t.a = o * s;
t.b = -o * n;
t.c = -o * r;
t.d = o * i;
t.tx = o * (r * c - s * a);
t.ty = o * (n * a - i * c);
return t;
};
n.fromMat4 = function(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;
return t;
};
n.transformVec2 = function(t, e, i, n) {
var r, s;
if (void 0 === n) {
n = i;
r = e.x;
s = e.y;
} else {
r = e;
s = i;
}
t.x = n.a * r + n.c * s + n.tx;
t.y = n.b * r + n.d * s + n.ty;
return t;
};
n.transformSize = function(t, e, i) {
t.width = i.a * e.width + i.c * e.height;
t.height = i.b * e.width + i.d * e.height;
return t;
};
n.transformRect = function(t, e, i) {
var n = e.x, r = e.y, s = n + e.width, o = r + e.height, a = i.a * n + i.c * r + i.tx, c = i.b * n + i.d * r + i.ty, h = i.a * s + i.c * r + i.tx, l = i.b * s + i.d * r + i.ty, u = i.a * n + i.c * o + i.tx, _ = i.b * n + i.d * o + i.ty, f = i.a * s + i.c * o + i.tx, d = i.b * s + i.d * o + i.ty, m = Math.min(a, h, u, f), p = Math.max(a, h, u, f), v = Math.min(c, l, _, d), y = Math.max(c, l, _, d);
t.x = m;
t.y = v;
t.width = p - m;
t.height = y - v;
return t;
};
n.transformObb = function(t, e, i, n, r, s) {
var o = r.x, a = r.y, c = r.width, h = r.height, l = s.a * o + s.c * a + s.tx, u = s.b * o + s.d * a + s.ty, _ = s.a * c, f = s.b * c, d = s.c * h, m = s.d * h;
e.x = l;
e.y = u;
i.x = _ + l;
i.y = f + u;
t.x = d + l;
t.y = m + u;
n.x = _ + d + l;
n.y = f + m + u;
};
cc.AffineTransform = e.exports = n;
}), {} ],
235: [ (function(i, n, r) {
var s = i("../platform/CCObject").Flags, o = i("./misc"), a = i("../platform/js"), c = i("../platform/id-generater"), h = i("../event-manager"), l = i("../renderer/render-flow"), u = s.Destroying, _ = s.DontDestroy, f = s.Deactivating, d = new c("Node");
function m(i) {
if (!i) {
cc.errorID(3804);
return null;
}
return "string" === ("object" === (e = typeof i) ? t(i) : e) ? a.getClassByName(i) : i;
}
function p(t, e) {
if (e._sealed) for (var i = 0; i < t._components.length; ++i) {
var n = t._components[i];
if (n.constructor === e) return n;
} else for (var r = 0; r < t._components.length; ++r) {
var s = t._components[r];
if (s instanceof e) return s;
}
return null;
}
function v(t, e, i) {
if (e._sealed) for (var n = 0; n < t._components.length; ++n) {
var r = t._components[n];
r.constructor === e && i.push(r);
} else for (var s = 0; s < t._components.length; ++s) {
var o = t._components[s];
o instanceof e && i.push(o);
}
}
var y = cc.Class({
name: "cc._BaseNode",
extends: cc.Object,
properties: {
_parent: null,
_children: [],
_active: !0,
_level: 0,
_components: [],
_prefab: null,
_persistNode: {
get: function() {
return (this._objFlags & _) > 0;
},
set: function(t) {
t ? this._objFlags |= _ : this._objFlags &= ~_;
}
},
name: {
get: function() {
return this._name;
},
set: function(t) {
0;
this._name = t;
}
},
uuid: {
get: function() {
return this._id;
}
},
children: {
get: function() {
return this._children;
}
},
childrenCount: {
get: function() {
return this._children.length;
}
},
active: {
get: function() {
return this._active;
},
set: function(t) {
t = !!t;
if (this._active !== t) {
this._active = t;
var e = this._parent;
if (e) {
e._activeInHierarchy && cc.director._nodeActivator.activateNode(this, t);
}
}
}
},
activeInHierarchy: {
get: function() {
return this._activeInHierarchy;
}
}
},
ctor: function(t) {
this._name = void 0 !== t ? t : "New Node";
this._activeInHierarchy = !1;
this._id = d.getNewId();
cc.director._scheduler && cc.director._scheduler.enableForTarget(this);
this.__eventTargets = [];
this._renderFlag = l.FLAG_TRANSFORM;
},
getParent: function() {
return this._parent;
},
setParent: function(t) {
if (this._parent !== t) {
0;
var e = this._parent;
0;
this._parent = t || null;
this._onSetParent(t);
if (t) {
0;
this._level = t._level + 1;
h._setDirtyForNode(this);
t._children.push(this);
t.emit && t.emit("child-added", this);
t._renderFlag |= l.FLAG_CHILDREN;
}
if (e) {
if (!(e._objFlags & u)) {
var i = e._children.indexOf(this);
0;
e._children.splice(i, 1);
e.emit && e.emit("child-removed", this);
this._onHierarchyChanged(e);
0 === e._children.length && (e._renderFlag &= ~l.FLAG_CHILDREN);
}
} else t && this._onHierarchyChanged(null);
}
},
attr: function(t) {
a.mixin(this, t);
},
getChildByUuid: function(t) {
if (!t) {
cc.log("Invalid uuid");
return null;
}
for (var e = this._children, i = 0, n = e.length; i < n; i++) if (e[i]._id === t) return e[i];
return null;
},
getChildByName: function(t) {
if (!t) {
cc.log("Invalid name");
return null;
}
for (var e = this._children, i = 0, n = e.length; i < n; i++) if (e[i]._name === t) return e[i];
return null;
},
addChild: function(t) {
0;
cc.assertID(t, 1606);
cc.assertID(null === t._parent, 1605);
t.setParent(this);
},
insertChild: function(t, e) {
t.parent = this;
t.setSiblingIndex(e);
},
getSiblingIndex: function() {
return this._parent ? this._parent._children.indexOf(this) : 0;
},
setSiblingIndex: function(t) {
if (this._parent) if (this._parent._objFlags & f) cc.errorID(3821); else {
var e = this._parent._children;
t = -1 !== t ? t : e.length - 1;
var i = e.indexOf(this);
if (t !== i) {
e.splice(i, 1);
t < e.length ? e.splice(t, 0, this) : e.push(this);
this._onSiblingIndexChanged && this._onSiblingIndexChanged(t);
}
}
},
walk: function(t, e) {
var i, n, r, s, o = cc._BaseNode, a = 1, c = o._stacks[o._stackId];
if (!c) {
c = [];
o._stacks.push(c);
}
o._stackId++;
c.length = 0;
c[0] = this;
var h = null;
s = !1;
for (;a; ) if (n = c[--a]) {
!s && t ? t(n) : s && e && e(n);
c[a] = null;
if (s) {
s = !1;
if (i) if (i[++r]) {
c[a] = i[r];
a++;
} else if (h) {
c[a] = h;
a++;
s = !0;
if (h._parent) {
r = (i = h._parent._children).indexOf(h);
h = h._parent;
} else {
h = null;
i = null;
}
if (r < 0) break;
}
} else if (n._children.length > 0) {
h = n;
i = n._children;
r = 0;
c[a] = i[r];
a++;
} else {
c[a] = n;
a++;
s = !0;
}
}
c.length = 0;
o._stackId--;
},
cleanup: function() {},
removeFromParent: function(t) {
if (this._parent) {
void 0 === t && (t = !0);
this._parent.removeChild(this, t);
}
},
removeChild: function(t, e) {
if (this._children.indexOf(t) > -1) {
(e || void 0 === e) && t.cleanup();
t.parent = null;
}
},
removeAllChildren: function(t) {
var e = this._children;
void 0 === t && (t = !0);
for (var i = e.length - 1; i >= 0; i--) {
var n = e[i];
if (n) {
t && n.cleanup();
n.parent = null;
}
}
this._children.length = 0;
},
isChildOf: function(t) {
var e = this;
do {
if (e === t) return !0;
e = e._parent;
} while (e);
return !1;
},
getComponent: function(t) {
var e = m(t);
return e ? p(this, e) : null;
},
getComponents: function(t) {
var e = m(t), i = [];
e && v(this, e, i);
return i;
},
getComponentInChildren: function(t) {
var e = m(t);
return e ? (function t(e, i) {
for (var n = 0; n < e.length; ++n) {
var r = e[n], s = p(r, i);
if (s) return s;
if (r._children.length > 0 && (s = t(r._children, i))) return s;
}
return null;
})(this._children, e) : null;
},
getComponentsInChildren: function(t) {
var e = m(t), i = [];
if (e) {
v(this, e, i);
(function t(e, i, n) {
for (var r = 0; r < e.length; ++r) {
var s = e[r];
v(s, i, n);
s._children.length > 0 && t(s._children, i, n);
}
})(this._children, e, i);
}
return i;
},
_checkMultipleComp: !1,
addComponent: function(i) {
0;
var n;
if ("string" === ("object" === (e = typeof i) ? t(i) : e)) {
if (!(n = a.getClassByName(i))) {
cc.errorID(3807, i);
cc._RFpeek() && cc.errorID(3808, i);
return null;
}
} else {
if (!i) {
cc.errorID(3804);
return null;
}
n = i;
}
if ("function" !== ("object" === (e = typeof n) ? t(n) : e)) {
cc.errorID(3809);
return null;
}
if (!a.isChildClassOf(n, cc.Component)) {
cc.errorID(3810);
return null;
}
0;
var r = n._requireComponent;
if (r && !this.getComponent(r)) {
if (!this.addComponent(r)) return null;
}
var s = new n();
s.node = this;
this._components.push(s);
0;
this._activeInHierarchy && cc.director._nodeActivator.activateComp(s);
return s;
},
_addComponentAt: !1,
removeComponent: function(t) {
if (t) {
t instanceof cc.Component || (t = this.getComponent(t));
t && t.destroy();
} else cc.errorID(3813);
},
_getDependComponent: !1,
_removeComponent: function(t) {
if (t) {
if (!(this._objFlags & u)) {
var e = this._components.indexOf(t);
if (-1 !== e) {
this._components.splice(e, 1);
0;
} else t.node !== this && cc.errorID(3815);
}
} else cc.errorID(3814);
},
destroy: function() {
cc.Object.prototype.destroy.call(this) && (this.active = !1);
},
destroyAllChildren: function() {
for (var t = this._children, e = 0; e < t.length; ++e) t[e].destroy();
},
_onSetParent: function(t) {},
_onPostActivated: function() {},
_onBatchRestored: function() {},
_onBatchCreated: function() {},
_onHierarchyChanged: function(t) {
var e = this._parent;
if (this._persistNode && !(e instanceof cc.Scene)) {
cc.game.removePersistRootNode(this);
0;
}
var i = this._active && !(!e || !e._activeInHierarchy);
this._activeInHierarchy !== i && cc.director._nodeActivator.activateNode(this, i);
},
_instantiate: function(t) {
t || (t = cc.instantiate._clone(this, this));
var e = this._prefab;
e && this === e.root && e.sync;
t._parent = null;
t._onBatchRestored();
return t;
},
_registerIfAttached: !1,
_onPreDestroy: function() {
var t, e;
this._objFlags |= u;
var i = this._parent, n = i && i._objFlags & u;
0;
var r = this._children;
for (t = 0, e = r.length; t < e; ++t) r[t]._destroyImmediate();
for (t = 0, e = this._components.length; t < e; ++t) {
this._components[t]._destroyImmediate();
}
var s = this.__eventTargets;
for (t = 0, e = s.length; t < e; ++t) {
var o = s[t];
o && o.targetOff(this);
}
s.length = 0;
this._persistNode && cc.game.removePersistRootNode(this);
if (!n && i) {
var a = i._children.indexOf(this);
i._children.splice(a, 1);
i.emit && i.emit("child-removed", this);
}
return n;
},
onRestore: !1
});
y.idGenerater = d;
y._stacks = [ [] ];
y._stackId = 0;
y.prototype._onPreDestroyBase = y.prototype._onPreDestroy;
0;
y.prototype._onHierarchyChangedBase = y.prototype._onHierarchyChanged;
0;
o.propertyDefine(y, [ "parent", "name", "children", "childrenCount" ], {});
0;
cc._BaseNode = n.exports = y;
}), {
"../event-manager": 100,
"../platform/CCObject": 166,
"../platform/id-generater": 176,
"../platform/js": 180,
"../renderer/render-flow": 203,
"./misc": 242
} ],
236: [ (function(t, e, i) {
var n = 1e-6;
e.exports = {
binarySearchEpsilon: function(t, e) {
for (var i = 0, r = t.length - 1, s = r >>> 1; i <= r; s = i + r >>> 1) {
var o = t[s];
if (o > e + n) r = s - 1; else {
if (!(o < e - n)) return s;
i = s + 1;
}
}
return ~i;
}
};
}), {} ],
237: [ (function(t, e, i) {
var n = t("./misc").BASE64_VALUES, r = "0123456789abcdef".split(""), s = [ "", "", "", "" ], o = s.concat(s, "-", s, "-", s, "-", s, "-", s, s, s), a = o.map((function(t, e) {
return "-" === t ? NaN : e;
})).filter(isFinite);
e.exports = function(t) {
if (22 !== t.length) return t;
o[0] = t[0];
o[1] = t[1];
for (var e = 2, i = 2; e < 22; e += 2) {
var s = n[t.charCodeAt(e)], c = n[t.charCodeAt(e + 1)];
o[a[i++]] = r[s >> 2];
o[a[i++]] = r[(3 & s) << 2 | c >> 4];
o[a[i++]] = r[15 & c];
}
return o.join("");
};
0;
}), {
"./misc": 242
} ],
238: [ (function(t, e, i) {
cc.find = e.exports = function(t, e) {
if (null == t) {
cc.errorID(5600);
return null;
}
if (e) 0; else {
var i = cc.director.getScene();
if (!i) {
0;
return null;
}
0;
e = i;
}
for (var n = e, r = "/" !== t[0] ? 0 : 1, s = t.split("/"), o = r; o < s.length; o++) {
var a = s[o], c = n._children;
n = null;
for (var h = 0, l = c.length; h < l; ++h) {
var u = c[h];
if (u.name === a) {
n = u;
break;
}
}
if (!n) return null;
}
return n;
};
}), {} ],
239: [ (function(t, e, i) {
var n = /^(click)(\s)*=|(param)(\s)*=/, r = /(\s)*src(\s)*=|(\s)*height(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/, s = function() {
this._parsedObject = {};
this._specialSymbolArray = [];
this._specialSymbolArray.push([ /&lt;/g, "<" ]);
this._specialSymbolArray.push([ /&gt;/g, ">" ]);
this._specialSymbolArray.push([ /&amp;/g, "&" ]);
this._specialSymbolArray.push([ /&quot;/g, '"' ]);
this._specialSymbolArray.push([ /&apos;/g, "'" ]);
};
s.prototype = {
constructor: s,
parse: function(t) {
this._resultObjectArray = [];
this._stack = [];
for (var e = 0, i = t.length; e < i; ) {
var n = t.indexOf("<", e);
if (n < 0) {
this._stack.pop();
this._processResult(t.substring(e));
e = i;
} else {
this._processResult(t.substring(e, n));
var r = t.indexOf(">", e);
-1 === r ? r = n : "/" === t.charAt(n + 1) ? this._stack.pop() : this._addToStack(t.substring(n + 1, r));
e = r + 1;
}
}
return this._resultObjectArray;
},
_attributeToObject: function(t) {
var e, i, n, s, o = {}, a = (t = t.trim()).match(/^(color|size)(\s)*=/);
if (a) {
e = a[0];
if ("" === (t = t.substring(e.length).trim())) return o;
i = t.indexOf(" ");
switch (e[0]) {
case "c":
o.color = i > -1 ? t.substring(0, i).trim() : t;
break;

case "s":
o.size = parseInt(t);
}
if (i > -1) {
s = t.substring(i + 1).trim();
n = this._processEventHandler(s);
o.event = n;
}
return o;
}
if ((a = t.match(/^(br(\s)*\/)/)) && a[0].length > 0 && (e = a[0].trim()).startsWith("br") && "/" === e[e.length - 1]) {
o.isNewLine = !0;
this._resultObjectArray.push({
text: "",
style: {
newline: !0
}
});
return o;
}
if ((a = t.match(/^(img(\s)*src(\s)*=[^>]+\/)/)) && a[0].length > 0 && (e = a[0].trim()).startsWith("img") && "/" === e[e.length - 1]) {
a = t.match(r);
for (var c, h = !1; a; ) {
e = (t = t.substring(t.indexOf(a[0]))).substr(0, a[0].length);
u = (i = (c = t.substring(e.length).trim()).indexOf(" ")) > -1 ? c.substr(0, i) : c;
e = (e = e.replace(/[^a-zA-Z]/g, "").trim()).toLocaleLowerCase();
t = c.substring(i).trim();
if ("src" === e) {
o.isImage = !0;
u.endsWith("/") && (u = u.substring(0, u.length - 1));
if (0 === u.indexOf("'")) {
h = !0;
u = u.substring(1, u.length - 1);
} else if (0 === u.indexOf('"')) {
h = !0;
u = u.substring(1, u.length - 1);
}
o.src = u;
} else "height" === e ? o.imageHeight = parseInt(u) : "width" === e ? o.imageWidth = parseInt(u) : "click" === e && (o.event = this._processEventHandler(e + "=" + u));
o.event && "param" === e && (o.event.param = u.replace(/^\"|\"$/g, ""));
a = t.match(r);
}
h && o.isImage && this._resultObjectArray.push({
text: "",
style: o
});
return {};
}
if (a = t.match(/^(outline(\s)*[^>]*)/)) {
var l = {
color: "#ffffff",
width: 1
};
if (t = a[0].substring("outline".length).trim()) {
var u, _ = /(\s)*color(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;
a = t.match(_);
for (;a; ) {
e = (t = t.substring(t.indexOf(a[0]))).substr(0, a[0].length);
u = (i = (c = t.substring(e.length).trim()).indexOf(" ")) > -1 ? c.substr(0, i) : c;
e = (e = e.replace(/[^a-zA-Z]/g, "").trim()).toLocaleLowerCase();
t = c.substring(i).trim();
"click" === e ? o.event = this._processEventHandler(e + "=" + u) : "color" === e ? l.color = u : "width" === e && (l.width = parseInt(u));
o.event && "param" === e && (o.event.param = u.replace(/^\"|\"$/g, ""));
a = t.match(_);
}
}
o.outline = l;
}
if ((a = t.match(/^(on|u|b|i)(\s)*/)) && a[0].length > 0) {
e = a[0];
t = t.substring(e.length).trim();
switch (e[0]) {
case "u":
o.underline = !0;
break;

case "i":
o.italic = !0;
break;

case "b":
o.bold = !0;
}
if ("" === t) return o;
n = this._processEventHandler(t);
o.event = n;
}
return o;
},
_processEventHandler: function(t) {
for (var e = 0, i = {}, r = t.match(n), s = !1; r; ) {
var o = r[0], a = "";
s = !1;
if ('"' === (t = t.substring(o.length).trim()).charAt(0)) {
if ((e = t.indexOf('"', 1)) > -1) {
a = t.substring(1, e).trim();
s = !0;
}
e++;
} else if ("'" === t.charAt(0)) {
if ((e = t.indexOf("'", 1)) > -1) {
a = t.substring(1, e).trim();
s = !0;
}
e++;
} else {
var c = t.match(/(\S)+/);
e = (a = c ? c[0] : "").length;
}
s && (i[o = o.substring(0, o.length - 1).trim()] = a);
r = (t = t.substring(e).trim()).match(n);
}
return i;
},
_addToStack: function(t) {
var e = this._attributeToObject(t);
if (0 === this._stack.length) this._stack.push(e); else {
if (e.isNewLine || e.isImage) return;
var i = this._stack[this._stack.length - 1];
for (var n in i) e[n] || (e[n] = i[n]);
this._stack.push(e);
}
},
_processResult: function(t) {
if ("" !== t) {
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: function(t) {
for (var e = 0; e < this._specialSymbolArray.length; ++e) {
var i = this._specialSymbolArray[e][0], n = this._specialSymbolArray[e][1];
t = t.replace(i, n);
}
return t;
}
};
0;
e.exports = s;
}), {} ],
240: [ (function(t, e, i) {
t("./CCPath");
t("./profiler/CCProfiler");
t("./find");
t("./mutable-forward-iterator");
}), {
"./CCPath": 233,
"./find": 238,
"./mutable-forward-iterator": 243,
"./profiler/CCProfiler": 246
} ],
241: [ (function(t, e, i) {
var n = t("../platform/js"), r = t("../renderer/render-engine").math, s = new n.Pool(128);
s.get = function() {
var t = this._get();
t ? r.mat4.identity(t) : t = r.mat4.create();
return t;
};
var o = new n.Pool(64);
o.get = function() {
var t = this._get();
if (t) {
t.x = t.y = t.z = 0;
t.w = 1;
} else t = r.quat.create();
return t;
};
e.exports = {
mat4: s,
quat: o
};
}), {
"../platform/js": 180,
"../renderer/render-engine": 202
} ],
242: [ (function(t, e, i) {
var n = t("../platform/js"), r = {
propertyDefine: function(t, e, i) {
function r(t, e, i, r) {
var s = Object.getOwnPropertyDescriptor(t, e);
if (s) {
s.get && (t[i] = s.get);
s.set && r && (t[r] = s.set);
} else {
var o = t[i];
n.getset(t, e, o, t[r]);
}
}
for (var s, o = t.prototype, a = 0; a < e.length; a++) {
var c = (s = e[a])[0].toUpperCase() + s.slice(1);
r(o, s, "get" + c, "set" + c);
}
for (s in i) {
var h = i[s];
r(o, s, h[0], h[1]);
}
},
NextPOT: function(t) {
t -= 1;
t |= t >> 1;
t |= t >> 2;
t |= t >> 4;
t |= t >> 8;
return (t |= t >> 16) + 1;
}
};
0;
r.BUILTIN_CLASSID_RE = /^(?:cc|dragonBones|sp|ccsg)\..+/;
for (var s = new Array(123), o = 0; o < 123; ++o) s[o] = 64;
for (var a = 0; a < 64; ++a) s["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charCodeAt(a)] = a;
r.BASE64_VALUES = s;
r.pushToMap = function(t, e, i, n) {
var r = t[e];
if (r) if (Array.isArray(r)) if (n) {
r.push(r[0]);
r[0] = i;
} else r.push(i); else t[e] = n ? [ i, r ] : [ r, i ]; else t[e] = i;
};
r.clampf = function(t, e, i) {
if (e > i) {
var n = e;
e = i;
i = n;
}
return t < e ? e : t < i ? t : i;
};
r.clamp01 = function(t) {
return t < 0 ? 0 : t < 1 ? t : 1;
};
r.lerp = function(t, e, i) {
return t + (e - t) * i;
};
r.degreesToRadians = function(t) {
return t * cc.macro.RAD;
};
r.radiansToDegrees = function(t) {
return t * cc.macro.DEG;
};
cc.misc = e.exports = r;
}), {
"../platform/js": 180
} ],
243: [ (function(t, e, i) {
function n(t) {
this.i = 0;
this.array = t;
}
var r = n.prototype;
r.remove = function(t) {
var e = this.array.indexOf(t);
e >= 0 && this.removeAt(e);
};
r.removeAt = function(t) {
this.array.splice(t, 1);
t <= this.i && --this.i;
};
r.fastRemove = function(t) {
var e = this.array.indexOf(t);
e >= 0 && this.fastRemoveAt(e);
};
r.fastRemoveAt = function(t) {
var e = this.array;
e[t] = e[e.length - 1];
--e.length;
t <= this.i && --this.i;
};
r.push = function(t) {
this.array.push(t);
};
e.exports = n;
}), {} ],
244: [ (function(i, n, r) {
var s = i("../CCNode"), o = s.EventType, a = s._LocalDirtyFlag, c = i("../renderer/render-engine").math, h = i("../renderer/render-flow"), l = Math.PI / 180, u = 1, _ = 2, f = 4, d = null, m = null;
function p() {
if (this._localMatDirty) {
var t = this._matrix;
c.mat4.fromRTS(t, this._quat, this._position, this._scale);
if (this._skewX || this._skewY) {
var e = t.m00, i = t.m01, n = t.m04, r = t.m05, s = Math.tan(this._skewX * l), o = Math.tan(this._skewY * l);
Infinity === s && (s = 99999999);
Infinity === o && (o = 99999999);
t.m00 = e + n * o;
t.m01 = i + r * o;
t.m04 = n + e * s;
t.m05 = r + i * s;
}
this._localMatDirty = 0;
this._worldMatDirty = !0;
}
}
function v() {
this._localMatDirty && this._updateLocalMatrix();
if (this._parent) {
var t = this._parent._worldMatrix;
c.mat4.mul(this._worldMatrix, t, this._matrix);
} else c.mat4.copy(this._worldMatrix, this._matrix);
this._worldMatDirty = !1;
}
function y() {
return new cc.Vec3(this._position);
}
function g(t, e, i) {
var n = void 0;
if (void 0 === e) {
n = t.x;
e = t.y;
i = t.z || 0;
} else {
n = t;
i = i || 0;
}
var r = this._position;
if (r.x !== n || r.y !== e || r.z !== i) {
r.x = n;
r.y = e;
r.z = i;
this.setLocalDirty(a.POSITION);
this._renderFlag |= h.FLAG_WORLD_TRANSFORM;
this._eventMask & u && this.emit(o.POSITION_CHANGED);
}
}
function x() {
return c.quat.clone(this._quat);
}
function C(t, e, i, n) {
var r = void 0;
if (void 0 === e) {
r = t.x;
e = t.y;
i = t.z;
n = t.w;
}
var s = this._quat;
if (s.x !== r || s.y !== e || s.z !== i || s.w !== n) {
s.x = r;
s.y = e;
s.z = i;
s.w = n;
this.setLocalDirty(a.ROTATION);
this._renderFlag |= h.FLAG_TRANSFORM;
this._eventMask & f && this.emit(o.ROTATION_CHANGED);
}
}
function A() {
return cc.v3(this._scale);
}
function b(i, n, r) {
if (i && "number" !== ("object" === (e = typeof i) ? t(i) : e)) {
n = i.y;
r = i.z || 1;
i = i.x;
} else if (void 0 !== i && void 0 === n) {
n = i;
r = i;
} else void 0 === r && (r = 1);
if (this._scale.x !== i || this._scale.y !== n || this._scale.z !== r) {
this._scale.x = i;
this._scale.y = n;
this._scale.z = r;
this.setLocalDirty(a.SCALE);
this._renderFlag |= h.FLAG_TRANSFORM;
this._eventMask & _ && this.emit(o.SCALE_CHANGED);
}
}
cc._polyfill3D = n.exports = {
enabled: !1,
enable: function() {
var t = cc.Node.prototype;
if (!d) {
d = t._updateLocalMatrix;
m = t._calculWorldMatrix;
}
if (!this.enabled) {
t._updateLocalMatrix = p;
t._calculWorldMatrix = v;
t.getPosition = y;
t.setPosition = g;
t.getScale = A;
t.setScale = b;
t.getQuat = x;
t.setQuat = C;
this.enabled = !0;
}
},
disable: function() {
if (this.enabled) {
cc.Node.prototype._updateLocalMatrix = d;
cc.Node.prototype._calculWorldMatrix = m;
this.enabled = !1;
}
}
};
}), {
"../CCNode": 29,
"../renderer/render-engine": 202,
"../renderer/render-flow": 203
} ],
245: [ (function(t, e, i) {
var n = t("../renderer").renderEngine.math;
cc._PrefabInfo = cc.Class({
name: "cc.PrefabInfo",
properties: {
root: null,
asset: null,
fileId: "",
sync: !1,
_synced: {
default: !1,
serializable: !1
}
}
});
e.exports = {
syncWithPrefab: function(t) {
var e = t._prefab;
e._synced = !0;
if (e.asset) {
var i = t._objFlags, r = t._parent, s = t._id, o = t._name, a = t._active, c = t._position.x, h = t._position.y, l = t._quat, u = t._localZOrder, _ = t._globalZOrder;
cc.game._isCloning = !0;
e.asset._doInstantiate(t);
cc.game._isCloning = !1;
t._objFlags = i;
t._parent = r;
t._id = s;
t._prefab = e;
t._name = o;
t._active = a;
t._position.x = c;
t._position.y = h;
n.quat.copy(t._quat, l);
t._localZOrder = u;
t._globalZOrder = _;
} else {
cc.errorID(3701, t.name);
t._prefab = null;
}
}
};
}), {
"../renderer": 201
} ],
246: [ (function(t, e, i) {
var n = t("../../platform/CCMacro"), r = t("./perf-counter"), s = !1, o = 15, a = null, c = null, h = null, l = null;
function u() {
(function() {
if (!h || !h.isValid) {
(h = new cc.Node("PROFILER-NODE")).x = h.y = 10;
h.groupIndex = cc.Node.BuiltinGroupIndex.DEBUG;
cc.Camera._setupDebugCamera();
h.zIndex = n.MAX_ZINDEX;
cc.game.addPersistRootNode(h);
var t = new cc.Node("LEFT-PANEL");
t.anchorX = t.anchorY = 0;
t.parent = h;
var e = t.addComponent(cc.Label);
e.font = a;
e.fontSize = o;
e.lineHeight = o;
var i = new cc.Node("RIGHT-PANEL");
i.anchorX = 1;
i.anchorY = 0;
i.x = 200;
i.parent = h;
var r = i.addComponent(cc.Label);
r.horizontalAlign = cc.Label.HorizontalAlign.RIGHT;
r.font = a;
r.fontSize = o;
r.lineHeight = o;
l = {
left: e,
right: r
};
}
})();
var t = cc.director._lastUpdate;
c.frame._counter.start(t);
c.logic._counter.start(t);
}
function _() {
var t = performance.now();
cc.director.isPaused() ? c.frame._counter.start(t) : c.logic._counter.end(t);
c.render._counter.start(t);
}
function f() {
var t = performance.now();
c.render._counter.end(t);
c.draws._counter.value = cc.renderer.drawCalls;
c.frame._counter.end(t);
c.fps._counter.frame(t);
var e = "", i = "";
for (var n in c) {
var r = c[n];
r._counter.sample(t);
e += r.desc + "\n";
i += r._counter.human() + "\n";
}
l.left.string = e;
l.right.string = i;
}
cc.profiler = e.exports = {
isShowingStats: function() {
return s;
},
hideStats: function() {
if (s) {
h && (h.active = !1);
cc.director.off(cc.Director.EVENT_BEFORE_UPDATE, u);
cc.director.off(cc.Director.EVENT_AFTER_UPDATE, _);
cc.director.off(cc.Director.EVENT_AFTER_DRAW, f);
s = !1;
}
},
showStats: function() {
if (!s) {
(function() {
if (!a) {
var t = document.createElement("canvas");
t.style.width = t.width = 256;
t.style.height = t.height = 256;
var e = t.getContext("2d");
e.font = o + "px Arial";
e.textBaseline = "top";
e.textAlign = "left";
e.fillStyle = "#fff";
var i = 2, n = 2, r = o;
(a = new cc.LabelAtlas())._fntConfig = {
atlasName: "profiler-arial",
commonHeight: r,
fontSize: o,
kerningDict: {},
fontDefDictionary: {}
};
a._name = "profiler-arial";
a.fontSize = o;
for (var s = a._fntConfig.fontDefDictionary, c = 32; c <= 126; c++) {
var h = String.fromCharCode(c), l = e.measureText(h).width;
if (i + l >= 256) {
i = 2;
n += r + 2;
}
e.fillText(h, i, n);
s[c] = {
xAdvance: l,
xOffset: 0,
yOffset: 0,
rect: {
x: i,
y: n,
width: l,
height: r
}
};
i += l + 2;
}
var u = new cc.Texture2D();
u.initWithElement(t);
var _ = new cc.SpriteFrame();
_.setTexture(u);
a.spriteFrame = _;
}
})();
(function() {
if (!c) {
c = {
frame: {
desc: "Frame time (ms)",
min: 0,
max: 50,
average: 500
},
fps: {
desc: "Framerate (FPS)",
below: 30,
average: 500
},
draws: {
desc: "Draw call"
},
logic: {
desc: "Game Logic (ms)",
min: 0,
max: 50,
average: 500,
color: "#080"
},
render: {
desc: "Renderer (ms)",
min: 0,
max: 50,
average: 500,
color: "#f90"
},
mode: {
desc: cc.game.renderType === cc.game.RENDER_TYPE_WEBGL ? "WebGL" : "Canvas",
min: 1
}
};
var t = performance.now();
for (var e in c) c[e]._counter = new r(e, c[e], t);
}
})();
h && (h.active = !0);
cc.director.on(cc.Director.EVENT_BEFORE_UPDATE, u);
cc.director.on(cc.Director.EVENT_AFTER_UPDATE, _);
cc.director.on(cc.Director.EVENT_AFTER_DRAW, f);
s = !0;
}
}
};
}), {
"../../platform/CCMacro": 165,
"./perf-counter": 248
} ],
247: [ (function(t, e, i) {
var n = cc.Class({
name: "cc.Counter",
ctor: function(t, e, i) {
this._id = t;
this._opts = e || {};
this._value = 0;
this._total = 0;
this._averageValue = 0;
this._accumValue = 0;
this._accumSamples = 0;
this._accumStart = i;
},
properties: {
value: {
get: function() {
return this._value;
},
set: function(t) {
this._value = t;
}
}
},
_average: function(t, e) {
if (this._opts.average) {
this._accumValue += t;
++this._accumSamples;
var i = e;
if (i - this._accumStart >= this._opts.average) {
this._averageValue = this._accumValue / this._accumSamples;
this._accumValue = 0;
this._accumStart = i;
this._accumSamples = 0;
}
}
},
sample: function(t) {
this._average(this._value, t);
},
human: function() {
var t = this._opts.average ? this._averageValue : this._value;
return Math.round(100 * t) / 100;
},
alarm: function() {
return this._opts.below && this._value < this._opts.below || this._opts.over && this._value > this._opts.over;
}
});
e.exports = n;
}), {} ],
248: [ (function(t, e, i) {
var n = t("./counter"), r = cc.Class({
name: "cc.PerfCounter",
extends: n,
ctor: function(t, e, i) {
this._time = i;
},
start: function(t) {
this._time = t;
},
end: function(t) {
this._value = t - this._time;
this._average(this._value);
},
tick: function() {
this.end();
this.start();
},
frame: function(t) {
var e = t, 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);
}
}
});
e.exports = r;
}), {
"./counter": 247
} ],
249: [ (function(t, e, i) {
e.exports = {
label_wordRex: /([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûа-яА-ЯЁё]+|\S)/,
label_symbolRex: /^[!,.:;'}\]%\?>、‘“》？。，！]/,
label_lastWordRex: /([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁё]+|\S)$/,
label_lastEnglish: /[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁё]+$/,
label_firstEnglish: /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁё]/,
label_firstEmoji: /^[\uD83C\uDF00-\uDFFF\uDC00-\uDE4F]/,
label_lastEmoji: /([\uDF00-\uDFFF\uDC00-\uDE4F]+|\S)$/,
label_wrapinspection: !0,
__CHINESE_REG: /^[\u4E00-\u9FFF\u3400-\u4DFF]+$/,
__JAPANESE_REG: /[\u3000-\u303F]|[\u3040-\u309F]|[\u30A0-\u30FF]|[\uFF00-\uFFEF]|[\u4E00-\u9FAF]|[\u2605-\u2606]|[\u2190-\u2195]|\u203B/g,
__KOREAN_REG: /^[\u1100-\u11FF]|[\u3130-\u318F]|[\uA960-\uA97F]|[\uAC00-\uD7AF]|[\uD7B0-\uD7FF]+$/,
isUnicodeCJK: function(t) {
return this.__CHINESE_REG.test(t) || this.__JAPANESE_REG.test(t) || this.__KOREAN_REG.test(t);
},
isUnicodeSpace: function(t) {
return (t = t.charCodeAt(0)) >= 9 && t <= 13 || 32 === t || 133 === t || 160 === t || 5760 === t || t >= 8192 && t <= 8202 || 8232 === t || 8233 === t || 8239 === t || 8287 === t || 12288 === t;
},
safeMeasureText: function(t, e) {
var i = t.measureText(e);
return i && i.width || 0;
},
fragmentText: function(t, e, i, n) {
var r = [];
if (0 === t.length || i < 0) {
r.push("");
return r;
}
for (var s = t; e > i && s.length > 1; ) {
for (var o = s.length * (i / e) | 0, a = s.substr(o), c = e - n(a), h = a, l = 0, u = 0; c > i && u++ < 10; ) {
o *= i / c;
o |= 0;
c = e - n(a = s.substr(o));
}
u = 0;
for (;c <= i && u++ < 10; ) {
if (a) {
var _ = this.label_wordRex.exec(a);
l = _ ? _[0].length : 1;
h = a;
}
o += l;
c = e - n(a = s.substr(o));
}
if (0 == (o -= l)) {
o = 1;
h = h.substr(1);
}
var f, d = s.substr(0, o);
if (this.label_wrapinspection && this.label_symbolRex.test(h || a)) {
0 == (o -= (f = this.label_lastWordRex.exec(d)) ? f[0].length : 0) && (o = 1);
h = s.substr(o);
d = s.substr(0, o);
}
if (this.label_firstEmoji.test(h) && (f = this.label_lastEmoji.exec(d)) && d !== f[0]) {
o -= f[0].length;
h = s.substr(o);
d = s.substr(0, o);
}
if (this.label_firstEnglish.test(h) && (f = this.label_lastEnglish.exec(d)) && d !== f[0]) {
o -= f[0].length;
h = s.substr(o);
d = s.substr(0, o);
}
0 === r.length ? r.push(d) : (d = d.trim()).length > 0 && r.push(d);
e = n(s = h || a);
}
0 === r.length ? r.push(s) : (s = s.trim()).length > 0 && r.push(s);
return r;
}
};
}), {} ],
250: [ (function(t, e, i) {
var n = t("../assets/CCTexture2D"), r = {
loadImage: function(t, e, i) {
cc.assertID(t, 3103);
var r = cc.loader.getRes(t);
if (r) {
if (r.loaded) {
e && e.call(i, r);
return r;
}
r.once("load", (function() {
e && e.call(i, r);
}), i);
return r;
}
(r = new n()).url = t;
cc.loader.load({
url: t,
texture: r
}, (function(t, n) {
if (t) return e && e.call(i, t || new Error("Unknown error"));
n.handleLoadedTexture();
e && e.call(i, null, n);
}));
return r;
},
cacheImage: function(t, e) {
if (t && e) {
var i = new n();
i.initWithElement(e);
var r = {
id: t,
url: t,
error: null,
content: i,
complete: !1
};
cc.loader.flowOut(r);
return i;
}
},
postLoadTexture: function(t, e) {
t.loaded ? e && e() : t.url ? cc.loader.load({
url: t.url,
skips: [ "Loader" ]
}, (function(i, n) {
if (n) {
0;
t.loaded || (t._nativeAsset = n);
}
e && e(i);
})) : e && e();
}
};
cc.textureUtil = e.exports = r;
}), {
"../assets/CCTexture2D": 49
} ],
251: [ (function(i, n, r) {
var s = i("./value-type"), o = i("../platform/js"), a = (function() {
function n(i, n, r, s) {
if ("object" === ("object" === (e = typeof i) ? t(i) : e)) {
n = i.g;
r = i.b;
s = i.a;
i = i.r;
}
i = i || 0;
n = n || 0;
r = r || 0;
s = "number" === ("object" === (e = typeof s) ? t(s) : e) ? s : 255;
this._val = (s << 24 >>> 0) + (r << 16) + (n << 8) + i;
}
o.extend(n, s);
i("../platform/CCClass").fastDefine("cc.Color", n, {
r: 0,
g: 0,
b: 0,
a: 255
});
var r = {
WHITE: [ 255, 255, 255, 255 ],
BLACK: [ 0, 0, 0, 255 ],
TRANSPARENT: [ 0, 0, 0, 0 ],
GRAY: [ 127.5, 127.5, 127.5 ],
RED: [ 255, 0, 0 ],
GREEN: [ 0, 255, 0 ],
BLUE: [ 0, 0, 255 ],
YELLOW: [ 255, 235, 4 ],
ORANGE: [ 255, 127, 0 ],
CYAN: [ 0, 255, 255 ],
MAGENTA: [ 255, 0, 255 ]
};
for (var a in r) o.get(n, a, (function(t) {
return function() {
return new n(t[0], t[1], t[2], t[3]);
};
})(r[a]));
var c = n.prototype;
c.clone = function() {
var t = new n();
t._val = this._val;
return t;
};
c.equals = function(t) {
return t && this._val === t._val;
};
c.lerp = function(t, e, i) {
i = i || new n();
var r = this.r, s = this.g, o = this.b, a = this.a;
i.r = r + (t.r - r) * e;
i.g = s + (t.g - s) * e;
i.b = o + (t.b - o) * e;
i.a = a + (t.a - a) * e;
return i;
};
c.toString = function() {
return "rgba(" + this.r.toFixed() + ", " + this.g.toFixed() + ", " + this.b.toFixed() + ", " + this.a.toFixed() + ")";
};
c.getR = function() {
return 255 & this._val;
};
c.setR = function(t) {
t = ~~cc.misc.clampf(t, 0, 255);
this._val = (4294967040 & this._val | t) >>> 0;
return this;
};
c.getG = function() {
return (65280 & this._val) >> 8;
};
c.setG = function(t) {
t = ~~cc.misc.clampf(t, 0, 255);
this._val = (4294902015 & this._val | t << 8) >>> 0;
return this;
};
c.getB = function() {
return (16711680 & this._val) >> 16;
};
c.setB = function(t) {
t = ~~cc.misc.clampf(t, 0, 255);
this._val = (4278255615 & this._val | t << 16) >>> 0;
return this;
};
c.getA = function() {
return (4278190080 & this._val) >>> 24;
};
c.setA = function(t) {
t = ~~cc.misc.clampf(t, 0, 255);
this._val = (16777215 & this._val | t << 24) >>> 0;
return this;
};
c._fastSetA = function(t) {
this._val = (16777215 & this._val | t << 24) >>> 0;
};
o.getset(c, "r", c.getR, c.setR, !0);
o.getset(c, "g", c.getG, c.setG, !0);
o.getset(c, "b", c.getB, c.setB, !0);
o.getset(c, "a", c.getA, c.setA, !0);
c.toCSS = function(t) {
return "rgba" === t ? "rgba(" + (0 | this.r) + "," + (0 | this.g) + "," + (0 | this.b) + "," + (this.a / 255).toFixed(2) + ")" : "rgb" === t ? "rgb(" + (0 | this.r) + "," + (0 | this.g) + "," + (0 | this.b) + ")" : "#" + this.toHEX(t);
};
c.fromHEX = function(t) {
t = 0 === t.indexOf("#") ? t.substring(1) : t;
var e = parseInt(t.substr(0, 2), 16) || 0, i = parseInt(t.substr(2, 2), 16) || 0, n = parseInt(t.substr(4, 2), 16) || 0, r = parseInt(t.substr(6, 2), 16) || 255;
this._val = (r << 24 >>> 0) + (n << 16) + (i << 8) + e;
return this;
};
c.toHEX = function(t) {
var e = [ (this.r < 16 ? "0" : "") + (0 | this.r).toString(16), (this.g < 16 ? "0" : "") + (0 | this.g).toString(16), (this.b < 16 ? "0" : "") + (0 | this.b).toString(16) ], i = -1;
if ("#rgb" === t) for (i = 0; i < e.length; ++i) e[i].length > 1 && (e[i] = e[i][0]); else if ("#rrggbb" === t) for (i = 0; i < e.length; ++i) 1 === e[i].length && (e[i] = "0" + e[i]); else "#rrggbbaa" === t && e.push((this.a < 16 ? "0" : "") + (0 | this.a).toString(16));
return e.join("");
};
c.toRGBValue = function() {
return 16777215 & this._val;
};
c.fromHSV = function(t, e, i) {
var n, r, s;
if (0 === e) n = r = s = i; else if (0 === i) n = r = s = 0; else {
1 === t && (t = 0);
t *= 6;
e = e;
i = i;
var o = Math.floor(t), a = t - o, c = i * (1 - e), h = i * (1 - e * a), l = i * (1 - e * (1 - a));
switch (o) {
case 0:
n = i;
r = l;
s = c;
break;

case 1:
n = h;
r = i;
s = c;
break;

case 2:
n = c;
r = i;
s = l;
break;

case 3:
n = c;
r = h;
s = i;
break;

case 4:
n = l;
r = c;
s = i;
break;

case 5:
n = i;
r = c;
s = h;
}
}
n *= 255;
r *= 255;
s *= 255;
this._val = (this.a << 24 >>> 0) + (s << 16) + (r << 8) + n;
return this;
};
c.toHSV = function() {
var t = this.r / 255, e = this.g / 255, i = this.b / 255, n = {
h: 0,
s: 0,
v: 0
}, r = Math.max(t, e, i), s = Math.min(t, e, i), o = 0;
n.v = r;
n.s = r ? (r - s) / r : 0;
if (n.s) {
o = r - s;
n.h = t === r ? (e - i) / o : e === r ? 2 + (i - t) / o : 4 + (t - e) / o;
n.h /= 6;
n.h < 0 && (n.h += 1);
} else n.h = 0;
return n;
};
c.set = function(t) {
if (t._val) this._val = t._val; else {
this.r = t.r;
this.g = t.g;
this.b = t.b;
this.a = t.a;
}
};
return n;
})();
cc.Color = a;
cc.color = function(i, n, r, s) {
if ("string" === ("object" === (e = typeof i) ? t(i) : e)) {
return new cc.Color().fromHEX(i);
}
return "object" === ("object" === (e = typeof i) ? t(i) : e) ? new cc.Color(i.r, i.g, i.b, i.a) : new cc.Color(i, n, r, s);
};
n.exports = cc.Color;
}), {
"../platform/CCClass": 160,
"../platform/js": 180,
"./value-type": 257
} ],
252: [ (function(t, e, i) {
t("./value-type");
t("./vec2");
t("./vec3");
t("./quat");
t("./mat4");
t("./size");
t("./rect");
t("./color");
cc.vmath = t("../renderer/render-engine").math;
}), {
"../renderer/render-engine": 202,
"./color": 251,
"./mat4": 253,
"./quat": 254,
"./rect": 255,
"./size": 256,
"./value-type": 257,
"./vec2": 258,
"./vec3": 259
} ],
253: [ (function(t, e, i) {
var n = t("./value-type"), r = t("../platform/js"), s = t("../platform/CCClass"), o = t("../renderer/render-engine").math.mat4;
function a(t, e, i, n, r, s, o, a, c, h, l, u, _, f, d, m) {
var p = this;
p.m00 = t;
p.m01 = e;
p.m02 = i;
p.m03 = n;
p.m04 = r;
p.m05 = s;
p.m06 = o;
p.m07 = a;
p.m08 = c;
p.m09 = h;
p.m10 = l;
p.m11 = u;
p.m12 = _;
p.m13 = f;
p.m14 = d;
p.m15 = m;
}
r.extend(a, n);
s.fastDefine("cc.Mat4", a, {
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
});
r.mixin(a.prototype, {
clone: function() {
var t = this;
return new a(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);
},
set: function(t) {
var e = this;
e.m00 = t.m00;
e.m01 = t.m01;
e.m02 = t.m02;
e.m03 = t.m03;
e.m04 = t.m04;
e.m05 = t.m05;
e.m06 = t.m06;
e.m07 = t.m07;
e.m08 = t.m08;
e.m09 = t.m09;
e.m10 = t.m10;
e.m11 = t.m11;
e.m12 = t.m12;
e.m13 = t.m13;
e.m14 = t.m14;
e.m15 = t.m15;
return this;
},
equals: function(t) {
return o.exactEquals(this, t);
},
fuzzyEquals: function(t) {
return o.equals(this, t);
},
toString: function() {
var t = this;
return "[\n" + t.m00 + ", " + t.m01 + ", " + t.m02 + ", " + t.m03 + ",\n" + t.m04 + ", " + t.m05 + ", " + t.m06 + ", " + t.m07 + ",\n" + t.m08 + ", " + t.m09 + ", " + t.m10 + ", " + t.m11 + ",\n" + t.m12 + ", " + t.m13 + ", " + t.m14 + ", " + t.m15 + "\n]";
},
identity: function() {
return o.identity(this);
},
transpose: function(t) {
t = t || new cc.Mat4();
return o.transpose(t, this);
},
invert: function(t) {
t = t || new cc.Mat4();
return o.invert(t, this);
},
adjoint: function(t) {
t = t || new cc.Mat4();
return o.adjoint(t, this);
},
determinant: function() {
return o.determinant(this);
},
add: function(t, e) {
e = e || new cc.Mat4();
return o.add(e, this, t);
},
sub: function(t, e) {
e = e || new cc.Mat4();
return o.subtract(e, this, t);
},
mul: function(t, e) {
e = e || new cc.Mat4();
return o.multiply(e, this, t);
},
mulScalar: function(t, e) {
e = e || new cc.Mat4();
return o.mulScalar(e, this, t);
},
translate: function(t, e) {
e = e || new cc.Mat4();
return o.translate(e, this, t);
},
scale: function(t, e) {
e = e || new cc.Mat4();
return o.scale(e, this, t);
},
rotate: function(t, e, i) {
i = i || new cc.Mat4();
return o.rotate(i, this, t, e);
},
getTranslation: function(t) {
t = t || new cc.Vec3();
return o.getTranslation(t, this);
},
getScale: function(t) {
t = t || new cc.Vec3();
return o.getScaling(t, this);
},
getRotation: function(t) {
t = t || new cc.Quat();
return o.getRotation(t, this);
},
fromRTS: function(t, e, i) {
return o.fromRTS(this, t, e, i);
},
fromQuat: function(t) {
return o.fromQuat(this, t);
}
});
cc.mat4 = function(t, e, i, n, r, s, o, c, h, l, u, _, f, d, m, p) {
return new a(t, e, i, n, r, s, o, c, h, l, u, _, f, d, m, p);
};
}), {
"../platform/CCClass": 160,
"../platform/js": 180,
"../renderer/render-engine": 202,
"./value-type": 257
} ],
254: [ (function(i, n, r) {
var s = i("./value-type"), o = i("../platform/js"), a = i("../platform/CCClass");
function c(i, n, r, s) {
if (i && "object" === ("object" === (e = typeof i) ? t(i) : e)) {
r = i.z;
n = i.y;
s = (i = i.x).w;
}
this.x = i || 0;
this.y = n || 0;
this.z = r || 0;
this.w = s || 1;
}
o.extend(c, s);
a.fastDefine("cc.Quat", c, {
x: 0,
y: 0,
z: 0,
w: 1
});
var h = c.prototype;
h.clone = function() {
return new c(this.x, this.y, this.z, this.w);
};
h.set = function(t) {
this.x = t.x;
this.y = t.y;
this.z = t.z;
this.w = t.w;
return this;
};
h.equals = function(t) {
return t && this.x === t.x && this.y === t.y && this.z === t.z && this.w === t.w;
};
h.getRoll = function() {
var t = 2 * (this.w * this.x + this.y * this.z), e = 1 - 2 * (this.x * this.x + this.y * this.y);
return 180 * Math.atan2(t, e) / Math.PI;
};
h.getPitch = function() {
var t = 2 * (this.w * this.y - this.z * this.x), e = t > 1 ? 1 : t;
e = t < -1 ? -1 : t;
return e = 180 * Math.asin(e) / Math.PI;
};
h.getYaw = function() {
var t = 2 * (this.w * this.z + this.x * this.y), e = 1 - 2 * (this.y * this.y + this.z * this.z);
return 180 * Math.atan2(t, e) / Math.PI;
};
cc.quat = function(t, e, i, n) {
return new c(t, e, i, n);
};
n.exports = cc.Quat = c;
}), {
"../platform/CCClass": 160,
"../platform/js": 180,
"./value-type": 257
} ],
255: [ (function(i, n, r) {
var s = i("./value-type"), o = i("../platform/js");
function a(i, n, r, s) {
if (i && "object" === ("object" === (e = typeof i) ? t(i) : e)) {
n = i.y;
r = i.width;
s = i.height;
i = i.x;
}
this.x = i || 0;
this.y = n || 0;
this.width = r || 0;
this.height = s || 0;
}
o.extend(a, s);
i("../platform/CCClass").fastDefine("cc.Rect", a, {
x: 0,
y: 0,
width: 0,
height: 0
});
a.fromMinMax = function(t, e) {
var i = Math.min(t.x, e.x), n = Math.min(t.y, e.y);
return new a(i, n, Math.max(t.x, e.x) - i, Math.max(t.y, e.y) - n);
};
var c = a.prototype;
c.clone = function() {
return new a(this.x, this.y, this.width, this.height);
};
c.equals = function(t) {
return t && this.x === t.x && this.y === t.y && this.width === t.width && this.height === t.height;
};
c.lerp = function(t, e, i) {
i = i || new a();
var n = this.x, r = this.y, s = this.width, o = this.height;
i.x = n + (t.x - n) * e;
i.y = r + (t.y - r) * e;
i.width = s + (t.width - s) * e;
i.height = o + (t.height - o) * e;
return i;
};
c.set = function(t) {
this.x = t.x;
this.y = t.y;
this.width = t.width;
this.height = t.height;
};
c.intersects = function(t) {
var e = this.x + this.width, i = this.y + this.height, n = t.x + t.width, r = t.y + t.height;
return !(e < t.x || n < this.x || i < t.y || r < this.y);
};
c.intersection = function(t, e) {
var i = this.x, n = this.y, r = this.x + this.width, s = this.y + this.height, o = e.x, a = e.y, c = e.x + e.width, h = e.y + e.height;
t.x = Math.max(i, o);
t.y = Math.max(n, a);
t.width = Math.min(r, c) - t.x;
t.height = Math.min(s, h) - t.y;
return t;
};
c.contains = function(t) {
return this.x <= t.x && this.x + this.width >= t.x && this.y <= t.y && this.y + this.height >= t.y;
};
c.containsRect = function(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;
};
c.union = function(t, e) {
var i = this.x, n = this.y, r = this.width, s = this.height, o = e.x, a = e.y, c = e.width, h = e.height;
t.x = Math.min(i, o);
t.y = Math.min(n, a);
t.width = Math.max(i + r, o + c) - t.x;
t.height = Math.max(n + s, a + h) - t.y;
return t;
};
c.transformMat4 = function(t, e) {
var i = this.x, n = this.y, r = i + this.width, s = n + this.height, o = e.m00 * i + e.m04 * n + e.m12, a = e.m01 * i + e.m05 * n + e.m13, c = e.m00 * r + e.m04 * n + e.m12, h = e.m01 * r + e.m05 * n + e.m13, l = e.m00 * i + e.m04 * s + e.m12, u = e.m01 * i + e.m05 * s + e.m13, _ = e.m00 * r + e.m04 * s + e.m12, f = e.m01 * r + e.m05 * s + e.m13, d = Math.min(o, c, l, _), m = Math.max(o, c, l, _), p = Math.min(a, h, u, f), v = Math.max(a, h, u, f);
t.x = d;
t.y = p;
t.width = m - d;
t.height = v - p;
return t;
};
c.toString = function() {
return "(" + this.x.toFixed(2) + ", " + this.y.toFixed(2) + ", " + this.width.toFixed(2) + ", " + this.height.toFixed(2) + ")";
};
o.getset(c, "xMin", (function() {
return this.x;
}), (function(t) {
this.width += this.x - t;
this.x = t;
}));
o.getset(c, "yMin", (function() {
return this.y;
}), (function(t) {
this.height += this.y - t;
this.y = t;
}));
o.getset(c, "xMax", (function() {
return this.x + this.width;
}), (function(t) {
this.width = t - this.x;
}));
o.getset(c, "yMax", (function() {
return this.y + this.height;
}), (function(t) {
this.height = t - this.y;
}));
o.getset(c, "center", (function() {
return new cc.Vec2(this.x + .5 * this.width, this.y + .5 * this.height);
}), (function(t) {
this.x = t.x - .5 * this.width;
this.y = t.y - .5 * this.height;
}));
o.getset(c, "origin", (function() {
return new cc.Vec2(this.x, this.y);
}), (function(t) {
this.x = t.x;
this.y = t.y;
}));
o.getset(c, "size", (function() {
return new cc.Size(this.width, this.height);
}), (function(t) {
this.width = t.width;
this.height = t.height;
}));
cc.Rect = a;
cc.rect = function(t, e, i, n) {
return new a(t, e, i, n);
};
n.exports = cc.Rect;
}), {
"../platform/CCClass": 160,
"../platform/js": 180,
"./value-type": 257
} ],
256: [ (function(i, n, r) {
var s = i("./value-type"), o = i("../platform/js");
function a(i, n) {
if (i && "object" === ("object" === (e = typeof i) ? t(i) : e)) {
n = i.height;
i = i.width;
}
this.width = i || 0;
this.height = n || 0;
}
o.extend(a, s);
i("../platform/CCClass").fastDefine("cc.Size", a, {
width: 0,
height: 0
});
o.get(a, "ZERO", (function() {
return new a(0, 0);
}));
var c = a.prototype;
c.clone = function() {
return new a(this.width, this.height);
};
c.equals = function(t) {
return t && this.width === t.width && this.height === t.height;
};
c.lerp = function(t, e, i) {
i = i || new a();
var n = this.width, r = this.height;
i.width = n + (t.width - n) * e;
i.height = r + (t.height - r) * e;
return i;
};
c.set = function(t) {
this.width = t.width;
this.height = t.height;
};
c.toString = function() {
return "(" + this.width.toFixed(2) + ", " + this.height.toFixed(2) + ")";
};
cc.size = function(t, e) {
return new a(t, e);
};
cc.Size = n.exports = a;
}), {
"../platform/CCClass": 160,
"../platform/js": 180,
"./value-type": 257
} ],
257: [ (function(t, e, i) {
var n = t("../platform/js");
function r() {}
n.setClassName("cc.ValueType", r);
var s = r.prototype;
0;
s.toString = function() {
return "" + {};
};
cc.ValueType = e.exports = r;
}), {
"../platform/js": 180
} ],
258: [ (function(i, n, r) {
var s = i("./value-type"), o = i("../platform/js"), a = i("../platform/CCClass"), c = i("../renderer/render-engine").math, h = i("../utils/misc");
function l(i, n) {
if (i && "object" === ("object" === (e = typeof i) ? t(i) : e)) {
n = i.y;
i = i.x;
}
this.x = i || 0;
this.y = n || 0;
}
o.extend(l, s);
a.fastDefine("cc.Vec2", l, {
x: 0,
y: 0
});
var u = l.prototype;
u.clone = function() {
return new l(this.x, this.y);
};
u.set = function(t) {
this.x = t.x;
this.y = t.y;
return this;
};
u.equals = function(t) {
return t && this.x === t.x && this.y === t.y;
};
u.fuzzyEquals = function(t, e) {
return this.x - e <= t.x && t.x <= this.x + e && this.y - e <= t.y && t.y <= this.y + e;
};
u.toString = function() {
return "(" + this.x.toFixed(2) + ", " + this.y.toFixed(2) + ")";
};
u.lerp = function(t, e, i) {
i = i || new l();
var n = this.x, r = this.y;
i.x = n + (t.x - n) * e;
i.y = r + (t.y - r) * e;
return i;
};
u.clampf = function(t, e) {
this.x = h.clampf(this.x, t.x, e.x);
this.y = h.clampf(this.y, t.y, e.y);
return this;
};
u.addSelf = function(t) {
this.x += t.x;
this.y += t.y;
return this;
};
u.add = function(t, e) {
(e = e || new l()).x = this.x + t.x;
e.y = this.y + t.y;
return e;
};
u.subSelf = function(t) {
this.x -= t.x;
this.y -= t.y;
return this;
};
u.sub = function(t, e) {
(e = e || new l()).x = this.x - t.x;
e.y = this.y - t.y;
return e;
};
u.mulSelf = function(t) {
this.x *= t;
this.y *= t;
return this;
};
u.mul = function(t, e) {
(e = e || new l()).x = this.x * t;
e.y = this.y * t;
return e;
};
u.scaleSelf = function(t) {
this.x *= t.x;
this.y *= t.y;
return this;
};
u.scale = function(t, e) {
(e = e || new l()).x = this.x * t.x;
e.y = this.y * t.y;
return e;
};
u.divSelf = function(t) {
this.x /= t;
this.y /= t;
return this;
};
u.div = function(t, e) {
(e = e || new l()).x = this.x / t;
e.y = this.y / t;
return e;
};
u.negSelf = function() {
this.x = -this.x;
this.y = -this.y;
return this;
};
u.neg = function(t) {
(t = t || new l()).x = -this.x;
t.y = -this.y;
return t;
};
u.dot = function(t) {
return this.x * t.x + this.y * t.y;
};
u.cross = function(t) {
return this.x * t.y - this.y * t.x;
};
u.mag = function() {
return Math.sqrt(this.x * this.x + this.y * this.y);
};
u.magSqr = function() {
return this.x * this.x + this.y * this.y;
};
u.normalizeSelf = function() {
var t = this.x * this.x + this.y * this.y;
if (1 === t) return this;
if (0 === t) return this;
var e = 1 / Math.sqrt(t);
this.x *= e;
this.y *= e;
return this;
};
u.normalize = function(t) {
(t = t || new l()).x = this.x;
t.y = this.y;
t.normalizeSelf();
return t;
};
u.angle = function(t) {
var e = this.magSqr(), i = t.magSqr();
if (0 === e || 0 === i) {
console.warn("Can't get angle between zero vector");
return 0;
}
var n = this.dot(t) / Math.sqrt(e * i);
n = h.clampf(n, -1, 1);
return Math.acos(n);
};
u.signAngle = function(t) {
var e = this.angle(t);
return this.cross(t) < 0 ? -e : e;
};
u.rotate = function(t, e) {
(e = e || new l()).x = this.x;
e.y = this.y;
return e.rotateSelf(t);
};
u.rotateSelf = function(t) {
var e = Math.sin(t), i = Math.cos(t), n = this.x;
this.x = i * n - e * this.y;
this.y = e * n + i * this.y;
return this;
};
u.project = function(t) {
return t.mul(this.dot(t) / t.dot(t));
};
u.transformMat4 = function(t, e) {
e = e || new l();
c.vec2.transformMat4(e, this, t);
};
o.get(l, "ONE", (function() {
return new l(1, 1);
}));
o.get(l, "ZERO", (function() {
return new l(0, 0);
}));
o.get(l, "UP", (function() {
return new l(0, 1);
}));
o.get(l, "RIGHT", (function() {
return new l(1, 0);
}));
cc.Vec2 = l;
cc.v2 = function(t, e) {
return new l(t, e);
};
cc.p = cc.v2;
n.exports = cc.Vec2;
}), {
"../platform/CCClass": 160,
"../platform/js": 180,
"../renderer/render-engine": 202,
"../utils/misc": 242,
"./value-type": 257
} ],
259: [ (function(i, n, r) {
var s = i("./value-type"), o = i("../platform/js"), a = i("../platform/CCClass"), c = i("../renderer/render-engine").math, h = i("../utils/misc");
function l(i, n, r) {
if (i && "object" === ("object" === (e = typeof i) ? t(i) : e)) {
r = i.z;
n = i.y;
i = i.x;
}
this.x = i || 0;
this.y = n || 0;
this.z = r || 0;
}
o.extend(l, s);
a.fastDefine("cc.Vec3", l, {
x: 0,
y: 0,
z: 0
});
var u = l.prototype;
u.clone = function() {
return new l(this.x, this.y, this.z);
};
u.set = function(t) {
this.x = t.x;
this.y = t.y;
this.z = t.z;
return this;
};
u.equals = function(t) {
return t && this.x === t.x && this.y === t.y && this.z === t.z;
};
u.fuzzyEquals = function(t, e) {
return this.x - e <= t.x && t.x <= this.x + e && this.y - e <= t.y && t.y <= this.y + e && this.z - e <= t.z && t.z <= this.z + e;
};
u.toString = function() {
return "(" + this.x.toFixed(2) + ", " + this.y.toFixed(2) + ", " + this.z.toFixed(2) + ")";
};
u.lerp = function(t, e, i) {
i = i || new l();
c.vec3.lerp(i, this, t, e);
return i;
};
u.clampf = function(t, e) {
this.x = h.clampf(this.x, t.x, e.x);
this.y = h.clampf(this.y, t.y, e.y);
this.z = h.clampf(this.z, t.z, e.z);
return this;
};
u.addSelf = function(t) {
this.x += t.x;
this.y += t.y;
this.z += t.z;
return this;
};
u.add = function(t, e) {
(e = e || new l()).x = this.x + t.x;
e.y = this.y + t.y;
e.z = this.z + t.z;
return e;
};
u.subSelf = function(t) {
this.x -= t.x;
this.y -= t.y;
this.z -= t.z;
return this;
};
u.sub = function(t, e) {
(e = e || new l()).x = this.x - t.x;
e.y = this.y - t.y;
e.z = this.z - t.z;
return e;
};
u.mulSelf = function(t) {
this.x *= t;
this.y *= t;
this.z *= t;
return this;
};
u.mul = function(t, e) {
(e = e || new l()).x = this.x * t;
e.y = this.y * t;
e.z = this.z * t;
return e;
};
u.scaleSelf = function(t) {
this.x *= t.x;
this.y *= t.y;
this.z *= t.z;
return this;
};
u.scale = function(t, e) {
(e = e || new l()).x = this.x * t.x;
e.y = this.y * t.y;
e.z = this.z * t.z;
return e;
};
u.divSelf = function(t) {
this.x /= t;
this.y /= t;
this.z /= t;
return this;
};
u.div = function(t, e) {
(e = e || new l()).x = this.x / t;
e.y = this.y / t;
e.z = this.z / t;
return e;
};
u.negSelf = function() {
this.x = -this.x;
this.y = -this.y;
this.z = -this.z;
return this;
};
u.neg = function(t) {
(t = t || new l()).x = -this.x;
t.y = -this.y;
t.z = -this.z;
return t;
};
u.dot = function(t) {
return this.x * t.x + this.y * t.y + this.z * t.z;
};
u.cross = function(t, e) {
e = e || new l();
c.vec3.cross(e, this, t);
return e;
};
u.mag = function() {
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
};
u.magSqr = function() {
return this.x * this.x + this.y * this.y + this.z * this.z;
};
u.normalizeSelf = function() {
c.vec3.normalize(this, this);
return this;
};
u.normalize = function(t) {
t = t || new l();
c.vec3.normalize(t, this);
return t;
};
u.transformMat4 = function(t, e) {
e = e || new l();
c.vec3.transformMat4(e, this, t);
};
cc.v3 = function(t, e, i) {
return new l(t, e, i);
};
n.exports = cc.Vec3 = l;
}), {
"../platform/CCClass": 160,
"../platform/js": 180,
"../renderer/render-engine": 202,
"../utils/misc": 242,
"./value-type": 257
} ],
260: [ (function(t, e, i) {
cc.js;
}), {} ],
261: [ (function(t, e, i) {
t("./core/CCGame");
t("./actions");
}), {
"./actions": 7,
"./core/CCGame": 28
} ],
262: [ (function(t, e, i) {
var n = t("../compression/zlib.min"), r = t("../core/CCDebug"), s = function(t) {
var e, i, n, s, o, a, c, h, l, u, _, f, d;
this.data = t;
this.pos = 8;
this.palette = [];
this.imgData = [];
this.transparency = {};
this.animation = null;
this.text = {};
o = null;
for (;;) {
e = this.readUInt32();
switch (h = function() {
var t, e;
e = [];
for (t = 0; t < 4; ++t) e.push(String.fromCharCode(this.data[this.pos++]));
return e;
}.call(this).join("")) {
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() || Infinity,
frames: []
};
break;

case "PLTE":
this.palette = this.read(e);
break;

case "fcTL":
o && this.animation.frames.push(o);
this.pos += 4;
o = {
width: this.readUInt32(),
height: this.readUInt32(),
xOffset: this.readUInt32(),
yOffset: this.readUInt32()
};
s = this.readUInt16();
n = this.readUInt16() || 100;
o.delay = 1e3 * s / n;
o.disposeOp = this.data[this.pos++];
o.blendOp = this.data[this.pos++];
o.data = [];
break;

case "IDAT":
case "fdAT":
if ("fdAT" === h) {
this.pos += 4;
e -= 4;
}
t = (null != o ? o.data : void 0) || this.imgData;
for (_ = 0; 0 <= e ? _ < e : _ > e; 0 <= e ? ++_ : --_) t.push(this.data[this.pos++]);
break;

case "tRNS":
this.transparency = {};
switch (this.colorType) {
case 3:
this.transparency.indexed = this.read(e);
if ((l = 255 - this.transparency.indexed.length) > 0) for (f = 0; 0 <= l ? f < l : f > l; 0 <= l ? ++f : --f) this.transparency.indexed.push(255);
break;

case 0:
this.transparency.grayscale = this.read(e)[0];
break;

case 2:
this.transparency.rgb = this.read(e);
}
break;

case "tEXt":
a = (u = this.read(e)).indexOf(0);
c = String.fromCharCode.apply(String, u.slice(0, a));
this.text[c] = String.fromCharCode.apply(String, u.slice(a + 1));
break;

case "IEND":
o && this.animation.frames.push(o);
this.colors = function() {
switch (this.colorType) {
case 0:
case 3:
case 4:
return 1;

case 2:
case 6:
return 3;
}
}.call(this);
this.hasAlphaChannel = 4 === (d = this.colorType) || 6 === d;
i = this.colors + (this.hasAlphaChannel ? 1 : 0);
this.pixelBitlength = this.bits * i;
this.colorSpace = function() {
switch (this.colors) {
case 1:
return "DeviceGray";

case 3:
return "DeviceRGB";
}
}.call(this);
Uint8Array != Array && (this.imgData = new Uint8Array(this.imgData));
return;

default:
this.pos += e;
}
this.pos += 4;
if (this.pos > this.data.length) throw new Error(r.getError(6017));
}
};
s.prototype = {
constructor: s,
read: function(t) {
var e, i;
i = [];
for (e = 0; 0 <= t ? e < t : e > t; 0 <= t ? ++e : --e) i.push(this.data[this.pos++]);
return i;
},
readUInt32: function() {
return this.data[this.pos++] << 24 | this.data[this.pos++] << 16 | this.data[this.pos++] << 8 | this.data[this.pos++];
},
readUInt16: function() {
return this.data[this.pos++] << 8 | this.data[this.pos++];
},
decodePixels: function(t) {
var e, i, s, o, a, c, h, l, u, _, f, d, m, p, v, y, g, x, C, A, b, S, T;
null == t && (t = this.imgData);
if (0 === t.length) return new Uint8Array(0);
t = new n.Inflate(t, {
index: 0,
verify: !1
}).decompress();
y = (d = this.pixelBitlength / 8) * this.width;
m = new Uint8Array(y * this.height);
c = t.length;
v = 0;
p = 0;
i = 0;
for (;p < c; ) {
switch (t[p++]) {
case 0:
for (o = C = 0; C < y; o = C += 1) m[i++] = t[p++];
break;

case 1:
for (o = A = 0; A < y; o = A += 1) {
e = t[p++];
a = o < d ? 0 : m[i - d];
m[i++] = (e + a) % 256;
}
break;

case 2:
for (o = b = 0; b < y; o = b += 1) {
e = t[p++];
s = (o - o % d) / d;
g = v && m[(v - 1) * y + s * d + o % d];
m[i++] = (g + e) % 256;
}
break;

case 3:
for (o = S = 0; S < y; o = S += 1) {
e = t[p++];
s = (o - o % d) / d;
a = o < d ? 0 : m[i - d];
g = v && m[(v - 1) * y + s * d + o % d];
m[i++] = (e + Math.floor((a + g) / 2)) % 256;
}
break;

case 4:
for (o = T = 0; T < y; o = T += 1) {
e = t[p++];
s = (o - o % d) / d;
a = o < d ? 0 : m[i - d];
if (0 === v) g = x = 0; else {
g = m[(v - 1) * y + s * d + o % d];
x = s && m[(v - 1) * y + (s - 1) * d + o % d];
}
h = a + g - x;
l = Math.abs(h - a);
_ = Math.abs(h - g);
f = Math.abs(h - x);
u = l <= _ && l <= f ? a : _ <= f ? g : x;
m[i++] = (e + u) % 256;
}
break;

default:
throw new Error(r.getError(6018, t[p - 1]));
}
v++;
}
return m;
},
copyToImageData: function(t, e) {
var i, n, r, s, o, a, c, h, l, u, _;
n = this.colors;
l = null;
i = this.hasAlphaChannel;
if (this.palette.length) {
l = null != (_ = this._decodedPalette) ? _ : this._decodedPalette = this.decodePalette();
n = 4;
i = !0;
}
h = (r = t.data || t).length;
o = l || e;
s = a = 0;
if (1 === n) for (;s < h; ) {
c = l ? 4 * e[s / 4] : a;
u = o[c++];
r[s++] = u;
r[s++] = u;
r[s++] = u;
r[s++] = i ? o[c++] : 255;
a = c;
} else for (;s < h; ) {
c = l ? 4 * e[s / 4] : a;
r[s++] = o[c++];
r[s++] = o[c++];
r[s++] = o[c++];
r[s++] = i ? o[c++] : 255;
a = c;
}
},
decodePalette: function() {
var t, e, i, n, r, s, o, a, c;
i = this.palette;
s = this.transparency.indexed || [];
r = new Uint8Array((s.length || 0) + i.length);
n = 0;
t = 0;
for (e = o = 0, a = i.length; o < a; e = o += 3) {
r[n++] = i[e];
r[n++] = i[e + 1];
r[n++] = i[e + 2];
r[n++] = null != (c = s[t++]) ? c : 255;
}
return r;
},
render: function(t) {
var e, i;
t.width = this.width;
t.height = this.height;
i = (e = t.getContext("2d")).createImageData(this.width, this.height);
this.copyToImageData(i, this.decodePixels());
return e.putImageData(i, 0, 0);
}
};
e.exports = s;
}), {
"../compression/zlib.min": 25,
"../core/CCDebug": 26
} ],
263: [ (function(t, e, i) {
var n = t("../core/assets/CCAsset"), r = t("../core/assets/CCSpriteFrame"), s = cc.Class({
name: "cc.ParticleAsset",
extends: n,
properties: {
spriteFrame: {
default: null,
type: r
}
}
});
cc.ParticleAsset = e.exports = s;
}), {
"../core/assets/CCAsset": 33,
"../core/assets/CCSpriteFrame": 46
} ],
264: [ (function(t, e, i) {
var n = t("../core/platform/CCMacro"), r = t("./CCParticleAsset"), s = t("../core/components/CCRenderComponent"), o = t("../compression/ZipUtils"), a = t("./CCPNGReader"), c = t("./CCTIFFReader"), h = t("../core/utils/texture-util"), l = t("../core/renderer/render-engine"), u = t("../core/renderer/render-flow"), _ = t("./particle-simulator"), f = l.gfx, d = n.BlendFactor;
var m = cc.Enum({
GRAVITY: 0,
RADIUS: 1
}), p = cc.Enum({
FREE: 0,
RELATIVE: 1,
GROUPED: 2
}), v = {
preview: {
default: !0,
editorOnly: !0,
notify: !1,
animatable: !1,
tooltip: !1
},
_custom: !1,
custom: {
get: function() {
return this._custom;
},
set: function(t) {
0;
if (this._custom !== t) {
this._custom = t;
this._applyFile();
0;
}
},
animatable: !1,
tooltip: !1
},
_file: {
default: null,
type: r
},
file: {
get: function() {
return this._file;
},
set: function(t, e) {
if (this._file !== t) {
this._file = t;
if (t) {
this._applyFile();
0;
} else this.custom = !0;
}
},
animatable: !1,
type: r,
tooltip: !1
},
_spriteFrame: {
default: null,
type: cc.SpriteFrame
},
spriteFrame: {
get: function() {
return this._spriteFrame;
},
set: function(t, e) {
var i = this._renderSpriteFrame;
if (i !== t) {
this._renderSpriteFrame = t;
t && !t._uuid || (this._spriteFrame = t);
if ((i && i.getTexture()) !== (t && t.getTexture())) {
this._texture = null;
this._applySpriteFrame(i);
}
0;
}
},
type: cc.SpriteFrame,
tooltip: !1
},
_texture: {
default: null,
type: cc.Texture2D,
editorOnly: !0
},
texture: {
get: function() {
return this._texture;
},
set: function(t) {
t && cc.warnID(6017);
},
type: cc.Texture2D,
tooltip: !1,
readonly: !0,
visible: !1,
animatable: !1
},
_srcBlendFactor: d.SRC_ALPHA,
_dstBlendFactor: d.ONE_MINUS_SRC_ALPHA,
srcBlendFactor: {
get: function() {
return this._srcBlendFactor;
},
set: function(t) {
if (this._srcBlendFactor !== t) {
this._srcBlendFactor = t;
this._updateBlendFunc(!0);
}
},
animatable: !1,
type: d,
tooltip: !1
},
dstBlendFactor: {
get: function() {
return this._dstBlendFactor;
},
set: function(t) {
if (this._dstBlendFactor !== t) {
this._dstBlendFactor = t;
this._updateBlendFunc(!0);
}
},
animatable: !1,
type: d,
tooltip: !1
},
particleCount: {
visible: !1,
get: function() {
return this._simulator.particles.length;
},
readonly: !0
},
_stopped: !0,
stopped: {
get: function() {
return this._stopped;
},
animatable: !1,
visible: !1
},
playOnLoad: !0,
autoRemoveOnFinish: {
default: !1,
animatable: !1,
tooltip: !1
},
active: {
get: function() {
return this._simulator.active;
},
visible: !1
},
totalParticles: 150,
duration: -1,
emissionRate: 10,
life: 1,
lifeVar: 0,
_startColor: null,
startColor: {
type: cc.Color,
get: function() {
return this._startColor;
},
set: function(t) {
this._startColor.r = t.r;
this._startColor.g = t.g;
this._startColor.b = t.b;
this._startColor.a = t.a;
}
},
_startColorVar: null,
startColorVar: {
type: cc.Color,
get: function() {
return this._startColorVar;
},
set: function(t) {
this._startColorVar.r = t.r;
this._startColorVar.g = t.g;
this._startColorVar.b = t.b;
this._startColorVar.a = t.a;
}
},
_endColor: null,
endColor: {
type: cc.Color,
get: function() {
return this._endColor;
},
set: function(t) {
this._endColor.r = t.r;
this._endColor.g = t.g;
this._endColor.b = t.b;
this._endColor.a = t.a;
}
},
_endColorVar: null,
endColorVar: {
type: cc.Color,
get: function() {
return this._endColorVar;
},
set: function(t) {
this._endColorVar.r = t.r;
this._endColorVar.g = t.g;
this._endColorVar.b = t.b;
this._endColorVar.a = t.a;
}
},
angle: 90,
angleVar: 20,
startSize: 50,
startSizeVar: 0,
endSize: 0,
endSizeVar: 0,
startSpin: 0,
startSpinVar: 0,
endSpin: 0,
endSpinVar: 0,
sourcePos: cc.Vec2.ZERO,
posVar: cc.Vec2.ZERO,
positionType: {
default: p.FREE,
type: p
},
emitterMode: {
default: m.GRAVITY,
type: m
},
gravity: cc.Vec2.ZERO,
speed: 180,
speedVar: 50,
tangentialAccel: 80,
tangentialAccelVar: 0,
radialAccel: 0,
radialAccelVar: 0,
rotationIsDir: !1,
startRadius: 0,
startRadiusVar: 0,
endRadius: 0,
endRadiusVar: 0,
rotatePerS: 0,
rotatePerSVar: 0
}, y = cc.Class({
name: "cc.ParticleSystem",
extends: s,
editor: !1,
ctor: function() {
this._previewTimer = null;
this._focused = !1;
this._simulator = new _(this);
this._startColor = cc.color(255, 255, 255, 255);
this._startColorVar = cc.color(0, 0, 0, 0);
this._endColor = cc.color(255, 255, 255, 0);
this._endColorVar = cc.color(0, 0, 0, 0);
this._renderSpriteFrame = null;
},
properties: v,
statics: {
DURATION_INFINITY: -1,
START_SIZE_EQUAL_TO_END_SIZE: -1,
START_RADIUS_EQUAL_TO_END_RADIUS: -1,
EmitterMode: m,
PositionType: p,
_PNGReader: a,
_TIFFReader: c
},
onFocusInEditor: !1,
onLostFocusInEditor: !1,
_convertTextureToSpriteFrame: !1,
__preload: function() {
0;
if (this._file) if (this._custom) {
!this._texture && this._applyFile();
} else this._applyFile(); else this._custom && this.spriteFrame && !this._renderSpriteFrame && this._applySpriteFrame(this.spriteFrame);
this.playOnLoad && this.resetSystem();
0;
},
onLoad: function() {
this._ia || y._assembler.createIA(this);
},
onEnable: function() {
this._super();
this.node._renderFlag &= ~u.FLAG_RENDER;
this._activateMaterial();
},
onDestroy: function() {
this.autoRemoveOnFinish && (this.autoRemoveOnFinish = !1);
this._super();
},
lateUpdate: function(t) {
!this._simulator.finished && this._material && this._simulator.step(t);
},
addParticle: function() {},
stopSystem: function() {
this._stopped = !0;
this._simulator.stop();
},
resetSystem: function() {
this._stopped = !1;
this._simulator.reset();
this._activateMaterial();
},
isFull: function() {
return this.particleCount >= this.totalParticles;
},
setTextureWithRect: function(t, e) {
t instanceof cc.Texture2D && (this.spriteFrame = new cc.SpriteFrame(t, e));
},
_applyFile: function() {
var t = this._file;
if (t) {
var e = this;
cc.loader.load(t.nativeUrl, (function(i, n) {
if (!i && n) {
if (e.isValid) {
e._plistFile = t.nativeUrl;
e._custom || e._initWithDictionary(n);
e._spriteFrame ? !e._renderSpriteFrame && e._spriteFrame && e._applySpriteFrame(e.spriteFrame) : t.spriteFrame ? e.spriteFrame = t.spriteFrame : e._custom && e._initTextureWithDictionary(n);
}
} else cc.errorID(6029);
}));
}
},
_initTextureWithDictionary: function(t) {
var e = cc.path.changeBasename(this._plistFile, t.textureFileName || "");
if (t.textureFileName) h.loadImage(e, (function(e, i) {
if (e) {
t.textureFileName = void 0;
this._initTextureWithDictionary(t);
} else this.spriteFrame = new cc.SpriteFrame(i);
}), this); else if (t.textureImageData) {
var i = t.textureImageData;
if (!(i && i.length > 0)) return !1;
var r = cc.loader.getRes(e);
if (!r) {
var s = o.unzipBase64AsArray(i, 1);
if (!s) {
cc.logID(6030);
return !1;
}
var l = (function(t) {
return t.length > 8 && 137 === t[0] && 80 === t[1] && 78 === t[2] && 71 === t[3] && 13 === t[4] && 10 === t[5] && 26 === t[6] && 10 === t[7] ? n.ImageFormat.PNG : t.length > 2 && (73 === t[0] && 73 === t[1] || 77 === t[0] && 77 === t[1] || 255 === t[0] && 216 === t[1]) ? n.ImageFormat.TIFF : n.ImageFormat.UNKNOWN;
})(s);
if (l !== n.ImageFormat.TIFF && l !== n.ImageFormat.PNG) {
cc.logID(6031);
return !1;
}
var u = document.createElement("canvas");
if (l === n.ImageFormat.PNG) {
new a(s).render(u);
} else c.parseTIFF(s, u);
r = h.cacheImage(e, u);
}
r || cc.logID(6032);
this.spriteFrame = new cc.SpriteFrame(r);
}
return !0;
},
_initWithDictionary: function(t) {
this.totalParticles = parseInt(t.maxParticles || 0);
this.life = parseFloat(t.particleLifespan || 0);
this.lifeVar = parseFloat(t.particleLifespanVariance || 0);
var 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 || n.SRC_ALPHA);
this.dstBlendFactor = parseInt(t.blendFuncDestination || n.ONE_MINUS_SRC_ALPHA);
var 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);
var r = this._startColorVar;
r.r = 255 * parseFloat(t.startColorVarianceRed || 0);
r.g = 255 * parseFloat(t.startColorVarianceGreen || 0);
r.b = 255 * parseFloat(t.startColorVarianceBlue || 0);
r.a = 255 * parseFloat(t.startColorVarianceAlpha || 0);
var s = this._endColor;
s.r = 255 * parseFloat(t.finishColorRed || 0);
s.g = 255 * parseFloat(t.finishColorGreen || 0);
s.b = 255 * parseFloat(t.finishColorBlue || 0);
s.a = 255 * parseFloat(t.finishColorAlpha || 0);
var o = this._endColorVar;
o.r = 255 * parseFloat(t.finishColorVarianceRed || 0);
o.g = 255 * parseFloat(t.finishColorVarianceGreen || 0);
o.b = 255 * parseFloat(t.finishColorVarianceBlue || 0);
o.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.sourcePos.x = 0;
this.sourcePos.y = 0;
this.posVar.x = parseFloat(t.sourcePositionVariancex || 0);
this.posVar.y = 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 || m.GRAVITY);
if (this.emitterMode === m.GRAVITY) {
this.gravity.x = parseFloat(t.gravityx || 0);
this.gravity.y = 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);
var a = t.rotationIsDir || "";
if (null !== a) {
a = a.toString().toLowerCase();
this.rotationIsDir = "true" === a || "1" === a;
} else this.rotationIsDir = !1;
} else {
if (this.emitterMode !== m.RADIUS) {
cc.warnID(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;
},
_onTextureLoaded: function() {
this._texture = this._renderSpriteFrame.getTexture();
this._simulator.updateUVs(!0);
this._activateMaterial();
},
_applySpriteFrame: function(t) {
t && t.off && t.off("load", this._onTextureLoaded, this);
var e = this._renderSpriteFrame = this._renderSpriteFrame || this._spriteFrame;
if (e) if (e.textureLoaded()) this._onTextureLoaded(null); else {
e.once("load", this._onTextureLoaded, this);
e.ensureLoadTexture();
}
},
_updateMaterial: function(t) {
this._material = t;
this._updateBlendFunc();
t.updateHash();
},
_updateBlendFunc: function(t) {
if (this._material) {
this._material._mainTech.passes[0].setBlend(f.BLEND_FUNC_ADD, this._srcBlendFactor, this._dstBlendFactor, f.BLEND_FUNC_ADD, this._srcBlendFactor, this._dstBlendFactor);
t && this._material.updateHash();
}
},
_activateMaterial: function() {
if (!this._material) {
this._material = new l.SpriteMaterial();
this._material.useTexture = !0;
this._material.useModel = !0;
this._material.useColor = !1;
}
if (this._texture && this._texture.loaded) {
this.markForUpdateRenderData(!0);
this.markForCustomIARender(!0);
this._material.texture = this._texture;
this._updateMaterial(this._material);
} else {
this.markForCustomIARender(!1);
this._renderSpriteFrame && this._applySpriteFrame();
}
},
_finishedSimulation: function() {
0;
this.disableRender();
this.autoRemoveOnFinish && this._stopped && this.node.destroy();
}
});
cc.ParticleSystem = e.exports = y;
}), {
"../compression/ZipUtils": 22,
"../core/components/CCRenderComponent": 77,
"../core/platform/CCMacro": 165,
"../core/renderer/render-engine": 202,
"../core/renderer/render-flow": 203,
"../core/utils/texture-util": 250,
"./CCPNGReader": 262,
"./CCParticleAsset": 263,
"./CCTIFFReader": 265,
"./particle-simulator": 267,
"fire-url": void 0
} ],
265: [ (function(t, e, i) {
var n = t("../core/CCDebug"), r = {
_littleEndian: !1,
_tiffData: null,
_fileDirectories: [],
getUint8: function(t) {
return this._tiffData[t];
},
getUint16: function(t) {
return this._littleEndian ? this._tiffData[t + 1] << 8 | this._tiffData[t] : this._tiffData[t] << 8 | this._tiffData[t + 1];
},
getUint32: function(t) {
var 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: function() {
var t = this.getUint16(0);
if (18761 === t) this.littleEndian = !0; else {
if (19789 !== t) {
console.log(t);
throw TypeError(n.getError(6019));
}
this.littleEndian = !1;
}
return this.littleEndian;
},
hasTowel: function() {
if (42 !== this.getUint16(2)) throw RangeError(n.getError(6020));
return !0;
},
getFieldTypeName: function(t) {
var e = this.fieldTypeNames;
return t in e ? e[t] : null;
},
getFieldTagName: function(t) {
var e = this.fieldTagNames;
if (t in e) return e[t];
cc.logID(6021, t);
return "Tag" + t;
},
getFieldTypeLength: function(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 : null;
},
getFieldValues: function(t, e, i, n) {
var r = [], s = this.getFieldTypeLength(e);
if (s * i <= 4) !1 === this.littleEndian ? r.push(n >>> 8 * (4 - s)) : r.push(n); else for (var o = 0; o < i; o++) {
var a = s * o;
if (s >= 8) if (-1 !== [ "RATIONAL", "SRATIONAL" ].indexOf(e)) {
r.push(this.getUint32(n + a));
r.push(this.getUint32(n + a + 4));
} else cc.logID(8e3); else r.push(this.getBytes(s, n + a));
}
"ASCII" === e && r.forEach((function(t, e, i) {
i[e] = String.fromCharCode(t);
}));
return r;
},
getBytes: function(t, e) {
if (t <= 0) cc.logID(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);
cc.logID(8002);
}
},
getBits: function(t, e, i) {
i = i || 0;
var n, r, s = e + Math.floor(i / 8), o = i + t, a = 32 - t;
if (o <= 0) cc.logID(6023); else if (o <= 8) {
n = 24 + i;
r = this.getUint8(s);
} else if (o <= 16) {
n = 16 + i;
r = this.getUint16(s);
} else if (o <= 32) {
n = i;
r = this.getUint32(s);
} else cc.logID(6022);
return {
bits: r << n >>> a,
byteOffset: s + Math.floor(o / 8),
bitOffset: o % 8
};
},
parseFileDirectory: function(t) {
for (var e = this.getUint16(t), i = [], n = t + 2, r = 0; r < e; n += 12, r++) {
var s = this.getUint16(n), o = this.getUint16(n + 2), a = this.getUint32(n + 4), c = this.getUint32(n + 8), h = this.getFieldTagName(s), l = this.getFieldTypeName(o), u = this.getFieldValues(h, l, a, c);
i[h] = {
type: l,
values: u
};
}
this._fileDirectories.push(i);
var _ = this.getUint32(n);
0 !== _ && this.parseFileDirectory(_);
},
clampColorSample: function(t, e) {
var i = Math.pow(2, 8 - e);
return Math.floor(t * i + (i - 1));
},
parseTIFF: function(t, e) {
e = e || document.createElement("canvas");
this._tiffData = t;
this.canvas = e;
this.checkLittleEndian();
if (this.hasTowel()) {
var i = this.getUint32(4);
this._fileDirectories.length = 0;
this.parseFileDirectory(i);
var r = this._fileDirectories[0], s = r.ImageWidth.values[0], o = r.ImageLength.values[0];
this.canvas.width = s;
this.canvas.height = o;
var a = [], c = r.Compression ? r.Compression.values[0] : 1, h = r.SamplesPerPixel.values[0], l = [], u = 0, _ = !1;
r.BitsPerSample.values.forEach((function(t, e, i) {
l[e] = {
bitsPerSample: t,
hasBytesPerSample: !1,
bytesPerSample: void 0
};
if (t % 8 == 0) {
l[e].hasBytesPerSample = !0;
l[e].bytesPerSample = t / 8;
}
u += t;
}), this);
if (u % 8 == 0) {
_ = !0;
var f = u / 8;
}
var d = r.StripOffsets.values, m = d.length;
if (r.StripByteCounts) var p = r.StripByteCounts.values; else {
cc.logID(8003);
if (1 !== m) throw Error(n.getError(6024));
p = [ Math.ceil(s * o * u / 8) ];
}
for (var v = 0; v < m; v++) {
var y = d[v];
a[v] = [];
for (var g = p[v], x = 0, C = 0, A = 1, b = !0, S = [], T = 0, w = 0, E = 0; x < g; x += A) switch (c) {
case 1:
var B = 0;
for (S = []; B < h; B++) {
if (!l[B].hasBytesPerSample) {
var M = this.getBits(l[B].bitsPerSample, y + x, C);
S.push(M.bits);
x = M.byteOffset - y;
C = M.bitOffset;
throw RangeError(n.getError(6025));
}
var D = l[B].bytesPerSample * B;
S.push(this.getBytes(l[B].bytesPerSample, y + x + D));
}
a[v].push(S);
if (!_) {
A = 0;
throw RangeError(n.getError(6026));
}
A = f;
break;

case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
break;

case 32773:
if (b) {
b = !1;
var I = 1, P = 1, R = this.getInt8(y + x);
R >= 0 && R <= 127 ? I = R + 1 : R >= -127 && R <= -1 ? P = 1 - R : b = !0;
} else {
var L = this.getUint8(y + x);
for (B = 0; B < P; B++) {
if (!l[w].hasBytesPerSample) throw RangeError(n.getError(6025));
E = E << 8 * T | L;
if (++T === l[w].bytesPerSample) {
S.push(E);
E = T = 0;
w++;
}
if (w === h) {
a[v].push(S);
S = [];
w = 0;
}
}
0 === --I && (b = !0);
}
A = 1;
}
}
if (e.getContext) {
var F = this.canvas.getContext("2d");
F.fillStyle = "rgba(255, 255, 255, 0)";
var V = r.RowsPerStrip ? r.RowsPerStrip.values[0] : o, O = a.length, N = o % V, k = 0 === N ? V : N, G = V, z = 0, U = r.PhotometricInterpretation.values[0], j = [], H = 0;
r.ExtraSamples && (H = (j = r.ExtraSamples.values).length);
if (r.ColorMap) var W = r.ColorMap.values, q = Math.pow(2, l[0].bitsPerSample);
for (v = 0; v < O; v++) {
v + 1 === O && (G = k);
for (var X = a[v].length, Y = z * v, J = 0, Z = 0; Z < X; J++) for (var K = 0; K < s; K++, 
Z++) {
var Q = a[v][Z], $ = 0, tt = 0, et = 0, it = 1;
if (H > 0) for (var nt = 0; nt < H; nt++) if (1 === j[nt] || 2 === j[nt]) {
it = Q[3 + nt] / 256;
break;
}
switch (U) {
case 0:
if (l[0].hasBytesPerSample) var rt = Math.pow(16, 2 * l[0].bytesPerSample);
Q.forEach((function(t, e, i) {
i[e] = rt - t;
}));

case 1:
$ = tt = et = this.clampColorSample(Q[0], l[0].bitsPerSample);
break;

case 2:
$ = this.clampColorSample(Q[0], l[0].bitsPerSample);
tt = this.clampColorSample(Q[1], l[1].bitsPerSample);
et = this.clampColorSample(Q[2], l[2].bitsPerSample);
break;

case 3:
if (void 0 === W) throw Error(n.getError(6027));
var st = Q[0];
$ = this.clampColorSample(W[st], 16);
tt = this.clampColorSample(W[q + st], 16);
et = this.clampColorSample(W[2 * q + st], 16);
break;

default:
throw RangeError(n.getError(6028, U));
}
F.fillStyle = "rgba(" + $ + ", " + tt + ", " + et + ", " + it + ")";
F.fillRect(K, Y + J, 1, 1);
}
z = G;
}
}
return this.canvas;
}
},
fieldTagNames: {
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"
},
fieldTypeNames: {
1: "BYTE",
2: "ASCII",
3: "SHORT",
4: "LONG",
5: "RATIONAL",
6: "SBYTE",
7: "UNDEFINED",
8: "SSHORT",
9: "SLONG",
10: "SRATIONAL",
11: "FLOAT",
12: "DOUBLE"
}
};
e.exports = r;
}), {
"../core/CCDebug": 26
} ],
266: [ (function(t, e, i) {
t("./CCParticleAsset");
t("./CCParticleSystem");
t("./particle-simulator");
t("./particle-system-assembler");
}), {
"./CCParticleAsset": 263,
"./CCParticleSystem": 264,
"./particle-simulator": 267,
"./particle-system-assembler": 268
} ],
267: [ (function(t, e, i) {
var n = t("../core/utils/affine-transform"), r = t("../core/platform/js"), s = t("../core/utils/misc"), o = cc.v2(0, 0), a = n.create(), c = cc.v2(), h = cc.v2(), l = cc.v2(), u = cc.v2(), _ = new r.Pool(function(t) {
t.pos.set(o);
t.startPos.set(o);
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(o);
t.dir.set(o);
t.radialAccel = 0;
t.tangentialAccel = 0;
t.angle = 0;
t.degreesPerSecond = 0;
t.radius = 0;
t.deltaRadius = 0;
}, 1024);
_.get = function() {
return this._get() || new function() {
this.pos = cc.v2(0, 0);
this.startPos = cc.v2(0, 0);
this.color = cc.color(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 = cc.v2(0, 0);
this.dir = cc.v2(0, 0);
this.radialAccel = 0;
this.tangentialAccel = 0;
this.angle = 0;
this.degreesPerSecond = 0;
this.radius = 0;
this.deltaRadius = 0;
}();
};
var f = function(t) {
this.sys = t;
this.particles = [];
this.active = !1;
this.finished = !1;
this.elapsed = 0;
this.emitCounter = 0;
this._uvFilled = 0;
};
f.prototype.stop = function() {
this.active = !1;
this.elapsed = this.sys.duration;
this.emitCounter = 0;
};
f.prototype.reset = function() {
this.active = !0;
this.elapsed = 0;
this.emitCounter = 0;
this.finished = !1;
for (var t = this.particles, e = 0; e < t.length; ++e) _.put(t[e]);
t.length = 0;
};
f.prototype.emitParticle = function(t) {
var e = this.sys, i = s.clampf, n = _.get();
this.particles.push(n);
n.timeToLive = e.life + e.lifeVar * (Math.random() - .5) * 2;
var r = n.timeToLive = Math.max(0, n.timeToLive);
n.pos.x = e.sourcePos.x + e.posVar.x * (Math.random() - .5) * 2;
n.pos.y = e.sourcePos.y + e.posVar.y * (Math.random() - .5) * 2;
var o, a, c, h, l = e._startColor, u = e._startColorVar, f = e._endColor, d = e._endColorVar;
n.color.r = o = i(l.r + u.r * (Math.random() - .5) * 2, 0, 255);
n.color.g = a = i(l.g + u.g * (Math.random() - .5) * 2, 0, 255);
n.color.b = c = i(l.b + u.b * (Math.random() - .5) * 2, 0, 255);
n.color.a = h = i(l.a + u.a * (Math.random() - .5) * 2, 0, 255);
n.deltaColor.r = (i(f.r + d.r * (Math.random() - .5) * 2, 0, 255) - o) / r;
n.deltaColor.g = (i(f.g + d.g * (Math.random() - .5) * 2, 0, 255) - a) / r;
n.deltaColor.b = (i(f.b + d.b * (Math.random() - .5) * 2, 0, 255) - c) / r;
n.deltaColor.a = (i(f.a + d.a * (Math.random() - .5) * 2, 0, 255) - h) / r;
var m = e.startSize + e.startSizeVar * (Math.random() - .5) * 2;
m = Math.max(0, m);
n.size = m;
if (e.endSize === cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE) n.deltaSize = 0; else {
var p = e.endSize + e.endSizeVar * (Math.random() - .5) * 2;
p = Math.max(0, p);
n.deltaSize = (p - m) / r;
}
var v = e.startSpin + e.startSpinVar * (Math.random() - .5) * 2, y = e.endSpin + e.endSpinVar * (Math.random() - .5) * 2;
n.rotation = v;
n.deltaRotation = (y - v) / r;
n.startPos.x = t.x;
n.startPos.y = t.y;
var g = s.degreesToRadians(e.angle + e.angleVar * (Math.random() - .5) * 2);
if (e.emitterMode === cc.ParticleSystem.EmitterMode.GRAVITY) {
var x = e.speed + e.speedVar * (Math.random() - .5) * 2;
n.dir.x = Math.cos(g);
n.dir.y = Math.sin(g);
n.dir.mulSelf(x);
n.radialAccel = e.radialAccel + e.radialAccelVar * (Math.random() - .5) * 2;
n.tangentialAccel = e.tangentialAccel + e.tangentialAccelVar * (Math.random() - .5) * 2;
e.rotationIsDir && (n.rotation = -s.radiansToDegrees(Math.atan2(n.dir.y, n.dir.x)));
} else {
var C = e.startRadius + e.startRadiusVar * (Math.random() - .5) * 2, A = e.endRadius + e.endRadiusVar * (Math.random() - .5) * 2;
n.radius = C;
n.deltaRadius = e.endRadius === cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS ? 0 : (A - C) / r;
n.angle = g;
n.degreesPerSecond = s.degreesToRadians(e.rotatePerS + e.rotatePerSVar * (Math.random() - .5) * 2);
}
};
f.prototype.updateUVs = function(t) {
var e = this.particles.length;
if (this.sys._buffer && this.sys._renderSpriteFrame) {
for (var i = 4 * this.sys._vertexFormat._bytes / 4, n = this.sys._buffer._vData, r = this.sys._renderSpriteFrame.uv, s = t ? 0 : this._uvFilled; s < e; s++) {
var o = s * i;
n[o + 2] = r[0];
n[o + 3] = r[1];
n[o + 7] = r[2];
n[o + 8] = r[3];
n[o + 12] = r[4];
n[o + 13] = r[5];
n[o + 17] = r[6];
n[o + 18] = r[7];
}
this._uvFilled = e;
}
};
f.prototype.updateParticleBuffer = function(t, e, i, n) {
var r = i._vData, o = i._uintVData, a = e.x, c = e.y, h = t.size / 2;
if (t.rotation) {
var l = -h, u = -h, _ = h, f = h, d = -s.degreesToRadians(t.rotation), m = Math.cos(d), p = Math.sin(d);
r[n] = l * m - u * p + a;
r[n + 1] = l * p + u * m + c;
r[n + 5] = _ * m - u * p + a;
r[n + 6] = _ * p + u * m + c;
r[n + 10] = l * m - f * p + a;
r[n + 11] = l * p + f * m + c;
r[n + 15] = _ * m - f * p + a;
r[n + 16] = _ * p + f * m + c;
} else {
r[n] = a - h;
r[n + 1] = c - h;
r[n + 5] = a + h;
r[n + 6] = c - h;
r[n + 10] = a - h;
r[n + 11] = c + h;
r[n + 15] = a + h;
r[n + 16] = c + h;
}
o[n + 4] = t.color._val;
o[n + 9] = t.color._val;
o[n + 14] = t.color._val;
o[n + 19] = t.color._val;
};
f.prototype.step = function(t) {
var e = this.sys, i = e.node, r = this.particles, s = 4 * e._vertexFormat._bytes / 4;
i._updateWorldMatrix();
n.fromMat4(a, i._worldMatrix);
if (e.positionType === cc.ParticleSystem.PositionType.FREE) n.transformVec2(c, o, a); else if (e.positionType === cc.ParticleSystem.PositionType.RELATIVE) {
c.x = i._position.x;
c.y = i._position.y;
}
n.invert(a, a);
var f = a;
if (this.active && e.emissionRate) {
var d = 1 / e.emissionRate;
r.length < e.totalParticles && (this.emitCounter += t);
for (;r.length < e.totalParticles && this.emitCounter > d; ) {
this.emitParticle(c);
this.emitCounter -= d;
}
this.elapsed += t;
-1 !== e.duration && e.duration < this.elapsed && e.stopSystem();
}
var m = e._buffer, p = r.length;
m.reset();
m.request(4 * p, 6 * p);
p > this._uvFilled && this.updateUVs();
for (var v = 0; v < r.length; ) {
h.x = h.y = l.x = l.y = u.x = u.y = 0;
var y = r[v];
y.timeToLive -= t;
if (y.timeToLive > 0) {
if (e.emitterMode === cc.ParticleSystem.EmitterMode.GRAVITY) {
var g = u, x = h, C = l;
if (y.pos.x || y.pos.y) {
x.set(y.pos);
x.normalizeSelf();
}
C.set(x);
x.mulSelf(y.radialAccel);
var A = C.x;
C.x = -C.y;
C.y = A;
C.mulSelf(y.tangentialAccel);
g.set(x);
g.addSelf(C);
g.addSelf(e.gravity);
g.mulSelf(t);
y.dir.addSelf(g);
g.set(y.dir);
g.mulSelf(t);
y.pos.addSelf(g);
} else {
y.angle += y.degreesPerSecond * t;
y.radius += y.deltaRadius * t;
y.pos.x = -Math.cos(y.angle) * y.radius;
y.pos.y = -Math.sin(y.angle) * y.radius;
}
y.color.r += y.deltaColor.r * t;
y.color.g += y.deltaColor.g * t;
y.color.b += y.deltaColor.b * t;
y.color.a += y.deltaColor.a * t;
y.size += y.deltaSize * t;
y.size < 0 && (y.size = 0);
y.rotation += y.deltaRotation * t;
var b = h;
if (e.positionType === cc.ParticleSystem.PositionType.FREE || e.positionType === cc.ParticleSystem.PositionType.RELATIVE) {
var S = l, T = u;
n.transformVec2(S, c, f);
n.transformVec2(T, y.startPos, f);
S.subSelf(T);
b.set(y.pos);
b.subSelf(S);
} else b.set(y.pos);
var w = s * v;
this.updateParticleBuffer(y, b, m, w);
++v;
} else {
var E = r[v];
v !== r.length - 1 && (r[v] = r[r.length - 1]);
_.put(E);
r.length--;
}
}
if (r.length > 0) {
m.uploadData();
e._ia._count = 6 * r.length;
} else if (!this.active) {
this.finished = !0;
e._finishedSimulation();
}
};
e.exports = f;
}), {
"../core/platform/js": 180,
"../core/utils/affine-transform": 234,
"../core/utils/misc": 242
} ],
268: [ (function(t, e, i) {
var n = t("./CCParticleSystem"), r = t("../core/renderer/"), s = t("../core/renderer/render-engine"), o = t("../core/renderer/webgl/vertex-format").vfmtPosUvColor, a = t("../core/renderer/webgl/quad-buffer"), c = {
useModel: !0,
createIA: function(t) {
r.device;
t._vertexFormat = o;
t._buffer = new a(r._handle, o);
t._ia = new s.InputAssembler();
t._ia._vertexBuffer = t._buffer._vb;
t._ia._indexBuffer = t._buffer._ib;
t._ia._start = 0;
t._ia._count = 0;
},
updateRenderData: function(t) {
if (!t._renderData) {
t._renderData = new s.IARenderData();
t._renderData.ia = t._ia;
}
t._renderData.material = t._material;
},
renderIA: function(t, e) {
e._flushIA(t._renderData);
}
};
n._assembler = c;
e.exports = c;
}), {
"../core/renderer/": 201,
"../core/renderer/render-engine": 202,
"../core/renderer/webgl/quad-buffer": 229,
"../core/renderer/webgl/vertex-format": 232,
"./CCParticleSystem": 264
} ],
269: [ (function(t, e, i) {
"use strict";
var n = t("../compression/ZipUtils"), r = t("../compression/zlib.min"), s = t("../core/platform/js");
t("../core/platform/CCSAXParser");
cc.TMXLayerInfo = function() {
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 = cc.v2(0, 0);
};
cc.TMXLayerInfo.prototype = {
constructor: cc.TMXLayerInfo,
getProperties: function() {
return this.properties;
},
setProperties: function(t) {
this.properties = t;
}
};
cc.TMXObjectGroupInfo = function() {
this.properties = {};
this.name = "";
this._objects = [];
this.visible = !0;
this._opacity = 0;
this._color = new cc.Color(255, 255, 255, 255);
this.offset = cc.v2(0, 0);
this._draworder = "topdown";
};
cc.TMXObjectGroupInfo.prototype = {
constructor: cc.TMXObjectGroupInfo,
getProperties: function() {
return this.properties;
},
setProperties: function(t) {
this.properties = t;
}
};
cc.TMXTilesetInfo = function() {
this.name = "";
this.firstGid = 0;
this.spacing = 0;
this.margin = 0;
this.sourceImage = null;
this.imageSize = cc.size(0, 0);
this.tileOffset = cc.v2(0, 0);
this._tileSize = cc.size(0, 0);
};
cc.TMXTilesetInfo.prototype = {
constructor: cc.TMXTilesetInfo,
rectForGID: function(t, e) {
var i = e || cc.rect(0, 0, 0, 0);
i.width = this._tileSize.width;
i.height = this._tileSize.height;
t &= cc.TiledMap.TileFlag.FLIPPED_MASK;
t -= parseInt(this.firstGid, 10);
var n = parseInt((this.imageSize.width - 2 * this.margin + this.spacing) / (this._tileSize.width + this.spacing), 10);
i.x = parseInt(t % n * (this._tileSize.width + this.spacing) + this.margin, 10);
i.y = parseInt(parseInt(t / n, 10) * (this._tileSize.height + this.spacing) + this.margin, 10);
return i;
}
};
function o(t, e) {
for (var i = [], n = t.getElementsByTagName("properties"), r = 0; r < n.length; ++r) for (var s = n[r].getElementsByTagName("property"), o = 0; o < s.length; ++o) i.push(s[o]);
e = e || {};
for (var a = 0; a < i.length; a++) {
var c = i[a], h = c.getAttribute("name"), l = c.getAttribute("type") || "string", u = c.getAttribute("value");
if ("int" === l) u = parseInt(u); else if ("float" === l) u = parseFloat(u); else if ("bool" === l) u = "true" === u; else if ("color" === l) {
u = 0 === u.indexOf("#") ? u.substring(1) : u;
var _ = parseInt(u.substr(0, 2), 16) || 255, f = parseInt(u.substr(2, 2), 16) || 0, d = parseInt(u.substr(4, 2), 16) || 0, m = parseInt(u.substr(6, 2), 16) || 0;
u = cc.color(f, d, m, _);
}
e[h] = u;
}
return e;
}
cc.TMXMapInfo = function(t, e, i) {
this.properties = [];
this.orientation = null;
this.parentElement = null;
this.parentGID = null;
this.layerAttrs = 0;
this.storingCharacters = !1;
this.currentString = null;
this._parser = new cc.SAXParser();
this._objectGroups = [];
this._allChildren = [];
this._mapSize = cc.size(0, 0);
this._tileSize = cc.size(0, 0);
this._layers = [];
this._tilesets = [];
this._tileProperties = {};
this._tsxMap = null;
this._textures = null;
this._staggerAxis = null;
this._staggerIndex = null;
this._hexSideLength = 0;
this.initWithXML(t, e, i);
};
cc.TMXMapInfo.prototype = {
constructor: cc.TMXMapInfo,
getOrientation: function() {
return this.orientation;
},
setOrientation: function(t) {
this.orientation = t;
},
getStaggerAxis: function() {
return this._staggerAxis;
},
setStaggerAxis: function(t) {
this._staggerAxis = t;
},
getStaggerIndex: function() {
return this._staggerIndex;
},
setStaggerIndex: function(t) {
this._staggerIndex = t;
},
getHexSideLength: function() {
return this._hexSideLength;
},
setHexSideLength: function(t) {
this._hexSideLength = t;
},
getMapSize: function() {
return cc.size(this._mapSize.width, this._mapSize.height);
},
setMapSize: function(t) {
this._mapSize.width = t.width;
this._mapSize.height = t.height;
},
_getMapWidth: function() {
return this._mapSize.width;
},
_setMapWidth: function(t) {
this._mapSize.width = t;
},
_getMapHeight: function() {
return this._mapSize.height;
},
_setMapHeight: function(t) {
this._mapSize.height = t;
},
getTileSize: function() {
return cc.size(this._tileSize.width, this._tileSize.height);
},
setTileSize: function(t) {
this._tileSize.width = t.width;
this._tileSize.height = t.height;
},
_getTileWidth: function() {
return this._tileSize.width;
},
_setTileWidth: function(t) {
this._tileSize.width = t;
},
_getTileHeight: function() {
return this._tileSize.height;
},
_setTileHeight: function(t) {
this._tileSize.height = t;
},
getLayers: function() {
return this._layers;
},
setLayers: function(t) {
this._allChildren.push(t);
this._layers.push(t);
},
getTilesets: function() {
return this._tilesets;
},
setTilesets: function(t) {
this._tilesets.push(t);
},
getObjectGroups: function() {
return this._objectGroups;
},
setObjectGroups: function(t) {
this._allChildren.push(t);
this._objectGroups.push(t);
},
getAllChildren: function() {
return this._allChildren;
},
getParentElement: function() {
return this.parentElement;
},
setParentElement: function(t) {
this.parentElement = t;
},
getParentGID: function() {
return this.parentGID;
},
setParentGID: function(t) {
this.parentGID = t;
},
getLayerAttribs: function() {
return this.layerAttrs;
},
setLayerAttribs: function(t) {
this.layerAttrs = t;
},
getStoringCharacters: function() {
return this.storingCharacters;
},
setStoringCharacters: function(t) {
this.storingCharacters = t;
},
getProperties: function() {
return this.properties;
},
setProperties: function(t) {
this.properties = t;
},
initWithXML: function(t, e, i) {
this._tilesets.length = 0;
this._layers.length = 0;
this._tsxMap = e;
this._textures = i;
this._objectGroups.length = 0;
this._allChildren.length = 0;
this.properties.length = 0;
this._tileProperties.length = 0;
this.currentString = "";
this.storingCharacters = !1;
this.layerAttrs = cc.TMXLayerInfo.ATTRIB_NONE;
this.parentElement = cc.TiledMap.NONE;
return this.parseXMLString(t);
},
parseXMLString: function(t, e) {
var i = void 0, n = this._parser._parseXML(t).documentElement, r = n.getAttribute("version"), s = n.getAttribute("orientation"), a = n.getAttribute("staggeraxis"), c = n.getAttribute("staggerindex"), h = n.getAttribute("hexsidelength");
if ("map" === n.nodeName) {
"1.0" !== r && null !== r && cc.logID(7216, r);
"orthogonal" === s ? this.orientation = cc.TiledMap.Orientation.ORTHO : "isometric" === s ? this.orientation = cc.TiledMap.Orientation.ISO : "hexagonal" === s ? this.orientation = cc.TiledMap.Orientation.HEX : null !== s && cc.logID(7217, s);
"x" === a ? this.setStaggerAxis(cc.TiledMap.StaggerAxis.STAGGERAXIS_X) : "y" === a && this.setStaggerAxis(cc.TiledMap.StaggerAxis.STAGGERAXIS_Y);
"odd" === c ? this.setStaggerIndex(cc.TiledMap.StaggerIndex.STAGGERINDEX_ODD) : "even" === c && this.setStaggerIndex(cc.TiledMap.StaggerIndex.STAGGERINDEX_EVEN);
h && this.setHexSideLength(parseFloat(h));
var l = cc.size(0, 0);
l.width = parseFloat(n.getAttribute("width"));
l.height = parseFloat(n.getAttribute("height"));
this.setMapSize(l);
(l = cc.size(0, 0)).width = parseFloat(n.getAttribute("tilewidth"));
l.height = parseFloat(n.getAttribute("tileheight"));
this.setTileSize(l);
this.properties = o(n);
}
var u = n.getElementsByTagName("tileset");
"map" !== n.nodeName && (u = []).push(n);
for (i = 0; i < u.length; i++) {
var _ = u[i], f = _.getAttribute("source");
if (f) {
var d = parseInt(_.getAttribute("firstgid")), m = this._tsxMap[f];
m && this.parseXMLString(m, d);
} else {
var p = new cc.TMXTilesetInfo();
p.name = _.getAttribute("name") || "";
p.firstGid = e || (parseInt(_.getAttribute("firstgid")) || 0);
p.spacing = parseInt(_.getAttribute("spacing")) || 0;
p.margin = parseInt(_.getAttribute("margin")) || 0;
var v = cc.size(0, 0);
v.width = parseFloat(_.getAttribute("tilewidth"));
v.height = parseFloat(_.getAttribute("tileheight"));
p._tileSize = v;
var y = _.getElementsByTagName("image")[0].getAttribute("source");
y.replace(/\\/g, "/");
p.sourceImage = this._textures[y];
p.sourceImage || cc.errorID(7221, y);
this.setTilesets(p);
var g = _.getElementsByTagName("tileoffset")[0];
if (g) {
var x = parseFloat(g.getAttribute("x")), C = parseFloat(g.getAttribute("y"));
p.tileOffset = cc.v2(x, C);
}
var A = _.getElementsByTagName("tile");
if (A) for (var b = 0; b < A.length; b++) {
var S = A[b];
this.parentGID = parseInt(p.firstGid) + parseInt(S.getAttribute("id") || 0);
this._tileProperties[this.parentGID] = o(S);
}
}
}
var T = n.childNodes;
for (i = 0; i < T.length; i++) {
var w = T[i];
if (!this._shouldIgnoreNode(w)) {
if ("layer" === w.nodeName) {
var E = this._parseLayer(w);
this.setLayers(E);
}
if ("objectgroup" === w.nodeName) {
var B = this._parseObjectGroup(w);
this.setObjectGroups(B);
}
}
}
return n;
},
_shouldIgnoreNode: function(t) {
return 3 === t.nodeType || 8 === t.nodeType || 4 === t.nodeType;
},
_parseLayer: function(t) {
var e = t.getElementsByTagName("data")[0], i = new cc.TMXLayerInfo();
i.name = t.getAttribute("name");
var s = cc.size(0, 0);
s.width = parseFloat(t.getAttribute("width"));
s.height = parseFloat(t.getAttribute("height"));
i._layerSize = s;
var a = t.getAttribute("visible");
i.visible = !("0" === a);
var c = t.getAttribute("opacity") || 1;
i._opacity = c ? parseInt(255 * parseFloat(c)) : 255;
i.offset = cc.v2(parseFloat(t.getAttribute("x")) || 0, parseFloat(t.getAttribute("y")) || 0);
for (var h = "", l = 0; l < e.childNodes.length; l++) h += e.childNodes[l].nodeValue;
h = h.trim();
var u = e.getAttribute("compression"), _ = e.getAttribute("encoding");
if (u && "gzip" !== u && "zlib" !== u) {
cc.logID(7218);
return null;
}
var f = void 0;
switch (u) {
case "gzip":
f = n.unzipBase64AsArray(h, 4);
break;

case "zlib":
f = (function(t) {
if (t.length % 4 != 0) return null;
for (var e = t.length / 4, i = window.Uint32Array ? new Uint32Array(e) : [], n = 0; n < e; n++) {
var r = 4 * n;
i[n] = t[r] + 256 * t[r + 1] + 65536 * t[r + 2] + t[r + 3] * (1 << 24);
}
return i;
})(new r.Inflate(n.Base64.decodeAsArray(h, 1)).decompress());
break;

case null:
case "":
if ("base64" === _) f = n.Base64.decodeAsArray(h, 4); else if ("csv" === _) {
f = [];
for (var d = h.split(","), m = 0; m < d.length; m++) f.push(parseInt(d[m]));
} else {
var p = e.getElementsByTagName("tile");
f = [];
for (var v = 0; v < p.length; v++) f.push(parseInt(p[v].getAttribute("gid")));
}
break;

default:
this.layerAttrs === cc.TMXLayerInfo.ATTRIB_NONE && cc.logID(7219);
}
f && (i._tiles = new Uint32Array(f));
i.properties = o(t);
return i;
},
_parseObjectGroup: function(t) {
var e = new cc.TMXObjectGroupInfo();
e.name = t.getAttribute("name") || "";
e.offset = cc.v2(parseFloat(t.getAttribute("offsetx")), parseFloat(t.getAttribute("offsety")));
var i = t.getAttribute("opacity") || 1;
e._opacity = i ? parseInt(255 * parseFloat(i)) : 255;
var n = t.getAttribute("visible");
n && 0 === parseInt(n) && (e.visible = !1);
var r = t.getAttribute("color");
r && e._color.fromHEX(r);
var s = t.getAttribute("draworder");
s && (e._draworder = s);
e.setProperties(o(t));
var a = t.getElementsByTagName("object");
if (a) for (var c = 0; c < a.length; c++) {
var h = a[c], l = {};
l.id = h.getAttribute("id") || 0;
l.name = h.getAttribute("name") || "";
l.width = parseFloat(h.getAttribute("width")) || 0;
l.height = parseFloat(h.getAttribute("height")) || 0;
l.x = parseFloat(h.getAttribute("x")) || 0;
l.y = parseFloat(h.getAttribute("y")) || 0;
l.rotation = parseFloat(h.getAttribute("rotation")) || 0;
o(h, l);
var u = h.getAttribute("visible");
l.visible = !(u && 0 === parseInt(u));
var _ = h.getAttribute("gid");
if (_) {
l.gid = parseInt(_);
l.type = cc.TiledMap.TMXObjectType.IMAGE;
}
var f = h.getElementsByTagName("ellipse");
f && f.length > 0 && (l.type = cc.TiledMap.TMXObjectType.ELLIPSE);
var d = h.getElementsByTagName("polygon");
if (d && d.length > 0) {
l.type = cc.TiledMap.TMXObjectType.POLYGON;
var m = d[0].getAttribute("points");
m && (l.points = this._parsePointsString(m));
}
var p = h.getElementsByTagName("polyline");
if (p && p.length > 0) {
l.type = cc.TiledMap.TMXObjectType.POLYLINE;
var v = p[0].getAttribute("points");
v && (l.polylinePoints = this._parsePointsString(v));
}
l.type || (l.type = cc.TiledMap.TMXObjectType.RECT);
e._objects.push(l);
}
return e;
},
_parsePointsString: function(t) {
if (!t) return null;
for (var e = [], i = t.split(" "), n = 0; n < i.length; n++) {
var r = i[n].split(",");
e.push({
x: parseFloat(r[0]),
y: parseFloat(r[1])
});
}
return e;
},
getTileProperties: function() {
return this._tileProperties;
},
setTileProperties: function(t) {
this._tileProperties.push(t);
},
getCurrentString: function() {
return this.currentString;
},
setCurrentString: function(t) {
this.currentString = t;
}
};
var a = cc.TMXMapInfo.prototype;
s.getset(a, "mapWidth", a._getMapWidth, a._setMapWidth);
s.getset(a, "mapHeight", a._getMapHeight, a._setMapHeight);
s.getset(a, "tileWidth", a._getTileWidth, a._setTileWidth);
s.getset(a, "tileHeight", a._getTileHeight, a._setTileHeight);
cc.TMXLayerInfo.ATTRIB_NONE = 1;
cc.TMXLayerInfo.ATTRIB_BASE64 = 2;
cc.TMXLayerInfo.ATTRIB_GZIP = 4;
cc.TMXLayerInfo.ATTRIB_ZLIB = 8;
}), {
"../compression/ZipUtils": 22,
"../compression/zlib.min": 25,
"../core/platform/CCSAXParser": 167,
"../core/platform/js": 180
} ],
270: [ (function(i, n, r) {
var s = i("../core/components/CCRenderComponent"), o = i("../core/renderer/render-engine").SpriteMaterial, a = cc.Class({
name: "cc.TiledLayer",
extends: s,
ctor: function() {
this._tiles = [];
this._texGrids = [];
this._textures = [];
this._spriteTiles = {};
this._tiledTiles = [];
this._layerName = "";
this._layerOrientation = null;
},
getLayerName: function() {
return this._layerName;
},
setLayerName: function(t) {
this._layerName = t;
},
getProperty: function(t) {
return this._properties[t];
},
getPositionAt: function(t, e) {
var i = void 0;
if (void 0 !== e) {
i = Math.floor(t);
e = Math.floor(e);
} else {
i = Math.floor(t.x);
e = Math.floor(t.y);
}
var n = void 0;
switch (this._layerOrientation) {
case cc.TiledMap.Orientation.ORTHO:
n = this._positionForOrthoAt(i, e);
break;

case cc.TiledMap.Orientation.ISO:
n = this._positionForIsoAt(i, e);
break;

case cc.TiledMap.Orientation.HEX:
n = this._positionForHexAt(i, e);
}
return n;
},
_isInvalidPosition: function(i, n) {
if (i && "object" === ("object" === (e = typeof i) ? t(i) : e)) {
var r = i;
n = r.y;
i = r.x;
}
return i >= this._layerSize.width || n >= this._layerSize.height || i < 0 || n < 0;
},
_positionForIsoAt: function(t, e) {
return cc.v2(this._mapTileSize.width / 2 * (this._layerSize.width + t - e - 1), this._mapTileSize.height / 2 * (2 * this._layerSize.height - t - e - 2));
},
_positionForOrthoAt: function(t, e) {
return cc.v2(t * this._mapTileSize.width, (this._layerSize.height - e - 1) * this._mapTileSize.height);
},
_positionForHexAt: function(t, e) {
var i = this._mapTileSize.width, n = this._mapTileSize.height, r = this._layerSize.height, s = this._tileset.tileOffset, o = this.node.width / 2, a = this.node.height / 2, c = this._staggerIndex === cc.TiledMap.StaggerIndex.STAGGERINDEX_ODD ? 1 : -1, h = 0, l = 0;
switch (this._staggerAxis) {
case cc.TiledMap.StaggerAxis.STAGGERAXIS_Y:
var u = 0, _ = this._staggerIndex === cc.TiledMap.StaggerIndex.STAGGERINDEX_ODD ? 0 : i / 2;
e % 2 == 1 && (u = i / 2 * c);
h = t * i + u + _ + s.x - o;
l = (r - e - 1) * (n - (n - this._hexSideLength) / 2) - s.y - a;
break;

case cc.TiledMap.StaggerAxis.STAGGERAXIS_X:
var f = 0, d = this._staggerIndex === cc.TiledMap.StaggerIndex.STAGGERINDEX_ODD ? n / 2 : 0;
t % 2 == 1 && (f = n / 2 * -c);
h = t * (i - (i - this._hexSideLength) / 2) + s.x - o;
l = (r - e - 1) * n + f + d - s.y - a;
}
return cc.v2(h, l);
},
setTileGIDAt: function(t, e, i, n) {
if (void 0 === e) throw new Error("cc.TiledLayer.setTileGIDAt(): pos should be non-null");
var r = void 0;
if (void 0 === n && e instanceof cc.Vec2) {
r = e;
n = i;
} else r = cc.v2(e, i);
r.x = Math.floor(r.x);
r.y = Math.floor(r.y);
if (this._isInvalidPosition(r)) throw new Error("cc.TiledLayer.setTileGIDAt(): invalid position");
if (this._tiles) if (0 !== t && t < this._tileset.firstGid) cc.logID(7239, t); else {
n = n || 0;
var s = this.getTileFlagsAt(r);
if (this.getTileGIDAt(r) !== t || s !== n) {
var o = (t | n) >>> 0;
this._updateTileForGID(o, r);
}
} else cc.logID(7238);
},
_updateTileForGID: function(t, e) {
if (0 === t || this._texGrids[t]) {
var i = 0 | e.x + e.y * this._layerSize.width;
i < this._tiles.length && (this._tiles[i] = t);
}
},
getTileGIDAt: function(t, e) {
if (void 0 === t) throw new Error("cc.TiledLayer.getTileGIDAt(): pos should be non-null");
var i = t;
if (void 0 === e) {
i = t.x;
e = t.y;
}
if (this._isInvalidPosition(i, e)) throw new Error("cc.TiledLayer.getTileGIDAt(): invalid position");
if (!this._tiles) {
cc.logID(7237);
return null;
}
var n = Math.floor(i) + Math.floor(e) * this._layerSize.width;
return (this._tiles[n] & cc.TiledMap.TileFlag.FLIPPED_MASK) >>> 0;
},
getTileFlagsAt: function(t, e) {
if (!t) throw new Error("TiledLayer.getTileFlagsAt: pos should be non-null");
void 0 !== e && (t = cc.v2(t, e));
if (this._isInvalidPosition(t)) throw new Error("TiledLayer.getTileFlagsAt: invalid position");
if (!this._tiles) {
cc.logID(7240);
return null;
}
var i = Math.floor(t.x) + Math.floor(t.y) * this._layerSize.width;
return (this._tiles[i] & cc.TiledMap.TileFlag.FLIPPED_ALL) >>> 0;
},
getTiledTileAt: function(t, e, i) {
if (this._isInvalidPosition(t, e)) throw new Error("TiledLayer.getTiledTileAt: invalid position");
if (!this._tiles) {
cc.logID(7236);
return null;
}
var n = Math.floor(t) + Math.floor(e) * this._layerSize.width, r = this._tiledTiles[n];
if (!r && i) {
var s = new cc.Node();
(r = s.addComponent(cc.TiledTile))._x = t;
r._y = e;
r._layer = this;
r._updateInfo();
s.parent = this.node;
return r;
}
return r;
},
setTiledTileAt: function(t, e, i) {
if (this._isInvalidPosition(t, e)) throw new Error("TiledLayer.setTiledTileAt: invalid position");
if (!this._tiles) {
cc.logID(7236);
return null;
}
var n = Math.floor(t) + Math.floor(e) * this._layerSize.width;
return this._tiledTiles[n] = i;
},
getTexture: function() {
return this._texture;
},
setTexture: function(t) {
this._texture = t;
this._activateMaterial();
},
getLayerSize: function() {
return this._layerSize;
},
getMapTileSize: function() {
return this._mapTileSize;
},
getTileSet: function() {
return this._tileset;
},
setTileSet: function(t) {
this._tileset = t;
},
getLayerOrientation: function() {
return this._layerOrientation;
},
getProperties: function() {
return this._properties;
},
_init: function(t, e, i) {
var n = e._layerSize;
this._layerName = e.name;
this._tiles = e._tiles;
this._properties = e.properties;
this._layerSize = n;
this._minGID = e._minGID;
this._maxGID = e._maxGID;
this._opacity = e._opacity;
this._staggerAxis = i.getStaggerAxis();
this._staggerIndex = i.getStaggerIndex();
this._hexSideLength = i.getHexSideLength();
this._tileset = t;
this._layerOrientation = i.orientation;
this._mapTileSize = i.getTileSize();
var r = i._tilesets;
if (r) {
this._textures.length = r.length;
this._texGrids.length = 0;
for (var s = 0, o = r.length; s < o; ++s) {
var a = r[s], c = a.sourceImage;
this._textures[s] = c;
this._fillTextureGrids(a, s);
t === a && (this._texture = c);
}
}
this._offset = this._calculateLayerOffset(e.offset);
if (this._layerOrientation === cc.TiledMap.Orientation.HEX) {
var h = 0, l = 0;
if (this._staggerAxis === cc.TiledMap.StaggerAxis.STAGGERAXIS_X) {
l = i._tileSize.height * (this._layerSize.height + .5);
h = (i._tileSize.width + this._hexSideLength) * Math.floor(this._layerSize.width / 2) + i._tileSize.width * (this._layerSize.width % 2);
} else {
h = i._tileSize.width * (this._layerSize.width + .5);
l = (i._tileSize.height + this._hexSideLength) * Math.floor(this._layerSize.height / 2) + i._tileSize.height * (this._layerSize.height % 2);
}
this.node.setContentSize(h, l);
} else this.node.setContentSize(this._layerSize.width * this._mapTileSize.width, this._layerSize.height * this._mapTileSize.height);
this._useAutomaticVertexZ = !1;
this._vertexZvalue = 0;
this._activateMaterial();
},
_calculateLayerOffset: function(t) {
var e = cc.v2(0, 0);
switch (this._layerOrientation) {
case cc.TiledMap.Orientation.ORTHO:
e = cc.v2(t.x * this._mapTileSize.width, -t.y * this._mapTileSize.height);
break;

case cc.TiledMap.Orientation.ISO:
e = cc.v2(this._mapTileSize.width / 2 * (t.x - t.y), this._mapTileSize.height / 2 * (-t.x - t.y));
break;

case cc.TiledMap.Orientation.HEX:
if (this._staggerAxis === cc.TiledMap.StaggerAxis.STAGGERAXIS_Y) {
var i = this._staggerIndex === cc.TiledMap.StaggerIndex.STAGGERINDEX_EVEN ? this._mapTileSize.width / 2 : 0;
e = cc.v2(t.x * this._mapTileSize.width + i, -t.y * (this._mapTileSize.height - (this._mapTileSize.width - this._hexSideLength) / 2));
} else if (this._staggerAxis === cc.TiledMap.StaggerAxis.STAGGERAXIS_X) {
var n = this._staggerIndex === cc.TiledMap.StaggerIndex.STAGGERINDEX_ODD ? this._mapTileSize.height / 2 : 0;
e = cc.v2(t.x * (this._mapTileSize.width - (this._mapTileSize.width - this._hexSideLength) / 2), -t.y * this._mapTileSize.height + n);
}
}
return e;
},
_fillTextureGrids: function(t, e) {
var i = this._textures[e];
if (i) if (i.loaded) {
if (!t.imageSize.width || !t.imageSize.height) {
t.imageSize.width = i.width;
t.imageSize.height = i.height;
}
for (var n = t._tileSize.width, r = t._tileSize.height, s = i.width, o = i.height, a = t.spacing, c = t.margin, h = Math.floor((s - 2 * c + a) / (n + a)), l = Math.floor((o - 2 * c + a) / (r + a)) * h, u = t.firstGid, _ = t.firstGid + l, f = this._texGrids, d = null, m = !!f[u], p = cc.macro.FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX ? .5 : 0; u < _; ++u) {
m && !f[u] && (m = !1);
if (!m && f[u]) break;
d = {
texId: e,
x: 0,
y: 0,
width: n,
height: r,
t: 0,
l: 0,
r: 0,
b: 0
};
t.rectForGID(u, d);
d.x += p;
d.y += p;
d.width -= 2 * p;
d.height -= 2 * p;
d.t = d.y / o;
d.l = d.x / s;
d.r = (d.x + d.width) / s;
d.b = (d.y + d.height) / o;
f[u] = d;
}
} else i.once("load", (function() {
this._fillTextureGrids(t, e);
}), this);
},
_activateMaterial: function() {
var t = this._material;
t || ((t = this._material = new o()).useColor = !1);
if (this._texture) {
t.texture = this._texture;
this.markForUpdateRenderData(!0);
this.markForRender(!0);
} else this.disableRender();
this._updateMaterial(t);
}
});
cc.TiledLayer = n.exports = a;
}), {
"../core/components/CCRenderComponent": 77,
"../core/renderer/render-engine": 202
} ],
271: [ (function(t, e, i) {
t("./CCTMXXMLParser");
t("./CCTiledMapAsset");
t("./CCTiledLayer");
t("./CCTiledTile");
t("./CCTiledObjectGroup");
var n = cc.Enum({
ORTHO: 0,
HEX: 1,
ISO: 2
}), r = cc.Enum({
NONE: 0,
MAP: 1,
LAYER: 2,
OBJECTGROUP: 3,
OBJECT: 4,
TILE: 5
}), s = cc.Enum({
HORIZONTAL: 2147483648,
VERTICAL: 1073741824,
DIAGONAL: 536870912,
FLIPPED_ALL: 3758096384,
FLIPPED_MASK: 536870911
}), o = cc.Enum({
STAGGERAXIS_X: 0,
STAGGERAXIS_Y: 1
}), a = cc.Enum({
STAGGERINDEX_ODD: 0,
STAGGERINDEX_EVEN: 1
}), c = cc.Enum({
RECT: 0,
ELLIPSE: 1,
POLYGON: 2,
POLYLINE: 3,
IMAGE: 4
}), h = cc.Class({
name: "cc.TiledMap",
extends: cc.Component,
editor: !1,
ctor: function() {
this._layers = [];
this._groups = [];
this._properties = [];
this._tileProperties = [];
this._mapSize = cc.size(0, 0);
this._tileSize = cc.size(0, 0);
},
statics: {
Orientation: n,
Property: r,
TileFlag: s,
StaggerAxis: o,
StaggerIndex: a,
TMXObjectType: c
},
properties: {
_tmxFile: {
default: null,
type: cc.TiledMapAsset
},
tmxAsset: {
get: function() {
return this._tmxFile;
},
set: function(t, e) {
if (this._tmxFile !== t) {
this._tmxFile = t;
this._applyFile();
}
},
type: cc.TiledMapAsset
}
},
getMapSize: function() {
return this._mapSize;
},
getTileSize: function() {
return this._tileSize;
},
getMapOrientation: function() {
return this._mapOrientation;
},
getObjectGroups: function() {
return this._groups;
},
getObjectGroup: function(t) {
for (var e = this._groups, i = 0, n = e.length; i < n; i++) {
var r = e[i];
if (r && r.getGroupName() === t) return r;
}
return null;
},
getProperties: function() {
return this._properties;
},
getLayers: function() {
return this._layers;
},
getLayer: function(t) {
for (var e = this._layers, i = 0, n = e.length; i < n; i++) {
var r = e[i];
if (r && r.getLayerName() === t) return r;
}
return null;
},
getProperty: function(t) {
return this._properties[t.toString()];
},
getPropertiesForGID: function(t) {
return this._tileProperties[t];
},
__preload: function() {
this._tmxFile && this._applyFile();
},
onEnable: function() {
this.node.on(cc.Node.EventType.ANCHOR_CHANGED, this._syncAnchorPoint, this);
},
onDisable: function() {
this.node.off(cc.Node.EventType.ANCHOR_CHANGED, this._syncAnchorPoint, this);
},
_applyFile: function() {
var t = this._tmxFile;
if (t) {
for (var e = t.textures, i = t.textureNames, n = {}, r = 0; r < e.length; ++r) n[i[r]] = e[r];
for (var s = t.tsxFileNames, o = t.tsxFiles, a = {}, c = 0; c < s.length; ++c) s[c].length > 0 && (a[s[c]] = o[c].text);
var h = new cc.TMXMapInfo(t.tmxXmlStr, a, n), l = h.getTilesets();
l && 0 !== l.length || cc.logID(7241);
this._buildWithMapInfo(h);
} else this._relseasMapInfo();
},
_relseasMapInfo: function() {
for (var t = this._layers, e = 0, i = t.length; e < i; e++) t[e].node.removeFromParent();
t.length = 0;
for (var n = this._groups, r = 0, s = n.length; r < s; r++) n[r].node.removeFromParent();
n.length = 0;
},
_syncAnchorPoint: function() {
for (var t = this.node.getAnchorPoint(), e = 0, i = this._layers.length; e < i; e++) this._layers[e].node.setAnchorPoint(t);
},
_buildWithMapInfo: function(t) {
this._mapSize = t.getMapSize();
this._tileSize = t.getTileSize();
this._mapOrientation = t.orientation;
this._properties = t.properties;
this._tileProperties = t.getTileProperties();
this._relseasMapInfo();
var e = this._layers, i = this._groups, n = this.node, r = t.getAllChildren();
if (r && r.length > 0) for (var s = 0, o = r.length; s < o; s++) {
var a = r[s], c = a.name, h = this.node.getChildByName(c);
if (!h) {
(h = new cc.Node()).name = c;
n.addChild(h);
}
if (a instanceof cc.TMXLayerInfo && a.visible) {
var l = h.getComponent(cc.TiledLayer);
l || (l = h.addComponent(cc.TiledLayer));
var u = this._tilesetForLayer(a, t);
l._init(u, a, t);
a.ownTiles = !1;
this.node.width = Math.max(this.node.width, h.width);
this.node.height = Math.max(this.node.height, h.height);
e.push(l);
} else if (a instanceof cc.TMXObjectGroupInfo) {
var _ = h.getComponent(cc.TiledObjectGroup);
_ || (_ = h.addComponent(cc.TiledObjectGroup));
_._init(a, t);
i.push(_);
}
}
this._syncAnchorPoint();
},
_tilesetForLayer: function(t, e) {
var i = t._layerSize, n = e.getTilesets();
if (n) for (var r = n.length - 1; r >= 0; r--) {
var s = n[r];
if (s) for (var o = 0; o < i.height; o++) for (var a = 0; a < i.width; a++) {
var c = a + i.width * o, h = t._tiles[c];
if (0 !== h && (h & cc.TiledMap.TileFlag.FLIPPED_MASK) >>> 0 >= s.firstGid) return s;
}
}
cc.logID(7215, t.name);
return null;
}
});
cc.TiledMap = e.exports = h;
cc.js.obsolete(cc.TiledMap.prototype, "cc.TiledMap.tmxFile", "tmxAsset", !0);
cc.js.get(cc.TiledMap.prototype, "mapLoaded", (function() {
cc.errorID(7203);
return [];
}), !1);
}), {
"./CCTMXXMLParser": 269,
"./CCTiledLayer": 270,
"./CCTiledMapAsset": 272,
"./CCTiledObjectGroup": 273,
"./CCTiledTile": 274
} ],
272: [ (function(t, e, i) {
var n = cc.Class({
name: "cc.TiledMapAsset",
extends: cc.Asset,
properties: {
tmxXmlStr: "",
textures: {
default: [],
type: [ cc.Texture2D ]
},
textureNames: [ cc.String ],
tsxFiles: [ cc.TextAsset ],
tsxFileNames: [ cc.String ]
},
statics: {
preventDeferredLoadDependents: !0
},
createNode: !1
});
cc.TiledMapAsset = n;
e.exports = n;
}), {} ],
273: [ (function(t, e, i) {
var n = cc.Class({
name: "cc.TiledObjectGroup",
extends: cc.Component,
getPositionOffset: function() {
return this._positionOffset;
},
getProperties: function() {
this._properties;
},
getGroupName: function() {
return this._groupName;
},
getProperty: function(t) {
return this._properties[t.toString()];
},
getObject: function(t) {
for (var e = 0, i = this._objects.length; e < i; e++) {
var n = this._objects[e];
if (n && n.name === t) return n;
}
return null;
},
getObjects: function() {
return this._objects;
},
_init: function(t, e) {
this._groupName = t.name;
this._positionOffset = t.offset;
this._mapInfo = e;
this._properties = t.getProperties();
var i = e._mapSize, n = e._tileSize, r = 0, s = 0;
if (e.orientation === cc.TiledMap.Orientation.HEX) if (e.getStaggerAxis() === cc.TiledMap.StaggerAxis.STAGGERAXIS_X) {
s = n.height * (i.height + .5);
r = (n.width + e.getHexSideLength()) * Math.floor(i.width / 2) + n.width * (i.width % 2);
} else {
r = n.width * (i.width + .5);
s = (n.height + e.getHexSideLength()) * Math.floor(i.height / 2) + n.height * (i.height % 2);
} else {
r = i.width * n.width;
s = i.height * n.height;
}
this.node.setContentSize(r, s);
for (var o = t._objects, a = 0, c = o.length; a < c; a++) {
var h = o[a];
h.offset = cc.v2(h.x, h.y);
if (cc.TiledMap.Orientation.ISO !== this._mapOrientation) h.y = s - h.y; else {
var l = h.offset.x / n.width * 2, u = h.offset.y / n.height;
h.x = n.width / 2 * (i.width + l - u);
h.y = n.height / 2 * (2 * i.height - l - u);
}
}
this._objects = o;
}
});
cc.TiledObjectGroup = e.exports = n;
}), {} ],
274: [ (function(t, e, i) {
var n = cc.Class({
name: "cc.TiledTile",
extends: cc.Component,
editor: !1,
ctor: function() {
this._layer = null;
},
properties: {
_x: 0,
_y: 0,
x: {
get: function() {
return this._x;
},
set: function(t) {
if (t !== this._x) if (this._layer && this._layer._isInvalidPosition(t, this._y)) cc.warn("Invalid x, the valid value is between [%s] ~ [%s]", 0, this._layer._layerSize.width); else {
this._resetTile();
this._x = t;
this._updateInfo();
}
},
type: cc.Integer
},
y: {
get: function() {
return this._y;
},
set: function(t) {
if (t !== this._y) if (this._layer && this._layer._isInvalidPosition(this._x, t)) cc.warn("Invalid y, the valid value is between [%s] ~ [%s]", 0, this._layer._layerSize.height); else {
this._resetTile();
this._y = t;
this._updateInfo();
}
},
type: cc.Integer
},
gid: {
get: function() {
return this._layer ? this._layer.getTileGIDAt(this._x, this._y) : 0;
},
set: function(t) {
this._layer && this._layer.setTileGIDAt(t, this._x, this._y);
},
type: cc.Integer
}
},
onEnable: function() {
var t = this.node.parent;
this._layer = t.getComponent(cc.TiledLayer);
this._resetTile();
this._updateInfo();
},
onDisable: function() {
this._resetTile();
},
_resetTile: function() {
this._layer && this._layer.getTiledTileAt(this._x, this._y) === this && this._layer.setTiledTileAt(this._x, this._y, null);
},
_updateInfo: function() {
if (this._layer) {
var t = this._x, e = this._y;
if (this._layer.getTiledTileAt(t, e)) cc.warn("There is already a TiledTile at [%s, %s]", t, e); else {
this.node.setPosition(this._layer.getPositionAt(t, e));
this._layer.setTiledTileAt(t, e, this);
}
}
}
});
cc.TiledTile = e.exports = n;
}), {} ],
275: [ (function(t, e, i) {
t("./CCTiledMap");
t("./tmx-layer-assembler");
}), {
"./CCTiledMap": 271,
"./tmx-layer-assembler": 276
} ],
276: [ (function(t, e, i) {
var n = t("./CCTiledLayer"), r = t("./CCTiledMap"), s = t("../core/renderer/render-engine"), o = t("../core/renderer/render-flow"), a = r.Orientation, c = r.TileFlag, h = c.FLIPPED_MASK, l = r.StaggerAxis, u = r.StaggerIndex, _ = s.math, f = _.mat4, d = _.vec3, m = f.create(), p = f.create(), v = d.create(), y = {
updateRenderData: function(t) {
var e = t._renderData;
e || (e = t._renderData = t.requestRenderData());
var i = t.node._contentSize, n = t.node._anchorPoint;
e.updateSizeNPivot(i.width, i.height, n.x, n.y);
e.material = t.getMaterial();
this.updateVertices(t);
},
fillBuffers: function(t, e) {
for (var i = t._renderData, n = i._data, r = e._meshBuffer, s = i.vertexCount, a = r.request(s, i.indiceCount), c = a.indiceOffset, h = a.byteOffset >> 2, l = a.vertexOffset, u = r._vData, _ = r._iData, f = r._uintVData, d = 0, m = i.vertexCount; d < m; d++) {
var p = n[d];
u[h++] = p.x;
u[h++] = p.y;
u[h++] = p.u;
u[h++] = p.v;
f[h++] = p.color;
}
for (var v = 0, y = i.indiceCount; v < y; v += 6) {
_[c++] = l;
_[c++] = l + 1;
_[c++] = l + 2;
_[c++] = l + 1;
_[c++] = l + 3;
_[c++] = l + 2;
l += 4;
}
t.node._renderFlag |= o.FLAG_UPDATE_RENDER_DATA;
},
updateVertices: function(t) {
var e = t.node, i = t._renderData, n = i._data, r = e._color._val, s = e._color.a;
i.dataLength = i.vertexCount = i.indiceCount = 0;
var o = t._layerOrientation;
if (t._tiles && t._tileset) {
var _ = e._anchorPoint.x * e._contentSize.width, y = e._anchorPoint.y * e._contentSize.height;
f.copy(m, e._worldMatrix);
d.set(v, -_, -y, 0);
f.translate(m, m, v);
var g = m.m00, x = m.m01, C = m.m04, A = m.m05, b = m.m12, S = m.m13, T = t._mapTileSize.width, w = t._mapTileSize.height, E = t._tileset._tileSize.width, B = t._tileset._tileSize.height, M = E - T, D = B - w, I = cc.winSize.width, P = cc.winSize.height, R = t._layerSize.height, L = t._layerSize.width, F = t._texGrids, V = t._tiledTiles, O = t._offset.x, N = t._offset.y, k = 0, G = 0, z = L, U = R, j = g, H = A, W = b += O * g + N * C, q = S += O * x + N * A, X = E * g, Y = B * A, J = cc.macro.ENABLE_TILEDMAP_CULLING;
if (J) {
var Z = cc.Camera.findCamera(t.node);
if (Z) {
Z.getWorldToCameraMatrix(p);
f.mul(m, p, m);
j = m.m00;
H = m.m05;
W = O * j + N * m.m04 + m.m12;
q = O * m.m01 + N * H + m.m13;
X = E * j;
Y = B * H;
}
if (o === a.ORTHO) {
f.invert(m, m);
var K = cc.visibleRect, Q = m.m00, $ = m.m01, tt = m.m04, et = m.m05, it = m.m12, nt = m.m13, rt = K.topLeft.x * Q + K.topLeft.y * tt + it, st = K.topLeft.x * $ + K.topLeft.y * et + nt, ot = K.bottomLeft.x * Q + K.bottomLeft.y * tt + it, at = K.bottomLeft.x * $ + K.bottomLeft.y * et + nt, ct = K.topRight.x * Q + K.topRight.y * tt + it, ht = K.topRight.x * $ + K.topRight.y * et + nt, lt = K.bottomRight.x * Q + K.bottomRight.y * tt + it, ut = K.bottomRight.x * $ + K.bottomRight.y * et + nt, _t = Math.min(rt, ot, ct, lt), ft = Math.max(rt, ot, ct, lt), dt = Math.min(st, at, ht, ut), mt = Math.max(st, at, ht, ut);
k = Math.floor(_t / T);
G = R - Math.ceil(mt / w);
z = Math.ceil((ft + M) / T);
U = R - Math.floor((dt - D) / w);
k < 0 && (k = 0);
G < 0 && (G = 0);
z > L && (z = L);
U > R && (U = R);
}
}
var pt = G * L, vt = void 0, yt = void 0, gt = void 0, xt = void 0, Ct = void 0, At = void 0, bt = void 0, St = void 0, Tt = void 0, wt = void 0, Et = void 0, Bt = void 0, Mt = void 0;
if (o === a.HEX) {
var Dt = t._hexSideLength;
Tt = t._staggerAxis;
wt = t._tileset.tileOffset;
Mt = t._staggerIndex === u.STAGGERINDEX_ODD ? 1 : -1;
Et = Tt === l.STAGGERAXIS_X ? (T - Dt) / 2 : 0;
Bt = Tt === l.STAGGERAXIS_Y ? (w - Dt) / 2 : 0;
}
for (var It = 0, Pt = void 0, Rt = void 0, Lt = void 0, Ft = void 0, Vt = void 0, Ot = void 0, Nt = void 0, kt = G; kt < U; ++kt) {
for (var Gt = k; Gt < z; ++Gt) {
var zt = pt + Gt, Ut = !1, jt = !1, Ht = V[zt];
if (yt = F[((vt = Ht ? Ht.gid : t._tiles[zt]) & h) >>> 0]) {
switch (o) {
case a.ORTHO:
xt = Gt * T;
Ct = (R - kt - 1) * w;
break;

case a.ISO:
xt = T / 2 * (L + Gt - kt - 1);
Ct = w / 2 * (2 * R - Gt - kt - 2);
break;

case a.HEX:
xt = Gt * (T - Et) + (Tt === l.STAGGERAXIS_Y && kt % 2 == 1 ? T / 2 * Mt : 0) + wt.x;
Ct = (R - kt - 1) * (w - Bt) + (Tt === l.STAGGERAXIS_X && Gt % 2 == 1 ? w / 2 * -Mt : 0) - wt.y;
}
if (Ht) {
var Wt = Ht.node;
Nt = r;
var qt = Wt.opacity * s / 255;
r = Wt.color.setA(qt)._val;
Pt = g;
Rt = x;
Lt = C;
Ft = A;
Vt = b;
Ot = S;
Wt._updateLocalMatrix();
f.copy(m, Wt._matrix);
d.set(v, -xt, -Ct, 0);
f.translate(m, m, v);
f.multiply(m, e._worldMatrix, m);
g = m.m00;
x = m.m01;
C = m.m04;
A = m.m05;
b = m.m12;
S = m.m13;
}
At = xt + E;
gt = Ct + B;
if (J && o === a.ISO) {
if ((bt = q + Ct * H) > P + Y) {
Gt += Math.floor(2 * (bt - P) / Y) - 1;
continue;
}
if ((St = W + At * j) < -X) {
Gt += Math.floor(2 * -St / X) - 1;
continue;
}
if (W + xt * j > I || q + gt * H < 0) {
Gt = z;
continue;
}
}
if (vt > c.DIAGONAL) {
Ut = (vt & c.HORIZONTAL) >>> 0;
jt = (vt & c.VERTICAL) >>> 0;
}
i.vertexCount += 4;
i.indiceCount += 6;
i.dataLength = i.vertexCount;
n[It].x = xt * g + gt * C + b;
n[It].y = xt * x + gt * A + S;
n[It].u = Ut ? yt.r : yt.l;
n[It].v = jt ? yt.b : yt.t;
n[It].color = r;
n[++It].x = xt * g + Ct * C + b;
n[It].y = xt * x + Ct * A + S;
n[It].u = Ut ? yt.r : yt.l;
n[It].v = jt ? yt.t : yt.b;
n[It].color = r;
n[++It].x = At * g + gt * C + b;
n[It].y = At * x + gt * A + S;
n[It].u = Ut ? yt.l : yt.r;
n[It].v = jt ? yt.b : yt.t;
n[It].color = r;
n[++It].x = At * g + Ct * C + b;
n[It].y = At * x + Ct * A + S;
n[It].u = Ut ? yt.l : yt.r;
n[It].v = jt ? yt.t : yt.b;
n[It].color = r;
It++;
if (Ht) {
r = Nt;
g = Pt;
x = Rt;
C = Lt;
A = Ft;
b = Vt;
S = Ot;
}
}
}
pt += L;
}
}
}
};
e.exports = n._assembler = y;
}), {
"../core/renderer/render-engine": 202,
"../core/renderer/render-flow": 203,
"./CCTiledLayer": 270,
"./CCTiledMap": 271
} ],
277: [ (function(t, e, i) {
var n = t("./video-player-impl"), r = n.EventType, s = cc.Enum({
REMOTE: 0,
LOCAL: 1
}), o = cc.Class({
name: "cc.VideoPlayer",
extends: cc.Component,
editor: !1,
properties: {
_resourceType: s.REMOTE,
resourceType: {
tooltip: !1,
type: s,
set: function(t) {
this._resourceType = t;
this._updateVideoSource();
},
get: function() {
return this._resourceType;
}
},
_remoteURL: "",
remoteURL: {
tooltip: !1,
type: cc.String,
set: function(t) {
this._remoteURL = t;
this._updateVideoSource();
},
get: function() {
return this._remoteURL;
}
},
_clip: {
default: null,
type: cc.Asset
},
clip: {
tooltip: !1,
get: function() {
return this._clip;
},
set: function(t) {
this._clip = t;
this._updateVideoSource();
},
type: cc.Asset
},
currentTime: {
tooltip: !1,
type: cc.Float,
set: function(t) {
this._impl && this._impl.seekTo(t);
},
get: function() {
return this._impl ? this._impl.currentTime() : -1;
}
},
_volume: 1,
volume: {
get: function() {
return this._volume;
},
set: function(t) {
this._volume = t;
this.isPlaying() && !this._mute && this._syncVolume();
},
range: [ 0, 1 ],
type: cc.Float,
tooltip: !1
},
_mute: !1,
mute: {
get: function() {
return this._mute;
},
set: function(t) {
this._mute = t;
this._syncVolume();
},
tooltip: !1
},
keepAspectRatio: {
tooltip: !1,
default: !0,
type: cc.Boolean,
notify: function() {
this._impl.setKeepAspectRatioEnabled(this.keepAspectRatio);
}
},
isFullscreen: {
tooltip: !1,
default: !1,
type: cc.Boolean,
notify: function() {
this._impl.setFullScreenEnabled(this.isFullscreen);
}
},
videoPlayerEvent: {
default: [],
type: cc.Component.EventHandler
}
},
statics: {
EventType: r,
ResourceType: s,
Impl: n
},
ctor: function() {
this._impl = new n();
},
_syncVolume: function() {
var t = this._impl;
if (t) {
var e = this._mute ? 0 : this._volume;
t.setVolume(e);
}
},
_updateVideoSource: function() {
var t = "";
this.resourceType === s.REMOTE ? t = this.remoteURL : this._clip && (t = this._clip.nativeUrl || "");
t && cc.loader.md5Pipe && (t = cc.loader.md5Pipe.transformURL(t));
this._impl.setURL(t);
},
onLoad: function() {
var t = this._impl;
if (t) {
t.createDomElementIfNeeded();
this._updateVideoSource();
t.seekTo(this.currentTime);
t.setKeepAspectRatioEnabled(this.keepAspectRatio);
t.setFullScreenEnabled(this.isFullscreen);
this.pause();
t.setEventListener(r.PLAYING, this.onPlaying.bind(this));
t.setEventListener(r.PAUSED, this.onPasued.bind(this));
t.setEventListener(r.STOPPED, this.onStopped.bind(this));
t.setEventListener(r.COMPLETED, this.onCompleted.bind(this));
t.setEventListener(r.META_LOADED, this.onMetaLoaded.bind(this));
t.setEventListener(r.CLICKED, this.onClicked.bind(this));
t.setEventListener(r.READY_TO_PLAY, this.onReadyToPlay.bind(this));
}
},
onRestore: function() {
this._impl || (this._impl = new n());
},
onEnable: function() {
this._impl && this._impl.enable();
},
onDisable: function() {
this._impl && this._impl.disable();
},
onDestroy: function() {
if (this._impl) {
this._impl.destroy();
this._impl = null;
}
},
update: function(t) {
this._impl && this._impl.updateMatrix(this.node);
},
onReadyToPlay: function() {
cc.Component.EventHandler.emitEvents(this.videoPlayerEvent, this, r.READY_TO_PLAY);
this.node.emit("ready-to-play", this);
},
onMetaLoaded: function() {
cc.Component.EventHandler.emitEvents(this.videoPlayerEvent, this, r.META_LOADED);
this.node.emit("meta-loaded", this);
},
onClicked: function() {
cc.Component.EventHandler.emitEvents(this.videoPlayerEvent, this, r.CLICKED);
this.node.emit("clicked", this);
},
onPlaying: function() {
cc.Component.EventHandler.emitEvents(this.videoPlayerEvent, this, r.PLAYING);
this.node.emit("playing", this);
},
onPasued: function() {
cc.Component.EventHandler.emitEvents(this.videoPlayerEvent, this, r.PAUSED);
this.node.emit("paused", this);
},
onStopped: function() {
cc.Component.EventHandler.emitEvents(this.videoPlayerEvent, this, r.STOPPED);
this.node.emit("stopped", this);
},
onCompleted: function() {
cc.Component.EventHandler.emitEvents(this.videoPlayerEvent, this, r.COMPLETED);
this.node.emit("completed", this);
},
play: function() {
if (this._impl) {
this._syncVolume();
this._impl.play();
}
},
resume: function() {
if (this._impl) {
this._syncVolume();
this._impl.resume();
}
},
pause: function() {
this._impl && this._impl.pause();
},
stop: function() {
this._impl && this._impl.stop();
},
getDuration: function() {
return this._impl ? this._impl.duration() : -1;
},
isPlaying: function() {
return !!this._impl && this._impl.isPlaying();
}
});
cc.VideoPlayer = e.exports = o;
}), {
"./video-player-impl": 278
} ],
278: [ (function(t, e, i) {
var n = t("../core/platform/utils"), r = t("../core/platform/CCSys"), s = {
HAVE_NOTHING: 0,
HAVE_METADATA: 1,
HAVE_CURRENT_DATA: 2,
HAVE_FUTURE_DATA: 3,
HAVE_ENOUGH_DATA: 4
}, o = t("../core/renderer/render-engine").math.mat4.create(), a = cc.Class({
name: "VideoPlayerImpl",
ctor: function() {
this._EventList = {};
this._video = null;
this._url = "";
this._fullScreenEnabled = !1;
this._loadedmeta = !1;
this._loaded = !1;
this._visible = !1;
this._playing = !1;
this._ignorePause = !1;
this._forceUpdate = !0;
this._m00 = 0;
this._m01 = 0;
this._m04 = 0;
this._m05 = 0;
this._m12 = 0;
this._m13 = 0;
this._w = 0;
this._h = 0;
this.__eventListeners = {};
},
_bindEvent: function() {
var t = this._video, e = this, i = this.__eventListeners;
i.loadedmetadata = function() {
e._loadedmeta = !0;
e._fullScreenEnabled ? cc.screen.requestFullScreen(t) : cc.screen.fullScreen() && cc.screen.exitFullScreen(t);
e._dispatchEvent(a.EventType.META_LOADED);
};
i.ended = function() {
if (e._video === t) {
e._playing = !1;
e._dispatchEvent(a.EventType.COMPLETED);
}
};
i.play = function() {
if (e._video === t) {
e._playing = !0;
e._updateVisibility();
e._dispatchEvent(a.EventType.PLAYING);
}
};
i.pause = function() {
if (e._video === t) {
e._playing = !1;
e._ignorePause || e._dispatchEvent(a.EventType.PAUSED);
}
};
i.click = function() {
e._dispatchEvent(a.EventType.CLICKED);
};
t.addEventListener("loadedmetadata", i.loadedmetadata);
t.addEventListener("ended", i.ended);
t.addEventListener("play", i.play);
t.addEventListener("pause", i.pause);
t.addEventListener("click", i.click);
i.onCanPlay = function() {
if (!(e._loaded || e._loadedmeta || e._playing)) {
var t = e._video;
if (t.readyState === s.HAVE_ENOUGH_DATA) {
t.currentTime = 0;
e._loaded = !0;
e._dispatchEvent(a.EventType.READY_TO_PLAY);
e._updateVisibility();
}
}
};
t.addEventListener("canplay", i.onCanPlay);
t.addEventListener("canplaythrough", i.onCanPlay);
t.addEventListener("suspend", i.onCanPlay);
},
_updateVisibility: function() {
var t = this._video;
if (t) if (this._visible) {
t.style.visibility = "visible";
this._forceUpdate = !0;
} else {
t.style.visibility = "hidden";
t.pause();
this._playing = !1;
this._forceUpdate = !1;
}
},
_updateSize: function(t, e) {
var i = this._video;
if (i) {
i.style.width = t + "px";
i.style.height = e + "px";
}
},
_createDom: function() {
var t = document.createElement("video");
t.style.position = "absolute";
t.style.bottom = "0px";
t.style.left = "0px";
t.className = "cocosVideo";
t.setAttribute("preload", "auto");
t.setAttribute("webkit-playsinline", "");
t.setAttribute("x5-playsinline", "");
t.setAttribute("playsinline", "");
this._video = t;
cc.game.container.appendChild(t);
},
createDomElementIfNeeded: function() {
this._video || this._createDom();
},
removeDom: function() {
var t = this._video;
if (t) {
n.contains(cc.game.container, t) && cc.game.container.removeChild(t);
var e = this.__eventListeners;
t.removeEventListener("loadedmetadata", e.loadedmetadata);
t.removeEventListener("ended", e.ended);
t.removeEventListener("play", e.play);
t.removeEventListener("pause", e.pause);
t.removeEventListener("click", e.click);
t.removeEventListener("canplay", e.onCanPlay);
t.removeEventListener("canplaythrough", e.onCanPlay);
t.removeEventListener("suspend", e.onCanPlay);
e.loadedmetadata = null;
e.ended = null;
e.play = null;
e.pause = null;
e.click = null;
e.onCanPlay = null;
}
this._video = null;
this._url = "";
},
setURL: function(t) {
var e, i = void 0;
if (this._url !== t) {
this._url = t;
this.removeDom();
this.createDomElementIfNeeded();
this._bindEvent();
var n = this._video;
n.style.visibility = "hidden";
this._loaded = !1;
this._playing = !1;
this._loadedmeta = !1;
(i = document.createElement("source")).src = t;
n.appendChild(i);
e = cc.path.extname(t);
for (var r = a._polyfill, s = 0; s < r.canPlayType.length; s++) if (e !== r.canPlayType[s]) {
(i = document.createElement("source")).src = t.replace(e, r.canPlayType[s]);
n.appendChild(i);
}
}
},
getURL: function() {
return this._url;
},
play: function() {
var t = this._video;
if (t && this._visible && !this._playing) if (a._polyfill.autoplayAfterOperation) {
setTimeout((function() {
t.play();
}), 20);
} else t.play();
},
pause: function() {
var t = this._video;
this._playing && t && t.pause();
},
resume: function() {
this.play();
},
stop: function() {
var t = this._video;
if (t && this._visible) {
this._ignorePause = !0;
t.currentTime = 0;
t.pause();
setTimeout(function() {
this._dispatchEvent(a.EventType.STOPPED);
this._ignorePause = !1;
}.bind(this), 0);
}
},
setVolume: function(t) {
var e = this._video;
e && (e.volume = t);
},
seekTo: function(t) {
var e = this._video;
if (e) {
this._loaded ? e.currentTime = t : (function() {
var i = function() {
e.currentTime = t;
e.removeEventListener(a._polyfill.event, i);
};
e.addEventListener(a._polyfill.event, i);
})();
a._polyfill.autoplayAfterOperation && this.isPlaying() && setTimeout((function() {
e.play();
}), 20);
}
},
isPlaying: function() {
var t = this._video;
a._polyfill.autoplayAfterOperation && this._playing && setTimeout((function() {
t.play();
}), 20);
return this._playing;
},
duration: function() {
var t = this._video, e = -1;
if (!t) return e;
(e = t.duration) <= 0 && cc.logID(7702);
return e;
},
currentTime: function() {
var t = this._video;
return t ? t.currentTime : -1;
},
setKeepAspectRatioEnabled: function() {
0;
cc.logID(7700);
},
isKeepAspectRatioEnabled: function() {
return !0;
},
setFullScreenEnabled: function(t) {
var e = this._video;
if (e) {
this._fullScreenEnabled = t;
t ? cc.screen.requestFullScreen(e) : cc.screen.fullScreen() && cc.screen.exitFullScreen(e);
}
},
isFullScreenEnabled: function() {
return this._fullScreenEnabled;
},
setEventListener: function(t, e) {
this._EventList[t] = e;
},
removeEventListener: function(t) {
this._EventList[t] = null;
},
_dispatchEvent: function(t) {
var e = this._EventList[t];
e && e.call(this, this, this._video.src);
},
onPlayEvent: function() {
this._EventList[a.EventType.PLAYING].call(this, this, this._video.src);
},
enable: function() {
var t = a.elements;
-1 === t.indexOf(this) && t.push(this);
this.setVisible(!0);
},
disable: function() {
var t = a.elements, e = t.indexOf(this);
-1 !== e && t.splice(e, 1);
this.setVisible(!1);
},
destroy: function() {
this.disable();
this.removeDom();
},
setVisible: function(t) {
if (this._visible !== t) {
this._visible = !!t;
this._updateVisibility();
}
},
updateMatrix: function(t) {
if (this._video && this._visible) {
t.getWorldMatrix(o);
if (this._forceUpdate || this._m00 !== o.m00 || this._m01 !== o.m01 || this._m04 !== o.m04 || this._m05 !== o.m05 || this._m12 !== o.m12 || this._m13 !== o.m13 || this._w !== t._contentSize.width || this._h !== t._contentSize.height) {
this._m00 = o.m00;
this._m01 = o.m01;
this._m04 = o.m04;
this._m05 = o.m05;
this._m12 = o.m12;
this._m13 = o.m13;
this._w = t._contentSize.width;
this._h = t._contentSize.height;
var e = cc.view._scaleX, i = cc.view._scaleY, n = cc.view._devicePixelRatio;
e /= n;
i /= n;
var r = cc.game.container, s = o.m00 * e, c = o.m01, h = o.m04, l = o.m05 * i, u = r && r.style.paddingLeft ? parseInt(r.style.paddingLeft) : 0, _ = r && r.style.paddingBottom ? parseInt(r.style.paddingBottom) : 0, f = void 0, d = void 0;
if (a._polyfill.zoomInvalid) {
this._updateSize(this._w * s, this._h * l);
s = 1;
l = 1;
f = this._w * e;
d = this._h * i;
} else {
f = this._w * e;
d = this._h * i;
this._updateSize(this._w, this._h);
}
var m = f * o.m00 * t._anchorPoint.x, p = d * o.m05 * t._anchorPoint.y, v = cc.view._viewportRect;
u += v.x / n;
_ += v.y / n;
var y = "matrix(" + s + "," + -c + "," + -h + "," + l + "," + (o.m12 * e - m + u) + "," + -(o.m13 * i - p + _) + ")";
this._video.style.transform = y;
this._video.style["-webkit-transform"] = y;
this._video.style["transform-origin"] = "0px 100% 0px";
this._video.style["-webkit-transform-origin"] = "0px 100% 0px";
}
}
}
});
a.EventType = {
PLAYING: 0,
PAUSED: 1,
STOPPED: 2,
COMPLETED: 3,
META_LOADED: 4,
CLICKED: 5,
READY_TO_PLAY: 6
};
a.elements = [];
a.pauseElements = [];
cc.game.on(cc.game.EVENT_HIDE, (function() {
for (var t, e = a.elements, i = 0; i < e.length; i++) if ((t = e[i]).isPlaying()) {
t.pause();
a.pauseElements.push(t);
}
}));
cc.game.on(cc.game.EVENT_SHOW, (function() {
for (var t = a.pauseElements, e = t.pop(); e; ) {
e.play();
e = t.pop();
}
}));
a._polyfill = {
devicePixelRatio: !1,
event: "canplay",
canPlayType: []
};
var c = cc.sys.platform === cc.sys.BAIDU_GAME, h = document.createElement("video");
if (!c) {
if (h.canPlayType("video/ogg")) {
a._polyfill.canPlayType.push(".ogg");
a._polyfill.canPlayType.push(".ogv");
}
h.canPlayType("video/mp4") && a._polyfill.canPlayType.push(".mp4");
h.canPlayType("video/webm") && a._polyfill.canPlayType.push(".webm");
}
r.browserType === r.BROWSER_TYPE_FIREFOX && (a._polyfill.autoplayAfterOperation = !0);
r.OS_ANDROID !== r.os || r.browserType !== r.BROWSER_TYPE_SOUGOU && r.browserType !== r.BROWSER_TYPE_360 || (a._polyfill.zoomInvalid = !0);
var l = document.createElement("style");
l.innerHTML = ".cocosVideo:-moz-full-screen{transform:matrix(1,0,0,1,0,0) !important;}.cocosVideo:full-screen{transform:matrix(1,0,0,1,0,0) !important;}.cocosVideo:-webkit-full-screen{transform:matrix(1,0,0,1,0,0) !important;}";
document.head.appendChild(l);
e.exports = a;
}), {
"../core/platform/CCSys": 169,
"../core/platform/utils": 184,
"../core/renderer/render-engine": 202
} ],
279: [ (function(t, e, i) {
var n = t("./webview-impl"), r = n.EventType;
function s() {}
var o = cc.Class({
name: "cc.WebView",
extends: cc.Component,
editor: !1,
properties: {
_useOriginalSize: !0,
_url: "",
url: {
type: String,
tooltip: !1,
get: function() {
return this._url;
},
set: function(t) {
this._url = t;
var e = this._impl;
e && e.loadURL(t);
}
},
webviewEvents: {
default: [],
type: cc.Component.EventHandler
}
},
statics: {
EventType: r,
Impl: n
},
ctor: function() {
this._impl = new o.Impl();
},
onRestore: function() {
this._impl || (this._impl = new o.Impl());
},
onEnable: function() {
var t = this._impl;
t.createDomElementIfNeeded(this.node.width, this.node.height);
t.setEventListener(r.LOADED, this._onWebViewLoaded.bind(this));
t.setEventListener(r.LOADING, this._onWebViewLoading.bind(this));
t.setEventListener(r.ERROR, this._onWebViewLoadError.bind(this));
t.loadURL(this._url);
t.setVisible(!0);
},
onDisable: function() {
var t = this._impl;
t.setVisible(!1);
t.setEventListener(r.LOADED, s);
t.setEventListener(r.LOADING, s);
t.setEventListener(r.ERROR, s);
},
onDestroy: function() {
if (this._impl) {
this._impl.destroy();
this._impl = null;
}
},
update: function(t) {
this._impl && this._impl.updateMatrix(this.node);
},
_onWebViewLoaded: function() {
cc.Component.EventHandler.emitEvents(this.webviewEvents, this, r.LOADED);
this.node.emit("loaded", this);
},
_onWebViewLoading: function() {
cc.Component.EventHandler.emitEvents(this.webviewEvents, this, r.LOADING);
this.node.emit("loading", this);
return !0;
},
_onWebViewLoadError: function() {
cc.Component.EventHandler.emitEvents(this.webviewEvents, this, r.ERROR);
this.node.emit("error", this);
},
setJavascriptInterfaceScheme: function(t) {
this._impl && this._impl.setJavascriptInterfaceScheme(t);
},
setOnJSCallback: function(t) {
this._impl && this._impl.setOnJSCallback(t);
},
evaluateJS: function(t) {
this._impl && this._impl.evaluateJS(t);
}
});
cc.WebView = e.exports = o;
}), {
"./webview-impl": 280
} ],
280: [ (function(t, e, i) {
var n = t("../core/platform/utils"), r = t("../core/platform/CCSys"), s = t("../core/renderer/render-engine").math.mat4.create(), o = cc.Class({
name: "WebViewImpl",
ctor: function() {
this._EventList = {};
this._visible = !1;
this._parent = null;
this._div = null;
this._iframe = null;
this._listener = null;
this._forceUpdate = !0;
this._m00 = 0;
this._m01 = 0;
this._m04 = 0;
this._m05 = 0;
this._m12 = 0;
this._m13 = 0;
this._w = 0;
this._h = 0;
this.__eventListeners = {};
},
_updateVisibility: function() {
if (this._div) {
var t = this._div;
this._visible ? t.style.visibility = "visible" : t.style.visibility = "hidden";
this._forceUpdate = !0;
}
},
_updateSize: function(t, e) {
var i = this._div;
if (i) {
i.style.width = t + "px";
i.style.height = e + "px";
}
},
_initEvent: function() {
var t = this, e = this._iframe;
e && (function() {
var i = t.__eventListeners, n = t;
i.load = function() {
n._dispatchEvent(o.EventType.LOADED);
};
i.error = function() {
n._dispatchEvent(o.EventType.ERROR);
};
e.addEventListener("load", i.load);
e.addEventListener("error", i.error);
})();
},
_initStyle: function() {
if (this._div) {
var t = this._div;
t.style.position = "absolute";
t.style.bottom = "0px";
t.style.left = "0px";
}
},
_setOpacity: function(t) {
var e = this._iframe;
e && e.style && (e.style.opacity = t / 255);
},
_createDom: function(t, e) {
if (o._polyfill.enableDiv) {
this._div = document.createElement("div");
this._div.style["-webkit-overflow"] = "auto";
this._div.style["-webkit-overflow-scrolling"] = "touch";
this._iframe = document.createElement("iframe");
this._div.appendChild(this._iframe);
this._iframe.style.width = "100%";
this._iframe.style.height = "100%";
} else this._div = this._iframe = document.createElement("iframe");
o._polyfill.enableBG && (this._div.style.background = "#FFF");
this._div.style.background = "#FFF";
this._div.style.height = e + "px";
this._div.style.width = t + "px";
this._div.style.overflow = "scroll";
this._iframe.style.border = "none";
cc.game.container.appendChild(this._div);
this._updateVisibility();
},
_createNativeControl: function(t, e) {
this._createDom(t, e);
this._initStyle();
this._initEvent();
},
createDomElementIfNeeded: function(t, e) {
this._div ? this._updateSize(t, e) : this._createNativeControl(t, e);
},
removeDom: function() {
var t = this._div;
if (t) {
n.contains(cc.game.container, t) && cc.game.container.removeChild(t);
this._div = null;
}
var e = this._iframe;
if (e) {
var i = this.__eventListeners;
e.removeEventListener("load", i.load);
e.removeEventListener("error", i.error);
i.load = null;
i.error = null;
this._iframe = null;
}
},
setOnJSCallback: function(t) {},
setJavascriptInterfaceScheme: function(t) {},
loadData: function(t, e, i, n) {},
loadHTMLString: function(t, e) {},
loadURL: function(t) {
var e = this, i = this._iframe;
i && (function() {
i.src = t;
var n = e, r = function() {
n._loaded = !0;
n._updateVisibility();
i.removeEventListener("load", r);
};
i.addEventListener("load", r);
e._dispatchEvent(o.EventType.LOADING);
})();
},
stopLoading: function() {
cc.logID(7800);
},
reload: function() {
var t = this._iframe;
if (t) {
var e = t.contentWindow;
e && e.location && e.location.reload();
}
},
canGoBack: function() {
cc.logID(7801);
return !0;
},
canGoForward: function() {
cc.logID(7802);
return !0;
},
goBack: function() {
try {
if (o._polyfill.closeHistory) return cc.logID(7803);
var t = this._iframe;
if (t) {
var e = t.contentWindow;
e && e.location && e.history.back.call(e);
}
} catch (t) {
cc.log(t);
}
},
goForward: function() {
try {
if (o._polyfill.closeHistory) return cc.logID(7804);
var t = this._iframe;
if (t) {
var e = t.contentWindow;
e && e.location && e.history.forward.call(e);
}
} catch (t) {
cc.log(t);
}
},
evaluateJS: function(t) {
var e = this._iframe;
if (e) {
var i = e.contentWindow;
try {
i.eval(t);
this._dispatchEvent(o.EventType.JS_EVALUATED);
} catch (t) {
console.error(t);
}
}
},
setScalesPageToFit: function() {
cc.logID(7805);
},
setEventListener: function(t, e) {
this._EventList[t] = e;
},
removeEventListener: function(t) {
this._EventList[t] = null;
},
_dispatchEvent: function(t) {
var e = this._EventList[t];
e && e.call(this, this, this._iframe.src);
},
_createRenderCmd: function() {
return new o.RenderCmd(this);
},
destroy: function() {
this.removeDom();
},
setVisible: function(t) {
if (this._visible !== t) {
this._visible = !!t;
this._updateVisibility();
}
},
updateMatrix: function(t) {
if (this._div && this._visible) {
t.getWorldMatrix(s);
if (this._forceUpdate || 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 !== t._contentSize.width || this._h !== t._contentSize.height) {
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 = t._contentSize.width;
this._h = t._contentSize.height;
var e = cc.view._scaleX, i = cc.view._scaleY, n = cc.view._devicePixelRatio;
e /= n;
i /= n;
var r = cc.game.container, o = s.m00 * e, a = s.m01, c = s.m04, h = s.m05 * i, l = r && r.style.paddingLeft ? parseInt(r.style.paddingLeft) : 0, u = r && r.style.paddingBottom ? parseInt(r.style.paddingBottom) : 0;
this._updateSize(this._w, this._h);
var _ = this._div.clientWidth * e, f = this._div.clientHeight * i, d = _ * s.m00 * t._anchorPoint.x, m = f * s.m05 * t._anchorPoint.y, p = cc.view._viewportRect;
l += p.x / n;
u += p.y / n;
var v = "matrix(" + o + "," + -a + "," + -c + "," + h + "," + (s.m12 * e - d + l) + "," + -(s.m13 * i - m + u) + ")";
this._div.style.transform = v;
this._div.style["-webkit-transform"] = v;
this._div.style["transform-origin"] = "0px 100% 0px";
this._div.style["-webkit-transform-origin"] = "0px 100% 0px";
this._setOpacity(t.opacity);
}
}
}
});
o.EventType = {
LOADING: 0,
LOADED: 1,
ERROR: 2,
JS_EVALUATED: 3
};
var a = o._polyfill = {
devicePixelRatio: !1,
enableDiv: !1
};
r.os === r.OS_IOS && (a.enableDiv = !0);
r.isMobile ? r.browserType === r.BROWSER_TYPE_FIREFOX && (a.enableBG = !0) : r.browserType === r.BROWSER_TYPE_IE && (a.closeHistory = !0);
e.exports = o;
}), {
"../core/platform/CCSys": 169,
"../core/platform/utils": 184,
"../core/renderer/render-engine": 202
} ],
281: [ (function(t, e, i) {
t("./cocos2d/core");
t("./cocos2d/animation");
t("./cocos2d/particle");
t("./cocos2d/tilemap");
t("./cocos2d/videoplayer/CCVideoPlayer");
t("./cocos2d/webview/CCWebView");
t("./cocos2d/core/components/CCStudioComponent");
t("./extensions/ccpool/CCNodePool");
t("./cocos2d/actions");
t("./extensions/spine");
t("./extensions/dragonbones");
t("./cocos2d/deprecated");
}), {
"./cocos2d/actions": 7,
"./cocos2d/animation": 16,
"./cocos2d/core": 110,
"./cocos2d/core/components/CCStudioComponent": 83,
"./cocos2d/deprecated": 260,
"./cocos2d/particle": 266,
"./cocos2d/particle/CCParticleAsset": 263,
"./cocos2d/tilemap": 275,
"./cocos2d/tilemap/CCTiledMapAsset": 272,
"./cocos2d/videoplayer/CCVideoPlayer": 277,
"./cocos2d/webview/CCWebView": 279,
"./extensions/ccpool/CCNodePool": 282,
"./extensions/dragonbones": 286,
"./extensions/spine": 289
} ],
282: [ (function(t, e, i) {
cc.NodePool = function(t) {
this.poolHandlerComp = t;
this._pool = [];
};
cc.NodePool.prototype = {
constructor: cc.NodePool,
size: function() {
return this._pool.length;
},
clear: function() {
for (var t = this._pool.length, e = 0; e < t; ++e) this._pool[e].destroy();
this._pool.length = 0;
},
put: function(t) {
if (t && -1 === this._pool.indexOf(t)) {
t.removeFromParent(!1);
var e = this.poolHandlerComp ? t.getComponent(this.poolHandlerComp) : null;
e && e.unuse && e.unuse();
this._pool.push(t);
}
},
get: function() {
var t = this._pool.length - 1;
if (t < 0) return null;
var e = this._pool[t];
this._pool.length = t;
var i = this.poolHandlerComp ? e.getComponent(this.poolHandlerComp) : null;
i && i.reuse && i.reuse.apply(i, arguments);
return e;
}
};
e.exports = cc.NodePool;
}), {} ],
283: [ (function(t, e, i) {
var n = t("../../cocos2d/core/components/CCRenderComponent"), r = t("../../cocos2d/core/renderer/render-engine").SpriteMaterial, s = t("../../cocos2d/core/event/event-target"), o = (t("../../cocos2d/core/CCNode"), 
t("../../cocos2d/core/graphics/graphics")), a = t("./ArmatureCache"), c = cc.Enum({
default: -1
}), h = cc.Enum({
"<None>": 0
}), l = (cc.Enum({
REALTIME: 0
}), cc.Enum({
REALTIME: 0,
SHARED_CACHE: 1,
PRIVATE_CACHE: 2
}));
var u = cc.Class({
name: "dragonBones.ArmatureDisplay",
extends: n,
editor: !1,
statics: {
AnimationCacheMode: l
},
properties: {
_factory: {
default: null,
type: dragonBones.CCFactory,
serializable: !1
},
dragonAsset: {
default: null,
type: dragonBones.DragonBonesAsset,
notify: function() {
this._refresh();
0;
},
tooltip: !1
},
dragonAtlasAsset: {
default: null,
type: dragonBones.DragonBonesAtlasAsset,
notify: function() {
this._parseDragonAtlasAsset();
this._buildArmature();
},
tooltip: !1
},
_armatureName: "",
armatureName: {
get: function() {
return this._armatureName;
},
set: function(t) {
this._armatureName = t;
var 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);
},
visible: !1
},
_animationName: "",
animationName: {
get: function() {
return this._animationName;
},
set: function(t) {
this._animationName = t;
},
visible: !1
},
_defaultArmatureIndex: {
default: 0,
notify: function() {
var t = "";
if (this.dragonAsset) {
var e = void 0;
this.dragonAsset && (e = this.dragonAsset.getArmatureEnum());
if (!e) return cc.errorID(7400, this.name);
t = e[this._defaultArmatureIndex];
}
void 0 !== t ? this.armatureName = t : cc.errorID(7401, this.name);
},
type: c,
visible: !0,
editorOnly: !0,
animatable: !1,
displayName: "Armature",
tooltip: !1
},
_animationIndex: {
default: 0,
notify: function() {
if (0 !== this._animationIndex) {
var t = void 0;
this.dragonAsset && (t = this.dragonAsset.getAnimsEnum(this.armatureName));
if (t) {
var e = t[this._animationIndex];
void 0 !== e ? this.playAnimation(e, this.playTimes) : cc.errorID(7402, this.name);
}
} else this.animationName = "";
},
type: h,
visible: !0,
editorOnly: !0,
displayName: "Animation",
tooltip: !1
},
_preCacheMode: -1,
_cacheMode: l.REALTIME,
_defaultCacheMode: {
default: 0,
type: l,
notify: function() {
this.setAnimationCacheMode(this._defaultCacheMode);
},
editorOnly: !0,
visible: !0,
animatable: !1,
displayName: "Animation Cache Mode",
tooltip: !1
},
timeScale: {
default: 1,
notify: function() {
this._armature && (this._armature.animation.timeScale = this.timeScale);
},
tooltip: !1
},
playTimes: {
default: -1,
tooltip: !1
},
premultipliedAlpha: {
default: !1,
tooltip: !1
},
debugBones: {
default: !1,
notify: function() {
this._updateDebugDraw();
},
tooltip: !1
},
enableBatch: {
default: !1,
notify: function() {
this._updateBatch();
},
tooltip: !1
},
_armatureKey: "",
_accTime: 0,
_playCount: 0,
_frameCache: null,
_curFrame: null,
_playing: !1,
_armatureCache: null
},
ctor: function() {
this._material = new r();
this._eventTarget = null;
this._materialCache = {};
this._inited = !1;
this._factory = dragonBones.CCFactory.getInstance();
},
onLoad: function() {
for (var t = this.node.children, e = 0, i = t.length; e < i; e++) {
var n = t[e];
0 === (n._name && n._name.search("CHILD_ARMATURE-")) && n.destroy();
}
},
_updateBatch: function() {
var t = this._materialCache;
for (var e in t) {
var i = t[e];
i && (i.useModel = !this.enableBatch);
}
},
_updateMaterial: function(t) {
this._super(t);
this._materialCache = {};
},
__preload: function() {
this._init();
},
_init: function() {
if (!this._inited) {
this._inited = !0;
this._cacheMode = l.REALTIME;
this._parseDragonAtlasAsset();
this._refresh();
for (var t = this.node.children, e = 0, i = t.length; e < i; e++) {
var n = t[e];
n && "DEBUG_DRAW_NODE" === n._name && n.destroy();
}
this._updateDebugDraw();
}
},
setAnimationCacheMode: function(t) {},
isAnimationCached: function() {
0;
return this._cacheMode !== l.REALTIME;
},
onEnable: function() {
this._super();
this._armature && !this.isAnimationCached() && this._factory._dragonBones.clock.add(this._armature);
},
onDisable: function() {
this._super();
this._armature && !this.isAnimationCached() && this._factory._dragonBones.clock.remove(this._armature);
},
update: function(t) {
if (this.isAnimationCached() && this._playing) {
var e = this._frameCache.frames, i = this._frameCache.totalTime, n = e.length;
0 == this._accTime && 0 == this._playCount && this._eventTarget && this._eventTarget.emit(dragonBones.EventObject.START);
this._accTime += t * this.timeScale;
var r = Math.floor(this._accTime / i * n);
if (r >= n) {
this._eventTarget && this._eventTarget.emit(dragonBones.EventObject.LOOP_COMPLETE);
this._eventTarget && this._eventTarget.emit(dragonBones.EventObject.COMPLETE);
this._playCount++;
if (-1 === this.playTimes || this.playTimes > 0 && this._playCount >= this.playTimes) {
this._accTime = 0;
this._playing = !1;
this._playCount = 0;
return;
}
this._accTime = 0;
r = 0;
}
this._curFrame = e[r];
}
},
onDestroy: function() {
this._super();
this._inited = !1;
if (this._cacheMode === l.PRIVATE_CACHE) {
this._armatureCache.dispose();
this._armatureCache = null;
this._armature = null;
} else if (this._cacheMode === l.SHARED_CACHE) {
this._armatureCache = null;
this._armature = null;
} else if (this._armature) {
this._armature.dispose();
this._armature = null;
}
},
_updateDebugDraw: function() {
if (this.debugBones) {
if (!this._debugDraw) {
var t = new cc.PrivateNode();
t.name = "DEBUG_DRAW_NODE";
var e = t.addComponent(o);
e.lineWidth = 1;
e.strokeColor = cc.color(255, 0, 0, 255);
this._debugDraw = e;
}
this._debugDraw.node.parent = this.node;
} else this._debugDraw && (this._debugDraw.node.parent = null);
},
_buildArmature: function() {
if (this.dragonAsset && this.dragonAtlasAsset && this.armatureName) {
if (this._armature) {
this._preCacheMode === l.PRIVATE_CACHE ? this._armatureCache.dispose() : this._preCacheMode === l.REALTIME && this._armature.dispose();
this._armatureCache = null;
this._armature = null;
this._displayProxy = null;
this._frameCache = null;
this._curFrame = null;
this._playing = !1;
this._preCacheMode = null;
this._eventTarget = null;
}
if (this._cacheMode === l.SHARED_CACHE) {
this._armatureCache = a.sharedCache;
this._eventTarget = new s();
} else if (this._cacheMode === l.PRIVATE_CACHE) {
this._armatureCache = new a();
this._eventTarget = new s();
}
var 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 = l.REALTIME);
}
this._preCacheMode = this._cacheMode;
if (this._cacheMode === l.REALTIME) {
this._displayProxy = this._factory.buildArmatureDisplay(this.armatureName, this._armatureKey, "", t);
if (!this._displayProxy) return;
this._displayProxy._ccNode = this.node;
this._armature = this._displayProxy._armature;
this._armature.animation.timeScale = this.timeScale;
}
this._cacheMode !== l.REALTIME && this.debugBones && cc.warn("Debug bones is invalid in cached mode");
this._updateBatch();
this.animationName && this.playAnimation(this.animationName, this.playTimes);
}
},
_parseDragonAtlasAsset: function() {
this.dragonAtlasAsset && this.dragonAtlasAsset.init(this._factory);
},
_refresh: function() {
this._buildArmature();
0;
},
_updateCacheModeEnum: !1,
_updateAnimEnum: !1,
_updateArmatureEnum: !1,
playAnimation: function(t, e) {
this.playTimes = void 0 === e ? -1 : e;
this.animationName = t;
if (this.isAnimationCached()) {
var i = this._armatureCache.getAnimationCache(this._armatureKey, t);
i || (i = this._armatureCache.updateAnimationCache(this._armatureKey, t));
if (i) {
this._accTime = 0;
this._playCount = 0;
this._frameCache = i;
this._playing = !0;
this._curFrame = this._frameCache.frames[0];
}
} else if (this._armature) return this._armature.animation.play(t, this.playTimes);
},
updateAnimationCache: function(t) {
if (this.isAnimationCached()) {
var e = this._armatureCache.updateAnimationCache(this._armatureKey, t);
this._frameCache = e || this._frameCache;
}
},
getArmatureNames: function() {
var t = this._factory.getDragonBonesData(this._armatureKey);
return t && t.armatureNames || [];
},
getAnimationNames: function(t) {
var e = [], i = this._factory.getDragonBonesData(this._armatureKey);
if (i) {
var n = i.getArmature(t);
if (n) for (var r in n.animations) n.animations.hasOwnProperty(r) && e.push(r);
}
return e;
},
on: function(t, e, i) {
this.addEventListener(t, e, i);
},
off: function(t, e, i) {
this.removeEventListener(t, e, i);
},
once: function(t, e, i) {
this._displayProxy ? this._displayProxy.once(t, e, i) : this._eventTarget && this._eventTarget.once(t, e, i);
},
addEventListener: function(t, e, i) {
this._displayProxy ? this._displayProxy.on(t, e, i) : this._eventTarget && this._eventTarget.on(t, e, i);
},
removeEventListener: function(t, e, i) {
this._displayProxy ? this._displayProxy.off(t, e, i) : this._eventTarget && this._eventTarget.off(t, e, i);
},
buildArmature: function(t, e) {
return this._factory.createArmatureNode(this, t, e);
},
armature: function() {
return this._armature;
}
});
e.exports = dragonBones.ArmatureDisplay = u;
}), {
"../../cocos2d/core/CCNode": 29,
"../../cocos2d/core/components/CCRenderComponent": 77,
"../../cocos2d/core/event/event-target": 102,
"../../cocos2d/core/graphics/graphics": 106,
"../../cocos2d/core/renderer/render-engine": 202,
"./ArmatureCache": void 0
} ],
284: [ (function(t, e, i) {
var n = cc.Class({
name: "dragonBones.DragonBonesAsset",
extends: cc.Asset,
ctor: function() {
this.reset();
},
properties: {
_dragonBonesJson: "",
dragonBonesJson: {
get: function() {
return this._dragonBonesJson;
},
set: function(t) {
this._dragonBonesJson = t;
this.reset();
}
},
_nativeAsset: {
get: function() {
return this._buffer;
},
set: function(t) {
this._buffer = t.buffer || t;
this.reset();
},
override: !0
}
},
statics: {
preventDeferredLoadDependents: !0
},
createNode: !1,
reset: function() {
this._clear();
0;
},
init: function(t, e) {
this._factory = t;
var i = this._uuid + "#" + e;
if (this._factory.getDragonBonesData(i)) return i;
var n = null;
n = this.dragonBonesJson ? JSON.parse(this.dragonBonesJson) : this._nativeAsset;
this._factory.parseDragonBonesData(n, i);
return i;
},
getArmatureEnum: !1,
getAnimsEnum: !1,
_clear: function() {},
destroy: function() {
this._clear();
this._super();
}
});
dragonBones.DragonBonesAsset = e.exports = n;
}), {
"./ArmatureCache": void 0
} ],
285: [ (function(t, e, i) {
var n = cc.Class({
name: "dragonBones.DragonBonesAtlasAsset",
extends: cc.Asset,
ctor: function() {
this._clear();
},
properties: {
_atlasJson: "",
atlasJson: {
get: function() {
return this._atlasJson;
},
set: function(t) {
this._atlasJson = t;
this._clear();
}
},
_texture: {
default: null,
type: cc.Texture2D,
formerlySerializedAs: "texture"
},
texture: {
get: function() {
return this._texture;
},
set: function(t) {
this._texture = t;
this._clear();
}
},
_textureAtlasData: null
},
statics: {
preventDeferredLoadDependents: !0
},
createNode: !1,
init: function(t) {
this._factory = t;
this._textureAtlasData ? t.addTextureAtlasData(this._textureAtlasData, this._uuid) : this._textureAtlasData = t.parseTextureAtlasData(this.atlasJson, this.texture, this._uuid);
},
_clear: function() {},
destroy: function() {
this._clear();
this._super();
}
});
dragonBones.DragonBonesAtlasAsset = e.exports = n;
}), {
"./ArmatureCache": void 0
} ],
286: [ (function(i, n, r) {
var s = "undefined" === ("object" === (e = typeof window) ? t(window) : e) ? global : window;
0;
if (void 0 !== s.dragonBones) {
dragonBones.DisplayType = {
Image: 0,
Armature: 1,
Mesh: 2
};
dragonBones.ArmatureType = {
Armature: 0,
MovieClip: 1,
Stage: 2
};
dragonBones.ExtensionType = {
FFD: 0,
AdjustColor: 10,
BevelFilter: 11,
BlurFilter: 12,
DropShadowFilter: 13,
GlowFilter: 14,
GradientBevelFilter: 15,
GradientGlowFilter: 16
};
dragonBones.EventType = {
Frame: 0,
Sound: 1
};
dragonBones.ActionType = {
Play: 0,
Stop: 1,
GotoAndPlay: 2,
GotoAndStop: 3,
FadeIn: 4,
FadeOut: 5
};
dragonBones.AnimationFadeOutMode = {
None: 0,
SameLayer: 1,
SameGroup: 2,
SameLayerAndGroup: 3,
All: 4
};
dragonBones.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
};
dragonBones.BoneType = {
Bone: 0,
Surface: 1
};
0;
i("./DragonBonesAsset");
i("./DragonBonesAtlasAsset");
i("./ArmatureDisplay");
i("./webgl-assembler");
}
}), {
"./ArmatureCache": void 0,
"./ArmatureDisplay": 283,
"./CCArmatureDisplay": void 0,
"./CCFactory": void 0,
"./CCSlot": void 0,
"./CCTextureData": void 0,
"./DragonBonesAsset": 284,
"./DragonBonesAtlasAsset": 285,
"./lib/dragonBones": void 0,
"./webgl-assembler": 287
} ],
287: [ (function(t, e, i) {
var n = t("./ArmatureDisplay"), r = t("../../cocos2d/core/renderer/render-engine"), s = t("../../cocos2d/core/renderer/render-flow"), o = r.gfx, a = t("../../cocos2d/core/renderer/render-engine").math, c = cc.color(255, 0, 0, 255), h = cc.color(0, 0, 255, 255), l = void 0, u = void 0, _ = void 0, f = void 0, d = void 0, m = void 0, p = void 0, v = void 0, y = void 0, g = void 0, x = void 0, C = void 0, A = void 0, b = void 0, S = void 0, T = void 0, w = void 0, E = void 0, B = void 0, M = void 0, D = void 0, I = void 0, P = void 0, R = void 0, L = void 0, F = void 0, V = void 0, O = void 0, N = void 0;
function k(t, e) {
if (!t) return null;
var i = void 0, n = void 0;
switch (e) {
case 1:
i = d ? cc.macro.ONE : cc.macro.SRC_ALPHA;
n = cc.macro.ONE;
break;

case 10:
i = cc.macro.DST_COLOR;
n = cc.macro.ONE_MINUS_SRC_ALPHA;
break;

case 12:
i = cc.macro.ONE;
n = cc.macro.ONE_MINUS_SRC_COLOR;
break;

case 0:
default:
i = d ? cc.macro.ONE : cc.macro.SRC_ALPHA;
n = cc.macro.ONE_MINUS_SRC_ALPHA;
}
var r = !g.enableBatch, s = t.url + i + n + r, a = g._material;
if (!a) return null;
var c = g._materialCache, h = c[s];
if (h) {
if (h.texture !== t) {
h.texture = t;
h.updateHash(s);
}
} else {
(h = c[a._hash] ? a.clone() : a).useModel = r;
h.texture = t;
h.useColor = !1;
h._mainTech.passes[0].setBlend(o.BLEND_FUNC_ADD, i, n, o.BLEND_FUNC_ADD, i, n);
c[s] = h;
h.updateHash(s);
}
return h;
}
function G(t) {
B = t.r * l;
M = t.g * u;
D = t.b * _;
I = t.a * f;
E = (I << 24 >>> 0) + (D << 16) + (M << 8) + B;
}
var z = {
updateRenderData: function(t, e) {},
realTimeTraverse: function(t, e) {
for (var i = t._slots, n = void 0, r = void 0, s = void 0, o = void 0, c = void 0, h = void 0, l = void 0, u = void 0, _ = void 0, f = 0, d = i.length; f < d; f++) if ((l = i[f])._visible && l._displayData) {
e ? l._mulMat(l._worldMatrix, e, l._matrix) : a.mat4.copy(l._worldMatrix, l._matrix);
if (l.childArmature) this.realTimeTraverse(l.childArmature, l._worldMatrix); else if (o = k(l.getTexture(), l._blendMode)) {
if (m || o._hash !== y.material._hash) {
m = !1;
y._flush();
y.node = v;
y.material = o;
}
G(l._color);
u = l._worldMatrix;
c = l._localVertices;
b = c.length >> 2;
h = l._indices;
S = h.length;
_ = p.request(b, S);
C = _.indiceOffset;
x = _.byteOffset >> 2;
A = _.vertexOffset;
n = p._vData;
r = p._iData;
s = p._uintVData;
R = u.m00;
L = u.m04;
F = u.m12;
V = u.m01;
O = u.m05;
N = u.m13;
for (var g = 0, B = c.length; g < B; ) {
T = c[g++];
w = c[g++];
n[x++] = T * R + w * L + F;
n[x++] = T * V + w * O + N;
n[x++] = c[g++];
n[x++] = c[g++];
s[x++] = E;
}
for (var M = 0, D = h.length; M < D; M++) r[C++] = A + h[M];
}
}
},
cacheTraverse: function(t, e) {
if (t) {
var i = t.segments;
if (0 != i.length) {
var n = void 0, r = void 0, s = void 0, o = void 0, a = void 0, c = t.vertices, h = t.indices, l = t.uintVert, u = 0, _ = 0, f = 0;
if (e) {
R = e.m00;
L = e.m04;
F = e.m12;
V = e.m01;
O = e.m05;
N = e.m13;
}
var d = 0, g = t.colors, B = g[d++], M = B.vfOffset;
G(B);
for (var D = 0, I = i.length; D < I; D++) {
var z = i[D];
o = k(z.tex, z.blendMode);
if (m || o._hash !== y.material._hash) {
m = !1;
y._flush();
y.node = v;
y.material = o;
}
b = z.vertexCount;
S = z.indexCount;
a = p.request(b, S);
C = a.indiceOffset;
A = a.vertexOffset;
x = a.byteOffset >> 2;
n = p._vData;
r = p._iData;
s = p._uintVData;
for (var U = C, j = C + S; U < j; U++) r[U] = A + h[_++];
f = z.vfCount;
switch (P) {
case 1:
case 0:
n.set(c.subarray(u, u + f), x);
u += f;
break;

case 16:
case 17:
for (var H = x, W = x + f; H < W; ) {
T = c[u++];
w = c[u++];
n[H++] = T * R + w * L + F;
n[H++] = T * V + w * O + N;
n[H++] = c[u++];
n[H++] = c[u++];
s[H++] = l[u++];
}
}
if (1 & P) for (var q = u - f, X = x + 4, Y = x + 4 + f; X < Y; X += 5, q += 5) {
if (q >= M) {
G(B = g[d++]);
M = B.vfOffset;
}
s[X] = E;
}
}
}
}
},
fillBuffers: function(t, e) {
t.node._renderFlag |= s.FLAG_UPDATE_RENDER_DATA;
m = !0;
d = t.premultipliedAlpha;
v = t.node;
p = e._meshBuffer;
y = e;
g = t;
P = 0;
var i = v._color;
l = i.r / 255;
u = i.g / 255;
_ = i.b / 255;
f = i.a / 255;
4294967295 !== i._val && (P |= 1);
var n = void 0;
if (g.enableBatch) {
n = v._worldMatrix;
m = !1;
P |= 16;
}
if (t.isAnimationCached()) this.cacheTraverse(t._curFrame, n); else {
var r = t._armature;
if (!r) return;
this.realTimeTraverse(r, n);
var o = t._debugDraw;
if (t.debugBones && o) {
o.clear();
o.lineWidth = 5;
o.strokeColor = c;
o.fillColor = h;
for (var a = r.getBones(), x = 0, C = a.length; x < C; x++) {
var A = a[x], b = Math.max(A.boneData.length, 5), S = A.globalTransformMatrix.tx, T = -A.globalTransformMatrix.ty, w = S + A.globalTransformMatrix.a * b, E = T - A.globalTransformMatrix.b * b;
o.moveTo(S, T);
o.lineTo(w, E);
o.stroke();
}
}
}
v = void 0;
p = void 0;
y = void 0;
g = void 0;
}
};
e.exports = n._assembler = z;
}), {
"../../cocos2d/core/renderer/render-engine": 202,
"../../cocos2d/core/renderer/render-flow": 203,
"./ArmatureDisplay": 283
} ],
288: [ (function(t, e, i) {
var n = t("./track-entry-listeners"), r = t("../../cocos2d/core/components/CCRenderComponent"), s = t("./lib/spine"), o = t("../../cocos2d/core/renderer/render-engine").SpineMaterial, a = t("../../cocos2d/core/graphics/graphics"), c = t("./skeleton-cache"), h = cc.Enum({
default: -1
}), l = cc.Enum({
"<None>": 0
}), u = cc.Enum({
REALTIME: 0,
SHARED_CACHE: 1,
PRIVATE_CACHE: 2
});
sp.Skeleton = cc.Class({
name: "sp.Skeleton",
extends: r,
editor: !1,
statics: {
AnimationCacheMode: u
},
properties: {
paused: {
default: !1,
visible: !1
},
skeletonData: {
default: null,
type: sp.SkeletonData,
notify: function() {
this.defaultSkin = "";
this.defaultAnimation = "";
0;
this._updateSkeletonData();
},
tooltip: !1
},
defaultSkin: {
default: "",
visible: !1
},
defaultAnimation: {
default: "",
visible: !1
},
animation: {
get: function() {
if (this.isAnimationCached()) return this._animationName;
var t = this.getCurrent(0);
return t && t.animation.name || "";
},
set: function(t) {
this.defaultAnimation = t;
if (t) this.setAnimation(0, t, this.loop); else {
this.clearTrack(0);
this.setToSetupPose();
}
},
visible: !1
},
_defaultSkinIndex: {
get: function() {
if (this.skeletonData && this.defaultSkin) {
var t = this.skeletonData.getSkinsEnum();
if (t) {
var e = t[this.defaultSkin];
if (void 0 !== e) return e;
}
}
return 0;
},
set: function(t) {
var e;
this.skeletonData && (e = this.skeletonData.getSkinsEnum());
if (!e) return cc.errorID("", this.name);
var i = e[t];
if (void 0 !== i) {
this.defaultSkin = i;
0;
} else cc.errorID(7501, this.name);
},
type: h,
visible: !0,
displayName: "Default Skin",
tooltip: !1
},
_animationIndex: {
get: function() {
var t = this.animation;
if (this.skeletonData && t) {
var e = this.skeletonData.getAnimsEnum();
if (e) {
var i = e[t];
if (void 0 !== i) return i;
}
}
return 0;
},
set: function(t) {
if (0 !== t) {
var e;
this.skeletonData && (e = this.skeletonData.getAnimsEnum());
if (!e) return cc.errorID(7502, this.name);
var i = e[t];
void 0 !== i ? this.animation = i : cc.errorID(7503, this.name);
} else this.animation = "";
},
type: l,
visible: !0,
displayName: "Animation",
tooltip: !1
},
_preCacheMode: -1,
_cacheMode: u.REALTIME,
_defaultCacheMode: {
default: 0,
type: u,
notify: function() {
this.setAnimationCacheMode(this._defaultCacheMode);
},
editorOnly: !0,
visible: !0,
animatable: !1,
displayName: "Animation Cache Mode",
tooltip: !1
},
loop: {
default: !0,
tooltip: !1
},
premultipliedAlpha: {
default: !0,
tooltip: !1
},
timeScale: {
default: 1,
tooltip: !1
},
debugSlots: {
default: !1,
editorOnly: !0,
tooltip: !1,
notify: function() {
this._updateDebugDraw();
}
},
debugBones: {
default: !1,
editorOnly: !0,
tooltip: !1,
notify: function() {
this._updateDebugDraw();
}
},
useTint: {
default: !1,
tooltip: !1,
notify: function() {
this._updateUseTint();
}
},
enableBatch: {
default: !1,
notify: function() {
this._updateBatch();
},
tooltip: !1
},
_accTime: 0,
_playCount: 0,
_frameCache: null,
_curFrame: null,
_skeletonCache: null,
_animationName: null,
_animationQueue: [],
_headAniInfo: null,
_playTimes: 0,
_isAniComplete: !0
},
ctor: function() {
this._skeleton = null;
this._rootBone = null;
this._listener = null;
this._boundingBox = cc.rect();
this._material = new o();
this._materialCache = {};
this._debugRenderer = null;
this._startSlotIndex = -1;
this._endSlotIndex = -1;
this._startEntry = {
animation: {
name: ""
},
trackIndex: 0
};
this._endEntry = {
animation: {
name: ""
},
trackIndex: 0
};
},
_updateMaterial: function(t) {
this._super(t);
this._materialCache = {};
},
_updateUseTint: function() {
var t = this._materialCache;
for (var e in t) {
var i = t[e];
i && (i.useTint = this.useTint);
}
},
_updateBatch: function() {
var t = this._materialCache;
for (var e in t) {
var i = t[e];
i && (i.useModel = !this.enableBatch);
}
},
setSkeletonData: function(t) {
null != t.width && null != t.height && this.node.setContentSize(t.width, t.height);
if (this.isAnimationCached()) {
var 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 s.Skeleton(t);
this._clipper = new s.SkeletonClipping();
this._rootBone = this._skeleton.getRootBone();
}
},
setSlotsRange: function(t, e) {
if (this.isAnimationCached()) console.warn("Slots visible range can not be modified in cached mode."); else {
this._startSlotIndex = t;
this._endSlotIndex = e;
}
},
setAnimationStateData: function(t) {
if (this.isAnimationCached()) console.warn("'setAnimationStateData' interface can not be invoked in cached mode."); else {
var e = new s.AnimationState(t);
if (this._listener) {
this._state && this._state.removeListener(this._listener);
e.addListener(this._listener);
}
this._state = e;
}
},
__preload: function() {
for (var t = this.node.children, e = 0, i = t.length; e < i; e++) {
var n = t[e];
n && "DEBUG_DRAW_NODE" === n._name && n.destroy();
}
this._cacheMode = u.REALTIME;
this._updateSkeletonData();
this._updateDebugDraw();
this._updateUseTint();
this._updateBatch();
},
setAnimationCacheMode: function(t) {},
isAnimationCached: function() {
0;
return this._cacheMode !== u.REALTIME;
},
update: function(t) {
0;
if (!this.paused) if (this.isAnimationCached()) {
if (this._isAniComplete) {
if (0 === this._animationQueue.length && !this._headAniInfo) return;
this._headAniInfo || (this._headAniInfo = this._animationQueue.shift());
this._accTime += t;
if (this._accTime > this._headAniInfo.delay) {
var e = this._headAniInfo;
this._headAniInfo = null;
this.setAnimation(0, e.animationName, e.loop);
}
return;
}
this._updateCache(t);
} else this._updateRealtime(t);
},
_updateCache: function(t) {
var e = this._frameCache.frames, i = this._frameCache.totalTime, n = e.length;
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 * this.timeScale;
var r = Math.floor(this._accTime / i * n);
if (r >= n) {
this._endEntry.animation.name = this._animationName;
this._listener && this._listener.complete && this._listener.complete(this._endEntry);
this._listener && this._listener.end && this._listener.end(this._endEntry);
this._playCount++;
if (this._playTimes > 0 && this._playCount >= this._playTimes) {
this._accTime = 0;
this._playCount = 0;
this._isAniComplete = !0;
return;
}
this._accTime = 0;
r = 0;
}
this._curFrame = e[r];
},
_updateRealtime: function(t) {
var e = this._skeleton, i = this._state;
if (e) {
e.update(t);
if (i) {
t *= this.timeScale;
i.update(t);
i.apply(e);
}
}
},
onRestore: function() {
if (!this._material) {
this._boundingBox = cc.rect();
this._material = new o();
this._materialCache = {};
}
},
updateWorldTransform: function() {
this.isAnimationCached() && this._skeleton && this._skeleton.updateWorldTransform();
},
setToSetupPose: function() {
this.isAnimationCached() ? cc.warn("'SetToSetupPose' interface can not be invoked in cached mode.") : this._skeleton && this._skeleton.setToSetupPose();
},
setBonesToSetupPose: function() {
this.isAnimationCached() ? cc.warn("'setBonesToSetupPose' interface can not be invoked in cached mode.") : this._skeleton && this._skeleton.setBonesToSetupPose();
},
setSlotsToSetupPose: function() {
this.isAnimationCached() ? cc.warn("'setSlotsToSetupPose' interface can not be invoked in cached mode.") : this._skeleton && this._skeleton.setSlotsToSetupPose();
},
updateAnimationCache: function(t) {
if (this.isAnimationCached()) {
var e = this._skeletonCache.updateAnimationCache(this.skeletonData._uuid, t);
this._frameCache = e || this._frameCache;
}
},
findBone: function(t) {
return this._skeleton ? this._skeleton.findBone(t) : null;
},
findSlot: function(t) {
return this._skeleton ? this._skeleton.findSlot(t) : null;
},
setSkin: function(t) {
if (this.isAnimationCached()) {
this._skeletonCache.resetSkeleton();
this._animationName && (this.animation = this._animationName);
} else if (this._skeleton) return this._skeleton.setSkinByName(t);
return null;
},
getAttachment: function(t, e) {
return this._skeleton ? this._skeleton.getAttachmentByName(t, e) : null;
},
setAttachment: function(t, e) {
this._skeleton && this._skeleton.setAttachment(t, e);
},
getTextureAtlas: function(t) {
return t.region;
},
setMix: function(t, e, i) {
this._state && this._state.data.setMix(t, e, i);
},
setAnimation: function(t, e, i) {
this._playTimes = i ? 0 : 1;
this._animationName = e;
if (this.isAnimationCached()) {
0 !== t && cc.warn("Track index can not greater than 0 in cached mode.");
var n = this._skeletonCache.getAnimationCache(this.skeletonData._uuid, e);
n || (n = this._skeletonCache.updateAnimationCache(this.skeletonData._uuid, e));
if (n) {
this._isAniComplete = !1;
this._accTime = 0;
this._playCount = 0;
this._frameCache = n;
this._curFrame = this._frameCache.frames[0];
}
} else if (this._skeleton) {
var r = this._skeleton.data.findAnimation(e);
if (!r) {
cc.logID(7509, e);
return null;
}
var s = this._state.setAnimationWith(t, r, i);
this._state.apply(this._skeleton);
return s;
}
return null;
},
addAnimation: function(t, e, i, n) {
if (this.isAnimationCached()) {
0 !== t && cc.warn("Track index can not greater than 0 in cached mode.");
this._animationQueue.push({
animationName: e,
loop: i,
delay: n
});
} else if (this._skeleton) {
n = n || 0;
var r = this._skeleton.data.findAnimation(e);
if (!r) {
cc.logID(7510, e);
return null;
}
return this._state.addAnimationWith(t, r, i, n);
}
return null;
},
findAnimation: function(t) {
return this._skeleton ? this._skeleton.data.findAnimation(t) : null;
},
getCurrent: function(t) {
if (this.isAnimationCached()) console.warn("'getCurrent' interface can not be invoked in cached mode."); else if (this._state) return this._state.getCurrent(t);
return null;
},
clearTracks: function() {
this.isAnimationCached() ? console.warn("'clearTracks' interface can not be invoked in cached mode.") : this._state && this._state.clearTracks();
},
clearTrack: function(t) {
if (this.isAnimationCached()) console.warn("'clearTrack' interface can not be invoked in cached mode."); else if (this._state) {
this._state.clearTrack(t);
0;
}
},
setStartListener: function(t) {
this._ensureListener();
this._listener.start = t;
},
setInterruptListener: function(t) {
this._ensureListener();
this._listener.interrupt = t;
},
setEndListener: function(t) {
this._ensureListener();
this._listener.end = t;
},
setDisposeListener: function(t) {
this._ensureListener();
this._listener.dispose = t;
},
setCompleteListener: function(t) {
this._ensureListener();
this._listener.complete = t;
},
setEventListener: function(t) {
this._ensureListener();
this._listener.event = t;
},
setTrackStartListener: function(t, e) {
n.getListeners(t).start = e;
},
setTrackInterruptListener: function(t, e) {
n.getListeners(t).interrupt = e;
},
setTrackEndListener: function(t, e) {
n.getListeners(t).end = e;
},
setTrackDisposeListener: function(t, e) {
n.getListeners(t).dispose = e;
},
setTrackCompleteListener: function(t, e) {
n.getListeners(t).complete = function(t) {
var i = Math.floor(t.trackTime / t.animationEnd);
e(t, i);
};
},
setTrackEventListener: function(t, e) {
n.getListeners(t).event = e;
},
getState: function() {
return this._state;
},
_updateAnimEnum: !1,
_updateSkinEnum: !1,
_ensureListener: function() {
if (!this._listener) {
this._listener = new n();
this._state && this._state.addListener(this._listener);
}
},
_updateSkeletonData: function() {
if (this.skeletonData) {
var t = this.skeletonData.getRuntimeData();
if (t) {
this._cacheMode === u.SHARED_CACHE ? this._skeletonCache = c.sharedCache : this._cacheMode === u.PRIVATE_CACHE && (this._skeletonCache = new c());
this.isAnimationCached() && (this.debugBones || this.debugSlots) && cc.warn("Debug bones or slots is invalid in cached mode");
try {
this.setSkeletonData(t);
this.isAnimationCached() || this.setAnimationStateData(new s.AnimationStateData(this._skeleton.data));
this.defaultSkin && this.setSkin(this.defaultSkin);
} catch (t) {
cc.warn(t);
}
this._preCacheMode = this._cacheMode;
this.animation = this.defaultAnimation;
}
}
},
_refreshInspector: function() {
this._updateAnimEnum();
this._updateSkinEnum();
Editor.Utils.refreshSelectedInspector("node", this.node.uuid);
},
_updateDebugDraw: function() {
if (this.debugBones || this.debugSlots) {
if (!this._debugRenderer) {
var t = new cc.PrivateNode();
t.name = "DEBUG_DRAW_NODE";
var e = t.addComponent(a);
e.lineWidth = 1;
e.strokeColor = cc.color(255, 0, 0, 255);
this._debugRenderer = e;
}
this._debugRenderer.node.parent = this.node;
this.isAnimationCached() && cc.warn("Debug bones or slots is invalid in cached mode");
} else this._debugRenderer && (this._debugRenderer.node.parent = null);
}
});
e.exports = sp.Skeleton;
}), {
"../../cocos2d/core/components/CCRenderComponent": 77,
"../../cocos2d/core/graphics/graphics": 106,
"../../cocos2d/core/renderer/render-engine": 202,
"./lib/spine": void 0,
"./skeleton-cache": void 0,
"./track-entry-listeners": 293
} ],
289: [ (function(i, n, r) {
var s = "undefined" === ("object" === (e = typeof window) ? t(window) : e) ? global : window, o = !0;
void 0 === s.spine && (o = !1);
if (o) {
s.sp = {};
sp.ATTACHMENT_TYPE = {
REGION: 0,
BOUNDING_BOX: 1,
MESH: 2,
SKINNED_MESH: 3
};
sp.AnimationEventType = cc.Enum({
START: 0,
INTERRUPT: 1,
END: 2,
DISPOSE: 3,
COMPLETE: 4,
EVENT: 5
});
sp.spine = s.spine;
i("./skeleton-texture");
i("./skeleton-data");
i("./Skeleton");
i("./spine-assembler");
}
}), {
"./Skeleton": 288,
"./lib/spine": void 0,
"./skeleton-data": 290,
"./skeleton-texture": 291,
"./spine-assembler": 292
} ],
290: [ (function(t, e, i) {
var n = cc.Class({
name: "sp.SkeletonData",
extends: cc.Asset,
ctor: function() {
this.reset();
},
properties: {
_skeletonJson: null,
skeletonJson: {
get: function() {
return this._skeletonJson;
},
set: function(t) {
this._skeletonJson = t;
this.reset();
}
},
_atlasText: "",
atlasText: {
get: function() {
return this._atlasText;
},
set: function(t) {
this._atlasText = t;
this.reset();
}
},
textures: {
default: [],
type: [ cc.Texture2D ]
},
textureNames: {
default: [],
type: [ cc.String ]
},
scale: 1
},
statics: {
preventDeferredLoadDependents: !0,
preventPreloadNativeObject: !0
},
createNode: !1,
reset: function() {
this._skeletonCache = null;
this._atlasCache = null;
0;
},
getRuntimeData: function(t) {
if (this._skeletonCache) return this._skeletonCache;
if (!(this.textures && this.textures.length > 0) && this.textureNames && this.textureNames.length > 0) {
t || cc.errorID(7507, this.name);
return null;
}
var e = this._getAtlas(t);
if (!e) return null;
var i = new sp.spine.AtlasAttachmentLoader(e), n = new sp.spine.SkeletonJson(i);
n.scale = this.scale;
var r = this.skeletonJson;
this._skeletonCache = n.readSkeletonData(r);
e.dispose(n);
return this._skeletonCache;
},
getSkinsEnum: !1,
getAnimsEnum: !1,
_getTexture: function(t) {
for (var e = this.textureNames, i = 0; i < e.length; i++) if (e[i] === t) {
var n = this.textures[i], r = new sp.SkeletonTexture({
width: n.width,
height: n.height
});
r.setRealTexture(n);
return r;
}
cc.errorID(7506, t);
return null;
},
_getAtlas: function(t) {
if (this._atlasCache) return this._atlasCache;
if (!this.atlasText) {
t || cc.errorID(7508, this.name);
return null;
}
return this._atlasCache = new sp.spine.TextureAtlas(this.atlasText, this._getTexture.bind(this));
},
destroy: function() {
0;
this._super();
}
});
sp.SkeletonData = e.exports = n;
}), {
"./skeleton-cache": void 0
} ],
291: [ (function(t, e, i) {
sp.SkeletonTexture = cc.Class({
name: "sp.SkeletonTexture",
extends: sp.spine.Texture,
_texture: null,
_material: null,
setRealTexture: function(t) {
this._texture = t;
},
getRealTexture: function() {
return this._texture;
},
setFilters: function(t, e) {
this._texture && this._texture.setFilters(t, e);
},
setWraps: function(t, e) {
this._texture && this._texture.setWrapMode(t, e);
},
dispose: function() {}
});
}), {} ],
292: [ (function(t, e, i) {
var n = t("./Skeleton"), r = t("./lib/spine"), s = t("../../cocos2d/core/renderer"), o = t("../../cocos2d/core/renderer/render-flow"), a = s.renderEngine.gfx, c = t("../../cocos2d/core/renderer/webgl/vertex-format"), h = c.vfmtPosUvColor, l = c.vfmtPosUvTwoColor, u = 0, _ = [ 0, 1, 2, 2, 3, 0 ], f = cc.color(0, 0, 255, 255), d = cc.color(255, 0, 0, 255), m = cc.color(0, 255, 0, 255), p = void 0, v = void 0;
0;
var y = void 0, g = void 0, x = void 0, C = void 0, A = void 0, b = void 0, S = void 0, T = void 0, w = void 0, E = void 0, B = void 0, M = void 0, D = void 0, I = void 0, P = void 0, R = void 0, L = 0, F = 0, V = 0, O = 0, N = 0, k = 0, G = 0, z = void 0, U = void 0, j = void 0, H = void 0, W = void 0, q = void 0, X = void 0, Y = void 0, J = void 0, Z = void 0, K = void 0, Q = void 0, $ = void 0, tt = void 0, et = void 0, it = void 0, nt = void 0, rt = void 0, st = void 0, ot = void 0, at = void 0, ct = void 0, ht = void 0, lt = void 0, ut = void 0, _t = void 0, ft = void 0, dt = void 0, mt = void 0;
function pt(t, e) {
var i = void 0, n = void 0;
switch (e) {
case r.BlendMode.Additive:
i = y ? cc.macro.ONE : cc.macro.SRC_ALPHA;
n = cc.macro.ONE;
break;

case r.BlendMode.Multiply:
i = cc.macro.DST_COLOR;
n = cc.macro.ONE_MINUS_SRC_ALPHA;
break;

case r.BlendMode.Screen:
i = cc.macro.ONE;
n = cc.macro.ONE_MINUS_SRC_COLOR;
break;

case r.BlendMode.Normal:
default:
i = y ? cc.macro.ONE : cc.macro.SRC_ALPHA;
n = cc.macro.ONE_MINUS_SRC_ALPHA;
}
var s = !ut.enableBatch, o = t.url + i + n + A + s, c = ut._material;
if (!c) return null;
var h = ut._materialCache, l = h[o];
if (l) {
if (l.texture !== t) {
l.texture = t;
l.updateHash(o);
}
} else {
(l = h[c._hash] ? c.clone() : c).useModel = s;
l.texture = t;
l.useTint = A;
l._mainTech.passes[0].setBlend(a.BLEND_FUNC_ADD, i, n, a.BLEND_FUNC_ADD, i, n);
l.updateHash(o);
h[o] = l;
}
return l;
}
function vt(t) {
g = y ? t.fa / 255 : 1;
et = T * g;
it = w * g;
nt = E * g;
rt = t.fr * et;
st = t.fg * it;
ot = t.fb * nt;
at = t.fa * B;
M = (at << 24 >>> 0) + (ot << 16) + (st << 8) + rt;
ct = t.dr * et;
ht = t.dg * it;
lt = t.db * nt;
D = ((y ? 255 : 0) << 24 >>> 0) + (lt << 16) + (ht << 8) + ct;
}
var yt = {
updateRenderData: function(t, e) {
var i = t._skeleton;
i && i.updateWorldTransform();
},
fillVertices: function(t, e, i, n, r) {
var s = _t._vData, o = _t._iData, a = _t._uintVData, c = void 0;
H = i.a * e.a * t.a * 255;
g = y ? H : 255;
z = T * e.r * t.r * g;
U = w * e.g * t.g * g;
j = E * e.b * t.b * g;
p.r = z * i.r;
p.g = U * i.g;
p.b = j * i.b;
p.a = H * B;
if (null == r.darkColor) v.set(0, 0, 0, 1); else {
v.r = r.darkColor.r * z;
v.g = r.darkColor.g * U;
v.b = r.darkColor.b * j;
}
v.a = y ? 255 : 0;
if (n.isClipping()) {
var h = s.subarray(V + 2);
n.clipTriangles(s.subarray(V), L, o.subarray(k), N, h, p, v, A, P);
var l = new Float32Array(n.clippedVertices), u = n.clippedTriangles;
N = u.length;
L = l.length / R * P;
c = _t.request(L / P, N);
k = c.indiceOffset, O = c.vertexOffset, V = c.byteOffset >> 2;
s = _t._vData, o = _t._iData;
a = _t._uintVData;
o.set(u, k);
if (A) for (var _ = 0, f = l.length, d = V; _ < f; _ += 12, d += P) {
s[d] = l[_];
s[d + 1] = l[_ + 1];
s[d + 2] = l[_ + 6];
s[d + 3] = l[_ + 7];
M = (l[_ + 5] << 24 >>> 0) + (l[_ + 4] << 16) + (l[_ + 3] << 8) + l[_ + 2];
a[d + 4] = M;
D = (l[_ + 11] << 24 >>> 0) + (l[_ + 10] << 16) + (l[_ + 9] << 8) + l[_ + 8];
a[d + 5] = D;
} else for (var m = 0, x = l.length, C = V; m < x; m += 8, C += P) {
s[C] = l[m];
s[C + 1] = l[m + 1];
s[C + 2] = l[m + 6];
s[C + 3] = l[m + 7];
M = (l[m + 5] << 24 >>> 0) + (l[m + 4] << 16) + (l[m + 3] << 8) + l[m + 2];
a[C + 4] = M;
}
} else {
M = (p.a << 24 >>> 0) + (p.b << 16) + (p.g << 8) + p.r;
D = (v.a << 24 >>> 0) + (v.b << 16) + (v.g << 8) + v.r;
if (A) for (var b = V, S = V + L; b < S; b += P) {
a[b + 4] = M;
a[b + 5] = D;
} else for (var I = V, F = V + L; I < F; I += P) a[I + 4] = M;
}
},
realTimeTraverse: function(t) {
var e = void 0, i = void 0, n = ut._skeleton, s = n.color, o = ut._debugRenderer, a = ut._clipper, c = null, h = void 0, l = void 0, u = void 0, p = void 0, v = void 0, y = void 0, g = void 0, T = void 0, w = void 0;
x = ut._startSlotIndex;
C = ut._endSlotIndex;
W = !1;
-1 == x && (W = !0);
b = ut.debugSlots;
S = ut.debugBones;
if (o && (S || b)) {
o.clear();
o.strokeColor = f;
o.lineWidth = 5;
}
R = A ? 12 : 8;
L = 0;
V = 0;
O = 0;
N = 0;
k = 0;
for (var E = 0, B = n.drawOrder.length; E < B; E++) {
w = n.drawOrder[E];
x >= 0 && x == w.data.index && (W = !0);
if (W) {
C >= 0 && C == w.data.index && (W = !1);
L = 0;
N = 0;
if (h = w.getAttachment()) {
y = h instanceof r.RegionAttachment;
g = h instanceof r.MeshAttachment;
if (h instanceof r.ClippingAttachment) a.clipStart(w, h); else if ((y || g) && (c = pt(h.region.texture._texture, w.data.blendMode))) {
if (q || c._hash !== ft.material._hash) {
q = !1;
ft._flush();
ft.node = dt;
ft.material = c;
}
if (y) {
v = _;
L = 4 * P;
N = 6;
T = _t.request(4, 6);
k = T.indiceOffset, O = T.vertexOffset, V = T.byteOffset >> 2;
e = _t._vData, i = _t._iData;
h.computeWorldVertices(w.bone, e, V, P);
if (o && b) {
o.moveTo(e[V], e[V + 1]);
for (var M = V + P, D = V + L; M < D; M += P) o.lineTo(e[M], e[M + 1]);
o.close();
o.stroke();
}
} else if (g) {
v = h.triangles;
L = (h.worldVerticesLength >> 1) * P;
N = v.length;
T = _t.request(L / P, N);
k = T.indiceOffset, O = T.vertexOffset, V = T.byteOffset >> 2;
e = _t._vData, i = _t._iData;
h.computeWorldVertices(w, 0, h.worldVerticesLength, e, V, P);
}
if (0 != L && 0 != N) {
i.set(v, k);
p = h.uvs;
for (var I = V, F = V + L, G = 0; I < F; I += P, G += 2) {
e[I + 2] = p[G];
e[I + 3] = p[G + 1];
}
l = h.color, u = w.color;
this.fillVertices(s, l, u, a, w);
if (N > 0) {
for (var z = k, U = k + N; z < U; z++) i[z] += O;
if (t) {
J = t.m00;
Z = t.m04;
K = t.m12;
Q = t.m01;
$ = t.m05;
tt = t.m13;
for (var j = V, H = V + L; j < H; j += P) {
X = e[j];
Y = e[j + 1];
e[j] = X * J + Y * Z + K;
e[j + 1] = X * Q + Y * $ + tt;
}
}
_t.adjust(L / P, N);
}
a.clipEndWithSlot(w);
}
}
}
} else a.clipEndWithSlot(w);
}
a.clipEnd();
if (o && S) {
var et = void 0;
o.strokeColor = d;
o.fillColor = f;
for (var it = 0, nt = n.bones.length; it < nt; it++) {
var rt = (et = n.bones[it]).data.length * et.a + et.worldX, st = et.data.length * et.c + et.worldY;
o.moveTo(et.worldX, et.worldY);
o.lineTo(rt, st);
o.stroke();
o.circle(et.worldX, et.worldY, 2 * Math.PI);
o.fill();
0 === it && (o.fillColor = m);
}
}
},
cacheTraverse: function(t) {
var e = ut._curFrame;
if (e) {
var i = e.segments;
if (0 != i.length) {
var n = void 0, r = void 0, s = void 0, o = void 0, a = void 0, c = e.vertices, h = e.indices, l = e.uintVert, _ = 0, f = 0, d = 0;
if (t) {
J = t.m00;
Z = t.m04;
K = t.m12;
Q = t.m01;
$ = t.m05;
tt = t.m13;
}
var m = 0, p = e.colors, v = p[m++], y = v.vfOffset;
vt(v);
for (var g = 0, x = i.length; g < x; g++) {
var C = i[g];
if (o = pt(C.tex, C.blendMode)) {
if (q || o._hash !== ft.material._hash) {
q = !1;
ft._flush();
ft.node = dt;
ft.material = o;
}
F = C.vertexCount;
N = C.indexCount;
L = F * P;
a = _t.request(F, N);
k = a.indiceOffset;
O = a.vertexOffset;
G = a.byteOffset >> 2;
n = _t._vData;
r = _t._iData;
s = _t._uintVData;
for (var b = k, S = k + N; b < S; b++) r[b] = O + h[f++];
d = C.vfCount;
switch (u) {
case 0:
for (var T = G, w = G + L; T < w; ) {
n[T++] = c[_++];
n[T++] = c[_++];
n[T++] = c[_++];
n[T++] = c[_++];
s[T++] = l[_++];
_++;
}
break;

case 1:
n.set(c.subarray(_, _ + L), G);
_ += L;
break;

case 16:
for (var E = G, B = G + L; E < B; ) {
X = c[_++];
Y = c[_++];
n[E++] = X * J + Y * Z + K;
n[E++] = X * Q + Y * $ + tt;
n[E++] = c[_++];
n[E++] = c[_++];
s[E++] = l[_++];
_++;
}
break;

case 17:
for (var I = G, R = G + L; I < R; ) {
X = c[_++];
Y = c[_++];
n[I++] = X * J + Y * Z + K;
n[I++] = X * Q + Y * $ + tt;
n[I++] = c[_++];
n[I++] = c[_++];
s[I++] = l[_++];
s[I++] = l[_++];
}
}
_t.adjust(F, N);
if (mt) for (var V = _ - d, z = G + 4, U = G + 4 + L; z < U; z += P, V += 6) {
if (V >= y) {
vt(v = p[m++]);
y = v.vfOffset;
}
s[z] = M;
A && (s[z + 1] = D);
}
}
}
}
}
},
fillBuffers: function(t, e) {
var i = t.node;
i._renderFlag |= o.FLAG_UPDATE_RENDER_DATA;
if (t._skeleton) {
var n = i._color;
T = n.r / 255;
w = n.g / 255;
E = n.b / 255;
B = n.a / 255;
A = t.useTint;
I = A ? l : h;
P = A ? 6 : 5;
dt = t.node;
_t = e.getBuffer("spine", I);
ft = e;
ut = t;
q = !0;
y = t.premultipliedAlpha;
g = 1;
u = 0;
mt = !1;
(4294967295 !== n._val || y) && (mt = !0);
A && (u |= 1);
var r = void 0;
if (ut.enableBatch) {
r = dt._worldMatrix;
q = !1;
u |= 16;
}
t.isAnimationCached() ? this.cacheTraverse(r) : this.realTimeTraverse(r);
dt = void 0;
_t = void 0;
ft = void 0;
ut = void 0;
}
}
};
n._assembler = yt;
e.exports = yt;
}), {
"../../cocos2d/core/renderer": 201,
"../../cocos2d/core/renderer/render-flow": 203,
"../../cocos2d/core/renderer/webgl/vertex-format": 232,
"./Skeleton": 288,
"./lib/spine": void 0
} ],
293: [ (function(t, e, i) {
var n = function() {
this.start = null;
this.end = null;
this.complete = null;
this.event = null;
this.interrupt = null;
this.dispose = null;
};
n.getListeners = function(t) {
t.listener || (t.listener = new n());
return t.listener;
};
e.exports = n;
}), {} ],
294: [ (function(i, n, r) {
(function(i, s) {
"object" === ("object" === (e = typeof r) ? t(r) : e) && "undefined" !== ("object" === (e = typeof n) ? t(n) : e) ? s(r) : "function" === ("object" === (e = typeof define) ? t(define) : e) && define.amd ? define([ "exports" ], s) : s(i.box2d = {});
})(this, (function(t) {
"use strict";
function e(t, e) {
return void 0 !== t ? t : e;
}
var i = 1e37, n = 1e-5, r = n * n, s = 3.14159265359, o = 2, a = 8, c = .008, h = 2 / 180 * s, l = 2 * c, u = -1;
var _ = (function() {
function t(t, e, i) {
void 0 === t && (t = 0);
void 0 === e && (e = 0);
void 0 === i && (i = 0);
this.major = 0;
this.minor = 0;
this.revision = 0;
this.major = t;
this.minor = e;
this.revision = i;
}
t.prototype.toString = function() {
return this.major + "." + this.minor + "." + this.revision;
};
return t;
})(), f = new _(2, 3, 2);
function d(t, e) {
for (var i = [], n = 0; n < t; ++n) i.push(e(n));
return i;
}
function m(t, e) {
void 0 === e && (e = 0);
for (var i = [], n = 0; n < t; ++n) i.push(e);
return i;
}
var p = s / 180, v = 180 / s, y = Math.abs, g = Math.min, x = Math.max;
function C(t, e, i) {
return t < e ? e : t > i ? i : t;
}
var A = isFinite;
function b(t) {
return t * t;
}
function S(t) {
return 1 / Math.sqrt(t);
}
var T = Math.sqrt, w = Math.pow;
var E = Math.cos, B = Math.sin, M = Math.acos, D = Math.asin, I = Math.atan2;
var P = (function() {
function t(t, e) {
void 0 === t && (t = 0);
void 0 === e && (e = 0);
this.x = t;
this.y = e;
}
t.prototype.Clone = function() {
return new t(this.x, this.y);
};
t.prototype.SetZero = function() {
this.x = 0;
this.y = 0;
return this;
};
t.prototype.Set = function(t, e) {
this.x = t;
this.y = e;
return this;
};
t.prototype.Copy = function(t) {
this.x = t.x;
this.y = t.y;
return this;
};
t.prototype.SelfAdd = function(t) {
this.x += t.x;
this.y += t.y;
return this;
};
t.prototype.SelfAddXY = function(t, e) {
this.x += t;
this.y += e;
return this;
};
t.prototype.SelfSub = function(t) {
this.x -= t.x;
this.y -= t.y;
return this;
};
t.prototype.SelfSubXY = function(t, e) {
this.x -= t;
this.y -= e;
return this;
};
t.prototype.SelfMul = function(t) {
this.x *= t;
this.y *= t;
return this;
};
t.prototype.SelfMulAdd = function(t, e) {
this.x += t * e.x;
this.y += t * e.y;
return this;
};
t.prototype.SelfMulSub = function(t, e) {
this.x -= t * e.x;
this.y -= t * e.y;
return this;
};
t.prototype.Dot = function(t) {
return this.x * t.x + this.y * t.y;
};
t.prototype.Cross = function(t) {
return this.x * t.y - this.y * t.x;
};
t.prototype.Length = function() {
var t = this.x, e = this.y;
return Math.sqrt(t * t + e * e);
};
t.prototype.LengthSquared = function() {
var t = this.x, e = this.y;
return t * t + e * e;
};
t.prototype.Normalize = function() {
var t = this.Length();
if (t >= n) {
var e = 1 / t;
this.x *= e;
this.y *= e;
}
return t;
};
t.prototype.SelfNormalize = function() {
var t = this.Length();
if (t >= n) {
var e = 1 / t;
this.x *= e;
this.y *= e;
}
return this;
};
t.prototype.SelfRotate = function(t) {
var e = Math.cos(t), i = Math.sin(t), n = this.x;
this.x = e * n - i * this.y;
this.y = i * n + e * this.y;
return this;
};
t.prototype.IsValid = function() {
return isFinite(this.x) && isFinite(this.y);
};
t.prototype.SelfCrossVS = function(t) {
var e = this.x;
this.x = t * this.y;
this.y = -t * e;
return this;
};
t.prototype.SelfCrossSV = function(t) {
var e = this.x;
this.x = -t * this.y;
this.y = t * e;
return this;
};
t.prototype.SelfMinV = function(t) {
this.x = g(this.x, t.x);
this.y = g(this.y, t.y);
return this;
};
t.prototype.SelfMaxV = function(t) {
this.x = x(this.x, t.x);
this.y = x(this.y, t.y);
return this;
};
t.prototype.SelfAbs = function() {
this.x = y(this.x);
this.y = y(this.y);
return this;
};
t.prototype.SelfNeg = function() {
this.x = -this.x;
this.y = -this.y;
return this;
};
t.prototype.SelfSkew = function() {
var t = this.x;
this.x = -this.y;
this.y = t;
return this;
};
t.MakeArray = function(e) {
return d(e, (function(e) {
return new t();
}));
};
t.AbsV = function(t, e) {
e.x = y(t.x);
e.y = y(t.y);
return e;
};
t.MinV = function(t, e, i) {
i.x = g(t.x, e.x);
i.y = g(t.y, e.y);
return i;
};
t.MaxV = function(t, e, i) {
i.x = x(t.x, e.x);
i.y = x(t.y, e.y);
return i;
};
t.ClampV = function(t, e, i, n) {
n.x = C(t.x, e.x, i.x);
n.y = C(t.y, e.y, i.y);
return n;
};
t.RotateV = function(t, e, i) {
var n = t.x, r = t.y, s = Math.cos(e), o = Math.sin(e);
i.x = s * n - o * r;
i.y = o * n + s * r;
return i;
};
t.DotVV = function(t, e) {
return t.x * e.x + t.y * e.y;
};
t.CrossVV = function(t, e) {
return t.x * e.y - t.y * e.x;
};
t.CrossVS = function(t, e, i) {
var n = t.x;
i.x = e * t.y;
i.y = -e * n;
return i;
};
t.CrossVOne = function(t, e) {
var i = t.x;
e.x = t.y;
e.y = -i;
return e;
};
t.CrossSV = function(t, e, i) {
var n = e.x;
i.x = -t * e.y;
i.y = t * n;
return i;
};
t.CrossOneV = function(t, e) {
var i = t.x;
e.x = -t.y;
e.y = i;
return e;
};
t.AddVV = function(t, e, i) {
i.x = t.x + e.x;
i.y = t.y + e.y;
return i;
};
t.SubVV = function(t, e, i) {
i.x = t.x - e.x;
i.y = t.y - e.y;
return i;
};
t.MulSV = function(t, e, i) {
i.x = e.x * t;
i.y = e.y * t;
return i;
};
t.MulVS = function(t, e, i) {
i.x = t.x * e;
i.y = t.y * e;
return i;
};
t.AddVMulSV = function(t, e, i, n) {
n.x = t.x + e * i.x;
n.y = t.y + e * i.y;
return n;
};
t.SubVMulSV = function(t, e, i, n) {
n.x = t.x - e * i.x;
n.y = t.y - e * i.y;
return n;
};
t.AddVCrossSV = function(t, e, i, n) {
var r = i.x;
n.x = t.x - e * i.y;
n.y = t.y + e * r;
return n;
};
t.MidVV = function(t, e, i) {
i.x = .5 * (t.x + e.x);
i.y = .5 * (t.y + e.y);
return i;
};
t.ExtVV = function(t, e, i) {
i.x = .5 * (e.x - t.x);
i.y = .5 * (e.y - t.y);
return i;
};
t.IsEqualToV = function(t, e) {
return t.x === e.x && t.y === e.y;
};
t.DistanceVV = function(t, e) {
var i = t.x - e.x, n = t.y - e.y;
return Math.sqrt(i * i + n * n);
};
t.DistanceSquaredVV = function(t, e) {
var i = t.x - e.x, n = t.y - e.y;
return i * i + n * n;
};
t.NegV = function(t, e) {
e.x = -t.x;
e.y = -t.y;
return e;
};
t.ZERO = new t(0, 0);
t.UNITX = new t(1, 0);
t.UNITY = new t(0, 1);
t.s_t0 = new t();
t.s_t1 = new t();
t.s_t2 = new t();
t.s_t3 = new t();
return t;
})(), R = new P(0, 0), L = (function() {
function t(t, e, i) {
void 0 === t && (t = 0);
void 0 === e && (e = 0);
void 0 === i && (i = 0);
this.x = t;
this.y = e;
this.z = i;
}
t.prototype.Clone = function() {
return new t(this.x, this.y, this.z);
};
t.prototype.SetZero = function() {
this.x = 0;
this.y = 0;
this.z = 0;
return this;
};
t.prototype.SetXYZ = function(t, e, i) {
this.x = t;
this.y = e;
this.z = i;
return this;
};
t.prototype.Copy = function(t) {
this.x = t.x;
this.y = t.y;
this.z = t.z;
return this;
};
t.prototype.SelfNeg = function() {
this.x = -this.x;
this.y = -this.y;
this.z = -this.z;
return this;
};
t.prototype.SelfAdd = function(t) {
this.x += t.x;
this.y += t.y;
this.z += t.z;
return this;
};
t.prototype.SelfAddXYZ = function(t, e, i) {
this.x += t;
this.y += e;
this.z += i;
return this;
};
t.prototype.SelfSub = function(t) {
this.x -= t.x;
this.y -= t.y;
this.z -= t.z;
return this;
};
t.prototype.SelfSubXYZ = function(t, e, i) {
this.x -= t;
this.y -= e;
this.z -= i;
return this;
};
t.prototype.SelfMul = function(t) {
this.x *= t;
this.y *= t;
this.z *= t;
return this;
};
t.DotV3V3 = function(t, e) {
return t.x * e.x + t.y * e.y + t.z * e.z;
};
t.CrossV3V3 = function(t, e, i) {
var n = t.x, r = t.y, s = t.z, o = e.x, a = e.y, c = e.z;
i.x = r * c - s * a;
i.y = s * o - n * c;
i.z = n * a - r * o;
return i;
};
t.ZERO = new t(0, 0, 0);
t.s_t0 = new t();
return t;
})(), F = (function() {
function t() {
this.ex = new P(1, 0);
this.ey = new P(0, 1);
}
t.prototype.Clone = function() {
return new t().Copy(this);
};
t.FromVV = function(e, i) {
return new t().SetVV(e, i);
};
t.FromSSSS = function(e, i, n, r) {
return new t().SetSSSS(e, i, n, r);
};
t.FromAngle = function(e) {
return new t().SetAngle(e);
};
t.prototype.SetSSSS = function(t, e, i, n) {
this.ex.Set(t, i);
this.ey.Set(e, n);
return this;
};
t.prototype.SetVV = function(t, e) {
this.ex.Copy(t);
this.ey.Copy(e);
return this;
};
t.prototype.SetAngle = function(t) {
var e = Math.cos(t), i = Math.sin(t);
this.ex.Set(e, i);
this.ey.Set(-i, e);
return this;
};
t.prototype.Copy = function(t) {
this.ex.Copy(t.ex);
this.ey.Copy(t.ey);
return this;
};
t.prototype.SetIdentity = function() {
this.ex.Set(1, 0);
this.ey.Set(0, 1);
return this;
};
t.prototype.SetZero = function() {
this.ex.SetZero();
this.ey.SetZero();
return this;
};
t.prototype.GetAngle = function() {
return Math.atan2(this.ex.y, this.ex.x);
};
t.prototype.GetInverse = function(t) {
var e = this.ex.x, i = this.ey.x, n = this.ex.y, r = this.ey.y, s = e * r - i * n;
0 !== s && (s = 1 / s);
t.ex.x = s * r;
t.ey.x = -s * i;
t.ex.y = -s * n;
t.ey.y = s * e;
return t;
};
t.prototype.Solve = function(t, e, i) {
var n = this.ex.x, r = this.ey.x, s = this.ex.y, o = this.ey.y, a = n * o - r * s;
0 !== a && (a = 1 / a);
i.x = a * (o * t - r * e);
i.y = a * (n * e - s * t);
return i;
};
t.prototype.SelfAbs = function() {
this.ex.SelfAbs();
this.ey.SelfAbs();
return this;
};
t.prototype.SelfInv = function() {
this.GetInverse(this);
return this;
};
t.prototype.SelfAddM = function(t) {
this.ex.SelfAdd(t.ex);
this.ey.SelfAdd(t.ey);
return this;
};
t.prototype.SelfSubM = function(t) {
this.ex.SelfSub(t.ex);
this.ey.SelfSub(t.ey);
return this;
};
t.AbsM = function(t, e) {
var i = t.ex, n = t.ey;
e.ex.x = y(i.x);
e.ex.y = y(i.y);
e.ey.x = y(n.x);
e.ey.y = y(n.y);
return e;
};
t.MulMV = function(t, e, i) {
var n = t.ex, r = t.ey, s = e.x, o = e.y;
i.x = n.x * s + r.x * o;
i.y = n.y * s + r.y * o;
return i;
};
t.MulTMV = function(t, e, i) {
var n = t.ex, r = t.ey, s = e.x, o = e.y;
i.x = n.x * s + n.y * o;
i.y = r.x * s + r.y * o;
return i;
};
t.AddMM = function(t, e, i) {
var n = t.ex, r = t.ey, s = e.ex, o = e.ey;
i.ex.x = n.x + s.x;
i.ex.y = n.y + s.y;
i.ey.x = r.x + o.x;
i.ey.y = r.y + o.y;
return i;
};
t.MulMM = function(t, e, i) {
var n = t.ex.x, r = t.ex.y, s = t.ey.x, o = t.ey.y, a = e.ex.x, c = e.ex.y, h = e.ey.x, l = e.ey.y;
i.ex.x = n * a + s * c;
i.ex.y = r * a + o * c;
i.ey.x = n * h + s * l;
i.ey.y = r * h + o * l;
return i;
};
t.MulTMM = function(t, e, i) {
var n = t.ex.x, r = t.ex.y, s = t.ey.x, o = t.ey.y, a = e.ex.x, c = e.ex.y, h = e.ey.x, l = e.ey.y;
i.ex.x = n * a + r * c;
i.ex.y = s * a + o * c;
i.ey.x = n * h + r * l;
i.ey.y = s * h + o * l;
return i;
};
t.IDENTITY = new t();
return t;
})(), V = (function() {
function t() {
this.ex = new L(1, 0, 0);
this.ey = new L(0, 1, 0);
this.ez = new L(0, 0, 1);
}
t.prototype.Clone = function() {
return new t().Copy(this);
};
t.prototype.SetVVV = function(t, e, i) {
this.ex.Copy(t);
this.ey.Copy(e);
this.ez.Copy(i);
return this;
};
t.prototype.Copy = function(t) {
this.ex.Copy(t.ex);
this.ey.Copy(t.ey);
this.ez.Copy(t.ez);
return this;
};
t.prototype.SetIdentity = function() {
this.ex.SetXYZ(1, 0, 0);
this.ey.SetXYZ(0, 1, 0);
this.ez.SetXYZ(0, 0, 1);
return this;
};
t.prototype.SetZero = function() {
this.ex.SetZero();
this.ey.SetZero();
this.ez.SetZero();
return this;
};
t.prototype.SelfAddM = function(t) {
this.ex.SelfAdd(t.ex);
this.ey.SelfAdd(t.ey);
this.ez.SelfAdd(t.ez);
return this;
};
t.prototype.Solve33 = function(t, e, i, n) {
var r = this.ex.x, s = this.ex.y, o = this.ex.z, a = this.ey.x, c = this.ey.y, h = this.ey.z, l = this.ez.x, u = this.ez.y, _ = this.ez.z, f = r * (c * _ - h * u) + s * (h * l - a * _) + o * (a * u - c * l);
0 !== f && (f = 1 / f);
n.x = f * (t * (c * _ - h * u) + e * (h * l - a * _) + i * (a * u - c * l));
n.y = f * (r * (e * _ - i * u) + s * (i * l - t * _) + o * (t * u - e * l));
n.z = f * (r * (c * i - h * e) + s * (h * t - a * i) + o * (a * e - c * t));
return n;
};
t.prototype.Solve22 = function(t, e, i) {
var n = this.ex.x, r = this.ey.x, s = this.ex.y, o = this.ey.y, a = n * o - r * s;
0 !== a && (a = 1 / a);
i.x = a * (o * t - r * e);
i.y = a * (n * e - s * t);
return i;
};
t.prototype.GetInverse22 = function(t) {
var e = this.ex.x, i = this.ey.x, n = this.ex.y, r = this.ey.y, s = e * r - i * n;
0 !== s && (s = 1 / s);
t.ex.x = s * r;
t.ey.x = -s * i;
t.ex.z = 0;
t.ex.y = -s * n;
t.ey.y = s * e;
t.ey.z = 0;
t.ez.x = 0;
t.ez.y = 0;
t.ez.z = 0;
};
t.prototype.GetSymInverse33 = function(t) {
var e = L.DotV3V3(this.ex, L.CrossV3V3(this.ey, this.ez, L.s_t0));
0 !== e && (e = 1 / e);
var i = this.ex.x, n = this.ey.x, r = this.ez.x, s = this.ey.y, o = this.ez.y, a = this.ez.z;
t.ex.x = e * (s * a - o * o);
t.ex.y = e * (r * o - n * a);
t.ex.z = e * (n * o - r * s);
t.ey.x = t.ex.y;
t.ey.y = e * (i * a - r * r);
t.ey.z = e * (r * n - i * o);
t.ez.x = t.ex.z;
t.ez.y = t.ey.z;
t.ez.z = e * (i * s - n * n);
};
t.MulM33V3 = function(t, e, i) {
var n = e.x, r = e.y, s = e.z;
i.x = t.ex.x * n + t.ey.x * r + t.ez.x * s;
i.y = t.ex.y * n + t.ey.y * r + t.ez.y * s;
i.z = t.ex.z * n + t.ey.z * r + t.ez.z * s;
return i;
};
t.MulM33XYZ = function(t, e, i, n, r) {
r.x = t.ex.x * e + t.ey.x * i + t.ez.x * n;
r.y = t.ex.y * e + t.ey.y * i + t.ez.y * n;
r.z = t.ex.z * e + t.ey.z * i + t.ez.z * n;
return r;
};
t.MulM33V2 = function(t, e, i) {
var n = e.x, r = e.y;
i.x = t.ex.x * n + t.ey.x * r;
i.y = t.ex.y * n + t.ey.y * r;
return i;
};
t.MulM33XY = function(t, e, i, n) {
n.x = t.ex.x * e + t.ey.x * i;
n.y = t.ex.y * e + t.ey.y * i;
return n;
};
t.IDENTITY = new t();
return t;
})(), O = (function() {
function t(t) {
void 0 === t && (t = 0);
this.s = 0;
this.c = 1;
if (t) {
this.s = Math.sin(t);
this.c = Math.cos(t);
}
}
t.prototype.Clone = function() {
return new t().Copy(this);
};
t.prototype.Copy = function(t) {
this.s = t.s;
this.c = t.c;
return this;
};
t.prototype.SetAngle = function(t) {
this.s = Math.sin(t);
this.c = Math.cos(t);
return this;
};
t.prototype.SetIdentity = function() {
this.s = 0;
this.c = 1;
return this;
};
t.prototype.GetAngle = function() {
return Math.atan2(this.s, this.c);
};
t.prototype.GetXAxis = function(t) {
t.x = this.c;
t.y = this.s;
return t;
};
t.prototype.GetYAxis = function(t) {
t.x = -this.s;
t.y = this.c;
return t;
};
t.MulRR = function(t, e, i) {
var n = t.c, r = t.s, s = e.c, o = e.s;
i.s = r * s + n * o;
i.c = n * s - r * o;
return i;
};
t.MulTRR = function(t, e, i) {
var n = t.c, r = t.s, s = e.c, o = e.s;
i.s = n * o - r * s;
i.c = n * s + r * o;
return i;
};
t.MulRV = function(t, e, i) {
var n = t.c, r = t.s, s = e.x, o = e.y;
i.x = n * s - r * o;
i.y = r * s + n * o;
return i;
};
t.MulTRV = function(t, e, i) {
var n = t.c, r = t.s, s = e.x, o = e.y;
i.x = n * s + r * o;
i.y = -r * s + n * o;
return i;
};
t.IDENTITY = new t();
return t;
})(), N = (function() {
function t() {
this.p = new P();
this.q = new O();
}
t.prototype.Clone = function() {
return new t().Copy(this);
};
t.prototype.Copy = function(t) {
this.p.Copy(t.p);
this.q.Copy(t.q);
return this;
};
t.prototype.SetIdentity = function() {
this.p.SetZero();
this.q.SetIdentity();
return this;
};
t.prototype.SetPositionRotation = function(t, e) {
this.p.Copy(t);
this.q.Copy(e);
return this;
};
t.prototype.SetPositionAngle = function(t, e) {
this.p.Copy(t);
this.q.SetAngle(e);
return this;
};
t.prototype.SetPosition = function(t) {
this.p.Copy(t);
return this;
};
t.prototype.SetPositionXY = function(t, e) {
this.p.Set(t, e);
return this;
};
t.prototype.SetRotation = function(t) {
this.q.Copy(t);
return this;
};
t.prototype.SetRotationAngle = function(t) {
this.q.SetAngle(t);
return this;
};
t.prototype.GetPosition = function() {
return this.p;
};
t.prototype.GetRotation = function() {
return this.q;
};
t.prototype.GetRotationAngle = function() {
return this.q.GetAngle();
};
t.prototype.GetAngle = function() {
return this.q.GetAngle();
};
t.MulXV = function(t, e, i) {
var n = t.q.c, r = t.q.s, s = e.x, o = e.y;
i.x = n * s - r * o + t.p.x;
i.y = r * s + n * o + t.p.y;
return i;
};
t.MulTXV = function(t, e, i) {
var n = t.q.c, r = t.q.s, s = e.x - t.p.x, o = e.y - t.p.y;
i.x = n * s + r * o;
i.y = -r * s + n * o;
return i;
};
t.MulXX = function(t, e, i) {
O.MulRR(t.q, e.q, i.q);
P.AddVV(O.MulRV(t.q, e.p, i.p), t.p, i.p);
return i;
};
t.MulTXX = function(t, e, i) {
O.MulTRR(t.q, e.q, i.q);
O.MulTRV(t.q, P.SubVV(e.p, t.p, i.p), i.p);
return i;
};
t.IDENTITY = new t();
return t;
})(), k = (function() {
function t() {
this.localCenter = new P();
this.c0 = new P();
this.c = new P();
this.a0 = 0;
this.a = 0;
this.alpha0 = 0;
}
t.prototype.Clone = function() {
return new t().Copy(this);
};
t.prototype.Copy = function(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;
};
t.prototype.GetTransform = function(t, e) {
var 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;
var n = i * this.a0 + e * this.a;
t.q.SetAngle(n);
t.p.SelfSub(O.MulRV(t.q, this.localCenter, P.s_t0));
return t;
};
t.prototype.Advance = function(t) {
var e = (t - this.alpha0) / (1 - this.alpha0), 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;
};
t.prototype.Normalize = function() {
var t = 6.28318530718 * Math.floor(this.a0 / 6.28318530718);
this.a0 -= t;
this.a -= t;
};
return t;
})(), G = (function() {
function t(t, e, i, n) {
void 0 === t && (t = .5);
void 0 === e && (e = .5);
void 0 === i && (i = .5);
void 0 === n && (n = 1);
this.r = t;
this.g = e;
this.b = i;
this.a = n;
}
t.prototype.Clone = function() {
return new t().Copy(this);
};
t.prototype.Copy = function(t) {
this.r = t.r;
this.g = t.g;
this.b = t.b;
this.a = t.a;
return this;
};
t.prototype.IsEqual = function(t) {
return this.r === t.r && this.g === t.g && this.b === t.b && this.a === t.a;
};
t.prototype.IsZero = function() {
return 0 === this.r && 0 === this.g && 0 === this.b && 0 === this.a;
};
t.prototype.Set = function(t, e, i, n) {
void 0 === n && (n = this.a);
this.SetRGBA(t, e, i, n);
};
t.prototype.SetByteRGB = function(t, e, i) {
this.r = t / 255;
this.g = e / 255;
this.b = i / 255;
return this;
};
t.prototype.SetByteRGBA = function(t, e, i, n) {
this.r = t / 255;
this.g = e / 255;
this.b = i / 255;
this.a = n / 255;
return this;
};
t.prototype.SetRGB = function(t, e, i) {
this.r = t;
this.g = e;
this.b = i;
return this;
};
t.prototype.SetRGBA = function(t, e, i, n) {
this.r = t;
this.g = e;
this.b = i;
this.a = n;
return this;
};
t.prototype.SelfAdd = function(t) {
this.r += t.r;
this.g += t.g;
this.b += t.b;
this.a += t.a;
return this;
};
t.prototype.Add = function(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;
};
t.prototype.SelfSub = function(t) {
this.r -= t.r;
this.g -= t.g;
this.b -= t.b;
this.a -= t.a;
return this;
};
t.prototype.Sub = function(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;
};
t.prototype.SelfMul = function(t) {
this.r *= t;
this.g *= t;
this.b *= t;
this.a *= t;
return this;
};
t.prototype.Mul = function(t, e) {
e.r = this.r * t;
e.g = this.g * t;
e.b = this.b * t;
e.a = this.a * t;
return e;
};
t.prototype.Mix = function(e, i) {
t.MixColors(this, e, i);
};
t.MixColors = function(t, e, i) {
var n = i * (e.r - t.r), r = i * (e.g - t.g), s = i * (e.b - t.b), o = i * (e.a - t.a);
t.r += n;
t.g += r;
t.b += s;
t.a += o;
e.r -= n;
e.g -= r;
e.b -= s;
e.a -= o;
};
t.prototype.MakeStyleString = function(e) {
void 0 === e && (e = this.a);
return t.MakeStyleString(this.r, this.g, this.b, e);
};
t.MakeStyleString = function(t, e, i, n) {
void 0 === n && (n = 1);
t *= 255;
e *= 255;
i *= 255;
return n < 1 ? "rgba(" + t + "," + e + "," + i + "," + n + ")" : "rgb(" + t + "," + e + "," + i + ")";
};
t.ZERO = new t(0, 0, 0, 0);
t.RED = new t(1, 0, 0);
t.GREEN = new t(0, 1, 0);
t.BLUE = new t(0, 0, 1);
return t;
})();
(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 = {}));
var z = (function() {
function t() {
this.m_drawFlags = 0;
}
t.prototype.SetFlags = function(t) {
this.m_drawFlags = t;
};
t.prototype.GetFlags = function() {
return this.m_drawFlags;
};
t.prototype.AppendFlags = function(t) {
this.m_drawFlags |= t;
};
t.prototype.ClearFlags = function(t) {
this.m_drawFlags &= ~t;
};
return t;
})(), U = (function() {
function t() {
this.m_start = Date.now();
}
t.prototype.Reset = function() {
this.m_start = Date.now();
return this;
};
t.prototype.GetMilliseconds = function() {
return Date.now() - this.m_start;
};
return t;
})(), j = (function() {
function t() {
this.m_count = 0;
this.m_min_count = 0;
this.m_max_count = 0;
}
t.prototype.GetCount = function() {
return this.m_count;
};
t.prototype.GetMinCount = function() {
return this.m_min_count;
};
t.prototype.GetMaxCount = function() {
return this.m_max_count;
};
t.prototype.ResetCount = function() {
var t = this.m_count;
this.m_count = 0;
return t;
};
t.prototype.ResetMinCount = function() {
this.m_min_count = 0;
};
t.prototype.ResetMaxCount = function() {
this.m_max_count = 0;
};
t.prototype.Increment = function() {
this.m_count++;
this.m_max_count < this.m_count && (this.m_max_count = this.m_count);
};
t.prototype.Decrement = function() {
this.m_count--;
this.m_min_count > this.m_count && (this.m_min_count = this.m_count);
};
return t;
})(), H = (function() {
function t(t) {
this.m_stack = [];
this.m_count = 0;
this.m_stack = d(t, (function(t) {
return null;
}));
this.m_count = 0;
}
t.prototype.Reset = function() {
this.m_count = 0;
return this;
};
t.prototype.Push = function(t) {
this.m_stack[this.m_count] = t;
this.m_count++;
};
t.prototype.Pop = function() {
this.m_count--;
var t = this.m_stack[this.m_count];
this.m_stack[this.m_count] = null;
if (null === t) throw new Error();
return t;
};
t.prototype.GetCount = function() {
return this.m_count;
};
return t;
})(), W = (function() {
return function() {};
})(), q = (function() {
return function() {};
})(), X = (function() {
function t() {
this.m_buffer = P.MakeArray(2);
this.m_vertices = this.m_buffer;
this.m_count = 0;
this.m_radius = 0;
}
t.prototype.Copy = function(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;
};
t.prototype.Reset = function() {
this.m_vertices = this.m_buffer;
this.m_count = 0;
this.m_radius = 0;
return this;
};
t.prototype.SetShape = function(t, e) {
t.SetupDistanceProxy(this, e);
};
t.prototype.SetVerticesRadius = function(t, e, i) {
this.m_vertices = t;
this.m_count = e;
this.m_radius = i;
};
t.prototype.GetSupport = function(t) {
for (var e = 0, i = P.DotVV(this.m_vertices[0], t), n = 1; n < this.m_count; ++n) {
var r = P.DotVV(this.m_vertices[n], t);
if (r > i) {
e = n;
i = r;
}
}
return e;
};
t.prototype.GetSupportVertex = function(t) {
for (var e = 0, i = P.DotVV(this.m_vertices[0], t), n = 1; n < this.m_count; ++n) {
var r = P.DotVV(this.m_vertices[n], t);
if (r > i) {
e = n;
i = r;
}
}
return this.m_vertices[e];
};
t.prototype.GetVertexCount = function() {
return this.m_count;
};
t.prototype.GetVertex = function(t) {
return this.m_vertices[t];
};
return t;
})(), Y = (function() {
function t() {
this.metric = 0;
this.count = 0;
this.indexA = [ 0, 0, 0 ];
this.indexB = [ 0, 0, 0 ];
}
t.prototype.Reset = function() {
this.metric = 0;
this.count = 0;
return this;
};
return t;
})(), J = (function() {
function t() {
this.proxyA = new X();
this.proxyB = new X();
this.transformA = new N();
this.transformB = new N();
this.useRadii = !1;
}
t.prototype.Reset = function() {
this.proxyA.Reset();
this.proxyB.Reset();
this.transformA.SetIdentity();
this.transformB.SetIdentity();
this.useRadii = !1;
return this;
};
return t;
})(), Z = (function() {
function t() {
this.pointA = new P();
this.pointB = new P();
this.distance = 0;
this.iterations = 0;
}
t.prototype.Reset = function() {
this.pointA.SetZero();
this.pointB.SetZero();
this.distance = 0;
this.iterations = 0;
return this;
};
return t;
})(), K = (function() {
return function() {
this.proxyA = new X();
this.proxyB = new X();
this.transformA = new N();
this.transformB = new N();
this.translationB = new P();
};
})(), Q = (function() {
return function() {
this.point = new P();
this.normal = new P();
this.lambda = 0;
this.iterations = 0;
};
})();
t.b2_gjkCalls = 0;
t.b2_gjkIters = 0;
t.b2_gjkMaxIters = 0;
var $ = (function() {
function t() {
this.wA = new P();
this.wB = new P();
this.w = new P();
this.a = 0;
this.indexA = 0;
this.indexB = 0;
}
t.prototype.Copy = function(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;
};
return t;
})(), tt = (function() {
function t() {
this.m_v1 = new $();
this.m_v2 = new $();
this.m_v3 = new $();
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;
}
t.prototype.ReadCache = function(t, e, i, r, s) {
this.m_count = t.count;
for (var o = this.m_vertices, a = 0; a < this.m_count; ++a) {
(_ = o[a]).indexA = t.indexA[a];
_.indexB = t.indexB[a];
var c = e.GetVertex(_.indexA), h = r.GetVertex(_.indexB);
N.MulXV(i, c, _.wA);
N.MulXV(s, h, _.wB);
P.SubVV(_.wB, _.wA, _.w);
_.a = 0;
}
if (this.m_count > 1) {
var l = t.metric, u = this.GetMetric();
(u < .5 * l || 2 * l < u || u < n) && (this.m_count = 0);
}
if (0 === this.m_count) {
var _;
(_ = o[0]).indexA = 0;
_.indexB = 0;
c = e.GetVertex(0), h = r.GetVertex(0);
N.MulXV(i, c, _.wA);
N.MulXV(s, h, _.wB);
P.SubVV(_.wB, _.wA, _.w);
_.a = 1;
this.m_count = 1;
}
};
t.prototype.WriteCache = function(t) {
t.metric = this.GetMetric();
t.count = this.m_count;
for (var e = this.m_vertices, i = 0; i < this.m_count; ++i) {
t.indexA[i] = e[i].indexA;
t.indexB[i] = e[i].indexB;
}
};
t.prototype.GetSearchDirection = function(t) {
switch (this.m_count) {
case 1:
return P.NegV(this.m_v1.w, t);

case 2:
var e = P.SubVV(this.m_v2.w, this.m_v1.w, t);
return P.CrossVV(e, P.NegV(this.m_v1.w, P.s_t0)) > 0 ? P.CrossOneV(e, t) : P.CrossVOne(e, t);

default:
return t.SetZero();
}
};
t.prototype.GetClosestPoint = function(t) {
switch (this.m_count) {
case 0:
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);

case 3:
default:
return t.SetZero();
}
};
t.prototype.GetWitnessPoints = function(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;
}
};
t.prototype.GetMetric = function() {
switch (this.m_count) {
case 0:
case 1:
return 0;

case 2:
return P.DistanceVV(this.m_v1.w, this.m_v2.w);

case 3:
return P.CrossVV(P.SubVV(this.m_v2.w, this.m_v1.w, P.s_t0), P.SubVV(this.m_v3.w, this.m_v1.w, P.s_t1));

default:
return 0;
}
};
t.prototype.Solve2 = function() {
var e = this.m_v1.w, i = this.m_v2.w, n = P.SubVV(i, e, t.s_e12), r = -P.DotVV(e, n);
if (r <= 0) {
this.m_v1.a = 1;
this.m_count = 1;
} else {
var s = P.DotVV(i, n);
if (s <= 0) {
this.m_v2.a = 1;
this.m_count = 1;
this.m_v1.Copy(this.m_v2);
} else {
var o = 1 / (s + r);
this.m_v1.a = s * o;
this.m_v2.a = r * o;
this.m_count = 2;
}
}
};
t.prototype.Solve3 = function() {
var e = this.m_v1.w, i = this.m_v2.w, n = this.m_v3.w, r = P.SubVV(i, e, t.s_e12), s = P.DotVV(e, r), o = P.DotVV(i, r), a = -s, c = P.SubVV(n, e, t.s_e13), h = P.DotVV(e, c), l = P.DotVV(n, c), u = -h, _ = P.SubVV(n, i, t.s_e23), f = P.DotVV(i, _), d = P.DotVV(n, _), m = -f, p = P.CrossVV(r, c), v = p * P.CrossVV(i, n), y = p * P.CrossVV(n, e), g = p * P.CrossVV(e, i);
if (a <= 0 && u <= 0) {
this.m_v1.a = 1;
this.m_count = 1;
} else if (o > 0 && a > 0 && g <= 0) {
var x = 1 / (o + a);
this.m_v1.a = o * x;
this.m_v2.a = a * x;
this.m_count = 2;
} else if (l > 0 && u > 0 && y <= 0) {
var C = 1 / (l + u);
this.m_v1.a = l * C;
this.m_v3.a = u * C;
this.m_count = 2;
this.m_v2.Copy(this.m_v3);
} else if (o <= 0 && m <= 0) {
this.m_v2.a = 1;
this.m_count = 1;
this.m_v1.Copy(this.m_v2);
} else if (l <= 0 && d <= 0) {
this.m_v3.a = 1;
this.m_count = 1;
this.m_v1.Copy(this.m_v3);
} else if (d > 0 && m > 0 && v <= 0) {
var A = 1 / (d + m);
this.m_v2.a = d * A;
this.m_v3.a = m * A;
this.m_count = 2;
this.m_v1.Copy(this.m_v3);
} else {
var b = 1 / (v + y + g);
this.m_v1.a = v * b;
this.m_v2.a = y * b;
this.m_v3.a = g * b;
this.m_count = 3;
}
};
t.s_e12 = new P();
t.s_e13 = new P();
t.s_e23 = new P();
return t;
})(), et = new tt(), it = [ 0, 0, 0 ], nt = [ 0, 0, 0 ], rt = new P(), st = new P(), ot = new P(), at = new P(), ct = new P();
function ht(e, i, s) {
++t.b2_gjkCalls;
var o = s.proxyA, a = s.proxyB, c = s.transformA, h = s.transformB, l = et;
l.ReadCache(i, o, c, a, h);
for (var u = l.m_vertices, _ = it, f = nt, d = 0, m = 0; m < 20; ) {
d = l.m_count;
for (var p = 0; p < d; ++p) {
_[p] = u[p].indexA;
f[p] = u[p].indexB;
}
switch (l.m_count) {
case 1:
break;

case 2:
l.Solve2();
break;

case 3:
l.Solve3();
}
if (3 === l.m_count) break;
var v = l.GetSearchDirection(st);
if (v.LengthSquared() < r) break;
var y = u[l.m_count];
y.indexA = o.GetSupport(O.MulTRV(c.q, P.NegV(v, P.s_t0), at));
N.MulXV(c, o.GetVertex(y.indexA), y.wA);
y.indexB = a.GetSupport(O.MulTRV(h.q, v, ct));
N.MulXV(h, a.GetVertex(y.indexB), y.wB);
P.SubVV(y.wB, y.wA, y.w);
++m;
++t.b2_gjkIters;
var g = !1;
for (p = 0; p < d; ++p) if (y.indexA === _[p] && y.indexB === f[p]) {
g = !0;
break;
}
if (g) break;
++l.m_count;
}
t.b2_gjkMaxIters = x(t.b2_gjkMaxIters, m);
l.GetWitnessPoints(e.pointA, e.pointB);
e.distance = P.DistanceVV(e.pointA, e.pointB);
e.iterations = m;
l.WriteCache(i);
if (s.useRadii) {
var C = o.m_radius, A = a.m_radius;
if (e.distance > C + A && e.distance > n) {
e.distance -= C + A;
var b = P.SubVV(e.pointB, e.pointA, ot);
b.Normalize();
e.pointA.SelfMulAdd(C, b);
e.pointB.SelfMulSub(A, b);
} else {
var S = P.MidVV(e.pointA, e.pointB, rt);
e.pointA.Copy(S);
e.pointB.Copy(S);
e.distance = 0;
}
}
}
var lt = new P(), ut = new tt(), _t = new P(), ft = new P(), dt = new P(), mt = new P(), pt = new P(), vt = new P();
(function(t) {
t[t.e_vertex = 0] = "e_vertex";
t[t.e_face = 1] = "e_face";
})(t.b2ContactFeatureType || (t.b2ContactFeatureType = {}));
var yt = (function() {
function t() {
this._key = 0;
this._key_invalid = !1;
this._indexA = 0;
this._indexB = 0;
this._typeA = 0;
this._typeB = 0;
}
Object.defineProperty(t.prototype, "key", {
get: function() {
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: function(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;
},
enumerable: !0,
configurable: !0
});
Object.defineProperty(t.prototype, "indexA", {
get: function() {
return this._indexA;
},
set: function(t) {
this._indexA = t;
this._key_invalid = !0;
},
enumerable: !0,
configurable: !0
});
Object.defineProperty(t.prototype, "indexB", {
get: function() {
return this._indexB;
},
set: function(t) {
this._indexB = t;
this._key_invalid = !0;
},
enumerable: !0,
configurable: !0
});
Object.defineProperty(t.prototype, "typeA", {
get: function() {
return this._typeA;
},
set: function(t) {
this._typeA = t;
this._key_invalid = !0;
},
enumerable: !0,
configurable: !0
});
Object.defineProperty(t.prototype, "typeB", {
get: function() {
return this._typeB;
},
set: function(t) {
this._typeB = t;
this._key_invalid = !0;
},
enumerable: !0,
configurable: !0
});
return t;
})(), gt = (function() {
function t() {
this.cf = new yt();
}
t.prototype.Copy = function(t) {
this.key = t.key;
return this;
};
t.prototype.Clone = function() {
return new t().Copy(this);
};
Object.defineProperty(t.prototype, "key", {
get: function() {
return this.cf.key;
},
set: function(t) {
this.cf.key = t;
},
enumerable: !0,
configurable: !0
});
return t;
})(), xt = (function() {
function t() {
this.localPoint = new P();
this.normalImpulse = 0;
this.tangentImpulse = 0;
this.id = new gt();
}
t.MakeArray = function(e) {
return d(e, (function(e) {
return new t();
}));
};
t.prototype.Reset = function() {
this.localPoint.SetZero();
this.normalImpulse = 0;
this.tangentImpulse = 0;
this.id.key = 0;
};
t.prototype.Copy = function(t) {
this.localPoint.Copy(t.localPoint);
this.normalImpulse = t.normalImpulse;
this.tangentImpulse = t.tangentImpulse;
this.id.Copy(t.id);
return this;
};
return t;
})();
(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 = {}));
var Ct = (function() {
function e() {
this.points = xt.MakeArray(o);
this.localNormal = new P();
this.localPoint = new P();
this.type = t.b2ManifoldType.e_unknown;
this.pointCount = 0;
}
e.prototype.Reset = function() {
for (var e = 0; e < o; ++e) this.points[e].Reset();
this.localNormal.SetZero();
this.localPoint.SetZero();
this.type = t.b2ManifoldType.e_unknown;
this.pointCount = 0;
};
e.prototype.Copy = function(t) {
this.pointCount = t.pointCount;
for (var e = 0; e < o; ++e) this.points[e].Copy(t.points[e]);
this.localNormal.Copy(t.localNormal);
this.localPoint.Copy(t.localPoint);
this.type = t.type;
return this;
};
e.prototype.Clone = function() {
return new e().Copy(this);
};
return e;
})(), At = (function() {
function e() {
this.normal = new P();
this.points = P.MakeArray(o);
this.separations = m(o);
}
e.prototype.Initialize = function(i, n, s, o, a) {
if (0 !== i.pointCount) switch (i.type) {
case t.b2ManifoldType.e_circles:
this.normal.Set(1, 0);
var c = N.MulXV(n, i.localPoint, e.Initialize_s_pointA), h = N.MulXV(o, i.points[0].localPoint, e.Initialize_s_pointB);
P.DistanceSquaredVV(c, h) > r && P.SubVV(h, c, this.normal).SelfNormalize();
var l = P.AddVMulSV(c, s, this.normal, e.Initialize_s_cA), u = P.SubVMulSV(h, a, this.normal, e.Initialize_s_cB);
P.MidVV(l, u, this.points[0]);
this.separations[0] = P.DotVV(P.SubVV(u, l, P.s_t0), this.normal);
break;

case t.b2ManifoldType.e_faceA:
O.MulRV(n.q, i.localNormal, this.normal);
for (var _ = N.MulXV(n, i.localPoint, e.Initialize_s_planePoint), f = 0; f < i.pointCount; ++f) {
var d = N.MulXV(o, i.points[f].localPoint, e.Initialize_s_clipPoint), m = s - P.DotVV(P.SubVV(d, _, P.s_t0), this.normal);
l = P.AddVMulSV(d, m, this.normal, e.Initialize_s_cA), u = P.SubVMulSV(d, a, this.normal, e.Initialize_s_cB);
P.MidVV(l, u, this.points[f]);
this.separations[f] = P.DotVV(P.SubVV(u, l, P.s_t0), this.normal);
}
break;

case t.b2ManifoldType.e_faceB:
O.MulRV(o.q, i.localNormal, this.normal);
for (_ = N.MulXV(o, i.localPoint, e.Initialize_s_planePoint), f = 0; f < i.pointCount; ++f) {
d = N.MulXV(n, i.points[f].localPoint, e.Initialize_s_clipPoint), m = a - P.DotVV(P.SubVV(d, _, P.s_t0), this.normal), 
u = P.AddVMulSV(d, m, this.normal, e.Initialize_s_cB), l = P.SubVMulSV(d, s, this.normal, e.Initialize_s_cA);
P.MidVV(l, u, this.points[f]);
this.separations[f] = P.DotVV(P.SubVV(l, u, P.s_t0), this.normal);
}
this.normal.SelfNeg();
}
};
e.Initialize_s_pointA = new P();
e.Initialize_s_pointB = new P();
e.Initialize_s_cA = new P();
e.Initialize_s_cB = new P();
e.Initialize_s_planePoint = new P();
e.Initialize_s_clipPoint = new P();
return e;
})();
(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 = {}));
var bt = (function() {
function t() {
this.v = new P();
this.id = new gt();
}
t.MakeArray = function(e) {
return d(e, (function(e) {
return new t();
}));
};
t.prototype.Copy = function(t) {
this.v.Copy(t.v);
this.id.Copy(t.id);
return this;
};
return t;
})(), St = (function() {
function t() {
this.p1 = new P();
this.p2 = new P();
this.maxFraction = 1;
}
t.prototype.Copy = function(t) {
this.p1.Copy(t.p1);
this.p2.Copy(t.p2);
this.maxFraction = t.maxFraction;
return this;
};
return t;
})(), Tt = (function() {
function t() {
this.normal = new P();
this.fraction = 0;
}
t.prototype.Copy = function(t) {
this.normal.Copy(t.normal);
this.fraction = t.fraction;
return this;
};
return t;
})(), wt = (function() {
function t() {
this.lowerBound = new P();
this.upperBound = new P();
this.m_cache_center = new P();
this.m_cache_extent = new P();
}
t.prototype.Copy = function(t) {
this.lowerBound.Copy(t.lowerBound);
this.upperBound.Copy(t.upperBound);
return this;
};
t.prototype.IsValid = function() {
var t = this.upperBound.x - this.lowerBound.x, e = this.upperBound.y - this.lowerBound.y, i = t >= 0 && e >= 0;
return i = i && this.lowerBound.IsValid() && this.upperBound.IsValid();
};
t.prototype.GetCenter = function() {
return P.MidVV(this.lowerBound, this.upperBound, this.m_cache_center);
};
t.prototype.GetExtents = function() {
return P.ExtVV(this.lowerBound, this.upperBound, this.m_cache_extent);
};
t.prototype.GetPerimeter = function() {
return 2 * (this.upperBound.x - this.lowerBound.x + (this.upperBound.y - this.lowerBound.y));
};
t.prototype.Combine1 = function(t) {
this.lowerBound.x = g(this.lowerBound.x, t.lowerBound.x);
this.lowerBound.y = g(this.lowerBound.y, t.lowerBound.y);
this.upperBound.x = x(this.upperBound.x, t.upperBound.x);
this.upperBound.y = x(this.upperBound.y, t.upperBound.y);
return this;
};
t.prototype.Combine2 = function(t, e) {
this.lowerBound.x = g(t.lowerBound.x, e.lowerBound.x);
this.lowerBound.y = g(t.lowerBound.y, e.lowerBound.y);
this.upperBound.x = x(t.upperBound.x, e.upperBound.x);
this.upperBound.y = x(t.upperBound.y, e.upperBound.y);
return this;
};
t.Combine = function(t, e, i) {
i.Combine2(t, e);
return i;
};
t.prototype.Contains = function(t) {
var e = !0;
return e = (e = (e = (e = e && this.lowerBound.x <= t.lowerBound.x) && this.lowerBound.y <= t.lowerBound.y) && t.upperBound.x <= this.upperBound.x) && t.upperBound.y <= this.upperBound.y;
};
t.prototype.RayCast = function(t, e) {
var r = -i, s = i, o = e.p1.x, a = e.p1.y, c = e.p2.x - e.p1.x, h = e.p2.y - e.p1.y, l = y(c), u = y(h), _ = t.normal;
if (l < n) {
if (o < this.lowerBound.x || this.upperBound.x < o) return !1;
} else {
var f = 1 / c, d = -1;
if ((p = (this.lowerBound.x - o) * f) > (v = (this.upperBound.x - o) * f)) {
var m = p;
p = v;
v = m;
d = 1;
}
if (p > r) {
_.x = d;
_.y = 0;
r = p;
}
if (r > (s = g(s, v))) return !1;
}
if (u < n) {
if (a < this.lowerBound.y || this.upperBound.y < a) return !1;
} else {
var p, v;
f = 1 / h, d = -1;
if ((p = (this.lowerBound.y - a) * f) > (v = (this.upperBound.y - a) * f)) {
m = p;
p = v;
v = m;
d = 1;
}
if (p > r) {
_.x = 0;
_.y = d;
r = p;
}
if (r > (s = g(s, v))) return !1;
}
if (r < 0 || e.maxFraction < r) return !1;
t.fraction = r;
return !0;
};
t.prototype.TestContain = function(t) {
return !(t.x < this.lowerBound.x || this.upperBound.x < t.x) && !(t.y < this.lowerBound.y || this.upperBound.y < t.y);
};
t.prototype.TestOverlap = function(t) {
var e = t.lowerBound.x - this.upperBound.x, i = t.lowerBound.y - this.upperBound.y, n = this.lowerBound.x - t.upperBound.x, r = this.lowerBound.y - t.upperBound.y;
return !(e > 0 || i > 0) && !(n > 0 || r > 0);
};
return t;
})();
function Et(t, e) {
var i = e.lowerBound.x - t.upperBound.x, n = e.lowerBound.y - t.upperBound.y, r = t.lowerBound.x - e.upperBound.x, s = t.lowerBound.y - e.upperBound.y;
return !(i > 0 || n > 0) && !(r > 0 || s > 0);
}
function Bt(e, i, n, r, s) {
var o = 0, a = i[0], c = i[1], h = P.DotVV(n, a.v) - r, l = P.DotVV(n, c.v) - r;
h <= 0 && e[o++].Copy(a);
l <= 0 && e[o++].Copy(c);
if (h * l < 0) {
var u = h / (h - l), _ = e[o].v;
_.x = a.v.x + u * (c.v.x - a.v.x);
_.y = a.v.y + u * (c.v.y - a.v.y);
var f = e[o].id;
f.cf.indexA = s;
f.cf.indexB = a.id.cf.indexB;
f.cf.typeA = t.b2ContactFeatureType.e_vertex;
f.cf.typeB = t.b2ContactFeatureType.e_face;
++o;
}
return o;
}
var Mt = new J(), Dt = new Y(), It = new Z();
function Pt(t, e, i, r, s, o) {
var a = Mt.Reset();
a.proxyA.SetShape(t, e);
a.proxyB.SetShape(i, r);
a.transformA.Copy(s);
a.transformB.Copy(o);
a.useRadii = !0;
var c = Dt.Reset();
c.count = 0;
var h = It.Reset();
ht(h, c, a);
return h.distance < 10 * n;
}
function Rt(t) {
if (null === t) throw new Error();
return t;
}
var Lt = (function() {
function t(t) {
void 0 === t && (t = 0);
this.m_id = 0;
this.aabb = new wt();
this.parent = null;
this.child1 = null;
this.child2 = null;
this.height = 0;
this.m_id = t;
}
t.prototype.IsLeaf = function() {
return null === this.child1;
};
return t;
})(), Ft = (function() {
function t() {
this.m_root = null;
this.m_freeList = null;
this.m_path = 0;
this.m_insertionCount = 0;
this.m_stack = new H(256);
}
t.prototype.Query = function(t, e) {
if (null !== this.m_root) {
var i = this.m_stack.Reset();
i.Push(this.m_root);
for (;i.GetCount() > 0; ) {
var n = i.Pop();
if (n.aabb.TestOverlap(t)) if (n.IsLeaf()) {
if (!e(n)) return;
} else {
i.Push(Rt(n.child1));
i.Push(Rt(n.child2));
}
}
}
};
t.prototype.QueryPoint = function(t, e) {
if (null !== this.m_root) {
var i = this.m_stack.Reset();
i.Push(this.m_root);
for (;i.GetCount() > 0; ) {
var n = i.Pop();
if (n.aabb.TestContain(t)) if (n.IsLeaf()) {
if (!e(n)) return;
} else {
i.Push(Rt(n.child1));
i.Push(Rt(n.child2));
}
}
}
};
t.prototype.RayCast = function(e, i) {
if (null !== this.m_root) {
var n = e.p1, r = e.p2, s = P.SubVV(r, n, t.s_r);
s.Normalize();
var o = P.CrossOneV(s, t.s_v), a = P.AbsV(o, t.s_abs_v), c = e.maxFraction, h = t.s_segmentAABB, l = n.x + c * (r.x - n.x), u = n.y + c * (r.y - n.y);
h.lowerBound.x = g(n.x, l);
h.lowerBound.y = g(n.y, u);
h.upperBound.x = x(n.x, l);
h.upperBound.y = x(n.y, u);
var _ = this.m_stack.Reset();
_.Push(this.m_root);
for (;_.GetCount() > 0; ) {
var f = _.Pop();
if (Et(f.aabb, h)) {
var d = f.aabb.GetCenter(), m = f.aabb.GetExtents();
if (!(y(P.DotVV(o, P.SubVV(n, d, P.s_t0))) - P.DotVV(a, m) > 0)) if (f.IsLeaf()) {
var p = t.s_subInput;
p.p1.Copy(e.p1);
p.p2.Copy(e.p2);
p.maxFraction = c;
var v = i(p, f);
if (0 === v) return;
if (v > 0) {
c = v;
l = n.x + c * (r.x - n.x);
u = n.y + c * (r.y - n.y);
h.lowerBound.x = g(n.x, l);
h.lowerBound.y = g(n.y, u);
h.upperBound.x = x(n.x, l);
h.upperBound.y = x(n.y, u);
}
} else {
_.Push(Rt(f.child1));
_.Push(Rt(f.child2));
}
}
}
}
};
t.prototype.AllocateNode = function() {
if (this.m_freeList) {
var e = this.m_freeList;
this.m_freeList = e.parent;
e.parent = null;
e.child1 = null;
e.child2 = null;
e.height = 0;
delete e.userData;
return e;
}
return new Lt(t.s_node_id++);
};
t.prototype.FreeNode = function(t) {
t.parent = this.m_freeList;
t.child1 = null;
t.child2 = null;
t.height = -1;
delete t.userData;
this.m_freeList = t;
};
t.prototype.CreateProxy = function(t, e) {
var i = this.AllocateNode();
i.aabb.lowerBound.x = t.lowerBound.x - .1;
i.aabb.lowerBound.y = t.lowerBound.y - .1;
i.aabb.upperBound.x = t.upperBound.x + .1;
i.aabb.upperBound.y = t.upperBound.y + .1;
i.userData = e;
i.height = 0;
this.InsertLeaf(i);
return i;
};
t.prototype.DestroyProxy = function(t) {
this.RemoveLeaf(t);
this.FreeNode(t);
};
t.prototype.MoveProxy = function(t, e, i) {
if (t.aabb.Contains(e)) return !1;
this.RemoveLeaf(t);
var n = .1 + 2 * (i.x > 0 ? i.x : -i.x), r = .1 + 2 * (i.y > 0 ? i.y : -i.y);
t.aabb.lowerBound.x = e.lowerBound.x - n;
t.aabb.lowerBound.y = e.lowerBound.y - r;
t.aabb.upperBound.x = e.upperBound.x + n;
t.aabb.upperBound.y = e.upperBound.y + r;
this.InsertLeaf(t);
return !0;
};
t.prototype.InsertLeaf = function(e) {
++this.m_insertionCount;
if (null !== this.m_root) {
for (var i = e.aabb, n = this.m_root; !n.IsLeaf(); ) {
var r = Rt(n.child1), s = Rt(n.child2), o = n.aabb.GetPerimeter(), a = t.s_combinedAABB;
a.Combine2(n.aabb, i);
var c = a.GetPerimeter(), h = 2 * c, l = 2 * (c - o), u = void 0, _ = t.s_aabb, f = void 0;
if (r.IsLeaf()) {
_.Combine2(i, r.aabb);
u = _.GetPerimeter() + l;
} else {
_.Combine2(i, r.aabb);
f = r.aabb.GetPerimeter();
u = _.GetPerimeter() - f + l;
}
var d = void 0;
if (s.IsLeaf()) {
_.Combine2(i, s.aabb);
d = _.GetPerimeter() + l;
} else {
_.Combine2(i, s.aabb);
f = s.aabb.GetPerimeter();
d = _.GetPerimeter() - f + l;
}
if (h < u && h < d) break;
n = u < d ? r : s;
}
var m = n, p = m.parent, v = this.AllocateNode();
v.parent = p;
delete v.userData;
v.aabb.Combine2(i, m.aabb);
v.height = m.height + 1;
if (p) {
p.child1 === m ? p.child1 = v : p.child2 = v;
v.child1 = m;
v.child2 = e;
m.parent = v;
e.parent = v;
} else {
v.child1 = m;
v.child2 = e;
m.parent = v;
e.parent = v;
this.m_root = v;
}
for (var y = e.parent; null !== y; ) {
r = Rt((y = this.Balance(y)).child1), s = Rt(y.child2);
y.height = 1 + x(r.height, s.height);
y.aabb.Combine2(r.aabb, s.aabb);
y = y.parent;
}
} else {
this.m_root = e;
this.m_root.parent = null;
}
};
t.prototype.RemoveLeaf = function(t) {
if (t !== this.m_root) {
var e, i = Rt(t.parent), n = i && i.parent;
e = i.child1 === t ? Rt(i.child2) : Rt(i.child1);
if (n) {
n.child1 === i ? n.child1 = e : n.child2 = e;
e.parent = n;
this.FreeNode(i);
for (var r = n; r; ) {
var s = Rt((r = this.Balance(r)).child1), o = Rt(r.child2);
r.aabb.Combine2(s.aabb, o.aabb);
r.height = 1 + x(s.height, o.height);
r = r.parent;
}
} else {
this.m_root = e;
e.parent = null;
this.FreeNode(i);
}
} else this.m_root = null;
};
t.prototype.Balance = function(t) {
if (t.IsLeaf() || t.height < 2) return t;
var e = Rt(t.child1), i = Rt(t.child2), n = i.height - e.height;
if (n > 1) {
var r = Rt(i.child1), s = Rt(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 (r.height > s.height) {
i.child2 = r;
t.child2 = s;
s.parent = t;
t.aabb.Combine2(e.aabb, s.aabb);
i.aabb.Combine2(t.aabb, r.aabb);
t.height = 1 + x(e.height, s.height);
i.height = 1 + x(t.height, r.height);
} else {
i.child2 = s;
t.child2 = r;
r.parent = t;
t.aabb.Combine2(e.aabb, r.aabb);
i.aabb.Combine2(t.aabb, s.aabb);
t.height = 1 + x(e.height, r.height);
i.height = 1 + x(t.height, s.height);
}
return i;
}
if (n < -1) {
var o = Rt(e.child1), a = Rt(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 (o.height > a.height) {
e.child2 = o;
t.child1 = a;
a.parent = t;
t.aabb.Combine2(i.aabb, a.aabb);
e.aabb.Combine2(t.aabb, o.aabb);
t.height = 1 + x(i.height, a.height);
e.height = 1 + x(t.height, o.height);
} else {
e.child2 = a;
t.child1 = o;
o.parent = t;
t.aabb.Combine2(i.aabb, o.aabb);
e.aabb.Combine2(t.aabb, a.aabb);
t.height = 1 + x(i.height, o.height);
e.height = 1 + x(t.height, a.height);
}
return e;
}
return t;
};
t.prototype.GetHeight = function() {
return null === this.m_root ? 0 : this.m_root.height;
};
t.GetAreaNode = function(e) {
if (null === e) return 0;
if (e.IsLeaf()) return 0;
var i = e.aabb.GetPerimeter();
i += t.GetAreaNode(e.child1);
return i += t.GetAreaNode(e.child2);
};
t.prototype.GetAreaRatio = function() {
if (null === this.m_root) return 0;
var e = this.m_root.aabb.GetPerimeter();
return t.GetAreaNode(this.m_root) / e;
};
t.prototype.ComputeHeightNode = function(t) {
if (!t || t.IsLeaf()) return 0;
var e = this.ComputeHeightNode(t.child1), i = this.ComputeHeightNode(t.child2);
return 1 + x(e, i);
};
t.prototype.ComputeHeight = function() {
return this.ComputeHeightNode(this.m_root);
};
t.prototype.ValidateStructure = function(t) {
if (null !== t) {
this.m_root;
var e = t;
if (!e.IsLeaf()) {
var i = Rt(e.child1), n = Rt(e.child2);
this.ValidateStructure(i);
this.ValidateStructure(n);
}
}
};
t.prototype.ValidateMetrics = function(e) {
if (null !== e) {
var i = e;
if (!i.IsLeaf()) {
var n = Rt(i.child1), r = Rt(i.child2);
t.s_aabb.Combine2(n.aabb, r.aabb);
this.ValidateMetrics(n);
this.ValidateMetrics(r);
}
}
};
t.prototype.Validate = function() {};
t.GetMaxBalanceNode = function(t, e) {
if (null === t) return e;
if (t.height <= 1) return e;
var i = Rt(t.child1), n = Rt(t.child2), r = y(n.height - i.height);
return x(e, r);
};
t.prototype.GetMaxBalance = function() {
return t.GetMaxBalanceNode(this.m_root, 0);
};
t.prototype.RebuildBottomUp = function() {
this.Validate();
};
t.ShiftOriginNode = function(e, i) {
if (null !== e && !(e.height <= 1)) {
var n = e.child1, r = e.child2;
t.ShiftOriginNode(n, i);
t.ShiftOriginNode(r, i);
e.aabb.lowerBound.SelfSub(i);
e.aabb.upperBound.SelfSub(i);
}
};
t.prototype.ShiftOrigin = function(e) {
t.ShiftOriginNode(this.m_root, e);
};
t.s_r = new P();
t.s_v = new P();
t.s_abs_v = new P();
t.s_segmentAABB = new wt();
t.s_subInput = new St();
t.s_combinedAABB = new wt();
t.s_aabb = new wt();
t.s_node_id = 0;
return t;
})(), Vt = (function() {
return function(t, e) {
this.proxyA = t;
this.proxyB = e;
};
})(), Ot = (function() {
function t() {
this.m_tree = new Ft();
this.m_proxyCount = 0;
this.m_moveCount = 0;
this.m_moveBuffer = [];
this.m_pairCount = 0;
this.m_pairBuffer = [];
}
t.prototype.CreateProxy = function(t, e) {
var i = this.m_tree.CreateProxy(t, e);
++this.m_proxyCount;
this.BufferMove(i);
return i;
};
t.prototype.DestroyProxy = function(t) {
this.UnBufferMove(t);
--this.m_proxyCount;
this.m_tree.DestroyProxy(t);
};
t.prototype.MoveProxy = function(t, e, i) {
this.m_tree.MoveProxy(t, e, i) && this.BufferMove(t);
};
t.prototype.TouchProxy = function(t) {
this.BufferMove(t);
};
t.prototype.GetProxyCount = function() {
return this.m_proxyCount;
};
t.prototype.UpdatePairs = function(t) {
var e = this;
this.m_pairCount = 0;
for (var i = function(t) {
var i = n.m_moveBuffer[t];
if (null === i) return "continue";
var r = i.aabb;
n.m_tree.Query(r, (function(t) {
if (t.m_id === i.m_id) return !0;
var n, r;
if (t.m_id < i.m_id) {
n = t;
r = i;
} else {
n = i;
r = t;
}
if (e.m_pairCount === e.m_pairBuffer.length) e.m_pairBuffer[e.m_pairCount] = new Vt(n, r); else {
var s = e.m_pairBuffer[e.m_pairCount];
s.proxyA = n;
s.proxyB = r;
}
++e.m_pairCount;
return !0;
}));
}, n = this, r = 0; r < this.m_moveCount; ++r) i(r);
this.m_moveCount = 0;
this.m_pairBuffer.length = this.m_pairCount;
this.m_pairBuffer.sort(Nt);
for (var s = 0; s < this.m_pairCount; ) {
var o = this.m_pairBuffer[s], a = o.proxyA.userData, c = o.proxyB.userData;
a && c && t(a, c);
++s;
for (;s < this.m_pairCount; ) {
var h = this.m_pairBuffer[s];
if (h.proxyA.m_id !== o.proxyA.m_id || h.proxyB.m_id !== o.proxyB.m_id) break;
++s;
}
}
};
t.prototype.Query = function(t, e) {
this.m_tree.Query(t, e);
};
t.prototype.QueryPoint = function(t, e) {
this.m_tree.QueryPoint(t, e);
};
t.prototype.RayCast = function(t, e) {
this.m_tree.RayCast(t, e);
};
t.prototype.GetTreeHeight = function() {
return this.m_tree.GetHeight();
};
t.prototype.GetTreeBalance = function() {
return this.m_tree.GetMaxBalance();
};
t.prototype.GetTreeQuality = function() {
return this.m_tree.GetAreaRatio();
};
t.prototype.ShiftOrigin = function(t) {
this.m_tree.ShiftOrigin(t);
};
t.prototype.BufferMove = function(t) {
this.m_moveBuffer[this.m_moveCount] = t;
++this.m_moveCount;
};
t.prototype.UnBufferMove = function(t) {
var e = this.m_moveBuffer.indexOf(t);
this.m_moveBuffer[e] = null;
};
return t;
})();
function Nt(t, e) {
return t.proxyA.m_id === e.proxyA.m_id ? t.proxyB.m_id - e.proxyB.m_id : t.proxyA.m_id - e.proxyA.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;
var kt = new N(), Gt = new N(), zt = new P(), Ut = new P(), jt = new P(), Ht = new P(), Wt = new P(), qt = (function() {
return function() {
this.proxyA = new X();
this.proxyB = new X();
this.sweepA = new k();
this.sweepB = new k();
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 = {}));
var Xt = (function() {
return function() {
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 = {}));
var Yt = (function() {
function e() {
this.m_sweepA = new k();
this.m_sweepB = new k();
this.m_type = t.b2SeparationFunctionType.e_unknown;
this.m_localPoint = new P();
this.m_axis = new P();
}
e.prototype.Initialize = function(e, i, n, r, s, o) {
this.m_proxyA = i;
this.m_proxyB = r;
var a = e.count;
this.m_sweepA.Copy(n);
this.m_sweepB.Copy(s);
var c = kt, h = Gt;
this.m_sweepA.GetTransform(c, o);
this.m_sweepB.GetTransform(h, o);
if (1 === a) {
this.m_type = t.b2SeparationFunctionType.e_points;
var l = this.m_proxyA.GetVertex(e.indexA[0]), u = this.m_proxyB.GetVertex(e.indexB[0]), _ = N.MulXV(c, l, zt), f = N.MulXV(h, u, Ut);
P.SubVV(f, _, this.m_axis);
var d = this.m_axis.Normalize();
this.m_localPoint.SetZero();
return d;
}
if (e.indexA[0] === e.indexA[1]) {
this.m_type = t.b2SeparationFunctionType.e_faceB;
var m = this.m_proxyB.GetVertex(e.indexB[0]), p = this.m_proxyB.GetVertex(e.indexB[1]);
P.CrossVOne(P.SubVV(p, m, P.s_t0), this.m_axis).SelfNormalize();
var v = O.MulRV(h.q, this.m_axis, jt);
P.MidVV(m, p, this.m_localPoint);
f = N.MulXV(h, this.m_localPoint, Ut), l = this.m_proxyA.GetVertex(e.indexA[0]), 
_ = N.MulXV(c, l, zt);
if ((d = P.DotVV(P.SubVV(_, f, P.s_t0), v)) < 0) {
this.m_axis.SelfNeg();
d = -d;
}
return d;
}
this.m_type = t.b2SeparationFunctionType.e_faceA;
var y = this.m_proxyA.GetVertex(e.indexA[0]), g = this.m_proxyA.GetVertex(e.indexA[1]);
P.CrossVOne(P.SubVV(g, y, P.s_t0), this.m_axis).SelfNormalize();
v = O.MulRV(c.q, this.m_axis, jt);
P.MidVV(y, g, this.m_localPoint);
_ = N.MulXV(c, this.m_localPoint, zt), u = this.m_proxyB.GetVertex(e.indexB[0]), 
f = N.MulXV(h, u, Ut);
if ((d = P.DotVV(P.SubVV(f, _, P.s_t0), v)) < 0) {
this.m_axis.SelfNeg();
d = -d;
}
return d;
};
e.prototype.FindMinSeparation = function(e, i, n) {
var r = kt, s = Gt;
this.m_sweepA.GetTransform(r, n);
this.m_sweepB.GetTransform(s, n);
switch (this.m_type) {
case t.b2SeparationFunctionType.e_points:
var o = O.MulTRV(r.q, this.m_axis, Ht), a = O.MulTRV(s.q, P.NegV(this.m_axis, P.s_t0), Wt);
e[0] = this.m_proxyA.GetSupport(o);
i[0] = this.m_proxyB.GetSupport(a);
var c = this.m_proxyA.GetVertex(e[0]), h = this.m_proxyB.GetVertex(i[0]), l = N.MulXV(r, c, zt), u = N.MulXV(s, h, Ut);
return P.DotVV(P.SubVV(u, l, P.s_t0), this.m_axis);

case t.b2SeparationFunctionType.e_faceA:
var _ = O.MulRV(r.q, this.m_axis, jt);
l = N.MulXV(r, this.m_localPoint, zt), a = O.MulTRV(s.q, P.NegV(_, P.s_t0), Wt);
e[0] = -1;
i[0] = this.m_proxyB.GetSupport(a);
h = this.m_proxyB.GetVertex(i[0]), u = N.MulXV(s, h, Ut);
return P.DotVV(P.SubVV(u, l, P.s_t0), _);

case t.b2SeparationFunctionType.e_faceB:
_ = O.MulRV(s.q, this.m_axis, jt), u = N.MulXV(s, this.m_localPoint, Ut), o = O.MulTRV(r.q, P.NegV(_, P.s_t0), Ht);
i[0] = -1;
e[0] = this.m_proxyA.GetSupport(o);
c = this.m_proxyA.GetVertex(e[0]), l = N.MulXV(r, c, zt);
return P.DotVV(P.SubVV(l, u, P.s_t0), _);

default:
e[0] = -1;
i[0] = -1;
return 0;
}
};
e.prototype.Evaluate = function(e, i, n) {
var r = kt, s = Gt;
this.m_sweepA.GetTransform(r, n);
this.m_sweepB.GetTransform(s, n);
switch (this.m_type) {
case t.b2SeparationFunctionType.e_points:
var o = this.m_proxyA.GetVertex(e), a = this.m_proxyB.GetVertex(i), c = N.MulXV(r, o, zt), h = N.MulXV(s, a, Ut);
return P.DotVV(P.SubVV(h, c, P.s_t0), this.m_axis);

case t.b2SeparationFunctionType.e_faceA:
var l = O.MulRV(r.q, this.m_axis, jt);
c = N.MulXV(r, this.m_localPoint, zt), a = this.m_proxyB.GetVertex(i), h = N.MulXV(s, a, Ut);
return P.DotVV(P.SubVV(h, c, P.s_t0), l);

case t.b2SeparationFunctionType.e_faceB:
l = O.MulRV(s.q, this.m_axis, jt), h = N.MulXV(s, this.m_localPoint, Ut), o = this.m_proxyA.GetVertex(e), 
c = N.MulXV(r, o, zt);
return P.DotVV(P.SubVV(c, h, P.s_t0), l);

default:
return 0;
}
};
return e;
})(), Jt = new U(), Zt = new Y(), Kt = new J(), Qt = new Z(), $t = new Yt(), te = [ 0 ], ee = [ 0 ], ie = new k(), ne = new k();
function re(e, i) {
var n = Jt.Reset();
++t.b2_toiCalls;
e.state = t.b2TOIOutputState.e_unknown;
e.t = i.tMax;
var r = i.proxyA, s = i.proxyB, o = ie.Copy(i.sweepA), h = ne.Copy(i.sweepB);
o.Normalize();
h.Normalize();
var l = i.tMax, u = r.m_radius + s.m_radius, _ = x(c, u - 3 * c), f = .25 * c, d = 0, m = 0, p = Zt;
p.count = 0;
var v = Kt;
v.proxyA.Copy(i.proxyA);
v.proxyB.Copy(i.proxyB);
v.useRadii = !1;
for (;;) {
var g = kt, C = Gt;
o.GetTransform(g, d);
h.GetTransform(C, d);
v.transformA.Copy(g);
v.transformB.Copy(C);
var A = Qt;
ht(A, p, v);
if (A.distance <= 0) {
e.state = t.b2TOIOutputState.e_overlapped;
e.t = 0;
break;
}
if (A.distance < _ + f) {
e.state = t.b2TOIOutputState.e_touching;
e.t = d;
break;
}
var b = $t;
b.Initialize(p, r, o, s, h, d);
for (var S = !1, T = l, w = 0; ;) {
var E = te, B = ee, M = b.FindMinSeparation(E, B, T);
if (M > _ + f) {
e.state = t.b2TOIOutputState.e_separated;
e.t = l;
S = !0;
break;
}
if (M > _ - f) {
d = T;
break;
}
var D = b.Evaluate(E[0], B[0], d);
if (D < _ - f) {
e.state = t.b2TOIOutputState.e_failed;
e.t = d;
S = !0;
break;
}
if (D <= _ + f) {
e.state = t.b2TOIOutputState.e_touching;
e.t = d;
S = !0;
break;
}
for (var I = 0, P = d, R = T; ;) {
var L = 0;
L = 1 & I ? P + (_ - D) * (R - P) / (M - D) : .5 * (P + R);
++I;
++t.b2_toiRootIters;
var F = b.Evaluate(E[0], B[0], L);
if (y(F - _) < f) {
T = L;
break;
}
if (F > _) {
P = L;
D = F;
} else {
R = L;
M = F;
}
if (50 === I) break;
}
t.b2_toiMaxRootIters = x(t.b2_toiMaxRootIters, I);
if (++w === a) break;
}
++m;
++t.b2_toiIters;
if (S) break;
if (20 === m) {
e.state = t.b2TOIOutputState.e_failed;
e.t = d;
break;
}
}
t.b2_toiMaxIters = x(t.b2_toiMaxIters, m);
var V = n.GetMilliseconds();
t.b2_toiMaxTime = x(t.b2_toiMaxTime, V);
t.b2_toiTime += V;
}
var se = new P(), oe = new P();
function ae(e, i, n, r, s) {
e.pointCount = 0;
var o = N.MulXV(n, i.m_p, se), a = N.MulXV(s, r.m_p, oe), c = P.DistanceSquaredVV(o, a), h = i.m_radius + r.m_radius;
if (!(c > 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(r.m_p);
e.points[0].id.key = 0;
}
}
var ce = new P(), he = new P(), le = new P();
function ue(e, r, s, o, a) {
e.pointCount = 0;
for (var c = N.MulXV(a, o.m_p, ce), h = N.MulTXV(s, c, he), l = 0, u = -i, _ = r.m_radius + o.m_radius, f = r.m_count, d = r.m_vertices, m = r.m_normals, p = 0; p < f; ++p) {
var v = P.DotVV(m[p], P.SubVV(h, d[p], P.s_t0));
if (v > _) return;
if (v > u) {
u = v;
l = p;
}
}
var y = l, g = (y + 1) % f, x = d[y], C = d[g];
if (u < n) {
e.pointCount = 1;
e.type = t.b2ManifoldType.e_faceA;
e.localNormal.Copy(m[l]);
P.MidVV(x, C, e.localPoint);
e.points[0].localPoint.Copy(o.m_p);
e.points[0].id.key = 0;
} else {
var A = P.DotVV(P.SubVV(h, x, P.s_t0), P.SubVV(C, x, P.s_t1)), b = P.DotVV(P.SubVV(h, C, P.s_t0), P.SubVV(x, C, P.s_t1));
if (A <= 0) {
if (P.DistanceSquaredVV(h, x) > _ * _) return;
e.pointCount = 1;
e.type = t.b2ManifoldType.e_faceA;
P.SubVV(h, x, e.localNormal).SelfNormalize();
e.localPoint.Copy(x);
e.points[0].localPoint.Copy(o.m_p);
e.points[0].id.key = 0;
} else if (b <= 0) {
if (P.DistanceSquaredVV(h, C) > _ * _) return;
e.pointCount = 1;
e.type = t.b2ManifoldType.e_faceA;
P.SubVV(h, C, e.localNormal).SelfNormalize();
e.localPoint.Copy(C);
e.points[0].localPoint.Copy(o.m_p);
e.points[0].id.key = 0;
} else {
var S = P.MidVV(x, C, le);
if (P.DotVV(P.SubVV(h, S, P.s_t1), m[y]) > _) return;
e.pointCount = 1;
e.type = t.b2ManifoldType.e_faceA;
e.localNormal.Copy(m[y]).SelfNormalize();
e.localPoint.Copy(S);
e.points[0].localPoint.Copy(o.m_p);
e.points[0].id.key = 0;
}
}
}
var _e = new P(), fe = new P(), de = new P(), me = new P();
function pe(t, e, n, r, s) {
for (var o = t.m_vertices, a = t.m_normals, c = r.m_count, h = r.m_vertices, l = O.MulRV(e.q, a[n], _e), u = O.MulTRV(s.q, l, fe), _ = 0, f = i, d = 0; d < c; ++d) {
var m = P.DotVV(h[d], u);
if (m < f) {
f = m;
_ = d;
}
}
var p = N.MulXV(e, o[n], de), v = N.MulXV(s, h[_], me);
return P.DotVV(P.SubVV(v, p, P.s_t0), l);
}
var ve = new P(), ye = new P();
function ge(t, e, n, r, s) {
for (var o = e.m_count, a = e.m_normals, c = P.SubVV(N.MulXV(s, r.m_centroid, P.s_t0), N.MulXV(n, e.m_centroid, P.s_t1), ve), h = O.MulTRV(n.q, c, ye), l = 0, u = -i, _ = 0; _ < o; ++_) {
var f = P.DotVV(a[_], h);
if (f > u) {
u = f;
l = _;
}
}
var d = pe(e, n, l, r, s), m = (l + o - 1) % o, p = pe(e, n, m, r, s), v = (l + 1) % o, y = pe(e, n, v, r, s), g = 0, x = 0, C = 0;
if (p > d && p > y) {
C = -1;
g = m;
x = p;
} else {
if (!(y > d)) {
t[0] = l;
return d;
}
C = 1;
g = v;
x = y;
}
for (;(d = pe(e, n, l = -1 === C ? (g + o - 1) % o : (g + 1) % o, r, s)) > x; ) {
g = l;
x = d;
}
t[0] = g;
return x;
}
var xe = new P();
var Ce = bt.MakeArray(2), Ae = bt.MakeArray(2), be = bt.MakeArray(2), Se = [ 0 ], Te = [ 0 ], we = new P(), Ee = new P(), Be = new P(), Me = new P(), De = new P(), Ie = new P(), Pe = new P(), Re = new P();
function Le(e, n, r, s, a) {
e.pointCount = 0;
var c = n.m_radius + s.m_radius, h = Se;
h[0] = 0;
var l = ge(h, n, r, s, a);
if (!(l > c)) {
var u = Te;
u[0] = 0;
var _ = ge(u, s, a, n, r);
if (!(_ > c)) {
var f, d, m, p, v = 0, y = 0;
if (_ > .98 * l + .001) {
f = s;
d = n;
m = a;
p = r;
v = u[0];
e.type = t.b2ManifoldType.e_faceB;
y = 1;
} else {
f = n;
d = s;
m = r;
p = a;
v = h[0];
e.type = t.b2ManifoldType.e_faceA;
y = 0;
}
var g = Ce;
(function(e, n, r, s, o, a) {
for (var c = n.m_normals, h = o.m_count, l = o.m_vertices, u = o.m_normals, _ = O.MulTRV(a.q, O.MulRV(r.q, c[s], P.s_t0), xe), f = 0, d = i, m = 0; m < h; ++m) {
var p = P.DotVV(_, u[m]);
if (p < d) {
d = p;
f = m;
}
}
var v = f, y = (v + 1) % h, g = e[0];
N.MulXV(a, l[v], g.v);
var x = g.id.cf;
x.indexA = s;
x.indexB = v;
x.typeA = t.b2ContactFeatureType.e_face;
x.typeB = t.b2ContactFeatureType.e_vertex;
var C = e[1];
N.MulXV(a, l[y], C.v);
var A = C.id.cf;
A.indexA = s;
A.indexB = y;
A.typeA = t.b2ContactFeatureType.e_face;
A.typeB = t.b2ContactFeatureType.e_vertex;
})(g, f, m, v, d, p);
var x = f.m_count, C = f.m_vertices, A = v, b = (v + 1) % x, S = C[A], T = C[b], w = P.SubVV(T, S, we);
w.Normalize();
var E = P.CrossVOne(w, Ee), B = P.MidVV(S, T, Be), M = O.MulRV(m.q, w, De), D = P.CrossVOne(M, Me), I = N.MulXV(m, S, Pe), R = N.MulXV(m, T, Re), L = P.DotVV(D, I), F = -P.DotVV(M, I) + c, V = P.DotVV(M, R) + c, k = Ae, G = be;
if (!(Bt(k, g, P.NegV(M, Ie), F, A) < 2 || Bt(G, k, M, V, b) < 2)) {
e.localNormal.Copy(E);
e.localPoint.Copy(B);
for (var z = 0, U = 0; U < o; ++U) {
var j = G[U];
if (P.DotVV(D, j.v) - L <= c) {
var H = e.points[z];
N.MulTXV(p, j.v, H.localPoint);
H.id.Copy(j.id);
if (y) {
var W = H.id.cf;
H.id.cf.indexA = W.indexB;
H.id.cf.indexB = W.indexA;
H.id.cf.typeA = W.typeB;
H.id.cf.typeB = W.typeA;
}
++z;
}
}
e.pointCount = z;
}
}
}
}
var Fe = new P(), Ve = new P(), Oe = new P(), Ne = new P(), ke = new P(), Ge = new P(), ze = new P(), Ue = new gt();
function je(e, i, n, r, s) {
e.pointCount = 0;
var o = N.MulTXV(n, N.MulXV(s, r.m_p, P.s_t0), Fe), a = i.m_vertex1, c = i.m_vertex2, h = P.SubVV(c, a, Ve), l = P.DotVV(h, P.SubVV(c, o, P.s_t0)), u = P.DotVV(h, P.SubVV(o, a, P.s_t0)), _ = i.m_radius + r.m_radius, f = Ue;
f.cf.indexB = 0;
f.cf.typeB = t.b2ContactFeatureType.e_vertex;
if (u <= 0) {
var d = a, m = P.SubVV(o, d, Oe);
if (P.DotVV(m, m) > _ * _) return;
if (i.m_hasVertex0) {
var p = i.m_vertex0, v = a, y = P.SubVV(v, p, Ne);
if (P.DotVV(y, P.SubVV(v, o, P.s_t0)) > 0) return;
}
f.cf.indexA = 0;
f.cf.typeA = t.b2ContactFeatureType.e_vertex;
e.pointCount = 1;
e.type = t.b2ManifoldType.e_circles;
e.localNormal.SetZero();
e.localPoint.Copy(d);
e.points[0].id.Copy(f);
e.points[0].localPoint.Copy(r.m_p);
} else if (l <= 0) {
var g = c, x = P.SubVV(o, g, Oe);
if (P.DotVV(x, x) > _ * _) return;
if (i.m_hasVertex3) {
var C = i.m_vertex3, A = c, b = P.SubVV(C, A, ke);
if (P.DotVV(b, P.SubVV(o, A, P.s_t0)) > 0) return;
}
f.cf.indexA = 1;
f.cf.typeA = t.b2ContactFeatureType.e_vertex;
e.pointCount = 1;
e.type = t.b2ManifoldType.e_circles;
e.localNormal.SetZero();
e.localPoint.Copy(g);
e.points[0].id.Copy(f);
e.points[0].localPoint.Copy(r.m_p);
} else {
var S = P.DotVV(h, h), T = Ge;
T.x = 1 / S * (l * a.x + u * c.x);
T.y = 1 / S * (l * a.y + u * c.y);
var w = P.SubVV(o, T, Oe);
if (!(P.DotVV(w, w) > _ * _)) {
var E = ze.Set(-h.y, h.x);
P.DotVV(E, P.SubVV(o, a, P.s_t0)) < 0 && E.Set(-E.x, -E.y);
E.Normalize();
f.cf.indexA = 0;
f.cf.typeA = t.b2ContactFeatureType.e_face;
e.pointCount = 1;
e.type = t.b2ManifoldType.e_faceA;
e.localNormal.Copy(E);
e.localPoint.Copy(a);
e.points[0].id.Copy(f);
e.points[0].localPoint.Copy(r.m_p);
}
}
}
var He = (function() {
return function() {
this.type = 0;
this.index = 0;
this.separation = 0;
};
})(), We = (function() {
return function() {
this.vertices = P.MakeArray(a);
this.normals = P.MakeArray(a);
this.count = 0;
};
})(), qe = (function() {
return function() {
this.i1 = 0;
this.i2 = 0;
this.v1 = new P();
this.v2 = new P();
this.normal = new P();
this.sideNormal1 = new P();
this.sideOffset1 = 0;
this.sideNormal2 = new P();
this.sideOffset2 = 0;
};
})(), Xe = new (function() {
function e() {
this.m_polygonB = new We();
this.m_xf = new N();
this.m_centroidB = new P();
this.m_v0 = new P();
this.m_v1 = new P();
this.m_v2 = new P();
this.m_v3 = new P();
this.m_normal0 = new P();
this.m_normal1 = new P();
this.m_normal2 = new P();
this.m_normal = new P();
this.m_type1 = 0;
this.m_type2 = 0;
this.m_lowerLimit = new P();
this.m_upperLimit = new P();
this.m_radius = 0;
this.m_front = !1;
}
e.prototype.Collide = function(i, n, r, s, a) {
N.MulTXX(r, a, this.m_xf);
N.MulXV(this.m_xf, s.m_centroid, this.m_centroidB);
this.m_v0.Copy(n.m_vertex0);
this.m_v1.Copy(n.m_vertex1);
this.m_v2.Copy(n.m_vertex2);
this.m_v3.Copy(n.m_vertex3);
var c = n.m_hasVertex0, h = n.m_hasVertex3, l = P.SubVV(this.m_v2, this.m_v1, e.s_edge1);
l.Normalize();
this.m_normal1.Set(l.y, -l.x);
var u = P.DotVV(this.m_normal1, P.SubVV(this.m_centroidB, this.m_v1, P.s_t0)), _ = 0, f = 0, d = !1, m = !1;
if (c) {
var p = P.SubVV(this.m_v1, this.m_v0, e.s_edge0);
p.Normalize();
this.m_normal0.Set(p.y, -p.x);
d = P.CrossVV(p, l) >= 0;
_ = P.DotVV(this.m_normal0, P.SubVV(this.m_centroidB, this.m_v0, P.s_t0));
}
if (h) {
var v = P.SubVV(this.m_v3, this.m_v2, e.s_edge2);
v.Normalize();
this.m_normal2.Set(v.y, -v.x);
m = P.CrossVV(l, v) > 0;
f = P.DotVV(this.m_normal2, P.SubVV(this.m_centroidB, this.m_v2, P.s_t0));
}
if (c && h) if (d && m) {
this.m_front = _ >= 0 || u >= 0 || f >= 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 = _ >= 0 || u >= 0 && f >= 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 (m) {
this.m_front = f >= 0 || _ >= 0 && u >= 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 = _ >= 0 && u >= 0 && f >= 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 (c) if (d) {
this.m_front = _ >= 0 || u >= 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 = _ >= 0 && u >= 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 (h) if (m) {
this.m_front = u >= 0 || f >= 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 = u >= 0 && f >= 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 = u >= 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 = s.m_count;
for (var y = 0; y < s.m_count; ++y) {
N.MulXV(this.m_xf, s.m_vertices[y], this.m_polygonB.vertices[y]);
O.MulRV(this.m_xf.q, s.m_normals[y], this.m_polygonB.normals[y]);
}
this.m_radius = s.m_radius + n.m_radius;
i.pointCount = 0;
var g = this.ComputeEdgeSeparation(e.s_edgeAxis);
if (0 !== g.type && !(g.separation > this.m_radius)) {
var x = this.ComputePolygonSeparation(e.s_polygonAxis);
if (!(0 !== x.type && x.separation > this.m_radius)) {
var C;
C = 0 === x.type ? g : x.separation > .98 * g.separation + .001 ? x : g;
var A = e.s_ie, b = e.s_rf;
if (1 === C.type) {
i.type = t.b2ManifoldType.e_faceA;
var S = 0, T = P.DotVV(this.m_normal, this.m_polygonB.normals[0]);
for (y = 1; y < this.m_polygonB.count; ++y) {
var w = P.DotVV(this.m_normal, this.m_polygonB.normals[y]);
if (w < T) {
T = w;
S = y;
}
}
var E = S, B = (E + 1) % this.m_polygonB.count;
(M = A[0]).v.Copy(this.m_polygonB.vertices[E]);
M.id.cf.indexA = 0;
M.id.cf.indexB = E;
M.id.cf.typeA = t.b2ContactFeatureType.e_face;
M.id.cf.typeB = t.b2ContactFeatureType.e_vertex;
(D = A[1]).v.Copy(this.m_polygonB.vertices[B]);
D.id.cf.indexA = 0;
D.id.cf.indexB = B;
D.id.cf.typeA = t.b2ContactFeatureType.e_face;
D.id.cf.typeB = t.b2ContactFeatureType.e_vertex;
if (this.m_front) {
b.i1 = 0;
b.i2 = 1;
b.v1.Copy(this.m_v1);
b.v2.Copy(this.m_v2);
b.normal.Copy(this.m_normal1);
} else {
b.i1 = 1;
b.i2 = 0;
b.v1.Copy(this.m_v2);
b.v2.Copy(this.m_v1);
b.normal.Copy(this.m_normal1).SelfNeg();
}
} else {
i.type = t.b2ManifoldType.e_faceB;
var M, D;
(M = A[0]).v.Copy(this.m_v1);
M.id.cf.indexA = 0;
M.id.cf.indexB = C.index;
M.id.cf.typeA = t.b2ContactFeatureType.e_vertex;
M.id.cf.typeB = t.b2ContactFeatureType.e_face;
(D = A[1]).v.Copy(this.m_v2);
D.id.cf.indexA = 0;
D.id.cf.indexB = C.index;
D.id.cf.typeA = t.b2ContactFeatureType.e_vertex;
D.id.cf.typeB = t.b2ContactFeatureType.e_face;
b.i1 = C.index;
b.i2 = (b.i1 + 1) % this.m_polygonB.count;
b.v1.Copy(this.m_polygonB.vertices[b.i1]);
b.v2.Copy(this.m_polygonB.vertices[b.i2]);
b.normal.Copy(this.m_polygonB.normals[b.i1]);
}
b.sideNormal1.Set(b.normal.y, -b.normal.x);
b.sideNormal2.Copy(b.sideNormal1).SelfNeg();
b.sideOffset1 = P.DotVV(b.sideNormal1, b.v1);
b.sideOffset2 = P.DotVV(b.sideNormal2, b.v2);
var I = e.s_clipPoints1, R = e.s_clipPoints2;
if (!(Bt(I, A, b.sideNormal1, b.sideOffset1, b.i1) < o || Bt(R, I, b.sideNormal2, b.sideOffset2, b.i2) < o)) {
if (1 === C.type) {
i.localNormal.Copy(b.normal);
i.localPoint.Copy(b.v1);
} else {
i.localNormal.Copy(s.m_normals[b.i1]);
i.localPoint.Copy(s.m_vertices[b.i1]);
}
var L = 0;
for (y = 0; y < o; ++y) {
if (P.DotVV(b.normal, P.SubVV(R[y].v, b.v1, P.s_t0)) <= this.m_radius) {
var F = i.points[L];
if (1 === C.type) {
N.MulTXV(this.m_xf, R[y].v, F.localPoint);
F.id = R[y].id;
} else {
F.localPoint.Copy(R[y].v);
F.id.cf.typeA = R[y].id.cf.typeB;
F.id.cf.typeB = R[y].id.cf.typeA;
F.id.cf.indexA = R[y].id.cf.indexB;
F.id.cf.indexB = R[y].id.cf.indexA;
}
++L;
}
}
i.pointCount = L;
}
}
}
};
e.prototype.ComputeEdgeSeparation = function(t) {
var e = t;
e.type = 1;
e.index = this.m_front ? 0 : 1;
e.separation = i;
for (var n = 0; n < this.m_polygonB.count; ++n) {
var r = P.DotVV(this.m_normal, P.SubVV(this.m_polygonB.vertices[n], this.m_v1, P.s_t0));
r < e.separation && (e.separation = r);
}
return e;
};
e.prototype.ComputePolygonSeparation = function(t) {
var n = t;
n.type = 0;
n.index = -1;
n.separation = -i;
for (var r = e.s_perp.Set(-this.m_normal.y, this.m_normal.x), s = 0; s < this.m_polygonB.count; ++s) {
var o = P.NegV(this.m_polygonB.normals[s], e.s_n), a = P.DotVV(o, P.SubVV(this.m_polygonB.vertices[s], this.m_v1, P.s_t0)), c = P.DotVV(o, P.SubVV(this.m_polygonB.vertices[s], this.m_v2, P.s_t0)), l = g(a, c);
if (l > this.m_radius) {
n.type = 2;
n.index = s;
n.separation = l;
return n;
}
if (P.DotVV(o, r) >= 0) {
if (P.DotVV(P.SubVV(o, this.m_upperLimit, P.s_t0), this.m_normal) < -h) continue;
} else if (P.DotVV(P.SubVV(o, this.m_lowerLimit, P.s_t0), this.m_normal) < -h) continue;
if (l > n.separation) {
n.type = 2;
n.index = s;
n.separation = l;
}
}
return n;
};
e.s_edge1 = new P();
e.s_edge0 = new P();
e.s_edge2 = new P();
e.s_ie = bt.MakeArray(2);
e.s_rf = new qe();
e.s_clipPoints1 = bt.MakeArray(2);
e.s_clipPoints2 = bt.MakeArray(2);
e.s_edgeAxis = new He();
e.s_polygonAxis = new He();
e.s_n = new P();
e.s_perp = new P();
return e;
}())();
function Ye(t, e, i, n, r) {
Xe.Collide(t, e, i, n, r);
}
var Je = (function() {
return function() {
this.mass = 0;
this.center = new P(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 = {}));
var Ze = (function() {
function e(e, i) {
this.m_type = t.b2ShapeType.e_unknown;
this.m_radius = 0;
this.m_type = e;
this.m_radius = i;
}
e.prototype.Copy = function(t) {
this.m_radius = t.m_radius;
return this;
};
e.prototype.GetType = function() {
return this.m_type;
};
return e;
})(), Ke = 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]);
};
function Qe(t, e) {
Ke(t, e);
function i() {
this.constructor = t;
}
t.prototype = null === e ? Object.create(e) : (i.prototype = e.prototype, new i());
}
var $e = (function(e) {
Qe(i, e);
function i(i) {
void 0 === i && (i = 0);
var n = e.call(this, t.b2ShapeType.e_circleShape, i) || this;
n.m_p = new P();
return n;
}
i.prototype.Set = function(t, e) {
void 0 === e && (e = this.m_radius);
this.m_p.Copy(t);
this.m_radius = e;
return this;
};
i.prototype.Clone = function() {
return new i().Copy(this);
};
i.prototype.Copy = function(t) {
e.prototype.Copy.call(this, t);
this.m_p.Copy(t.m_p);
return this;
};
i.prototype.GetChildCount = function() {
return 1;
};
i.prototype.TestPoint = function(t, e) {
var n = N.MulXV(t, this.m_p, i.TestPoint_s_center), r = P.SubVV(e, n, i.TestPoint_s_d);
return P.DotVV(r, r) <= b(this.m_radius);
};
i.prototype.ComputeDistance = function(t, e, n, r) {
var s = N.MulXV(t, this.m_p, i.ComputeDistance_s_center);
P.SubVV(e, s, n);
return n.Normalize() - this.m_radius;
};
i.prototype.RayCast = function(t, e, r, s) {
var o = N.MulXV(r, this.m_p, i.RayCast_s_position), a = P.SubVV(e.p1, o, i.RayCast_s_s), c = P.DotVV(a, a) - b(this.m_radius), h = P.SubVV(e.p2, e.p1, i.RayCast_s_r), l = P.DotVV(a, h), u = P.DotVV(h, h), _ = l * l - u * c;
if (_ < 0 || u < n) return !1;
var f = -(l + T(_));
if (0 <= f && f <= e.maxFraction * u) {
f /= u;
t.fraction = f;
P.AddVMulSV(a, f, h, t.normal).SelfNormalize();
return !0;
}
return !1;
};
i.prototype.ComputeAABB = function(t, e, n) {
var r = N.MulXV(e, this.m_p, i.ComputeAABB_s_p);
t.lowerBound.Set(r.x - this.m_radius, r.y - this.m_radius);
t.upperBound.Set(r.x + this.m_radius, r.y + this.m_radius);
};
i.prototype.ComputeMass = function(t, e) {
var i = b(this.m_radius);
t.mass = e * s * i;
t.center.Copy(this.m_p);
t.I = t.mass * (.5 * i + P.DotVV(this.m_p, this.m_p));
};
i.prototype.SetupDistanceProxy = function(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;
};
i.prototype.ComputeSubmergedArea = function(t, e, i, r) {
var o = N.MulXV(i, this.m_p, new P()), a = -(P.DotVV(t, o) - e);
if (a < -this.m_radius + n) return 0;
if (a > this.m_radius) {
r.Copy(o);
return s * this.m_radius * this.m_radius;
}
var c = this.m_radius * this.m_radius, h = a * a, l = c * (D(a / this.m_radius) + s / 2) + a * T(c - h), u = -2 / 3 * w(c - h, 1.5) / l;
r.x = o.x + t.x * u;
r.y = o.y + t.y * u;
return l;
};
i.prototype.Dump = function(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);
};
i.TestPoint_s_center = new P();
i.TestPoint_s_d = new P();
i.ComputeDistance_s_center = new P();
i.RayCast_s_position = new P();
i.RayCast_s_s = new P();
i.RayCast_s_r = new P();
i.ComputeAABB_s_p = new P();
return i;
})(Ze), ti = (function(e) {
Qe(r, e);
function r() {
var i = e.call(this, t.b2ShapeType.e_polygonShape, l) || this;
i.m_centroid = new P(0, 0);
i.m_vertices = [];
i.m_normals = [];
i.m_count = 0;
return i;
}
r.prototype.Clone = function() {
return new r().Copy(this);
};
r.prototype.Copy = function(t) {
e.prototype.Copy.call(this, t);
this.m_centroid.Copy(t.m_centroid);
this.m_count = t.m_count;
this.m_vertices = P.MakeArray(this.m_count);
this.m_normals = P.MakeArray(this.m_count);
for (var i = 0; i < this.m_count; ++i) {
this.m_vertices[i].Copy(t.m_vertices[i]);
this.m_normals[i].Copy(t.m_normals[i]);
}
return this;
};
r.prototype.GetChildCount = function() {
return 1;
};
r.prototype.Set = function(t, e, i) {
void 0 === e && (e = t.length);
void 0 === i && (i = 0);
if (e < 3) return this.SetAsBox(1, 1);
for (var n = g(e, a), s = r.Set_s_ps, o = 0, h = 0; h < n; ++h) {
for (var l = t[i + h], u = !0, _ = 0; _ < o; ++_) if (P.DistanceSquaredVV(l, s[_]) < .5 * c * (.5 * c)) {
u = !1;
break;
}
u && s[o++].Copy(l);
}
if ((n = o) < 3) return this.SetAsBox(1, 1);
var f = 0, d = s[0].x;
for (h = 1; h < n; ++h) {
var m = s[h].x;
if (m > d || m === d && s[h].y < s[f].y) {
f = h;
d = m;
}
}
for (var p = r.Set_s_hull, v = 0, y = f; ;) {
p[v] = y;
var x = 0;
for (_ = 1; _ < n; ++_) if (x !== y) {
var C = P.SubVV(s[x], s[p[v]], r.Set_s_r), A = (l = P.SubVV(s[_], s[p[v]], r.Set_s_v), 
P.CrossVV(C, l));
A < 0 && (x = _);
0 === A && l.LengthSquared() > C.LengthSquared() && (x = _);
} else x = _;
++v;
y = x;
if (x === f) break;
}
this.m_count = v;
this.m_vertices = P.MakeArray(this.m_count);
this.m_normals = P.MakeArray(this.m_count);
for (h = 0; h < v; ++h) this.m_vertices[h].Copy(s[p[h]]);
for (h = 0; h < v; ++h) {
var b = this.m_vertices[h], S = this.m_vertices[(h + 1) % v], T = P.SubVV(S, b, P.s_t0);
P.CrossVOne(T, this.m_normals[h]).SelfNormalize();
}
r.ComputeCentroid(this.m_vertices, v, this.m_centroid);
return this;
};
r.prototype.SetAsArray = function(t, e) {
void 0 === e && (e = t.length);
return this.Set(t, e);
};
r.prototype.SetAsBox = function(t, e, i, n) {
void 0 === n && (n = 0);
this.m_count = 4;
this.m_vertices = P.MakeArray(this.m_count);
this.m_normals = P.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);
var r = new N();
r.SetPosition(i);
r.SetRotationAngle(n);
for (var s = 0; s < this.m_count; ++s) {
N.MulXV(r, this.m_vertices[s], this.m_vertices[s]);
O.MulRV(r.q, this.m_normals[s], this.m_normals[s]);
}
}
return this;
};
r.prototype.TestPoint = function(t, e) {
for (var i = N.MulTXV(t, e, r.TestPoint_s_pLocal), n = 0; n < this.m_count; ++n) {
if (P.DotVV(this.m_normals[n], P.SubVV(i, this.m_vertices[n], P.s_t0)) > 0) return !1;
}
return !0;
};
r.prototype.ComputeDistance = function(t, e, n, s) {
for (var o = N.MulTXV(t, e, r.ComputeDistance_s_pLocal), a = -i, c = r.ComputeDistance_s_normalForMaxDistance.Copy(o), h = 0; h < this.m_count; ++h) {
var l = P.DotVV(this.m_normals[h], P.SubVV(o, this.m_vertices[h], P.s_t0));
if (l > a) {
a = l;
c.Copy(this.m_normals[h]);
}
}
if (a > 0) {
var u = r.ComputeDistance_s_minDistance.Copy(c), _ = a * a;
for (h = 0; h < this.m_count; ++h) {
var f = P.SubVV(o, this.m_vertices[h], r.ComputeDistance_s_distance), d = f.LengthSquared();
if (_ > d) {
u.Copy(f);
_ = d;
}
}
O.MulRV(t.q, u, n);
n.Normalize();
return Math.sqrt(_);
}
O.MulRV(t.q, c, n);
return a;
};
r.prototype.RayCast = function(t, e, i, n) {
for (var s = N.MulTXV(i, e.p1, r.RayCast_s_p1), o = N.MulTXV(i, e.p2, r.RayCast_s_p2), a = P.SubVV(o, s, r.RayCast_s_d), c = 0, h = e.maxFraction, l = -1, u = 0; u < this.m_count; ++u) {
var _ = P.DotVV(this.m_normals[u], P.SubVV(this.m_vertices[u], s, P.s_t0)), f = P.DotVV(this.m_normals[u], a);
if (0 === f) {
if (_ < 0) return !1;
} else if (f < 0 && _ < c * f) {
c = _ / f;
l = u;
} else f > 0 && _ < h * f && (h = _ / f);
if (h < c) return !1;
}
if (l >= 0) {
t.fraction = c;
O.MulRV(i.q, this.m_normals[l], t.normal);
return !0;
}
return !1;
};
r.prototype.ComputeAABB = function(t, e, i) {
for (var n = N.MulXV(e, this.m_vertices[0], t.lowerBound), s = t.upperBound.Copy(n), o = 0; o < this.m_count; ++o) {
var a = N.MulXV(e, this.m_vertices[o], r.ComputeAABB_s_v);
P.MinV(a, n, n);
P.MaxV(a, s, s);
}
var c = this.m_radius;
n.SelfSubXY(c, c);
s.SelfAddXY(c, c);
};
r.prototype.ComputeMass = function(t, e) {
for (var i = r.ComputeMass_s_center.SetZero(), n = 0, s = 0, o = r.ComputeMass_s_s.SetZero(), a = 0; a < this.m_count; ++a) o.SelfAdd(this.m_vertices[a]);
o.SelfMul(1 / this.m_count);
for (a = 0; a < this.m_count; ++a) {
var c = P.SubVV(this.m_vertices[a], o, r.ComputeMass_s_e1), h = P.SubVV(this.m_vertices[(a + 1) % this.m_count], o, r.ComputeMass_s_e2), l = P.CrossVV(c, h), u = .5 * l;
n += u;
i.SelfAdd(P.MulSV(u * (1 / 3), P.AddVV(c, h, P.s_t0), P.s_t1));
var _ = c.x, f = c.y, d = h.x, m = h.y;
s += 1 / 3 * .25 * l * (_ * _ + d * _ + d * d + (f * f + m * f + m * m));
}
t.mass = e * n;
i.SelfMul(1 / n);
P.AddVV(i, o, t.center);
t.I = e * s;
t.I += t.mass * (P.DotVV(t.center, t.center) - P.DotVV(i, i));
};
r.prototype.Validate = function() {
for (var t = 0; t < this.m_count; ++t) for (var e = t, i = (t + 1) % this.m_count, n = this.m_vertices[e], s = P.SubVV(this.m_vertices[i], n, r.Validate_s_e), o = 0; o < this.m_count; ++o) if (o !== e && o !== i) {
var a = P.SubVV(this.m_vertices[o], n, r.Validate_s_v);
if (P.CrossVV(s, a) < 0) return !1;
}
return !0;
};
r.prototype.SetupDistanceProxy = function(t, e) {
t.m_vertices = this.m_vertices;
t.m_count = this.m_count;
t.m_radius = this.m_radius;
};
r.prototype.ComputeSubmergedArea = function(t, e, i, s) {
for (var o = O.MulTRV(i.q, t, r.ComputeSubmergedArea_s_normalL), a = e - P.DotVV(t, i.p), c = r.ComputeSubmergedArea_s_depths, h = 0, l = -1, u = -1, _ = !1, f = 0; f < this.m_count; ++f) {
c[f] = P.DotVV(o, this.m_vertices[f]) - a;
var d = c[f] < -n;
if (f > 0) if (d) {
if (!_) {
l = f - 1;
h++;
}
} else if (_) {
u = f - 1;
h++;
}
_ = d;
}
switch (h) {
case 0:
if (_) {
var m = r.ComputeSubmergedArea_s_md;
this.ComputeMass(m, 1);
N.MulXV(i, m.center, s);
return m.mass;
}
return 0;

case 1:
-1 === l ? l = this.m_count - 1 : u = this.m_count - 1;
}
for (var p, v = (l + 1) % this.m_count, y = (u + 1) % this.m_count, g = (0 - c[l]) / (c[v] - c[l]), x = (0 - c[u]) / (c[y] - c[u]), C = r.ComputeSubmergedArea_s_intoVec.Set(this.m_vertices[l].x * (1 - g) + this.m_vertices[v].x * g, this.m_vertices[l].y * (1 - g) + this.m_vertices[v].y * g), A = r.ComputeSubmergedArea_s_outoVec.Set(this.m_vertices[u].x * (1 - x) + this.m_vertices[y].x * x, this.m_vertices[u].y * (1 - x) + this.m_vertices[y].y * x), b = 0, S = r.ComputeSubmergedArea_s_center.SetZero(), T = this.m_vertices[v], w = v; w !== y; ) {
p = (w = (w + 1) % this.m_count) === y ? A : this.m_vertices[w];
var E = .5 * ((T.x - C.x) * (p.y - C.y) - (T.y - C.y) * (p.x - C.x));
b += E;
S.x += E * (C.x + T.x + p.x) / 3;
S.y += E * (C.y + T.y + p.y) / 3;
T = p;
}
S.SelfMul(1 / b);
N.MulXV(i, S, s);
return b;
};
r.prototype.Dump = function(t) {
t("    const shape: b2PolygonShape = new b2PolygonShape();\n");
t("    const vs: b2Vec2[] = b2Vec2.MakeArray(%d);\n", a);
for (var e = 0; e < this.m_count; ++e) t("    vs[%d].Set(%.15f, %.15f);\n", e, this.m_vertices[e].x, this.m_vertices[e].y);
t("    shape.Set(vs, %d);\n", this.m_count);
};
r.ComputeCentroid = function(t, e, i) {
var n = i;
n.SetZero();
for (var s = 0, o = r.ComputeCentroid_s_pRef.SetZero(), a = 0; a < e; ++a) {
var c = o, h = t[a], l = t[(a + 1) % e], u = P.SubVV(h, c, r.ComputeCentroid_s_e1), _ = P.SubVV(l, c, r.ComputeCentroid_s_e2), f = .5 * P.CrossVV(u, _);
s += f;
n.x += f * (1 / 3) * (c.x + h.x + l.x);
n.y += f * (1 / 3) * (c.y + h.y + l.y);
}
n.SelfMul(1 / s);
return n;
};
r.Set_s_ps = P.MakeArray(a);
r.Set_s_hull = m(a);
r.Set_s_r = new P();
r.Set_s_v = new P();
r.TestPoint_s_pLocal = new P();
r.ComputeDistance_s_pLocal = new P();
r.ComputeDistance_s_normalForMaxDistance = new P();
r.ComputeDistance_s_minDistance = new P();
r.ComputeDistance_s_distance = new P();
r.RayCast_s_p1 = new P();
r.RayCast_s_p2 = new P();
r.RayCast_s_d = new P();
r.ComputeAABB_s_v = new P();
r.ComputeMass_s_center = new P();
r.ComputeMass_s_s = new P();
r.ComputeMass_s_e1 = new P();
r.ComputeMass_s_e2 = new P();
r.Validate_s_e = new P();
r.Validate_s_v = new P();
r.ComputeSubmergedArea_s_normalL = new P();
r.ComputeSubmergedArea_s_depths = m(a);
r.ComputeSubmergedArea_s_md = new Je();
r.ComputeSubmergedArea_s_intoVec = new P();
r.ComputeSubmergedArea_s_outoVec = new P();
r.ComputeSubmergedArea_s_center = new P();
r.ComputeCentroid_s_pRef = new P();
r.ComputeCentroid_s_e1 = new P();
r.ComputeCentroid_s_e2 = new P();
return r;
})(Ze), ei = (function(e) {
Qe(i, e);
function i() {
var i = e.call(this, t.b2ShapeType.e_edgeShape, l) || this;
i.m_vertex1 = new P();
i.m_vertex2 = new P();
i.m_vertex0 = new P();
i.m_vertex3 = new P();
i.m_hasVertex0 = !1;
i.m_hasVertex3 = !1;
return i;
}
i.prototype.Set = function(t, e) {
this.m_vertex1.Copy(t);
this.m_vertex2.Copy(e);
this.m_hasVertex0 = !1;
this.m_hasVertex3 = !1;
return this;
};
i.prototype.Clone = function() {
return new i().Copy(this);
};
i.prototype.Copy = function(t) {
e.prototype.Copy.call(this, 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;
};
i.prototype.GetChildCount = function() {
return 1;
};
i.prototype.TestPoint = function(t, e) {
return !1;
};
i.prototype.ComputeDistance = function(t, e, n, r) {
var s = N.MulXV(t, this.m_vertex1, i.ComputeDistance_s_v1), o = N.MulXV(t, this.m_vertex2, i.ComputeDistance_s_v2), a = P.SubVV(e, s, i.ComputeDistance_s_d), c = P.SubVV(o, s, i.ComputeDistance_s_s), h = P.DotVV(a, c);
if (h > 0) {
var l = P.DotVV(c, c);
h > l ? P.SubVV(e, o, a) : a.SelfMulSub(h / l, c);
}
n.Copy(a);
return n.Normalize();
};
i.prototype.RayCast = function(t, e, n, r) {
var s = N.MulTXV(n, e.p1, i.RayCast_s_p1), o = N.MulTXV(n, e.p2, i.RayCast_s_p2), a = P.SubVV(o, s, i.RayCast_s_d), c = this.m_vertex1, h = this.m_vertex2, l = P.SubVV(h, c, i.RayCast_s_e), u = t.normal.Set(l.y, -l.x).SelfNormalize(), _ = P.DotVV(u, P.SubVV(c, s, P.s_t0)), f = P.DotVV(u, a);
if (0 === f) return !1;
var d = _ / f;
if (d < 0 || e.maxFraction < d) return !1;
var m = P.AddVMulSV(s, d, a, i.RayCast_s_q), p = P.SubVV(h, c, i.RayCast_s_r), v = P.DotVV(p, p);
if (0 === v) return !1;
var y = P.DotVV(P.SubVV(m, c, P.s_t0), p) / v;
if (y < 0 || 1 < y) return !1;
t.fraction = d;
O.MulRV(n.q, t.normal, t.normal);
_ > 0 && t.normal.SelfNeg();
return !0;
};
i.prototype.ComputeAABB = function(t, e, n) {
var r = N.MulXV(e, this.m_vertex1, i.ComputeAABB_s_v1), s = N.MulXV(e, this.m_vertex2, i.ComputeAABB_s_v2);
P.MinV(r, s, t.lowerBound);
P.MaxV(r, s, t.upperBound);
var o = this.m_radius;
t.lowerBound.SelfSubXY(o, o);
t.upperBound.SelfAddXY(o, o);
};
i.prototype.ComputeMass = function(t, e) {
t.mass = 0;
P.MidVV(this.m_vertex1, this.m_vertex2, t.center);
t.I = 0;
};
i.prototype.SetupDistanceProxy = function(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;
};
i.prototype.ComputeSubmergedArea = function(t, e, i, n) {
n.SetZero();
return 0;
};
i.prototype.Dump = function(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);
};
i.ComputeDistance_s_v1 = new P();
i.ComputeDistance_s_v2 = new P();
i.ComputeDistance_s_d = new P();
i.ComputeDistance_s_s = new P();
i.RayCast_s_p1 = new P();
i.RayCast_s_p2 = new P();
i.RayCast_s_d = new P();
i.RayCast_s_e = new P();
i.RayCast_s_q = new P();
i.RayCast_s_r = new P();
i.ComputeAABB_s_v1 = new P();
i.ComputeAABB_s_v2 = new P();
return i;
})(Ze), ii = (function(e) {
Qe(i, e);
function i() {
var i = e.call(this, t.b2ShapeType.e_chainShape, l) || this;
i.m_vertices = [];
i.m_count = 0;
i.m_prevVertex = new P();
i.m_nextVertex = new P();
i.m_hasPrevVertex = !1;
i.m_hasNextVertex = !1;
return i;
}
i.prototype.CreateLoop = function(t, e, i) {
void 0 === e && (e = t.length);
void 0 === i && (i = 0);
if (e < 3) return this;
this.m_count = e + 1;
this.m_vertices = P.MakeArray(this.m_count);
for (var n = 0; n < e; ++n) this.m_vertices[n].Copy(t[i + n]);
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;
};
i.prototype.CreateChain = function(t, e, i) {
void 0 === e && (e = t.length);
void 0 === i && (i = 0);
this.m_count = e;
this.m_vertices = P.MakeArray(e);
for (var n = 0; n < e; ++n) this.m_vertices[n].Copy(t[i + n]);
this.m_hasPrevVertex = !1;
this.m_hasNextVertex = !1;
this.m_prevVertex.SetZero();
this.m_nextVertex.SetZero();
return this;
};
i.prototype.SetPrevVertex = function(t) {
this.m_prevVertex.Copy(t);
this.m_hasPrevVertex = !0;
return this;
};
i.prototype.SetNextVertex = function(t) {
this.m_nextVertex.Copy(t);
this.m_hasNextVertex = !0;
return this;
};
i.prototype.Clone = function() {
return new i().Copy(this);
};
i.prototype.Copy = function(t) {
e.prototype.Copy.call(this, t);
this.CreateChain(t.m_vertices, 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;
};
i.prototype.GetChildCount = function() {
return this.m_count - 1;
};
i.prototype.GetChildEdge = function(e, i) {
e.m_type = t.b2ShapeType.e_edgeShape;
e.m_radius = this.m_radius;
e.m_vertex1.Copy(this.m_vertices[i]);
e.m_vertex2.Copy(this.m_vertices[i + 1]);
if (i > 0) {
e.m_vertex0.Copy(this.m_vertices[i - 1]);
e.m_hasVertex0 = !0;
} else {
e.m_vertex0.Copy(this.m_prevVertex);
e.m_hasVertex0 = this.m_hasPrevVertex;
}
if (i < this.m_count - 2) {
e.m_vertex3.Copy(this.m_vertices[i + 2]);
e.m_hasVertex3 = !0;
} else {
e.m_vertex3.Copy(this.m_nextVertex);
e.m_hasVertex3 = this.m_hasNextVertex;
}
};
i.prototype.TestPoint = function(t, e) {
return !1;
};
i.prototype.ComputeDistance = function(t, e, n, r) {
var s = i.ComputeDistance_s_edgeShape;
this.GetChildEdge(s, r);
return s.ComputeDistance(t, e, n, 0);
};
i.prototype.RayCast = function(t, e, n, r) {
var s = i.RayCast_s_edgeShape;
s.m_vertex1.Copy(this.m_vertices[r]);
s.m_vertex2.Copy(this.m_vertices[(r + 1) % this.m_count]);
return s.RayCast(t, e, n, 0);
};
i.prototype.ComputeAABB = function(t, e, n) {
var r = this.m_vertices[n], s = this.m_vertices[(n + 1) % this.m_count], o = N.MulXV(e, r, i.ComputeAABB_s_v1), a = N.MulXV(e, s, i.ComputeAABB_s_v2);
P.MinV(o, a, t.lowerBound);
P.MaxV(o, a, t.upperBound);
};
i.prototype.ComputeMass = function(t, e) {
t.mass = 0;
t.center.SetZero();
t.I = 0;
};
i.prototype.SetupDistanceProxy = function(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;
};
i.prototype.ComputeSubmergedArea = function(t, e, i, n) {
n.SetZero();
return 0;
};
i.prototype.Dump = function(t) {
t("    const shape: b2ChainShape = new b2ChainShape();\n");
t("    const vs: b2Vec2[] = b2Vec2.MakeArray(%d);\n", a);
for (var e = 0; e < this.m_count; ++e) t("    vs[%d].Set(%.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 ei();
i.RayCast_s_edgeShape = new ei();
i.ComputeAABB_s_v1 = new P();
i.ComputeAABB_s_v2 = new P();
return i;
})(Ze), ni = (function() {
function t() {
this.categoryBits = 1;
this.maskBits = 65535;
this.groupIndex = 0;
}
t.prototype.Clone = function() {
return new t().Copy(this);
};
t.prototype.Copy = function(t) {
this.categoryBits = t.categoryBits;
this.maskBits = t.maskBits;
this.groupIndex = t.groupIndex || 0;
return this;
};
t.DEFAULT = new t();
return t;
})(), ri = (function() {
return function() {
this.userData = null;
this.friction = .2;
this.restitution = 0;
this.density = 0;
this.isSensor = !1;
this.filter = new ni();
};
})(), si = (function() {
return function(t) {
this.aabb = new wt();
this.childIndex = 0;
this.fixture = t;
};
})(), oi = (function() {
function t(t, e) {
this.m_density = 0;
this.m_next = null;
this.m_friction = 0;
this.m_restitution = 0;
this.m_proxies = [];
this.m_proxyCount = 0;
this.m_filter = new ni();
this.m_isSensor = !1;
this.m_userData = null;
this.m_body = e;
this.m_shape = t.shape.Clone();
}
t.prototype.GetType = function() {
return this.m_shape.GetType();
};
t.prototype.GetShape = function() {
return this.m_shape;
};
t.prototype.SetSensor = function(t) {
if (t !== this.m_isSensor) {
this.m_body.SetAwake(!0);
this.m_isSensor = t;
}
};
t.prototype.IsSensor = function() {
return this.m_isSensor;
};
t.prototype.SetFilterData = function(t) {
this.m_filter.Copy(t);
this.Refilter();
};
t.prototype.GetFilterData = function() {
return this.m_filter;
};
t.prototype.Refilter = function() {
for (var t = this.m_body.GetContactList(); t; ) {
var e = t.contact, i = e.GetFixtureA(), n = e.GetFixtureB();
i !== this && n !== this || e.FlagForFiltering();
t = t.next;
}
var r = this.m_body.GetWorld();
if (null !== r) for (var s = r.m_contactManager.m_broadPhase, o = 0; o < this.m_proxyCount; ++o) s.TouchProxy(this.m_proxies[o].treeNode);
};
t.prototype.GetBody = function() {
return this.m_body;
};
t.prototype.GetNext = function() {
return this.m_next;
};
t.prototype.GetUserData = function() {
return this.m_userData;
};
t.prototype.SetUserData = function(t) {
this.m_userData = t;
};
t.prototype.TestPoint = function(t) {
return this.m_shape.TestPoint(this.m_body.GetTransform(), t);
};
t.prototype.ComputeDistance = function(t, e, i) {
return this.m_shape.ComputeDistance(this.m_body.GetTransform(), t, e, i);
};
t.prototype.RayCast = function(t, e, i) {
return this.m_shape.RayCast(t, e, this.m_body.GetTransform(), i);
};
t.prototype.GetMassData = function(t) {
void 0 === t && (t = new Je());
this.m_shape.ComputeMass(t, this.m_density);
return t;
};
t.prototype.SetDensity = function(t) {
this.m_density = t;
};
t.prototype.GetDensity = function() {
return this.m_density;
};
t.prototype.GetFriction = function() {
return this.m_friction;
};
t.prototype.SetFriction = function(t) {
this.m_friction = t;
};
t.prototype.GetRestitution = function() {
return this.m_restitution;
};
t.prototype.SetRestitution = function(t) {
this.m_restitution = t;
};
t.prototype.GetAABB = function(t) {
return this.m_proxies[t].aabb;
};
t.prototype.Dump = function(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);
};
t.prototype.Create = function(t) {
var i = this;
this.m_userData = t.userData;
this.m_friction = e(t.friction, .2);
this.m_restitution = e(t.restitution, 0);
this.m_next = null;
this.m_filter.Copy(e(t.filter, ni.DEFAULT));
this.m_isSensor = e(t.isSensor, !1);
this.m_proxies = d(this.m_shape.GetChildCount(), (function(t) {
return new si(i);
}));
this.m_proxyCount = 0;
this.m_density = e(t.density, 0);
};
t.prototype.Destroy = function() {};
t.prototype.CreateProxies = function(t) {
var e = this.m_body.m_world.m_contactManager.m_broadPhase;
this.m_proxyCount = this.m_shape.GetChildCount();
for (var i = 0; i < this.m_proxyCount; ++i) {
var n = this.m_proxies[i] = new si(this);
this.m_shape.ComputeAABB(n.aabb, t, i);
n.treeNode = e.CreateProxy(n.aabb, n);
n.childIndex = i;
}
};
t.prototype.DestroyProxies = function() {
for (var t = this.m_body.m_world.m_contactManager.m_broadPhase, e = 0; e < this.m_proxyCount; ++e) {
var i = this.m_proxies[e];
delete i.treeNode.userData;
t.DestroyProxy(i.treeNode);
delete i.treeNode;
}
this.m_proxyCount = 0;
};
t.prototype.TouchProxies = function() {
for (var t = this.m_body.m_world.m_contactManager.m_broadPhase, e = this.m_proxyCount, i = 0; i < e; ++i) t.TouchProxy(this.m_proxies[i].treeNode);
};
t.prototype.Synchronize = function(e, i) {
if (0 !== this.m_proxyCount) for (var n = this.m_body.m_world.m_contactManager.m_broadPhase, r = 0; r < this.m_proxyCount; ++r) {
var s = this.m_proxies[r], o = t.Synchronize_s_aabb1, a = t.Synchronize_s_aabb2;
this.m_shape.ComputeAABB(o, e, r);
this.m_shape.ComputeAABB(a, i, r);
s.aabb.Combine2(o, a);
var c = P.SubVV(i.p, e.p, t.Synchronize_s_displacement);
n.MoveProxy(s.treeNode, s.aabb, c);
}
};
t.Synchronize_s_aabb1 = new wt();
t.Synchronize_s_aabb2 = new wt();
t.Synchronize_s_displacement = new P();
return t;
})();
(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 = {}));
var ai = (function() {
return function() {
this.type = t.b2BodyType.b2_staticBody;
this.position = new P(0, 0);
this.angle = 0;
this.linearVelocity = new P(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;
};
})(), ci = (function() {
function i(i, n) {
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 N();
this.m_xf0 = new N();
this.m_sweep = new k();
this.m_linearVelocity = new P();
this.m_angularVelocity = 0;
this.m_force = new P();
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 = e(i.bullet, !1);
this.m_fixedRotationFlag = e(i.fixedRotation, !1);
this.m_autoSleepFlag = e(i.allowSleep, !0);
this.m_awakeFlag = e(i.awake, !0);
this.m_activeFlag = e(i.active, !0);
this.m_world = n;
this.m_xf.p.Copy(e(i.position, P.ZERO));
this.m_xf.q.SetAngle(e(i.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(e(i.linearVelocity, P.ZERO));
this.m_angularVelocity = e(i.angularVelocity, 0);
this.m_linearDamping = e(i.linearDamping, 0);
this.m_angularDamping = e(i.angularDamping, 0);
this.m_gravityScale = e(i.gravityScale, 1);
this.m_force.SetZero();
this.m_torque = 0;
this.m_sleepTime = 0;
this.m_type = e(i.type, t.b2BodyType.b2_staticBody);
if (i.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 = i.userData;
this.m_fixtureList = null;
this.m_fixtureCount = 0;
this.m_controllerList = null;
this.m_controllerCount = 0;
}
i.prototype.CreateFixture = function(t, e) {
void 0 === e && (e = 0);
return t instanceof Ze ? this.CreateFixtureShapeDensity(t, e) : this.CreateFixtureDef(t);
};
i.prototype.CreateFixtureDef = function(t) {
if (this.m_world.IsLocked()) throw new Error();
var e = new oi(t, this);
e.Create(t);
this.m_activeFlag && e.CreateProxies(this.m_xf);
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;
};
i.prototype.CreateFixtureShapeDensity = function(t, e) {
void 0 === e && (e = 0);
var n = i.CreateFixtureShapeDensity_s_def;
n.shape = t;
n.density = e;
return this.CreateFixtureDef(n);
};
i.prototype.DestroyFixture = function(t) {
if (this.m_world.IsLocked()) throw new Error();
for (var e = this.m_fixtureList, i = null; 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;
}
for (var n = this.m_contactList; n; ) {
var r = n.contact;
n = n.next;
var s = r.GetFixtureA(), o = r.GetFixtureB();
t !== s && t !== o || this.m_world.m_contactManager.Destroy(r);
}
this.m_activeFlag && t.DestroyProxies();
t.m_next = null;
t.Destroy();
--this.m_fixtureCount;
this.ResetMassData();
};
i.prototype.SetTransformVec = function(t, e) {
this.SetTransformXY(t.x, t.y, e);
};
i.prototype.SetTransformXY = function(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);
N.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 (var n = this.m_fixtureList; n; n = n.m_next) n.Synchronize(this.m_xf, this.m_xf);
this.m_world.m_contactManager.FindNewContacts();
};
i.prototype.SetTransform = function(t) {
this.SetTransformVec(t.p, t.GetAngle());
};
i.prototype.GetTransform = function() {
return this.m_xf;
};
i.prototype.GetPosition = function() {
return this.m_xf.p;
};
i.prototype.SetPosition = function(t) {
this.SetTransformVec(t, this.GetAngle());
};
i.prototype.SetPositionXY = function(t, e) {
this.SetTransformXY(t, e, this.GetAngle());
};
i.prototype.GetAngle = function() {
return this.m_sweep.a;
};
i.prototype.SetAngle = function(t) {
this.SetTransformVec(this.GetPosition(), t);
};
i.prototype.GetWorldCenter = function() {
return this.m_sweep.c;
};
i.prototype.GetLocalCenter = function() {
return this.m_sweep.localCenter;
};
i.prototype.SetLinearVelocity = function(e) {
if (this.m_type !== t.b2BodyType.b2_staticBody) {
P.DotVV(e, e) > 0 && this.SetAwake(!0);
this.m_linearVelocity.Copy(e);
}
};
i.prototype.GetLinearVelocity = function() {
return this.m_linearVelocity;
};
i.prototype.SetAngularVelocity = function(e) {
if (this.m_type !== t.b2BodyType.b2_staticBody) {
e * e > 0 && this.SetAwake(!0);
this.m_angularVelocity = e;
}
};
i.prototype.GetAngularVelocity = function() {
return this.m_angularVelocity;
};
i.prototype.GetDefinition = function(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;
};
i.prototype.ApplyForce = function(e, i, n) {
void 0 === n && (n = !0);
if (this.m_type === t.b2BodyType.b2_dynamicBody) {
n && !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;
}
}
};
i.prototype.ApplyForceToCenter = function(e, i) {
void 0 === i && (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;
}
}
};
i.prototype.ApplyTorque = function(e, i) {
void 0 === i && (i = !0);
if (this.m_type === t.b2BodyType.b2_dynamicBody) {
i && !this.m_awakeFlag && this.SetAwake(!0);
this.m_awakeFlag && (this.m_torque += e);
}
};
i.prototype.ApplyLinearImpulse = function(e, i, n) {
void 0 === n && (n = !0);
if (this.m_type === t.b2BodyType.b2_dynamicBody) {
n && !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);
}
}
};
i.prototype.ApplyLinearImpulseToCenter = function(e, i) {
void 0 === i && (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;
}
}
};
i.prototype.ApplyAngularImpulse = function(e, i) {
void 0 === i && (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);
}
};
i.prototype.GetMass = function() {
return this.m_mass;
};
i.prototype.GetInertia = function() {
return this.m_I + this.m_mass * P.DotVV(this.m_sweep.localCenter, this.m_sweep.localCenter);
};
i.prototype.GetMassData = function(t) {
t.mass = this.m_mass;
t.I = this.m_I + this.m_mass * P.DotVV(this.m_sweep.localCenter, this.m_sweep.localCenter);
t.center.Copy(this.m_sweep.localCenter);
return t;
};
i.prototype.SetMassData = function(e) {
if (this.m_world.IsLocked()) throw new Error();
if (this.m_type === t.b2BodyType.b2_dynamicBody) {
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 * P.DotVV(e.center, e.center);
this.m_invI = 1 / this.m_I;
}
var n = i.SetMassData_s_oldCenter.Copy(this.m_sweep.c);
this.m_sweep.localCenter.Copy(e.center);
N.MulXV(this.m_xf, this.m_sweep.localCenter, this.m_sweep.c);
this.m_sweep.c0.Copy(this.m_sweep.c);
P.AddVCrossSV(this.m_linearVelocity, this.m_angularVelocity, P.SubVV(this.m_sweep.c, n, P.s_t0), this.m_linearVelocity);
}
};
i.prototype.ResetMassData = function() {
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) {
for (var e = i.ResetMassData_s_localCenter.SetZero(), n = this.m_fixtureList; n; n = n.m_next) if (0 !== n.m_density) {
var r = n.GetMassData(i.ResetMassData_s_massData);
this.m_mass += r.mass;
e.x += r.center.x * r.mass;
e.y += r.center.y * r.mass;
this.m_I += r.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 * P.DotVV(e, e);
this.m_invI = 1 / this.m_I;
} else {
this.m_I = 0;
this.m_invI = 0;
}
var s = i.ResetMassData_s_oldCenter.Copy(this.m_sweep.c);
this.m_sweep.localCenter.Copy(e);
N.MulXV(this.m_xf, this.m_sweep.localCenter, this.m_sweep.c);
this.m_sweep.c0.Copy(this.m_sweep.c);
P.AddVCrossSV(this.m_linearVelocity, this.m_angularVelocity, P.SubVV(this.m_sweep.c, s, P.s_t0), this.m_linearVelocity);
} else {
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;
}
};
i.prototype.GetWorldPoint = function(t, e) {
return N.MulXV(this.m_xf, t, e);
};
i.prototype.GetWorldVector = function(t, e) {
return O.MulRV(this.m_xf.q, t, e);
};
i.prototype.GetLocalPoint = function(t, e) {
return N.MulTXV(this.m_xf, t, e);
};
i.prototype.GetLocalVector = function(t, e) {
return O.MulTRV(this.m_xf.q, t, e);
};
i.prototype.GetLinearVelocityFromWorldPoint = function(t, e) {
return P.AddVCrossSV(this.m_linearVelocity, this.m_angularVelocity, P.SubVV(t, this.m_sweep.c, P.s_t0), e);
};
i.prototype.GetLinearVelocityFromLocalPoint = function(t, e) {
return this.GetLinearVelocityFromWorldPoint(this.GetWorldPoint(t, e), e);
};
i.prototype.GetLinearDamping = function() {
return this.m_linearDamping;
};
i.prototype.SetLinearDamping = function(t) {
this.m_linearDamping = t;
};
i.prototype.GetAngularDamping = function() {
return this.m_angularDamping;
};
i.prototype.SetAngularDamping = function(t) {
this.m_angularDamping = t;
};
i.prototype.GetGravityScale = function() {
return this.m_gravityScale;
};
i.prototype.SetGravityScale = function(t) {
this.m_gravityScale = t;
};
i.prototype.SetType = function(e) {
if (this.m_world.IsLocked()) throw new Error();
if (this.m_type !== e) {
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;
for (var i = this.m_contactList; i; ) {
var n = i;
i = i.next;
this.m_world.m_contactManager.Destroy(n.contact);
}
this.m_contactList = null;
for (var r = this.m_fixtureList; r; r = r.m_next) r.TouchProxies();
}
};
i.prototype.GetType = function() {
return this.m_type;
};
i.prototype.SetBullet = function(t) {
this.m_bulletFlag = t;
};
i.prototype.IsBullet = function() {
return this.m_bulletFlag;
};
i.prototype.SetSleepingAllowed = function(t) {
this.m_autoSleepFlag = t;
t || this.SetAwake(!0);
};
i.prototype.IsSleepingAllowed = function() {
return this.m_autoSleepFlag;
};
i.prototype.SetAwake = function(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;
}
};
i.prototype.IsAwake = function() {
return this.m_awakeFlag;
};
i.prototype.SetActive = function(t) {
if (this.m_world.IsLocked()) throw new Error();
if (t !== this.IsActive()) {
this.m_activeFlag = t;
if (t) for (var e = this.m_fixtureList; e; e = e.m_next) e.CreateProxies(this.m_xf); else {
for (e = this.m_fixtureList; e; e = e.m_next) e.DestroyProxies();
for (var i = this.m_contactList; i; ) {
var n = i;
i = i.next;
this.m_world.m_contactManager.Destroy(n.contact);
}
this.m_contactList = null;
}
}
};
i.prototype.IsActive = function() {
return this.m_activeFlag;
};
i.prototype.SetFixedRotation = function(t) {
if (this.m_fixedRotationFlag !== t) {
this.m_fixedRotationFlag = t;
this.m_angularVelocity = 0;
this.ResetMassData();
}
};
i.prototype.IsFixedRotation = function() {
return this.m_fixedRotationFlag;
};
i.prototype.GetFixtureList = function() {
return this.m_fixtureList;
};
i.prototype.GetJointList = function() {
return this.m_jointList;
};
i.prototype.GetContactList = function() {
return this.m_contactList;
};
i.prototype.GetNext = function() {
return this.m_next;
};
i.prototype.GetUserData = function() {
return this.m_userData;
};
i.prototype.SetUserData = function(t) {
this.m_userData = t;
};
i.prototype.GetWorld = function() {
return this.m_world;
};
i.prototype.Dump = function(e) {
var i = this.m_islandIndex;
e("{\n");
e("  const bd: b2BodyDef = new b2BodyDef();\n");
var n = "";
switch (this.m_type) {
case t.b2BodyType.b2_staticBody:
n = "b2BodyType.b2_staticBody";
break;

case t.b2BodyType.b2_kinematicBody:
n = "b2BodyType.b2_kinematicBody";
break;

case t.b2BodyType.b2_dynamicBody:
n = "b2BodyType.b2_dynamicBody";
}
e("  bd.type = %s;\n", n);
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 (var r = this.m_fixtureList; r; r = r.m_next) {
e("  {\n");
r.Dump(e, i);
e("  }\n");
}
e("}\n");
};
i.prototype.SynchronizeFixtures = function() {
var t = i.SynchronizeFixtures_s_xf1;
t.q.SetAngle(this.m_sweep.a0);
O.MulRV(t.q, this.m_sweep.localCenter, t.p);
P.SubVV(this.m_sweep.c0, t.p, t.p);
for (var e = this.m_fixtureList; e; e = e.m_next) e.Synchronize(t, this.m_xf);
};
i.prototype.SynchronizeTransform = function() {
this.m_xf.q.SetAngle(this.m_sweep.a);
O.MulRV(this.m_xf.q, this.m_sweep.localCenter, this.m_xf.p);
P.SubVV(this.m_sweep.c, this.m_xf.p, this.m_xf.p);
};
i.prototype.ShouldCollide = function(e) {
return (this.m_type !== t.b2BodyType.b2_staticBody || e.m_type !== t.b2BodyType.b2_staticBody) && this.ShouldCollideConnected(e);
};
i.prototype.ShouldCollideConnected = function(t) {
for (var e = this.m_jointList; e; e = e.next) if (e.other === t && !e.joint.m_collideConnected) return !1;
return !0;
};
i.prototype.Advance = function(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);
O.MulRV(this.m_xf.q, this.m_sweep.localCenter, this.m_xf.p);
P.SubVV(this.m_sweep.c, this.m_xf.p, this.m_xf.p);
};
i.prototype.GetControllerList = function() {
return this.m_controllerList;
};
i.prototype.GetControllerCount = function() {
return this.m_controllerCount;
};
i.CreateFixtureShapeDensity_s_def = new ri();
i.SetMassData_s_oldCenter = new P();
i.ResetMassData_s_localCenter = new P();
i.ResetMassData_s_oldCenter = new P();
i.ResetMassData_s_massData = new Je();
i.SynchronizeFixtures_s_xf1 = new N();
return i;
})();
(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 = {}));
var hi = (function() {
function t() {
this.linear = new P();
this.angularA = 0;
this.angularB = 0;
}
t.prototype.SetZero = function() {
this.linear.SetZero();
this.angularA = 0;
this.angularB = 0;
return this;
};
t.prototype.Set = function(t, e, i) {
this.linear.Copy(t);
this.angularA = e;
this.angularB = i;
return this;
};
return t;
})(), li = (function() {
return function(t, e) {
this.prev = null;
this.next = null;
this.joint = t;
this.other = e;
};
})(), ui = (function() {
return function(e) {
this.type = t.b2JointType.e_unknownJoint;
this.userData = null;
this.collideConnected = !1;
this.type = e;
};
})(), _i = (function() {
function i(i) {
this.m_type = t.b2JointType.e_unknownJoint;
this.m_prev = null;
this.m_next = null;
this.m_index = 0;
this.m_islandFlag = !1;
this.m_collideConnected = !1;
this.m_userData = null;
this.m_type = i.type;
this.m_edgeA = new li(this, i.bodyB);
this.m_edgeB = new li(this, i.bodyA);
this.m_bodyA = i.bodyA;
this.m_bodyB = i.bodyB;
this.m_collideConnected = e(i.collideConnected, !1);
this.m_userData = i.userData;
}
i.prototype.GetType = function() {
return this.m_type;
};
i.prototype.GetBodyA = function() {
return this.m_bodyA;
};
i.prototype.GetBodyB = function() {
return this.m_bodyB;
};
i.prototype.GetNext = function() {
return this.m_next;
};
i.prototype.GetUserData = function() {
return this.m_userData;
};
i.prototype.SetUserData = function(t) {
this.m_userData = t;
};
i.prototype.IsActive = function() {
return this.m_bodyA.IsActive() && this.m_bodyB.IsActive();
};
i.prototype.GetCollideConnected = function() {
return this.m_collideConnected;
};
i.prototype.Dump = function(t) {
t("// Dump is not supported for this joint type.\n");
};
i.prototype.ShiftOrigin = function(t) {};
return i;
})(), fi = (function(e) {
Qe(i, e);
function i() {
var i = e.call(this, t.b2JointType.e_distanceJoint) || this;
i.localAnchorA = new P();
i.localAnchorB = new P();
i.length = 1;
i.frequencyHz = 0;
i.dampingRatio = 0;
return i;
}
i.prototype.Initialize = function(t, e, i, n) {
this.bodyA = t;
this.bodyB = e;
this.bodyA.GetLocalPoint(i, this.localAnchorA);
this.bodyB.GetLocalPoint(n, this.localAnchorB);
this.length = P.DistanceVV(i, n);
this.frequencyHz = 0;
this.dampingRatio = 0;
};
return i;
})(ui), di = (function(t) {
Qe(i, t);
function i(i) {
var n = t.call(this, i) || this;
n.m_frequencyHz = 0;
n.m_dampingRatio = 0;
n.m_bias = 0;
n.m_localAnchorA = new P();
n.m_localAnchorB = new P();
n.m_gamma = 0;
n.m_impulse = 0;
n.m_length = 0;
n.m_indexA = 0;
n.m_indexB = 0;
n.m_u = new P();
n.m_rA = new P();
n.m_rB = new P();
n.m_localCenterA = new P();
n.m_localCenterB = new P();
n.m_invMassA = 0;
n.m_invMassB = 0;
n.m_invIA = 0;
n.m_invIB = 0;
n.m_mass = 0;
n.m_qA = new O();
n.m_qB = new O();
n.m_lalcA = new P();
n.m_lalcB = new P();
n.m_frequencyHz = e(i.frequencyHz, 0);
n.m_dampingRatio = e(i.dampingRatio, 0);
n.m_localAnchorA.Copy(i.localAnchorA);
n.m_localAnchorB.Copy(i.localAnchorB);
n.m_length = i.length;
return n;
}
i.prototype.GetAnchorA = function(t) {
return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, t);
};
i.prototype.GetAnchorB = function(t) {
return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, t);
};
i.prototype.GetReactionForce = function(t, e) {
e.x = t * this.m_impulse * this.m_u.x;
e.y = t * this.m_impulse * this.m_u.y;
return e;
};
i.prototype.GetReactionTorque = function(t) {
return 0;
};
i.prototype.GetLocalAnchorA = function() {
return this.m_localAnchorA;
};
i.prototype.GetLocalAnchorB = function() {
return this.m_localAnchorB;
};
i.prototype.SetLength = function(t) {
this.m_length = t;
};
i.prototype.Length = function() {
return this.m_length;
};
i.prototype.SetFrequency = function(t) {
this.m_frequencyHz = t;
};
i.prototype.GetFrequency = function() {
return this.m_frequencyHz;
};
i.prototype.SetDampingRatio = function(t) {
this.m_dampingRatio = t;
};
i.prototype.GetDampingRatio = function() {
return this.m_dampingRatio;
};
i.prototype.Dump = function(t) {
var e = this.m_bodyA.m_islandIndex, 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);
};
i.prototype.InitVelocityConstraints = function(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;
var e = t.positions[this.m_indexA].c, n = t.positions[this.m_indexA].a, r = t.velocities[this.m_indexA].v, o = t.velocities[this.m_indexA].w, a = t.positions[this.m_indexB].c, h = t.positions[this.m_indexB].a, l = t.velocities[this.m_indexB].v, u = t.velocities[this.m_indexB].w, _ = this.m_qA.SetAngle(n), f = this.m_qB.SetAngle(h);
P.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA);
O.MulRV(_, this.m_lalcA, this.m_rA);
P.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB);
O.MulRV(f, this.m_lalcB, this.m_rB);
this.m_u.x = a.x + this.m_rB.x - e.x - this.m_rA.x;
this.m_u.y = a.y + this.m_rB.y - e.y - this.m_rA.y;
var d = this.m_u.Length();
d > c ? this.m_u.SelfMul(1 / d) : this.m_u.SetZero();
var m = P.CrossVV(this.m_rA, this.m_u), p = P.CrossVV(this.m_rB, this.m_u), v = this.m_invMassA + this.m_invIA * m * m + this.m_invMassB + this.m_invIB * p * p;
this.m_mass = 0 !== v ? 1 / v : 0;
if (this.m_frequencyHz > 0) {
var y = d - this.m_length, g = 2 * s * this.m_frequencyHz, x = 2 * this.m_mass * this.m_dampingRatio * g, C = this.m_mass * g * g, A = t.step.dt;
this.m_gamma = A * (x + A * C);
this.m_gamma = 0 !== this.m_gamma ? 1 / this.m_gamma : 0;
this.m_bias = y * A * C * this.m_gamma;
v += this.m_gamma;
this.m_mass = 0 !== v ? 1 / v : 0;
} else {
this.m_gamma = 0;
this.m_bias = 0;
}
if (t.step.warmStarting) {
this.m_impulse *= t.step.dtRatio;
var b = P.MulSV(this.m_impulse, this.m_u, i.InitVelocityConstraints_s_P);
r.SelfMulSub(this.m_invMassA, b);
o -= this.m_invIA * P.CrossVV(this.m_rA, b);
l.SelfMulAdd(this.m_invMassB, b);
u += this.m_invIB * P.CrossVV(this.m_rB, b);
} else this.m_impulse = 0;
t.velocities[this.m_indexA].w = o;
t.velocities[this.m_indexB].w = u;
};
i.prototype.SolveVelocityConstraints = function(t) {
var e = t.velocities[this.m_indexA].v, n = t.velocities[this.m_indexA].w, r = t.velocities[this.m_indexB].v, s = t.velocities[this.m_indexB].w, o = P.AddVCrossSV(e, n, this.m_rA, i.SolveVelocityConstraints_s_vpA), a = P.AddVCrossSV(r, s, this.m_rB, i.SolveVelocityConstraints_s_vpB), c = P.DotVV(this.m_u, P.SubVV(a, o, P.s_t0)), h = -this.m_mass * (c + this.m_bias + this.m_gamma * this.m_impulse);
this.m_impulse += h;
var l = P.MulSV(h, this.m_u, i.SolveVelocityConstraints_s_P);
e.SelfMulSub(this.m_invMassA, l);
n -= this.m_invIA * P.CrossVV(this.m_rA, l);
r.SelfMulAdd(this.m_invMassB, l);
s += this.m_invIB * P.CrossVV(this.m_rB, l);
t.velocities[this.m_indexA].w = n;
t.velocities[this.m_indexB].w = s;
};
i.prototype.SolvePositionConstraints = function(t) {
if (this.m_frequencyHz > 0) return !0;
var e = t.positions[this.m_indexA].c, n = t.positions[this.m_indexA].a, r = t.positions[this.m_indexB].c, s = t.positions[this.m_indexB].a, o = this.m_qA.SetAngle(n), a = this.m_qB.SetAngle(s), h = O.MulRV(o, this.m_lalcA, this.m_rA), l = O.MulRV(a, this.m_lalcB, this.m_rB), u = this.m_u;
u.x = r.x + l.x - e.x - h.x;
u.y = r.y + l.y - e.y - h.y;
var _ = this.m_u.Normalize() - this.m_length;
_ = C(_, -.2, .2);
var f = -this.m_mass * _, d = P.MulSV(f, u, i.SolvePositionConstraints_s_P);
e.SelfMulSub(this.m_invMassA, d);
n -= this.m_invIA * P.CrossVV(h, d);
r.SelfMulAdd(this.m_invMassB, d);
s += this.m_invIB * P.CrossVV(l, d);
t.positions[this.m_indexA].a = n;
t.positions[this.m_indexB].a = s;
return y(_) < c;
};
i.InitVelocityConstraints_s_P = new P();
i.SolveVelocityConstraints_s_vpA = new P();
i.SolveVelocityConstraints_s_vpB = new P();
i.SolveVelocityConstraints_s_P = new P();
i.SolvePositionConstraints_s_P = new P();
return i;
})(_i), mi = (function(e) {
Qe(i, e);
function i() {
var i = e.call(this, t.b2JointType.e_areaJoint) || this;
i.bodies = [];
i.frequencyHz = 0;
i.dampingRatio = 0;
return i;
}
i.prototype.AddBody = function(t) {
this.bodies.push(t);
1 === this.bodies.length ? this.bodyA = t : 2 === this.bodies.length && (this.bodyB = t);
};
return i;
})(ui), pi = (function(t) {
Qe(i, t);
function i(i) {
var n = t.call(this, i) || this;
n.m_frequencyHz = 0;
n.m_dampingRatio = 0;
n.m_impulse = 0;
n.m_targetArea = 0;
n.m_bodies = i.bodies;
n.m_frequencyHz = e(i.frequencyHz, 0);
n.m_dampingRatio = e(i.dampingRatio, 0);
n.m_targetLengths = m(i.bodies.length);
n.m_normals = P.MakeArray(i.bodies.length);
n.m_joints = [];
n.m_deltas = P.MakeArray(i.bodies.length);
n.m_delta = new P();
var r = new fi();
r.frequencyHz = n.m_frequencyHz;
r.dampingRatio = n.m_dampingRatio;
n.m_targetArea = 0;
for (var s = 0; s < n.m_bodies.length; ++s) {
var o = n.m_bodies[s], a = n.m_bodies[(s + 1) % n.m_bodies.length], c = o.GetWorldCenter(), h = a.GetWorldCenter();
n.m_targetLengths[s] = P.DistanceVV(c, h);
n.m_targetArea += P.CrossVV(c, h);
r.Initialize(o, a, c, h);
n.m_joints[s] = o.GetWorld().CreateJoint(r);
}
n.m_targetArea *= .5;
return n;
}
i.prototype.GetAnchorA = function(t) {
return t;
};
i.prototype.GetAnchorB = function(t) {
return t;
};
i.prototype.GetReactionForce = function(t, e) {
return e;
};
i.prototype.GetReactionTorque = function(t) {
return 0;
};
i.prototype.SetFrequency = function(t) {
this.m_frequencyHz = t;
for (var e = 0; e < this.m_joints.length; ++e) this.m_joints[e].SetFrequency(t);
};
i.prototype.GetFrequency = function() {
return this.m_frequencyHz;
};
i.prototype.SetDampingRatio = function(t) {
this.m_dampingRatio = t;
for (var e = 0; e < this.m_joints.length; ++e) this.m_joints[e].SetDampingRatio(t);
};
i.prototype.GetDampingRatio = function() {
return this.m_dampingRatio;
};
i.prototype.Dump = function(t) {
t("Area joint dumping is not supported.\n");
};
i.prototype.InitVelocityConstraints = function(t) {
for (var e = 0; e < this.m_bodies.length; ++e) {
var i = this.m_bodies[(e + this.m_bodies.length - 1) % this.m_bodies.length], n = this.m_bodies[(e + 1) % this.m_bodies.length], r = t.positions[i.m_islandIndex].c, s = t.positions[n.m_islandIndex].c, o = this.m_deltas[e];
P.SubVV(s, r, o);
}
if (t.step.warmStarting) {
this.m_impulse *= t.step.dtRatio;
for (e = 0; e < this.m_bodies.length; ++e) {
var a = this.m_bodies[e], c = t.velocities[a.m_islandIndex].v;
o = this.m_deltas[e];
c.x += a.m_invMass * o.y * .5 * this.m_impulse;
c.y += a.m_invMass * -o.x * .5 * this.m_impulse;
}
} else this.m_impulse = 0;
};
i.prototype.SolveVelocityConstraints = function(t) {
for (var e = 0, i = 0, n = 0; n < this.m_bodies.length; ++n) {
var r = this.m_bodies[n], s = t.velocities[r.m_islandIndex].v;
e += (a = this.m_deltas[n]).LengthSquared() / r.GetMass();
i += P.CrossVV(s, a);
}
var o = -2 * i / e;
this.m_impulse += o;
for (n = 0; n < this.m_bodies.length; ++n) {
r = this.m_bodies[n], s = t.velocities[r.m_islandIndex].v;
var a = this.m_deltas[n];
s.x += r.m_invMass * a.y * .5 * o;
s.y += r.m_invMass * -a.x * .5 * o;
}
};
i.prototype.SolvePositionConstraints = function(t) {
for (var e = 0, i = 0, r = 0; r < this.m_bodies.length; ++r) {
var s = this.m_bodies[r], o = this.m_bodies[(r + 1) % this.m_bodies.length], a = t.positions[s.m_islandIndex].c, h = t.positions[o.m_islandIndex].c, l = (f = P.SubVV(h, a, this.m_delta)).Length();
l < n && (l = 1);
this.m_normals[r].x = f.y / l;
this.m_normals[r].y = -f.x / l;
e += l;
i += P.CrossVV(a, h);
}
i *= .5;
var u = .5 * (this.m_targetArea - i) / e, _ = !0;
for (r = 0; r < this.m_bodies.length; ++r) {
s = this.m_bodies[r], a = t.positions[s.m_islandIndex].c;
var f, d = (r + 1) % this.m_bodies.length;
(f = P.AddVV(this.m_normals[r], this.m_normals[d], this.m_delta)).SelfMul(u);
var m = f.LengthSquared();
m > b(.2) && f.SelfMul(.2 / T(m));
m > b(c) && (_ = !1);
a.x += f.x;
a.y += f.y;
}
return _;
};
return i;
})(_i), vi = (function(e) {
Qe(i, e);
function i() {
var i = e.call(this, t.b2JointType.e_frictionJoint) || this;
i.localAnchorA = new P();
i.localAnchorB = new P();
i.maxForce = 0;
i.maxTorque = 0;
return i;
}
i.prototype.Initialize = function(t, e, i) {
this.bodyA = t;
this.bodyB = e;
this.bodyA.GetLocalPoint(i, this.localAnchorA);
this.bodyB.GetLocalPoint(i, this.localAnchorB);
};
return i;
})(ui), yi = (function(t) {
Qe(i, t);
function i(i) {
var n = t.call(this, i) || this;
n.m_localAnchorA = new P();
n.m_localAnchorB = new P();
n.m_linearImpulse = new P();
n.m_angularImpulse = 0;
n.m_maxForce = 0;
n.m_maxTorque = 0;
n.m_indexA = 0;
n.m_indexB = 0;
n.m_rA = new P();
n.m_rB = new P();
n.m_localCenterA = new P();
n.m_localCenterB = new P();
n.m_invMassA = 0;
n.m_invMassB = 0;
n.m_invIA = 0;
n.m_invIB = 0;
n.m_linearMass = new F();
n.m_angularMass = 0;
n.m_qA = new O();
n.m_qB = new O();
n.m_lalcA = new P();
n.m_lalcB = new P();
n.m_K = new F();
n.m_localAnchorA.Copy(i.localAnchorA);
n.m_localAnchorB.Copy(i.localAnchorB);
n.m_linearImpulse.SetZero();
n.m_maxForce = e(i.maxForce, 0);
n.m_maxTorque = e(i.maxTorque, 0);
n.m_linearMass.SetZero();
return n;
}
i.prototype.InitVelocityConstraints = function(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;
var e = t.positions[this.m_indexA].a, i = t.velocities[this.m_indexA].v, n = t.velocities[this.m_indexA].w, r = t.positions[this.m_indexB].a, s = t.velocities[this.m_indexB].v, o = t.velocities[this.m_indexB].w, a = this.m_qA.SetAngle(e), c = this.m_qB.SetAngle(r);
P.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA);
var h = O.MulRV(a, this.m_lalcA, this.m_rA);
P.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB);
var l = O.MulRV(c, this.m_lalcB, this.m_rB), u = this.m_invMassA, _ = this.m_invMassB, f = this.m_invIA, d = this.m_invIB, m = this.m_K;
m.ex.x = u + _ + f * h.y * h.y + d * l.y * l.y;
m.ex.y = -f * h.x * h.y - d * l.x * l.y;
m.ey.x = m.ex.y;
m.ey.y = u + _ + f * h.x * h.x + d * l.x * l.x;
m.GetInverse(this.m_linearMass);
this.m_angularMass = f + d;
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;
var p = this.m_linearImpulse;
i.SelfMulSub(u, p);
n -= f * (P.CrossVV(this.m_rA, p) + this.m_angularImpulse);
s.SelfMulAdd(_, p);
o += d * (P.CrossVV(this.m_rB, p) + 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 = o;
};
i.prototype.SolveVelocityConstraints = function(t) {
var e = t.velocities[this.m_indexA].v, n = t.velocities[this.m_indexA].w, r = t.velocities[this.m_indexB].v, s = t.velocities[this.m_indexB].w, o = this.m_invMassA, a = this.m_invMassB, c = this.m_invIA, h = this.m_invIB, l = t.step.dt, u = s - n, _ = -this.m_angularMass * u, f = this.m_angularImpulse, d = l * this.m_maxTorque;
this.m_angularImpulse = C(this.m_angularImpulse + _, -d, d);
n -= c * (_ = this.m_angularImpulse - f);
s += h * _;
var m = P.SubVV(P.AddVCrossSV(r, s, this.m_rB, P.s_t0), P.AddVCrossSV(e, n, this.m_rA, P.s_t1), i.SolveVelocityConstraints_s_Cdot_v2), p = F.MulMV(this.m_linearMass, m, i.SolveVelocityConstraints_s_impulseV).SelfNeg(), v = i.SolveVelocityConstraints_s_oldImpulseV.Copy(this.m_linearImpulse);
this.m_linearImpulse.SelfAdd(p);
d = l * this.m_maxForce;
if (this.m_linearImpulse.LengthSquared() > d * d) {
this.m_linearImpulse.Normalize();
this.m_linearImpulse.SelfMul(d);
}
P.SubVV(this.m_linearImpulse, v, p);
e.SelfMulSub(o, p);
n -= c * P.CrossVV(this.m_rA, p);
r.SelfMulAdd(a, p);
s += h * P.CrossVV(this.m_rB, p);
t.velocities[this.m_indexA].w = n;
t.velocities[this.m_indexB].w = s;
};
i.prototype.SolvePositionConstraints = function(t) {
return !0;
};
i.prototype.GetAnchorA = function(t) {
return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, t);
};
i.prototype.GetAnchorB = function(t) {
return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, t);
};
i.prototype.GetReactionForce = function(t, e) {
e.x = t * this.m_linearImpulse.x;
e.y = t * this.m_linearImpulse.y;
return e;
};
i.prototype.GetReactionTorque = function(t) {
return t * this.m_angularImpulse;
};
i.prototype.GetLocalAnchorA = function() {
return this.m_localAnchorA;
};
i.prototype.GetLocalAnchorB = function() {
return this.m_localAnchorB;
};
i.prototype.SetMaxForce = function(t) {
this.m_maxForce = t;
};
i.prototype.GetMaxForce = function() {
return this.m_maxForce;
};
i.prototype.SetMaxTorque = function(t) {
this.m_maxTorque = t;
};
i.prototype.GetMaxTorque = function() {
return this.m_maxTorque;
};
i.prototype.Dump = function(t) {
var e = this.m_bodyA.m_islandIndex, 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);
};
i.SolveVelocityConstraints_s_Cdot_v2 = new P();
i.SolveVelocityConstraints_s_impulseV = new P();
i.SolveVelocityConstraints_s_oldImpulseV = new P();
return i;
})(_i), gi = (function(e) {
Qe(i, e);
function i() {
var i = e.call(this, t.b2JointType.e_gearJoint) || this;
i.ratio = 1;
return i;
}
return i;
})(ui), xi = (function(i) {
Qe(n, i);
function n(n) {
var r, s, o = i.call(this, n) || this;
o.m_typeA = t.b2JointType.e_unknownJoint;
o.m_typeB = t.b2JointType.e_unknownJoint;
o.m_localAnchorA = new P();
o.m_localAnchorB = new P();
o.m_localAnchorC = new P();
o.m_localAnchorD = new P();
o.m_localAxisC = new P();
o.m_localAxisD = new P();
o.m_referenceAngleA = 0;
o.m_referenceAngleB = 0;
o.m_constant = 0;
o.m_ratio = 0;
o.m_impulse = 0;
o.m_indexA = 0;
o.m_indexB = 0;
o.m_indexC = 0;
o.m_indexD = 0;
o.m_lcA = new P();
o.m_lcB = new P();
o.m_lcC = new P();
o.m_lcD = new P();
o.m_mA = 0;
o.m_mB = 0;
o.m_mC = 0;
o.m_mD = 0;
o.m_iA = 0;
o.m_iB = 0;
o.m_iC = 0;
o.m_iD = 0;
o.m_JvAC = new P();
o.m_JvBD = new P();
o.m_JwA = 0;
o.m_JwB = 0;
o.m_JwC = 0;
o.m_JwD = 0;
o.m_mass = 0;
o.m_qA = new O();
o.m_qB = new O();
o.m_qC = new O();
o.m_qD = new O();
o.m_lalcA = new P();
o.m_lalcB = new P();
o.m_lalcC = new P();
o.m_lalcD = new P();
o.m_joint1 = n.joint1;
o.m_joint2 = n.joint2;
o.m_typeA = o.m_joint1.GetType();
o.m_typeB = o.m_joint2.GetType();
o.m_bodyC = o.m_joint1.GetBodyA();
o.m_bodyA = o.m_joint1.GetBodyB();
var a = o.m_bodyA.m_xf, c = o.m_bodyA.m_sweep.a, h = o.m_bodyC.m_xf, l = o.m_bodyC.m_sweep.a;
if (o.m_typeA === t.b2JointType.e_revoluteJoint) {
var u = n.joint1;
o.m_localAnchorC.Copy(u.m_localAnchorA);
o.m_localAnchorA.Copy(u.m_localAnchorB);
o.m_referenceAngleA = u.m_referenceAngle;
o.m_localAxisC.SetZero();
r = c - l - o.m_referenceAngleA;
} else {
var _ = n.joint1;
o.m_localAnchorC.Copy(_.m_localAnchorA);
o.m_localAnchorA.Copy(_.m_localAnchorB);
o.m_referenceAngleA = _.m_referenceAngle;
o.m_localAxisC.Copy(_.m_localXAxisA);
var f = o.m_localAnchorC, d = O.MulTRV(h.q, P.AddVV(O.MulRV(a.q, o.m_localAnchorA, P.s_t0), P.SubVV(a.p, h.p, P.s_t1), P.s_t0), P.s_t0);
r = P.DotVV(P.SubVV(d, f, P.s_t0), o.m_localAxisC);
}
o.m_bodyD = o.m_joint2.GetBodyA();
o.m_bodyB = o.m_joint2.GetBodyB();
var m = o.m_bodyB.m_xf, p = o.m_bodyB.m_sweep.a, v = o.m_bodyD.m_xf, y = o.m_bodyD.m_sweep.a;
if (o.m_typeB === t.b2JointType.e_revoluteJoint) {
u = n.joint2;
o.m_localAnchorD.Copy(u.m_localAnchorA);
o.m_localAnchorB.Copy(u.m_localAnchorB);
o.m_referenceAngleB = u.m_referenceAngle;
o.m_localAxisD.SetZero();
s = p - y - o.m_referenceAngleB;
} else {
_ = n.joint2;
o.m_localAnchorD.Copy(_.m_localAnchorA);
o.m_localAnchorB.Copy(_.m_localAnchorB);
o.m_referenceAngleB = _.m_referenceAngle;
o.m_localAxisD.Copy(_.m_localXAxisA);
var g = o.m_localAnchorD, x = O.MulTRV(v.q, P.AddVV(O.MulRV(m.q, o.m_localAnchorB, P.s_t0), P.SubVV(m.p, v.p, P.s_t1), P.s_t0), P.s_t0);
s = P.DotVV(P.SubVV(x, g, P.s_t0), o.m_localAxisD);
}
o.m_ratio = e(n.ratio, 1);
o.m_constant = r + o.m_ratio * s;
o.m_impulse = 0;
return o;
}
n.prototype.InitVelocityConstraints = function(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;
var i = e.positions[this.m_indexA].a, r = e.velocities[this.m_indexA].v, s = e.velocities[this.m_indexA].w, o = e.positions[this.m_indexB].a, a = e.velocities[this.m_indexB].v, c = e.velocities[this.m_indexB].w, h = e.positions[this.m_indexC].a, l = e.velocities[this.m_indexC].v, u = e.velocities[this.m_indexC].w, _ = e.positions[this.m_indexD].a, f = e.velocities[this.m_indexD].v, d = e.velocities[this.m_indexD].w, m = this.m_qA.SetAngle(i), p = this.m_qB.SetAngle(o), v = this.m_qC.SetAngle(h), y = this.m_qD.SetAngle(_);
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 {
var g = O.MulRV(v, this.m_localAxisC, n.InitVelocityConstraints_s_u);
P.SubVV(this.m_localAnchorC, this.m_lcC, this.m_lalcC);
var x = O.MulRV(v, this.m_lalcC, n.InitVelocityConstraints_s_rC);
P.SubVV(this.m_localAnchorA, this.m_lcA, this.m_lalcA);
var C = O.MulRV(m, this.m_lalcA, n.InitVelocityConstraints_s_rA);
this.m_JvAC.Copy(g);
this.m_JwC = P.CrossVV(x, g);
this.m_JwA = P.CrossVV(C, g);
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 {
g = O.MulRV(y, this.m_localAxisD, n.InitVelocityConstraints_s_u);
P.SubVV(this.m_localAnchorD, this.m_lcD, this.m_lalcD);
var A = O.MulRV(y, this.m_lalcD, n.InitVelocityConstraints_s_rD);
P.SubVV(this.m_localAnchorB, this.m_lcB, this.m_lalcB);
var b = O.MulRV(p, this.m_lalcB, n.InitVelocityConstraints_s_rB);
P.MulSV(this.m_ratio, g, this.m_JvBD);
this.m_JwD = this.m_ratio * P.CrossVV(A, g);
this.m_JwB = this.m_ratio * P.CrossVV(b, g);
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) {
r.SelfMulAdd(this.m_mA * this.m_impulse, this.m_JvAC);
s += this.m_iA * this.m_impulse * this.m_JwA;
a.SelfMulAdd(this.m_mB * this.m_impulse, this.m_JvBD);
c += this.m_iB * this.m_impulse * this.m_JwB;
l.SelfMulSub(this.m_mC * this.m_impulse, this.m_JvAC);
u -= this.m_iC * this.m_impulse * this.m_JwC;
f.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 = s;
e.velocities[this.m_indexB].w = c;
e.velocities[this.m_indexC].w = u;
e.velocities[this.m_indexD].w = d;
};
n.prototype.SolveVelocityConstraints = function(t) {
var e = t.velocities[this.m_indexA].v, i = t.velocities[this.m_indexA].w, n = t.velocities[this.m_indexB].v, r = t.velocities[this.m_indexB].w, s = t.velocities[this.m_indexC].v, o = t.velocities[this.m_indexC].w, a = t.velocities[this.m_indexD].v, c = t.velocities[this.m_indexD].w, h = P.DotVV(this.m_JvAC, P.SubVV(e, s, P.s_t0)) + P.DotVV(this.m_JvBD, P.SubVV(n, a, P.s_t0));
h += this.m_JwA * i - this.m_JwC * o + (this.m_JwB * r - this.m_JwD * c);
var l = -this.m_mass * h;
this.m_impulse += l;
e.SelfMulAdd(this.m_mA * l, this.m_JvAC);
i += this.m_iA * l * this.m_JwA;
n.SelfMulAdd(this.m_mB * l, this.m_JvBD);
r += this.m_iB * l * this.m_JwB;
s.SelfMulSub(this.m_mC * l, this.m_JvAC);
o -= this.m_iC * l * this.m_JwC;
a.SelfMulSub(this.m_mD * l, this.m_JvBD);
c -= this.m_iD * l * this.m_JwD;
t.velocities[this.m_indexA].w = i;
t.velocities[this.m_indexB].w = r;
t.velocities[this.m_indexC].w = o;
t.velocities[this.m_indexD].w = c;
};
n.prototype.SolvePositionConstraints = function(e) {
var i, r, s, o, a, h, l = e.positions[this.m_indexA].c, u = e.positions[this.m_indexA].a, _ = e.positions[this.m_indexB].c, f = e.positions[this.m_indexB].a, d = e.positions[this.m_indexC].c, m = e.positions[this.m_indexC].a, p = e.positions[this.m_indexD].c, v = e.positions[this.m_indexD].a, y = this.m_qA.SetAngle(u), g = this.m_qB.SetAngle(f), x = this.m_qC.SetAngle(m), C = this.m_qD.SetAngle(v), A = this.m_JvAC, b = this.m_JvBD, S = 0;
if (this.m_typeA === t.b2JointType.e_revoluteJoint) {
A.SetZero();
s = 1;
a = 1;
S += this.m_iA + this.m_iC;
i = u - m - this.m_referenceAngleA;
} else {
var T = O.MulRV(x, this.m_localAxisC, n.SolvePositionConstraints_s_u), w = O.MulRV(x, this.m_lalcC, n.SolvePositionConstraints_s_rC), E = O.MulRV(y, this.m_lalcA, n.SolvePositionConstraints_s_rA);
A.Copy(T);
a = P.CrossVV(w, T);
s = P.CrossVV(E, T);
S += this.m_mC + this.m_mA + this.m_iC * a * a + this.m_iA * s * s;
var B = this.m_lalcC, M = O.MulTRV(x, P.AddVV(E, P.SubVV(l, d, P.s_t0), P.s_t0), P.s_t0);
i = P.DotVV(P.SubVV(M, B, P.s_t0), this.m_localAxisC);
}
if (this.m_typeB === t.b2JointType.e_revoluteJoint) {
b.SetZero();
o = this.m_ratio;
h = this.m_ratio;
S += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD);
r = f - v - this.m_referenceAngleB;
} else {
T = O.MulRV(C, this.m_localAxisD, n.SolvePositionConstraints_s_u);
var D = O.MulRV(C, this.m_lalcD, n.SolvePositionConstraints_s_rD), I = O.MulRV(g, this.m_lalcB, n.SolvePositionConstraints_s_rB);
P.MulSV(this.m_ratio, T, b);
h = this.m_ratio * P.CrossVV(D, T);
o = this.m_ratio * P.CrossVV(I, T);
S += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * h * h + this.m_iB * o * o;
var R = this.m_lalcD, L = O.MulTRV(C, P.AddVV(I, P.SubVV(_, p, P.s_t0), P.s_t0), P.s_t0);
r = P.DotVV(P.SubVV(L, R, P.s_t0), this.m_localAxisD);
}
var F = i + this.m_ratio * r - this.m_constant, V = 0;
S > 0 && (V = -F / S);
l.SelfMulAdd(this.m_mA * V, A);
u += this.m_iA * V * s;
_.SelfMulAdd(this.m_mB * V, b);
f += this.m_iB * V * o;
d.SelfMulSub(this.m_mC * V, A);
m -= this.m_iC * V * a;
p.SelfMulSub(this.m_mD * V, b);
v -= this.m_iD * V * h;
e.positions[this.m_indexA].a = u;
e.positions[this.m_indexB].a = f;
e.positions[this.m_indexC].a = m;
e.positions[this.m_indexD].a = v;
return 0 < c;
};
n.prototype.GetAnchorA = function(t) {
return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, t);
};
n.prototype.GetAnchorB = function(t) {
return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, t);
};
n.prototype.GetReactionForce = function(t, e) {
return P.MulSV(t * this.m_impulse, this.m_JvAC, e);
};
n.prototype.GetReactionTorque = function(t) {
return t * this.m_impulse * this.m_JwA;
};
n.prototype.GetJoint1 = function() {
return this.m_joint1;
};
n.prototype.GetJoint2 = function() {
return this.m_joint2;
};
n.prototype.GetRatio = function() {
return this.m_ratio;
};
n.prototype.SetRatio = function(t) {
this.m_ratio = t;
};
n.prototype.Dump = function(t) {
var e = this.m_bodyA.m_islandIndex, i = this.m_bodyB.m_islandIndex, n = this.m_joint1.m_index, r = 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", n);
t("  jd.joint2 = joints[%d];\n", r);
t("  jd.ratio = %.15f;\n", this.m_ratio);
t("  joints[%d] = this.m_world.CreateJoint(jd);\n", this.m_index);
};
n.InitVelocityConstraints_s_u = new P();
n.InitVelocityConstraints_s_rA = new P();
n.InitVelocityConstraints_s_rB = new P();
n.InitVelocityConstraints_s_rC = new P();
n.InitVelocityConstraints_s_rD = new P();
n.SolvePositionConstraints_s_u = new P();
n.SolvePositionConstraints_s_rA = new P();
n.SolvePositionConstraints_s_rB = new P();
n.SolvePositionConstraints_s_rC = new P();
n.SolvePositionConstraints_s_rD = new P();
return n;
})(_i), Ci = (function(e) {
Qe(i, e);
function i() {
var i = e.call(this, t.b2JointType.e_motorJoint) || this;
i.linearOffset = new P(0, 0);
i.angularOffset = 0;
i.maxForce = 1;
i.maxTorque = 1;
i.correctionFactor = .3;
return i;
}
i.prototype.Initialize = function(t, e) {
this.bodyA = t;
this.bodyB = e;
this.bodyA.GetLocalPoint(this.bodyB.GetPosition(), this.linearOffset);
var i = this.bodyA.GetAngle(), n = this.bodyB.GetAngle();
this.angularOffset = n - i;
};
return i;
})(ui), Ai = (function(t) {
Qe(i, t);
function i(i) {
var n = t.call(this, i) || this;
n.m_linearOffset = new P();
n.m_angularOffset = 0;
n.m_linearImpulse = new P();
n.m_angularImpulse = 0;
n.m_maxForce = 0;
n.m_maxTorque = 0;
n.m_correctionFactor = .3;
n.m_indexA = 0;
n.m_indexB = 0;
n.m_rA = new P();
n.m_rB = new P();
n.m_localCenterA = new P();
n.m_localCenterB = new P();
n.m_linearError = new P();
n.m_angularError = 0;
n.m_invMassA = 0;
n.m_invMassB = 0;
n.m_invIA = 0;
n.m_invIB = 0;
n.m_linearMass = new F();
n.m_angularMass = 0;
n.m_qA = new O();
n.m_qB = new O();
n.m_K = new F();
n.m_linearOffset.Copy(e(i.linearOffset, P.ZERO));
n.m_linearImpulse.SetZero();
n.m_maxForce = e(i.maxForce, 0);
n.m_maxTorque = e(i.maxTorque, 0);
n.m_correctionFactor = e(i.correctionFactor, .3);
return n;
}
i.prototype.GetAnchorA = function(t) {
var e = this.m_bodyA.GetPosition();
t.x = e.x;
t.y = e.y;
return t;
};
i.prototype.GetAnchorB = function(t) {
var e = this.m_bodyB.GetPosition();
t.x = e.x;
t.y = e.y;
return t;
};
i.prototype.GetReactionForce = function(t, e) {
return P.MulSV(t, this.m_linearImpulse, e);
};
i.prototype.GetReactionTorque = function(t) {
return t * this.m_angularImpulse;
};
i.prototype.SetLinearOffset = function(t) {
if (!P.IsEqualToV(t, this.m_linearOffset)) {
this.m_bodyA.SetAwake(!0);
this.m_bodyB.SetAwake(!0);
this.m_linearOffset.Copy(t);
}
};
i.prototype.GetLinearOffset = function() {
return this.m_linearOffset;
};
i.prototype.SetAngularOffset = function(t) {
if (t !== this.m_angularOffset) {
this.m_bodyA.SetAwake(!0);
this.m_bodyB.SetAwake(!0);
this.m_angularOffset = t;
}
};
i.prototype.GetAngularOffset = function() {
return this.m_angularOffset;
};
i.prototype.SetMaxForce = function(t) {
this.m_maxForce = t;
};
i.prototype.GetMaxForce = function() {
return this.m_maxForce;
};
i.prototype.SetMaxTorque = function(t) {
this.m_maxTorque = t;
};
i.prototype.GetMaxTorque = function() {
return this.m_maxTorque;
};
i.prototype.InitVelocityConstraints = function(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;
var e = t.positions[this.m_indexA].c, i = t.positions[this.m_indexA].a, n = t.velocities[this.m_indexA].v, r = t.velocities[this.m_indexA].w, s = t.positions[this.m_indexB].c, o = t.positions[this.m_indexB].a, a = t.velocities[this.m_indexB].v, c = t.velocities[this.m_indexB].w, h = this.m_qA.SetAngle(i), l = this.m_qB.SetAngle(o), u = O.MulRV(h, P.SubVV(this.m_linearOffset, this.m_localCenterA, P.s_t0), this.m_rA), _ = O.MulRV(l, P.NegV(this.m_localCenterB, P.s_t0), this.m_rB), f = this.m_invMassA, d = this.m_invMassB, m = this.m_invIA, p = this.m_invIB, v = this.m_K;
v.ex.x = f + d + m * u.y * u.y + p * _.y * _.y;
v.ex.y = -m * u.x * u.y - p * _.x * _.y;
v.ey.x = v.ex.y;
v.ey.y = f + d + m * u.x * u.x + p * _.x * _.x;
v.GetInverse(this.m_linearMass);
this.m_angularMass = m + p;
this.m_angularMass > 0 && (this.m_angularMass = 1 / this.m_angularMass);
P.SubVV(P.AddVV(s, _, P.s_t0), P.AddVV(e, u, P.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;
var y = this.m_linearImpulse;
n.SelfMulSub(f, y);
r -= m * (P.CrossVV(u, y) + this.m_angularImpulse);
a.SelfMulAdd(d, y);
c += p * (P.CrossVV(_, y) + this.m_angularImpulse);
} else {
this.m_linearImpulse.SetZero();
this.m_angularImpulse = 0;
}
t.velocities[this.m_indexA].w = r;
t.velocities[this.m_indexB].w = c;
};
i.prototype.SolveVelocityConstraints = function(t) {
var e = t.velocities[this.m_indexA].v, n = t.velocities[this.m_indexA].w, r = t.velocities[this.m_indexB].v, s = t.velocities[this.m_indexB].w, o = this.m_invMassA, a = this.m_invMassB, c = this.m_invIA, h = this.m_invIB, l = t.step.dt, u = t.step.inv_dt, _ = s - n + u * this.m_correctionFactor * this.m_angularError, f = -this.m_angularMass * _, d = this.m_angularImpulse, m = l * this.m_maxTorque;
this.m_angularImpulse = C(this.m_angularImpulse + f, -m, m);
n -= c * (f = this.m_angularImpulse - d);
s += h * f;
var p = this.m_rA, v = this.m_rB, y = P.AddVV(P.SubVV(P.AddVV(r, P.CrossSV(s, v, P.s_t0), P.s_t0), P.AddVV(e, P.CrossSV(n, p, P.s_t1), P.s_t1), P.s_t2), P.MulSV(u * this.m_correctionFactor, this.m_linearError, P.s_t3), i.SolveVelocityConstraints_s_Cdot_v2), g = F.MulMV(this.m_linearMass, y, i.SolveVelocityConstraints_s_impulse_v2).SelfNeg(), x = i.SolveVelocityConstraints_s_oldImpulse_v2.Copy(this.m_linearImpulse);
this.m_linearImpulse.SelfAdd(g);
m = l * this.m_maxForce;
if (this.m_linearImpulse.LengthSquared() > m * m) {
this.m_linearImpulse.Normalize();
this.m_linearImpulse.SelfMul(m);
}
P.SubVV(this.m_linearImpulse, x, g);
e.SelfMulSub(o, g);
n -= c * P.CrossVV(p, g);
r.SelfMulAdd(a, g);
s += h * P.CrossVV(v, g);
t.velocities[this.m_indexA].w = n;
t.velocities[this.m_indexB].w = s;
};
i.prototype.SolvePositionConstraints = function(t) {
return !0;
};
i.prototype.Dump = function(t) {
var e = this.m_bodyA.m_islandIndex, 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);
};
i.SolveVelocityConstraints_s_Cdot_v2 = new P();
i.SolveVelocityConstraints_s_impulse_v2 = new P();
i.SolveVelocityConstraints_s_oldImpulse_v2 = new P();
return i;
})(_i), bi = (function(e) {
Qe(i, e);
function i() {
var i = e.call(this, t.b2JointType.e_mouseJoint) || this;
i.target = new P();
i.maxForce = 0;
i.frequencyHz = 5;
i.dampingRatio = .7;
return i;
}
return i;
})(ui), Si = (function(t) {
Qe(i, t);
function i(i) {
var n = t.call(this, i) || this;
n.m_localAnchorB = new P();
n.m_targetA = new P();
n.m_frequencyHz = 0;
n.m_dampingRatio = 0;
n.m_beta = 0;
n.m_impulse = new P();
n.m_maxForce = 0;
n.m_gamma = 0;
n.m_indexA = 0;
n.m_indexB = 0;
n.m_rB = new P();
n.m_localCenterB = new P();
n.m_invMassB = 0;
n.m_invIB = 0;
n.m_mass = new F();
n.m_C = new P();
n.m_qB = new O();
n.m_lalcB = new P();
n.m_K = new F();
n.m_targetA.Copy(e(i.target, P.ZERO));
N.MulTXV(n.m_bodyB.GetTransform(), n.m_targetA, n.m_localAnchorB);
n.m_maxForce = e(i.maxForce, 0);
n.m_impulse.SetZero();
n.m_frequencyHz = e(i.frequencyHz, 0);
n.m_dampingRatio = e(i.dampingRatio, 0);
n.m_beta = 0;
n.m_gamma = 0;
return n;
}
i.prototype.SetTarget = function(t) {
this.m_bodyB.IsAwake() || this.m_bodyB.SetAwake(!0);
this.m_targetA.Copy(t);
};
i.prototype.GetTarget = function() {
return this.m_targetA;
};
i.prototype.SetMaxForce = function(t) {
this.m_maxForce = t;
};
i.prototype.GetMaxForce = function() {
return this.m_maxForce;
};
i.prototype.SetFrequency = function(t) {
this.m_frequencyHz = t;
};
i.prototype.GetFrequency = function() {
return this.m_frequencyHz;
};
i.prototype.SetDampingRatio = function(t) {
this.m_dampingRatio = t;
};
i.prototype.GetDampingRatio = function() {
return this.m_dampingRatio;
};
i.prototype.InitVelocityConstraints = function(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;
var e = t.positions[this.m_indexB].c, i = t.positions[this.m_indexB].a, n = t.velocities[this.m_indexB].v, r = t.velocities[this.m_indexB].w, o = this.m_qB.SetAngle(i), a = this.m_bodyB.GetMass(), c = 2 * s * this.m_frequencyHz, h = 2 * a * this.m_dampingRatio * c, l = a * (c * c), u = t.step.dt;
this.m_gamma = u * (h + u * l);
0 !== this.m_gamma && (this.m_gamma = 1 / this.m_gamma);
this.m_beta = u * l * this.m_gamma;
P.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB);
O.MulRV(o, this.m_lalcB, this.m_rB);
var _ = 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);
r *= .98;
if (t.step.warmStarting) {
this.m_impulse.SelfMul(t.step.dtRatio);
n.x += this.m_invMassB * this.m_impulse.x;
n.y += this.m_invMassB * this.m_impulse.y;
r += this.m_invIB * P.CrossVV(this.m_rB, this.m_impulse);
} else this.m_impulse.SetZero();
t.velocities[this.m_indexB].w = r;
};
i.prototype.SolveVelocityConstraints = function(t) {
var e = t.velocities[this.m_indexB].v, n = t.velocities[this.m_indexB].w, r = P.AddVCrossSV(e, n, this.m_rB, i.SolveVelocityConstraints_s_Cdot), s = F.MulMV(this.m_mass, P.AddVV(r, P.AddVV(this.m_C, P.MulSV(this.m_gamma, this.m_impulse, P.s_t0), P.s_t0), P.s_t0).SelfNeg(), i.SolveVelocityConstraints_s_impulse), o = i.SolveVelocityConstraints_s_oldImpulse.Copy(this.m_impulse);
this.m_impulse.SelfAdd(s);
var a = t.step.dt * this.m_maxForce;
this.m_impulse.LengthSquared() > a * a && this.m_impulse.SelfMul(a / this.m_impulse.Length());
P.SubVV(this.m_impulse, o, s);
e.SelfMulAdd(this.m_invMassB, s);
n += this.m_invIB * P.CrossVV(this.m_rB, s);
t.velocities[this.m_indexB].w = n;
};
i.prototype.SolvePositionConstraints = function(t) {
return !0;
};
i.prototype.GetAnchorA = function(t) {
t.x = this.m_targetA.x;
t.y = this.m_targetA.y;
return t;
};
i.prototype.GetAnchorB = function(t) {
return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, t);
};
i.prototype.GetReactionForce = function(t, e) {
return P.MulSV(t, this.m_impulse, e);
};
i.prototype.GetReactionTorque = function(t) {
return 0;
};
i.prototype.Dump = function(t) {
t("Mouse joint dumping is not supported.\n");
};
i.prototype.ShiftOrigin = function(t) {
this.m_targetA.SelfSub(t);
};
i.SolveVelocityConstraints_s_Cdot = new P();
i.SolveVelocityConstraints_s_impulse = new P();
i.SolveVelocityConstraints_s_oldImpulse = new P();
return i;
})(_i), Ti = (function(e) {
Qe(i, e);
function i() {
var i = e.call(this, t.b2JointType.e_prismaticJoint) || this;
i.localAnchorA = new P();
i.localAnchorB = new P();
i.localAxisA = new P(1, 0);
i.referenceAngle = 0;
i.enableLimit = !1;
i.lowerTranslation = 0;
i.upperTranslation = 0;
i.enableMotor = !1;
i.maxMotorForce = 0;
i.motorSpeed = 0;
return i;
}
i.prototype.Initialize = function(t, e, i, n) {
this.bodyA = t;
this.bodyB = e;
this.bodyA.GetLocalPoint(i, this.localAnchorA);
this.bodyB.GetLocalPoint(i, this.localAnchorB);
this.bodyA.GetLocalVector(n, this.localAxisA);
this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle();
};
return i;
})(ui), wi = (function(i) {
Qe(n, i);
function n(n) {
var r = i.call(this, n) || this;
r.m_localAnchorA = new P();
r.m_localAnchorB = new P();
r.m_localXAxisA = new P();
r.m_localYAxisA = new P();
r.m_referenceAngle = 0;
r.m_impulse = new L(0, 0, 0);
r.m_motorImpulse = 0;
r.m_lowerTranslation = 0;
r.m_upperTranslation = 0;
r.m_maxMotorForce = 0;
r.m_motorSpeed = 0;
r.m_enableLimit = !1;
r.m_enableMotor = !1;
r.m_limitState = t.b2LimitState.e_inactiveLimit;
r.m_indexA = 0;
r.m_indexB = 0;
r.m_localCenterA = new P();
r.m_localCenterB = new P();
r.m_invMassA = 0;
r.m_invMassB = 0;
r.m_invIA = 0;
r.m_invIB = 0;
r.m_axis = new P(0, 0);
r.m_perp = new P(0, 0);
r.m_s1 = 0;
r.m_s2 = 0;
r.m_a1 = 0;
r.m_a2 = 0;
r.m_K = new V();
r.m_K3 = new V();
r.m_K2 = new F();
r.m_motorMass = 0;
r.m_qA = new O();
r.m_qB = new O();
r.m_lalcA = new P();
r.m_lalcB = new P();
r.m_rA = new P();
r.m_rB = new P();
r.m_localAnchorA.Copy(e(n.localAnchorA, P.ZERO));
r.m_localAnchorB.Copy(e(n.localAnchorB, P.ZERO));
r.m_localXAxisA.Copy(e(n.localAxisA, new P(1, 0))).SelfNormalize();
P.CrossOneV(r.m_localXAxisA, r.m_localYAxisA);
r.m_referenceAngle = e(n.referenceAngle, 0);
r.m_lowerTranslation = e(n.lowerTranslation, 0);
r.m_upperTranslation = e(n.upperTranslation, 0);
r.m_maxMotorForce = e(n.maxMotorForce, 0);
r.m_motorSpeed = e(n.motorSpeed, 0);
r.m_enableLimit = e(n.enableLimit, !1);
r.m_enableMotor = e(n.enableMotor, !1);
return r;
}
n.prototype.InitVelocityConstraints = function(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;
var i = e.positions[this.m_indexA].c, r = e.positions[this.m_indexA].a, s = e.velocities[this.m_indexA].v, o = e.velocities[this.m_indexA].w, a = e.positions[this.m_indexB].c, h = e.positions[this.m_indexB].a, l = e.velocities[this.m_indexB].v, u = e.velocities[this.m_indexB].w, _ = this.m_qA.SetAngle(r), f = this.m_qB.SetAngle(h);
P.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA);
var d = O.MulRV(_, this.m_lalcA, this.m_rA);
P.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB);
var m = O.MulRV(f, this.m_lalcB, this.m_rB), p = P.AddVV(P.SubVV(a, i, P.s_t0), P.SubVV(m, d, P.s_t1), n.InitVelocityConstraints_s_d), v = this.m_invMassA, g = this.m_invMassB, x = this.m_invIA, C = this.m_invIB;
O.MulRV(_, this.m_localXAxisA, this.m_axis);
this.m_a1 = P.CrossVV(P.AddVV(p, d, P.s_t0), this.m_axis);
this.m_a2 = P.CrossVV(m, this.m_axis);
this.m_motorMass = v + g + x * this.m_a1 * this.m_a1 + C * this.m_a2 * this.m_a2;
this.m_motorMass > 0 && (this.m_motorMass = 1 / this.m_motorMass);
O.MulRV(_, this.m_localYAxisA, this.m_perp);
this.m_s1 = P.CrossVV(P.AddVV(p, d, P.s_t0), this.m_perp);
this.m_s2 = P.CrossVV(m, this.m_perp);
this.m_K.ex.x = v + g + x * this.m_s1 * this.m_s1 + C * this.m_s2 * this.m_s2;
this.m_K.ex.y = x * this.m_s1 + C * this.m_s2;
this.m_K.ex.z = x * this.m_s1 * this.m_a1 + C * this.m_s2 * this.m_a2;
this.m_K.ey.x = this.m_K.ex.y;
this.m_K.ey.y = x + C;
0 === this.m_K.ey.y && (this.m_K.ey.y = 1);
this.m_K.ey.z = x * this.m_a1 + C * 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 = v + g + x * this.m_a1 * this.m_a1 + C * this.m_a2 * this.m_a2;
if (this.m_enableLimit) {
var A = P.DotVV(this.m_axis, p);
if (y(this.m_upperTranslation - this.m_lowerTranslation) < 2 * c) this.m_limitState = t.b2LimitState.e_equalLimits; else if (A <= 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 (A >= 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;
var b = P.AddVV(P.MulSV(this.m_impulse.x, this.m_perp, P.s_t0), P.MulSV(this.m_motorImpulse + this.m_impulse.z, this.m_axis, P.s_t1), n.InitVelocityConstraints_s_P), S = this.m_impulse.x * this.m_s1 + this.m_impulse.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_a1, T = this.m_impulse.x * this.m_s2 + this.m_impulse.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_a2;
s.SelfMulSub(v, b);
o -= x * S;
l.SelfMulAdd(g, b);
u += C * T;
} else {
this.m_impulse.SetZero();
this.m_motorImpulse = 0;
}
e.velocities[this.m_indexA].w = o;
e.velocities[this.m_indexB].w = u;
};
n.prototype.SolveVelocityConstraints = function(e) {
var i = e.velocities[this.m_indexA].v, r = e.velocities[this.m_indexA].w, s = e.velocities[this.m_indexB].v, o = e.velocities[this.m_indexB].w, a = this.m_invMassA, c = this.m_invMassB, h = this.m_invIA, l = this.m_invIB;
if (this.m_enableMotor && this.m_limitState !== t.b2LimitState.e_equalLimits) {
var u = P.DotVV(this.m_axis, P.SubVV(s, i, P.s_t0)) + this.m_a2 * o - this.m_a1 * r, _ = this.m_motorMass * (this.m_motorSpeed - u), f = this.m_motorImpulse, d = e.step.dt * this.m_maxMotorForce;
this.m_motorImpulse = C(this.m_motorImpulse + _, -d, d);
_ = this.m_motorImpulse - f;
var m = P.MulSV(_, this.m_axis, n.SolveVelocityConstraints_s_P), p = _ * this.m_a1, v = _ * this.m_a2;
i.SelfMulSub(a, m);
r -= h * p;
s.SelfMulAdd(c, m);
o += l * v;
}
var y = P.DotVV(this.m_perp, P.SubVV(s, i, P.s_t0)) + this.m_s2 * o - this.m_s1 * r, A = o - r;
if (this.m_enableLimit && this.m_limitState !== t.b2LimitState.e_inactiveLimit) {
var b = P.DotVV(this.m_axis, P.SubVV(s, i, P.s_t0)) + this.m_a2 * o - this.m_a1 * r, S = n.SolveVelocityConstraints_s_f1.Copy(this.m_impulse), T = this.m_K.Solve33(-y, -A, -b, n.SolveVelocityConstraints_s_df3);
this.m_impulse.SelfAdd(T);
this.m_limitState === t.b2LimitState.e_atLowerLimit ? this.m_impulse.z = x(this.m_impulse.z, 0) : this.m_limitState === t.b2LimitState.e_atUpperLimit && (this.m_impulse.z = g(this.m_impulse.z, 0));
var w = -y - (this.m_impulse.z - S.z) * this.m_K.ez.x, E = -A - (this.m_impulse.z - S.z) * this.m_K.ez.y, B = this.m_K.Solve22(w, E, n.SolveVelocityConstraints_s_f2r);
B.x += S.x;
B.y += S.y;
this.m_impulse.x = B.x;
this.m_impulse.y = B.y;
T.x = this.m_impulse.x - S.x;
T.y = this.m_impulse.y - S.y;
T.z = this.m_impulse.z - S.z;
m = P.AddVV(P.MulSV(T.x, this.m_perp, P.s_t0), P.MulSV(T.z, this.m_axis, P.s_t1), n.SolveVelocityConstraints_s_P), 
p = T.x * this.m_s1 + T.y + T.z * this.m_a1, v = T.x * this.m_s2 + T.y + T.z * this.m_a2;
i.SelfMulSub(a, m);
r -= h * p;
s.SelfMulAdd(c, m);
o += l * v;
} else {
var M = this.m_K.Solve22(-y, -A, n.SolveVelocityConstraints_s_df2);
this.m_impulse.x += M.x;
this.m_impulse.y += M.y;
m = P.MulSV(M.x, this.m_perp, n.SolveVelocityConstraints_s_P), p = M.x * this.m_s1 + M.y, 
v = M.x * this.m_s2 + M.y;
i.SelfMulSub(a, m);
r -= h * p;
s.SelfMulAdd(c, m);
o += l * v;
}
e.velocities[this.m_indexA].w = r;
e.velocities[this.m_indexB].w = o;
};
n.prototype.SolvePositionConstraints = function(t) {
var e = t.positions[this.m_indexA].c, i = t.positions[this.m_indexA].a, r = t.positions[this.m_indexB].c, s = t.positions[this.m_indexB].a, o = this.m_qA.SetAngle(i), a = this.m_qB.SetAngle(s), l = this.m_invMassA, u = this.m_invMassB, _ = this.m_invIA, f = this.m_invIB, d = O.MulRV(o, this.m_lalcA, this.m_rA), m = O.MulRV(a, this.m_lalcB, this.m_rB), p = P.SubVV(P.AddVV(r, m, P.s_t0), P.AddVV(e, d, P.s_t1), n.SolvePositionConstraints_s_d), v = O.MulRV(o, this.m_localXAxisA, this.m_axis), g = P.CrossVV(P.AddVV(p, d, P.s_t0), v), A = P.CrossVV(m, v), b = O.MulRV(o, this.m_localYAxisA, this.m_perp), S = P.CrossVV(P.AddVV(p, d, P.s_t0), b), T = P.CrossVV(m, b), w = n.SolvePositionConstraints_s_impulse, E = P.DotVV(b, p), B = s - i - this.m_referenceAngle, M = y(E), D = y(B), I = !1, R = 0;
if (this.m_enableLimit) {
var L = P.DotVV(v, p);
if (y(this.m_upperTranslation - this.m_lowerTranslation) < 2 * c) {
R = C(L, -.2, .2);
M = x(M, y(L));
I = !0;
} else if (L <= this.m_lowerTranslation) {
R = C(L - this.m_lowerTranslation + c, -.2, 0);
M = x(M, this.m_lowerTranslation - L);
I = !0;
} else if (L >= this.m_upperTranslation) {
R = C(L - this.m_upperTranslation - c, 0, .2);
M = x(M, L - this.m_upperTranslation);
I = !0;
}
}
if (I) {
var F = l + u + _ * S * S + f * T * T, V = _ * S + f * T, N = _ * S * g + f * T * A;
0 === (U = _ + f) && (U = 1);
var k = _ * g + f * A, G = l + u + _ * g * g + f * A * A, z = this.m_K3;
z.ex.SetXYZ(F, V, N);
z.ey.SetXYZ(V, U, k);
z.ez.SetXYZ(N, k, G);
w = z.Solve33(-E, -B, -R, w);
} else {
var U;
F = l + u + _ * S * S + f * T * T, V = _ * S + f * T;
0 === (U = _ + f) && (U = 1);
var j = this.m_K2;
j.ex.Set(F, V);
j.ey.Set(V, U);
var H = j.Solve(-E, -B, n.SolvePositionConstraints_s_impulse1);
w.x = H.x;
w.y = H.y;
w.z = 0;
}
var W = P.AddVV(P.MulSV(w.x, b, P.s_t0), P.MulSV(w.z, v, P.s_t1), n.SolvePositionConstraints_s_P), q = w.x * S + w.y + w.z * g, X = w.x * T + w.y + w.z * A;
e.SelfMulSub(l, W);
i -= _ * q;
r.SelfMulAdd(u, W);
s += f * X;
t.positions[this.m_indexA].a = i;
t.positions[this.m_indexB].a = s;
return M <= c && D <= h;
};
n.prototype.GetAnchorA = function(t) {
return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, t);
};
n.prototype.GetAnchorB = function(t) {
return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, t);
};
n.prototype.GetReactionForce = function(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;
};
n.prototype.GetReactionTorque = function(t) {
return t * this.m_impulse.y;
};
n.prototype.GetLocalAnchorA = function() {
return this.m_localAnchorA;
};
n.prototype.GetLocalAnchorB = function() {
return this.m_localAnchorB;
};
n.prototype.GetLocalAxisA = function() {
return this.m_localXAxisA;
};
n.prototype.GetReferenceAngle = function() {
return this.m_referenceAngle;
};
n.prototype.GetJointTranslation = function() {
var t = this.m_bodyA.GetWorldPoint(this.m_localAnchorA, n.GetJointTranslation_s_pA), e = this.m_bodyB.GetWorldPoint(this.m_localAnchorB, n.GetJointTranslation_s_pB), i = P.SubVV(e, t, n.GetJointTranslation_s_d), r = this.m_bodyA.GetWorldVector(this.m_localXAxisA, n.GetJointTranslation_s_axis);
return P.DotVV(i, r);
};
n.prototype.GetJointSpeed = function() {
var t = this.m_bodyA, e = this.m_bodyB;
P.SubVV(this.m_localAnchorA, t.m_sweep.localCenter, this.m_lalcA);
var i = O.MulRV(t.m_xf.q, this.m_lalcA, this.m_rA);
P.SubVV(this.m_localAnchorB, e.m_sweep.localCenter, this.m_lalcB);
var n = O.MulRV(e.m_xf.q, this.m_lalcB, this.m_rB), r = P.AddVV(t.m_sweep.c, i, P.s_t0), s = P.AddVV(e.m_sweep.c, n, P.s_t1), o = P.SubVV(s, r, P.s_t2), a = t.GetWorldVector(this.m_localXAxisA, this.m_axis), c = t.m_linearVelocity, h = e.m_linearVelocity, l = t.m_angularVelocity, u = e.m_angularVelocity;
return P.DotVV(o, P.CrossSV(l, a, P.s_t0)) + P.DotVV(a, P.SubVV(P.AddVCrossSV(h, u, n, P.s_t0), P.AddVCrossSV(c, l, i, P.s_t1), P.s_t0));
};
n.prototype.IsLimitEnabled = function() {
return this.m_enableLimit;
};
n.prototype.EnableLimit = function(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;
}
};
n.prototype.GetLowerLimit = function() {
return this.m_lowerTranslation;
};
n.prototype.GetUpperLimit = function() {
return this.m_upperTranslation;
};
n.prototype.SetLimits = function(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;
}
};
n.prototype.IsMotorEnabled = function() {
return this.m_enableMotor;
};
n.prototype.EnableMotor = function(t) {
if (t !== this.m_enableMotor) {
this.m_bodyA.SetAwake(!0);
this.m_bodyB.SetAwake(!0);
this.m_enableMotor = t;
}
};
n.prototype.SetMotorSpeed = function(t) {
if (t !== this.m_motorSpeed) {
this.m_bodyA.SetAwake(!0);
this.m_bodyB.SetAwake(!0);
this.m_motorSpeed = t;
}
};
n.prototype.GetMotorSpeed = function() {
return this.m_motorSpeed;
};
n.prototype.SetMaxMotorForce = function(t) {
if (t !== this.m_maxMotorForce) {
this.m_bodyA.SetAwake(!0);
this.m_bodyB.SetAwake(!0);
this.m_maxMotorForce = t;
}
};
n.prototype.GetMaxMotorForce = function() {
return this.m_maxMotorForce;
};
n.prototype.GetMotorForce = function(t) {
return t * this.m_motorImpulse;
};
n.prototype.Dump = function(t) {
var e = this.m_bodyA.m_islandIndex, 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);
};
n.InitVelocityConstraints_s_d = new P();
n.InitVelocityConstraints_s_P = new P();
n.SolveVelocityConstraints_s_P = new P();
n.SolveVelocityConstraints_s_f2r = new P();
n.SolveVelocityConstraints_s_f1 = new L();
n.SolveVelocityConstraints_s_df3 = new L();
n.SolveVelocityConstraints_s_df2 = new P();
n.SolvePositionConstraints_s_d = new P();
n.SolvePositionConstraints_s_impulse = new L();
n.SolvePositionConstraints_s_impulse1 = new P();
n.SolvePositionConstraints_s_P = new P();
n.GetJointTranslation_s_pA = new P();
n.GetJointTranslation_s_pB = new P();
n.GetJointTranslation_s_d = new P();
n.GetJointTranslation_s_axis = new P();
return n;
})(_i), Ei = (function(e) {
Qe(i, e);
function i() {
var i = e.call(this, t.b2JointType.e_pulleyJoint) || this;
i.groundAnchorA = new P(-1, 1);
i.groundAnchorB = new P(1, 1);
i.localAnchorA = new P(-1, 0);
i.localAnchorB = new P(1, 0);
i.lengthA = 0;
i.lengthB = 0;
i.ratio = 1;
i.collideConnected = !0;
return i;
}
i.prototype.Initialize = function(t, e, i, n, r, s, o) {
this.bodyA = t;
this.bodyB = e;
this.groundAnchorA.Copy(i);
this.groundAnchorB.Copy(n);
this.bodyA.GetLocalPoint(r, this.localAnchorA);
this.bodyB.GetLocalPoint(s, this.localAnchorB);
this.lengthA = P.DistanceVV(r, i);
this.lengthB = P.DistanceVV(s, n);
this.ratio = o;
};
return i;
})(ui), Bi = (function(t) {
Qe(i, t);
function i(i) {
var n = t.call(this, i) || this;
n.m_groundAnchorA = new P();
n.m_groundAnchorB = new P();
n.m_lengthA = 0;
n.m_lengthB = 0;
n.m_localAnchorA = new P();
n.m_localAnchorB = new P();
n.m_constant = 0;
n.m_ratio = 0;
n.m_impulse = 0;
n.m_indexA = 0;
n.m_indexB = 0;
n.m_uA = new P();
n.m_uB = new P();
n.m_rA = new P();
n.m_rB = new P();
n.m_localCenterA = new P();
n.m_localCenterB = new P();
n.m_invMassA = 0;
n.m_invMassB = 0;
n.m_invIA = 0;
n.m_invIB = 0;
n.m_mass = 0;
n.m_qA = new O();
n.m_qB = new O();
n.m_lalcA = new P();
n.m_lalcB = new P();
n.m_groundAnchorA.Copy(e(i.groundAnchorA, new P(-1, 1)));
n.m_groundAnchorB.Copy(e(i.groundAnchorB, new P(1, 0)));
n.m_localAnchorA.Copy(e(i.localAnchorA, new P(-1, 0)));
n.m_localAnchorB.Copy(e(i.localAnchorB, new P(1, 0)));
n.m_lengthA = e(i.lengthA, 0);
n.m_lengthB = e(i.lengthB, 0);
n.m_ratio = e(i.ratio, 1);
n.m_constant = e(i.lengthA, 0) + n.m_ratio * e(i.lengthB, 0);
n.m_impulse = 0;
return n;
}
i.prototype.InitVelocityConstraints = function(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;
var e = t.positions[this.m_indexA].c, n = t.positions[this.m_indexA].a, r = t.velocities[this.m_indexA].v, s = t.velocities[this.m_indexA].w, o = t.positions[this.m_indexB].c, a = t.positions[this.m_indexB].a, h = t.velocities[this.m_indexB].v, l = t.velocities[this.m_indexB].w, u = this.m_qA.SetAngle(n), _ = this.m_qB.SetAngle(a);
P.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA);
O.MulRV(u, this.m_lalcA, this.m_rA);
P.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB);
O.MulRV(_, this.m_lalcB, this.m_rB);
this.m_uA.Copy(e).SelfAdd(this.m_rA).SelfSub(this.m_groundAnchorA);
this.m_uB.Copy(o).SelfAdd(this.m_rB).SelfSub(this.m_groundAnchorB);
var f = this.m_uA.Length(), d = this.m_uB.Length();
f > 10 * c ? this.m_uA.SelfMul(1 / f) : this.m_uA.SetZero();
d > 10 * c ? this.m_uB.SelfMul(1 / d) : this.m_uB.SetZero();
var m = P.CrossVV(this.m_rA, this.m_uA), p = P.CrossVV(this.m_rB, this.m_uB), v = this.m_invMassA + this.m_invIA * m * m, y = this.m_invMassB + this.m_invIB * p * p;
this.m_mass = v + this.m_ratio * this.m_ratio * y;
this.m_mass > 0 && (this.m_mass = 1 / this.m_mass);
if (t.step.warmStarting) {
this.m_impulse *= t.step.dtRatio;
var g = P.MulSV(-this.m_impulse, this.m_uA, i.InitVelocityConstraints_s_PA), x = P.MulSV(-this.m_ratio * this.m_impulse, this.m_uB, i.InitVelocityConstraints_s_PB);
r.SelfMulAdd(this.m_invMassA, g);
s += this.m_invIA * P.CrossVV(this.m_rA, g);
h.SelfMulAdd(this.m_invMassB, x);
l += this.m_invIB * P.CrossVV(this.m_rB, x);
} else this.m_impulse = 0;
t.velocities[this.m_indexA].w = s;
t.velocities[this.m_indexB].w = l;
};
i.prototype.SolveVelocityConstraints = function(t) {
var e = t.velocities[this.m_indexA].v, n = t.velocities[this.m_indexA].w, r = t.velocities[this.m_indexB].v, s = t.velocities[this.m_indexB].w, o = P.AddVCrossSV(e, n, this.m_rA, i.SolveVelocityConstraints_s_vpA), a = P.AddVCrossSV(r, s, this.m_rB, i.SolveVelocityConstraints_s_vpB), c = -P.DotVV(this.m_uA, o) - this.m_ratio * P.DotVV(this.m_uB, a), h = -this.m_mass * c;
this.m_impulse += h;
var l = P.MulSV(-h, this.m_uA, i.SolveVelocityConstraints_s_PA), u = P.MulSV(-this.m_ratio * h, this.m_uB, i.SolveVelocityConstraints_s_PB);
e.SelfMulAdd(this.m_invMassA, l);
n += this.m_invIA * P.CrossVV(this.m_rA, l);
r.SelfMulAdd(this.m_invMassB, u);
s += this.m_invIB * P.CrossVV(this.m_rB, u);
t.velocities[this.m_indexA].w = n;
t.velocities[this.m_indexB].w = s;
};
i.prototype.SolvePositionConstraints = function(t) {
var e = t.positions[this.m_indexA].c, n = t.positions[this.m_indexA].a, r = t.positions[this.m_indexB].c, s = t.positions[this.m_indexB].a, o = this.m_qA.SetAngle(n), a = this.m_qB.SetAngle(s);
P.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA);
var h = O.MulRV(o, this.m_lalcA, this.m_rA);
P.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB);
var l = O.MulRV(a, this.m_lalcB, this.m_rB), u = this.m_uA.Copy(e).SelfAdd(h).SelfSub(this.m_groundAnchorA), _ = this.m_uB.Copy(r).SelfAdd(l).SelfSub(this.m_groundAnchorB), f = u.Length(), d = _.Length();
f > 10 * c ? u.SelfMul(1 / f) : u.SetZero();
d > 10 * c ? _.SelfMul(1 / d) : _.SetZero();
var m = P.CrossVV(h, u), p = P.CrossVV(l, _), v = this.m_invMassA + this.m_invIA * m * m, g = this.m_invMassB + this.m_invIB * p * p, x = v + this.m_ratio * this.m_ratio * g;
x > 0 && (x = 1 / x);
var C = this.m_constant - f - this.m_ratio * d, A = y(C), b = -x * C, S = P.MulSV(-b, u, i.SolvePositionConstraints_s_PA), T = P.MulSV(-this.m_ratio * b, _, i.SolvePositionConstraints_s_PB);
e.SelfMulAdd(this.m_invMassA, S);
n += this.m_invIA * P.CrossVV(h, S);
r.SelfMulAdd(this.m_invMassB, T);
s += this.m_invIB * P.CrossVV(l, T);
t.positions[this.m_indexA].a = n;
t.positions[this.m_indexB].a = s;
return A < c;
};
i.prototype.GetAnchorA = function(t) {
return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, t);
};
i.prototype.GetAnchorB = function(t) {
return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, t);
};
i.prototype.GetReactionForce = function(t, e) {
e.x = t * this.m_impulse * this.m_uB.x;
e.y = t * this.m_impulse * this.m_uB.y;
return e;
};
i.prototype.GetReactionTorque = function(t) {
return 0;
};
i.prototype.GetGroundAnchorA = function() {
return this.m_groundAnchorA;
};
i.prototype.GetGroundAnchorB = function() {
return this.m_groundAnchorB;
};
i.prototype.GetLengthA = function() {
return this.m_lengthA;
};
i.prototype.GetLengthB = function() {
return this.m_lengthB;
};
i.prototype.GetRatio = function() {
return this.m_ratio;
};
i.prototype.GetCurrentLengthA = function() {
var t = this.m_bodyA.GetWorldPoint(this.m_localAnchorA, i.GetCurrentLengthA_s_p), e = this.m_groundAnchorA;
return P.DistanceVV(t, e);
};
i.prototype.GetCurrentLengthB = function() {
var t = this.m_bodyB.GetWorldPoint(this.m_localAnchorB, i.GetCurrentLengthB_s_p), e = this.m_groundAnchorB;
return P.DistanceVV(t, e);
};
i.prototype.Dump = function(t) {
var e = this.m_bodyA.m_islandIndex, 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);
};
i.prototype.ShiftOrigin = function(t) {
this.m_groundAnchorA.SelfSub(t);
this.m_groundAnchorB.SelfSub(t);
};
i.InitVelocityConstraints_s_PA = new P();
i.InitVelocityConstraints_s_PB = new P();
i.SolveVelocityConstraints_s_vpA = new P();
i.SolveVelocityConstraints_s_vpB = new P();
i.SolveVelocityConstraints_s_PA = new P();
i.SolveVelocityConstraints_s_PB = new P();
i.SolvePositionConstraints_s_PA = new P();
i.SolvePositionConstraints_s_PB = new P();
i.GetCurrentLengthA_s_p = new P();
i.GetCurrentLengthB_s_p = new P();
return i;
})(_i), Mi = (function(e) {
Qe(i, e);
function i() {
var i = e.call(this, t.b2JointType.e_revoluteJoint) || this;
i.localAnchorA = new P(0, 0);
i.localAnchorB = new P(0, 0);
i.referenceAngle = 0;
i.enableLimit = !1;
i.lowerAngle = 0;
i.upperAngle = 0;
i.enableMotor = !1;
i.motorSpeed = 0;
i.maxMotorTorque = 0;
return i;
}
i.prototype.Initialize = function(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();
};
return i;
})(ui), Di = (function(i) {
Qe(n, i);
function n(n) {
var r = i.call(this, n) || this;
r.m_localAnchorA = new P();
r.m_localAnchorB = new P();
r.m_impulse = new L();
r.m_motorImpulse = 0;
r.m_enableMotor = !1;
r.m_maxMotorTorque = 0;
r.m_motorSpeed = 0;
r.m_enableLimit = !1;
r.m_referenceAngle = 0;
r.m_lowerAngle = 0;
r.m_upperAngle = 0;
r.m_indexA = 0;
r.m_indexB = 0;
r.m_rA = new P();
r.m_rB = new P();
r.m_localCenterA = new P();
r.m_localCenterB = new P();
r.m_invMassA = 0;
r.m_invMassB = 0;
r.m_invIA = 0;
r.m_invIB = 0;
r.m_mass = new V();
r.m_motorMass = 0;
r.m_limitState = t.b2LimitState.e_inactiveLimit;
r.m_qA = new O();
r.m_qB = new O();
r.m_lalcA = new P();
r.m_lalcB = new P();
r.m_K = new F();
r.m_localAnchorA.Copy(e(n.localAnchorA, P.ZERO));
r.m_localAnchorB.Copy(e(n.localAnchorB, P.ZERO));
r.m_referenceAngle = e(n.referenceAngle, 0);
r.m_impulse.SetZero();
r.m_motorImpulse = 0;
r.m_lowerAngle = e(n.lowerAngle, 0);
r.m_upperAngle = e(n.upperAngle, 0);
r.m_maxMotorTorque = e(n.maxMotorTorque, 0);
r.m_motorSpeed = e(n.motorSpeed, 0);
r.m_enableLimit = e(n.enableLimit, !1);
r.m_enableMotor = e(n.enableMotor, !1);
r.m_limitState = t.b2LimitState.e_inactiveLimit;
return r;
}
n.prototype.InitVelocityConstraints = function(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;
var i = e.positions[this.m_indexA].a, r = e.velocities[this.m_indexA].v, s = e.velocities[this.m_indexA].w, o = e.positions[this.m_indexB].a, a = e.velocities[this.m_indexB].v, c = e.velocities[this.m_indexB].w, l = this.m_qA.SetAngle(i), u = this.m_qB.SetAngle(o);
P.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA);
O.MulRV(l, this.m_lalcA, this.m_rA);
P.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB);
O.MulRV(u, this.m_lalcB, this.m_rB);
var _ = this.m_invMassA, f = this.m_invMassB, d = this.m_invIA, m = this.m_invIB, p = d + m === 0;
this.m_mass.ex.x = _ + f + this.m_rA.y * this.m_rA.y * d + this.m_rB.y * this.m_rB.y * m;
this.m_mass.ey.x = -this.m_rA.y * this.m_rA.x * d - this.m_rB.y * this.m_rB.x * m;
this.m_mass.ez.x = -this.m_rA.y * d - this.m_rB.y * m;
this.m_mass.ex.y = this.m_mass.ey.x;
this.m_mass.ey.y = _ + f + this.m_rA.x * this.m_rA.x * d + this.m_rB.x * this.m_rB.x * m;
this.m_mass.ez.y = this.m_rA.x * d + this.m_rB.x * m;
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 + m;
this.m_motorMass = d + m;
this.m_motorMass > 0 && (this.m_motorMass = 1 / this.m_motorMass);
this.m_enableMotor && !p || (this.m_motorImpulse = 0);
if (this.m_enableLimit && !p) {
var v = o - i - this.m_referenceAngle;
if (y(this.m_upperAngle - this.m_lowerAngle) < 2 * h) this.m_limitState = t.b2LimitState.e_equalLimits; else if (v <= this.m_lowerAngle) {
this.m_limitState !== t.b2LimitState.e_atLowerLimit && (this.m_impulse.z = 0);
this.m_limitState = t.b2LimitState.e_atLowerLimit;
} else if (v >= 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;
var g = n.InitVelocityConstraints_s_P.Set(this.m_impulse.x, this.m_impulse.y);
r.SelfMulSub(_, g);
s -= d * (P.CrossVV(this.m_rA, g) + this.m_motorImpulse + this.m_impulse.z);
a.SelfMulAdd(f, g);
c += m * (P.CrossVV(this.m_rB, g) + this.m_motorImpulse + this.m_impulse.z);
} else {
this.m_impulse.SetZero();
this.m_motorImpulse = 0;
}
e.velocities[this.m_indexA].w = s;
e.velocities[this.m_indexB].w = c;
};
n.prototype.SolveVelocityConstraints = function(e) {
var i = e.velocities[this.m_indexA].v, r = e.velocities[this.m_indexA].w, s = e.velocities[this.m_indexB].v, o = e.velocities[this.m_indexB].w, a = this.m_invMassA, c = this.m_invMassB, h = this.m_invIA, l = this.m_invIB, u = h + l === 0;
if (this.m_enableMotor && this.m_limitState !== t.b2LimitState.e_equalLimits && !u) {
var _ = o - r - this.m_motorSpeed, f = -this.m_motorMass * _, d = this.m_motorImpulse, m = e.step.dt * this.m_maxMotorTorque;
this.m_motorImpulse = C(this.m_motorImpulse + f, -m, m);
r -= h * (f = this.m_motorImpulse - d);
o += l * f;
}
if (this.m_enableLimit && this.m_limitState !== t.b2LimitState.e_inactiveLimit && !u) {
var p = P.SubVV(P.AddVCrossSV(s, o, this.m_rB, P.s_t0), P.AddVCrossSV(i, r, this.m_rA, P.s_t1), n.SolveVelocityConstraints_s_Cdot1), v = o - r, y = this.m_mass.Solve33(p.x, p.y, v, n.SolveVelocityConstraints_s_impulse_v3).SelfNeg();
if (this.m_limitState === t.b2LimitState.e_equalLimits) this.m_impulse.SelfAdd(y); else if (this.m_limitState === t.b2LimitState.e_atLowerLimit) {
if (this.m_impulse.z + y.z < 0) {
var g = -p.x + this.m_impulse.z * this.m_mass.ez.x, x = -p.y + this.m_impulse.z * this.m_mass.ez.y, A = this.m_mass.Solve22(g, x, n.SolveVelocityConstraints_s_reduced_v2);
y.x = A.x;
y.y = A.y;
y.z = -this.m_impulse.z;
this.m_impulse.x += A.x;
this.m_impulse.y += A.y;
this.m_impulse.z = 0;
} else this.m_impulse.SelfAdd(y);
} else if (this.m_limitState === t.b2LimitState.e_atUpperLimit) {
if (this.m_impulse.z + y.z > 0) {
g = -p.x + this.m_impulse.z * this.m_mass.ez.x, x = -p.y + this.m_impulse.z * this.m_mass.ez.y, 
A = this.m_mass.Solve22(g, x, n.SolveVelocityConstraints_s_reduced_v2);
y.x = A.x;
y.y = A.y;
y.z = -this.m_impulse.z;
this.m_impulse.x += A.x;
this.m_impulse.y += A.y;
this.m_impulse.z = 0;
} else this.m_impulse.SelfAdd(y);
}
var b = n.SolveVelocityConstraints_s_P.Set(y.x, y.y);
i.SelfMulSub(a, b);
r -= h * (P.CrossVV(this.m_rA, b) + y.z);
s.SelfMulAdd(c, b);
o += l * (P.CrossVV(this.m_rB, b) + y.z);
} else {
var S = P.SubVV(P.AddVCrossSV(s, o, this.m_rB, P.s_t0), P.AddVCrossSV(i, r, this.m_rA, P.s_t1), n.SolveVelocityConstraints_s_Cdot_v2), T = this.m_mass.Solve22(-S.x, -S.y, n.SolveVelocityConstraints_s_impulse_v2);
this.m_impulse.x += T.x;
this.m_impulse.y += T.y;
i.SelfMulSub(a, T);
r -= h * P.CrossVV(this.m_rA, T);
s.SelfMulAdd(c, T);
o += l * P.CrossVV(this.m_rB, T);
}
e.velocities[this.m_indexA].w = r;
e.velocities[this.m_indexB].w = o;
};
n.prototype.SolvePositionConstraints = function(e) {
var i, r = e.positions[this.m_indexA].c, s = e.positions[this.m_indexA].a, o = e.positions[this.m_indexB].c, a = e.positions[this.m_indexB].a, l = this.m_qA.SetAngle(s), u = this.m_qB.SetAngle(a), _ = 0, f = this.m_invIA + this.m_invIB === 0;
if (this.m_enableLimit && this.m_limitState !== t.b2LimitState.e_inactiveLimit && !f) {
var d = a - s - this.m_referenceAngle, m = 0;
if (this.m_limitState === t.b2LimitState.e_equalLimits) {
var p = C(d - this.m_lowerAngle, -.13962634015955555, .13962634015955555);
m = -this.m_motorMass * p;
_ = y(p);
} else if (this.m_limitState === t.b2LimitState.e_atLowerLimit) {
_ = -(p = d - this.m_lowerAngle);
p = C(p + h, -.13962634015955555, 0);
m = -this.m_motorMass * p;
} else if (this.m_limitState === t.b2LimitState.e_atUpperLimit) {
_ = p = d - this.m_upperAngle;
p = C(p - h, 0, .13962634015955555);
m = -this.m_motorMass * p;
}
s -= this.m_invIA * m;
a += this.m_invIB * m;
}
l.SetAngle(s);
u.SetAngle(a);
P.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA);
var v = O.MulRV(l, this.m_lalcA, this.m_rA);
P.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB);
var g = O.MulRV(u, this.m_lalcB, this.m_rB), x = P.SubVV(P.AddVV(o, g, P.s_t0), P.AddVV(r, v, P.s_t1), n.SolvePositionConstraints_s_C_v2);
i = x.Length();
var A = this.m_invMassA, b = this.m_invMassB, S = this.m_invIA, T = this.m_invIB, w = this.m_K;
w.ex.x = A + b + S * v.y * v.y + T * g.y * g.y;
w.ex.y = -S * v.x * v.y - T * g.x * g.y;
w.ey.x = w.ex.y;
w.ey.y = A + b + S * v.x * v.x + T * g.x * g.x;
var E = w.Solve(x.x, x.y, n.SolvePositionConstraints_s_impulse).SelfNeg();
r.SelfMulSub(A, E);
s -= S * P.CrossVV(v, E);
o.SelfMulAdd(b, E);
a += T * P.CrossVV(g, E);
e.positions[this.m_indexA].a = s;
e.positions[this.m_indexB].a = a;
return i <= c && _ <= h;
};
n.prototype.GetAnchorA = function(t) {
return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, t);
};
n.prototype.GetAnchorB = function(t) {
return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, t);
};
n.prototype.GetReactionForce = function(t, e) {
e.x = t * this.m_impulse.x;
e.y = t * this.m_impulse.y;
return e;
};
n.prototype.GetReactionTorque = function(t) {
return t * this.m_impulse.z;
};
n.prototype.GetLocalAnchorA = function() {
return this.m_localAnchorA;
};
n.prototype.GetLocalAnchorB = function() {
return this.m_localAnchorB;
};
n.prototype.GetReferenceAngle = function() {
return this.m_referenceAngle;
};
n.prototype.GetJointAngle = function() {
return this.m_bodyB.m_sweep.a - this.m_bodyA.m_sweep.a - this.m_referenceAngle;
};
n.prototype.GetJointSpeed = function() {
return this.m_bodyB.m_angularVelocity - this.m_bodyA.m_angularVelocity;
};
n.prototype.IsMotorEnabled = function() {
return this.m_enableMotor;
};
n.prototype.EnableMotor = function(t) {
if (t !== this.m_enableMotor) {
this.m_bodyA.SetAwake(!0);
this.m_bodyB.SetAwake(!0);
this.m_enableMotor = t;
}
};
n.prototype.GetMotorTorque = function(t) {
return t * this.m_motorImpulse;
};
n.prototype.GetMotorSpeed = function() {
return this.m_motorSpeed;
};
n.prototype.SetMaxMotorTorque = function(t) {
if (t !== this.m_maxMotorTorque) {
this.m_bodyA.SetAwake(!0);
this.m_bodyB.SetAwake(!0);
this.m_maxMotorTorque = t;
}
};
n.prototype.GetMaxMotorTorque = function() {
return this.m_maxMotorTorque;
};
n.prototype.IsLimitEnabled = function() {
return this.m_enableLimit;
};
n.prototype.EnableLimit = function(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;
}
};
n.prototype.GetLowerLimit = function() {
return this.m_lowerAngle;
};
n.prototype.GetUpperLimit = function() {
return this.m_upperAngle;
};
n.prototype.SetLimits = function(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;
}
};
n.prototype.SetMotorSpeed = function(t) {
if (t !== this.m_motorSpeed) {
this.m_bodyA.SetAwake(!0);
this.m_bodyB.SetAwake(!0);
this.m_motorSpeed = t;
}
};
n.prototype.Dump = function(t) {
var e = this.m_bodyA.m_islandIndex, 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);
};
n.InitVelocityConstraints_s_P = new P();
n.SolveVelocityConstraints_s_P = new P();
n.SolveVelocityConstraints_s_Cdot_v2 = new P();
n.SolveVelocityConstraints_s_Cdot1 = new P();
n.SolveVelocityConstraints_s_impulse_v3 = new L();
n.SolveVelocityConstraints_s_reduced_v2 = new P();
n.SolveVelocityConstraints_s_impulse_v2 = new P();
n.SolvePositionConstraints_s_C_v2 = new P();
n.SolvePositionConstraints_s_impulse = new P();
return n;
})(_i), Ii = (function(e) {
Qe(i, e);
function i() {
var i = e.call(this, t.b2JointType.e_ropeJoint) || this;
i.localAnchorA = new P(-1, 0);
i.localAnchorB = new P(1, 0);
i.maxLength = 0;
return i;
}
return i;
})(ui), Pi = (function(i) {
Qe(n, i);
function n(n) {
var r = i.call(this, n) || this;
r.m_localAnchorA = new P();
r.m_localAnchorB = new P();
r.m_maxLength = 0;
r.m_length = 0;
r.m_impulse = 0;
r.m_indexA = 0;
r.m_indexB = 0;
r.m_u = new P();
r.m_rA = new P();
r.m_rB = new P();
r.m_localCenterA = new P();
r.m_localCenterB = new P();
r.m_invMassA = 0;
r.m_invMassB = 0;
r.m_invIA = 0;
r.m_invIB = 0;
r.m_mass = 0;
r.m_state = t.b2LimitState.e_inactiveLimit;
r.m_qA = new O();
r.m_qB = new O();
r.m_lalcA = new P();
r.m_lalcB = new P();
r.m_localAnchorA.Copy(e(n.localAnchorA, new P(-1, 0)));
r.m_localAnchorB.Copy(e(n.localAnchorB, new P(1, 0)));
r.m_maxLength = e(n.maxLength, 0);
return r;
}
n.prototype.InitVelocityConstraints = function(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;
var i = e.positions[this.m_indexA].c, r = e.positions[this.m_indexA].a, s = e.velocities[this.m_indexA].v, o = e.velocities[this.m_indexA].w, a = e.positions[this.m_indexB].c, h = e.positions[this.m_indexB].a, l = e.velocities[this.m_indexB].v, u = e.velocities[this.m_indexB].w, _ = this.m_qA.SetAngle(r), f = this.m_qB.SetAngle(h);
P.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA);
O.MulRV(_, this.m_lalcA, this.m_rA);
P.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB);
O.MulRV(f, this.m_lalcB, this.m_rB);
this.m_u.Copy(a).SelfAdd(this.m_rB).SelfSub(i).SelfSub(this.m_rA);
this.m_length = this.m_u.Length();
var d = this.m_length - this.m_maxLength;
this.m_state = d > 0 ? t.b2LimitState.e_atUpperLimit : t.b2LimitState.e_inactiveLimit;
if (this.m_length > c) {
this.m_u.SelfMul(1 / this.m_length);
var m = P.CrossVV(this.m_rA, this.m_u), p = P.CrossVV(this.m_rB, this.m_u), v = this.m_invMassA + this.m_invIA * m * m + this.m_invMassB + this.m_invIB * p * p;
this.m_mass = 0 !== v ? 1 / v : 0;
if (e.step.warmStarting) {
this.m_impulse *= e.step.dtRatio;
var y = P.MulSV(this.m_impulse, this.m_u, n.InitVelocityConstraints_s_P);
s.SelfMulSub(this.m_invMassA, y);
o -= this.m_invIA * P.CrossVV(this.m_rA, y);
l.SelfMulAdd(this.m_invMassB, y);
u += this.m_invIB * P.CrossVV(this.m_rB, y);
} else this.m_impulse = 0;
e.velocities[this.m_indexA].w = o;
e.velocities[this.m_indexB].w = u;
} else {
this.m_u.SetZero();
this.m_mass = 0;
this.m_impulse = 0;
}
};
n.prototype.SolveVelocityConstraints = function(t) {
var e = t.velocities[this.m_indexA].v, i = t.velocities[this.m_indexA].w, r = t.velocities[this.m_indexB].v, s = t.velocities[this.m_indexB].w, o = P.AddVCrossSV(e, i, this.m_rA, n.SolveVelocityConstraints_s_vpA), a = P.AddVCrossSV(r, s, this.m_rB, n.SolveVelocityConstraints_s_vpB), c = this.m_length - this.m_maxLength, h = P.DotVV(this.m_u, P.SubVV(a, o, P.s_t0));
c < 0 && (h += t.step.inv_dt * c);
var l = -this.m_mass * h, u = this.m_impulse;
this.m_impulse = g(0, this.m_impulse + l);
l = this.m_impulse - u;
var _ = P.MulSV(l, this.m_u, n.SolveVelocityConstraints_s_P);
e.SelfMulSub(this.m_invMassA, _);
i -= this.m_invIA * P.CrossVV(this.m_rA, _);
r.SelfMulAdd(this.m_invMassB, _);
s += this.m_invIB * P.CrossVV(this.m_rB, _);
t.velocities[this.m_indexA].w = i;
t.velocities[this.m_indexB].w = s;
};
n.prototype.SolvePositionConstraints = function(t) {
var e = t.positions[this.m_indexA].c, i = t.positions[this.m_indexA].a, r = t.positions[this.m_indexB].c, s = t.positions[this.m_indexB].a, o = this.m_qA.SetAngle(i), a = this.m_qB.SetAngle(s);
P.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA);
var h = O.MulRV(o, this.m_lalcA, this.m_rA);
P.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB);
var l = O.MulRV(a, this.m_lalcB, this.m_rB), u = this.m_u.Copy(r).SelfAdd(l).SelfSub(e).SelfSub(h), _ = u.Normalize(), f = _ - this.m_maxLength;
f = C(f, 0, .2);
var d = -this.m_mass * f, m = P.MulSV(d, u, n.SolvePositionConstraints_s_P);
e.SelfMulSub(this.m_invMassA, m);
i -= this.m_invIA * P.CrossVV(h, m);
r.SelfMulAdd(this.m_invMassB, m);
s += this.m_invIB * P.CrossVV(l, m);
t.positions[this.m_indexA].a = i;
t.positions[this.m_indexB].a = s;
return _ - this.m_maxLength < c;
};
n.prototype.GetAnchorA = function(t) {
return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, t);
};
n.prototype.GetAnchorB = function(t) {
return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, t);
};
n.prototype.GetReactionForce = function(t, e) {
return P.MulSV(t * this.m_impulse, this.m_u, e);
};
n.prototype.GetReactionTorque = function(t) {
return 0;
};
n.prototype.GetLocalAnchorA = function() {
return this.m_localAnchorA;
};
n.prototype.GetLocalAnchorB = function() {
return this.m_localAnchorB;
};
n.prototype.SetMaxLength = function(t) {
this.m_maxLength = t;
};
n.prototype.GetMaxLength = function() {
return this.m_maxLength;
};
n.prototype.GetLimitState = function() {
return this.m_state;
};
n.prototype.Dump = function(t) {
var e = this.m_bodyA.m_islandIndex, 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);
};
n.InitVelocityConstraints_s_P = new P();
n.SolveVelocityConstraints_s_vpA = new P();
n.SolveVelocityConstraints_s_vpB = new P();
n.SolveVelocityConstraints_s_P = new P();
n.SolvePositionConstraints_s_P = new P();
return n;
})(_i), Ri = (function(e) {
Qe(i, e);
function i() {
var i = e.call(this, t.b2JointType.e_weldJoint) || this;
i.localAnchorA = new P();
i.localAnchorB = new P();
i.referenceAngle = 0;
i.frequencyHz = 0;
i.dampingRatio = 0;
return i;
}
i.prototype.Initialize = function(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();
};
return i;
})(ui), Li = (function(t) {
Qe(i, t);
function i(i) {
var n = t.call(this, i) || this;
n.m_frequencyHz = 0;
n.m_dampingRatio = 0;
n.m_bias = 0;
n.m_localAnchorA = new P();
n.m_localAnchorB = new P();
n.m_referenceAngle = 0;
n.m_gamma = 0;
n.m_impulse = new L(0, 0, 0);
n.m_indexA = 0;
n.m_indexB = 0;
n.m_rA = new P();
n.m_rB = new P();
n.m_localCenterA = new P();
n.m_localCenterB = new P();
n.m_invMassA = 0;
n.m_invMassB = 0;
n.m_invIA = 0;
n.m_invIB = 0;
n.m_mass = new V();
n.m_qA = new O();
n.m_qB = new O();
n.m_lalcA = new P();
n.m_lalcB = new P();
n.m_K = new V();
n.m_frequencyHz = e(i.frequencyHz, 0);
n.m_dampingRatio = e(i.dampingRatio, 0);
n.m_localAnchorA.Copy(e(i.localAnchorA, P.ZERO));
n.m_localAnchorB.Copy(e(i.localAnchorB, P.ZERO));
n.m_referenceAngle = e(i.referenceAngle, 0);
n.m_impulse.SetZero();
return n;
}
i.prototype.InitVelocityConstraints = function(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;
var e = t.positions[this.m_indexA].a, n = t.velocities[this.m_indexA].v, r = t.velocities[this.m_indexA].w, o = t.positions[this.m_indexB].a, a = t.velocities[this.m_indexB].v, c = t.velocities[this.m_indexB].w, h = this.m_qA.SetAngle(e), l = this.m_qB.SetAngle(o);
P.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA);
O.MulRV(h, this.m_lalcA, this.m_rA);
P.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB);
O.MulRV(l, this.m_lalcB, this.m_rB);
var u = this.m_invMassA, _ = this.m_invMassB, f = this.m_invIA, d = this.m_invIB, m = this.m_K;
m.ex.x = u + _ + this.m_rA.y * this.m_rA.y * f + this.m_rB.y * this.m_rB.y * d;
m.ey.x = -this.m_rA.y * this.m_rA.x * f - this.m_rB.y * this.m_rB.x * d;
m.ez.x = -this.m_rA.y * f - this.m_rB.y * d;
m.ex.y = m.ey.x;
m.ey.y = u + _ + this.m_rA.x * this.m_rA.x * f + this.m_rB.x * this.m_rB.x * d;
m.ez.y = this.m_rA.x * f + this.m_rB.x * d;
m.ex.z = m.ez.x;
m.ey.z = m.ez.y;
m.ez.z = f + d;
if (this.m_frequencyHz > 0) {
m.GetInverse22(this.m_mass);
var p = f + d, v = p > 0 ? 1 / p : 0, y = o - e - this.m_referenceAngle, g = 2 * s * this.m_frequencyHz, x = 2 * v * this.m_dampingRatio * g, C = v * g * g, A = t.step.dt;
this.m_gamma = A * (x + A * C);
this.m_gamma = 0 !== this.m_gamma ? 1 / this.m_gamma : 0;
this.m_bias = y * A * C * this.m_gamma;
p += this.m_gamma;
this.m_mass.ez.z = 0 !== p ? 1 / p : 0;
} else {
m.GetSymInverse33(this.m_mass);
this.m_gamma = 0;
this.m_bias = 0;
}
if (t.step.warmStarting) {
this.m_impulse.SelfMul(t.step.dtRatio);
var b = i.InitVelocityConstraints_s_P.Set(this.m_impulse.x, this.m_impulse.y);
n.SelfMulSub(u, b);
r -= f * (P.CrossVV(this.m_rA, b) + this.m_impulse.z);
a.SelfMulAdd(_, b);
c += d * (P.CrossVV(this.m_rB, b) + this.m_impulse.z);
} else this.m_impulse.SetZero();
t.velocities[this.m_indexA].w = r;
t.velocities[this.m_indexB].w = c;
};
i.prototype.SolveVelocityConstraints = function(t) {
var e = t.velocities[this.m_indexA].v, n = t.velocities[this.m_indexA].w, r = t.velocities[this.m_indexB].v, s = t.velocities[this.m_indexB].w, o = this.m_invMassA, a = this.m_invMassB, c = this.m_invIA, h = this.m_invIB;
if (this.m_frequencyHz > 0) {
var l = s - n, u = -this.m_mass.ez.z * (l + this.m_bias + this.m_gamma * this.m_impulse.z);
this.m_impulse.z += u;
n -= c * u;
s += h * u;
var _ = P.SubVV(P.AddVCrossSV(r, s, this.m_rB, P.s_t0), P.AddVCrossSV(e, n, this.m_rA, P.s_t1), i.SolveVelocityConstraints_s_Cdot1), f = V.MulM33XY(this.m_mass, _.x, _.y, i.SolveVelocityConstraints_s_impulse1).SelfNeg();
this.m_impulse.x += f.x;
this.m_impulse.y += f.y;
var d = f;
e.SelfMulSub(o, d);
n -= c * P.CrossVV(this.m_rA, d);
r.SelfMulAdd(a, d);
s += h * P.CrossVV(this.m_rB, d);
} else {
_ = P.SubVV(P.AddVCrossSV(r, s, this.m_rB, P.s_t0), P.AddVCrossSV(e, n, this.m_rA, P.s_t1), i.SolveVelocityConstraints_s_Cdot1), 
l = s - n;
var m = V.MulM33XYZ(this.m_mass, _.x, _.y, l, i.SolveVelocityConstraints_s_impulse).SelfNeg();
this.m_impulse.SelfAdd(m);
d = i.SolveVelocityConstraints_s_P.Set(m.x, m.y);
e.SelfMulSub(o, d);
n -= c * (P.CrossVV(this.m_rA, d) + m.z);
r.SelfMulAdd(a, d);
s += h * (P.CrossVV(this.m_rB, d) + m.z);
}
t.velocities[this.m_indexA].w = n;
t.velocities[this.m_indexB].w = s;
};
i.prototype.SolvePositionConstraints = function(t) {
var e = t.positions[this.m_indexA].c, n = t.positions[this.m_indexA].a, r = t.positions[this.m_indexB].c, s = t.positions[this.m_indexB].a, o = this.m_qA.SetAngle(n), a = this.m_qB.SetAngle(s), l = this.m_invMassA, u = this.m_invMassB, _ = this.m_invIA, f = this.m_invIB;
P.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA);
var d = O.MulRV(o, this.m_lalcA, this.m_rA);
P.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB);
var m, p, v = O.MulRV(a, this.m_lalcB, this.m_rB), g = this.m_K;
g.ex.x = l + u + d.y * d.y * _ + v.y * v.y * f;
g.ey.x = -d.y * d.x * _ - v.y * v.x * f;
g.ez.x = -d.y * _ - v.y * f;
g.ex.y = g.ey.x;
g.ey.y = l + u + d.x * d.x * _ + v.x * v.x * f;
g.ez.y = d.x * _ + v.x * f;
g.ex.z = g.ez.x;
g.ey.z = g.ez.y;
g.ez.z = _ + f;
if (this.m_frequencyHz > 0) {
m = (C = P.SubVV(P.AddVV(r, v, P.s_t0), P.AddVV(e, d, P.s_t1), i.SolvePositionConstraints_s_C1)).Length();
p = 0;
var x = g.Solve22(C.x, C.y, i.SolvePositionConstraints_s_P).SelfNeg();
e.SelfMulSub(l, x);
n -= _ * P.CrossVV(d, x);
r.SelfMulAdd(u, x);
s += f * P.CrossVV(v, x);
} else {
var C = P.SubVV(P.AddVV(r, v, P.s_t0), P.AddVV(e, d, P.s_t1), i.SolvePositionConstraints_s_C1), A = s - n - this.m_referenceAngle;
m = C.Length();
p = y(A);
var b = g.Solve33(C.x, C.y, A, i.SolvePositionConstraints_s_impulse).SelfNeg();
x = i.SolvePositionConstraints_s_P.Set(b.x, b.y);
e.SelfMulSub(l, x);
n -= _ * (P.CrossVV(this.m_rA, x) + b.z);
r.SelfMulAdd(u, x);
s += f * (P.CrossVV(this.m_rB, x) + b.z);
}
t.positions[this.m_indexA].a = n;
t.positions[this.m_indexB].a = s;
return m <= c && p <= h;
};
i.prototype.GetAnchorA = function(t) {
return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, t);
};
i.prototype.GetAnchorB = function(t) {
return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, t);
};
i.prototype.GetReactionForce = function(t, e) {
e.x = t * this.m_impulse.x;
e.y = t * this.m_impulse.y;
return e;
};
i.prototype.GetReactionTorque = function(t) {
return t * this.m_impulse.z;
};
i.prototype.GetLocalAnchorA = function() {
return this.m_localAnchorA;
};
i.prototype.GetLocalAnchorB = function() {
return this.m_localAnchorB;
};
i.prototype.GetReferenceAngle = function() {
return this.m_referenceAngle;
};
i.prototype.SetFrequency = function(t) {
this.m_frequencyHz = t;
};
i.prototype.GetFrequency = function() {
return this.m_frequencyHz;
};
i.prototype.SetDampingRatio = function(t) {
this.m_dampingRatio = t;
};
i.prototype.GetDampingRatio = function() {
return this.m_dampingRatio;
};
i.prototype.Dump = function(t) {
var e = this.m_bodyA.m_islandIndex, 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);
};
i.InitVelocityConstraints_s_P = new P();
i.SolveVelocityConstraints_s_Cdot1 = new P();
i.SolveVelocityConstraints_s_impulse1 = new P();
i.SolveVelocityConstraints_s_impulse = new L();
i.SolveVelocityConstraints_s_P = new P();
i.SolvePositionConstraints_s_C1 = new P();
i.SolvePositionConstraints_s_P = new P();
i.SolvePositionConstraints_s_impulse = new L();
return i;
})(_i), Fi = (function(e) {
Qe(i, e);
function i() {
var i = e.call(this, t.b2JointType.e_wheelJoint) || this;
i.localAnchorA = new P(0, 0);
i.localAnchorB = new P(0, 0);
i.localAxisA = new P(1, 0);
i.enableMotor = !1;
i.maxMotorTorque = 0;
i.motorSpeed = 0;
i.frequencyHz = 2;
i.dampingRatio = .7;
return i;
}
i.prototype.Initialize = function(t, e, i, n) {
this.bodyA = t;
this.bodyB = e;
this.bodyA.GetLocalPoint(i, this.localAnchorA);
this.bodyB.GetLocalPoint(i, this.localAnchorB);
this.bodyA.GetLocalVector(n, this.localAxisA);
};
return i;
})(ui), Vi = (function(t) {
Qe(i, t);
function i(i) {
var n = t.call(this, i) || this;
n.m_frequencyHz = 0;
n.m_dampingRatio = 0;
n.m_localAnchorA = new P();
n.m_localAnchorB = new P();
n.m_localXAxisA = new P();
n.m_localYAxisA = new P();
n.m_impulse = 0;
n.m_motorImpulse = 0;
n.m_springImpulse = 0;
n.m_maxMotorTorque = 0;
n.m_motorSpeed = 0;
n.m_enableMotor = !1;
n.m_indexA = 0;
n.m_indexB = 0;
n.m_localCenterA = new P();
n.m_localCenterB = new P();
n.m_invMassA = 0;
n.m_invMassB = 0;
n.m_invIA = 0;
n.m_invIB = 0;
n.m_ax = new P();
n.m_ay = new P();
n.m_sAx = 0;
n.m_sBx = 0;
n.m_sAy = 0;
n.m_sBy = 0;
n.m_mass = 0;
n.m_motorMass = 0;
n.m_springMass = 0;
n.m_bias = 0;
n.m_gamma = 0;
n.m_qA = new O();
n.m_qB = new O();
n.m_lalcA = new P();
n.m_lalcB = new P();
n.m_rA = new P();
n.m_rB = new P();
n.m_frequencyHz = e(i.frequencyHz, 2);
n.m_dampingRatio = e(i.dampingRatio, .7);
n.m_localAnchorA.Copy(e(i.localAnchorA, P.ZERO));
n.m_localAnchorB.Copy(e(i.localAnchorB, P.ZERO));
n.m_localXAxisA.Copy(e(i.localAxisA, P.UNITX));
P.CrossOneV(n.m_localXAxisA, n.m_localYAxisA);
n.m_maxMotorTorque = e(i.maxMotorTorque, 0);
n.m_motorSpeed = e(i.motorSpeed, 0);
n.m_enableMotor = e(i.enableMotor, !1);
n.m_ax.SetZero();
n.m_ay.SetZero();
return n;
}
i.prototype.GetMotorSpeed = function() {
return this.m_motorSpeed;
};
i.prototype.GetMaxMotorTorque = function() {
return this.m_maxMotorTorque;
};
i.prototype.SetSpringFrequencyHz = function(t) {
this.m_frequencyHz = t;
};
i.prototype.GetSpringFrequencyHz = function() {
return this.m_frequencyHz;
};
i.prototype.SetSpringDampingRatio = function(t) {
this.m_dampingRatio = t;
};
i.prototype.GetSpringDampingRatio = function() {
return this.m_dampingRatio;
};
i.prototype.InitVelocityConstraints = function(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;
var e = this.m_invMassA, n = this.m_invMassB, r = this.m_invIA, o = this.m_invIB, a = t.positions[this.m_indexA].c, c = t.positions[this.m_indexA].a, h = t.velocities[this.m_indexA].v, l = t.velocities[this.m_indexA].w, u = t.positions[this.m_indexB].c, _ = t.positions[this.m_indexB].a, f = t.velocities[this.m_indexB].v, d = t.velocities[this.m_indexB].w, m = this.m_qA.SetAngle(c), p = this.m_qB.SetAngle(_);
P.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA);
var v = O.MulRV(m, this.m_lalcA, this.m_rA);
P.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB);
var y = O.MulRV(p, this.m_lalcB, this.m_rB), g = P.SubVV(P.AddVV(u, y, P.s_t0), P.AddVV(a, v, P.s_t1), i.InitVelocityConstraints_s_d);
O.MulRV(m, this.m_localYAxisA, this.m_ay);
this.m_sAy = P.CrossVV(P.AddVV(g, v, P.s_t0), this.m_ay);
this.m_sBy = P.CrossVV(y, this.m_ay);
this.m_mass = e + n + r * this.m_sAy * this.m_sAy + o * 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) {
O.MulRV(m, this.m_localXAxisA, this.m_ax);
this.m_sAx = P.CrossVV(P.AddVV(g, v, P.s_t0), this.m_ax);
this.m_sBx = P.CrossVV(y, this.m_ax);
var x = e + n + r * this.m_sAx * this.m_sAx + o * this.m_sBx * this.m_sBx;
if (x > 0) {
this.m_springMass = 1 / x;
var C = P.DotVV(g, this.m_ax), A = 2 * s * this.m_frequencyHz, b = 2 * this.m_springMass * this.m_dampingRatio * A, S = this.m_springMass * A * A, T = t.step.dt;
this.m_gamma = T * (b + T * S);
this.m_gamma > 0 && (this.m_gamma = 1 / this.m_gamma);
this.m_bias = C * T * S * this.m_gamma;
this.m_springMass = x + 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 = r + o;
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;
var w = P.AddVV(P.MulSV(this.m_impulse, this.m_ay, P.s_t0), P.MulSV(this.m_springImpulse, this.m_ax, P.s_t1), i.InitVelocityConstraints_s_P), E = this.m_impulse * this.m_sAy + this.m_springImpulse * this.m_sAx + this.m_motorImpulse, B = this.m_impulse * this.m_sBy + this.m_springImpulse * this.m_sBx + this.m_motorImpulse;
h.SelfMulSub(this.m_invMassA, w);
l -= this.m_invIA * E;
f.SelfMulAdd(this.m_invMassB, w);
d += this.m_invIB * B;
} else {
this.m_impulse = 0;
this.m_springImpulse = 0;
this.m_motorImpulse = 0;
}
t.velocities[this.m_indexA].w = l;
t.velocities[this.m_indexB].w = d;
};
i.prototype.SolveVelocityConstraints = function(t) {
var e = this.m_invMassA, n = this.m_invMassB, r = this.m_invIA, s = this.m_invIB, o = t.velocities[this.m_indexA].v, a = t.velocities[this.m_indexA].w, c = t.velocities[this.m_indexB].v, h = t.velocities[this.m_indexB].w, l = P.DotVV(this.m_ax, P.SubVV(c, o, P.s_t0)) + this.m_sBx * h - this.m_sAx * a, u = -this.m_springMass * (l + this.m_bias + this.m_gamma * this.m_springImpulse);
this.m_springImpulse += u;
var _ = P.MulSV(u, this.m_ax, i.SolveVelocityConstraints_s_P), f = u * this.m_sAx, d = u * this.m_sBx;
o.SelfMulSub(e, _);
a -= r * f;
c.SelfMulAdd(n, _);
l = (h += s * d) - a - this.m_motorSpeed, u = -this.m_motorMass * l;
var m = this.m_motorImpulse, p = t.step.dt * this.m_maxMotorTorque;
this.m_motorImpulse = C(this.m_motorImpulse + u, -p, p);
a -= r * (u = this.m_motorImpulse - m);
h += s * u;
l = P.DotVV(this.m_ay, P.SubVV(c, o, P.s_t0)) + this.m_sBy * h - this.m_sAy * a, 
u = -this.m_mass * l;
this.m_impulse += u;
_ = P.MulSV(u, this.m_ay, i.SolveVelocityConstraints_s_P), f = u * this.m_sAy, d = u * this.m_sBy;
o.SelfMulSub(e, _);
a -= r * f;
c.SelfMulAdd(n, _);
h += s * d;
t.velocities[this.m_indexA].w = a;
t.velocities[this.m_indexB].w = h;
};
i.prototype.SolvePositionConstraints = function(t) {
var e = t.positions[this.m_indexA].c, n = t.positions[this.m_indexA].a, r = t.positions[this.m_indexB].c, s = t.positions[this.m_indexB].a, o = this.m_qA.SetAngle(n), a = this.m_qB.SetAngle(s);
P.SubVV(this.m_localAnchorA, this.m_localCenterA, this.m_lalcA);
var h = O.MulRV(o, this.m_lalcA, this.m_rA);
P.SubVV(this.m_localAnchorB, this.m_localCenterB, this.m_lalcB);
var l, u = O.MulRV(a, this.m_lalcB, this.m_rB), _ = P.AddVV(P.SubVV(r, e, P.s_t0), P.SubVV(u, h, P.s_t1), i.SolvePositionConstraints_s_d), f = O.MulRV(o, this.m_localYAxisA, this.m_ay), d = P.CrossVV(P.AddVV(_, h, P.s_t0), f), m = P.CrossVV(u, f), p = P.DotVV(_, this.m_ay), v = this.m_invMassA + this.m_invMassB + this.m_invIA * this.m_sAy * this.m_sAy + this.m_invIB * this.m_sBy * this.m_sBy;
l = 0 !== v ? -p / v : 0;
var g = P.MulSV(l, f, i.SolvePositionConstraints_s_P), x = l * d, C = l * m;
e.SelfMulSub(this.m_invMassA, g);
n -= this.m_invIA * x;
r.SelfMulAdd(this.m_invMassB, g);
s += this.m_invIB * C;
t.positions[this.m_indexA].a = n;
t.positions[this.m_indexB].a = s;
return y(p) <= c;
};
i.prototype.GetDefinition = function(t) {
return t;
};
i.prototype.GetAnchorA = function(t) {
return this.m_bodyA.GetWorldPoint(this.m_localAnchorA, t);
};
i.prototype.GetAnchorB = function(t) {
return this.m_bodyB.GetWorldPoint(this.m_localAnchorB, t);
};
i.prototype.GetReactionForce = function(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;
};
i.prototype.GetReactionTorque = function(t) {
return t * this.m_motorImpulse;
};
i.prototype.GetLocalAnchorA = function() {
return this.m_localAnchorA;
};
i.prototype.GetLocalAnchorB = function() {
return this.m_localAnchorB;
};
i.prototype.GetLocalAxisA = function() {
return this.m_localXAxisA;
};
i.prototype.GetJointTranslation = function() {
return this.GetPrismaticJointTranslation();
};
i.prototype.GetJointLinearSpeed = function() {
return this.GetPrismaticJointSpeed();
};
i.prototype.GetJointAngle = function() {
return this.GetRevoluteJointAngle();
};
i.prototype.GetJointAngularSpeed = function() {
return this.GetRevoluteJointSpeed();
};
i.prototype.GetPrismaticJointTranslation = function() {
var t = this.m_bodyA, e = this.m_bodyB, i = t.GetWorldPoint(this.m_localAnchorA, new P()), n = e.GetWorldPoint(this.m_localAnchorB, new P()), r = P.SubVV(n, i, new P()), s = t.GetWorldVector(this.m_localXAxisA, new P());
return P.DotVV(r, s);
};
i.prototype.GetPrismaticJointSpeed = function() {
var t = this.m_bodyA, e = this.m_bodyB;
P.SubVV(this.m_localAnchorA, t.m_sweep.localCenter, this.m_lalcA);
var i = O.MulRV(t.m_xf.q, this.m_lalcA, this.m_rA);
P.SubVV(this.m_localAnchorB, e.m_sweep.localCenter, this.m_lalcB);
var n = O.MulRV(e.m_xf.q, this.m_lalcB, this.m_rB), r = P.AddVV(t.m_sweep.c, i, P.s_t0), s = P.AddVV(e.m_sweep.c, n, P.s_t1), o = P.SubVV(s, r, P.s_t2), a = t.GetWorldVector(this.m_localXAxisA, new P()), c = t.m_linearVelocity, h = e.m_linearVelocity, l = t.m_angularVelocity, u = e.m_angularVelocity;
return P.DotVV(o, P.CrossSV(l, a, P.s_t0)) + P.DotVV(a, P.SubVV(P.AddVCrossSV(h, u, n, P.s_t0), P.AddVCrossSV(c, l, i, P.s_t1), P.s_t0));
};
i.prototype.GetRevoluteJointAngle = function() {
return this.m_bodyB.m_sweep.a - this.m_bodyA.m_sweep.a;
};
i.prototype.GetRevoluteJointSpeed = function() {
var t = this.m_bodyA.m_angularVelocity;
return this.m_bodyB.m_angularVelocity - t;
};
i.prototype.IsMotorEnabled = function() {
return this.m_enableMotor;
};
i.prototype.EnableMotor = function(t) {
if (t !== this.m_enableMotor) {
this.m_bodyA.SetAwake(!0);
this.m_bodyB.SetAwake(!0);
this.m_enableMotor = t;
}
};
i.prototype.SetMotorSpeed = function(t) {
if (t !== this.m_motorSpeed) {
this.m_bodyA.SetAwake(!0);
this.m_bodyB.SetAwake(!0);
this.m_motorSpeed = t;
}
};
i.prototype.SetMaxMotorTorque = function(t) {
if (t !== this.m_maxMotorTorque) {
this.m_bodyA.SetAwake(!0);
this.m_bodyB.SetAwake(!0);
this.m_maxMotorTorque = t;
}
};
i.prototype.GetMotorTorque = function(t) {
return t * this.m_motorImpulse;
};
i.prototype.Dump = function(t) {
var e = this.m_bodyA.m_islandIndex, 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);
};
i.InitVelocityConstraints_s_d = new P();
i.InitVelocityConstraints_s_P = new P();
i.SolveVelocityConstraints_s_P = new P();
i.SolvePositionConstraints_s_d = new P();
i.SolvePositionConstraints_s_P = new P();
return i;
})(_i);
function Oi(t, e) {
return T(t * e);
}
function Ni(t, e) {
return t > e ? t : e;
}
var ki = (function() {
return function(t) {
this.prev = null;
this.next = null;
this.contact = t;
};
})(), Gi = (function() {
function t() {
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_indexA = 0;
this.m_indexB = 0;
this.m_manifold = new Ct();
this.m_toiCount = 0;
this.m_toi = 0;
this.m_friction = 0;
this.m_restitution = 0;
this.m_tangentSpeed = 0;
this.m_oldManifold = new Ct();
this.m_nodeA = new ki(this);
this.m_nodeB = new ki(this);
}
t.prototype.GetManifold = function() {
return this.m_manifold;
};
t.prototype.GetWorldManifold = function(t) {
var e = this.m_fixtureA.GetBody(), i = this.m_fixtureB.GetBody(), n = this.m_fixtureA.GetShape(), r = this.m_fixtureB.GetShape();
t.Initialize(this.m_manifold, e.GetTransform(), n.m_radius, i.GetTransform(), r.m_radius);
};
t.prototype.IsTouching = function() {
return this.m_touchingFlag;
};
t.prototype.SetEnabled = function(t) {
this.m_enabledFlag = t;
};
t.prototype.IsEnabled = function() {
return this.m_enabledFlag;
};
t.prototype.GetNext = function() {
return this.m_next;
};
t.prototype.GetFixtureA = function() {
return this.m_fixtureA;
};
t.prototype.GetChildIndexA = function() {
return this.m_indexA;
};
t.prototype.GetFixtureB = function() {
return this.m_fixtureB;
};
t.prototype.GetChildIndexB = function() {
return this.m_indexB;
};
t.prototype.FlagForFiltering = function() {
this.m_filterFlag = !0;
};
t.prototype.SetFriction = function(t) {
this.m_friction = t;
};
t.prototype.GetFriction = function() {
return this.m_friction;
};
t.prototype.ResetFriction = function() {
this.m_friction = Oi(this.m_fixtureA.m_friction, this.m_fixtureB.m_friction);
};
t.prototype.SetRestitution = function(t) {
this.m_restitution = t;
};
t.prototype.GetRestitution = function() {
return this.m_restitution;
};
t.prototype.ResetRestitution = function() {
this.m_restitution = Ni(this.m_fixtureA.m_restitution, this.m_fixtureB.m_restitution);
};
t.prototype.SetTangentSpeed = function(t) {
this.m_tangentSpeed = t;
};
t.prototype.GetTangentSpeed = function() {
return this.m_tangentSpeed;
};
t.prototype.Reset = function(t, e, i, n) {
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 = n;
this.m_manifold.pointCount = 0;
this.m_prev = null;
this.m_next = null;
delete this.m_nodeA.contact;
this.m_nodeA.prev = null;
this.m_nodeA.next = null;
delete this.m_nodeA.other;
delete this.m_nodeB.contact;
this.m_nodeB.prev = null;
this.m_nodeB.next = null;
delete this.m_nodeB.other;
this.m_toiCount = 0;
this.m_friction = Oi(this.m_fixtureA.m_friction, this.m_fixtureB.m_friction);
this.m_restitution = Ni(this.m_fixtureA.m_restitution, this.m_fixtureB.m_restitution);
};
t.prototype.Update = function(t) {
var e = this.m_oldManifold;
this.m_oldManifold = this.m_manifold;
this.m_manifold = e;
this.m_enabledFlag = !0;
var i = !1, n = this.m_touchingFlag, r = this.m_fixtureA.IsSensor(), s = this.m_fixtureB.IsSensor(), o = r || s, a = this.m_fixtureA.GetBody(), c = this.m_fixtureB.GetBody(), h = a.GetTransform(), l = c.GetTransform();
if (o) {
var u = this.m_fixtureA.GetShape(), _ = this.m_fixtureB.GetShape();
i = Pt(u, this.m_indexA, _, this.m_indexB, h, l);
this.m_manifold.pointCount = 0;
} else {
this.Evaluate(this.m_manifold, h, l);
i = this.m_manifold.pointCount > 0;
for (var f = 0; f < this.m_manifold.pointCount; ++f) {
var d = this.m_manifold.points[f];
d.normalImpulse = 0;
d.tangentImpulse = 0;
for (var m = d.id, p = 0; p < this.m_oldManifold.pointCount; ++p) {
var v = this.m_oldManifold.points[p];
if (v.id.key === m.key) {
d.normalImpulse = v.normalImpulse;
d.tangentImpulse = v.tangentImpulse;
break;
}
}
}
if (i !== n) {
a.SetAwake(!0);
c.SetAwake(!0);
}
}
this.m_touchingFlag = i;
!n && i && t && t.BeginContact(this);
n && !i && t && t.EndContact(this);
!o && i && t && t.PreSolve(this, this.m_oldManifold);
};
t.prototype.ComputeTOI = function(e, i) {
var n = t.ComputeTOI_s_input;
n.proxyA.SetShape(this.m_fixtureA.GetShape(), this.m_indexA);
n.proxyB.SetShape(this.m_fixtureB.GetShape(), this.m_indexB);
n.sweepA.Copy(e);
n.sweepB.Copy(i);
n.tMax = c;
var r = t.ComputeTOI_s_output;
re(r, n);
return r.t;
};
t.ComputeTOI_s_input = new qt();
t.ComputeTOI_s_output = new Xt();
return t;
})(), zi = (function(t) {
Qe(e, t);
function e() {
return t.call(this) || this;
}
e.Create = function(t) {
return new e();
};
e.Destroy = function(t, e) {};
e.prototype.Reset = function(e, i, n, r) {
t.prototype.Reset.call(this, e, i, n, r);
};
e.prototype.Evaluate = function(t, e, i) {
ae(t, this.m_fixtureA.GetShape(), e, this.m_fixtureB.GetShape(), i);
};
return e;
})(Gi), Ui = (function(t) {
Qe(e, t);
function e() {
return t.call(this) || this;
}
e.Create = function(t) {
return new e();
};
e.Destroy = function(t, e) {};
e.prototype.Reset = function(e, i, n, r) {
t.prototype.Reset.call(this, e, i, n, r);
};
e.prototype.Evaluate = function(t, e, i) {
Le(t, this.m_fixtureA.GetShape(), e, this.m_fixtureB.GetShape(), i);
};
return e;
})(Gi), ji = (function(t) {
Qe(e, t);
function e() {
return t.call(this) || this;
}
e.Create = function(t) {
return new e();
};
e.Destroy = function(t, e) {};
e.prototype.Reset = function(e, i, n, r) {
t.prototype.Reset.call(this, e, i, n, r);
};
e.prototype.Evaluate = function(t, e, i) {
ue(t, this.m_fixtureA.GetShape(), e, this.m_fixtureB.GetShape(), i);
};
return e;
})(Gi), Hi = (function(t) {
Qe(e, t);
function e() {
return t.call(this) || this;
}
e.Create = function(t) {
return new e();
};
e.Destroy = function(t, e) {};
e.prototype.Reset = function(e, i, n, r) {
t.prototype.Reset.call(this, e, i, n, r);
};
e.prototype.Evaluate = function(t, e, i) {
je(t, this.m_fixtureA.GetShape(), e, this.m_fixtureB.GetShape(), i);
};
return e;
})(Gi), Wi = (function(t) {
Qe(e, t);
function e() {
return t.call(this) || this;
}
e.Create = function(t) {
return new e();
};
e.Destroy = function(t, e) {};
e.prototype.Reset = function(e, i, n, r) {
t.prototype.Reset.call(this, e, i, n, r);
};
e.prototype.Evaluate = function(t, e, i) {
Ye(t, this.m_fixtureA.GetShape(), e, this.m_fixtureB.GetShape(), i);
};
return e;
})(Gi), qi = (function(t) {
Qe(e, t);
function e() {
return t.call(this) || this;
}
e.Create = function(t) {
return new e();
};
e.Destroy = function(t, e) {};
e.prototype.Reset = function(e, i, n, r) {
t.prototype.Reset.call(this, e, i, n, r);
};
e.prototype.Evaluate = function(t, i, n) {
var r = this.m_fixtureA.GetShape(), s = this.m_fixtureB.GetShape(), o = r, a = e.Evaluate_s_edge;
o.GetChildEdge(a, this.m_indexA);
je(t, a, i, s, n);
};
e.Evaluate_s_edge = new ei();
return e;
})(Gi), Xi = (function(t) {
Qe(e, t);
function e() {
return t.call(this) || this;
}
e.Create = function(t) {
return new e();
};
e.Destroy = function(t, e) {};
e.prototype.Reset = function(e, i, n, r) {
t.prototype.Reset.call(this, e, i, n, r);
};
e.prototype.Evaluate = function(t, i, n) {
var r = this.m_fixtureA.GetShape(), s = this.m_fixtureB.GetShape(), o = r, a = e.Evaluate_s_edge;
o.GetChildEdge(a, this.m_indexA);
Ye(t, a, i, s, n);
};
e.Evaluate_s_edge = new ei();
return e;
})(Gi), Yi = (function() {
return function() {
this.createFcn = null;
this.destroyFcn = null;
this.primary = !1;
};
})(), Ji = (function() {
function e(t) {
this.m_allocator = null;
this.m_allocator = t;
this.InitializeRegisters();
}
e.prototype.AddType = function(t, e, i, n) {
var r = this, s = d(256, (function(e) {
return t(r.m_allocator);
}));
function o(e) {
return s.pop() || t(e);
}
function a(t, e) {
s.push(t);
}
this.m_registers[i][n].createFcn = o;
this.m_registers[i][n].destroyFcn = a;
this.m_registers[i][n].primary = !0;
if (i !== n) {
this.m_registers[n][i].createFcn = o;
this.m_registers[n][i].destroyFcn = a;
this.m_registers[n][i].primary = !1;
}
};
e.prototype.InitializeRegisters = function() {
this.m_registers = [];
for (var e = 0; e < t.b2ShapeType.e_shapeTypeCount; e++) {
this.m_registers[e] = [];
for (var i = 0; i < t.b2ShapeType.e_shapeTypeCount; i++) this.m_registers[e][i] = new Yi();
}
this.AddType(zi.Create, zi.Destroy, t.b2ShapeType.e_circleShape, t.b2ShapeType.e_circleShape);
this.AddType(ji.Create, ji.Destroy, t.b2ShapeType.e_polygonShape, t.b2ShapeType.e_circleShape);
this.AddType(Ui.Create, Ui.Destroy, t.b2ShapeType.e_polygonShape, t.b2ShapeType.e_polygonShape);
this.AddType(Hi.Create, Hi.Destroy, t.b2ShapeType.e_edgeShape, t.b2ShapeType.e_circleShape);
this.AddType(Wi.Create, Wi.Destroy, t.b2ShapeType.e_edgeShape, t.b2ShapeType.e_polygonShape);
this.AddType(qi.Create, qi.Destroy, t.b2ShapeType.e_chainShape, t.b2ShapeType.e_circleShape);
this.AddType(Xi.Create, Xi.Destroy, t.b2ShapeType.e_chainShape, t.b2ShapeType.e_polygonShape);
};
e.prototype.Create = function(t, e, i, n) {
var r = t.GetType(), s = i.GetType(), o = this.m_registers[r][s];
if (o.createFcn) {
var a = o.createFcn(this.m_allocator);
o.primary ? a.Reset(t, e, i, n) : a.Reset(i, n, t, e);
return a;
}
return null;
};
e.prototype.Destroy = function(t) {
var e = t.m_fixtureA, i = t.m_fixtureB;
if (t.m_manifold.pointCount > 0 && !e.IsSensor() && !i.IsSensor()) {
e.GetBody().SetAwake(!0);
i.GetBody().SetAwake(!0);
}
var n = e.GetType(), r = i.GetType(), s = this.m_registers[n][r];
s.destroyFcn && s.destroyFcn(t, this.m_allocator);
};
return e;
})(), Zi = (function() {
function t() {}
t.prototype.SayGoodbyeJoint = function(t) {};
t.prototype.SayGoodbyeFixture = function(t) {};
t.prototype.SayGoodbyeParticleGroup = function(t) {};
t.prototype.SayGoodbyeParticle = function(t, e) {};
return t;
})(), Ki = (function() {
function e() {}
e.prototype.ShouldCollide = function(e, i) {
var n = e.GetBody(), r = i.GetBody();
if (r.GetType() === t.b2BodyType.b2_staticBody && n.GetType() === t.b2BodyType.b2_staticBody) return !1;
if (!r.ShouldCollideConnected(n)) return !1;
var s = e.GetFilterData(), o = i.GetFilterData();
return s.groupIndex === o.groupIndex && 0 !== s.groupIndex ? s.groupIndex > 0 : 0 != (s.maskBits & o.categoryBits) && 0 != (s.categoryBits & o.maskBits);
};
e.prototype.ShouldCollideFixtureParticle = function(t, e, i) {
return !0;
};
e.prototype.ShouldCollideParticleParticle = function(t, e, i) {
return !0;
};
e.b2_defaultFilter = new e();
return e;
})(), Qi = (function() {
return function() {
this.normalImpulses = m(o);
this.tangentImpulses = m(o);
this.count = 0;
};
})(), $i = (function() {
function t() {}
t.prototype.BeginContact = function(t) {};
t.prototype.EndContact = function(t) {};
t.prototype.BeginContactFixtureParticle = function(t, e) {};
t.prototype.EndContactFixtureParticle = function(t, e) {};
t.prototype.BeginContactParticleParticle = function(t, e) {};
t.prototype.EndContactParticleParticle = function(t, e) {};
t.prototype.PreSolve = function(t, e) {};
t.prototype.PostSolve = function(t, e) {};
t.b2_defaultListener = new t();
return t;
})(), tn = (function() {
function t() {}
t.prototype.ReportFixture = function(t) {
return !0;
};
t.prototype.ReportParticle = function(t, e) {
return !1;
};
t.prototype.ShouldQueryParticleSystem = function(t) {
return !0;
};
return t;
})(), en = (function() {
function t() {}
t.prototype.ReportFixture = function(t, e, i, n) {
return n;
};
t.prototype.ReportParticle = function(t, e, i, n, r) {
return 0;
};
t.prototype.ShouldQueryParticleSystem = function(t) {
return !0;
};
return t;
})(), nn = (function() {
function e() {
this.m_broadPhase = new Ot();
this.m_contactList = null;
this.m_contactCount = 0;
this.m_contactFilter = Ki.b2_defaultFilter;
this.m_contactListener = $i.b2_defaultListener;
this.m_allocator = null;
this.m_contactFactory = new Ji(this.m_allocator);
}
e.prototype.AddPair = function(t, e) {
var i = t.fixture, n = e.fixture, r = t.childIndex, s = e.childIndex, o = i.GetBody(), a = n.GetBody();
if (o !== a) {
for (var c = a.GetContactList(); c; ) {
if (c.other === o) {
var h = c.contact.GetFixtureA(), l = c.contact.GetFixtureB(), u = c.contact.GetChildIndexA(), _ = c.contact.GetChildIndexB();
if (h === i && l === n && u === r && _ === s) return;
if (h === n && l === i && u === s && _ === r) return;
}
c = c.next;
}
if (!this.m_contactFilter || this.m_contactFilter.ShouldCollide(i, n)) {
var f = this.m_contactFactory.Create(i, r, n, s);
if (null !== f) {
i = f.GetFixtureA();
n = f.GetFixtureB();
r = f.GetChildIndexA();
s = f.GetChildIndexB();
o = i.m_body;
a = n.m_body;
f.m_prev = null;
f.m_next = this.m_contactList;
null !== this.m_contactList && (this.m_contactList.m_prev = f);
this.m_contactList = f;
f.m_nodeA.contact = f;
f.m_nodeA.other = a;
f.m_nodeA.prev = null;
f.m_nodeA.next = o.m_contactList;
null !== o.m_contactList && (o.m_contactList.prev = f.m_nodeA);
o.m_contactList = f.m_nodeA;
f.m_nodeB.contact = f;
f.m_nodeB.other = o;
f.m_nodeB.prev = null;
f.m_nodeB.next = a.m_contactList;
null !== a.m_contactList && (a.m_contactList.prev = f.m_nodeB);
a.m_contactList = f.m_nodeB;
if (!i.IsSensor() && !n.IsSensor()) {
o.SetAwake(!0);
a.SetAwake(!0);
}
++this.m_contactCount;
}
}
}
};
e.prototype.FindNewContacts = function() {
var t = this;
this.m_broadPhase.UpdatePairs((function(e, i) {
t.AddPair(e, i);
}));
};
e.prototype.Destroy = function(t) {
var e = t.GetFixtureA(), i = t.GetFixtureB(), n = e.GetBody(), r = 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 === n.m_contactList && (n.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 === r.m_contactList && (r.m_contactList = t.m_nodeB.next);
this.m_contactFactory.Destroy(t);
--this.m_contactCount;
};
e.prototype.Collide = function() {
for (var e = this.m_contactList; e; ) {
var i = e.GetFixtureA(), n = e.GetFixtureB(), r = e.GetChildIndexA(), s = e.GetChildIndexB(), o = i.GetBody(), a = n.GetBody();
if (e.m_filterFlag) {
if (this.m_contactFilter && !this.m_contactFilter.ShouldCollide(i, n)) {
e = (_ = e).m_next;
this.Destroy(_);
continue;
}
e.m_filterFlag = !1;
}
var c = o.IsAwake() && o.m_type !== t.b2BodyType.b2_staticBody, h = a.IsAwake() && a.m_type !== t.b2BodyType.b2_staticBody;
if (c || h) {
var l = i.m_proxies[r].treeNode, u = n.m_proxies[s].treeNode;
if (Et(l.aabb, u.aabb)) {
e.Update(this.m_contactListener);
e = e.m_next;
} else {
var _;
e = (_ = e).m_next;
this.Destroy(_);
}
} else e = e.m_next;
}
};
return e;
})(), rn = (function() {
function t() {
this.step = 0;
this.collide = 0;
this.solve = 0;
this.solveInit = 0;
this.solveVelocity = 0;
this.solvePosition = 0;
this.broadphase = 0;
this.solveTOI = 0;
}
t.prototype.Reset = function() {
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;
};
return t;
})(), sn = (function() {
function t() {
this.dt = 0;
this.inv_dt = 0;
this.dtRatio = 0;
this.velocityIterations = 0;
this.positionIterations = 0;
this.particleIterations = 0;
this.warmStarting = !1;
}
t.prototype.Copy = function(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;
};
return t;
})(), on = (function() {
function t() {
this.c = new P();
this.a = 0;
}
t.MakeArray = function(e) {
return d(e, (function(e) {
return new t();
}));
};
return t;
})(), an = (function() {
function t() {
this.v = new P();
this.w = 0;
}
t.MakeArray = function(e) {
return d(e, (function(e) {
return new t();
}));
};
return t;
})(), cn = (function() {
return function() {
this.step = new sn();
};
})(), hn = (function() {
function t() {
this.rA = new P();
this.rB = new P();
this.normalImpulse = 0;
this.tangentImpulse = 0;
this.normalMass = 0;
this.tangentMass = 0;
this.velocityBias = 0;
}
t.MakeArray = function(e) {
return d(e, (function(e) {
return new t();
}));
};
return t;
})(), ln = (function() {
function t() {
this.points = hn.MakeArray(o);
this.normal = new P();
this.tangent = new P();
this.normalMass = new F();
this.K = new F();
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;
}
t.MakeArray = function(e) {
return d(e, (function(e) {
return new t();
}));
};
return t;
})(), un = (function() {
function e() {
this.localPoints = P.MakeArray(o);
this.localNormal = new P();
this.localPoint = new P();
this.indexA = 0;
this.indexB = 0;
this.invMassA = 0;
this.invMassB = 0;
this.localCenterA = new P();
this.localCenterB = new P();
this.invIA = 0;
this.invIB = 0;
this.type = t.b2ManifoldType.e_unknown;
this.radiusA = 0;
this.radiusB = 0;
this.pointCount = 0;
}
e.MakeArray = function(t) {
return d(t, (function(t) {
return new e();
}));
};
return e;
})(), _n = (function() {
return function() {
this.step = new sn();
this.count = 0;
this.allocator = null;
};
})(), fn = (function() {
function e() {
this.normal = new P();
this.point = new P();
this.separation = 0;
}
e.prototype.Initialize = function(i, n, r, s) {
var o = e.Initialize_s_pointA, a = e.Initialize_s_pointB, c = e.Initialize_s_planePoint, h = e.Initialize_s_clipPoint;
switch (i.type) {
case t.b2ManifoldType.e_circles:
N.MulXV(n, i.localPoint, o);
N.MulXV(r, i.localPoints[0], a);
P.SubVV(a, o, this.normal).SelfNormalize();
P.MidVV(o, a, this.point);
this.separation = P.DotVV(P.SubVV(a, o, P.s_t0), this.normal) - i.radiusA - i.radiusB;
break;

case t.b2ManifoldType.e_faceA:
O.MulRV(n.q, i.localNormal, this.normal);
N.MulXV(n, i.localPoint, c);
N.MulXV(r, i.localPoints[s], h);
this.separation = P.DotVV(P.SubVV(h, c, P.s_t0), this.normal) - i.radiusA - i.radiusB;
this.point.Copy(h);
break;

case t.b2ManifoldType.e_faceB:
O.MulRV(r.q, i.localNormal, this.normal);
N.MulXV(r, i.localPoint, c);
N.MulXV(n, i.localPoints[s], h);
this.separation = P.DotVV(P.SubVV(h, c, P.s_t0), this.normal) - i.radiusA - i.radiusB;
this.point.Copy(h);
this.normal.SelfNeg();
}
};
e.Initialize_s_pointA = new P();
e.Initialize_s_pointB = new P();
e.Initialize_s_planePoint = new P();
e.Initialize_s_clipPoint = new P();
return e;
})(), dn = (function() {
function t() {
this.m_step = new sn();
this.m_allocator = null;
this.m_positionConstraints = un.MakeArray(1024);
this.m_velocityConstraints = ln.MakeArray(1024);
this.m_count = 0;
}
t.prototype.Initialize = function(t) {
this.m_step.Copy(t.step);
this.m_allocator = t.allocator;
this.m_count = t.count;
if (this.m_positionConstraints.length < this.m_count) for (var e = x(2 * this.m_positionConstraints.length, this.m_count); this.m_positionConstraints.length < e; ) this.m_positionConstraints[this.m_positionConstraints.length] = new un();
if (this.m_velocityConstraints.length < this.m_count) for (e = x(2 * this.m_velocityConstraints.length, this.m_count); this.m_velocityConstraints.length < e; ) this.m_velocityConstraints[this.m_velocityConstraints.length] = new ln();
this.m_positions = t.positions;
this.m_velocities = t.velocities;
this.m_contacts = t.contacts;
for (var i = 0; i < this.m_count; ++i) {
var n = this.m_contacts[i], r = n.m_fixtureA, s = n.m_fixtureB, o = r.GetShape(), a = s.GetShape(), c = o.m_radius, h = a.m_radius, l = r.GetBody(), u = s.GetBody(), _ = n.GetManifold(), f = _.pointCount, d = this.m_velocityConstraints[i];
d.friction = n.m_friction;
d.restitution = n.m_restitution;
d.tangentSpeed = n.m_tangentSpeed;
d.indexA = l.m_islandIndex;
d.indexB = u.m_islandIndex;
d.invMassA = l.m_invMass;
d.invMassB = u.m_invMass;
d.invIA = l.m_invI;
d.invIB = u.m_invI;
d.contactIndex = i;
d.pointCount = f;
d.K.SetZero();
d.normalMass.SetZero();
var m = this.m_positionConstraints[i];
m.indexA = l.m_islandIndex;
m.indexB = u.m_islandIndex;
m.invMassA = l.m_invMass;
m.invMassB = u.m_invMass;
m.localCenterA.Copy(l.m_sweep.localCenter);
m.localCenterB.Copy(u.m_sweep.localCenter);
m.invIA = l.m_invI;
m.invIB = u.m_invI;
m.localNormal.Copy(_.localNormal);
m.localPoint.Copy(_.localPoint);
m.pointCount = f;
m.radiusA = c;
m.radiusB = h;
m.type = _.type;
for (var p = 0; p < f; ++p) {
var v = _.points[p], y = d.points[p];
if (this.m_step.warmStarting) {
y.normalImpulse = this.m_step.dtRatio * v.normalImpulse;
y.tangentImpulse = this.m_step.dtRatio * v.tangentImpulse;
} else {
y.normalImpulse = 0;
y.tangentImpulse = 0;
}
y.rA.SetZero();
y.rB.SetZero();
y.normalMass = 0;
y.tangentMass = 0;
y.velocityBias = 0;
m.localPoints[p].Copy(v.localPoint);
}
}
return this;
};
t.prototype.InitializeVelocityConstraints = function() {
for (var e = t.InitializeVelocityConstraints_s_xfA, i = t.InitializeVelocityConstraints_s_xfB, n = t.InitializeVelocityConstraints_s_worldManifold, r = 0; r < this.m_count; ++r) {
var s = this.m_velocityConstraints[r], o = this.m_positionConstraints[r], a = o.radiusA, c = o.radiusB, h = this.m_contacts[s.contactIndex].GetManifold(), l = s.indexA, u = s.indexB, _ = s.invMassA, f = s.invMassB, d = s.invIA, m = s.invIB, p = o.localCenterA, v = o.localCenterB, y = this.m_positions[l].c, g = this.m_positions[l].a, x = this.m_velocities[l].v, C = this.m_velocities[l].w, A = this.m_positions[u].c, b = this.m_positions[u].a, S = this.m_velocities[u].v, T = this.m_velocities[u].w;
e.q.SetAngle(g);
i.q.SetAngle(b);
P.SubVV(y, O.MulRV(e.q, p, P.s_t0), e.p);
P.SubVV(A, O.MulRV(i.q, v, P.s_t0), i.p);
n.Initialize(h, e, a, i, c);
s.normal.Copy(n.normal);
P.CrossVOne(s.normal, s.tangent);
for (var w = s.pointCount, E = 0; E < w; ++E) {
var B = s.points[E];
P.SubVV(n.points[E], y, B.rA);
P.SubVV(n.points[E], A, B.rB);
var M = P.CrossVV(B.rA, s.normal), D = P.CrossVV(B.rB, s.normal), I = _ + f + d * M * M + m * D * D;
B.normalMass = I > 0 ? 1 / I : 0;
var R = s.tangent, L = P.CrossVV(B.rA, R), F = P.CrossVV(B.rB, R), V = _ + f + d * L * L + m * F * F;
B.tangentMass = V > 0 ? 1 / V : 0;
B.velocityBias = 0;
var N = P.DotVV(s.normal, P.SubVV(P.AddVCrossSV(S, T, B.rB, P.s_t0), P.AddVCrossSV(x, C, B.rA, P.s_t1), P.s_t0));
N < -1 && (B.velocityBias += -s.restitution * N);
}
s.pointCount;
}
};
t.prototype.WarmStart = function() {
for (var e = t.WarmStart_s_P, i = 0; i < this.m_count; ++i) {
for (var n = this.m_velocityConstraints[i], r = n.indexA, s = n.indexB, o = n.invMassA, a = n.invIA, c = n.invMassB, h = n.invIB, l = n.pointCount, u = this.m_velocities[r].v, _ = this.m_velocities[r].w, f = this.m_velocities[s].v, d = this.m_velocities[s].w, m = n.normal, p = n.tangent, v = 0; v < l; ++v) {
var y = n.points[v];
P.AddVV(P.MulSV(y.normalImpulse, m, P.s_t0), P.MulSV(y.tangentImpulse, p, P.s_t1), e);
_ -= a * P.CrossVV(y.rA, e);
u.SelfMulSub(o, e);
d += h * P.CrossVV(y.rB, e);
f.SelfMulAdd(c, e);
}
this.m_velocities[r].w = _;
this.m_velocities[s].w = d;
}
};
t.prototype.SolveVelocityConstraints = function() {
for (var e = t.SolveVelocityConstraints_s_dv, i = (t.SolveVelocityConstraints_s_dv1, 
t.SolveVelocityConstraints_s_dv2, t.SolveVelocityConstraints_s_P), n = (t.SolveVelocityConstraints_s_a, 
t.SolveVelocityConstraints_s_b, t.SolveVelocityConstraints_s_x, t.SolveVelocityConstraints_s_d, 
t.SolveVelocityConstraints_s_P1, t.SolveVelocityConstraints_s_P2, t.SolveVelocityConstraints_s_P1P2, 
0); n < this.m_count; ++n) {
for (var r = this.m_velocityConstraints[n], s = r.indexA, o = r.indexB, a = r.invMassA, c = r.invIA, h = r.invMassB, l = r.invIB, u = r.pointCount, _ = this.m_velocities[s].v, f = this.m_velocities[s].w, d = this.m_velocities[o].v, m = this.m_velocities[o].w, p = r.normal, v = r.tangent, y = r.friction, g = 0; g < u; ++g) {
var A = r.points[g];
P.SubVV(P.AddVCrossSV(d, m, A.rB, P.s_t0), P.AddVCrossSV(_, f, A.rA, P.s_t1), e);
var b = P.DotVV(e, v) - r.tangentSpeed, S = A.tangentMass * -b, T = y * A.normalImpulse;
S = (w = C(A.tangentImpulse + S, -T, T)) - A.tangentImpulse;
A.tangentImpulse = w;
P.MulSV(S, v, i);
_.SelfMulSub(a, i);
f -= c * P.CrossVV(A.rA, i);
d.SelfMulAdd(h, i);
m += l * P.CrossVV(A.rB, i);
}
r.pointCount;
for (g = 0; g < u; ++g) {
A = r.points[g];
P.SubVV(P.AddVCrossSV(d, m, A.rB, P.s_t0), P.AddVCrossSV(_, f, A.rA, P.s_t1), e);
var w, E = P.DotVV(e, p);
S = -A.normalMass * (E - A.velocityBias);
S = (w = x(A.normalImpulse + S, 0)) - A.normalImpulse;
A.normalImpulse = w;
P.MulSV(S, p, i);
_.SelfMulSub(a, i);
f -= c * P.CrossVV(A.rA, i);
d.SelfMulAdd(h, i);
m += l * P.CrossVV(A.rB, i);
}
this.m_velocities[s].w = f;
this.m_velocities[o].w = m;
}
};
t.prototype.StoreImpulses = function() {
for (var t = 0; t < this.m_count; ++t) for (var e = this.m_velocityConstraints[t], i = this.m_contacts[e.contactIndex].GetManifold(), n = 0; n < e.pointCount; ++n) {
i.points[n].normalImpulse = e.points[n].normalImpulse;
i.points[n].tangentImpulse = e.points[n].tangentImpulse;
}
};
t.prototype.SolvePositionConstraints = function() {
for (var e = t.SolvePositionConstraints_s_xfA, i = t.SolvePositionConstraints_s_xfB, n = t.SolvePositionConstraints_s_psm, r = t.SolvePositionConstraints_s_rA, s = t.SolvePositionConstraints_s_rB, o = t.SolvePositionConstraints_s_P, a = 0, h = 0; h < this.m_count; ++h) {
for (var l = this.m_positionConstraints[h], u = l.indexA, _ = l.indexB, f = l.localCenterA, d = l.invMassA, m = l.invIA, p = l.localCenterB, v = l.invMassB, y = l.invIB, x = l.pointCount, A = this.m_positions[u].c, b = this.m_positions[u].a, S = this.m_positions[_].c, T = this.m_positions[_].a, w = 0; w < x; ++w) {
e.q.SetAngle(b);
i.q.SetAngle(T);
P.SubVV(A, O.MulRV(e.q, f, P.s_t0), e.p);
P.SubVV(S, O.MulRV(i.q, p, P.s_t0), i.p);
n.Initialize(l, e, i, w);
var E = n.normal, B = n.point, M = n.separation;
P.SubVV(B, A, r);
P.SubVV(B, S, s);
a = g(a, M);
var D = C(.2 * (M + c), -.2, 0), I = P.CrossVV(r, E), R = P.CrossVV(s, E), L = d + v + m * I * I + y * R * R, F = L > 0 ? -D / L : 0;
P.MulSV(F, E, o);
A.SelfMulSub(d, o);
b -= m * P.CrossVV(r, o);
S.SelfMulAdd(v, o);
T += y * P.CrossVV(s, o);
}
this.m_positions[u].a = b;
this.m_positions[_].a = T;
}
return a > -3 * c;
};
t.prototype.SolveTOIPositionConstraints = function(e, i) {
for (var n = t.SolveTOIPositionConstraints_s_xfA, r = t.SolveTOIPositionConstraints_s_xfB, s = t.SolveTOIPositionConstraints_s_psm, o = t.SolveTOIPositionConstraints_s_rA, a = t.SolveTOIPositionConstraints_s_rB, h = t.SolveTOIPositionConstraints_s_P, l = 0, u = 0; u < this.m_count; ++u) {
var _ = this.m_positionConstraints[u], f = _.indexA, d = _.indexB, m = _.localCenterA, p = _.localCenterB, v = _.pointCount, y = 0, x = 0;
if (f === e || f === i) {
y = _.invMassA;
x = _.invIA;
}
var A = 0, b = 0;
if (d === e || d === i) {
A = _.invMassB;
b = _.invIB;
}
for (var S = this.m_positions[f].c, T = this.m_positions[f].a, w = this.m_positions[d].c, E = this.m_positions[d].a, B = 0; B < v; ++B) {
n.q.SetAngle(T);
r.q.SetAngle(E);
P.SubVV(S, O.MulRV(n.q, m, P.s_t0), n.p);
P.SubVV(w, O.MulRV(r.q, p, P.s_t0), r.p);
s.Initialize(_, n, r, B);
var M = s.normal, D = s.point, I = s.separation;
P.SubVV(D, S, o);
P.SubVV(D, w, a);
l = g(l, I);
var R = C(.75 * (I + c), -.2, 0), L = P.CrossVV(o, M), F = P.CrossVV(a, M), V = y + A + x * L * L + b * F * F, N = V > 0 ? -R / V : 0;
P.MulSV(N, M, h);
S.SelfMulSub(y, h);
T -= x * P.CrossVV(o, h);
w.SelfMulAdd(A, h);
E += b * P.CrossVV(a, h);
}
this.m_positions[f].a = T;
this.m_positions[d].a = E;
}
return l >= -1.5 * c;
};
t.InitializeVelocityConstraints_s_xfA = new N();
t.InitializeVelocityConstraints_s_xfB = new N();
t.InitializeVelocityConstraints_s_worldManifold = new At();
t.WarmStart_s_P = new P();
t.SolveVelocityConstraints_s_dv = new P();
t.SolveVelocityConstraints_s_dv1 = new P();
t.SolveVelocityConstraints_s_dv2 = new P();
t.SolveVelocityConstraints_s_P = new P();
t.SolveVelocityConstraints_s_a = new P();
t.SolveVelocityConstraints_s_b = new P();
t.SolveVelocityConstraints_s_x = new P();
t.SolveVelocityConstraints_s_d = new P();
t.SolveVelocityConstraints_s_P1 = new P();
t.SolveVelocityConstraints_s_P2 = new P();
t.SolveVelocityConstraints_s_P1P2 = new P();
t.SolvePositionConstraints_s_xfA = new N();
t.SolvePositionConstraints_s_xfB = new N();
t.SolvePositionConstraints_s_psm = new fn();
t.SolvePositionConstraints_s_rA = new P();
t.SolvePositionConstraints_s_rB = new P();
t.SolvePositionConstraints_s_P = new P();
t.SolveTOIPositionConstraints_s_xfA = new N();
t.SolveTOIPositionConstraints_s_xfB = new N();
t.SolveTOIPositionConstraints_s_psm = new fn();
t.SolveTOIPositionConstraints_s_rA = new P();
t.SolveTOIPositionConstraints_s_rB = new P();
t.SolveTOIPositionConstraints_s_P = new P();
return t;
})(), mn = (function() {
function e() {
this.m_allocator = null;
this.m_bodies = [];
this.m_contacts = [];
this.m_joints = [];
this.m_positions = on.MakeArray(1024);
this.m_velocities = an.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;
}
e.prototype.Initialize = function(t, e, i, n, r) {
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_allocator = n;
this.m_listener = r;
if (this.m_positions.length < t) for (var s = x(2 * this.m_positions.length, t); this.m_positions.length < s; ) this.m_positions[this.m_positions.length] = new on();
if (this.m_velocities.length < t) for (s = x(2 * this.m_velocities.length, t); this.m_velocities.length < s; ) this.m_velocities[this.m_velocities.length] = new an();
};
e.prototype.Clear = function() {
this.m_bodyCount = 0;
this.m_contactCount = 0;
this.m_jointCount = 0;
};
e.prototype.AddBody = function(t) {
t.m_islandIndex = this.m_bodyCount;
this.m_bodies[this.m_bodyCount++] = t;
};
e.prototype.AddContact = function(t) {
this.m_contacts[this.m_contactCount++] = t;
};
e.prototype.AddJoint = function(t) {
this.m_joints[this.m_jointCount++] = t;
};
e.prototype.Solve = function(n, r, s, o) {
for (var a = e.s_timer.Reset(), c = r.dt, h = 0; h < this.m_bodyCount; ++h) {
var l = this.m_bodies[h];
this.m_positions[h].c.Copy(l.m_sweep.c);
var u = l.m_sweep.a, _ = this.m_velocities[h].v.Copy(l.m_linearVelocity), f = l.m_angularVelocity;
l.m_sweep.c0.Copy(l.m_sweep.c);
l.m_sweep.a0 = l.m_sweep.a;
if (l.m_type === t.b2BodyType.b2_dynamicBody) {
_.x += c * (l.m_gravityScale * s.x + l.m_invMass * l.m_force.x);
_.y += c * (l.m_gravityScale * s.y + l.m_invMass * l.m_force.y);
f += c * l.m_invI * l.m_torque;
_.SelfMul(1 / (1 + c * l.m_linearDamping));
f *= 1 / (1 + c * l.m_angularDamping);
}
this.m_positions[h].a = u;
this.m_velocities[h].w = f;
}
a.Reset();
var d = e.s_solverData;
d.step.Copy(r);
d.positions = this.m_positions;
d.velocities = this.m_velocities;
var m = e.s_contactSolverDef;
m.step.Copy(r);
m.contacts = this.m_contacts;
m.count = this.m_contactCount;
m.positions = this.m_positions;
m.velocities = this.m_velocities;
m.allocator = this.m_allocator;
var p = e.s_contactSolver.Initialize(m);
p.InitializeVelocityConstraints();
r.warmStarting && p.WarmStart();
for (h = 0; h < this.m_jointCount; ++h) this.m_joints[h].InitVelocityConstraints(d);
n.solveInit = a.GetMilliseconds();
a.Reset();
for (h = 0; h < r.velocityIterations; ++h) {
for (var v = 0; v < this.m_jointCount; ++v) this.m_joints[v].SolveVelocityConstraints(d);
p.SolveVelocityConstraints();
}
p.StoreImpulses();
n.solveVelocity = a.GetMilliseconds();
for (h = 0; h < this.m_bodyCount; ++h) {
var x = this.m_positions[h].c, C = (u = this.m_positions[h].a, _ = this.m_velocities[h].v, 
f = this.m_velocities[h].w, P.MulSV(c, _, e.s_translation));
if (P.DotVV(C, C) > 4) {
var A = 2 / C.Length();
_.SelfMul(A);
}
var b = c * f;
if (b * b > 2.4674011002726646) {
f *= A = 1.570796326795 / y(b);
}
x.x += c * _.x;
x.y += c * _.y;
u += c * f;
this.m_positions[h].a = u;
this.m_velocities[h].w = f;
}
a.Reset();
var S = !1;
for (h = 0; h < r.positionIterations; ++h) {
var T = p.SolvePositionConstraints(), w = !0;
for (v = 0; v < this.m_jointCount; ++v) {
var E = this.m_joints[v].SolvePositionConstraints(d);
w = w && E;
}
if (T && w) {
S = !0;
break;
}
}
for (h = 0; h < this.m_bodyCount; ++h) {
var B = this.m_bodies[h];
B.m_sweep.c.Copy(this.m_positions[h].c);
B.m_sweep.a = this.m_positions[h].a;
B.m_linearVelocity.Copy(this.m_velocities[h].v);
B.m_angularVelocity = this.m_velocities[h].w;
B.SynchronizeTransform();
}
n.solvePosition = a.GetMilliseconds();
this.Report(p.m_velocityConstraints);
if (o) {
var M = i;
for (h = 0; h < this.m_bodyCount; ++h) {
if ((l = this.m_bodies[h]).GetType() !== t.b2BodyType.b2_staticBody) if (!l.m_autoSleepFlag || l.m_angularVelocity * l.m_angularVelocity > .0012184696791469947 || P.DotVV(l.m_linearVelocity, l.m_linearVelocity) > 1e-4) {
l.m_sleepTime = 0;
M = 0;
} else {
l.m_sleepTime += c;
M = g(M, l.m_sleepTime);
}
}
if (M >= .5 && S) for (h = 0; h < this.m_bodyCount; ++h) {
(l = this.m_bodies[h]).SetAwake(!1);
}
}
};
e.prototype.SolveTOI = function(t, i, n) {
for (var r = 0; r < this.m_bodyCount; ++r) {
var s = this.m_bodies[r];
this.m_positions[r].c.Copy(s.m_sweep.c);
this.m_positions[r].a = s.m_sweep.a;
this.m_velocities[r].v.Copy(s.m_linearVelocity);
this.m_velocities[r].w = s.m_angularVelocity;
}
var o = e.s_contactSolverDef;
o.contacts = this.m_contacts;
o.count = this.m_contactCount;
o.allocator = this.m_allocator;
o.step.Copy(t);
o.positions = this.m_positions;
o.velocities = this.m_velocities;
var a = e.s_contactSolver.Initialize(o);
for (r = 0; r < t.positionIterations; ++r) {
if (a.SolveTOIPositionConstraints(i, n)) break;
}
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;
this.m_bodies[n].m_sweep.c0.Copy(this.m_positions[n].c);
this.m_bodies[n].m_sweep.a0 = this.m_positions[n].a;
a.InitializeVelocityConstraints();
for (r = 0; r < t.velocityIterations; ++r) a.SolveVelocityConstraints();
var c = t.dt;
for (r = 0; r < this.m_bodyCount; ++r) {
var h = this.m_positions[r].c, l = this.m_positions[r].a, u = this.m_velocities[r].v, _ = this.m_velocities[r].w, f = P.MulSV(c, u, e.s_translation);
if (P.DotVV(f, f) > 4) {
var d = 2 / f.Length();
u.SelfMul(d);
}
var m = c * _;
if (m * m > 2.4674011002726646) {
_ *= d = 1.570796326795 / y(m);
}
h.SelfMulAdd(c, u);
l += c * _;
this.m_positions[r].a = l;
this.m_velocities[r].w = _;
var p = this.m_bodies[r];
p.m_sweep.c.Copy(h);
p.m_sweep.a = l;
p.m_linearVelocity.Copy(u);
p.m_angularVelocity = _;
p.SynchronizeTransform();
}
this.Report(a.m_velocityConstraints);
};
e.prototype.Report = function(t) {
if (null !== this.m_listener) for (var i = 0; i < this.m_contactCount; ++i) {
var n = this.m_contacts[i];
if (n) {
var r = t[i], s = e.s_impulse;
s.count = r.pointCount;
for (var o = 0; o < r.pointCount; ++o) {
s.normalImpulses[o] = r.points[o].normalImpulse;
s.tangentImpulses[o] = r.points[o].tangentImpulse;
}
this.m_listener.PostSolve(n, s);
}
}
};
e.s_timer = new U();
e.s_solverData = new cn();
e.s_contactSolverDef = new _n();
e.s_contactSolver = new dn();
e.s_translation = new P();
e.s_impulse = new Qi();
return e;
})();
(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 = {}));
var pn = (function() {
return function() {
this.flags = 0;
this.position = new P();
this.velocity = new P();
this.color = new G(0, 0, 0, 0);
this.lifetime = 0;
this.userData = null;
this.group = null;
};
})();
function vn(t, e, i) {
return C(Math.ceil(Math.sqrt(t / (.01 * e)) * i), 1, 8);
}
var yn = (function() {
function t() {
this.m_index = u;
}
t.prototype.GetIndex = function() {
return this.m_index;
};
t.prototype.SetIndex = function(t) {
this.m_index = t;
};
return 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 = {}));
var gn = (function() {
return function() {
this.flags = 0;
this.groupFlags = 0;
this.position = new P();
this.angle = 0;
this.linearVelocity = new P();
this.angularVelocity = 0;
this.color = new G();
this.strength = 1;
this.shapeCount = 0;
this.stride = 0;
this.particleCount = 0;
this.lifetime = 0;
this.userData = null;
this.group = null;
};
})(), xn = (function() {
function e(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 P();
this.m_linearVelocity = new P();
this.m_angularVelocity = 0;
this.m_transform = new N();
this.m_userData = null;
this.m_system = t;
}
e.prototype.GetNext = function() {
return this.m_next;
};
e.prototype.GetParticleSystem = function() {
return this.m_system;
};
e.prototype.GetParticleCount = function() {
return this.m_lastIndex - this.m_firstIndex;
};
e.prototype.GetBufferIndex = function() {
return this.m_firstIndex;
};
e.prototype.ContainsParticle = function(t) {
return this.m_firstIndex <= t && t < this.m_lastIndex;
};
e.prototype.GetAllParticleFlags = function() {
if (!this.m_system.m_flagsBuffer.data) throw new Error();
for (var t = 0, e = this.m_firstIndex; e < this.m_lastIndex; e++) t |= this.m_system.m_flagsBuffer.data[e];
return t;
};
e.prototype.GetGroupFlags = function() {
return this.m_groupFlags;
};
e.prototype.SetGroupFlags = function(e) {
e |= this.m_groupFlags & t.b2ParticleGroupFlag.b2_particleGroupInternalMask;
this.m_system.SetGroupFlags(this, e);
};
e.prototype.GetMass = function() {
this.UpdateStatistics();
return this.m_mass;
};
e.prototype.GetInertia = function() {
this.UpdateStatistics();
return this.m_inertia;
};
e.prototype.GetCenter = function() {
this.UpdateStatistics();
return this.m_center;
};
e.prototype.GetLinearVelocity = function() {
this.UpdateStatistics();
return this.m_linearVelocity;
};
e.prototype.GetAngularVelocity = function() {
this.UpdateStatistics();
return this.m_angularVelocity;
};
e.prototype.GetTransform = function() {
return this.m_transform;
};
e.prototype.GetPosition = function() {
return this.m_transform.p;
};
e.prototype.GetAngle = function() {
return this.m_transform.q.GetAngle();
};
e.prototype.GetLinearVelocityFromWorldPoint = function(t, i) {
var n = e.GetLinearVelocityFromWorldPoint_s_t0;
this.UpdateStatistics();
return P.AddVCrossSV(this.m_linearVelocity, this.m_angularVelocity, P.SubVV(t, this.m_center, n), i);
};
e.prototype.GetUserData = function() {
return this.m_userData;
};
e.prototype.SetUserData = function(t) {
this.m_userData = t;
};
e.prototype.ApplyForce = function(t) {
this.m_system.ApplyForce(this.m_firstIndex, this.m_lastIndex, t);
};
e.prototype.ApplyLinearImpulse = function(t) {
this.m_system.ApplyLinearImpulse(this.m_firstIndex, this.m_lastIndex, t);
};
e.prototype.DestroyParticles = function(t) {
if (this.m_system.m_world.IsLocked()) throw new Error();
for (var e = this.m_firstIndex; e < this.m_lastIndex; e++) this.m_system.DestroyParticle(e, t);
};
e.prototype.UpdateStatistics = function() {
if (!this.m_system.m_positionBuffer.data) throw new Error();
if (!this.m_system.m_velocityBuffer.data) throw new Error();
var t = new P(), e = new P();
if (this.m_timestamp !== this.m_system.m_timestamp) {
var i = this.m_system.GetParticleMass();
this.m_mass = i * (this.m_lastIndex - this.m_firstIndex);
this.m_center.SetZero();
this.m_linearVelocity.SetZero();
for (var n = this.m_firstIndex; n < this.m_lastIndex; n++) {
this.m_center.SelfMulAdd(i, this.m_system.m_positionBuffer.data[n]);
this.m_linearVelocity.SelfMulAdd(i, this.m_system.m_velocityBuffer.data[n]);
}
if (this.m_mass > 0) {
var r = 1 / this.m_mass;
this.m_center.SelfMul(r);
this.m_linearVelocity.SelfMul(r);
}
this.m_inertia = 0;
this.m_angularVelocity = 0;
for (n = this.m_firstIndex; n < this.m_lastIndex; n++) {
P.SubVV(this.m_system.m_positionBuffer.data[n], this.m_center, t);
P.SubVV(this.m_system.m_velocityBuffer.data[n], this.m_linearVelocity, e);
this.m_inertia += i * P.DotVV(t, t);
this.m_angularVelocity += i * P.CrossVV(t, e);
}
this.m_inertia > 0 && (this.m_angularVelocity *= 1 / this.m_inertia);
this.m_timestamp = this.m_system.m_timestamp;
}
};
e.GetLinearVelocityFromWorldPoint_s_t0 = new P();
return e;
})(), Cn = (function() {
function t(t) {
this.m_front = 0;
this.m_back = 0;
this.m_capacity = 0;
this.m_buffer = d(t, (function(t) {
return null;
}));
this.m_capacity = t;
}
t.prototype.Push = function(t) {
if (this.m_back >= this.m_capacity) {
for (var e = this.m_front; e < this.m_back; e++) this.m_buffer[e - this.m_front] = this.m_buffer[e];
this.m_back -= this.m_front;
this.m_front = 0;
if (this.m_back >= this.m_capacity) if (this.m_capacity > 0) {
this.m_buffer.concat(d(this.m_capacity, (function(t) {
return null;
})));
this.m_capacity *= 2;
} else {
this.m_buffer.concat(d(1, (function(t) {
return null;
})));
this.m_capacity = 1;
}
}
this.m_buffer[this.m_back] = t;
this.m_back++;
};
t.prototype.Pop = function() {
this.m_buffer[this.m_front] = null;
this.m_front++;
};
t.prototype.Empty = function() {
return this.m_front === this.m_back;
};
t.prototype.Front = function() {
var t = this.m_buffer[this.m_front];
if (!t) throw new Error();
return t;
};
return t;
})(), An = (function() {
function t(e) {
this.m_generatorCapacity = 0;
this.m_generatorCount = 0;
this.m_countX = 0;
this.m_countY = 0;
this.m_diagram = [];
this.m_generatorBuffer = d(e, (function(e) {
return new t.Generator();
}));
this.m_generatorCapacity = e;
}
t.prototype.AddGenerator = function(t, e, i) {
var n = this.m_generatorBuffer[this.m_generatorCount++];
n.center.Copy(t);
n.tag = e;
n.necessary = i;
};
t.prototype.Generate = function(e, n) {
for (var r = 1 / e, s = new P(+i, +i), o = new P(-i, -i), a = 0, c = 0; c < this.m_generatorCount; c++) {
if ((f = this.m_generatorBuffer[c]).necessary) {
P.MinV(s, f.center, s);
P.MaxV(o, f.center, o);
++a;
}
}
if (0 !== a) {
s.x -= n;
s.y -= n;
o.x += n;
o.y += n;
this.m_countX = 1 + Math.floor(r * (o.x - s.x));
this.m_countY = 1 + Math.floor(r * (o.y - s.y));
this.m_diagram = [];
var h = new Cn(4 * this.m_countX * this.m_countY);
for (c = 0; c < this.m_generatorCount; c++) {
(f = this.m_generatorBuffer[c]).center.SelfSub(s).SelfMul(r);
var l = Math.floor(f.center.x), u = Math.floor(f.center.y);
l >= 0 && u >= 0 && l < this.m_countX && u < this.m_countY && h.Push(new t.Task(l, u, l + u * this.m_countX, f));
}
for (;!h.Empty(); ) {
l = (d = h.Front()).m_x, u = d.m_y;
var _ = d.m_i, f = d.m_generator;
h.Pop();
if (!this.m_diagram[_]) {
this.m_diagram[_] = f;
l > 0 && h.Push(new t.Task(l - 1, u, _ - 1, f));
u > 0 && h.Push(new t.Task(l, u - 1, _ - this.m_countX, f));
l < this.m_countX - 1 && h.Push(new t.Task(l + 1, u, _ + 1, f));
u < this.m_countY - 1 && h.Push(new t.Task(l, u + 1, _ + this.m_countX, f));
}
}
for (u = 0; u < this.m_countY; u++) for (l = 0; l < this.m_countX - 1; l++) {
_ = l + u * this.m_countX;
if ((m = this.m_diagram[_]) !== (p = this.m_diagram[_ + 1])) {
h.Push(new t.Task(l, u, _, p));
h.Push(new t.Task(l + 1, u, _ + 1, m));
}
}
for (u = 0; u < this.m_countY - 1; u++) for (l = 0; l < this.m_countX; l++) {
_ = l + u * this.m_countX;
if ((m = this.m_diagram[_]) !== (p = this.m_diagram[_ + this.m_countX])) {
h.Push(new t.Task(l, u, _, p));
h.Push(new t.Task(l, u + 1, _ + this.m_countX, m));
}
}
for (;!h.Empty(); ) {
var d, m, p;
l = (d = h.Front()).m_x, u = d.m_y, _ = d.m_i, c = d.m_generator;
h.Pop();
if ((m = this.m_diagram[_]) !== (p = c)) {
var v = m.center.x - l, y = m.center.y - u, g = p.center.x - l, x = p.center.y - u;
if (v * v + y * y > g * g + x * x) {
this.m_diagram[_] = p;
l > 0 && h.Push(new t.Task(l - 1, u, _ - 1, p));
u > 0 && h.Push(new t.Task(l, u - 1, _ - this.m_countX, p));
l < this.m_countX - 1 && h.Push(new t.Task(l + 1, u, _ + 1, p));
u < this.m_countY - 1 && h.Push(new t.Task(l, u + 1, _ + this.m_countX, p));
}
}
}
} else {
this.m_countX = 0;
this.m_countY = 0;
}
};
t.prototype.GetNodes = function(t) {
for (var e = 0; e < this.m_countY - 1; e++) for (var i = 0; i < this.m_countX - 1; i++) {
var n = i + e * this.m_countX, r = this.m_diagram[n], s = this.m_diagram[n + 1], o = this.m_diagram[n + this.m_countX], a = this.m_diagram[n + 1 + this.m_countX];
if (s !== o) {
r !== s && r !== o && (r.necessary || s.necessary || o.necessary) && t(r.tag, s.tag, o.tag);
a !== s && a !== o && (r.necessary || s.necessary || o.necessary) && t(s.tag, a.tag, o.tag);
}
}
};
return t;
})();
(function(t) {
var e = (function() {
return function() {
this.center = new P();
this.tag = 0;
this.necessary = !1;
};
})();
t.Generator = e;
var i = (function() {
return function(t, e, i, n) {
this.m_x = t;
this.m_y = e;
this.m_i = i;
this.m_generator = n;
};
})();
t.Task = i;
})(An || (An = {}));
function bn(t, e, i) {
var n = t[e];
t[e] = t[i];
t[i] = n;
}
function Sn(t, e) {
return t < e;
}
function Tn(t, e, i, n) {
void 0 === e && (e = 0);
void 0 === i && (i = t.length - e);
void 0 === n && (n = Sn);
for (var r = e, s = [], o = 0; ;) {
for (;r + 1 < i; i++) {
var a = t[r + Math.floor(Math.random() * (i - r))];
s[o++] = i;
for (var c = r - 1; ;) {
for (;n(t[++c], a); ) ;
for (;n(a, t[--i]); ) ;
if (c >= i) break;
bn(t, c, i);
}
}
if (0 === o) break;
r = i;
i = s[--o];
}
return t;
}
function wn(t, e, i, n) {
void 0 === e && (e = 0);
void 0 === i && (i = t.length - e);
void 0 === n && (n = Sn);
return Tn(t, e, i, n);
}
function En(t, e, i) {
void 0 === i && (i = t.length);
for (var n = 0, r = 0; r < i; ++r) e(t[r]) || (r !== n ? bn(t, n++, r) : ++n);
return n;
}
function Bn(t, e, i, n, r) {
void 0 === r && (r = Sn);
for (var s = i - e; s > 0; ) {
var o = Math.floor(s / 2), a = e + o;
if (r(t[a], n)) {
e = ++a;
s -= o + 1;
} else s = o;
}
return e;
}
function Mn(t, e, i, n, r) {
void 0 === r && (r = Sn);
for (var s = i - e; s > 0; ) {
var o = Math.floor(s / 2), a = e + o;
if (r(n, t[a])) s = o; else {
e = ++a;
s -= o + 1;
}
}
return e;
}
function Dn(t, e, i, n) {
for (var r = i; e !== r; ) {
bn(t, e++, r++);
r === n ? r = i : e === i && (i = r);
}
}
var In = (function() {
function t(t) {
this.data = [];
this.count = 0;
this.capacity = 0;
this.allocator = t;
}
t.prototype.Append = function() {
this.count >= this.capacity && this.Grow();
return this.count++;
};
t.prototype.Reserve = function(t) {
if (!(this.capacity >= t)) {
for (var e = this.capacity; e < t; ++e) this.data[e] = this.allocator();
this.capacity = t;
}
};
t.prototype.Grow = function() {
var t = this.capacity ? 2 * this.capacity : 256;
this.Reserve(t);
};
t.prototype.Free = function() {
if (0 !== this.data.length) {
this.data = [];
this.capacity = 0;
this.count = 0;
}
};
t.prototype.Shorten = function(t) {};
t.prototype.Data = function() {
return this.data;
};
t.prototype.GetCount = function() {
return this.count;
};
t.prototype.SetCount = function(t) {
this.count = t;
};
t.prototype.GetCapacity = function() {
return this.capacity;
};
t.prototype.RemoveIf = function(t) {
this.count = En(this.data, t, this.count);
};
t.prototype.Unique = function(t) {
this.count = (function(t, e, i, n) {
if (e === i) return i;
for (var r = e; ++e !== i; ) n(t[r], t[e]) || bn(t, ++r, e);
return ++r;
})(this.data, 0, this.count, t);
};
return t;
})(), Pn = (function(t) {
Qe(e, t);
function e(e) {
var i = t.call(this) || this;
i.m_system = e;
return i;
}
e.prototype.ShouldQueryParticleSystem = function(t) {
return !1;
};
e.prototype.ReportFixture = function(t) {
if (t.IsSensor()) return !0;
for (var e = t.GetShape().GetChildCount(), i = 0; i < e; i++) for (var n = t.GetAABB(i), r = this.m_system.GetInsideBoundsEnumerator(n), s = void 0; (s = r.GetNext()) >= 0; ) this.ReportFixtureAndParticle(t, i, s);
return !0;
};
e.prototype.ReportParticle = function(t, e) {
return !1;
};
e.prototype.ReportFixtureAndParticle = function(t, e, i) {};
return e;
})(tn), Rn = (function() {
function t() {
this.indexA = 0;
this.indexB = 0;
this.weight = 0;
this.normal = new P();
this.flags = 0;
}
t.prototype.SetIndices = function(t, e) {
this.indexA = t;
this.indexB = e;
};
t.prototype.SetWeight = function(t) {
this.weight = t;
};
t.prototype.SetNormal = function(t) {
this.normal.Copy(t);
};
t.prototype.SetFlags = function(t) {
this.flags = t;
};
t.prototype.GetIndexA = function() {
return this.indexA;
};
t.prototype.GetIndexB = function() {
return this.indexB;
};
t.prototype.GetWeight = function() {
return this.weight;
};
t.prototype.GetNormal = function() {
return this.normal;
};
t.prototype.GetFlags = function() {
return this.flags;
};
t.prototype.IsEqual = function(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;
};
t.prototype.IsNotEqual = function(t) {
return !this.IsEqual(t);
};
t.prototype.ApproximatelyEqual = function(t) {
return this.indexA === t.indexA && this.indexB === t.indexB && this.flags === t.flags && y(this.weight - t.weight) < .01 && P.DistanceSquaredVV(this.normal, t.normal) < 1e-4;
};
return t;
})(), Ln = (function() {
return function() {
this.index = 0;
this.weight = 0;
this.normal = new P();
this.mass = 0;
};
})(), Fn = (function() {
return function() {
this.indexA = 0;
this.indexB = 0;
this.flags = 0;
this.strength = 0;
this.distance = 0;
};
})(), Vn = (function() {
return function() {
this.indexA = 0;
this.indexB = 0;
this.indexC = 0;
this.flags = 0;
this.strength = 0;
this.pa = new P(0, 0);
this.pb = new P(0, 0);
this.pc = new P(0, 0);
this.ka = 0;
this.kb = 0;
this.kc = 0;
this.s = 0;
};
})(), On = (function() {
function t() {
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;
}
t.prototype.Copy = function(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;
};
t.prototype.Clone = function() {
return new t().Copy(this);
};
return t;
})();
t.b2ParticleSystem = (function() {
function n(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 n.UserOverridableBuffer();
this.m_flagsBuffer = new n.UserOverridableBuffer();
this.m_positionBuffer = new n.UserOverridableBuffer();
this.m_velocityBuffer = new n.UserOverridableBuffer();
this.m_forceBuffer = [];
this.m_weightBuffer = [];
this.m_staticPressureBuffer = [];
this.m_accumulationBuffer = [];
this.m_accumulation2Buffer = [];
this.m_depthBuffer = [];
this.m_colorBuffer = new n.UserOverridableBuffer();
this.m_groupBuffer = [];
this.m_userDataBuffer = new n.UserOverridableBuffer();
this.m_stuckThreshold = 0;
this.m_lastBodyContactStepBuffer = new n.UserOverridableBuffer();
this.m_bodyContactCountBuffer = new n.UserOverridableBuffer();
this.m_consecutiveContactStepsBuffer = new n.UserOverridableBuffer();
this.m_stuckParticleBuffer = new In(function() {
return 0;
});
this.m_proxyBuffer = new In(function() {
return new n.Proxy();
});
this.m_contactBuffer = new In(function() {
return new Rn();
});
this.m_bodyContactBuffer = new In(function() {
return new Ln();
});
this.m_pairBuffer = new In(function() {
return new Fn();
});
this.m_triadBuffer = new In(function() {
return new Vn();
});
this.m_expirationTimeBuffer = new n.UserOverridableBuffer();
this.m_indexByExpirationTimeBuffer = new n.UserOverridableBuffer();
this.m_timeElapsed = 0;
this.m_expirationTimeBufferRequiresSorting = !1;
this.m_groupCount = 0;
this.m_groupList = null;
this.m_def = new On();
this.m_prev = null;
this.m_next = 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);
}
n.computeTag = function(t, e) {
return (e + n.yOffset >>> 0 << n.yShift) + (n.xScale * t + n.xOffset >>> 0) >>> 0;
};
n.computeRelativeTag = function(t, e, i) {
return t + (i << n.yShift) + (e << n.xShift) >>> 0;
};
n.prototype.Drop = function() {
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);
};
n.prototype.CreateParticle = function(t) {
if (this.m_world.IsLocked()) throw new Error();
if (this.m_count >= this.m_internalAllocatedCapacity) {
var i = this.m_count ? 2 * this.m_count : 256;
this.ReallocateInternalAllocatedBuffers(i);
}
if (this.m_count >= this.m_internalAllocatedCapacity) {
if (!this.m_def.destroyByAge) return u;
this.DestroyOldestParticle(0, !1);
this.SolveZombie();
}
var n = this.m_count++;
if (!this.m_flagsBuffer.data) throw new Error();
this.m_flagsBuffer.data[n] = 0;
this.m_lastBodyContactStepBuffer.data && (this.m_lastBodyContactStepBuffer.data[n] = 0);
this.m_bodyContactCountBuffer.data && (this.m_bodyContactCountBuffer.data[n] = 0);
this.m_consecutiveContactStepsBuffer.data && (this.m_consecutiveContactStepsBuffer.data[n] = 0);
if (!this.m_positionBuffer.data) throw new Error();
if (!this.m_velocityBuffer.data) throw new Error();
this.m_positionBuffer.data[n] = (this.m_positionBuffer.data[n] || new P()).Copy(e(t.position, P.ZERO));
this.m_velocityBuffer.data[n] = (this.m_velocityBuffer.data[n] || new P()).Copy(e(t.velocity, P.ZERO));
this.m_weightBuffer[n] = 0;
this.m_forceBuffer[n] = (this.m_forceBuffer[n] || new P()).SetZero();
this.m_staticPressureBuffer && (this.m_staticPressureBuffer[n] = 0);
this.m_depthBuffer && (this.m_depthBuffer[n] = 0);
var r = new G().Copy(e(t.color, G.ZERO));
if (this.m_colorBuffer.data || !r.IsZero()) {
this.m_colorBuffer.data = this.RequestBuffer(this.m_colorBuffer.data);
this.m_colorBuffer.data[n] = (this.m_colorBuffer.data[n] || new G()).Copy(r);
}
if (this.m_userDataBuffer.data || t.userData) {
this.m_userDataBuffer.data = this.RequestBuffer(this.m_userDataBuffer.data);
this.m_userDataBuffer.data[n] = t.userData;
}
this.m_handleIndexBuffer.data && (this.m_handleIndexBuffer.data[n] = null);
var s = this.m_proxyBuffer.data[this.m_proxyBuffer.Append()], o = e(t.lifetime, 0), a = o > 0;
if (this.m_expirationTimeBuffer.data || a) {
this.SetParticleLifetime(n, a ? o : this.ExpirationTimeToLifetime(-this.GetQuantizedTimeElapsed()));
if (!this.m_indexByExpirationTimeBuffer.data) throw new Error();
this.m_indexByExpirationTimeBuffer.data[n] = n;
}
s.index = n;
var c = e(t.group, null);
this.m_groupBuffer[n] = c;
if (c) if (c.m_firstIndex < c.m_lastIndex) {
this.RotateBuffer(c.m_firstIndex, c.m_lastIndex, n);
c.m_lastIndex = n + 1;
} else {
c.m_firstIndex = n;
c.m_lastIndex = n + 1;
}
this.SetParticleFlags(n, e(t.flags, 0));
return n;
};
n.prototype.GetParticleHandleFromIndex = function(t) {
this.m_handleIndexBuffer.data = this.RequestBuffer(this.m_handleIndexBuffer.data);
var e = this.m_handleIndexBuffer.data[t];
if (e) return e;
(e = new yn()).SetIndex(t);
this.m_handleIndexBuffer.data[t] = e;
return e;
};
n.prototype.DestroyParticle = function(e, i) {
void 0 === i && (i = !1);
if (!this.m_flagsBuffer.data) throw new Error();
var n = t.b2ParticleFlag.b2_zombieParticle;
i && (n |= t.b2ParticleFlag.b2_destructionListenerParticle);
this.SetParticleFlags(e, this.m_flagsBuffer.data[e] | n);
};
n.prototype.DestroyOldestParticle = function(t, e) {
void 0 === e && (e = !1);
var i = this.GetParticleCount();
if (!this.m_indexByExpirationTimeBuffer.data) throw new Error();
if (!this.m_expirationTimeBuffer.data) throw new Error();
var n = this.m_indexByExpirationTimeBuffer.data[i - (t + 1)], r = this.m_indexByExpirationTimeBuffer.data[t];
this.DestroyParticle(this.m_expirationTimeBuffer.data[n] > 0 ? n : r, e);
};
n.prototype.DestroyParticlesInShape = function(t, e, i) {
void 0 === i && (i = !1);
var r = n.DestroyParticlesInShape_s_aabb;
if (this.m_world.IsLocked()) throw new Error();
var s = new n.DestroyParticlesInShapeCallback(this, t, e, i), o = r;
t.ComputeAABB(o, e, 0);
this.m_world.QueryAABB(s, o);
return s.Destroyed();
};
n.prototype.CreateParticleGroup = function(t) {
var i = n.CreateParticleGroup_s_transform;
if (this.m_world.IsLocked()) throw new Error();
var r = i;
r.SetPositionAngle(e(t.position, P.ZERO), e(t.angle, 0));
var s = this.m_count;
t.shape && this.CreateParticlesWithShapeForGroup(t.shape, t, r);
t.shapes && this.CreateParticlesWithShapesForGroup(t.shapes, e(t.shapeCount, t.shapes.length), t, r);
if (t.positionData) for (var o = e(t.particleCount, t.positionData.length), a = 0; a < o; a++) {
var c = t.positionData[a];
this.CreateParticleForGroup(t, r, c);
}
var h = this.m_count, l = new xn(this);
l.m_firstIndex = s;
l.m_lastIndex = h;
l.m_strength = e(t.strength, 1);
l.m_userData = t.userData;
l.m_transform.Copy(r);
l.m_prev = null;
l.m_next = this.m_groupList;
this.m_groupList && (this.m_groupList.m_prev = l);
this.m_groupList = l;
++this.m_groupCount;
for (a = s; a < h; a++) this.m_groupBuffer[a] = l;
this.SetGroupFlags(l, e(t.groupFlags, 0));
var u = new n.ConnectionFilter();
this.UpdateContacts(!0);
this.UpdatePairsAndTriads(s, h, u);
if (t.group) {
this.JoinParticleGroups(t.group, l);
l = t.group;
}
return l;
};
n.prototype.JoinParticleGroups = function(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);
var i = new n.JoinParticleGroupsFilter(e.m_firstIndex);
this.UpdateContacts(!0);
this.UpdatePairsAndTriads(t.m_firstIndex, e.m_lastIndex, i);
for (var r = e.m_firstIndex; r < e.m_lastIndex; r++) this.m_groupBuffer[r] = t;
var 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);
};
n.prototype.SplitParticleGroup = function(t) {
this.UpdateContacts(!0);
var e = d(t.GetParticleCount(), (function(t) {
return new n.ParticleListNode();
}));
n.InitializeParticleLists(t, e);
this.MergeParticleListsInContact(t, e);
var i = n.FindLongestParticleList(t, e);
this.MergeZombieParticleListNodes(t, e, i);
this.CreateParticleGroupsFromParticleList(t, e, i);
this.UpdatePairsAndTriadsWithParticleList(t, e);
};
n.prototype.GetParticleGroupList = function() {
return this.m_groupList;
};
n.prototype.GetParticleGroupCount = function() {
return this.m_groupCount;
};
n.prototype.GetParticleCount = function() {
return this.m_count;
};
n.prototype.GetMaxParticleCount = function() {
return this.m_def.maxCount;
};
n.prototype.SetMaxParticleCount = function(t) {
this.m_def.maxCount = t;
};
n.prototype.GetAllParticleFlags = function() {
return this.m_allParticleFlags;
};
n.prototype.GetAllGroupFlags = function() {
return this.m_allGroupFlags;
};
n.prototype.SetPaused = function(t) {
this.m_paused = t;
};
n.prototype.GetPaused = function() {
return this.m_paused;
};
n.prototype.SetDensity = function(t) {
this.m_def.density = t;
this.m_inverseDensity = 1 / this.m_def.density;
};
n.prototype.GetDensity = function() {
return this.m_def.density;
};
n.prototype.SetGravityScale = function(t) {
this.m_def.gravityScale = t;
};
n.prototype.GetGravityScale = function() {
return this.m_def.gravityScale;
};
n.prototype.SetDamping = function(t) {
this.m_def.dampingStrength = t;
};
n.prototype.GetDamping = function() {
return this.m_def.dampingStrength;
};
n.prototype.SetStaticPressureIterations = function(t) {
this.m_def.staticPressureIterations = t;
};
n.prototype.GetStaticPressureIterations = function() {
return this.m_def.staticPressureIterations;
};
n.prototype.SetRadius = function(t) {
this.m_particleDiameter = 2 * t;
this.m_squaredDiameter = this.m_particleDiameter * this.m_particleDiameter;
this.m_inverseDiameter = 1 / this.m_particleDiameter;
};
n.prototype.GetRadius = function() {
return this.m_particleDiameter / 2;
};
n.prototype.GetPositionBuffer = function() {
if (!this.m_positionBuffer.data) throw new Error();
return this.m_positionBuffer.data;
};
n.prototype.GetVelocityBuffer = function() {
if (!this.m_velocityBuffer.data) throw new Error();
return this.m_velocityBuffer.data;
};
n.prototype.GetColorBuffer = function() {
this.m_colorBuffer.data = this.RequestBuffer(this.m_colorBuffer.data);
return this.m_colorBuffer.data;
};
n.prototype.GetGroupBuffer = function() {
return this.m_groupBuffer;
};
n.prototype.GetWeightBuffer = function() {
return this.m_weightBuffer;
};
n.prototype.GetUserDataBuffer = function() {
this.m_userDataBuffer.data = this.RequestBuffer(this.m_userDataBuffer.data);
return this.m_userDataBuffer.data;
};
n.prototype.GetFlagsBuffer = function() {
if (!this.m_flagsBuffer.data) throw new Error();
return this.m_flagsBuffer.data;
};
n.prototype.SetParticleFlags = function(e, i) {
if (!this.m_flagsBuffer.data) throw new Error();
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;
};
n.prototype.GetParticleFlags = function(t) {
if (!this.m_flagsBuffer.data) throw new Error();
return this.m_flagsBuffer.data[t];
};
n.prototype.SetFlagsBuffer = function(t, e) {
this.SetUserOverridableBuffer(this.m_flagsBuffer, t, e);
};
n.prototype.SetPositionBuffer = function(t, e) {
this.SetUserOverridableBuffer(this.m_positionBuffer, t, e);
};
n.prototype.SetVelocityBuffer = function(t, e) {
this.SetUserOverridableBuffer(this.m_velocityBuffer, t, e);
};
n.prototype.SetColorBuffer = function(t, e) {
this.SetUserOverridableBuffer(this.m_colorBuffer, t, e);
};
n.prototype.SetUserDataBuffer = function(t, e) {
this.SetUserOverridableBuffer(this.m_userDataBuffer, t, e);
};
n.prototype.GetContacts = function() {
return this.m_contactBuffer.data;
};
n.prototype.GetContactCount = function() {
return this.m_contactBuffer.count;
};
n.prototype.GetBodyContacts = function() {
return this.m_bodyContactBuffer.data;
};
n.prototype.GetBodyContactCount = function() {
return this.m_bodyContactBuffer.count;
};
n.prototype.GetPairs = function() {
return this.m_pairBuffer.data;
};
n.prototype.GetPairCount = function() {
return this.m_pairBuffer.count;
};
n.prototype.GetTriads = function() {
return this.m_triadBuffer.data;
};
n.prototype.GetTriadCount = function() {
return this.m_triadBuffer.count;
};
n.prototype.SetStuckThreshold = function(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);
}
};
n.prototype.GetStuckCandidates = function() {
return this.m_stuckParticleBuffer.Data();
};
n.prototype.GetStuckCandidateCount = function() {
return this.m_stuckParticleBuffer.GetCount();
};
n.prototype.ComputeCollisionEnergy = function() {
if (!this.m_velocityBuffer.data) throw new Error();
for (var t = n.ComputeCollisionEnergy_s_v, e = this.m_velocityBuffer.data, i = 0, r = 0; r < this.m_contactBuffer.count; r++) {
var s = this.m_contactBuffer.data[r], o = s.indexA, a = s.indexB, c = s.normal, h = P.SubVV(e[a], e[o], t), l = P.DotVV(h, c);
l < 0 && (i += l * l);
}
return .5 * this.GetParticleMass() * i;
};
n.prototype.SetStrictContactCheck = function(t) {
this.m_def.strictContactCheck = t;
};
n.prototype.GetStrictContactCheck = function() {
return this.m_def.strictContactCheck;
};
n.prototype.SetParticleLifetime = function(t, e) {
var 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) for (var n = this.GetParticleCount(), r = 0; r < n; ++r) this.m_indexByExpirationTimeBuffer.data[r] = r;
var s = e / this.m_def.lifetimeGranularity, o = s > 0 ? this.GetQuantizedTimeElapsed() + s : s;
if (o !== this.m_expirationTimeBuffer.data[t]) {
this.m_expirationTimeBuffer.data[t] = o;
this.m_expirationTimeBufferRequiresSorting = !0;
}
};
n.prototype.GetParticleLifetime = function(t) {
return this.ExpirationTimeToLifetime(this.GetExpirationTimeBuffer()[t]);
};
n.prototype.SetDestructionByAge = function(t) {
t && this.GetExpirationTimeBuffer();
this.m_def.destroyByAge = t;
};
n.prototype.GetDestructionByAge = function() {
return this.m_def.destroyByAge;
};
n.prototype.GetExpirationTimeBuffer = function() {
this.m_expirationTimeBuffer.data = this.RequestBuffer(this.m_expirationTimeBuffer.data);
return this.m_expirationTimeBuffer.data;
};
n.prototype.ExpirationTimeToLifetime = function(t) {
return (t > 0 ? t - this.GetQuantizedTimeElapsed() : t) * this.m_def.lifetimeGranularity;
};
n.prototype.GetIndexByExpirationTimeBuffer = function() {
this.GetParticleCount() ? this.SetParticleLifetime(0, this.GetParticleLifetime(0)) : this.m_indexByExpirationTimeBuffer.data = this.RequestBuffer(this.m_indexByExpirationTimeBuffer.data);
if (!this.m_indexByExpirationTimeBuffer.data) throw new Error();
return this.m_indexByExpirationTimeBuffer.data;
};
n.prototype.ParticleApplyLinearImpulse = function(t, e) {
this.ApplyLinearImpulse(t, t + 1, e);
};
n.prototype.ApplyLinearImpulse = function(t, e, i) {
if (!this.m_velocityBuffer.data) throw new Error();
for (var n = this.m_velocityBuffer.data, r = (e - t) * this.GetParticleMass(), s = new P().Copy(i).SelfMul(1 / r), o = t; o < e; o++) n[o].SelfAdd(s);
};
n.IsSignificantForce = function(t) {
return 0 !== t.x || 0 !== t.y;
};
n.prototype.ParticleApplyForce = function(t, e) {
if (!this.m_flagsBuffer.data) throw new Error();
if (n.IsSignificantForce(e) && this.ForceCanBeApplied(this.m_flagsBuffer.data[t])) {
this.PrepareForceBuffer();
this.m_forceBuffer[t].SelfAdd(e);
}
};
n.prototype.ApplyForce = function(t, e, i) {
var r = new P().Copy(i).SelfMul(1 / (e - t));
if (n.IsSignificantForce(r)) {
this.PrepareForceBuffer();
for (var s = t; s < e; s++) this.m_forceBuffer[s].SelfAdd(r);
}
};
n.prototype.GetNext = function() {
return this.m_next;
};
n.prototype.QueryAABB = function(t, e) {
if (0 !== this.m_proxyBuffer.count) {
var i = this.m_proxyBuffer.count, r = Bn(this.m_proxyBuffer.data, 0, i, n.computeTag(this.m_inverseDiameter * e.lowerBound.x, this.m_inverseDiameter * e.lowerBound.y), n.Proxy.CompareProxyTag), s = Mn(this.m_proxyBuffer.data, r, i, n.computeTag(this.m_inverseDiameter * e.upperBound.x, this.m_inverseDiameter * e.upperBound.y), n.Proxy.CompareTagProxy);
if (!this.m_positionBuffer.data) throw new Error();
for (var o = this.m_positionBuffer.data, a = r; a < s; ++a) {
var c = this.m_proxyBuffer.data[a].index, h = o[c];
if (e.lowerBound.x < h.x && h.x < e.upperBound.x && e.lowerBound.y < h.y && h.y < e.upperBound.y && !t.ReportParticle(this, c)) break;
}
}
};
n.prototype.QueryShapeAABB = function(t, e, i, r) {
void 0 === r && (r = 0);
var s = n.QueryShapeAABB_s_aabb;
e.ComputeAABB(s, i, r);
this.QueryAABB(t, s);
};
n.prototype.QueryPointAABB = function(t, e, i) {
void 0 === i && (i = c);
var r = n.QueryPointAABB_s_aabb;
r.lowerBound.Set(e.x - i, e.y - i);
r.upperBound.Set(e.x + i, e.y + i);
this.QueryAABB(t, r);
};
n.prototype.RayCast = function(t, e, i) {
var r = n.RayCast_s_aabb, s = n.RayCast_s_p, o = n.RayCast_s_v, a = n.RayCast_s_n, c = n.RayCast_s_point;
if (0 !== this.m_proxyBuffer.count) {
if (!this.m_positionBuffer.data) throw new Error();
var h = this.m_positionBuffer.data, l = r;
P.MinV(e, i, l.lowerBound);
P.MaxV(e, i, l.upperBound);
for (var u, _ = 1, f = P.SubVV(i, e, o), d = P.DotVV(f, f), m = this.GetInsideBoundsEnumerator(l); (u = m.GetNext()) >= 0; ) {
var p = P.SubVV(e, h[u], s), v = P.DotVV(p, f), y = v * v - d * (P.DotVV(p, p) - this.m_squaredDiameter);
if (y >= 0) {
var x = T(y), C = (-v - x) / d;
if (C > _) continue;
if (C < 0 && ((C = (-v + x) / d) < 0 || C > _)) continue;
var A = P.AddVMulSV(p, C, f, a);
A.Normalize();
var b = t.ReportParticle(this, u, P.AddVMulSV(e, C, f, c), A, C);
if ((_ = g(_, b)) <= 0) break;
}
}
}
};
n.prototype.ComputeAABB = function(t) {
var e = this.GetParticleCount();
t.lowerBound.x = +i;
t.lowerBound.y = +i;
t.upperBound.x = -i;
t.upperBound.y = -i;
if (!this.m_positionBuffer.data) throw new Error();
for (var n = this.m_positionBuffer.data, r = 0; r < e; r++) {
var s = n[r];
P.MinV(t.lowerBound, s, t.lowerBound);
P.MaxV(t.upperBound, s, 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;
};
n.prototype.FreeBuffer = function(t, e) {
null !== t && (t.length = 0);
};
n.prototype.FreeUserOverridableBuffer = function(t) {
0 === t.userSuppliedCapacity && this.FreeBuffer(t.data, this.m_internalAllocatedCapacity);
};
n.prototype.ReallocateBuffer3 = function(t, e, i) {
if (i <= e) throw new Error();
var n = t ? t.slice() : [];
n.length = i;
return n;
};
n.prototype.ReallocateBuffer5 = function(t, e, i, n, r) {
if (n <= i) throw new Error();
if (e && !(n <= e)) throw new Error();
r && !t || e || (t = this.ReallocateBuffer3(t, i, n));
return t;
};
n.prototype.ReallocateBuffer4 = function(t, e, i, n) {
return this.ReallocateBuffer5(t.data, t.userSuppliedCapacity, e, i, n);
};
n.prototype.RequestBuffer = function(t) {
if (!t) {
0 === this.m_internalAllocatedCapacity && this.ReallocateInternalAllocatedBuffers(256);
(t = []).length = this.m_internalAllocatedCapacity;
}
return t;
};
n.prototype.ReallocateHandleBuffers = function(t) {
this.m_handleIndexBuffer.data = this.ReallocateBuffer4(this.m_handleIndexBuffer, this.m_internalAllocatedCapacity, t, !0);
};
n.prototype.ReallocateInternalAllocatedBuffers = function(t) {
function e(t, e) {
return e && t > e ? e : t;
}
t = e(t = e(t = e(t = e(t = e(t = e(t, this.m_def.maxCount), this.m_flagsBuffer.userSuppliedCapacity), this.m_positionBuffer.userSuppliedCapacity), this.m_velocityBuffer.userSuppliedCapacity), this.m_colorBuffer.userSuppliedCapacity), 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);
var i = this.m_stuckThreshold > 0;
this.m_lastBodyContactStepBuffer.data = this.ReallocateBuffer4(this.m_lastBodyContactStepBuffer, this.m_internalAllocatedCapacity, t, i);
this.m_bodyContactCountBuffer.data = this.ReallocateBuffer4(this.m_bodyContactCountBuffer, this.m_internalAllocatedCapacity, t, i);
this.m_consecutiveContactStepsBuffer.data = this.ReallocateBuffer4(this.m_consecutiveContactStepsBuffer, this.m_internalAllocatedCapacity, t, i);
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;
}
};
n.prototype.CreateParticleForGroup = function(t, i, n) {
var r = new pn();
r.flags = e(t.flags, 0);
N.MulXV(i, n, r.position);
P.AddVV(e(t.linearVelocity, P.ZERO), P.CrossSV(e(t.angularVelocity, 0), P.SubVV(r.position, e(t.position, P.ZERO), P.s_t0), P.s_t0), r.velocity);
r.color.Copy(e(t.color, G.ZERO));
r.lifetime = e(t.lifetime, 0);
r.userData = t.userData;
this.CreateParticle(r);
};
n.prototype.CreateParticlesStrokeShapeForGroup = function(i, r, s) {
var o = n.CreateParticlesStrokeShapeForGroup_s_edge, a = n.CreateParticlesStrokeShapeForGroup_s_d, c = n.CreateParticlesStrokeShapeForGroup_s_p, h = e(r.stride, 0);
0 === h && (h = this.GetParticleStride());
for (var l = 0, u = i.GetChildCount(), _ = 0; _ < u; _++) {
var f = null;
if (i.GetType() === t.b2ShapeType.e_edgeShape) f = i; else {
f = o;
i.GetChildEdge(f, _);
}
for (var d = P.SubVV(f.m_vertex2, f.m_vertex1, a), m = d.Length(); l < m; ) {
var p = P.AddVMulSV(f.m_vertex1, l / m, d, c);
this.CreateParticleForGroup(r, s, p);
l += h;
}
l -= m;
}
};
n.prototype.CreateParticlesFillShapeForGroup = function(t, i, r) {
var s = n.CreateParticlesFillShapeForGroup_s_aabb, o = n.CreateParticlesFillShapeForGroup_s_p, a = e(i.stride, 0);
0 === a && (a = this.GetParticleStride());
var c = N.IDENTITY, h = s;
t.ComputeAABB(h, c, 0);
for (var l = Math.floor(h.lowerBound.y / a) * a; l < h.upperBound.y; l += a) for (var u = Math.floor(h.lowerBound.x / a) * a; u < h.upperBound.x; u += a) {
var _ = o.Set(u, l);
t.TestPoint(c, _) && this.CreateParticleForGroup(i, r, _);
}
};
n.prototype.CreateParticlesWithShapeForGroup = function(e, i, n) {
switch (e.GetType()) {
case t.b2ShapeType.e_edgeShape:
case t.b2ShapeType.e_chainShape:
this.CreateParticlesStrokeShapeForGroup(e, i, n);
break;

case t.b2ShapeType.e_polygonShape:
case t.b2ShapeType.e_circleShape:
this.CreateParticlesFillShapeForGroup(e, i, n);
}
};
n.prototype.CreateParticlesWithShapesForGroup = function(t, e, i, r) {
var s = new n.CompositeShape(t, e);
this.CreateParticlesFillShapeForGroup(s, i, r);
};
n.prototype.CloneParticle = function(t, e) {
var i = new pn();
if (!this.m_flagsBuffer.data) throw new Error();
if (!this.m_positionBuffer.data) throw new Error();
if (!this.m_velocityBuffer.data) throw new Error();
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;
var n = this.CreateParticle(i);
if (this.m_handleIndexBuffer.data) {
var r = this.m_handleIndexBuffer.data[t];
r && r.SetIndex(n);
this.m_handleIndexBuffer.data[n] = r;
this.m_handleIndexBuffer.data[t] = null;
}
this.m_lastBodyContactStepBuffer.data && (this.m_lastBodyContactStepBuffer.data[n] = this.m_lastBodyContactStepBuffer.data[t]);
this.m_bodyContactCountBuffer.data && (this.m_bodyContactCountBuffer.data[n] = this.m_bodyContactCountBuffer.data[t]);
this.m_consecutiveContactStepsBuffer.data && (this.m_consecutiveContactStepsBuffer.data[n] = this.m_consecutiveContactStepsBuffer.data[t]);
this.m_hasForce && this.m_forceBuffer[n].Copy(this.m_forceBuffer[t]);
this.m_staticPressureBuffer && (this.m_staticPressureBuffer[n] = this.m_staticPressureBuffer[t]);
this.m_depthBuffer && (this.m_depthBuffer[n] = this.m_depthBuffer[t]);
this.m_expirationTimeBuffer.data && (this.m_expirationTimeBuffer.data[n] = this.m_expirationTimeBuffer.data[t]);
return n;
};
n.prototype.DestroyParticlesInGroup = function(t, e) {
void 0 === e && (e = !1);
for (var i = t.m_firstIndex; i < t.m_lastIndex; i++) this.DestroyParticle(i, e);
};
n.prototype.DestroyParticleGroup = function(t) {
this.m_world.m_destructionListener && this.m_world.m_destructionListener.SayGoodbyeParticleGroup(t);
this.SetGroupFlags(t, 0);
for (var 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;
};
n.ParticleCanBeConnected = function(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);
};
n.prototype.UpdatePairsAndTriads = function(e, i, r) {
var s = n.UpdatePairsAndTriads_s_dab, o = n.UpdatePairsAndTriads_s_dbc, a = n.UpdatePairsAndTriads_s_dca;
if (!this.m_flagsBuffer.data) throw new Error();
if (!this.m_positionBuffer.data) throw new Error();
if (!this.m_velocityBuffer.data) throw new Error();
for (var c = this.m_positionBuffer.data, h = 0, l = e; l < i; l++) h |= this.m_flagsBuffer.data[l];
if (h & n.k_pairFlags) for (var u = 0; u < this.m_contactBuffer.count; u++) {
var _ = this.m_contactBuffer.data[u], f = _.indexA, d = _.indexB, m = this.m_flagsBuffer.data[f], p = this.m_flagsBuffer.data[d], v = this.m_groupBuffer[f], y = this.m_groupBuffer[d];
if (f >= e && f < i && d >= e && d < i && !((m | p) & t.b2ParticleFlag.b2_zombieParticle) && (m | p) & n.k_pairFlags && (r.IsNecessary(f) || r.IsNecessary(d)) && n.ParticleCanBeConnected(m, v) && n.ParticleCanBeConnected(p, y) && r.ShouldCreatePair(f, d)) {
var x = this.m_pairBuffer.data[this.m_pairBuffer.Append()];
x.indexA = f;
x.indexB = d;
x.flags = _.flags;
x.strength = g(v ? v.m_strength : 1, y ? y.m_strength : 1);
x.distance = P.DistanceVV(c[f], c[d]);
}
wn(this.m_pairBuffer.data, 0, this.m_pairBuffer.count, n.ComparePairIndices);
this.m_pairBuffer.Unique(n.MatchPairIndices);
}
if (h & n.k_triadFlags) {
var C = new An(i - e);
for (l = e; l < i; l++) {
var A = this.m_flagsBuffer.data[l], b = this.m_groupBuffer[l];
A & t.b2ParticleFlag.b2_zombieParticle || !n.ParticleCanBeConnected(A, b) || C.AddGenerator(c[l], l, r.IsNecessary(l));
}
var S = this.GetParticleStride();
C.Generate(S / 2, 2 * S);
var T = this;
C.GetNodes((function(t, e, i) {
if (!T.m_flagsBuffer.data) throw new Error();
var h = T.m_flagsBuffer.data[t], l = T.m_flagsBuffer.data[e], u = T.m_flagsBuffer.data[i];
if ((h | l | u) & n.k_triadFlags && r.ShouldCreateTriad(t, e, i)) {
var _ = c[t], f = c[e], d = c[i], m = P.SubVV(_, f, s), p = P.SubVV(f, d, o), v = P.SubVV(d, _, a), y = 4 * T.m_squaredDiameter;
if (P.DotVV(m, m) > y || P.DotVV(p, p) > y || P.DotVV(v, v) > y) return;
var x = T.m_groupBuffer[t], C = T.m_groupBuffer[e], A = T.m_groupBuffer[i], b = T.m_triadBuffer.data[T.m_triadBuffer.Append()];
b.indexA = t;
b.indexB = e;
b.indexC = i;
b.flags = h | l | u;
b.strength = g(g(x ? x.m_strength : 1, C ? C.m_strength : 1), A ? A.m_strength : 1);
var S = (_.x + f.x + d.x) / 3, w = (_.y + f.y + d.y) / 3;
b.pa.x = _.x - S;
b.pa.y = _.y - w;
b.pb.x = f.x - S;
b.pb.y = f.y - w;
b.pc.x = d.x - S;
b.pc.y = d.y - w;
b.ka = -P.DotVV(v, m);
b.kb = -P.DotVV(m, p);
b.kc = -P.DotVV(p, v);
b.s = P.CrossVV(_, f) + P.CrossVV(f, d) + P.CrossVV(d, _);
}
}));
wn(this.m_triadBuffer.data, 0, this.m_triadBuffer.count, n.CompareTriadIndices);
this.m_triadBuffer.Unique(n.MatchTriadIndices);
}
};
n.prototype.UpdatePairsAndTriadsWithReactiveParticles = function() {
var e = new n.ReactiveFilter(this.m_flagsBuffer);
this.UpdatePairsAndTriads(0, this.m_count, e);
if (!this.m_flagsBuffer.data) throw new Error();
for (var i = 0; i < this.m_count; i++) this.m_flagsBuffer.data[i] &= ~t.b2ParticleFlag.b2_reactiveParticle;
this.m_allParticleFlags &= ~t.b2ParticleFlag.b2_reactiveParticle;
};
n.ComparePairIndices = function(t, e) {
var i = t.indexA - e.indexA;
return 0 !== i ? i < 0 : t.indexB < e.indexB;
};
n.MatchPairIndices = function(t, e) {
return t.indexA === e.indexA && t.indexB === e.indexB;
};
n.CompareTriadIndices = function(t, e) {
var i = t.indexA - e.indexA;
if (0 !== i) return i < 0;
var n = t.indexB - e.indexB;
return 0 !== n ? n < 0 : t.indexC < e.indexC;
};
n.MatchTriadIndices = function(t, e) {
return t.indexA === e.indexA && t.indexB === e.indexB && t.indexC === e.indexC;
};
n.InitializeParticleLists = function(t, e) {
for (var i = t.GetBufferIndex(), n = t.GetParticleCount(), r = 0; r < n; r++) {
var s = e[r];
s.list = s;
s.next = null;
s.count = 1;
s.index = r + i;
}
};
n.prototype.MergeParticleListsInContact = function(t, e) {
for (var i = t.GetBufferIndex(), r = 0; r < this.m_contactBuffer.count; r++) {
var s = this.m_contactBuffer.data[r], o = s.indexA, a = s.indexB;
if (t.ContainsParticle(o) && t.ContainsParticle(a)) {
var c = e[o - i].list, h = e[a - i].list;
if (c !== h) {
if (c.count < h.count) {
var l = c;
c = h;
h = l;
}
n.MergeParticleLists(c, h);
}
}
}
};
n.MergeParticleLists = function(t, e) {
for (var i = e; ;) {
i.list = t;
var n = i.next;
if (!n) {
i.next = t.next;
break;
}
i = n;
}
t.next = e;
t.count += e.count;
e.count = 0;
};
n.FindLongestParticleList = function(t, e) {
for (var i = t.GetParticleCount(), n = e[0], r = 0; r < i; r++) {
var s = e[r];
n.count < s.count && (n = s);
}
return n;
};
n.prototype.MergeZombieParticleListNodes = function(e, i, r) {
if (!this.m_flagsBuffer.data) throw new Error();
for (var s = e.GetParticleCount(), o = 0; o < s; o++) {
var a = i[o];
a !== r && this.m_flagsBuffer.data[a.index] & t.b2ParticleFlag.b2_zombieParticle && n.MergeParticleListAndNode(r, a);
}
};
n.MergeParticleListAndNode = function(t, e) {
e.list = t;
e.next = t.next;
t.next = e;
t.count++;
e.count = 0;
};
n.prototype.CreateParticleGroupsFromParticleList = function(e, i, n) {
if (!this.m_flagsBuffer.data) throw new Error();
var r = e.GetParticleCount(), s = new gn();
s.groupFlags = e.GetGroupFlags();
s.userData = e.GetUserData();
for (var o = 0; o < r; o++) {
var a = i[o];
if (a.count && a !== n) for (var c = this.CreateParticleGroup(s), h = a; h; h = h.next) {
var l = h.index, u = this.CloneParticle(l, c);
this.m_flagsBuffer.data[l] |= t.b2ParticleFlag.b2_zombieParticle;
h.index = u;
}
}
};
n.prototype.UpdatePairsAndTriadsWithParticleList = function(t, e) {
for (var i = t.GetBufferIndex(), n = 0; n < this.m_pairBuffer.count; n++) {
var r = this.m_pairBuffer.data[n], s = r.indexA, o = r.indexB;
t.ContainsParticle(s) && (r.indexA = e[s - i].index);
t.ContainsParticle(o) && (r.indexB = e[o - i].index);
}
for (n = 0; n < this.m_triadBuffer.count; n++) {
var a = this.m_triadBuffer.data[n], c = (s = a.indexA, o = a.indexB, a.indexC);
t.ContainsParticle(s) && (a.indexA = e[s - i].index);
t.ContainsParticle(o) && (a.indexB = e[o - i].index);
t.ContainsParticle(c) && (a.indexC = e[c - i].index);
}
};
n.prototype.ComputeDepth = function() {
for (var e = [], n = 0, r = 0; r < this.m_contactBuffer.count; r++) {
var s = (y = this.m_contactBuffer.data[r]).indexA, o = y.indexB, a = this.m_groupBuffer[s], c = this.m_groupBuffer[o];
a && a === c && a.m_groupFlags & t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth && (e[n++] = y);
}
for (var h = [], l = 0, u = this.m_groupList; u; u = u.GetNext()) if (u.m_groupFlags & t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth) {
h[l++] = u;
this.SetGroupFlags(u, u.m_groupFlags & ~t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth);
for (var _ = u.m_firstIndex; _ < u.m_lastIndex; _++) this.m_accumulationBuffer[_] = 0;
}
for (r = 0; r < n; r++) {
s = (y = e[r]).indexA, o = y.indexB;
var f = y.weight;
this.m_accumulationBuffer[s] += f;
this.m_accumulationBuffer[o] += f;
}
for (_ = 0; _ < l; _++) for (var d = (u = h[_]).m_firstIndex; d < u.m_lastIndex; d++) {
f = this.m_accumulationBuffer[d];
this.m_depthBuffer[d] = f < .8 ? 0 : i;
}
for (var m = T(this.m_count) >> 0, p = 0; p < m; p++) {
var v = !1;
for (r = 0; r < n; r++) {
s = (y = e[r]).indexA, o = y.indexB;
var y, g = 1 - y.weight, x = this.m_depthBuffer[s], C = this.m_depthBuffer[o], A = C + g, b = x + g;
if (x > A) {
this.m_depthBuffer[s] = A;
v = !0;
}
if (C > b) {
this.m_depthBuffer[o] = b;
v = !0;
}
}
if (!v) break;
}
for (_ = 0; _ < l; _++) for (var S = (u = h[_]).m_firstIndex; S < u.m_lastIndex; S++) this.m_depthBuffer[S] < i ? this.m_depthBuffer[S] *= this.m_particleDiameter : this.m_depthBuffer[S] = 0;
};
n.prototype.GetInsideBoundsEnumerator = function(t) {
var e = n.computeTag(this.m_inverseDiameter * t.lowerBound.x - 1, this.m_inverseDiameter * t.lowerBound.y - 1), i = n.computeTag(this.m_inverseDiameter * t.upperBound.x + 1, this.m_inverseDiameter * t.upperBound.y + 1), r = this.m_proxyBuffer.count, s = Bn(this.m_proxyBuffer.data, 0, r, e, n.Proxy.CompareProxyTag), o = Mn(this.m_proxyBuffer.data, 0, r, i, n.Proxy.CompareTagProxy);
return new n.InsideBoundsEnumerator(this, e, i, s, o);
};
n.prototype.UpdateAllParticleFlags = function() {
if (!this.m_flagsBuffer.data) throw new Error();
this.m_allParticleFlags = 0;
for (var t = 0; t < this.m_count; t++) this.m_allParticleFlags |= this.m_flagsBuffer.data[t];
this.m_needsUpdateAllParticleFlags = !1;
};
n.prototype.UpdateAllGroupFlags = function() {
this.m_allGroupFlags = 0;
for (var t = this.m_groupList; t; t = t.GetNext()) this.m_allGroupFlags |= t.m_groupFlags;
this.m_needsUpdateAllGroupFlags = !1;
};
n.prototype.AddContact = function(t, e, i) {
if (!this.m_flagsBuffer.data) throw new Error();
if (!this.m_positionBuffer.data) throw new Error();
var r = n.AddContact_s_d, s = this.m_positionBuffer.data, o = P.SubVV(s[e], s[t], r), a = P.DotVV(o, o);
if (a < this.m_squaredDiameter) {
var c = S(a);
isFinite(c) || (c = 198177537e11);
var h = this.m_contactBuffer.data[this.m_contactBuffer.Append()];
h.indexA = t;
h.indexB = e;
h.flags = this.m_flagsBuffer.data[t] | this.m_flagsBuffer.data[e];
h.weight = 1 - a * c * this.m_inverseDiameter;
P.MulSV(c, o, h.normal);
}
};
n.prototype.FindContacts_Reference = function(t) {
var e = this.m_proxyBuffer.count;
this.m_contactBuffer.count = 0;
for (var i = 0, r = 0; i < e; i++) {
for (var s = n.computeRelativeTag(this.m_proxyBuffer.data[i].tag, 1, 0), o = i + 1; o < e && !(s < this.m_proxyBuffer.data[o].tag); o++) this.AddContact(this.m_proxyBuffer.data[i].index, this.m_proxyBuffer.data[o].index, this.m_contactBuffer);
for (var a = n.computeRelativeTag(this.m_proxyBuffer.data[i].tag, -1, 1); r < e && !(a <= this.m_proxyBuffer.data[r].tag); r++) ;
var c = n.computeRelativeTag(this.m_proxyBuffer.data[i].tag, 1, 1);
for (o = r; o < e && !(c < this.m_proxyBuffer.data[o].tag); o++) this.AddContact(this.m_proxyBuffer.data[i].index, this.m_proxyBuffer.data[o].index, this.m_contactBuffer);
}
};
n.prototype.FindContacts = function(t) {
this.FindContacts_Reference(t);
};
n.prototype.UpdateProxies_Reference = function(t) {
if (!this.m_positionBuffer.data) throw new Error();
for (var e = this.m_positionBuffer.data, i = this.m_inverseDiameter, r = 0; r < this.m_proxyBuffer.count; ++r) {
var s = this.m_proxyBuffer.data[r], o = e[s.index];
s.tag = n.computeTag(i * o.x, i * o.y);
}
};
n.prototype.UpdateProxies = function(t) {
this.UpdateProxies_Reference(t);
};
n.prototype.SortProxies = function(t) {
Tn(this.m_proxyBuffer.data, 0, this.m_proxyBuffer.count, n.Proxy.CompareProxyProxy);
};
n.prototype.FilterContacts = function(e) {
var i = this.GetParticleContactFilter();
if (null !== i) {
var n = this;
this.m_contactBuffer.RemoveIf((function(e) {
return 0 != (e.flags & t.b2ParticleFlag.b2_particleContactFilterParticle) && !i.ShouldCollideParticleParticle(n, e.indexA, e.indexB);
}));
}
};
n.prototype.NotifyContactListenerPreContact = function(t) {
if (null !== this.GetParticleContactListener()) {
t.Initialize(this.m_contactBuffer, this.m_flagsBuffer);
throw new Error();
}
};
n.prototype.NotifyContactListenerPostContact = function(t) {
var e = this.GetParticleContactListener();
if (null !== e) {
for (var i = 0; i < this.m_contactBuffer.count; ++i) {
var n = this.m_contactBuffer.data[i];
e.BeginContactParticleParticle(this, n);
}
throw new Error();
}
};
n.b2ParticleContactIsZombie = function(e) {
return (e.flags & t.b2ParticleFlag.b2_zombieParticle) === t.b2ParticleFlag.b2_zombieParticle;
};
n.prototype.UpdateContacts = function(t) {
this.UpdateProxies(this.m_proxyBuffer);
this.SortProxies(this.m_proxyBuffer);
var e = new n.b2ParticlePairSet();
this.NotifyContactListenerPreContact(e);
this.FindContacts(this.m_contactBuffer);
this.FilterContacts(this.m_contactBuffer);
this.NotifyContactListenerPostContact(e);
t && this.m_contactBuffer.RemoveIf(n.b2ParticleContactIsZombie);
};
n.prototype.NotifyBodyContactListenerPreContact = function(t) {
if (null !== this.GetFixtureContactListener()) {
t.Initialize(this.m_bodyContactBuffer, this.m_flagsBuffer);
throw new Error();
}
};
n.prototype.NotifyBodyContactListenerPostContact = function(t) {
var e = this.GetFixtureContactListener();
if (null !== e) {
for (var i = 0; i < this.m_bodyContactBuffer.count; i++) {
var n = this.m_bodyContactBuffer.data[i];
e.BeginContactFixtureParticle(this, n);
}
throw new Error();
}
};
n.prototype.UpdateBodyContacts = function() {
var t = n.UpdateBodyContacts_s_aabb, e = new n.FixtureParticleSet();
this.NotifyBodyContactListenerPreContact(e);
if (this.m_stuckThreshold > 0) {
if (!this.m_bodyContactCountBuffer.data) throw new Error();
if (!this.m_lastBodyContactStepBuffer.data) throw new Error();
if (!this.m_consecutiveContactStepsBuffer.data) throw new Error();
for (var i = this.GetParticleCount(), r = 0; r < i; r++) {
this.m_bodyContactCountBuffer.data[r] = 0;
this.m_timestamp > this.m_lastBodyContactStepBuffer.data[r] + 1 && (this.m_consecutiveContactStepsBuffer.data[r] = 0);
}
}
this.m_bodyContactBuffer.SetCount(0);
this.m_stuckParticleBuffer.SetCount(0);
var s = t;
this.ComputeAABB(s);
var o = new n.UpdateBodyContactsCallback(this, this.GetFixtureContactFilter());
this.m_world.QueryAABB(o, s);
this.m_def.strictContactCheck && this.RemoveSpuriousBodyContacts();
this.NotifyBodyContactListenerPostContact(e);
};
n.prototype.Solve = function(e) {
var i = n.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;
var r = i.Copy(e);
r.dt /= e.particleIterations;
r.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(r);
this.m_allParticleFlags & t.b2ParticleFlag.b2_viscousParticle && this.SolveViscous();
this.m_allParticleFlags & t.b2ParticleFlag.b2_repulsiveParticle && this.SolveRepulsive(r);
this.m_allParticleFlags & t.b2ParticleFlag.b2_powderParticle && this.SolvePowder(r);
this.m_allParticleFlags & t.b2ParticleFlag.b2_tensileParticle && this.SolveTensile(r);
this.m_allGroupFlags & t.b2ParticleGroupFlag.b2_solidParticleGroup && this.SolveSolid(r);
this.m_allParticleFlags & t.b2ParticleFlag.b2_colorMixingParticle && this.SolveColorMixing();
this.SolveGravity(r);
this.m_allParticleFlags & t.b2ParticleFlag.b2_staticPressureParticle && this.SolveStaticPressure(r);
this.SolvePressure(r);
this.SolveDamping(r);
this.m_allParticleFlags & n.k_extraDampingFlags && this.SolveExtraDamping();
this.m_allParticleFlags & t.b2ParticleFlag.b2_elasticParticle && this.SolveElastic(r);
this.m_allParticleFlags & t.b2ParticleFlag.b2_springParticle && this.SolveSpring(r);
this.LimitVelocity(r);
this.m_allGroupFlags & t.b2ParticleGroupFlag.b2_rigidParticleGroup && this.SolveRigidDamping();
this.m_allParticleFlags & t.b2ParticleFlag.b2_barrierParticle && this.SolveBarrier(r);
this.SolveCollision(r);
this.m_allGroupFlags & t.b2ParticleGroupFlag.b2_rigidParticleGroup && this.SolveRigid(r);
this.m_allParticleFlags & t.b2ParticleFlag.b2_wallParticle && this.SolveWall();
if (!this.m_positionBuffer.data) throw new Error();
if (!this.m_velocityBuffer.data) throw new Error();
for (var s = 0; s < this.m_count; s++) this.m_positionBuffer.data[s].SelfMulAdd(r.dt, this.m_velocityBuffer.data[s]);
}
}
};
n.prototype.SolveCollision = function(t) {
var e = n.SolveCollision_s_aabb;
if (!this.m_positionBuffer.data) throw new Error();
if (!this.m_velocityBuffer.data) throw new Error();
var r = this.m_positionBuffer.data, s = this.m_velocityBuffer.data, o = e;
o.lowerBound.x = +i;
o.lowerBound.y = +i;
o.upperBound.x = -i;
o.upperBound.y = -i;
for (var a = 0; a < this.m_count; a++) {
var c = s[a], h = r[a], l = h.x + t.dt * c.x, u = h.y + t.dt * c.y;
o.lowerBound.x = g(o.lowerBound.x, g(h.x, l));
o.lowerBound.y = g(o.lowerBound.y, g(h.y, u));
o.upperBound.x = x(o.upperBound.x, x(h.x, l));
o.upperBound.y = x(o.upperBound.y, x(h.y, u));
}
var _ = new n.SolveCollisionCallback(this, t);
this.m_world.QueryAABB(_, o);
};
n.prototype.LimitVelocity = function(t) {
if (!this.m_velocityBuffer.data) throw new Error();
for (var e = this.m_velocityBuffer.data, i = this.GetCriticalVelocitySquared(t), n = 0; n < this.m_count; n++) {
var r = e[n], s = P.DotVV(r, r);
s > i && r.SelfMul(T(i / s));
}
};
n.prototype.SolveGravity = function(t) {
if (!this.m_velocityBuffer.data) throw new Error();
for (var e = n.SolveGravity_s_gravity, i = this.m_velocityBuffer.data, r = P.MulSV(t.dt * this.m_def.gravityScale, this.m_world.GetGravity(), e), s = 0; s < this.m_count; s++) i[s].SelfAdd(r);
};
n.prototype.SolveBarrier = function(e) {
var i = n.SolveBarrier_s_aabb, r = n.SolveBarrier_s_va, s = n.SolveBarrier_s_vb, o = n.SolveBarrier_s_pba, a = n.SolveBarrier_s_vba, c = n.SolveBarrier_s_vc, h = n.SolveBarrier_s_pca, l = n.SolveBarrier_s_vca, u = n.SolveBarrier_s_qba, _ = n.SolveBarrier_s_qca, f = n.SolveBarrier_s_dv, d = n.SolveBarrier_s_f;
if (!this.m_flagsBuffer.data) throw new Error();
if (!this.m_positionBuffer.data) throw new Error();
if (!this.m_velocityBuffer.data) throw new Error();
for (var m = this.m_positionBuffer.data, p = this.m_velocityBuffer.data, v = 0; v < this.m_count; v++) {
0 != (this.m_flagsBuffer.data[v] & n.k_barrierWallFlags) && p[v].SetZero();
}
for (var y = 2.5 * e.dt, g = this.GetParticleMass(), x = 0; x < this.m_pairBuffer.count; x++) {
var C = this.m_pairBuffer.data[x];
if (C.flags & t.b2ParticleFlag.b2_barrierParticle) {
var A = C.indexA, b = C.indexB, S = m[A], w = m[b], E = i;
P.MinV(S, w, E.lowerBound);
P.MaxV(S, w, E.upperBound);
for (var B = this.m_groupBuffer[A], M = this.m_groupBuffer[b], D = this.GetLinearVelocity(B, A, S, r), I = this.GetLinearVelocity(M, b, w, s), R = P.SubVV(w, S, o), L = P.SubVV(I, D, a), F = this.GetInsideBoundsEnumerator(E), V = void 0; (V = F.GetNext()) >= 0; ) {
var O = m[V], N = this.m_groupBuffer[V];
if (B !== N && M !== N) {
var k = this.GetLinearVelocity(N, V, O, c), G = P.SubVV(O, S, h), z = P.SubVV(k, D, l), U = P.CrossVV(L, z), j = P.CrossVV(R, z) - P.CrossVV(G, L), H = P.CrossVV(R, G), W = void 0, q = void 0, X = u, Y = _;
if (0 === U) {
if (0 === j) continue;
if (!((q = -H / j) >= 0 && q < y)) continue;
P.AddVMulSV(R, q, L, X);
P.AddVMulSV(G, q, z, Y);
if (!((W = P.DotVV(X, Y) / P.DotVV(X, X)) >= 0 && W <= 1)) continue;
} else {
var J = j * j - 4 * H * U;
if (J < 0) continue;
var Z = T(J), K = (-j - Z) / (2 * U), Q = (-j + Z) / (2 * U);
if (K > Q) {
var $ = K;
K = Q;
Q = $;
}
q = K;
P.AddVMulSV(R, q, L, X);
P.AddVMulSV(G, q, z, Y);
W = P.DotVV(X, Y) / P.DotVV(X, X);
if (!(q >= 0 && q < y && W >= 0 && W <= 1)) {
if (!((q = Q) >= 0 && q < y)) continue;
P.AddVMulSV(R, q, L, X);
P.AddVMulSV(G, q, z, Y);
if (!((W = P.DotVV(X, Y) / P.DotVV(X, X)) >= 0 && W <= 1)) continue;
}
}
var tt = f;
tt.x = D.x + W * L.x - k.x;
tt.y = D.y + W * L.y - k.y;
var et = P.MulSV(g, tt, d);
if (N && this.IsRigidGroup(N)) {
var it = N.GetMass(), nt = N.GetInertia();
it > 0 && N.m_linearVelocity.SelfMulAdd(1 / it, et);
nt > 0 && (N.m_angularVelocity += P.CrossVV(P.SubVV(O, N.GetCenter(), P.s_t0), et) / nt);
} else p[V].SelfAdd(tt);
this.ParticleApplyForce(V, et.SelfMul(-e.inv_dt));
}
}
}
}
};
n.prototype.SolveStaticPressure = function(e) {
if (!this.m_flagsBuffer.data) throw new Error();
this.m_staticPressureBuffer = this.RequestBuffer(this.m_staticPressureBuffer);
for (var i = this.GetCriticalPressure(e), n = this.m_def.staticPressureStrength * i, r = .25 * i, s = this.m_def.staticPressureRelaxation, o = 0; o < this.m_def.staticPressureIterations; o++) {
for (var a = 0; a < this.m_count; a++) this.m_accumulationBuffer[a] = 0;
for (var c = 0; c < this.m_contactBuffer.count; c++) {
var h = this.m_contactBuffer.data[c];
if (h.flags & t.b2ParticleFlag.b2_staticPressureParticle) {
var l = h.indexA, u = h.indexB, _ = h.weight;
this.m_accumulationBuffer[l] += _ * this.m_staticPressureBuffer[u];
this.m_accumulationBuffer[u] += _ * this.m_staticPressureBuffer[l];
}
}
for (a = 0; a < this.m_count; a++) {
_ = this.m_weightBuffer[a];
if (this.m_flagsBuffer.data[a] & t.b2ParticleFlag.b2_staticPressureParticle) {
var f = (this.m_accumulationBuffer[a] + n * (_ - 1)) / (_ + s);
this.m_staticPressureBuffer[a] = C(f, 0, r);
} else this.m_staticPressureBuffer[a] = 0;
}
}
};
n.prototype.ComputeWeight = function() {
for (var t = 0; t < this.m_count; t++) this.m_weightBuffer[t] = 0;
for (t = 0; t < this.m_bodyContactBuffer.count; t++) {
var e = (n = this.m_bodyContactBuffer.data[t]).index, i = n.weight;
this.m_weightBuffer[e] += i;
}
for (t = 0; t < this.m_contactBuffer.count; t++) {
e = (n = this.m_contactBuffer.data[t]).indexA;
var n, r = n.indexB;
i = n.weight;
this.m_weightBuffer[e] += i;
this.m_weightBuffer[r] += i;
}
};
n.prototype.SolvePressure = function(e) {
var i = n.SolvePressure_s_f;
if (!this.m_flagsBuffer.data) throw new Error();
if (!this.m_positionBuffer.data) throw new Error();
if (!this.m_velocityBuffer.data) throw new Error();
for (var r = this.m_positionBuffer.data, s = this.m_velocityBuffer.data, o = this.GetCriticalPressure(e), a = this.m_def.pressureStrength * o, c = .25 * o, h = 0; h < this.m_count; h++) {
var l = this.m_weightBuffer[h], u = a * x(0, l - 1);
this.m_accumulationBuffer[h] = g(u, c);
}
if (this.m_allParticleFlags & n.k_noPressureFlags) for (h = 0; h < this.m_count; h++) this.m_flagsBuffer.data[h] & n.k_noPressureFlags && (this.m_accumulationBuffer[h] = 0);
if (this.m_allParticleFlags & t.b2ParticleFlag.b2_staticPressureParticle) for (h = 0; h < this.m_count; h++) this.m_flagsBuffer.data[h] & t.b2ParticleFlag.b2_staticPressureParticle && (this.m_accumulationBuffer[h] += this.m_staticPressureBuffer[h]);
for (var _ = e.dt / (this.m_def.density * this.m_particleDiameter), f = this.GetParticleInvMass(), d = 0; d < this.m_bodyContactBuffer.count; d++) {
var m = (b = this.m_bodyContactBuffer.data[d]).index, p = b.body, v = (l = b.weight, 
b.mass), y = b.normal, C = r[m], A = (u = this.m_accumulationBuffer[m] + a * l, 
P.MulSV(_ * l * v * u, y, i));
s[m].SelfMulSub(f, A);
p.ApplyLinearImpulse(A, C, !0);
}
for (d = 0; d < this.m_contactBuffer.count; d++) {
var b;
m = (b = this.m_contactBuffer.data[d]).indexA, p = b.indexB, l = b.weight, y = b.normal, 
u = this.m_accumulationBuffer[m] + this.m_accumulationBuffer[p], A = P.MulSV(_ * l * u, y, i);
s[m].SelfSub(A);
s[p].SelfAdd(A);
}
};
n.prototype.SolveDamping = function(t) {
var e = n.SolveDamping_s_v, i = n.SolveDamping_s_f;
if (!this.m_positionBuffer.data) throw new Error();
if (!this.m_velocityBuffer.data) throw new Error();
for (var r = this.m_positionBuffer.data, s = this.m_velocityBuffer.data, o = this.m_def.dampingStrength, a = 1 / this.GetCriticalVelocity(t), c = this.GetParticleInvMass(), h = 0; h < this.m_bodyContactBuffer.count; h++) {
var l = (C = this.m_bodyContactBuffer.data[h]).index, u = C.body, _ = C.weight, f = C.mass, d = C.normal, m = r[l], p = P.SubVV(u.GetLinearVelocityFromWorldPoint(m, P.s_t0), s[l], e);
if ((A = P.DotVV(p, d)) < 0) {
var v = x(o * _, g(-a * A, .5)), y = P.MulSV(v * f * A, d, i);
s[l].SelfMulAdd(c, y);
u.ApplyLinearImpulse(y.SelfNeg(), m, !0);
}
}
for (h = 0; h < this.m_contactBuffer.count; h++) {
var C, A;
l = (C = this.m_contactBuffer.data[h]).indexA, u = C.indexB, _ = C.weight, d = C.normal, 
p = P.SubVV(s[u], s[l], e);
if ((A = P.DotVV(p, d)) < 0) {
v = x(o * _, g(-a * A, .5)), y = P.MulSV(v * A, d, i);
s[l].SelfAdd(y);
s[u].SelfSub(y);
}
}
};
n.prototype.SolveRigidDamping = function() {
var t = n.SolveRigidDamping_s_t0, e = n.SolveRigidDamping_s_t1, i = n.SolveRigidDamping_s_p, r = n.SolveRigidDamping_s_v, s = [ 0 ], o = [ 0 ], a = [ 0 ], c = [ 0 ], h = [ 0 ], l = [ 0 ];
if (!this.m_positionBuffer.data) throw new Error();
for (var u = this.m_positionBuffer.data, _ = this.m_def.dampingStrength, f = 0; f < this.m_bodyContactBuffer.count; f++) {
var d = (A = this.m_bodyContactBuffer.data[f]).index;
if ((b = this.m_groupBuffer[d]) && this.IsRigidGroup(b)) {
var m = A.body, p = A.normal, v = A.weight, y = u[d], x = P.SubVV(m.GetLinearVelocityFromWorldPoint(y, t), b.GetLinearVelocityFromWorldPoint(y, e), r);
if ((E = P.DotVV(x, p)) < 0) {
this.InitDampingParameterWithRigidGroupOrParticle(s, o, a, !0, b, d, y, p);
this.InitDampingParameter(c, h, l, m.GetMass(), m.GetInertia() - m.GetMass() * m.GetLocalCenter().LengthSquared(), m.GetWorldCenter(), y, p);
var C = _ * g(v, 1) * this.ComputeDampingImpulse(s[0], o[0], a[0], c[0], h[0], l[0], E);
this.ApplyDamping(s[0], o[0], a[0], !0, b, d, C, p);
m.ApplyLinearImpulse(P.MulSV(-C, p, P.s_t0), y, !0);
}
}
}
for (f = 0; f < this.m_contactBuffer.count; f++) {
d = (A = this.m_contactBuffer.data[f]).indexA, m = A.indexB, p = A.normal, v = A.weight;
var A, b = this.m_groupBuffer[d], S = this.m_groupBuffer[m], T = this.IsRigidGroup(b), w = this.IsRigidGroup(S);
if (b !== S && (T || w)) {
var E;
y = P.MidVV(u[d], u[m], i), x = P.SubVV(this.GetLinearVelocity(S, m, y, t), this.GetLinearVelocity(b, d, y, e), r);
if ((E = P.DotVV(x, p)) < 0) {
this.InitDampingParameterWithRigidGroupOrParticle(s, o, a, T, b, d, y, p);
this.InitDampingParameterWithRigidGroupOrParticle(c, h, l, w, S, m, y, p);
C = _ * v * this.ComputeDampingImpulse(s[0], o[0], a[0], c[0], h[0], l[0], E);
this.ApplyDamping(s[0], o[0], a[0], T, b, d, C, p);
this.ApplyDamping(c[0], h[0], l[0], w, S, m, -C, p);
}
}
}
};
n.prototype.SolveExtraDamping = function() {
var t = n.SolveExtraDamping_s_v, e = n.SolveExtraDamping_s_f;
if (!this.m_flagsBuffer.data) throw new Error();
if (!this.m_positionBuffer.data) throw new Error();
if (!this.m_velocityBuffer.data) throw new Error();
for (var i = this.m_velocityBuffer.data, r = this.m_positionBuffer.data, s = this.GetParticleInvMass(), o = 0; o < this.m_bodyContactBuffer.count; o++) {
var a = this.m_bodyContactBuffer.data[o], c = a.index;
if (this.m_flagsBuffer.data[c] & n.k_extraDampingFlags) {
var h = a.body, l = a.mass, u = a.normal, _ = r[c], f = P.SubVV(h.GetLinearVelocityFromWorldPoint(_, P.s_t0), i[c], t), d = P.DotVV(f, u);
if (d < 0) {
var m = P.MulSV(.5 * l * d, u, e);
i[c].SelfMulAdd(s, m);
h.ApplyLinearImpulse(m.SelfNeg(), _, !0);
}
}
}
};
n.prototype.SolveWall = function() {
if (!this.m_flagsBuffer.data) throw new Error();
if (!this.m_velocityBuffer.data) throw new Error();
for (var e = this.m_velocityBuffer.data, i = 0; i < this.m_count; i++) this.m_flagsBuffer.data[i] & t.b2ParticleFlag.b2_wallParticle && e[i].SetZero();
};
n.prototype.SolveRigid = function(e) {
var i = n.SolveRigid_s_position, r = n.SolveRigid_s_rotation, s = n.SolveRigid_s_transform, o = n.SolveRigid_s_velocityTransform;
if (!this.m_positionBuffer.data) throw new Error();
if (!this.m_velocityBuffer.data) throw new Error();
for (var a = this.m_positionBuffer.data, c = this.m_velocityBuffer.data, h = this.m_groupList; h; h = h.GetNext()) if (h.m_groupFlags & t.b2ParticleGroupFlag.b2_rigidParticleGroup) {
h.UpdateStatistics();
var l = r;
l.SetAngle(e.dt * h.m_angularVelocity);
var u = P.AddVV(h.m_center, P.SubVV(P.MulSV(e.dt, h.m_linearVelocity, P.s_t0), O.MulRV(l, h.m_center, P.s_t1), P.s_t0), i), _ = s;
_.SetPositionRotation(u, l);
N.MulXX(_, h.m_transform, h.m_transform);
var f = o;
f.p.x = e.inv_dt * _.p.x;
f.p.y = e.inv_dt * _.p.y;
f.q.s = e.inv_dt * _.q.s;
f.q.c = e.inv_dt * (_.q.c - 1);
for (var d = h.m_firstIndex; d < h.m_lastIndex; d++) N.MulXV(f, a[d], c[d]);
}
};
n.prototype.SolveElastic = function(e) {
var i = n.SolveElastic_s_pa, r = n.SolveElastic_s_pb, s = n.SolveElastic_s_pc, o = n.SolveElastic_s_r, a = n.SolveElastic_s_t0;
if (!this.m_positionBuffer.data) throw new Error();
if (!this.m_velocityBuffer.data) throw new Error();
for (var c = this.m_positionBuffer.data, h = this.m_velocityBuffer.data, l = e.inv_dt * this.m_def.elasticStrength, u = 0; u < this.m_triadBuffer.count; u++) {
var _ = this.m_triadBuffer.data[u];
if (_.flags & t.b2ParticleFlag.b2_elasticParticle) {
var f = _.indexA, d = _.indexB, m = _.indexC, p = _.pa, v = _.pb, y = _.pc, g = i.Copy(c[f]), x = r.Copy(c[d]), C = s.Copy(c[m]), A = h[f], b = h[d], T = h[m];
g.SelfMulAdd(e.dt, A);
x.SelfMulAdd(e.dt, b);
C.SelfMulAdd(e.dt, T);
var w = (g.x + x.x + C.x) / 3, E = (g.y + x.y + C.y) / 3;
g.x -= w;
g.y -= E;
x.x -= w;
x.y -= E;
C.x -= w;
C.y -= E;
var B = o;
B.s = P.CrossVV(p, g) + P.CrossVV(v, x) + P.CrossVV(y, C);
B.c = P.DotVV(p, g) + P.DotVV(v, x) + P.DotVV(y, C);
var M = S(B.s * B.s + B.c * B.c);
isFinite(M) || (M = 198177537e11);
B.s *= M;
B.c *= M;
var D = l * _.strength;
O.MulRV(B, p, a);
P.SubVV(a, g, a);
P.MulSV(D, a, a);
A.SelfAdd(a);
O.MulRV(B, v, a);
P.SubVV(a, x, a);
P.MulSV(D, a, a);
b.SelfAdd(a);
O.MulRV(B, y, a);
P.SubVV(a, C, a);
P.MulSV(D, a, a);
T.SelfAdd(a);
}
}
};
n.prototype.SolveSpring = function(e) {
var i = n.SolveSpring_s_pa, r = n.SolveSpring_s_pb, s = n.SolveSpring_s_d, o = n.SolveSpring_s_f;
if (!this.m_positionBuffer.data) throw new Error();
if (!this.m_velocityBuffer.data) throw new Error();
for (var a = this.m_positionBuffer.data, c = this.m_velocityBuffer.data, h = e.inv_dt * this.m_def.springStrength, l = 0; l < this.m_pairBuffer.count; l++) {
var u = this.m_pairBuffer.data[l];
if (u.flags & t.b2ParticleFlag.b2_springParticle) {
var _ = u.indexA, f = u.indexB, d = i.Copy(a[_]), m = r.Copy(a[f]), p = c[_], v = c[f];
d.SelfMulAdd(e.dt, p);
m.SelfMulAdd(e.dt, v);
var y = P.SubVV(m, d, s), g = u.distance, x = y.Length(), C = h * u.strength, A = P.MulSV(C * (g - x) / x, y, o);
p.SelfSub(A);
v.SelfAdd(A);
}
}
};
n.prototype.SolveTensile = function(e) {
var i = n.SolveTensile_s_weightedNormal, r = n.SolveTensile_s_s, s = n.SolveTensile_s_f;
if (!this.m_velocityBuffer.data) throw new Error();
for (var o = this.m_velocityBuffer.data, a = 0; a < this.m_count; a++) {
this.m_accumulation2Buffer[a] = new P();
this.m_accumulation2Buffer[a].SetZero();
}
for (var c = 0; c < this.m_contactBuffer.count; c++) {
if ((y = this.m_contactBuffer.data[c]).flags & t.b2ParticleFlag.b2_tensileParticle) {
var h = y.indexA, l = y.indexB, u = y.weight, _ = y.normal, f = P.MulSV((1 - u) * u, _, i);
this.m_accumulation2Buffer[h].SelfSub(f);
this.m_accumulation2Buffer[l].SelfAdd(f);
}
}
var d = this.GetCriticalVelocity(e), m = this.m_def.surfaceTensionPressureStrength * d, p = this.m_def.surfaceTensionNormalStrength * d, v = .5 * d;
for (c = 0; c < this.m_contactBuffer.count; c++) {
var y;
if ((y = this.m_contactBuffer.data[c]).flags & t.b2ParticleFlag.b2_tensileParticle) {
h = y.indexA, l = y.indexB, u = y.weight, _ = y.normal;
var x = this.m_weightBuffer[h] + this.m_weightBuffer[l], C = P.SubVV(this.m_accumulation2Buffer[l], this.m_accumulation2Buffer[h], r), A = g(m * (x - 2) + p * P.DotVV(C, _), v) * u, b = P.MulSV(A, _, s);
o[h].SelfSub(b);
o[l].SelfAdd(b);
}
}
};
n.prototype.SolveViscous = function() {
var e = n.SolveViscous_s_v, i = n.SolveViscous_s_f;
if (!this.m_flagsBuffer.data) throw new Error();
if (!this.m_positionBuffer.data) throw new Error();
if (!this.m_velocityBuffer.data) throw new Error();
for (var r = this.m_positionBuffer.data, s = this.m_velocityBuffer.data, o = this.m_def.viscousStrength, a = this.GetParticleInvMass(), c = 0; c < this.m_bodyContactBuffer.count; c++) {
var h = (p = this.m_bodyContactBuffer.data[c]).index;
if (this.m_flagsBuffer.data[h] & t.b2ParticleFlag.b2_viscousParticle) {
var l = p.body, u = p.weight, _ = p.mass, f = r[h], d = P.SubVV(l.GetLinearVelocityFromWorldPoint(f, P.s_t0), s[h], e), m = P.MulSV(o * _ * u, d, i);
s[h].SelfMulAdd(a, m);
l.ApplyLinearImpulse(m.SelfNeg(), f, !0);
}
}
for (c = 0; c < this.m_contactBuffer.count; c++) {
var p;
if ((p = this.m_contactBuffer.data[c]).flags & t.b2ParticleFlag.b2_viscousParticle) {
h = p.indexA, l = p.indexB, u = p.weight, d = P.SubVV(s[l], s[h], e), m = P.MulSV(o * u, d, i);
s[h].SelfAdd(m);
s[l].SelfSub(m);
}
}
};
n.prototype.SolveRepulsive = function(e) {
var i = n.SolveRepulsive_s_f;
if (!this.m_velocityBuffer.data) throw new Error();
for (var r = this.m_velocityBuffer.data, s = this.m_def.repulsiveStrength * this.GetCriticalVelocity(e), o = 0; o < this.m_contactBuffer.count; o++) {
var a = this.m_contactBuffer.data[o];
if (a.flags & t.b2ParticleFlag.b2_repulsiveParticle) {
var c = a.indexA, h = a.indexB;
if (this.m_groupBuffer[c] !== this.m_groupBuffer[h]) {
var l = a.weight, u = a.normal, _ = P.MulSV(s * l, u, i);
r[c].SelfSub(_);
r[h].SelfAdd(_);
}
}
}
};
n.prototype.SolvePowder = function(e) {
var i = n.SolvePowder_s_f;
if (!this.m_flagsBuffer.data) throw new Error();
if (!this.m_positionBuffer.data) throw new Error();
if (!this.m_velocityBuffer.data) throw new Error();
for (var r = this.m_positionBuffer.data, s = this.m_velocityBuffer.data, o = this.m_def.powderStrength * this.GetCriticalVelocity(e), a = this.GetParticleInvMass(), c = 0; c < this.m_bodyContactBuffer.count; c++) {
var h = (m = this.m_bodyContactBuffer.data[c]).index;
if (this.m_flagsBuffer.data[h] & t.b2ParticleFlag.b2_powderParticle) {
if ((p = m.weight) > .25) {
var l = m.body, u = m.mass, _ = r[h], f = m.normal, d = P.MulSV(o * u * (p - .25), f, i);
s[h].SelfMulSub(a, d);
l.ApplyLinearImpulse(d, _, !0);
}
}
}
for (c = 0; c < this.m_contactBuffer.count; c++) {
var m;
if ((m = this.m_contactBuffer.data[c]).flags & t.b2ParticleFlag.b2_powderParticle) {
var p;
if ((p = m.weight) > .25) {
h = m.indexA, l = m.indexB, f = m.normal, d = P.MulSV(o * (p - .25), f, i);
s[h].SelfSub(d);
s[l].SelfAdd(d);
}
}
}
};
n.prototype.SolveSolid = function(t) {
var e = n.SolveSolid_s_f;
if (!this.m_velocityBuffer.data) throw new Error();
var i = this.m_velocityBuffer.data;
this.m_depthBuffer = this.RequestBuffer(this.m_depthBuffer);
for (var r = t.inv_dt * this.m_def.ejectionStrength, s = 0; s < this.m_contactBuffer.count; s++) {
var o = this.m_contactBuffer.data[s], a = o.indexA, c = o.indexB;
if (this.m_groupBuffer[a] !== this.m_groupBuffer[c]) {
var h = o.weight, l = o.normal, u = this.m_depthBuffer[a] + this.m_depthBuffer[c], _ = P.MulSV(r * u * h, l, e);
i[a].SelfSub(_);
i[c].SelfAdd(_);
}
}
};
n.prototype.SolveForce = function(t) {
if (!this.m_velocityBuffer.data) throw new Error();
for (var e = this.m_velocityBuffer.data, i = t.dt * this.GetParticleInvMass(), n = 0; n < this.m_count; n++) e[n].SelfMulAdd(i, this.m_forceBuffer[n]);
this.m_hasForce = !1;
};
n.prototype.SolveColorMixing = function() {
if (!this.m_flagsBuffer.data) throw new Error();
if (!this.m_colorBuffer.data) throw new Error();
var e = .5 * this.m_def.colorMixingStrength;
if (e) for (var i = 0; i < this.m_contactBuffer.count; i++) {
var n = this.m_contactBuffer.data[i], r = n.indexA, s = n.indexB;
if (this.m_flagsBuffer.data[r] & this.m_flagsBuffer.data[s] & t.b2ParticleFlag.b2_colorMixingParticle) {
var o = this.m_colorBuffer.data[r], a = this.m_colorBuffer.data[s];
G.MixColors(o, a, e);
}
}
};
n.prototype.SolveZombie = function() {
if (!this.m_flagsBuffer.data) throw new Error();
if (!this.m_positionBuffer.data) throw new Error();
if (!this.m_velocityBuffer.data) throw new Error();
for (var e = 0, i = [], n = 0; n < this.m_count; n++) i[n] = u;
var r = 0;
for (n = 0; n < this.m_count; n++) {
var s = this.m_flagsBuffer.data[n];
if (s & t.b2ParticleFlag.b2_zombieParticle) {
var o = this.m_world.m_destructionListener;
s & t.b2ParticleFlag.b2_destructionListenerParticle && o && o.SayGoodbyeParticle(this, n);
if (this.m_handleIndexBuffer.data) {
if (a = this.m_handleIndexBuffer.data[n]) {
a.SetIndex(u);
this.m_handleIndexBuffer.data[n] = null;
}
}
i[n] = u;
} else {
i[n] = e;
if (n !== e) {
if (this.m_handleIndexBuffer.data) {
var a;
(a = this.m_handleIndexBuffer.data[n]) && a.SetIndex(e);
this.m_handleIndexBuffer.data[e] = a;
}
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++;
r |= s;
}
}
for (var c = function(t) {
return t.index < 0;
}, h = function(t) {
return t.indexA < 0 || t.indexB < 0;
}, l = function(t) {
return t.index < 0;
}, _ = function(t) {
return t.indexA < 0 || t.indexB < 0;
}, f = function(t) {
return t.indexA < 0 || t.indexB < 0 || t.indexC < 0;
}, d = 0; d < this.m_proxyBuffer.count; d++) {
var m = this.m_proxyBuffer.data[d];
m.index = i[m.index];
}
this.m_proxyBuffer.RemoveIf(c);
for (d = 0; d < this.m_contactBuffer.count; d++) {
(p = this.m_contactBuffer.data[d]).indexA = i[p.indexA];
p.indexB = i[p.indexB];
}
this.m_contactBuffer.RemoveIf(h);
for (d = 0; d < this.m_bodyContactBuffer.count; d++) {
var p;
(p = this.m_bodyContactBuffer.data[d]).index = i[p.index];
}
this.m_bodyContactBuffer.RemoveIf(l);
for (d = 0; d < this.m_pairBuffer.count; d++) {
var v = this.m_pairBuffer.data[d];
v.indexA = i[v.indexA];
v.indexB = i[v.indexB];
}
this.m_pairBuffer.RemoveIf(_);
for (d = 0; d < this.m_triadBuffer.count; d++) {
var y = this.m_triadBuffer.data[d];
y.indexA = i[y.indexA];
y.indexB = i[y.indexB];
y.indexC = i[y.indexC];
}
this.m_triadBuffer.RemoveIf(f);
if (this.m_indexByExpirationTimeBuffer.data) for (var C = 0, A = 0; A < this.m_count; A++) {
var b = i[this.m_indexByExpirationTimeBuffer.data[A]];
b !== u && (this.m_indexByExpirationTimeBuffer.data[C++] = b);
}
for (var S = this.m_groupList; S; S = S.GetNext()) {
var T = e, w = 0, E = !1;
for (n = S.m_firstIndex; n < S.m_lastIndex; n++) {
var B = i[n];
if (B >= 0) {
T = g(T, B);
w = x(w, B + 1);
} else E = !0;
}
if (T < w) {
S.m_firstIndex = T;
S.m_lastIndex = w;
E && 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 = r;
this.m_needsUpdateAllParticleFlags = !1;
for (S = this.m_groupList; S; ) {
var M = S.GetNext();
S.m_groupFlags & t.b2ParticleGroupFlag.b2_particleGroupWillBeDestroyed && this.DestroyParticleGroup(S);
S = M;
}
};
n.prototype.SolveLifetimes = function(t) {
if (!this.m_expirationTimeBuffer.data) throw new Error();
if (!this.m_indexByExpirationTimeBuffer.data) throw new Error();
this.m_timeElapsed = this.LifetimeToExpirationTime(t.dt);
var e = this.GetQuantizedTimeElapsed(), i = this.m_expirationTimeBuffer.data, n = this.m_indexByExpirationTimeBuffer.data, r = this.GetParticleCount();
if (this.m_expirationTimeBufferRequiresSorting) {
Tn(n, 0, r, (function(t, e) {
var n = i[t], r = i[e], s = n <= 0;
return s === r <= 0 ? n > r : s;
}));
this.m_expirationTimeBufferRequiresSorting = !1;
}
for (var s = r - 1; s >= 0; --s) {
var o = n[s], a = i[o];
if (e < a || a <= 0) break;
this.DestroyParticle(o);
}
};
n.prototype.RotateBuffer = function(t, e, i) {
if (t !== e && e !== i) {
if (!this.m_flagsBuffer.data) throw new Error();
if (!this.m_positionBuffer.data) throw new Error();
if (!this.m_velocityBuffer.data) throw new Error();
Dn(this.m_flagsBuffer.data, t, e, i);
this.m_lastBodyContactStepBuffer.data && Dn(this.m_lastBodyContactStepBuffer.data, t, e, i);
this.m_bodyContactCountBuffer.data && Dn(this.m_bodyContactCountBuffer.data, t, e, i);
this.m_consecutiveContactStepsBuffer.data && Dn(this.m_consecutiveContactStepsBuffer.data, t, e, i);
Dn(this.m_positionBuffer.data, t, e, i);
Dn(this.m_velocityBuffer.data, t, e, i);
Dn(this.m_groupBuffer, t, e, i);
this.m_hasForce && Dn(this.m_forceBuffer, t, e, i);
this.m_staticPressureBuffer && Dn(this.m_staticPressureBuffer, t, e, i);
this.m_depthBuffer && Dn(this.m_depthBuffer, t, e, i);
this.m_colorBuffer.data && Dn(this.m_colorBuffer.data, t, e, i);
this.m_userDataBuffer.data && Dn(this.m_userDataBuffer.data, t, e, i);
if (this.m_handleIndexBuffer.data) {
Dn(this.m_handleIndexBuffer.data, t, e, i);
for (var n = t; n < i; ++n) {
var r = this.m_handleIndexBuffer.data[n];
r && r.SetIndex(f(r.GetIndex()));
}
}
if (this.m_expirationTimeBuffer.data) {
Dn(this.m_expirationTimeBuffer.data, t, e, i);
var s = this.GetParticleCount();
if (!this.m_indexByExpirationTimeBuffer.data) throw new Error();
var o = this.m_indexByExpirationTimeBuffer.data;
for (n = 0; n < s; ++n) o[n] = f(o[n]);
}
for (var a = 0; a < this.m_proxyBuffer.count; a++) {
var c = this.m_proxyBuffer.data[a];
c.index = f(c.index);
}
for (a = 0; a < this.m_contactBuffer.count; a++) {
(h = this.m_contactBuffer.data[a]).indexA = f(h.indexA);
h.indexB = f(h.indexB);
}
for (a = 0; a < this.m_bodyContactBuffer.count; a++) {
var h;
(h = this.m_bodyContactBuffer.data[a]).index = f(h.index);
}
for (a = 0; a < this.m_pairBuffer.count; a++) {
var l = this.m_pairBuffer.data[a];
l.indexA = f(l.indexA);
l.indexB = f(l.indexB);
}
for (a = 0; a < this.m_triadBuffer.count; a++) {
var u = this.m_triadBuffer.data[a];
u.indexA = f(u.indexA);
u.indexB = f(u.indexB);
u.indexC = f(u.indexC);
}
for (var _ = this.m_groupList; _; _ = _.GetNext()) {
_.m_firstIndex = f(_.m_firstIndex);
_.m_lastIndex = f(_.m_lastIndex - 1) + 1;
}
}
function f(n) {
return n < t ? n : n < e ? n + i - e : n < i ? n + t - e : n;
}
};
n.prototype.GetCriticalVelocity = function(t) {
return this.m_particleDiameter * t.inv_dt;
};
n.prototype.GetCriticalVelocitySquared = function(t) {
var e = this.GetCriticalVelocity(t);
return e * e;
};
n.prototype.GetCriticalPressure = function(t) {
return this.m_def.density * this.GetCriticalVelocitySquared(t);
};
n.prototype.GetParticleStride = function() {
return .75 * this.m_particleDiameter;
};
n.prototype.GetParticleMass = function() {
var t = this.GetParticleStride();
return this.m_def.density * t * t;
};
n.prototype.GetParticleInvMass = function() {
var t = this.m_inverseDiameter * (1 / .75);
return this.m_inverseDensity * t * t;
};
n.prototype.GetFixtureContactFilter = function() {
return this.m_allParticleFlags & t.b2ParticleFlag.b2_fixtureContactFilterParticle ? this.m_world.m_contactManager.m_contactFilter : null;
};
n.prototype.GetParticleContactFilter = function() {
return this.m_allParticleFlags & t.b2ParticleFlag.b2_particleContactFilterParticle ? this.m_world.m_contactManager.m_contactFilter : null;
};
n.prototype.GetFixtureContactListener = function() {
return this.m_allParticleFlags & t.b2ParticleFlag.b2_fixtureContactListenerParticle ? this.m_world.m_contactManager.m_contactListener : null;
};
n.prototype.GetParticleContactListener = function() {
return this.m_allParticleFlags & t.b2ParticleFlag.b2_particleContactListenerParticle ? this.m_world.m_contactManager.m_contactListener : null;
};
n.prototype.SetUserOverridableBuffer = function(t, e, i) {
t.data = e;
t.userSuppliedCapacity = i;
};
n.prototype.SetGroupFlags = function(e, i) {
var n = e.m_groupFlags;
(n ^ i) & t.b2ParticleGroupFlag.b2_solidParticleGroup && (i |= t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth);
n & ~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;
};
n.BodyContactCompare = function(t, e) {
return t.index === e.index ? t.weight > e.weight : t.index < e.index;
};
n.prototype.RemoveSpuriousBodyContacts = function() {
Tn(this.m_bodyContactBuffer.data, 0, this.m_bodyContactBuffer.count, n.BodyContactCompare);
var t = n.RemoveSpuriousBodyContacts_s_n, e = n.RemoveSpuriousBodyContacts_s_pos, i = n.RemoveSpuriousBodyContacts_s_normal, r = this, s = -1, o = 0;
this.m_bodyContactBuffer.count = En(this.m_bodyContactBuffer.data, (function(n) {
if (n.index !== s) {
o = 0;
s = n.index;
}
if (o++ > 3) return !0;
var a = t.Copy(n.normal);
a.SelfMul(r.m_particleDiameter * (1 - n.weight));
if (!r.m_positionBuffer.data) throw new Error();
var h = P.AddVV(r.m_positionBuffer.data[n.index], a, e);
if (!n.fixture.TestPoint(h)) {
for (var l = n.fixture.GetShape().GetChildCount(), u = 0; u < l; u++) {
var _ = i;
if (n.fixture.ComputeDistance(h, _, u) < c) return !1;
}
return !0;
}
return !1;
}), this.m_bodyContactBuffer.count);
};
n.prototype.DetectStuckParticle = function(t) {
if (!(this.m_stuckThreshold <= 0)) {
if (!this.m_bodyContactCountBuffer.data) throw new Error();
if (!this.m_consecutiveContactStepsBuffer.data) throw new Error();
if (!this.m_lastBodyContactStepBuffer.data) throw new Error();
++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;
}
};
n.prototype.ValidateParticleIndex = function(t) {
return t >= 0 && t < this.GetParticleCount() && t !== u;
};
n.prototype.GetQuantizedTimeElapsed = function() {
return Math.floor(this.m_timeElapsed / 4294967296);
};
n.prototype.LifetimeToExpirationTime = function(t) {
return this.m_timeElapsed + Math.floor(t / this.m_def.lifetimeGranularity * 4294967296);
};
n.prototype.ForceCanBeApplied = function(e) {
return !(e & t.b2ParticleFlag.b2_wallParticle);
};
n.prototype.PrepareForceBuffer = function() {
if (!this.m_hasForce) {
for (var t = 0; t < this.m_count; t++) this.m_forceBuffer[t].SetZero();
this.m_hasForce = !0;
}
};
n.prototype.IsRigidGroup = function(e) {
return null !== e && 0 != (e.m_groupFlags & t.b2ParticleGroupFlag.b2_rigidParticleGroup);
};
n.prototype.GetLinearVelocity = function(t, e, i, n) {
if (t && this.IsRigidGroup(t)) return t.GetLinearVelocityFromWorldPoint(i, n);
if (!this.m_velocityBuffer.data) throw new Error();
return n.Copy(this.m_velocityBuffer.data[e]);
};
n.prototype.InitDampingParameter = function(t, e, i, n, r, s, o, a) {
t[0] = n > 0 ? 1 / n : 0;
e[0] = r > 0 ? 1 / r : 0;
i[0] = P.CrossVV(P.SubVV(o, s, P.s_t0), a);
};
n.prototype.InitDampingParameterWithRigidGroupOrParticle = function(e, i, n, r, s, o, a, c) {
if (s && r) this.InitDampingParameter(e, i, n, s.GetMass(), s.GetInertia(), s.GetCenter(), a, c); else {
if (!this.m_flagsBuffer.data) throw new Error();
var h = this.m_flagsBuffer.data[o];
this.InitDampingParameter(e, i, n, h & t.b2ParticleFlag.b2_wallParticle ? 0 : this.GetParticleMass(), 0, a, a, c);
}
};
n.prototype.ComputeDampingImpulse = function(t, e, i, n, r, s, o) {
var a = t + e * i * i + n + r * s * s;
return a > 0 ? o / a : 0;
};
n.prototype.ApplyDamping = function(t, e, i, n, r, s, o, a) {
if (r && n) {
r.m_linearVelocity.SelfMulAdd(o * t, a);
r.m_angularVelocity += o * i * e;
} else {
if (!this.m_velocityBuffer.data) throw new Error();
this.m_velocityBuffer.data[s].SelfMulAdd(o * t, a);
}
};
n.xTruncBits = 12;
n.yTruncBits = 12;
n.tagBits = 32;
n.yOffset = 1 << n.yTruncBits - 1;
n.yShift = n.tagBits - n.yTruncBits;
n.xShift = n.tagBits - n.yTruncBits - n.xTruncBits;
n.xScale = 1 << n.xShift;
n.xOffset = n.xScale * (1 << n.xTruncBits - 1);
n.yMask = (1 << n.yTruncBits) - 1 << n.yShift;
n.xMask = ~n.yMask;
n.DestroyParticlesInShape_s_aabb = new wt();
n.CreateParticleGroup_s_transform = new N();
n.ComputeCollisionEnergy_s_v = new P();
n.QueryShapeAABB_s_aabb = new wt();
n.QueryPointAABB_s_aabb = new wt();
n.RayCast_s_aabb = new wt();
n.RayCast_s_p = new P();
n.RayCast_s_v = new P();
n.RayCast_s_n = new P();
n.RayCast_s_point = new P();
n.k_pairFlags = t.b2ParticleFlag.b2_springParticle;
n.k_triadFlags = t.b2ParticleFlag.b2_elasticParticle;
n.k_noPressureFlags = t.b2ParticleFlag.b2_powderParticle | t.b2ParticleFlag.b2_tensileParticle;
n.k_extraDampingFlags = t.b2ParticleFlag.b2_staticPressureParticle;
n.k_barrierWallFlags = t.b2ParticleFlag.b2_barrierParticle | t.b2ParticleFlag.b2_wallParticle;
n.CreateParticlesStrokeShapeForGroup_s_edge = new ei();
n.CreateParticlesStrokeShapeForGroup_s_d = new P();
n.CreateParticlesStrokeShapeForGroup_s_p = new P();
n.CreateParticlesFillShapeForGroup_s_aabb = new wt();
n.CreateParticlesFillShapeForGroup_s_p = new P();
n.UpdatePairsAndTriads_s_dab = new P();
n.UpdatePairsAndTriads_s_dbc = new P();
n.UpdatePairsAndTriads_s_dca = new P();
n.AddContact_s_d = new P();
n.UpdateBodyContacts_s_aabb = new wt();
n.Solve_s_subStep = new sn();
n.SolveCollision_s_aabb = new wt();
n.SolveGravity_s_gravity = new P();
n.SolveBarrier_s_aabb = new wt();
n.SolveBarrier_s_va = new P();
n.SolveBarrier_s_vb = new P();
n.SolveBarrier_s_pba = new P();
n.SolveBarrier_s_vba = new P();
n.SolveBarrier_s_vc = new P();
n.SolveBarrier_s_pca = new P();
n.SolveBarrier_s_vca = new P();
n.SolveBarrier_s_qba = new P();
n.SolveBarrier_s_qca = new P();
n.SolveBarrier_s_dv = new P();
n.SolveBarrier_s_f = new P();
n.SolvePressure_s_f = new P();
n.SolveDamping_s_v = new P();
n.SolveDamping_s_f = new P();
n.SolveRigidDamping_s_t0 = new P();
n.SolveRigidDamping_s_t1 = new P();
n.SolveRigidDamping_s_p = new P();
n.SolveRigidDamping_s_v = new P();
n.SolveExtraDamping_s_v = new P();
n.SolveExtraDamping_s_f = new P();
n.SolveRigid_s_position = new P();
n.SolveRigid_s_rotation = new O();
n.SolveRigid_s_transform = new N();
n.SolveRigid_s_velocityTransform = new N();
n.SolveElastic_s_pa = new P();
n.SolveElastic_s_pb = new P();
n.SolveElastic_s_pc = new P();
n.SolveElastic_s_r = new O();
n.SolveElastic_s_t0 = new P();
n.SolveSpring_s_pa = new P();
n.SolveSpring_s_pb = new P();
n.SolveSpring_s_d = new P();
n.SolveSpring_s_f = new P();
n.SolveTensile_s_weightedNormal = new P();
n.SolveTensile_s_s = new P();
n.SolveTensile_s_f = new P();
n.SolveViscous_s_v = new P();
n.SolveViscous_s_f = new P();
n.SolveRepulsive_s_f = new P();
n.SolvePowder_s_f = new P();
n.SolveSolid_s_f = new P();
n.RemoveSpuriousBodyContacts_s_n = new P();
n.RemoveSpuriousBodyContacts_s_pos = new P();
n.RemoveSpuriousBodyContacts_s_normal = new P();
return n;
})();
(function(e) {
var n = (function() {
return function() {
this.data = null;
this.userSuppliedCapacity = 0;
};
})();
e.UserOverridableBuffer = n;
var r = (function() {
function t() {
this.index = u;
this.tag = 0;
}
t.CompareProxyProxy = function(t, e) {
return t.tag < e.tag;
};
t.CompareTagProxy = function(t, e) {
return t < e.tag;
};
t.CompareProxyTag = function(t, e) {
return t.tag < e;
};
return t;
})();
e.Proxy = r;
var s = (function() {
function t(t, i, n, r, s) {
this.m_system = t;
this.m_xLower = (i & e.xMask) >>> 0;
this.m_xUpper = (n & e.xMask) >>> 0;
this.m_yLower = (i & e.yMask) >>> 0;
this.m_yUpper = (n & e.yMask) >>> 0;
this.m_first = r;
this.m_last = s;
}
t.prototype.GetNext = function() {
for (;this.m_first < this.m_last; ) {
var t = (this.m_system.m_proxyBuffer.data[this.m_first].tag & e.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 u;
};
return t;
})();
e.InsideBoundsEnumerator = s;
var o = (function() {
return function() {
this.next = null;
this.count = 0;
this.index = 0;
};
})();
e.ParticleListNode = o;
var a = (function() {
function t() {}
t.prototype.Allocate = function(t, e) {
return e;
};
t.prototype.Clear = function() {};
t.prototype.GetCount = function() {
return 0;
};
t.prototype.Invalidate = function(t) {};
t.prototype.GetValidBuffer = function() {
return [];
};
t.prototype.GetBuffer = function() {
return [];
};
t.prototype.SetCount = function(t) {};
return t;
})();
e.FixedSetAllocator = a;
var h = (function() {
return function(t, e) {
this.second = u;
this.first = t;
this.second = e;
};
})();
e.FixtureParticle = h;
var l = (function(t) {
Qe(e, t);
function e() {
return null !== t && t.apply(this, arguments) || this;
}
e.prototype.Initialize = function(t, e) {};
e.prototype.Find = function(t) {
return u;
};
return e;
})(e.FixedSetAllocator);
e.FixtureParticleSet = l;
var _ = (function() {
return function(t, e) {
this.first = u;
this.second = u;
this.first = t;
this.second = e;
};
})();
e.ParticlePair = _;
var f = (function(t) {
Qe(e, t);
function e() {
return null !== t && t.apply(this, arguments) || this;
}
e.prototype.Initialize = function(t, e) {};
e.prototype.Find = function(t) {
return u;
};
return e;
})(e.FixedSetAllocator);
e.b2ParticlePairSet = f;
var d = (function() {
function t() {}
t.prototype.IsNecessary = function(t) {
return !0;
};
t.prototype.ShouldCreatePair = function(t, e) {
return !0;
};
t.prototype.ShouldCreateTriad = function(t, e, i) {
return !0;
};
return t;
})();
e.ConnectionFilter = d;
var m = (function(t) {
Qe(e, t);
function e(e, i, n, r) {
var s = t.call(this) || this;
s.m_callDestructionListener = !1;
s.m_destroyed = 0;
s.m_system = e;
s.m_shape = i;
s.m_xf = n;
s.m_callDestructionListener = r;
s.m_destroyed = 0;
return s;
}
e.prototype.ReportFixture = function(t) {
return !1;
};
e.prototype.ReportParticle = function(t, e) {
if (t !== this.m_system) return !1;
if (!this.m_system.m_positionBuffer.data) throw new Error();
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;
};
e.prototype.Destroyed = function() {
return this.m_destroyed;
};
return e;
})(tn);
e.DestroyParticlesInShapeCallback = m;
var p = (function(t) {
Qe(e, t);
function e(e) {
var i = t.call(this) || this;
i.m_threshold = 0;
i.m_threshold = e;
return i;
}
e.prototype.ShouldCreatePair = function(t, e) {
return t < this.m_threshold && this.m_threshold <= e || e < this.m_threshold && this.m_threshold <= t;
};
e.prototype.ShouldCreateTriad = function(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);
};
return e;
})(e.ConnectionFilter);
e.JoinParticleGroupsFilter = p;
var v = (function(e) {
Qe(n, e);
function n(i, n) {
void 0 === n && (n = i.length);
var r = e.call(this, t.b2ShapeType.e_unknown, 0) || this;
r.m_shapeCount = 0;
r.m_shapes = i;
r.m_shapeCount = n;
return r;
}
n.prototype.Clone = function() {
throw new Error();
};
n.prototype.GetChildCount = function() {
return 1;
};
n.prototype.TestPoint = function(t, e) {
for (var i = 0; i < this.m_shapeCount; i++) if (this.m_shapes[i].TestPoint(t, e)) return !0;
return !1;
};
n.prototype.ComputeDistance = function(t, e, i, n) {
return 0;
};
n.prototype.RayCast = function(t, e, i, n) {
return !1;
};
n.prototype.ComputeAABB = function(t, e, n) {
var r = new wt();
t.lowerBound.x = +i;
t.lowerBound.y = +i;
t.upperBound.x = -i;
t.upperBound.y = -i;
for (var s = 0; s < this.m_shapeCount; s++) for (var o = this.m_shapes[s].GetChildCount(), a = 0; a < o; a++) {
var c = r;
this.m_shapes[s].ComputeAABB(c, e, a);
t.Combine1(c);
}
};
n.prototype.ComputeMass = function(t, e) {};
n.prototype.SetupDistanceProxy = function(t, e) {};
n.prototype.ComputeSubmergedArea = function(t, e, i, n) {
return 0;
};
n.prototype.Dump = function(t) {};
return n;
})(Ze);
e.CompositeShape = v;
var y = (function(e) {
Qe(i, e);
function i(t) {
var i = e.call(this) || this;
i.m_flagsBuffer = t;
return i;
}
i.prototype.IsNecessary = function(e) {
if (!this.m_flagsBuffer.data) throw new Error();
return 0 != (this.m_flagsBuffer.data[e] & t.b2ParticleFlag.b2_reactiveParticle);
};
return i;
})(e.ConnectionFilter);
e.ReactiveFilter = y;
var g = (function(i) {
Qe(n, i);
function n(t, e) {
var n = i.call(this, t) || this;
n.m_contactFilter = e;
return n;
}
n.prototype.ShouldCollideFixtureParticle = function(e, i, n) {
if (this.m_contactFilter) {
if (this.m_system.GetFlagsBuffer()[n] & t.b2ParticleFlag.b2_fixtureContactFilterParticle) return this.m_contactFilter.ShouldCollideFixtureParticle(e, this.m_system, n);
}
return !0;
};
n.prototype.ReportFixtureAndParticle = function(i, n, r) {
var s = e.UpdateBodyContactsCallback.ReportFixtureAndParticle_s_n, o = e.UpdateBodyContactsCallback.ReportFixtureAndParticle_s_rp;
if (!this.m_system.m_flagsBuffer.data) throw new Error();
if (!this.m_system.m_positionBuffer.data) throw new Error();
var a = this.m_system.m_positionBuffer.data[r], c = s, h = i.ComputeDistance(a, c, n);
if (h < this.m_system.m_particleDiameter && this.ShouldCollideFixtureParticle(i, this.m_system, r)) {
var l = i.GetBody(), u = l.GetWorldCenter(), _ = l.GetMass(), f = l.GetInertia() - _ * l.GetLocalCenter().LengthSquared(), d = _ > 0 ? 1 / _ : 0, m = f > 0 ? 1 / f : 0, p = this.m_system.m_flagsBuffer.data[r] & t.b2ParticleFlag.b2_wallParticle ? 0 : this.m_system.GetParticleInvMass(), v = P.SubVV(a, u, o), y = P.CrossVV(v, c), g = p + d + m * y * y, x = this.m_system.m_bodyContactBuffer.data[this.m_system.m_bodyContactBuffer.Append()];
x.index = r;
x.body = l;
x.fixture = i;
x.weight = 1 - h * this.m_system.m_inverseDiameter;
x.normal.Copy(c.SelfNeg());
x.mass = g > 0 ? 1 / g : 0;
this.m_system.DetectStuckParticle(r);
}
};
n.ReportFixtureAndParticle_s_n = new P();
n.ReportFixtureAndParticle_s_rp = new P();
return n;
})(Pn);
e.UpdateBodyContactsCallback = g;
var x = (function(i) {
Qe(n, i);
function n(t, e) {
var n = i.call(this, t) || this;
n.m_step = e;
return n;
}
n.prototype.ReportFixtureAndParticle = function(i, n, r) {
var s = e.SolveCollisionCallback.ReportFixtureAndParticle_s_p1, o = e.SolveCollisionCallback.ReportFixtureAndParticle_s_output, a = e.SolveCollisionCallback.ReportFixtureAndParticle_s_input, h = e.SolveCollisionCallback.ReportFixtureAndParticle_s_p, l = e.SolveCollisionCallback.ReportFixtureAndParticle_s_v, u = e.SolveCollisionCallback.ReportFixtureAndParticle_s_f, _ = i.GetBody();
if (!this.m_system.m_positionBuffer.data) throw new Error();
if (!this.m_system.m_velocityBuffer.data) throw new Error();
var f = this.m_system.m_positionBuffer.data[r], d = this.m_system.m_velocityBuffer.data[r], m = o, p = a;
if (0 === this.m_system.m_iterationIndex) {
var v = N.MulTXV(_.m_xf0, f, s);
if (i.GetShape().GetType() === t.b2ShapeType.e_circleShape) {
v.SelfSub(_.GetLocalCenter());
O.MulRV(_.m_xf0.q, v, v);
O.MulTRV(_.m_xf.q, v, v);
v.SelfAdd(_.GetLocalCenter());
}
N.MulXV(_.m_xf, v, p.p1);
} else p.p1.Copy(f);
P.AddVMulSV(f, this.m_step.dt, d, p.p2);
p.maxFraction = 1;
if (i.RayCast(m, p, n)) {
var y = m.normal, g = h;
g.x = (1 - m.fraction) * p.p1.x + m.fraction * p.p2.x + c * y.x;
g.y = (1 - m.fraction) * p.p1.y + m.fraction * p.p2.y + c * y.y;
var x = l;
x.x = this.m_step.inv_dt * (g.x - f.x);
x.y = this.m_step.inv_dt * (g.y - f.y);
this.m_system.m_velocityBuffer.data[r].Copy(x);
var C = u;
C.x = this.m_step.inv_dt * this.m_system.GetParticleMass() * (d.x - x.x);
C.y = this.m_step.inv_dt * this.m_system.GetParticleMass() * (d.y - x.y);
this.m_system.ParticleApplyForce(r, C);
}
};
n.prototype.ReportParticle = function(t, e) {
return !1;
};
n.ReportFixtureAndParticle_s_p1 = new P();
n.ReportFixtureAndParticle_s_output = new Tt();
n.ReportFixtureAndParticle_s_input = new St();
n.ReportFixtureAndParticle_s_p = new P();
n.ReportFixtureAndParticle_s_v = new P();
n.ReportFixtureAndParticle_s_f = new P();
return n;
})(Pn);
e.SolveCollisionCallback = x;
})(t.b2ParticleSystem || (t.b2ParticleSystem = {}));
var Nn = (function() {
function e(t) {
this.m_newFixture = !1;
this.m_locked = !1;
this.m_clearForces = !0;
this.m_contactManager = new nn();
this.m_bodyList = null;
this.m_jointList = null;
this.m_particleSystemList = null;
this.m_bodyCount = 0;
this.m_jointCount = 0;
this.m_gravity = new P();
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 rn();
this.m_island = new mn();
this.s_stack = [];
this.m_controllerList = null;
this.m_controllerCount = 0;
this.m_gravity.Copy(t);
}
e.prototype.SetDestructionListener = function(t) {
this.m_destructionListener = t;
};
e.prototype.SetContactFilter = function(t) {
this.m_contactManager.m_contactFilter = t;
};
e.prototype.SetContactListener = function(t) {
this.m_contactManager.m_contactListener = t;
};
e.prototype.SetDebugDraw = function(t) {
this.m_debugDraw = t;
};
e.prototype.CreateBody = function(t) {
void 0 === t && (t = {});
if (this.IsLocked()) throw new Error();
var e = new ci(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;
};
e.prototype.DestroyBody = function(t) {
if (this.IsLocked()) throw new Error();
for (var e = t.m_jointList; e; ) {
var 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;
for (var n = t.m_controllerList; n; ) {
var r = n;
n = n.nextController;
r.controller.RemoveBody(t);
}
for (var s = t.m_contactList; s; ) {
var o = s;
s = s.next;
this.m_contactManager.Destroy(o.contact);
}
t.m_contactList = null;
for (var a = t.m_fixtureList; a; ) {
var c = a;
a = a.m_next;
this.m_destructionListener && this.m_destructionListener.SayGoodbyeFixture(c);
c.DestroyProxies();
c.Destroy();
t.m_fixtureList = a;
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;
};
e._Joint_Create = function(e, i) {
switch (e.type) {
case t.b2JointType.e_distanceJoint:
return new di(e);

case t.b2JointType.e_mouseJoint:
return new Si(e);

case t.b2JointType.e_prismaticJoint:
return new wi(e);

case t.b2JointType.e_revoluteJoint:
return new Di(e);

case t.b2JointType.e_pulleyJoint:
return new Bi(e);

case t.b2JointType.e_gearJoint:
return new xi(e);

case t.b2JointType.e_wheelJoint:
return new Vi(e);

case t.b2JointType.e_weldJoint:
return new Li(e);

case t.b2JointType.e_frictionJoint:
return new yi(e);

case t.b2JointType.e_ropeJoint:
return new Pi(e);

case t.b2JointType.e_motorJoint:
return new Ai(e);

case t.b2JointType.e_areaJoint:
return new pi(e);
}
throw new Error();
};
e._Joint_Destroy = function(t, e) {};
e.prototype.CreateJoint = function(t) {
if (this.IsLocked()) throw new Error();
var i = e._Joint_Create(t, null);
i.m_prev = null;
i.m_next = this.m_jointList;
this.m_jointList && (this.m_jointList.m_prev = i);
this.m_jointList = i;
++this.m_jointCount;
i.m_edgeA.prev = null;
i.m_edgeA.next = i.m_bodyA.m_jointList;
i.m_bodyA.m_jointList && (i.m_bodyA.m_jointList.prev = i.m_edgeA);
i.m_bodyA.m_jointList = i.m_edgeA;
i.m_edgeB.prev = null;
i.m_edgeB.next = i.m_bodyB.m_jointList;
i.m_bodyB.m_jointList && (i.m_bodyB.m_jointList.prev = i.m_edgeB);
i.m_bodyB.m_jointList = i.m_edgeB;
var n = t.bodyA, r = t.bodyB;
if (!t.collideConnected) for (var s = r.GetContactList(); s; ) {
s.other === n && s.contact.FlagForFiltering();
s = s.next;
}
return i;
};
e.prototype.DestroyJoint = function(t) {
if (this.IsLocked()) throw new Error();
var i = t.m_collideConnected;
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);
var n = t.m_bodyA, r = t.m_bodyB;
n.SetAwake(!0);
r.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 === n.m_jointList && (n.m_jointList = t.m_edgeA.next);
t.m_edgeA.prev = null;
t.m_edgeA.next = null;
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 === r.m_jointList && (r.m_jointList = t.m_edgeB.next);
t.m_edgeB.prev = null;
t.m_edgeB.next = null;
e._Joint_Destroy(t, null);
--this.m_jointCount;
if (!i) for (var s = r.GetContactList(); s; ) {
s.other === n && s.contact.FlagForFiltering();
s = s.next;
}
};
e.prototype.CreateParticleSystem = function(e) {
if (this.IsLocked()) throw new Error();
var i = new t.b2ParticleSystem(e, this);
i.m_prev = null;
i.m_next = this.m_particleSystemList;
this.m_particleSystemList && (this.m_particleSystemList.m_prev = i);
this.m_particleSystemList = i;
return i;
};
e.prototype.DestroyParticleSystem = function(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);
};
e.prototype.CalculateReasonableParticleIterations = function(t) {
if (null === this.m_particleSystemList) return 1;
return vn(this.m_gravity.Length(), (function(t) {
for (var e = i, n = t.GetParticleSystemList(); null !== n; n = n.m_next) e = g(e, n.GetRadius());
return e;
})(this), t);
};
e.prototype.Step = function(t, i, n, r) {
void 0 === r && (r = this.CalculateReasonableParticleIterations(t));
var s = e.Step_s_stepTimer.Reset();
if (this.m_newFixture) {
this.m_contactManager.FindNewContacts();
this.m_newFixture = !1;
}
this.m_locked = !0;
var o = e.Step_s_step;
o.dt = t;
o.velocityIterations = i;
o.positionIterations = n;
o.particleIterations = r;
o.inv_dt = t > 0 ? 1 / t : 0;
o.dtRatio = this.m_inv_dt0 * t;
o.warmStarting = this.m_warmStarting;
var a = e.Step_s_timer.Reset();
this.m_contactManager.Collide();
this.m_profile.collide = a.GetMilliseconds();
if (this.m_stepComplete && o.dt > 0) {
for (var c = e.Step_s_timer.Reset(), h = this.m_particleSystemList; h; h = h.m_next) h.Solve(o);
this.Solve(o);
this.m_profile.solve = c.GetMilliseconds();
}
if (this.m_continuousPhysics && o.dt > 0) {
var l = e.Step_s_timer.Reset();
this.SolveTOI(o);
this.m_profile.solveTOI = l.GetMilliseconds();
}
o.dt > 0 && (this.m_inv_dt0 = o.inv_dt);
this.m_clearForces && this.ClearForces();
this.m_locked = !1;
this.m_profile.step = s.GetMilliseconds();
};
e.prototype.ClearForces = function() {
for (var t = this.m_bodyList; t; t = t.m_next) {
t.m_force.SetZero();
t.m_torque = 0;
}
};
e.prototype.DrawParticleSystem = function(t) {
if (null !== this.m_debugDraw) {
var e = t.GetParticleCount();
if (e) {
var i = t.GetRadius(), n = t.GetPositionBuffer();
if (t.m_colorBuffer.data) {
var r = t.GetColorBuffer();
this.m_debugDraw.DrawParticles(n, i, r, e);
} else this.m_debugDraw.DrawParticles(n, i, null, e);
}
}
};
e.prototype.DrawDebugData = function() {
if (null !== this.m_debugDraw) {
var i = this.m_debugDraw.GetFlags(), n = e.DrawDebugData_s_color.SetRGB(0, 0, 0);
if (i & t.b2DrawFlags.e_shapeBit) for (var r = this.m_bodyList; r; r = r.m_next) {
var s = r.m_xf;
this.m_debugDraw.PushTransform(s);
for (var o = r.GetFixtureList(); o; o = o.m_next) if (r.IsActive()) if (r.GetType() === t.b2BodyType.b2_staticBody) {
n.SetRGB(.5, .9, .5);
this.DrawShape(o, n);
} else if (r.GetType() === t.b2BodyType.b2_kinematicBody) {
n.SetRGB(.5, .5, .9);
this.DrawShape(o, n);
} else if (r.IsAwake()) {
n.SetRGB(.9, .7, .7);
this.DrawShape(o, n);
} else {
n.SetRGB(.6, .6, .6);
this.DrawShape(o, n);
} else {
n.SetRGB(.5, .5, .3);
this.DrawShape(o, n);
}
this.m_debugDraw.PopTransform(s);
}
if (i & t.b2DrawFlags.e_particleBit) for (var a = this.m_particleSystemList; a; a = a.m_next) this.DrawParticleSystem(a);
if (i & t.b2DrawFlags.e_jointBit) for (var c = this.m_jointList; c; c = c.m_next) this.DrawJoint(c);
if (i & t.b2DrawFlags.e_aabbBit) {
n.SetRGB(.9, .3, .9);
var h = e.DrawDebugData_s_vs;
for (r = this.m_bodyList; r; r = r.m_next) if (r.IsActive()) for (o = r.GetFixtureList(); o; o = o.m_next) for (var l = 0; l < o.m_proxyCount; ++l) {
var u = o.m_proxies[l].treeNode.aabb;
h[0].Set(u.lowerBound.x, u.lowerBound.y);
h[1].Set(u.upperBound.x, u.lowerBound.y);
h[2].Set(u.upperBound.x, u.upperBound.y);
h[3].Set(u.lowerBound.x, u.upperBound.y);
this.m_debugDraw.DrawPolygon(h, 4, n);
}
}
if (i & t.b2DrawFlags.e_centerOfMassBit) for (r = this.m_bodyList; r; r = r.m_next) {
(s = e.DrawDebugData_s_xf).q.Copy(r.m_xf.q);
s.p.Copy(r.GetWorldCenter());
this.m_debugDraw.DrawTransform(s);
}
if (i & t.b2DrawFlags.e_controllerBit) for (var _ = this.m_controllerList; _; _ = _.m_next) _.Draw(this.m_debugDraw);
}
};
e.prototype.QueryAABB = function(t, e, i) {
this.m_contactManager.m_broadPhase.Query(e, (function(e) {
var n = e.userData.fixture;
return t ? t.ReportFixture(n) : !i || i(n);
}));
if (t instanceof tn) for (var n = this.m_particleSystemList; n; n = n.m_next) t.ShouldQueryParticleSystem(n) && n.QueryAABB(t, e);
};
e.prototype.QueryAllAABB = function(t, e) {
void 0 === e && (e = []);
this.QueryAABB(null, t, (function(t) {
e.push(t);
return !0;
}));
return e;
};
e.prototype.QueryPointAABB = function(t, e, i) {
this.m_contactManager.m_broadPhase.QueryPoint(e, (function(e) {
var n = e.userData.fixture;
return t ? t.ReportFixture(n) : !i || i(n);
}));
if (t instanceof tn) for (var n = this.m_particleSystemList; n; n = n.m_next) t.ShouldQueryParticleSystem(n) && n.QueryPointAABB(t, e);
};
e.prototype.QueryAllPointAABB = function(t, e) {
void 0 === e && (e = []);
this.QueryPointAABB(null, t, (function(t) {
e.push(t);
return !0;
}));
return e;
};
e.prototype.QueryFixtureShape = function(t, i, n, r, s) {
var o = e.QueryFixtureShape_s_aabb;
i.ComputeAABB(o, r, n);
this.m_contactManager.m_broadPhase.Query(o, (function(e) {
var o = e.userData, a = o.fixture;
if (Pt(i, n, a.GetShape(), o.childIndex, r, a.GetBody().GetTransform())) {
if (t) return t.ReportFixture(a);
if (s) return s(a);
}
return !0;
}));
if (t instanceof tn) for (var a = this.m_particleSystemList; a; a = a.m_next) t.ShouldQueryParticleSystem(a) && a.QueryAABB(t, o);
};
e.prototype.QueryAllFixtureShape = function(t, e, i, n) {
void 0 === n && (n = []);
this.QueryFixtureShape(null, t, e, i, (function(t) {
n.push(t);
return !0;
}));
return n;
};
e.prototype.QueryFixturePoint = function(t, e, i) {
this.m_contactManager.m_broadPhase.QueryPoint(e, (function(n) {
var r = n.userData.fixture;
if (r.TestPoint(e)) {
if (t) return t.ReportFixture(r);
if (i) return i(r);
}
return !0;
}));
if (t) for (var n = this.m_particleSystemList; n; n = n.m_next) t.ShouldQueryParticleSystem(n) && n.QueryPointAABB(t, e);
};
e.prototype.QueryAllFixturePoint = function(t, e) {
void 0 === e && (e = []);
this.QueryFixturePoint(null, t, (function(t) {
e.push(t);
return !0;
}));
return e;
};
e.prototype.RayCast = function(t, i, n, r) {
var s = e.RayCast_s_input;
s.maxFraction = 1;
s.p1.Copy(i);
s.p2.Copy(n);
this.m_contactManager.m_broadPhase.RayCast(s, (function(s, o) {
var a = o.userData, c = a.fixture, h = a.childIndex, l = e.RayCast_s_output;
if (c.RayCast(l, s, h)) {
var u = l.fraction, _ = e.RayCast_s_point;
_.Set((1 - u) * i.x + u * n.x, (1 - u) * i.y + u * n.y);
if (t) return t.ReportFixture(c, _, l.normal, u);
if (r) return r(c, _, l.normal, u);
}
return s.maxFraction;
}));
if (t) for (var o = this.m_particleSystemList; o; o = o.m_next) t.ShouldQueryParticleSystem(o) && o.RayCast(t, i, n);
};
e.prototype.RayCastOne = function(t, e) {
var i = null, n = 1;
this.RayCast(null, t, e, (function(t, e, r, s) {
if (s < n) {
n = s;
i = t;
}
return n;
}));
return i;
};
e.prototype.RayCastAll = function(t, e, i) {
void 0 === i && (i = []);
this.RayCast(null, t, e, (function(t, e, n, r) {
i.push(t);
return 1;
}));
return i;
};
e.prototype.GetBodyList = function() {
return this.m_bodyList;
};
e.prototype.GetJointList = function() {
return this.m_jointList;
};
e.prototype.GetParticleSystemList = function() {
return this.m_particleSystemList;
};
e.prototype.GetContactList = function() {
return this.m_contactManager.m_contactList;
};
e.prototype.SetAllowSleeping = function(t) {
if (t !== this.m_allowSleep) {
this.m_allowSleep = t;
if (!this.m_allowSleep) for (var e = this.m_bodyList; e; e = e.m_next) e.SetAwake(!0);
}
};
e.prototype.GetAllowSleeping = function() {
return this.m_allowSleep;
};
e.prototype.SetWarmStarting = function(t) {
this.m_warmStarting = t;
};
e.prototype.GetWarmStarting = function() {
return this.m_warmStarting;
};
e.prototype.SetContinuousPhysics = function(t) {
this.m_continuousPhysics = t;
};
e.prototype.GetContinuousPhysics = function() {
return this.m_continuousPhysics;
};
e.prototype.SetSubStepping = function(t) {
this.m_subStepping = t;
};
e.prototype.GetSubStepping = function() {
return this.m_subStepping;
};
e.prototype.GetProxyCount = function() {
return this.m_contactManager.m_broadPhase.GetProxyCount();
};
e.prototype.GetBodyCount = function() {
return this.m_bodyCount;
};
e.prototype.GetJointCount = function() {
return this.m_jointCount;
};
e.prototype.GetContactCount = function() {
return this.m_contactManager.m_contactCount;
};
e.prototype.GetTreeHeight = function() {
return this.m_contactManager.m_broadPhase.GetTreeHeight();
};
e.prototype.GetTreeBalance = function() {
return this.m_contactManager.m_broadPhase.GetTreeBalance();
};
e.prototype.GetTreeQuality = function() {
return this.m_contactManager.m_broadPhase.GetTreeQuality();
};
e.prototype.SetGravity = function(t, e) {
void 0 === e && (e = !0);
if (!P.IsEqualToV(this.m_gravity, t)) {
this.m_gravity.Copy(t);
if (e) for (var i = this.m_bodyList; i; i = i.m_next) i.SetAwake(!0);
}
};
e.prototype.GetGravity = function() {
return this.m_gravity;
};
e.prototype.IsLocked = function() {
return this.m_locked;
};
e.prototype.SetAutoClearForces = function(t) {
this.m_clearForces = t;
};
e.prototype.GetAutoClearForces = function() {
return this.m_clearForces;
};
e.prototype.ShiftOrigin = function(t) {
if (this.IsLocked()) throw new Error();
for (var 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 (var i = this.m_jointList; i; i = i.m_next) i.ShiftOrigin(t);
this.m_contactManager.m_broadPhase.ShiftOrigin(t);
};
e.prototype.GetContactManager = function() {
return this.m_contactManager;
};
e.prototype.GetProfile = function() {
return this.m_profile;
};
e.prototype.Dump = function(e) {
if (!this.m_locked) {
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");
for (var i = 0, n = this.m_bodyList; n; n = n.m_next) {
n.m_islandIndex = i;
n.Dump(e);
++i;
}
i = 0;
for (var r = this.m_jointList; r; r = r.m_next) {
r.m_index = i;
++i;
}
for (r = this.m_jointList; r; r = r.m_next) if (r.m_type !== t.b2JointType.e_gearJoint) {
e("{\n");
r.Dump(e);
e("}\n");
}
for (r = this.m_jointList; r; r = r.m_next) if (r.m_type === t.b2JointType.e_gearJoint) {
e("{\n");
r.Dump(e);
e("}\n");
}
}
};
e.prototype.DrawJoint = function(i) {
if (null !== this.m_debugDraw) {
var n = i.GetBodyA(), r = i.GetBodyB(), s = n.m_xf, o = r.m_xf, a = s.p, c = o.p, h = i.GetAnchorA(e.DrawJoint_s_p1), l = i.GetAnchorB(e.DrawJoint_s_p2), u = e.DrawJoint_s_color.SetRGB(.5, .8, .8);
switch (i.m_type) {
case t.b2JointType.e_distanceJoint:
this.m_debugDraw.DrawSegment(h, l, u);
break;

case t.b2JointType.e_pulleyJoint:
var _ = i, f = _.GetGroundAnchorA(), d = _.GetGroundAnchorB();
this.m_debugDraw.DrawSegment(f, h, u);
this.m_debugDraw.DrawSegment(d, l, u);
this.m_debugDraw.DrawSegment(f, d, u);
break;

case t.b2JointType.e_mouseJoint:
var m = e.DrawJoint_s_c;
m.Set(0, 1, 0);
this.m_debugDraw.DrawPoint(h, 4, m);
this.m_debugDraw.DrawPoint(l, 4, m);
m.Set(.8, .8, .8);
this.m_debugDraw.DrawSegment(h, l, m);
break;

default:
this.m_debugDraw.DrawSegment(a, h, u);
this.m_debugDraw.DrawSegment(h, l, u);
this.m_debugDraw.DrawSegment(c, l, u);
}
}
};
e.prototype.DrawShape = function(i, n) {
if (null !== this.m_debugDraw) {
var r = i.GetShape();
switch (r.m_type) {
case t.b2ShapeType.e_circleShape:
var s = r, o = s.m_p, a = s.m_radius, c = P.UNITX;
this.m_debugDraw.DrawSolidCircle(o, a, c, n);
break;

case t.b2ShapeType.e_edgeShape:
var h = r, l = h.m_vertex1, u = h.m_vertex2;
this.m_debugDraw.DrawSegment(l, u, n);
break;

case t.b2ShapeType.e_chainShape:
var _ = r, f = _.m_count, d = _.m_vertices, m = e.DrawShape_s_ghostColor.SetRGBA(.75 * n.r, .75 * n.g, .75 * n.b, n.a);
l = d[0];
this.m_debugDraw.DrawPoint(l, 4, n);
if (_.m_hasPrevVertex) {
var p = _.m_prevVertex;
this.m_debugDraw.DrawSegment(p, l, m);
this.m_debugDraw.DrawCircle(p, .1, m);
}
for (var v = 1; v < f; ++v) {
u = d[v];
this.m_debugDraw.DrawSegment(l, u, n);
this.m_debugDraw.DrawPoint(u, 4, n);
l = u;
}
if (_.m_hasNextVertex) {
var y = _.m_nextVertex;
this.m_debugDraw.DrawSegment(y, l, m);
this.m_debugDraw.DrawCircle(y, .1, m);
}
break;

case t.b2ShapeType.e_polygonShape:
var g = r, x = g.m_count;
d = g.m_vertices;
this.m_debugDraw.DrawSolidPolygon(d, x, n);
}
}
};
e.prototype.Solve = function(e) {
for (var i = this.m_bodyList; i; i = i.m_next) i.m_xf0.Copy(i.m_xf);
for (var n = this.m_controllerList; n; n = n.m_next) n.Step(e);
this.m_profile.solveInit = 0;
this.m_profile.solveVelocity = 0;
this.m_profile.solvePosition = 0;
var r = this.m_island;
r.Initialize(this.m_bodyCount, this.m_contactManager.m_contactCount, this.m_jointCount, null, this.m_contactManager.m_contactListener);
for (i = this.m_bodyList; i; i = i.m_next) i.m_islandFlag = !1;
for (var s = this.m_contactManager.m_contactList; s; s = s.m_next) s.m_islandFlag = !1;
for (var o = this.m_jointList; o; o = o.m_next) o.m_islandFlag = !1;
for (var a = this.s_stack, c = this.m_bodyList; c; c = c.m_next) if (!c.m_islandFlag && c.IsAwake() && c.IsActive() && c.GetType() !== t.b2BodyType.b2_staticBody) {
r.Clear();
var h = 0;
a[h++] = c;
c.m_islandFlag = !0;
for (;h > 0; ) {
if (!(i = a[--h])) throw new Error();
r.AddBody(i);
i.m_awakeFlag = !0;
if (i.GetType() !== t.b2BodyType.b2_staticBody) {
for (var l = i.m_contactList; l; l = l.next) {
var u = l.contact;
if (!u.m_islandFlag && (u.IsEnabled() && u.IsTouching())) {
var _ = u.m_fixtureA.m_isSensor, f = u.m_fixtureB.m_isSensor;
if (!_ && !f) {
r.AddContact(u);
u.m_islandFlag = !0;
if (!(m = l.other)) throw new Error();
if (!m.m_islandFlag) {
a[h++] = m;
m.m_islandFlag = !0;
}
}
}
}
for (var d = i.m_jointList; d; d = d.next) if (!d.joint.m_islandFlag) {
var m;
if ((m = d.other).IsActive()) {
r.AddJoint(d.joint);
d.joint.m_islandFlag = !0;
if (!m.m_islandFlag) {
a[h++] = m;
m.m_islandFlag = !0;
}
}
}
}
}
var p = new rn();
r.Solve(p, e, this.m_gravity, this.m_allowSleep);
this.m_profile.solveInit += p.solveInit;
this.m_profile.solveVelocity += p.solveVelocity;
this.m_profile.solvePosition += p.solvePosition;
for (var v = 0; v < r.m_bodyCount; ++v) {
(i = r.m_bodies[v]).GetType() === t.b2BodyType.b2_staticBody && (i.m_islandFlag = !1);
}
}
for (v = 0; v < a.length && a[v]; ++v) a[v] = null;
var y = new U();
for (i = this.m_bodyList; i; i = i.m_next) i.m_islandFlag && i.GetType() !== t.b2BodyType.b2_staticBody && i.SynchronizeFixtures();
this.m_contactManager.FindNewContacts();
this.m_profile.broadphase = y.GetMilliseconds();
};
e.prototype.SolveTOI = function(i) {
var r = this.m_island;
r.Initialize(64, 32, 0, null, this.m_contactManager.m_contactListener);
if (this.m_stepComplete) {
for (var s = this.m_bodyList; s; s = s.m_next) {
s.m_islandFlag = !1;
s.m_sweep.alpha0 = 0;
}
for (var o = this.m_contactManager.m_contactList; o; o = o.m_next) {
o.m_toiFlag = !1;
o.m_islandFlag = !1;
o.m_toiCount = 0;
o.m_toi = 1;
}
}
for (;;) {
var a = null, c = 1;
for (o = this.m_contactManager.m_contactList; o; o = o.m_next) if (o.IsEnabled() && !(o.m_toiCount > 8)) {
var h = 1;
if (o.m_toiFlag) h = o.m_toi; else {
var l = o.GetFixtureA(), u = o.GetFixtureB();
if (l.IsSensor() || u.IsSensor()) continue;
var _ = l.GetBody(), f = u.GetBody(), d = _.m_type, m = f.m_type, p = _.IsAwake() && d !== t.b2BodyType.b2_staticBody, v = f.IsAwake() && m !== t.b2BodyType.b2_staticBody;
if (!p && !v) continue;
var y = _.IsBullet() || d !== t.b2BodyType.b2_dynamicBody, x = f.IsBullet() || m !== t.b2BodyType.b2_dynamicBody;
if (!y && !x) continue;
var C = _.m_sweep.alpha0;
if (_.m_sweep.alpha0 < f.m_sweep.alpha0) {
C = f.m_sweep.alpha0;
_.m_sweep.Advance(C);
} else if (f.m_sweep.alpha0 < _.m_sweep.alpha0) {
C = _.m_sweep.alpha0;
f.m_sweep.Advance(C);
}
var A = o.GetChildIndexA(), b = o.GetChildIndexB(), S = e.SolveTOI_s_toi_input;
S.proxyA.SetShape(l.GetShape(), A);
S.proxyB.SetShape(u.GetShape(), b);
S.sweepA.Copy(_.m_sweep);
S.sweepB.Copy(f.m_sweep);
S.tMax = 1;
var T = e.SolveTOI_s_toi_output;
re(T, S);
var w = T.t;
h = T.state === t.b2TOIOutputState.e_touching ? g(C + (1 - C) * w, 1) : 1;
o.m_toi = h;
o.m_toiFlag = !0;
}
if (h < c) {
a = o;
c = h;
}
}
if (null === a || 1 - 10 * n < c) {
this.m_stepComplete = !0;
break;
}
var E = a.GetFixtureA(), B = a.GetFixtureB(), M = E.GetBody(), D = B.GetBody(), I = e.SolveTOI_s_backup1.Copy(M.m_sweep), P = e.SolveTOI_s_backup2.Copy(D.m_sweep);
M.Advance(c);
D.Advance(c);
a.Update(this.m_contactManager.m_contactListener);
a.m_toiFlag = !1;
++a.m_toiCount;
if (a.IsEnabled() && a.IsTouching()) {
M.SetAwake(!0);
D.SetAwake(!0);
r.Clear();
r.AddBody(M);
r.AddBody(D);
r.AddContact(a);
M.m_islandFlag = !0;
D.m_islandFlag = !0;
a.m_islandFlag = !0;
for (var R = 0; R < 2; ++R) {
if ((z = 0 === R ? M : D).m_type === t.b2BodyType.b2_dynamicBody) for (var L = z.m_contactList; L && r.m_bodyCount !== r.m_bodyCapacity && r.m_contactCount !== r.m_contactCapacity; L = L.next) {
var F = L.contact;
if (!F.m_islandFlag) {
var V = L.other;
if (V.m_type !== t.b2BodyType.b2_dynamicBody || z.IsBullet() || V.IsBullet()) {
var O = F.m_fixtureA.m_isSensor, N = F.m_fixtureB.m_isSensor;
if (!O && !N) {
var k = e.SolveTOI_s_backup.Copy(V.m_sweep);
V.m_islandFlag || V.Advance(c);
F.Update(this.m_contactManager.m_contactListener);
if (F.IsEnabled()) if (F.IsTouching()) {
F.m_islandFlag = !0;
r.AddContact(F);
if (!V.m_islandFlag) {
V.m_islandFlag = !0;
V.m_type !== t.b2BodyType.b2_staticBody && V.SetAwake(!0);
r.AddBody(V);
}
} else {
V.m_sweep.Copy(k);
V.SynchronizeTransform();
} else {
V.m_sweep.Copy(k);
V.SynchronizeTransform();
}
}
}
}
}
}
var G = e.SolveTOI_s_subStep;
G.dt = (1 - c) * i.dt;
G.inv_dt = 1 / G.dt;
G.dtRatio = 1;
G.positionIterations = 20;
G.velocityIterations = i.velocityIterations;
G.particleIterations = i.particleIterations;
G.warmStarting = !1;
r.SolveTOI(G, M.m_islandIndex, D.m_islandIndex);
for (R = 0; R < r.m_bodyCount; ++R) {
var z;
(z = r.m_bodies[R]).m_islandFlag = !1;
if (z.m_type === t.b2BodyType.b2_dynamicBody) {
z.SynchronizeFixtures();
for (L = z.m_contactList; L; L = L.next) {
L.contact.m_toiFlag = !1;
L.contact.m_islandFlag = !1;
}
}
}
this.m_contactManager.FindNewContacts();
if (this.m_subStepping) {
this.m_stepComplete = !1;
break;
}
} else {
a.SetEnabled(!1);
M.m_sweep.Copy(I);
D.m_sweep.Copy(P);
M.SynchronizeTransform();
D.SynchronizeTransform();
}
}
};
e.prototype.AddController = function(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;
};
e.prototype.RemoveController = function(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;
};
e.Step_s_step = new sn();
e.Step_s_stepTimer = new U();
e.Step_s_timer = new U();
e.DrawDebugData_s_color = new G(0, 0, 0);
e.DrawDebugData_s_vs = P.MakeArray(4);
e.DrawDebugData_s_xf = new N();
e.QueryFixtureShape_s_aabb = new wt();
e.RayCast_s_input = new St();
e.RayCast_s_output = new Tt();
e.RayCast_s_point = new P();
e.DrawJoint_s_p1 = new P();
e.DrawJoint_s_p2 = new P();
e.DrawJoint_s_color = new G(.5, .8, .8);
e.DrawJoint_s_c = new G();
e.DrawShape_s_ghostColor = new G();
e.SolveTOI_s_subStep = new sn();
e.SolveTOI_s_backup = new k();
e.SolveTOI_s_backup1 = new k();
e.SolveTOI_s_backup2 = new k();
e.SolveTOI_s_toi_input = new qt();
e.SolveTOI_s_toi_output = new Xt();
return e;
})(), kn = (function() {
return function(t, e) {
this.prevBody = null;
this.nextBody = null;
this.prevController = null;
this.nextController = null;
this.controller = t;
this.body = e;
};
})(), Gn = (function() {
function t() {
this.m_bodyList = null;
this.m_bodyCount = 0;
this.m_prev = null;
this.m_next = null;
}
t.prototype.GetNext = function() {
return this.m_next;
};
t.prototype.GetPrev = function() {
return this.m_prev;
};
t.prototype.GetBodyList = function() {
return this.m_bodyList;
};
t.prototype.AddBody = function(t) {
var e = new kn(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;
};
t.prototype.RemoveBody = function(t) {
if (this.m_bodyCount <= 0) throw new Error();
for (var e = this.m_bodyList; 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;
};
t.prototype.Clear = function() {
for (;this.m_bodyList; ) this.RemoveBody(this.m_bodyList.body);
this.m_bodyCount = 0;
};
return t;
})(), zn = (function(t) {
Qe(e, t);
function e() {
var e = null !== t && t.apply(this, arguments) || this;
e.normal = new P(0, 1);
e.offset = 0;
e.density = 0;
e.velocity = new P(0, 0);
e.linearDrag = 0;
e.angularDrag = 0;
e.useDensity = !1;
e.useWorldGravity = !0;
e.gravity = new P(0, 0);
return e;
}
e.prototype.Step = function(t) {
if (this.m_bodyList) {
this.useWorldGravity && this.gravity.Copy(this.m_bodyList.body.GetWorld().GetGravity());
for (var e = this.m_bodyList; e; e = e.nextBody) {
var i = e.body;
if (i.IsAwake()) {
for (var r = new P(), s = new P(), o = 0, a = 0, c = i.GetFixtureList(); c; c = c.m_next) {
var h = new P(), l = c.GetShape().ComputeSubmergedArea(this.normal, this.offset, i.GetTransform(), h);
o += l;
r.x += l * h.x;
r.y += l * h.y;
var u = 0;
a += l * (u = this.useDensity ? c.GetDensity() : 1);
s.x += l * h.x * u;
s.y += l * h.y * u;
}
r.x /= o;
r.y /= o;
s.x /= a;
s.y /= a;
if (!(o < n)) {
var _ = this.gravity.Clone().SelfNeg();
_.SelfMul(this.density * o);
i.ApplyForce(_, s);
var f = i.GetLinearVelocityFromWorldPoint(r, new P());
f.SelfSub(this.velocity);
f.SelfMul(-this.linearDrag * o);
i.ApplyForce(f, r);
i.ApplyTorque(-i.GetInertia() / i.GetMass() * o * i.GetAngularVelocity() * this.angularDrag);
}
}
}
}
};
e.prototype.Draw = function(t) {
var e = 100, i = new P(), n = new P();
i.x = this.normal.x * this.offset + this.normal.y * e;
i.y = this.normal.y * this.offset - this.normal.x * e;
n.x = this.normal.x * this.offset - this.normal.y * e;
n.y = this.normal.y * this.offset + this.normal.x * e;
var r = new G(0, 0, .8);
t.DrawSegment(i, n, r);
};
return e;
})(Gn), Un = (function(t) {
Qe(e, t);
function e() {
var e = null !== t && t.apply(this, arguments) || this;
e.A = new P(0, 0);
return e;
}
e.prototype.Step = function(t) {
for (var i = P.MulSV(t.dt, this.A, e.Step_s_dtA), n = this.m_bodyList; n; n = n.nextBody) {
var r = n.body;
r.IsAwake() && r.SetLinearVelocity(P.AddVV(r.GetLinearVelocity(), i, P.s_t0));
}
};
e.prototype.Draw = function(t) {};
e.Step_s_dtA = new P();
return e;
})(Gn), jn = (function(t) {
Qe(e, t);
function e() {
var e = null !== t && t.apply(this, arguments) || this;
e.F = new P(0, 0);
return e;
}
e.prototype.Step = function(t) {
for (var e = this.m_bodyList; e; e = e.nextBody) {
var i = e.body;
i.IsAwake() && i.ApplyForce(this.F, i.GetWorldCenter());
}
};
e.prototype.Draw = function(t) {};
return e;
})(Gn), Hn = (function(t) {
Qe(e, t);
function e() {
var e = null !== t && t.apply(this, arguments) || this;
e.G = 1;
e.invSqr = !0;
return e;
}
e.prototype.Step = function(t) {
if (this.invSqr) for (var i = this.m_bodyList; i; i = i.nextBody) for (var r = (h = i.body).GetWorldCenter(), s = h.GetMass(), o = this.m_bodyList; o && o !== i; o = o.nextBody) {
var a = (l = o.body).GetWorldCenter(), c = l.GetMass();
if (!((f = (u = a.x - r.x) * u + (_ = a.y - r.y) * _) < n)) {
(d = e.Step_s_f.Set(u, _)).SelfMul(this.G / f / T(f) * s * c);
h.IsAwake() && h.ApplyForce(d, r);
l.IsAwake() && l.ApplyForce(d.SelfMul(-1), a);
}
} else for (i = this.m_bodyList; i; i = i.nextBody) {
var h;
for (r = (h = i.body).GetWorldCenter(), s = h.GetMass(), o = this.m_bodyList; o && o !== i; o = o.nextBody) {
var l, u, _, f;
a = (l = o.body).GetWorldCenter(), c = l.GetMass();
if (!((f = (u = a.x - r.x) * u + (_ = a.y - r.y) * _) < n)) {
var d;
(d = e.Step_s_f.Set(u, _)).SelfMul(this.G / f * s * c);
h.IsAwake() && h.ApplyForce(d, r);
l.IsAwake() && l.ApplyForce(d.SelfMul(-1), a);
}
}
}
};
e.prototype.Draw = function(t) {};
e.Step_s_f = new P();
return e;
})(Gn), Wn = (function(t) {
Qe(e, t);
function e() {
var e = null !== t && t.apply(this, arguments) || this;
e.T = new F();
e.maxTimestep = 0;
return e;
}
e.prototype.Step = function(t) {
var i = t.dt;
if (!(i <= n)) {
i > this.maxTimestep && this.maxTimestep > 0 && (i = this.maxTimestep);
for (var r = this.m_bodyList; r; r = r.nextBody) {
var s = r.body;
if (s.IsAwake()) {
var o = s.GetWorldVector(F.MulMV(this.T, s.GetLocalVector(s.GetLinearVelocity(), P.s_t0), P.s_t1), e.Step_s_damping);
s.SetLinearVelocity(P.AddVV(s.GetLinearVelocity(), P.MulSV(i, o, P.s_t0), P.s_t1));
}
}
}
};
e.prototype.Draw = function(t) {};
e.prototype.SetAxisAligned = function(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 / x(t, e) : 0;
};
e.Step_s_damping = new P();
return e;
})(Gn), qn = (function() {
return function() {
this.vertices = [];
this.count = 0;
this.masses = [];
this.gravity = new P(0, 0);
this.damping = .1;
this.k2 = .9;
this.k3 = .1;
};
})(), Xn = (function() {
function t() {
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 P();
this.m_damping = 0;
this.m_k2 = 1;
this.m_k3 = .1;
}
t.prototype.GetVertexCount = function() {
return this.m_count;
};
t.prototype.GetVertices = function() {
return this.m_ps;
};
t.prototype.Initialize = function(t) {
this.m_count = t.count;
this.m_ps = P.MakeArray(this.m_count);
this.m_p0s = P.MakeArray(this.m_count);
this.m_vs = P.MakeArray(this.m_count);
this.m_ims = m(this.m_count);
for (var 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();
var i = t.masses[e];
this.m_ims[e] = i > 0 ? 1 / i : 0;
}
var n = this.m_count - 1, r = this.m_count - 2;
this.m_Ls = m(n);
this.m_as = m(r);
for (e = 0; e < n; ++e) {
var s = this.m_ps[e], o = this.m_ps[e + 1];
this.m_Ls[e] = P.DistanceVV(s, o);
}
for (e = 0; e < r; ++e) {
s = this.m_ps[e], o = this.m_ps[e + 1];
var a = this.m_ps[e + 2], c = P.SubVV(o, s, P.s_t0), h = P.SubVV(a, o, P.s_t1), l = P.CrossVV(c, h), u = P.DotVV(c, h);
this.m_as[e] = I(l, u);
}
this.m_gravity.Copy(t.gravity);
this.m_damping = t.damping;
this.m_k2 = t.k2;
this.m_k3 = t.k3;
};
t.prototype.Step = function(t, e) {
if (0 !== t) {
for (var i = Math.exp(-t * this.m_damping), n = 0; n < this.m_count; ++n) {
this.m_p0s[n].Copy(this.m_ps[n]);
this.m_ims[n] > 0 && this.m_vs[n].SelfMulAdd(t, this.m_gravity);
this.m_vs[n].SelfMul(i);
this.m_ps[n].SelfMulAdd(t, this.m_vs[n]);
}
for (n = 0; n < e; ++n) {
this.SolveC2();
this.SolveC3();
this.SolveC2();
}
var r = 1 / t;
for (n = 0; n < this.m_count; ++n) P.MulSV(r, P.SubVV(this.m_ps[n], this.m_p0s[n], P.s_t0), this.m_vs[n]);
}
};
t.prototype.SolveC2 = function() {
for (var e = this.m_count - 1, i = 0; i < e; ++i) {
var n = this.m_ps[i], r = this.m_ps[i + 1], s = P.SubVV(r, n, t.s_d), o = s.Normalize(), a = this.m_ims[i], c = this.m_ims[i + 1];
if (a + c !== 0) {
var h = a / (a + c), l = c / (a + c);
n.SelfMulSub(this.m_k2 * h * (this.m_Ls[i] - o), s);
r.SelfMulAdd(this.m_k2 * l * (this.m_Ls[i] - o), s);
}
}
};
t.prototype.SetAngle = function(t) {
for (var e = this.m_count - 2, i = 0; i < e; ++i) this.m_as[i] = t;
};
t.prototype.SolveC3 = function() {
for (var e = this.m_count - 2, i = 0; i < e; ++i) {
var n = this.m_ps[i], r = this.m_ps[i + 1], o = this.m_ps[i + 2], a = this.m_ims[i], c = this.m_ims[i + 1], h = this.m_ims[i + 2], l = P.SubVV(r, n, t.s_d1), u = P.SubVV(o, r, t.s_d2), _ = l.LengthSquared(), f = u.LengthSquared();
if (_ * f != 0) {
var d = P.CrossVV(l, u), m = P.DotVV(l, u), p = I(d, m), v = P.MulSV(-1 / _, l.SelfSkew(), t.s_Jd1), y = P.MulSV(1 / f, u.SelfSkew(), t.s_Jd2), g = P.NegV(v, t.s_J1), x = P.SubVV(v, y, t.s_J2), C = y, A = a * P.DotVV(g, g) + c * P.DotVV(x, x) + h * P.DotVV(C, C);
if (0 !== A) {
A = 1 / A;
for (var b = p - this.m_as[i]; b > s; ) b = (p -= 2 * s) - this.m_as[i];
for (;b < -s; ) b = (p += 2 * s) - this.m_as[i];
var S = -this.m_k3 * A * b;
n.SelfMulAdd(a * S, g);
r.SelfMulAdd(c * S, x);
o.SelfMulAdd(h * S, C);
}
}
}
};
t.prototype.Draw = function(t) {
for (var e = new G(.4, .5, .7), i = 0; i < this.m_count - 1; ++i) t.DrawSegment(this.m_ps[i], this.m_ps[i + 1], e);
};
t.s_d = new P();
t.s_d1 = new P();
t.s_d2 = new P();
t.s_Jd1 = new P();
t.s_Jd2 = new P();
t.s_J1 = new P();
t.s_J2 = new P();
return t;
})();
t.b2Assert = function(t) {
for (var e = [], i = 1; i < arguments.length; i++) e[i - 1] = arguments[i];
if (!t) throw new (Error.bind.apply(Error, [ void 0 ].concat(e)))();
};
t.b2Maybe = e;
t.b2_maxFloat = i;
t.b2_epsilon = n;
t.b2_epsilon_sq = r;
t.b2_pi = s;
t.b2_maxManifoldPoints = o;
t.b2_maxPolygonVertices = a;
t.b2_aabbExtension = .1;
t.b2_aabbMultiplier = 2;
t.b2_linearSlop = c;
t.b2_angularSlop = h;
t.b2_polygonRadius = l;
t.b2_maxSubSteps = 8;
t.b2_maxTOIContacts = 32;
t.b2_velocityThreshold = 1;
t.b2_maxLinearCorrection = .2;
t.b2_maxAngularCorrection = .13962634015955555;
t.b2_maxTranslation = 2;
t.b2_maxTranslationSquared = 4;
t.b2_maxRotation = 1.570796326795;
t.b2_maxRotationSquared = 2.4674011002726646;
t.b2_baumgarte = .2;
t.b2_toiBaumgarte = .75;
t.b2_invalidParticleIndex = u;
t.b2_maxParticleIndex = 2147483647;
t.b2_particleStride = .75;
t.b2_minParticleWeight = 1;
t.b2_maxParticlePressure = .25;
t.b2_maxParticleForce = .5;
t.b2_maxTriadDistance = 2;
t.b2_maxTriadDistanceSquared = 4;
t.b2_minParticleSystemBufferCapacity = 256;
t.b2_barrierCollisionTime = 2.5;
t.b2_timeToSleep = .5;
t.b2_linearSleepTolerance = .01;
t.b2_angularSleepTolerance = .03490658503988889;
t.b2Alloc = function(t) {
return null;
};
t.b2Free = function(t) {};
t.b2Log = function(t) {
for (var e = [], i = 1; i < arguments.length; i++) e[i - 1] = arguments[i];
};
t.b2Version = _;
t.b2_version = f;
t.b2_branch = "master";
t.b2_commit = "fbf51801d80fc389d43dc46524520e89043b6faf";
t.b2ParseInt = function(t) {
return parseInt(t, 10);
};
t.b2ParseUInt = function(t) {
return Math.abs(parseInt(t, 10));
};
t.b2MakeArray = d;
t.b2MakeNullArray = function(t) {
for (var e = [], i = 0; i < t; ++i) e.push(null);
return e;
};
t.b2MakeNumberArray = m;
t.b2_pi_over_180 = p;
t.b2_180_over_pi = v;
t.b2_two_pi = 6.28318530718;
t.b2Abs = y;
t.b2Min = g;
t.b2Max = x;
t.b2Clamp = C;
t.b2Swap = function(t, e) {
var i = t[0];
t[0] = e[0];
e[0] = i;
};
t.b2IsValid = A;
t.b2Sq = b;
t.b2InvSqrt = S;
t.b2Sqrt = T;
t.b2Pow = w;
t.b2DegToRad = function(t) {
return t * p;
};
t.b2RadToDeg = function(t) {
return t * v;
};
t.b2Cos = E;
t.b2Sin = B;
t.b2Acos = M;
t.b2Asin = D;
t.b2Atan2 = I;
t.b2NextPowerOfTwo = function(t) {
t |= t >> 1 & 2147483647;
t |= t >> 2 & 1073741823;
t |= t >> 4 & 268435455;
t |= t >> 8 & 16777215;
return 1 + (t |= t >> 16 & 65535);
};
t.b2IsPowerOfTwo = function(t) {
return t > 0 && 0 == (t & t - 1);
};
t.b2Random = function() {
return 2 * Math.random() - 1;
};
t.b2RandomRange = function(t, e) {
return (e - t) * Math.random() + t;
};
t.b2Vec2 = P;
t.b2Vec2_zero = R;
t.b2Vec3 = L;
t.b2Mat22 = F;
t.b2Mat33 = V;
t.b2Rot = O;
t.b2Transform = N;
t.b2Sweep = k;
t.b2Color = G;
t.b2Draw = z;
t.b2Timer = U;
t.b2Counter = j;
t.b2GrowableStack = H;
t.b2BlockAllocator = W;
t.b2StackAllocator = q;
t.b2ContactFeature = yt;
t.b2ContactID = gt;
t.b2ManifoldPoint = xt;
t.b2Manifold = Ct;
t.b2WorldManifold = At;
t.b2GetPointStates = function(e, i, n, r) {
var s;
for (s = 0; s < n.pointCount; ++s) {
var a = n.points[s].id.key;
e[s] = t.b2PointState.b2_removeState;
for (var c = 0, h = r.pointCount; c < h; ++c) if (r.points[c].id.key === a) {
e[s] = t.b2PointState.b2_persistState;
break;
}
}
for (;s < o; ++s) e[s] = t.b2PointState.b2_nullState;
for (s = 0; s < r.pointCount; ++s) {
a = r.points[s].id.key;
i[s] = t.b2PointState.b2_addState;
for (c = 0, h = n.pointCount; c < h; ++c) if (n.points[c].id.key === a) {
i[s] = t.b2PointState.b2_persistState;
break;
}
}
for (;s < o; ++s) i[s] = t.b2PointState.b2_nullState;
};
t.b2ClipVertex = bt;
t.b2RayCastInput = St;
t.b2RayCastOutput = Tt;
t.b2AABB = wt;
t.b2TestOverlapAABB = Et;
t.b2ClipSegmentToLine = Bt;
t.b2TestOverlapShape = Pt;
t.b2DistanceProxy = X;
t.b2SimplexCache = Y;
t.b2DistanceInput = J;
t.b2DistanceOutput = Z;
t.b2ShapeCastInput = K;
t.b2ShapeCastOutput = Q;
t.b2_gjk_reset = function() {
t.b2_gjkCalls = 0;
t.b2_gjkIters = 0;
t.b2_gjkMaxIters = 0;
};
t.b2SimplexVertex = $;
t.b2Simplex = tt;
t.b2Distance = ht;
t.b2ShapeCast = function(t, e) {
t.iterations = 0;
t.lambda = 1;
t.normal.SetZero();
t.point.SetZero();
var i = e.proxyA, n = e.proxyB, r = x(i.m_radius, l) + x(n.m_radius, l), s = e.transformA, o = e.transformB, a = e.translationB, h = lt.Set(0, 0), u = 0, _ = ut;
_.m_count = 0;
for (var f = _.m_vertices, d = i.GetSupport(O.MulTRV(s.q, P.NegV(a, P.s_t1), P.s_t0)), m = N.MulXV(s, i.GetVertex(d), _t), p = n.GetSupport(O.MulTRV(o.q, a, P.s_t0)), v = N.MulXV(o, n.GetVertex(p), ft), g = P.SubVV(m, v, dt), C = x(l, r - l), A = .5 * c, b = 0; b < 20 && y(g.Length() - C) > A; ) {
t.iterations += 1;
d = i.GetSupport(O.MulTRV(s.q, P.NegV(g, P.s_t1), P.s_t0));
m = N.MulXV(s, i.GetVertex(d), _t);
p = n.GetSupport(O.MulTRV(o.q, g, P.s_t0));
v = N.MulXV(o, n.GetVertex(p), ft);
var S = P.SubVV(m, v, mt);
g.Normalize();
var T = P.DotVV(g, S), w = P.DotVV(g, a);
if (T - C > u * w) {
if (w <= 0) return !1;
if ((u = (T - C) / w) > 1) return !1;
h.Copy(g).SelfNeg();
_.m_count = 0;
}
var E = f[_.m_count];
E.indexA = p;
E.wA.Copy(v).SelfMulAdd(u, a);
E.indexB = d;
E.wB.Copy(m);
E.w.Copy(E.wB).SelfSub(E.wA);
E.a = 1;
_.m_count += 1;
switch (_.m_count) {
case 1:
break;

case 2:
_.Solve2();
break;

case 3:
_.Solve3();
}
if (3 === _.m_count) return !1;
_.GetClosestPoint(g);
++b;
}
var B = pt, M = vt;
_.GetWitnessPoints(B, M);
if (g.LengthSquared() > 0) {
h.Copy(g).SelfNeg();
h.Normalize();
}
t.normal.Copy(h);
t.lambda = u;
t.iterations = b;
return !0;
};
t.b2Pair = Vt;
t.b2BroadPhase = Ot;
t.b2PairLessThan = Nt;
t.b2TreeNode = Lt;
t.b2DynamicTree = Ft;
t.b2_toi_reset = function() {
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;
};
t.b2TOIInput = qt;
t.b2TOIOutput = Xt;
t.b2SeparationFunction = Yt;
t.b2TimeOfImpact = re;
t.b2CollideCircles = ae;
t.b2CollidePolygonAndCircle = ue;
t.b2CollidePolygons = Le;
t.b2CollideEdgeAndCircle = je;
t.b2CollideEdgeAndPolygon = Ye;
t.b2MassData = Je;
t.b2Shape = Ze;
t.b2CircleShape = $e;
t.b2PolygonShape = ti;
t.b2EdgeShape = ei;
t.b2ChainShape = ii;
t.b2Filter = ni;
t.b2FixtureDef = ri;
t.b2FixtureProxy = si;
t.b2Fixture = oi;
t.b2BodyDef = ai;
t.b2Body = ci;
t.b2World = Nn;
t.b2DestructionListener = Zi;
t.b2ContactFilter = Ki;
t.b2ContactImpulse = Qi;
t.b2ContactListener = $i;
t.b2QueryCallback = tn;
t.b2RayCastCallback = en;
t.b2Island = mn;
t.b2Profile = rn;
t.b2TimeStep = sn;
t.b2Position = on;
t.b2Velocity = an;
t.b2SolverData = cn;
t.b2ContactManager = nn;
t.b2MixFriction = Oi;
t.b2MixRestitution = Ni;
t.b2ContactEdge = ki;
t.b2Contact = Gi;
t.b2ContactRegister = Yi;
t.b2ContactFactory = Ji;
t.g_blockSolve = !1;
t.b2VelocityConstraintPoint = hn;
t.b2ContactVelocityConstraint = ln;
t.b2ContactPositionConstraint = un;
t.b2ContactSolverDef = _n;
t.b2PositionSolverManifold = fn;
t.b2ContactSolver = dn;
t.b2CircleContact = zi;
t.b2PolygonContact = Ui;
t.b2PolygonAndCircleContact = ji;
t.b2EdgeAndCircleContact = Hi;
t.b2EdgeAndPolygonContact = Wi;
t.b2ChainAndCircleContact = qi;
t.b2ChainAndPolygonContact = Xi;
t.b2Jacobian = hi;
t.b2JointEdge = li;
t.b2JointDef = ui;
t.b2Joint = _i;
t.b2AreaJointDef = mi;
t.b2AreaJoint = pi;
t.b2DistanceJointDef = fi;
t.b2DistanceJoint = di;
t.b2FrictionJointDef = vi;
t.b2FrictionJoint = yi;
t.b2GearJointDef = gi;
t.b2GearJoint = xi;
t.b2MotorJointDef = Ci;
t.b2MotorJoint = Ai;
t.b2MouseJointDef = bi;
t.b2MouseJoint = Si;
t.b2PrismaticJointDef = Ti;
t.b2PrismaticJoint = wi;
t.b2_minPulleyLength = 2;
t.b2PulleyJointDef = Ei;
t.b2PulleyJoint = Bi;
t.b2RevoluteJointDef = Mi;
t.b2RevoluteJoint = Di;
t.b2RopeJointDef = Ii;
t.b2RopeJoint = Pi;
t.b2WeldJointDef = Ri;
t.b2WeldJoint = Li;
t.b2WheelJointDef = Fi;
t.b2WheelJoint = Vi;
t.b2ControllerEdge = kn;
t.b2Controller = Gn;
t.b2BuoyancyController = zn;
t.b2ConstantAccelController = Un;
t.b2ConstantForceController = jn;
t.b2GravityController = Hn;
t.b2TensorDampingController = Wn;
t.b2ParticleDef = pn;
t.b2CalculateParticleIterations = vn;
t.b2ParticleHandle = yn;
t.b2ParticleGroupDef = gn;
t.b2ParticleGroup = xn;
t.b2GrowableBuffer = In;
t.b2FixtureParticleQueryCallback = Pn;
t.b2ParticleContact = Rn;
t.b2ParticleBodyContact = Ln;
t.b2ParticlePair = Fn;
t.b2ParticleTriad = Vn;
t.b2ParticleSystemDef = On;
t.b2RopeDef = qn;
t.b2Rope = Xn;
Object.defineProperty(t, "__esModule", {
value: !0
});
}));
}), {} ],
295: [ (function(i, n, r) {
var s = "undefined" === ("object" === (e = typeof window) ? t(window) : e) ? global : window;
s.cc = s.cc || {};
s._cc = s._cc || {};
i("./predefine");
i("./polyfill/string");
i("./polyfill/misc");
i("./polyfill/array");
i("./polyfill/object");
i("./polyfill/array-buffer");
i("./polyfill/typescript");
i("./cocos2d/core/predefine");
i("./cocos2d");
i("./extends");
0;
n.exports = s.cc;
}), {
"./cocos2d": 261,
"./cocos2d/core/predefine": 185,
"./extends": 281,
"./package": void 0,
"./polyfill/array": 297,
"./polyfill/array-buffer": 296,
"./polyfill/misc": 298,
"./polyfill/object": 299,
"./polyfill/string": 300,
"./polyfill/typescript": 301,
"./predefine": 302
} ],
296: [ (function(t, e, i) {
ArrayBuffer.isView || (function() {
var t = Object.getPrototypeOf(Object.getPrototypeOf(new Uint8Array())).constructor;
ArrayBuffer.isView = function(e) {
return e instanceof t;
};
})();
}), {} ],
297: [ (function(t, e, i) {
Array.isArray || (Array.isArray = function(t) {
return "[object Array]" === Object.prototype.toString.call(t);
});
}), {} ],
298: [ (function(i, n, r) {
Math.sign || (Math.sign = function(t) {
return 0 === (t = +t) || isNaN(t) ? t : t > 0 ? 1 : -1;
});
Number.isInteger || (Number.isInteger = function(i) {
return "number" === ("object" === (e = typeof i) ? t(i) : e) && isFinite(i) && Math.floor(i) === i;
});
var s = window.performance || Date, o = Object.create(null);
console.time = function(t) {
o[t] = s.now();
};
console.timeEnd = function(t) {
var e = o[t], i = s.now() - e;
console.log(t + ": " + i + "ms");
};
}), {} ],
299: [ (function(t, e, i) {
Object.assign || (Object.assign = function(t, e) {
cc.js.mixin(t, e);
});
Object.getOwnPropertyDescriptors || (Object.getOwnPropertyDescriptors = function(t) {
for (var e = {}, i = Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t)), n = 0; n < i.length; ++n) {
var r = i[n];
e[r] = Object.getOwnPropertyDescriptor(t, r);
}
return e;
});
}), {} ],
300: [ (function(i, n, r) {
String.prototype.startsWith || (String.prototype.startsWith = function(t, e) {
e = e || 0;
return this.lastIndexOf(t, e) === e;
});
String.prototype.endsWith || (String.prototype.endsWith = function(i, n) {
("undefined" === ("object" === (e = typeof n) ? t(n) : e) || n > this.length) && (n = this.length);
n -= i.length;
var r = this.indexOf(i, n);
return -1 !== r && r === n;
});
}), {} ],
301: [ (function(i, n, r) {
var s = 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]);
};
window.__extends = function(t, e) {
s(t, e);
function i() {
this.constructor = t;
}
t.prototype = null === e ? Object.create(e) : (i.prototype = e.prototype, new i());
};
window.__assign = Object.assign || function(t) {
for (var e, i = 1, n = arguments.length; i < n; i++) {
e = arguments[i];
for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (t[r] = e[r]);
}
return t;
};
window.__rest = function(i, n) {
var r = {};
for (var s in i) Object.prototype.hasOwnProperty.call(i, s) && n.indexOf(s) < 0 && (r[s] = i[s]);
if (null != i && "function" === ("object" === (e = typeof Object.getOwnPropertySymbols) ? t(Object.getOwnPropertySymbols) : e)) {
var o = 0;
for (s = Object.getOwnPropertySymbols(i); o < s.length; o++) n.indexOf(s[o]) < 0 && (r[s[o]] = i[s[o]]);
}
return r;
};
window.__decorate = function(i, n, r, s) {
var o, a = arguments.length, c = a < 3 ? n : null === s ? s = Object.getOwnPropertyDescriptor(n, r) : s;
if ("object" === ("object" === (e = typeof Reflect) ? t(Reflect) : e) && "function" === ("object" === (e = typeof Reflect.decorate) ? t(Reflect.decorate) : e)) c = Reflect.decorate(i, n, r, s); else for (var h = i.length - 1; h >= 0; h--) (o = i[h]) && (c = (a < 3 ? o(c) : a > 3 ? o(n, r, c) : o(n, r)) || c);
return a > 3 && c && Object.defineProperty(n, r, c), c;
};
window.__param = function(t, e) {
return function(i, n) {
e(i, n, t);
};
};
window.__metadata = function(i, n) {
if ("object" === ("object" === (e = typeof Reflect) ? t(Reflect) : e) && "function" === ("object" === (e = typeof Reflect.metadata) ? t(Reflect.metadata) : e)) return Reflect.metadata(i, n);
};
window.__awaiter = function(t, e, i, n) {
return new (i || (i = Promise))(function(r, s) {
function o(t) {
try {
c(n.next(t));
} catch (t) {
s(t);
}
}
function a(t) {
try {
c(n.throw(t));
} catch (t) {
s(t);
}
}
function c(t) {
t.done ? r(t.value) : new i(function(e) {
e(t.value);
}).then(o, a);
}
c((n = n.apply(t, e || [])).next());
});
};
window.__generator = function(i, n) {
var r, s, o, a, c = {
label: 0,
sent: function() {
if (1 & o[0]) throw o[1];
return o[1];
},
trys: [],
ops: []
};
return a = {
next: h(0),
throw: h(1),
return: h(2)
}, "function" === ("object" === (e = typeof Symbol) ? t(Symbol) : e) && (a[Symbol.iterator] = function() {
return this;
}), a;
function h(t) {
return function(e) {
return (function(t) {
if (r) throw new TypeError("Generator is already executing.");
for (;c; ) try {
if (r = 1, s && (o = s[2 & t[0] ? "return" : t[0] ? "throw" : "next"]) && !(o = o.call(s, t[1])).done) return o;
(s = 0, o) && (t = [ 0, o.value ]);
switch (t[0]) {
case 0:
case 1:
o = t;
break;

case 4:
c.label++;
return {
value: t[1],
done: !1
};

case 5:
c.label++;
s = t[1];
t = [ 0 ];
continue;

case 7:
t = c.ops.pop();
c.trys.pop();
continue;

default:
if (!(o = c.trys, o = o.length > 0 && o[o.length - 1]) && (6 === t[0] || 2 === t[0])) {
c = 0;
continue;
}
if (3 === t[0] && (!o || t[1] > o[0] && t[1] < o[3])) {
c.label = t[1];
break;
}
if (6 === t[0] && c.label < o[1]) {
c.label = o[1];
o = t;
break;
}
if (o && c.label < o[2]) {
c.label = o[2];
c.ops.push(t);
break;
}
o[2] && c.ops.pop();
c.trys.pop();
continue;
}
t = n.call(i, c);
} catch (e) {
t = [ 6, e ];
s = 0;
} finally {
r = o = 0;
}
if (5 & t[0]) throw t[1];
return {
value: t[0] ? t[1] : void 0,
done: !0
};
})([ t, e ]);
};
}
};
window.__exportStar = function(t, e) {
for (var i in t) e.hasOwnProperty(i) || (e[i] = t[i]);
};
window.__values = function(i) {
var n = "function" === ("object" === (e = typeof Symbol) ? t(Symbol) : e) && i[Symbol.iterator], r = 0;
return n ? n.call(i) : {
next: function() {
i && r >= i.length && (i = void 0);
return {
value: i && i[r++],
done: !i
};
}
};
};
window.__read = function(i, n) {
var r = "function" === ("object" === (e = typeof Symbol) ? t(Symbol) : e) && i[Symbol.iterator];
if (!r) return i;
var s, o, a = r.call(i), c = [];
try {
for (;(void 0 === n || n-- > 0) && !(s = a.next()).done; ) c.push(s.value);
} catch (t) {
o = {
error: t
};
} finally {
try {
s && !s.done && (r = a.return) && r.call(a);
} finally {
if (o) throw o.error;
}
}
return c;
};
window.__spread = function() {
for (var t = [], e = 0; e < arguments.length; e++) t = t.concat(__read(arguments[e]));
return t;
};
window.__await = function(t) {
return this instanceof __await ? (this.v = t, this) : new __await(t);
};
window.__asyncGenerator = function(t, e, i) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var n, r = i.apply(t, e || []), s = [];
return n = {}, o("next"), o("throw"), o("return"), n[Symbol.asyncIterator] = function() {
return this;
}, n;
function o(t) {
r[t] && (n[t] = function(e) {
return new Promise(function(i, n) {
s.push([ t, e, i, n ]) > 1 || a(t, e);
});
});
}
function a(t, e) {
try {
(function(t) {
t.value instanceof __await ? Promise.resolve(t.value.v).then(c, h) : l(s[0][2], t);
})(r[t](e));
} catch (t) {
l(s[0][3], t);
}
}
function c(t) {
a("next", t);
}
function h(t) {
a("throw", t);
}
function l(t, e) {
(t(e), s.shift(), s.length) && a(s[0][0], s[0][1]);
}
};
window.__asyncDelegator = function(t) {
var e, i;
return e = {}, n("next"), n("throw", (function(t) {
throw t;
})), n("return"), e[Symbol.iterator] = function() {
return this;
}, e;
function n(n, r) {
t[n] && (e[n] = function(e) {
return (i = !i) ? {
value: __await(t[n](e)),
done: "return" === n
} : r ? r(e) : e;
});
}
};
window.__asyncValues = function(i) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var n = i[Symbol.asyncIterator];
return n ? n.call(i) : "function" === ("object" === (e = typeof __values) ? t(__values) : e) ? __values(i) : i[Symbol.iterator]();
};
}), {} ],
302: [ (function(i, n, r) {
var s = "undefined" === ("object" === (e = typeof window) ? t(window) : e) ? global : window;
function o(i, n) {
"undefined" === ("object" === (e = typeof s[i]) ? t(s[i]) : e) && (s[i] = n);
}
o("CC_BUILD", !1);
s.CC_BUILD = !0;
s.CC_TEST = !1;
s.CC_EDITOR = !1;
s.CC_PREVIEW = !1;
s.CC_DEV = !1;
s.CC_DEBUG = !1;
s.CC_JSB = !0;
s.CC_WECHATGAMESUB = !1;
s.CC_WECHATGAME = !1;
s.CC_QQPLAY = !1;
s.CC_RUNTIME = !1;
s.CC_SUPPORT_JIT = !0;
0;
s.CocosEngine = cc.ENGINE_VERSION = "2.0.9";
}), {} ]
}, {}, [ 295 ]);
function t(t) {
return t && t.toString && "[object CallbackConstructor]" === t.toString() ? "function" : "object";
}
var e = "";
})();