Created
December 4, 2022 04:15
-
-
Save korrio/7a3f2e85aeb88719a53e888fc5d055b6 to your computer and use it in GitHub Desktop.
slot.js
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(t, e, i) { | |
function n(i) { | |
var r = e[i]; | |
if (!r) { | |
var s = t[i]; | |
if (!s) | |
return; | |
var a = {}; | |
r = e[i] = { | |
exports: a | |
}, | |
s[0]((function(t) { | |
return n(s[1][t] || t) | |
} | |
), r, a) | |
} | |
return r.exports | |
} | |
for (var r = 0; r < i.length; r++) | |
n(i[r]) | |
} | |
)({ | |
1: [(function(t) { | |
"use strict"; | |
t("../core/platform/CCClass"); | |
var e = 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; | |
return t.originalTarget = null, | |
t.target = null, | |
t.tag = this.tag, | |
t | |
}, | |
isDone: function() { | |
return !0 | |
}, | |
startWithTarget: function(t) { | |
this.originalTarget = t, | |
this.target = t | |
}, | |
stop: function() { | |
this.target = null | |
}, | |
step: function() {}, | |
update: function() {}, | |
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() { | |
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) { | |
return !!t && (this._innerAction = t, | |
this._speed = e, | |
!0) | |
}, | |
clone: function() { | |
var t = new cc.Speed; | |
return t.initWithAction(this._innerAction.clone(), this._speed), | |
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); | |
return t.initWithTarget(this._followedNode, i), | |
t | |
}, | |
isBoundarySet: function() { | |
return this._boundarySet | |
}, | |
setBoundarySet: function(t) { | |
this._boundarySet = t | |
}, | |
setBoudarySet: function(t) { | |
this.setBoundarySet(t) | |
}, | |
initWithTarget: function(t, e) { | |
if (!t) | |
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; | |
return this._fullScreenSize = cc.v2(i.width, i.height), | |
this._halfScreenSize = this._fullScreenSize.mul(.5), | |
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)), | |
!0 | |
}, | |
step: function() { | |
var t = this.target.convertToWorldSpaceAR(cc.Vec2.ZERO) | |
, i = this._followedNode.convertToWorldSpaceAR(cc.Vec2.ZERO) | |
, n = t.sub(i) | |
, r = this.target.parent.convertToNodeSpaceAR(n.add(this._halfScreenSize)); | |
if (this._boundarySet) { | |
if (this._boundaryFullyCovered) | |
return; | |
this.target.setPosition(e.clampf(r.x, this.leftBoundary, this.rightBoundary), e.clampf(r.y, this.bottomBoundary, this.topBoundary)) | |
} else | |
this.target.setPosition(r.x, r.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": 162, | |
"../core/utils/misc": 236 | |
}], | |
2: [(function() { | |
"use strict"; | |
function t(t, e) { | |
return t[Math.min(t.length - 1, Math.max(e, 0))] | |
} | |
function e(t) { | |
for (var e = [], i = t.length - 1; i >= 0; i--) | |
e.push(cc.v2(t[i].x, t[i].y)); | |
return e | |
} | |
function i(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) { | |
return !(!e || 0 === e.length || !cc.ActionInterval.prototype.initWithDuration.call(this, t) || (this.setPoints(e), | |
this._tension = i, | |
0)) | |
}, | |
clone: function() { | |
var t = new cc.CardinalSplineTo; | |
return t.initWithDuration(this._duration, i(this._points), this._tension), | |
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(e) { | |
var i, n; | |
e = this._computeEaseTime(e); | |
var r = this._points; | |
if (1 === e) | |
i = r.length - 1, | |
n = 1; | |
else { | |
var s = this._deltaT; | |
n = (e - s * (i = 0 | e / s)) / s | |
} | |
var a, o, c, l, h, u, f, d, _, p, v, g, m, y, T, E, A = (a = t(r, i - 1), | |
o = t(r, i - 0), | |
c = t(r, i + 1), | |
l = t(r, i + 2), | |
_ = (d = (1 - this._tension) / 2) * (2 * (u = (h = n) * h) - (f = u * h) - h), | |
p = d * (-f + u) + (2 * f - 3 * u) + 1, | |
v = d * (f - 2 * u + h) + -2 * f + 3 * u, | |
g = d * (f - u), | |
m = a.x * _ + o.x * p + c.x * v + l.x * g, | |
y = a.y * _ + o.y * p + c.y * v + l.y * g, | |
cc.v2(m, y)); | |
if (cc.macro.ENABLE_STACKABLE_ACTIONS && (T = this.target.x - this._previousPosition.x, | |
E = this.target.y - this._previousPosition.y, | |
0 !== T || 0 !== E)) { | |
var x = this._accumulatedDiff; | |
T = x.x + T, | |
E = x.y + E, | |
x.x = T, | |
x.y = E, | |
A.x += T, | |
A.y += E | |
} | |
this.updatePosition(A) | |
}, | |
reverse: function() { | |
var t = e(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, i = this._points.slice(), n = i[0], r = 1; r < i.length; ++r) | |
t = i[r], | |
i[r] = t.sub(n), | |
n = t; | |
var s = e(i); | |
for (n = s[s.length - 1], | |
s.pop(), | |
n.x = -n.x, | |
n.y = -n.y, | |
s.unshift(n), | |
r = 1; r < s.length; ++r) | |
(t = s[r]).x = -t.x, | |
t.y = -t.y, | |
t.x += n.x, | |
t.y += n.y, | |
s[r] = t, | |
n = 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; | |
return t.initWithDuration(this._duration, i(this._points), this._tension), | |
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; | |
return t.initWithDuration(this._duration, i(this._points)), | |
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; | |
return t.initWithDuration(this._duration, i(this._points)), | |
t | |
} | |
}), | |
cc.catmullRomBy = function(t, e) { | |
return new cc.CatmullRomBy(t,e) | |
} | |
} | |
), {}], | |
3: [(function() { | |
"use strict"; | |
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 t = { | |
easing: function(t) { | |
return 0 === t ? 0 : Math.pow(2, 10 * (t - 1)) | |
}, | |
reverse: function() { | |
return e | |
} | |
}; | |
cc.easeExponentialIn = function() { | |
return t | |
} | |
; | |
var e = { | |
easing: function(t) { | |
return 1 === t ? 1 : 1 - Math.pow(2, -10 * t) | |
}, | |
reverse: function() { | |
return t | |
} | |
}; | |
cc.easeExponentialOut = function() { | |
return e | |
} | |
; | |
var i = { | |
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 i | |
} | |
}; | |
cc.easeExponentialInOut = function() { | |
return i | |
} | |
; | |
var n = { | |
easing: function(t) { | |
return 0 === t || 1 === t ? t : -1 * Math.cos(t * Math.PI / 2) + 1 | |
}, | |
reverse: function() { | |
return r | |
} | |
}; | |
cc.easeSineIn = function() { | |
return n | |
} | |
; | |
var r = { | |
easing: function(t) { | |
return 0 === t || 1 === t ? t : Math.sin(t * Math.PI / 2) | |
}, | |
reverse: function() { | |
return n | |
} | |
}; | |
cc.easeSineOut = function() { | |
return r | |
} | |
; | |
var s = { | |
easing: function(t) { | |
return 0 === t || 1 === t ? t : -.5 * (Math.cos(Math.PI * t) - 1) | |
}, | |
reverse: function() { | |
return s | |
} | |
}; | |
cc.easeSineInOut = function() { | |
return s | |
} | |
; | |
var a = { | |
easing: function(t) { | |
return 0 === t || 1 === t ? t : -Math.pow(2, 10 * (t -= 1)) * Math.sin((t - .075) * Math.PI * 2 / .3) | |
}, | |
reverse: function() { | |
return o | |
} | |
}; | |
cc.easeElasticIn = function(t) { | |
return t && .3 !== t ? { | |
_period: t, | |
easing: function(t) { | |
return 0 === t || 1 === t ? t : -Math.pow(2, 10 * (t -= 1)) * Math.sin((t - this._period / 4) * Math.PI * 2 / this._period) | |
}, | |
reverse: function() { | |
return cc.easeElasticOut(this._period) | |
} | |
} : a | |
} | |
; | |
var o = { | |
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 a | |
} | |
}; | |
function c(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 | |
} | |
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) | |
} | |
} : o | |
} | |
, | |
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) | |
} | |
} | |
} | |
; | |
var l = { | |
easing: function(t) { | |
return 1 - c(1 - t) | |
}, | |
reverse: function() { | |
return h | |
} | |
}; | |
cc.easeBounceIn = function() { | |
return l | |
} | |
; | |
var h = { | |
easing: function(t) { | |
return c(t) | |
}, | |
reverse: function() { | |
return l | |
} | |
}; | |
cc.easeBounceOut = function() { | |
return h | |
} | |
; | |
var u = { | |
easing: function(t) { | |
return t < .5 ? .5 * (1 - c(1 - (t *= 2))) : .5 * c(2 * t - 1) + .5 | |
}, | |
reverse: function() { | |
return u | |
} | |
}; | |
cc.easeBounceInOut = function() { | |
return u | |
} | |
; | |
var f = { | |
easing: function(t) { | |
return 0 === t || 1 === t ? t : t * t * (2.70158 * t - 1.70158) | |
}, | |
reverse: function() { | |
return d | |
} | |
}; | |
cc.easeBackIn = function() { | |
return f | |
} | |
; | |
var d = { | |
easing: function(t) { | |
return 0 === t ? 0 : (t -= 1) * t * (2.70158 * t + 1.70158) + 1 | |
}, | |
reverse: function() { | |
return f | |
} | |
}; | |
cc.easeBackOut = function() { | |
return d | |
} | |
; | |
var _ = { | |
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 _ | |
} | |
}; | |
cc.easeBackInOut = function() { | |
return _ | |
} | |
, | |
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 p = { | |
easing: function(t) { | |
return Math.pow(t, 2) | |
}, | |
reverse: function() { | |
return p | |
} | |
}; | |
cc.easeQuadraticActionIn = function() { | |
return p | |
} | |
; | |
var v = { | |
easing: function(t) { | |
return -t * (t - 2) | |
}, | |
reverse: function() { | |
return v | |
} | |
}; | |
cc.easeQuadraticActionOut = function() { | |
return v | |
} | |
; | |
var g = { | |
easing: function(t) { | |
return (t *= 2) < 1 ? t * t * .5 : -.5 * (--t * (t - 2) - 1) | |
}, | |
reverse: function() { | |
return g | |
} | |
}; | |
cc.easeQuadraticActionInOut = function() { | |
return g | |
} | |
; | |
var m = { | |
easing: function(t) { | |
return t * t * t * t | |
}, | |
reverse: function() { | |
return m | |
} | |
}; | |
cc.easeQuarticActionIn = function() { | |
return m | |
} | |
; | |
var y = { | |
easing: function(t) { | |
return -((t -= 1) * t * t * t - 1) | |
}, | |
reverse: function() { | |
return y | |
} | |
}; | |
cc.easeQuarticActionOut = function() { | |
return y | |
} | |
; | |
var T = { | |
easing: function(t) { | |
return (t *= 2) < 1 ? .5 * t * t * t * t : -.5 * ((t -= 2) * t * t * t - 2) | |
}, | |
reverse: function() { | |
return T | |
} | |
}; | |
cc.easeQuarticActionInOut = function() { | |
return T | |
} | |
; | |
var E = { | |
easing: function(t) { | |
return t * t * t * t * t | |
}, | |
reverse: function() { | |
return E | |
} | |
}; | |
cc.easeQuinticActionIn = function() { | |
return E | |
} | |
; | |
var A = { | |
easing: function(t) { | |
return (t -= 1) * t * t * t * t + 1 | |
}, | |
reverse: function() { | |
return A | |
} | |
}; | |
cc.easeQuinticActionOut = function() { | |
return A | |
} | |
; | |
var x = { | |
easing: function(t) { | |
return (t *= 2) < 1 ? .5 * t * t * t * t * t : .5 * ((t -= 2) * t * t * t * t + 2) | |
}, | |
reverse: function() { | |
return x | |
} | |
}; | |
cc.easeQuinticActionInOut = function() { | |
return x | |
} | |
; | |
var C = { | |
easing: function(t) { | |
return -1 * (Math.sqrt(1 - t * t) - 1) | |
}, | |
reverse: function() { | |
return C | |
} | |
}; | |
cc.easeCircleActionIn = function() { | |
return C | |
} | |
; | |
var b = { | |
easing: function(t) { | |
return Math.sqrt(1 - (t -= 1) * t) | |
}, | |
reverse: function() { | |
return b | |
} | |
}; | |
cc.easeCircleActionOut = function() { | |
return b | |
} | |
; | |
var S = { | |
easing: function(t) { | |
return (t *= 2) < 1 ? -.5 * (Math.sqrt(1 - t * t) - 1) : .5 * (Math.sqrt(1 - (t -= 2) * t) + 1) | |
}, | |
reverse: function() { | |
return S | |
} | |
}; | |
cc.easeCircleActionInOut = function() { | |
return S | |
} | |
; | |
var R = { | |
easing: function(t) { | |
return t * t * t | |
}, | |
reverse: function() { | |
return R | |
} | |
}; | |
cc.easeCubicActionIn = function() { | |
return R | |
} | |
; | |
var M = { | |
easing: function(t) { | |
return (t -= 1) * t * t + 1 | |
}, | |
reverse: function() { | |
return M | |
} | |
}; | |
cc.easeCubicActionOut = function() { | |
return M | |
} | |
; | |
var w = { | |
easing: function(t) { | |
return (t *= 2) < 1 ? .5 * t * t * t : .5 * ((t -= 2) * t * t + 2) | |
}, | |
reverse: function() { | |
return w | |
} | |
}; | |
cc.easeCubicActionInOut = function() { | |
return w | |
} | |
} | |
), {}], | |
4: [(function() { | |
"use strict"; | |
cc.ActionInstant = cc.Class({ | |
name: "cc.ActionInstant", | |
extends: cc.FiniteTimeAction, | |
isDone: function() { | |
return !0 | |
}, | |
step: function() { | |
this.update(1) | |
}, | |
update: function() {}, | |
reverse: function() { | |
return this.clone() | |
}, | |
clone: function() { | |
return new cc.ActionInstant | |
} | |
}), | |
cc.Show = cc.Class({ | |
name: "cc.Show", | |
extends: cc.ActionInstant, | |
update: function() { | |
for (var t = this.target.getComponentsInChildren(cc.RenderComponent), e = 0; e < t.length; ++e) | |
t[e].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() { | |
for (var t = this.target.getComponentsInChildren(cc.RenderComponent), e = 0; e < t.length; ++e) | |
t[e].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() { | |
for (var t = this.target.getComponentsInChildren(cc.RenderComponent), e = 0; e < t.length; ++e) { | |
var i = t[e]; | |
i.enabled = !i.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() { | |
this.target.removeFromParent(this._isNeedCleanUp) | |
}, | |
init: function(t) { | |
return this._isNeedCleanUp = t, | |
!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.DestroySelf = cc.Class({ | |
name: "cc.DestroySelf", | |
extends: cc.ActionInstant, | |
update: function() { | |
this.target.destroy() | |
}, | |
reverse: function() { | |
return new cc.DestroySelf | |
}, | |
clone: function() { | |
return new cc.DestroySelf | |
} | |
}), | |
cc.destroySelf = function() { | |
return new cc.DestroySelf | |
} | |
, | |
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) { | |
return this._flippedX = t, | |
!0 | |
}, | |
update: function() { | |
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; | |
return t.initWithFlipX(this._flippedX), | |
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) { | |
return this._flippedY = t, | |
!0 | |
}, | |
update: function() { | |
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; | |
return t.initWithFlipY(this._flippedY), | |
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, | |
void 0 !== t && (void 0 !== t.x && (e = t.y, | |
t = t.x), | |
this.initWithPosition(t, e)) | |
}, | |
initWithPosition: function(t, e) { | |
return this._x = t, | |
this._y = e, | |
!0 | |
}, | |
update: function() { | |
this.target.setPosition(this._x, this._y) | |
}, | |
clone: function() { | |
var t = new cc.Place; | |
return t.initWithPosition(this._x, this._y), | |
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) { | |
return t && (this._function = t), | |
e && (this._selectorTarget = e), | |
void 0 !== i && (this._data = i), | |
!0 | |
}, | |
execute: function() { | |
this._function && this._function.call(this._selectorTarget, this.target, this._data) | |
}, | |
update: function() { | |
this.execute() | |
}, | |
getTargetCallback: function() { | |
return this._selectorTarget | |
}, | |
setTargetCallback: function(t) { | |
t !== this._selectorTarget && (this._selectorTarget && (this._selectorTarget = null), | |
this._selectorTarget = t) | |
}, | |
clone: function() { | |
var t = new cc.CallFunc; | |
return t.initWithFunction(this._function, this._selectorTarget, this._data), | |
t | |
} | |
}), | |
cc.callFunc = function(t, e, i) { | |
return new cc.CallFunc(t,e,i) | |
} | |
} | |
), {}], | |
5: [(function() { | |
"use strict"; | |
function t(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.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) { | |
return this._duration = 0 === t ? cc.macro.FLT_EPSILON : t, | |
this._elapsed = 0, | |
this._firstTick = !0, | |
!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); | |
return this._cloneDecoration(t), | |
t | |
}, | |
easing: function() { | |
this._easeList ? this._easeList.length = 0 : this._easeList = []; | |
for (var t = 0; t < arguments.length; t++) | |
this._easeList.push(arguments[t]); | |
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) { | |
this._firstTick ? (this._firstTick = !1, | |
this._elapsed = 0) : 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), | |
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() { | |
return null | |
}, | |
setAmplitudeRate: function() {}, | |
getAmplitudeRate: function() { | |
return 0 | |
}, | |
speed: function(t) { | |
return t <= 0 ? this : (this._speedMethod = !0, | |
this._speed *= t, | |
this) | |
}, | |
getSpeed: function() { | |
return this._speed | |
}, | |
setSpeed: function(t) { | |
return this._speed = t, | |
this | |
}, | |
repeat: function(t) { | |
return isNaN(t = Math.round(t)) || t < 1 ? this : (this._repeatMethod = !0, | |
this._timesForRepeat *= t, | |
this) | |
}, | |
repeatForever: function() { | |
return this._repeatMethod = !0, | |
this._timesForRepeat = this.MAX_VALUE, | |
this._repeatForever = !0, | |
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; | |
if (i >= 0 && e[i], | |
i >= 0) { | |
for (var n, r = e[0], s = 1; s < i; s++) | |
e[s] && (n = r, | |
r = cc.Sequence._actionOneTwo(n, e[s])); | |
this.initWithTwoActions(r, e[i]) | |
} | |
} | |
}, | |
initWithTwoActions: function(t, e) { | |
if (!t || !e) | |
return !1; | |
var i = t._duration | |
, n = e._duration | |
, r = (i *= t._repeatMethod ? t._timesForRepeat : 1) + (n *= e._repeatMethod ? e._timesForRepeat : 1); | |
return this.initWithDuration(r), | |
this._actions[0] = t, | |
this._actions[1] = e, | |
!0 | |
}, | |
clone: function() { | |
var t = new cc.Sequence; | |
return this._cloneDecoration(t), | |
t.initWithTwoActions(this._actions[0].clone(), this._actions[1].clone()), | |
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, a = this._last; | |
(t = this._computeEaseTime(t)) < r ? (e = 0 !== r ? t / r : 1, | |
0 === n && 1 === a && this._reversed && (s[1].update(0), | |
s[1].stop())) : (n = 1, | |
e = 1 === r ? 1 : (t - r) / (1 - r), | |
-1 === a && (s[0].startWithTarget(this.target), | |
s[0].update(1), | |
s[0].stop()), | |
0 === a && (s[0].update(1), | |
s[0].stop())), | |
i = s[n], | |
a === n && i.isDone() || (a !== 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()); | |
return this._cloneDecoration(t), | |
this._reverseEaseList(t), | |
t._reversed = !0, | |
t | |
} | |
}), | |
cc.sequence = function(t) { | |
var e = t instanceof Array ? t : arguments; | |
if (1 === e.length) | |
return null; | |
var i = e.length - 1; | |
i >= 0 && e[i]; | |
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; | |
return i.initWithTwoActions(t, e), | |
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; | |
return !!this.initWithDuration(i) && (this._times = e, | |
this._innerAction = t, | |
t instanceof cc.ActionInstant && (this._actionInstant = !0, | |
this._times -= 1), | |
this._total = 0, | |
!0) | |
}, | |
clone: function() { | |
var t = new cc.Repeat; | |
return this._cloneDecoration(t), | |
t.initWithAction(this._innerAction.clone(), this._times), | |
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; | |
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); | |
return this._cloneDecoration(t), | |
this._reverseEaseList(t), | |
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 = function(t) { | |
return new cc.RepeatForever(t) | |
} | |
, | |
cc.RepeatForever = cc.Class({ | |
name: "cc.RepeatForever", | |
extends: cc.ActionInterval, | |
ctor: function(t) { | |
this._innerAction = null, | |
t && this.initWithAction(t) | |
}, | |
initWithAction: function(t) { | |
return !!t && (this._innerAction = t, | |
!0) | |
}, | |
clone: function() { | |
var t = new cc.RepeatForever; | |
return this._cloneDecoration(t), | |
t.initWithAction(this._innerAction.clone()), | |
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), | |
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()); | |
return this._cloneDecoration(t), | |
this._reverseEaseList(t), | |
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; | |
if (i >= 0 && e[i], | |
i >= 0) { | |
for (var n, r = e[0], s = 1; s < i; s++) | |
e[s] && (n = r, | |
r = cc.Spawn._actionOneTwo(n, e[s])); | |
this.initWithTwoActions(r, e[i]) | |
} | |
} | |
}, | |
initWithTwoActions: function(t, e) { | |
if (!t || !e) | |
return !1; | |
var i = !1 | |
, n = t._duration | |
, r = e._duration; | |
return 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), | |
i | |
}, | |
clone: function() { | |
var t = new cc.Spawn; | |
return this._cloneDecoration(t), | |
t.initWithTwoActions(this._one.clone(), this._two.clone()), | |
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()); | |
return this._cloneDecoration(t), | |
this._reverseEaseList(t), | |
t | |
} | |
}), | |
cc.spawn = function(t) { | |
var e = t instanceof Array ? t : arguments; | |
if (1 === e.length) | |
return null; | |
e.length > 0 && e[e.length - 1]; | |
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; | |
return i.initWithTwoActions(t, e), | |
i | |
} | |
, | |
cc.RotateTo = cc.Class({ | |
name: "cc.RotateTo", | |
extends: cc.ActionInterval, | |
statics: { | |
_reverse: !1 | |
}, | |
ctor: function(t, e) { | |
this._startAngle = 0, | |
this._dstAngle = 0, | |
this._angle = 0, | |
void 0 !== e && this.initWithDuration(t, e) | |
}, | |
initWithDuration: function(t, e) { | |
return !!cc.ActionInterval.prototype.initWithDuration.call(this, t) && (this._dstAngle = e, | |
!0) | |
}, | |
clone: function() { | |
var t = new cc.RotateTo; | |
return this._cloneDecoration(t), | |
t.initWithDuration(this._duration, this._dstAngle), | |
t | |
}, | |
startWithTarget: function(t) { | |
cc.ActionInterval.prototype.startWithTarget.call(this, t); | |
var e = t.angle % 360 | |
, i = cc.RotateTo._reverse ? this._dstAngle - e : this._dstAngle + e; | |
i > 180 && (i -= 360), | |
i < -180 && (i += 360), | |
this._startAngle = e, | |
this._angle = cc.RotateTo._reverse ? i : -i | |
}, | |
reverse: function() {}, | |
update: function(t) { | |
t = this._computeEaseTime(t), | |
this.target && (this.target.angle = this._startAngle + this._angle * t) | |
} | |
}), | |
cc.rotateTo = function(t, e) { | |
return new cc.RotateTo(t,e) | |
} | |
, | |
cc.RotateBy = cc.Class({ | |
name: "cc.RotateBy", | |
extends: cc.ActionInterval, | |
statics: { | |
_reverse: !1 | |
}, | |
ctor: function(t, e) { | |
e *= cc.RotateBy._reverse ? 1 : -1, | |
this._deltaAngle = 0, | |
this._startAngle = 0, | |
void 0 !== e && this.initWithDuration(t, e) | |
}, | |
initWithDuration: function(t, e) { | |
return !!cc.ActionInterval.prototype.initWithDuration.call(this, t) && (this._deltaAngle = e, | |
!0) | |
}, | |
clone: function() { | |
var t = new cc.RotateBy; | |
return this._cloneDecoration(t), | |
t.initWithDuration(this._duration, this._deltaAngle), | |
t | |
}, | |
startWithTarget: function(t) { | |
cc.ActionInterval.prototype.startWithTarget.call(this, t), | |
this._startAngle = t.angle | |
}, | |
update: function(t) { | |
t = this._computeEaseTime(t), | |
this.target && (this.target.angle = this._startAngle + this._deltaAngle * t) | |
}, | |
reverse: function() { | |
var t = new cc.RotateBy; | |
return t.initWithDuration(this._duration, -this._deltaAngle), | |
this._cloneDecoration(t), | |
this._reverseEaseList(t), | |
t | |
} | |
}), | |
cc.rotateBy = function(t, e) { | |
return new cc.RotateBy(t,e) | |
} | |
, | |
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) { | |
return !!cc.ActionInterval.prototype.initWithDuration.call(this, t) && (void 0 !== e.x && (i = e.y, | |
e = e.x), | |
this._positionDelta.x = e, | |
this._positionDelta.y = i, | |
!0) | |
}, | |
clone: function() { | |
var t = new cc.MoveBy; | |
return this._cloneDecoration(t), | |
t.initWithDuration(this._duration, this._positionDelta), | |
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) { | |
if (t = this._computeEaseTime(t), | |
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 | |
, a = this._previousPosition; | |
n.x = n.x + r - a.x, | |
n.y = n.y + s - a.y, | |
e += n.x, | |
i += n.y, | |
a.x = e, | |
a.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)); | |
return this._cloneDecoration(t), | |
this._reverseEaseList(t), | |
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) { | |
return !!cc.MoveBy.prototype.initWithDuration.call(this, t, e, i) && (void 0 !== e.x && (i = e.y, | |
e = e.x), | |
this._endPosition.x = e, | |
this._endPosition.y = i, | |
!0) | |
}, | |
clone: function() { | |
var t = new cc.MoveTo; | |
return this._cloneDecoration(t), | |
t.initWithDuration(this._duration, this._endPosition), | |
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; | |
return cc.ActionInterval.prototype.initWithDuration.call(this, t) && (this._endSkewX = e, | |
this._endSkewY = i, | |
n = !0), | |
n | |
}, | |
clone: function() { | |
var t = new cc.SkewTo; | |
return this._cloneDecoration(t), | |
t.initWithDuration(this._duration, this._endSkewX, this._endSkewY), | |
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; | |
return cc.SkewTo.prototype.initWithDuration.call(this, t, e, i) && (this._skewX = e, | |
this._skewY = i, | |
n = !0), | |
n | |
}, | |
clone: function() { | |
var t = new cc.SkewBy; | |
return this._cloneDecoration(t), | |
t.initWithDuration(this._duration, this._skewX, this._skewY), | |
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); | |
return this._cloneDecoration(t), | |
this._reverseEaseList(t), | |
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) { | |
return !!cc.ActionInterval.prototype.initWithDuration.call(this, t) && (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, | |
!0) | |
}, | |
clone: function() { | |
var t = new cc.JumpBy; | |
return this._cloneDecoration(t), | |
t.initWithDuration(this._duration, this._delta, this._height, this._jumps), | |
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) { | |
if (t = this._computeEaseTime(t), | |
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 | |
, a = this.target.y | |
, o = this._previousPosition; | |
r.x = r.x + s - o.x, | |
r.y = r.y + a - o.y, | |
n += r.x, | |
i += r.y, | |
o.x = n, | |
o.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); | |
return this._cloneDecoration(t), | |
this._reverseEaseList(t), | |
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) { | |
return !!cc.JumpBy.prototype.initWithDuration.call(this, t, e, i, n, r) && (void 0 === r && (i = e.y, | |
e = e.x), | |
this._endPosition.x = e, | |
this._endPosition.y = i, | |
!0) | |
}, | |
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; | |
return this._cloneDecoration(t), | |
t.initWithDuration(this._duration, this._endPosition, this._height, this._jumps), | |
t | |
} | |
}), | |
cc.jumpTo = function(t, e, i, n, r) { | |
return new cc.JumpTo(t,e,i,n,r) | |
} | |
, | |
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) { | |
return !!cc.ActionInterval.prototype.initWithDuration.call(this, t) && (this._config = e, | |
!0) | |
}, | |
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)) | |
} | |
return t.initWithDuration(this._duration, e), | |
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(e) { | |
if (e = this._computeEaseTime(e), | |
this.target) { | |
var i = this._config | |
, n = i[0].x | |
, r = i[1].x | |
, s = i[2].x | |
, a = i[0].y | |
, o = i[1].y | |
, c = i[2].y | |
, l = t(0, n, r, s, e) | |
, h = t(0, a, o, c, e) | |
, u = this._startPosition; | |
if (cc.macro.ENABLE_STACKABLE_ACTIONS) { | |
var f = this.target.x | |
, d = this.target.y | |
, _ = this._previousPosition; | |
u.x = u.x + f - _.x, | |
u.y = u.y + d - _.y, | |
l += u.x, | |
h += u.y, | |
_.x = l, | |
_.y = h, | |
this.target.setPosition(l, h) | |
} else | |
this.target.setPosition(u.x + l, u.y + h) | |
} | |
}, | |
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 | |
, a = t[2].y | |
, o = [cc.v2(n - s, r - a), cc.v2(e - s, i - a), cc.v2(-s, -a)] | |
, c = new cc.BezierBy(this._duration,o); | |
return this._cloneDecoration(c), | |
this._reverseEaseList(c), | |
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) { | |
return !!cc.ActionInterval.prototype.initWithDuration.call(this, t) && (this._toConfig = e, | |
!0) | |
}, | |
clone: function() { | |
var t = new cc.BezierTo; | |
return this._cloneDecoration(t), | |
t.initWithDuration(this._duration, this._toConfig), | |
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) { | |
return !!cc.ActionInterval.prototype.initWithDuration.call(this, t) && (this._endScaleX = e, | |
this._endScaleY = null != i ? i : e, | |
!0) | |
}, | |
clone: function() { | |
var t = new cc.ScaleTo; | |
return this._cloneDecoration(t), | |
t.initWithDuration(this._duration, this._endScaleX, this._endScaleY), | |
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), | |
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); | |
return this._cloneDecoration(t), | |
this._reverseEaseList(t), | |
t | |
}, | |
clone: function() { | |
var t = new cc.ScaleBy; | |
return this._cloneDecoration(t), | |
t.initWithDuration(this._duration, this._endScaleX, this._endScaleY), | |
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) { | |
return !!cc.ActionInterval.prototype.initWithDuration.call(this, t) && (this._times = e, | |
!0) | |
}, | |
clone: function() { | |
var t = new cc.Blink; | |
return this._cloneDecoration(t), | |
t.initWithDuration(this._duration, this._times), | |
t | |
}, | |
update: function(t) { | |
if (t = this._computeEaseTime(t), | |
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); | |
return this._cloneDecoration(t), | |
this._reverseEaseList(t), | |
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) { | |
return !!cc.ActionInterval.prototype.initWithDuration.call(this, t) && (this._toOpacity = e, | |
!0) | |
}, | |
clone: function() { | |
var t = new cc.FadeTo; | |
return this._cloneDecoration(t), | |
t.initWithDuration(this._duration, this._toOpacity), | |
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; | |
return t.initWithDuration(this._duration, 0), | |
this._cloneDecoration(t), | |
this._reverseEaseList(t), | |
t | |
}, | |
clone: function() { | |
var t = new cc.FadeIn; | |
return this._cloneDecoration(t), | |
t.initWithDuration(this._duration, this._toOpacity), | |
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; | |
return t._reverseAction = this, | |
t.initWithDuration(this._duration, 255), | |
this._cloneDecoration(t), | |
this._reverseEaseList(t), | |
t | |
}, | |
clone: function() { | |
var t = new cc.FadeOut; | |
return this._cloneDecoration(t), | |
t.initWithDuration(this._duration, this._toOpacity), | |
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), | |
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) { | |
return !!cc.ActionInterval.prototype.initWithDuration.call(this, t) && (this._to = cc.color(e, i, n), | |
!0) | |
}, | |
clone: function() { | |
var t = new cc.TintTo; | |
this._cloneDecoration(t); | |
var e = this._to; | |
return t.initWithDuration(this._duration, e.r, e.g, e.b), | |
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) { | |
return !!cc.ActionInterval.prototype.initWithDuration.call(this, t) && (this._deltaR = e, | |
this._deltaG = i, | |
this._deltaB = n, | |
!0) | |
}, | |
clone: function() { | |
var t = new cc.TintBy; | |
return this._cloneDecoration(t), | |
t.initWithDuration(this._duration, this._deltaR, this._deltaG, this._deltaB), | |
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); | |
return this._cloneDecoration(t), | |
this._reverseEaseList(t), | |
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() {}, | |
reverse: function() { | |
var t = new cc.DelayTime(this._duration); | |
return this._cloneDecoration(t), | |
this._reverseEaseList(t), | |
t | |
}, | |
clone: function() { | |
var t = new cc.DelayTime; | |
return this._cloneDecoration(t), | |
t.initWithDuration(this._duration), | |
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) { | |
return !!t && t !== this._other && !!cc.ActionInterval.prototype.initWithDuration.call(this, t._duration) && (this._other = t, | |
!0) | |
}, | |
clone: function() { | |
var t = new cc.ReverseTime; | |
return this._cloneDecoration(t), | |
t.initWithAction(this._other.clone()), | |
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) { | |
return !!this.initWithDuration(e._duration) && (this._forcedTarget = t, | |
this._action = e, | |
!0) | |
}, | |
clone: function() { | |
var t = new cc.TargetedAction; | |
return this._cloneDecoration(t), | |
t.initWithTarget(this._forcedTarget, this._action.clone()), | |
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) { | |
"use strict"; | |
t("../core/platform/CCClass"); | |
var e = t("../core/platform/js") | |
, i = function() { | |
this.actions = [], | |
this.target = null, | |
this.actionIndex = 0, | |
this.currentAction = null, | |
this.paused = !1, | |
this.lock = !1 | |
}; | |
cc.ActionManager = function() { | |
this._hashTargets = e.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 n = this._elementPool.pop(); | |
return n || (n = new i), | |
n.target = t, | |
n.paused = !!e, | |
n | |
}, | |
_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]; | |
n ? n.actions || (n.actions = []) : (n = this._getElement(e, i), | |
this._hashTargets[e._id] = n, | |
this._arrayTargets.push(n)), | |
n.actions.push(t), | |
t.startWithTarget(e) | |
} | |
}, | |
removeAllActions: function() { | |
for (var t = this._arrayTargets, i = 0; i < t.length; i++) { | |
var n = t[i]; | |
n && this._putElement(n) | |
} | |
this._arrayTargets.length = 0, | |
this._hashTargets = e.createMap(!0) | |
}, | |
removeAllActionsFromTarget: function(t) { | |
if (null != t) { | |
var e = this._hashTargets[t._id]; | |
e && (e.actions.length = 0, | |
this._deleteHashElement(e)) | |
} | |
}, | |
removeAction: function(t) { | |
if (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 | |
} | |
} | |
}, | |
_removeActionByTag: function(t, e, i) { | |
for (var n = 0, r = e.actions.length; n < r; ++n) { | |
var s = e.actions[n]; | |
if (s && s.getTag() === t) { | |
if (i && s.getOriginalTarget() !== i) | |
continue; | |
this._removeActionAtIndex(n, e); | |
break | |
} | |
} | |
}, | |
_removeAllActionsByTag: function(t, e, i) { | |
for (var n = e.actions.length - 1; n >= 0; --n) { | |
var r = e.actions[n]; | |
if (r && r.getTag() === t) { | |
if (i && r.getOriginalTarget() !== i) | |
continue; | |
this._removeActionAtIndex(n, e) | |
} | |
} | |
}, | |
removeActionByTag: function(t, e) { | |
cc.Action.TAG_INVALID; | |
var i = this._hashTargets; | |
if (e) { | |
var n = i[e._id]; | |
n && this._removeActionByTag(t, n, e) | |
} else | |
for (var r in i) { | |
var s = i[r]; | |
this._removeActionByTag(t, s) | |
} | |
}, | |
removeAllActionsByTag: function(t, e) { | |
cc.Action.TAG_INVALID; | |
var i = this._hashTargets; | |
if (e) { | |
var n = i[e._id]; | |
n && this._removeAllActionsByTag(t, n, e) | |
} else | |
for (var r in i) { | |
var s = i[r]; | |
this._removeAllActionsByTag(t, s) | |
} | |
}, | |
getActionByTag: function(t, e) { | |
cc.Action.TAG_INVALID; | |
var i = this._hashTargets[e._id]; | |
if (i && null != i.actions) | |
for (var n = 0; n < i.actions.length; ++n) { | |
var r = i.actions[n]; | |
if (r && r.getTag() === t) | |
return r | |
} | |
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]; | |
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++) { | |
if (this._currentTarget = i[n], | |
!(e = this._currentTarget).paused && e.actions) { | |
for (e.lock = !0, | |
e.actionIndex = 0; e.actionIndex < e.actions.length; e.actionIndex++) | |
if (e.currentAction = e.actions[e.actionIndex], | |
e.currentAction) { | |
if (e.currentAction.step(t * (e.currentAction._speedMethod ? e.currentAction._speed : 1)), | |
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-- | |
} | |
} | |
} | |
} | |
), { | |
"../core/platform/CCClass": 162, | |
"../core/platform/js": 183 | |
}], | |
7: [(function(t) { | |
"use strict"; | |
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(t) { | |
"use strict"; | |
var e = t("../animation/bezier") | |
, i = 0 | |
, n = cc.Class({ | |
name: "cc.TweenAction", | |
extends: cc.ActionInterval, | |
ctor: function(t, e, i) { | |
if (this._opts = i = i || Object.create(null), | |
this._props = Object.create(null), | |
i.progress = i.progress || this.progress, | |
i.easing && "string" == typeof i.easing) { | |
var n = i.easing; | |
i.easing = cc.easing[n], | |
i.easing | |
} | |
var r = this._opts.relative; | |
for (var s in e) { | |
var a = e[s] | |
, o = void 0 | |
, c = void 0; | |
if (void 0 !== a.value && (a.easing || a.progress) && (o = "string" == typeof a.easing ? cc.easing[a.easing] : a.easing, | |
c = a.progress, | |
a = a.value), | |
"number" == typeof a || a.lerp && (!r || a.add || a.mul) && a.clone) { | |
var l = Object.create(null); | |
l.value = a, | |
l.easing = o, | |
l.progress = c, | |
this._props[s] = l | |
} | |
} | |
this._originProps = e, | |
this.initWithDuration(t) | |
}, | |
clone: function() { | |
var t = new n(this._duration,this._originProps,this._opts); | |
return this._cloneDecoration(t), | |
t | |
}, | |
startWithTarget: function(t) { | |
cc.ActionInterval.prototype.startWithTarget.call(this, t); | |
var e = !!this._opts.relative | |
, i = this._props; | |
for (var n in i) { | |
var r = t[n] | |
, s = i[n]; | |
"number" == typeof r ? (s.start = r, | |
s.current = r, | |
s.end = e ? r + s.value : s.value) : (s.start = r.clone(), | |
s.current = r.clone(), | |
s.end = e ? (r.add || r.mul).call(r, s.value) : s.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 = e.progress; | |
for (var a in r) { | |
var o = r[a] | |
, c = o.easing ? o.easing(t) : i | |
, l = o.current = (o.progress || s)(o.start, o.end, o.current, c); | |
n[a] = l | |
} | |
var h = e.onUpdate; | |
h && h(n, t) | |
} | |
}, | |
progress: function(t, e, i, n) { | |
return "number" == typeof t ? i = t + (e - t) * n : t.lerp(e, n, i), | |
i | |
} | |
}) | |
, r = cc.Class({ | |
name: "cc.SetAction", | |
extends: cc.ActionInstant, | |
ctor: function(t) { | |
this._props = {}, | |
void 0 !== t && this.init(t) | |
}, | |
init: function(t) { | |
for (var e in t) | |
this._props[e] = t[e]; | |
return !0 | |
}, | |
update: function() { | |
var t = this._props | |
, e = this.target; | |
for (var i in t) | |
e[i] = t[i] | |
}, | |
clone: function() { | |
var t = new r; | |
return t.init(this._props), | |
t | |
} | |
}); | |
function s(t) { | |
this._actions = [], | |
this._finalAction = null, | |
this._target = t, | |
this._tag = cc.Action.TAG_INVALID | |
} | |
s.stopAll = function() { | |
cc.director.getActionManager().removeAllActions() | |
} | |
, | |
s.stopAllByTag = function(t) { | |
cc.director.getActionManager().removeAllActionsByTag(t) | |
} | |
, | |
s.stopAllByTarget = function(t) { | |
cc.director.getActionManager().removeAllActionsFromTarget(t) | |
} | |
, | |
s.prototype.then = function(t) { | |
return t instanceof cc.Action ? this._actions.push(t.clone()) : this._actions.push(t._union()), | |
this | |
} | |
, | |
s.prototype.target = function(t) { | |
return this._target = t, | |
this | |
} | |
, | |
s.prototype.start = function() { | |
var t = this._target; | |
return t ? t instanceof cc.Object && !t.isValid ? void 0 : (this._finalAction && cc.director.getActionManager().removeAction(this._finalAction), | |
this._finalAction = this._union(), | |
void 0 === t._id && (t._id = ++i), | |
this._finalAction.setTag(this._tag), | |
cc.director.getActionManager().addAction(this._finalAction, t, !1), | |
this) : this | |
} | |
, | |
s.prototype.stop = function() { | |
return this._finalAction && (cc.director.getActionManager().removeAction(this._finalAction), | |
this._finalAction = null), | |
this | |
} | |
, | |
s.prototype.tag = function(t) { | |
return this._tag = t, | |
this | |
} | |
, | |
s.prototype.clone = function(t) { | |
var e = this._union(); | |
return cc.tween(t).then(e.clone()) | |
} | |
, | |
s.prototype.union = function() { | |
var t = this._union(); | |
return this._actions.length = 0, | |
this._actions.push(t), | |
this | |
} | |
, | |
s.prototype._union = function() { | |
var t = this._actions; | |
return 1 === t.length ? t[0] : cc.sequence(t) | |
} | |
, | |
Object.assign(s.prototype, { | |
bezierTo: function(t, i, n, r, s) { | |
var a = i.x | |
, o = i.y | |
, c = n.x | |
, l = n.y; | |
return (s = s || Object.create(null)).progress = function(t, i, n, r) { | |
return n.x = (0, | |
e.bezier)(t.x, a, c, i.x, r), | |
n.y = (0, | |
e.bezier)(t.y, o, l, i.y, r), | |
n | |
} | |
, | |
this.to(t, { | |
position: r | |
}, s) | |
}, | |
bezierBy: function(t, i, n, r, s) { | |
var a = i.x | |
, o = i.y | |
, c = n.x | |
, l = n.y; | |
return (s = s || Object.create(null)).progress = function(t, i, n, r) { | |
var s = t.x | |
, h = t.y; | |
return n.x = (0, | |
e.bezier)(s, a + s, c + s, i.x, r), | |
n.y = (0, | |
e.bezier)(h, o + h, l + h, i.y, r), | |
n | |
} | |
, | |
this.by(t, { | |
position: r | |
}, s) | |
}, | |
flipX: function() { | |
var t = this; | |
return this.call((function() { | |
t._target.scaleX *= -1 | |
} | |
), this) | |
}, | |
flipY: function() { | |
var t = this; | |
return this.call((function() { | |
t._target.scaleY *= -1 | |
} | |
), this) | |
}, | |
blink: function(t, e, i) { | |
var n = 1 / e; | |
return (i = i || Object.create(null)).progress = function(t, e, i, r) { | |
return r >= 1 ? t : r % n > n / 2 ? 255 : 0 | |
} | |
, | |
this.to(t, { | |
opacity: 1 | |
}, i) | |
} | |
}); | |
var a = []; | |
function o(t) { | |
return function() { | |
a.length = 0; | |
for (var e = arguments.length, i = 0; i < e; i++) { | |
var n = a[i] = arguments[i]; | |
n instanceof s && (a[i] = n._union()) | |
} | |
return t.apply(this, a) | |
} | |
} | |
for (var c = { | |
to: function(t, e, i) { | |
return (i = i || Object.create(null)).relative = !1, | |
new n(t,e,i) | |
}, | |
by: function(t, e, i) { | |
return (i = i || Object.create(null)).relative = !0, | |
new n(t,e,i) | |
}, | |
set: function(t) { | |
return new r(t) | |
}, | |
delay: cc.delayTime, | |
call: cc.callFunc, | |
hide: cc.hide, | |
show: cc.show, | |
removeSelf: cc.removeSelf, | |
sequence: o(cc.sequence), | |
parallel: o(cc.spawn) | |
}, l = { | |
repeat: cc.repeat, | |
repeatForever: cc.repeatForever, | |
reverseTime: cc.reverseTime | |
}, h = Object.keys(c), u = function(t) { | |
var e = h[t]; | |
s.prototype[e] = function() { | |
var t = c[e].apply(this, arguments); | |
return this._actions.push(t), | |
this | |
} | |
}, f = 0; f < h.length; f++) | |
u(f); | |
h = Object.keys(l); | |
for (var d = function(t) { | |
var e = h[t]; | |
s.prototype[e] = function() { | |
var t = this._actions | |
, i = arguments[arguments.length - 1] | |
, n = arguments.length - 1; | |
i instanceof cc.Tween ? i = i._union() : i instanceof cc.Action || (i = t[t.length - 1], | |
t.length -= 1, | |
n += 1); | |
for (var r = [i], s = 0; s < n; s++) | |
r.push(arguments[s]); | |
return i = l[e].apply(this, r), | |
t.push(i), | |
this | |
} | |
}, _ = 0; _ < h.length; _++) | |
d(_); | |
cc.tween = function(t) { | |
return new s(t) | |
} | |
, | |
cc.Tween = s | |
} | |
), { | |
"../animation/bezier": 14 | |
}], | |
9: [(function(t, e) { | |
"use strict"; | |
var i = cc.js | |
, n = t("./playable") | |
, r = t("./animation-curves") | |
, s = r.EventAnimCurve | |
, a = r.EventInfo | |
, o = t("./types").WrapModeMask | |
, c = t("../core/utils/binary-search").binarySearchEpsilon; | |
function l(t, e) { | |
n.call(this), | |
this.target = t, | |
this.animation = e, | |
this._anims = new i.array.MutableForwardIterator([]) | |
} | |
i.extend(l, n); | |
var h = l.prototype; | |
function u(t, e) { | |
var i = e.clip; | |
e.duration = i.duration, | |
e.speed = i.speed, | |
e.wrapMode = i.wrapMode, | |
e.frameRate = i.sample, | |
(e.wrapMode & o.Loop) === o.Loop ? e.repeatCount = Infinity : e.repeatCount = 1; | |
var n = e.curves = i.createCurves(e, t) | |
, r = i.events; | |
if (r) | |
for (var l, h = 0, u = r.length; h < u; h++) { | |
l || ((l = new s).target = t, | |
n.push(l)); | |
var f = r[h] | |
, d = f.frame / e.duration | |
, _ = void 0 | |
, p = c(l.ratios, d); | |
p >= 0 ? _ = l.events[p] : (_ = new a, | |
l.ratios.push(d), | |
l.events.push(_)), | |
_.add(f.func, f.params) | |
} | |
} | |
h.playState = function(t, e) { | |
t.clip && (t.curveLoaded || u(this.target, t), | |
t.animator = this, | |
t.play(), | |
"number" == typeof e && t.setTime(e), | |
this.play()) | |
} | |
, | |
h.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) | |
} | |
} | |
, | |
h.addAnimation = function(t) { | |
-1 === this._anims.array.indexOf(t) && this._anims.push(t), | |
t._setEventTarget(this.animation) | |
} | |
, | |
h.removeAnimation = function(t) { | |
var e = this._anims.array.indexOf(t); | |
e >= 0 && (this._anims.fastRemoveAt(e), | |
0 === this._anims.array.length && this.stop()), | |
t.animator = null | |
} | |
, | |
h.sample = function() { | |
var t = this._anims | |
, e = t.array; | |
for (t.i = 0; t.i < e.length; ++t.i) | |
e[t.i].sample() | |
} | |
, | |
h.stopState = function(t) { | |
t && t.stop() | |
} | |
, | |
h.pauseState = function(t) { | |
t && t.pause() | |
} | |
, | |
h.resumeState = function(t) { | |
t && t.resume(), | |
this.isPaused && this.resume() | |
} | |
, | |
h.setStateTime = function(t, e) { | |
if (void 0 !== e) | |
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() | |
} | |
} | |
} | |
, | |
h.onStop = function() { | |
var t = this._anims | |
, e = t.array; | |
for (t.i = 0; t.i < e.length; ++t.i) | |
e[t.i].stop() | |
} | |
, | |
h.onPause = function() { | |
for (var t = this._anims.array, e = 0; e < t.length; ++e) { | |
var i = t[e]; | |
i.pause(), | |
i.animator = null | |
} | |
} | |
, | |
h.onResume = function() { | |
for (var t = this._anims.array, e = 0; e < t.length; ++e) { | |
var i = t[e]; | |
i.animator = this, | |
i.resume() | |
} | |
} | |
, | |
h._reloadClip = function(t) { | |
u(this.target, t) | |
} | |
, | |
e.exports = l | |
} | |
), { | |
"../core/utils/binary-search": 229, | |
"./animation-curves": 11, | |
"./playable": 18, | |
"./types": 19 | |
}], | |
10: [(function(t, e) { | |
"use strict"; | |
var i = t("./types").WrapMode | |
, n = t("./animation-curves") | |
, r = n.DynamicAnimCurve | |
, s = n.quickFindIndex | |
, a = t("./motion-path-helper").sampleMotionPaths | |
, o = t("../core/utils/binary-search").binarySearchEpsilon | |
, c = cc.Class({ | |
name: "cc.AnimationClip", | |
extends: cc.Asset, | |
properties: { | |
_duration: { | |
default: 0, | |
type: cc.Float | |
}, | |
duration: { | |
get: function() { | |
return this._duration | |
} | |
}, | |
sample: { | |
default: 60 | |
}, | |
speed: { | |
default: 1 | |
}, | |
wrapMode: { | |
default: i.Normal | |
}, | |
curveData: { | |
default: {}, | |
visible: !1 | |
}, | |
events: { | |
default: [], | |
visible: !1 | |
} | |
}, | |
statics: { | |
createWithSpriteFrames: function(t, e) { | |
if (!Array.isArray(t)) | |
return null; | |
var i = new c; | |
i.sample = e || i.sample, | |
i._duration = t.length / i.sample; | |
for (var n = [], r = 1 / i.sample, s = 0, a = t.length; s < a; s++) | |
n[s] = { | |
frame: s * r, | |
value: t[s] | |
}; | |
return i.curveData = { | |
comps: { | |
"cc.Sprite": { | |
spriteFrame: n | |
} | |
} | |
}, | |
i | |
} | |
}, | |
onLoad: function() { | |
this._duration = Number.parseFloat(this.duration), | |
this.speed = Number.parseFloat(this.speed), | |
this.wrapMode = Number.parseInt(this.wrapMode), | |
this.frameRate = Number.parseFloat(this.sample) | |
}, | |
createPropCurve: function(t, e, i) { | |
var n = [] | |
, c = t instanceof cc.Node && "position" === e | |
, l = new r; | |
l.target = t, | |
l.prop = e; | |
for (var h = 0, u = i.length; h < u; h++) { | |
var f = i[h] | |
, d = f.frame / this.duration; | |
l.ratios.push(d), | |
c && n.push(f.motionPath); | |
var _ = f.value; | |
l.values.push(_); | |
var p = f.curve; | |
if (p) { | |
if ("string" == typeof p) { | |
l.types.push(p); | |
continue | |
} | |
if (Array.isArray(p)) { | |
p[0] === p[1] && p[2] === p[3] ? l.types.push(r.Linear) : l.types.push(r.Bezier(p)); | |
continue | |
} | |
} | |
l.types.push(r.Linear) | |
} | |
c && a(n, l, this.duration, this.sample, t); | |
for (var v, g, m = l.ratios, y = !0, T = 1, E = m.length; T < E; T++) | |
if (v = m[T] - m[T - 1], | |
1 === T) | |
g = v; | |
else if (Math.abs(v - g) > 1e-6) { | |
y = !1; | |
break | |
} | |
l._findFrameIndex = y ? s : o; | |
var A = l.values[0]; | |
return null == A || l._lerp || ("number" == typeof A ? l._lerp = r.prototype._lerpNumber : A instanceof cc.Quat ? l._lerp = r.prototype._lerpQuat : A instanceof cc.Vec2 ? l._lerp = r.prototype._lerpVector2 : A instanceof cc.Vec3 ? l._lerp = r.prototype._lerpVector3 : A.lerp && (l._lerp = r.prototype._lerpObject)), | |
l | |
}, | |
createTargetCurves: function(t, e, i) { | |
var n = e.props | |
, r = e.comps; | |
if (n) | |
for (var s in n) { | |
var a = n[s] | |
, o = this.createPropCurve(t, s, a); | |
i.push(o) | |
} | |
if (r) | |
for (var c in r) { | |
var l = t.getComponent(c); | |
if (l) { | |
var h = r[c]; | |
for (var u in h) { | |
var f = h[u] | |
, d = this.createPropCurve(l, u, f); | |
i.push(d) | |
} | |
} | |
} | |
}, | |
createCurves: function(t, e) { | |
var i = this.curveData | |
, n = i.paths | |
, r = []; | |
for (var s in this.createTargetCurves(e, i, r), | |
n) { | |
var a = cc.find(s, e); | |
if (a) { | |
var o = n[s]; | |
this.createTargetCurves(a, o, r) | |
} | |
} | |
return r | |
} | |
}); | |
cc.AnimationClip = e.exports = c | |
} | |
), { | |
"../core/utils/binary-search": 229, | |
"./animation-curves": 11, | |
"./motion-path-helper": 17, | |
"./types": 19 | |
}], | |
11: [(function(t, e) { | |
"use strict"; | |
var i = t("./bezier").bezierByTime | |
, n = t("../core/utils/binary-search").binarySearchEpsilon | |
, r = t("./types").WrapModeMask | |
, s = t("./types").WrappedInfo; | |
function a(t, e) { | |
if ("string" == typeof e) { | |
var n = cc.easing[e]; | |
n && (t = n(t)) | |
} else | |
Array.isArray(e) && (t = i(e, t)); | |
return t | |
} | |
var o = cc.Class({ | |
name: "cc.AnimCurve", | |
sample: function() {}, | |
onTimeChangedManually: void 0 | |
}); | |
var c, l = cc.Class({ | |
name: "cc.DynamicAnimCurve", | |
extends: o, | |
ctor: function() { | |
this._cachedIndex = 0 | |
}, | |
properties: { | |
target: null, | |
prop: "", | |
values: [], | |
ratios: [], | |
types: [] | |
}, | |
_findFrameIndex: n, | |
_lerp: void 0, | |
_lerpNumber: function(t, e, i) { | |
return t + (e - t) * i | |
}, | |
_lerpObject: function(t, e, i) { | |
return t.lerp(e, i) | |
}, | |
_lerpQuat: (c = cc.quat(), | |
function(t, e, i) { | |
return t.lerp(e, i, c) | |
} | |
), | |
_lerpVector2: (function() { | |
var t = cc.v2(); | |
return function(e, i, n) { | |
return e.lerp(i, n, t) | |
} | |
} | |
)(), | |
_lerpVector3: (function() { | |
var t = cc.v3(); | |
return function(e, i, n) { | |
return e.lerp(i, n, t) | |
} | |
} | |
)(), | |
sample: function(t, e) { | |
var i = this.values | |
, n = this.ratios | |
, r = n.length; | |
if (0 !== r) { | |
var s, o = !0, c = this._cachedIndex; | |
if (c < 0 && (c = ~c) > 0 && c < n.length) { | |
var l = n[c - 1] | |
, h = n[c]; | |
e > l && e < h && (o = !1) | |
} | |
o && (this._cachedIndex = this._findFrameIndex(n, e)); | |
var u = this._cachedIndex; | |
if (u < 0) | |
if ((u = ~u) <= 0) | |
s = i[0]; | |
else if (u >= r) | |
s = i[r - 1]; | |
else { | |
var f = i[u - 1]; | |
if (this._lerp) { | |
var d = n[u - 1] | |
, _ = n[u] | |
, p = this.types[u - 1] | |
, v = (e - d) / (_ - d); | |
p && (v = a(v, p)); | |
var g = i[u]; | |
s = this._lerp(f, g, v) | |
} else | |
s = f | |
} | |
else | |
s = i[u]; | |
this.target[this.prop] = s | |
} | |
} | |
}); | |
l.Linear = null, | |
l.Bezier = function(t) { | |
return t | |
} | |
; | |
var h = function() { | |
this.events = [] | |
}; | |
h.prototype.add = function(t, e) { | |
this.events.push({ | |
func: t || "", | |
params: e || [] | |
}) | |
} | |
; | |
var u = cc.Class({ | |
name: "cc.EventAnimCurve", | |
extends: o, | |
properties: { | |
target: null, | |
ratios: [], | |
events: [], | |
_wrappedInfo: { | |
default: function() { | |
return new s | |
} | |
}, | |
_lastWrappedInfo: null, | |
_ignoreIndex: NaN | |
}, | |
_wrapIterations: function(t) { | |
return t - (0 | t) == 0 && (t -= 1), | |
0 | t | |
}, | |
sample: function(t, e, i) { | |
var a = this.ratios.length | |
, o = i.getWrappedInfo(i.time, this._wrappedInfo) | |
, c = o.direction | |
, l = n(this.ratios, o.ratio); | |
if (l < 0 && (l = ~l - 1, | |
c < 0 && (l += 1)), | |
this._ignoreIndex !== l && (this._ignoreIndex = NaN), | |
o.frameIndex = l, | |
!this._lastWrappedInfo) | |
return this._fireEvent(l), | |
void (this._lastWrappedInfo = new s(o)); | |
var h = i.wrapMode | |
, u = this._wrapIterations(o.iterations) | |
, f = this._lastWrappedInfo | |
, d = this._wrapIterations(f.iterations) | |
, _ = f.frameIndex | |
, p = f.direction | |
, v = -1 !== d && u !== d; | |
if (_ === l && v && 1 === a) | |
this._fireEvent(0); | |
else if (_ !== l || v) { | |
c = p; | |
do { | |
if (_ !== l) { | |
if (-1 === c && 0 === _ && l > 0 ? ((h & r.PingPong) === r.PingPong ? c *= -1 : _ = a, | |
d++) : 1 === c && _ === a - 1 && l < a - 1 && ((h & r.PingPong) === r.PingPong ? c *= -1 : _ = -1, | |
d++), | |
_ === l) | |
break; | |
if (d > u) | |
break | |
} | |
_ += c, | |
cc.director.getAnimationManager().pushDelayEvent(this, "_fireEvent", [_]) | |
} while (_ !== l && _ > -1 && _ < a) | |
} | |
this._lastWrappedInfo.set(o) | |
}, | |
_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, a = 0; a < i.length; a++) { | |
var o = i[a] | |
, c = o[s]; | |
c && c.apply(o, r.params) | |
} | |
} | |
}, | |
onTimeChangedManually: function(t, e) { | |
this._lastWrappedInfo = null, | |
this._ignoreIndex = NaN; | |
var i = e.getWrappedInfo(t, this._wrappedInfo) | |
, r = i.direction | |
, s = n(this.ratios, i.ratio); | |
s < 0 && (s = ~s - 1, | |
r < 0 && (s += 1), | |
this._ignoreIndex = s) | |
} | |
}); | |
e.exports = { | |
AnimCurve: o, | |
DynamicAnimCurve: l, | |
EventAnimCurve: u, | |
EventInfo: h, | |
computeRatioByType: a, | |
quickFindIndex: function(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 ~t.length; | |
var s = (e = (e - n) / (r - n)) / (1 / i) | |
, a = 0 | s; | |
return s - a < 1e-6 ? a : a + 1 - s < 1e-6 ? a + 1 : ~(a + 1) | |
} | |
} | |
} | |
), { | |
"../core/utils/binary-search": 229, | |
"./bezier": 14, | |
"./types": 19 | |
}], | |
12: [(function(t, e) { | |
"use strict"; | |
var i = cc.js | |
, n = cc.Class({ | |
ctor: function() { | |
this._anims = new i.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; s < r.length; 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) | |
}, | |
pushDelayEvent: function(t, e, i) { | |
this._delayEvents.push({ | |
target: t, | |
func: e, | |
args: i | |
}) | |
} | |
}); | |
cc.AnimationManager = e.exports = n | |
} | |
), {}], | |
13: [(function(t, e) { | |
"use strict"; | |
var i = cc.js | |
, n = t("./playable") | |
, r = t("./types") | |
, s = r.WrappedInfo | |
, a = r.WrapMode | |
, o = r.WrapModeMask; | |
function c(t, e) { | |
n.call(this), | |
this._currentFramePlayed = !1, | |
this._delay = 0, | |
this._delayTime = 0, | |
this._wrappedInfo = new s, | |
this._lastWrappedInfo = null, | |
this._process = h, | |
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 = a.Normal, | |
this.time = 0, | |
this._target = null, | |
this._lastframeEventOn = !1, | |
this.emit = function() { | |
for (var t = Array(arguments.length), e = 0, i = t.length; e < i; e++) | |
t[e] = arguments[e]; | |
cc.director.getAnimationManager().pushDelayEvent(this, "_emit", t) | |
} | |
} | |
i.extend(c, n); | |
var l = c.prototype; | |
function h() { | |
var t, e = this.sample(); | |
this._lastframeEventOn && (t = this._lastWrappedInfo ? this._lastWrappedInfo : this._lastWrappedInfo = new s(e), | |
this.repeatCount > 1 && (0 | e.iterations) > (0 | t.iterations) && this.emit("lastframe", this), | |
t.set(e)), | |
e.stopped && (this.stop(), | |
this.emit("finished", this)) | |
} | |
function u() { | |
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); | |
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) | |
} | |
l._emit = function(t, e) { | |
this._target && this._target.isValid && this._target.emit(t, t, e) | |
} | |
, | |
l.on = function(t, e, i) { | |
return this._target && this._target.isValid ? ("lastframe" === t && (this._lastframeEventOn = !0), | |
this._target.on(t, e, i)) : null | |
} | |
, | |
l.once = function(t, e, i) { | |
if (this._target && this._target.isValid) { | |
"lastframe" === t && (this._lastframeEventOn = !0); | |
var n = this; | |
return this._target.once(t, (function(t) { | |
e.call(i, t), | |
n._lastframeEventOn = !1 | |
} | |
)) | |
} | |
return null | |
} | |
, | |
l.off = function(t, e, i) { | |
this._target && this._target.isValid && ("lastframe" === t && (this._target.hasEventListener(t) || (this._lastframeEventOn = !1)), | |
this._target.off(t, e, i)) | |
} | |
, | |
l._setEventTarget = function(t) { | |
this._target = t | |
} | |
, | |
l.onPlay = function() { | |
this.setTime(0), | |
this._delayTime = this._delay, | |
cc.director.getAnimationManager().addAnimation(this), | |
this.animator && this.animator.addAnimation(this), | |
this.emit("play", this) | |
} | |
, | |
l.onStop = function() { | |
this.isPaused || cc.director.getAnimationManager().removeAnimation(this), | |
this.animator && this.animator.removeAnimation(this), | |
this.emit("stop", this) | |
} | |
, | |
l.onResume = function() { | |
cc.director.getAnimationManager().addAnimation(this), | |
this.emit("resume", this) | |
} | |
, | |
l.onPause = function() { | |
cc.director.getAnimationManager().removeAnimation(this), | |
this.emit("pause", this) | |
} | |
, | |
l.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) | |
} | |
} | |
, | |
l.update = function(t) { | |
this._delayTime > 0 && (this._delayTime -= t, | |
this._delayTime > 0) || (this._currentFramePlayed ? this.time += t * this.speed : this._currentFramePlayed = !0, | |
this._process()) | |
} | |
, | |
l._needRevers = function(t) { | |
var e = this.wrapMode | |
, i = !1; | |
return (e & o.PingPong) === o.PingPong && (t - (0 | t) == 0 && t > 0 && (t -= 1), | |
1 & t && (i = !i)), | |
(e & o.Reverse) === o.Reverse && (i = !i), | |
i | |
} | |
, | |
l.getWrappedInfo = function(t, e) { | |
e = e || new s; | |
var i = !1 | |
, n = this.duration | |
, r = this.repeatCount | |
, a = t > 0 ? t / n : -t / n; | |
if (a >= r) { | |
a = r, | |
i = !0; | |
var c = r - (0 | r); | |
0 === c && (c = 1), | |
t = c * n * (t > 0 ? 1 : -1) | |
} | |
if (t > n) { | |
var l = t % n; | |
t = 0 === l ? n : l | |
} else | |
t < 0 && 0 != (t %= n) && (t += n); | |
var h = !1 | |
, u = this._wrapMode & o.ShouldWrap; | |
u && (h = this._needRevers(a)); | |
var f = h ? -1 : 1; | |
return this.speed < 0 && (f *= -1), | |
u && h && (t = n - t), | |
e.ratio = t / n, | |
e.time = t, | |
e.direction = f, | |
e.stopped = i, | |
e.iterations = a, | |
e | |
} | |
, | |
l.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 | |
} | |
, | |
i.get(l, "clip", (function() { | |
return this._clip | |
} | |
)), | |
i.get(l, "name", (function() { | |
return this._name | |
} | |
)), | |
i.obsolete(l, "AnimationState.length", "duration"), | |
i.getset(l, "curveLoaded", (function() { | |
return this.curves.length > 0 | |
} | |
), (function() { | |
this.curves.length = 0 | |
} | |
)), | |
i.getset(l, "wrapMode", (function() { | |
return this._wrapMode | |
} | |
), (function(t) { | |
this._wrapMode = t, | |
this.time = 0, | |
t & o.Loop ? this.repeatCount = Infinity : this.repeatCount = 1 | |
} | |
)), | |
i.getset(l, "repeatCount", (function() { | |
return this._repeatCount | |
} | |
), (function(t) { | |
this._repeatCount = t; | |
var e = this._wrapMode & o.ShouldWrap | |
, i = (this.wrapMode & o.Reverse) === o.Reverse; | |
this._process = Infinity !== t || e || i ? h : u | |
} | |
)), | |
i.getset(l, "delay", (function() { | |
return this._delay | |
} | |
), (function(t) { | |
this._delayTime = this._delay = t | |
} | |
)), | |
cc.AnimationState = e.exports = c | |
} | |
), { | |
"./playable": 18, | |
"./types": 19 | |
}], | |
14: [(function(t, e) { | |
"use strict"; | |
var i = Math.cos | |
, n = Math.acos | |
, r = Math.max | |
, s = 6.283185307179586 | |
, a = Math.sqrt; | |
function o(t) { | |
return t < 0 ? -Math.pow(-t, 1 / 3) : Math.pow(t, 1 / 3) | |
} | |
function c(t, e) { | |
var c, l, h, u, f = e - 0, d = e - t[0], _ = 3 * f, p = 3 * d, v = 3 * (e - t[2]), g = 1 / (-f + p - v + (e - 1)), m = (_ - 6 * d + v) * g, y = m * (1 / 3), T = (-_ + p) * g, E = 1 / 3 * (3 * T - m * m), A = E * (1 / 3), x = (2 * m * m * m - 9 * m * T + f * g * 27) / 27, C = x / 2, b = C * C + A * A * A; | |
if (b < 0) { | |
var S = 1 / 3 * -E | |
, R = a(S * S * S) | |
, M = -x / (2 * R) | |
, w = n(M < -1 ? -1 : M > 1 ? 1 : M) | |
, I = 2 * o(R); | |
return l = I * i(w * (1 / 3)) - y, | |
h = I * i((w + s) * (1 / 3)) - y, | |
u = I * i((w + 2 * s) * (1 / 3)) - y, | |
0 <= l && l <= 1 ? 0 <= h && h <= 1 ? 0 <= u && u <= 1 ? r(l, h, u) : r(l, h) : 0 <= u && u <= 1 ? r(l, u) : l : 0 <= h && h <= 1 ? 0 <= u && u <= 1 ? r(h, u) : h : u | |
} | |
if (0 === b) | |
return h = -(c = C < 0 ? o(-C) : -o(C)) - y, | |
0 <= (l = 2 * c - y) && l <= 1 ? 0 <= h && h <= 1 ? r(l, h) : l : h; | |
var O = a(b); | |
return (c = o(-C + O)) - o(C + O) - y | |
} | |
e.exports = { | |
bezier: function(t, e, i, n, r) { | |
var s = 1 - r; | |
return s * (s * (t + (3 * e - t) * r) + 3 * i * r * r) + n * r * r * r | |
}, | |
bezierByTime: function(t, e) { | |
var i = c(t, e) | |
, n = t[1]; | |
return ((1 - i) * (n + (t[3] - n) * i) * 3 + i * i) * i | |
} | |
} | |
} | |
), {}], | |
15: [(function(t, e) { | |
"use strict"; | |
var i = { | |
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; | |
return 0 === t ? 0 : 1 === t ? 1 : (!i || i < 1 ? (i = 1, | |
e = .1) : e = .4 * Math.asin(1 / i) / (2 * Math.PI), | |
-i * Math.pow(2, 10 * (t -= 1)) * Math.sin(2 * Math.PI * (t - e) / .4)) | |
}, | |
elasticOut: function(t) { | |
var e, i = .1; | |
return 0 === t ? 0 : 1 === t ? 1 : (!i || i < 1 ? (i = 1, | |
e = .1) : e = .4 * Math.asin(1 / i) / (2 * Math.PI), | |
i * Math.pow(2, -10 * t) * Math.sin(2 * Math.PI * (t - e) / .4) + 1) | |
}, | |
elasticInOut: function(t) { | |
var e, i = .1; | |
return 0 === t ? 0 : 1 === t ? 1 : (!i || i < 1 ? (i = 1, | |
e = .1) : e = .4 * Math.asin(1 / i) / (2 * Math.PI), | |
(t *= 2) < 1 ? i * Math.pow(2, 10 * (t -= 1)) * Math.sin(2 * Math.PI * (t - e) / .4) * -.5 : i * Math.pow(2, -10 * (t -= 1)) * Math.sin(2 * Math.PI * (t - e) / .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) | |
}, | |
bounceIn: function(t) { | |
return 1 - i.bounceOut(1 - t) | |
}, | |
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 | |
}, | |
bounceInOut: function(t) { | |
return t < .5 ? .5 * i.bounceIn(2 * t) : .5 * i.bounceOut(2 * t - 1) + .5 | |
}, | |
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 n(t, e) { | |
return function(i) { | |
return i < .5 ? e(2 * i) / 2 : t(2 * i - 1) / 2 + .5 | |
} | |
} | |
i.quadOutIn = n(i.quadIn, i.quadOut), | |
i.cubicOutIn = n(i.cubicIn, i.cubicOut), | |
i.quartOutIn = n(i.quartIn, i.quartOut), | |
i.quintOutIn = n(i.quintIn, i.quintOut), | |
i.sineOutIn = n(i.sineIn, i.sineOut), | |
i.expoOutIn = n(i.expoIn, i.expoOut), | |
i.circOutIn = n(i.circIn, i.circOut), | |
i.backOutIn = n(i.backIn, i.backOut), | |
i.bounceIn = function(t) { | |
return 1 - i.bounceOut(1 - t) | |
} | |
, | |
i.bounceInOut = function(t) { | |
return t < .5 ? .5 * i.bounceIn(2 * t) : .5 * i.bounceOut(2 * t - 1) + .5 | |
} | |
, | |
i.bounceOutIn = n(i.bounceIn, i.bounceOut), | |
cc.easing = e.exports = i | |
} | |
), {}], | |
16: [(function(t) { | |
"use strict"; | |
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) { | |
"use strict"; | |
var i = t("./animation-curves").DynamicAnimCurve | |
, n = t("./animation-curves").computeRatioByType | |
, r = t("./bezier").bezier | |
, s = t("../core/utils/binary-search").binarySearchEpsilon | |
, a = cc.v2; | |
function o(t) { | |
this.points = t || [], | |
this.beziers = [], | |
this.ratios = [], | |
this.progresses = [], | |
this.length = 0, | |
this.computeBeziers() | |
} | |
function c() { | |
this.start = a(), | |
this.end = a(), | |
this.startCtrlPoint = a(), | |
this.endCtrlPoint = a() | |
} | |
function l(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 | |
} | |
o.prototype.computeBeziers = function() { | |
var t; | |
this.beziers.length = 0, | |
this.ratios.length = 0, | |
this.progresses.length = 0, | |
this.length = 0; | |
for (var e = 1; e < this.points.length; e++) { | |
var i = this.points[e - 1] | |
, n = this.points[e]; | |
(t = new c).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 | |
} | |
, | |
c.prototype.getPointAt = function(t) { | |
var e = this.getUtoTmapping(t); | |
return this.getPoint(e) | |
} | |
, | |
c.prototype.getPoint = function(t) { | |
var e = r(this.start.x, this.startCtrlPoint.x, this.endCtrlPoint.x, this.end.x, t) | |
, i = r(this.start.y, this.startCtrlPoint.y, this.endCtrlPoint.y, this.end.y, t); | |
return new a(e,i) | |
} | |
, | |
c.prototype.getLength = function() { | |
var t = this.getLengths(); | |
return t[t.length - 1] | |
} | |
, | |
c.prototype.getLengths = function(t) { | |
if (t || (t = this.__arcLengthDivisions ? this.__arcLengthDivisions : 200), | |
this.cacheArcLengths && this.cacheArcLengths.length === t + 1) | |
return this.cacheArcLengths; | |
var e, i, n = [], r = this.getPoint(0), s = a(), o = 0; | |
for (n.push(0), | |
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; | |
return this.cacheArcLengths = n, | |
n | |
} | |
, | |
c.prototype.getUtoTmapping = function(t, e) { | |
var i, n = this.getLengths(), r = 0, s = n.length; | |
i = e || t * n[s - 1]; | |
for (var a, o = 0, c = s - 1; o <= c; ) | |
if ((a = n[r = Math.floor(o + (c - o) / 2)] - i) < 0) | |
o = r + 1; | |
else { | |
if (!(a > 0)) { | |
c = r; | |
break | |
} | |
c = r - 1 | |
} | |
if (n[r = c] === i) | |
return r / (s - 1); | |
var l = n[r]; | |
return (r + (i - l) / (n[r + 1] - l)) / (s - 1) | |
} | |
, | |
e.exports = { | |
sampleMotionPaths: function(t, e, r, c) { | |
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 u = e.values = e.values.map((function(t) { | |
return Array.isArray(t) && (t = 2 === t.length ? cc.v2(t[0], t[1]) : cc.v3(t[0], t[1], t[2])), | |
t | |
} | |
)); | |
if (0 !== t.length && 0 !== u.length) { | |
for (var f = !1, d = 0; d < t.length; d++) { | |
var _ = t[d]; | |
if (_ && !l(_) && (_ = null), | |
_ && _.length > 0) { | |
f = !0; | |
break | |
} | |
} | |
if (f && 1 !== u.length) { | |
for (var p = e.types, v = e.ratios, g = e.values = [], m = e.types = [], y = e.ratios = [], T = 0, E = i.Linear, A = 0, x = t.length; A < x - 1; A++) { | |
var C, b = t[A], S = v[A], R = v[A + 1] - S, M = u[A], w = u[A + 1], I = p[A], O = [], L = T / R, P = 1 / (R * r * c); | |
if (b && b.length > 0) { | |
var D = []; | |
D.push(h(M)); | |
for (var N = 0, F = b.length; N < F; N++) { | |
var B = h(b[N]); | |
D.push(B) | |
} | |
D.push(h(w)); | |
var V = new o(D); | |
V.computeBeziers(); | |
for (var k = V.progresses; 1 - L > 1e-6; ) { | |
var U, z, H, G; | |
if ((C = n(C = L, I)) < 0) | |
G = (0 - C) * (z = V.beziers[0]).getLength(), | |
H = z.start.sub(z.endCtrlPoint).normalize(), | |
U = z.start.add(H.mul(G)); | |
else if (C > 1) | |
G = (C - 1) * (z = V.beziers[V.beziers.length - 1]).getLength(), | |
H = z.end.sub(z.startCtrlPoint).normalize(), | |
U = z.end.add(H.mul(G)); | |
else { | |
var W = s(k, C); | |
W < 0 && (W = ~W), | |
C -= W > 0 ? k[W - 1] : 0, | |
C /= V.ratios[W], | |
U = V.beziers[W].getPointAt(C) | |
} | |
O.push(U), | |
L += P | |
} | |
} else | |
for (; 1 - L > 1e-6; ) | |
C = n(C = L, I), | |
O.push(M.lerp(w, C)), | |
L += P; | |
for (E = "constant" === I ? I : i.Linear, | |
N = 0, | |
F = O.length; N < F; N++) { | |
var X = S + T + P * N * R; | |
Y(O[N], E, X) | |
} | |
T = Math.abs(L - 1) > 1e-6 ? (L - 1) * R : 0 | |
} | |
v[v.length - 1] !== y[y.length - 1] && Y(u[u.length - 1], E, v[v.length - 1]) | |
} | |
} | |
function Y(t, e, i) { | |
g.push(t), | |
m.push(e), | |
y.push(i) | |
} | |
}, | |
Curve: o, | |
Bezier: c | |
} | |
} | |
), { | |
"../core/utils/binary-search": 229, | |
"./animation-curves": 11, | |
"./bezier": 14 | |
}], | |
18: [(function(t, e) { | |
"use strict"; | |
var i = cc.js | |
, n = t("../core/CCDebug"); | |
function r() { | |
this._isPlaying = !1, | |
this._isPaused = !1, | |
this._stepOnce = !1 | |
} | |
var s = r.prototype; | |
i.get(s, "isPlaying", (function() { | |
return this._isPlaying | |
} | |
), !0), | |
i.get(s, "isPaused", (function() { | |
return this._isPaused | |
} | |
), !0); | |
var a = function() {}; | |
s.onPlay = a, | |
s.onPause = a, | |
s.onResume = a, | |
s.onStop = a, | |
s.onError = a, | |
s.play = function() { | |
this._isPlaying ? this._isPaused ? (this._isPaused = !1, | |
this.onResume()) : this.onError(n.getError(3912)) : (this._isPlaying = !0, | |
this.onPlay()) | |
} | |
, | |
s.stop = function() { | |
this._isPlaying && (this._isPlaying = !1, | |
this.onStop(), | |
this._isPaused = !1) | |
} | |
, | |
s.pause = function() { | |
this._isPlaying && !this._isPaused && (this._isPaused = !0, | |
this.onPause()) | |
} | |
, | |
s.resume = function() { | |
this._isPlaying && this._isPaused && (this._isPaused = !1, | |
this.onResume()) | |
} | |
, | |
s.step = function() { | |
this.pause(), | |
this._stepOnce = !0, | |
this._isPlaying || this.play() | |
} | |
, | |
e.exports = r | |
} | |
), { | |
"../core/CCDebug": 23 | |
}], | |
19: [(function(t, e) { | |
"use strict"; | |
var i = { | |
Loop: 2, | |
ShouldWrap: 4, | |
PingPong: 22, | |
Reverse: 36 | |
} | |
, n = cc.Enum({ | |
Default: 0, | |
Normal: 1, | |
Reverse: i.Reverse, | |
Loop: i.Loop, | |
LoopReverse: i.Loop | i.Reverse, | |
PingPong: i.PingPong, | |
PingPongReverse: i.PingPong | i.Reverse | |
}); | |
function r(t) { | |
t ? this.set(t) : (this.ratio = 0, | |
this.time = 0, | |
this.direction = 1, | |
this.stopped = !0, | |
this.iterations = 0, | |
this.frameIndex = void 0) | |
} | |
cc.WrapMode = n, | |
r.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: i, | |
WrapMode: n, | |
WrappedInfo: r | |
} | |
} | |
), {}], | |
20: [(function(t, e) { | |
"use strict"; | |
var i, n = t("../core/event/event-target"), r = t("../core/platform/CCSys"), s = function t(e) { | |
n.call(this), | |
this._shouldRecycleOnEnded = !1, | |
this._src = e, | |
this._element = null, | |
this._state = t.State.INITIALZING; | |
var i = this; | |
this._onended = function() { | |
i._state = t.State.STOPPED, | |
i.emit("ended") | |
} | |
, | |
this._onendedSecond = function() { | |
i._unbindEnded(i._onendedSecond), | |
i._bindEnded() | |
} | |
}; | |
function a(t) { | |
if (t.onended = void 0, | |
t.stop(0), | |
s.ScratchAudioBuffer) | |
try { | |
t.buffer = s.ScratchAudioBuffer | |
} catch (e) {} | |
} | |
cc.js.extend(s, n), | |
s.State = { | |
ERROR: -1, | |
INITIALZING: 0, | |
PLAYING: 1, | |
PAUSED: 2, | |
STOPPED: 3 | |
}, | |
s.ScratchAudioBuffer = void 0, | |
(i = s.prototype)._bindEnded = function(t) { | |
if (!(t = t || this._onended)._binded) { | |
t._binded = !0; | |
var e = this._element; | |
this._src && e instanceof HTMLAudioElement ? e.addEventListener("ended", this._onended) : e.onended = this._onended | |
} | |
} | |
, | |
i._unbindEnded = function(t) { | |
if ((t = t || this._onended)._binded) { | |
t._binded = !1; | |
var e = this._element; | |
e instanceof HTMLAudioElement ? e.removeEventListener("ended", t) : e && (e.onended = null) | |
} | |
} | |
, | |
i._onLoaded = function() { | |
this._createElement(), | |
this._state = s.State.INITIALZING, | |
this.setVolume(1), | |
this.setLoop(!1) | |
} | |
, | |
i._createElement = function() { | |
var t = this._src._nativeAsset; | |
t instanceof HTMLAudioElement ? (this._element || (this._element = document.createElement("audio")), | |
this._element.src = t.src) : this._element = new o(t,this) | |
} | |
, | |
i.play = function(t, e) { | |
var i = this; | |
this._src && this._src._ensureLoaded((function() { | |
i._state = s.State.PLAYING, | |
i._offset = i._length = 0, | |
i._bindEnded(); | |
var n = i._element.play(t, e); | |
window.Promise && n instanceof Promise && n.catch((function() {} | |
)) | |
} | |
)) | |
} | |
, | |
i.destroy = function() { | |
this._element = null | |
} | |
, | |
i.pause = function() { | |
if (this.getState() === s.State.PLAYING) { | |
var t = this; | |
this._src && this._src._ensureLoaded((function() { | |
t._unbindEnded(), | |
t._element.pause(), | |
t._state = s.State.PAUSED | |
} | |
)) | |
} | |
} | |
, | |
i.resume = function() { | |
if (this.getState() === s.State.PAUSED) { | |
var t = this; | |
this._src && this._src._ensureLoaded((function() { | |
t._bindEnded(), | |
t._element.play(), | |
t._state = s.State.PLAYING | |
} | |
)) | |
} | |
} | |
, | |
i.stop = function() { | |
var t = this; | |
this._src && this._src._ensureLoaded((function() { | |
t._element._rateParam = void 0, | |
t._element.pause(), | |
t._element.currentTime = 0, | |
t._unbindEnded(), | |
t._state = s.State.STOPPED, | |
t.emit("stop") | |
} | |
)) | |
} | |
, | |
i.setLoop = function(t) { | |
var e = this; | |
this._src && this._src._ensureLoaded((function() { | |
e._element.loop = t | |
} | |
)) | |
} | |
, | |
i.isLoop = function() { | |
return !!this._element && this._element.loop | |
} | |
, | |
i.setVolume = function(t) { | |
var e = this; | |
this._src && this._src._ensureLoaded((function() { | |
e._element.volume = t | |
} | |
)) | |
} | |
, | |
i.getVolume = function() { | |
return this._element ? this._element.volume : 1 | |
} | |
, | |
i.setCurrentTime = function(t) { | |
var e = this; | |
this._src && this._src._ensureLoaded((function() { | |
e._unbindEnded(), | |
e._bindEnded(e._onendedSecond), | |
e._element.currentTime = t | |
} | |
)) | |
} | |
, | |
i.getCurrentTime = function() { | |
return this._element ? this._element.currentTime : 0 | |
} | |
, | |
i.getDuration = function() { | |
return this._src ? this._src.duration : 0 | |
} | |
, | |
i.getState = function(t) { | |
return void 0 === t && (t = !0), | |
t && this._forceUpdatingState(), | |
this._state | |
} | |
, | |
i._forceUpdatingState = function() { | |
var t = this._element; | |
t && (s.State.PLAYING === this._state && t.paused ? this._state = s.State.STOPPED : s.State.STOPPED !== this._state || t.paused || (this._state = s.State.PLAYING)) | |
} | |
, | |
Object.defineProperty(i, "src", { | |
get: function() { | |
return this._src | |
}, | |
set: function(t) { | |
if (this._unbindEnded(), | |
t && t.isValid) { | |
if (t !== this._src) | |
if (this._src = t, | |
t.loaded) | |
this._onLoaded(); | |
else { | |
var e = this; | |
t.once("load", (function() { | |
t === e._src && e._onLoaded() | |
} | |
)) | |
} | |
} else | |
this._src = null, | |
this._element instanceof o ? this._element = null : this._element && (this._element.src = ""), | |
this._state = s.State.INITIALZING; | |
return t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), | |
Object.defineProperty(i, "paused", { | |
get: function() { | |
return !this._element || this._element.paused | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), | |
cc.sys.browserType === cc.sys.BROWSER_TYPE_EDGE || cc.sys.browserType === cc.sys.BROWSER_TYPE_BAIDU || (cc.sys.browserType, | |
cc.sys.BROWSER_TYPE_UC); | |
var o = function(t, e) { | |
this._audio = e, | |
this._context = r.__audioSupport.context, | |
this._buffer = t, | |
this._gainObj = this._context.createGain(), | |
this.volume = 1, | |
this._useSetTarget = void 0 !== this._gainObj.gain.setValueAtTime, | |
this._useSetTarget ? this._gainObj.gain.setValueAtTime(1, this._context.currentTime) : this._gainObj.gain.value = 1, | |
this._gainObj.connect(this._context.destination), | |
this._loop = !1, | |
this._startTime = -1, | |
this._currentSource = null, | |
this.playedLength = 0, | |
this._offset = 0, | |
this._duration = t.duration, | |
this._fadeParam = void 0, | |
this._rateParam = void 0, | |
this._endCallback = function() { | |
var t = this._currentSource; | |
t && (this._currentSource = null, | |
a(t)), | |
this._fadeParam && (this._fadeParam.callback && this._fadeParam.callback(), | |
this._fadeParam.callback = void 0, | |
this._stopFade(!0)), | |
this._rateParam = void 0, | |
this.onended && this.onended(this) | |
} | |
.bind(this) | |
}; | |
(function(t) { | |
t.play = function(t, e) { | |
void 0 === t && (t = 0), | |
void 0 === e && (e = 0), | |
this.paused || (a(this._currentSource), | |
this.playedLength = 0, | |
this._stopFade(!0)); | |
var i = this.playedLength; | |
t || e ? (this._offset = t, | |
e ? this._duration = e : e = this._duration = this._buffer.duration - t) : (t = this._offset + i, | |
e = this._duration - i), | |
"suspended" === this._context.state && this._context.resume(); | |
var n = this._context.createBufferSource(); | |
n.buffer = this._buffer, | |
n.connect(this._gainObj), | |
this._startTime = this._context.currentTime - i, | |
this._loop ? (n.loop = !0, | |
n.loopStart = this._offset, | |
n.loopEnd = this._offset + this._duration, | |
n.start ? n.start(0, t) : n.noteGrainOn ? n.noteGrainOn(0, t) : n.noteOn(0, t)) : n.start ? n.start(0, t, e) : n.noteGrainOn ? n.noteGrainOn(0, t, e) : n.noteOn(0, t, e), | |
this._rateParam && void 0 === this._rateParam.applyTime && (1 === this._rateParam.rate ? this._rateParam = void 0 : (n.playbackRate.value = this._rateParam.rate, | |
this._rateParam.applyTime = this._context.currentTime)), | |
this._resumeFade(), | |
this._currentSource = n, | |
n.onended = this._endCallback; | |
var r = cc.sys; | |
r.os === r.OS_IOS && r.isBrowser && r.isMobile && ("suspended" === n.context.state && 0 !== this._context.currentTime || "interrupted" === n.context.state) && n.context.resume() | |
} | |
, | |
t.pause = function() { | |
if (!this.paused) { | |
var t = this._context.currentTime - this._startTime | |
, e = this._currentSource; | |
this._currentSource = null, | |
this._startTime = -1, | |
e && (a(e), | |
this._rateParam && void 0 !== this._rateParam.applyTime && (t += this._instantRateOffset(), | |
this._rateParam.applyTime = void 0, | |
this._rateParam.offset = 0)), | |
this.playedLength = t % this._duration, | |
this._pauseFade() | |
} | |
} | |
, | |
Object.defineProperty(t, "paused", { | |
get: function() { | |
if (this._currentSource && this._currentSource.loop) | |
return !1; | |
if (-1 === this._startTime) | |
return !0; | |
var t = this._context.currentTime - this._startTime; | |
return this._rateParam && void 0 !== this._rateParam.applyTime && (t += this._instantRateOffset()), | |
t > this._duration | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), | |
t.fade = function(t, e, i, n) { | |
if (this.paused || t === e || 0 === i) | |
this.volume = e; | |
else { | |
var r = i; | |
this._rateParam && (i /= this._rateParam.rate), | |
this.volume = t, | |
this._gainObj.gain.linearRampToValueAtTime(e, this._context.currentTime + i), | |
this._volume = e, | |
this._fadeParam = { | |
from: t, | |
to: e, | |
duration: r, | |
callback: n, | |
cancel: setTimeout(this._fadeComplete.bind(this), 1e3 * i) | |
} | |
} | |
} | |
, | |
t._stopFade = function(t) { | |
void 0 !== this._fadeParam && (void 0 !== this._fadeParam.cancel && clearTimeout(this._fadeParam.cancel), | |
this._gainObj.gain.cancelScheduledValues(this._context.currentTime), | |
t && (this._volume = this._fadeParam.to, | |
this._useSetTarget ? this._gainObj.gain.setValueAtTime(this._volume, this._context.currentTime) : this._gainObj.gain.value = this._volume), | |
this._fadeParam = void 0) | |
} | |
, | |
t._pauseFade = function() { | |
void 0 !== this._fadeParam && this._fadeParam.cancel && (clearTimeout(this._fadeParam.cancel), | |
this._fadeParam.cancel = void 0, | |
this._gainObj.gain.cancelScheduledValues(this._context.currentTime)) | |
} | |
, | |
t._resumeFade = function() { | |
if (void 0 !== this._fadeParam && !this._fadeParam.cancel) { | |
var t = this._fadeParam.to | |
, e = this._fadeParam.from | |
, i = this._fadeParam.duration | |
, n = t - e | |
, r = (this._gainObj.gain.value - e) / n; | |
(r < 0 || r > 1) && (r = 0, | |
this._gainObj.gain.value = e); | |
var s = i * (1 - r); | |
this._rateParam && this._rateParam.applyTime && (s /= this._rateParam.rate), | |
this._volume = t, | |
this._gainObj.gain.linearRampToValueAtTime(t, this._context.currentTime + s), | |
this._fadeParam.cancel = setTimeout(this._fadeComplete.bind(this), 1e3 * s) | |
} | |
} | |
, | |
t._fadeComplete = function() { | |
this._fadeParam && (this._fadeParam.callback && this._fadeParam.callback(), | |
this._fadeParam = void 0) | |
} | |
, | |
t._instantRateOffset = function() { | |
if (this._rateParam && this._rateParam.applyTime) { | |
var t = (this._context.currentTime - this._rateParam.applyTime) * (this._rateParam.rate - 1); | |
return this._rateParam.offset + t | |
} | |
return 0 | |
} | |
, | |
Object.defineProperty(t, "loop", { | |
get: function() { | |
return this._loop | |
}, | |
set: function(t) { | |
return this._loop !== t && (this.paused ? this._loop = t : (this.pause(), | |
this._loop = t, | |
this.play())), | |
t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), | |
Object.defineProperty(t, "volume", { | |
get: function() { | |
return this._volume | |
}, | |
set: function(t) { | |
this._stopFade(!1), | |
this._volume = t, | |
this._useSetTarget ? this._gainObj.gain.setValueAtTime(t, this._context.currentTime) : this._gainObj.gain.value = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), | |
Object.defineProperty(t, "currentTime", { | |
get: function() { | |
if (this.paused) | |
return this.playedLength; | |
var t = this._context.currentTime - this._startTime; | |
return this._rateParam && void 0 !== this._rateParam.applyTime && (t += this._instantRateOffset()), | |
t % this._duration | |
}, | |
set: function(t) { | |
return this._stopFade(!0), | |
this.paused ? this.playedLength = t : (this._rateParam && void 0 !== this._rateParam.applyTime && (this._rateParam.applyTime = void 0, | |
this._rateParam.offset = 0), | |
this.pause(), | |
this.playedLength = t, | |
this.play()), | |
t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), | |
Object.defineProperty(t, "duration", { | |
get: function() { | |
return this._duration | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), | |
Object.defineProperty(t, "rate", { | |
get: function() { | |
return this._rateParam ? this._rateParam.rate : 1 | |
}, | |
set: function(t) { | |
if (!(t <= 0)) { | |
var e = null !== this._currentSource; | |
if (void 0 === this._rateParam) | |
this._rateParam = { | |
applyTime: e ? this._context.currentTime : void 0, | |
rate: t, | |
offset: 0 | |
}; | |
else { | |
if (this._rateParam.rate === t) | |
return; | |
void 0 !== this._rateParam.applyTime && e && (this._rateParam.offset = this._instantRateOffset(), | |
this._rateParam.applyTime = this._context.currentTime), | |
this._rateParam.rate = t | |
} | |
void 0 !== this._rateParam.applyTime && e && (this._currentSource.playbackRate.value = t, | |
this._pauseFade(), | |
this._resumeFade()) | |
} | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}) | |
} | |
)(o.prototype); | |
var c = window.shell && window.shell.WebAudio ? window.shell.WebAudio : s; | |
e.exports = cc._Audio = c | |
} | |
), { | |
"../core/event/event-target": 134, | |
"../core/platform/CCSys": 171 | |
}], | |
21: [(function(t, e) { | |
"use strict"; | |
var i = { | |
name: "Jacob__Codec" | |
}; | |
i.Base64 = t("./base64"), | |
i.unzip = function() { | |
return i.GZip.gunzip.apply(i.GZip, arguments) | |
} | |
, | |
i.unzipBase64 = function() { | |
var t = i.Base64.decode.apply(i.Base64, arguments); | |
try { | |
return i.GZip.gunzip.call(i.GZip, t) | |
} catch (e) { | |
return t.slice(7) | |
} | |
} | |
, | |
i.unzipBase64AsArray = function(t, e) { | |
e = e || 1; | |
var i, n, r, s = this.unzipBase64(t), a = []; | |
for (i = 0, | |
r = s.length / e; i < r; i++) | |
for (a[i] = 0, | |
n = e - 1; n >= 0; --n) | |
a[i] += s.charCodeAt(i * e + n) << 8 * n; | |
return a | |
} | |
, | |
i.unzipAsArray = function(t, e) { | |
e = e || 1; | |
var i, n, r, s = this.unzip(t), a = []; | |
for (i = 0, | |
r = s.length / e; i < r; i++) | |
for (a[i] = 0, | |
n = e - 1; n >= 0; --n) | |
a[i] += s.charCodeAt(i * e + n) << 8 * n; | |
return a | |
} | |
, | |
cc.codec = e.exports = i | |
} | |
), { | |
"./base64": 22 | |
}], | |
22: [(function(t, e) { | |
"use strict"; | |
var i = t("../core/utils/misc").BASE64_VALUES | |
, n = { | |
name: "Jacob__Codec__Base64", | |
decode: function(t) { | |
var e, n, r, s, a, o, c = [], l = 0; | |
for (t = t.replace(/[^A-Za-z0-9\+\/\=]/g, ""); l < t.length; ) | |
e = i[t.charCodeAt(l++)] << 2 | (s = i[t.charCodeAt(l++)]) >> 4, | |
n = (15 & s) << 4 | (a = i[t.charCodeAt(l++)]) >> 2, | |
r = (3 & a) << 6 | (o = i[t.charCodeAt(l++)]), | |
c.push(String.fromCharCode(e)), | |
64 !== a && c.push(String.fromCharCode(n)), | |
64 !== o && c.push(String.fromCharCode(r)); | |
return c.join("") | |
}, | |
decodeAsArray: function(t, e) { | |
var i, n, r, s = this.decode(t), a = []; | |
for (i = 0, | |
r = s.length / e; i < r; i++) | |
for (a[i] = 0, | |
n = e - 1; n >= 0; --n) | |
a[i] += s.charCodeAt(i * e + n) << 8 * n; | |
return a | |
} | |
}; | |
e.exports = n | |
} | |
), { | |
"../core/utils/misc": 236 | |
}], | |
23: [(function(t, e) { | |
"use strict"; | |
var i, n = t("./platform/utils"), r = (t("../../DebugInfos"), | |
("undefined" == typeof window ? global : window).console); | |
cc.log = cc.warn = cc.error = cc.assert = r.log.bind ? r.log.bind(r) : r.log, | |
cc._throw = function(t) { | |
n.callInNextTick((function() { | |
throw t | |
} | |
)) | |
} | |
, | |
cc.logID = function() {} | |
, | |
cc.warnID = function() {} | |
, | |
cc.errorID = function() {} | |
, | |
cc.assertID = function() {} | |
; | |
var s, a = 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: a, | |
_resetDebugSetting: function(t) { | |
if (cc.log = cc.warn = cc.error = cc.assert = function() {} | |
, | |
t !== a.NONE) { | |
if (t > a.ERROR) { | |
var e = function(t) { | |
if (cc.game.canvas) { | |
if (!i) { | |
var e = document.createElement("Div"); | |
e.setAttribute("id", "logInfoDiv"), | |
e.setAttribute("width", "200"), | |
e.setAttribute("height", cc.game.canvas.height); | |
var n = e.style; | |
n.zIndex = "99999", | |
n.position = "absolute", | |
n.top = n.left = "0", | |
(i = document.createElement("textarea")).setAttribute("rows", "20"), | |
i.setAttribute("cols", "30"), | |
i.setAttribute("disabled", "true"); | |
var r = i.style; | |
r.backgroundColor = "transparent", | |
r.borderBottom = "1px solid #cccccc", | |
r.borderTopWidth = r.borderLeftWidth = r.borderRightWidth = "0px", | |
r.borderTopStyle = r.borderLeftStyle = r.borderRightStyle = "none", | |
r.padding = "0px", | |
r.margin = 0, | |
e.appendChild(i), | |
cc.game.canvas.parentNode.appendChild(e) | |
} | |
i.value = i.value + t + "\r\n", | |
i.scrollTop = i.scrollHeight | |
} | |
}; | |
cc.error = function() { | |
e("ERROR : " + cc.js.formatStr.apply(null, arguments)) | |
} | |
, | |
cc.assert = function(t, i) { | |
!t && i && (i = cc.js.formatStr.apply(null, cc.js.shiftArguments.apply(null, arguments)), | |
e("ASSERT: " + i)) | |
} | |
, | |
t !== a.ERROR_FOR_WEB_PAGE && (cc.warn = function() { | |
e("WARN : " + cc.js.formatStr.apply(null, arguments)) | |
} | |
), | |
t === a.INFO_FOR_WEB_PAGE && (cc.log = function() { | |
e(cc.js.formatStr.apply(null, arguments)) | |
} | |
) | |
} else | |
r && r.log.apply && (r.error || (r.error = r.log), | |
r.warn || (r.warn = r.log), | |
r.error.bind ? cc.error = r.error.bind(r) : cc.error = function() { | |
return r.error.apply(r, arguments) | |
} | |
, | |
cc.assert = function(t, e) { | |
if (!t) | |
throw e && (e = cc.js.formatStr.apply(null, cc.js.shiftArguments.apply(null, arguments))), | |
Error(e) | |
} | |
); | |
t !== a.ERROR && (r.warn.bind ? cc.warn = r.warn.bind(r) : cc.warn = function() { | |
return r.warn.apply(r, arguments) | |
} | |
), | |
t === a.INFO && (r.log.bind ? cc.log = r.log.bind(r) : cc.log = function() { | |
return r.log.apply(r, arguments) | |
} | |
) | |
} | |
}, | |
getError: (s = "ERROR", | |
function() { | |
var t = arguments[0] | |
, e = s + " " + t + "."; | |
if (1 === arguments.length) | |
return e; | |
if (2 === arguments.length) | |
return e + " Arguments: " + arguments[1]; | |
var i = cc.js.shiftArguments.apply(null, arguments); | |
return e + " Arguments: " + i.join(", ") | |
} | |
), | |
isDisplayStats: function() { | |
return !!cc.profiler && cc.profiler.isShowingStats() | |
}, | |
setDisplayStats: function(t) { | |
cc.profiler && cc.game.renderType !== cc.game.RENDER_TYPE_CANVAS && (t ? cc.profiler.showStats() : cc.profiler.hideStats(), | |
cc.game.config.showFPS = !!t) | |
} | |
} | |
} | |
), { | |
"../../DebugInfos": void 0, | |
"./platform/utils": 186 | |
}], | |
24: [(function(t, e) { | |
"use strict"; | |
var i = t("./event/event-target") | |
, n = t("./component-scheduler") | |
, r = t("./node-activator") | |
, s = t("./platform/CCObject") | |
, a = t("./CCGame") | |
, o = t("./renderer") | |
, c = t("./event-manager") | |
, l = t("./CCScheduler"); | |
cc.Director = function() { | |
i.call(this), | |
this._invalid = !1, | |
this._paused = !1, | |
this._purgeDirectorInNextLoop = !1, | |
this._winSizeInPoints = null, | |
this._scene = null, | |
this._loadingScene = "", | |
this._totalFrames = 0, | |
this._lastUpdate = 0, | |
this._deltaTime = 0, | |
this._startTime = 0, | |
this._maxParticleDeltaTime = 0, | |
this._timeScale = 1, | |
this._scheduler = null, | |
this._compScheduler = null, | |
this._nodeActivator = null, | |
this._actionManager = null; | |
var t = this; | |
a.on(a.EVENT_SHOW, (function() { | |
t._lastUpdate = performance.now() | |
} | |
)), | |
a.once(a.EVENT_ENGINE_INITED, this.init, this) | |
} | |
, | |
cc.Director.prototype = { | |
constructor: cc.Director, | |
init: function() { | |
return this._totalFrames = 0, | |
this._lastUpdate = performance.now(), | |
this._startTime = this._lastUpdate, | |
this._paused = !1, | |
this._purgeDirectorInNextLoop = !1, | |
this._winSizeInPoints = cc.size(0, 0), | |
this._scheduler = new l, | |
this.sharedInit(), | |
!0 | |
}, | |
sharedInit: function() { | |
this._compScheduler = new n, | |
this._nodeActivator = new r, | |
c && c.setEnabled(!0), | |
cc.ActionManager ? (this._actionManager = new cc.ActionManager, | |
this._scheduler.scheduleUpdate(this._actionManager, l.PRIORITY_SYSTEM, !1)) : this._actionManager = null, | |
cc.AnimationManager ? (this._animationManager = new cc.AnimationManager, | |
this._scheduler.scheduleUpdate(this._animationManager, l.PRIORITY_SYSTEM, !1)) : this._animationManager = null, | |
cc.CollisionManager ? (this._collisionManager = new cc.CollisionManager, | |
this._scheduler.scheduleUpdate(this._collisionManager, l.PRIORITY_SYSTEM, !1)) : this._collisionManager = null, | |
cc.PhysicsManager ? (this._physicsManager = new cc.PhysicsManager, | |
this._scheduler.scheduleUpdate(this._physicsManager, l.PRIORITY_SYSTEM, !1)) : this._physicsManager = null, | |
cc.Physics3DManager, | |
this._physics3DManager = null, | |
cc._widgetManager && cc._widgetManager.init(this) | |
}, | |
calculateDeltaTime: function(t) { | |
t || (t = performance.now()), | |
this._deltaTime = t > this._lastUpdate ? (t - this._lastUpdate) / 1e3 : 0, | |
this._lastUpdate = t | |
}, | |
convertToGL: function(t) { | |
var e = a.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) | |
, c = i._devicePixelRatio * (s + n.height - t.y); | |
return i._isRotated ? cc.v2(i._viewportRect.width - c, o) : cc.v2(o, c) | |
}, | |
convertToUI: function(t) { | |
var e = a.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); | |
return i._isRotated ? (o.x = r + t.y / i._devicePixelRatio, | |
o.y = s + n.height - (i._viewportRect.width - t.x) / i._devicePixelRatio) : (o.x = r + t.x * i._devicePixelRatio, | |
o.y = s + n.height - t.y * i._devicePixelRatio), | |
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.assetManager.releaseAll() | |
}, | |
purgeDirector: function() { | |
this._scheduler.unscheduleAll(), | |
this._compScheduler.unscheduleAll(), | |
this._nodeActivator.reset(), | |
c && c.setEnabled(!1), | |
cc.isValid(this._scene) && this._scene.destroy(), | |
this._scene = null, | |
cc.renderer.clear(), | |
cc.assetManager.builtins.clear(), | |
this.stopAnimation(), | |
cc.assetManager.releaseAll() | |
}, | |
reset: function() { | |
this.purgeDirector(), | |
c && c.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._resetDeltaTime(), | |
this.startAnimation() | |
}, | |
runSceneImmediate: function(t, e, i) { | |
t instanceof cc.SceneAsset && (t = t.scene), | |
t._load(), | |
this.emit(cc.Director.EVENT_BEFORE_SCENE_DESTROY, t); | |
for (var n = Object.keys(a._persistRootNodes).map((function(t) { | |
return a._persistRootNodes[t] | |
} | |
)), r = 0; r < n.length; r++) { | |
var o = n[r] | |
, c = t.getChildByUuid(o.uuid); | |
if (c) { | |
var l = c.getSiblingIndex(); | |
c._destroyImmediate(), | |
t.insertChild(o, l) | |
} else | |
o.parent = t | |
} | |
var h = this._scene; | |
cc.assetManager._releaseManager._autoRelease(h, t, a._persistRootNodes), | |
cc.isValid(h) && h.destroy(), | |
this._scene = null, | |
s._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) { | |
t instanceof cc.SceneAsset && (t = t.scene), | |
t._load(), | |
this.once(cc.Director.EVENT_AFTER_DRAW, (function() { | |
this.runSceneImmediate(t, e, i) | |
} | |
), this) | |
}, | |
loadScene: function(t, e, i) { | |
if (this._loadingScene) | |
return !1; | |
var n = cc.assetManager.bundles.find((function(e) { | |
return e.getSceneInfo(t) | |
} | |
)); | |
if (n) { | |
this.emit(cc.Director.EVENT_BEFORE_SCENE_LOADING, t), | |
this._loadingScene = t; | |
var r = this; | |
return n.loadScene(t, (function(t, n) { | |
r._loadingScene = "", | |
t ? (t = "Failed to load scene: " + t, | |
e && e(t)) : r.runSceneImmediate(n, i, e) | |
} | |
)), | |
!0 | |
} | |
return !1 | |
}, | |
preloadScene: function(t, e, i) { | |
var n = cc.assetManager.bundles.find((function(e) { | |
return e.getSceneInfo(t) | |
} | |
)); | |
if (!n) | |
return null; | |
n.preloadScene(t, null, e, i) | |
}, | |
resume: function() { | |
this._paused && (this._lastUpdate = performance.now(), | |
this._lastUpdate, | |
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 / a.getFrameRate() | |
}, | |
setAnimationInterval: function(t) { | |
a.setFrameRate(Math.round(1e3 / t)) | |
}, | |
getDeltaTime: function() { | |
return this._deltaTime | |
}, | |
getTotalTime: function() { | |
return performance.now() - this._startTime | |
}, | |
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) { | |
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 | |
}, | |
getPhysics3DManager: function() { | |
return this._physics3DManager | |
}, | |
startAnimation: function() { | |
this._invalid = !1 | |
}, | |
stopAnimation: function() { | |
this._invalid = !0 | |
}, | |
_resetDeltaTime: function() { | |
this._lastUpdate = performance.now(), | |
this._deltaTime = 0 | |
}, | |
setTimeScale: function(t) { | |
this._timeScale = t | |
}, | |
getTimeScale: function() { | |
return this._timeScale | |
}, | |
mainLoop: function(t) { | |
if (this._purgeDirectorInNextLoop) | |
this._purgeDirectorInNextLoop = !1, | |
this.purgeDirector(); | |
else if (!this._invalid) { | |
this.calculateDeltaTime(t); | |
var e = this._deltaTime; | |
1 !== this._timeScale && (e *= this._timeScale), | |
this._paused || (this.emit(cc.Director.EVENT_BEFORE_UPDATE), | |
this._compScheduler.startPhase(), | |
this._compScheduler.updatePhase(e), | |
this._scheduler.update(e), | |
this._compScheduler.lateUpdatePhase(e), | |
this.emit(cc.Director.EVENT_AFTER_UPDATE), | |
s._deferredDestroy()), | |
this.emit(cc.Director.EVENT_BEFORE_DRAW), | |
o.render(this._scene, e), | |
this.emit(cc.Director.EVENT_AFTER_DRAW), | |
c.frameUpdateListeners(), | |
this._totalFrames++ | |
} | |
}, | |
__fastOn: function(t, e, i) { | |
this.on(t, e, i) | |
}, | |
__fastOff: function(t, e, i) { | |
this.off(t, e, i) | |
} | |
}, | |
cc.js.addon(cc.Director.prototype, i.prototype), | |
cc.Director.EVENT_PROJECTION_CHANGED = "director_projection_changed", | |
cc.Director.EVENT_BEFORE_SCENE_LOADING = "director_before_scene_loading", | |
cc.Director.EVENT_BEFORE_SCENE_DESTROY = "director_before_scene_destroy", | |
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.EVENT_BEFORE_PHYSICS = "director_before_physics", | |
cc.Director.EVENT_AFTER_PHYSICS = "director_after_physics", | |
cc.director = new cc.Director, | |
e.exports = cc.director | |
} | |
), { | |
"./CCGame": 25, | |
"./CCScheduler": 29, | |
"./component-scheduler": 95, | |
"./event-manager": 133, | |
"./event/event-target": 134, | |
"./node-activator": 161, | |
"./platform/CCObject": 168, | |
"./renderer": 193 | |
}], | |
25: [(function(t, e) { | |
"use strict"; | |
var i = t("./event/event-target") | |
, n = t("./CCDebug") | |
, r = t("./renderer") | |
, s = t("../core/renderer/utils/dynamic-atlas/manager") | |
, a = { | |
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, | |
frame: null, | |
container: null, | |
canvas: null, | |
renderType: -1, | |
config: null, | |
onStart: null, | |
setFrameRate: function(t) { | |
this.config.frameRate = t, | |
this._setAnimFrame(), | |
this._paused || (this._intervalId && window.cancelAnimFrame(this._intervalId), | |
this._intervalId = 0, | |
this._runMainLoop()) | |
}, | |
getFrameRate: function() { | |
return this.config.frameRate | |
}, | |
step: function() { | |
cc.director.mainLoop() | |
}, | |
pause: function() { | |
this._paused || (this._paused = !0, | |
this._intervalId && window.cancelAnimFrame(this._intervalId), | |
this._intervalId = 0, | |
this.emit(a.EVENT_HIDE, this)) | |
}, | |
resume: function() { | |
this._paused && (this._paused = !1, | |
cc.director._resetDeltaTime(), | |
this._runMainLoop(), | |
this.emit(a.EVENT_SHOW, this)) | |
}, | |
isPaused: function() { | |
return this._paused | |
}, | |
restart: function() { | |
cc.director.once(cc.Director.EVENT_AFTER_DRAW, (function() { | |
for (var t in a._persistRootNodes) | |
a.removePersistRootNode(a._persistRootNodes[t]); | |
cc.director.getScene().destroy(), | |
cc.Object._deferredDestroy(), | |
cc.director.reset(), | |
a.pause(), | |
cc.assetManager.builtins.init((function(t) { | |
if (t) | |
throw t; | |
a.onStart(), | |
a.emit(a.EVENT_RESTART) | |
} | |
)) | |
} | |
)) | |
}, | |
end: function() { | |
close() | |
}, | |
_initEngine: function() { | |
this._rendererInitialized || (this._initRenderer(), | |
this._initEvents(), | |
this.emit(this.EVENT_ENGINE_INITED)) | |
}, | |
_loadPreviewScript: function(t) { | |
t() | |
}, | |
_prepareFinished: function(t) { | |
var e = this; | |
try { | |
this._initEngine() | |
} catch (i) { | |
return void (t && t(i)) | |
} | |
this._setAnimFrame(), | |
cc.assetManager.builtins.init((function(i) { | |
i ? t && t(i) : (e._prepared = !0, | |
e._runMainLoop(), | |
e._paused = !1, | |
e.emit(e.EVENT_GAME_INITED), | |
t && t()) | |
} | |
)) | |
}, | |
eventTargetOn: i.prototype.on, | |
eventTargetOnce: i.prototype.once, | |
on: function(t, e, i, n) { | |
this._prepared && t === this.EVENT_ENGINE_INITED || !this._paused && t === this.EVENT_GAME_INITED ? e.call(i) : this.eventTargetOn(t, e, i, n) | |
}, | |
once: function(t, e, i) { | |
this._prepared && t === this.EVENT_ENGINE_INITED || !this._paused && t === this.EVENT_GAME_INITED ? e.call(i) : this.eventTargetOnce(t, e, i) | |
}, | |
prepare: function(t) { | |
var e = this; | |
this._prepared ? t && t() : this._loadPreviewScript((function() { | |
e._prepareFinished(t) | |
} | |
)) | |
}, | |
run: function(t, e) { | |
this._initConfig(t), | |
this.onStart = e, | |
this.prepare(a.onStart && a.onStart.bind(a)) | |
}, | |
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)) | |
return; | |
if (t.parent !== i) | |
return | |
} else | |
t.parent = i; | |
this._persistRootNodes[e] = t, | |
t._persistNode = !0, | |
cc.assetManager._releaseManager._addPersistNodeRef(t) | |
} | |
} | |
}, | |
removePersistRootNode: function(t) { | |
var e = t.uuid || ""; | |
t === this._persistRootNodes[e] && (delete this._persistRootNodes[e], | |
t._persistNode = !1, | |
cc.assetManager._releaseManager._removePersistNodeRef(t)) | |
}, | |
isPersistRootNode: function(t) { | |
return t._persistNode | |
}, | |
_setAnimFrame: function() { | |
this._lastTime = performance.now(); | |
var t = a.config.frameRate; | |
this._frameTime = 1e3 / t, | |
cc.director._maxParticleDeltaTime = this._frameTime / 1e3 * 2; | |
var e = window.requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame; | |
60 !== t && 30 !== t ? (window.requestAnimFrame = e ? this._stTimeWithRAF : this._stTime, | |
window.cancelAnimFrame = this._ctTime) : (window.requestAnimFrame = e || this._stTime, | |
window.cancelAnimFrame = window.cancelAnimationFrame || window.cancelRequestAnimationFrame || window.msCancelRequestAnimationFrame || window.mozCancelRequestAnimationFrame || window.oCancelRequestAnimationFrame || window.webkitCancelRequestAnimationFrame || window.msCancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.oCancelAnimationFrame || this._ctTime) | |
}, | |
_stTimeWithRAF: function(t) { | |
var e = performance.now() | |
, i = Math.max(0, a._frameTime - (e - a._lastTime)) | |
, n = window.setTimeout((function() { | |
window.requestAnimationFrame(t) | |
} | |
), i); | |
return a._lastTime = e + i, | |
n | |
}, | |
_stTime: function(t) { | |
var e = performance.now() | |
, i = Math.max(0, a._frameTime - (e - a._lastTime)) | |
, n = window.setTimeout((function() { | |
t() | |
} | |
), i); | |
return a._lastTime = e + i, | |
n | |
}, | |
_ctTime: function(t) { | |
window.clearTimeout(t) | |
}, | |
_runMainLoop: function() { | |
if (this._prepared) { | |
var t, e = this, i = e.config, r = cc.director, s = !0, a = i.frameRate; | |
n.setDisplayStats(i.showFPS), | |
t = function(i) { | |
if (!e._paused) { | |
if (e._intervalId = window.requestAnimFrame(t), | |
30 === a && (s = !s)) | |
return; | |
r.mainLoop(i) | |
} | |
} | |
, | |
e._intervalId = window.requestAnimFrame(t) | |
} | |
}, | |
_initConfig: function(t) { | |
"number" != typeof t.debugMode && (t.debugMode = 0), | |
t.exposeClassName = !!t.exposeClassName, | |
"number" != typeof t.frameRate && (t.frameRate = 60); | |
var e = t.renderMode; | |
("number" != typeof e || e > 2 || e < 0) && (t.renderMode = 0), | |
"boolean" != typeof t.registerSystemEvent && (t.registerSystemEvent = !0), | |
t.showFPS = 1 !== e && !!t.showFPS, | |
this.collisionMatrix = t.collisionMatrix || [], | |
this.groupList = t.groupList || [], | |
n._resetDebugSetting(t.debugMode), | |
this.config = t, | |
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 ? cc.sys.capabilities.opengl ? (this.renderType = this.RENDER_TYPE_WEBGL, | |
i = !0) : cc.sys.capabilities.canvas && (this.renderType = this.RENDER_TYPE_CANVAS, | |
i = !0) : 1 === e && cc.sys.capabilities.canvas ? (this.renderType = this.RENDER_TYPE_CANVAS, | |
i = !0) : 2 === e && cc.sys.capabilities.opengl && (this.renderType = this.RENDER_TYPE_WEBGL, | |
i = !0), | |
!i) | |
throw Error(n.getError(3820, e)) | |
}, | |
_initRenderer: function() { | |
if (!this._rendererInitialized) { | |
var t, e, i, n, a = this.config.id, o = a instanceof HTMLElement ? a : document.querySelector(a) || document.querySelector("#" + a); | |
if ("CANVAS" === o.tagName ? (t = o.width, | |
e = o.height, | |
this.canvas = i = o, | |
this.container = n = document.createElement("DIV"), | |
i.parentNode && i.parentNode.insertBefore(n, i)) : (o.tagName, | |
t = o.clientWidth, | |
e = o.clientHeight, | |
this.canvas = i = document.createElement("CANVAS"), | |
this.container = n = document.createElement("DIV"), | |
o.appendChild(n)), | |
n.setAttribute("id", "Cocos2dGameContainer"), | |
n.appendChild(i), | |
this.frame = n.parentNode === document.body ? document.documentElement : n.parentNode, | |
(function(t) { | |
(" " + t.className + " ").indexOf(" gameCanvas ") > -1 || (t.className && (t.className += " "), | |
t.className += "gameCanvas") | |
} | |
)(i), | |
i.setAttribute("width", t || 480), | |
i.setAttribute("height", e || 320), | |
i.setAttribute("tabindex", 99), | |
this._determineRenderType(), | |
this.renderType === this.RENDER_TYPE_WEBGL) { | |
var c = { | |
stencil: !0, | |
antialias: cc.macro.ENABLE_WEBGL_ANTIALIAS, | |
alpha: cc.macro.ENABLE_TRANSPARENT_CANVAS | |
}; | |
r.initWebGL(i, c), | |
this._renderContext = r.device._gl, | |
!cc.macro.CLEANUP_IMAGE_CACHE && s && (s.enabled = !0) | |
} | |
this._renderContext || (this.renderType = this.RENDER_TYPE_CANVAS, | |
r.initCanvas(i), | |
this._renderContext = r.device._ctx), | |
this.canvas.oncontextmenu = function() { | |
if (!cc._isContextMenuEnable) | |
return !1 | |
} | |
, | |
this._rendererInitialized = !0 | |
} | |
}, | |
_initEvents: function() { | |
var t, e = window, i = this; | |
this.config.registerSystemEvent && cc.internal.inputManager.registerSystemEvent(this.canvas), | |
void 0 !== document.hidden ? t = "hidden" : void 0 !== document.mozHidden ? t = "mozHidden" : void 0 !== document.msHidden ? t = "msHidden" : void 0 !== document.webkitHidden && (t = "webkitHidden"); | |
var n = !1; | |
function r() { | |
n || i._paused || (n = !0, | |
i.pause()) | |
} | |
function s() { | |
n && (n = !1, | |
i.resume()) | |
} | |
if (t) | |
for (var a = ["visibilitychange", "mozvisibilitychange", "msvisibilitychange", "webkitvisibilitychange", "qbrowserVisibilityChange"], o = function(e) { | |
var i = document[t]; | |
(i = i || e.hidden) ? r() : s() | |
}, c = 0; c < a.length; c++) | |
document.addEventListener(a[c], o); | |
else | |
e.addEventListener("blur", r), | |
e.addEventListener("focus", s); | |
navigator.userAgent.indexOf("MicroMessenger") > -1 && (e.onfocus = s), | |
"onpageshow"in window && "onpagehide"in window && (e.addEventListener("pagehide", r), | |
e.addEventListener("pageshow", s), | |
document.addEventListener("pagehide", r), | |
document.addEventListener("pageshow", s)) | |
} | |
}; | |
i.call(a), | |
cc.js.addon(a, i.prototype), | |
cc.game = e.exports = a | |
} | |
), { | |
"../core/renderer/utils/dynamic-atlas/manager": 196, | |
"./CCDebug": 23, | |
"./event/event-target": 134, | |
"./renderer": 193 | |
}], | |
26: [(function(t, e) { | |
"use strict"; | |
var i = t("./value-types") | |
, n = t("./value-types/utils") | |
, r = t("./utils/base-node") | |
, s = t("./utils/prefab-helper") | |
, a = t("./utils/trans-pool").NodeMemPool | |
, o = t("./utils/affine-transform") | |
, c = t("./event-manager") | |
, l = t("./platform/CCMacro") | |
, h = t("./platform/js") | |
, u = (t("./event/event"), | |
t("./event/event-target")) | |
, f = t("./renderer/render-flow") | |
, d = cc.Object.Flags.Destroying | |
, _ = Math.PI / 180 | |
, p = !!cc.ActionManager | |
, v = function() {} | |
, g = new i.Vec3 | |
, m = new i.Quat | |
, y = new i.Vec3 | |
, T = new i.Vec3 | |
, E = new i.Quat | |
, A = new i.Quat | |
, x = new i.Vec3 | |
, C = new i.Vec3 | |
, b = new i.Vec3 | |
, S = new i.Vec3 | |
, R = new i.Vec3 | |
, M = new i.Quat | |
, w = new i.Quat | |
, I = new i.Vec3 | |
, O = new i.Quat | |
, L = new i.Vec3 | |
, P = new i.Quat | |
, D = new i.Vec3 | |
, N = new i.Vec3 | |
, F = new i.Quat | |
, B = new i.Quat | |
, V = (new i.Quat, | |
cc.mat4()) | |
, k = new i.Vec3 | |
, U = new h.Pool; | |
U.get = function() { | |
return this._get() || [] | |
} | |
; | |
var z = cc.Enum({ | |
DEBUG: 31 | |
}) | |
, H = cc.Enum({ | |
POSITION: 1, | |
SCALE: 2, | |
ROTATION: 4, | |
SKEW: 8, | |
TRS: 7, | |
RS: 6, | |
TRSS: 15, | |
PHYSICS_POSITION: 16, | |
PHYSICS_SCALE: 32, | |
PHYSICS_ROTATION: 64, | |
PHYSICS_TRS: 112, | |
PHYSICS_RS: 96, | |
ALL_POSITION: 17, | |
ALL_SCALE: 34, | |
ALL_ROTATION: 68, | |
ALL_TRS: 119, | |
ALL: 65535 | |
}) | |
, G = 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", | |
SIBLING_ORDER_CHANGED: "sibling-order-changed" | |
}) | |
, W = [G.TOUCH_START, G.TOUCH_MOVE, G.TOUCH_END, G.TOUCH_CANCEL] | |
, X = [G.MOUSE_DOWN, G.MOUSE_ENTER, G.MOUSE_MOVE, G.MOUSE_LEAVE, G.MOUSE_UP, G.MOUSE_WHEEL] | |
, Y = null | |
, j = function(t, e) { | |
var i = t.getLocation() | |
, n = this.owner; | |
return !!n._hitTest(i, this) && (e.type = G.TOUCH_START, | |
e.touch = t, | |
e.bubbles = !0, | |
n.dispatchEvent(e), | |
!0) | |
} | |
, q = function(t, e) { | |
var i = this.owner; | |
e.type = G.TOUCH_MOVE, | |
e.touch = t, | |
e.bubbles = !0, | |
i.dispatchEvent(e) | |
} | |
, Z = function(t, e) { | |
var i = t.getLocation() | |
, n = this.owner; | |
n._hitTest(i, this) ? e.type = G.TOUCH_END : e.type = G.TOUCH_CANCEL, | |
e.touch = t, | |
e.bubbles = !0, | |
n.dispatchEvent(e) | |
} | |
, K = function(t, e) { | |
t.getLocation(); | |
var i = this.owner; | |
e.type = G.TOUCH_CANCEL, | |
e.touch = t, | |
e.bubbles = !0, | |
i.dispatchEvent(e) | |
} | |
, Q = function(t) { | |
var e = t.getLocation() | |
, i = this.owner; | |
i._hitTest(e, this) && (t.type = G.MOUSE_DOWN, | |
t.bubbles = !0, | |
i.dispatchEvent(t)) | |
} | |
, J = function(t) { | |
var e = t.getLocation() | |
, i = this.owner; | |
if (i._hitTest(e, this)) | |
this._previousIn || (Y && Y._mouseListener && (t.type = G.MOUSE_LEAVE, | |
Y.dispatchEvent(t), | |
Y._mouseListener._previousIn = !1), | |
Y = this.owner, | |
t.type = G.MOUSE_ENTER, | |
i.dispatchEvent(t), | |
this._previousIn = !0), | |
t.type = G.MOUSE_MOVE, | |
t.bubbles = !0, | |
i.dispatchEvent(t); | |
else { | |
if (!this._previousIn) | |
return; | |
t.type = G.MOUSE_LEAVE, | |
i.dispatchEvent(t), | |
this._previousIn = !1, | |
Y = null | |
} | |
t.stopPropagation() | |
} | |
, $ = function(t) { | |
var e = t.getLocation() | |
, i = this.owner; | |
i._hitTest(e, this) && (t.type = G.MOUSE_UP, | |
t.bubbles = !0, | |
i.dispatchEvent(t), | |
t.stopPropagation()) | |
} | |
, tt = function(t) { | |
var e = t.getLocation() | |
, i = this.owner; | |
i._hitTest(e, this) && (t.type = G.MOUSE_WHEEL, | |
t.bubbles = !0, | |
i.dispatchEvent(t), | |
t.stopPropagation()) | |
}; | |
function et(t, e) { | |
if (e) { | |
for (var i = 0, n = null, r = t; r && cc.Node.isNode(r); r = r._parent, | |
++i) | |
if (r.getComponent(e)) { | |
var s = { | |
index: i, | |
node: r | |
}; | |
n ? n.push(s) : n = [s] | |
} | |
return n | |
} | |
return null | |
} | |
function it(t, e) { | |
if (!(t._objFlags & d)) { | |
if (t._bubblingListeners) | |
for (var i = 0, n = e.length; i < n; ++i) | |
if (t._bubblingListeners.hasEventListener(e[i])) | |
return !0; | |
if (t._capturingListeners) | |
for (var r = 0, s = e.length; r < s; ++r) | |
if (t._capturingListeners.hasEventListener(e[r])) | |
return !0; | |
return !1 | |
} | |
return !0 | |
} | |
function nt(t, e, i) { | |
var n, r; | |
for (e.target = t, | |
i.length = 0, | |
t._getCapturingTargets(e.type, i), | |
e.eventPhase = 1, | |
r = i.length - 1; r >= 0; --r) | |
if ((n = i[r])._capturingListeners && (e.currentTarget = n, | |
n._capturingListeners.emit(e.type, e, i), | |
e._propagationStopped)) | |
return void (i.length = 0); | |
if (i.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), | |
!e._propagationStopped && e.bubbles) | |
for (t._getBubblingTargets(e.type, i), | |
e.eventPhase = 3, | |
r = 0; r < i.length; ++r) | |
if ((n = i[r])._bubblingListeners && (e.currentTarget = n, | |
n._bubblingListeners.emit(e.type, e), | |
e._propagationStopped)) | |
return void (i.length = 0); | |
i.length = 0 | |
} | |
function rt(t) { | |
var e = t.groupIndex; | |
return 0 === e && t.parent && (e = rt(t.parent)), | |
e | |
} | |
function st(t) { | |
var e = rt(t); | |
t._cullingMask = 1 << e; | |
for (var i = 0; i < t._children.length; i++) | |
st(t._children[i]) | |
} | |
function at() { | |
if (this._localMatDirty & H.TRSS) { | |
var t = this._matrix | |
, e = t.m; | |
if (i.Trs.toMat4(t, this._trs), | |
this._skewX || this._skewY) { | |
var n = e[0] | |
, r = e[1] | |
, s = e[4] | |
, a = e[5] | |
, o = Math.tan(this._skewX * _) | |
, c = Math.tan(this._skewY * _); | |
Infinity === o && (o = 99999999), | |
Infinity === c && (c = 99999999), | |
e[0] = n + s * c, | |
e[1] = r + a * c, | |
e[4] = s + n * o, | |
e[5] = a + r * o | |
} | |
this._localMatDirty &= ~H.TRSS, | |
this._worldMatDirty = !0 | |
} | |
} | |
function ot() { | |
var t = this._localMatDirty; | |
if (t & H.TRSS) { | |
var e = this._matrix.m | |
, i = this._trs; | |
if (t & (H.RS | H.SKEW)) { | |
var n = -this._eulerAngles.z | |
, r = this._skewX || this._skewY | |
, s = i[7] | |
, a = i[8]; | |
if (n || r) { | |
var o = 1 | |
, c = 0 | |
, l = 0 | |
, h = 1; | |
if (n) { | |
var u = n * _; | |
l = Math.sin(u), | |
o = h = Math.cos(u), | |
c = -l | |
} | |
if (e[0] = o *= s, | |
e[1] = c *= s, | |
e[4] = l *= a, | |
e[5] = h *= a, | |
r) { | |
var f = e[0] | |
, d = e[1] | |
, p = e[4] | |
, v = e[5] | |
, g = Math.tan(this._skewX * _) | |
, m = Math.tan(this._skewY * _); | |
Infinity === g && (g = 99999999), | |
Infinity === m && (m = 99999999), | |
e[0] = f + p * m, | |
e[1] = d + v * m, | |
e[4] = p + f * g, | |
e[5] = v + d * g | |
} | |
} else | |
e[0] = s, | |
e[1] = 0, | |
e[4] = 0, | |
e[5] = a | |
} | |
e[12] = i[0], | |
e[13] = i[1], | |
this._localMatDirty &= ~H.TRSS, | |
this._worldMatDirty = !0 | |
} | |
} | |
function ct() { | |
if (this._localMatDirty & H.TRSS && this._updateLocalMatrix(), | |
this._parent) { | |
var t = this._parent._worldMatrix; | |
i.Mat4.mul(this._worldMatrix, t, this._matrix) | |
} else | |
i.Mat4.copy(this._worldMatrix, this._matrix); | |
this._worldMatDirty = !1 | |
} | |
function lt() { | |
this._localMatDirty & H.TRSS && this._updateLocalMatrix(); | |
var t = this._parent; | |
t ? this._mulMat(this._worldMatrix, t._worldMatrix, this._matrix) : i.Mat4.copy(this._worldMatrix, this._matrix), | |
this._worldMatDirty = !1 | |
} | |
function ht(t, e, i) { | |
var n = e.m | |
, r = i.m | |
, s = t.m | |
, a = n[0] | |
, o = n[1] | |
, c = n[4] | |
, l = n[5] | |
, h = n[12] | |
, u = n[13] | |
, f = r[0] | |
, d = r[1] | |
, _ = r[4] | |
, p = r[5] | |
, v = r[12] | |
, g = r[13]; | |
0 !== o || 0 !== c ? (s[0] = f * a + d * c, | |
s[1] = f * o + d * l, | |
s[4] = _ * a + p * c, | |
s[5] = _ * o + p * l, | |
s[12] = a * v + c * g + h, | |
s[13] = o * v + l * g + u) : (s[0] = f * a, | |
s[1] = d * l, | |
s[4] = _ * a, | |
s[5] = p * l, | |
s[12] = a * v + h, | |
s[13] = l * g + u) | |
} | |
var ut = i.Mat4.mul | |
, ft = { | |
name: "cc.Node", | |
extends: r, | |
properties: { | |
_opacity: 255, | |
_color: cc.Color.WHITE, | |
_contentSize: cc.Size, | |
_anchorPoint: cc.v2(.5, .5), | |
_position: void 0, | |
_scale: void 0, | |
_trs: null, | |
_eulerAngles: cc.Vec3, | |
_skewX: 0, | |
_skewY: 0, | |
_zIndex: { | |
default: void 0, | |
type: cc.Integer | |
}, | |
_localZOrder: { | |
default: 0, | |
serializable: !1 | |
}, | |
_is3DNode: !1, | |
_groupIndex: { | |
default: 0, | |
formerlySerializedAs: "groupIndex" | |
}, | |
groupIndex: { | |
get: function() { | |
return this._groupIndex | |
}, | |
set: function(t) { | |
this._groupIndex = t, | |
st(this), | |
this.emit(G.GROUP_CHANGED, this) | |
} | |
}, | |
group: { | |
get: function() { | |
return cc.game.groupList[this.groupIndex] || "" | |
}, | |
set: function(t) { | |
this.groupIndex = cc.game.groupList.indexOf(t) | |
} | |
}, | |
x: { | |
get: function() { | |
return this._trs[0] | |
}, | |
set: function(t) { | |
var e = this._trs; | |
t !== e[0] && (e[0] = t, | |
this.setLocalDirty(H.ALL_POSITION), | |
1 & this._eventMask && this.emit(G.POSITION_CHANGED)) | |
} | |
}, | |
y: { | |
get: function() { | |
return this._trs[1] | |
}, | |
set: function(t) { | |
var e = this._trs; | |
t !== e[1] && (e[1] = t, | |
this.setLocalDirty(H.ALL_POSITION), | |
1 & this._eventMask && this.emit(G.POSITION_CHANGED)) | |
} | |
}, | |
z: { | |
get: function() { | |
return this._trs[2] | |
}, | |
set: function(t) { | |
var e = this._trs; | |
t !== e[2] && (e[2] = t, | |
this.setLocalDirty(H.ALL_POSITION), | |
this._renderFlag |= f.FLAG_WORLD_TRANSFORM, | |
1 & this._eventMask && this.emit(G.POSITION_CHANGED)) | |
} | |
}, | |
rotation: { | |
get: function() { | |
return -this.angle | |
}, | |
set: function(t) { | |
this.angle = -t | |
} | |
}, | |
angle: { | |
get: function() { | |
return this._eulerAngles.z | |
}, | |
set: function(t) { | |
i.Vec3.set(this._eulerAngles, 0, 0, t), | |
i.Trs.fromAngleZ(this._trs, t), | |
this.setLocalDirty(H.ALL_ROTATION), | |
4 & this._eventMask && this.emit(G.ROTATION_CHANGED) | |
} | |
}, | |
rotationX: { | |
get: function() { | |
return this._eulerAngles.x | |
}, | |
set: function(t) { | |
this._eulerAngles.x !== t && (this._eulerAngles.x = t, | |
this._eulerAngles.x === this._eulerAngles.y ? i.Trs.fromAngleZ(this._trs, -t) : i.Trs.fromEulerNumber(this._trs, t, this._eulerAngles.y, 0), | |
this.setLocalDirty(H.ALL_ROTATION), | |
4 & this._eventMask && this.emit(G.ROTATION_CHANGED)) | |
} | |
}, | |
rotationY: { | |
get: function() { | |
return this._eulerAngles.y | |
}, | |
set: function(t) { | |
this._eulerAngles.y !== t && (this._eulerAngles.y = t, | |
this._eulerAngles.x === this._eulerAngles.y ? i.Trs.fromAngleZ(this._trs, -t) : i.Trs.fromEulerNumber(this._trs, this._eulerAngles.x, t, 0), | |
this.setLocalDirty(H.ALL_ROTATION), | |
4 & this._eventMask && this.emit(G.ROTATION_CHANGED)) | |
} | |
}, | |
eulerAngles: { | |
get: function() { | |
return i.Trs.toEuler(this._eulerAngles, this._trs) | |
}, | |
set: function(t) { | |
i.Trs.fromEuler(this._trs, t), | |
this.setLocalDirty(H.ALL_ROTATION), | |
this._renderFlag |= f.FLAG_TRANSFORM, | |
4 & this._eventMask && this.emit(G.ROTATION_CHANGED) | |
} | |
}, | |
quat: { | |
get: function() { | |
var t = this._trs; | |
return new i.Quat(t[3],t[4],t[5],t[6]) | |
}, | |
set: function(t) { | |
this.setRotation(t) | |
} | |
}, | |
scale: { | |
get: function() { | |
return this._trs[7] | |
}, | |
set: function(t) { | |
this.setScale(t) | |
} | |
}, | |
scaleX: { | |
get: function() { | |
return this._trs[7] | |
}, | |
set: function(t) { | |
this._trs[7] !== t && (this._trs[7] = t, | |
this.setLocalDirty(H.ALL_SCALE), | |
2 & this._eventMask && this.emit(G.SCALE_CHANGED)) | |
} | |
}, | |
scaleY: { | |
get: function() { | |
return this._trs[8] | |
}, | |
set: function(t) { | |
this._trs[8] !== t && (this._trs[8] = t, | |
this.setLocalDirty(H.ALL_SCALE), | |
2 & this._eventMask && this.emit(G.SCALE_CHANGED)) | |
} | |
}, | |
scaleZ: { | |
get: function() { | |
return this._trs[9] | |
}, | |
set: function(t) { | |
this._trs[9] !== t && (this._trs[9] = t, | |
this.setLocalDirty(H.ALL_SCALE), | |
this._renderFlag |= f.FLAG_TRANSFORM, | |
2 & this._eventMask && this.emit(G.SCALE_CHANGED)) | |
} | |
}, | |
skewX: { | |
get: function() { | |
return this._skewX | |
}, | |
set: function(t) { | |
this._skewX = t, | |
this.setLocalDirty(H.SKEW) | |
} | |
}, | |
skewY: { | |
get: function() { | |
return this._skewY | |
}, | |
set: function(t) { | |
this._skewY = t, | |
this.setLocalDirty(H.SKEW) | |
} | |
}, | |
opacity: { | |
get: function() { | |
return this._opacity | |
}, | |
set: function(t) { | |
this._opacity !== t && (this._opacity = t, | |
this._renderFlag |= f.FLAG_OPACITY_COLOR) | |
}, | |
range: [0, 255] | |
}, | |
color: { | |
get: function() { | |
return this._color.clone() | |
}, | |
set: function(t) { | |
this._color.equals(t) || (this._color.set(t), | |
this._renderFlag |= f.FLAG_COLOR, | |
32 & this._eventMask && this.emit(G.COLOR_CHANGED, t)) | |
} | |
}, | |
anchorX: { | |
get: function() { | |
return this._anchorPoint.x | |
}, | |
set: function(t) { | |
var e = this._anchorPoint; | |
e.x !== t && (e.x = t, | |
16 & this._eventMask && this.emit(G.ANCHOR_CHANGED)) | |
} | |
}, | |
anchorY: { | |
get: function() { | |
return this._anchorPoint.y | |
}, | |
set: function(t) { | |
var e = this._anchorPoint; | |
e.y !== t && (e.y = t, | |
16 & this._eventMask && this.emit(G.ANCHOR_CHANGED)) | |
} | |
}, | |
width: { | |
get: function() { | |
return this._contentSize.width | |
}, | |
set: function(t) { | |
t !== this._contentSize.width && (this._contentSize.width = t, | |
8 & this._eventMask && this.emit(G.SIZE_CHANGED)) | |
} | |
}, | |
height: { | |
get: function() { | |
return this._contentSize.height | |
}, | |
set: function(t) { | |
t !== this._contentSize.height && (this._contentSize.height = t, | |
8 & this._eventMask && this.emit(G.SIZE_CHANGED)) | |
} | |
}, | |
zIndex: { | |
get: function() { | |
return this._localZOrder >> 16 | |
}, | |
set: function(t) { | |
t > l.MAX_ZINDEX ? t = l.MAX_ZINDEX : t < l.MIN_ZINDEX && (t = l.MIN_ZINDEX), | |
this.zIndex !== t && (this._localZOrder = 65535 & this._localZOrder | t << 16, | |
this.emit(G.SIBLING_ORDER_CHANGED), | |
this._onSiblingIndexChanged()) | |
} | |
}, | |
swallowTouches: { | |
get: function() { | |
return this._swallowTouches | |
}, | |
set: function(t) { | |
this._swallowTouches = t, | |
this._touchListener && this._touchListener.setSwallowTouches(t) | |
} | |
}, | |
is3DNode: { | |
get: function() { | |
return this._is3DNode | |
}, | |
set: function(t) { | |
this._is3DNode !== t && (this._is3DNode = t, | |
this._update3DFunction()) | |
} | |
}, | |
up: { | |
get: function() { | |
return i.Vec3.transformQuat(L, i.Vec3.UP, this.getWorldRotation(P)).clone() | |
} | |
}, | |
right: { | |
get: function() { | |
return i.Vec3.transformQuat(L, i.Vec3.RIGHT, this.getWorldRotation(P)).clone() | |
} | |
}, | |
forward: { | |
get: function() { | |
return i.Vec3.transformQuat(L, i.Vec3.FORWARD, this.getWorldRotation(P)).clone() | |
} | |
} | |
}, | |
ctor: function() { | |
this._reorderChildDirty = !1, | |
this._widget = null, | |
this._renderComponent = null, | |
this._capturingListeners = null, | |
this._bubblingListeners = null, | |
this._touchListener = null, | |
this._mouseListener = null, | |
this._initDataFromPool(), | |
this._eventMask = 0, | |
this._cullingMask = 1, | |
this._childArrivalOrder = 1, | |
this._swallowTouches = !0, | |
this._renderFlag = f.FLAG_TRANSFORM | f.FLAG_OPACITY_COLOR | |
}, | |
statics: { | |
EventType: G, | |
_LocalDirtyFlag: H, | |
isNode: function(t) { | |
return t instanceof dt && (t.constructor === dt || !(t instanceof cc.Scene)) | |
}, | |
BuiltinGroupIndex: z | |
}, | |
_onSiblingIndexChanged: function() { | |
this._parent && this._parent._delaySort() | |
}, | |
_onPreDestroy: function() { | |
this._onPreDestroyBase(), | |
p && cc.director.getActionManager().removeAllActionsFromTarget(this), | |
Y === this && (Y = null), | |
this._bubblingListeners && this._bubblingListeners.clear(), | |
this._capturingListeners && this._capturingListeners.clear(), | |
(this._touchListener || this._mouseListener) && (c.removeListeners(this), | |
this._touchListener && (this._touchListener.owner = null, | |
this._touchListener.mask = null, | |
this._touchListener = null), | |
this._mouseListener && (this._mouseListener.owner = null, | |
this._mouseListener.mask = null, | |
this._mouseListener = null)), | |
this._backDataIntoPool(), | |
this._reorderChildDirty && cc.director.__fastOff(cc.Director.EVENT_AFTER_UPDATE, this.sortAllChildren, this) | |
}, | |
_onPostActivated: function(t) { | |
var e = p ? cc.director.getActionManager() : null; | |
t ? (this._renderFlag |= f.FLAG_WORLD_TRANSFORM, | |
e && e.resumeTarget(this), | |
c.resumeTarget(this), | |
this._checkListenerMask()) : (e && e.pauseTarget(this), | |
c.pauseTarget(this)) | |
}, | |
_onHierarchyChanged: function(t) { | |
this._updateOrderOfArrival(), | |
st(this), | |
this._parent && this._parent._delaySort(), | |
this._renderFlag |= f.FLAG_WORLD_TRANSFORM | f.FLAG_OPACITY_COLOR, | |
this._onHierarchyChangedBase(t), | |
cc._widgetManager && (cc._widgetManager._nodesOrderDirty = !0), | |
t && this._activeInHierarchy && this._checkListenerMask() | |
}, | |
_update3DFunction: function() { | |
this._is3DNode ? (this._updateLocalMatrix = at, | |
this._calculWorldMatrix = ct, | |
this._mulMat = ut) : (this._updateLocalMatrix = ot, | |
this._calculWorldMatrix = lt, | |
this._mulMat = ht), | |
this._renderComponent && this._renderComponent._on3DNodeChanged && this._renderComponent._on3DNodeChanged(), | |
this._renderFlag |= f.FLAG_TRANSFORM, | |
this._localMatDirty = H.ALL | |
}, | |
_initDataFromPool: function() { | |
this._spaceInfo || (this._spaceInfo = a.pop()); | |
var t = this._spaceInfo; | |
this._matrix = cc.mat4(t.localMat), | |
i.Mat4.identity(this._matrix), | |
this._worldMatrix = cc.mat4(t.worldMat), | |
i.Mat4.identity(this._worldMatrix), | |
this._localMatDirty = H.ALL, | |
this._worldMatDirty = !0; | |
var e = this._trs = t.trs; | |
e[0] = 0, | |
e[1] = 0, | |
e[2] = 0, | |
e[3] = 0, | |
e[4] = 0, | |
e[5] = 0, | |
e[6] = 1, | |
e[7] = 1, | |
e[8] = 1, | |
e[9] = 1 | |
}, | |
_backDataIntoPool: function() { | |
a.push(this._spaceInfo), | |
this._matrix = null, | |
this._worldMatrix = null, | |
this._trs = null, | |
this._spaceInfo = null | |
}, | |
_toEuler: function() { | |
if (this.is3DNode) | |
i.Trs.toEuler(this._eulerAngles, this._trs); | |
else { | |
var t = Math.asin(this._trs[5]) / _ * 2; | |
i.Vec3.set(this._eulerAngles, 0, 0, t) | |
} | |
}, | |
_fromEuler: function() { | |
this.is3DNode ? i.Trs.fromEuler(this._trs, this._eulerAngles) : i.Trs.fromAngleZ(this._trs, this._eulerAngles.z) | |
}, | |
_initProperties: function() { | |
this._is3DNode && this._update3DFunction(); | |
var t = this._trs; | |
if (t) { | |
var e = t; | |
t = this._trs = this._spaceInfo.trs, | |
11 === e.length ? t.set(e.subarray(1)) : t.set(e) | |
} else | |
t = this._trs = this._spaceInfo.trs; | |
this._fromEuler() | |
}, | |
_onBatchCreated: function(t) { | |
this._initProperties(), | |
this._cullingMask = 1 << rt(this), | |
this._activeInHierarchy || (p && cc.director.getActionManager().pauseTarget(this), | |
c.pauseTarget(this)); | |
for (var e = this._children, i = 0, n = e.length; i < n; i++) { | |
var r = e[i]; | |
if (!t) { | |
var a = r._prefab; | |
a && a.sync && a.root === r && s.syncWithPrefab(r), | |
r._updateOrderOfArrival() | |
} | |
r._onBatchCreated(t) | |
} | |
e.length > 0 && (this._renderFlag |= f.FLAG_CHILDREN) | |
}, | |
_checkListenerMask: function() { | |
if (this._touchListener) { | |
var t = this._touchListener.mask = et(this, cc.Mask); | |
this._mouseListener && (this._mouseListener.mask = t) | |
} else | |
this._mouseListener && (this._mouseListener.mask = et(this, cc.Mask)) | |
}, | |
_checknSetupSysEvent: function(t) { | |
var e = !1 | |
, i = !1; | |
return -1 !== W.indexOf(t) ? (this._touchListener || (this._touchListener = cc.EventListener.create({ | |
event: cc.EventListener.TOUCH_ONE_BY_ONE, | |
swallowTouches: this._swallowTouches, | |
owner: this, | |
mask: et(this, cc.Mask), | |
onTouchBegan: j, | |
onTouchMoved: q, | |
onTouchEnded: Z, | |
onTouchCancelled: K | |
}), | |
c.addListener(this._touchListener, this), | |
e = !0), | |
i = !0) : -1 !== X.indexOf(t) && (this._mouseListener || (this._mouseListener = cc.EventListener.create({ | |
event: cc.EventListener.MOUSE, | |
_previousIn: !1, | |
owner: this, | |
mask: et(this, cc.Mask), | |
onMouseDown: Q, | |
onMouseMove: J, | |
onMouseUp: $, | |
onMouseScroll: tt | |
}), | |
c.addListener(this._mouseListener, this), | |
e = !0), | |
i = !0), | |
e && !this._activeInHierarchy && cc.director.getScheduler().schedule((function() { | |
this._activeInHierarchy || c.pauseTarget(this) | |
} | |
), this, 0, 0, 0, !1), | |
i | |
}, | |
on: function(t, e, i, n) { | |
return this._realon(t, e, i, n, !1) | |
}, | |
_realon: function(t, e, i, n, r) { | |
if ("boolean" == typeof i ? (n = i, | |
i = void 0) : n = !!n, | |
e) { | |
if (this._checknSetupSysEvent(t)) | |
return this._onDispatch(t, e, i, n, r); | |
switch (t) { | |
case G.POSITION_CHANGED: | |
this._eventMask |= 1; | |
break; | |
case G.SCALE_CHANGED: | |
this._eventMask |= 2; | |
break; | |
case G.ROTATION_CHANGED: | |
this._eventMask |= 4; | |
break; | |
case G.SIZE_CHANGED: | |
this._eventMask |= 8; | |
break; | |
case G.ANCHOR_CHANGED: | |
this._eventMask |= 16; | |
break; | |
case G.COLOR_CHANGED: | |
this._eventMask |= 32 | |
} | |
return this._onDispatch(t, e, i, !1, r) | |
} | |
}, | |
once: function(t, e, i, n) { | |
this._realon(t, e, i, n, !0) | |
}, | |
_onDispatch: function(t, e, i, n, r) { | |
var s = null; | |
return (s = n ? this._capturingListeners = this._capturingListeners || new u : this._bubblingListeners = this._bubblingListeners || new u).hasEventListener(t, e, i) || (s.on(t, e, i, r), | |
i && i.__eventTargets && i.__eventTargets.push(this)), | |
e | |
}, | |
off: function(t, e, i, n) { | |
"boolean" == typeof i ? (n = i, | |
i = void 0) : n = !!n; | |
var r = -1 !== W.indexOf(t) | |
, s = !r && -1 !== X.indexOf(t); | |
if (r || s) | |
this._offDispatch(t, e, i, n), | |
r ? this._touchListener && !it(this, W) && (c.removeListener(this._touchListener), | |
this._touchListener = null) : s && this._mouseListener && !it(this, X) && (c.removeListener(this._mouseListener), | |
this._mouseListener = null); | |
else if (this._bubblingListeners && (this._offDispatch(t, e, i, !1), | |
!this._bubblingListeners.hasEventListener(t))) | |
switch (t) { | |
case G.POSITION_CHANGED: | |
this._eventMask &= -2; | |
break; | |
case G.SCALE_CHANGED: | |
this._eventMask &= -3; | |
break; | |
case G.ROTATION_CHANGED: | |
this._eventMask &= -5; | |
break; | |
case G.SIZE_CHANGED: | |
this._eventMask &= -9; | |
break; | |
case G.ANCHOR_CHANGED: | |
this._eventMask &= -17; | |
break; | |
case G.COLOR_CHANGED: | |
this._eventMask &= -33 | |
} | |
}, | |
_offDispatch: function(t, e, i, n) { | |
if (e) { | |
var r = n ? this._capturingListeners : this._bubblingListeners; | |
r && r.off(t, e, i) && i && i.__eventTargets && h.array.fastRemove(i.__eventTargets, this) | |
} else | |
this._capturingListeners && this._capturingListeners.removeAll(t), | |
this._bubblingListeners && this._bubblingListeners.removeAll(t) | |
}, | |
targetOff: function(t) { | |
var e = this._bubblingListeners; | |
e && (e.targetOff(t), | |
1 & this._eventMask && !e.hasEventListener(G.POSITION_CHANGED) && (this._eventMask &= -2), | |
2 & this._eventMask && !e.hasEventListener(G.SCALE_CHANGED) && (this._eventMask &= -3), | |
4 & this._eventMask && !e.hasEventListener(G.ROTATION_CHANGED) && (this._eventMask &= -5), | |
8 & this._eventMask && !e.hasEventListener(G.SIZE_CHANGED) && (this._eventMask &= -9), | |
16 & this._eventMask && !e.hasEventListener(G.ANCHOR_CHANGED) && (this._eventMask &= -17), | |
32 & this._eventMask && !e.hasEventListener(G.COLOR_CHANGED) && (this._eventMask &= -33)), | |
this._capturingListeners && this._capturingListeners.targetOff(t), | |
t && t.__eventTargets && h.array.fastRemoveAll(t.__eventTargets, this), | |
this._touchListener && !it(this, W) && (c.removeListener(this._touchListener), | |
this._touchListener = null), | |
this._mouseListener && !it(this, X) && (c.removeListener(this._mouseListener), | |
this._mouseListener = null) | |
}, | |
hasEventListener: function(t) { | |
var e = !1; | |
return this._bubblingListeners && (e = this._bubblingListeners.hasEventListener(t)), | |
!e && this._capturingListeners && (e = this._capturingListeners.hasEventListener(t)), | |
e | |
}, | |
emit: function(t, e, i, n, r, s) { | |
this._bubblingListeners && this._bubblingListeners.emit(t, e, i, n, r, s) | |
}, | |
dispatchEvent: function(t) { | |
var e = U.get(); | |
nt(this, t, e), | |
U.put(e) | |
}, | |
pauseSystemEvents: function(t) { | |
c.pauseTarget(this, t) | |
}, | |
resumeSystemEvents: function(t) { | |
c.resumeTarget(this, t) | |
}, | |
_hitTest: function(t, e) { | |
var n = this._contentSize.width | |
, r = this._contentSize.height | |
, s = D | |
, a = N | |
, o = cc.Camera.findCamera(this); | |
if (o ? o.getScreenToWorldPoint(t, s) : s.set(t), | |
this._updateWorldMatrix(), | |
!i.Mat4.invert(V, this._worldMatrix)) | |
return !1; | |
i.Vec2.transformMat4(a, s, V), | |
a.x += this._anchorPoint.x * n, | |
a.y += this._anchorPoint.y * r; | |
var c = !1; | |
if (a.x >= 0 && a.y >= 0 && a.x <= n && a.y <= r && (c = !0, | |
e && e.mask)) | |
for (var l = e.mask, h = this, u = l ? l.length : 0, f = 0, d = 0; h && d < u; ++f, | |
h = h.parent) { | |
var _ = l[d]; | |
if (f === _.index) { | |
if (h !== _.node) { | |
l.length = d; | |
break | |
} | |
var p = h.getComponent(cc.Mask); | |
if (p && p._enabled && !p._hitTest(s)) { | |
c = !1; | |
break | |
} | |
d++ | |
} else if (f > _.index) { | |
l.length = d; | |
break | |
} | |
} | |
return c | |
}, | |
_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: p ? function(t) { | |
if (this.active) { | |
var e = cc.director.getActionManager(); | |
return e._suppressDeprecation || (e._suppressDeprecation = !0), | |
e.addAction(t, this, !1), | |
t | |
} | |
} | |
: v, | |
pauseAllActions: p ? function() { | |
cc.director.getActionManager().pauseTarget(this) | |
} | |
: v, | |
resumeAllActions: p ? function() { | |
cc.director.getActionManager().resumeTarget(this) | |
} | |
: v, | |
stopAllActions: p ? function() { | |
cc.director.getActionManager().removeAllActionsFromTarget(this) | |
} | |
: v, | |
stopAction: p ? function(t) { | |
cc.director.getActionManager().removeAction(t) | |
} | |
: v, | |
stopActionByTag: p ? function(t) { | |
t !== cc.Action.TAG_INVALID && cc.director.getActionManager().removeActionByTag(t, this) | |
} | |
: v, | |
getActionByTag: p ? function(t) { | |
return t === cc.Action.TAG_INVALID ? null : cc.director.getActionManager().getActionByTag(t, this) | |
} | |
: function() { | |
return null | |
} | |
, | |
getNumberOfRunningActions: p ? function() { | |
return cc.director.getActionManager().getNumberOfRunningActionsInTarget(this) | |
} | |
: function() { | |
return 0 | |
} | |
, | |
getPosition: function(t) { | |
return t = t || new i.Vec3, | |
i.Trs.toPosition(t, this._trs) | |
}, | |
setPosition: function(t, e, i) { | |
var n; | |
void 0 === e ? (n = t.x, | |
e = t.y, | |
i = t.z) : n = t; | |
var r = this._trs; | |
void 0 === i && (i = r[2]), | |
(r[0] !== n || r[1] !== e || r[2] !== i) && (r[0] = n, | |
r[1] = e, | |
r[2] = i, | |
this.setLocalDirty(H.ALL_POSITION), | |
this._renderFlag |= f.FLAG_WORLD_TRANSFORM, | |
1 & this._eventMask && this.emit(G.POSITION_CHANGED)) | |
}, | |
getScale: function(t) { | |
return void 0 !== t ? i.Trs.toScale(t, this._trs) : this._trs[7] | |
}, | |
setScale: function(t, e, i) { | |
var n; | |
t && "number" != typeof t ? (n = t.x, | |
e = t.y, | |
i = t.z) : void 0 !== t && void 0 === e ? (n = t, | |
e = t, | |
i = t) : n = t; | |
var r = this._trs; | |
void 0 === i && (i = r[9]), | |
r[7] === n && r[8] === e && r[9] === i || (r[7] = n, | |
r[8] = e, | |
r[9] = i, | |
this.setLocalDirty(H.ALL_SCALE), | |
this._renderFlag |= f.FLAG_TRANSFORM, | |
2 & this._eventMask && this.emit(G.SCALE_CHANGED)) | |
}, | |
getRotation: function(t) { | |
return t instanceof i.Quat ? i.Trs.toRotation(t, this._trs) : -this.angle | |
}, | |
setRotation: function(t, e, i, n) { | |
if ("number" == typeof t && void 0 === e) | |
this.angle = -t; | |
else { | |
var r = t; | |
void 0 === e && (r = t.x, | |
e = t.y, | |
i = t.z, | |
n = t.w); | |
var s = this._trs; | |
s[3] === r && s[4] === e && s[5] === i && s[6] === n || (s[3] = r, | |
s[4] = e, | |
s[5] = i, | |
s[6] = n, | |
this.setLocalDirty(H.ALL_ROTATION), | |
4 & this._eventMask && this.emit(G.ROTATION_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 ((0, | |
n.approx)(t.width, i.width) && (0, | |
n.approx)(t.height, i.height)) | |
return; | |
i.width = t.width, | |
i.height = t.height | |
} else { | |
if ((0, | |
n.approx)(t, i.width) && (0, | |
n.approx)(e, i.height)) | |
return; | |
i.width = t, | |
i.height = e | |
} | |
8 & this._eventMask && this.emit(G.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(H.ALL_POSITION), | |
16 & this._eventMask && this.emit(G.ANCHOR_CHANGED) | |
}, | |
_invTransformPoint: function(t, e) { | |
this._parent ? this._parent._invTransformPoint(t, e) : i.Vec3.copy(t, e); | |
var n = this._trs; | |
return i.Trs.toPosition(y, n), | |
i.Vec3.sub(t, t, y), | |
i.Trs.toRotation(E, n), | |
i.Quat.conjugate(A, E), | |
i.Vec3.transformQuat(t, t, A), | |
i.Trs.toScale(y, n), | |
i.Vec3.inverseSafe(T, y), | |
i.Vec3.mul(t, t, T), | |
t | |
}, | |
getWorldPosition: function(t) { | |
i.Trs.toPosition(t, this._trs); | |
for (var e, n = this._parent; n; ) | |
e = n._trs, | |
i.Trs.toScale(g, e), | |
i.Vec3.mul(t, t, g), | |
i.Trs.toRotation(m, e), | |
i.Vec3.transformQuat(t, t, m), | |
i.Trs.toPosition(g, e), | |
i.Vec3.add(t, t, g), | |
n = n._parent; | |
return t | |
}, | |
setWorldPosition: function(t) { | |
var e = this._trs; | |
this._parent ? this._parent._invTransformPoint(x, t) : i.Vec3.copy(x, t), | |
i.Trs.fromPosition(e, x), | |
this.setLocalDirty(H.ALL_POSITION), | |
1 & this._eventMask && this.emit(G.POSITION_CHANGED) | |
}, | |
getWorldRotation: function(t) { | |
i.Trs.toRotation(F, this._trs), | |
i.Quat.copy(t, F); | |
for (var e = this._parent; e; ) | |
i.Trs.toRotation(F, e._trs), | |
i.Quat.mul(t, F, t), | |
e = e._parent; | |
return t | |
}, | |
setWorldRotation: function(t) { | |
this._parent ? (this._parent.getWorldRotation(B), | |
i.Quat.conjugate(B, B), | |
i.Quat.mul(B, B, t)) : i.Quat.copy(B, t), | |
i.Trs.fromRotation(this._trs, B), | |
this.setLocalDirty(H.ALL_ROTATION) | |
}, | |
getWorldScale: function(t) { | |
i.Trs.toScale(C, this._trs), | |
i.Vec3.copy(t, C); | |
for (var e = this._parent; e; ) | |
i.Trs.toScale(C, e._trs), | |
i.Vec3.mul(t, t, C), | |
e = e._parent; | |
return t | |
}, | |
setWorldScale: function(t) { | |
this._parent ? (this._parent.getWorldScale(b), | |
i.Vec3.div(b, t, b)) : i.Vec3.copy(b, t), | |
i.Trs.fromScale(this._trs, b), | |
this.setLocalDirty(H.ALL_SCALE) | |
}, | |
getWorldRT: function(t) { | |
var e = S | |
, n = M | |
, r = this._trs; | |
i.Trs.toPosition(e, r), | |
i.Trs.toRotation(n, r); | |
for (var s = this._parent; s; ) | |
r = s._trs, | |
i.Trs.toScale(R, r), | |
i.Vec3.mul(e, e, R), | |
i.Trs.toRotation(w, r), | |
i.Vec3.transformQuat(e, e, w), | |
i.Trs.toPosition(R, r), | |
i.Vec3.add(e, e, R), | |
i.Quat.mul(n, w, n), | |
s = s._parent; | |
return i.Mat4.fromRT(t, n, e), | |
t | |
}, | |
lookAt: function(t, e) { | |
this.getWorldPosition(I), | |
i.Vec3.sub(I, I, t), | |
i.Vec3.normalize(I, I), | |
i.Quat.fromViewUp(O, I, e), | |
this.setWorldRotation(O) | |
}, | |
_updateLocalMatrix: ot, | |
_calculWorldMatrix: function() { | |
this._localMatDirty & H.TRSS && this._updateLocalMatrix(); | |
var t = this._parent; | |
t ? this._mulMat(this._worldMatrix, t._worldMatrix, this._matrix) : i.Mat4.copy(this._worldMatrix, this._matrix), | |
this._worldMatDirty = !1 | |
}, | |
_mulMat: ht, | |
_updateWorldMatrix: function() { | |
if (this._parent && this._parent._updateWorldMatrix(), | |
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 |= t, | |
this._worldMatDirty = !0, | |
t === H.ALL_POSITION || t === H.POSITION ? this._renderFlag |= f.FLAG_WORLD_TRANSFORM : this._renderFlag |= f.FLAG_TRANSFORM | |
}, | |
setWorldDirty: function() { | |
this._worldMatDirty = !0 | |
}, | |
getLocalMatrix: function(t) { | |
return this._updateLocalMatrix(), | |
i.Mat4.copy(t, this._matrix) | |
}, | |
getWorldMatrix: function(t) { | |
return this._updateWorldMatrix(), | |
i.Mat4.copy(t, this._worldMatrix) | |
}, | |
convertToNodeSpaceAR: function(t, e) { | |
return this._updateWorldMatrix(), | |
i.Mat4.invert(V, this._worldMatrix), | |
t instanceof cc.Vec2 ? (e = e || new cc.Vec2, | |
i.Vec2.transformMat4(e, t, V)) : (e = e || new cc.Vec3, | |
i.Vec3.transformMat4(e, t, V)) | |
}, | |
convertToWorldSpaceAR: function(t, e) { | |
return this._updateWorldMatrix(), | |
t instanceof cc.Vec2 ? (e = e || new cc.Vec2, | |
i.Vec2.transformMat4(e, t, this._worldMatrix)) : (e = e || new cc.Vec3, | |
i.Vec3.transformMat4(e, t, this._worldMatrix)) | |
}, | |
convertToNodeSpace: function(t) { | |
this._updateWorldMatrix(), | |
i.Mat4.invert(V, this._worldMatrix); | |
var e = new cc.Vec2; | |
return i.Vec2.transformMat4(e, t, V), | |
e.x += this._anchorPoint.x * this._contentSize.width, | |
e.y += this._anchorPoint.y * this._contentSize.height, | |
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 i.Vec2.transformMat4(e, e, this._worldMatrix) | |
}, | |
getNodeToParentTransform: function(t) { | |
t || (t = o.identity()), | |
this._updateLocalMatrix(); | |
var e = this._contentSize; | |
return k.x = -this._anchorPoint.x * e.width, | |
k.y = -this._anchorPoint.y * e.height, | |
i.Mat4.copy(V, this._matrix), | |
i.Mat4.transform(V, V, k), | |
o.fromMat4(t, V) | |
}, | |
getNodeToParentTransformAR: function(t) { | |
return t || (t = o.identity()), | |
this._updateLocalMatrix(), | |
o.fromMat4(t, this._matrix) | |
}, | |
getNodeToWorldTransform: function(t) { | |
t || (t = o.identity()), | |
this._updateWorldMatrix(); | |
var e = this._contentSize; | |
return k.x = -this._anchorPoint.x * e.width, | |
k.y = -this._anchorPoint.y * e.height, | |
i.Mat4.copy(V, this._worldMatrix), | |
i.Mat4.transform(V, V, k), | |
o.fromMat4(t, V) | |
}, | |
getNodeToWorldTransformAR: function(t) { | |
return t || (t = o.identity()), | |
this._updateWorldMatrix(), | |
o.fromMat4(t, this._worldMatrix) | |
}, | |
getParentToNodeTransform: function(t) { | |
return t || (t = o.identity()), | |
this._updateLocalMatrix(), | |
i.Mat4.invert(V, this._matrix), | |
o.fromMat4(t, V) | |
}, | |
getWorldToNodeTransform: function(t) { | |
return t || (t = o.identity()), | |
this._updateWorldMatrix(), | |
i.Mat4.invert(V, this._worldMatrix), | |
o.fromMat4(t, V) | |
}, | |
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() { | |
return this._parent ? (this._parent._updateWorldMatrix(), | |
this._getBoundingBoxTo()) : this.getBoundingBox() | |
}, | |
_getBoundingBoxTo: function() { | |
var t = this._contentSize.width | |
, e = this._contentSize.height | |
, i = cc.rect(-this._anchorPoint.x * t, -this._anchorPoint.y * e, t, e); | |
if (this._calculWorldMatrix(), | |
i.transformMat4(i, this._worldMatrix), | |
!this._children) | |
return i; | |
for (var n = this._children, r = 0; r < n.length; r++) { | |
var s = n[r]; | |
if (s && s.active) { | |
var a = s._getBoundingBoxTo(); | |
a && i.union(i, a) | |
} | |
} | |
return i | |
}, | |
_updateOrderOfArrival: function() { | |
var t = this._parent ? ++this._parent._childArrivalOrder : 0; | |
this._localZOrder = 4294901760 & this._localZOrder | t, | |
this.emit(G.SIBLING_ORDER_CHANGED) | |
}, | |
setSelfGroupIndex: function(t) { | |
this._groupIndex = t || 0, | |
this._cullingMask = 1 << t | |
}, | |
addChild: function(t, e, i) { | |
t.parent = this, | |
void 0 !== e && (t.zIndex = e), | |
void 0 !== i && (t.name = i) | |
}, | |
cleanup: function() { | |
p && cc.director.getActionManager().removeAllActionsFromTarget(this), | |
c.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; | |
this._childArrivalOrder = 1; | |
for (var e = 0, i = t.length; e < i; e++) | |
t[e]._updateOrderOfArrival(); | |
if (c._setDirtyForNode(this), | |
t.length > 1) { | |
for (var n, r, s = 1, a = t.length; s < a; s++) { | |
n = t[s]; | |
for (var o = s; o > 0 && (r = t[o - 1])._localZOrder > n._localZOrder; o--) | |
t[o] = r; | |
t[o] = n | |
} | |
this.emit(G.CHILD_REORDER, this) | |
} | |
cc.director.__fastOff(cc.Director.EVENT_AFTER_UPDATE, this.sortAllChildren, this) | |
} | |
}, | |
_delaySort: function() { | |
this._reorderChildDirty || (this._reorderChildDirty = !0, | |
cc.director.__fastOn(cc.Director.EVENT_AFTER_UPDATE, this.sortAllChildren, this)) | |
}, | |
_restoreProperties: !1, | |
onRestore: !1 | |
} | |
, dt = cc.Class(ft) | |
, _t = dt.prototype; | |
h.getset(_t, "position", _t.getPosition, _t.setPosition, !1, !0), | |
cc.Node = e.exports = dt | |
} | |
), { | |
"./event-manager": 133, | |
"./event/event": 135, | |
"./event/event-target": 134, | |
"./platform/CCMacro": 167, | |
"./platform/js": 183, | |
"./renderer/render-flow": 194, | |
"./utils/affine-transform": 227, | |
"./utils/base-node": 228, | |
"./utils/prefab-helper": 239, | |
"./utils/trans-pool": 245, | |
"./value-types": 251, | |
"./value-types/utils": 258 | |
}], | |
27: [(function(t, e) { | |
"use strict"; | |
var i = t("./CCNode") | |
, n = t("./renderer/render-flow") | |
, r = (cc.Object.Flags.HideInHierarchy, | |
i._LocalDirtyFlag) | |
, s = cc.Class({ | |
name: "cc.PrivateNode", | |
extends: i, | |
properties: { | |
x: { | |
get: function() { | |
return this._originPos.x | |
}, | |
set: function(t) { | |
var e = this._originPos; | |
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; | |
t !== e.y && (e.y = t, | |
this._posDirty(!0)) | |
}, | |
override: !0 | |
}, | |
zIndex: { | |
get: function() { | |
return cc.macro.MIN_ZINDEX | |
}, | |
set: function() {}, | |
override: !0 | |
}, | |
showInEditor: { | |
default: !1, | |
editorOnly: !0, | |
override: !0 | |
} | |
}, | |
ctor: function() { | |
this._localZOrder = cc.macro.MIN_ZINDEX << 16, | |
this._originPos = cc.v2() | |
}, | |
_posDirty: function(t) { | |
this.setLocalDirty(r.POSITION), | |
this._renderFlag |= n.FLAG_TRANSFORM, | |
!0 === t && 1 & this._eventMask && this.emit(i.EventType.POSITION_CHANGED) | |
}, | |
_updateLocalMatrix: function() { | |
if (this._localMatDirty) { | |
var t = this.parent; | |
t && (this._trs[0] = this._originPos.x - (t._anchorPoint.x - .5) * t._contentSize.width, | |
this._trs[1] = 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; | |
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), | |
e !== t && (e && e.off(i.EventType.ANCHOR_CHANGED, this._posDirty, this), | |
t && t.on(i.EventType.ANCHOR_CHANGED, this._posDirty, this)) | |
}, | |
_updateOrderOfArrival: function() {} | |
}) | |
, a = s.prototype; | |
cc.js.getset(a, "parent", a.getParent, a.setParent), | |
cc.js.getset(a, "position", a.getPosition, a.setPosition), | |
cc.PrivateNode = e.exports = s | |
} | |
), { | |
"./CCNode": 26, | |
"./renderer/render-flow": 194 | |
}], | |
28: [(function(t, e) { | |
"use strict"; | |
cc.Scene = cc.Class({ | |
name: "cc.Scene", | |
extends: t("./CCNode"), | |
properties: { | |
_is3DNode: { | |
default: !0, | |
override: !0 | |
}, | |
autoReleaseAssets: !1 | |
}, | |
ctor: function() { | |
this._anchorPoint.x = 0, | |
this._anchorPoint.y = 0, | |
this._activeInHierarchy = !1, | |
this._inited = !cc.game._isCloning, | |
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() { | |
this._inited || (this._onBatchCreated(!1), | |
this._inited = !0) | |
}, | |
_activate: function(t) { | |
t = !1 !== t, | |
cc.director._nodeActivator.activateNode(this, t) | |
} | |
}), | |
e.exports = cc.Scene | |
} | |
), { | |
"./CCNode": 26 | |
}], | |
29: [(function(t, e) { | |
"use strict"; | |
var i = t("./platform/js") | |
, n = new (t("./platform/id-generater"))("Scheduler") | |
, r = function(t, e, i, n) { | |
this.target = t, | |
this.priority = e, | |
this.paused = i, | |
this.markedForDeletion = n | |
} | |
, s = []; | |
r.get = function(t, e, i, n) { | |
var a = s.pop(); | |
return a ? (a.target = t, | |
a.priority = e, | |
a.paused = i, | |
a.markedForDeletion = n) : a = new r(t,e,i,n), | |
a | |
} | |
, | |
r.put = function(t) { | |
s.length < 20 && (t.target = null, | |
s.push(t)) | |
} | |
; | |
var a = function(t, e, i, n) { | |
this.list = t, | |
this.entry = e, | |
this.target = i, | |
this.callback = n | |
} | |
, o = []; | |
a.get = function(t, e, i, n) { | |
var r = o.pop(); | |
return r ? (r.list = t, | |
r.entry = e, | |
r.target = i, | |
r.callback = n) : r = new a(t,e,i,n), | |
r | |
} | |
, | |
a.put = function(t) { | |
o.length < 20 && (t.list = t.entry = t.target = t.callback = null, | |
o.push(t)) | |
} | |
; | |
var c = function(t, e, i, n) { | |
this.timers = t, | |
this.target = e, | |
this.timerIndex = i, | |
this.paused = n | |
} | |
, l = []; | |
function h() { | |
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 | |
} | |
c.get = function(t, e, i, n) { | |
var r = l.pop(); | |
return r ? (r.timers = t, | |
r.target = e, | |
r.timerIndex = i, | |
r.paused = n) : r = new c(t,e,i,n), | |
r | |
} | |
, | |
c.put = function(t) { | |
l.length < 20 && (t.timers = t.target = null, | |
l.push(t)) | |
} | |
; | |
var u = h.prototype; | |
u.initWithCallback = function(t, e, i, n, r, s) { | |
return 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, | |
!0 | |
} | |
, | |
u.getInterval = function() { | |
return this._interval | |
} | |
, | |
u.setInterval = function(t) { | |
this._interval = t | |
} | |
, | |
u.update = function(t) { | |
-1 === this._elapsed ? (this._elapsed = 0, | |
this._timesExecuted = 0) : (this._elapsed += t, | |
this._runForever && !this._useDelay ? this._elapsed >= this._interval && (this.trigger(), | |
this._elapsed = 0) : (this._useDelay ? this._elapsed >= this._delay && (this.trigger(), | |
this._elapsed -= this._delay, | |
this._timesExecuted += 1, | |
this._useDelay = !1) : this._elapsed >= this._interval && (this.trigger(), | |
this._elapsed = 0, | |
this._timesExecuted += 1), | |
this._callback && !this._runForever && this._timesExecuted > this._repeat && this.cancel())) | |
} | |
, | |
u.getCallback = function() { | |
return this._callback | |
} | |
, | |
u.trigger = function() { | |
this._target && this._callback && (this._lock = !0, | |
this._callback.call(this._target, this._elapsed), | |
this._lock = !1) | |
} | |
, | |
u.cancel = function() { | |
this._scheduler.unschedule(this._callback, this._target) | |
} | |
; | |
var f = []; | |
function d() {} | |
function _(t) { | |
var e = t._id; | |
return e || t.__instanceId && (e = t._id = t.__instanceId), | |
e | |
} | |
h.get = function() { | |
return f.pop() || new h | |
} | |
, | |
h.put = function(t) { | |
f.length < 20 && !t._lock && (t._scheduler = t._target = t._callback = null, | |
f.push(t)) | |
} | |
, | |
cc.Scheduler = function() { | |
this._timeScale = 1, | |
this._updatesNegList = [], | |
this._updates0List = [], | |
this._updatesPosList = [], | |
this._hashForUpdates = i.createMap(!0), | |
this._hashForTimers = i.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 | |
} | |
c.put(t) | |
}, | |
_removeUpdateFromHash: function(t) { | |
var e = t.target._id | |
, i = this._hashForUpdates[e]; | |
if (i) { | |
for (var n = i.list, s = i.entry, o = 0, c = n.length; o < c; o++) | |
if (n[o] === s) { | |
n.splice(o, 1); | |
break | |
} | |
delete this._hashForUpdates[e], | |
r.put(s), | |
a.put(i) | |
} | |
}, | |
_priorityIn: function(t, e, i) { | |
for (var n = 0, r = t.length; n < r; n++) | |
if (i < t[n].priority) | |
return void t.splice(n, 0, e); | |
t.push(e) | |
}, | |
_appendIn: function(t, e) { | |
t.push(e) | |
}, | |
enableForTarget: function(t) { | |
t._id || t.__instanceId || (t._id = n.getNewId()) | |
}, | |
setTimeScale: function(t) { | |
this._timeScale = t | |
}, | |
getTimeScale: function() { | |
return this._timeScale | |
}, | |
update: function(t) { | |
var e, i, n, r; | |
for (this._updateHashLocked = !0, | |
1 !== this._timeScale && (t *= this._timeScale), | |
i = this._updatesNegList; null != i; ) { | |
for (e = 0, | |
n = i.length; e < n; e++) | |
(r = i[e]).paused || r.markedForDeletion || r.target.update(t); | |
i = i === this._updatesNegList ? this._updates0List : i === this._updates0List ? this._updatesPosList : null | |
} | |
var s, a = this._arrayForTimers; | |
for (e = 0; e < a.length; e++) { | |
if (s = a[e], | |
this._currentTarget = s, | |
this._currentTargetSalvaged = !1, | |
!s.paused) | |
for (s.timerIndex = 0; s.timerIndex < s.timers.length; ++s.timerIndex) | |
s.timers[s.timerIndex].update(t); | |
this._currentTargetSalvaged && 0 === this._currentTarget.timers.length && (this._removeHashElement(this._currentTarget), | |
--e) | |
} | |
for (i = this._updatesNegList; null != i; ) { | |
for (e = 0; e < i.length; ) | |
(r = i[e]).markedForDeletion ? this._removeUpdateFromHash(r) : e++; | |
i = i === this._updatesNegList ? this._updates0List : i === this._updates0List ? this._updatesPosList : null | |
} | |
this._updateHashLocked = !1, | |
this._currentTarget = null | |
}, | |
schedule: function(t, e, i, n, r, s) { | |
if ("function" != typeof t) { | |
var a = t; | |
t = e, | |
e = a | |
} | |
4 !== arguments.length && 5 !== arguments.length || (s = !!n, | |
n = cc.macro.REPEAT_FOREVER, | |
r = 0); | |
var o, l, u = _(e), f = this._hashForTimers[u]; | |
if (f ? f.paused : (f = c.get(null, e, 0, s), | |
this._arrayForTimers.push(f), | |
this._hashForTimers[u] = f), | |
null == f.timers) | |
f.timers = []; | |
else | |
for (l = 0; l < f.timers.length; ++l) | |
if ((o = f.timers[l]) && t === o._callback) | |
return void (o._interval = i); | |
(o = h.get()).initWithCallback(this, t, e, i, n, r), | |
f.timers.push(o), | |
this._currentTarget === f && this._currentTargetSalvaged && (this._currentTargetSalvaged = !1) | |
}, | |
scheduleUpdate: function(t, e, i) { | |
var n = _(t) | |
, s = this._hashForUpdates[n]; | |
if (s && s.entry) { | |
if (s.entry.priority === e) | |
return s.entry.markedForDeletion = !1, | |
void (s.entry.paused = i); | |
if (this._updateHashLocked) | |
return s.entry.markedForDeletion = !1, | |
void (s.entry.paused = i); | |
this.unscheduleUpdate(t) | |
} | |
var o, c = r.get(t, e, i, !1); | |
0 === e ? (o = this._updates0List, | |
this._appendIn(o, c)) : (o = e < 0 ? this._updatesNegList : this._updatesPosList, | |
this._priorityIn(o, c, e)), | |
this._hashForUpdates[n] = a.get(o, c, t, null) | |
}, | |
unschedule: function(t, e) { | |
if (1 === arguments.length && "function" != typeof t && (e = t, | |
t = d), | |
e && t) { | |
var i = _(e) | |
, n = this | |
, r = n._hashForTimers[i]; | |
if (r) { | |
for (var s = r.timers, a = 0, o = s.length; a < o; a++) { | |
var c = s[a]; | |
if ((t === d || t === c._callback) && (h.put(c), | |
t !== d)) { | |
s.splice(a, 1), | |
r.timerIndex >= a && r.timerIndex--; | |
break | |
} | |
} | |
t === d && (s.length = 0), | |
0 === s.length && (n._currentTarget === r ? n._currentTargetSalvaged = !0 : n._removeHashElement(r)) | |
} | |
} | |
}, | |
unscheduleUpdate: function(t) { | |
if (t) { | |
var e = _(t) | |
, i = this._hashForUpdates[e]; | |
i && (this._updateHashLocked ? i.entry.markedForDeletion = !0 : this._removeUpdateFromHash(i.entry)) | |
} | |
}, | |
unscheduleAllForTarget: function(t) { | |
t && (this.unschedule(t), | |
this.unscheduleUpdate(t)) | |
}, | |
unscheduleAll: function() { | |
var t, e, i = this._arrayForTimers; | |
for (t = i.length - 1; t >= 0; t--) | |
e = i[t], | |
this.unschedule(e.target); | |
this.unscheduleAllWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM) | |
}, | |
unscheduleAllWithMinPriority: function(t) { | |
var e, i, n, r = 0; | |
for (i = t < 0 ? this._updatesNegList : 0 === t ? this._updates0List : this._updatesPosList; null != i; ) { | |
for (n = 0; n < i.length; ) | |
r = i.length, | |
(e = i[n]) && e.priority >= t && this.unscheduleUpdate(e.target), | |
r === i.length && n++; | |
i = i === this._updatesNegList ? this._updates0List : i === this._updates0List ? this._updatesPosList : null | |
} | |
}, | |
isScheduled: function(t, e) { | |
var i = _(e) | |
, 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() { | |
this._setPausedForAllTimers(!0), | |
this._setPausedForAllTargetsWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM, !0) | |
}, | |
pauseAllTargetsWithMinPriority: function(t) { | |
this._setPausedForAllTargetsWithMinPriority(t, !0) | |
}, | |
resumeAllTargets: function() { | |
this._setPausedForAllTimers(!1), | |
this._setPausedForAllTargetsWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM, !1) | |
}, | |
resumeAllTargetsWithMinPriority: function(t) { | |
this._setPausedForAllTargetsWithMinPriority(t, !1) | |
}, | |
_setPausedForAllTimers: function(t) { | |
var e, i, n, r = this._arrayForTimers; | |
for (i = 0, | |
n = r.length; i < n; i++) | |
(e = r[i]) && (e.paused = t) | |
}, | |
_setPausedForAllTargetsWithMinPriority: function(t, e) { | |
var i, n, r; | |
for (r = t < 0 ? this._updatesNegList : 0 === t ? this._updates0List : this._updatesPosList; null != r; ) { | |
for (n = 0; n < r.length; n++) | |
(i = r[n]) && i.priority >= t && (i.paused = e); | |
r = r === this._updatesNegList ? this._updates0List : r === this._updates0List ? this._updatesPosList : null | |
} | |
}, | |
pauseTarget: function(t) { | |
var e = _(t) | |
, i = this._hashForTimers[e]; | |
i && (i.paused = !0); | |
var n = this._hashForUpdates[e]; | |
n && (n.entry.paused = !0) | |
}, | |
resumeTarget: function(t) { | |
var e = _(t) | |
, i = this._hashForTimers[e]; | |
i && (i.paused = !1); | |
var n = this._hashForUpdates[e]; | |
n && (n.entry.paused = !1) | |
}, | |
isTargetPaused: function(t) { | |
var e = _(t) | |
, 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, | |
e.exports = cc.Scheduler | |
} | |
), { | |
"./platform/id-generater": 179, | |
"./platform/js": 183 | |
}], | |
30: [(function(t, e) { | |
"use strict"; | |
var i = t("./preprocess") | |
, n = t("./fetch") | |
, r = t("./cache") | |
, s = t("./helper") | |
, a = t("./releaseManager") | |
, o = t("./depend-util") | |
, c = t("./load") | |
, l = t("./pipeline") | |
, h = t("./task") | |
, u = t("./request-item") | |
, f = t("./downloader") | |
, d = t("./parser") | |
, _ = t("./pack-manager") | |
, p = t("./bundle") | |
, v = t("./builtins") | |
, g = t("./factory") | |
, m = t("./urlTransformer") | |
, y = m.parse | |
, T = m.combine | |
, E = t("./utilities") | |
, A = E.parseParameters | |
, x = E.asyncify | |
, C = E.parseLoadResArgs | |
, b = t("./shared") | |
, S = b.assets | |
, R = b.files | |
, M = b.parsed | |
, w = b.pipeline | |
, I = b.transformPipeline | |
, O = b.fetchPipeline | |
, L = b.RequestType | |
, P = b.bundles | |
, D = b.BuiltinBundleName; | |
function N() { | |
this._preprocessPipe = i, | |
this._fetchPipe = n, | |
this._loadPipe = c, | |
this.pipeline = w.append(i).append(c), | |
this.fetchPipeline = O.append(i).append(n), | |
this.transformPipeline = I.append(y).append(T), | |
this.bundles = P, | |
this.assets = S, | |
this._files = R, | |
this._parsed = M, | |
this.generalImportBase = "", | |
this.generalNativeBase = "", | |
this.dependUtil = o, | |
this._releaseManager = a, | |
this.cacheAsset = !0, | |
this.force = !1, | |
this.utils = s, | |
this.downloader = f, | |
this.parser = d, | |
this.builtins = v, | |
this.packManager = _, | |
this.factory = g, | |
this.cacheManager = null, | |
this.presets = { | |
default: { | |
priority: 0 | |
}, | |
preload: { | |
maxConcurrency: 2, | |
maxRequestsPerFrame: 2, | |
priority: -1 | |
}, | |
scene: { | |
maxConcurrency: 8, | |
maxRequestsPerFrame: 8, | |
priority: 1 | |
}, | |
bundle: { | |
maxConcurrency: 8, | |
maxRequestsPerFrame: 8, | |
priority: 2 | |
}, | |
script: { | |
maxConcurrency: 1024, | |
maxRequestsPerFrame: 1024, | |
priority: 2 | |
} | |
}, | |
this._parseLoadResArgs = C, | |
this._onProgress = null | |
} | |
N.Pipeline = l, | |
N.Task = h, | |
N.Cache = r, | |
N.RequestItem = u, | |
N.Bundle = p, | |
N.BuiltinBundleName = D, | |
N.prototype = { | |
constructor: N, | |
get main() { | |
return P.get(D.MAIN) | |
}, | |
get resources() { | |
return P.get(D.RESOURCES) | |
}, | |
get internal() { | |
return P.get(D.INTERNAL) | |
}, | |
init: function(t) { | |
t = t || Object.create(null), | |
this._files.clear(), | |
this._parsed.clear(), | |
this._releaseManager.init(), | |
this.assets.clear(), | |
this.bundles.clear(), | |
this.packManager.init(), | |
this.downloader.init(t.bundleVers, t.server), | |
this.parser.init(), | |
this.dependUtil.init(), | |
this.generalImportBase = t.importBase, | |
this.generalNativeBase = t.nativeBase | |
}, | |
getBundle: function(t) { | |
return P.get(t) | |
}, | |
removeBundle: function(t) { | |
t._destroy(), | |
P.remove(t.name) | |
}, | |
loadAny: function(t, e, i, n) { | |
var r = A(e, i, n); | |
e = r.options, | |
i = r.onProgress, | |
n = r.onComplete, | |
e.preset = e.preset || "default", | |
i = i || this._onProgress, | |
t = Array.isArray(t) ? t.concat() : t; | |
var s = new h({ | |
input: t, | |
onProgress: i, | |
onComplete: x(n), | |
options: e | |
}); | |
w.async(s) | |
}, | |
preloadAny: function(t, e, i, n) { | |
var r = A(e, i, n); | |
e = r.options, | |
i = r.onProgress, | |
n = r.onComplete, | |
e.preset = e.preset || "preload", | |
i = i || this._onProgress, | |
t = Array.isArray(t) ? t.concat() : t; | |
var s = new h({ | |
input: t, | |
onProgress: i, | |
onComplete: x(n), | |
options: e | |
}); | |
O.async(s) | |
}, | |
postLoadNative: function(t, e, i) { | |
if (!(t instanceof cc.Asset)) | |
throw Error("input is not asset"); | |
var n = A(e, void 0, i); | |
if (e = n.options, | |
i = n.onComplete, | |
!t._native || t._nativeAsset) | |
return x(i)(null); | |
var r = o.getNativeDep(t._uuid); | |
if (r) { | |
if (!P.has(r.bundle)) { | |
var s = P.find((function(e) { | |
return e.getAssetInfo(t._uuid) | |
} | |
)); | |
s && (r.bundle = s.name) | |
} | |
this.loadAny(r, e, (function(e, n) { | |
e || t.isValid && !t._nativeAsset && (t._nativeAsset = n), | |
i && i(e) | |
} | |
)) | |
} | |
}, | |
loadRemote: function(t, e, i) { | |
var n = A(e, void 0, i); | |
if (e = n.options, | |
i = n.onComplete, | |
this.assets.has(t)) | |
return x(i)(null, this.assets.get(t)); | |
e.__isNative__ = !0, | |
e.preset = e.preset || "remote", | |
this.loadAny({ | |
url: t | |
}, e, null, (function(n, r) { | |
n ? i && i(n, null) : g.create(t, r, e.ext || cc.path.extname(t), e, (function(t, e) { | |
i && i(t, e) | |
} | |
)) | |
} | |
)) | |
}, | |
loadScript: function(t, e, i) { | |
var n = A(e, void 0, i); | |
e = n.options, | |
i = n.onComplete, | |
e.__requestType__ = L.URL, | |
e.preset = e.preset || "script", | |
this.loadAny(t, e, i) | |
}, | |
loadBundle: function(t, e, i) { | |
var n = A(e, void 0, i) | |
, r = (e = n.options, | |
i = n.onComplete, | |
cc.path.basename(t)); | |
if (this.bundles.has(r)) | |
return x(i)(null, this.getBundle(r)); | |
e.preset = e.preset || "bundle", | |
e.ext = "bundle", | |
this.loadRemote(t, e, i) | |
}, | |
releaseAsset: function(t) { | |
a.tryRelease(t, !0) | |
}, | |
releaseUnusedAssets: function() { | |
S.forEach((function(t) { | |
a.tryRelease(t) | |
} | |
)) | |
}, | |
releaseAll: function() { | |
S.forEach((function(t) { | |
a.tryRelease(t, !0) | |
} | |
)) | |
}, | |
_transform: function(t, e) { | |
var i = h.create({ | |
input: t, | |
options: e | |
}) | |
, n = []; | |
try { | |
for (var r = I.sync(i), s = 0, a = r.length; s < a; s++) { | |
var o = r[s] | |
, c = o.url; | |
o.recycle(), | |
n.push(c) | |
} | |
} catch (l) { | |
for (s = 0, | |
a = i.output.length; s < a; s++) | |
i.output[s].recycle() | |
} | |
return i.recycle(), | |
n.length > 1 ? n : n[0] | |
} | |
}, | |
cc.AssetManager = N, | |
cc.assetManager = new N, | |
Object.defineProperty(cc, "resources", { | |
get: function() { | |
return P.get(D.RESOURCES) | |
} | |
}), | |
e.exports = cc.assetManager | |
} | |
), { | |
"./builtins": 31, | |
"./bundle": 32, | |
"./cache": 33, | |
"./depend-util": 35, | |
"./downloader": 40, | |
"./factory": 41, | |
"./fetch": 42, | |
"./helper": 44, | |
"./load": 46, | |
"./pack-manager": 47, | |
"./parser": 48, | |
"./pipeline": 49, | |
"./preprocess": 50, | |
"./releaseManager": 51, | |
"./request-item": 52, | |
"./shared": 53, | |
"./task": 54, | |
"./urlTransformer": 55, | |
"./utilities": 56 | |
}], | |
31: [(function(t, e) { | |
"use strict"; | |
var i = t("./cache") | |
, n = t("./releaseManager") | |
, r = t("./shared").BuiltinBundleName | |
, s = { | |
_assets: new i({ | |
material: new i, | |
effect: new i | |
}), | |
_loadBuiltins: function(t, e) { | |
var i = t + "s" | |
, n = this._assets.get(t); | |
return cc.assetManager.internal.loadDir(i, null, null, (function(t, i) { | |
if (t) | |
e(t); | |
else { | |
for (var r = 0; r < i.length; r++) { | |
var s = i[r]; | |
n.add(s.name, s.addRef()) | |
} | |
e() | |
} | |
} | |
)) | |
}, | |
init: function(t) { | |
var e = this; | |
if (this.clear(), | |
cc.game.renderType === cc.game.RENDER_TYPE_CANVAS || !cc.assetManager.bundles.has(r.INTERNAL)) | |
return t && t(); | |
this._loadBuiltins("effect", (function(i) { | |
i ? t && t(i) : e._loadBuiltins("material", t) | |
} | |
)) | |
}, | |
getBuiltin: function(t, e) { | |
return 0 === arguments.length ? this._assets : 1 === arguments.length ? this._assets.get(t) : this._assets.get(t).get(e) | |
}, | |
clear: function() { | |
this._assets.forEach((function(t) { | |
t.forEach((function(t) { | |
n.tryRelease(t, !0) | |
} | |
)), | |
t.clear() | |
} | |
)) | |
} | |
}; | |
e.exports = s | |
} | |
), { | |
"./cache": 33, | |
"./releaseManager": 51, | |
"./shared": 53 | |
}], | |
32: [(function(t, e) { | |
"use strict"; | |
var i = t("./config") | |
, n = t("./releaseManager") | |
, r = t("./utilities") | |
, s = r.parseParameters | |
, a = r.parseLoadResArgs | |
, o = t("./shared") | |
, c = o.RequestType | |
, l = o.assets | |
, h = o.bundles; | |
function u() { | |
this._config = new i | |
} | |
u.prototype = { | |
constructor: u, | |
get name() { | |
return this._config.name | |
}, | |
get deps() { | |
return this._config.deps | |
}, | |
get base() { | |
return this._config.base | |
}, | |
getInfoWithPath: function(t, e) { | |
return this._config.getInfoWithPath(t, e) | |
}, | |
getDirWithPath: function(t, e, i) { | |
return this._config.getDirWithPath(t, e, i) | |
}, | |
getAssetInfo: function(t) { | |
return this._config.getAssetInfo(t) | |
}, | |
getSceneInfo: function(t) { | |
return this._config.getSceneInfo(t) | |
}, | |
init: function(t) { | |
this._config.init(t), | |
h.add(t.name, this) | |
}, | |
load: function(t, e, i, n) { | |
var r = a(e, i, n); | |
e = r.type, | |
i = r.onProgress, | |
n = r.onComplete, | |
cc.assetManager.loadAny(t, { | |
__requestType__: c.PATH, | |
type: e, | |
bundle: this.name, | |
__outputAsArray__: Array.isArray(t) | |
}, i, n) | |
}, | |
preload: function(t, e, i, n) { | |
var r = a(e, i, n); | |
e = r.type, | |
i = r.onProgress, | |
n = r.onComplete, | |
cc.assetManager.preloadAny(t, { | |
__requestType__: c.PATH, | |
type: e, | |
bundle: this.name | |
}, i, n) | |
}, | |
loadDir: function(t, e, i, n) { | |
var r = a(e, i, n); | |
e = r.type, | |
i = r.onProgress, | |
n = r.onComplete, | |
cc.assetManager.loadAny(t, { | |
__requestType__: c.DIR, | |
type: e, | |
bundle: this.name, | |
__outputAsArray__: !0 | |
}, i, n) | |
}, | |
preloadDir: function(t, e, i, n) { | |
var r = a(e, i, n); | |
e = r.type, | |
i = r.onProgress, | |
n = r.onComplete, | |
cc.assetManager.preloadAny(t, { | |
__requestType__: c.DIR, | |
type: e, | |
bundle: this.name | |
}, i, n) | |
}, | |
loadScene: function(t, e, i, n) { | |
var r = s(e, i, n); | |
e = r.options, | |
i = r.onProgress, | |
n = r.onComplete, | |
e.preset = e.preset || "scene", | |
e.bundle = this.name, | |
cc.assetManager.loadAny({ | |
scene: t | |
}, e, i, (function(t, e) { | |
if (t) | |
n && n(t); | |
else if (e instanceof cc.SceneAsset) { | |
var i = e.scene; | |
i._id = e._uuid, | |
i._name = e._name, | |
n && n(null, e) | |
} else | |
n && n(Error("The asset " + e._uuid + " is not a scene")) | |
} | |
)) | |
}, | |
preloadScene: function(t, e, i, n) { | |
var r = s(e, i, n); | |
e = r.options, | |
i = r.onProgress, | |
n = r.onComplete, | |
e.bundle = this.name, | |
cc.assetManager.preloadAny({ | |
scene: t | |
}, e, i, (function(t) { | |
n && n(t) | |
} | |
)) | |
}, | |
get: function(t, e) { | |
var i = this.getInfoWithPath(t, e); | |
return l.get(i && i.uuid) | |
}, | |
release: function(t, e) { | |
n.tryRelease(this.get(t, e), !0) | |
}, | |
releaseUnusedAssets: function() { | |
var t = this; | |
l.forEach((function(e) { | |
var i = t.getAssetInfo(e._uuid); | |
i && !i.redirect && n.tryRelease(e) | |
} | |
)) | |
}, | |
releaseAll: function() { | |
var t = this; | |
l.forEach((function(e) { | |
var i = t.getAssetInfo(e._uuid); | |
i && !i.redirect && n.tryRelease(e, !0) | |
} | |
)) | |
}, | |
_destroy: function() { | |
this._config.destroy() | |
} | |
}, | |
e.exports = u | |
} | |
), { | |
"./config": 34, | |
"./releaseManager": 51, | |
"./shared": 53, | |
"./utilities": 56 | |
}], | |
33: [(function(t, e) { | |
"use strict"; | |
var i = t("../platform/js"); | |
function n(t) { | |
t ? (this._map = t, | |
this._count = Object.keys(t).length) : (this._map = i.createMap(!0), | |
this._count = 0) | |
} | |
n.prototype = { | |
constructor: n, | |
add: function(t, e) { | |
return t in this._map || this._count++, | |
this._map[t] = e | |
}, | |
get: function(t) { | |
return this._map[t] | |
}, | |
has: function(t) { | |
return t in this._map | |
}, | |
remove: function(t) { | |
var e = this._map[t]; | |
return t in this._map && (delete this._map[t], | |
this._count--), | |
e | |
}, | |
clear: function() { | |
0 !== this._count && (this._map = i.createMap(!0), | |
this._count = 0) | |
}, | |
forEach: function(t) { | |
for (var e in this._map) | |
t(this._map[e], e) | |
}, | |
find: function(t) { | |
for (var e in this._map) | |
if (t(this._map[e], e)) | |
return this._map[e]; | |
return null | |
}, | |
get count() { | |
return this._count | |
}, | |
destroy: function() { | |
this._map = null | |
} | |
}, | |
e.exports = n | |
} | |
), { | |
"../platform/js": 183 | |
}], | |
34: [(function(t, e) { | |
"use strict"; | |
var i = t("../platform/js") | |
, n = t("./cache") | |
, r = t("./helper").normalize | |
, s = t("./utilities").processOptions; | |
function a() { | |
this.name = "", | |
this.base = "", | |
this.importBase = "", | |
this.nativeBase = "", | |
this.deps = null, | |
this.assetInfos = new n, | |
this.scenes = new n, | |
this.paths = new n | |
} | |
a.prototype = { | |
constructor: a, | |
init: function(t) { | |
s(t), | |
this.importBase = t.importBase || "", | |
this.nativeBase = t.nativeBase || "", | |
this.base = t.base || "", | |
this.name = t.name || "", | |
this.deps = t.deps || [], | |
this._initUuid(t.uuids), | |
this._initPath(t.paths), | |
this._initScene(t.scenes), | |
this._initPackage(t.packs), | |
this._initVersion(t.versions), | |
this._initRedirect(t.redirect) | |
}, | |
_initUuid: function(t) { | |
if (t) { | |
this.assetInfos.clear(); | |
for (var e = 0, i = t.length; e < i; e++) { | |
var n = t[e]; | |
this.assetInfos.add(n, { | |
uuid: n | |
}) | |
} | |
} | |
}, | |
_initPath: function(t) { | |
if (t) { | |
var e = this.paths; | |
for (var n in e.clear(), | |
t) { | |
var r = t[n] | |
, s = r[0] | |
, a = r[1] | |
, o = 3 === r.length | |
, c = this.assetInfos.get(n); | |
c.path = s, | |
c.ctor = i._getClassById(a), | |
e.has(s) ? o ? e.get(s).push(c) : e.get(s).unshift(c) : e.add(s, [c]) | |
} | |
} | |
}, | |
_initScene: function(t) { | |
if (t) { | |
var e = this.scenes; | |
e.clear(); | |
var i = this.assetInfos; | |
for (var n in t) { | |
var r = t[n] | |
, s = i.get(r); | |
s.url = n, | |
e.add(n, s) | |
} | |
} | |
}, | |
_initPackage: function(t) { | |
if (t) { | |
var e = this.assetInfos; | |
for (var i in t) { | |
var n = t[i] | |
, r = { | |
uuid: i, | |
packs: n, | |
ext: ".json" | |
}; | |
e.add(i, r); | |
for (var s = 0, a = n.length; s < a; s++) { | |
var o = n[s] | |
, c = e.get(o) | |
, l = c.packs; | |
l ? 1 === a ? l.unshift(r) : l.push(r) : c.packs = [r] | |
} | |
} | |
} | |
}, | |
_initVersion: function(t) { | |
if (t) { | |
var e = this.assetInfos | |
, i = t.import; | |
if (i) | |
for (var n = 0, r = i.length; n < r; n += 2) { | |
var s = i[n]; | |
e.get(s).ver = i[n + 1] | |
} | |
if (i = t.native) | |
for (n = 0, | |
r = i.length; n < r; n += 2) | |
s = i[n], | |
e.get(s).nativeVer = i[n + 1] | |
} | |
}, | |
_initRedirect: function(t) { | |
if (t) | |
for (var e = this.assetInfos, i = 0, n = t.length; i < n; i += 2) { | |
var r = t[i]; | |
e.get(r).redirect = t[i + 1] | |
} | |
}, | |
getInfoWithPath: function(t, e) { | |
if (!t) | |
return null; | |
t = r(t); | |
var n = this.paths.get(t); | |
if (n) { | |
if (!e) | |
return n[0]; | |
for (var s = 0, a = n.length; s < a; s++) { | |
var o = n[s]; | |
if (i.isChildClassOf(o.ctor, e)) | |
return o | |
} | |
} | |
return null | |
}, | |
getDirWithPath: function(t, e, n) { | |
"/" === (t = r(t))[t.length - 1] && (t = t.slice(0, -1)); | |
var s = n || []; | |
function a(t, e) { | |
return !(t.length > e.length) || 47 === t.charCodeAt(e.length) | |
} | |
return this.paths.forEach((function(n, r) { | |
if (r.startsWith(t) && a(r, t) || !t) | |
for (var o = 0, c = n.length; o < c; o++) { | |
var l = n[o]; | |
e && !i.isChildClassOf(l.ctor, e) || s.push(l) | |
} | |
} | |
)), | |
s | |
}, | |
getAssetInfo: function(t) { | |
return this.assetInfos.get(t) | |
}, | |
getSceneInfo: function(t) { | |
return t.endsWith(".fire") || (t += ".fire"), | |
"/" === t[0] || t.startsWith("db://") || (t = "/" + t), | |
this.scenes.find((function(e, i) { | |
return i.endsWith(t) | |
} | |
)) | |
}, | |
destroy: function() { | |
this.paths.destroy(), | |
this.scenes.destroy(), | |
this.assetInfos.destroy() | |
} | |
}, | |
e.exports = a | |
} | |
), { | |
"../platform/js": 183, | |
"./cache": 33, | |
"./helper": 44, | |
"./utilities": 56 | |
}], | |
35: [(function(t, e) { | |
"use strict"; | |
var i = (function(t) { | |
if (t && t.__esModule) | |
return t; | |
if (null === t || "object" != typeof t && "function" != typeof t) | |
return { | |
default: t | |
}; | |
var e = n(void 0); | |
if (e && e.has(t)) | |
return e.get(t); | |
var i = {} | |
, r = Object.defineProperty && Object.getOwnPropertyDescriptor; | |
for (var s in t) | |
if ("default" !== s && Object.prototype.hasOwnProperty.call(t, s)) { | |
var a = r ? Object.getOwnPropertyDescriptor(t, s) : null; | |
a && (a.get || a.set) ? Object.defineProperty(i, s, a) : i[s] = t[s] | |
} | |
return i.default = t, | |
e && e.set(t, i), | |
i | |
} | |
)(t("../platform/deserialize-compiled")); | |
function n(t) { | |
if ("function" != typeof WeakMap) | |
return null; | |
var e = new WeakMap | |
, i = new WeakMap; | |
return (n = function(t) { | |
return t ? i : e | |
} | |
)(t) | |
} | |
var r = t("./cache") | |
, s = t("./deserialize") | |
, a = t("./shared") | |
, o = a.files | |
, c = a.parsed | |
, l = { | |
_depends: new r, | |
init: function() { | |
this._depends.clear() | |
}, | |
getNativeDep: function(t) { | |
var e = this._depends.get(t); | |
return e ? e.nativeDep && Object.assign({}, e.nativeDep) : null | |
}, | |
getDeps: function(t) { | |
return this._depends.has(t) ? this._depends.get(t).deps : [] | |
}, | |
getDepsRecursively: function(t) { | |
var e = Object.create(null) | |
, i = []; | |
return this._descend(t, e, i), | |
i | |
}, | |
_descend: function(t, e, i) { | |
for (var n = this.getDeps(t), r = 0; r < n.length; r++) { | |
var s = n[r]; | |
e[s] || (e[s] = !0, | |
i.push(s), | |
this._descend(s, e, i)) | |
} | |
}, | |
remove: function(t) { | |
this._depends.remove(t) | |
}, | |
parse: function(t, e) { | |
var n = null; | |
if (Array.isArray(e) || e.__type__) { | |
if (n = this._depends.get(t)) | |
return n; | |
if (Array.isArray(e) && !(0, | |
i.hasNativeDep)(e)) | |
n = { | |
deps: this._parseDepsFromJson(e) | |
}; | |
else | |
try { | |
var r = s(e); | |
(n = this._parseDepsFromAsset(r)).nativeDep && (n.nativeDep.uuid = t), | |
c.add(t + "@import", r) | |
} catch (a) { | |
o.remove(t + "@import"), | |
n = { | |
deps: [] | |
} | |
} | |
} else { | |
if ((n = this._depends.get(t)) && n.parsedFromExistAsset) | |
return n; | |
n = this._parseDepsFromAsset(e) | |
} | |
return this._depends.add(t, n), | |
n | |
}, | |
_parseDepsFromAsset: function(t) { | |
for (var e = { | |
deps: [], | |
parsedFromExistAsset: !0, | |
preventPreloadNativeObject: t.constructor.preventPreloadNativeObject, | |
preventDeferredLoadDependents: t.constructor.preventDeferredLoadDependents | |
}, i = t.__depends__, n = 0, r = i.length; n < r; n++) { | |
var s = i[n].uuid; | |
e.deps.push(s) | |
} | |
return t.__nativeDepend__ && (e.nativeDep = t._nativeDep), | |
e | |
}, | |
_parseDepsFromJson: function(t) { | |
var e = (0, | |
i.getDependUuidList)(t); | |
return e.forEach((function(t, i) { | |
return e[i] = cc.assetManager.utils.decodeUuid(t) | |
} | |
)), | |
e | |
} | |
}; | |
e.exports = l | |
} | |
), { | |
"../platform/deserialize-compiled": 177, | |
"./cache": 33, | |
"./deserialize": 36, | |
"./shared": 53 | |
}], | |
36: [(function(t, e) { | |
"use strict"; | |
var i = t("./helper"); | |
t("../platform/deserialize"), | |
e.exports = function(t, e) { | |
var n; | |
n = cc._MissingScript.safeFindClass; | |
var r, s = null, a = (s = cc.deserialize.Details.pool).get(); | |
try { | |
r = cc.deserialize(t, a, { | |
classFinder: n, | |
customEnv: e | |
}) | |
} catch (d) { | |
throw s.put(a), | |
d | |
} | |
for (var o = a.uuidList, c = a.uuidObjList, l = a.uuidPropList, h = [], u = 0; u < o.length; u++) { | |
var f = o[u]; | |
h[u] = { | |
uuid: i.decodeUuid(f), | |
owner: c[u], | |
prop: l[u] | |
} | |
} | |
return r.__depends__ = h, | |
r._native && (r.__nativeDepend__ = !0), | |
s.put(a), | |
r | |
} | |
} | |
), { | |
"../platform/deserialize": 178, | |
"../platform/deserialize-compiled": 177, | |
"../platform/deserialize-editor": void 0, | |
"./helper": 44 | |
}], | |
37: [(function(t, e) { | |
"use strict"; | |
var i = t("./utilities").parseParameters | |
, n = t("./download-file").downloadFile; | |
e.exports = function(t, e, r) { | |
var s = i(e, void 0, r) | |
, a = s.options | |
, o = s.onComplete; | |
a.responseType = "blobURL", | |
n(t, a, (function(e, i) { | |
if (e) | |
o && o(e); | |
else { | |
var n = new Image; | |
n.addEventListener("load", r), | |
n.addEventListener("error", s), | |
n.src = i | |
} | |
function r() { | |
n.removeEventListener("load", r), | |
n.removeEventListener("error", s), | |
URL.revokeObjectURL(i), | |
o && o(null, n) | |
} | |
function s() { | |
n.removeEventListener("load", r), | |
n.removeEventListener("error", s), | |
URL.revokeObjectURL(i), | |
o && o(Error(cc.debug.getError(4930, t))) | |
} | |
} | |
)) | |
} | |
} | |
), { | |
"./download-file": 38, | |
"./utilities": 56 | |
}], | |
38: [(function(t, e) { | |
"use strict"; | |
var i = t("./utilities").parseParameters | |
, n = "undefined" == typeof window ? global : window | |
, r = n.shell || Object.create(null) | |
, s = r.fetch || n.fetch | |
, a = r.fetchBlobURL || function(t, e) { | |
return s(t, e).then((function(t) { | |
if (!t.ok) | |
throw t.status; | |
return t.blob().then((function(t) { | |
return URL.createObjectURL(t) | |
} | |
)) | |
} | |
)) | |
} | |
, o = r.unregisterBlobURL || function() { | |
return null | |
} | |
, c = function(t) { | |
return r.authenticate ? r.authenticate(t) : t | |
}; | |
cc.setAuthenticateUrl = function(t) { | |
c = t | |
} | |
; | |
var l = (function() { | |
function t() { | |
this._aborted = !1 | |
} | |
var e = t.prototype; | |
return e.abort = function() { | |
this._aborted = !0 | |
} | |
, | |
e.isAborted = function() { | |
return this._aborted | |
} | |
, | |
t | |
} | |
)(); | |
function h(t, e) { | |
var i = +t.headers.get("Content-Length"); | |
if (!Number.isInteger(i)) | |
return t; | |
var n = t.body.getReader() | |
, r = 0 | |
, s = []; | |
return n.read().then((function a(o) { | |
return o.done ? new Response(new Blob(s,{ | |
type: t.headers.get("Content-Type") | |
}),{ | |
status: t.status | |
}) : (r += o.value.length, | |
s.push(o.value), | |
e(r, i), | |
n.read().then(a)) | |
} | |
)) | |
} | |
function u(t) { | |
var e = Object.create(null); | |
return !0 === t.withCredentials ? e.credentials = "include" : !1 === t.withCredentials && (e.credentials = "omit"), | |
t.header && (e.headers = t.header), | |
e | |
} | |
function f(t, e, i) { | |
var n = u(e) | |
, r = new l; | |
return a(t, n).then((function(e) { | |
if (r.isAborted()) | |
throw [4928, t + "(abort)"]; | |
var n = i; | |
i = null, | |
n(null, e) | |
} | |
)).catch((function(e) { | |
i && (Array.isArray(e) || (e = [4928, t + "(error)"]), | |
r.isAborted() && (e[1] = "(abort)"), | |
i(Error(cc.debug.getError(e[0], e[1])))) | |
} | |
)), | |
r | |
} | |
function d(t, e, i, n) { | |
var r = void 0 !== e.responseType ? e.responseType : "text" | |
, a = u(e) | |
, o = new l; | |
return s(t, a).then((function(e) { | |
if (o.isAborted()) | |
throw [4928, t + "(abort)"]; | |
if (!e.ok) | |
throw [4928, t + "(wrong status)"]; | |
return i ? h(e, i) : e | |
} | |
)).then((function(e) { | |
if (o.isAborted()) | |
throw [4928, t + "(abort)"]; | |
var i; | |
switch (r) { | |
case "json": | |
i = e.json(); | |
break; | |
case "arraybuffer": | |
i = e.arrayBuffer(); | |
break; | |
case "blob": | |
i = e.blob(); | |
break; | |
default: | |
i = e.text() | |
} | |
return i.then((function(e) { | |
if (o.isAborted()) | |
throw [4928, t + "(abort)"]; | |
var i = n; | |
n = null, | |
i(null, e) | |
} | |
)) | |
} | |
)).catch((function(e) { | |
n && (Array.isArray(e) || (e = [4928, t + "(error)"]), | |
n(Error(cc.debug.getError(e[0]), e[1]))) | |
} | |
)), | |
o | |
} | |
e.exports = { | |
downloadFile: function(t, e, n, r) { | |
var s = i(e, n, r) | |
, a = s.options | |
, o = s.onProgress | |
, l = s.onComplete | |
, h = c(t); | |
return "blobURL" === a.responseType ? f(h, a, l) : d(h, a, o, l) | |
}, | |
unregisterBlobURL: o | |
} | |
} | |
), { | |
"./utilities": 56 | |
}], | |
39: [(function(t, e) { | |
"use strict"; | |
var i = t("./utilities").parseParameters | |
, n = t("./download-file") | |
, r = n.downloadFile | |
, s = n.unregisterBlobURL | |
, a = {}; | |
e.exports = function(t, e, n) { | |
var o = i(e, void 0, n); | |
if (e = o.options, | |
n = o.onComplete, | |
a[t]) | |
return n && n(null); | |
e.responseType = "blobURL", | |
r(t, e, (function(e, i) { | |
if (e) | |
return n && n(e); | |
var r = document.createElement("script"); | |
r.async = !0, | |
r.src = i, | |
r.addEventListener("load", (function() { | |
document.head.removeChild(r), | |
URL.revokeObjectURL(i), | |
a[t] = !0, | |
n && n(null) | |
} | |
), !1), | |
r.addEventListener("error", (function() { | |
document.head.removeChild(r), | |
URL.revokeObjectURL(i), | |
s(i), | |
n && n(Error(cc.debug.getError(4928, t))) | |
} | |
), !1), | |
document.head.appendChild(r) | |
} | |
)) | |
} | |
} | |
), { | |
"./download-file": 38, | |
"./utilities": 56 | |
}], | |
40: [(function(t, e) { | |
"use strict"; | |
function i() { | |
return (i = Object.assign || function(t) { | |
for (var e = 1; e < arguments.length; e++) { | |
var i = arguments[e]; | |
for (var n in i) | |
Object.prototype.hasOwnProperty.call(i, n) && (t[n] = i[n]) | |
} | |
return t | |
} | |
).apply(this, arguments) | |
} | |
var n = t("../platform/js") | |
, r = t("../CCDebug") | |
, s = t("./font-loader").loadFont | |
, a = t("../platform/utils").callInNextTick | |
, o = t("./download-dom-image") | |
, c = t("./download-file").downloadFile | |
, l = t("./download-script.js") | |
, h = t("./cache") | |
, u = t("./shared").files | |
, f = t("../platform/CCSys") | |
, d = f.__audioSupport | |
, _ = f.capabilities | |
, p = t("./utilities").retry | |
, v = /^(?:\w+:\/\/|\.+\/).+/ | |
, g = d.format || [] | |
, m = function(t, e, i) { | |
i(Error(r.getError(4927))) | |
} | |
, y = function(t, e, i) { | |
g.length > 0 ? x(t, e, i) : m(0, 0, i) | |
} | |
, T = function() { | |
var t = _.imageBitmap && cc.macro.ALLOW_IMAGE_BITMAP ? E : o; | |
t.apply(this, arguments) | |
} | |
, E = function(t, e, i) { | |
e.responseType = "blob", | |
c(t, e, e.onFileProgress, i) | |
} | |
, A = function(t, e, i) { | |
e.responseType = "json", | |
c(t, e, e.onFileProgress, (function(t, e) { | |
if (!t && "string" == typeof e) | |
try { | |
e = JSON.parse(e) | |
} catch (n) { | |
t = n | |
} | |
i && i(t, e) | |
} | |
)) | |
} | |
, x = function(t, e, i) { | |
e.responseType = "arraybuffer", | |
c(t, e, e.onFileProgress, i) | |
} | |
, C = function(t, e, i) { | |
e.responseType = "text", | |
c(t, e, e.onFileProgress, i) | |
} | |
, b = function(t, e, i) { | |
i(null, t) | |
} | |
, S = new h | |
, R = [] | |
, M = !1 | |
, w = 0 | |
, I = 0 | |
, O = -1 | |
, L = !1 | |
, P = function() { | |
var t = Date.now() | |
, e = cc.director._deltaTime > N._maxInterval ? N._maxInterval : cc.director._deltaTime; | |
t - O > 1e3 * e && (I = 0, | |
O = t) | |
} | |
, D = function t(e, i) { | |
for (L = !1, | |
P(); R.length > 0 && w < e && I < i; ) { | |
M && (R.sort((function(t, e) { | |
return t.priority - e.priority | |
} | |
)), | |
M = !1); | |
var n = R.pop(); | |
if (!n) | |
break; | |
w++, | |
I++, | |
n.invoke() | |
} | |
R.length > 0 && w < e && (a(t, e, i), | |
L = !0) | |
} | |
, N = { | |
_remoteServerAddress: "", | |
_maxInterval: 1 / 30, | |
get remoteServerAddress() { | |
return this._remoteServerAddress | |
}, | |
maxConcurrency: 6, | |
maxRequestsPerFrame: 6, | |
maxRetryCount: 3, | |
limited: !0, | |
retryInterval: 2e3, | |
bundleVers: null, | |
downloadFile: c, | |
downloadScript: l, | |
init: function(t, e) { | |
S.clear(), | |
R.length = 0, | |
this._remoteServerAddress = e || "", | |
this._remoteServerAddress && !this._remoteServerAddress.endsWith("/") && (this._remoteServerAddress += "/"), | |
this.bundleVers = t || Object.create(null) | |
}, | |
register: function(t, e) { | |
"object" == typeof t ? n.mixin(F, t) : F[t] = e | |
}, | |
download: function(t, e, n, r, s) { | |
var o = F[n] || F.default; | |
r = i({ | |
remoteServerAddress: this.remoteServerAddress | |
}, r); | |
var c, l, h = this; | |
if (c = u.get(t)) | |
s(null, c); | |
else if (l = S.get(t)) { | |
l.push(s); | |
for (var f = 0, d = R.length; f < d; f++) { | |
var _ = R[f]; | |
if (_.id === t) { | |
var v = r.priority || 0; | |
return void (_.priority < v && (_.priority = v, | |
M = !0)) | |
} | |
} | |
} else { | |
var g = void 0 !== r.maxRetryCount ? r.maxRetryCount : this.maxRetryCount | |
, m = void 0 !== r.maxConcurrency ? r.maxConcurrency : this.maxConcurrency | |
, y = void 0 !== r.maxRequestsPerFrame ? r.maxRequestsPerFrame : this.maxRequestsPerFrame; | |
p((function(i, n) { | |
if (0 === i && S.add(t, [s]), | |
!h.limited) | |
return o(e, r, n); | |
function c() { | |
o(e, r, (function() { | |
w--, | |
!L && R.length > 0 && (a(D, m, y), | |
L = !0), | |
n.apply(this, arguments) | |
} | |
)) | |
} | |
P(), | |
w < m && I < y ? (c(), | |
w++, | |
I++) : (R.push({ | |
id: t, | |
priority: r.priority || 0, | |
invoke: c | |
}), | |
M = !0, | |
!L && w < m && (a(D, m, y), | |
L = !0)) | |
} | |
), g, this.retryInterval, (function(e, i) { | |
e || u.add(t, i); | |
for (var n = S.remove(t), r = 0, s = n.length; r < s; r++) | |
n[r](e, i) | |
} | |
)) | |
} | |
} | |
} | |
, F = { | |
".png": T, | |
".jpg": T, | |
".bmp": T, | |
".jpeg": T, | |
".gif": T, | |
".ico": T, | |
".tiff": T, | |
".webp": T, | |
".image": T, | |
".pvr": x, | |
".pkm": x, | |
".mp3": y, | |
".ogg": y, | |
".wav": y, | |
".m4a": y, | |
".txt": C, | |
".xml": C, | |
".vsh": C, | |
".fsh": C, | |
".atlas": C, | |
".tmx": C, | |
".tsx": C, | |
".json": A, | |
".ExportJson": A, | |
".plist": C, | |
".fnt": C, | |
".font": s, | |
".eot": s, | |
".ttf": s, | |
".woff": s, | |
".svg": s, | |
".ttc": s, | |
".mp4": b, | |
".avi": b, | |
".mov": b, | |
".mpg": b, | |
".mpeg": b, | |
".rm": b, | |
".rmvb": b, | |
".binary": x, | |
".bin": x, | |
".dbbin": x, | |
".skel": x, | |
".js": l, | |
bundle: function(t, e, i) { | |
var n = cc.path.basename(t) | |
, r = t; | |
v.test(r) || (r = e.remoteServerAddress ? e.remoteServerAddress + "assets/" + n : "assets/" + n); | |
var s, a, o = e.version || N.bundleVers[n], c = 0; | |
"string" == typeof o ? s = a = o : o && (s = o.config, | |
a = o.index); | |
var h = null | |
, u = null; | |
A(r + "/config." + (s ? s + "." : "") + "json", e, (function(t, e) { | |
t && (u = t), | |
(h = e) && (h.base = r + "/"), | |
2 == ++c && i(u, h) | |
} | |
)), | |
l(r + "/index." + (a ? a + "." : "") + "js", e, (function(t) { | |
t && (u = t), | |
2 == ++c && i(u, h) | |
} | |
)) | |
}, | |
default: C | |
}; | |
N._downloaders = F, | |
e.exports = N | |
} | |
), { | |
"../CCDebug": 23, | |
"../platform/CCSys": 171, | |
"../platform/js": 183, | |
"../platform/utils": 186, | |
"./cache": 33, | |
"./download-dom-image": 37, | |
"./download-file": 38, | |
"./download-script.js": 39, | |
"./font-loader": 43, | |
"./shared": 53, | |
"./utilities": 56 | |
}], | |
41: [(function(t, e) { | |
"use strict"; | |
var i = t("./bundle") | |
, n = t("./cache") | |
, r = t("./shared") | |
, s = r.assets | |
, a = r.bundles | |
, o = new n; | |
function c(t, e, i, n) { | |
var r = null | |
, s = null; | |
try { | |
(r = new cc.Texture2D)._nativeUrl = t, | |
r._nativeAsset = e | |
} catch (a) { | |
s = a | |
} | |
n && n(s, r) | |
} | |
function l(t, e, i, n) { | |
var r = new cc.AudioClip; | |
r._nativeUrl = t, | |
r._nativeAsset = e, | |
r.duration = e.duration, | |
n && n(null, r) | |
} | |
function h(t, e, i, n) { | |
var r = new cc.VideoClip; | |
r._nativeUrl = t, | |
r._nativeAsset = e, | |
n && n(null, r) | |
} | |
function u(t, e, i, n) { | |
var r = new cc.JsonAsset; | |
r.json = e, | |
n && n(null, r) | |
} | |
function f(t, e, i, n) { | |
var r = new cc.TextAsset; | |
r.text = e, | |
n && n(null, r) | |
} | |
function d(t, e, i, n) { | |
var r = new cc.TTFFont; | |
r._nativeUrl = t, | |
r._nativeAsset = e, | |
n && n(null, r) | |
} | |
function _(t, e, i, n) { | |
var r = new cc.BufferAsset; | |
r._nativeUrl = t, | |
r._nativeAsset = e, | |
n && n(null, r) | |
} | |
var p = { | |
register: function(t, e) { | |
"object" == typeof t ? cc.js.mixin(v, t) : v[t] = e | |
}, | |
create: function(t, e, i, n, r) { | |
var a, c, l = v[i] || v.default; | |
(a = s.get(t)) ? r(null, a) : (c = o.get(t)) ? c.push(r) : (o.add(t, [r]), | |
l(t, e, n, (function(e, i) { | |
!e && i instanceof cc.Asset && (i._uuid = t, | |
s.add(t, i)); | |
for (var n = o.remove(t), r = 0, a = n.length; r < a; r++) | |
n[r](e, i) | |
} | |
))) | |
} | |
} | |
, v = { | |
".png": c, | |
".jpg": c, | |
".bmp": c, | |
".jpeg": c, | |
".gif": c, | |
".ico": c, | |
".tiff": c, | |
".webp": c, | |
".image": c, | |
".pvr": c, | |
".pkm": c, | |
".mp3": l, | |
".ogg": l, | |
".wav": l, | |
".m4a": l, | |
".mp4": h, | |
".avi": h, | |
".mov": h, | |
".mpg": h, | |
".mpeg": h, | |
".rm": h, | |
".rmvb": h, | |
".txt": f, | |
".xml": f, | |
".vsh": f, | |
".fsh": f, | |
".atlas": f, | |
".tmx": f, | |
".tsx": f, | |
".fnt": f, | |
".json": u, | |
".ExportJson": u, | |
".font": d, | |
".eot": d, | |
".ttf": d, | |
".woff": d, | |
".svg": d, | |
".ttc": d, | |
".binary": _, | |
".bin": _, | |
".dbbin": _, | |
".skel": _, | |
bundle: function(t, e, n, r) { | |
var s = a.get(e.name); | |
s || (s = new i, | |
e.base = e.base || t + "/", | |
s.init(e)), | |
r && r(null, s) | |
}, | |
default: function(t, e, i, n) { | |
var r = new cc.Asset; | |
r._nativeUrl = t, | |
r._nativeAsset = e, | |
n && n(null, r) | |
} | |
}; | |
e.exports = p | |
} | |
), { | |
"./bundle": 32, | |
"./cache": 33, | |
"./shared": 53 | |
}], | |
42: [(function(t, e) { | |
"use strict"; | |
var i = t("./pack-manager") | |
, n = t("./task") | |
, r = t("./utilities") | |
, s = r.getDepends | |
, a = r.clear | |
, o = r.forEach | |
, c = t("./shared") | |
, l = c.assets | |
, h = c.fetchPipeline; | |
function u(t) { | |
for (var e = t.output, i = 0, n = e.length; i < n; i++) | |
e[i].content && e[i].content.decRef(!1) | |
} | |
function f(t, e, i, n, r, a, o) { | |
var c = e.options.__exclude__ | |
, l = e.progress; | |
t.content = i, | |
t.file = n, | |
e.output.push(t), | |
r && (c[t.uuid] = !0, | |
s(t.uuid, n || i, c, a, !0, !1, t.config), | |
l.total = o + a.length), | |
l.canInvoke && e.dispatch("progress", ++l.finish, l.total, t) | |
} | |
e.exports = function(t, e) { | |
var r = !1; | |
t.progress || (t.progress = { | |
finish: 0, | |
total: t.input.length, | |
canInvoke: !0 | |
}, | |
r = !0); | |
var s = t.options | |
, c = [] | |
, d = t.progress | |
, _ = d.total; | |
s.__exclude__ = s.__exclude__ || Object.create(null), | |
t.output = [], | |
o(t.input, (function(n, s) { | |
if (!n.isNative && l.has(n.uuid)) { | |
var a = l.get(n.uuid); | |
return a.addRef(), | |
f(n, t, a, null, a.__asyncLoadAssets__, c, _), | |
s() | |
} | |
i.load(n, t.options, (function(i, a) { | |
i ? t.isFinish || (!cc.assetManager.force || r ? (d.canInvoke = !1, | |
e(i)) : f(n, t, null, null, !1, c, _)) : t.isFinish || f(n, t, null, a, !n.isNative, c, _), | |
s() | |
} | |
)) | |
} | |
), (function() { | |
if (t.isFinish) | |
return a(t, !0), | |
t.dispatch("error"); | |
if (c.length > 0) { | |
var i = n.create({ | |
name: t.name + " dependencies", | |
input: c, | |
progress: d, | |
options: s, | |
onProgress: t.onProgress, | |
onError: n.prototype.recycle, | |
onComplete: function(n) { | |
n || (t.output.push.apply(t.output, this.output), | |
i.recycle()), | |
r && u(t), | |
e(n) | |
} | |
}); | |
h.async(i) | |
} else | |
r && u(t), | |
e() | |
} | |
)) | |
} | |
} | |
), { | |
"./pack-manager": 47, | |
"./shared": 53, | |
"./task": 54, | |
"./utilities": 56 | |
}], | |
43: [(function(t, e) { | |
"use strict"; | |
var i, n = t("../utils/text-utils"), r = null, s = "BES bswy:->@123\u4e01\u3041\u1101", a = Object.create(null), o = -1, c = [], l = 3e3, h = (i = void 0, | |
function() { | |
if (void 0 === i) | |
if (window.FontFace) { | |
var t = /Gecko.*Firefox\/(\d+)/.exec(window.navigator.userAgent) | |
, e = /OS X.*Version\/10\..*Safari/.exec(window.navigator.userAgent) && /Apple/.exec(window.navigator.vendor); | |
i = t ? parseInt(t[1], 10) > 42 : !e | |
} else | |
i = !1; | |
return i | |
} | |
); | |
function u() { | |
for (var t = !0, e = Date.now(), i = c.length - 1; i >= 0; i--) { | |
var a = c[i] | |
, h = a.fontFamilyName; | |
if (e - a.startTime > l) | |
a.onComplete(null, h), | |
c.splice(i, 1); | |
else { | |
var u = a.refWidth | |
, f = "40px " + h; | |
r.font = f, | |
u !== n.safeMeasureText(r, s, f) ? (c.splice(i, 1), | |
a.onComplete(null, h)) : t = !1 | |
} | |
} | |
t && (clearInterval(o), | |
o = -1) | |
} | |
var f = { | |
loadFont: function(t, e, i) { | |
var d = f._getFontFamily(t); | |
if (a[d]) | |
return i(null, d); | |
if (!r) { | |
var _ = document.createElement("canvas"); | |
_.width = 100, | |
_.height = 100, | |
r = _.getContext("2d") | |
} | |
var p = "40px " + d; | |
r.font = p; | |
var v = n.safeMeasureText(r, s, p) | |
, g = document.createElement("style"); | |
g.type = "text/css"; | |
var m = ""; | |
m += isNaN(d - 0) ? "@font-face { font-family:" + d + "; src:" : "@font-face { font-family:'" + d + "'; src:", | |
m += "url('" + t + "');", | |
g.textContent = m + "}", | |
document.body.appendChild(g); | |
var y, T, E, A, x, C, b = document.createElement("div"), S = b.style; | |
if (S.fontFamily = d, | |
b.innerHTML = ".", | |
S.position = "absolute", | |
S.left = "-100px", | |
S.top = "-100px", | |
document.body.appendChild(b), | |
h()) | |
y = Date.now(), | |
T = d, | |
E = i, | |
A = new Promise(function(t, e) { | |
(function i() { | |
Date.now() - y >= l ? e() : document.fonts.load("40px " + T).then((function(e) { | |
e.length >= 1 ? t() : setTimeout(i, 100) | |
} | |
), (function() { | |
e() | |
} | |
)) | |
} | |
)() | |
} | |
), | |
x = null, | |
C = new Promise(function(t, e) { | |
x = setTimeout(e, l) | |
} | |
), | |
Promise.race([C, A]).then((function() { | |
x && (clearTimeout(x), | |
x = null), | |
E(null, T) | |
} | |
), (function() { | |
E(null, T) | |
} | |
)); | |
else { | |
var R = { | |
fontFamilyName: d, | |
refWidth: v, | |
onComplete: i, | |
startTime: Date.now() | |
}; | |
c.push(R), | |
-1 === o && (o = setInterval(u, 100)) | |
} | |
a[d] = g | |
}, | |
_getFontFamily: function(t) { | |
var e = t.lastIndexOf(".ttf"); | |
if (-1 === e) | |
return t; | |
var i, n = t.lastIndexOf("/"); | |
return -1 !== (i = -1 === n ? t.substring(0, e) + "_LABEL" : t.substring(n + 1, e) + "_LABEL").indexOf(" ") && (i = '"' + i + '"'), | |
i | |
} | |
}; | |
e.exports = f | |
} | |
), { | |
"../utils/text-utils": 243 | |
}], | |
44: [(function(t, e) { | |
"use strict"; | |
var i, n = t("./shared").bundles, r = { | |
decodeUuid: t("../utils/decode-uuid"), | |
getUuidFromURL: (i = /.*[/\\][0-9a-fA-F]{2}[/\\]([0-9a-fA-F-]{8,})/, | |
function(t) { | |
var e = t.match(i); | |
return e ? e[1] : "" | |
} | |
), | |
getUrlWithUuid: function(t, e) { | |
(e = e || Object.create(null)).__isNative__ = e.isNative, | |
e.ext = e.nativeExt; | |
var i = n.find((function(e) { | |
return e.getAssetInfo(t) | |
} | |
)); | |
return i && (e.bundle = i.name), | |
cc.assetManager._transform(t, e) | |
}, | |
isScene: function(t) { | |
return t && (t.constructor === cc.SceneAsset || t instanceof cc.Scene) | |
}, | |
normalize: function(t) { | |
return t && (46 === t.charCodeAt(0) && 47 === t.charCodeAt(1) ? t = t.slice(2) : 47 === t.charCodeAt(0) && (t = t.slice(1))), | |
t | |
} | |
}; | |
e.exports = r | |
} | |
), { | |
"../utils/decode-uuid": 231, | |
"./shared": 53 | |
}], | |
45: [(function(t) { | |
"use strict"; | |
t("./CCAssetManager") | |
} | |
), { | |
"./CCAssetManager": 30 | |
}], | |
46: [(function(t, e) { | |
"use strict"; | |
var i = t("./pack-manager") | |
, n = t("./pipeline") | |
, r = t("./parser") | |
, s = t("./utilities") | |
, a = s.getDepends | |
, o = s.cache | |
, c = s.gatherAsset | |
, l = s.setProperties | |
, h = s.forEach | |
, u = s.clear | |
, f = s.checkCircleReference | |
, d = t("./shared") | |
, _ = d.assets | |
, p = d.files | |
, v = d.parsed | |
, g = d.pipeline | |
, m = t("./task") | |
, y = new n("loadOneAsset",[function(t, e) { | |
var n = t.output = t.input | |
, r = n.options | |
, s = n.isNative | |
, a = n.uuid | |
, o = n.file | |
, c = r.reload; | |
if (o || !c && !s && _.has(a)) | |
return e(); | |
i.load(n, t.options, (function(t, i) { | |
n.file = i, | |
e(t) | |
} | |
)) | |
} | |
, function(t, e) { | |
var i = t.output = t.input | |
, n = t.progress | |
, s = t.options.__exclude__ | |
, a = i.id | |
, o = i.file | |
, c = i.options; | |
if (i.isNative) | |
r.parse(a, o, i.ext, c, (function(r, s) { | |
if (r) | |
return e(r); | |
i.content = s, | |
n.canInvoke && t.dispatch("progress", ++n.finish, n.total, i), | |
p.remove(a), | |
v.remove(a), | |
e() | |
} | |
)); | |
else { | |
var l = i.uuid; | |
if (l in s) { | |
var h = s[l] | |
, u = h.finish | |
, d = h.content | |
, g = h.err | |
, m = h.callbacks; | |
n.canInvoke && t.dispatch("progress", ++n.finish, n.total, i), | |
u || f(l, l, s) ? (d && d.addRef && d.addRef(), | |
i.content = d, | |
e(g)) : m.push({ | |
done: e, | |
item: i | |
}) | |
} else if (!c.reload && _.has(l)) { | |
var y = _.get(l); | |
c.__asyncLoadAssets__ || !y.__asyncLoadAssets__ ? (i.content = y.addRef(), | |
n.canInvoke && t.dispatch("progress", ++n.finish, n.total, i), | |
e()) : T(t, y, e, !1) | |
} else | |
r.parse(a, o, "import", c, (function(i, n) { | |
if (i) | |
return e(i); | |
n._uuid = l, | |
T(t, n, e, !0) | |
} | |
)) | |
} | |
} | |
]); | |
function T(t, e, i, n) { | |
var r = t.input | |
, s = t.progress | |
, c = r.uuid | |
, h = r.id | |
, u = r.options | |
, f = r.config | |
, d = u.__asyncLoadAssets__ | |
, _ = u.cacheAsset | |
, y = []; | |
e.addRef && e.addRef(), | |
a(c, e, Object.create(null), y, !1, d, f), | |
s.canInvoke && t.dispatch("progress", ++s.finish, s.total += y.length, r); | |
var T = t.options.__exclude__[c] = { | |
content: e, | |
finish: !1, | |
callbacks: [{ | |
done: i, | |
item: r | |
}] | |
} | |
, E = m.create({ | |
input: y, | |
options: t.options, | |
onProgress: t.onProgress, | |
onError: m.prototype.recycle, | |
progress: s, | |
onComplete: function(t) { | |
if (e.decRef && e.decRef(!1), | |
e.__asyncLoadAssets__ = d, | |
T.finish = !0, | |
T.err = t, | |
!t) { | |
for (var i = Array.isArray(E.output) ? E.output : [E.output], r = Object.create(null), s = 0, a = i.length; s < a; s++) { | |
var u = i[s]; | |
u && (r[u instanceof cc.Asset ? u._uuid + "@import" : c + "@native"] = u) | |
} | |
if (n) { | |
if (!l(c, e, r) && !e.__onLoadInvoked__) | |
try { | |
e.onLoad && e.onLoad(), | |
e.__onLoadInvoked__ = !0 | |
} catch (A) {} | |
p.remove(h), | |
v.remove(h), | |
o(c, e, void 0 !== _ ? _ : cc.assetManager.cacheAsset) | |
} else if (e.__nativeDepend__ && !e._nativeAsset && !l(c, e, r) && !e.__onLoadInvoked__) | |
try { | |
e.onLoad && e.onLoad(), | |
e.__onLoadInvoked__ = !0 | |
} catch (A) {} | |
E.recycle() | |
} | |
for (var f = T.callbacks, g = 0, m = f.length; g < m; g++) { | |
var y = f[g]; | |
e.addRef && e.addRef(), | |
y.item.content = e, | |
y.done(t) | |
} | |
f.length = 0 | |
} | |
}); | |
g.async(E) | |
} | |
e.exports = function(t, e) { | |
var i = !1; | |
t.progress || (t.progress = { | |
finish: 0, | |
total: t.input.length, | |
canInvoke: !0 | |
}, | |
i = !0); | |
var n = t.options | |
, r = t.progress; | |
n.__exclude__ = n.__exclude__ || Object.create(null), | |
t.output = [], | |
h(t.input, (function(s, a) { | |
var o = m.create({ | |
input: s, | |
onProgress: t.onProgress, | |
options: n, | |
progress: r, | |
onComplete: function(n, s) { | |
n && !t.isFinish && (!cc.assetManager.force || i ? (r.canInvoke = !1, | |
e(n)) : r.canInvoke && t.dispatch("progress", ++r.finish, r.total, s)), | |
t.output.push(s), | |
o.recycle(), | |
a() | |
} | |
}); | |
y.async(o) | |
} | |
), (function() { | |
if (n.__exclude__ = null, | |
t.isFinish) | |
return u(t, !0), | |
t.dispatch("error"); | |
c(t), | |
u(t, !0), | |
e() | |
} | |
)) | |
} | |
} | |
), { | |
"./pack-manager": 47, | |
"./parser": 48, | |
"./pipeline": 49, | |
"./shared": 53, | |
"./task": 54, | |
"./utilities": 56 | |
}], | |
47: [(function(t, e) { | |
"use strict"; | |
var i = t("../platform/deserialize-compiled") | |
, n = t("./downloader") | |
, r = t("./cache") | |
, s = t("../platform/js") | |
, a = t("./shared").files | |
, o = new r; | |
function c(t) { | |
return o.has(t.uuid) | |
} | |
var l = { | |
unpackJson: function(t, e, n, r) { | |
var a = s.createMap(!0) | |
, o = null; | |
if (Array.isArray(e)) { | |
(e = (0, | |
i.unpackJSONs)(e)).length, | |
t.length; | |
for (var c = 0; c < t.length; c++) | |
a[t[c] + "@import"] = e[c] | |
} else { | |
var l = s._getClassId(cc.Texture2D); | |
if (e.type === l) { | |
if (e.data) { | |
var h = e.data.split("|"); | |
h.length, | |
t.length; | |
for (var u = 0; u < t.length; u++) | |
a[t[u] + "@import"] = (0, | |
i.packCustomObjData)(l, h[u], !0) | |
} | |
} else | |
o = Error("unmatched type pack!"), | |
a = null | |
} | |
r && r(o, a) | |
}, | |
init: function() { | |
o.clear() | |
}, | |
register: function(t, e) { | |
"object" == typeof t ? s.mixin(h, t) : h[t] = e | |
}, | |
unpack: function(t, e, i, n, r) { | |
e ? (0, | |
h[i])(t, e, n, r) : r && r(Error("package data is wrong!")) | |
}, | |
load: function(t, e, i) { | |
if (t.isNative || !t.info || !t.info.packs) | |
return n.download(t.id, t.url, t.ext, t.options, i); | |
if (a.has(t.id)) | |
return i(null, a.get(t.id)); | |
var r = t.info.packs | |
, s = r.find(c); | |
if (s) | |
return o.get(s.uuid).push({ | |
onComplete: i, | |
id: t.id | |
}); | |
s = r[0], | |
o.add(s.uuid, [{ | |
onComplete: i, | |
id: t.id | |
}]); | |
var h = cc.assetManager._transform(s.uuid, { | |
ext: s.ext, | |
bundle: t.config.name | |
}); | |
n.download(s.uuid, h, s.ext, t.options, (function(e, i) { | |
a.remove(s.uuid), | |
l.unpack(s.packs, i, s.ext, t.options, (function(t, e) { | |
if (t) | |
t.message = "unpack " + h + " failed! details: " + t.message; | |
else | |
for (var i in e) | |
a.add(i, e[i]); | |
for (var n = o.remove(s.uuid), r = 0, c = n.length; r < c; r++) { | |
var l = n[r]; | |
if (t) | |
l.onComplete(t); | |
else { | |
var u = e[l.id]; | |
u ? l.onComplete(null, u) : l.onComplete(Error("can not retrieve data from package")) | |
} | |
} | |
} | |
)) | |
} | |
)) | |
} | |
} | |
, h = { | |
".json": l.unpackJson | |
}; | |
e.exports = l | |
} | |
), { | |
"../platform/deserialize-compiled": 177, | |
"../platform/js": 183, | |
"./cache": 33, | |
"./downloader": 40, | |
"./shared": 53 | |
}], | |
48: [(function(t, e) { | |
"use strict"; | |
var i = t("../platform/CCSAXParser").plistParser | |
, n = t("../platform/js") | |
, r = t("./deserialize") | |
, s = t("./cache") | |
, a = t("./helper").isScene | |
, o = t("./shared") | |
, c = o.parsed | |
, l = o.files | |
, h = t("../platform/CCSys") | |
, u = h.__audioSupport | |
, f = h.capabilities | |
, d = new s | |
, _ = { | |
parseImage: function(t, e, i) { | |
if (f.imageBitmap && t instanceof Blob) { | |
var n = {}; | |
n.imageOrientation = e.__flipY__ ? "flipY" : "none", | |
n.premultiplyAlpha = e.__premultiplyAlpha__ ? "premultiply" : "none", | |
createImageBitmap(t, n).then((function(t) { | |
t.flipY = !!e.__flipY__, | |
t.premultiplyAlpha = !!e.__premultiplyAlpha__, | |
i && i(null, t) | |
} | |
), (function(t) { | |
i && i(t, null) | |
} | |
)) | |
} else | |
i && i(null, t) | |
}, | |
parseAudio: function(t, e, i) { | |
t instanceof ArrayBuffer && u.WEB_AUDIO ? u.context.decodeAudioData(t, (function(t) { | |
i && i(null, t) | |
} | |
), (function(t) { | |
i && i(t, null) | |
} | |
)) : i && i(null, t) | |
}, | |
parsePVRTex: function(t, e, i) { | |
var n = null | |
, r = null; | |
try { | |
var s = t instanceof ArrayBuffer ? t : t.buffer | |
, a = new Int32Array(s,0,13); | |
if (55727696 != a[0]) | |
throw Error("Invalid magic number in PVR header"); | |
var o = a[7] | |
, c = a[6] | |
, l = a[12] + 52; | |
r = { | |
_data: new Uint8Array(s,l), | |
_compressed: !0, | |
width: o, | |
height: c | |
} | |
} catch (h) { | |
n = h | |
} | |
i && i(n, r) | |
}, | |
parsePKMTex: (function() { | |
function t(t, e) { | |
return t[e] << 8 | t[e + 1] | |
} | |
return function(e, i, n) { | |
var r = null | |
, s = null; | |
try { | |
var a = e instanceof ArrayBuffer ? e : e.buffer | |
, o = new Uint8Array(a) | |
, c = t(o, 6); | |
if (0 !== c && 1 !== c && 3 !== c) | |
return Error("Invalid magic number in ETC header"); | |
var l = t(o, 12) | |
, h = t(o, 14); | |
t(o, 8), | |
t(o, 10), | |
s = { | |
_data: new Uint8Array(a,16), | |
_compressed: !0, | |
width: l, | |
height: h | |
} | |
} catch (u) { | |
r = u | |
} | |
n && n(r, s) | |
} | |
} | |
)(), | |
parsePlist: function(t, e, n) { | |
var r = null | |
, s = i.parse(t); | |
s || (r = Error("parse failed")), | |
n && n(r, s) | |
}, | |
parseImport: function(t, e, i) { | |
if (!t) | |
return i && i(Error("Json is empty")); | |
var n, s = null; | |
try { | |
n = r(t, e) | |
} catch (a) { | |
s = a | |
} | |
i && i(s, n) | |
}, | |
init: function() { | |
d.clear() | |
}, | |
register: function(t, e) { | |
"object" == typeof t ? n.mixin(p, t) : p[t] = e | |
}, | |
parse: function(t, e, i, n, r) { | |
var s, o, h; | |
(s = c.get(t)) ? r(null, s) : (o = d.get(t)) ? o.push(r) : (h = p[i]) ? (d.add(t, [r]), | |
h(e, n, (function(e, i) { | |
e ? l.remove(t) : a(i) || c.add(t, i); | |
for (var n = d.remove(t), r = 0, s = n.length; r < s; r++) | |
n[r](e, i) | |
} | |
))) : r(null, e) | |
} | |
} | |
, p = { | |
".png": _.parseImage, | |
".jpg": _.parseImage, | |
".bmp": _.parseImage, | |
".jpeg": _.parseImage, | |
".gif": _.parseImage, | |
".ico": _.parseImage, | |
".tiff": _.parseImage, | |
".webp": _.parseImage, | |
".image": _.parseImage, | |
".pvr": _.parsePVRTex, | |
".pkm": _.parsePKMTex, | |
".mp3": _.parseAudio, | |
".ogg": _.parseAudio, | |
".wav": _.parseAudio, | |
".m4a": _.parseAudio, | |
".plist": _.parsePlist, | |
import: _.parseImport | |
}; | |
e.exports = _ | |
} | |
), { | |
"../platform/CCSAXParser": 169, | |
"../platform/CCSys": 171, | |
"../platform/js": 183, | |
"./cache": 33, | |
"./deserialize": 36, | |
"./helper": 44, | |
"./shared": 53 | |
}], | |
49: [(function(t, e) { | |
"use strict"; | |
var i = t("./task") | |
, n = 0; | |
function r(t, e) { | |
if (Array.isArray(e)) { | |
this.id = n++, | |
this.name = t, | |
this.pipes = []; | |
for (var i = 0, r = e.length; i < r; i++) | |
"function" == typeof e[i] && this.pipes.push(e[i]) | |
} | |
} | |
r.prototype = { | |
constructor: r, | |
insert: function(t, e) { | |
if (!("function" != typeof t || e > this.pipes.length)) | |
return this.pipes.splice(e, 0, t), | |
this | |
}, | |
append: function(t) { | |
if ("function" == typeof t) | |
return this.pipes.push(t), | |
this | |
}, | |
remove: function(t) { | |
if ("number" == typeof t) | |
return this.pipes.splice(t, 1), | |
this | |
}, | |
sync: function(t) { | |
var e = this.pipes; | |
if (t instanceof i && 0 !== e.length) { | |
null != t.output && (t.input = t.output, | |
t.output = null), | |
t._isFinish = !1; | |
for (var n = 0, r = e.length; n < r; ) { | |
var s = (0, | |
e[n])(t); | |
if (s) | |
return t._isFinish = !0, | |
s; | |
++n !== r && (t.input = t.output, | |
t.output = null) | |
} | |
return t._isFinish = !0, | |
t.output | |
} | |
}, | |
async: function(t) { | |
var e = this.pipes; | |
t instanceof i && 0 !== e.length && (null != t.output && (t.input = t.output, | |
t.output = null), | |
t._isFinish = !1, | |
this._flow(0, t)) | |
}, | |
_flow: function(t, e) { | |
var i = this; | |
(0, | |
this.pipes[t])(e, (function(n) { | |
n ? (e._isFinish = !0, | |
e.onComplete && e.onComplete(n)) : ++t < i.pipes.length ? (e.input = e.output, | |
e.output = null, | |
i._flow(t, e)) : (e._isFinish = !0, | |
e.onComplete && e.onComplete(n, e.output)) | |
} | |
)) | |
} | |
}, | |
e.exports = r | |
} | |
), { | |
"./task": 54 | |
}], | |
50: [(function(t, e) { | |
"use strict"; | |
var i = t("./task") | |
, n = t("./shared") | |
, r = n.transformPipeline | |
, s = n.RequestType; | |
e.exports = function(t, e) { | |
var n = t.options | |
, a = Object.create(null) | |
, o = Object.create(null); | |
for (var c in n) | |
switch (c) { | |
case s.PATH: | |
case s.UUID: | |
case s.DIR: | |
case s.SCENE: | |
case s.URL: | |
break; | |
case "__requestType__": | |
case "__isNative__": | |
case "ext": | |
case "type": | |
case "__nativeName__": | |
case "audioLoadMode": | |
case "bundle": | |
a[c] = n[c]; | |
break; | |
case "__exclude__": | |
case "__outputAsArray__": | |
o[c] = n[c]; | |
break; | |
default: | |
a[c] = n[c], | |
o[c] = n[c] | |
} | |
t.options = o; | |
var l = i.create({ | |
input: t.input, | |
options: a | |
}) | |
, h = null; | |
try { | |
t.output = t.source = r.sync(l) | |
} catch (d) { | |
h = d; | |
for (var u = 0, f = l.output.length; u < f; u++) | |
l.output[u].recycle() | |
} | |
l.recycle(), | |
e(h) | |
} | |
} | |
), { | |
"./shared": 53, | |
"./task": 54 | |
}], | |
51: [(function(t, e) { | |
"use strict"; | |
var i = t("./depend-util") | |
, n = t("./cache"); | |
t("../assets/CCAsset"); | |
var r = t("./shared").assets | |
, s = t("../platform/utils").callInNextTick; | |
function a(t, e) { | |
t._uuid && e.push(t._uuid) | |
} | |
function o(t, e) { | |
for (var i = Object.getOwnPropertyNames(t), n = 0; n < i.length; n++) { | |
var r = i[n]; | |
if ("node" !== r && "__eventTargets" !== r) { | |
var s = t[r]; | |
if ("object" == typeof s && s) | |
if (Array.isArray(s)) | |
for (var o = 0; o < s.length; o++) { | |
var c = s[o]; | |
c instanceof cc.Asset && a(c, e) | |
} | |
else if (s.constructor && s.constructor !== Object) | |
s instanceof cc.Asset && a(s, e); | |
else | |
for (var l = Object.getOwnPropertyNames(s), h = 0; h < l.length; h++) { | |
var u = s[l[h]]; | |
u instanceof cc.Asset && a(u, e) | |
} | |
} | |
} | |
} | |
var c = []; | |
function l(t, e) { | |
for (var i = 0; i < t._components.length; i++) | |
o(t._components[i], e); | |
for (var n = 0; n < t._children.length; n++) | |
l(t._children[n], e) | |
} | |
function h(t, e, n, s) { | |
n.push(t._uuid); | |
for (var a = i.getDeps(t._uuid), o = 0, c = a.length; o < c; o++) { | |
var l = r.get(a[o]); | |
if (l) { | |
var u = l._uuid; | |
if (u in e ? e[u] += s : e[u] = l.refCount + s, | |
n.includes(u)) | |
continue; | |
h(l, e, n, s) | |
} | |
} | |
} | |
function u(t) { | |
var e = Object.create(null); | |
if (e[t._uuid] = t.refCount, | |
h(t, e, c, -1), | |
c.length = 0, | |
0 !== e[t._uuid]) | |
return e[t._uuid]; | |
for (var i in e) | |
0 !== e[i] && h(r.get(i), e, c, 1); | |
return c.length = 0, | |
e[t._uuid] | |
} | |
var f = new n | |
, d = new n | |
, _ = !1; | |
function p() { | |
_ = !1, | |
d.forEach((function(t) { | |
v._free(t) | |
} | |
)), | |
d.clear() | |
} | |
var v = { | |
init: function() { | |
f.clear(), | |
d.clear() | |
}, | |
_addPersistNodeRef: function(t) { | |
var e = []; | |
l(t, e); | |
for (var i = 0, n = e.length; i < n; i++) { | |
var s = r.get(e[i]); | |
s && s.addRef() | |
} | |
f.add(t.uuid, e) | |
}, | |
_removePersistNodeRef: function(t) { | |
if (f.has(t.uuid)) { | |
for (var e = f.get(t.uuid), i = 0, n = e.length; i < n; i++) { | |
var s = r.get(e[i]); | |
s && s.decRef() | |
} | |
f.remove(t.uuid) | |
} | |
}, | |
_autoRelease: function(t, e, n) { | |
if (t) { | |
for (var s = i.getDeps(t._id), a = 0, o = s.length; a < o; a++) { | |
var c = r.get(s[a]); | |
c && c.decRef(t.autoReleaseAssets) | |
} | |
var l = i._depends.get(t._id); | |
if (l && l.persistDeps) | |
for (var h = l.persistDeps, u = 0, d = h.length; u < d; u++) { | |
var _ = r.get(h[u]); | |
_ && _.decRef(t.autoReleaseAssets) | |
} | |
t._id !== e._id && i.remove(t._id) | |
} | |
var p = i._depends.get(e._id); | |
for (var v in p && (p.persistDeps = []), | |
n) { | |
for (var g = n[v], m = f.get(g.uuid), y = 0, T = m.length; y < T; y++) { | |
var E = r.get(m[y]); | |
E && E.addRef() | |
} | |
p && p.persistDeps.push.apply(p.persistDeps, m) | |
} | |
}, | |
_free: function(t, e) { | |
if (d.remove(t._uuid), | |
cc.isValid(t, !0) && !(!e && t.refCount > 0 && u(t) > 0)) { | |
r.remove(t._uuid); | |
for (var n = i.getDeps(t._uuid), s = 0, a = n.length; s < a; s++) { | |
var o = r.get(n[s]); | |
o && (o.decRef(!1), | |
v._free(o, !1)) | |
} | |
t.destroy(), | |
i.remove(t._uuid) | |
} | |
}, | |
tryRelease: function(t, e) { | |
t instanceof cc.Asset && (e ? v._free(t, e) : (d.add(t._uuid, t), | |
_ || (_ = !0, | |
s(p)))) | |
} | |
}; | |
e.exports = v | |
} | |
), { | |
"../assets/CCAsset": 57, | |
"../platform/utils": 186, | |
"./cache": 33, | |
"./depend-util": 35, | |
"./shared": 53 | |
}], | |
52: [(function(t, e) { | |
"use strict"; | |
var i = []; | |
function n() { | |
this._id = "", | |
this.uuid = "", | |
this.url = "", | |
this.ext = ".json", | |
this.content = null, | |
this.file = null, | |
this.info = null, | |
this.config = null, | |
this.isNative = !1, | |
this.options = Object.create(null) | |
} | |
n.prototype = { | |
constructor: n, | |
get id() { | |
return this._id || (this._id = this.uuid + "@" + (this.isNative ? "native" : "import")), | |
this._id | |
}, | |
recycle: function() { | |
500 !== i.length && (this._id = "", | |
this.uuid = "", | |
this.url = "", | |
this.ext = ".json", | |
this.content = null, | |
this.file = null, | |
this.info = null, | |
this.config = null, | |
this.isNative = !1, | |
this.options = Object.create(null), | |
i.push(this)) | |
} | |
}, | |
n.create = function() { | |
return 0 !== i.length ? i.pop() : new n | |
} | |
, | |
e.exports = n | |
} | |
), {}], | |
53: [(function(t, e) { | |
"use strict"; | |
var i = t("./cache") | |
, n = t("./pipeline") | |
, r = new i | |
, s = new i | |
, a = new i | |
, o = new i | |
, c = new n("normal load",[]) | |
, l = new n("fetch",[]) | |
, h = new n("transform url",[]); | |
e.exports = { | |
assets: r, | |
files: s, | |
parsed: a, | |
pipeline: c, | |
fetchPipeline: l, | |
transformPipeline: h, | |
RequestType: { | |
UUID: "uuid", | |
PATH: "path", | |
DIR: "dir", | |
URL: "url", | |
SCENE: "scene" | |
}, | |
bundles: o, | |
BuiltinBundleName: { | |
RESOURCES: "resources", | |
INTERNAL: "internal", | |
MAIN: "main", | |
START_SCENE: "start-scene" | |
} | |
} | |
} | |
), { | |
"./cache": 33, | |
"./pipeline": 49 | |
}], | |
54: [(function(t, e) { | |
"use strict"; | |
var i = 0 | |
, n = []; | |
function r(t) { | |
this.id = i++, | |
this._isFinish = !0, | |
this.onComplete = null, | |
this.onProgress = null, | |
this.onError = null, | |
this.source = null, | |
this.output = null, | |
this.input = null, | |
this.progress = null, | |
this.options = null, | |
this.set(t) | |
} | |
r.prototype = { | |
constructor: r, | |
set: function(t) { | |
t = t || Object.create(null), | |
this.onComplete = t.onComplete, | |
this.onProgress = t.onProgress, | |
this.onError = t.onError, | |
this.source = this.input = t.input, | |
this.output = null, | |
this.progress = t.progress, | |
this.options = t.options || Object.create(null) | |
}, | |
dispatch: function(t, e, i, n, r) { | |
switch (t) { | |
case "complete": | |
this.onComplete && this.onComplete(e, i, n, r); | |
break; | |
case "progress": | |
this.onProgress && this.onProgress(e, i, n, r); | |
break; | |
case "error": | |
this.onError && this.onError(e, i, n, r); | |
break; | |
default: | |
var s = "on" + t[0].toUpperCase() + t.substr(1); | |
"function" == typeof this[s] && this[s](e, i, n, r) | |
} | |
}, | |
recycle: function() { | |
500 !== n.length && (this.onComplete = null, | |
this.onProgress = null, | |
this.onError = null, | |
this.source = this.output = this.input = null, | |
this.progress = null, | |
this.options = null, | |
n.push(this)) | |
}, | |
get isFinish() { | |
return this._isFinish | |
} | |
}, | |
r.create = function(t) { | |
var e = null; | |
return 0 !== n.length ? (e = n.pop()).set(t) : e = new r(t), | |
e | |
} | |
, | |
e.exports = r | |
} | |
), {}], | |
55: [(function(t, e) { | |
"use strict"; | |
var i = t("./helper").decodeUuid | |
, n = t("./request-item") | |
, r = t("./shared") | |
, s = r.RequestType | |
, a = r.bundles; | |
e.exports = { | |
parse: function(t) { | |
var e = t.input | |
, r = t.options; | |
e = Array.isArray(e) ? e : [e], | |
t.output = []; | |
for (var o = 0; o < e.length; o++) { | |
var c = e[o] | |
, l = n.create(); | |
if ("string" == typeof c && ((c = Object.create(null))[r.__requestType__ || s.UUID] = e[o]), | |
"object" == typeof c) | |
for (var h in cc.js.addon(c, r), | |
c.preset && cc.js.addon(c, cc.assetManager.presets[c.preset]), | |
c) { | |
switch (h) { | |
case s.UUID: | |
var u = l.uuid = i(c.uuid); | |
if (a.has(c.bundle)) { | |
if ((p = (v = a.get(c.bundle)._config).getAssetInfo(u)) && p.redirect) { | |
if (!a.has(p.redirect)) | |
throw Error("Please load bundle " + p.redirect + " first"); | |
p = (v = a.get(p.redirect)._config).getAssetInfo(u) | |
} | |
l.config = v, | |
l.info = p | |
} | |
l.ext = c.ext || ".json"; | |
break; | |
case "__requestType__": | |
case "ext": | |
case "bundle": | |
case "preset": | |
case "type": | |
break; | |
case s.DIR: | |
if (a.has(c.bundle)) { | |
var f = []; | |
a.get(c.bundle)._config.getDirWithPath(c.dir, c.type, f); | |
for (var d = 0, _ = f.length; d < _; d++) { | |
var p = f[d]; | |
e.push({ | |
uuid: p.uuid, | |
__isNative__: !1, | |
ext: ".json", | |
bundle: c.bundle | |
}) | |
} | |
} | |
l.recycle(), | |
l = null; | |
break; | |
case s.PATH: | |
if (a.has(c.bundle)) { | |
if ((p = (v = a.get(c.bundle)._config).getInfoWithPath(c.path, c.type)) && p.redirect) { | |
if (!a.has(p.redirect)) | |
throw Error("you need to load bundle " + p.redirect + " first"); | |
p = (v = a.get(p.redirect)._config).getAssetInfo(p.uuid) | |
} | |
if (!p) | |
throw l.recycle(), | |
Error("Bundle " + c.bundle + " doesn't contain " + c.path); | |
l.config = v, | |
l.uuid = p.uuid, | |
l.info = p | |
} | |
l.ext = c.ext || ".json"; | |
break; | |
case s.SCENE: | |
if (a.has(c.bundle)) { | |
var v; | |
if ((p = (v = a.get(c.bundle)._config).getSceneInfo(c.scene)) && p.redirect) { | |
if (!a.has(p.redirect)) | |
throw Error("you need to load bundle " + p.redirect + " first"); | |
p = (v = a.get(p.redirect)._config).getAssetInfo(p.uuid) | |
} | |
if (!p) | |
throw l.recycle(), | |
Error("Bundle " + v.name + " doesn't contain scene " + c.scene); | |
l.config = v, | |
l.uuid = p.uuid, | |
l.info = p | |
} | |
break; | |
case "__isNative__": | |
l.isNative = c.__isNative__; | |
break; | |
case s.URL: | |
l.url = c.url, | |
l.uuid = c.uuid || c.url, | |
l.ext = c.ext || cc.path.extname(c.url), | |
l.isNative = void 0 === c.__isNative__ || c.__isNative__; | |
break; | |
default: | |
l.options[h] = c[h] | |
} | |
if (!l) | |
break | |
} | |
if (l && (t.output.push(l), | |
!l.uuid && !l.url)) | |
throw Error("Can not parse this input:" + JSON.stringify(c)) | |
} | |
return null | |
}, | |
combine: function(t) { | |
for (var e = t.output = t.input, i = 0; i < e.length; i++) { | |
var n = e[i]; | |
if (!n.url) { | |
var r, s, a = n.config; | |
s = n.isNative ? a && a.nativeBase ? a.base + a.nativeBase : cc.assetManager.generalNativeBase : a && a.importBase ? a.base + a.importBase : cc.assetManager.generalImportBase; | |
var o = n.uuid | |
, c = ""; | |
n.info && (c = n.isNative ? n.info.nativeVer ? "." + n.info.nativeVer : "" : n.info.ver ? "." + n.info.ver : ""), | |
r = ".ttf" === n.ext ? s + "/" + o.slice(0, 2) + "/" + o + c + "/" + n.options.__nativeName__ : s + "/" + o.slice(0, 2) + "/" + o + c + n.ext, | |
n.url = r | |
} | |
} | |
return null | |
} | |
} | |
} | |
), { | |
"./helper": 44, | |
"./request-item": 52, | |
"./shared": 53 | |
}], | |
56: [(function(t, e) { | |
"use strict"; | |
var i = t("./depend-util") | |
, n = t("./helper") | |
, r = n.isScene | |
, s = n.decodeUuid | |
, a = t("./shared").assets | |
, o = t("../platform/utils").callInNextTick; | |
t("../assets/CCAsset"); | |
var c = { | |
processOptions: function(t) { | |
var e = t.uuids | |
, i = t.paths | |
, n = t.types | |
, r = t.deps | |
, a = t.paths = Object.create(null); | |
if (!1 === t.debug) { | |
for (var o = 0, c = e.length; o < c; o++) | |
e[o] = s(e[o]); | |
for (var l in i) { | |
var h = i[l] | |
, u = h[1]; | |
h[1] = n[u] | |
} | |
} else { | |
for (var f = Object.create(null), d = 0, _ = e.length; d < _; d++) { | |
var p = e[d]; | |
e[d] = f[p] = s(p) | |
} | |
e = f | |
} | |
for (var v in i) { | |
var g = i[v]; | |
a[e[v]] = g | |
} | |
var m = t.scenes; | |
for (var y in m) { | |
var T = m[y]; | |
m[y] = e[T] | |
} | |
var E = t.packs; | |
for (var A in E) | |
for (var x = E[A], C = 0; C < x.length; ++C) | |
x[C] = e[x[C]]; | |
var b = t.versions; | |
if (b) | |
for (var S in b) | |
for (var R = b[S], M = 0; M < R.length; M += 2) { | |
var w = R[M]; | |
R[M] = e[w] || w | |
} | |
var I = t.redirect; | |
if (I) | |
for (var O = 0; O < I.length; O += 2) | |
I[O] = e[I[O]], | |
I[O + 1] = r[I[O + 1]] | |
}, | |
clear: function(t, e) { | |
for (var i = 0, n = t.input.length; i < n; i++) { | |
var r = t.input[i]; | |
e && !r.isNative && r.content && r.content.decRef && r.content.decRef(!1), | |
r.recycle() | |
} | |
t.input = null | |
}, | |
retry: function(t, e, i, n, r) { | |
t(r = r || 0, (function(s, a) { | |
r++, | |
!s || r > e ? n && n(s, a) : setTimeout((function() { | |
c.retry(t, e, i, n, r) | |
} | |
), i) | |
} | |
)) | |
}, | |
getDepends: function(t, e, n, r, s, a, o) { | |
try { | |
var c = i.parse(t, e) | |
, l = !0; | |
if (e instanceof cc.Asset && (!e.__nativeDepend__ || e._nativeAsset) && (l = !1), | |
s) { | |
for (var h = 0, u = c.deps.length; h < u; h++) { | |
var f = c.deps[h]; | |
f in n || (n[f] = !0, | |
r.push({ | |
uuid: f, | |
bundle: o && o.name | |
})) | |
} | |
l && c.nativeDep && (o && (c.nativeDep.bundle = o.name), | |
r.push(Object.assign({}, c.nativeDep))) | |
} else { | |
a = !!e.asyncLoadAssets || a && !c.preventDeferredLoadDependents; | |
for (var d = 0, _ = c.deps.length; d < _; d++) { | |
var p = c.deps[d]; | |
p in n || (n[p] = !0, | |
r.push({ | |
uuid: p, | |
__asyncLoadAssets__: a, | |
bundle: o && o.name | |
})) | |
} | |
l && !a && !c.preventPreloadNativeObject && c.nativeDep && (o && (c.nativeDep.bundle = o.name), | |
r.push(Object.assign({}, c.nativeDep))) | |
} | |
} catch (v) {} | |
}, | |
cache: function(t, e, i) { | |
e && (!r(e) && i && a.add(t, e)) | |
}, | |
setProperties: function(t, e, i) { | |
var n = !1 | |
, r = e.__depends__; | |
if (r) { | |
for (var s = 0, a = r.length; s < a; s++) { | |
var o = r[s] | |
, c = i[o.uuid + "@import"]; | |
c ? o.owner[o.prop] = c.addRef() : n = !0 | |
} | |
e.__depends__ = void 0 | |
} | |
return e.__nativeDepend__ && (e._nativeAsset || (i[t + "@native"] ? e._nativeAsset = i[t + "@native"] : n = !0), | |
e.__nativeDepend__ = void 0), | |
n | |
}, | |
gatherAsset: function(t) { | |
var e = t.source; | |
if (t.options.__outputAsArray__ || 1 !== e.length) | |
for (var i = t.output = [], n = 0, r = e.length; n < r; n++) | |
i.push(e[n].content); | |
else | |
t.output = e[0].content | |
}, | |
forEach: function(t, e, i) { | |
var n = 0 | |
, r = []; | |
0 === t.length && i && i(r); | |
for (var s = 0, a = t.length; s < a; s++) | |
e(t[s], (function(t) { | |
t && r.push(t), | |
++n === a && i && i(r) | |
} | |
)) | |
}, | |
parseParameters: function(t, e, i) { | |
if (void 0 === i) { | |
var n = "function" == typeof t; | |
e ? (i = e, | |
n || (e = null)) : void 0 === e && n && (i = t, | |
t = null, | |
e = null), | |
void 0 !== e && n && (e = t, | |
t = null) | |
} | |
return { | |
options: t = t || Object.create(null), | |
onProgress: e, | |
onComplete: i | |
} | |
}, | |
parseLoadResArgs: function(t, e, i) { | |
if (void 0 === i) { | |
var n = cc.js.isChildClassOf(t, cc.Asset); | |
e ? (i = e, | |
n && (e = null)) : void 0 !== e || n || (i = t, | |
e = null, | |
t = null), | |
void 0 === e || n || (e = t, | |
t = null) | |
} | |
return { | |
type: t, | |
onProgress: e, | |
onComplete: i | |
} | |
}, | |
checkCircleReference: function(t, e, n, r) { | |
if (r || (r = Object.create(null)), | |
!n[e] || r[e]) | |
return !1; | |
r[e] = !0; | |
var s = !1 | |
, a = i.getDeps(e); | |
if (a) | |
for (var o = 0, l = a.length; o < l; o++) { | |
var h = a[o]; | |
if (h === t || c.checkCircleReference(t, h, n, r)) { | |
s = !0; | |
break | |
} | |
} | |
return s | |
}, | |
asyncify: function(t) { | |
return function(e, i) { | |
if (t) { | |
var n = []; | |
Array.isArray(i) ? i.forEach((function(t) { | |
return t instanceof cc.Asset && n.push(t.addRef()) | |
} | |
)) : i instanceof cc.Asset && n.push(i.addRef()), | |
o((function() { | |
n.forEach((function(t) { | |
return t.decRef(!1) | |
} | |
)), | |
t(e, i) | |
} | |
)) | |
} | |
} | |
} | |
}; | |
e.exports = c | |
} | |
), { | |
"../assets/CCAsset": 57, | |
"../platform/utils": 186, | |
"./depend-util": 35, | |
"./helper": 44, | |
"./shared": 53 | |
}], | |
57: [(function(t, e) { | |
"use strict"; | |
var i = t("../platform/CCObject"); | |
cc.Asset = cc.Class({ | |
name: "cc.Asset", | |
extends: i, | |
ctor: function() { | |
Object.defineProperty(this, "_uuid", { | |
value: "", | |
writable: !0 | |
}), | |
this.loaded = !0, | |
this._nativeUrl = "", | |
this._ref = 0 | |
}, | |
properties: { | |
nativeUrl: { | |
get: function() { | |
if (!this._nativeUrl && this._native) { | |
var t = this._native; | |
if (47 === t.charCodeAt(0)) | |
return t.slice(1); | |
46 === t.charCodeAt(0) ? this._nativeUrl = cc.assetManager.utils.getUrlWithUuid(this._uuid, { | |
nativeExt: t, | |
isNative: !0 | |
}) : this._nativeUrl = cc.assetManager.utils.getUrlWithUuid(this._uuid, { | |
__nativeName__: t, | |
nativeExt: cc.path.extname(t), | |
isNative: !0 | |
}) | |
} | |
return this._nativeUrl | |
}, | |
visible: !1 | |
}, | |
refCount: { | |
get: function() { | |
return this._ref | |
} | |
}, | |
_native: "", | |
_nativeAsset: { | |
get: function() { | |
return this._$nativeAsset | |
}, | |
set: function(t) { | |
this._$nativeAsset = t | |
} | |
}, | |
_nativeDep: { | |
get: function() { | |
if (this._native) | |
return { | |
__isNative__: !0, | |
uuid: this._uuid, | |
ext: this._native | |
} | |
} | |
} | |
}, | |
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 | |
}, | |
addRef: function() { | |
return this._ref++, | |
this | |
}, | |
decRef: function(t) { | |
return this._ref > 0 && this._ref--, | |
!1 !== t && cc.assetManager._releaseManager.tryRelease(this), | |
this | |
}, | |
destroy: function() { | |
return this.loaded = !1, | |
this._super() | |
} | |
}), | |
e.exports = cc.Asset | |
} | |
), { | |
"../platform/CCObject": 168 | |
}], | |
58: [(function(t, e) { | |
"use strict"; | |
var i = t("./CCAsset") | |
, n = t("../event/event-target") | |
, r = cc.Enum({ | |
WEB_AUDIO: 0, | |
DOM_AUDIO: 1 | |
}) | |
, s = cc.Class({ | |
name: "cc.AudioClip", | |
extends: i, | |
mixins: [n], | |
ctor: function() { | |
this._loading = !1, | |
this.loaded = !1, | |
this._audio = null | |
}, | |
properties: { | |
duration: 0, | |
loadMode: { | |
default: r.WEB_AUDIO, | |
type: r | |
}, | |
_nativeAsset: { | |
get: function() { | |
return this._audio | |
}, | |
set: function(t) { | |
t instanceof cc.AudioClip ? this._audio = t._nativeAsset : this._audio = t, | |
this._audio && (this.loaded = !0, | |
this.emit("load")) | |
}, | |
override: !0 | |
}, | |
_nativeDep: { | |
get: function() { | |
return { | |
uuid: this._uuid, | |
audioLoadMode: this.loadMode, | |
ext: cc.path.extname(this._native), | |
__isNative__: !0 | |
} | |
}, | |
override: !0 | |
} | |
}, | |
statics: { | |
LoadMode: r, | |
_loadByUrl: null | |
}, | |
_ensureLoaded: function(t) { | |
if (this.isValid) { | |
if (this.loaded) | |
return t && t(); | |
if (t && this.once("load", t), | |
!this._loading) { | |
this._loading = !0; | |
var e = this; | |
cc.assetManager.postLoadNative(this, (function() { | |
e._loading = !1 | |
} | |
)) | |
} | |
} | |
} | |
}); | |
cc.AudioClip = s, | |
e.exports = s | |
} | |
), { | |
"../event/event-target": 134, | |
"./CCAsset": 57 | |
}], | |
59: [(function(t, e) { | |
"use strict"; | |
var i = function() { | |
this.u = 0, | |
this.v = 0, | |
this.w = 0, | |
this.h = 0, | |
this.offsetX = 0, | |
this.offsetY = 0, | |
this.textureID = 0, | |
this.valid = !1, | |
this.xAdvance = 0 | |
} | |
, n = function(t) { | |
this._letterDefinitions = {}, | |
this._texture = t | |
}; | |
n.prototype = { | |
constructor: n, | |
addLetterDefinitions: function(t, e) { | |
this._letterDefinitions[t] = e | |
}, | |
cloneLetterDefinition: function() { | |
var t = {}; | |
for (var e in this._letterDefinitions) { | |
var n = new i; | |
cc.js.mixin(n, this._letterDefinitions[e]), | |
t[e] = n | |
} | |
return t | |
}, | |
getTexture: function() { | |
return this._texture | |
}, | |
getLetter: function(t) { | |
return this._letterDefinitions[t] | |
}, | |
getLetterDefinitionForChar: function(t) { | |
var e = t.charCodeAt(0); | |
return this._letterDefinitions.hasOwnProperty(e) ? this._letterDefinitions[e] : null | |
}, | |
clear: function() { | |
this._letterDefinitions = {} | |
} | |
}; | |
var r = cc.Class({ | |
name: "cc.BitmapFont", | |
extends: cc.Font, | |
properties: { | |
fntDataStr: { | |
default: "" | |
}, | |
spriteFrame: { | |
default: null, | |
type: cc.SpriteFrame | |
}, | |
fontSize: { | |
default: -1 | |
}, | |
_fntConfig: null, | |
_fontDefDictionary: null | |
}, | |
onLoad: function() { | |
var t = this.spriteFrame; | |
this._fontDefDictionary || (this._fontDefDictionary = new n, | |
t && (this._fontDefDictionary._texture = t._texture)); | |
var e = this._fntConfig; | |
if (e) { | |
var r = e.fontDefDictionary; | |
for (var s in r) { | |
var a = new i | |
, o = r[s].rect; | |
a.offsetX = r[s].xOffset, | |
a.offsetY = r[s].yOffset, | |
a.w = o.width, | |
a.h = o.height, | |
a.u = o.x, | |
a.v = o.y, | |
a.textureID = 0, | |
a.valid = !0, | |
a.xAdvance = r[s].xAdvance, | |
this._fontDefDictionary.addLetterDefinitions(s, a) | |
} | |
} | |
} | |
}); | |
cc.BitmapFont = r, | |
cc.BitmapFont.FontLetterDefinition = i, | |
cc.BitmapFont.FontAtlas = n, | |
e.exports = r | |
} | |
), {}], | |
60: [(function(t, e) { | |
"use strict"; | |
var i = 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 | |
}, | |
buffer: function() { | |
return this._buffer | |
} | |
} | |
}); | |
cc.BufferAsset = e.exports = i | |
} | |
), {}], | |
61: [(function(t, e) { | |
"use strict"; | |
var i = cc.Class({ | |
name: "cc.Font", | |
extends: cc.Asset | |
}); | |
cc.Font = e.exports = i | |
} | |
), {}], | |
62: [(function(t, e) { | |
"use strict"; | |
var i = cc.Class({ | |
name: "cc.JsonAsset", | |
extends: cc.Asset, | |
properties: { | |
json: null | |
} | |
}); | |
e.exports = cc.JsonAsset = i | |
} | |
), {}], | |
63: [(function(t, e) { | |
"use strict"; | |
var i = cc.Class({ | |
name: "cc.LabelAtlas", | |
extends: cc.BitmapFont, | |
onLoad: function() { | |
this.spriteFrame && this._fntConfig && this._super() | |
} | |
}); | |
cc.LabelAtlas = i, | |
e.exports = i | |
} | |
), {}], | |
64: [(function(t, e) { | |
"use strict"; | |
var i = cc.Enum({ | |
AUTO: 0, | |
SINGLE_INSTANCE: 1, | |
MULTI_INSTANCE: 2 | |
}) | |
, n = cc.Class({ | |
name: "cc.Prefab", | |
extends: cc.Asset, | |
ctor: function() { | |
this._createFunction = null, | |
this._instantiatedTimes = 0 | |
}, | |
properties: { | |
data: null, | |
optimizationPolicy: i.AUTO, | |
asyncLoadAssets: !1, | |
readonly: { | |
default: !1, | |
editorOnly: !0 | |
} | |
}, | |
statics: { | |
OptimizationPolicy: i, | |
OptimizationPolicyThreshold: 3 | |
}, | |
createNode: !1, | |
compileCreateFunction: function() { | |
var e = t("../platform/instantiate-jit"); | |
this._createFunction = e.compile(this.data) | |
}, | |
_doInstantiate: function(t) { | |
return this.data._prefab, | |
this._createFunction || this.compileCreateFunction(), | |
this._createFunction(t) | |
}, | |
_instantiate: function() { | |
var t; | |
return this.optimizationPolicy !== i.SINGLE_INSTANCE && (this.optimizationPolicy === i.MULTI_INSTANCE || this._instantiatedTimes + 1 >= n.OptimizationPolicyThreshold) ? (t = this._doInstantiate(), | |
this.data._instantiate(t)) : t = this.data._instantiate(), | |
++this._instantiatedTimes, | |
t | |
}, | |
destroy: function() { | |
this.data && this.data.destroy(), | |
this._super() | |
} | |
}); | |
cc.Prefab = e.exports = n, | |
cc.js.obsolete(cc, "cc._Prefab", "Prefab") | |
} | |
), { | |
"../platform/instantiate-jit": 181 | |
}], | |
65: [(function(t, e) { | |
"use strict"; | |
var i, n = (i = t("../../renderer/gfx")) && i.__esModule ? i : { | |
default: i | |
}, r = t("../renderer"), s = t("./CCTexture2D"), a = cc.Enum({ | |
RB_FMT_D24S8: n.default.RB_FMT_D24S8, | |
RB_FMT_S8: n.default.RB_FMT_S8, | |
RB_FMT_D16: n.default.RB_FMT_D16 | |
}), o = cc.Class({ | |
name: "cc.RenderTexture", | |
extends: s, | |
statics: { | |
DepthStencilFormat: a | |
}, | |
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), | |
this._resetUnderlyingMipmaps(); | |
var s, a = { | |
colors: [this._texture] | |
}; | |
this._depthStencilBuffer && this._depthStencilBuffer.destroy(), | |
i && (s = new n.default.RenderBuffer(r.device,i,t,e), | |
i === n.default.RB_FMT_D24S8 ? a.depthStencil = s : i === n.default.RB_FMT_S8 ? a.stencil = s : i === n.default.RB_FMT_D16 && (a.depth = s)), | |
this._depthStencilBuffer = s, | |
this._framebuffer && this._framebuffer.destroy(), | |
this._framebuffer = new n.default.FrameBuffer(r.device,t,e,a), | |
this._packable = !1, | |
this.loaded = !0, | |
this.emit("load") | |
}, | |
updateSize: function(t, e) { | |
this.width = Math.floor(t || cc.visibleRect.width), | |
this.height = Math.floor(e || cc.visibleRect.height), | |
this._resetUnderlyingMipmaps(); | |
var i = this._depthStencilBuffer; | |
i && i.update(this.width, this.height), | |
this._framebuffer._width = t, | |
this._framebuffer._height = e | |
}, | |
drawTextureAt: function(t, e, i) { | |
t._image && 0 !== t._image.width && 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, n, r) { | |
if (!this._framebuffer || !this._texture) | |
return t; | |
e = e || 0, | |
i = i || 0; | |
var s = n || this.width | |
, a = r || this.height; | |
t = t || new Uint8Array(s * a * 4); | |
var o = cc.game._renderContext | |
, c = o.getParameter(o.FRAMEBUFFER_BINDING); | |
return o.bindFramebuffer(o.FRAMEBUFFER, this._framebuffer.getHandle()), | |
o.readPixels(e, i, s, a, o.RGBA, o.UNSIGNED_BYTE, t), | |
o.bindFramebuffer(o.FRAMEBUFFER, c), | |
t | |
}, | |
destroy: function() { | |
this._super(), | |
this._framebuffer && (this._framebuffer.destroy(), | |
this._framebuffer = null) | |
} | |
}); | |
cc.RenderTexture = e.exports = o | |
} | |
), { | |
"../../renderer/gfx": 282, | |
"../renderer": 193, | |
"./CCTexture2D": 72 | |
}], | |
66: [(function(t, e) { | |
"use strict"; | |
var i = cc.Class({ | |
name: "cc.SceneAsset", | |
extends: cc.Asset, | |
properties: { | |
scene: null, | |
asyncLoadAssets: void 0 | |
} | |
}); | |
cc.SceneAsset = i, | |
e.exports = i | |
} | |
), {}], | |
67: [(function() { | |
"use strict"; | |
var t = cc.Class({ | |
name: "cc.Script", | |
extends: cc.Asset | |
}); | |
cc._Script = t; | |
var e = cc.Class({ | |
name: "cc.JavaScript", | |
extends: t | |
}); | |
cc._JavaScript = e; | |
var i = cc.Class({ | |
name: "cc.TypeScript", | |
extends: t | |
}); | |
cc._TypeScript = i | |
} | |
), {}], | |
68: [(function(t, e) { | |
"use strict"; | |
var i = 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]; | |
return e ? (e.name || (e.name = t), | |
e) : null | |
}, | |
getSpriteFrames: function() { | |
var t = [] | |
, e = this._spriteFrames; | |
for (var i in e) | |
t.push(this.getSpriteFrame(i)); | |
return t | |
} | |
}); | |
cc.SpriteAtlas = i, | |
e.exports = i | |
} | |
), {}], | |
69: [(function(t, e) { | |
"use strict"; | |
var i = t("../event/event-target") | |
, n = [{ | |
u: 0, | |
v: 0 | |
}, { | |
u: 0, | |
v: 0 | |
}, { | |
u: 0, | |
v: 0 | |
}, { | |
u: 0, | |
v: 0 | |
}] | |
, r = cc.Class({ | |
name: "cc.SpriteFrame", | |
extends: t("../assets/CCAsset"), | |
mixins: [i], | |
properties: { | |
_textureSetter: { | |
set: function(t) { | |
t && this._texture !== t && this._refreshTexture(t) | |
} | |
}, | |
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() { | |
i.call(this); | |
var t = arguments[0] | |
, e = arguments[1] | |
, n = arguments[2] | |
, r = arguments[3] | |
, s = arguments[4]; | |
this._rect = null, | |
this.uv = [], | |
this._texture = null, | |
this._original = null, | |
this._offset = null, | |
this._originalSize = null, | |
this._rotated = !1, | |
this._flipX = !1, | |
this._flipY = !1, | |
this.vertices = null, | |
this._capInsets = [0, 0, 0, 0], | |
this.uvSliced = [], | |
void 0 !== t && this.setTexture(t, e, n, r, s) | |
}, | |
textureLoaded: function() { | |
return this._texture && this._texture.loaded | |
}, | |
onTextureLoaded: function(t, e) { | |
return this.textureLoaded() ? (t.call(e), | |
!0) : (this.once("load", t, e), | |
this.ensureLoadTexture(), | |
!1) | |
}, | |
isRotated: function() { | |
return this._rotated | |
}, | |
setRotated: function(t) { | |
this._rotated = t, | |
this._texture && this._calculateUV() | |
}, | |
isFlipX: function() { | |
return this._flipX | |
}, | |
isFlipY: function() { | |
return this._flipY | |
}, | |
setFlipX: function(t) { | |
this._flipX = t, | |
this._texture && this._calculateUV() | |
}, | |
setFlipY: function(t) { | |
this._flipY = 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) { | |
this._originalSize ? (this._originalSize.width = t.width, | |
this._originalSize.height = t.height) : 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; | |
this._rect ? this._checkRect(this._texture) : this._rect = cc.rect(0, 0, e, i), | |
this._originalSize || (this._originalSize = cc.size(e, i)), | |
this._offset || (this._offset = 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 r(this._texture,this.getRect(),this._rotated,this.getOffset(),this.getOriginalSize()) | |
}, | |
setTexture: function(t, e, i, n, r) { | |
if ((1 !== arguments.length || t !== this._texture) && (this._rect = e || null, | |
n ? this.setOffset(n) : this._offset = null, | |
r ? this.setOriginalSize(r) : this._originalSize = null, | |
this._rotated = i || !1, | |
"string" != typeof t)) | |
return t instanceof cc.Texture2D && this._refreshTexture(t), | |
!0 | |
}, | |
ensureLoadTexture: function() { | |
this._texture && (this._texture.loaded || (this._refreshTexture(this._texture), | |
cc.assetManager.postLoadNative(this._texture))) | |
}, | |
_checkRect: function(t) { | |
var e = this._rect; | |
e.x, | |
e.y, | |
this._rotated ? (e.height, | |
e.width) : (e.width, | |
e.height), | |
t.width, | |
t.height | |
}, | |
_flipXY: function(t) { | |
if (this._flipX) { | |
var e = t[0]; | |
t[0] = t[1], | |
t[1] = e, | |
e = t[2], | |
t[2] = t[3], | |
t[3] = e | |
} | |
if (this._flipY) { | |
var i = t[0]; | |
t[0] = t[2], | |
t[2] = i, | |
i = t[1], | |
t[1] = t[3], | |
t[3] = i | |
} | |
}, | |
_calculateSlicedUV: function() { | |
var t = this._rect | |
, e = this._texture.width | |
, i = this._texture.height | |
, r = this._capInsets[0] | |
, s = this._capInsets[2] | |
, a = t.width - r - s | |
, o = this._capInsets[1] | |
, c = this._capInsets[3] | |
, l = t.height - o - c | |
, h = this.uvSliced; | |
if (h.length = 0, | |
this._rotated) { | |
n[0].u = t.x / e, | |
n[1].u = (t.x + c) / e, | |
n[2].u = (t.x + c + l) / e, | |
n[3].u = (t.x + t.height) / e, | |
n[3].v = t.y / i, | |
n[2].v = (t.y + r) / i, | |
n[1].v = (t.y + r + a) / i, | |
n[0].v = (t.y + t.width) / i, | |
this._flipXY(n); | |
for (var u = 0; u < 4; ++u) | |
for (var f = n[u], d = 0; d < 4; ++d) { | |
var _ = n[3 - d]; | |
h.push({ | |
u: f.u, | |
v: _.v | |
}) | |
} | |
} else { | |
n[0].u = t.x / e, | |
n[1].u = (t.x + r) / e, | |
n[2].u = (t.x + r + a) / e, | |
n[3].u = (t.x + t.width) / e, | |
n[3].v = t.y / i, | |
n[2].v = (t.y + o) / i, | |
n[1].v = (t.y + o + l) / i, | |
n[0].v = (t.y + t.height) / i, | |
this._flipXY(n); | |
for (var p = 0; p < 4; ++p) | |
for (var v = n[p], g = 0; g < 4; ++g) { | |
var m = n[g]; | |
h.push({ | |
u: m.u, | |
v: v.v | |
}) | |
} | |
} | |
}, | |
_setDynamicAtlasFrame: function(t) { | |
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() { | |
this._original && (this._rect.x = this._original._x, | |
this._rect.y = this._original._y, | |
this._texture = this._original._texture, | |
this._original = null, | |
this._texture.loaded ? this._calculateUV() : this.ensureLoadTexture()) | |
}, | |
_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 | |
, a = 0 === n ? 0 : (t.x + t.height) / n | |
, o = 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] = o, | |
i[4] = a, | |
i[5] = c, | |
i[6] = a, | |
i[7] = o | |
} else { | |
var l = 0 === n ? 0 : t.x / n | |
, h = 0 === n ? 0 : (t.x + t.width) / n | |
, u = 0 === r ? 0 : (t.y + t.height) / r | |
, f = 0 === r ? 0 : t.y / r; | |
i[0] = l, | |
i[1] = u, | |
i[2] = h, | |
i[3] = u, | |
i[4] = l, | |
i[5] = f, | |
i[6] = h, | |
i[7] = f | |
} | |
if (this._flipX) { | |
var d = i[0]; | |
i[0] = i[2], | |
i[2] = d, | |
d = i[1], | |
i[1] = i[3], | |
i[3] = d, | |
d = i[4], | |
i[4] = i[6], | |
i[6] = d, | |
d = i[5], | |
i[5] = i[7], | |
i[7] = d | |
} | |
if (this._flipY) { | |
var _ = i[0]; | |
i[0] = i[4], | |
i[4] = _, | |
_ = i[1], | |
i[1] = i[5], | |
i[5] = _, | |
_ = i[2], | |
i[2] = i[6], | |
i[6] = _, | |
_ = i[3], | |
i[3] = i[7], | |
i[7] = _ | |
} | |
var p = this.vertices; | |
if (p) { | |
p.nu.length = 0, | |
p.nv.length = 0; | |
for (var v = 0; v < p.u.length; v++) | |
p.nu[v] = p.u[v] / n, | |
p.nv[v] = p.v[v] / r | |
} | |
this._calculateSlicedUV() | |
}, | |
_serialize: !1, | |
_deserialize: function(t) { | |
var e = t.rect; | |
e && (this._rect = new cc.Rect(e[0],e[1],e[2],e[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 i = t.capInsets; | |
i && (this._capInsets[0] = i[0], | |
this._capInsets[1] = i[1], | |
this._capInsets[2] = i[2], | |
this._capInsets[3] = i[3]), | |
this.vertices = t.vertices, | |
this.vertices && (this.vertices.nu = [], | |
this.vertices.nv = []) | |
} | |
}) | |
, s = r.prototype; | |
s.copyWithZone = s.clone, | |
s.copy = s.clone, | |
s.initWithTexture = s.setTexture, | |
cc.SpriteFrame = r, | |
e.exports = r | |
} | |
), { | |
"../assets/CCAsset": 57, | |
"../event/event-target": 134 | |
}], | |
70: [(function(t, e) { | |
"use strict"; | |
var i = t("./CCFont") | |
, n = cc.Class({ | |
name: "cc.TTFFont", | |
extends: i, | |
properties: { | |
_fontFamily: null, | |
_nativeAsset: { | |
type: cc.String, | |
get: function() { | |
return this._fontFamily | |
}, | |
set: function(t) { | |
this._fontFamily = t || "Arial" | |
}, | |
override: !0 | |
}, | |
_nativeDep: { | |
get: function() { | |
return { | |
uuid: this._uuid, | |
__nativeName__: this._native, | |
ext: cc.path.extname(this._native), | |
__isNative__: !0 | |
} | |
}, | |
override: !0 | |
} | |
} | |
}); | |
cc.TTFFont = e.exports = n | |
} | |
), { | |
"./CCFont": 61 | |
}], | |
71: [(function(t, e) { | |
"use strict"; | |
var i = cc.Class({ | |
name: "cc.TextAsset", | |
extends: cc.Asset, | |
properties: { | |
text: "" | |
}, | |
toString: function() { | |
return this.text | |
} | |
}); | |
e.exports = cc.TextAsset = i | |
} | |
), {}], | |
72: [(function(t, e) { | |
"use strict"; | |
var i, n = (i = t("../../renderer/gfx")) && i.__esModule ? i : { | |
default: i | |
}, r = t("../event/event-target"), s = t("../renderer"); | |
t("../platform/CCClass"); | |
var a = new (t("../platform/id-generater"))("Tex") | |
, o = 1024 | |
, c = cc.Enum({ | |
RGB565: n.default.TEXTURE_FMT_R5_G6_B5, | |
RGB5A1: n.default.TEXTURE_FMT_R5_G5_B5_A1, | |
RGBA4444: n.default.TEXTURE_FMT_R4_G4_B4_A4, | |
RGB888: n.default.TEXTURE_FMT_RGB8, | |
RGBA8888: n.default.TEXTURE_FMT_RGBA8, | |
RGBA32F: n.default.TEXTURE_FMT_RGBA32F, | |
A8: n.default.TEXTURE_FMT_A8, | |
I8: n.default.TEXTURE_FMT_L8, | |
AI8: n.default.TEXTURE_FMT_L8_A8, | |
RGB_PVRTC_2BPPV1: n.default.TEXTURE_FMT_RGB_PVRTC_2BPPV1, | |
RGBA_PVRTC_2BPPV1: n.default.TEXTURE_FMT_RGBA_PVRTC_2BPPV1, | |
RGB_A_PVRTC_2BPPV1: o++, | |
RGB_PVRTC_4BPPV1: n.default.TEXTURE_FMT_RGB_PVRTC_4BPPV1, | |
RGBA_PVRTC_4BPPV1: n.default.TEXTURE_FMT_RGBA_PVRTC_4BPPV1, | |
RGB_A_PVRTC_4BPPV1: o++, | |
RGB_ETC1: n.default.TEXTURE_FMT_RGB_ETC1, | |
RGBA_ETC1: o++, | |
RGB_ETC2: n.default.TEXTURE_FMT_RGB_ETC2, | |
RGBA_ETC2: n.default.TEXTURE_FMT_RGBA_ETC2 | |
}) | |
, l = cc.Enum({ | |
REPEAT: 10497, | |
CLAMP_TO_EDGE: 33071, | |
MIRRORED_REPEAT: 33648 | |
}) | |
, h = cc.Enum({ | |
LINEAR: 9729, | |
NEAREST: 9728 | |
}) | |
, u = { | |
9728: 0, | |
9729: 1 | |
} | |
, f = [] | |
, d = { | |
width: void 0, | |
height: void 0, | |
minFilter: void 0, | |
magFilter: void 0, | |
wrapS: void 0, | |
wrapT: void 0, | |
format: void 0, | |
genMipmaps: void 0, | |
images: void 0, | |
image: void 0, | |
flipY: void 0, | |
premultiplyAlpha: void 0 | |
}; | |
function _() { | |
for (var t in d) | |
d[t] = void 0; | |
return f.length = 0, | |
d.images = f, | |
d | |
} | |
var p = cc.Class({ | |
name: "cc.Texture2D", | |
extends: t("../assets/CCAsset"), | |
mixins: [r], | |
properties: { | |
_nativeAsset: { | |
get: function() { | |
return this._image | |
}, | |
set: function(t) { | |
t._compressed && t._data ? this.initWithData(t._data, this._format, t.width, t.height) : this.initWithElement(t) | |
}, | |
override: !0 | |
}, | |
_format: c.RGBA8888, | |
_premultiplyAlpha: !1, | |
_flipY: !1, | |
_minFilter: h.LINEAR, | |
_magFilter: h.LINEAR, | |
_mipFilter: h.LINEAR, | |
_wrapS: l.CLAMP_TO_EDGE, | |
_wrapT: l.CLAMP_TO_EDGE, | |
_isAlphaAtlas: !1, | |
_genMipmaps: !1, | |
genMipmaps: { | |
get: function() { | |
return this._genMipmaps | |
}, | |
set: function(t) { | |
if (this._genMipmaps !== t) { | |
var e = _(); | |
e.genMipmaps = t, | |
this.update(e) | |
} | |
} | |
}, | |
_packable: !0, | |
packable: { | |
get: function() { | |
return this._packable | |
}, | |
set: function(t) { | |
this._packable = t | |
} | |
}, | |
_nativeDep: { | |
get: function() { | |
return { | |
__isNative__: !0, | |
uuid: this._uuid, | |
ext: this._native, | |
__flipY__: this._flipY, | |
__premultiplyAlpha__: this._premultiplyAlpha | |
} | |
}, | |
override: !0 | |
} | |
}, | |
statics: { | |
PixelFormat: c, | |
WrapMode: l, | |
Filter: h, | |
_FilterIndex: u, | |
extnames: [".png", ".jpg", ".jpeg", ".bmp", ".webp", ".pvr", ".pkm"], | |
_parseExt: function(t, e) { | |
for (var i = cc.renderer.device, n = t.split("_"), r = "", s = "", a = 999, o = e, l = cc.macro.SUPPORT_TEXTURE_FORMATS, h = 0; h < n.length; h++) { | |
var u = n[h].split("@") | |
, f = u[0]; | |
f = p.extnames[f.charCodeAt(0) - 48] || f; | |
var d = l.indexOf(f); | |
if (-1 !== d && d < a) { | |
var _ = u[1] ? parseInt(u[1]) : e; | |
if (".pvr" === f && !i.ext("WEBGL_compressed_texture_pvrtc")) | |
continue; | |
if (!(_ !== c.RGB_ETC1 && _ !== c.RGBA_ETC1 || i.ext("WEBGL_compressed_texture_etc1"))) | |
continue; | |
if (!(_ !== c.RGB_ETC2 && _ !== c.RGBA_ETC2 || i.ext("WEBGL_compressed_texture_etc"))) | |
continue; | |
if (".webp" === f && !cc.sys.capabilities.webp) | |
continue; | |
a = d, | |
s = f, | |
o = _ | |
} else | |
r || (r = f) | |
} | |
return { | |
bestExt: s, | |
bestFormat: o, | |
defaultExt: r | |
} | |
} | |
}, | |
ctor: function() { | |
this._id = a.getNewId(), | |
this.loaded = !1, | |
this.width = 0, | |
this.height = 0, | |
this._hashDirty = !0, | |
this._hash = 0, | |
this._texture = null | |
}, | |
getImpl: function() { | |
return this._texture || (this._texture = new s.Texture2D(s.device,{})), | |
this._texture | |
}, | |
getId: function() { | |
return this._id | |
}, | |
toString: function() { | |
return this.nativeUrl || "" | |
}, | |
update: function(t) { | |
if (t) { | |
var e = !1; | |
void 0 !== t.width && (this.width = t.width), | |
void 0 !== t.height && (this.height = t.height), | |
void 0 !== t.minFilter && (this._minFilter = t.minFilter, | |
t.minFilter = u[t.minFilter]), | |
void 0 !== t.magFilter && (this._magFilter = t.magFilter, | |
t.magFilter = u[t.magFilter]), | |
void 0 !== t.mipFilter && (this._mipFilter = t.mipFilter, | |
t.mipFilter = u[t.mipFilter]), | |
void 0 !== t.wrapS && (this._wrapS = t.wrapS), | |
void 0 !== t.wrapT && (this._wrapT = t.wrapT), | |
void 0 !== t.format && (this._format = t.format), | |
void 0 !== t.flipY && (this._flipY = t.flipY, | |
e = !0), | |
void 0 !== t.premultiplyAlpha && (this._premultiplyAlpha = t.premultiplyAlpha, | |
e = !0), | |
void 0 !== t.genMipmaps && (this._genMipmaps = t.genMipmaps), | |
cc.sys.capabilities.imageBitmap && this._image instanceof ImageBitmap ? this._checkImageBitmap(this._upload.bind(this, t, e)) : this._upload(t, e) | |
} | |
}, | |
_upload: function(t, e) { | |
e && this._image && (t.image = this._image), | |
t.images && t.images.length > 0 ? this._image = t.images[0] : void 0 !== t.image && (this._image = t.image, | |
t.images || (f.length = 0, | |
t.images = f), | |
t.images.push(t.image)), | |
this._texture && this._texture.update(t), | |
this._hashDirty = !0 | |
}, | |
initWithElement: function(t) { | |
if (t) | |
if (this._image = t, | |
t.complete || t instanceof HTMLCanvasElement) | |
this.handleLoadedTexture(); | |
else if (cc.sys.capabilities.imageBitmap && t instanceof ImageBitmap) | |
this._checkImageBitmap(this.handleLoadedTexture.bind(this)); | |
else { | |
var e = this; | |
t.addEventListener("load", (function() { | |
e.handleLoadedTexture() | |
} | |
)), | |
t.addEventListener("error", (function() {} | |
)) | |
} | |
}, | |
initWithData: function(t, e, i, n) { | |
var r = _(); | |
return r.image = t, | |
r.images = [r.image], | |
r.genMipmaps = this._genMipmaps, | |
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 = this._getGFXPixelFormat(e), | |
r.width = i, | |
r.height = n, | |
this._texture ? this._texture.update(r) : this._texture = new s.Texture2D(s.device,r), | |
this.width = i, | |
this.height = n, | |
this._updateFormat(), | |
this._checkPackable(), | |
this.loaded = !0, | |
this.emit("load"), | |
!0 | |
}, | |
getHtmlElementObj: function() { | |
return this._image | |
}, | |
destroy: function() { | |
cc.sys.capabilities.imageBitmap && this._image instanceof ImageBitmap && this._image.close && this._image.close(), | |
this._packable && cc.dynamicAtlasManager && cc.dynamicAtlasManager.deleteAtlasTexture(this), | |
this._image = null, | |
this._texture && this._texture.destroy(), | |
this._super() | |
}, | |
getPixelFormat: function() { | |
return this._format | |
}, | |
hasPremultipliedAlpha: function() { | |
return this._premultiplyAlpha || !1 | |
}, | |
isAlphaAtlas: function() { | |
return this._isAlphaAtlas | |
}, | |
handleLoadedTexture: function() { | |
if (this._image && this._image.width && this._image.height) { | |
this.width = this._image.width, | |
this.height = this._image.height; | |
var t = _(); | |
t.image = this._image, | |
t.images = [t.image], | |
t.width = this.width, | |
t.height = this.height, | |
t.genMipmaps = this._genMipmaps, | |
t.format = this._getGFXPixelFormat(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._updateFormat(), | |
this._checkPackable(), | |
this.loaded = !0, | |
this.emit("load"), | |
cc.macro.CLEANUP_IMAGE_CACHE && this._cleanupImageCache() | |
} | |
}, | |
_cleanupImageCache: function() { | |
this._image instanceof HTMLImageElement ? this._clearImage() : cc.sys.capabilities.imageBitmap && this._image instanceof ImageBitmap && this._image.close && this._image.close() | |
}, | |
description: function() { | |
return "<cc.Texture2D | Name = " + this.nativeUrl + " | 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 = _(); | |
i.wrapS = t, | |
i.wrapT = e, | |
this.update(i) | |
} | |
}, | |
setFilters: function(t, e) { | |
if (this._minFilter !== t || this._magFilter !== e) { | |
var i = _(); | |
i.minFilter = t, | |
i.magFilter = e, | |
this.update(i) | |
} | |
}, | |
setFlipY: function(t) { | |
if (this._flipY !== t) { | |
var e = _(); | |
e.flipY = t, | |
e.premultiplyAlpha = this._premultiplyAlpha, | |
this.update(e) | |
} | |
}, | |
setPremultiplyAlpha: function(t) { | |
if (this._premultiplyAlpha !== t) { | |
var e = _(); | |
e.flipY = this._flipY, | |
e.premultiplyAlpha = t, | |
this.update(e) | |
} | |
}, | |
_updateFormat: function() { | |
this._isAlphaAtlas = this._format === c.RGBA_ETC1 || this._format === c.RGB_A_PVRTC_4BPPV1 || this._format === c.RGB_A_PVRTC_2BPPV1 | |
}, | |
_checkPackable: function() { | |
var t = cc.dynamicAtlasManager; | |
if (t) | |
if (this._isCompressed()) | |
this._packable = !1; | |
else { | |
var e = this.width | |
, i = this.height; | |
!this._image || e > t.maxFrameSize || i > t.maxFrameSize || this._getHash() !== t.Atlas.DEFAULT_HASH ? this._packable = !1 : this._image && this._image instanceof HTMLCanvasElement && (this._packable = !0) | |
} | |
}, | |
_getOpts: function() { | |
var t = _(); | |
return t.width = this.width, | |
t.height = this.height, | |
t.genMipmaps = this._genMipmaps, | |
t.format = this._format, | |
t.premultiplyAlpha = this._premultiplyAlpha, | |
t.anisotropy = this._anisotropy, | |
t.flipY = this._flipY, | |
t.minFilter = u[this._minFilter], | |
t.magFilter = u[this._magFilter], | |
t.mipFilter = u[this._mipFilter], | |
t.wrapS = this._wrapS, | |
t.wrapT = this._wrapT, | |
t | |
}, | |
_getGFXPixelFormat: function(t) { | |
return t === c.RGBA_ETC1 ? t = c.RGB_ETC1 : t === c.RGB_A_PVRTC_4BPPV1 ? t = c.RGB_PVRTC_4BPPV1 : t === c.RGB_A_PVRTC_2BPPV1 && (t = c.RGB_PVRTC_2BPPV1), | |
t | |
}, | |
_resetUnderlyingMipmaps: function(t) { | |
var e = this._getOpts(); | |
e.images = t || [null], | |
this._texture ? this._texture.update(e) : this._texture = new s.Texture2D(s.device,e) | |
}, | |
_serialize: !1, | |
_deserialize: function(t) { | |
var e = t.split(",") | |
, i = e[0]; | |
if (i) { | |
var n = p._parseExt(i, this._format); | |
if (n.bestExt) | |
this._setRawAsset(n.bestExt), | |
this._format = n.bestFormat; | |
else { | |
if (!n.defaultExt) | |
throw Error(cc.debug.getError(3121)); | |
this._setRawAsset(n.defaultExt) | |
} | |
} | |
8 === e.length && (this._minFilter = parseInt(e[1]), | |
this._magFilter = parseInt(e[2]), | |
this._wrapS = parseInt(e[3]), | |
this._wrapT = parseInt(e[4]), | |
this._premultiplyAlpha = 49 === e[5].charCodeAt(0), | |
this._genMipmaps = 49 === e[6].charCodeAt(0), | |
this._packable = 49 === e[7].charCodeAt(0)) | |
}, | |
_getHash: function() { | |
if (!this._hashDirty) | |
return this._hash; | |
var t = this._genMipmaps ? 1 : 0 | |
, e = this._premultiplyAlpha ? 1 : 0 | |
, i = this._flipY ? 1 : 0 | |
, n = this._minFilter === h.LINEAR ? 1 : 2 | |
, r = this._magFilter === h.LINEAR ? 1 : 2 | |
, s = this._wrapS === l.REPEAT ? 1 : this._wrapS === l.CLAMP_TO_EDGE ? 2 : 3 | |
, a = this._wrapT === l.REPEAT ? 1 : this._wrapT === l.CLAMP_TO_EDGE ? 2 : 3 | |
, o = this._format; | |
return this._image, | |
this._hash = +("" + n + r + o + s + a + t + e + i), | |
this._hashDirty = !1, | |
this._hash | |
}, | |
_isCompressed: function() { | |
return this._format < c.A8 || this._format > c.RGBA32F | |
}, | |
_clearImage: function() { | |
this._image.src = "" | |
}, | |
_checkImageBitmap: function(t) { | |
var e = this | |
, i = this._image | |
, n = this._flipY | |
, r = this._premultiplyAlpha; | |
this._flipY !== i.flipY || this._premultiplyAlpha !== i.premultiplyAlpha ? createImageBitmap(i, { | |
imageOrientation: n !== i.flipY ? "flipY" : "none", | |
premultiplyAlpha: r ? "premultiply" : "none" | |
}).then((function(s) { | |
i.close && i.close(), | |
s.flipY = n, | |
s.premultiplyAlpha = r, | |
e._image = s, | |
t() | |
} | |
), (function() {} | |
)) : t() | |
} | |
}); | |
cc.Texture2D = e.exports = p | |
} | |
), { | |
"../../renderer/gfx": 282, | |
"../assets/CCAsset": 57, | |
"../event/event-target": 134, | |
"../platform/CCClass": 162, | |
"../platform/id-generater": 179, | |
"../renderer": 193 | |
}], | |
73: [(function(t, e) { | |
"use strict"; | |
var i = t("./CCAsset") | |
, n = t("../event/event-target") | |
, r = cc.Class({ | |
name: "cc.VideoClip", | |
extends: i, | |
mixins: [n] | |
}); | |
cc.VideoClip = r, | |
e.exports = r | |
} | |
), { | |
"../event/event-target": 134, | |
"./CCAsset": 57 | |
}], | |
74: [(function(t) { | |
"use strict"; | |
t("./CCAsset"), | |
t("./CCFont"), | |
t("./CCPrefab"), | |
t("./CCAudioClip"), | |
t("./CCVideoClip"), | |
t("./CCScripts"), | |
t("./CCSceneAsset"), | |
t("./CCSpriteFrame"), | |
t("./CCTexture2D"), | |
t("./CCRenderTexture"), | |
t("./CCTTFFont"), | |
t("./CCSpriteAtlas"), | |
t("./CCBitmapFont"), | |
t("./CCLabelAtlas"), | |
t("./CCTextAsset"), | |
t("./CCJsonAsset"), | |
t("./CCBufferAsset"), | |
t("./material") | |
} | |
), { | |
"./CCAsset": 57, | |
"./CCAudioClip": 58, | |
"./CCBitmapFont": 59, | |
"./CCBufferAsset": 60, | |
"./CCFont": 61, | |
"./CCJsonAsset": 62, | |
"./CCLabelAtlas": 63, | |
"./CCPrefab": 64, | |
"./CCRenderTexture": 65, | |
"./CCSceneAsset": 66, | |
"./CCScripts": 67, | |
"./CCSpriteAtlas": 68, | |
"./CCSpriteFrame": 69, | |
"./CCTTFFont": 70, | |
"./CCTextAsset": 71, | |
"./CCTexture2D": 72, | |
"./CCVideoClip": 73, | |
"./material": 81 | |
}], | |
75: [(function(t, e) { | |
"use strict"; | |
var i, n = (i = t("../CCAsset")) && i.__esModule ? i : { | |
default: i | |
}, r = t("./effect-parser"), s = cc.Class({ | |
name: "cc.EffectAsset", | |
extends: n.default, | |
ctor: function() { | |
this._effect = null | |
}, | |
properties: { | |
properties: Object, | |
techniques: [], | |
shaders: [] | |
}, | |
onLoad: function() { | |
if (cc.game.renderType !== cc.game.RENDER_TYPE_CANVAS) { | |
for (var t = cc.renderer._forward._programLib, e = 0; e < this.shaders.length; e++) | |
t.define(this.shaders[e]); | |
this._initEffect() | |
} | |
}, | |
_initEffect: function() { | |
this._effect || (this._effect = (0, | |
r.parseEffect)(this), | |
Object.freeze(this._effect)) | |
}, | |
getInstantiatedEffect: function() { | |
return this._initEffect(), | |
this._effect.clone() | |
}, | |
getEffect: function() { | |
return this._initEffect(), | |
this._effect | |
} | |
}); | |
e.exports = cc.EffectAsset = s | |
} | |
), { | |
"../CCAsset": 57, | |
"./effect-parser": 78 | |
}], | |
76: [(function(t, e, i) { | |
"use strict"; | |
i.__esModule = !0, | |
i.default = void 0; | |
var n = t("../CCAsset") | |
, r = t("../CCTexture2D") | |
, s = (r.PixelFormat, | |
t("./CCEffectAsset")) | |
, a = (t("../../utils/texture-util"), | |
cc.gfx) | |
, o = cc.Enum({ | |
SPRITE: "2d-sprite", | |
GRAY_SPRITE: "2d-gray-sprite", | |
UNLIT: "unlit" | |
}) | |
, c = cc.Class({ | |
name: "cc.Material", | |
extends: n, | |
ctor: function() { | |
this.loaded = !1, | |
this._manualHash = !1, | |
this._dirty = !0, | |
this._effect = null | |
}, | |
properties: { | |
_defines: { | |
default: void 0, | |
type: Object | |
}, | |
_props: { | |
default: void 0, | |
type: Object | |
}, | |
_effectAsset: { | |
type: s, | |
default: null | |
}, | |
_techniqueIndex: 0, | |
_techniqueData: Object, | |
effectName: void 0, | |
effectAsset: { | |
get: function() { | |
return this._effectAsset | |
}, | |
set: function(t) { | |
cc.game.renderType !== cc.game.RENDER_TYPE_CANVAS && (this._effectAsset = t, | |
t && (this._effect = this._effectAsset.getInstantiatedEffect())) | |
} | |
}, | |
effect: { | |
get: function() { | |
return this._effect | |
} | |
}, | |
techniqueIndex: { | |
get: function() { | |
return this._techniqueIndex | |
}, | |
set: function(t) { | |
this._techniqueIndex = t, | |
this._effect.switchTechnique(t) | |
} | |
} | |
}, | |
statics: { | |
getBuiltinMaterial: function(t) { | |
return cc.game.renderType === cc.game.RENDER_TYPE_CANVAS ? new cc.Material : cc.assetManager.builtins.getBuiltin("material", "builtin-" + t) | |
}, | |
BUILTIN_NAME: o, | |
createWithBuiltin: function(t, e) { | |
void 0 === e && (e = 0); | |
var i = cc.assetManager.builtins.getBuiltin("effect", "builtin-" + t); | |
return c.create(i, e) | |
}, | |
create: function(t, e) { | |
if (void 0 === e && (e = 0), | |
!t) | |
return null; | |
var i = new c; | |
return i.effectAsset = t, | |
i.techniqueIndex = e, | |
i | |
} | |
}, | |
setProperty: function(t, e, i, n) { | |
if (cc.game.renderType !== cc.game.RENDER_TYPE_CANVAS) { | |
if ("string" == typeof i && (i = parseInt(i)), | |
e instanceof r) { | |
var s = e.isAlphaAtlas() | |
, a = "CC_USE_ALPHA_ATLAS_" + t | |
, o = this.getDefine(a, i); | |
(s || o) && this.define(a, s), | |
e.loaded || cc.assetManager.postLoadNative(e) | |
} | |
this._effect.setProperty(t, e, i, n) | |
} | |
}, | |
getProperty: function(t, e) { | |
return "string" == typeof e && (e = parseInt(e)), | |
this._effect.getProperty(t, e) | |
}, | |
define: function(t, e, i, n) { | |
cc.game.renderType !== cc.game.RENDER_TYPE_CANVAS && ("string" == typeof i && (i = parseInt(i)), | |
this._effect.define(t, e, i, n)) | |
}, | |
getDefine: function(t, e) { | |
return "string" == typeof e && (e = parseInt(e)), | |
this._effect.getDefine(t, e) | |
}, | |
setCullMode: function(t, e) { | |
void 0 === t && (t = a.CULL_BACK), | |
this._effect.setCullMode(t, e) | |
}, | |
setDepth: function(t, e, i, n) { | |
void 0 === t && (t = !1), | |
void 0 === e && (e = !1), | |
void 0 === i && (i = a.DS_FUNC_LESS), | |
this._effect.setDepth(t, e, i, n) | |
}, | |
setBlend: function(t, e, i, n, r, s, o, c, l) { | |
void 0 === t && (t = !1), | |
void 0 === e && (e = a.BLEND_FUNC_ADD), | |
void 0 === i && (i = a.BLEND_SRC_ALPHA), | |
void 0 === n && (n = a.BLEND_ONE_MINUS_SRC_ALPHA), | |
void 0 === r && (r = a.BLEND_FUNC_ADD), | |
void 0 === s && (s = a.BLEND_SRC_ALPHA), | |
void 0 === o && (o = a.BLEND_ONE_MINUS_SRC_ALPHA), | |
void 0 === c && (c = 4294967295), | |
this._effect.setBlend(t, e, i, n, r, s, o, c, l) | |
}, | |
setStencilEnabled: function(t, e) { | |
void 0 === t && (t = a.STENCIL_INHERIT), | |
this._effect.setStencilEnabled(t, e) | |
}, | |
setStencil: function(t, e, i, n, r, s, o, c, l) { | |
void 0 === t && (t = a.STENCIL_INHERIT), | |
void 0 === e && (e = a.DS_FUNC_ALWAYS), | |
void 0 === i && (i = 0), | |
void 0 === n && (n = 255), | |
void 0 === r && (r = a.STENCIL_OP_KEEP), | |
void 0 === s && (s = a.STENCIL_OP_KEEP), | |
void 0 === o && (o = a.STENCIL_OP_KEEP), | |
void 0 === c && (c = 255), | |
this._effect.setStencil(t, e, i, n, r, s, o, c, l) | |
}, | |
updateHash: function(t) { | |
this._manualHash = t, | |
this._effect && this._effect.updateHash(t) | |
}, | |
getHash: function() { | |
return this._manualHash || this._effect && this._effect.getHash() | |
}, | |
onLoad: function() { | |
if (this.effectAsset = this._effectAsset, | |
this._effect) { | |
this._techniqueIndex && this._effect.switchTechnique(this._techniqueIndex), | |
this._techniqueData = this._techniqueData || {}; | |
var t = this._techniqueData; | |
for (var e in t) { | |
var i = t[e = parseInt(e)]; | |
if (i) { | |
for (var n in i.defines) | |
this.define(n, i.defines[n], e); | |
for (var r in i.props) | |
this.setProperty(r, i.props[r], e) | |
} | |
} | |
} | |
} | |
}) | |
, l = c; | |
i.default = l, | |
cc.Material = c, | |
e.exports = i.default | |
} | |
), { | |
"../../utils/texture-util": 244, | |
"../CCAsset": 57, | |
"../CCTexture2D": 72, | |
"./CCEffectAsset": 75 | |
}], | |
77: [(function(t, e, i) { | |
"use strict"; | |
i.__esModule = !0, | |
i.default = void 0; | |
var n = s(t("../../../renderer/core/pass")) | |
, r = s(t("../../../renderer/enums")); | |
function s(t) { | |
return t && t.__esModule ? t : { | |
default: t | |
} | |
} | |
function a(t, e) { | |
for (var i = 0; i < e.length; i++) { | |
var n = e[i]; | |
n.enumerable = n.enumerable || !1, | |
n.configurable = !0, | |
"value"in n && (n.writable = !0), | |
Object.defineProperty(t, n.key, n) | |
} | |
} | |
var o = cc.gfx | |
, c = (function() { | |
function t() { | |
this._dirty = !0, | |
this._name = "", | |
this._technique = null | |
} | |
var e, i, s = t.prototype; | |
return s._createPassProp = function(t, e) { | |
var i = e._properties[t]; | |
if (i) { | |
var n = Object.create(null); | |
return n.name = t, | |
n.type = i.type, | |
i.value instanceof Float32Array ? n.value = new Float32Array(i.value) : i.value instanceof Float64Array ? n.value = new Float64Array(i.value) : n.value = i.value, | |
e._properties[t] = n, | |
n | |
} | |
} | |
, | |
s._setPassProperty = function(t, e, i, s) { | |
var a = i._properties; | |
a.hasOwnProperty(t) || this._createPassProp(t, i); | |
var o = a[t] | |
, c = e; | |
return o.type === r.default.PARAM_TEXTURE_2D && (c = e && e.getImpl()), | |
o.value === c || (this._dirty = !0, | |
n.default.prototype.setProperty.call(i, t, e, s)) | |
} | |
, | |
s.setProperty = function(t, e, i, n) { | |
var r = this.passes | |
, s = 0 | |
, a = r.length; | |
void 0 !== i && (s = i, | |
a = i + 1); | |
for (var o = s; o < a; o++) | |
this._setPassProperty(t, e, r[o], n) | |
} | |
, | |
s.getProperty = function(t, e) { | |
var i = this.passes; | |
if (!(e >= i.length)) { | |
var n = 0 | |
, r = i.length; | |
void 0 !== e && (n = e, | |
r = e + 1); | |
for (var s = n; s < r; s++) { | |
var a = i[s].getProperty(t); | |
if (void 0 !== a) | |
return a | |
} | |
} | |
} | |
, | |
s.define = function(t, e, i, n) { | |
var r = this.passes | |
, s = 0 | |
, a = r.length; | |
void 0 !== i && (s = i, | |
a = i + 1); | |
for (var o = s; o < a; o++) | |
r[o].define(t, e, n) | |
} | |
, | |
s.getDefine = function(t, e) { | |
var i = this.passes; | |
if (!(e >= i.length)) { | |
var n = 0 | |
, r = i.length; | |
void 0 !== e && (n = e, | |
r = e + 1); | |
for (var s = n; s < r; s++) { | |
var a = i[s].getDefine(t); | |
if (void 0 !== a) | |
return a | |
} | |
} | |
} | |
, | |
s.setCullMode = function(t, e) { | |
void 0 === t && (t = o.CULL_BACK); | |
var i = this.passes | |
, n = 0 | |
, r = i.length; | |
void 0 !== e && (n = e, | |
r = e + 1); | |
for (var s = n; s < r; s++) | |
i[s].setCullMode(t); | |
this._dirty = !0 | |
} | |
, | |
s.setDepth = function(t, e, i, n) { | |
var r = this.passes | |
, s = 0 | |
, a = r.length; | |
void 0 !== n && (s = n, | |
a = n + 1); | |
for (var o = s; o < a; o++) | |
r[o].setDepth(t, e, i); | |
this._dirty = !0 | |
} | |
, | |
s.setBlend = function(t, e, i, n, r, s, a, o, c) { | |
var l = this.passes | |
, h = 0 | |
, u = l.length; | |
void 0 !== c && (h = c, | |
u = c + 1); | |
for (var f = h; f < u; f++) | |
l[f].setBlend(t, e, i, n, r, s, a, o); | |
this._dirty = !0 | |
} | |
, | |
s.setStencilEnabled = function(t, e) { | |
void 0 === t && (t = o.STENCIL_INHERIT); | |
var i = this.passes | |
, n = 0 | |
, r = i.length; | |
void 0 !== e && (n = e, | |
r = e + 1); | |
for (var s = n; s < r; s++) | |
i[s].setStencilEnabled(t); | |
this._dirty = !0 | |
} | |
, | |
s.setStencil = function(t, e, i, n, r, s, a, o, c) { | |
var l = this.passes | |
, h = 0 | |
, u = l.length; | |
void 0 !== c && (h = c, | |
u = c + 1); | |
for (var f = h; f < u; f++) { | |
var d = l[f]; | |
d.setStencilFront(t, e, i, n, r, s, a, o), | |
d.setStencilBack(t, e, i, n, r, s, a, o) | |
} | |
this._dirty = !0 | |
} | |
, | |
e = t, | |
(i = [{ | |
key: "name", | |
get: function() { | |
return this._name | |
} | |
}, { | |
key: "technique", | |
get: function() { | |
return this._technique | |
} | |
}, { | |
key: "passes", | |
get: function() { | |
return [] | |
} | |
}]) && a(e.prototype, i), | |
Object.defineProperty(e, "prototype", { | |
writable: !1 | |
}), | |
t | |
} | |
)(); | |
i.default = c, | |
cc.EffectBase = c, | |
e.exports = i.default | |
} | |
), { | |
"../../../renderer/core/pass": 273, | |
"../../../renderer/enums": 277 | |
}], | |
78: [(function(t, e, i) { | |
"use strict"; | |
i.__esModule = !0, | |
i.parseEffect = function(t) { | |
var e = f(t); | |
return new a.default(t.name,e,0,t) | |
} | |
; | |
var n = c(t("../../../renderer/core/pass")) | |
, r = t("../../../renderer/types") | |
, s = c(t("../../../renderer/enums")) | |
, a = c(t("./effect")) | |
, o = c(t("../../../renderer/core/technique")); | |
function c(t) { | |
return t && t.__esModule ? t : { | |
default: t | |
} | |
} | |
function l(t) { | |
return cc.renderer._forward._programLib.getTemplate(t) | |
} | |
function h(t, e) { | |
var i = e.properties || {} | |
, n = l(e.program) | |
, a = function(t) { | |
if (!n.uniforms.find((function(e) { | |
return e.name === t | |
} | |
))) | |
return "continue" | |
}; | |
for (var o in i) | |
a(o); | |
var c = {}; | |
return n.uniforms.forEach((function(t) { | |
var e, n = t.name, a = c[n] = Object.assign({}, t), o = i[n]; | |
void 0 === (e = o ? o.type === s.default.PARAM_TEXTURE_2D ? null : o.type === s.default.PARAM_INT || o.type === s.default.PARAM_FLOAT ? Array.isArray(o.value) ? o.value[0] : o.value : new Float32Array(o.value) : r.enums2default[t.type]) && (e = null), | |
a.value = e | |
} | |
)), | |
c | |
} | |
function u(t) { | |
var e = {}; | |
return l(t.program).defines.forEach((function(t) { | |
e[t.name] = r.enums2default[t.type] | |
} | |
)), | |
e | |
} | |
function f(t) { | |
for (var e = t.techniques.length, i = Array(e), r = 0; r < e; ++r) { | |
for (var s = t.techniques[r], a = s.name || r, c = s.passes.length, l = Array(c), f = 0; f < c; ++f) { | |
var d = s.passes[f] | |
, _ = d.name || f | |
, p = t.name + "-" + a + "-" + _ | |
, v = d.stage || "opaque" | |
, g = h(0, d) | |
, m = u(d) | |
, y = l[f] = new n.default(_,p,d.program,v,g,m); | |
d.rasterizerState && y.setCullMode(d.rasterizerState.cullMode); | |
var T = d.blendState && d.blendState.targets[0]; | |
T && y.setBlend(T.blend, T.blendEq, T.blendSrc, T.blendDst, T.blendAlphaEq, T.blendSrcAlpha, T.blendDstAlpha, T.blendColor); | |
var E = d.depthStencilState; | |
E && (y.setDepth(E.depthTest, E.depthWrite, E.depthFunc), | |
y.setStencilFront(E.stencilTest, E.stencilFuncFront, E.stencilRefFront, E.stencilMaskFront, E.stencilFailOpFront, E.stencilZFailOpFront, E.stencilZPassOpFront, E.stencilWriteMaskFront), | |
y.setStencilBack(E.stencilTest, E.stencilFuncBack, E.stencilRefBack, E.stencilMaskBack, E.stencilFailOpBack, E.stencilZFailOpBack, E.stencilZPassOpBack, E.stencilWriteMaskBack)) | |
} | |
i[r] = new o.default(a,l) | |
} | |
return i | |
} | |
} | |
), { | |
"../../../renderer/core/pass": 273, | |
"../../../renderer/core/technique": 275, | |
"../../../renderer/enums": 277, | |
"../../../renderer/types": 305, | |
"./effect": 80 | |
}], | |
79: [(function(t, e, i) { | |
"use strict"; | |
i.__esModule = !0, | |
i.default = void 0; | |
var n = a(t("../../../renderer/murmurhash2_gc")) | |
, r = a(t("./utils")) | |
, s = a(t("./effect-base")); | |
function a(t) { | |
return t && t.__esModule ? t : { | |
default: t | |
} | |
} | |
function o(t, e) { | |
for (var i = 0; i < e.length; i++) { | |
var n = e[i]; | |
n.enumerable = n.enumerable || !1, | |
n.configurable = !0, | |
"value"in n && (n.writable = !0), | |
Object.defineProperty(t, n.key, n) | |
} | |
} | |
function c(t, e) { | |
return (c = Object.setPrototypeOf || function(t, e) { | |
return t.__proto__ = e, | |
t | |
} | |
)(t, e) | |
} | |
cc.gfx; | |
var l = (function(t) { | |
var e, i; | |
function s(e) { | |
var i; | |
return (i = t.call(this) || this)._effect = void 0, | |
i._passes = [], | |
i._stagePasses = {}, | |
i._hash = 0, | |
i.init(e), | |
i | |
} | |
i = t, | |
(e = s).prototype = Object.create(i.prototype), | |
e.prototype.constructor = e, | |
c(e, i); | |
var a, l, h = s.prototype; | |
return h._onEffectChanged = function() {} | |
, | |
h.init = function(t) { | |
if (t instanceof s && (t = t.effect), | |
this._effect = t, | |
this._dirty = !0, | |
t) { | |
var e = t.passes | |
, i = this._passes; | |
i.length = 0; | |
for (var n = this._stagePasses = {}, r = 0; r < e.length; r++) { | |
var a = i[r] = Object.setPrototypeOf({}, e[r]); | |
a._properties = Object.setPrototypeOf({}, e[r]._properties), | |
a._defines = Object.setPrototypeOf({}, e[r]._defines), | |
n[a._stage] || (n[a._stage] = []), | |
n[a._stage].push(a) | |
} | |
} | |
} | |
, | |
h.updateHash = function() {} | |
, | |
h.getHash = function() { | |
if (!this._dirty) | |
return this._hash; | |
this._dirty = !1; | |
var t = ""; | |
t += r.default.serializePasses(this._passes); | |
var e = this._effect; | |
return e && (t += r.default.serializePasses(e.passes)), | |
this._hash = (0, | |
n.default)(t, 666), | |
this.updateHash(this._hash), | |
this._hash | |
} | |
, | |
a = s, | |
(l = [{ | |
key: "effect", | |
get: function() { | |
return this._effect | |
} | |
}, { | |
key: "name", | |
get: function() { | |
return this._effect && this._effect.name + " (variant)" | |
} | |
}, { | |
key: "passes", | |
get: function() { | |
return this._passes | |
} | |
}, { | |
key: "stagePasses", | |
get: function() { | |
return this._stagePasses | |
} | |
}]) && o(a.prototype, l), | |
Object.defineProperty(a, "prototype", { | |
writable: !1 | |
}), | |
s | |
} | |
)(s.default); | |
i.default = l, | |
cc.EffectVariant = l, | |
e.exports = i.default | |
} | |
), { | |
"../../../renderer/murmurhash2_gc": 300, | |
"./effect-base": 77, | |
"./utils": 84 | |
}], | |
80: [(function(t, e, i) { | |
"use strict"; | |
var n; | |
function r(t, e) { | |
for (var i = 0; i < e.length; i++) { | |
var n = e[i]; | |
n.enumerable = n.enumerable || !1, | |
n.configurable = !0, | |
"value"in n && (n.writable = !0), | |
Object.defineProperty(t, n.key, n) | |
} | |
} | |
function s(t, e) { | |
return (s = Object.setPrototypeOf || function(t, e) { | |
return t.__proto__ = e, | |
t | |
} | |
)(t, e) | |
} | |
i.__esModule = !0, | |
i.default = void 0; | |
var a = (function(t) { | |
var e, i; | |
function n(e, i, n, r) { | |
var s; | |
return (s = t.call(this) || this)._techniques = [], | |
s._asset = null, | |
s.init(e, i, n, r, !0), | |
s | |
} | |
i = t, | |
(e = n).prototype = Object.create(i.prototype), | |
e.prototype.constructor = e, | |
s(e, i); | |
var a, o, c = n.prototype; | |
return c.init = function(t, e, i, n) { | |
this._name = t, | |
this._techniques = e, | |
this._technique = e[i], | |
this._asset = n | |
} | |
, | |
c.switchTechnique = function(t) { | |
t >= this._techniques.length || (this._technique = this._techniques[t]) | |
} | |
, | |
c.clear = function() { | |
this._techniques = [] | |
} | |
, | |
c.clone = function() { | |
for (var t = [], e = 0; e < this._techniques.length; e++) | |
t.push(this._techniques[e].clone()); | |
var i = this._techniques.indexOf(this._technique); | |
return new n(this._name,t,i,this._asset) | |
} | |
, | |
a = n, | |
(o = [{ | |
key: "technique", | |
get: function() { | |
return this._technique | |
} | |
}, { | |
key: "passes", | |
get: function() { | |
return this._technique.passes | |
} | |
}]) && r(a.prototype, o), | |
Object.defineProperty(a, "prototype", { | |
writable: !1 | |
}), | |
n | |
} | |
)(((n = t("./effect-base")) && n.__esModule ? n : { | |
default: n | |
}).default); | |
i.default = a, | |
cc.Effect = a, | |
e.exports = i.default | |
} | |
), { | |
"./effect-base": 77 | |
}], | |
81: [(function(t) { | |
"use strict"; | |
t("./CCEffectAsset"), | |
t("./CCMaterial"), | |
t("./material-variant") | |
} | |
), { | |
"./CCEffectAsset": 75, | |
"./CCMaterial": 76, | |
"./material-variant": 83 | |
}], | |
82: [(function(t, e, i) { | |
"use strict"; | |
i.__esModule = !0, | |
i.default = void 0; | |
var n = s(t("./utils")) | |
, r = s(t("../../utils/pool")); | |
function s(t) { | |
return t && t.__esModule ? t : { | |
default: t | |
} | |
} | |
function a(t, e) { | |
return (a = Object.setPrototypeOf || function(t, e) { | |
return t.__proto__ = e, | |
t | |
} | |
)(t, e) | |
} | |
var o = new (function(t) { | |
var e, i; | |
function r() { | |
for (var e, i = arguments.length, n = Array(i), r = 0; r < i; r++) | |
n[r] = arguments[r]; | |
return (e = t.call.apply(t, [this].concat(n)) || this).enabled = !1, | |
e._pool = {}, | |
e | |
} | |
i = t, | |
(e = r).prototype = Object.create(i.prototype), | |
e.prototype.constructor = e, | |
a(e, i); | |
var s = r.prototype; | |
return s.get = function(t, e) { | |
var i, r = this._pool; | |
if (t instanceof cc.MaterialVariant) { | |
if (!t._owner) | |
return t._owner = e, | |
t; | |
if (t._owner === e) | |
return t; | |
t = t.material | |
} | |
if (this.enabled) { | |
var s = t.effectAsset._uuid; | |
if (r[s]) { | |
var a = n.default.serializeDefines(t._effect._defines) + n.default.serializeTechniques(t._effect._techniques); | |
i = r[s][a] && r[s][a].pop() | |
} | |
} | |
return i ? this.count-- : ((i = new cc.MaterialVariant(t))._name = t._name + " (Instance)", | |
i._uuid = t._uuid), | |
i._owner = e, | |
i | |
} | |
, | |
s.put = function(t) { | |
if (this.enabled && t._owner) { | |
var e = this._pool | |
, i = t.effectAsset._uuid; | |
e[i] || (e[i] = {}); | |
var r = n.default.serializeDefines(t._effect._defines) + n.default.serializeTechniques(t._effect._techniques); | |
e[i][r] || (e[i][r] = []), | |
this.count > this.maxSize || (this._clean(t), | |
e[i][r].push(t), | |
this.count++) | |
} | |
} | |
, | |
s.clear = function() { | |
this._pool = {}, | |
this.count = 0 | |
} | |
, | |
s._clean = function(t) { | |
t._owner = null | |
} | |
, | |
r | |
}(r.default)); | |
r.default.register("material", o); | |
var c = o; | |
i.default = c, | |
e.exports = i.default | |
} | |
), { | |
"../../utils/pool": 238, | |
"./utils": 84 | |
}], | |
83: [(function(t, e, i) { | |
"use strict"; | |
i.__esModule = !0, | |
i.default = void 0; | |
var n, r = o(t("./CCMaterial")), s = o(t("./effect-variant")), a = o(t("./material-pool")); | |
function o(t) { | |
return t && t.__esModule ? t : { | |
default: t | |
} | |
} | |
function c(t, e) { | |
for (var i = 0; i < e.length; i++) { | |
var n = e[i]; | |
n.enumerable = n.enumerable || !1, | |
n.configurable = !0, | |
"value"in n && (n.writable = !0), | |
Object.defineProperty(t, n.key, n) | |
} | |
} | |
function l(t, e) { | |
return (l = Object.setPrototypeOf || function(t, e) { | |
return t.__proto__ = e, | |
t | |
} | |
)(t, e) | |
} | |
var h = (0, | |
cc._decorator.ccclass)("cc.MaterialVariant")(n = (function(t) { | |
var e, i, n, o; | |
function h(e) { | |
var i; | |
return (i = t.call(this) || this)._owner = null, | |
i._material = null, | |
i.init(e), | |
i | |
} | |
return i = t, | |
(e = h).prototype = Object.create(i.prototype), | |
e.prototype.constructor = e, | |
l(e, i), | |
h.createWithBuiltin = function(t, e) { | |
return h.create(r.default.getBuiltinMaterial(t), e) | |
} | |
, | |
h.create = function(t, e) { | |
return t ? a.default.get(t, e) : null | |
} | |
, | |
h.prototype.init = function(t) { | |
this._effect = new s.default(t.effect), | |
this._effectAsset = t._effectAsset, | |
this._material = t | |
} | |
, | |
n = h, | |
(o = [{ | |
key: "uuid", | |
get: function() { | |
return this._material._uuid | |
} | |
}, { | |
key: "owner", | |
get: function() { | |
return this._owner | |
} | |
}, { | |
key: "material", | |
get: function() { | |
return this._material | |
} | |
}]) && c(n.prototype, o), | |
Object.defineProperty(n, "prototype", { | |
writable: !1 | |
}), | |
h | |
} | |
)(r.default)) || n; | |
i.default = h, | |
cc.MaterialVariant = h, | |
e.exports = i.default | |
} | |
), { | |
"./CCMaterial": 76, | |
"./effect-variant": 79, | |
"./material-pool": 82 | |
}], | |
84: [(function(t, e, i) { | |
"use strict"; | |
i.__esModule = !0, | |
i.default = void 0; | |
var n, r = (n = t("../../../renderer/enums")) && n.__esModule ? n : { | |
default: n | |
}, s = []; | |
function a(t, e) { | |
for (var i = e.length, n = 0; n < i; n++) { | |
var r = e[n]; | |
s[n] = r + t[r] | |
} | |
return s.length = i, | |
s.join("") | |
} | |
function o(t, e) { | |
for (var i = 0, n = 0, a = e.length; n < a; n++) { | |
var o = t[e[n]] | |
, c = o.value; | |
c && (o.type === r.default.PARAM_TEXTURE_2D || o.type === r.default.PARAM_TEXTURE_CUBE ? s[i] = c._id : s[i] = c.toString(), | |
i++) | |
} | |
return s.length = i, | |
s.join(";") | |
} | |
var c = { | |
serializeDefines: a, | |
serializePasses: function(t) { | |
for (var e, i, n = "", r = 0; r < t.length; r++) | |
n += (void 0, | |
i = void 0, | |
i = (e = t[r])._programName + e._cullMode, | |
e._blend && (i += e._blendEq + e._blendAlphaEq + e._blendSrc + e._blendDst + e._blendSrcAlpha + e._blendDstAlpha + e._blendColor), | |
e._depthTest && (i += e._depthWrite + e._depthFunc), | |
e._stencilTest && (i += e._stencilFuncFront + e._stencilRefFront + e._stencilMaskFront + e._stencilFailOpFront + e._stencilZFailOpFront + e._stencilZPassOpFront + e._stencilWriteMaskFront + e._stencilFuncBack + e._stencilRefBack + e._stencilMaskBack + e._stencilFailOpBack + e._stencilZFailOpBack + e._stencilZPassOpBack + e._stencilWriteMaskBack), | |
i += o(e._properties, e._propertyNames), | |
i += a(e._defines, e._defineNames)); | |
return n | |
}, | |
serializeUniforms: o | |
}; | |
i.default = c, | |
e.exports = i.default | |
} | |
), { | |
"../../../renderer/enums": 277 | |
}], | |
85: [(function(t, e) { | |
"use strict"; | |
t("../CCNode").EventType; | |
var i = 56 | |
, n = 7 | |
, r = cc.Enum({ | |
ONCE: 0, | |
ON_WINDOW_RESIZE: 1, | |
ALWAYS: 2 | |
}); | |
function s(t, e, i, n) { | |
for (var r = t._parent.scaleX, s = t._parent.scaleY, a = 0, o = 0, c = t._parent; ; ) { | |
if (a += c.x, | |
o += c.y, | |
!(c = c._parent)) | |
return i.x = i.y = 0, | |
void (n.x = n.y = 1); | |
if (c === e) | |
break; | |
var l = c.scaleX | |
, h = c.scaleY; | |
a *= l, | |
o *= h, | |
r *= l, | |
s *= h | |
} | |
n.x = 0 !== r ? 1 / r : 1, | |
n.y = 0 !== s ? 1 / s : 1, | |
i.x = -a, | |
i.y = -o | |
} | |
var a = cc.Vec2.ZERO | |
, o = cc.Vec2.ONE; | |
function c(t, e) { | |
var r, c, l, h = e._target; | |
h ? s(t, r = h, c = a, l = o) : r = t._parent; | |
var u, f = (u = r)instanceof cc.Scene ? cc.visibleRect : u._contentSize, d = r._anchorPoint, _ = r instanceof cc.Scene, p = t.x, v = t.y, g = t._anchorPoint; | |
if (e._alignFlags & i) { | |
var m, y, T = f.width; | |
_ ? (m = cc.visibleRect.left.x, | |
y = cc.visibleRect.right.x) : y = (m = -d.x * T) + T, | |
m += e._isAbsLeft ? e._left : e._left * T, | |
y -= e._isAbsRight ? e._right : e._right * T, | |
h && (m += c.x, | |
m *= l.x, | |
y += c.x, | |
y *= l.x); | |
var E, A = g.x, x = t.scaleX; | |
if (x < 0 && (A = 1 - A, | |
x = -x), | |
e.isStretchWidth) | |
E = y - m, | |
0 !== x && (t.width = E / x), | |
p = m + A * E; | |
else if (E = t.width * x, | |
e.isAlignHorizontalCenter) { | |
var C = e._isAbsHorizontalCenter ? e._horizontalCenter : e._horizontalCenter * T | |
, b = (.5 - d.x) * f.width; | |
h && (C *= l.x, | |
b += c.x, | |
b *= l.x), | |
p = b + (A - .5) * E + C | |
} else | |
p = e.isAlignLeft ? m + A * E : y + (A - 1) * E | |
} | |
if (e._alignFlags & n) { | |
var S, R, M = f.height; | |
_ ? (R = cc.visibleRect.bottom.y, | |
S = cc.visibleRect.top.y) : S = (R = -d.y * M) + M, | |
R += e._isAbsBottom ? e._bottom : e._bottom * M, | |
S -= e._isAbsTop ? e._top : e._top * M, | |
h && (R += c.y, | |
R *= l.y, | |
S += c.y, | |
S *= l.y); | |
var w, I = g.y, O = t.scaleY; | |
if (O < 0 && (I = 1 - I, | |
O = -O), | |
e.isStretchHeight) | |
w = S - R, | |
0 !== O && (t.height = w / O), | |
v = R + I * w; | |
else if (w = t.height * O, | |
e.isAlignVerticalCenter) { | |
var L = e._isAbsVerticalCenter ? e._verticalCenter : e._verticalCenter * M | |
, P = (.5 - d.y) * f.height; | |
h && (L *= l.y, | |
P += c.y, | |
P *= l.y), | |
v = P + (I - .5) * w + L | |
} else | |
v = e.isAlignBottom ? R + I * w : S + (I - 1) * w | |
} | |
t.setPosition(p, v) | |
} | |
function l(t) { | |
var e = t._widget; | |
e && (c(t, e), | |
e.alignMode !== r.ALWAYS ? f.remove(e) : u.push(e)); | |
for (var i = t._children, n = 0; n < i.length; n++) { | |
var s = i[n]; | |
s._active && l(s) | |
} | |
} | |
function h() { | |
var t = cc.director.getScene(); | |
if (t) { | |
if (f.isAligning = !0, | |
f._nodesOrderDirty) | |
u.length = 0, | |
l(t), | |
f._nodesOrderDirty = !1; | |
else { | |
var e, i = f._activeWidgetsIterator; | |
for (i.i = 0; i.i < u.length; ++i.i) | |
c((e = u[i.i]).node, e) | |
} | |
f.isAligning = !1 | |
} | |
} | |
var u = [] | |
, 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(u), | |
init: function(t) { | |
t.on(cc.Director.EVENT_AFTER_UPDATE, h); | |
var e = this.onResized.bind(this); | |
cc.view.on("canvas-resize", e), | |
window.addEventListener("orientationchange", e) | |
}, | |
add: function(t) { | |
t.node._widget = t, | |
this._nodesOrderDirty = !0 | |
}, | |
remove: function(t) { | |
t.node._widget = null, | |
this._activeWidgetsIterator.remove(t) | |
}, | |
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.enabled && e.alignMode === r.ON_WINDOW_RESIZE && this.add(e); | |
for (var i = t._children, n = 0; n < i.length; n++) { | |
var s = i[n]; | |
this.refreshWidgetOnResized(s) | |
} | |
}, | |
updateAlignment: function t(e) { | |
var i = e._parent; | |
cc.Node.isNode(i) && t(i); | |
var n = e._widget || e.getComponent(cc.Widget); | |
n && i && c(e, n) | |
}, | |
AlignMode: r | |
} | |
} | |
), { | |
"../CCNode": 26 | |
}], | |
86: [(function(t, e) { | |
"use strict"; | |
var i = t("../value-types") | |
, n = t("../geom-utils") | |
, r = t("../utils/affine-transform") | |
, s = t("../renderer/index") | |
, a = t("../renderer/render-flow") | |
, o = t("../CCGame") | |
, c = null; | |
c = t("../../renderer/scene/camera"); | |
var l = cc.mat4() | |
, h = cc.mat4() | |
, u = cc.v3() | |
, f = cc.v3() | |
, d = cc.v3() | |
, _ = []; | |
function p() { | |
for (var t = 0, e = Number.MAX_VALUE; t < _.length; t++) { | |
var i = _[t]; | |
i._depth < e && (T.main = i, | |
e = i._depth) | |
} | |
} | |
var v = null; | |
function g() { | |
if (v) { | |
var t = v.getNode() | |
, e = cc.game.canvas; | |
t.z = e.height / 1.1566, | |
t.x = e.width / 2, | |
t.y = e.height / 2 | |
} | |
} | |
var m = cc.Enum({ | |
COLOR: 1, | |
DEPTH: 2, | |
STENCIL: 4 | |
}) | |
, y = cc.Enum({ | |
OPAQUE: 1, | |
TRANSPARENT: 2 | |
}) | |
, T = cc.Class({ | |
name: "cc.Camera", | |
extends: cc.Component, | |
ctor: function() { | |
if (o.renderType !== o.RENDER_TYPE_CANVAS) { | |
var t = new c; | |
t.setStages(["opaque"]), | |
t.dirty = !0, | |
this._inited = !1, | |
this._camera = t | |
} else | |
this._inited = !0 | |
}, | |
editor: !1, | |
properties: { | |
_cullingMask: 4294967295, | |
_clearFlags: m.DEPTH | m.STENCIL, | |
_backgroundColor: cc.color(0, 0, 0, 255), | |
_depth: 0, | |
_zoomRatio: 1, | |
_targetTexture: null, | |
_fov: 60, | |
_orthoSize: 10, | |
_nearClip: 1, | |
_farClip: 4096, | |
_ortho: !0, | |
_rect: cc.rect(0, 0, 1, 1), | |
_renderStages: 1, | |
_alignWithScreen: !0, | |
zoomRatio: { | |
get: function() { | |
return this._zoomRatio | |
}, | |
set: function(t) { | |
this._zoomRatio = t | |
}, | |
tooltip: !1 | |
}, | |
fov: { | |
get: function() { | |
return this._fov | |
}, | |
set: function(t) { | |
this._fov = t | |
}, | |
tooltip: !1 | |
}, | |
orthoSize: { | |
get: function() { | |
return this._orthoSize | |
}, | |
set: function(t) { | |
this._orthoSize = t | |
}, | |
tooltip: !1 | |
}, | |
nearClip: { | |
get: function() { | |
return this._nearClip | |
}, | |
set: function(t) { | |
this._nearClip = t, | |
this._updateClippingpPlanes() | |
}, | |
tooltip: !1 | |
}, | |
farClip: { | |
get: function() { | |
return this._farClip | |
}, | |
set: function(t) { | |
this._farClip = t, | |
this._updateClippingpPlanes() | |
}, | |
tooltip: !1 | |
}, | |
ortho: { | |
get: function() { | |
return this._ortho | |
}, | |
set: function(t) { | |
this._ortho = t, | |
this._updateProjection() | |
}, | |
tooltip: !1 | |
}, | |
rect: { | |
get: function() { | |
return this._rect | |
}, | |
set: function(t) { | |
this._rect = t, | |
this._updateRect() | |
}, | |
tooltip: !1 | |
}, | |
cullingMask: { | |
get: function() { | |
return this._cullingMask | |
}, | |
set: function(t) { | |
this._cullingMask = t, | |
this._updateCameraMask() | |
}, | |
tooltip: !1 | |
}, | |
clearFlags: { | |
get: function() { | |
return this._clearFlags | |
}, | |
set: function(t) { | |
this._clearFlags = t, | |
this._camera && this._camera.setClearFlags(t) | |
}, | |
tooltip: !1 | |
}, | |
backgroundColor: { | |
get: function() { | |
return this._backgroundColor | |
}, | |
set: function(t) { | |
this._backgroundColor.equals(t) || (this._backgroundColor.set(t), | |
this._updateBackgroundColor()) | |
}, | |
tooltip: !1 | |
}, | |
depth: { | |
get: function() { | |
return this._depth | |
}, | |
set: function(t) { | |
T.main === this ? this._depth < t && p() : T.main && t < T.main._depth && _.includes(this) && (T.main = this), | |
this._depth = t, | |
this._camera && this._camera.setPriority(t) | |
}, | |
tooltip: !1 | |
}, | |
targetTexture: { | |
get: function() { | |
return this._targetTexture | |
}, | |
set: function(t) { | |
this._targetTexture = t, | |
this._updateTargetTexture() | |
}, | |
tooltip: !1 | |
}, | |
renderStages: { | |
get: function() { | |
return this._renderStages | |
}, | |
set: function(t) { | |
this._renderStages = t, | |
this._updateStages() | |
}, | |
tooltip: !1 | |
}, | |
alignWithScreen: { | |
get: function() { | |
return this._alignWithScreen | |
}, | |
set: function(t) { | |
this._alignWithScreen = t | |
} | |
}, | |
_is3D: { | |
get: function() { | |
return this.node && this.node._is3DNode | |
} | |
} | |
}, | |
statics: { | |
main: null, | |
cameras: _, | |
ClearFlags: m, | |
findCamera: function(t) { | |
for (var e = 0, i = _.length; e < i; e++) { | |
var n = _[e]; | |
if (n.containsNode(t)) | |
return n | |
} | |
return null | |
}, | |
_findRendererCamera: function(t) { | |
for (var e = s.scene._cameras, i = 0; i < e._count; i++) | |
if (e._data[i]._cullingMask & t._cullingMask) | |
return e._data[i]; | |
return null | |
}, | |
_setupDebugCamera: function() { | |
if (!v && o.renderType !== o.RENDER_TYPE_CANVAS) { | |
var t = new c; | |
v = t, | |
t.setStages(["opaque"]), | |
t.setFov(60 * Math.PI / 180), | |
t.setNear(.1), | |
t.setFar(4096), | |
t.dirty = !0, | |
t.cullingMask = 1 << cc.Node.BuiltinGroupIndex.DEBUG, | |
t.setPriority(cc.macro.MAX_ZINDEX), | |
t.setClearFlags(0), | |
t.setColor(0, 0, 0, 0); | |
var e = new cc.Node; | |
t.setNode(e), | |
g(), | |
cc.view.on("design-resolution-changed", g), | |
s.scene.addCamera(t) | |
} | |
} | |
}, | |
_updateCameraMask: function() { | |
if (this._camera) { | |
var t = this._cullingMask & ~(1 << cc.Node.BuiltinGroupIndex.DEBUG); | |
this._camera.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() { | |
if (this._camera) { | |
var t = this._targetTexture; | |
this._camera.setFrameBuffer(t ? t._framebuffer : null) | |
} | |
}, | |
_updateClippingpPlanes: function() { | |
this._camera && (this._camera.setNear(this._nearClip), | |
this._camera.setFar(this._farClip)) | |
}, | |
_updateProjection: function() { | |
if (this._camera) { | |
var t = this._ortho ? 1 : 0; | |
this._camera.setType(t) | |
} | |
}, | |
_updateRect: function() { | |
if (this._camera) { | |
var t = this._rect; | |
this._camera.setRect(t.x, t.y, t.width, t.height) | |
} | |
}, | |
_updateStages: function() { | |
var t = this._renderStages | |
, e = []; | |
t & y.OPAQUE && e.push("opaque"), | |
t & y.TRANSPARENT && e.push("transparent"), | |
this._camera.setStages(e) | |
}, | |
_init: function() { | |
if (!this._inited) { | |
this._inited = !0; | |
var t = this._camera; | |
t && (t.setNode(this.node), | |
t.setClearFlags(this._clearFlags), | |
t.setPriority(this._depth), | |
this._updateBackgroundColor(), | |
this._updateCameraMask(), | |
this._updateTargetTexture(), | |
this._updateClippingpPlanes(), | |
this._updateProjection(), | |
this._updateStages(), | |
this._updateRect(), | |
this.beforeDraw()) | |
} | |
}, | |
__preload: function() { | |
this._init() | |
}, | |
onEnable: function() { | |
o.renderType !== o.RENDER_TYPE_CANVAS && (cc.director.on(cc.Director.EVENT_BEFORE_DRAW, this.beforeDraw, this), | |
s.scene.addCamera(this._camera)), | |
_.push(this), | |
(!T.main || this._depth < T.main._depth) && (T.main = this) | |
}, | |
onDisable: function() { | |
o.renderType !== o.RENDER_TYPE_CANVAS && (cc.director.off(cc.Director.EVENT_BEFORE_DRAW, this.beforeDraw, this), | |
s.scene.removeCamera(this._camera)), | |
cc.js.array.fastRemove(_, this), | |
T.main === this && (T.main = null, | |
p()) | |
}, | |
getScreenToWorldMatrix2D: function(t) { | |
return this.getWorldToScreenMatrix2D(t), | |
i.Mat4.invert(t, t), | |
t | |
}, | |
getWorldToScreenMatrix2D: function(t) { | |
this.node.getWorldRT(l); | |
var e = this.zoomRatio | |
, n = l.m; | |
n[0] *= e, | |
n[1] *= e, | |
n[4] *= e, | |
n[5] *= e; | |
var r = n[12] | |
, s = n[13] | |
, a = cc.visibleRect.center; | |
return n[12] = a.x - (n[0] * r + n[4] * s), | |
n[13] = a.y - (n[1] * r + n[5] * s), | |
t !== l && i.Mat4.copy(t, l), | |
t | |
}, | |
getScreenToWorldPoint: function(t, e) { | |
return this.node.is3DNode ? (e = e || new cc.Vec3, | |
this._camera.screenToWorld(e, t, cc.visibleRect.width, cc.visibleRect.height)) : (e = e || new cc.Vec2, | |
this.getScreenToWorldMatrix2D(l), | |
i.Vec2.transformMat4(e, t, l)), | |
e | |
}, | |
getWorldToScreenPoint: function(t, e) { | |
return this.node.is3DNode ? (e = e || new cc.Vec3, | |
this._camera.worldToScreen(e, t, cc.visibleRect.width, cc.visibleRect.height)) : (e = e || new cc.Vec2, | |
this.getWorldToScreenMatrix2D(l), | |
i.Vec2.transformMat4(e, t, l)), | |
e | |
}, | |
getRay: function(t) { | |
return cc.geomUtils ? (i.Vec3.set(d, t.x, t.y, 1), | |
this._camera.screenToWorld(f, d, cc.visibleRect.width, cc.visibleRect.height), | |
this.ortho ? (i.Vec3.set(d, t.x, t.y, -1), | |
this._camera.screenToWorld(u, d, cc.visibleRect.width, cc.visibleRect.height)) : this.node.getWorldPosition(u), | |
n.Ray.fromPoints(new n.Ray, u, f)) : t | |
}, | |
containsNode: function(t) { | |
return (t._cullingMask & this.cullingMask) > 0 | |
}, | |
render: function(t) { | |
if (!(t = t || cc.director.getScene())) | |
return null; | |
this.node.getWorldMatrix(l), | |
this.beforeDraw(), | |
a.renderCamera(this._camera, t) | |
}, | |
_onAlignWithScreen: function() { | |
var t = cc.game.canvas.height / cc.view._scaleY; | |
this._targetTexture && (t = cc.visibleRect.height); | |
var e = this._fov * cc.macro.RAD; | |
this.node.z = t / (2 * Math.tan(e / 2)), | |
e = 2 * Math.atan(Math.tan(e / 2) / this.zoomRatio), | |
this._camera.setFov(e), | |
this._camera.setOrthoHeight(t / 2 / this.zoomRatio), | |
this.node.setRotation(0, 0, 0, 1) | |
}, | |
beforeDraw: function() { | |
if (this._camera) { | |
if (this._alignWithScreen) | |
this._onAlignWithScreen(); | |
else { | |
var t = this._fov * cc.macro.RAD; | |
t = 2 * Math.atan(Math.tan(t / 2) / this.zoomRatio), | |
this._camera.setFov(t), | |
this._camera.setOrthoHeight(this._orthoSize / this.zoomRatio) | |
} | |
this._camera.dirty = !0 | |
} | |
} | |
}); | |
cc.js.mixin(T.prototype, { | |
getNodeToCameraTransform: function(t) { | |
var e = r.identity(); | |
return t.getWorldMatrix(h), | |
this.containsNode(t) && (this.getWorldToCameraMatrix(l), | |
i.Mat4.mul(h, h, l)), | |
r.fromMat4(e, h), | |
e | |
}, | |
getCameraToWorldPoint: function(t, e) { | |
return this.getScreenToWorldPoint(t, e) | |
}, | |
getWorldToCameraPoint: function(t, e) { | |
return this.getWorldToScreenPoint(t, e) | |
}, | |
getCameraToWorldMatrix: function(t) { | |
return this.getScreenToWorldMatrix2D(t) | |
}, | |
getWorldToCameraMatrix: function(t) { | |
return this.getWorldToScreenMatrix2D(t) | |
} | |
}), | |
e.exports = cc.Camera = T | |
} | |
), { | |
"../../renderer/scene/camera": 302, | |
"../CCGame": 25, | |
"../geom-utils": 142, | |
"../renderer/index": 193, | |
"../renderer/render-flow": 194, | |
"../utils/affine-transform": 227, | |
"../value-types": 251 | |
}], | |
87: [(function(t, e) { | |
"use strict"; | |
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 i = cc.Class({ | |
name: "cc.BoxCollider", | |
extends: cc.Collider, | |
mixins: [cc.Collider.Box], | |
editor: !1 | |
}); | |
cc.BoxCollider = e.exports = i | |
} | |
), {}], | |
88: [(function(t, e) { | |
"use strict"; | |
cc.Collider.Circle = cc.Class({ | |
properties: { | |
_offset: cc.v2(0, 0), | |
_radius: 50, | |
offset: { | |
tooltip: !1, | |
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 i = cc.Class({ | |
name: "cc.CircleCollider", | |
extends: cc.Collider, | |
mixins: [cc.Collider.Circle], | |
editor: !1 | |
}); | |
cc.CircleCollider = e.exports = i | |
} | |
), {}], | |
89: [(function(t, e) { | |
"use strict"; | |
var i = 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 = i | |
} | |
), {}], | |
90: [(function(t, e) { | |
"use strict"; | |
var i, n = (i = t("../value-types/vec2")) && i.__esModule ? i : { | |
default: i | |
}, r = t("./CCContact"), s = r.CollisionType, a = t("../CCNode").EventType, o = new n.default; | |
function c(t, e, i, n, r, s) { | |
var a = t.x | |
, o = t.y | |
, c = t.width | |
, l = t.height | |
, h = e.m | |
, u = h[0] | |
, f = h[1] | |
, d = h[4] | |
, _ = h[5] | |
, p = u * a + d * o + h[12] | |
, v = f * a + _ * o + h[13] | |
, g = u * c | |
, m = f * c | |
, y = d * l | |
, T = _ * l; | |
n.x = p, | |
n.y = v, | |
r.x = g + p, | |
r.y = m + v, | |
i.x = y + p, | |
i.y = T + v, | |
s.x = g + y + p, | |
s.y = m + T + v | |
} | |
var l = 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() { | |
if (this.enabled) { | |
var t, e, i = this._colliders; | |
for (t = 0, | |
e = i.length; t < e; t++) | |
this.updateCollider(i[t]); | |
var n = this._contacts | |
, r = []; | |
for (t = 0, | |
e = n.length; t < e; t++) { | |
var a = n[t].updateState(); | |
a !== s.None && r.push([a, n[t]]) | |
} | |
for (t = 0, | |
e = r.length; t < e; t++) { | |
var o = r[t]; | |
this._doCollide(o[0], o[1]) | |
} | |
this.drawColliders() | |
} | |
}, | |
_doCollide: function(t, e) { | |
var i; | |
switch (t) { | |
case s.CollisionEnter: | |
i = "onCollisionEnter"; | |
break; | |
case s.CollisionStay: | |
i = "onCollisionStay"; | |
break; | |
case s.CollisionExit: | |
i = "onCollisionExit" | |
} | |
var n, r, a, o = e.collider1, c = e.collider2, l = o.node._components, h = c.node._components; | |
for (n = 0, | |
r = l.length; n < r; n++) | |
(a = l[n])[i] && a[i](c, o); | |
for (n = 0, | |
r = h.length; n < r; n++) | |
(a = h[n])[i] && a[i](o, c) | |
}, | |
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 = cc.mat4(), | |
e.radius = 0, | |
t instanceof cc.BoxCollider ? (e.position = null, | |
e.points = [cc.v2(), cc.v2(), cc.v2(), cc.v2()]) : t instanceof cc.PolygonCollider ? (e.position = null, | |
e.points = t.points.map((function(t) { | |
return cc.v2(t.x, t.y) | |
} | |
))) : t instanceof cc.CircleCollider && (e.position = cc.v2(), | |
e.points = null) | |
} | |
}, | |
updateCollider: function(t) { | |
var e = t.offset | |
, i = t.world | |
, r = i.aabb | |
, s = i.matrix; | |
t.node.getWorldMatrix(s); | |
var a = i.preAabb; | |
if (a.x = r.x, | |
a.y = r.y, | |
a.width = r.width, | |
a.height = r.height, | |
t instanceof cc.BoxCollider) { | |
var l = t.size; | |
r.x = e.x - l.width / 2, | |
r.y = e.y - l.height / 2, | |
r.width = l.width, | |
r.height = l.height; | |
var h = i.points | |
, u = h[0] | |
, f = h[1] | |
, d = h[2] | |
, _ = h[3]; | |
c(r, s, u, f, d, _); | |
var p = Math.min(u.x, f.x, d.x, _.x) | |
, v = Math.min(u.y, f.y, d.y, _.y) | |
, g = Math.max(u.x, f.x, d.x, _.x) | |
, m = Math.max(u.y, f.y, d.y, _.y); | |
r.x = p, | |
r.y = v, | |
r.width = g - p, | |
r.height = m - v | |
} else if (t instanceof cc.CircleCollider) { | |
n.default.transformMat4(o, t.offset, s), | |
i.position.x = o.x, | |
i.position.y = o.y; | |
var y = s.m | |
, T = y[12] | |
, E = y[13]; | |
y[12] = y[13] = 0, | |
o.x = t.radius, | |
o.y = 0, | |
n.default.transformMat4(o, o, s); | |
var A = Math.sqrt(o.x * o.x + o.y * o.y); | |
i.radius = A, | |
r.x = i.position.x - A, | |
r.y = i.position.y - A, | |
r.width = 2 * A, | |
r.height = 2 * A, | |
y[12] = T, | |
y[13] = E | |
} else if (t instanceof cc.PolygonCollider) { | |
var x = t.points | |
, C = i.points; | |
C.length = x.length; | |
for (var b = 1e6, S = 1e6, R = -1e6, M = -1e6, w = 0, I = x.length; w < I; w++) { | |
C[w] || (C[w] = cc.v2()), | |
o.x = x[w].x + e.x, | |
o.y = x[w].y + e.y, | |
n.default.transformMat4(o, o, s); | |
var O = o.x | |
, L = o.y; | |
C[w].x = O, | |
C[w].y = L, | |
O > R && (R = O), | |
O < b && (b = O), | |
L > M && (M = L), | |
L < S && (S = L) | |
} | |
r.x = b, | |
r.y = S, | |
r.width = R - b, | |
r.height = M - S | |
} | |
}, | |
addCollider: function(t) { | |
var e = this._colliders; | |
if (-1 === e.indexOf(t)) { | |
for (var i = 0, n = e.length; i < n; i++) { | |
var s = e[i]; | |
if (this.shouldCollide(t, s)) { | |
var o = new r(t,s); | |
this._contacts.push(o) | |
} | |
} | |
e.push(t), | |
this.initCollider(t) | |
} | |
t.node.on(a.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, r = n.length - 1; r >= 0; r--) { | |
var o = n[r]; | |
o.collider1 !== t && o.collider2 !== t || (o.touching && this._doCollide(s.CollisionExit, o), | |
n.splice(r, 1)) | |
} | |
t.node.off(a.GROUP_CHANGED, this.onNodeGroupChanged, this) | |
} | |
}, | |
onNodeGroupChanged: function(t) { | |
for (var e = t.getComponents(cc.Collider), i = 0, n = e.length; i < n; i++) { | |
var r = e[i]; | |
cc.PhysicsCollider && r instanceof cc.PhysicsCollider || (this.removeCollider(r), | |
this.addCollider(r)) | |
} | |
}, | |
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]; | |
if (t.strokeColor = cc.Color.WHITE, | |
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 a = 1; a < s.length; a++) | |
t.lineTo(s[a].x, s[a].y); | |
t.close(), | |
t.stroke() | |
} | |
} else | |
r instanceof cc.CircleCollider && (t.circle(r.world.position.x, r.world.position.y, r.world.radius), | |
t.stroke()); | |
if (this.enabledDrawBoundingBox) { | |
var o = r.world.aabb; | |
t.strokeColor = cc.Color.BLUE, | |
t.moveTo(o.xMin, o.yMin), | |
t.lineTo(o.xMin, o.yMax), | |
t.lineTo(o.xMax, o.yMax), | |
t.lineTo(o.xMax, o.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(l.prototype, "enabledDebugDraw", (function() { | |
return this._enabledDebugDraw | |
} | |
), (function(t) { | |
t && !this._enabledDebugDraw ? (this._checkDebugDrawValid(), | |
this._debugDrawer.node.active = !0) : !t && this._enabledDebugDraw && (this._debugDrawer.clear(!0), | |
this._debugDrawer.node.active = !1), | |
this._enabledDebugDraw = t | |
} | |
)), | |
cc.CollisionManager = e.exports = l | |
} | |
), { | |
"../CCNode": 26, | |
"../value-types/vec2": 260, | |
"./CCContact": 91 | |
}], | |
91: [(function(t, e) { | |
"use strict"; | |
var i = t("./CCIntersection") | |
, n = cc.Enum({ | |
None: 0, | |
CollisionEnter: 1, | |
CollisionStay: 2, | |
CollisionExit: 3 | |
}); | |
function r(t, e) { | |
this.collider1 = t, | |
this.collider2 = e, | |
this.touching = !1; | |
var n = t instanceof cc.BoxCollider || t instanceof cc.PolygonCollider | |
, r = e instanceof cc.BoxCollider || e instanceof cc.PolygonCollider | |
, s = t instanceof cc.CircleCollider | |
, a = e instanceof cc.CircleCollider; | |
n && r ? this.testFunc = i.polygonPolygon : s && a ? this.testFunc = i.circleCircle : n && a ? this.testFunc = i.polygonCircle : s && r && (this.testFunc = i.polygonCircle, | |
this.collider1 = e, | |
this.collider2 = t) | |
} | |
r.prototype.test = function() { | |
var t = this.collider1.world | |
, e = this.collider2.world; | |
return !!t.aabb.intersects(e.aabb) && (this.testFunc === i.polygonPolygon ? this.testFunc(t.points, e.points) : this.testFunc === i.circleCircle ? this.testFunc(t, e) : this.testFunc === i.polygonCircle && this.testFunc(t.points, e)) | |
} | |
, | |
r.prototype.updateState = function() { | |
var t = this.test() | |
, e = n.None; | |
return t && !this.touching ? (this.touching = !0, | |
e = n.CollisionEnter) : t && this.touching ? e = n.CollisionStay : !t && this.touching && (this.touching = !1, | |
e = n.CollisionExit), | |
e | |
} | |
, | |
r.CollisionType = n, | |
e.exports = r | |
} | |
), { | |
"./CCIntersection": 92 | |
}], | |
92: [(function(t, e) { | |
"use strict"; | |
var i = {}; | |
function n(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) | |
, a = (n.y - i.y) * (e.x - t.x) - (n.x - i.x) * (e.y - t.y); | |
if (0 !== a) { | |
var o = r / a | |
, c = s / a; | |
if (0 <= o && o <= 1 && 0 <= c && c <= 1) | |
return !0 | |
} | |
return !1 | |
} | |
function r(t, e, i) { | |
for (var r = i.length, s = 0; s < r; ++s) | |
if (n(t, e, i[s], i[(s + 1) % r])) | |
return !0; | |
return !1 | |
} | |
function s(t, e) { | |
for (var i = !1, n = t.x, r = t.y, s = e.length, a = 0, o = s - 1; a < s; o = a++) { | |
var c = e[a].x | |
, l = e[a].y | |
, h = e[o].x | |
, u = e[o].y; | |
l > r != u > r && n < (h - c) * (r - l) / (u - l) + c && (i = !i) | |
} | |
return i | |
} | |
function a(t, e, i, n) { | |
var r, s = i.x - e.x, a = i.y - e.y, o = s * s + a * a, c = ((t.x - e.x) * s + (t.y - e.y) * a) / o; | |
return r = n ? o ? c < 0 ? e : c > 1 ? i : cc.v2(e.x + c * s, e.y + c * a) : e : cc.v2(e.x + c * s, e.y + c * a), | |
s = t.x - r.x, | |
a = t.y - r.y, | |
Math.sqrt(s * s + a * a) | |
} | |
i.lineLine = n, | |
i.lineRect = function(t, e, i) { | |
var r = new cc.Vec2(i.x,i.y) | |
, s = new cc.Vec2(i.x,i.yMax) | |
, a = new cc.Vec2(i.xMax,i.yMax) | |
, o = new cc.Vec2(i.xMax,i.y); | |
return !!(n(t, e, r, s) || n(t, e, s, a) || n(t, e, a, o) || n(t, e, o, r)) | |
} | |
, | |
i.linePolygon = r, | |
i.rectRect = function(t, e) { | |
var i = t.x | |
, n = t.y | |
, r = t.x + t.width | |
, s = t.y + t.height | |
, a = e.x | |
, o = e.y | |
, c = e.x + e.width | |
, l = e.y + e.height; | |
return i <= c && r >= a && n <= l && s >= o | |
} | |
, | |
i.rectPolygon = function(t, e) { | |
var i, n, a = new cc.Vec2(t.x,t.y), o = new cc.Vec2(t.x,t.yMax), c = new cc.Vec2(t.xMax,t.yMax), l = new cc.Vec2(t.xMax,t.y); | |
if (r(a, o, e)) | |
return !0; | |
if (r(o, c, e)) | |
return !0; | |
if (r(c, l, e)) | |
return !0; | |
if (r(l, a, e)) | |
return !0; | |
for (i = 0, | |
n = e.length; i < n; ++i) | |
if (s(e[i], t)) | |
return !0; | |
return !!(s(a, e) || s(o, e) || s(c, e) || s(l, e)) | |
} | |
, | |
i.polygonPolygon = function(t, e) { | |
var i, n; | |
for (i = 0, | |
n = t.length; i < n; ++i) | |
if (r(t[i], t[(i + 1) % n], e)) | |
return !0; | |
for (i = 0, | |
n = e.length; i < n; ++i) | |
if (s(e[i], t)) | |
return !0; | |
for (i = 0, | |
n = t.length; i < n; ++i) | |
if (s(t[i], e)) | |
return !0; | |
return !1 | |
} | |
, | |
i.circleCircle = function(t, e) { | |
return t.position.sub(e.position).mag() < t.radius + e.radius | |
} | |
, | |
i.polygonCircle = function(t, e) { | |
var i = e.position; | |
if (s(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 | |
} | |
, | |
i.pointInPolygon = s, | |
i.pointLineDistance = a, | |
cc.Intersection = e.exports = i | |
} | |
), {}], | |
93: [(function(t, e) { | |
"use strict"; | |
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 i = cc.Class({ | |
name: "cc.PolygonCollider", | |
extends: cc.Collider, | |
mixins: [cc.Collider.Polygon], | |
editor: !1 | |
}); | |
cc.PolygonCollider = e.exports = i | |
} | |
), {}], | |
94: [(function(t) { | |
"use strict"; | |
t("./CCCollisionManager"), | |
t("./CCCollider"), | |
t("./CCBoxCollider"), | |
t("./CCCircleCollider"), | |
t("./CCPolygonCollider") | |
} | |
), { | |
"./CCBoxCollider": 87, | |
"./CCCircleCollider": 88, | |
"./CCCollider": 89, | |
"./CCCollisionManager": 90, | |
"./CCPolygonCollider": 93 | |
}], | |
95: [(function(t, e) { | |
"use strict"; | |
t("./platform/CCClass"); | |
var i = t("./platform/CCObject").Flags | |
, n = t("./platform/js").array | |
, r = i.IsStartCalled | |
, s = i.IsOnEnableCalled; | |
function a(t, e) { | |
for (var i = e.constructor._executionOrder, n = e._id, r = 0, s = t.length - 1, a = s >>> 1; r <= s; a = r + s >>> 1) { | |
var o = t[a] | |
, c = o.constructor._executionOrder; | |
if (c > i) | |
s = a - 1; | |
else if (c < i) | |
r = a + 1; | |
else { | |
var l = o._id; | |
if (l > n) | |
s = a - 1; | |
else { | |
if (!(l < n)) | |
return a; | |
r = a + 1 | |
} | |
} | |
} | |
return ~r | |
} | |
function o(t, e) { | |
for (var i = t.array, n = t.i + 1; n < i.length; ) { | |
var r = i[n]; | |
r._enabled && r.node && r.node._activeInHierarchy ? ++n : (t.removeAt(n), | |
e && (r._objFlags &= ~e)) | |
} | |
} | |
i.IsEditorOnEnableCalled; | |
var c = cc.Class({ | |
__ctor__: function(t) { | |
var e = n.MutableForwardIterator; | |
this._zero = new e([]), | |
this._neg = new e([]), | |
this._pos = new e([]), | |
this._invoke = t | |
}, | |
statics: { | |
stableRemoveInactive: o | |
}, | |
add: null, | |
remove: null, | |
invoke: null | |
}); | |
function l(t, e) { | |
return t.constructor._executionOrder - e.constructor._executionOrder | |
} | |
var h = cc.Class({ | |
extends: c, | |
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) { | |
o(this._zero, t), | |
o(this._neg, t), | |
o(this._pos, t) | |
}, | |
invoke: function() { | |
var t = this._neg; | |
t.array.length > 0 && (t.array.sort(l), | |
this._invoke(t), | |
t.array.length = 0), | |
this._invoke(this._zero), | |
this._zero.array.length = 0; | |
var e = this._pos; | |
e.array.length > 0 && (e.array.sort(l), | |
this._invoke(e), | |
e.array.length = 0) | |
} | |
}) | |
, u = cc.Class({ | |
extends: c, | |
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 = a(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 = a(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 f(t, e, i, n) { | |
var r = "var a=it.array;for(it.i=0;it.i<a.length;++it.i){var c=a[it.i];" + t + "}"; | |
return n = e ? Function("it", "dt", r) : Function("it", r), | |
t = Function("c", "dt", t), | |
function(e, r) { | |
try { | |
n(e, r) | |
} catch (a) { | |
cc._throw(a); | |
var s = e.array; | |
for (i && (s[e.i]._objFlags |= i), | |
++e.i; e.i < s.length; ++e.i) | |
try { | |
t(s[e.i], r) | |
} catch (a) { | |
cc._throw(a), | |
i && (s[e.i]._objFlags |= i) | |
} | |
} | |
} | |
} | |
var d = f("c.start();c._objFlags|=" + r, !1, r) | |
, _ = f("c.update(dt)", !0) | |
, p = f("c.lateUpdate(dt)", !0); | |
function v() { | |
this.startInvoker = new h(d), | |
this.updateInvoker = new u(_), | |
this.lateUpdateInvoker = new u(p), | |
this._deferredComps = [], | |
this._updating = !1 | |
} | |
var g = cc.Class({ | |
ctor: v, | |
unscheduleAll: v, | |
statics: { | |
LifeCycleInvoker: c, | |
OneOffInvoker: h, | |
createInvokeImpl: f, | |
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]; | |
n._enabled && (n.onEnable(), | |
!n.node._activeInHierarchy || e._onEnabled(n)) | |
} | |
} | |
}, | |
_onEnabled: function(t) { | |
cc.director.getScheduler().resumeTarget(t), | |
t._objFlags |= s, | |
this._updating ? this._deferredComps.push(t) : this._scheduleImmediate(t) | |
}, | |
_onDisabled: function(t) { | |
cc.director.getScheduler().pauseTarget(t), | |
t._objFlags &= ~s; | |
var e = this._deferredComps.indexOf(t); | |
e >= 0 ? n.fastRemoveAt(this._deferredComps, e) : (!t.start || t._objFlags & r || this.startInvoker.remove(t), | |
t.update && this.updateInvoker.remove(t), | |
t.lateUpdate && this.lateUpdateInvoker.remove(t)) | |
}, | |
enableComp: function(t, e) { | |
if (!(t._objFlags & s)) { | |
if (t.onEnable) { | |
if (e) | |
return void e.add(t); | |
if (t.onEnable(), | |
!t.node._activeInHierarchy) | |
return | |
} | |
this._onEnabled(t) | |
} | |
}, | |
disableComp: function(t) { | |
t._objFlags & s && (t.onDisable && t.onDisable(), | |
this._onDisabled(t)) | |
}, | |
_scheduleImmediate: function(t) { | |
"function" != typeof t.start || t._objFlags & r || this.startInvoker.add(t), | |
"function" == typeof t.update && this.updateInvoker.add(t), | |
"function" == typeof t.lateUpdate && this.lateUpdateInvoker.add(t) | |
}, | |
_deferredSchedule: function() { | |
for (var t = this._deferredComps, e = 0, i = t.length; e < i; e++) | |
this._scheduleImmediate(t[e]); | |
t.length = 0 | |
}, | |
_startForNewComps: function() { | |
this._deferredComps.length > 0 && (this._deferredSchedule(), | |
this.startInvoker.invoke()) | |
}, | |
startPhase: function() { | |
this._updating = !0, | |
this.startInvoker.invoke(), | |
this._startForNewComps() | |
}, | |
updatePhase: function(t) { | |
this.updateInvoker.invoke(t) | |
}, | |
lateUpdatePhase: function(t) { | |
this.lateUpdateInvoker.invoke(t), | |
this._updating = !1, | |
this._startForNewComps() | |
} | |
}); | |
e.exports = g | |
} | |
), { | |
"./platform/CCClass": 162, | |
"./platform/CCObject": 168, | |
"./platform/js": 183, | |
"./utils/misc": 236 | |
}], | |
96: [(function(t, e) { | |
"use strict"; | |
var i = t("../../animation/animation-animator") | |
, n = t("../../animation/animation-clip") | |
, r = t("../event/event-target") | |
, s = t("../platform/js") | |
, a = function(t, e) { | |
return t === e | |
} | |
, o = cc.Enum({ | |
PLAY: "play", | |
STOP: "stop", | |
PAUSE: "pause", | |
RESUME: "resume", | |
LASTFRAME: "lastframe", | |
FINISHED: "finished" | |
}) | |
, c = cc.Class({ | |
name: "cc.Animation", | |
extends: t("./CCComponent"), | |
mixins: [r], | |
editor: !1, | |
statics: { | |
EventType: o | |
}, | |
ctor: function() { | |
cc.EventTarget.call(this), | |
this._animator = null, | |
this._nameToState = s.createMap(!0), | |
this._didInit = !1, | |
this._currentClip = null | |
}, | |
properties: { | |
_defaultClip: { | |
default: null, | |
type: n | |
}, | |
defaultClip: { | |
type: n, | |
get: function() { | |
return this._defaultClip | |
}, | |
set: function() {}, | |
tooltip: !1 | |
}, | |
currentClip: { | |
get: function() { | |
return this._currentClip | |
}, | |
set: function(t) { | |
this._currentClip = t | |
}, | |
type: n, | |
visible: !1 | |
}, | |
_writableClips: { | |
get: function() { | |
return this._clips | |
}, | |
set: function(t) { | |
this._didInit = !1, | |
this._clips = t, | |
this._init() | |
}, | |
type: [n] | |
}, | |
_clips: { | |
default: [], | |
type: [n], | |
tooltip: !1, | |
visible: !0 | |
}, | |
playOnLoad: { | |
default: !1, | |
tooltip: !1 | |
} | |
}, | |
start: function() { | |
if (this.playOnLoad && this._defaultClip && (!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); | |
return this._animator.stopStatesExcept(i), | |
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; | |
n.isPlaying && i.isPlaying ? i.isPaused ? n.resumeState(i) : (n.stopState(i), | |
n.playState(i, e)) : 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.getAnimationState(t); | |
e && this._animator.resumeState(e) | |
} else | |
this.enabled = !0 | |
}, | |
setCurrentTime: function(t, e) { | |
if (this._init(), | |
e) { | |
var i = this.getAnimationState(e); | |
i && this._animator.setStateTime(i, t) | |
} else | |
this._animator.setStateTime(t) | |
}, | |
getAnimationState: function(t) { | |
this._init(); | |
var e = this._nameToState[t]; | |
return e && !e.curveLoaded && this._animator._reloadClip(e), | |
e || null | |
}, | |
hasAnimationState: function(t) { | |
return this._init(), | |
!!this._nameToState[t] | |
}, | |
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); | |
return this._nameToState[e] = r, | |
r | |
} | |
}, | |
removeClip: function(t, e) { | |
if (t) { | |
var i; | |
for (var n in this._init(), | |
this._nameToState) | |
if (i = this._nameToState[n], | |
a(i.clip, t)) | |
break; | |
if (t === this._defaultClip) { | |
if (!e) | |
return; | |
this._defaultClip = null | |
} | |
if (i && i.isPlaying) { | |
if (!e) | |
return; | |
this.stop(i.name) | |
} | |
this._clips = this._clips.filter((function(e) { | |
return !a(e, t) | |
} | |
)), | |
i && delete this._nameToState[i.name] | |
} | |
}, | |
sample: function(t) { | |
if (this._init(), | |
t) { | |
var e = this.getAnimationState(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) { | |
var s = this._nameToState; | |
for (var a in s) | |
s[a]._lastframeEventOn = !0 | |
} | |
return r | |
}, | |
off: function(t, e, i) { | |
if (this._init(), | |
"lastframe" === t) { | |
var n = this._nameToState; | |
for (var r in n) | |
n[r]._lastframeEventOn = !1 | |
} | |
this._EventTargetOff(t, e, i) | |
}, | |
_init: function() { | |
this._didInit || (this._didInit = !0, | |
this._animator = new i(this.node,this), | |
this._createStates()) | |
}, | |
_createStates: function() { | |
this._nameToState = s.createMap(!0); | |
for (var t = null, e = !1, i = 0; i < this._clips.length; ++i) { | |
var n = this._clips[i]; | |
n && (t = new cc.AnimationState(n), | |
this._nameToState[t.name] = t, | |
a(this._defaultClip, n) && (e = t)) | |
} | |
this._defaultClip && !e && (t = new cc.AnimationState(this._defaultClip), | |
this._nameToState[t.name] = t) | |
} | |
}); | |
c.prototype._EventTargetOn = r.prototype.on, | |
c.prototype._EventTargetOff = r.prototype.off, | |
cc.Animation = e.exports = c | |
} | |
), { | |
"../../animation/animation-animator": 9, | |
"../../animation/animation-clip": 10, | |
"../event/event-target": 134, | |
"../platform/js": 183, | |
"./CCComponent": 100 | |
}], | |
97: [(function(t, e) { | |
"use strict"; | |
var i = ["touchstart", "touchmove", "touchend", "mousedown", "mousemove", "mouseup", "mouseenter", "mouseleave", "mousewheel"]; | |
function n(t) { | |
t.stopPropagation() | |
} | |
var r = 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 < i.length; t++) | |
this.node.on(i[t], n, this) | |
}, | |
onDisable: function() { | |
for (var t = 0; t < i.length; t++) | |
this.node.off(i[t], n, this) | |
} | |
}); | |
cc.BlockInputEvents = e.exports = r | |
} | |
), { | |
"./CCComponent": 100 | |
}], | |
98: [(function(t, e) { | |
"use strict"; | |
var i = t("./CCComponent") | |
, n = t("../utils/gray-sprite-state") | |
, r = cc.Enum({ | |
NONE: 0, | |
COLOR: 1, | |
SPRITE: 2, | |
SCALE: 3 | |
}) | |
, s = cc.Enum({ | |
NORMAL: 0, | |
HOVER: 1, | |
PRESSED: 2, | |
DISABLED: 3 | |
}) | |
, a = cc.Class({ | |
name: "cc.Button", | |
extends: i, | |
mixins: [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._graySpriteMaterial = null, | |
this._spriteMaterial = 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(!0) | |
} | |
}, | |
transition: { | |
default: r.NONE, | |
tooltip: !1, | |
type: r, | |
animatable: !1, | |
notify: function(t) { | |
this._updateTransition(t) | |
}, | |
formerlySerializedAs: "transition" | |
}, | |
normalColor: { | |
default: cc.Color.WHITE, | |
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(), | |
t && this.target !== t && this._unregisterTargetEvent(t) | |
} | |
}, | |
clickEvents: { | |
default: [], | |
type: cc.Component.EventHandler, | |
tooltip: !1 | |
} | |
}, | |
statics: { | |
Transition: r | |
}, | |
__preload: function() { | |
this._applyTarget(), | |
this._resetState() | |
}, | |
_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(), | |
this._updateState() | |
}, | |
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(); | |
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() | |
, i = t.clone(); | |
e.opacity = i.a, | |
i.a = 255, | |
e.color = i | |
}, | |
_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; | |
if (this.duration > 0 && (i = this.time / this.duration), | |
i >= 1 && (i = 1), | |
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) { | |
t.on(cc.Node.EventType.SCALE_CHANGED, this._onTargetScaleChanged, this) | |
}, | |
_unregisterTargetEvent: function(t) { | |
t.off(cc.Node.EventType.SCALE_CHANGED, this._onTargetScaleChanged, this) | |
}, | |
_getTargetSprite: function(t) { | |
var e = null; | |
return t && (e = t.getComponent(cc.Sprite)), | |
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) { | |
this.interactable && this.enabledInHierarchy && (this._pressed = !0, | |
this._updateState(), | |
t.stopPropagation()) | |
}, | |
_onTouchMove: function(t) { | |
if (this.interactable && this.enabledInHierarchy && this._pressed) { | |
var e, i = t.touch, n = this.node._hitTest(i.getLocation()), a = this._getTarget(), o = this._originalScale; | |
this.transition === r.SCALE && o ? n ? (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) : (this.time = 0, | |
this._transitionFinished = !0, | |
a.setScale(o.x, o.y)) : (e = n ? s.PRESSED : s.NORMAL, | |
this._applyTransition(e)), | |
t.stopPropagation() | |
} | |
}, | |
_onTouchEnded: function(t) { | |
this.interactable && this.enabledInHierarchy && (this._pressed && (cc.Component.EventHandler.emitEvents(this.clickEvents, t), | |
this.node.emit("click", this)), | |
this._pressed = !1, | |
this._updateState(), | |
t.stopPropagation()) | |
}, | |
_onTouchCancel: function() { | |
this.interactable && this.enabledInHierarchy && (this._pressed = !1, | |
this._updateState()) | |
}, | |
_onMouseMoveIn: function() { | |
!this._pressed && this.interactable && this.enabledInHierarchy && (this.transition !== r.SPRITE || this.hoverSprite) && (this._hovered || (this._hovered = !0, | |
this._updateState())) | |
}, | |
_onMouseMoveOut: function() { | |
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), | |
this._fromColor = e.clone(), | |
this._toColor = 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() { | |
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(t) { | |
if (this._sprite && (this.enableAutoGrayEffect || t)) { | |
var e = !1; | |
this.transition === r.SPRITE && this.disabledSprite || (e = this.enableAutoGrayEffect && !this.interactable), | |
this._switchGrayMaterial(e, this._sprite) | |
} | |
} | |
}); | |
cc.Button = e.exports = a | |
} | |
), { | |
"../utils/gray-sprite-state": 233, | |
"./CCComponent": 100 | |
}], | |
99: [(function(t, e) { | |
"use strict"; | |
var i = t("../camera/CCCamera") | |
, n = t("./CCComponent") | |
, r = cc.Class({ | |
name: "cc.Canvas", | |
extends: n, | |
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() | |
}, | |
tooltip: !1 | |
}, | |
_fitWidth: !1, | |
_fitHeight: !0, | |
fitHeight: { | |
get: function() { | |
return this._fitHeight | |
}, | |
set: function(t) { | |
this._fitHeight !== t && (this._fitHeight = t, | |
this.applySettings()) | |
}, | |
tooltip: !1 | |
}, | |
fitWidth: { | |
get: function() { | |
return this._fitWidth | |
}, | |
set: function(t) { | |
this._fitWidth !== t && (this._fitWidth = t, | |
this.applySettings()) | |
}, | |
tooltip: !1 | |
} | |
}, | |
_fitDesignResolution: !1, | |
__preload: function() { | |
if (!r.instance) { | |
r.instance = this, | |
this.applySettings(); | |
var t = this.getComponent(cc.Widget); | |
t && t.updateAlignment() | |
} | |
}, | |
start: function() { | |
if (!i.main && cc.game.renderType !== cc.game.RENDER_TYPE_CANVAS) { | |
var t = new cc.Node("Main Camera"); | |
t.parent = this.node, | |
t.setSiblingIndex(0); | |
var e = t.addComponent(i) | |
, n = i.ClearFlags; | |
e.clearFlags = n.COLOR | n.DEPTH | n.STENCIL, | |
e.depth = -1 | |
} | |
}, | |
onDestroy: function() { | |
r.instance === this && (r.instance = null) | |
}, | |
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 = r | |
} | |
), { | |
"../camera/CCCamera": 86, | |
"./CCComponent": 100 | |
}], | |
100: [(function(t, e) { | |
"use strict"; | |
var i = t("../platform/CCObject") | |
, n = t("../platform/js") | |
, r = new (t("../platform/id-generater"))("Comp") | |
, s = (i.Flags.IsOnEnableCalled, | |
i.Flags.IsOnLoadCalled) | |
, a = !!cc.ActionManager | |
, o = cc.Class({ | |
name: "cc.Component", | |
extends: i, | |
ctor: function() { | |
this._id = r.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("."); | |
return e >= 0 && (t = t.slice(e + 1)), | |
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, | |
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 && this.node._activeInHierarchy | |
}, | |
visible: !1 | |
}, | |
_isOnLoadCalled: { | |
get: function() { | |
return this._objFlags & s | |
} | |
} | |
}, | |
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() { | |
a && cc.director.getActionManager().removeAllActionsFromTarget(this), | |
this.unscheduleAllCallbacks(); | |
for (var t = this.__eventTargets; t.length; ) { | |
var e = t.pop(); | |
e && e.targetOff(this) | |
} | |
cc.director._nodeActivator.destroyComp(this), | |
this.node._removeComponent(this) | |
}, | |
_instantiate: function(t) { | |
return t || (t = cc.instantiate._clone(this, this)), | |
t.node = null, | |
t | |
}, | |
schedule: function(t, e, i, n) { | |
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) | |
} | |
}); | |
o._requireComponent = null, | |
o._executionOrder = 0, | |
n.value(o, "_registerEditorProps", (function(t, e) { | |
var i = e.requireComponent; | |
i && (t._requireComponent = i); | |
var n = e.executionOrder; | |
n && "number" == typeof n && (t._executionOrder = n) | |
} | |
)), | |
o.prototype.__scriptUuid = "", | |
cc.Component = e.exports = o | |
} | |
), { | |
"../platform/CCObject": 168, | |
"../platform/id-generater": 179, | |
"../platform/js": 183 | |
}], | |
101: [(function() { | |
"use strict"; | |
cc.Component.EventHandler = cc.Class({ | |
name: "cc.ClickEvent", | |
properties: { | |
target: { | |
default: null, | |
type: cc.Node | |
}, | |
component: "", | |
_componentId: "", | |
_componentName: { | |
get: function() { | |
return this._genCompIdIfNeeded(), | |
this._compId2Name(this._componentId) | |
}, | |
set: function(t) { | |
this._componentId = this._compName2Id(t) | |
} | |
}, | |
handler: { | |
default: "" | |
}, | |
customEventData: { | |
default: "" | |
} | |
}, | |
statics: { | |
emitEvents: function(t) { | |
var e; | |
if (arguments.length > 0) | |
for (var i = 0, n = (e = Array(arguments.length - 1)).length; i < n; i++) | |
e[i] = arguments[i + 1]; | |
for (var r = 0, s = t.length; r < s; r++) { | |
var a = t[r]; | |
a instanceof cc.Component.EventHandler && a.emit(e) | |
} | |
} | |
}, | |
emit: function(t) { | |
var e = this.target; | |
if (cc.isValid(e)) { | |
this._genCompIdIfNeeded(); | |
var i = cc.js._getClassById(this._componentId) | |
, n = e.getComponent(i); | |
if (cc.isValid(n)) { | |
var r = n[this.handler]; | |
"function" == typeof r && (null != this.customEventData && "" !== this.customEventData && (t = t.slice()).push(this.customEventData), | |
r.apply(n, t)) | |
} | |
} | |
}, | |
_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() { | |
this._componentId || (this._componentName = this.component, | |
this.component = "") | |
} | |
}) | |
} | |
), {}], | |
102: [(function(t, e) { | |
"use strict"; | |
var i = t("../platform/CCMacro") | |
, n = t("./CCRenderComponent") | |
, r = (t("../assets/material/CCMaterial"), | |
t("../renderer/utils/label/label-frame")) | |
, s = t("../utils/blend-func") | |
, a = t("../renderer/utils/utils").deleteFromDynamicAtlas | |
, o = i.TextAlignment | |
, c = i.VerticalTextAlignment | |
, l = cc.Enum({ | |
NONE: 0, | |
CLAMP: 1, | |
SHRINK: 2, | |
RESIZE_HEIGHT: 3 | |
}) | |
, h = cc.Enum({ | |
NONE: 0, | |
BITMAP: 1, | |
CHAR: 2 | |
}) | |
, u = cc.Class({ | |
name: "cc.Label", | |
extends: n, | |
mixins: [s], | |
ctor: function() { | |
this._actualFontSize = 0, | |
this._assemblerData = null, | |
this._frame = null, | |
this._ttfTexture = null, | |
this._letterTexture = null, | |
cc.game.renderType === cc.game.RENDER_TYPE_CANVAS ? this._updateMaterial = this._updateMaterialCanvas : this._updateMaterial = this._updateMaterialWebgl, | |
this._customOffsetX = 0, | |
this._customOffsetY = 0, | |
this._actualLineHeight = void 0 | |
}, | |
editor: !1, | |
properties: { | |
_string: { | |
default: "", | |
formerlySerializedAs: "_N$string" | |
}, | |
string: { | |
get: function() { | |
return this._string | |
}, | |
set: function(t) { | |
var e = this._string; | |
this._string = "" + t, | |
this.string !== e && this.setVertsDirty(), | |
this._checkStringEmpty() | |
}, | |
multiline: !0, | |
tooltip: !1 | |
}, | |
horizontalAlign: { | |
default: o.LEFT, | |
type: o, | |
tooltip: !1, | |
notify: function(t) { | |
this.horizontalAlign !== t && this.setVertsDirty() | |
}, | |
animatable: !1 | |
}, | |
verticalAlign: { | |
default: c.TOP, | |
type: c, | |
tooltip: !1, | |
notify: function(t) { | |
this.verticalAlign !== t && this.setVertsDirty() | |
}, | |
animatable: !1 | |
}, | |
actualFontSize: { | |
displayName: "Actual Font Size", | |
animatable: !1, | |
readonly: !0, | |
get: function() { | |
return this._actualFontSize | |
}, | |
tooltip: !1 | |
}, | |
_fontSize: 40, | |
fontSize: { | |
get: function() { | |
return this._fontSize | |
}, | |
set: function(t) { | |
this._fontSize !== t && (this._fontSize = t, | |
this.setVertsDirty()) | |
}, | |
range: [0, 512], | |
tooltip: !1 | |
}, | |
fontFamily: { | |
default: "Arial", | |
tooltip: !1, | |
notify: function(t) { | |
this.fontFamily !== t && this.setVertsDirty() | |
}, | |
animatable: !1 | |
}, | |
_lineHeight: 40, | |
lineHeight: { | |
get: function() { | |
return this._lineHeight | |
}, | |
set: function(t) { | |
this._lineHeight !== t && (this._lineHeight = t, | |
this.setVertsDirty()) | |
}, | |
tooltip: !1 | |
}, | |
overflow: { | |
default: l.NONE, | |
type: l, | |
tooltip: !1, | |
notify: function(t) { | |
this.overflow !== t && this.setVertsDirty() | |
}, | |
animatable: !1 | |
}, | |
_enableWrapText: !0, | |
enableWrapText: { | |
get: function() { | |
return this._enableWrapText | |
}, | |
set: function(t) { | |
this._enableWrapText !== t && (this._enableWrapText = t, | |
this.setVertsDirty()) | |
}, | |
animatable: !1, | |
tooltip: !1 | |
}, | |
_N$file: null, | |
font: { | |
get: function() { | |
return this._N$file | |
}, | |
set: function(t) { | |
this.font !== t && (t || (this._isSystemFontUsed = !0), | |
this._N$file = t, | |
t && this._isSystemFontUsed && (this._isSystemFontUsed = !1), | |
this.enabledInHierarchy && this._forceUpdateRenderData()) | |
}, | |
type: cc.Font, | |
tooltip: !1, | |
animatable: !1 | |
}, | |
_isSystemFontUsed: !0, | |
useSystemFont: { | |
get: function() { | |
return this._isSystemFontUsed | |
}, | |
set: function(t) { | |
if (this._isSystemFontUsed !== t) { | |
if (this._isSystemFontUsed = !!t, | |
t) { | |
if (this.font = null, | |
!this.enabledInHierarchy) | |
return; | |
this._forceUpdateRenderData() | |
} | |
this.markForValidate() | |
} | |
}, | |
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.setVertsDirty() | |
}, | |
tooltip: !1 | |
}, | |
_batchAsBitmap: !1, | |
cacheMode: { | |
default: h.NONE, | |
type: h, | |
tooltip: !1, | |
notify: function(t) { | |
this.cacheMode !== t && (t !== h.BITMAP || this.font instanceof cc.BitmapFont || this._frame && this._frame._resetDynamicAtlasFrame(), | |
t === h.CHAR && (this._ttfTexture = null), | |
this.enabledInHierarchy && this._forceUpdateRenderData()) | |
}, | |
animatable: !1 | |
}, | |
_styleFlags: 0, | |
enableBold: { | |
get: function() { | |
return !!(1 & this._styleFlags) | |
}, | |
set: function(t) { | |
t ? this._styleFlags |= 1 : this._styleFlags &= -2, | |
this.setVertsDirty() | |
}, | |
animatable: !1, | |
tooltip: !1 | |
}, | |
enableItalic: { | |
get: function() { | |
return !!(2 & this._styleFlags) | |
}, | |
set: function(t) { | |
t ? this._styleFlags |= 2 : this._styleFlags &= -3, | |
this.setVertsDirty() | |
}, | |
animatable: !1, | |
tooltip: !1 | |
}, | |
enableUnderline: { | |
get: function() { | |
return !!(4 & this._styleFlags) | |
}, | |
set: function(t) { | |
t ? this._styleFlags |= 4 : this._styleFlags &= -5, | |
this.setVertsDirty() | |
}, | |
animatable: !1, | |
tooltip: !1 | |
}, | |
_underlineHeight: 0, | |
underlineHeight: { | |
get: function() { | |
return this._underlineHeight | |
}, | |
set: function(t) { | |
this._underlineHeight !== t && (this._underlineHeight = t, | |
this.setVertsDirty()) | |
}, | |
tooltip: !1 | |
}, | |
customOffsetX: { | |
get: function() { | |
return this._customOffsetX | |
}, | |
set: function(t) { | |
this._customOffsetX !== t && (this._customOffsetX = t, | |
this.setVertsDirty()) | |
} | |
}, | |
customOffsetY: { | |
get: function() { | |
return this._customOffsetY | |
}, | |
set: function(t) { | |
this._customOffsetY !== t && (this._customOffsetY = t, | |
this.setVertsDirty()) | |
} | |
}, | |
actualLineHeight: { | |
get: function() { | |
return this._actualLineHeight || this._lineHeight | |
}, | |
set: function(t) { | |
this._actualLineHeight !== t && (this._actualLineHeight = t, | |
this.setVertsDirty()) | |
} | |
} | |
}, | |
statics: { | |
HorizontalAlign: o, | |
VerticalAlign: c, | |
Overflow: l, | |
CacheMode: h, | |
_shareAtlas: null, | |
clearCharCache: function() { | |
u._shareAtlas && u._shareAtlas.clearAllCache() | |
} | |
}, | |
onLoad: function() { | |
this._batchAsBitmap && this.cacheMode === h.NONE && (this.cacheMode = h.BITMAP, | |
this._batchAsBitmap = !1), | |
cc.game.renderType === cc.game.RENDER_TYPE_CANVAS && (this.cacheMode = h.NONE) | |
}, | |
onEnable: function() { | |
this._super(), | |
this.node.on(cc.Node.EventType.SIZE_CHANGED, this._nodeSizeChanged, this), | |
this.node.on(cc.Node.EventType.ANCHOR_CHANGED, this.setVertsDirty, this), | |
this.node.on(cc.Node.EventType.COLOR_CHANGED, this._nodeColorChanged, this), | |
this._forceUpdateRenderData() | |
}, | |
onDisable: function() { | |
this._super(), | |
this.node.off(cc.Node.EventType.SIZE_CHANGED, this._nodeSizeChanged, this), | |
this.node.off(cc.Node.EventType.ANCHOR_CHANGED, this.setVertsDirty, this), | |
this.node.off(cc.Node.EventType.COLOR_CHANGED, this._nodeColorChanged, this) | |
}, | |
onDestroy: function() { | |
this._assembler && this._assembler._resetAssemblerData && this._assembler._resetAssemblerData(this._assemblerData), | |
this._assemblerData = null, | |
this._letterTexture = null, | |
this._ttfTexture && (this._ttfTexture.destroy(), | |
this._ttfTexture = null), | |
this._super() | |
}, | |
onRestore: !1, | |
_nodeSizeChanged: function() { | |
this.overflow !== l.NONE && this.setVertsDirty() | |
}, | |
_nodeColorChanged: function() { | |
this.font instanceof cc.BitmapFont || this.setVertsDirty() | |
}, | |
setVertsDirty: function() { | |
this._super() | |
}, | |
_updateColor: function() { | |
this.font instanceof cc.BitmapFont || this._srcBlendFactor === cc.macro.BlendFactor.SRC_ALPHA && this.node._renderFlag & cc.RenderFlow.FLAG_OPACITY || this.setVertsDirty(), | |
n.prototype._updateColor.call(this) | |
}, | |
_validateRender: function() { | |
if (this.string) { | |
if (this._materials[0]) { | |
var t = this.font; | |
if (!(t instanceof cc.BitmapFont)) | |
return; | |
var e = t.spriteFrame; | |
if (e && e.textureLoaded() && t._fntConfig) | |
return | |
} | |
this.disableRender() | |
} else | |
this.disableRender() | |
}, | |
_resetAssembler: function() { | |
this._resetFrame(), | |
n.prototype._resetAssembler.call(this) | |
}, | |
_resetFrame: function() { | |
!this._frame || this.font instanceof cc.BitmapFont || (a(this, this._frame), | |
this._frame = null) | |
}, | |
_checkStringEmpty: function() { | |
this.markForRender(!!this.string) | |
}, | |
_on3DNodeChanged: function() { | |
this._resetAssembler(), | |
this._applyFontTexture() | |
}, | |
_onBMFontTextureLoaded: function() { | |
this._frame._texture = this.font.spriteFrame._texture, | |
this.markForRender(!0), | |
this._updateMaterial(), | |
this._assembler && this._assembler.updateRenderData(this) | |
}, | |
_onBlendChanged: function() { | |
this.useSystemFont && this.enabledInHierarchy && this._forceUpdateRenderData() | |
}, | |
_applyFontTexture: function() { | |
var t = this.font; | |
if (t instanceof cc.BitmapFont) { | |
var e = t.spriteFrame; | |
this._frame = e, | |
e && e.onTextureLoaded(this._onBMFontTextureLoaded, this) | |
} else | |
this._nativeTTF() || (this._frame || (this._frame = new r), | |
this.cacheMode === h.CHAR ? (this._letterTexture = this._assembler._getAssemblerData(), | |
this._frame._refreshTexture(this._letterTexture)) : this._ttfTexture || (this._ttfTexture = new cc.Texture2D, | |
this._assemblerData = this._assembler._getAssemblerData(), | |
this._ttfTexture.initWithElement(this._assemblerData.canvas)), | |
this.cacheMode !== h.CHAR && (this._frame._resetDynamicAtlasFrame(), | |
this._frame._refreshTexture(this._ttfTexture), | |
this._srcBlendFactor === cc.macro.BlendFactor.ONE && this._ttfTexture.setPremultiplyAlpha(!0)), | |
this._updateMaterial()), | |
this._assembler && this._assembler.updateRenderData(this); | |
this.markForValidate() | |
}, | |
_updateMaterialCanvas: function() { | |
this._frame && (this._frame._texture._nativeUrl = this.uuid + "_texture") | |
}, | |
_updateMaterialWebgl: function() { | |
var t = this.getMaterial(0); | |
this._nativeTTF() ? t && this._assembler._updateTTFMaterial(this) : this._frame && (t && t.setProperty("texture", this._frame._texture), | |
s.prototype._updateMaterial.call(this)) | |
}, | |
_forceUseCanvas: !1, | |
_useNativeTTF: function() { | |
return cc.macro.ENABLE_NATIVE_TTF_RENDERER && !this._forceUseCanvas | |
}, | |
_nativeTTF: function() { | |
return this._useNativeTTF() && !!this._assembler && !!this._assembler._updateTTFMaterial | |
}, | |
_forceUpdateRenderData: function() { | |
this.setVertsDirty(), | |
this._resetAssembler(), | |
this._applyFontTexture() | |
}, | |
_enableBold: function(t) { | |
this.enableBold = !!t | |
}, | |
_enableItalics: function(t) { | |
this.enableItalic = !!t | |
}, | |
_enableUnderline: function(t) { | |
this.enableUnderline = !!t | |
} | |
}); | |
cc.Label = e.exports = u | |
} | |
), { | |
"../assets/material/CCMaterial": 76, | |
"../platform/CCMacro": 167, | |
"../renderer/utils/label/label-frame": 198, | |
"../renderer/utils/utils": 201, | |
"../utils/blend-func": 230, | |
"./CCRenderComponent": 109 | |
}], | |
103: [(function(t, e) { | |
"use strict"; | |
var i = cc.Class({ | |
name: "cc.LabelOutline", | |
extends: t("./CCComponent"), | |
editor: !1, | |
properties: { | |
_color: cc.Color.WHITE, | |
_width: 1, | |
color: { | |
tooltip: !1, | |
get: function() { | |
return this._color.clone() | |
}, | |
set: function(t) { | |
this._color.equals(t) || this._color.set(t), | |
this._updateRenderData() | |
} | |
}, | |
width: { | |
tooltip: !1, | |
get: function() { | |
return this._width | |
}, | |
set: function(t) { | |
this._width !== t && (this._width = t, | |
this._updateRenderData()) | |
}, | |
range: [0, 512] | |
} | |
}, | |
onEnable: function() { | |
this._updateRenderData() | |
}, | |
onDisable: function() { | |
this._updateRenderData() | |
}, | |
_updateRenderData: function() { | |
var t = this.node.getComponent(cc.Label); | |
t && t.setVertsDirty() | |
} | |
}); | |
cc.LabelOutline = e.exports = i | |
} | |
), { | |
"./CCComponent": 100 | |
}], | |
104: [(function(t, e) { | |
"use strict"; | |
var i = cc.Class({ | |
name: "cc.LabelShadow", | |
extends: t("./CCComponent"), | |
editor: !1, | |
properties: { | |
_color: cc.Color.WHITE, | |
_offset: cc.v2(2, 2), | |
_blur: 2, | |
color: { | |
tooltip: !1, | |
get: function() { | |
return this._color.clone() | |
}, | |
set: function(t) { | |
this._color.equals(t) || this._color.set(t), | |
this._updateRenderData() | |
} | |
}, | |
offset: { | |
tooltip: !1, | |
get: function() { | |
return this._offset | |
}, | |
set: function(t) { | |
this._offset = t, | |
this._updateRenderData() | |
} | |
}, | |
blur: { | |
tooltip: !1, | |
get: function() { | |
return this._blur | |
}, | |
set: function(t) { | |
this._blur = t, | |
this._updateRenderData() | |
}, | |
range: [0, 1024] | |
} | |
}, | |
onEnable: function() { | |
this._updateRenderData() | |
}, | |
onDisable: function() { | |
this._updateRenderData() | |
}, | |
_updateRenderData: function() { | |
var t = this.node.getComponent(cc.Label); | |
t && t.setVertsDirty() | |
} | |
}); | |
cc.LabelShadow = e.exports = i | |
} | |
), { | |
"./CCComponent": 100 | |
}], | |
105: [(function(t, e) { | |
"use strict"; | |
var i = t("../CCNode").EventType | |
, n = cc.Enum({ | |
NONE: 0, | |
HORIZONTAL: 1, | |
VERTICAL: 2, | |
GRID: 3 | |
}) | |
, r = cc.Enum({ | |
NONE: 0, | |
CONTAINER: 1, | |
CHILDREN: 2 | |
}) | |
, s = cc.Enum({ | |
HORIZONTAL: 0, | |
VERTICAL: 1 | |
}) | |
, a = cc.Enum({ | |
BOTTOM_TO_TOP: 0, | |
TOP_TO_BOTTOM: 1 | |
}) | |
, o = cc.Enum({ | |
LEFT_TO_RIGHT: 0, | |
RIGHT_TO_LEFT: 1 | |
}) | |
, c = cc.Class({ | |
name: "cc.Layout", | |
extends: t("./CCComponent"), | |
editor: !1, | |
properties: { | |
_layoutSize: cc.size(300, 200), | |
_layoutDirty: { | |
default: !0, | |
serializable: !1 | |
}, | |
_resize: r.NONE, | |
_N$layoutType: n.NONE, | |
type: { | |
type: n, | |
get: function() { | |
return this._N$layoutType | |
}, | |
set: function(t) { | |
this._N$layoutType = t, | |
this._doLayoutDirty() | |
}, | |
tooltip: !1, | |
animatable: !1 | |
}, | |
resizeMode: { | |
type: r, | |
tooltip: !1, | |
animatable: !1, | |
get: function() { | |
return this._resize | |
}, | |
set: function(t) { | |
this.type === n.NONE && t === r.CHILDREN || (this._resize = t, | |
this._doLayoutDirty()) | |
} | |
}, | |
cellSize: { | |
default: cc.size(40, 40), | |
tooltip: !1, | |
type: cc.Size, | |
notify: function() { | |
this._doLayoutDirty() | |
} | |
}, | |
startAxis: { | |
default: s.HORIZONTAL, | |
tooltip: !1, | |
type: s, | |
notify: function() { | |
this._doLayoutDirty() | |
}, | |
animatable: !1 | |
}, | |
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: o.LEFT_TO_RIGHT, | |
type: o, | |
notify: function() { | |
this._doLayoutDirty() | |
}, | |
tooltip: !1, | |
animatable: !1 | |
}, | |
affectedByScale: { | |
default: !1, | |
notify: function() { | |
this._doLayoutDirty() | |
}, | |
animatable: !1, | |
tooltip: !1 | |
} | |
}, | |
statics: { | |
Type: n, | |
VerticalDirection: a, | |
HorizontalDirection: o, | |
ResizeMode: r, | |
AxisDirection: s | |
}, | |
onEnable: function() { | |
this._addEventListeners(), | |
this.node.getContentSize().equals(cc.size(0, 0)) && this.node.setContentSize(this._layoutSize), | |
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(i.SIZE_CHANGED, this._resized, this), | |
this.node.on(i.ANCHOR_CHANGED, this._doLayoutDirty, this), | |
this.node.on(i.CHILD_ADDED, this._childAdded, this), | |
this.node.on(i.CHILD_REMOVED, this._childRemoved, this), | |
this.node.on(i.CHILD_REORDER, this._doLayoutDirty, this), | |
this._addChildrenEventListeners() | |
}, | |
_removeEventListeners: function() { | |
cc.director.off(cc.Director.EVENT_AFTER_UPDATE, this.updateLayout, this), | |
this.node.off(i.SIZE_CHANGED, this._resized, this), | |
this.node.off(i.ANCHOR_CHANGED, this._doLayoutDirty, this), | |
this.node.off(i.CHILD_ADDED, this._childAdded, this), | |
this.node.off(i.CHILD_REMOVED, this._childRemoved, this), | |
this.node.off(i.CHILD_REORDER, this._doLayoutDirty, this), | |
this._removeChildrenEventListeners() | |
}, | |
_addChildrenEventListeners: function() { | |
for (var t = this.node.children, e = 0; e < t.length; ++e) { | |
var n = t[e]; | |
n.on(i.SCALE_CHANGED, this._doScaleDirty, this), | |
n.on(i.SIZE_CHANGED, this._doLayoutDirty, this), | |
n.on(i.POSITION_CHANGED, this._doLayoutDirty, this), | |
n.on(i.ANCHOR_CHANGED, this._doLayoutDirty, this), | |
n.on("active-in-hierarchy-changed", this._doLayoutDirty, this) | |
} | |
}, | |
_removeChildrenEventListeners: function() { | |
for (var t = this.node.children, e = 0; e < t.length; ++e) { | |
var n = t[e]; | |
n.off(i.SCALE_CHANGED, this._doScaleDirty, this), | |
n.off(i.SIZE_CHANGED, this._doLayoutDirty, this), | |
n.off(i.POSITION_CHANGED, this._doLayoutDirty, this), | |
n.off(i.ANCHOR_CHANGED, this._doLayoutDirty, this), | |
n.off("active-in-hierarchy-changed", this._doLayoutDirty, this) | |
} | |
}, | |
_childAdded: function(t) { | |
t.on(i.SCALE_CHANGED, this._doScaleDirty, this), | |
t.on(i.SIZE_CHANGED, this._doLayoutDirty, this), | |
t.on(i.POSITION_CHANGED, this._doLayoutDirty, this), | |
t.on(i.ANCHOR_CHANGED, this._doLayoutDirty, this), | |
t.on("active-in-hierarchy-changed", this._doLayoutDirty, this), | |
this._doLayoutDirty() | |
}, | |
_childRemoved: function(t) { | |
t.off(i.SCALE_CHANGED, this._doScaleDirty, this), | |
t.off(i.SIZE_CHANGED, this._doLayoutDirty, this), | |
t.off(i.POSITION_CHANGED, this._doLayoutDirty, this), | |
t.off(i.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, s) { | |
var c = this.node.getAnchorPoint() | |
, l = this.node.children | |
, h = 1 | |
, u = this.paddingLeft | |
, f = -c.x * t; | |
this.horizontalDirection === o.RIGHT_TO_LEFT && (h = -1, | |
f = (1 - c.x) * t, | |
u = this.paddingRight); | |
for (var d = f + h * u - h * this.spacingX, _ = 0, p = 0, v = 0, g = 0, m = 0, y = 0, T = 0, E = 0; E < l.length; ++E) | |
(x = l[E]).activeInHierarchy && T++; | |
var A = this.cellSize.width; | |
for (this.type !== n.GRID && this.resizeMode === r.CHILDREN && (A = (t - (this.paddingLeft + this.paddingRight) - (T - 1) * this.spacingX) / T), | |
E = 0; E < l.length; ++E) { | |
var x = l[E] | |
, C = this._getUsedScaleValue(x.scaleX) | |
, b = this._getUsedScaleValue(x.scaleY); | |
if (x.activeInHierarchy) { | |
this._resize === r.CHILDREN && (x.width = A / C, | |
this.type === n.GRID && (x.height = this.cellSize.height / b)); | |
var S = x.anchorX | |
, R = x.width * C | |
, M = x.height * b; | |
v > p && (p = v), | |
M >= p && (v = p, | |
p = M, | |
y = x.getAnchorPoint().y), | |
this.horizontalDirection === o.RIGHT_TO_LEFT && (S = 1 - x.anchorX), | |
d = d + h * S * R + h * this.spacingX; | |
var w = h * (1 - S) * R; | |
if (e) { | |
var I = d + w + h * (h > 0 ? this.paddingRight : this.paddingLeft) | |
, O = this.horizontalDirection === o.LEFT_TO_RIGHT && I > (1 - c.x) * t | |
, L = this.horizontalDirection === o.RIGHT_TO_LEFT && I < -c.x * t; | |
(O || L) && (M >= p ? (0 === v && (v = p), | |
_ += v, | |
v = p) : (_ += p, | |
v = M, | |
p = 0), | |
d = f + h * (u + S * R), | |
g++) | |
} | |
var P = i(x, _, g); | |
t >= R + this.paddingLeft + this.paddingRight && s && x.setPosition(cc.v2(d, P)); | |
var D, N = 1, F = 0 === p ? M : p; | |
this.verticalDirection === a.TOP_TO_BOTTOM ? (m = m || this.node._contentSize.height, | |
(D = P + (N = -1) * (F * y + this.paddingBottom)) < m && (m = D)) : (m = m || -this.node._contentSize.height, | |
(D = P + N * (F * y + this.paddingTop)) > m && (m = D)), | |
d += w | |
} | |
} | |
return m | |
}, | |
_getVerticalBaseHeight: function(t) { | |
var e = 0 | |
, i = 0; | |
if (this.resizeMode === r.CONTAINER) { | |
for (var n = 0; n < t.length; ++n) { | |
var s = t[n]; | |
s.activeInHierarchy && (i++, | |
e += s.height * this._getUsedScaleValue(s.scaleY)) | |
} | |
e += (i - 1) * this.spacingY + this.paddingBottom + this.paddingTop | |
} else | |
e = this.node.getContentSize().height; | |
return e | |
}, | |
_doLayoutVertically: function(t, e, i, s) { | |
var c = this.node.getAnchorPoint() | |
, l = this.node.children | |
, h = 1 | |
, u = this.paddingBottom | |
, f = -c.y * t; | |
this.verticalDirection === a.TOP_TO_BOTTOM && (h = -1, | |
f = (1 - c.y) * t, | |
u = this.paddingTop); | |
for (var d = f + h * u - h * this.spacingY, _ = 0, p = 0, v = 0, g = 0, m = 0, y = 0, T = 0, E = 0; E < l.length; ++E) | |
(x = l[E]).activeInHierarchy && T++; | |
var A = this.cellSize.height; | |
for (this.type !== n.GRID && this.resizeMode === r.CHILDREN && (A = (t - (this.paddingTop + this.paddingBottom) - (T - 1) * this.spacingY) / T), | |
E = 0; E < l.length; ++E) { | |
var x = l[E] | |
, C = this._getUsedScaleValue(x.scaleX) | |
, b = this._getUsedScaleValue(x.scaleY); | |
if (x.activeInHierarchy) { | |
this.resizeMode === r.CHILDREN && (x.height = A / b, | |
this.type === n.GRID && (x.width = this.cellSize.width / C)); | |
var S = x.anchorY | |
, R = x.width * C | |
, M = x.height * b; | |
v > p && (p = v), | |
R >= p && (v = p, | |
p = R, | |
y = x.getAnchorPoint().x), | |
this.verticalDirection === a.TOP_TO_BOTTOM && (S = 1 - x.anchorY), | |
d = d + h * S * M + h * this.spacingY; | |
var w = h * (1 - S) * M; | |
if (e) { | |
var I = d + w + h * (h > 0 ? this.paddingTop : this.paddingBottom) | |
, O = this.verticalDirection === a.BOTTOM_TO_TOP && I > (1 - c.y) * t | |
, L = this.verticalDirection === a.TOP_TO_BOTTOM && I < -c.y * t; | |
(O || L) && (R >= p ? (0 === v && (v = p), | |
_ += v, | |
v = p) : (_ += p, | |
v = R, | |
p = 0), | |
d = f + h * (u + S * M), | |
g++) | |
} | |
var P = i(x, _, g); | |
t >= M + (this.paddingTop + this.paddingBottom) && s && x.setPosition(cc.v2(P, d)); | |
var D, N = 1, F = 0 === p ? R : p; | |
this.horizontalDirection === o.RIGHT_TO_LEFT ? (N = -1, | |
m = m || this.node._contentSize.width, | |
(D = P + N * (F * y + this.paddingLeft)) < m && (m = D)) : (m = m || -this.node._contentSize.width, | |
(D = P + N * (F * y + this.paddingRight)) > m && (m = D)), | |
d += w | |
} | |
} | |
return m | |
}, | |
_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.convertToNodeSpaceAR(cc.v2(e.x, e.y)); | |
r = cc.v2(r.x - this.paddingLeft, r.y - this.paddingBottom); | |
var s = this.node.convertToNodeSpaceAR(cc.v2(e.xMax, e.yMax)) | |
, a = (s = cc.v2(s.x + this.paddingRight, s.y + this.paddingTop)).sub(r); | |
if (0 !== (a = cc.size(parseFloat(a.x.toFixed(2)), parseFloat(a.y.toFixed(2)))).width) { | |
var o = -r.x / a.width; | |
this.node.anchorX = parseFloat(o.toFixed(2)) | |
} | |
if (0 !== a.height) { | |
var c = -r.y / a.height; | |
this.node.anchorY = parseFloat(c.toFixed(2)) | |
} | |
this.node.setContentSize(a) | |
} | |
}, | |
_doLayoutGridAxisHorizontal: function(t, e) { | |
var i = e.width | |
, n = 1 | |
, s = -t.y * e.height | |
, o = this.paddingBottom; | |
this.verticalDirection === a.TOP_TO_BOTTOM && (n = -1, | |
s = (1 - t.y) * e.height, | |
o = this.paddingTop); | |
var c = function(t, e, i) { | |
return s + n * (e + t.anchorY * t.height * this._getUsedScaleValue(t.scaleY) + o + i * this.spacingY) | |
} | |
.bind(this) | |
, l = 0; | |
if (this.resizeMode === r.CONTAINER) { | |
var h = this._doLayoutHorizontally(i, !0, c, !1); | |
(l = s - h) < 0 && (l *= -1), | |
s = -t.y * l, | |
this.verticalDirection === a.TOP_TO_BOTTOM && (n = -1, | |
s = (1 - t.y) * l) | |
} | |
this._doLayoutHorizontally(i, !0, c, !0), | |
this.resizeMode === r.CONTAINER && this.node.setContentSize(i, l) | |
}, | |
_doLayoutGridAxisVertical: function(t, e) { | |
var i = e.height | |
, n = 1 | |
, s = -t.x * e.width | |
, a = this.paddingLeft; | |
this.horizontalDirection === o.RIGHT_TO_LEFT && (n = -1, | |
s = (1 - t.x) * e.width, | |
a = this.paddingRight); | |
var c = function(t, e, i) { | |
return s + n * (e + t.anchorX * t.width * this._getUsedScaleValue(t.scaleX) + a + i * this.spacingX) | |
} | |
.bind(this) | |
, l = 0; | |
if (this.resizeMode === r.CONTAINER) { | |
var h = this._doLayoutVertically(i, !0, c, !1); | |
(l = s - h) < 0 && (l *= -1), | |
s = -t.x * l, | |
this.horizontalDirection === o.RIGHT_TO_LEFT && (n = -1, | |
s = (1 - t.x) * l) | |
} | |
this._doLayoutVertically(i, !0, c, !0), | |
this.resizeMode === r.CONTAINER && this.node.setContentSize(l, i) | |
}, | |
_doLayoutGrid: function() { | |
var t = this.node.getAnchorPoint() | |
, e = this.node.getContentSize(); | |
this.startAxis === s.HORIZONTAL ? this._doLayoutGridAxisHorizontal(t, e) : this.startAxis === s.VERTICAL && this._doLayoutGridAxisVertical(t, e) | |
}, | |
_getHorizontalBaseWidth: function(t) { | |
var e = 0 | |
, i = 0; | |
if (this.resizeMode === r.CONTAINER) { | |
for (var n = 0; n < t.length; ++n) { | |
var s = t[n]; | |
s.activeInHierarchy && (i++, | |
e += s.width * this._getUsedScaleValue(s.scaleX)) | |
} | |
e += (i - 1) * this.spacingX + this.paddingLeft + this.paddingRight | |
} else | |
e = this.node.getContentSize().width; | |
return e | |
}, | |
_doLayout: function() { | |
if (this.type === n.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 === n.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 === n.NONE ? this.resizeMode === r.CONTAINER && this._doLayoutBasic() : this.type === n.GRID && this._doLayoutGrid() | |
}, | |
_getUsedScaleValue: function(t) { | |
return this.affectedByScale ? Math.abs(t) : 1 | |
}, | |
updateLayout: function() { | |
this._layoutDirty && this.node.children.length > 0 && this.node.children.find((function(t) { | |
return t.activeInHierarchy | |
} | |
)) && (this._doLayout(), | |
this._layoutDirty = !1) | |
} | |
}); | |
cc.Layout = e.exports = c | |
} | |
), { | |
"../CCNode": 26, | |
"./CCComponent": 100 | |
}], | |
106: [(function(t, e) { | |
"use strict"; | |
var i = a(t("../../renderer/gfx")) | |
, n = a(t("../value-types/mat4")) | |
, r = a(t("../value-types/vec2")) | |
, s = a(t("../assets/material/material-variant")); | |
function a(t) { | |
return t && t.__esModule ? t : { | |
default: t | |
} | |
} | |
var o = t("../utils/misc") | |
, c = t("./CCRenderComponent") | |
, l = t("../renderer/render-flow") | |
, h = t("../graphics/graphics") | |
, u = new r.default | |
, f = new n.default | |
, d = []; | |
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 | |
} | |
var p = cc.Enum({ | |
RECT: 0, | |
ELLIPSE: 1, | |
IMAGE_STENCIL: 2 | |
}) | |
, v = cc.Class({ | |
name: "cc.Mask", | |
extends: c, | |
editor: !1, | |
ctor: function() { | |
this._graphics = null, | |
this._enableMaterial = null, | |
this._exitMaterial = null, | |
this._clearMaterial = null | |
}, | |
properties: { | |
_spriteFrame: { | |
default: null, | |
type: cc.SpriteFrame | |
}, | |
_type: p.RECT, | |
type: { | |
get: function() { | |
return this._type | |
}, | |
set: function(t) { | |
this._type !== t && this._resetAssembler(), | |
this._type = t, | |
this._type !== p.IMAGE_STENCIL && (this.spriteFrame = null, | |
this.alphaThreshold = 0, | |
this._updateGraphics()), | |
this._activateMaterial() | |
}, | |
type: p, | |
tooltip: !1 | |
}, | |
spriteFrame: { | |
type: cc.SpriteFrame, | |
tooltip: !1, | |
get: function() { | |
return this._spriteFrame | |
}, | |
set: function(t) { | |
var e = this._spriteFrame; | |
e !== t && (e && e.off("load", this.setVertsDirty, this), | |
this._spriteFrame = t, | |
this.setVertsDirty(), | |
this._updateMaterial()) | |
} | |
}, | |
alphaThreshold: { | |
default: .1, | |
type: cc.Float, | |
range: [0, 1, .1], | |
slide: !0, | |
tooltip: !1, | |
notify: function() { | |
cc.game.renderType !== cc.game.RENDER_TYPE_CANVAS && this._updateMaterial() | |
} | |
}, | |
inverted: { | |
default: !1, | |
type: cc.Boolean, | |
tooltip: !1, | |
notify: function() { | |
cc.game.renderType, | |
cc.game.RENDER_TYPE_CANVAS | |
} | |
}, | |
_segments: 64, | |
segements: { | |
get: function() { | |
return this._segments | |
}, | |
set: function(t) { | |
this._segments = o.clampf(t, 3, 1e4), | |
this._updateGraphics() | |
}, | |
type: cc.Integer, | |
tooltip: !1 | |
}, | |
_resizeToTarget: { | |
animatable: !1, | |
set: function(t) { | |
t && this._resizeNodeToTargetNode() | |
} | |
} | |
}, | |
statics: { | |
Type: p | |
}, | |
onRestore: function() { | |
this._activateMaterial() | |
}, | |
onEnable: function() { | |
this._super(), | |
this._type !== p.IMAGE_STENCIL ? this._updateGraphics() : this._spriteFrame && this._spriteFrame.once("load", this.setVertsDirty, this), | |
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) | |
}, | |
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 &= ~l.FLAG_POST_RENDER | |
}, | |
onDestroy: function() { | |
this._super(), | |
this._removeGraphics(), | |
this._spriteFrame && this._spriteFrame.off("load", this.setVertsDirty, this) | |
}, | |
_resizeNodeToTargetNode: !1, | |
_validateRender: function() { | |
if (this._type === p.IMAGE_STENCIL) { | |
var t = this._spriteFrame; | |
t && t.textureLoaded() || this.disableRender() | |
} | |
}, | |
_activateMaterial: function() { | |
this._createGraphics(); | |
var t = this._materials[0]; | |
(t = t ? s.default.create(t, this) : s.default.createWithBuiltin("2d-sprite", this)).define("USE_ALPHA_TEST", !0), | |
this._type === p.IMAGE_STENCIL ? (t.define("CC_USE_MODEL", !1), | |
t.define("USE_TEXTURE", !0)) : (t.define("CC_USE_MODEL", !0), | |
t.define("USE_TEXTURE", !1)), | |
this._enableMaterial || (this._enableMaterial = s.default.createWithBuiltin("2d-sprite", this)), | |
this._exitMaterial || (this._exitMaterial = s.default.createWithBuiltin("2d-sprite", this), | |
this._exitMaterial.setStencilEnabled(i.default.STENCIL_DISABLE)), | |
this._clearMaterial || (this._clearMaterial = s.default.createWithBuiltin("clear-stencil", this)), | |
this.setMaterial(0, t), | |
this._graphics._materials[0] = t, | |
this._updateMaterial() | |
}, | |
_updateMaterial: function() { | |
var t = this._materials[0]; | |
if (t) { | |
if (this._type === p.IMAGE_STENCIL && this.spriteFrame) { | |
var e = this.spriteFrame.getTexture(); | |
t.setProperty("texture", e) | |
} | |
t.setProperty("alphaThreshold", this.alphaThreshold) | |
} | |
}, | |
_createGraphics: function() { | |
this._graphics || (this._graphics = new h, | |
cc.Assembler.init(this._graphics), | |
this._graphics.node = this.node, | |
this._graphics.lineWidth = 0, | |
this._graphics.strokeColor = cc.color(0, 0, 0, 0)) | |
}, | |
_updateGraphics: function() { | |
if (this.enabledInHierarchy) { | |
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 === p.RECT) | |
e.rect(r, s, i, n); | |
else if (this._type === p.ELLIPSE) { | |
for (var a = _(cc.v2(r + i / 2, s + n / 2), { | |
x: i / 2, | |
y: n / 2 | |
}, this._segments), o = 0; o < a.length; ++o) { | |
var c = a[o]; | |
0 === o ? 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(), | |
this.setVertsDirty() | |
} | |
}, | |
_removeGraphics: function() { | |
this._graphics && (this._graphics.destroy(), | |
this._graphics._destroyImmediate(), | |
this._graphics = null) | |
}, | |
_hitTest: function(t) { | |
var e = this.node | |
, i = e.getContentSize() | |
, s = i.width | |
, a = i.height | |
, o = u; | |
if (e._updateWorldMatrix(), | |
!n.default.invert(f, e._worldMatrix)) | |
return !1; | |
r.default.transformMat4(o, t, f), | |
o.x += e._anchorPoint.x * s, | |
o.y += e._anchorPoint.y * a; | |
var c = !1; | |
if (this.type === p.RECT || this.type === p.IMAGE_STENCIL) | |
c = o.x >= 0 && o.y >= 0 && o.x <= s && o.y <= a; | |
else if (this.type === p.ELLIPSE) { | |
var l = s / 2 | |
, h = a / 2 | |
, d = o.x - .5 * s | |
, _ = o.y - .5 * a; | |
c = d * d / (l * l) + _ * _ / (h * h) < 1 | |
} | |
return this.inverted && (c = !c), | |
c | |
}, | |
markForRender: function(t) { | |
var e = l.FLAG_RENDER | l.FLAG_UPDATE_RENDER_DATA | l.FLAG_POST_RENDER; | |
t ? (this.node._renderFlag |= e, | |
this.markForValidate()) : t || (this.node._renderFlag &= ~e) | |
}, | |
disableRender: function() { | |
this.node._renderFlag &= ~(l.FLAG_RENDER | l.FLAG_UPDATE_RENDER_DATA | l.FLAG_POST_RENDER) | |
} | |
}); | |
cc.Mask = e.exports = v | |
} | |
), { | |
"../../renderer/gfx": 282, | |
"../assets/material/material-variant": 83, | |
"../graphics/graphics": 151, | |
"../renderer/render-flow": 194, | |
"../utils/misc": 236, | |
"../value-types/mat4": 253, | |
"../value-types/vec2": 260, | |
"./CCRenderComponent": 109 | |
}], | |
107: [(function(t, e) { | |
"use strict"; | |
var i = t("../utils/misc") | |
, n = t("./CCComponent") | |
, r = cc.Enum({ | |
HORIZONTAL: 0, | |
VERTICAL: 1, | |
FILLED: 2 | |
}) | |
, s = cc.Class({ | |
name: "cc.ProgressBar", | |
extends: n, | |
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 = r.FILLED); | |
var s = t.getContentSize(); | |
if (this.mode === r.HORIZONTAL ? this.totalLength = s.width : this.mode === r.VERTICAL ? this.totalLength = s.height : this.totalLength = this.barSprite.fillRange, | |
t.parent === this.node) { | |
var a = -e.width * i.x; | |
t.setPosition(cc.v2(a, 0)) | |
} | |
} | |
}, | |
_updateBarStatus: function() { | |
if (this.barSprite) { | |
var t = this.barSprite.node; | |
if (!t) | |
return; | |
var e, n, s, a = t.getAnchorPoint(), o = t.getContentSize(), c = t.getPosition(), l = cc.v2(0, .5), h = i.clamp01(this.progress), u = this.totalLength * h; | |
switch (this.mode) { | |
case r.HORIZONTAL: | |
this.reverse && (l = cc.v2(1, .5)), | |
e = cc.size(u, o.height), | |
n = this.totalLength, | |
s = o.height; | |
break; | |
case r.VERTICAL: | |
l = this.reverse ? cc.v2(.5, 1) : cc.v2(.5, 0), | |
e = cc.size(o.width, u), | |
n = o.width, | |
s = this.totalLength | |
} | |
if (this.mode === r.FILLED) | |
this.barSprite.type !== cc.Sprite.Type.FILLED || (this.reverse && (u *= -1), | |
this.barSprite.fillRange = u); | |
else if (this.barSprite.type !== cc.Sprite.Type.FILLED) { | |
var f = l.x - a.x | |
, d = l.y - a.y | |
, _ = cc.v2(n * f, s * d); | |
t.setPosition(c.x + _.x, c.y + _.y), | |
t.setAnchorPoint(l), | |
t.setContentSize(e) | |
} | |
} | |
}, | |
properties: { | |
barSprite: { | |
default: null, | |
type: cc.Sprite, | |
tooltip: !1, | |
notify: function() { | |
this._initBarSprite() | |
}, | |
animatable: !1 | |
}, | |
mode: { | |
default: r.HORIZONTAL, | |
type: r, | |
tooltip: !1, | |
notify: function() { | |
if (this.barSprite) { | |
var t = this.barSprite.node; | |
if (!t) | |
return; | |
var e = t.getContentSize(); | |
this.mode === r.HORIZONTAL ? this.totalLength = e.width : this.mode === r.VERTICAL ? this.totalLength = e.height : this.mode === r.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 === r.FILLED && (t = i.clamp01(t)), | |
this._N$totalLength = t, | |
this._updateBarStatus() | |
} | |
}, | |
progress: { | |
default: 1, | |
type: cc.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: r | |
} | |
}); | |
cc.ProgressBar = e.exports = s | |
} | |
), { | |
"../utils/misc": 236, | |
"./CCComponent": 100 | |
}], | |
108: [(function(t, e) { | |
"use strict"; | |
var i = cc.Class({ | |
name: "cc.PropagateTouchEvents", | |
extends: t("./CCComponent"), | |
editor: { | |
menu: "i18n:MAIN_MENU.component.ui/Propagate Touch Events", | |
inspector: "unpack://engine/inspectors/comps/propagate-touch-events.js" | |
}, | |
onEnable: function() { | |
this._swallowTouches = this.node.swallowTouches, | |
this.node.swallowTouches = !1 | |
}, | |
onDisable: function() { | |
this.node.swallowTouches = this._swallowTouches | |
} | |
}); | |
cc.PropagateTouchEvents = e.exports = i | |
} | |
), { | |
"./CCComponent": 100 | |
}], | |
109: [(function(t, e) { | |
"use strict"; | |
var i = s(t("../renderer/assembler")) | |
, n = s(t("../assets/material/material-variant")) | |
, r = t("../value-types"); | |
function s(t) { | |
return t && t.__esModule ? t : { | |
default: t | |
} | |
} | |
var a = t("./CCComponent") | |
, o = t("../renderer/render-flow") | |
, c = t("../assets/material/CCMaterial") | |
, l = new r.Color | |
, h = cc.Class({ | |
name: "RenderComponent", | |
extends: a, | |
editor: !1, | |
properties: { | |
_materials: { | |
default: [], | |
type: c | |
}, | |
materials: { | |
get: function() { | |
return this._materials | |
}, | |
set: function(t) { | |
this._materials = t, | |
this._activateMaterial() | |
}, | |
type: [c], | |
displayName: "Materials", | |
animatable: !1 | |
} | |
}, | |
ctor: function() { | |
this._vertsDirty = !0, | |
this._assembler = null | |
}, | |
_resetAssembler: function() { | |
i.default.init(this), | |
this._updateColor(), | |
this.setVertsDirty() | |
}, | |
__preload: function() { | |
this._resetAssembler(), | |
this._activateMaterial() | |
}, | |
onEnable: function() { | |
this.node._renderComponent && (this.node._renderComponent.enabled = !1), | |
this.node._renderComponent = this, | |
this.node._renderFlag |= o.FLAG_OPACITY_COLOR, | |
this.setVertsDirty() | |
}, | |
onDisable: function() { | |
this.node._renderComponent = null, | |
this.disableRender() | |
}, | |
onDestroy: function() { | |
for (var t = this._materials, e = 0; e < t.length; e++) | |
cc.pool.material.put(t[e]); | |
t.length = 0, | |
cc.pool.assembler.put(this._assembler), | |
this.disableRender() | |
}, | |
setVertsDirty: function() { | |
this._vertsDirty = !0, | |
this.markForRender(!0) | |
}, | |
_on3DNodeChanged: function() { | |
this._resetAssembler() | |
}, | |
_validateRender: function() {}, | |
markForValidate: function() { | |
cc.RenderFlow.registerValidate(this) | |
}, | |
markForRender: function(t) { | |
var e = o.FLAG_RENDER | o.FLAG_UPDATE_RENDER_DATA; | |
t ? (this.node._renderFlag |= e, | |
this.markForValidate()) : this.node._renderFlag &= ~e | |
}, | |
disableRender: function() { | |
this.node._renderFlag &= ~(o.FLAG_RENDER | o.FLAG_UPDATE_RENDER_DATA) | |
}, | |
getMaterial: function(t) { | |
if (t < 0 || t >= this._materials.length) | |
return null; | |
var e = this._materials[t]; | |
if (!e) | |
return null; | |
var i = n.default.create(e, this); | |
return i !== e && this.setMaterial(t, i), | |
i | |
}, | |
getMaterials: function() { | |
for (var t = this._materials, e = 0; e < t.length; e++) | |
t[e] = n.default.create(t[e], this); | |
return t | |
}, | |
setMaterial: function(t, e) { | |
return e !== this._materials[t] && (e = n.default.create(e, this), | |
this._materials[t] = e), | |
this._updateMaterial(), | |
this.markForRender(!0), | |
e | |
}, | |
_getDefaultMaterial: function() { | |
return c.getBuiltinMaterial("2d-sprite") | |
}, | |
_activateMaterial: function() { | |
var t = this._materials; | |
if (!t[0]) { | |
var e = this._getDefaultMaterial(); | |
t[0] = e | |
} | |
for (var i = 0; i < t.length; i++) | |
t[i] = n.default.create(t[i], this); | |
this._updateMaterial() | |
}, | |
_updateMaterial: function() {}, | |
_updateColor: function() { | |
if (this._assembler.updateColor) { | |
var t = this.srcBlendFactor === cc.macro.BlendFactor.ONE; | |
t && r.Color.premultiplyAlpha(l, this.node._color); | |
var e = t ? l._val : null; | |
this._assembler.updateColor(this, e) | |
} | |
}, | |
_checkBacth: function(t, e) { | |
var i = this._materials[0]; | |
(i && i.getHash() !== t.material.getHash() || t.cullingMask !== e) && (t._flush(), | |
t.node = i.getDefine("CC_USE_MODEL") ? this.node : t._dummyNode, | |
t.material = i, | |
t.cullingMask = e) | |
} | |
}); | |
cc.RenderComponent = e.exports = h | |
} | |
), { | |
"../assets/material/CCMaterial": 76, | |
"../assets/material/material-variant": 83, | |
"../renderer/assembler": 190, | |
"../renderer/render-flow": 194, | |
"../value-types": 251, | |
"./CCComponent": 100 | |
}], | |
110: [(function(t, e) { | |
"use strict"; | |
var i = t("../platform/js") | |
, n = t("../platform/CCMacro") | |
, r = t("../utils/text-utils") | |
, s = new (t("../utils/html-text-parser")) | |
, a = n.TextAlignment | |
, o = n.VerticalTextAlignment | |
, c = cc.Label.CacheMode | |
, l = new i.Pool(function(t) { | |
if (!cc.isValid(t)) | |
return !1; | |
var e = t.getComponent(cc.LabelOutline); | |
return e && (e.width = 0), | |
!0 | |
} | |
,20); | |
l.get = function(t, e) { | |
var i = this._get(); | |
i || ((i = new cc.PrivateNode("RICHTEXT_CHILD"))._objFlags |= cc.Object.Flags.DontSave), | |
i.setPosition(0, 0), | |
i.setAnchorPoint(.5, .5), | |
i.skewX = 0; | |
var n = i.getComponent(cc.Label); | |
return n || (n = i.addComponent(cc.Label)), | |
n.string = "", | |
n.horizontalAlign = a.LEFT, | |
n.verticalAlign = o.CENTER, | |
n._forceUseCanvas = !0, | |
n.customOffsetX = e.customOffsetX, | |
n.customOffsetY = e.customOffsetY, | |
n.actualLineHeight = e.actualLineHeight, | |
i | |
} | |
; | |
var h = cc.Class({ | |
name: "cc.RichText", | |
extends: cc.Component, | |
ctor: function() { | |
this._textArray = null, | |
this._labelSegments = [], | |
this._labelSegmentsCache = [], | |
this._linesWidth = [], | |
this._customOffsetX = 0, | |
this._customOffsetY = 0, | |
this._actualLineHeight = void 0, | |
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: a.LEFT, | |
type: a, | |
tooltip: !1, | |
animatable: !1, | |
notify: function(t) { | |
this.horizontalAlign !== t && (this._layoutDirty = !0, | |
this._updateRichTextStatus()) | |
} | |
}, | |
fontSize: { | |
default: 40, | |
tooltip: !1, | |
notify: function(t) { | |
this.fontSize !== t && (this._layoutDirty = !0, | |
this._updateRichTextStatus()) | |
} | |
}, | |
_fontFamily: "Arial", | |
fontFamily: { | |
tooltip: !1, | |
get: function() { | |
return this._fontFamily | |
}, | |
set: function(t) { | |
this._fontFamily !== t && (this._fontFamily = t, | |
this._layoutDirty = !0, | |
this._updateRichTextStatus()) | |
}, | |
animatable: !1 | |
}, | |
font: { | |
default: null, | |
type: cc.TTFFont, | |
tooltip: !1, | |
notify: function(t) { | |
this.font !== t && (this._layoutDirty = !0, | |
this.font ? (this.useSystemFont = !1, | |
this._onTTFLoaded()) : this.useSystemFont = !0, | |
this._updateRichTextStatus()) | |
} | |
}, | |
_isSystemFontUsed: !0, | |
useSystemFont: { | |
get: function() { | |
return this._isSystemFontUsed | |
}, | |
set: function(t) { | |
this._isSystemFontUsed !== t && (this._isSystemFontUsed = t, | |
this._layoutDirty = !0, | |
this._updateRichTextStatus()) | |
}, | |
animatable: !1, | |
tooltip: !1 | |
}, | |
cacheMode: { | |
default: c.NONE, | |
type: c, | |
tooltip: !1, | |
notify: function(t) { | |
this.cacheMode !== t && this._updateRichTextStatus() | |
}, | |
animatable: !1 | |
}, | |
maxWidth: { | |
default: 0, | |
tooltip: !1, | |
notify: function(t) { | |
this.maxWidth !== t && (this._layoutDirty = !0, | |
this._updateRichTextStatus()) | |
} | |
}, | |
lineHeight: { | |
default: 40, | |
tooltip: !1, | |
notify: function(t) { | |
this.lineHeight !== t && (this._layoutDirty = !0, | |
this._updateRichTextStatus()) | |
} | |
}, | |
imageAtlas: { | |
default: null, | |
type: cc.SpriteAtlas, | |
tooltip: !1, | |
notify: function(t) { | |
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()) | |
} | |
}, | |
customOffsetX: { | |
get: function() { | |
return this._customOffsetX | |
}, | |
set: function(t) { | |
this._customOffsetX !== t && (this._customOffsetX = t, | |
this._layoutDirty = !0, | |
this._updateRichTextStatus()) | |
} | |
}, | |
customOffsetY: { | |
get: function() { | |
return this._customOffsetY | |
}, | |
set: function(t) { | |
this._customOffsetY !== t && (this._customOffsetY = t, | |
this._layoutDirty = !0, | |
this._updateRichTextStatus()) | |
} | |
}, | |
actualLineHeight: { | |
get: function() { | |
return this._actualLineHeight || this.lineHeight | |
}, | |
set: function(t) { | |
this._actualLineHeight !== t && (this._actualLineHeight = t, | |
this._updateRichTextStatus()) | |
} | |
} | |
}, | |
statics: { | |
HorizontalAlign: a, | |
VerticalAlign: o | |
}, | |
onEnable: function() { | |
this.handleTouchEvent && this._addEventListeners(), | |
this._onTTFLoaded(), | |
this._activateChildren(!0) | |
}, | |
onDisable: function() { | |
this.handleTouchEvent && this._removeEventListeners(), | |
this._activateChildren(!1) | |
}, | |
_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, null, !0) | |
} | |
.bind(this)) | |
}, | |
_createFontLabel: function(t) { | |
return l.get(t, this) | |
}, | |
_onTTFLoaded: function() { | |
if (this.font instanceof cc.TTFFont) | |
if (this.font._nativeAsset) | |
this._layoutDirty = !0, | |
this._updateRichTextStatus(); | |
else { | |
var t = this; | |
cc.assetManager.postLoadNative(this.font, (function() { | |
t._layoutDirty = !0, | |
t._updateRichTextStatus() | |
} | |
)) | |
} | |
else | |
this._layoutDirty = !0, | |
this._updateRichTextStatus() | |
}, | |
_measureText: function(t, e) { | |
var i = this | |
, n = function(e) { | |
var n; | |
return 0 === i._labelSegmentsCache.length ? (n = i._createFontLabel(e), | |
i._labelSegmentsCache.push(n)) : n = i._labelSegmentsCache[0], | |
n._styleIndex = t, | |
i._applyTextAttribute(n, e, !0), | |
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 | |
, a = r._clickParam; | |
s && e._containsTouchLocation(r, t.touch.getLocation()) && (i.forEach((function(e) { | |
e.enabledInHierarchy && e[s] && e[s](t, a) | |
} | |
)), | |
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]; | |
"RICHTEXT_CHILD" !== i.name && "RICHTEXT_Image_CHILD" !== i.name || (i.parent === this.node ? i.parent = null : t.splice(e, 1), | |
"RICHTEXT_CHILD" === i.name && l.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; | |
return (i = 0 === this._labelSegmentsCache.length ? this._createFontLabel(t) : this._labelSegmentsCache.pop())._styleIndex = e, | |
i._lineCount = this._lineCount, | |
i.active = this.node.active, | |
i.setAnchorPoint(0, 0), | |
this._applyTextAttribute(i, t, !1), | |
this.node.addChild(i), | |
this._labelSegments.push(i), | |
i | |
}, | |
_updateRichTextWithMaxWidth: function(t, e, i) { | |
var n = e; | |
if (this._lineOffsetX > 0 && n + this._lineOffsetX > this.maxWidth) | |
for (var s = 0; this._lineOffsetX <= this.maxWidth; ) { | |
var a = this._getFirstWordLen(t, s, t.length) | |
, o = t.substr(s, a) | |
, c = this._measureText(i, o); | |
if (!(this._lineOffsetX + c <= this.maxWidth)) { | |
if (s > 0) { | |
var l = t.substr(0, s); | |
this._addLabelSegment(l, i), | |
t = t.substr(s, t.length), | |
n = this._measureText(i, t) | |
} | |
this._updateLineInfo(); | |
break | |
} | |
this._lineOffsetX += c, | |
s += a | |
} | |
if (n > this.maxWidth) | |
for (var h = r.fragmentText(t, n, this.maxWidth, this._measureText(i)), u = 0; u < h.length; ++u) { | |
var f = h[u] | |
, d = this._addLabelSegment(f, i).getContentSize(); | |
this._lineOffsetX += d.width, | |
h.length > 1 && u < h.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; | |
var r = i.style | |
, s = n.style; | |
if (r) { | |
if (s) { | |
if (!r.outline != !s.outline) | |
return !0; | |
if (r.size !== s.size || !r.italic != !s.italic || r.isImage !== s.isImage) | |
return !0; | |
if (r.src !== s.src || r.imageAlign !== s.imageAlign || r.imageHeight !== s.imageHeight || r.imageWidth !== s.imageWidth || r.imageOffset !== s.imageOffset) | |
return !0 | |
} else if (r.size || r.italic || r.isImage || r.outline) | |
return !0 | |
} else if (s && (s.size || s.italic || s.isImage || s.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"); | |
n._objFlags |= cc.Object.Flags.DontSave; | |
var r = n.addComponent(cc.Sprite); | |
switch (t.style.imageAlign) { | |
case "top": | |
n.setAnchorPoint(0, 1); | |
break; | |
case "center": | |
n.setAnchorPoint(0, .5); | |
break; | |
default: | |
n.setAnchorPoint(0, 0) | |
} | |
t.style.imageOffset && (n._imageOffset = t.style.imageOffset), | |
r.type = cc.Sprite.Type.SLICED, | |
r.sizeMode = cc.Sprite.SizeMode.CUSTOM, | |
this.node.addChild(n), | |
this._labelSegments.push(n); | |
var s = i.getRect() | |
, a = 1 | |
, o = s.width | |
, c = s.height | |
, l = t.style.imageWidth | |
, h = t.style.imageHeight; | |
h > 0 ? (o *= a = h / c, | |
c *= a) : (o *= a = this.lineHeight / c, | |
c *= a), | |
l > 0 && (o = l), | |
this.maxWidth > 0 ? (this._lineOffsetX + o > this.maxWidth && this._updateLineInfo(), | |
this._lineOffsetX += o) : (this._lineOffsetX += o, | |
this._lineOffsetX > this._labelWidth && (this._labelWidth = this._lineOffsetX)), | |
r.spriteFrame = i, | |
n.setContentSize(o, c), | |
n._lineCount = this._lineCount, | |
t.style.event ? (t.style.event.click && (n._clickHandler = t.style.event.click), | |
t.style.event.param ? n._clickParam = t.style.event.param : n._clickParam = "") : n._clickHandler = null | |
} | |
}, | |
_updateRichText: function() { | |
if (this.enabledInHierarchy) { | |
var t = s.parse(this.string); | |
if (!this._needsUpdateTextLayout(t)) | |
return this._textArray = t, | |
this._updateLabelSegmentTextAttributes(), | |
void this._updateRichTextPosition(); | |
this._textArray = t, | |
this._resetState(); | |
for (var e, i = !1, n = 0; n < this._textArray.length; ++n) { | |
var a = this._textArray[n] | |
, o = a.text; | |
if ("" === o) { | |
if (a.style && a.style.newline) { | |
this._updateLineInfo(); | |
continue | |
} | |
if (a.style && a.style.isImage && this.imageAtlas) { | |
this._addRichTextImageElement(a); | |
continue | |
} | |
} | |
for (var c = o.split("\n"), l = 0; l < c.length; ++l) { | |
var h = c[l]; | |
if ("" !== h) | |
if (i = !1, | |
this.maxWidth > 0) { | |
var u = this._measureText(n, h); | |
this._updateRichTextWithMaxWidth(h, u, n), | |
c.length > 1 && l < c.length - 1 && this._updateLineInfo() | |
} else | |
e = this._addLabelSegment(h, n).getContentSize(), | |
this._lineOffsetX += e.width, | |
this._lineOffsetX > this._labelWidth && (this._labelWidth = this._lineOffsetX), | |
c.length > 1 && l < c.length - 1 && this._updateLineInfo(); | |
else { | |
if (this._isLastComponentCR(o) && l === c.length - 1) | |
continue; | |
this._updateLineInfo(), | |
i = !0 | |
} | |
} | |
} | |
i || this._linesWidth.push(this._lineOffsetX), | |
this.maxWidth > 0 && (this._labelWidth = this.maxWidth), | |
this._labelHeight = (this._lineCount + r.BASELINE_RATIO) * this.lineHeight, | |
this.node.setContentSize(this._labelWidth, this._labelHeight), | |
this._updateRichTextPosition(), | |
this._layoutDirty = !1 | |
} | |
}, | |
_getFirstWordLen: function(t, e, i) { | |
var n = t.charAt(e); | |
if (r.isUnicodeCJK(n) || r.isUnicodeSpace(n)) | |
return 1; | |
for (var s = 1, a = e + 1; a < i && (n = t.charAt(a), | |
!r.isUnicodeSpace(n) && !r.isUnicodeCJK(n)); ++a) | |
s++; | |
return s | |
}, | |
_updateRichTextPosition: function() { | |
for (var t = 0, e = 1, i = this._lineCount, n = 0; n < this._labelSegments.length; ++n) { | |
var s = this._labelSegments[n] | |
, o = s._lineCount; | |
o > e && (t = 0, | |
e = o); | |
var l = 0; | |
switch (this.horizontalAlign) { | |
case a.LEFT: | |
l = -this._labelWidth / 2; | |
break; | |
case a.CENTER: | |
l = -this._linesWidth[o - 1] / 2; | |
break; | |
case a.RIGHT: | |
l = this._labelWidth / 2 - this._linesWidth[o - 1] | |
} | |
s.x = t + l; | |
var h = s.getContentSize(); | |
if (s.y = this.lineHeight * (i - o) - this._labelHeight / 2, | |
o === e && (t += h.width), | |
s.getComponent(cc.Sprite)) { | |
var u = this.lineHeight | |
, f = this.lineHeight * (1 + r.BASELINE_RATIO); | |
switch (s.anchorY) { | |
case 1: | |
s.y += u + (f - u) / 2; | |
break; | |
case .5: | |
s.y += f / 2; | |
break; | |
default: | |
s.y += (f - u) / 2 | |
} | |
if (s._imageOffset) { | |
var d = s._imageOffset.split(","); | |
if (1 === d.length && d[0]) { | |
var _ = parseFloat(d[0]); | |
Number.isInteger(_) && (s.y += _) | |
} else if (2 === d.length) { | |
var p = parseFloat(d[0]) | |
, v = parseFloat(d[1]); | |
Number.isInteger(p) && (s.x += p), | |
Number.isInteger(v) && (s.y += v) | |
} | |
} | |
} else | |
s.anchorY = 0; | |
var g = s.getComponent(cc.LabelOutline); | |
if (g && g.width && (s.y = s.y - g.width), | |
s.getComponent(cc.Label) && this.cacheMode === c.CHAR) { | |
var m = g ? g.width : 0; | |
s.y = ((i - 1) / 2 - (o - 1)) * (this.lineHeight + m / 2), | |
s.anchorY = .5 | |
} | |
} | |
}, | |
_convertLiteralColorValue: function(t) { | |
var e = t.toUpperCase(); | |
return cc.Color[e] ? cc.Color[e] : cc.color().fromHEX(t) | |
}, | |
_applyTextAttribute: function(t, e, i) { | |
var n = t.getComponent(cc.Label); | |
if (n) { | |
var r = t._styleIndex | |
, s = null; | |
if (this._textArray[r] && (s = this._textArray[r].style), | |
s && s.color ? t.color = this._convertLiteralColorValue(s.color) : t.color = this.node.color, | |
n.cacheMode = this.cacheMode, | |
this.font instanceof cc.Font && !this._isSystemFontUsed ? n.font = this.font : n.fontFamily = this.fontFamily, | |
n.useSystemFont = this._isSystemFontUsed, | |
n.lineHeight = this.lineHeight, | |
n.enableBold = s && s.bold, | |
n.enableItalics = s && s.italic, | |
s && s.italic && (t.skewX = 12), | |
n.enableUnderline = s && s.underline, | |
s && s.outline) { | |
var a = t.getComponent(cc.LabelOutline); | |
a || (a = t.addComponent(cc.LabelOutline)), | |
a.color = this._convertLiteralColorValue(s.outline.color), | |
a.width = s.outline.width | |
} | |
s && s.size ? n.fontSize = s.size : n.fontSize = this.fontSize, | |
null !== e && ("string" != typeof e && (e = "" + e), | |
n.string = e), | |
i && n._forceUpdateRenderData(), | |
s && s.event ? (s.event.click && (t._clickHandler = s.event.click), | |
s.event.param ? t._clickParam = s.event.param : t._clickParam = "") : t._clickHandler = null | |
} | |
}, | |
onDestroy: function() { | |
for (var t = 0; t < this._labelSegments.length; ++t) | |
this._labelSegments[t].removeFromParent(), | |
l.put(this._labelSegments[t]) | |
} | |
}); | |
cc.RichText = e.exports = h | |
} | |
), { | |
"../platform/CCMacro": 167, | |
"../platform/js": 183, | |
"../utils/html-text-parser": 234, | |
"../utils/text-utils": 243 | |
}], | |
111: [(function(t, e) { | |
"use strict"; | |
var i = t("./CCWidget") | |
, n = t("../base-ui/CCWidgetManager") | |
, r = cc.Class({ | |
name: "cc.SafeArea", | |
extends: t("./CCComponent"), | |
editor: !1, | |
onEnable: function() { | |
this.updateArea(), | |
cc.view.on("canvas-resize", this.updateArea, this) | |
}, | |
onDisable: function() { | |
cc.view.off("canvas-resize", this.updateArea, this) | |
}, | |
updateArea: function() { | |
var t = this.node.getComponent(i); | |
if (t) { | |
t.updateAlignment(); | |
var e = this.node.position | |
, r = this.node.getAnchorPoint(); | |
t.isAlignTop = t.isAlignBottom = t.isAlignLeft = t.isAlignRight = !0; | |
var s = cc.winSize.width | |
, a = cc.winSize.height | |
, o = cc.sys.getSafeAreaRect(); | |
t.top = a - o.y - o.height, | |
t.bottom = o.y, | |
t.left = o.x, | |
t.right = s - o.x - o.width, | |
t.updateAlignment(); | |
var c = this.node.position | |
, l = r.x - (c.x - e.x) / this.node.width | |
, h = r.y - (c.y - e.y) / this.node.height; | |
this.node.setAnchorPoint(l, h), | |
n.add(t) | |
} | |
} | |
}); | |
cc.SafeArea = e.exports = r | |
} | |
), { | |
"../base-ui/CCWidgetManager": 85, | |
"./CCComponent": 100, | |
"./CCWidget": 120 | |
}], | |
112: [(function(t, e) { | |
"use strict"; | |
var i = t("../utils/misc") | |
, n = (t("./CCComponent"), | |
cc.Enum({ | |
HORIZONTAL: 0, | |
VERTICAL: 1 | |
})) | |
, r = 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: n.HORIZONTAL, | |
type: n, | |
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: n | |
}, | |
setTargetScrollView: function(t) { | |
this._scrollView = t | |
}, | |
_convertToScrollViewSpace: function(t) { | |
var e = this._scrollView.node | |
, i = t.convertToWorldSpaceAR(cc.v2(-t.anchorX * t.width, -t.anchorY * t.height)) | |
, n = e.convertToNodeSpaceAR(i); | |
return n.x += e.anchorX * e.width, | |
n.y += e.anchorY * e.height, | |
n | |
}, | |
_setOpacity: function(t) { | |
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() | |
, r = this._scrollView.node.getContentSize() | |
, s = this.node.getContentSize(); | |
if (this._conditionalDisableScrollBar(i, r)) | |
return; | |
this.enableAutoHide && (this._autoHideRemainingTime = this.autoHideTime, | |
this._setOpacity(this._opacity)); | |
var a = 0 | |
, o = 0 | |
, c = 0 | |
, l = 0 | |
, h = 0; | |
this.direction === n.HORIZONTAL ? (a = i.width, | |
o = r.width, | |
h = s.width, | |
c = t.x, | |
l = -this._convertToScrollViewSpace(e).x) : this.direction === n.VERTICAL && (a = i.height, | |
o = r.height, | |
h = s.height, | |
c = t.y, | |
l = -this._convertToScrollViewSpace(e).y); | |
var u = this._calculateLength(a, o, h, c) | |
, f = this._calculatePosition(a, o, h, l, c, u); | |
this._updateLength(u), | |
this._updateHanlderPosition(f) | |
} | |
} | |
}, | |
_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() | |
, r = this.handle.node.parent | |
, s = this.node.convertToWorldSpaceAR(cc.v2(-t.width * e.x, -t.height * e.y)) | |
, a = r.convertToNodeSpaceAR(s); | |
return this.direction === n.HORIZONTAL ? a = cc.v2(a.x, a.y + (t.height - i.height) / 2) : this.direction === n.VERTICAL && (a = cc.v2(a.x + (t.width - i.width) / 2, a.y)), | |
this.handle.node.setPosition(a), | |
a | |
}, | |
_onTouchBegan: function() { | |
this.enableAutoHide && (this._touching = !0) | |
}, | |
_conditionalDisableScrollBar: function(t, e) { | |
return t.width <= e.width && this.direction === n.HORIZONTAL || t.height <= e.height && this.direction === n.VERTICAL | |
}, | |
_onTouchEnded: function() { | |
if (this.enableAutoHide && (this._touching = !1, | |
!(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; | |
return n && (r += 20 * (n > 0 ? n : -n)), | |
i * (e / r) | |
}, | |
_calculatePosition: function(t, e, r, s, a, o) { | |
var c = t - e; | |
a && (c += Math.abs(a)); | |
var l = 0; | |
c && (l = s / c, | |
l = i.clamp01(l)); | |
var h = (r - o) * l; | |
return this.direction === n.VERTICAL ? cc.v2(0, h) : cc.v2(h, 0) | |
}, | |
_updateLength: function(t) { | |
if (this.handle) { | |
var e = this.handle.node | |
, i = e.getContentSize(); | |
e.setAnchorPoint(cc.v2(0, 0)), | |
this.direction === n.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, | |
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 = r | |
} | |
), { | |
"../utils/misc": 236, | |
"./CCComponent": 100 | |
}], | |
113: [(function(t, e) { | |
"use strict"; | |
var i = t("../CCNode").EventType | |
, n = cc.v2() | |
, r = cc.v2() | |
, s = function() { | |
return (new Date).getMilliseconds() | |
} | |
, a = 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": a.SCROLL_TO_TOP, | |
"scroll-to-bottom": a.SCROLL_TO_BOTTOM, | |
"scroll-to-left": a.SCROLL_TO_LEFT, | |
"scroll-to-right": a.SCROLL_TO_RIGHT, | |
scrolling: a.SCROLLING, | |
"bounce-bottom": a.BOUNCE_BOTTOM, | |
"bounce-left": a.BOUNCE_LEFT, | |
"bounce-right": a.BOUNCE_RIGHT, | |
"bounce-top": a.BOUNCE_TOP, | |
"scroll-ended": a.SCROLL_ENDED, | |
"touch-up": a.TOUCH_UP, | |
"scroll-ended-with-threshold": a.AUTOSCROLL_ENDED_WITH_THRESHOLD, | |
"scroll-began": a.SCROLL_BEGAN | |
} | |
, c = 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() { | |
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: cc.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() { | |
this.horizontalScrollBar && (this.horizontalScrollBar.setTargetScrollView(this), | |
this._updateScrollBar(0)) | |
}, | |
animatable: !1 | |
}, | |
verticalScrollBar: { | |
default: void 0, | |
type: cc.Scrollbar, | |
tooltip: !1, | |
notify: function() { | |
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: a | |
}, | |
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; | |
return i = i >= 0 ? i : 0, | |
n = n >= 0 ? n : 0, | |
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) { | |
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 = -cc.view._scaleY; | |
this.vertical ? i = cc.v2(0, t.getScrollY() * n) : this.horizontal && (i = cc.v2(t.getScrollY() * n, 0)), | |
this._mouseWheelEventElapsedTime = 0, | |
this._processDeltaMove(i), | |
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)) | |
return this._processInertiaScroll(), | |
this.unschedule(this._checkMouseWheel), | |
this._dispatchEvent("scroll-ended"), | |
void (this._stopMouseWheel = !1); | |
this._mouseWheelEventElapsedTime += t, | |
this._mouseWheelEventElapsedTime > .1 && (this._onScrollBarTouchEnded(), | |
this.unschedule(this._checkMouseWheel), | |
this._dispatchEvent("scroll-ended"), | |
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() | |
, a = this._getContentBottomBoundary() - this._bottomBoundary; | |
a = -a; | |
var o = this._getContentLeftBoundary() - this._leftBoundary; | |
o = -o; | |
var c = cc.v2(0, 0) | |
, l = 0; | |
return i && (l = s.width - r.width, | |
c.x = o - l * e.x), | |
n && (l = s.height - r.height, | |
c.y = a - l * e.y), | |
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, | |
e.height < t.height && (r = e.height - t.height, | |
n.y = i - r), | |
e.width < t.width && (r = e.width - t.width, | |
n.x = s), | |
this._updateScrollBarState(), | |
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; | |
if (this.content && this._handleMoveLogic(i), | |
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) | |
}, | |
_getLocalAxisAlignDelta: function(t) { | |
return this.node.convertToNodeSpaceAR(t.getLocation(), n), | |
this.node.convertToNodeSpaceAR(t.getPreviousLocation(), r), | |
n.sub(r) | |
}, | |
_handleMoveLogic: function(t) { | |
var e = this._getLocalAxisAlignDelta(t); | |
this._processDeltaMove(e) | |
}, | |
_scrollChildren: function(t) { | |
var e, i = t = this._clampDelta(t); | |
this.elastic && (e = this._getHowMuchOutOfBoundary(), | |
i.x *= 0 === e.x ? 1 : .5, | |
i.y *= 0 === e.y ? 1 : .5), | |
this.elastic || (e = this._getHowMuchOutOfBoundary(i), | |
i = i.add(e)); | |
var n = "" | |
, r = ""; | |
this.vertical && (i.y > 0 ? this.content.y - this.content.anchorY * this.content.height + i.y >= this._bottomBoundary && (n = "scroll-to-bottom") : i.y < 0 && this.content.y - this.content.anchorY * this.content.height + this.content.height + i.y <= this._topBoundary && (n = "scroll-to-top")), | |
this.horizontal && (i.x < 0 ? this.content.x - this.content.anchorX * this.content.width + this.content.width + i.x <= this._rightBoundary && (r = "scroll-to-right") : i.x > 0 && this.content.x - this.content.anchorX * this.content.width + i.x >= this._leftBoundary && (r = "scroll-to-left")), | |
this._moveContent(i, !1), | |
(this.horizontal && 0 !== i.x || this.vertical && 0 !== i.y) && (this._scrolling || (this._scrolling = !0, | |
this._dispatchEvent("scroll-began")), | |
this._dispatchEvent("scrolling")), | |
"" !== n && this._dispatchEvent(n), | |
"" !== r && this._dispatchEvent(r) | |
}, | |
_handlePressLogic: function() { | |
this._autoScrolling && this._dispatchEvent("scroll-ended"), | |
this._autoScrolling = !1, | |
this._isBouncing = !1, | |
this._touchMovePreviousTimestamp = s(), | |
this._touchMoveDisplacements.length = 0, | |
this._touchMoveTimeDeltas.length = 0, | |
this._onScrollBarTouchBegan() | |
}, | |
_clampDelta: function(t) { | |
var e = this.content.getContentSize() | |
, i = this._view.getContentSize(); | |
return e.width < i.width && (t.x = 0), | |
e.height < i.height && (t.y = 0), | |
t | |
}, | |
_gatherTouchMove: function(t) { | |
for (t = this._clampDelta(t); this._touchMoveDisplacements.length >= 5; ) | |
this._touchMoveDisplacements.shift(), | |
this._touchMoveTimeDeltas.shift(); | |
this._touchMoveDisplacements.push(t); | |
var e = s(); | |
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); | |
return this._startAutoScroll(t, e, !0), | |
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), | |
!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 = this._getLocalAxisAlignDelta(t); | |
this._gatherTouchMove(e), | |
this._processInertiaScroll(), | |
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) | |
return this._autoScrollCurrentlyOutOfBoundary = !0, | |
this._autoScrollBraking = !0, | |
this._autoScrollBrakingStartPosition = this.getContentPosition(), | |
!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, r = Math.min(1, this._autoScrollAccumulatedTime / this._autoScrollTotalTime); | |
this._autoScrollAttenuate && (n = r, | |
r = (n -= 1) * n * n * n * n + 1); | |
var s = this._autoScrollStartPosition.add(this._autoScrollTargetDelta.mul(r)) | |
, a = Math.abs(r - 1) <= 1e-4; | |
if (Math.abs(r - 1) <= this.getScrollEndedEventTiming() && !this._isScrollEndedWithThresholdEventFired && (this._dispatchEvent("scroll-ended-with-threshold"), | |
this._isScrollEndedWithThresholdEventFired = !0), | |
this.elastic) { | |
var o = s.sub(this._autoScrollBrakingStartPosition); | |
e && (o = o.mul(i)), | |
s = this._autoScrollBrakingStartPosition.add(o) | |
} else { | |
var c = s.sub(this.getContentPosition()) | |
, l = this._getHowMuchOutOfBoundary(c); | |
l.fuzzyEquals(cc.v2(0, 0), 1e-4) || (s = s.add(l), | |
a = !0) | |
} | |
a && (this._autoScrolling = !1); | |
var h = s.sub(this.getContentPosition()); | |
this._moveContent(this._clampDelta(h), a), | |
this._dispatchEvent("scrolling"), | |
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._view.getContentSize() | |
, a = r.width - s.width | |
, o = r.height - s.height | |
, c = this._calculateAttenuatedFactor(a) | |
, l = this._calculateAttenuatedFactor(o); | |
n = cc.v2(n.x * a * (1 - this.brake) * c, n.y * o * l * (1 - this.brake)); | |
var h = t.mag() | |
, u = n.mag() / h; | |
n = n.add(t), | |
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); | |
return e = this._touchMoveDisplacements.reduce((function(t, e) { | |
return t.add(e) | |
} | |
), e), | |
cc.v2(e.x * (1 - this.brake) / t, e.y * (1 - this.brake) / t) | |
}, | |
_flattenVectorByDirection: function(t) { | |
var e = t; | |
return e.x = this.horizontal ? e.x : 0, | |
e.y = this.vertical ? e.y : 0, | |
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); | |
return 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)), | |
t.fuzzyEquals(cc.v2(0, 0), 1e-4) && (this._outOfBoundaryAmount = e, | |
this._outOfBoundaryAmountDirty = !1), | |
this._clampDelta(e) | |
}, | |
_updateScrollBarState: function() { | |
if (this.content) { | |
var t = this.content.getContentSize() | |
, e = this._view.getContentSize(); | |
this.verticalScrollBar && (t.height < e.height ? this.verticalScrollBar.hide() : this.verticalScrollBar.show()), | |
this.horizontalScrollBar && (t.width < e.width ? this.horizontalScrollBar.hide() : this.horizontalScrollBar.show()) | |
} | |
}, | |
_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() { | |
if (this._outOfBoundaryAmountDirty = !0, | |
this._isOutOfBoundary()) { | |
var t = this._getHowMuchOutOfBoundary(cc.v2(0, 0)) | |
, e = this.getContentPosition().add(t); | |
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() | |
}, | |
onDisable: function() { | |
this._unregisterEvent(), | |
this.content && (this.content.off(i.SIZE_CHANGED, this._calculateBoundary, this), | |
this.content.off(i.SCALE_CHANGED, this._calculateBoundary, this), | |
this._view && (this._view.off(i.POSITION_CHANGED, this._calculateBoundary, this), | |
this._view.off(i.SCALE_CHANGED, this._calculateBoundary, this), | |
this._view.off(i.SIZE_CHANGED, this._calculateBoundary, this))), | |
this._hideScrollbar(), | |
this.stopAutoScroll() | |
}, | |
onEnable: function() { | |
this._registerEvent(), | |
this.content && (this.content.on(i.SIZE_CHANGED, this._calculateBoundary, this), | |
this.content.on(i.SCALE_CHANGED, this._calculateBoundary, this), | |
this._view && (this._view.on(i.POSITION_CHANGED, this._calculateBoundary, this), | |
this._view.on(i.SCALE_CHANGED, this._calculateBoundary, this), | |
this._view.on(i.SIZE_CHANGED, this._calculateBoundary, this))), | |
this._updateScrollBarState() | |
}, | |
update: function(t) { | |
this._autoScrolling && this._processAutoScrolling(t) | |
} | |
}); | |
cc.ScrollView = e.exports = c | |
} | |
), { | |
"../CCNode": 26, | |
"./CCViewGroup": 119 | |
}], | |
114: [(function(t, e) { | |
"use strict"; | |
var i = t("../utils/misc") | |
, n = t("./CCComponent") | |
, r = cc.Enum({ | |
Horizontal: 0, | |
Vertical: 1 | |
}) | |
, s = cc.Class({ | |
name: "cc.Slider", | |
extends: n, | |
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() {} | |
}, | |
direction: { | |
default: r.Horizontal, | |
type: r, | |
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: r | |
}, | |
__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), | |
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), | |
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) { | |
this.handle && (this._dragging = !0, | |
this._touchHandle || this._handleSliderLogic(t.touch), | |
t.stopPropagation()) | |
}, | |
_onTouchMoved: function(t) { | |
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 | |
, n = e.convertToNodeSpaceAR(t.getLocation()); | |
this.direction === r.Horizontal ? this.progress = i.clamp01((n.x - this._offset.x + e.anchorX * e.width) / e.width) : this.progress = i.clamp01((n.y - this._offset.y + e.anchorY * e.height) / e.height) | |
} | |
}, | |
_updateHandlePosition: function() { | |
if (this.handle) { | |
var t; | |
t = this.direction === r.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 = s | |
} | |
), { | |
"../utils/misc": 236, | |
"./CCComponent": 100 | |
}], | |
115: [(function(t, e) { | |
"use strict"; | |
var i = t("../utils/misc") | |
, n = (t("../CCNode").EventType, | |
t("./CCRenderComponent")) | |
, r = t("../utils/blend-func") | |
, s = cc.Enum({ | |
SIMPLE: 0, | |
SLICED: 1, | |
TILED: 2, | |
FILLED: 3, | |
MESH: 4 | |
}) | |
, a = cc.Enum({ | |
HORIZONTAL: 0, | |
VERTICAL: 1, | |
RADIAL: 2 | |
}) | |
, o = cc.Enum({ | |
CUSTOM: 0, | |
TRIMMED: 1, | |
RAW: 2 | |
}) | |
, c = cc.Enum({ | |
NORMAL: 0, | |
GRAY: 1 | |
}) | |
, l = cc.Class({ | |
name: "cc.Sprite", | |
extends: n, | |
mixins: [r], | |
editor: !1, | |
properties: { | |
_spriteFrame: { | |
default: null, | |
type: cc.SpriteFrame | |
}, | |
_type: s.SIMPLE, | |
_sizeMode: o.TRIMMED, | |
_fillType: 0, | |
_fillCenter: cc.v2(0, 0), | |
_fillStart: 0, | |
_fillRange: 0, | |
_isTrimmedMode: !0, | |
_atlas: { | |
default: null, | |
type: cc.SpriteAtlas, | |
tooltip: !1, | |
editorOnly: !0, | |
visible: !0, | |
animatable: !1 | |
}, | |
spriteFrame: { | |
get: function() { | |
return this._spriteFrame | |
}, | |
set: function(t) { | |
var e = this._spriteFrame; | |
e !== t && (this._spriteFrame = t, | |
this._applySpriteFrame(e)) | |
}, | |
type: cc.SpriteFrame | |
}, | |
type: { | |
get: function() { | |
return this._type | |
}, | |
set: function(t) { | |
this._type !== t && (this._type = t, | |
this.setVertsDirty(), | |
this._resetAssembler()) | |
}, | |
type: s, | |
animatable: !1, | |
tooltip: !1 | |
}, | |
fillType: { | |
get: function() { | |
return this._fillType | |
}, | |
set: function(t) { | |
t !== this._fillType && (this._fillType = t, | |
this.setVertsDirty(), | |
this._resetAssembler()) | |
}, | |
type: a, | |
tooltip: !1 | |
}, | |
fillCenter: { | |
get: function() { | |
return this._fillCenter | |
}, | |
set: function(t) { | |
this._fillCenter.x = t.x, | |
this._fillCenter.y = t.y, | |
this._type === s.FILLED && this.setVertsDirty() | |
}, | |
tooltip: !1 | |
}, | |
fillStart: { | |
get: function() { | |
return this._fillStart | |
}, | |
set: function(t) { | |
this._fillStart = i.clampf(t, -1, 1), | |
this._type === s.FILLED && this.setVertsDirty() | |
}, | |
tooltip: !1 | |
}, | |
fillRange: { | |
get: function() { | |
return this._fillRange | |
}, | |
set: function(t) { | |
this._fillRange = i.clampf(t, -1, 1), | |
this._type === s.FILLED && this.setVertsDirty() | |
}, | |
tooltip: !1 | |
}, | |
trim: { | |
get: function() { | |
return this._isTrimmedMode | |
}, | |
set: function(t) { | |
this._isTrimmedMode !== t && (this._isTrimmedMode = t, | |
this._type !== s.SIMPLE && this._type !== s.MESH || this.setVertsDirty()) | |
}, | |
animatable: !1, | |
tooltip: !1 | |
}, | |
sizeMode: { | |
get: function() { | |
return this._sizeMode | |
}, | |
set: function(t) { | |
this._sizeMode = t, | |
t !== o.CUSTOM && this._applySpriteSize() | |
}, | |
animatable: !1, | |
type: o, | |
tooltip: !1 | |
} | |
}, | |
statics: { | |
FillType: a, | |
Type: s, | |
SizeMode: o, | |
State: c | |
}, | |
setVisible: function(t) { | |
this.enabled = t | |
}, | |
setState: function() {}, | |
getState: function() {}, | |
__preload: function() { | |
this._super(), | |
this._applySpriteFrame() | |
}, | |
onEnable: function() { | |
this._super(), | |
this._spriteFrame && this._spriteFrame.isValid && this._spriteFrame.ensureLoadTexture(), | |
this.node.on(cc.Node.EventType.SIZE_CHANGED, this.setVertsDirty, this), | |
this.node.on(cc.Node.EventType.ANCHOR_CHANGED, this.setVertsDirty, this) | |
}, | |
onDisable: function() { | |
this._super(), | |
this.node.off(cc.Node.EventType.SIZE_CHANGED, this.setVertsDirty, this), | |
this.node.off(cc.Node.EventType.ANCHOR_CHANGED, this.setVertsDirty, this) | |
}, | |
onRestore: !1, | |
_updateMaterial: function() { | |
var t = null; | |
this._spriteFrame && (t = this._spriteFrame.getTexture()); | |
var e = this.getMaterial(0); | |
if (e) { | |
var i = e.getDefine("USE_TEXTURE"); | |
void 0 === i || i || e.define("USE_TEXTURE", !0); | |
var n = t && t.getImpl(); | |
e.getProperty("texture") !== n && e.setProperty("texture", t) | |
} | |
r.prototype._updateMaterial.call(this) | |
}, | |
_applyAtlas: !1, | |
_validateRender: function() { | |
var t = this._spriteFrame; | |
this._materials[0] && t && t.textureLoaded() || this.disableRender() | |
}, | |
_applySpriteSize: function() { | |
if (this.isValid && this._spriteFrame && this._spriteFrame.isValid) { | |
if (o.RAW === this._sizeMode) { | |
var t = this._spriteFrame._originalSize; | |
this.node.setContentSize(t) | |
} else if (o.TRIMMED === this._sizeMode) { | |
var e = this._spriteFrame._rect; | |
this.node.setContentSize(e.width, e.height) | |
} | |
this.setVertsDirty() | |
} | |
}, | |
_applySpriteFrame: function(t) { | |
if (this.isValid) { | |
var e = t && t.isValid && t.getTexture(); | |
e && !e.loaded && t.off("load", this._applySpriteSize, this); | |
var i = this._spriteFrame | |
, n = i && i.isValid | |
, r = n && i.getTexture(); | |
e !== r && this._updateMaterial(), | |
r && r.loaded ? this._applySpriteSize() : (this.disableRender(), | |
n && i.once("load", this._applySpriteSize, this)) | |
} | |
} | |
}); | |
cc.Sprite = e.exports = l | |
} | |
), { | |
"../CCNode": 26, | |
"../utils/blend-func": 230, | |
"../utils/misc": 236, | |
"./CCRenderComponent": 109 | |
}], | |
116: [(function(t, e) { | |
"use strict"; | |
var i = t("../utils/gray-sprite-state") | |
, n = cc.Class({ | |
name: "cc.Toggle", | |
extends: t("./CCButton"), | |
mixins: [i], | |
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; | |
e && e.enabled && this._N$isChecked && !e.allowSwitchOff || (this._N$isChecked = t, | |
this._updateCheckMark(), | |
e && e.enabled && e.updateToggles(this), | |
cc.Toggle._triggerEventInScript_isChecked && 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() | |
} | |
} | |
}, | |
statics: { | |
_triggerEventInScript_check: !1, | |
_triggerEventInScript_isChecked: !1 | |
}, | |
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, | |
cc.Toggle._triggerEventInScript_isChecked || !cc.Toggle._triggerEventInScript_check && !t || this._emitToggleEvents() | |
}, | |
check: function() { | |
this.isChecked = !0, | |
!cc.Toggle._triggerEventInScript_isChecked && cc.Toggle._triggerEventInScript_check && this._emitToggleEvents() | |
}, | |
uncheck: function() { | |
this.isChecked = !1, | |
!cc.Toggle._triggerEventInScript_isChecked && cc.Toggle._triggerEventInScript_check && this._emitToggleEvents() | |
}, | |
_updateCheckMark: function() { | |
this.checkMark && (this.checkMark.node.active = !!this.isChecked) | |
}, | |
_updateDisabledState: function() { | |
if (this._super(), | |
this.enableAutoGrayEffect && this.checkMark) { | |
var t = !this.interactable; | |
this._switchGrayMaterial(t, this.checkMark) | |
} | |
}, | |
_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": 183, | |
"../utils/gray-sprite-state": 233, | |
"./CCButton": 98, | |
"./CCToggleGroup": 118 | |
}], | |
117: [(function(t, e) { | |
"use strict"; | |
var i = 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) { | |
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; | |
return this.toggleItems.forEach((function(e) { | |
t ? e._hideCheckMark() : e.isChecked && (t = !0) | |
} | |
)), | |
t | |
}, | |
_makeAtLeastOneToggleChecked: function() { | |
if (!this._allowOnlyOneToggleChecked() && !this.allowSwitchOff) { | |
var t = this.toggleItems; | |
t.length > 0 && t[0].check() | |
} | |
}, | |
onEnable: function() { | |
this._makeAtLeastOneToggleChecked(), | |
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) | |
} | |
}); | |
t("../platform/js").get(i.prototype, "toggleItems", (function() { | |
return this.node._children.map((function(t) { | |
return t.getComponent(cc.Toggle) | |
} | |
)).filter(Boolean) | |
} | |
)), | |
cc.ToggleContainer = e.exports = i | |
} | |
), { | |
"../platform/js": 183 | |
}], | |
118: [(function(t, e) { | |
"use strict"; | |
var i = 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; | |
return this._toggleItems.forEach((function(e) { | |
t && e.enabled && e._hideCheckMark(), | |
e.isChecked && e.enabled && (t = !0) | |
} | |
)), | |
t | |
}, | |
_makeAtLeastOneToggleChecked: function() { | |
this._allowOnlyOneToggleChecked() || this.allowSwitchOff || this._toggleItems.length > 0 && (this._toggleItems[0].isChecked = !0) | |
}, | |
start: function() { | |
this._makeAtLeastOneToggleChecked() | |
} | |
}) | |
, n = t("../platform/js") | |
, r = !1; | |
n.get(cc, "ToggleGroup", (function() { | |
return r || (r = !0), | |
i | |
} | |
)), | |
e.exports = i | |
} | |
), { | |
"../platform/js": 183 | |
}], | |
119: [(function(t, e) { | |
"use strict"; | |
var i = cc.Class({ | |
name: "cc.ViewGroup", | |
extends: t("./CCComponent") | |
}); | |
cc.ViewGroup = e.exports = i | |
} | |
), { | |
"./CCComponent": 100 | |
}], | |
120: [(function(t, e) { | |
"use strict"; | |
var i = t("../base-ui/CCWidgetManager") | |
, n = i.AlignMode | |
, r = i._AlignFlags | |
, s = r.TOP | |
, a = r.MID | |
, o = r.BOT | |
, c = r.LEFT | |
, l = r.CENTER | |
, h = r.RIGHT | |
, u = s | o | |
, f = c | h | |
, d = cc.Class({ | |
name: "cc.Widget", | |
extends: t("./CCComponent"), | |
editor: !1, | |
properties: { | |
target: { | |
get: function() { | |
return this._target | |
}, | |
set: function(t) { | |
this._target = t | |
}, | |
type: cc.Node, | |
tooltip: !1 | |
}, | |
isAlignTop: { | |
get: function() { | |
return (this._alignFlags & s) > 0 | |
}, | |
set: function(t) { | |
this._setAlign(s, t) | |
}, | |
animatable: !1, | |
tooltip: !1 | |
}, | |
isAlignVerticalCenter: { | |
get: function() { | |
return (this._alignFlags & a) > 0 | |
}, | |
set: function(t) { | |
t ? (this.isAlignTop = !1, | |
this.isAlignBottom = !1, | |
this._alignFlags |= a) : this._alignFlags &= ~a | |
}, | |
animatable: !1, | |
tooltip: !1 | |
}, | |
isAlignBottom: { | |
get: function() { | |
return (this._alignFlags & o) > 0 | |
}, | |
set: function(t) { | |
this._setAlign(o, t) | |
}, | |
animatable: !1, | |
tooltip: !1 | |
}, | |
isAlignLeft: { | |
get: function() { | |
return (this._alignFlags & c) > 0 | |
}, | |
set: function(t) { | |
this._setAlign(c, t) | |
}, | |
animatable: !1, | |
tooltip: !1 | |
}, | |
isAlignHorizontalCenter: { | |
get: function() { | |
return (this._alignFlags & l) > 0 | |
}, | |
set: function(t) { | |
t ? (this.isAlignLeft = !1, | |
this.isAlignRight = !1, | |
this._alignFlags |= l) : this._alignFlags &= ~l | |
}, | |
animatable: !1, | |
tooltip: !1 | |
}, | |
isAlignRight: { | |
get: function() { | |
return (this._alignFlags & h) > 0 | |
}, | |
set: function(t) { | |
this._setAlign(h, t) | |
}, | |
animatable: !1, | |
tooltip: !1 | |
}, | |
isStretchWidth: { | |
get: function() { | |
return (this._alignFlags & f) === f | |
}, | |
visible: !1 | |
}, | |
isStretchHeight: { | |
get: function() { | |
return (this._alignFlags & u) === u | |
}, | |
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: n.ON_WINDOW_RESIZE, | |
type: n, | |
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: n | |
}, | |
onLoad: function() { | |
void 0 !== this._wasAlignOnce && (this.alignMode = this._wasAlignOnce ? n.ONCE : n.ALWAYS, | |
this._wasAlignOnce = void 0) | |
}, | |
onEnable: function() { | |
i.add(this) | |
}, | |
onDisable: function() { | |
i.remove(this) | |
}, | |
_validateTargetInDEV: !1, | |
_setAlign: function(t, e) { | |
if (e !== (this._alignFlags & t) > 0) { | |
var i = (t & f) > 0; | |
e ? (this._alignFlags |= t, | |
i ? (this.isAlignHorizontalCenter = !1, | |
this.isStretchWidth && (this._originalWidth = this.node.width)) : (this.isAlignVerticalCenter = !1, | |
this.isStretchHeight && (this._originalHeight = this.node.height))) : (i ? this.isStretchWidth && (this.node.width = this._originalWidth) : this.isStretchHeight && (this.node.height = this._originalHeight), | |
this._alignFlags &= ~t) | |
} | |
}, | |
updateAlignment: function() { | |
i.updateAlignment(this.node) | |
} | |
}); | |
Object.defineProperty(d.prototype, "isAlignOnce", { | |
get: function() { | |
return this.alignMode === n.ONCE | |
}, | |
set: function(t) { | |
this.alignMode = t ? n.ONCE : n.ALWAYS | |
} | |
}), | |
cc.Widget = e.exports = d | |
} | |
), { | |
"../base-ui/CCWidgetManager": 85, | |
"./CCComponent": 100 | |
}], | |
121: [(function(t, e) { | |
"use strict"; | |
var i = t("./CCComponent") | |
, n = cc.Class({ | |
name: "cc.SubContextView", | |
extends: i, | |
editor: !1, | |
properties: { | |
_firstlyEnabled: !0, | |
_fps: 60, | |
fps: { | |
get: function() { | |
return this._fps | |
}, | |
set: function(t) { | |
this._fps !== t && (this._fps = t, | |
this._updateInterval = 1 / t, | |
this._updateSubContextFrameRate()) | |
}, | |
tooltip: !1 | |
} | |
}, | |
ctor: function() { | |
this._sprite = null, | |
this._tex = new cc.Texture2D, | |
this._tex._packable = !1, | |
this._context = null, | |
this._updatedTime = performance.now(), | |
this._updateInterval = 0 | |
}, | |
onLoad: function() { | |
if (window.__globalAdapter && __globalAdapter.getOpenDataContext) { | |
this._updateInterval = 1e3 / this._fps, | |
this._context = __globalAdapter.getOpenDataContext(), | |
this.reset(); | |
var t = this._context.canvas; | |
this._tex.setPremultiplyAlpha(!0), | |
this._tex.initWithElement(t), | |
this._tex._packable = !1, | |
this._sprite = this.node.getComponent(cc.Sprite), | |
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 | |
}, | |
reset: function() { | |
if (this._context) { | |
this.updateSubContextViewport(); | |
var t = this._context.canvas; | |
t && (t.width = this.node.width, | |
t.height = this.node.height) | |
} | |
}, | |
onEnable: function() { | |
this._firstlyEnabled && this._context ? (this._context.postMessage({ | |
fromEngine: !0, | |
event: "boot" | |
}), | |
this._firstlyEnabled = !1) : this._runSubContextMainLoop(), | |
this._registerNodeEvent(), | |
this._updateSubContextFrameRate(), | |
this.updateSubContextViewport() | |
}, | |
onDisable: function() { | |
this._unregisterNodeEvent(), | |
this._stopSubContextMainLoop() | |
}, | |
update: function(t) { | |
if (void 0 === t) | |
return this._context && this._context.postMessage({ | |
fromEngine: !0, | |
event: "step" | |
}), | |
void this._updateSubContextTexture(); | |
performance.now() - this._updatedTime >= this._updateInterval && (this._updatedTime += this._updateInterval, | |
this._updateSubContextTexture()) | |
}, | |
_updateSubContextTexture: function() { | |
this._tex && this._context && (this._tex.initWithElement(this._context.canvas), | |
this._tex._packable = !1, | |
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 | |
}) | |
} | |
}, | |
_registerNodeEvent: function() { | |
this.node.on("position-changed", this.updateSubContextViewport, this), | |
this.node.on("scale-changed", this.updateSubContextViewport, this), | |
this.node.on("size-changed", this.updateSubContextViewport, this) | |
}, | |
_unregisterNodeEvent: function() { | |
this.node.off("position-changed", this.updateSubContextViewport, this), | |
this.node.off("scale-changed", this.updateSubContextViewport, this), | |
this.node.off("size-changed", this.updateSubContextViewport, this) | |
}, | |
_runSubContextMainLoop: function() { | |
this._context && this._context.postMessage({ | |
fromEngine: !0, | |
event: "mainLoop", | |
value: !0 | |
}) | |
}, | |
_stopSubContextMainLoop: function() { | |
this._context && this._context.postMessage({ | |
fromEngine: !0, | |
event: "mainLoop", | |
value: !1 | |
}) | |
}, | |
_updateSubContextFrameRate: function() { | |
this._context && this._context.postMessage({ | |
fromEngine: !0, | |
event: "frameRate", | |
value: this._fps | |
}) | |
} | |
}); | |
cc.SubContextView = e.exports = n, | |
cc.WXSubContextView = n, | |
cc.SwanSubContextView = n | |
} | |
), { | |
"./CCComponent": 100 | |
}], | |
122: [(function(t, e) { | |
"use strict"; | |
var i = t("../../platform/CCMacro") | |
, n = t("../editbox/EditBoxImplBase") | |
, r = t("../CCLabel") | |
, s = t("./types") | |
, a = s.InputMode | |
, o = s.InputFlag | |
, c = s.KeyboardReturnType; | |
function l(t) { | |
return t.charAt(0).toUpperCase() + t.slice(1) | |
} | |
var h = cc.Class({ | |
name: "cc.EditBox", | |
extends: cc.Component, | |
editor: !1, | |
properties: { | |
_string: "", | |
string: { | |
tooltip: !1, | |
get: function() { | |
return this._string | |
}, | |
set: function(t) { | |
t = "" + t, | |
this.maxLength >= 0 && t.length >= this.maxLength && (t = t.slice(0, this.maxLength)), | |
this._string = t, | |
this._updateString(t) | |
} | |
}, | |
textLabel: { | |
tooltip: !1, | |
default: null, | |
type: r, | |
notify: function(t) { | |
this.textLabel && this.textLabel !== t && (this._updateTextLabel(), | |
this._updateLabels()) | |
} | |
}, | |
placeholderLabel: { | |
tooltip: !1, | |
default: null, | |
type: r, | |
notify: function(t) { | |
this.placeholderLabel && this.placeholderLabel !== t && (this._updatePlaceholderLabel(), | |
this._updateLabels()) | |
} | |
}, | |
background: { | |
tooltip: !1, | |
default: null, | |
type: cc.Sprite, | |
notify: function(t) { | |
this.background && this.background !== t && this._updateBackgroundSprite() | |
} | |
}, | |
_N$backgroundImage: { | |
default: void 0, | |
type: cc.SpriteFrame | |
}, | |
backgroundImage: { | |
get: function() { | |
return this.background ? this.background.spriteFrame : null | |
}, | |
set: function(t) { | |
this.background && (this.background.spriteFrame = t) | |
} | |
}, | |
returnType: { | |
default: c.DEFAULT, | |
tooltip: !1, | |
displayName: "KeyboardReturnType", | |
type: c | |
}, | |
_N$returnType: { | |
default: void 0, | |
type: cc.Float | |
}, | |
inputFlag: { | |
tooltip: !1, | |
default: o.DEFAULT, | |
type: o, | |
notify: function() { | |
this._updateString(this._string) | |
} | |
}, | |
inputMode: { | |
tooltip: !1, | |
default: a.ANY, | |
type: a, | |
notify: function(t) { | |
this.inputMode !== t && (this._updateTextLabel(), | |
this._updatePlaceholderLabel()) | |
} | |
}, | |
fontSize: { | |
get: function() { | |
return this.textLabel ? this.textLabel.fontSize : 0 | |
}, | |
set: function(t) { | |
this.textLabel && (this.textLabel.fontSize = t) | |
} | |
}, | |
_N$fontSize: { | |
default: void 0, | |
type: cc.Float | |
}, | |
lineHeight: { | |
get: function() { | |
return this.textLabel ? this.textLabel.lineHeight : 0 | |
}, | |
set: function(t) { | |
this.textLabel && (this.textLabel.lineHeight = t) | |
} | |
}, | |
_N$lineHeight: { | |
default: void 0, | |
type: cc.Float | |
}, | |
fontColor: { | |
get: function() { | |
return this.textLabel ? this.textLabel.node.color : cc.Color.BLACK | |
}, | |
set: function(t) { | |
this.textLabel && (this.textLabel.node.color = t, | |
this.textLabel.node.opacity = t.a) | |
} | |
}, | |
_N$fontColor: void 0, | |
placeholder: { | |
tooltip: !1, | |
get: function() { | |
return this.placeholderLabel ? this.placeholderLabel.string : "" | |
}, | |
set: function(t) { | |
this.placeholderLabel && (this.placeholderLabel.string = t) | |
} | |
}, | |
_N$placeholder: { | |
default: void 0, | |
type: cc.String | |
}, | |
placeholderFontSize: { | |
get: function() { | |
return this.placeholderLabel ? this.placeholderLabel.fontSize : 0 | |
}, | |
set: function(t) { | |
this.placeholderLabel && (this.placeholderLabel.fontSize = t) | |
} | |
}, | |
_N$placeholderFontSize: { | |
default: void 0, | |
type: cc.Float | |
}, | |
placeholderFontColor: { | |
get: function() { | |
return this.placeholderLabel ? this.placeholderLabel.node.color : cc.Color.BLACK | |
}, | |
set: function(t) { | |
this.placeholderLabel && (this.placeholderLabel.node.color = t, | |
this.placeholderLabel.node.opacity = t.a) | |
} | |
}, | |
_N$placeholderFontColor: void 0, | |
maxLength: { | |
tooltip: !1, | |
default: 20 | |
}, | |
_N$maxLength: { | |
default: void 0, | |
type: cc.Float | |
}, | |
stayOnTop: { | |
default: !1, | |
notify: function() {} | |
}, | |
_tabIndex: 0, | |
tabIndex: { | |
tooltip: !1, | |
get: function() { | |
return this._tabIndex | |
}, | |
set: function(t) { | |
this._tabIndex !== 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: { | |
_ImplClass: n, | |
KeyboardReturnType: c, | |
InputFlag: o, | |
InputMode: a | |
}, | |
_init: function() { | |
this._upgradeComp(), | |
this._isLabelVisible = !0, | |
this.node.on(cc.Node.EventType.SIZE_CHANGED, this._syncSize, this), | |
(this._impl = new h._ImplClass).init(this), | |
this._updateString(this._string), | |
this._syncSize() | |
}, | |
_updateBackgroundSprite: 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)), | |
e.parent = this.node, | |
this.background = t | |
} | |
t.type = cc.Sprite.Type.SLICED, | |
void 0 !== this._N$backgroundImage && (t.spriteFrame = this._N$backgroundImage, | |
this._N$backgroundImage = void 0) | |
}, | |
_updateTextLabel: function() { | |
var t = this.textLabel; | |
if (!t) { | |
var e = this.node.getChildByName("TEXT_LABEL"); | |
e || (e = new cc.Node("TEXT_LABEL")), | |
(t = e.getComponent(r)) || (t = e.addComponent(r)), | |
e.parent = this.node, | |
this.textLabel = t | |
} | |
t.node.setAnchorPoint(0, 1), | |
t.overflow = r.Overflow.CLAMP, | |
this.inputMode === a.ANY ? (t.verticalAlign = i.VerticalTextAlignment.TOP, | |
t.enableWrapText = !0) : (t.verticalAlign = i.VerticalTextAlignment.CENTER, | |
t.enableWrapText = !1), | |
t.string = this._updateLabelStringStyle(this._string), | |
void 0 !== this._N$fontColor && (t.node.color = this._N$fontColor, | |
t.node.opacity = this._N$fontColor.a, | |
this._N$fontColor = void 0), | |
void 0 !== this._N$fontSize && (t.fontSize = this._N$fontSize, | |
this._N$fontSize = void 0), | |
void 0 !== this._N$lineHeight && (t.lineHeight = this._N$lineHeight, | |
this._N$lineHeight = void 0) | |
}, | |
_updatePlaceholderLabel: function() { | |
var t = this.placeholderLabel; | |
if (!t) { | |
var e = this.node.getChildByName("PLACEHOLDER_LABEL"); | |
e || (e = new cc.Node("PLACEHOLDER_LABEL")), | |
(t = e.getComponent(r)) || (t = e.addComponent(r)), | |
e.parent = this.node, | |
this.placeholderLabel = t | |
} | |
t.node.setAnchorPoint(0, 1), | |
t.overflow = r.Overflow.CLAMP, | |
this.inputMode === a.ANY ? (t.verticalAlign = i.VerticalTextAlignment.TOP, | |
t.enableWrapText = !0) : (t.verticalAlign = i.VerticalTextAlignment.CENTER, | |
t.enableWrapText = !1), | |
t.string = this.placeholder, | |
void 0 !== this._N$placeholderFontColor && (t.node.color = this._N$placeholderFontColor, | |
t.node.opacity = this._N$placeholderFontColor.a, | |
this._N$placeholderFontColor = void 0), | |
void 0 !== this._N$placeholderFontSize && (t.fontSize = this._N$placeholderFontSize, | |
this._N$placeholderFontSize = void 0) | |
}, | |
_upgradeComp: function() { | |
void 0 !== this._N$returnType && (this.returnType = this._N$returnType, | |
this._N$returnType = void 0), | |
void 0 !== this._N$maxLength && (this.maxLength = this._N$maxLength, | |
this._N$maxLength = void 0), | |
void 0 !== this._N$backgroundImage && this._updateBackgroundSprite(), | |
void 0 === this._N$fontColor && void 0 === this._N$fontSize && void 0 === this._N$lineHeight || this._updateTextLabel(), | |
void 0 === this._N$placeholderFontColor && void 0 === this._N$placeholderFontSize || this._updatePlaceholderLabel(), | |
void 0 !== this._N$placeholder && (this.placeholder = this._N$placeholder, | |
this._N$placeholder = void 0) | |
}, | |
_syncSize: function() { | |
if (this._impl) { | |
var t = this.node.getContentSize(); | |
this._impl.setSize(t.width, t.height) | |
} | |
}, | |
_showLabels: function() { | |
this._isLabelVisible = !0, | |
this._updateLabels() | |
}, | |
_hideLabels: function() { | |
this._isLabelVisible = !1, | |
this.textLabel && (this.textLabel.node.active = !1), | |
this.placeholderLabel && (this.placeholderLabel.node.active = !1) | |
}, | |
_updateLabels: function() { | |
if (this._isLabelVisible) { | |
var t = this._string; | |
this.textLabel && (this.textLabel.node.active = "" !== t), | |
this.placeholderLabel && (this.placeholderLabel.node.active = "" === t) | |
} | |
}, | |
_updateString: function(t) { | |
var e = this.textLabel; | |
if (e) { | |
var i = t; | |
i && (i = this._updateLabelStringStyle(i)), | |
e.string = i, | |
this._updateLabels() | |
} | |
}, | |
_updateLabelStringStyle: function(t, e) { | |
var i = this.inputFlag; | |
if (e || i !== o.PASSWORD) | |
i === o.INITIAL_CAPS_ALL_CHARACTERS ? t = t.toUpperCase() : i === o.INITIAL_CAPS_WORD ? t = t.replace(/(?:^|\s)\S/g, (function(t) { | |
return t.toUpperCase() | |
} | |
)) : i === o.INITIAL_CAPS_SENTENCE && (t = l(t)); | |
else { | |
for (var n = "", r = t.length, s = 0; s < r; ++s) | |
n += "\u25cf"; | |
t = n | |
} | |
return t | |
}, | |
editBoxEditingDidBegan: function() { | |
cc.Component.EventHandler.emitEvents(this.editingDidBegan, this), | |
this.node.emit("editing-did-began", this) | |
}, | |
editBoxEditingDidEnded: function() { | |
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) | |
}, | |
onEnable: function() { | |
this._registerEvent(), | |
this._impl && this._impl.enable() | |
}, | |
onDisable: function() { | |
this._unregisterEvent(), | |
this._impl && this._impl.disable() | |
}, | |
onDestroy: function() { | |
this._impl && this._impl.clear() | |
}, | |
__preload: function() { | |
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) | |
}, | |
_unregisterEvent: function() { | |
this.node.off(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this), | |
this.node.off(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this) | |
}, | |
_onTouchBegan: function(t) { | |
t.stopPropagation() | |
}, | |
_onTouchCancel: function(t) { | |
t.stopPropagation() | |
}, | |
_onTouchEnded: function(t) { | |
this._impl && this._impl.beginEditing(), | |
t.stopPropagation() | |
}, | |
setFocus: function() { | |
this._impl && this._impl.setFocus(!0) | |
}, | |
focus: function() { | |
this._impl && this._impl.setFocus(!0) | |
}, | |
blur: function() { | |
this._impl && this._impl.setFocus(!1) | |
}, | |
isFocused: function() { | |
return !!this._impl && this._impl.isFocused() | |
}, | |
update: function() { | |
this._impl && this._impl.update() | |
} | |
}); | |
cc.EditBox = e.exports = h, | |
cc.sys.isBrowser && t("./WebEditBoxImpl") | |
} | |
), { | |
"../../platform/CCMacro": 167, | |
"../CCLabel": 102, | |
"../editbox/EditBoxImplBase": 123, | |
"./WebEditBoxImpl": 124, | |
"./types": 126 | |
}], | |
123: [(function(t, e) { | |
"use strict"; | |
var i = cc.Class({ | |
ctor: function() { | |
this._delegate = null, | |
this._editing = !1 | |
}, | |
init: function() {}, | |
enable: function() {}, | |
disable: function() { | |
this._editing && this.endEditing() | |
}, | |
clear: function() {}, | |
update: function() {}, | |
setTabIndex: function() {}, | |
setSize: function() {}, | |
setFocus: function(t) { | |
t ? this.beginEditing() : this.endEditing() | |
}, | |
isFocused: function() { | |
return this._editing | |
}, | |
beginEditing: function() {}, | |
endEditing: function() {} | |
}); | |
e.exports = i | |
} | |
), {}], | |
124: [(function(t) { | |
"use strict"; | |
var e, i = (e = t("../../value-types/mat4")) && e.__esModule ? e : { | |
default: e | |
}, n = t("../../platform/utils"), r = t("../../platform/CCMacro"), s = t("./types"), a = t("../CCLabel"), o = t("./tabIndexUtil"), c = cc.EditBox, l = cc.js, h = s.InputMode, u = s.InputFlag, f = s.KeyboardReturnType, 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 _ = 0 | |
, p = cc.v3() | |
, v = null | |
, g = !1 | |
, m = !1 | |
, y = c._ImplClass; | |
function T() { | |
y.call(this), | |
this._domId = "EditBoxId_" + ++_, | |
this._placeholderStyleSheet = null, | |
this._elem = null, | |
this._isTextArea = !1, | |
this._worldMat = new i.default, | |
this._cameraMat = new i.default, | |
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._cacheViewportRect = cc.rect(0, 0, 0, 0), | |
this._inputMode = null, | |
this._inputFlag = null, | |
this._returnType = null, | |
this._eventListeners = {}, | |
this._textLabelFont = null, | |
this._textLabelFontSize = null, | |
this._textLabelFontColor = null, | |
this._textLabelAlign = null, | |
this._placeholderLabelFont = null, | |
this._placeholderLabelFontSize = null, | |
this._placeholderLabelFontColor = null, | |
this._placeholderLabelAlign = null, | |
this._placeholderLineHeight = null | |
} | |
l.extend(T, y), | |
c._ImplClass = T, | |
Object.assign(T.prototype, { | |
init: function(t) { | |
t && (this._delegate = t, | |
t.inputMode === h.ANY ? this._createTextArea() : this._createInput(), | |
o.add(this), | |
this.setTabIndex(t.tabIndex), | |
this._initStyleSheet(), | |
this._registerEventListeners(), | |
this._addDomToGameContainer(), | |
g = cc.view.isAutoFullScreenEnabled(), | |
m = cc.view._resizeWithBrowserSize) | |
}, | |
clear: function() { | |
this._removeEventListeners(), | |
this._removeDomFromGameContainer(), | |
o.remove(this), | |
v === this && (v = null) | |
}, | |
update: function() { | |
this._updateMatrix() | |
}, | |
setTabIndex: function(t) { | |
this._elem.tabIndex = t, | |
o.resort() | |
}, | |
setSize: function(t, e) { | |
var i = this._elem; | |
i.style.width = t + "px", | |
i.style.height = e + "px" | |
}, | |
beginEditing: function() { | |
v && v !== this && v.setFocus(!1), | |
this._editing = !0, | |
v = this, | |
this._delegate.editBoxEditingDidBegan(), | |
this._showDom(), | |
this._elem.focus() | |
}, | |
endEditing: function() { | |
this._elem && this._elem.blur() | |
}, | |
_createInput: function() { | |
this._isTextArea = !1, | |
this._elem = document.createElement("input") | |
}, | |
_createTextArea: function() { | |
this._isTextArea = !0, | |
this._elem = document.createElement("textarea") | |
}, | |
_addDomToGameContainer: function() { | |
cc.game.container.appendChild(this._elem), | |
document.head.appendChild(this._placeholderStyleSheet) | |
}, | |
_removeDomFromGameContainer: function() { | |
n.contains(cc.game.container, this._elem) && cc.game.container.removeChild(this._elem), | |
n.contains(document.head, this._placeholderStyleSheet) && document.head.removeChild(this._placeholderStyleSheet), | |
delete this._elem, | |
delete this._placeholderStyleSheet | |
}, | |
_showDom: function() { | |
this._updateMaxLength(), | |
this._updateInputType(), | |
this._updateStyleSheet(), | |
this._elem.style.display = "", | |
this._delegate._hideLabels(), | |
cc.sys.isMobile && this._showDomOnMobile() | |
}, | |
_hideDom: function() { | |
this._elem.style.display = "none", | |
this._delegate._showLabels(), | |
cc.sys.isMobile && this._hideDomOnMobile() | |
}, | |
_showDomOnMobile: function() { | |
cc.sys.os === cc.sys.OS_ANDROID && (g && (cc.view.enableAutoFullScreen(!1), | |
cc.screen.exitFullScreen()), | |
m && cc.view.resizeWithBrowserSize(!1), | |
this._adjustWindowScroll()) | |
}, | |
_hideDomOnMobile: function() { | |
cc.sys.os === cc.sys.OS_ANDROID && (m && cc.view.resizeWithBrowserSize(!0), | |
setTimeout((function() { | |
v || g && cc.view.enableAutoFullScreen(!0) | |
} | |
), 800)) | |
}, | |
_adjustWindowScroll: function() { | |
var t = this; | |
setTimeout((function() { | |
window.scrollY < 100 && t._elem.scrollIntoView({ | |
block: "start", | |
inline: "nearest", | |
behavior: "smooth" | |
}) | |
} | |
), 800) | |
}, | |
_scrollBackWindow: function() { | |
setTimeout((function() { | |
var t = cc.sys; | |
t.browserType !== t.BROWSER_TYPE_WECHAT || t.os !== t.OS_IOS ? window.scrollTo(0, 0) : window.top && window.top.scrollTo(0, 0) | |
} | |
), 800) | |
}, | |
_updateCameraMatrix: function() { | |
var t = this._delegate.node; | |
t.getWorldMatrix(this._worldMat); | |
var e = this._worldMat | |
, n = t._contentSize | |
, r = t._anchorPoint; | |
p.x = -r.x * n.width, | |
p.y = -r.y * n.height, | |
i.default.transform(e, e, p); | |
var s = cc.Camera.findCamera(t); | |
return !!s && (s.getWorldToScreenMatrix2D(this._cameraMat), | |
i.default.mul(this._cameraMat, this._cameraMat, e), | |
!0) | |
}, | |
_updateMatrix: function() { | |
if (this._updateCameraMatrix()) { | |
var t = this._cameraMat.m | |
, e = this._delegate.node | |
, i = cc.view; | |
if (this._m00 !== t[0] || this._m01 !== t[1] || this._m04 !== t[4] || this._m05 !== t[5] || this._m12 !== t[12] || this._m13 !== t[13] || this._w !== e._contentSize.width || this._h !== e._contentSize.height || !this._cacheViewportRect.equals(i._viewportRect)) { | |
this._m00 = t[0], | |
this._m01 = t[1], | |
this._m04 = t[4], | |
this._m05 = t[5], | |
this._m12 = t[12], | |
this._m13 = t[13], | |
this._w = e._contentSize.width, | |
this._h = e._contentSize.height, | |
this._cacheViewportRect.set(i._viewportRect); | |
var n = i._scaleX | |
, r = i._scaleY | |
, s = i._viewportRect | |
, a = i._devicePixelRatio; | |
n /= a, | |
r /= a; | |
var o = cc.game.container | |
, c = t[0] * n | |
, l = t[1] | |
, h = t[4] | |
, u = t[5] * r | |
, f = o && o.style.paddingLeft && parseInt(o.style.paddingLeft); | |
f += s.x / a; | |
var _ = o && o.style.paddingBottom && parseInt(o.style.paddingBottom); | |
_ += s.y / a; | |
var p = t[12] * n + f | |
, v = t[13] * r + _; | |
d.zoomInvalid && (this.setSize(e.width * c, e.height * u), | |
c = 1, | |
u = 1); | |
var g = this._elem | |
, m = "matrix(" + c + "," + -l + "," + -h + "," + u + "," + p + "," + -v + ")"; | |
g.style.transform = m, | |
g.style["-webkit-transform"] = m, | |
g.style["transform-origin"] = "0px 100% 0px", | |
g.style["-webkit-transform-origin"] = "0px 100% 0px" | |
} | |
} | |
}, | |
_updateInputType: function() { | |
var t = this._delegate | |
, e = t.inputMode | |
, i = t.inputFlag | |
, n = t.returnType | |
, r = this._elem; | |
if (this._inputMode !== e || this._inputFlag !== i || this._returnType !== n) { | |
if (this._inputMode = e, | |
this._inputFlag = i, | |
this._returnType = n, | |
this._isTextArea) { | |
var s = "none"; | |
return i === u.INITIAL_CAPS_ALL_CHARACTERS ? s = "uppercase" : i === u.INITIAL_CAPS_WORD && (s = "capitalize"), | |
void (r.style.textTransform = s) | |
} | |
if (i === u.PASSWORD) | |
return r.type = "password", | |
void (r.style.textTransform = "none"); | |
var a = r.type; | |
e === h.EMAIL_ADDR ? a = "email" : e === h.NUMERIC || e === h.DECIMAL ? a = "number" : e === h.PHONE_NUMBER ? (a = "number", | |
r.pattern = "[0-9]*", | |
r.onmousewheel = function() { | |
return !1 | |
} | |
) : e === h.URL ? a = "url" : (a = "text", | |
n === f.SEARCH && (a = "search")), | |
r.type = a; | |
var o = "none"; | |
i === u.INITIAL_CAPS_ALL_CHARACTERS ? o = "uppercase" : i === u.INITIAL_CAPS_WORD && (o = "capitalize"), | |
r.style.textTransform = o | |
} | |
}, | |
_updateMaxLength: function() { | |
var t = this._delegate.maxLength; | |
t < 0 && (t = 65535), | |
this._elem.maxLength = t | |
}, | |
_initStyleSheet: function() { | |
var t = this._elem; | |
t.style.display = "none", | |
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 = "none", | |
t.style.position = "absolute", | |
t.style.bottom = "0px", | |
t.style.left = "2px", | |
t.className = "cocosEditBox", | |
t.id = this._domId, | |
this._isTextArea ? (t.style.resize = "none", | |
t.style.overflow_y = "scroll") : (t.type = "text", | |
t.style["-moz-appearance"] = "textfield"), | |
this._placeholderStyleSheet = document.createElement("style") | |
}, | |
_updateStyleSheet: function() { | |
var t = this._delegate | |
, e = this._elem; | |
e.value = t.string, | |
e.placeholder = t.placeholder, | |
this._updateTextLabel(t.textLabel), | |
this._updatePlaceholderLabel(t.placeholderLabel) | |
}, | |
_updateTextLabel: function(t) { | |
if (t) { | |
var e = t.font; | |
e = !e || e instanceof cc.BitmapFont ? t.fontFamily : e._fontFamily; | |
var i = t.fontSize * t.node.scaleY; | |
if (this._textLabelFont !== e || this._textLabelFontSize !== i || this._textLabelFontColor !== t.fontColor || this._textLabelAlign !== t.horizontalAlign) { | |
this._textLabelFont = e, | |
this._textLabelFontSize = i, | |
this._textLabelFontColor = t.fontColor, | |
this._textLabelAlign = t.horizontalAlign; | |
var n = this._elem; | |
switch (n.style.fontSize = i + "px", | |
n.style.color = t.node.color.toCSS(), | |
n.style.fontFamily = e, | |
t.horizontalAlign) { | |
case a.HorizontalAlign.LEFT: | |
n.style.textAlign = "left"; | |
break; | |
case a.HorizontalAlign.CENTER: | |
n.style.textAlign = "center"; | |
break; | |
case a.HorizontalAlign.RIGHT: | |
n.style.textAlign = "right" | |
} | |
} | |
} | |
}, | |
_updatePlaceholderLabel: function(t) { | |
if (t) { | |
var e = t.font; | |
e = !e || e instanceof cc.BitmapFont ? t.fontFamily : t.font._fontFamily; | |
var i = t.fontSize * t.node.scaleY; | |
if (this._placeholderLabelFont !== e || this._placeholderLabelFontSize !== i || this._placeholderLabelFontColor !== t.fontColor || this._placeholderLabelAlign !== t.horizontalAlign || this._placeholderLineHeight !== t.fontSize) { | |
this._placeholderLabelFont = e, | |
this._placeholderLabelFontSize = i, | |
this._placeholderLabelFontColor = t.fontColor, | |
this._placeholderLabelAlign = t.horizontalAlign, | |
this._placeholderLineHeight = t.fontSize; | |
var n, r = this._placeholderStyleSheet, s = t.node.color.toCSS(), o = t.fontSize; | |
switch (t.horizontalAlign) { | |
case a.HorizontalAlign.LEFT: | |
n = "left"; | |
break; | |
case a.HorizontalAlign.CENTER: | |
n = "center"; | |
break; | |
case a.HorizontalAlign.RIGHT: | |
n = "right" | |
} | |
r.innerHTML = "#" + this._domId + "::-webkit-input-placeholder,#" + this._domId + "::-moz-placeholder,#" + this._domId + ":-ms-input-placeholder{text-transform: initial; font-family: " + e + "; font-size: " + i + "px; color: " + s + "; line-height: " + o + "px; text-align: " + n + ";}", | |
cc.sys.browserType === cc.sys.BROWSER_TYPE_EDGE && (r.innerHTML += "#" + this._domId + "::-ms-clear{display: none;}") | |
} | |
} | |
}, | |
_registerEventListeners: function() { | |
var t = this | |
, e = this._elem | |
, i = !1 | |
, n = this._eventListeners; | |
n.compositionStart = function() { | |
i = !0 | |
} | |
, | |
n.compositionEnd = function() { | |
i = !1, | |
t._delegate.editBoxTextChanged(e.value) | |
} | |
, | |
n.onInput = function() { | |
if (!i) { | |
var n = t._delegate.maxLength; | |
n >= 0 && (e.value = e.value.slice(0, n)), | |
t._delegate.editBoxTextChanged(e.value) | |
} | |
} | |
, | |
n.onClick = function() { | |
t._editing && cc.sys.isMobile && t._adjustWindowScroll() | |
} | |
, | |
n.onKeydown = function(i) { | |
i.keyCode === r.KEY.enter ? (i.stopPropagation(), | |
t._delegate.editBoxEditingReturn(), | |
t._isTextArea || e.blur()) : i.keyCode === r.KEY.tab && (i.stopPropagation(), | |
i.preventDefault(), | |
o.next(t)) | |
} | |
, | |
n.onBlur = function() { | |
cc.sys.isMobile && i && n.compositionEnd(), | |
t._editing = !1, | |
v = null, | |
t._hideDom(), | |
t._delegate.editBoxEditingDidEnded() | |
} | |
, | |
e.addEventListener("compositionstart", n.compositionStart), | |
e.addEventListener("compositionend", n.compositionEnd), | |
e.addEventListener("input", n.onInput), | |
e.addEventListener("keydown", n.onKeydown), | |
e.addEventListener("blur", n.onBlur), | |
e.addEventListener("touchstart", n.onClick) | |
}, | |
_removeEventListeners: function() { | |
var t = this._elem | |
, e = this._eventListeners; | |
t.removeEventListener("compositionstart", e.compositionStart), | |
t.removeEventListener("compositionend", e.compositionEnd), | |
t.removeEventListener("input", e.onInput), | |
t.removeEventListener("keydown", e.onKeydown), | |
t.removeEventListener("blur", e.onBlur), | |
t.removeEventListener("touchstart", e.onClick), | |
e.compositionStart = null, | |
e.compositionEnd = null, | |
e.onInput = null, | |
e.onKeydown = null, | |
e.onBlur = null, | |
e.onClick = null | |
} | |
}) | |
} | |
), { | |
"../../platform/CCMacro": 167, | |
"../../platform/utils": 186, | |
"../../value-types/mat4": 253, | |
"../CCLabel": 102, | |
"./tabIndexUtil": 125, | |
"./types": 126 | |
}], | |
125: [(function(t, e) { | |
"use strict"; | |
e.exports = { | |
_tabIndexList: [], | |
add: function(t) { | |
var e = this._tabIndexList; | |
-1 === e.indexOf(t) && e.push(t) | |
}, | |
remove: function(t) { | |
var e = this._tabIndexList | |
, i = e.indexOf(t); | |
-1 !== i && e.splice(i, 1) | |
}, | |
resort: function() { | |
this._tabIndexList.sort((function(t, e) { | |
return t._delegate._tabIndex - e._delegate._tabIndex | |
} | |
)) | |
}, | |
next: function(t) { | |
var e = this._tabIndexList | |
, i = e.indexOf(t); | |
if (t.setFocus(!1), | |
-1 !== i) { | |
var n = e[i + 1]; | |
n && n._delegate._tabIndex >= 0 && n.setFocus(!0) | |
} | |
} | |
} | |
} | |
), {}], | |
126: [(function(t, e) { | |
"use strict"; | |
var i = cc.Enum({ | |
DEFAULT: 0, | |
DONE: 1, | |
SEND: 2, | |
SEARCH: 3, | |
GO: 4, | |
NEXT: 5 | |
}) | |
, n = cc.Enum({ | |
ANY: 0, | |
EMAIL_ADDR: 1, | |
NUMERIC: 2, | |
PHONE_NUMBER: 3, | |
URL: 4, | |
DECIMAL: 5, | |
SINGLE_LINE: 6 | |
}) | |
, r = cc.Enum({ | |
PASSWORD: 0, | |
SENSITIVE: 1, | |
INITIAL_CAPS_WORD: 2, | |
INITIAL_CAPS_SENTENCE: 3, | |
INITIAL_CAPS_ALL_CHARACTERS: 4, | |
DEFAULT: 5 | |
}); | |
e.exports = { | |
KeyboardReturnType: i, | |
InputMode: n, | |
InputFlag: r | |
} | |
} | |
), {}], | |
127: [(function(t, e) { | |
"use strict"; | |
t("./CCComponent"), | |
t("./CCComponentEventHandler"), | |
t("./missing-script"); | |
var i = t("./SubContextView"); | |
i || (i = cc.Class({ | |
name: "cc.SubContextView", | |
extends: cc.Component | |
}), | |
cc.SubContextView = cc.WXSubContextView = cc.SwanSubContextView = i); | |
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("./CCLabelShadow"), t("./CCRichText"), t("./CCToggleContainer"), t("./CCToggleGroup"), t("./CCToggle"), t("./CCBlockInputEvents"), t("./CCPropagateTouchEvents"), t("./CCMotionStreak"), t("./CCSafeArea"), i]; | |
e.exports = n | |
} | |
), { | |
"./CCAnimation": 96, | |
"./CCAudioSource": void 0, | |
"./CCBlockInputEvents": 97, | |
"./CCButton": 98, | |
"./CCCanvas": 99, | |
"./CCComponent": 100, | |
"./CCComponentEventHandler": 101, | |
"./CCLabel": 102, | |
"./CCLabelOutline": 103, | |
"./CCLabelShadow": 104, | |
"./CCLayout": 105, | |
"./CCMask": 106, | |
"./CCMotionStreak": void 0, | |
"./CCPageView": void 0, | |
"./CCPageViewIndicator": void 0, | |
"./CCProgressBar": 107, | |
"./CCPropagateTouchEvents": 108, | |
"./CCRichText": 110, | |
"./CCSafeArea": 111, | |
"./CCScrollBar": 112, | |
"./CCScrollView": 113, | |
"./CCSlider": 114, | |
"./CCSprite": 115, | |
"./CCToggle": 116, | |
"./CCToggleContainer": 117, | |
"./CCToggleGroup": 118, | |
"./CCWidget": 120, | |
"./SubContextView": 121, | |
"./editbox/CCEditBox": 122, | |
"./missing-script": 128 | |
}], | |
128: [(function(t, e) { | |
"use strict"; | |
var i = cc.js | |
, n = 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) { | |
return i._getClassById(t) || (cc.deserialize.reportMissingClass(t), | |
n) | |
} | |
}, | |
onLoad: function() {} | |
}); | |
cc._MissingScript = e.exports = n | |
} | |
), {}], | |
129: [(function(t, e) { | |
"use strict"; | |
var i = cc.js; | |
t("../event/event"); | |
var n = 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 | |
}; | |
i.extend(n, cc.Event); | |
var r = n.prototype; | |
r.setScrollData = function(t, e) { | |
this._scrollX = t, | |
this._scrollY = e | |
} | |
, | |
r.getScrollX = function() { | |
return this._scrollX | |
} | |
, | |
r.getScrollY = function() { | |
return this._scrollY | |
} | |
, | |
r.setLocation = function(t, e) { | |
this._x = t, | |
this._y = e | |
} | |
, | |
r.getLocation = function() { | |
return cc.v2(this._x, this._y) | |
} | |
, | |
r.getLocationInView = function() { | |
return cc.v2(this._x, cc.view._designResolutionSize.height - this._y) | |
} | |
, | |
r._setPrevCursor = function(t, e) { | |
this._prevX = t, | |
this._prevY = e | |
} | |
, | |
r.getPreviousLocation = function() { | |
return cc.v2(this._prevX, this._prevY) | |
} | |
, | |
r.getDelta = function() { | |
return cc.v2(this._x - this._prevX, this._y - this._prevY) | |
} | |
, | |
r.getDeltaX = function() { | |
return this._x - this._prevX | |
} | |
, | |
r.getDeltaY = function() { | |
return this._y - this._prevY | |
} | |
, | |
r.setButton = function(t) { | |
this._button = t | |
} | |
, | |
r.getButton = function() { | |
return this._button | |
} | |
, | |
r.getLocationX = function() { | |
return this._x | |
} | |
, | |
r.getLocationY = function() { | |
return this._y | |
} | |
, | |
n.NONE = 0, | |
n.DOWN = 1, | |
n.UP = 2, | |
n.MOVE = 3, | |
n.SCROLL = 4, | |
n.BUTTON_LEFT = 0, | |
n.BUTTON_RIGHT = 2, | |
n.BUTTON_MIDDLE = 1, | |
n.BUTTON_4 = 3, | |
n.BUTTON_5 = 4, | |
n.BUTTON_6 = 5, | |
n.BUTTON_7 = 6, | |
n.BUTTON_8 = 7; | |
var s = function(t, e) { | |
cc.Event.call(this, cc.Event.TOUCH, e), | |
this._eventCode = 0, | |
this._touches = t || [], | |
this.touch = null, | |
this.currentTouch = null | |
}; | |
i.extend(s, cc.Event), | |
(r = s.prototype).getEventCode = function() { | |
return this._eventCode | |
} | |
, | |
r.getTouches = function() { | |
return this._touches | |
} | |
, | |
r._setEventCode = function(t) { | |
this._eventCode = t | |
} | |
, | |
r._setTouches = function(t) { | |
this._touches = t | |
} | |
, | |
r.setLocation = function(t, e) { | |
this.touch && this.touch.setTouchInfo(this.touch.getID(), t, e) | |
} | |
, | |
r.getLocation = function() { | |
return this.touch ? this.touch.getLocation() : cc.v2() | |
} | |
, | |
r.getLocationInView = function() { | |
return this.touch ? this.touch.getLocationInView() : cc.v2() | |
} | |
, | |
r.getPreviousLocation = function() { | |
return this.touch ? this.touch.getPreviousLocation() : cc.v2() | |
} | |
, | |
r.getStartLocation = function() { | |
return this.touch ? this.touch.getStartLocation() : cc.v2() | |
} | |
, | |
r.getID = function() { | |
return this.touch ? this.touch.getID() : null | |
} | |
, | |
r.getDelta = function() { | |
return this.touch ? this.touch.getDelta() : cc.v2() | |
} | |
, | |
r.getDeltaX = function() { | |
return this.touch ? this.touch.getDelta().x : 0 | |
} | |
, | |
r.getDeltaY = function() { | |
return this.touch ? this.touch.getDelta().y : 0 | |
} | |
, | |
r.getLocationX = function() { | |
return this.touch ? this.touch.getLocationX() : 0 | |
} | |
, | |
r.getLocationY = function() { | |
return this.touch ? this.touch.getLocationY() : 0 | |
} | |
, | |
s.MAX_TOUCHES = 5, | |
s.BEGAN = 0, | |
s.MOVED = 1, | |
s.ENDED = 2, | |
s.CANCELED = 3; | |
var a = function(t, e) { | |
cc.Event.call(this, cc.Event.ACCELERATION, e), | |
this.acc = t | |
}; | |
i.extend(a, cc.Event); | |
var o = function(t, e, i) { | |
cc.Event.call(this, cc.Event.KEYBOARD, i), | |
this.keyCode = t, | |
this.isPressed = e | |
}; | |
i.extend(o, cc.Event), | |
cc.Event.EventMouse = n, | |
cc.Event.EventTouch = s, | |
cc.Event.EventAcceleration = a, | |
cc.Event.EventKeyboard = o, | |
e.exports = cc.Event | |
} | |
), { | |
"../event/event": 135 | |
}], | |
130: [(function(t, e) { | |
"use strict"; | |
var i = 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 n = 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" | |
} | |
, r = function(t, e) { | |
this._onCustomEvent = e, | |
cc.EventListener.call(this, cc.EventListener.CUSTOM, t, this._callback) | |
}; | |
i.extend(r, cc.EventListener), | |
i.mixin(r.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 r(this._listenerID,this._onCustomEvent) | |
} | |
}); | |
var s = function() { | |
cc.EventListener.call(this, cc.EventListener.MOUSE, n.MOUSE, this._callback) | |
}; | |
i.extend(s, cc.EventListener), | |
i.mixin(s.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 s; | |
return t.onMouseDown = this.onMouseDown, | |
t.onMouseUp = this.onMouseUp, | |
t.onMouseMove = this.onMouseMove, | |
t.onMouseScroll = this.onMouseScroll, | |
t | |
}, | |
checkAvailable: function() { | |
return !0 | |
} | |
}); | |
var a = function() { | |
cc.EventListener.call(this, cc.EventListener.TOUCH_ONE_BY_ONE, n.TOUCH_ONE_BY_ONE, null), | |
this._claimedTouches = [] | |
}; | |
i.extend(a, cc.EventListener), | |
i.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; | |
return t.onTouchBegan = this.onTouchBegan, | |
t.onTouchMoved = this.onTouchMoved, | |
t.onTouchEnded = this.onTouchEnded, | |
t.onTouchCancelled = this.onTouchCancelled, | |
t.swallowTouches = this.swallowTouches, | |
t | |
}, | |
checkAvailable: function() { | |
return !!this.onTouchBegan | |
} | |
}); | |
var o = function() { | |
cc.EventListener.call(this, cc.EventListener.TOUCH_ALL_AT_ONCE, n.TOUCH_ALL_AT_ONCE, null) | |
}; | |
i.extend(o, cc.EventListener), | |
i.mixin(o.prototype, { | |
constructor: o, | |
onTouchesBegan: null, | |
onTouchesMoved: null, | |
onTouchesEnded: null, | |
onTouchesCancelled: null, | |
clone: function() { | |
var t = new o; | |
return t.onTouchesBegan = this.onTouchesBegan, | |
t.onTouchesMoved = this.onTouchesMoved, | |
t.onTouchesEnded = this.onTouchesEnded, | |
t.onTouchesCancelled = this.onTouchesCancelled, | |
t | |
}, | |
checkAvailable: function() { | |
return null !== this.onTouchesBegan || null !== this.onTouchesMoved || null !== this.onTouchesEnded || null !== this.onTouchesCancelled | |
} | |
}); | |
var c = function(t) { | |
this._onAccelerationEvent = t, | |
cc.EventListener.call(this, cc.EventListener.ACCELERATION, n.ACCELERATION, this._callback) | |
}; | |
i.extend(c, cc.EventListener), | |
i.mixin(c.prototype, { | |
constructor: c, | |
_onAccelerationEvent: null, | |
_callback: function(t) { | |
this._onAccelerationEvent(t.acc, t) | |
}, | |
checkAvailable: function() { | |
return !0 | |
}, | |
clone: function() { | |
return new c(this._onAccelerationEvent) | |
} | |
}); | |
var l = function() { | |
cc.EventListener.call(this, cc.EventListener.KEYBOARD, n.KEYBOARD, this._callback) | |
}; | |
i.extend(l, cc.EventListener), | |
i.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; | |
return t.onKeyPressed = this.onKeyPressed, | |
t.onKeyReleased = this.onKeyReleased, | |
t | |
}, | |
checkAvailable: function() { | |
return null !== this.onKeyPressed || null !== this.onKeyReleased | |
} | |
}), | |
cc.EventListener.create = function(t) { | |
var e = t.event; | |
delete t.event; | |
var i = null; | |
for (var n in e === cc.EventListener.TOUCH_ONE_BY_ONE ? i = new a : e === cc.EventListener.TOUCH_ALL_AT_ONCE ? i = new o : e === cc.EventListener.MOUSE ? i = new s : e === cc.EventListener.CUSTOM ? (i = new r(t.eventName,t.callback), | |
delete t.eventName, | |
delete t.callback) : e === cc.EventListener.KEYBOARD ? i = new l : e === cc.EventListener.ACCELERATION && (i = new c(t.callback), | |
delete t.callback), | |
t) | |
i[n] = t[n]; | |
return i | |
} | |
, | |
e.exports = cc.EventListener | |
} | |
), { | |
"../platform/js": 183 | |
}], | |
131: [(function(t, e) { | |
"use strict"; | |
var i = t("../platform/js"); | |
t("./CCEventListener"); | |
var n = cc.EventListener.ListenerID | |
, r = function() { | |
this._fixedListeners = [], | |
this._sceneGraphListeners = [], | |
this.gt0Index = 0 | |
}; | |
r.prototype = { | |
constructor: r, | |
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 s = function(t) { | |
var e = cc.Event | |
, i = t.type; | |
return i === e.ACCELERATION ? n.ACCELERATION : i === e.KEYBOARD ? n.KEYBOARD : i.startsWith(e.MOUSE) ? n.MOUSE : (i.startsWith(e.TOUCH), | |
"") | |
} | |
, a = { | |
DIRTY_NONE: 0, | |
DIRTY_FIXED_PRIORITY: 1, | |
DIRTY_SCENE_GRAPH_PRIORITY: 2, | |
DIRTY_ALL: 3, | |
_listenersMap: {}, | |
_priorityDirtyFlagMap: {}, | |
_nodeListenersMap: {}, | |
_toAddedListeners: [], | |
_toRemovedListeners: [], | |
_dirtyListeners: {}, | |
_inDispatch: 0, | |
_isEnabled: !1, | |
_currentTouch: null, | |
_currentTouchListener: null, | |
_internalCustomListenerIDs: [], | |
_setDirtyForNode: function(t) { | |
var e = this._nodeListenersMap[t._id]; | |
if (e) | |
for (var i = 0, n = e.length; i < n; i++) { | |
var r = e[i]._getListenerID(); | |
null == this._dirtyListeners[r] && (this._dirtyListeners[r] = !0) | |
} | |
if (t.childrenCount > 0) | |
for (var s = t._children, a = 0, o = s.length; a < o; a++) | |
this._setDirtyForNode(s[a]) | |
}, | |
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++) { | |
var s = r[i]; | |
s._setPaused(!0), | |
s._claimedTouches && s._claimedTouches.includes(this._currentTouch) && this._clearCurTouch() | |
} | |
if (!0 === e) { | |
var a = t._children; | |
for (i = 0, | |
n = a ? a.length : 0; i < n; i++) | |
this.pauseTarget(a[i], !0) | |
} | |
} | |
}, | |
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); | |
if (this._setDirtyForNode(t), | |
!0 === e) { | |
var s = t._children; | |
for (i = 0, | |
n = s ? s.length : 0; i < n; i++) | |
this.resumeTarget(s[i], !0) | |
} | |
} | |
}, | |
_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 r, | |
this._listenersMap[e] = i), | |
i.push(t), | |
0 === t._getFixedPriority()) { | |
this._setDirty(e, this.DIRTY_SCENE_GRAPH_PRIORITY); | |
var n = t._getSceneGraphPriority(); | |
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() { | |
var t = this._dirtyListeners; | |
for (var e in t) | |
this._setDirty(e, this.DIRTY_SCENE_GRAPH_PRIORITY); | |
this._dirtyListeners = {} | |
}, | |
_removeAllListenersInVector: function(t) { | |
if (t) | |
for (var e, i = t.length - 1; i >= 0; i--) | |
(e = t[i])._setRegistered(!1), | |
null != e._getSceneGraphPriority() && (this._dissociateNodeAndEventListener(e._getSceneGraphPriority(), e), | |
e._setSceneGraphPriority(null)), | |
0 === this._inDispatch && cc.js.array.removeAt(t, 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], | |
this._inDispatch || (i.clear(), | |
delete this._listenersMap[t]) | |
} | |
var s, a = this._toAddedListeners; | |
for (e = a.length - 1; e >= 0; e--) | |
(s = a[e]) && s._getListenerID() === t && cc.js.array.removeAt(a, e) | |
}, | |
_sortEventListeners: function(t) { | |
var e = this.DIRTY_NONE | |
, i = this._priorityDirtyFlagMap; | |
i[t] && (e = i[t]), | |
e !== this.DIRTY_NONE && (i[t] = this.DIRTY_NONE, | |
e & this.DIRTY_FIXED_PRIORITY && this._sortListenersOfFixedPriority(t), | |
e & this.DIRTY_SCENE_GRAPH_PRIORITY && cc.director.getScene() && this._sortListenersOfSceneGraphPriority(t)) | |
}, | |
_sortListenersOfSceneGraphPriority: function(t) { | |
var e = this._getListeners(t); | |
if (e) { | |
var i = e.getSceneGraphPriorityListeners(); | |
i && 0 !== i.length && e.getSceneGraphPriorityListeners().sort(this._sortEventListenersOfSceneGraphPriorityDes) | |
} | |
}, | |
_sortEventListenersOfSceneGraphPriorityDes: function(t, e) { | |
var i = t._getSceneGraphPriority() | |
, n = e._getSceneGraphPriority(); | |
if (!n || !n._activeInHierarchy || null === n._parent) | |
return -1; | |
if (!i || !i._activeInHierarchy || null === i._parent) | |
return 1; | |
for (var r = i, s = n, a = !1; r._parent._id !== s._parent._id; ) | |
r = null === r._parent._parent ? (a = !0) && n : r._parent, | |
s = null === s._parent._parent ? (a = !0) && i : s._parent; | |
if (r._id === s._id) { | |
if (r._id === n._id) | |
return -1; | |
if (r._id === i._id) | |
return 1 | |
} | |
return a ? r._localZOrder - s._localZOrder : s._localZOrder - r._localZOrder | |
}, | |
_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(), a = this._toRemovedListeners; | |
if (s) | |
for (e = s.length - 1; e >= 0; e--) | |
(i = s[e])._isRegistered() || (cc.js.array.removeAt(s, e), | |
-1 !== (n = a.indexOf(i)) && a.splice(n, 1)); | |
if (r) | |
for (e = r.length - 1; e >= 0; e--) | |
(i = r[e])._isRegistered() || (cc.js.array.removeAt(r, e), | |
-1 !== (n = a.indexOf(i)) && a.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) | |
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() { | |
if (!(this._inDispatch > 1)) { | |
var t; | |
(t = this._listenersMap[n.TOUCH_ONE_BY_ONE]) && this._onUpdateListeners(t), | |
(t = this._listenersMap[n.TOUCH_ALL_AT_ONCE]) && this._onUpdateListeners(t); | |
var e = this._toAddedListeners; | |
if (0 !== e.length) { | |
for (var i = 0, r = e.length; i < r; i++) | |
this._forceAddEventListener(e[i]); | |
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(), a = n.getSceneGraphPriorityListeners(); | |
a && -1 !== (r = a.indexOf(i)) && a.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, o = i.getEventCode(), c = cc.Event.EventTouch; | |
if (o === c.BEGAN) { | |
if (!cc.macro.ENABLE_MULTI_TOUCH && a._currentTouch) { | |
var l = a._currentTouchListener._node; | |
if (l && l.activeInHierarchy) | |
return !1 | |
} | |
t.onTouchBegan && (s = t.onTouchBegan(n, i)) && t._registered && (t._claimedTouches.push(n), | |
a._currentTouchListener = t, | |
a._currentTouch = n) | |
} else if (t._claimedTouches.length > 0 && -1 !== (r = t._claimedTouches.indexOf(n))) { | |
if (s = !0, | |
!cc.macro.ENABLE_MULTI_TOUCH && a._currentTouch && a._currentTouch !== n) | |
return !1; | |
o === c.MOVED && t.onTouchMoved ? t.onTouchMoved(n, i) : o === c.ENDED ? (t.onTouchEnded && t.onTouchEnded(n, i), | |
t._registered && t._claimedTouches.splice(r, 1), | |
a._clearCurTouch()) : o === c.CANCELED && (t.onTouchCancelled && t.onTouchCancelled(n, i), | |
t._registered && t._claimedTouches.splice(r, 1), | |
a._clearCurTouch()) | |
} | |
return i.isStopped() ? (a._updateTouchListeners(i), | |
!0) : !(!s || !t.swallowTouches || (e.needsMutableSet && e.touches.splice(n, 1), | |
0)) | |
}, | |
_dispatchTouchEvent: function(t) { | |
this._sortEventListeners(n.TOUCH_ONE_BY_ONE), | |
this._sortEventListeners(n.TOUCH_ALL_AT_ONCE); | |
var e = this._getListeners(n.TOUCH_ONE_BY_ONE) | |
, i = this._getListeners(n.TOUCH_ALL_AT_ONCE); | |
if (null !== e || null !== i) { | |
var r = t.getTouches() | |
, s = cc.js.array.copy(r) | |
, a = { | |
event: t, | |
needsMutableSet: e && i, | |
touches: s, | |
selTouch: null | |
}; | |
if (e) | |
for (var o = 0; o < r.length; o++) | |
t.currentTouch = r[o], | |
t._propagationStopped = t._propagationImmediateStopped = !1, | |
this._dispatchEventToListeners(e, this._onTouchEventCallback, a); | |
i && s.length > 0 && (this._dispatchEventToListeners(i, this._onTouchesEventCallback, { | |
event: t, | |
touches: s | |
}), | |
t.isStopped()) || 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(); | |
return 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.CANCELED && t.onTouchesCancelled && t.onTouchesCancelled(r, n), | |
!!n.isStopped() && (a._updateTouchListeners(n), | |
!0) | |
}, | |
_associateNodeAndEventListener: function(t, e) { | |
var i = this._nodeListenersMap[t._id]; | |
i || (i = [], | |
this._nodeListenersMap[t._id] = i), | |
i.push(e) | |
}, | |
_dissociateNodeAndEventListener: function(t, e) { | |
var i = this._nodeListenersMap[t._id]; | |
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, a = t.getFixedPriorityListeners(), o = t.getSceneGraphPriorityListeners(), c = 0; | |
if (a && 0 !== a.length) | |
for (; c < t.gt0Index; ++c) | |
if ((r = a[c]).isEnabled() && !r._isPaused() && r._isRegistered() && e(r, i)) { | |
s = !0; | |
break | |
} | |
if (o && !s) | |
for (n = 0; n < o.length; n++) | |
if ((r = o[n]).isEnabled() && !r._isPaused() && r._isRegistered() && e(r, i)) { | |
s = !0; | |
break | |
} | |
if (a && !s) | |
for (; c < a.length; ++c) | |
if ((r = a[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] | |
}, | |
_sortNumberAsc: function(t, e) { | |
return t - e | |
}, | |
hasEventListener: function(t) { | |
return !!this._getListeners(t) | |
}, | |
addListener: function(t, e) { | |
if (cc.js.isNumber(e) || e instanceof cc._BaseNode) { | |
if (t instanceof cc.EventListener) { | |
if (t._isRegistered()) | |
return | |
} else | |
t = cc.EventListener.create(t); | |
if (t.checkAvailable()) { | |
if (cc.js.isNumber(e)) { | |
if (0 === e) | |
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 | |
} | |
} | |
}, | |
addCustomListener: function(t, e) { | |
var i = new cc.EventListener.create({ | |
event: cc.EventListener.CUSTOM, | |
eventName: t, | |
callback: e | |
}); | |
return this.addListener(i, 1), | |
i | |
}, | |
removeListener: function(t) { | |
if (null != t) { | |
var e, i = this._listenersMap; | |
for (var n in i) { | |
var r = i[n] | |
, s = r.getFixedPriorityListeners() | |
, a = r.getSceneGraphPriorityListeners(); | |
if ((e = this._removeListenerInVector(a, t)) ? this._setDirty(t._getListenerID(), this.DIRTY_SCENE_GRAPH_PRIORITY) : (e = this._removeListenerInVector(s, t)) && this._setDirty(t._getListenerID(), this.DIRTY_FIXED_PRIORITY), | |
r.empty() && (delete this._priorityDirtyFlagMap[t._getListenerID()], | |
delete i[n]), | |
e) | |
break | |
} | |
if (!e) | |
for (var o = this._toAddedListeners, c = o.length - 1; c >= 0; c--) { | |
var l = o[c]; | |
if (l === t) { | |
cc.js.array.removeAt(o, c), | |
l._setRegistered(!1); | |
break | |
} | |
} | |
this._currentTouchListener === t && this._clearCurTouch() | |
} | |
}, | |
_clearCurTouch: function() { | |
this._currentTouchListener = null, | |
this._currentTouch = null | |
}, | |
_removeListenerInCallback: function(t, e) { | |
if (null == t) | |
return !1; | |
for (var i = t.length - 1; i >= 0; i--) { | |
var n = t[i]; | |
if (n._onCustomEvent === e || n._onEvent === e) | |
return n._setRegistered(!1), | |
null != n._getSceneGraphPriority() && (this._dissociateNodeAndEventListener(n._getSceneGraphPriority(), n), | |
n._setSceneGraphPriority(null)), | |
0 === this._inDispatch ? cc.js.array.removeAt(t, i) : this._toRemovedListeners.push(n), | |
!0 | |
} | |
return !1 | |
}, | |
_removeListenerInVector: function(t, e) { | |
if (null == t) | |
return !1; | |
for (var i = t.length - 1; i >= 0; i--) { | |
var n = t[i]; | |
if (n === e) | |
return n._setRegistered(!1), | |
null != n._getSceneGraphPriority() && (this._dissociateNodeAndEventListener(n._getSceneGraphPriority(), n), | |
n._setSceneGraphPriority(null)), | |
0 === this._inDispatch ? cc.js.array.removeAt(t, i) : this._toRemovedListeners.push(n), | |
!0 | |
} | |
return !1 | |
}, | |
removeListeners: function(t, e) { | |
var i = this; | |
if (cc.js.isNumber(t) || t instanceof cc._BaseNode) | |
if (void 0 !== t._id) { | |
var r, s = i._nodeListenersMap[t._id]; | |
if (s) { | |
var a = cc.js.array.copy(s); | |
for (r = 0; r < a.length; r++) | |
i.removeListener(a[r]); | |
delete i._nodeListenersMap[t._id] | |
} | |
var o = i._toAddedListeners; | |
for (r = 0; r < o.length; ) { | |
var c = o[r]; | |
c._getSceneGraphPriority() === t ? (c._setSceneGraphPriority(null), | |
c._setRegistered(!1), | |
o.splice(r, 1)) : ++r | |
} | |
if (!0 === e) { | |
var l, h = t.children; | |
for (r = 0, | |
l = h.length; r < l; r++) | |
i.removeListeners(h[r], !0) | |
} | |
} else | |
t === cc.EventListener.TOUCH_ONE_BY_ONE ? i._removeListenersForListenerID(n.TOUCH_ONE_BY_ONE) : t === cc.EventListener.TOUCH_ALL_AT_ONCE ? i._removeListenersForListenerID(n.TOUCH_ALL_AT_ONCE) : t === cc.EventListener.MOUSE ? i._removeListenersForListenerID(n.MOUSE) : t === cc.EventListener.ACCELERATION ? i._removeListenersForListenerID(n.ACCELERATION) : t === cc.EventListener.KEYBOARD && i._removeListenersForListenerID(n.KEYBOARD) | |
}, | |
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 && -1 !== r.indexOf(t)) | |
return t._getSceneGraphPriority(), | |
void (t._getFixedPriority() !== e && (t._setFixedPriority(e), | |
this._setDirty(t._getListenerID(), this.DIRTY_FIXED_PRIORITY))) | |
} | |
} | |
}, | |
setEnabled: function(t) { | |
this._isEnabled = t | |
}, | |
isEnabled: function() { | |
return this._isEnabled | |
}, | |
dispatchEvent: function(t) { | |
if (this._isEnabled && (this._updateDirtyFlagForSceneGraph(), | |
this._inDispatch++, | |
t && t.getType)) { | |
if (t.getType().startsWith(cc.Event.TOUCH)) | |
return this._dispatchTouchEvent(t), | |
void this._inDispatch--; | |
var e = s(t); | |
this._sortEventListeners(e); | |
var i = this._listenersMap[e]; | |
null != i && (this._dispatchEventToListeners(i, this._onListenerCallback, t), | |
this._onUpdateListeners(i)), | |
this._inDispatch-- | |
} | |
}, | |
_onListenerCallback: function(t, e) { | |
return e.currentTarget = t._target, | |
t._onEvent(e), | |
e.isStopped() | |
}, | |
dispatchCustomEvent: function(t, e) { | |
var i = new cc.Event.EventCustom(t); | |
i.setUserData(e), | |
this.dispatchEvent(i) | |
} | |
}; | |
i.get(cc, "eventManager", (function() { | |
return a | |
} | |
)), | |
e.exports = cc.internal.eventManager = a | |
} | |
), { | |
"../platform/js": 183, | |
"./CCEventListener": 130 | |
}], | |
132: [(function() { | |
"use strict"; | |
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, | |
this._startPointCaptured || (this._startPoint = cc.v2(this._point), | |
cc.view._convertPointWithScale(this._startPoint), | |
this._startPointCaptured = !0) | |
}, | |
_setPoint: function(t, e) { | |
void 0 === e ? (this._point.x = t.x, | |
this._point.y = t.y) : (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) | |
} | |
} | |
} | |
), {}], | |
133: [(function(t, e) { | |
"use strict"; | |
t("./CCEvent"), | |
t("./CCTouch"), | |
t("./CCEventListener"); | |
var i = t("./CCEventManager"); | |
e.exports = i | |
} | |
), { | |
"./CCEvent": 129, | |
"./CCEventListener": 130, | |
"./CCEventManager": 131, | |
"./CCTouch": 132 | |
}], | |
134: [(function(t, e) { | |
"use strict"; | |
var i = t("../platform/js") | |
, n = t("../platform/callbacks-invoker") | |
, r = i.array | |
, s = r.fastRemove | |
, a = r.fastRemoveAll; | |
function o() { | |
n.call(this) | |
} | |
i.extend(o, n); | |
var c = o.prototype; | |
c.__on = c.on, | |
c.on = function(t, e, i, n) { | |
if (e) | |
return this.hasEventListener(t, e, i) || (this.__on(t, e, i, n), | |
i && i.__eventTargets && i.__eventTargets.push(this)), | |
e | |
} | |
, | |
c.__off = c.off, | |
c.off = function(t, e, i) { | |
if (e) { | |
var n = this.__off(t, e, i); | |
return n && i && i.__eventTargets && s(i.__eventTargets, this), | |
n | |
} | |
var r = this._callbackTable[t]; | |
if (!r) | |
return !1; | |
for (var a = r.callbackInfos, o = a.length, c = 0; c < o; ++c) { | |
var l = a[c] && a[c].target; | |
l && l.__eventTargets && s(l.__eventTargets, this) | |
} | |
return this.removeAll(t), | |
a.length < o | |
} | |
, | |
c.targetOff = function(t) { | |
this.removeAll(t), | |
t && t.__eventTargets && a(t.__eventTargets, this) | |
} | |
, | |
c.once = function(t, e, i) { | |
this.on(t, e, i, !0) | |
} | |
, | |
c.dispatchEvent = function(t) { | |
this.emit(t.type, t) | |
} | |
, | |
c.clear = function() { | |
for (var t in this._callbackTable) | |
this.off(t) | |
} | |
, | |
cc.EventTarget = e.exports = o | |
} | |
), { | |
"../platform/callbacks-invoker": 175, | |
"../platform/js": 183 | |
}], | |
135: [(function(t, e) { | |
"use strict"; | |
var i = 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 n = function(t, e) { | |
cc.Event.call(this, t, e), | |
this.detail = null | |
}; | |
i.extend(n, cc.Event), | |
n.prototype.reset = n, | |
n.prototype.setUserData = function(t) { | |
this.detail = t | |
} | |
, | |
n.prototype.getUserData = function() { | |
return this.detail | |
} | |
, | |
n.prototype.getEventName = cc.Event.prototype.getType; | |
var r = new i.Pool(10); | |
n.put = function(t) { | |
r.put(t) | |
} | |
, | |
n.get = function(t, e) { | |
var i = r._get(); | |
return i ? i.reset(t, e) : i = new n(t,e), | |
i | |
} | |
, | |
cc.Event.EventCustom = n, | |
e.exports = cc.Event | |
} | |
), { | |
"../platform/js": 183 | |
}], | |
136: [(function(t) { | |
"use strict"; | |
t("./event"), | |
t("./event-target"), | |
t("./system-event") | |
} | |
), { | |
"./event": 135, | |
"./event-target": 134, | |
"./system-event": 137 | |
}], | |
137: [(function(t, e) { | |
"use strict"; | |
var i = t("../event/event-target") | |
, n = t("../event-manager") | |
, r = t("../platform/CCInputManager") | |
, s = cc.Enum({ | |
KEY_DOWN: "keydown", | |
KEY_UP: "keyup", | |
DEVICEMOTION: "devicemotion" | |
}) | |
, a = null | |
, o = null | |
, c = cc.Class({ | |
name: "SystemEvent", | |
extends: i, | |
statics: { | |
EventType: s | |
}, | |
setAccelerometerEnabled: function(t) { | |
t && window.DeviceMotionEvent && "function" == typeof DeviceMotionEvent.requestPermission ? DeviceMotionEvent.requestPermission().then((function(t) { | |
r.setAccelerometerEnabled("granted" === t) | |
} | |
)) : r.setAccelerometerEnabled(t) | |
}, | |
setAccelerometerInterval: function(t) { | |
r.setAccelerometerInterval(t) | |
}, | |
on: function(t, e, i, r) { | |
this._super(t, e, i, r), | |
t !== s.KEY_DOWN && t !== s.KEY_UP || (a || (a = cc.EventListener.create({ | |
event: cc.EventListener.KEYBOARD, | |
onKeyPressed: function(t, e) { | |
e.type = s.KEY_DOWN, | |
cc.systemEvent.dispatchEvent(e) | |
}, | |
onKeyReleased: function(t, e) { | |
e.type = s.KEY_UP, | |
cc.systemEvent.dispatchEvent(e) | |
} | |
})), | |
n.hasEventListener(cc.EventListener.ListenerID.KEYBOARD) || n.addListener(a, 1)), | |
t === s.DEVICEMOTION && (o || (o = cc.EventListener.create({ | |
event: cc.EventListener.ACCELERATION, | |
callback: function(t, e) { | |
e.type = s.DEVICEMOTION, | |
cc.systemEvent.dispatchEvent(e) | |
} | |
})), | |
n.hasEventListener(cc.EventListener.ListenerID.ACCELERATION) || n.addListener(o, 1)) | |
}, | |
off: function(t, e, i) { | |
if (this._super(t, e, i), | |
a && (t === s.KEY_DOWN || t === s.KEY_UP)) { | |
var r = this.hasEventListener(s.KEY_DOWN) | |
, c = this.hasEventListener(s.KEY_UP); | |
r || c || n.removeListener(a) | |
} | |
o && t === s.DEVICEMOTION && (this.hasEventListener(s.DEVICEMOTION) || n.removeListener(o)) | |
} | |
}); | |
cc.SystemEvent = e.exports = c, | |
cc.systemEvent = new cc.SystemEvent | |
} | |
), { | |
"../event-manager": 133, | |
"../event/event-target": 134, | |
"../platform/CCInputManager": 166 | |
}], | |
138: [(function(t, e, i) { | |
"use strict"; | |
i.__esModule = !0, | |
i.default = void 0; | |
var n = a(t("../value-types/vec3")) | |
, r = a(t("../value-types/mat3")) | |
, s = a(t("./enums")); | |
function a(t) { | |
return t && t.__esModule ? t : { | |
default: t | |
} | |
} | |
var o = new n.default | |
, c = new n.default | |
, l = new r.default | |
, h = function(t, e, i) { | |
var r = l.m | |
, s = i.m; | |
r[0] = Math.abs(s[0]), | |
r[1] = Math.abs(s[1]), | |
r[2] = Math.abs(s[2]), | |
r[3] = Math.abs(s[4]), | |
r[4] = Math.abs(s[5]), | |
r[5] = Math.abs(s[6]), | |
r[6] = Math.abs(s[8]), | |
r[7] = Math.abs(s[9]), | |
r[8] = Math.abs(s[10]), | |
n.default.transformMat3(t, e, l) | |
} | |
, u = (function() { | |
function t(t, e, i, r, a, o) { | |
this.center = void 0, | |
this.halfExtents = void 0, | |
this._type = void 0, | |
this._type = s.default.SHAPE_AABB, | |
this.center = new n.default(t,e,i), | |
this.halfExtents = new n.default(r,a,o) | |
} | |
t.create = function(e, i, n, r, s, a) { | |
return new t(e,i,n,r,s,a) | |
} | |
, | |
t.clone = function(e) { | |
return new t(e.center.x,e.center.y,e.center.z,e.halfExtents.x,e.halfExtents.y,e.halfExtents.z) | |
} | |
, | |
t.copy = function(t, e) { | |
return n.default.copy(t.center, e.center), | |
n.default.copy(t.halfExtents, e.halfExtents), | |
t | |
} | |
, | |
t.fromPoints = function(t, e, i) { | |
return n.default.scale(t.center, n.default.add(o, e, i), .5), | |
n.default.scale(t.halfExtents, n.default.sub(c, i, e), .5), | |
t | |
} | |
, | |
t.set = function(t, e, i, r, s, a, o) { | |
return n.default.set(t.center, e, i, r), | |
n.default.set(t.halfExtents, s, a, o), | |
t | |
} | |
; | |
var e = t.prototype; | |
return e.getBoundary = function(t, e) { | |
n.default.sub(t, this.center, this.halfExtents), | |
n.default.add(e, this.center, this.halfExtents) | |
} | |
, | |
e.transform = function(t, e, i, r, s) { | |
s || (s = this), | |
n.default.transformMat4(s.center, this.center, t), | |
h(s.halfExtents, this.halfExtents, t) | |
} | |
, | |
t | |
} | |
)(); | |
i.default = u, | |
e.exports = i.default | |
} | |
), { | |
"../value-types/mat3": 252, | |
"../value-types/vec3": 261, | |
"./enums": 140 | |
}], | |
139: [(function(t, e, i) { | |
"use strict"; | |
i.__esModule = !0, | |
i.point_plane = f, | |
i.pt_point_aabb = function(t, e, i) { | |
return n.Vec3.copy(t, e), | |
n.Vec3.subtract(c, i.center, i.halfExtents), | |
n.Vec3.add(l, i.center, i.halfExtents), | |
t.x = t.x < c.x ? c.x : t.x, | |
t.y = t.y < c.x ? c.y : t.y, | |
t.z = t.z < c.x ? c.z : t.z, | |
t.x = t.x > l.x ? l.x : t.x, | |
t.y = t.y > l.x ? l.y : t.y, | |
t.z = t.z > l.x ? l.z : t.z, | |
t | |
} | |
, | |
i.pt_point_obb = function(t, e, i) { | |
var c = i.orientation.m; | |
n.Vec3.set(r, c[0], c[1], c[2]), | |
n.Vec3.set(s, c[3], c[4], c[5]), | |
n.Vec3.set(a, c[6], c[7], c[8]), | |
h[0] = r, | |
h[1] = s, | |
h[2] = a, | |
u[0] = i.halfExtents.x, | |
u[1] = i.halfExtents.y, | |
u[2] = i.halfExtents.z, | |
n.Vec3.subtract(o, e, i.center), | |
n.Vec3.set(t, i.center.x, i.center.y, i.center.z); | |
for (var l = 0; l < 3; l++) { | |
var f = n.Vec3.dot(o, h[l]); | |
f > u[l] && (f = u[l]), | |
f < -u[l] && (f = -u[l]), | |
t.x += f * h[l].x, | |
t.y += f * h[l].y, | |
t.z += f * h[l].z | |
} | |
return t | |
} | |
, | |
i.pt_point_plane = function(t, e, i) { | |
var r = f(e, i); | |
return n.Vec3.subtract(t, e, n.Vec3.multiplyScalar(t, i.n, r)) | |
} | |
; | |
var n = t("../value-types") | |
, r = new n.Vec3 | |
, s = new n.Vec3 | |
, a = new n.Vec3 | |
, o = new n.Vec3 | |
, c = new n.Vec3 | |
, l = new n.Vec3 | |
, h = [, , , ] | |
, u = [, , , ]; | |
function f(t, e) { | |
return n.Vec3.dot(e.n, t) - e.d | |
} | |
} | |
), { | |
"../value-types": 251 | |
}], | |
140: [(function(t, e, i) { | |
"use strict"; | |
i.__esModule = !0, | |
i.default = void 0, | |
i.default = { | |
SHAPE_RAY: 1, | |
SHAPE_LINE: 2, | |
SHAPE_SPHERE: 4, | |
SHAPE_AABB: 8, | |
SHAPE_OBB: 16, | |
SHAPE_PLANE: 32, | |
SHAPE_TRIANGLE: 64, | |
SHAPE_FRUSTUM: 128, | |
SHAPE_FRUSTUM_ACCURATE: 256 | |
}, | |
e.exports = i.default | |
} | |
), {}], | |
141: [(function(t, e, i) { | |
"use strict"; | |
i.__esModule = !0, | |
i.default = void 0; | |
var n = t("../value-types") | |
, r = a(t("./enums")) | |
, s = a(t("./plane")); | |
function a(t) { | |
return t && t.__esModule ? t : { | |
default: t | |
} | |
} | |
function o(t, e) { | |
for (var i = 0; i < e.length; i++) { | |
var n = e[i]; | |
n.enumerable = n.enumerable || !1, | |
n.configurable = !0, | |
"value"in n && (n.writable = !0), | |
Object.defineProperty(t, n.key, n) | |
} | |
} | |
var c = [, , , , , , , , ]; | |
c[0] = new n.Vec3(1,1,1), | |
c[1] = new n.Vec3(-1,1,1), | |
c[2] = new n.Vec3(-1,-1,1), | |
c[3] = new n.Vec3(1,-1,1), | |
c[4] = new n.Vec3(1,1,-1), | |
c[5] = new n.Vec3(-1,1,-1), | |
c[6] = new n.Vec3(-1,-1,-1), | |
c[7] = new n.Vec3(1,-1,-1); | |
var l, h = (function() { | |
function t() { | |
this.planes = void 0, | |
this.vertices = void 0, | |
this._type = void 0, | |
this._type = r.default.SHAPE_FRUSTUM, | |
this.planes = [, , , , , , ]; | |
for (var t = 0; t < 6; ++t) | |
this.planes[t] = s.default.create(0, 0, 0, 0); | |
this.vertices = [, , , , , , , , ]; | |
for (var e = 0; e < 8; ++e) | |
this.vertices[e] = new n.Vec3 | |
} | |
t.create = function() { | |
return new t | |
} | |
, | |
t.clone = function(e) { | |
return t.copy(new t, e) | |
} | |
, | |
t.copy = function(t, e) { | |
t._type = e._type; | |
for (var i = 0; i < 6; ++i) | |
s.default.copy(t.planes[i], e.planes[i]); | |
for (var r = 0; r < 8; ++r) | |
n.Vec3.copy(t.vertices[r], e.vertices[r]); | |
return t | |
} | |
; | |
var e, i, a = t.prototype; | |
return a.update = function(t, e) { | |
var i = t.m; | |
if (n.Vec3.set(this.planes[0].n, i[3] + i[0], i[7] + i[4], i[11] + i[8]), | |
this.planes[0].d = -(i[15] + i[12]), | |
n.Vec3.set(this.planes[1].n, i[3] - i[0], i[7] - i[4], i[11] - i[8]), | |
this.planes[1].d = -(i[15] - i[12]), | |
n.Vec3.set(this.planes[2].n, i[3] + i[1], i[7] + i[5], i[11] + i[9]), | |
this.planes[2].d = -(i[15] + i[13]), | |
n.Vec3.set(this.planes[3].n, i[3] - i[1], i[7] - i[5], i[11] - i[9]), | |
this.planes[3].d = -(i[15] - i[13]), | |
n.Vec3.set(this.planes[4].n, i[3] + i[2], i[7] + i[6], i[11] + i[10]), | |
this.planes[4].d = -(i[15] + i[14]), | |
n.Vec3.set(this.planes[5].n, i[3] - i[2], i[7] - i[6], i[11] - i[10]), | |
this.planes[5].d = -(i[15] - i[14]), | |
this._type === r.default.SHAPE_FRUSTUM_ACCURATE) { | |
for (var s = 0; s < 6; s++) { | |
var a = this.planes[s] | |
, o = 1 / a.n.length(); | |
n.Vec3.multiplyScalar(a.n, a.n, o), | |
a.d *= o | |
} | |
for (var l = 0; l < 8; l++) | |
n.Vec3.transformMat4(this.vertices[l], c[l], e) | |
} | |
} | |
, | |
a.transform = function(t) { | |
if (this._type === r.default.SHAPE_FRUSTUM_ACCURATE) { | |
for (var e = 0; e < 8; e++) | |
n.Vec3.transformMat4(this.vertices[e], this.vertices[e], t); | |
s.default.fromPoints(this.planes[0], this.vertices[1], this.vertices[5], this.vertices[6]), | |
s.default.fromPoints(this.planes[1], this.vertices[3], this.vertices[7], this.vertices[4]), | |
s.default.fromPoints(this.planes[2], this.vertices[6], this.vertices[7], this.vertices[3]), | |
s.default.fromPoints(this.planes[3], this.vertices[0], this.vertices[4], this.vertices[5]), | |
s.default.fromPoints(this.planes[4], this.vertices[2], this.vertices[3], this.vertices[0]), | |
s.default.fromPoints(this.planes[0], this.vertices[7], this.vertices[6], this.vertices[5]) | |
} | |
} | |
, | |
e = t, | |
(i = [{ | |
key: "accurate", | |
set: function(t) { | |
this._type = t ? r.default.SHAPE_FRUSTUM_ACCURATE : r.default.SHAPE_FRUSTUM | |
} | |
}]) && o(e.prototype, i), | |
Object.defineProperty(e, "prototype", { | |
writable: !1 | |
}), | |
t | |
} | |
)(); | |
i.default = h, | |
h.createOrtho = (l = new n.Vec3, | |
function(t, e, i, r, a, o) { | |
var c = e / 2 | |
, h = i / 2; | |
n.Vec3.set(l, c, h, r), | |
n.Vec3.transformMat4(t.vertices[0], l, o), | |
n.Vec3.set(l, -c, h, r), | |
n.Vec3.transformMat4(t.vertices[1], l, o), | |
n.Vec3.set(l, -c, -h, r), | |
n.Vec3.transformMat4(t.vertices[2], l, o), | |
n.Vec3.set(l, c, -h, r), | |
n.Vec3.transformMat4(t.vertices[3], l, o), | |
n.Vec3.set(l, c, h, a), | |
n.Vec3.transformMat4(t.vertices[4], l, o), | |
n.Vec3.set(l, -c, h, a), | |
n.Vec3.transformMat4(t.vertices[5], l, o), | |
n.Vec3.set(l, -c, -h, a), | |
n.Vec3.transformMat4(t.vertices[6], l, o), | |
n.Vec3.set(l, c, -h, a), | |
n.Vec3.transformMat4(t.vertices[7], l, o), | |
s.default.fromPoints(t.planes[0], t.vertices[1], t.vertices[6], t.vertices[5]), | |
s.default.fromPoints(t.planes[1], t.vertices[3], t.vertices[4], t.vertices[7]), | |
s.default.fromPoints(t.planes[2], t.vertices[6], t.vertices[3], t.vertices[7]), | |
s.default.fromPoints(t.planes[3], t.vertices[0], t.vertices[5], t.vertices[4]), | |
s.default.fromPoints(t.planes[4], t.vertices[2], t.vertices[0], t.vertices[3]), | |
s.default.fromPoints(t.planes[0], t.vertices[7], t.vertices[5], t.vertices[6]) | |
} | |
), | |
e.exports = i.default | |
} | |
), { | |
"../value-types": 251, | |
"./enums": 140, | |
"./plane": 146 | |
}], | |
142: [(function(t, e, i) { | |
"use strict"; | |
i.__esModule = !0; | |
var n = { | |
enums: !0, | |
Triangle: !0, | |
Aabb: !0, | |
Ray: !0, | |
intersect: !0, | |
Sphere: !0, | |
Obb: !0, | |
Frustum: !0, | |
Line: !0, | |
Plane: !0 | |
}; | |
i.intersect = i.enums = i.Triangle = i.Sphere = i.Ray = i.Plane = i.Obb = i.Line = i.Frustum = i.Aabb = void 0; | |
var r = p(t("./enums")); | |
i.enums = r.default; | |
var s = p(t("./triangle")); | |
i.Triangle = s.default; | |
var a = p(t("./aabb")); | |
i.Aabb = a.default; | |
var o = p(t("./ray")); | |
i.Ray = o.default; | |
var c = p(t("./intersect")); | |
i.intersect = c.default; | |
var l = p(t("./sphere")); | |
i.Sphere = l.default; | |
var h = p(t("./obb")); | |
i.Obb = h.default; | |
var u = p(t("./frustum")); | |
i.Frustum = u.default; | |
var f = p(t("./line")); | |
i.Line = f.default; | |
var d = p(t("./plane")); | |
i.Plane = d.default; | |
var _ = t("./distance"); | |
function p(t) { | |
return t && t.__esModule ? t : { | |
default: t | |
} | |
} | |
Object.keys(_).forEach((function(t) { | |
"default" !== t && "__esModule" !== t && (Object.prototype.hasOwnProperty.call(n, t) || t in i && i[t] === _[t] || (i[t] = _[t])) | |
} | |
)), | |
cc.geomUtils = e.exports | |
} | |
), { | |
"./aabb": 138, | |
"./distance": 139, | |
"./enums": 140, | |
"./frustum": 141, | |
"./intersect": 143, | |
"./line": 144, | |
"./obb": 145, | |
"./plane": 146, | |
"./ray": 147, | |
"./sphere": 148, | |
"./triangle": 149 | |
}], | |
143: [(function(t, e, i) { | |
"use strict"; | |
i.__esModule = !0, | |
i.default = void 0; | |
var n = f(t("../../renderer/gfx")) | |
, r = f(t("../../renderer/memop/recycle-pool")) | |
, s = t("../value-types") | |
, a = f(t("./aabb")) | |
, o = (function(t) { | |
if (t && t.__esModule) | |
return t; | |
if (null === t || "object" != typeof t && "function" != typeof t) | |
return { | |
default: t | |
}; | |
var e = u(void 0); | |
if (e && e.has(t)) | |
return e.get(t); | |
var i = {} | |
, n = Object.defineProperty && Object.getOwnPropertyDescriptor; | |
for (var r in t) | |
if ("default" !== r && Object.prototype.hasOwnProperty.call(t, r)) { | |
var s = n ? Object.getOwnPropertyDescriptor(t, r) : null; | |
s && (s.get || s.set) ? Object.defineProperty(i, r, s) : i[r] = t[r] | |
} | |
return i.default = t, | |
e && e.set(t, i), | |
i | |
} | |
)(t("./distance")) | |
, c = f(t("./enums")) | |
, l = f(t("./ray")) | |
, h = f(t("./triangle")); | |
function u(t) { | |
if ("function" != typeof WeakMap) | |
return null; | |
var e = new WeakMap | |
, i = new WeakMap; | |
return (u = function(t) { | |
return t ? i : e | |
} | |
)(t) | |
} | |
function f(t) { | |
return t && t.__esModule ? t : { | |
default: t | |
} | |
} | |
var d, _, p, v, g, m, y, T, E, A, x, C, b, S, R, M = (function() { | |
var t = h.default.create() | |
, e = Infinity; | |
function i(t, e, i, n) { | |
s.Vec3.set(t, e[i * n], e[i * n + 1], e[i * n + 2]) | |
} | |
return function(r, s) { | |
e = Infinity; | |
for (var a = s._subMeshes, o = 0; o < a.length; o++) | |
if (a[o]._primitiveType === n.default.PT_TRIANGLES) | |
for (var c = s._subDatas[o] || s._subDatas[0], l = s._getAttrMeshData(o, n.default.ATTR_POSITION), h = c.getIData(Uint16Array), u = c.vfm.element(n.default.ATTR_POSITION).num, f = 0; f < h.length; f += 3) { | |
i(t.a, l, h[f], u), | |
i(t.b, l, h[f + 1], u), | |
i(t.c, l, h[f + 2], u); | |
var d = L(r, t); | |
d > 0 && d < e && (e = d) | |
} | |
return e | |
} | |
} | |
)(), w = (function() { | |
function t(e, i) { | |
for (var n = e.children, r = n.length - 1; r >= 0; r--) | |
t(n[r], i); | |
i(e) | |
} | |
function e(t, e) { | |
return t.distance - e.distance | |
} | |
function i(t, e, i) { | |
var n = i.m | |
, r = e.x | |
, s = e.y | |
, a = e.z | |
, o = n[3] * r + n[7] * s + n[11] * a; | |
return o = o ? 1 / o : 1, | |
t.x = (n[0] * r + n[4] * s + n[8] * a) * o, | |
t.y = (n[1] * r + n[5] * s + n[9] * a) * o, | |
t.z = (n[2] * r + n[6] * s + n[10] * a) * o, | |
t | |
} | |
var n = new r.default(function() { | |
return { | |
distance: 0, | |
node: null | |
} | |
} | |
,1) | |
, o = [] | |
, c = a.default.create() | |
, h = new s.Vec3 | |
, u = new s.Vec3 | |
, f = new l.default | |
, d = cc.mat4() | |
, _ = cc.mat4() | |
, p = new s.Vec3; | |
function v(t) { | |
return t > 0 && t < Infinity | |
} | |
return function(r, l, g, m) { | |
return n.reset(), | |
o.length = 0, | |
t(r = r || cc.director.getScene(), (function(t) { | |
if (!m || m(t)) { | |
s.Mat4.invert(_, t.getWorldMatrix(d)), | |
s.Vec3.transformMat4(f.o, l.o, _), | |
s.Vec3.normalize(f.d, i(f.d, l.d, _)); | |
var e = Infinity | |
, r = t._renderComponent; | |
if (r instanceof cc.MeshRenderer ? e = B(f, r._boundingBox) : t.width && t.height && (s.Vec3.set(h, -t.width * t.anchorX, -t.height * t.anchorY, t.z), | |
s.Vec3.set(u, t.width * (1 - t.anchorX), t.height * (1 - t.anchorY), t.z), | |
a.default.fromPoints(c, h, u), | |
e = B(f, c)), | |
v(e) && (g && (e = g(f, t, e)), | |
v(e))) { | |
s.Vec3.scale(p, f.d, e), | |
i(p, p, d); | |
var y = n.add(); | |
y.node = t, | |
y.distance = s.Vec3.mag(p), | |
o.push(y) | |
} | |
} | |
} | |
)), | |
o.sort(e), | |
o | |
} | |
} | |
)(), I = (d = new s.Vec3(0,0,0), | |
function(t, e) { | |
var i = s.Vec3.dot(t.d, e.n); | |
if (Math.abs(i) < Number.EPSILON) | |
return 0; | |
s.Vec3.multiplyScalar(d, e.n, e.d); | |
var n = s.Vec3.dot(s.Vec3.subtract(d, d, t.o), e.n) / i; | |
return n < 0 ? 0 : n | |
} | |
), O = (_ = new s.Vec3(0,0,0), | |
function(t, e) { | |
s.Vec3.subtract(_, t.e, t.s); | |
var i = (e.d - s.Vec3.dot(t.s, e.n)) / s.Vec3.dot(_, e.n); | |
return i < 0 || i > 1 ? 0 : i | |
} | |
), L = (function() { | |
var t = new s.Vec3(0,0,0) | |
, e = new s.Vec3(0,0,0) | |
, i = new s.Vec3(0,0,0) | |
, n = new s.Vec3(0,0,0) | |
, r = new s.Vec3(0,0,0); | |
return function(a, o, c) { | |
s.Vec3.subtract(t, o.b, o.a), | |
s.Vec3.subtract(e, o.c, o.a), | |
s.Vec3.cross(i, a.d, e); | |
var l = s.Vec3.dot(t, i); | |
if (l < Number.EPSILON && (!c || l > -Number.EPSILON)) | |
return 0; | |
var h = 1 / l; | |
s.Vec3.subtract(n, a.o, o.a); | |
var u = s.Vec3.dot(n, i) * h; | |
if (u < 0 || u > 1) | |
return 0; | |
s.Vec3.cross(r, n, t); | |
var f = s.Vec3.dot(a.d, r) * h; | |
if (f < 0 || u + f > 1) | |
return 0; | |
var d = s.Vec3.dot(e, r) * h; | |
return d < 0 ? 0 : d | |
} | |
} | |
)(), P = L, D = (function() { | |
var t = new s.Vec3(0,0,0) | |
, e = new s.Vec3(0,0,0) | |
, i = new s.Vec3(0,0,0) | |
, n = new s.Vec3(0,0,0) | |
, r = new s.Vec3(0,0,0) | |
, a = new s.Vec3(0,0,0); | |
return function(o, c, l) { | |
s.Vec3.subtract(t, c.b, c.a), | |
s.Vec3.subtract(e, c.c, c.a), | |
s.Vec3.subtract(i, o.s, o.e), | |
s.Vec3.cross(r, t, e); | |
var h = s.Vec3.dot(i, r); | |
if (h <= 0) | |
return 0; | |
s.Vec3.subtract(n, o.s, c.a); | |
var u = s.Vec3.dot(n, r); | |
if (u < 0 || u > h) | |
return 0; | |
s.Vec3.cross(a, i, n); | |
var f = s.Vec3.dot(e, a); | |
if (f < 0 || f > h) | |
return 0; | |
var d = -s.Vec3.dot(t, a); | |
if (d < 0 || f + d > h) | |
return 0; | |
if (l) { | |
var _ = 1 / h | |
, p = 1 - (f *= _) - (d *= _); | |
s.Vec3.set(l, c.a.x * p + c.b.x * f + c.c.x * d, c.a.y * p + c.b.y * f + c.c.y * d, c.a.z * p + c.b.z * f + c.c.z * d) | |
} | |
return 1 | |
} | |
} | |
)(), N = (p = new s.Vec3(0,0,0), | |
v = new s.Vec3(0,0,0), | |
g = new s.Vec3(0,0,0), | |
m = new s.Vec3(0,0,0), | |
y = new s.Vec3(0,0,0), | |
T = new s.Vec3(0,0,0), | |
E = new s.Vec3(0,0,0), | |
function(t, e, i, n, r, a, o) { | |
s.Vec3.subtract(p, e, t), | |
s.Vec3.subtract(v, i, t), | |
s.Vec3.subtract(g, n, t), | |
s.Vec3.subtract(m, r, t), | |
s.Vec3.cross(T, m, p); | |
var c = s.Vec3.dot(v, T); | |
if (c >= 0) { | |
var l = -s.Vec3.dot(g, T); | |
if (l < 0) | |
return 0; | |
var h = s.Vec3.dot(s.Vec3.cross(E, p, g), v); | |
if (h < 0) | |
return 0; | |
if (o) { | |
var u = 1 / (l + c + h); | |
l *= u, | |
c *= u, | |
h *= u, | |
s.Vec3.set(o, i.x * l + n.x * c + r.x * h, i.y * l + n.y * c + r.y * h, i.z * l + n.z * c + r.z * h) | |
} | |
} else { | |
s.Vec3.subtract(y, a, t); | |
var f = s.Vec3.dot(y, T); | |
if (f < 0) | |
return 0; | |
var d = s.Vec3.dot(s.Vec3.cross(E, p, v), y); | |
if (d < 0) | |
return 0; | |
if (o) { | |
var _ = 1 / (f + (c = -c) + d); | |
f *= _, | |
c *= _, | |
d *= _, | |
s.Vec3.set(o, i.x * f + a.x * c + r.x * d, i.y * f + a.y * c + r.y * d, i.z * f + a.z * c + r.z * d) | |
} | |
} | |
return 1 | |
} | |
), F = (function() { | |
var t = new s.Vec3(0,0,0); | |
return function(e, i) { | |
var n = i.radius | |
, r = i.center | |
, a = e.o | |
, o = e.d | |
, c = n * n; | |
s.Vec3.subtract(t, r, a); | |
var l = t.lengthSqr() | |
, h = s.Vec3.dot(t, o) | |
, u = c - (l - h * h); | |
if (u < 0) | |
return 0; | |
var f = Math.sqrt(u) | |
, d = l < c ? h + f : h - f; | |
return d < 0 ? 0 : d | |
} | |
} | |
)(), B = (A = new s.Vec3, | |
x = new s.Vec3, | |
function(t, e) { | |
var i = t.o | |
, n = t.d | |
, r = 1 / n.x | |
, a = 1 / n.y | |
, o = 1 / n.z; | |
s.Vec3.subtract(A, e.center, e.halfExtents), | |
s.Vec3.add(x, e.center, e.halfExtents); | |
var c = (A.x - i.x) * r | |
, l = (x.x - i.x) * r | |
, h = (A.y - i.y) * a | |
, u = (x.y - i.y) * a | |
, f = (A.z - i.z) * o | |
, d = (x.z - i.z) * o | |
, _ = Math.max(Math.max(Math.min(c, l), Math.min(h, u)), Math.min(f, d)) | |
, p = Math.min(Math.min(Math.max(c, l), Math.max(h, u)), Math.max(f, d)); | |
return p < 0 || _ > p ? 0 : _ | |
} | |
), V = B, k = (function() { | |
var t = new s.Vec3 | |
, e = new s.Vec3 | |
, i = new s.Vec3 | |
, n = new s.Vec3 | |
, r = new s.Vec3 | |
, a = new s.Vec3 | |
, o = new s.Vec3 | |
, c = [, , , ] | |
, l = [, , , ] | |
, h = [, , , ] | |
, u = [, , , , , , ]; | |
return function(f, d) { | |
c[0] = d.halfExtents.x, | |
c[1] = d.halfExtents.y, | |
c[2] = d.halfExtents.z, | |
t = d.center, | |
e = f.o, | |
i = f.d; | |
var _ = d.orientation.m; | |
s.Vec3.set(n, _[0], _[1], _[2]), | |
s.Vec3.set(r, _[3], _[4], _[5]), | |
s.Vec3.set(a, _[6], _[7], _[8]), | |
s.Vec3.subtract(o, t, e), | |
l[0] = s.Vec3.dot(n, i), | |
l[1] = s.Vec3.dot(r, i), | |
l[2] = s.Vec3.dot(a, i), | |
h[0] = s.Vec3.dot(n, o), | |
h[1] = s.Vec3.dot(r, o), | |
h[2] = s.Vec3.dot(a, o); | |
for (var p = 0; p < 3; ++p) { | |
if (0 === l[p]) { | |
if (-h[p] - c[p] > 0 || -h[p] + c[p] < 0) | |
return 0; | |
l[p] = 1e-7 | |
} | |
u[2 * p + 0] = (h[p] + c[p]) / l[p], | |
u[2 * p + 1] = (h[p] - c[p]) / l[p] | |
} | |
var v = Math.max(Math.max(Math.min(u[0], u[1]), Math.min(u[2], u[3])), Math.min(u[4], u[5])) | |
, g = Math.min(Math.min(Math.max(u[0], u[1]), Math.max(u[2], u[3])), Math.max(u[4], u[5])); | |
return g < 0 || v > g || v < 0 ? 0 : v | |
} | |
} | |
)(), U = (C = new s.Vec3, | |
b = new s.Vec3, | |
S = new s.Vec3, | |
R = new s.Vec3, | |
function(t, e) { | |
return s.Vec3.subtract(C, t.center, t.halfExtents), | |
s.Vec3.add(b, t.center, t.halfExtents), | |
s.Vec3.subtract(S, e.center, e.halfExtents), | |
s.Vec3.add(R, e.center, e.halfExtents), | |
C.x <= R.x && b.x >= S.x && C.y <= R.y && b.y >= S.y && C.z <= R.z && b.z >= S.z | |
} | |
); | |
function z(t, e, i) { | |
s.Vec3.set(i[0], t.x, e.y, e.z), | |
s.Vec3.set(i[1], t.x, e.y, t.z), | |
s.Vec3.set(i[2], t.x, t.y, e.z), | |
s.Vec3.set(i[3], t.x, t.y, t.z), | |
s.Vec3.set(i[4], e.x, e.y, e.z), | |
s.Vec3.set(i[5], e.x, e.y, t.z), | |
s.Vec3.set(i[6], e.x, t.y, e.z), | |
s.Vec3.set(i[7], e.x, t.y, t.z) | |
} | |
function H(t, e, i, n, r, a) { | |
s.Vec3.set(a[0], t.x + i.x * e.x + n.x * e.y + r.x * e.z, t.y + i.y * e.x + n.y * e.y + r.y * e.z, t.z + i.z * e.x + n.z * e.y + r.z * e.z), | |
s.Vec3.set(a[1], t.x - i.x * e.x + n.x * e.y + r.x * e.z, t.y - i.y * e.x + n.y * e.y + r.y * e.z, t.z - i.z * e.x + n.z * e.y + r.z * e.z), | |
s.Vec3.set(a[2], t.x + i.x * e.x - n.x * e.y + r.x * e.z, t.y + i.y * e.x - n.y * e.y + r.y * e.z, t.z + i.z * e.x - n.z * e.y + r.z * e.z), | |
s.Vec3.set(a[3], t.x + i.x * e.x + n.x * e.y - r.x * e.z, t.y + i.y * e.x + n.y * e.y - r.y * e.z, t.z + i.z * e.x + n.z * e.y - r.z * e.z), | |
s.Vec3.set(a[4], t.x - i.x * e.x - n.x * e.y - r.x * e.z, t.y - i.y * e.x - n.y * e.y - r.y * e.z, t.z - i.z * e.x - n.z * e.y - r.z * e.z), | |
s.Vec3.set(a[5], t.x + i.x * e.x - n.x * e.y - r.x * e.z, t.y + i.y * e.x - n.y * e.y - r.y * e.z, t.z + i.z * e.x - n.z * e.y - r.z * e.z), | |
s.Vec3.set(a[6], t.x - i.x * e.x + n.x * e.y - r.x * e.z, t.y - i.y * e.x + n.y * e.y - r.y * e.z, t.z - i.z * e.x + n.z * e.y - r.z * e.z), | |
s.Vec3.set(a[7], t.x - i.x * e.x - n.x * e.y + r.x * e.z, t.y - i.y * e.x - n.y * e.y + r.y * e.z, t.z - i.z * e.x - n.z * e.y + r.z * e.z) | |
} | |
function G(t, e) { | |
for (var i = s.Vec3.dot(e, t[0]), n = i, r = 1; r < 8; ++r) { | |
var a = s.Vec3.dot(e, t[r]); | |
i = a < i ? a : i, | |
n = a > n ? a : n | |
} | |
return [i, n] | |
} | |
var W, X = (function() { | |
for (var t = Array(15), e = 0; e < 15; e++) | |
t[e] = new s.Vec3(0,0,0); | |
for (var i = [, , , , , , , , ], n = [, , , , , , , , ], r = 0; r < 8; r++) | |
i[r] = new s.Vec3(0,0,0), | |
n[r] = new s.Vec3(0,0,0); | |
var a = new s.Vec3 | |
, o = new s.Vec3; | |
return function(e, r) { | |
var c = r.orientation.m; | |
s.Vec3.set(t[0], 1, 0, 0), | |
s.Vec3.set(t[1], 0, 1, 0), | |
s.Vec3.set(t[2], 0, 0, 1), | |
s.Vec3.set(t[3], c[0], c[1], c[2]), | |
s.Vec3.set(t[4], c[3], c[4], c[5]), | |
s.Vec3.set(t[5], c[6], c[7], c[8]); | |
for (var l = 0; l < 3; ++l) | |
s.Vec3.cross(t[6 + 3 * l], t[l], t[0]), | |
s.Vec3.cross(t[7 + 3 * l], t[l], t[1]), | |
s.Vec3.cross(t[7 + 3 * l], t[l], t[2]); | |
s.Vec3.subtract(a, e.center, e.halfExtents), | |
s.Vec3.add(o, e.center, e.halfExtents), | |
z(a, o, i), | |
H(r.center, r.halfExtents, t[3], t[4], t[5], n); | |
for (var h = 0; h < 15; ++h) { | |
var u = G(i, t[h]) | |
, f = G(n, t[h]); | |
if (f[0] > u[1] || u[0] > f[1]) | |
return 0 | |
} | |
return 1 | |
} | |
} | |
)(), Y = function(t, e) { | |
var i = t.halfExtents.x * Math.abs(e.n.x) + t.halfExtents.y * Math.abs(e.n.y) + t.halfExtents.z * Math.abs(e.n.z) | |
, n = s.Vec3.dot(e.n, t.center); | |
return n + i < e.d ? -1 : n - i > e.d ? 0 : 1 | |
}, j = function(t, e) { | |
for (var i = 0; i < e.planes.length; i++) | |
if (-1 === Y(t, e.planes[i])) | |
return 0; | |
return 1 | |
}, q = (function() { | |
for (var t = [, , , , , , , , ], e = 0, i = 0, n = 0; n < t.length; n++) | |
t[n] = new s.Vec3(0,0,0); | |
return function(n, r) { | |
for (var a = 0, o = !1, c = 0; c < r.planes.length; c++) { | |
if (-1 === (a = Y(n, r.planes[c]))) | |
return 0; | |
1 === a && (o = !0) | |
} | |
if (!o) | |
return 1; | |
for (var l = 0; l < r.vertices.length; l++) | |
s.Vec3.subtract(t[l], r.vertices[l], n.center); | |
e = 0, | |
i = 0; | |
for (var h = 0; h < r.vertices.length; h++) | |
t[h].x > n.halfExtents.x ? e++ : t[h].x < -n.halfExtents.x && i++; | |
if (e === r.vertices.length || i === r.vertices.length) | |
return 0; | |
e = 0, | |
i = 0; | |
for (var u = 0; u < r.vertices.length; u++) | |
t[u].y > n.halfExtents.y ? e++ : t[u].y < -n.halfExtents.y && i++; | |
if (e === r.vertices.length || i === r.vertices.length) | |
return 0; | |
e = 0, | |
i = 0; | |
for (var f = 0; f < r.vertices.length; f++) | |
t[f].z > n.halfExtents.z ? e++ : t[f].z < -n.halfExtents.z && i++; | |
return e === r.vertices.length || i === r.vertices.length ? 0 : 1 | |
} | |
} | |
)(), Z = (function() { | |
var t = new s.Vec3(0,0,0) | |
, e = new s.Mat3; | |
return function(i, n) { | |
return s.Vec3.subtract(t, n, i.center), | |
s.Vec3.transformMat3(t, t, s.Mat3.transpose(e, i.orientation)), | |
r = t, | |
a = i.halfExtents, | |
Math.abs(r.x) < a.x && Math.abs(r.y) < a.y && Math.abs(r.z) < a.z; | |
var r, a | |
} | |
} | |
)(), K = (W = function(t, e, i, n) { | |
return Math.abs(t.x * e + t.y * i + t.z * n) | |
} | |
, | |
function(t, e) { | |
var i = t.orientation.m | |
, n = t.halfExtents.x * W(e.n, i[0], i[1], i[2]) + t.halfExtents.y * W(e.n, i[3], i[4], i[5]) + t.halfExtents.z * W(e.n, i[6], i[7], i[8]) | |
, r = s.Vec3.dot(e.n, t.center); | |
return r + n < e.d ? -1 : r - n > e.d ? 0 : 1 | |
} | |
), Q = function(t, e) { | |
for (var i = 0; i < e.planes.length; i++) | |
if (-1 === K(t, e.planes[i])) | |
return 0; | |
return 1 | |
}, J = (function() { | |
for (var t = [, , , , , , , , ], e = 0, i = 0, n = 0, r = 0; r < t.length; r++) | |
t[r] = new s.Vec3(0,0,0); | |
var a = function(t, e, i, n) { | |
return t.x * e + t.y * i + t.z * n | |
}; | |
return function(r, o) { | |
for (var c = 0, l = !1, h = 0; h < o.planes.length; h++) { | |
if (-1 === (c = K(r, o.planes[h]))) | |
return 0; | |
1 === c && (l = !0) | |
} | |
if (!l) | |
return 1; | |
for (var u = 0; u < o.vertices.length; u++) | |
s.Vec3.subtract(t[u], o.vertices[u], r.center); | |
i = 0, | |
n = 0; | |
for (var f = r.orientation.m, d = 0; d < o.vertices.length; d++) | |
(e = a(t[d], f[0], f[1], f[2])) > r.halfExtents.x ? i++ : e < -r.halfExtents.x && n++; | |
if (i === o.vertices.length || n === o.vertices.length) | |
return 0; | |
i = 0, | |
n = 0; | |
for (var _ = 0; _ < o.vertices.length; _++) | |
(e = a(t[_], f[3], f[4], f[5])) > r.halfExtents.y ? i++ : e < -r.halfExtents.y && n++; | |
if (i === o.vertices.length || n === o.vertices.length) | |
return 0; | |
i = 0, | |
n = 0; | |
for (var p = 0; p < o.vertices.length; p++) | |
(e = a(t[p], f[6], f[7], f[8])) > r.halfExtents.z ? i++ : e < -r.halfExtents.z && n++; | |
return i === o.vertices.length || n === o.vertices.length ? 0 : 1 | |
} | |
} | |
)(), $ = (function() { | |
for (var t = Array(15), e = 0; e < 15; e++) | |
t[e] = new s.Vec3(0,0,0); | |
for (var i = [, , , , , , , , ], n = [, , , , , , , , ], r = 0; r < 8; r++) | |
i[r] = new s.Vec3(0,0,0), | |
n[r] = new s.Vec3(0,0,0); | |
return function(e, r) { | |
var a = e.orientation.m | |
, o = r.orientation.m; | |
s.Vec3.set(t[0], a[0], a[1], a[2]), | |
s.Vec3.set(t[1], a[3], a[4], a[5]), | |
s.Vec3.set(t[2], a[6], a[7], a[8]), | |
s.Vec3.set(t[3], o[0], o[1], o[2]), | |
s.Vec3.set(t[4], o[3], o[4], o[5]), | |
s.Vec3.set(t[5], o[6], o[7], o[8]); | |
for (var c = 0; c < 3; ++c) | |
s.Vec3.cross(t[6 + 3 * c], t[c], t[0]), | |
s.Vec3.cross(t[7 + 3 * c], t[c], t[1]), | |
s.Vec3.cross(t[7 + 3 * c], t[c], t[2]); | |
H(e.center, e.halfExtents, t[0], t[1], t[2], i), | |
H(r.center, r.halfExtents, t[3], t[4], t[5], n); | |
for (var l = 0; l < 15; ++l) { | |
var h = G(i, t[l]) | |
, u = G(n, t[l]); | |
if (u[0] > h[1] || h[0] > u[1]) | |
return 0 | |
} | |
return 1 | |
} | |
} | |
)(), tt = function(t, e) { | |
var i = s.Vec3.dot(e.n, t.center) | |
, n = t.radius * e.n.length(); | |
return i + n < e.d ? -1 : i - n > e.d ? 0 : 1 | |
}, et = function(t, e) { | |
for (var i = 0; i < e.planes.length; i++) | |
if (-1 === tt(t, e.planes[i])) | |
return 0; | |
return 1 | |
}, it = (function() { | |
var t = new s.Vec3(0,0,0) | |
, e = [1, -1, 1, -1, 1, -1]; | |
return function(i, n) { | |
for (var r = 0; r < 6; r++) { | |
var a = n.planes[r] | |
, o = i.radius | |
, c = i.center | |
, l = a.n | |
, h = a.d | |
, u = s.Vec3.dot(l, c); | |
if (u + o < h) | |
return 0; | |
if (!(u - o > h)) { | |
s.Vec3.add(t, c, s.Vec3.multiplyScalar(t, l, o)); | |
for (var f = 0; f < 6; f++) | |
if (f !== r && f !== r + e[r]) { | |
var d = n.planes[f]; | |
if (s.Vec3.dot(d.n, t) < d.d) | |
return 0 | |
} | |
} | |
} | |
return 1 | |
} | |
} | |
)(), nt = function(t, e) { | |
var i = t.radius + e.radius; | |
return s.Vec3.squaredDistance(t.center, e.center) < i * i | |
}, rt = (function() { | |
var t = new s.Vec3; | |
return function(e, i) { | |
return o.pt_point_aabb(t, e.center, i), | |
s.Vec3.squaredDistance(e.center, t) < e.radius * e.radius | |
} | |
} | |
)(), st = (function() { | |
var t = new s.Vec3; | |
return function(e, i) { | |
return o.pt_point_obb(t, e.center, i), | |
s.Vec3.squaredDistance(e.center, t) < e.radius * e.radius | |
} | |
} | |
)(), at = { | |
rayAabb: V, | |
rayMesh: M, | |
raycast: w, | |
rayTriangle: P, | |
ray_sphere: F, | |
ray_aabb: B, | |
ray_obb: k, | |
ray_plane: I, | |
ray_triangle: L, | |
line_plane: O, | |
line_triangle: D, | |
line_quad: N, | |
sphere_sphere: nt, | |
sphere_aabb: rt, | |
sphere_obb: st, | |
sphere_plane: tt, | |
sphere_frustum: et, | |
sphere_frustum_accurate: it, | |
aabb_aabb: U, | |
aabb_obb: X, | |
aabb_plane: Y, | |
aabb_frustum: j, | |
aabb_frustum_accurate: q, | |
obb_obb: $, | |
obb_plane: K, | |
obb_frustum: Q, | |
obb_frustum_accurate: J, | |
obb_point: Z, | |
resolve: function(t, e, i) { | |
void 0 === i && (i = null); | |
var n = t._type | |
, r = e._type | |
, s = this[n | r]; | |
return n < r ? s(t, e, i) : s(e, t, i) | |
} | |
}; | |
at[c.default.SHAPE_RAY | c.default.SHAPE_SPHERE] = F, | |
at[c.default.SHAPE_RAY | c.default.SHAPE_AABB] = B, | |
at[c.default.SHAPE_RAY | c.default.SHAPE_OBB] = k, | |
at[c.default.SHAPE_RAY | c.default.SHAPE_PLANE] = I, | |
at[c.default.SHAPE_RAY | c.default.SHAPE_TRIANGLE] = L, | |
at[c.default.SHAPE_LINE | c.default.SHAPE_PLANE] = O, | |
at[c.default.SHAPE_LINE | c.default.SHAPE_TRIANGLE] = D, | |
at[c.default.SHAPE_SPHERE] = nt, | |
at[c.default.SHAPE_SPHERE | c.default.SHAPE_AABB] = rt, | |
at[c.default.SHAPE_SPHERE | c.default.SHAPE_OBB] = st, | |
at[c.default.SHAPE_SPHERE | c.default.SHAPE_PLANE] = tt, | |
at[c.default.SHAPE_SPHERE | c.default.SHAPE_FRUSTUM] = et, | |
at[c.default.SHAPE_SPHERE | c.default.SHAPE_FRUSTUM_ACCURATE] = it, | |
at[c.default.SHAPE_AABB] = U, | |
at[c.default.SHAPE_AABB | c.default.SHAPE_OBB] = X, | |
at[c.default.SHAPE_AABB | c.default.SHAPE_PLANE] = Y, | |
at[c.default.SHAPE_AABB | c.default.SHAPE_FRUSTUM] = j, | |
at[c.default.SHAPE_AABB | c.default.SHAPE_FRUSTUM_ACCURATE] = q, | |
at[c.default.SHAPE_OBB] = $, | |
at[c.default.SHAPE_OBB | c.default.SHAPE_PLANE] = K, | |
at[c.default.SHAPE_OBB | c.default.SHAPE_FRUSTUM] = Q, | |
at[c.default.SHAPE_OBB | c.default.SHAPE_FRUSTUM_ACCURATE] = J; | |
var ot = at; | |
i.default = ot, | |
e.exports = i.default | |
} | |
), { | |
"../../renderer/gfx": 282, | |
"../../renderer/memop/recycle-pool": 297, | |
"../value-types": 251, | |
"./aabb": 138, | |
"./distance": 139, | |
"./enums": 140, | |
"./ray": 147, | |
"./triangle": 149 | |
}], | |
144: [(function(t, e, i) { | |
"use strict"; | |
i.__esModule = !0, | |
i.default = void 0; | |
var n, r = t("../value-types"), s = (n = t("./enums")) && n.__esModule ? n : { | |
default: n | |
}, a = (function() { | |
function t(t, e, i, n, a, o) { | |
void 0 === t && (t = 0), | |
void 0 === e && (e = 0), | |
void 0 === i && (i = 0), | |
void 0 === n && (n = 0), | |
void 0 === a && (a = 0), | |
void 0 === o && (o = -1), | |
this.s = void 0, | |
this.e = void 0, | |
this._type = void 0, | |
this._type = s.default.SHAPE_LINE, | |
this.s = new r.Vec3(t,e,i), | |
this.e = new r.Vec3(n,a,o) | |
} | |
return t.create = function(e, i, n, r, s, a) { | |
return new t(e,i,n,r,s,a) | |
} | |
, | |
t.clone = function(e) { | |
return new t(e.s.x,e.s.y,e.s.z,e.e.x,e.e.y,e.e.z) | |
} | |
, | |
t.copy = function(t, e) { | |
return r.Vec3.copy(t.s, e.s), | |
r.Vec3.copy(t.e, e.e), | |
t | |
} | |
, | |
t.fromPoints = function(t, e, i) { | |
return r.Vec3.copy(t.s, e), | |
r.Vec3.copy(t.e, i), | |
t | |
} | |
, | |
t.set = function(t, e, i, n, r, s, a) { | |
return t.s.x = e, | |
t.s.y = i, | |
t.s.z = n, | |
t.e.x = r, | |
t.e.y = s, | |
t.e.z = a, | |
t | |
} | |
, | |
t.len = function(t) { | |
return r.Vec3.distance(t.s, t.e) | |
} | |
, | |
t.prototype.length = function() { | |
return r.Vec3.distance(this.s, this.e) | |
} | |
, | |
t | |
} | |
)(); | |
i.default = a, | |
e.exports = i.default | |
} | |
), { | |
"../value-types": 251, | |
"./enums": 140 | |
}], | |
145: [(function(t, e, i) { | |
"use strict"; | |
i.__esModule = !0, | |
i.default = void 0; | |
var n, r = t("../value-types"), s = (n = t("./enums")) && n.__esModule ? n : { | |
default: n | |
}; | |
function a(t, e) { | |
for (var i = 0; i < e.length; i++) { | |
var n = e[i]; | |
n.enumerable = n.enumerable || !1, | |
n.configurable = !0, | |
"value"in n && (n.writable = !0), | |
Object.defineProperty(t, n.key, n) | |
} | |
} | |
var o = new r.Vec3 | |
, c = new r.Vec3 | |
, l = new r.Mat3 | |
, h = (function() { | |
function t(t, e, i, n, a, o, c, l, h, u, f, d, _, p, v) { | |
void 0 === t && (t = 0), | |
void 0 === e && (e = 0), | |
void 0 === i && (i = 0), | |
void 0 === n && (n = 1), | |
void 0 === a && (a = 1), | |
void 0 === o && (o = 1), | |
void 0 === c && (c = 1), | |
void 0 === l && (l = 0), | |
void 0 === h && (h = 0), | |
void 0 === u && (u = 0), | |
void 0 === f && (f = 1), | |
void 0 === d && (d = 0), | |
void 0 === _ && (_ = 0), | |
void 0 === p && (p = 0), | |
void 0 === v && (v = 1), | |
this.center = void 0, | |
this.halfExtents = void 0, | |
this.orientation = void 0, | |
this._type = void 0, | |
this._type = s.default.SHAPE_OBB, | |
this.center = new r.Vec3(t,e,i), | |
this.halfExtents = new r.Vec3(n,a,o), | |
this.orientation = new r.Mat3(c,l,h,u,f,d,_,p,v) | |
} | |
t.create = function(e, i, n, r, s, a, o, c, l, h, u, f, d, _, p) { | |
return new t(e,i,n,r,s,a,o,c,l,h,u,f,d,_,p) | |
} | |
, | |
t.clone = function(e) { | |
var i = e.orientation.m; | |
return new t(e.center.x,e.center.y,e.center.z,e.halfExtents.x,e.halfExtents.y,e.halfExtents.z,i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8]) | |
} | |
, | |
t.copy = function(t, e) { | |
return r.Vec3.copy(t.center, e.center), | |
r.Vec3.copy(t.halfExtents, e.halfExtents), | |
r.Mat3.copy(t.orientation, e.orientation), | |
t | |
} | |
, | |
t.fromPoints = function(t, e, i) { | |
return r.Vec3.multiplyScalar(t.center, r.Vec3.add(o, e, i), .5), | |
r.Vec3.multiplyScalar(t.halfExtents, r.Vec3.subtract(c, i, e), .5), | |
r.Mat3.identity(t.orientation), | |
t | |
} | |
, | |
t.set = function(t, e, i, n, s, a, o, c, l, h, u, f, d, _, p, v) { | |
return r.Vec3.set(t.center, e, i, n), | |
r.Vec3.set(t.halfExtents, s, a, o), | |
r.Mat3.set(t.orientation, c, l, h, u, f, d, _, p, v), | |
t | |
} | |
; | |
var e, i, n = t.prototype; | |
return n.getBoundary = function(t, e) { | |
var i, n, s, a, c; | |
i = o, | |
n = this.halfExtents, | |
s = this.orientation, | |
a = l.m, | |
c = s.m, | |
a[0] = Math.abs(c[0]), | |
a[1] = Math.abs(c[1]), | |
a[2] = Math.abs(c[2]), | |
a[3] = Math.abs(c[3]), | |
a[4] = Math.abs(c[4]), | |
a[5] = Math.abs(c[5]), | |
a[6] = Math.abs(c[6]), | |
a[7] = Math.abs(c[7]), | |
a[8] = Math.abs(c[8]), | |
r.Vec3.transformMat3(i, n, l), | |
r.Vec3.subtract(t, this.center, o), | |
r.Vec3.add(e, this.center, o) | |
} | |
, | |
n.transform = function(t, e, i, n, s) { | |
r.Vec3.transformMat4(s.center, this.center, t), | |
r.Mat3.fromQuat(s.orientation, i), | |
r.Vec3.multiply(s.halfExtents, this.halfExtents, n) | |
} | |
, | |
n.translateAndRotate = function(t, e, i) { | |
r.Vec3.transformMat4(i.center, this.center, t), | |
r.Mat3.fromQuat(i.orientation, e) | |
} | |
, | |
n.setScale = function(t, e) { | |
r.Vec3.multiply(e.halfExtents, this.halfExtents, t) | |
} | |
, | |
e = t, | |
(i = [{ | |
key: "type", | |
get: function() { | |
return this._type | |
} | |
}]) && a(e.prototype, i), | |
Object.defineProperty(e, "prototype", { | |
writable: !1 | |
}), | |
t | |
} | |
)(); | |
i.default = h, | |
e.exports = i.default | |
} | |
), { | |
"../value-types": 251, | |
"./enums": 140 | |
}], | |
146: [(function(t, e, i) { | |
"use strict"; | |
i.__esModule = !0, | |
i.default = void 0; | |
var n, r = t("../value-types"), s = (n = t("./enums")) && n.__esModule ? n : { | |
default: n | |
}, a = new r.Vec3(0,0,0), o = new r.Vec3(0,0,0), c = cc.mat4(), l = cc.v4(), h = (function() { | |
function t(t, e, i, n) { | |
void 0 === t && (t = 0), | |
void 0 === e && (e = 1), | |
void 0 === i && (i = 0), | |
void 0 === n && (n = 0), | |
this.n = void 0, | |
this.d = void 0, | |
this._type = void 0, | |
this._type = s.default.SHAPE_PLANE, | |
this.n = new r.Vec3(t,e,i), | |
this.d = n | |
} | |
return t.create = function(e, i, n, r) { | |
return new t(e,i,n,r) | |
} | |
, | |
t.clone = function(e) { | |
return new t(e.n.x,e.n.y,e.n.z,e.d) | |
} | |
, | |
t.copy = function(t, e) { | |
return r.Vec3.copy(t.n, e.n), | |
t.d = e.d, | |
t | |
} | |
, | |
t.fromPoints = function(t, e, i, n) { | |
return r.Vec3.subtract(a, i, e), | |
r.Vec3.subtract(o, n, e), | |
r.Vec3.normalize(t.n, r.Vec3.cross(t.n, a, o)), | |
t.d = r.Vec3.dot(t.n, e), | |
t | |
} | |
, | |
t.set = function(t, e, i, n, r) { | |
return t.n.x = e, | |
t.n.y = i, | |
t.n.z = n, | |
t.d = r, | |
t | |
} | |
, | |
t.fromNormalAndPoint = function(t, e, i) { | |
return r.Vec3.copy(t.n, e), | |
t.d = r.Vec3.dot(e, i), | |
t | |
} | |
, | |
t.normalize = function(t, e) { | |
var i = e.n.len(); | |
return r.Vec3.normalize(t.n, e.n), | |
i > 0 && (t.d = e.d / i), | |
t | |
} | |
, | |
t.prototype.transform = function(t) { | |
r.Mat4.invert(c, t), | |
r.Mat4.transpose(c, c), | |
r.Vec4.set(l, this.n.x, this.n.y, this.n.z, this.d), | |
r.Vec4.transformMat4(l, l, c), | |
r.Vec3.set(this.n, l.x, l.y, l.z), | |
this.d = l.w | |
} | |
, | |
t | |
} | |
)(); | |
i.default = h, | |
e.exports = i.default | |
} | |
), { | |
"../value-types": 251, | |
"./enums": 140 | |
}], | |
147: [(function(t, e, i) { | |
"use strict"; | |
i.__esModule = !0, | |
i.default = void 0; | |
var n, r = t("../value-types"), s = (n = t("./enums")) && n.__esModule ? n : { | |
default: n | |
}, a = (function() { | |
function t(t, e, i, n, a, o) { | |
void 0 === t && (t = 0), | |
void 0 === e && (e = 0), | |
void 0 === i && (i = 0), | |
void 0 === n && (n = 0), | |
void 0 === a && (a = 0), | |
void 0 === o && (o = -1), | |
this.o = void 0, | |
this.d = void 0, | |
this._type = void 0, | |
this._type = s.default.SHAPE_RAY, | |
this.o = new r.Vec3(t,e,i), | |
this.d = new r.Vec3(n,a,o) | |
} | |
return t.create = function(e, i, n, r, s, a) { | |
return void 0 === e && (e = 0), | |
void 0 === i && (i = 0), | |
void 0 === n && (n = 0), | |
void 0 === r && (r = 0), | |
void 0 === s && (s = 0), | |
void 0 === a && (a = 1), | |
new t(e,i,n,r,s,a) | |
} | |
, | |
t.clone = function(e) { | |
return new t(e.o.x,e.o.y,e.o.z,e.d.x,e.d.y,e.d.z) | |
} | |
, | |
t.copy = function(t, e) { | |
return r.Vec3.copy(t.o, e.o), | |
r.Vec3.copy(t.d, e.d), | |
t | |
} | |
, | |
t.fromPoints = function(t, e, i) { | |
return r.Vec3.copy(t.o, e), | |
r.Vec3.normalize(t.d, r.Vec3.subtract(t.d, i, e)), | |
t | |
} | |
, | |
t.set = function(t, e, i, n, r, s, a) { | |
return t.o.x = e, | |
t.o.y = i, | |
t.o.z = n, | |
t.d.x = r, | |
t.d.y = s, | |
t.d.z = a, | |
t | |
} | |
, | |
t.prototype.computeHit = function(t, e) { | |
r.Vec3.normalize(t, this.d), | |
r.Vec3.scaleAndAdd(t, this.o, t, e) | |
} | |
, | |
t | |
} | |
)(); | |
i.default = a, | |
e.exports = i.default | |
} | |
), { | |
"../value-types": 251, | |
"./enums": 140 | |
}], | |
148: [(function(t, e, i) { | |
"use strict"; | |
i.__esModule = !0, | |
i.default = void 0; | |
var n, r = t("../value-types"), s = (n = t("./enums")) && n.__esModule ? n : { | |
default: n | |
}, a = new r.Vec3, o = (function() { | |
function t(t, e, i, n) { | |
void 0 === t && (t = 0), | |
void 0 === e && (e = 0), | |
void 0 === i && (i = 0), | |
void 0 === n && (n = 1), | |
this.center = void 0, | |
this.radius = void 0, | |
this._type = void 0, | |
this._type = s.default.SHAPE_SPHERE, | |
this.center = new r.Vec3(t,e,i), | |
this.radius = n | |
} | |
t.create = function(e, i, n, r) { | |
return new t(e,i,n,r) | |
} | |
, | |
t.clone = function(e) { | |
return new t(e.center.x,e.center.y,e.center.z,e.radius) | |
} | |
, | |
t.copy = function(t, e) { | |
return r.Vec3.copy(t.center, e.center), | |
t.radius = e.radius, | |
t | |
} | |
, | |
t.fromPoints = function(t, e, i) { | |
return r.Vec3.multiplyScalar(t.center, r.Vec3.add(a, e, i), .5), | |
t.radius = .5 * r.Vec3.subtract(a, i, e).len(), | |
t | |
} | |
, | |
t.set = function(t, e, i, n, r) { | |
return t.center.x = e, | |
t.center.y = i, | |
t.center.z = n, | |
t.radius = r, | |
t | |
} | |
; | |
var e = t.prototype; | |
return e.clone = function() { | |
return t.clone(this) | |
} | |
, | |
e.copy = function(e) { | |
return t.copy(this, e) | |
} | |
, | |
e.getBoundary = function(t, e) { | |
r.Vec3.set(t, this.center.x - this.radius, this.center.y - this.radius, this.center.z - this.radius), | |
r.Vec3.set(e, this.center.x + this.radius, this.center.y + this.radius, this.center.z + this.radius) | |
} | |
, | |
e.transform = function(t, e, i, n, s) { | |
r.Vec3.transformMat4(s.center, this.center, t), | |
s.radius = this.radius * n.maxAxis() | |
} | |
, | |
e.translateAndRotate = function(t, e, i) { | |
r.Vec3.transformMat4(i.center, this.center, t) | |
} | |
, | |
e.setScale = function(t, e) { | |
e.radius = this.radius * t.maxAxis() | |
} | |
, | |
t | |
} | |
)(); | |
i.default = o, | |
e.exports = i.default | |
} | |
), { | |
"../value-types": 251, | |
"./enums": 140 | |
}], | |
149: [(function(t, e, i) { | |
"use strict"; | |
i.__esModule = !0, | |
i.default = void 0; | |
var n = s(t("../value-types/vec3")) | |
, r = s(t("./enums")); | |
function s(t) { | |
return t && t.__esModule ? t : { | |
default: t | |
} | |
} | |
var a = (function() { | |
function t(t, e, i, s, a, o, c, l, h) { | |
this.a = void 0, | |
this.b = void 0, | |
this.c = void 0, | |
this._type = void 0, | |
this.a = new n.default(t,e,i), | |
this.b = new n.default(s,a,o), | |
this.c = new n.default(c,l,h), | |
this._type = r.default.SHAPE_TRIANGLE | |
} | |
return t.create = function(e, i, n, r, s, a, o, c, l) { | |
return new t(e,i,n,r,s,a,o,c,l) | |
} | |
, | |
t.clone = function(e) { | |
return new t(e.a.x,e.a.y,e.a.z,e.b.x,e.b.y,e.b.z,e.c.x,e.c.y,e.c.z) | |
} | |
, | |
t.copy = function(t, e) { | |
return n.default.copy(t.a, e.a), | |
n.default.copy(t.b, e.b), | |
n.default.copy(t.c, e.c), | |
t | |
} | |
, | |
t.fromPoints = function(t, e, i, r) { | |
return n.default.copy(t.a, e), | |
n.default.copy(t.b, i), | |
n.default.copy(t.c, r), | |
t | |
} | |
, | |
t.set = function(t, e, i, n, r, s, a, o, c, l) { | |
return t.a.x = e, | |
t.a.y = i, | |
t.a.z = n, | |
t.b.x = r, | |
t.b.y = s, | |
t.b.z = a, | |
t.c.x = o, | |
t.c.y = c, | |
t.c.z = l, | |
t | |
} | |
, | |
t | |
} | |
)(); | |
i.default = a, | |
e.exports = i.default | |
} | |
), { | |
"../value-types/vec3": 261, | |
"./enums": 140 | |
}], | |
150: [(function(t, e) { | |
"use strict"; | |
var i = cc.Class({ | |
name: "cc.GraphicsPoint", | |
extends: cc.Vec2, | |
ctor: function() { | |
this.reset() | |
}, | |
reset: function() { | |
this.dx = 0, | |
this.dy = 0, | |
this.dmx = 0, | |
this.dmy = 0, | |
this.flags = 0, | |
this.len = 0 | |
} | |
}); | |
cc.GraphicsPoint = e.exports = i | |
} | |
), {}], | |
151: [(function(t, e) { | |
"use strict"; | |
var i = t("../components/CCRenderComponent") | |
, n = t("../assets/material/CCMaterial") | |
, r = t("./types") | |
, s = r.PointFlags | |
, a = r.LineCap | |
, o = r.LineJoin | |
, c = cc.Class({ | |
name: "cc.Graphics", | |
extends: i, | |
editor: !1, | |
ctor: function() { | |
this._impl = new c._Impl(this) | |
}, | |
properties: { | |
_lineWidth: 2, | |
_strokeColor: cc.Color.BLACK, | |
_lineJoin: o.MITER, | |
_lineCap: a.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: o | |
}, | |
lineCap: { | |
get: function() { | |
return this._lineCap | |
}, | |
set: function(t) { | |
this._lineCap = t, | |
this._impl.lineCap = t | |
}, | |
type: a | |
}, | |
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: o, | |
LineCap: a, | |
PointFlags: s | |
}, | |
onRestore: function() { | |
this._impl || (this._impl = new c._Impl(this)) | |
}, | |
onDestroy: function() { | |
this.clear(!0), | |
this._super(), | |
this._impl = null | |
}, | |
_getDefaultMaterial: function() { | |
return n.getBuiltinMaterial("2d-graphics") | |
}, | |
_updateMaterial: function() { | |
var t = this._materials[0]; | |
t && (void 0 !== t.getDefine("CC_USE_MODEL") && t.define("CC_USE_MODEL", !0), | |
void 0 !== t.getDefine("CC_SUPPORT_standard_derivatives") && cc.sys.glExtension("OES_standard_derivatives") && t.define("CC_SUPPORT_standard_derivatives", !0)) | |
}, | |
moveTo: function(t, e) { | |
this._impl.moveTo(t, e) | |
}, | |
lineTo: function(t, e) { | |
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(t), | |
this._assembler && this._assembler.clear(t) | |
}, | |
close: function() { | |
this._impl.close() | |
}, | |
stroke: function() { | |
this._assembler || this._resetAssembler(), | |
this._assembler.stroke(this) | |
}, | |
fill: function() { | |
this._assembler || this._resetAssembler(), | |
this._assembler.fill(this) | |
} | |
}); | |
cc.Graphics = e.exports = c, | |
cc.Graphics.Types = r, | |
cc.Graphics.Helper = t("./helper") | |
} | |
), { | |
"../assets/material/CCMaterial": 76, | |
"../components/CCRenderComponent": 109, | |
"./helper": 152, | |
"./types": 154 | |
}], | |
152: [(function(t, e) { | |
"use strict"; | |
var i = t("./types").PointFlags | |
, n = Math.PI | |
, r = Math.min | |
, s = Math.max | |
, a = Math.cos | |
, o = Math.sin | |
, c = Math.abs | |
, l = Math.sign | |
, h = .5522847493; | |
cc.GraphicsHelper = e.exports = { | |
arc: function(t, e, i, l, h, u, f) { | |
var d, _, p, v = 0, g = 0, m = 0, y = 0, T = 0, E = 0, A = 0, x = 0, C = 0, b = 0, S = 0, R = 0, M = 0; | |
if (g = u - h, | |
f = f || !1) | |
if (c(g) >= 2 * n) | |
g = 2 * n; | |
else | |
for (; g < 0; ) | |
g += 2 * n; | |
else if (c(g) >= 2 * n) | |
g = 2 * -n; | |
else | |
for (; g > 0; ) | |
g -= 2 * n; | |
for (p = 0 | s(1, r(c(g) / (.5 * n) + .5, 5)), | |
m = c(4 / 3 * (1 - a(d = g / p / 2)) / o(d)), | |
f || (m = -m), | |
_ = 0; _ <= p; _++) | |
E = e + (y = a(v = h + g * (_ / p))) * l, | |
A = i + (T = o(v)) * l, | |
x = -T * l * m, | |
C = y * l * m, | |
0 === _ ? t.moveTo(E, A) : t.bezierCurveTo(b + R, S + M, E - x, A - C, E, A), | |
b = E, | |
S = A, | |
R = x, | |
M = C | |
}, | |
ellipse: function(t, e, i, n, r) { | |
t.moveTo(e - n, i), | |
t.bezierCurveTo(e - n, i + r * h, e - n * h, i + r, e, i + r), | |
t.bezierCurveTo(e + n * h, i + r, e + n, i + r * h, e + n, i), | |
t.bezierCurveTo(e + n, i - r * h, e + n * h, i - r, e, i - r), | |
t.bezierCurveTo(e - n * h, i - r, e - n, i - r * h, e - n, i), | |
t.close() | |
}, | |
roundRect: function(t, e, i, n, s, a) { | |
if (a < .1) | |
t.rect(e, i, n, s); | |
else { | |
var o = r(a, .5 * c(n)) * l(n) | |
, u = r(a, .5 * c(s)) * l(s); | |
t.moveTo(e, i + u), | |
t.lineTo(e, i + s - u), | |
t.bezierCurveTo(e, i + s - u * (1 - h), e + o * (1 - h), i + s, e + o, i + s), | |
t.lineTo(e + n - o, i + s), | |
t.bezierCurveTo(e + n - o * (1 - h), i + s, e + n, i + s - u * (1 - h), e + n, i + s - u), | |
t.lineTo(e + n, i + u), | |
t.bezierCurveTo(e + n, i + u * (1 - h), e + n - o * (1 - h), i, e + n - o, i), | |
t.lineTo(e + o, i), | |
t.bezierCurveTo(e + o * (1 - h), i, e, i + u * (1 - h), e, i + u), | |
t.close() | |
} | |
}, | |
tesselateBezier: function t(e, n, r, s, a, o, l, h, u, f, d) { | |
var _, p, v, g, m, y, T, E, A, x, C, b, S, R, M, w; | |
f > 10 || (m = .5 * (o + h), | |
y = .5 * (l + u), | |
T = .5 * ((_ = .5 * (n + s)) + (v = .5 * (s + o))), | |
E = .5 * ((p = .5 * (r + a)) + (g = .5 * (a + l))), | |
((M = c((s - h) * (R = u - r) - (a - u) * (S = h - n))) + (w = c((o - h) * R - (l - u) * S))) * (M + w) < e._tessTol * (S * S + R * R) ? e._addPoint(h, u, 0 === d ? d | i.PT_BEVEL : d) : (t(e, n, r, _, p, T, E, C = .5 * (T + (A = .5 * (v + m))), b = .5 * (E + (x = .5 * (g + y))), f + 1, 0), | |
t(e, C, b, A, x, m, y, h, u, f + 1, d))) | |
} | |
} | |
} | |
), { | |
"./types": 154 | |
}], | |
153: [(function(t) { | |
"use strict"; | |
t("./graphics"), | |
t("./graphics-point"), | |
t("./helper") | |
} | |
), { | |
"./graphics": 151, | |
"./graphics-point": 150, | |
"./helper": 152 | |
}], | |
154: [(function(t, e) { | |
"use strict"; | |
var i = cc.Enum({ | |
BUTT: 0, | |
ROUND: 1, | |
SQUARE: 2 | |
}) | |
, n = cc.Enum({ | |
BEVEL: 0, | |
ROUND: 1, | |
MITER: 2 | |
}) | |
, r = cc.Enum({ | |
PT_CORNER: 1, | |
PT_LEFT: 2, | |
PT_BEVEL: 4, | |
PT_INNERBEVEL: 8 | |
}); | |
e.exports = { | |
LineCap: i, | |
LineJoin: n, | |
PointFlags: r | |
} | |
} | |
), {}], | |
155: [(function(t) { | |
"use strict"; | |
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("./geom-utils"), | |
t("./mesh"), | |
t("./3d"), | |
t("./base-ui/CCWidgetManager") | |
} | |
), { | |
"./3d": void 0, | |
"./CCNode": 26, | |
"./CCPrivateNode": 27, | |
"./CCScene": 28, | |
"./assets": 74, | |
"./base-ui/CCWidgetManager": 85, | |
"./camera/CCCamera": 86, | |
"./collider": 94, | |
"./collider/CCIntersection": 92, | |
"./components": 127, | |
"./geom-utils": 142, | |
"./graphics": 153, | |
"./mesh": 158, | |
"./physics": void 0, | |
"./platform": 180 | |
}], | |
156: [(function(t, e) { | |
"use strict"; | |
var i = s(t("../../renderer/core/input-assembler")) | |
, n = s(t("../../renderer/gfx")) | |
, r = t("./mesh-data"); | |
function s(t) { | |
return t && t.__esModule ? t : { | |
default: t | |
} | |
} | |
var a = t("../renderer") | |
, o = t("../event/event-target"); | |
function c(t, e, i) { | |
t[e] = i._val | |
} | |
function l(t, e, i) { | |
t[e] = i.x, | |
t[e + 1] = i.y | |
} | |
function h(t, e, i) { | |
t[e] = i.x, | |
t[e + 1] = i.y, | |
t[e + 2] = i.z | |
} | |
var u, f = { | |
5120: "getInt8", | |
5121: "getUint8", | |
5122: "getInt16", | |
5123: "getUint16", | |
5124: "getInt32", | |
5125: "getUint32", | |
5126: "getFloat32" | |
}, d = { | |
5120: "setInt8", | |
5121: "setUint8", | |
5122: "setInt16", | |
5123: "setUint16", | |
5124: "setInt32", | |
5125: "setUint32", | |
5126: "setFloat32" | |
}, _ = (u = new ArrayBuffer(2), | |
new DataView(u).setInt16(0, 256, !0), | |
256 === new Int16Array(u)[0]), p = cc.Class({ | |
name: "cc.Mesh", | |
extends: cc.Asset, | |
mixins: [o], | |
properties: { | |
_nativeAsset: { | |
override: !0, | |
get: function() { | |
return this._buffer | |
}, | |
set: function(t) { | |
this._buffer = ArrayBuffer.isView(t) ? t.buffer : t, | |
this.initWithBuffer() | |
} | |
}, | |
_vertexBundles: { | |
default: null, | |
type: r.VertexBundle | |
}, | |
_primitives: { | |
default: null, | |
Primitive: r.Primitive | |
}, | |
_minPos: cc.v3(), | |
_maxPos: cc.v3(), | |
subMeshes: { | |
get: function() { | |
return this._subMeshes | |
}, | |
set: function(t) { | |
this._subMeshes = t | |
} | |
}, | |
subDatas: { | |
get: function() { | |
return this._subDatas | |
} | |
} | |
}, | |
ctor: function() { | |
this._subMeshes = [], | |
this._subDatas = [], | |
this.loaded = !1 | |
}, | |
initWithBuffer: function() { | |
this._subMeshes.length = 0; | |
for (var t = this._primitives, e = 0; e < t.length; e++) { | |
var s = t[e] | |
, o = s.data | |
, c = new Uint8Array(this._buffer,o.offset,o.length) | |
, l = this._vertexBundles[s.vertexBundleIndices[0]] | |
, h = l.data | |
, u = new n.default.VertexFormat(l.formats) | |
, f = new Uint8Array(this._buffer,h.offset,h.length) | |
, d = this._canVertexFormatBatch(u) | |
, _ = new r.MeshData; | |
_.vData = f, | |
_.iData = c, | |
_.vfm = u, | |
_.offset = h.offset, | |
_.canBatch = d, | |
this._subDatas.push(_); | |
var p = new n.default.VertexBuffer(a.device,u,n.default.USAGE_STATIC,f) | |
, v = new n.default.IndexBuffer(a.device,s.indexUnit,n.default.USAGE_STATIC,c); | |
this._subMeshes.push(new i.default(p,v)) | |
} | |
this.loaded = !0, | |
this.emit("load") | |
}, | |
_canVertexFormatBatch: function(t) { | |
var e = t._attr2el[n.default.ATTR_POSITION]; | |
return !e || e.type === n.default.ATTR_TYPE_FLOAT32 && t._bytes % 4 == 0 | |
}, | |
init: function(t, e, s, o) { | |
void 0 === s && (s = !1), | |
void 0 === o && (o = 0); | |
var c = new Uint8Array(t._bytes * e) | |
, l = new r.MeshData; | |
l.vData = c, | |
l.vfm = t, | |
l.vDirty = !0, | |
l.canBatch = this._canVertexFormatBatch(t); | |
var h = new n.default.VertexBuffer(a.device,t,s ? n.default.USAGE_DYNAMIC : n.default.USAGE_STATIC,c); | |
l.vb = h, | |
this._subMeshes[o] = new i.default(l.vb); | |
var u = this._subDatas[o]; | |
u && (u.vb && u.vb.destroy(), | |
u.ib && u.ib.destroy()), | |
this._subDatas[o] = l, | |
this.loaded = !0, | |
this.emit("load"), | |
this.emit("init-format") | |
}, | |
setVertices: function(t, e, i) { | |
i = i || 0; | |
var r = this._subDatas[i] | |
, s = r.vfm.element(t); | |
if (s) { | |
var a, o = "number" == typeof e[0], u = s.num, f = o ? e.length / u | 0 : e.length; | |
r.vData.byteLength < f * s.stride && r.setVData(new Uint8Array(f * r.vfm._bytes)); | |
var d = 4; | |
t === n.default.ATTR_COLOR ? o ? (a = r.getVData(), | |
d = 1) : a = r.getVData(Uint32Array) : a = r.getVData(Float32Array); | |
var _ = s.stride / d | |
, p = s.offset / d; | |
if (o) | |
for (var v = 0, g = e.length / u; v < g; v++) | |
for (var m = v * u, y = v * _ + p, T = 0; T < u; T++) | |
a[y + T] = e[m + T]; | |
else { | |
var E; | |
E = t === n.default.ATTR_COLOR ? c : 2 === u ? l : h; | |
for (var A = 0, x = e.length; A < x; A++) | |
E(a, A * _ + p, e[A]) | |
} | |
r.vDirty = !0 | |
} | |
}, | |
setIndices: function(t, e, i) { | |
e = e || 0; | |
var r = t; | |
t instanceof Uint16Array ? r = new Uint8Array(t.buffer,t.byteOffset,t.byteLength) : Array.isArray(t) && (r = new Uint16Array(t), | |
r = new Uint8Array(r.buffer,r.byteOffset,r.byteLength)); | |
var s = i ? n.default.USAGE_DYNAMIC : n.default.USAGE_STATIC | |
, o = this._subDatas[e]; | |
if (o.ib) | |
o.iData = r, | |
o.iDirty = !0; | |
else { | |
o.iData = r; | |
var c = new n.default.IndexBuffer(a.device,n.default.INDEX_FMT_UINT16,s,r,r.byteLength / n.default.IndexBuffer.BYTES_PER_INDEX[n.default.INDEX_FMT_UINT16]); | |
o.ib = c, | |
this._subMeshes[e]._indexBuffer = o.ib | |
} | |
}, | |
setPrimitiveType: function(t, e) { | |
e = e || 0, | |
this._subMeshes[e] && (this._subMeshes[e]._primitiveType = t) | |
}, | |
clear: function() { | |
this._subMeshes.length = 0; | |
for (var t = this._subDatas, e = 0, i = t.length; e < i; e++) { | |
var n = t[e].vb; | |
n && n.destroy(); | |
var r = t[e].ib; | |
r && r.destroy() | |
} | |
t.length = 0 | |
}, | |
setBoundingBox: function(t, e) { | |
this._minPos = t, | |
this._maxPos = e | |
}, | |
destroy: function() { | |
this.clear() | |
}, | |
_uploadData: function() { | |
for (var t = this._subDatas, e = 0, i = t.length; e < i; e++) { | |
var n = t[e]; | |
if (n.vDirty) { | |
var r = n.vb | |
, s = n.vData; | |
r.update(0, s), | |
n.vDirty = !1 | |
} | |
if (n.iDirty) { | |
var a = n.ib | |
, o = n.iData; | |
a.update(0, o), | |
n.iDirty = !1 | |
} | |
} | |
}, | |
_getAttrMeshData: function(t, e) { | |
var i = this._subDatas[t]; | |
if (!i) | |
return []; | |
var n = i.vfm | |
, r = n.element(e); | |
if (!r) | |
return []; | |
i.attrDatas || (i.attrDatas = {}); | |
var s = i.attrDatas | |
, a = s[e]; | |
if (a) | |
return a; | |
a = s[e] = []; | |
for (var o = i.vData, c = new DataView(o.buffer,o.byteOffset,o.byteLength), l = r.stride, h = r.offset, u = r.num, d = r.bytes / u, p = f[r.type], v = o.byteLength / n._bytes, g = 0; g < v; g++) | |
for (var m = g * l + h, y = 0; y < u; y++) { | |
var T = c[p](m + y * d, _); | |
a.push(T) | |
} | |
return a | |
}, | |
copyAttribute: function(t, e, i, n, r) { | |
var s = !1 | |
, a = this._subDatas[t]; | |
if (!a) | |
return s; | |
var o = a.vfm | |
, c = o.element(e); | |
if (!c) | |
return s; | |
var l = d[c.type]; | |
if (!l) | |
return s; | |
var h = this._getAttrMeshData(t, e) | |
, u = a.vData.byteLength / o._bytes | |
, f = c.bytes / c.num; | |
if (h.length > 0) { | |
for (var p = new DataView(i,r), v = n, g = c.num, m = 0; m < u; ++m) | |
for (var y = m * g, T = 0; T < g; ++T) { | |
var E = y + T | |
, A = v * m + f * T; | |
p[l](A, h[E], _) | |
} | |
s = !0 | |
} | |
return s | |
}, | |
copyIndices: function(t, e) { | |
var i = this._subDatas[t]; | |
if (!i) | |
return !1; | |
for (var r = i.iData, s = r.length / 2, a = new DataView(r.buffer,r.byteOffset,r.byteLength), o = f[n.default.INDEX_FMT_UINT8], c = 0; c < s; ++c) | |
e[c] = a[o](2 * c); | |
return !0 | |
} | |
}); | |
cc.Mesh = e.exports = p | |
} | |
), { | |
"../../renderer/core/input-assembler": 272, | |
"../../renderer/gfx": 282, | |
"../event/event-target": 134, | |
"../renderer": 193, | |
"./mesh-data": 159 | |
}], | |
157: [(function(t, e) { | |
"use strict"; | |
var i = s(t("../../renderer/gfx")) | |
, n = (s(t("../../renderer/core/input-assembler")), | |
s(t("../geom-utils/aabb"))) | |
, r = (s(t("../value-types/vec3")), | |
s(t("../value-types/mat4")), | |
s(t("../assets/material/material-variant"))); | |
function s(t) { | |
return t && t.__esModule ? t : { | |
default: t | |
} | |
} | |
var a = t("../components/CCRenderComponent") | |
, o = t("./CCMesh") | |
, c = t("../renderer/render-flow") | |
, l = (t("../renderer"), | |
t("../assets/material/CCMaterial")) | |
, h = cc.Enum({ | |
OFF: 0, | |
ON: 1 | |
}) | |
, u = cc.Class({ | |
name: "cc.MeshRenderer", | |
extends: a, | |
editor: !1, | |
properties: { | |
_mesh: { | |
default: null, | |
type: o | |
}, | |
_receiveShadows: !1, | |
_shadowCastingMode: h.OFF, | |
_enableAutoBatch: !1, | |
mesh: { | |
get: function() { | |
return this._mesh | |
}, | |
set: function(t) { | |
this._mesh !== t && (this._setMesh(t), | |
t ? (this.markForRender(!0), | |
this.node._renderFlag |= c.FLAG_TRANSFORM) : this.disableRender()) | |
}, | |
type: o, | |
animatable: !1 | |
}, | |
textures: { | |
default: [], | |
type: cc.Texture2D, | |
visible: !1 | |
}, | |
receiveShadows: { | |
get: function() { | |
return this._receiveShadows | |
}, | |
set: function(t) { | |
this._receiveShadows = t, | |
this._updateReceiveShadow() | |
}, | |
animatable: !1 | |
}, | |
shadowCastingMode: { | |
get: function() { | |
return this._shadowCastingMode | |
}, | |
set: function(t) { | |
this._shadowCastingMode = t, | |
this._updateCastShadow() | |
}, | |
type: h, | |
animatable: !1 | |
}, | |
enableAutoBatch: { | |
get: function() { | |
return this._enableAutoBatch | |
}, | |
set: function(t) { | |
this._enableAutoBatch = t | |
} | |
} | |
}, | |
statics: { | |
ShadowCastingMode: h | |
}, | |
ctor: function() { | |
this._boundingBox = cc.geomUtils && new n.default | |
}, | |
onEnable: function() { | |
var t = this; | |
this._super(), | |
this._mesh && !this._mesh.loaded ? (this.disableRender(), | |
this._mesh.once("load", (function() { | |
t.isValid && (t._setMesh(t._mesh), | |
t.markForRender(!0)) | |
} | |
)), | |
cc.assetManager.postLoadNative(this._mesh)) : this._setMesh(this._mesh), | |
this._updateRenderNode(), | |
this._updateMaterial() | |
}, | |
onDestroy: function() { | |
this._setMesh(null), | |
cc.pool.assembler.put(this._assembler) | |
}, | |
_updateRenderNode: function() { | |
this._assembler.setRenderNode(this.node) | |
}, | |
_setMesh: function(t) { | |
cc.geomUtils && t && n.default.fromPoints(this._boundingBox, t._minPos, t._maxPos), | |
this._mesh && this._mesh.off("init-format", this._updateMeshAttribute, this), | |
t && t.on("init-format", this._updateMeshAttribute, this), | |
this._mesh = t, | |
this._assembler && (this._assembler._worldDatas = {}), | |
this._updateMeshAttribute() | |
}, | |
_getDefaultMaterial: function() { | |
return l.getBuiltinMaterial("unlit") | |
}, | |
_validateRender: function() { | |
var t = this._mesh; | |
t && t._subDatas.length > 0 || this.disableRender() | |
}, | |
_updateMaterial: function() { | |
var t = this.textures; | |
if (t && t.length > 0) | |
for (var e = this._getDefaultMaterial(), i = 0; i < t.length; i++) { | |
var n = this._materials[i]; | |
n && n._uuid !== e._uuid || (n || (n = r.default.create(e, this), | |
this.setMaterial(i, n)), | |
n.setProperty("diffuseTexture", t[i])) | |
} | |
this._updateReceiveShadow(), | |
this._updateCastShadow(), | |
this._updateMeshAttribute() | |
}, | |
_updateReceiveShadow: function() { | |
for (var t = this.getMaterials(), e = 0; e < t.length; e++) | |
t[e].define("CC_USE_SHADOW_MAP", this._receiveShadows, void 0, !0) | |
}, | |
_updateCastShadow: function() { | |
for (var t = this.getMaterials(), e = 0; e < t.length; e++) | |
t[e].define("CC_CASTING_SHADOW", this._shadowCastingMode === h.ON, void 0, !0) | |
}, | |
_updateMeshAttribute: function() { | |
var t = this._mesh && this._mesh.subDatas; | |
if (t) | |
for (var e = this.getMaterials(), n = 0; n < e.length && t[n]; n++) { | |
var r = t[n].vfm | |
, s = e[n]; | |
s.define("CC_USE_ATTRIBUTE_COLOR", !!r.element(i.default.ATTR_COLOR), void 0, !0), | |
s.define("CC_USE_ATTRIBUTE_UV0", !!r.element(i.default.ATTR_UV0), void 0, !0), | |
s.define("CC_USE_ATTRIBUTE_NORMAL", !!r.element(i.default.ATTR_NORMAL), void 0, !0), | |
s.define("CC_USE_ATTRIBUTE_TANGENT", !!r.element(i.default.ATTR_TANGENT), void 0, !0) | |
} | |
}, | |
_checkBacth: function() {} | |
}); | |
cc.MeshRenderer = e.exports = u | |
} | |
), { | |
"../../renderer/core/input-assembler": 272, | |
"../../renderer/gfx": 282, | |
"../assets/material/CCMaterial": 76, | |
"../assets/material/material-variant": 83, | |
"../components/CCRenderComponent": 109, | |
"../geom-utils/aabb": 138, | |
"../renderer": 193, | |
"../renderer/render-flow": 194, | |
"../value-types/mat4": 253, | |
"../value-types/vec3": 261, | |
"./CCMesh": 156 | |
}], | |
158: [(function(t) { | |
"use strict"; | |
t("./CCMesh"), | |
t("./CCMeshRenderer"), | |
t("./mesh-renderer") | |
} | |
), { | |
"./CCMesh": 156, | |
"./CCMeshRenderer": 157, | |
"./mesh-renderer": 160 | |
}], | |
159: [(function(t, e, i) { | |
"use strict"; | |
i.__esModule = !0, | |
i.BufferRange = void 0, | |
i.MeshData = l, | |
i.VertexFormat = i.VertexBundle = i.Primitive = void 0; | |
var n, r = (n = t("../../renderer/gfx")) && n.__esModule ? n : { | |
default: n | |
}, s = cc.Class({ | |
name: "cc.BufferRange", | |
properties: { | |
offset: 0, | |
length: 0 | |
} | |
}); | |
i.BufferRange = s; | |
var a = cc.Class({ | |
name: "cc.mesh.VertexFormat", | |
properties: { | |
name: "", | |
type: -1, | |
num: -1, | |
normalize: !1 | |
} | |
}); | |
i.VertexFormat = a; | |
var o = cc.Class({ | |
name: "cc.mesh.VertexBundle", | |
properties: { | |
data: { | |
default: null, | |
type: s | |
}, | |
formats: { | |
default: [], | |
type: a | |
}, | |
verticesCount: 0 | |
} | |
}); | |
i.VertexBundle = o; | |
var c = cc.Class({ | |
name: "cc.mesh.Primitive", | |
properties: { | |
vertexBundleIndices: { | |
default: [], | |
type: cc.Float | |
}, | |
data: { | |
default: null, | |
type: s | |
}, | |
indexUnit: r.default.INDEX_FMT_UINT16, | |
topology: r.default.PT_TRIANGLES | |
} | |
}); | |
function l() { | |
this.vData = null, | |
this.float32VData = null, | |
this.uint32VData = null, | |
this.iData = null, | |
this.uint16IData = null, | |
this.vfm = null, | |
this.offset = 0, | |
this.vb = null, | |
this.ib = null, | |
this.vDirty = !1, | |
this.iDirty = !1, | |
this.enable = !0 | |
} | |
i.Primitive = c, | |
l.prototype.setVData = function(t) { | |
this.vData = t, | |
this.float32VData = null, | |
this.uint32VData = null | |
} | |
, | |
l.prototype.getVData = function(t) { | |
return t === Float32Array ? (this.float32VData || (this.float32VData = new Float32Array(this.vData.buffer,this.vData.byteOffset,this.vData.byteLength / 4)), | |
this.float32VData) : t === Uint32Array ? (this.uint32VData || (this.uint32VData = new Uint32Array(this.vData.buffer,this.vData.byteOffset,this.vData.byteLength / 4)), | |
this.uint32VData) : this.vData | |
} | |
, | |
l.prototype.getIData = function(t) { | |
return t === Uint16Array ? (this.uint16IData || (this.uint16IData = new Uint16Array(this.iData.buffer,this.iData.byteOffset,this.iData.byteLength / 2)), | |
this.uint16IData) : this.iData | |
} | |
} | |
), { | |
"../../renderer/gfx": 282 | |
}], | |
160: [(function(t, e, i) { | |
"use strict"; | |
i.__esModule = !0, | |
i.default = void 0; | |
var n = a(t("../renderer/assembler")) | |
, r = a(t("../../renderer/gfx")) | |
, s = a(t("../value-types/vec3")); | |
function a(t) { | |
return t && t.__esModule ? t : { | |
default: t | |
} | |
} | |
function o(t, e) { | |
return (o = Object.setPrototypeOf || function(t, e) { | |
return t.__proto__ = e, | |
t | |
} | |
)(t, e) | |
} | |
var c = t("./CCMeshRenderer") | |
, l = new s.default | |
, h = (function(t) { | |
var e, i; | |
function n() { | |
return t.apply(this, arguments) || this | |
} | |
i = t, | |
(e = n).prototype = Object.create(i.prototype), | |
e.prototype.constructor = e, | |
o(e, i); | |
var a = n.prototype; | |
return a.init = function(e) { | |
t.prototype.init.call(this, e), | |
this._worldDatas = {}, | |
this._renderNode = null | |
} | |
, | |
a.setRenderNode = function(t) { | |
this._renderNode = t | |
} | |
, | |
a.fillBuffers = function(t, e) { | |
if (t.mesh) { | |
t.mesh._uploadData(); | |
for (var i = e.cullingMask === t.node._cullingMask, n = t.enableAutoBatch, s = t._materials, a = t.mesh._subMeshes, o = t.mesh.subDatas, c = 0; c < a.length; c++) { | |
var l = a[c] | |
, h = o[c] | |
, u = s[c] || s[0]; | |
n && h.canBatch && l._primitiveType === r.default.PT_TRIANGLES ? (i && u.getHash() === e.material.getHash() || e._flush(), | |
e.material = u, | |
e.cullingMask = t.node._cullingMask, | |
e.node = e._dummyNode, | |
this._fillBuffer(t, h, e, c)) : (e._flush(), | |
e.material = u, | |
e.cullingMask = t.node._cullingMask, | |
e.node = this._renderNode, | |
e._flushIA(l)) | |
} | |
} | |
} | |
, | |
a._fillBuffer = function(t, e, i, n) { | |
var r = e.getVData(Float32Array) | |
, s = e.vfm | |
, a = r.byteLength / s._bytes | 0 | |
, o = e.getIData(Uint16Array) | |
, c = o.length | |
, l = i.getBuffer("mesh", s) | |
, h = l.request(a, c) | |
, u = h.indiceOffset | |
, f = h.byteOffset >> 2 | |
, d = h.vertexOffset | |
, _ = l._vData | |
, p = l._iData; | |
!i.worldMatDirty && this._worldDatas[n] || this._updateWorldVertices(n, a, r, s, t.node._worldMatrix), | |
_.set(this._worldDatas[n], f); | |
for (var v = 0; v < c; v++) | |
p[u + v] = d + o[v] | |
} | |
, | |
a._updateWorldVertices = function(t, e, i, n, a) { | |
var o = this._worldDatas[t]; | |
o || (o = this._worldDatas[t] = new Float32Array(i.length)).set(i); | |
for (var c = n._bytes / 4, h = n._elements, u = 0, f = h.length; u < f; u++) { | |
var d = h[u] | |
, _ = d.offset / 4; | |
if (d.name === r.default.ATTR_POSITION || d.name === r.default.ATTR_NORMAL) | |
for (var p = d.name === r.default.ATTR_NORMAL ? s.default.transformMat4Normal : s.default.transformMat4, v = 0; v < e; v++) { | |
var g = v * c + _; | |
l.x = i[g], | |
l.y = i[g + 1], | |
l.z = i[g + 2], | |
p(l, l, a), | |
o[g] = l.x, | |
o[g + 1] = l.y, | |
o[g + 2] = l.z | |
} | |
} | |
} | |
, | |
a._drawDebugDatas = function(t, e, i) { | |
var n = t._debugDatas[i]; | |
if (n) | |
for (var r = 0; r < n.length; r++) { | |
var s = n[r]; | |
if (s) { | |
var a = s.material; | |
e.material = a, | |
e._flushIA(s.ia |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment