836 lines
39 KiB
JavaScript
836 lines
39 KiB
JavaScript
|
let i = new Object()
|
||
|
function e(e, t) {
|
||
|
for (var n = 0; n < t.length; n++) {
|
||
|
var r = t[n];
|
||
|
r.enumerable = r.enumerable || !1,
|
||
|
r.configurable = !0,
|
||
|
"value"in r && (r.writable = !0),
|
||
|
Object.defineProperty(e, r.key, r)
|
||
|
}
|
||
|
}
|
||
|
const a = function(t, n, r) {
|
||
|
return n && e(t.prototype, n),
|
||
|
r && e(t, r),
|
||
|
t
|
||
|
}
|
||
|
|
||
|
const d = function() {
|
||
|
function e() {
|
||
|
u(this, e),
|
||
|
this.current = null,
|
||
|
this.previous = null,
|
||
|
this.currentTrackName = ""
|
||
|
}
|
||
|
return a(e, [{
|
||
|
key: "check",
|
||
|
value: function(e, t) {
|
||
|
e !== this.currentTrackName && (this.previous = this.current,
|
||
|
this.current = t.createHistory(),
|
||
|
this.currentTrackName = e)
|
||
|
}
|
||
|
}]),
|
||
|
e
|
||
|
}()
|
||
|
|
||
|
|
||
|
function u(e, t) {
|
||
|
if (!(e instanceof t)){}
|
||
|
//throw new TypeError("Cannot call a class as a function")
|
||
|
}
|
||
|
|
||
|
i.throttle = function (e, t) {
|
||
|
var n = !1
|
||
|
, r = void 0
|
||
|
, a = void 0;
|
||
|
return function i() {
|
||
|
for (var o = arguments.length, s = Array(o), l = 0; l < o; l++)
|
||
|
s[l] = arguments[l];
|
||
|
if (n)
|
||
|
return r = s,
|
||
|
void (a = this);
|
||
|
n = !0,
|
||
|
e.apply(this, s),
|
||
|
setTimeout((function () {
|
||
|
n = !1,
|
||
|
r && (i.apply(a, r),
|
||
|
r = null,
|
||
|
a = null)
|
||
|
}
|
||
|
), t)
|
||
|
}
|
||
|
}, i.isAvailable = function (e) {
|
||
|
var t = void 0 === e ? "undefined" : r(e);
|
||
|
return "undefined" !== t && ("number" === t || "bigint" === t ? !Number.isNaN(e) : "string" === t ? 0 !== e.length : "boolean" === t || "function" === t || "symbol" === t || ("object" === t ? null !== e && (e instanceof Array ? 0 !== e.length : e instanceof Map || e instanceof Set ? 0 !== e.size : e instanceof HTMLElement || 0 !== Object.keys(e).length) : void 0))
|
||
|
}, i.fromEntries = function (e) {
|
||
|
return [].concat(function (e) {
|
||
|
if (Array.isArray(e)) {
|
||
|
for (var t = 0, n = Array(e.length); t < e.length; t++)
|
||
|
n[t] = e[t];
|
||
|
return n
|
||
|
}
|
||
|
return Array.from(e)
|
||
|
}(e)).reduce((function (e, t) {
|
||
|
var n = function (e, t) {
|
||
|
if (Array.isArray(e))
|
||
|
return e;
|
||
|
if (Symbol.iterator in Object(e))
|
||
|
return function (e, t) {
|
||
|
var n = []
|
||
|
, r = !0
|
||
|
, a = !1
|
||
|
, i = void 0;
|
||
|
try {
|
||
|
for (var o, s = e[Symbol.iterator](); !(r = (o = s.next()).done) && (n.push(o.value),
|
||
|
2 !== n.length); r = !0)
|
||
|
;
|
||
|
} catch (e) {
|
||
|
a = !0,
|
||
|
i = e
|
||
|
} finally {
|
||
|
try {
|
||
|
!r && s.return && s.return()
|
||
|
} finally {
|
||
|
if (a)
|
||
|
throw i
|
||
|
}
|
||
|
}
|
||
|
return n
|
||
|
}(e);
|
||
|
throw new TypeError("Invalid attempt to destructure non-iterable instance")
|
||
|
}(t)
|
||
|
, r = n[0]
|
||
|
, a = n[1];
|
||
|
return e[r] = a,
|
||
|
e
|
||
|
}
|
||
|
), {})
|
||
|
}
|
||
|
|
||
|
const f = function (t) {
|
||
|
u(this, e);
|
||
|
var n = t || {}
|
||
|
, r = n.mode
|
||
|
, a = void 0 === r ? 1 : r
|
||
|
, i = n.name
|
||
|
, o = void 0 === i ? "" : i;
|
||
|
this.mode = a,
|
||
|
this.name = o
|
||
|
}
|
||
|
|
||
|
function l(e, t) {
|
||
|
if ("function" != typeof t && null !== t)
|
||
|
throw new TypeError("Super expression must either be null or a function, not " + typeof t);
|
||
|
e.prototype = Object.create(t && t.prototype, {
|
||
|
constructor: {
|
||
|
value: e,
|
||
|
enumerable: !1,
|
||
|
writable: !0,
|
||
|
configurable: !0
|
||
|
}
|
||
|
}),
|
||
|
t && (Object.setPrototypeOf ? Object.setPrototypeOf(e, t) : e.__proto__ = t)
|
||
|
}
|
||
|
|
||
|
function s(e, t) {
|
||
|
if (!e)
|
||
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
||
|
return !t || "object" != typeof t && "function" != typeof t ? e : t
|
||
|
}
|
||
|
|
||
|
const p = function (e) {
|
||
|
function t(e) {
|
||
|
u(this, t);
|
||
|
var n = s(this, (t.__proto__ || Object.getPrototypeOf(t)).call(this, e));
|
||
|
return n.copy(e),
|
||
|
n
|
||
|
}
|
||
|
|
||
|
return l(t, e),
|
||
|
a(t, [{
|
||
|
key: "copy",
|
||
|
value: function (e) {
|
||
|
var t = e || {}
|
||
|
, n = t.rotateOffset
|
||
|
, r = void 0 === n ? 0 : n
|
||
|
, a = t.rotateTime
|
||
|
, i = void 0 === a ? 2 : a
|
||
|
, o = t.rotateRange
|
||
|
, s = void 0 === o ? 10 : o
|
||
|
, l = t.rotateCenter
|
||
|
, u = void 0 === l ? 0 : l
|
||
|
, c = t.childOffset
|
||
|
, f = void 0 === c ? .25 : c
|
||
|
, d = t.spring
|
||
|
, h = void 0 === d ? 0 : d
|
||
|
, p = t.affectByLevel
|
||
|
, m = void 0 === p ? .1 : p
|
||
|
, v = t.springLevel
|
||
|
, g = void 0 === v ? 0 : v
|
||
|
, y = t.scaleYRange
|
||
|
, A = void 0 === y ? 0 : y
|
||
|
, b = t.scaleYTime
|
||
|
, x = void 0 === b ? 2 : b
|
||
|
, _ = t.scaleYCenter
|
||
|
, w = void 0 === _ ? 0 : _
|
||
|
, k = t.scaleYOffset
|
||
|
, S = void 0 === k ? 0 : k
|
||
|
, E = t.scaleYChildOffset
|
||
|
, C = void 0 === E ? .25 : E
|
||
|
, T = t.scaleYSpring
|
||
|
, B = void 0 === T ? 0 : T
|
||
|
, M = t.scaleYAffectByLevel
|
||
|
, I = void 0 === M ? .1 : M
|
||
|
, O = t.scaleXRange
|
||
|
, R = void 0 === O ? 0 : O
|
||
|
, L = t.scaleXTime
|
||
|
, P = void 0 === L ? 2 : L
|
||
|
, D = t.scaleXCenter
|
||
|
, F = void 0 === D ? 0 : D
|
||
|
, N = t.scaleXOffset
|
||
|
, j = void 0 === N ? 0 : N
|
||
|
, U = t.scaleXChildOffset
|
||
|
, z = void 0 === U ? .25 : U
|
||
|
, X = t.scaleXSpring
|
||
|
, Q = void 0 === X ? 0 : X
|
||
|
, Y = t.scaleXAffectByLevel
|
||
|
, H = void 0 === Y ? .1 : Y;
|
||
|
this.rotateOffset = r,
|
||
|
this.rotateCenter = u,
|
||
|
this.rotateTime = i,
|
||
|
this.rotateRange = s,
|
||
|
this.affectByLevel = m,
|
||
|
this.springLevel = g,
|
||
|
this.spring = h,
|
||
|
this.childOffset = f,
|
||
|
this.scaleYRange = A,
|
||
|
this.scaleYCenter = w,
|
||
|
this.scaleYTime = x,
|
||
|
this.scaleYOffset = S,
|
||
|
this.scaleYChildOffset = C,
|
||
|
this.scaleYSpring = B,
|
||
|
this.scaleYAffectByLevel = I,
|
||
|
this.scaleXRange = R,
|
||
|
this.scaleXCenter = F,
|
||
|
this.scaleXTime = P,
|
||
|
this.scaleXOffset = j,
|
||
|
this.scaleXChildOffset = z,
|
||
|
this.scaleXSpring = Q,
|
||
|
this.scaleXAffectByLevel = H,
|
||
|
this.sinScaleXSameAsY = R === A && w === F && P === x && j === S && z === C && Q === B && I === H
|
||
|
}
|
||
|
}]),
|
||
|
t
|
||
|
}(f)
|
||
|
|
||
|
|
||
|
const h = function (e) {
|
||
|
function t(e) {
|
||
|
u(this, t);
|
||
|
var n = s(this, (t.__proto__ || Object.getPrototypeOf(t)).call(this, e));
|
||
|
return n.copy(e),
|
||
|
n
|
||
|
}
|
||
|
|
||
|
return l(t, e),
|
||
|
a(t, [{
|
||
|
key: "copy",
|
||
|
value: function (e) {
|
||
|
var t = e || {}
|
||
|
, n = t.delay
|
||
|
, r = void 0 === n ? .1 : n
|
||
|
, a = t.speed
|
||
|
, i = void 0 === a ? .1 : a
|
||
|
, o = t.spring
|
||
|
, s = void 0 === o ? 0 : o
|
||
|
, l = t.affectByRange
|
||
|
, u = void 0 === l ? 1 : l
|
||
|
, c = t.affectByX
|
||
|
, f = void 0 === c ? 1 : c
|
||
|
, d = t.affectByY
|
||
|
, h = void 0 === d ? 1 : d
|
||
|
, p = t.rotateMoveRange
|
||
|
, m = void 0 === p ? 1 : p
|
||
|
, v = t.affectByLevel
|
||
|
, g = void 0 === v ? 0 : v
|
||
|
, y = t.springLevel
|
||
|
, A = void 0 === y ? 0 : y
|
||
|
, b = t.limitRange
|
||
|
, x = void 0 === b ? 10 : b;
|
||
|
this.delay = r,
|
||
|
this.speed = i,
|
||
|
this.affectByRange = u,
|
||
|
this.affectByX = f,
|
||
|
this.affectByY = h,
|
||
|
this.rotateMoveRange = m,
|
||
|
this.spring = s,
|
||
|
this.affectByLevel = g,
|
||
|
this.springLevel = A,
|
||
|
this.limitRange = x
|
||
|
}
|
||
|
}, {
|
||
|
key: "createHistory",
|
||
|
value: function () {
|
||
|
return {
|
||
|
speedX: 0,
|
||
|
speedY: 0,
|
||
|
buffer: []
|
||
|
}
|
||
|
}
|
||
|
}]),
|
||
|
t
|
||
|
}(f)
|
||
|
|
||
|
|
||
|
const m = function (e) {
|
||
|
function t(e) {
|
||
|
u(this, t);
|
||
|
var n = s(this, (t.__proto__ || Object.getPrototypeOf(t)).call(this, e));
|
||
|
return n.copy(e),
|
||
|
n
|
||
|
}
|
||
|
|
||
|
return l(t, e),
|
||
|
a(t, [{
|
||
|
key: "copy",
|
||
|
value: function (e) {
|
||
|
var t = e || {}
|
||
|
, n = t.moveXFreq
|
||
|
, r = void 0 === n ? 1 : n
|
||
|
, a = t.moveXAmp
|
||
|
, i = void 0 === a ? 0 : a
|
||
|
, o = t.moveXOctaves
|
||
|
, s = void 0 === o ? 0 : o
|
||
|
, l = t.moveXDelay
|
||
|
, u = void 0 === l ? 0 : l
|
||
|
, c = t.moveXCenter
|
||
|
, f = void 0 === c ? 0 : c
|
||
|
, d = t.moveXSeed
|
||
|
, h = void 0 === d ? Math.floor(1e4 * Math.random()) : d
|
||
|
, p = t.moveYFreq
|
||
|
, m = void 0 === p ? r : p
|
||
|
, v = t.moveYAmp
|
||
|
, g = void 0 === v ? i : v
|
||
|
, y = t.moveYOctaves
|
||
|
, A = void 0 === y ? s : y
|
||
|
, b = t.moveYDelay
|
||
|
, x = void 0 === b ? u : b
|
||
|
, _ = t.moveYCenter
|
||
|
, w = void 0 === _ ? f : _
|
||
|
, k = t.scaleXFreq
|
||
|
, S = void 0 === k ? 1 : k
|
||
|
, E = t.scaleXAmp
|
||
|
, C = void 0 === E ? 0 : E
|
||
|
, T = t.scaleXOctaves
|
||
|
, B = void 0 === T ? 0 : T
|
||
|
, M = t.scaleXDelay
|
||
|
, I = void 0 === M ? 0 : M
|
||
|
, O = t.scaleXCenter
|
||
|
, R = void 0 === O ? 0 : O
|
||
|
, L = t.scaleYFreq
|
||
|
, P = void 0 === L ? S : L
|
||
|
, D = t.scaleYAmp
|
||
|
, F = void 0 === D ? C : D
|
||
|
, N = t.scaleYOctaves
|
||
|
, j = void 0 === N ? B : N
|
||
|
, U = t.scaleYDelay
|
||
|
, z = void 0 === U ? I : U
|
||
|
, X = t.scaleYCenter
|
||
|
, Q = void 0 === X ? R : X
|
||
|
, Y = t.rotateSpeed
|
||
|
, H = void 0 === Y ? 0 : Y
|
||
|
, G = t.rotateFreq
|
||
|
, V = void 0 === G ? 1 : G
|
||
|
, q = t.rotateAmp
|
||
|
, W = void 0 === q ? 0 : q
|
||
|
, J = t.rotateOctaves
|
||
|
, Z = void 0 === J ? 0 : J
|
||
|
, K = t.rotateDelay
|
||
|
, $ = void 0 === K ? 0 : K
|
||
|
, ee = t.rotateCenter
|
||
|
, te = void 0 === ee ? 0 : ee
|
||
|
, ne = t.rotateFollowLimit
|
||
|
, re = void 0 === ne ? 0 : ne
|
||
|
, ae = t.rotateFollowSpeed
|
||
|
, ie = void 0 === ae ? .1 : ae
|
||
|
, oe = t.rotateFollowFlip
|
||
|
, se = void 0 === oe ? 0 : oe
|
||
|
, le = t.rotateFollowXMax
|
||
|
, ue = void 0 === le ? 20 : le
|
||
|
, ce = t.rotateFollowYMax
|
||
|
, fe = void 0 === ce ? 20 : ce;
|
||
|
this.moveXFreq = r,
|
||
|
this.moveXAmp = i,
|
||
|
this.moveXOctaves = s,
|
||
|
this.moveXDelay = u,
|
||
|
this.moveXCenter = f,
|
||
|
this.moveXSeed = h,
|
||
|
this.moveYFreq = m,
|
||
|
this.moveYAmp = g,
|
||
|
this.moveYOctaves = A,
|
||
|
this.moveYDelay = x,
|
||
|
this.moveYCenter = w,
|
||
|
this.moveYSameAsX = r === m && i === g && s === A && u === x && f === w,
|
||
|
this.scaleXFreq = S,
|
||
|
this.scaleXAmp = C,
|
||
|
this.scaleXOctaves = B,
|
||
|
this.scaleXDelay = I,
|
||
|
this.scaleXCenter = R,
|
||
|
this.scaleYFreq = P,
|
||
|
this.scaleYAmp = F,
|
||
|
this.scaleYOctaves = j,
|
||
|
this.scaleYDelay = z,
|
||
|
this.scaleYCenter = Q,
|
||
|
this.scaleYSameAsX = S === P && C === F && B === j && I === z && R === Q,
|
||
|
this.rotateSpeed = H,
|
||
|
this.rotateFreq = V,
|
||
|
this.rotateAmp = W,
|
||
|
this.rotateOctaves = Z,
|
||
|
this.rotateDelay = $,
|
||
|
this.rotateCenter = te,
|
||
|
this.rotateFollowEnable = 0 !== re,
|
||
|
this.rotateFollowLimit = re,
|
||
|
this.rotateFollowSpeed = ie,
|
||
|
this.rotateFollowFlip = se,
|
||
|
this.rotateFollowXMax = ue,
|
||
|
this.rotateFollowYMax = fe
|
||
|
}
|
||
|
}]),
|
||
|
t
|
||
|
}(f)
|
||
|
|
||
|
|
||
|
const v = function (e) {
|
||
|
function t(e) {
|
||
|
u(this, t);
|
||
|
var n = s(this, (t.__proto__ || Object.getPrototypeOf(t)).call(this, e));
|
||
|
return n.copy(e),
|
||
|
n
|
||
|
}
|
||
|
|
||
|
return l(t, e),
|
||
|
a(t, [{
|
||
|
key: "copy",
|
||
|
value: function (e) {
|
||
|
var t = e || {}
|
||
|
, n = t.delay
|
||
|
, r = void 0 === n ? .1 : n
|
||
|
, a = t.speed
|
||
|
, i = void 0 === a ? .1 : a
|
||
|
, o = t.spring
|
||
|
, s = void 0 === o ? 0 : o
|
||
|
, l = t.springRot
|
||
|
, u = void 0 === l ? 0 : l
|
||
|
, c = t.affectByLevel
|
||
|
, f = void 0 === c ? 0 : c
|
||
|
, d = t.springLevel
|
||
|
, h = void 0 === d ? 0 : d
|
||
|
, p = t.limitRange
|
||
|
, m = void 0 === p ? 80 : p
|
||
|
, v = t.rotateOffset
|
||
|
, g = void 0 === v ? 0 : v
|
||
|
, y = t.friction
|
||
|
, A = void 0 === y ? .7 : y
|
||
|
, b = t.springUseTarget
|
||
|
, x = void 0 !== b && b
|
||
|
, _ = t.windX
|
||
|
, w = void 0 === _ ? 0 : _
|
||
|
, k = t.windY
|
||
|
, S = void 0 === k ? 0 : k
|
||
|
, E = t.windFreq
|
||
|
, C = void 0 === E ? 1 : E
|
||
|
, T = t.windOctaves
|
||
|
, B = void 0 === T ? 0 : T
|
||
|
, M = t.windAccel
|
||
|
, I = void 0 === M ? 1 : M
|
||
|
, O = t.windDelay
|
||
|
, R = void 0 === O ? 0 : O
|
||
|
, L = t.gravityX
|
||
|
, P = void 0 === L ? 0 : L
|
||
|
, D = t.gravityY
|
||
|
, F = void 0 === D ? 0 : D;
|
||
|
this.delay = r,
|
||
|
this.speed = i,
|
||
|
this.spring = s,
|
||
|
this.springRot = u,
|
||
|
this.affectByLevel = f,
|
||
|
this.springLevel = h,
|
||
|
this.limitRange = m,
|
||
|
this.rotateOffset = g,
|
||
|
this.friction = A,
|
||
|
this.springUseTarget = x,
|
||
|
this.windX = w,
|
||
|
this.windY = S,
|
||
|
this.windFreq = C,
|
||
|
this.windAccel = I,
|
||
|
this.windDelay = R,
|
||
|
this.windOctaves = B,
|
||
|
this.gravityX = P,
|
||
|
this.gravityY = F,
|
||
|
this.hasWindForce = w || S
|
||
|
}
|
||
|
}]),
|
||
|
t
|
||
|
}(f)
|
||
|
|
||
|
const g = function (e) {
|
||
|
function t(e) {
|
||
|
u(this, t);
|
||
|
var n = s(this, (t.__proto__ || Object.getPrototypeOf(t)).call(this, e));
|
||
|
return n.copy(e),
|
||
|
n
|
||
|
}
|
||
|
|
||
|
return l(t, e),
|
||
|
a(t, [{
|
||
|
key: "copy",
|
||
|
value: function (e) {
|
||
|
var t = e || {}
|
||
|
, n = t.elasticSpring
|
||
|
, r = void 0 === n ? .4 : n
|
||
|
, a = t.elasticFriction
|
||
|
, i = void 0 === a ? .6 : a
|
||
|
, o = t.elasticSoftness
|
||
|
, s = void 0 === o ? 1 : o
|
||
|
, l = t.elasticSpringY
|
||
|
, u = void 0 === l ? r : l
|
||
|
, c = t.elasticFrictionY
|
||
|
, f = void 0 === c ? i : c
|
||
|
, d = t.elasticSoftnessY
|
||
|
, h = void 0 === d ? s : d;
|
||
|
this.elasticSpring = r,
|
||
|
this.elasticFriction = i,
|
||
|
this.elasticSoftness = s,
|
||
|
this.elasticSpringY = u,
|
||
|
this.elasticFrictionY = f,
|
||
|
this.elasticSoftnessY = h
|
||
|
}
|
||
|
}]),
|
||
|
t
|
||
|
}(f)
|
||
|
|
||
|
|
||
|
const y = function (e) {
|
||
|
function t(e) {
|
||
|
u(this, t);
|
||
|
var n = s(this, (t.__proto__ || Object.getPrototypeOf(t)).call(this, e));
|
||
|
return n.copy(e),
|
||
|
n
|
||
|
}
|
||
|
|
||
|
return l(t, e),
|
||
|
a(t, [{
|
||
|
key: "copy",
|
||
|
value: function (e) {
|
||
|
var t = e || {}
|
||
|
, n = t.delay
|
||
|
, r = void 0 === n ? 0 : n
|
||
|
, a = t.xFrames
|
||
|
, i = void 0 === a ? [] : a
|
||
|
, s = t.yFrames
|
||
|
, l = void 0 === s ? [] : s
|
||
|
, u = t.sxFrames
|
||
|
, c = void 0 === u ? [] : u
|
||
|
, f = t.syFrames
|
||
|
, d = void 0 === f ? [] : f;
|
||
|
this.delay = r,
|
||
|
this.xFrames = i.map((function (e) {
|
||
|
return new o.default(e)
|
||
|
}
|
||
|
)),
|
||
|
this.xFramesEnd = this.xFrames.length ? this.xFrames[this.xFrames.length - 1].start : 0,
|
||
|
this.yFrames = l.map((function (e) {
|
||
|
return new o.default(e)
|
||
|
}
|
||
|
)),
|
||
|
this.yFramesEnd = this.yFrames.length ? this.yFrames[this.yFrames.length - 1].start : 0,
|
||
|
this.sxFrames = c.map((function (e) {
|
||
|
return new o.default(e)
|
||
|
}
|
||
|
)),
|
||
|
this.sxFramesEnd = this.sxFrames.length ? this.sxFrames[this.sxFrames.length - 1].start : 0,
|
||
|
this.sYSameAsSX = 0 === d.length,
|
||
|
this.sYSameAsSX ? (this.syFrames = [],
|
||
|
this.syFramesEnd = 0) : (this.syFrames = d.map((function (e) {
|
||
|
return new o.default(e)
|
||
|
}
|
||
|
)),
|
||
|
this.syFramesEnd = this.syFrames.length ? this.syFrames[this.syFrames.length - 1].start : 0)
|
||
|
}
|
||
|
}]),
|
||
|
t
|
||
|
}(f);
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
const AutoBone = function () {
|
||
|
function e(t, n) {
|
||
|
u(this, e);
|
||
|
var r = t || {}, a = r.animation, o = void 0 === a ? {} : a, s = r.rootBoneName, l = void 0 === s ? "" : s,
|
||
|
c = r.endBoneName, f = void 0 === c ? [] : c, h = r.targetBoneName, p = void 0 === h ? "" : h,
|
||
|
m = r.targetEndBoneName, v = void 0 === m ? "" : m, g = r.targetWeight, y = void 0 === g ? 1 : g;
|
||
|
this.animation = (0, i.fromEntries)(Object.keys(o).map((function (e) {
|
||
|
return [e, o[e]]
|
||
|
})).map((function (t) {
|
||
|
var n = function (e, t) {
|
||
|
if (Array.isArray(e)) return e;
|
||
|
if (Symbol.iterator in Object(e)) return function (e, t) {
|
||
|
var n = [], r = !0, a = !1, i = void 0;
|
||
|
try {
|
||
|
for (var o, s = e[Symbol.iterator](); !(r = (o = s.next()).done) && (n.push(o.value), 2 !== n.length); r = !0) ;
|
||
|
} catch (e) {
|
||
|
a = !0, i = e
|
||
|
} finally {
|
||
|
try {
|
||
|
!r && s.return && s.return()
|
||
|
} finally {
|
||
|
if (a) throw i
|
||
|
}
|
||
|
}
|
||
|
return n
|
||
|
}(e);
|
||
|
throw new TypeError("Invalid attempt to destructure non-iterable instance")
|
||
|
}(t), r = n[0], a = n[1];
|
||
|
return [r, e.createAnimation(a)]
|
||
|
}))), this.rootMovement = 0, this.rootBoneName = l, this.endBoneName = Array.isArray(f) ? f : [f].filter((function (e) {
|
||
|
return "" !== e
|
||
|
})), this.targetBoneName = p, this.targetEndBoneName = v, this.targetWeight = y, this.history = new d, this.bind(n)
|
||
|
}
|
||
|
|
||
|
return a(e, [{
|
||
|
key: "bind", value: function (e) {
|
||
|
this.spineObj = e, this.rootBone = e.skeleton.findBone(this.rootBoneName), "" !== this.targetBoneName && (this.targetBone = e.skeleton.findBone(this.targetBoneName)), this.init(this.rootBone)
|
||
|
}
|
||
|
}, {
|
||
|
key: "init", value: function (e) {
|
||
|
var t = this, n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0;
|
||
|
e.initX = e.x, e.initY = e.y, e.initWorldX = e.worldX, e.initWorldY = e.worldY, e.initScaleX = e.scaleX, e.initScaleY = e.scaleY, e.initRotation = e.rotation, e.autoMovePrevWorldX = e.worldX, e.autoMovePrevWorldY = e.worldY, e.autoMoveSpeedX = 0, e.autoMoveSpeedY = 0, e.autoMoveFriction = 0, e.followRotation = 0, e.elasticSpeedX = 0, e.elasticSpeedY = 0, e.children.forEach((function (e) {
|
||
|
t.init(e, n + 1)
|
||
|
})), 0 === e.children.length && (e.tailAutoMovePrevWorldX = e.y * e.b + e.worldX, e.tailAutoMovePrevWorldY = e.y * e.d + e.worldY)
|
||
|
}
|
||
|
}, {
|
||
|
key: "reset", value: function () {
|
||
|
this.rootMovement = 0, this.resetBone()
|
||
|
}
|
||
|
}, {
|
||
|
key: "resetBone", value: function () {
|
||
|
var e = this, t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : this.rootBone;
|
||
|
t.worldX = t.initWorldX, t.worldY = t.initWorldY, t.scaleX = t.initScaleX, t.scaleY = t.initScaleY, t.rotation = t.initRotation, this.endBoneName.includes(t.name) || t.children.forEach((function (t) {
|
||
|
e.resetBone(t)
|
||
|
}))
|
||
|
}
|
||
|
}, {
|
||
|
key: "render", value: function (e, t, n, r) {
|
||
|
var a = null, i = this.currentAnimation, o = this.currentTrackName, s = 1;
|
||
|
this.history.current || this.history.check(this.currentTrackName, i), r && o !== r && (a = this.animation[r] || this.defaultAnimation, this.history.check(this.currentTrackName, i)), a && 1 !== n && (s = n, this.renderAutoBone(a, this.history.previous, e, t, 1)), this.renderAutoBone(i, this.history.current, e, t, s)
|
||
|
}
|
||
|
}, {
|
||
|
key: "renderAutoBone", value: function (e, t, n, r, a) {
|
||
|
var i = e.mode;
|
||
|
if (1 === i) this.updateSineMode(e, r, this.rootBone, this.targetBone, 0, a); else if (2 === i) this.updatePhysicMode(e, t, this.rootBone, r, n, a); else if (3 === i) {
|
||
|
var o = e.moveXFreq, s = e.moveXAmp, l = e.moveXOctaves, u = e.moveXDelay, f = e.moveXCenter,
|
||
|
d = e.moveYSameAsX, h = e.moveXSeed, p = 0 === s ? 0 : this.updateWiggleMode(o, s, l, r, u) + f;
|
||
|
if (this.rootBone.x = this.mixValue(this.rootBone.x, this.rootBone.initX + p, a), d) p = 0 === s ? 0 : this.updateWiggleMode(o, s, l, r, u + h) + f, this.rootBone.y = this.mixValue(this.rootBone.y, this.rootBone.initY + p, a); else {
|
||
|
var m = e.moveYFreq, v = e.moveYAmp, g = e.moveYOctaves, y = e.moveYDelay, A = e.moveYCenter;
|
||
|
p = 0 === v ? 0 : this.updateWiggleMode(m, v, g, r, y) + A, this.rootBone.y = this.mixValue(this.rootBone.y, this.rootBone.initY + p, a)
|
||
|
}
|
||
|
var b = e.scaleXFreq, x = e.scaleXAmp, _ = e.scaleXOctaves, w = e.scaleXDelay, k = e.scaleXCenter,
|
||
|
S = e.scaleYSameAsX;
|
||
|
if (p = 0 === x ? 0 : this.updateWiggleMode(b, x, _, r, w) + k, this.rootBone.scaleX = this.mixValue(this.rootBone.scaleX, this.rootBone.initScaleX + p, a), S) this.rootBone.scaleY = this.mixValue(this.rootBone.scaleY, this.rootBone.initScaleY + p, a); else {
|
||
|
var E = e.scaleYFreq, C = e.scaleYAmp, T = e.scaleYOctaves, B = e.scaleYDelay, M = e.scaleYCenter;
|
||
|
p = 0 === C ? 0 : this.updateWiggleMode(E, C, T, r, B) + M, this.rootBone.scaleY = this.mixValue(this.rootBone.scaleY, this.rootBone.initScaleY + p, a)
|
||
|
}
|
||
|
var I = e.rotateSpeed, O = e.rotateFreq, R = e.rotateAmp, L = e.rotateOctaves, P = e.rotateDelay,
|
||
|
D = e.rotateCenter, F = e.rotateFollowEnable, N = e.rotateFollowLimit, j = e.rotateFollowSpeed,
|
||
|
U = e.rotateFollowFlip, z = e.rotateFollowXMax, X = e.rotateFollowYMax;
|
||
|
if (p = this.rootBone.initRotation + r * I * 360 + D, p += 0 === R ? 0 : this.updateWiggleMode(O, R, L, r, P), F) {
|
||
|
var Q = this.rootBone.worldX - this.rootBone.autoMovePrevWorldX,
|
||
|
Y = this.rootBone.worldY - this.rootBone.autoMovePrevWorldY, H = void 0,
|
||
|
G = (H = 1 === U ? -N * Math.max(-1, Math.min(1, Q / z)) - N * Math.max(-1, Math.min(1, Y / X)) : (Math.atan2(Y, Q) * c + 360) % 360) - this.rootBone.followRotation;
|
||
|
G >= 180 ? H -= 360 : G <= -180 && (H += 360), this.rootBone.followRotation += Math.min(N, Math.max(-N, H - this.rootBone.followRotation)) * j, this.rootBone.followRotation = (this.rootBone.followRotation + 360) % 360, 2 === U && Math.abs(this.rootBone.followRotation - 180) < 90 && (this.rootBone.scaleY *= -1), p += this.rootBone.followRotation
|
||
|
}
|
||
|
this.rootBone.autoMovePrevWorldX = this.rootBone.worldX, this.rootBone.autoMovePrevWorldY = this.rootBone.worldY, this.rootBone.rotation = this.mixValue(this.rootBone.rotation, p, a)
|
||
|
} else if (4 === i) {
|
||
|
var V = this.rootBone.getWorldScale(), q = V.x, W = V.y, J = e.hasWindForce, Z = e.gravityX,
|
||
|
K = e.gravityY;
|
||
|
if (e.forceX = -Z, e.forceY = -K, J) {
|
||
|
var $ = .5 + .5 * this.updateWiggleMode(1 / e.windFreq, 1, e.windOctaves, r, e.windDelay, .8);
|
||
|
e.forceX += e.windX * $, e.forceY += e.windY * $
|
||
|
}
|
||
|
this.updateSpringMagic(e, this.rootBone, this.targetBone, r, n, 0, a, q * W < 0 ? -1 : 1)
|
||
|
} else 5 === i ? this.updateElasic(e, this.rootBone, n, a) : 6 === i && this.updateKeyFrameMode(e, this.rootBone, r, a)
|
||
|
}
|
||
|
}, {
|
||
|
key: "getHistoryRotate", value: function (e, t) {
|
||
|
for (var n = t.length - 1; n > -1; n--) {
|
||
|
var r = t[n];
|
||
|
if (r.time > e) {
|
||
|
for (var a = n - 1; a > -1; a--) {
|
||
|
var i = t[a];
|
||
|
if (e >= i.time) return i.delta + (r.delta - i.delta) * (e - i.time) / (r.time - i.time)
|
||
|
}
|
||
|
return 0
|
||
|
}
|
||
|
}
|
||
|
return 0
|
||
|
}
|
||
|
}, {
|
||
|
key: "mixValue", value: function (e, t, n) {
|
||
|
return e + (t - e) * n
|
||
|
}
|
||
|
}, {
|
||
|
key: "updateSineMode", value: function (e, t) {
|
||
|
var n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : this.rootBone,
|
||
|
r = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : this.targetBone, a = this,
|
||
|
i = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : 0, o = arguments[5];
|
||
|
if (!this.endBoneName.includes(n.data.name)) {
|
||
|
var s = r && r.data.name !== this.targetEndBoneName,
|
||
|
l = s ? this.mixValue(n.initRotation, r.rotation, this.targetWeight) : n.initRotation;
|
||
|
n.rotation = this.mixValue(n.rotation, l + Math.sin((e.rotateOffset - Math.pow(e.childOffset * i, 1 + e.spring) + t) * Math.PI * 2 / e.rotateTime) * e.rotateRange * Math.pow(1 + i * e.affectByLevel, 1 + e.springLevel) + e.rotateCenter, o);
|
||
|
var u = 0;
|
||
|
if (0 !== e.scaleYRange) {
|
||
|
var c = s ? this.mixValue(n.initScaleY, r.scaleY, this.targetWeight) : n.initScaleY;
|
||
|
if (u = Math.sin((e.scaleYOffset - Math.pow(e.scaleYChildOffset * i, 1 + e.scaleYSpring) + t) * Math.PI * 2 / e.scaleYTime) * e.scaleYRange * Math.pow(1 + i * e.scaleYAffectByLevel, 1 + e.springLevel) + e.scaleYCenter, n.scaleY = this.mixValue(n.scaleY, c + u, o), e.sinScaleXSameAsY) {
|
||
|
var f = s ? this.mixValue(n.initScaleX, r.scaleX, this.targetWeight) : n.initScaleX;
|
||
|
n.scaleX = this.mixValue(n.scaleX, f + u, o)
|
||
|
}
|
||
|
}
|
||
|
if (!e.sinScaleXSameAsY && 0 !== e.scaleXRange) {
|
||
|
var d = s ? this.mixValue(n.initScaleX, r.scaleX, this.targetWeight) : n.initScaleX;
|
||
|
u = Math.sin((e.scaleXOffset - Math.pow(e.scaleXChildOffset * i, 1 + e.scaleXSpring) + t) * Math.PI * 2 / e.scaleXTime) * e.scaleXRange * Math.pow(1 + i * e.scaleXAffectByLevel, 1 + e.springLevel) + e.scaleXCenter, n.scaleX = this.mixValue(n.scaleX, d + u, o)
|
||
|
}
|
||
|
n.children.forEach((function (n, l) {
|
||
|
var u = s ? r.children[l] : null;
|
||
|
a.updateSineMode(e, t, n, u, i + 1, o)
|
||
|
}))
|
||
|
}
|
||
|
}
|
||
|
}, {
|
||
|
key: "updateWiggleMode", value: function (e, t, n, r, a) {
|
||
|
for (var i = arguments.length > 5 && void 0 !== arguments[5] ? arguments[5] : .5, o = 0, s = 1, l = n + 1, u = 1 / (2 - 1 / Math.pow(2, l - 1)), c = u, f = 0, d = 0; d < l; d++) o += s * Math.sin(r * c * Math.PI * 2 / e + a), c = u * Math.pow(1.5, d + 1), f += s, s *= i;
|
||
|
return o / f * t
|
||
|
}
|
||
|
}, {
|
||
|
key: "updatePhysicMode", value: function (e, t, n, r, a, i) {
|
||
|
var o = this, s = Math.min(e.limitRange, Math.max(-e.limitRange, n.autoMovePrevWorldX - n.worldX)),
|
||
|
l = Math.min(e.limitRange, Math.max(-e.limitRange, n.autoMovePrevWorldY - n.worldY));
|
||
|
t.speedX += (e.affectByX * s - t.speedX) * e.speed * a, t.speedY += (e.affectByY * l - t.speedY) * e.speed * a, n.autoMovePrevWorldX = n.worldX, n.autoMovePrevWorldY = n.worldY;
|
||
|
var u = e.affectByRange * (-t.speedX * n.c + t.speedY * n.d);
|
||
|
n.rotation = this.mixValue(n.rotation, u + n.initRotation, i), t.buffer.push({
|
||
|
time: r, delta: u
|
||
|
}), t.buffer.length > 300 && t.buffer.shift(), n.children.forEach((function (n) {
|
||
|
o.updateFollowMode(e, t, n, r, 1, i)
|
||
|
}))
|
||
|
}
|
||
|
}, {
|
||
|
key: "updateFollowMode", value: function (e, t, n, r, a, i) {
|
||
|
var o = this;
|
||
|
this.endBoneName.includes(n.data.name) || (n.rotation = this.mixValue(n.rotation, n.initRotation + this.getHistoryRotate(r - e.delay * (1 + a * e.spring), t.buffer) * e.rotateMoveRange * Math.pow(1 + a * e.affectByLevel, 1 + e.springLevel), i), n.children.forEach((function (n) {
|
||
|
o.updateFollowMode(e, t, n, r, a + 1, i)
|
||
|
})))
|
||
|
}
|
||
|
}, {
|
||
|
key: "updateSpringMagic", value: function (e, t, n, r, a, i, o, s) {
|
||
|
var l = this;
|
||
|
if (!this.endBoneName.includes(t.data.name)) {
|
||
|
t.updateWorldTransform(), t.autoMovePrevWorldX = t.worldX, t.autoMovePrevWorldY = t.worldY;
|
||
|
var u = n && n.data.name !== this.targetEndBoneName,
|
||
|
f = u ? this.mixValue(t.initRotation, n.rotation, this.targetWeight) : t.initRotation,
|
||
|
d = e.springUseTarget && n ? n : t, h = 1 + i * e.affectByLevel, p = Math.pow(h, 1 + e.springLevel),
|
||
|
m = e.delay * p * (1 + e.springRot * h) * a * (0 === i ? 1 + e.spring : 1), v = e.friction,
|
||
|
g = e.forceX, y = e.forceY, A = 1 - e.windAccel;
|
||
|
if (t.children.length > 0) t.children.forEach((function (h, p) {
|
||
|
if (0 === p) {
|
||
|
var b = h.x, x = h.y, _ = b * d.a + x * d.b + t.worldX, w = b * d.c + x * d.d + t.worldY;
|
||
|
_ = (_ - h.autoMovePrevWorldX) * m, w = (w - h.autoMovePrevWorldY) * m, t.autoMoveSpeedX += _, t.autoMoveSpeedY += w, t.autoMoveSpeedX *= v, t.autoMoveSpeedY *= v, t.autoMoveSpeedX += g * e.windAccel, t.autoMoveSpeedY += y * e.windAccel;
|
||
|
var k = h.autoMovePrevWorldX + t.autoMoveSpeedX + g * A,
|
||
|
S = h.autoMovePrevWorldY + t.autoMoveSpeedY + y * A,
|
||
|
E = t.worldToLocalRotation(s * Math.atan2(S - t.worldY, s * (k - t.worldX)) * c + (0 === i ? e.rotateOffset : 0)),
|
||
|
C = Math.min(e.limitRange, Math.max(-e.limitRange, E - f)) + f;
|
||
|
t.rotation = l.mixValue(t.rotation, f * e.speed + (1 - e.speed) * C, o * t.autoMoveFriction), t.updateWorldTransform()
|
||
|
}
|
||
|
var T = u ? n.children[p] : null;
|
||
|
l.updateSpringMagic(e, h, T, r, a, i + 1, o, s)
|
||
|
})); else {
|
||
|
var b = t.x, x = t.y, _ = b * d.a + x * d.b + t.worldX, w = b * d.c + x * d.d + t.worldY;
|
||
|
_ = (_ - t.tailAutoMovePrevWorldX) * m, w = (w - t.tailAutoMovePrevWorldY) * m, t.autoMoveSpeedX += _, t.autoMoveSpeedY += w, t.autoMoveSpeedX *= v, t.autoMoveSpeedY *= v, t.autoMoveSpeedX += g * e.windAccel, t.autoMoveSpeedY += y * e.windAccel;
|
||
|
var k = t.tailAutoMovePrevWorldX + t.autoMoveSpeedX + g * A,
|
||
|
S = t.tailAutoMovePrevWorldY + t.autoMoveSpeedY + y * A,
|
||
|
E = t.worldToLocalRotation(s * Math.atan2(S - t.worldY, s * (k - t.worldX)) * c + (0 === i ? e.rotateOffset : 0)),
|
||
|
C = Math.min(e.limitRange, Math.max(-e.limitRange, E - f)) + f;
|
||
|
t.rotation = this.mixValue(t.rotation, f * e.speed + (1 - e.speed) * C, o * t.autoMoveFriction), t.updateWorldTransform(), t.tailAutoMovePrevWorldX = b * t.a + x * t.b + t.worldX, t.tailAutoMovePrevWorldY = b * t.c + x * t.d + t.worldY
|
||
|
}
|
||
|
t.autoMoveFriction += .1 * (1 - t.autoMoveFriction) * a
|
||
|
}
|
||
|
}
|
||
|
}, {
|
||
|
key: "updateElasic", value: function (e, t, n, r) {
|
||
|
if (!this.endBoneName.includes(t.data.name)) {
|
||
|
var a = t.parent, i = t.initX, o = t.initY, s = i * a.a + o * a.b + a.worldX,
|
||
|
l = i * a.c + o * a.d + a.worldY, u = (s - t.autoMovePrevWorldX) * e.elasticSpring * n,
|
||
|
c = (l - t.autoMovePrevWorldY) * e.elasticSpringY * n;
|
||
|
t.elasticSpeedX += u, t.elasticSpeedX *= e.elasticFriction, t.elasticSpeedY += c, t.elasticSpeedY *= e.elasticFrictionY, t.autoMovePrevWorldX += t.elasticSpeedX, t.autoMovePrevWorldY += t.elasticSpeedY;
|
||
|
var f = a.worldToLocal({
|
||
|
x: t.autoMovePrevWorldX, y: t.autoMovePrevWorldY
|
||
|
}), d = f.x, h = f.y;
|
||
|
isNaN(d) || isNaN(h) || (t.x = this.mixValue(t.x, d * e.elasticSoftness + (1 - e.elasticSoftness) * t.initX, r * t.autoMoveFriction), t.y = this.mixValue(t.y, h * e.elasticSoftness + (1 - e.elasticSoftnessY) * t.initY, r * t.autoMoveFriction), t.autoMoveFriction += .1 * (1 - t.autoMoveFriction) * n)
|
||
|
}
|
||
|
}
|
||
|
}, {
|
||
|
key: "updateKeyFrameMode", value: function (e, t, n, r) {
|
||
|
var a = n + e.delay + 1e3, i = void 0, s = void 0, l = void 0, u = void 0, c = void 0, f = void 0,
|
||
|
d = void 0;
|
||
|
e.xFramesEnd > 0 && (i = a % e.xFramesEnd, l = (s = o.default.getBlock(e.xFrames, i)).start.value, u = s.end.value, c = s.start.start, f = s.end.start, d = s.end.easeFunc, t.x = this.mixValue(t.x, (u - l) * d((i - c) / (f - c)) + l, r)), e.yFramesEnd > 0 && (i = a % e.yFramesEnd, l = (s = o.default.getBlock(e.yFrames, i)).start.value, u = s.end.value, c = s.start.start, f = s.end.start, d = s.end.easeFunc, t.y = this.mixValue(t.y, (u - l) * d((i - c) / (f - c)) + l, r)), e.sxFramesEnd > 0 && (i = a % e.sxFramesEnd, l = (s = o.default.getBlock(e.sxFrames, i)).start.value, u = s.end.value, c = s.start.start, f = s.end.start, d = s.end.easeFunc, t.scaleX = this.mixValue(t.scaleX, (u - l) * d((i - c) / (f - c)) + l, r), e.sYSameAsSX ? t.scaleY = t.scaleX : e.syFramesEnd > 0 && (i = a % e.syFramesEnd, l = (s = o.default.getBlock(e.syFrames, i)).start.value, u = s.end.value, c = s.start.start, f = s.end.start, d = s.end.easeFunc, t.scaleY = this.mixValue(t.scaleY, (u - l) * d((i - c) / (f - c)) + l, r)))
|
||
|
}
|
||
|
}, {
|
||
|
key: "currentTrackName", get: function () {
|
||
|
return this.spineObj.state.tracks.length ? this.spineObj.state.tracks[0].animation.name : ""
|
||
|
}
|
||
|
}, {
|
||
|
key: "currentAnimation", get: function () {
|
||
|
var e = this.spineObj.state.tracks[0].animation.name;
|
||
|
return this.animation[e] || this.defaultAnimation
|
||
|
}
|
||
|
}, {
|
||
|
key: "defaultAnimation", get: function () {
|
||
|
return this.animation.default
|
||
|
}
|
||
|
}], [{
|
||
|
key: "createAnimation", value: function (e) {
|
||
|
switch (e.mode) {
|
||
|
case 1:
|
||
|
return new p(e);
|
||
|
case 2:
|
||
|
return new h(e);
|
||
|
case 3:
|
||
|
return new m(e);
|
||
|
case 4:
|
||
|
return new v(e);
|
||
|
case 5:
|
||
|
return new g(e);
|
||
|
case 6:
|
||
|
return new y(e);
|
||
|
default:
|
||
|
return new f(e)
|
||
|
}
|
||
|
}
|
||
|
}]), e
|
||
|
}()
|
||
|
console.log(new AutoBone({
|
||
|
"rootBoneName": "hair_05",
|
||
|
"animation": {
|
||
|
"default": {
|
||
|
"name": "default",
|
||
|
"mode": 1,
|
||
|
"rotateCenter": 0,
|
||
|
"rotateTime": 2,
|
||
|
"rotateRange": 2,
|
||
|
"rotateOffset": 0,
|
||
|
"childOffset": 0.25,
|
||
|
"spring": 0,
|
||
|
"affectByLevel": 0.1,
|
||
|
"springLevel": 0
|
||
|
}
|
||
|
}
|
||
|
}, {}))
|