vuepress-plugin-helper-live2d
Version:
VuePress集成Live2D看板娘. Live2D plugin for VuePress.
1,744 lines (1,638 loc) • 263 kB
JavaScript
! function (t) {
// 修复Node同构代码的问题
if (typeof navigator === "undefined") {
return;
}
function i(r) {
if (e[r])
return e[r].exports;
var o = e[r] = {
i: r,
l: !1,
exports: {}
};
return t[r].call(o.exports, o, o.exports, i),
o.l = !0,
o.exports
}
var e = {};
i.m = t,
i.c = e,
i.d = function (t, e, r) {
i.o(t, e) || Object.defineProperty(t, e, {
configurable: !1,
enumerable: !0,
get: r
})
},
i.n = function (t) {
var e = t && t.__esModule ? function () {
return t.default
} :
function () {
return t
};
return i.d(e, "a", e),
e
},
i.o = function (t, i) {
return Object.prototype.hasOwnProperty.call(t, i)
},
i.p = "",
i(i.s = 4)
}([function (t, i, e) {
"use strict";
function r() {
this.live2DModel = null,
this.modelMatrix = null,
this.eyeBlink = null,
this.physics = null,
this.pose = null,
this.debugMode = !1,
this.initialized = !1,
this.updating = !1,
this.alpha = 1,
this.accAlpha = 0,
this.lipSync = !1,
this.lipSyncValue = 0,
this.accelX = 0,
this.accelY = 0,
this.accelZ = 0,
this.dragX = 0,
this.dragY = 0,
this.startTimeMSec = null,
this.mainMotionManager = new h,
this.expressionManager = new h,
this.motions = {},
this.expressions = {},
this.isTexLoaded = !1
}
function o() {
AMotion.prototype.constructor.call(this),
this.paramList = new Array
}
function n() {
this.id = "",
this.type = -1,
this.value = null
}
function s() {
this.nextBlinkTime = null,
this.stateStartTime = null,
this.blinkIntervalMsec = null,
this.eyeState = g.STATE_FIRST,
this.blinkIntervalMsec = 4e3,
this.closingMotionMsec = 100,
this.closedMotionMsec = 50,
this.openingMotionMsec = 150,
this.closeIfZero = !0,
this.eyeID_L = "PARAM_EYE_L_OPEN",
this.eyeID_R = "PARAM_EYE_R_OPEN"
}
function _() {
this.tr = new Float32Array(16),
this.identity()
}
function a(t, i) {
_.prototype.constructor.call(this),
this.width = t,
this.height = i
}
function h() {
MotionQueueManager.prototype.constructor.call(this),
this.currentPriority = null,
this.reservePriority = null,
this.super = MotionQueueManager.prototype
}
function l() {
this.physicsList = new Array,
this.startTimeMSec = UtSystem.getUserTimeMSec()
}
function $() {
this.lastTime = 0,
this.lastModel = null,
this.partsGroups = new Array
}
function u(t) {
this.paramIndex = -1,
this.partsIndex = -1,
this.link = null,
this.id = t
}
function p() {
this.EPSILON = .01,
this.faceTargetX = 0,
this.faceTargetY = 0,
this.faceX = 0,
this.faceY = 0,
this.faceVX = 0,
this.faceVY = 0,
this.lastTimeSec = 0
}
function f() {
_.prototype.constructor.call(this),
this.screenLeft = null,
this.screenRight = null,
this.screenTop = null,
this.screenBottom = null,
this.maxLeft = null,
this.maxRight = null,
this.maxTop = null,
this.maxBottom = null,
this.max = Number.MAX_VALUE,
this.min = 0
}
function c() {}
var d = 0;
r.prototype.getModelMatrix = function () {
return this.modelMatrix
},
r.prototype.setAlpha = function (t) {
t > .999 && (t = 1),
t < .001 && (t = 0),
this.alpha = t
},
r.prototype.getAlpha = function () {
return this.alpha
},
r.prototype.isInitialized = function () {
return this.initialized
},
r.prototype.setInitialized = function (t) {
this.initialized = t
},
r.prototype.isUpdating = function () {
return this.updating
},
r.prototype.setUpdating = function (t) {
this.updating = t
},
r.prototype.getLive2DModel = function () {
return this.live2DModel
},
r.prototype.setLipSync = function (t) {
this.lipSync = t
},
r.prototype.setLipSyncValue = function (t) {
this.lipSyncValue = t
},
r.prototype.setAccel = function (t, i, e) {
this.accelX = t,
this.accelY = i,
this.accelZ = e
},
r.prototype.setDrag = function (t, i) {
this.dragX = t,
this.dragY = i
},
r.prototype.getMainMotionManager = function () {
return this.mainMotionManager
},
r.prototype.getExpressionManager = function () {
return this.expressionManager
},
r.prototype.loadModelData = function (t, i) {
var e = c.getPlatformManager();
this.debugMode && e.log("Load model : " + t);
var r = this;
e.loadLive2DModel(t, function (t) {
if (r.live2DModel = t,
r.live2DModel.saveParam(),
0 != Live2D.getError())
return void console.error("Error : Failed to loadModelData().");
r.modelMatrix = new a(r.live2DModel.getCanvasWidth(), r.live2DModel.getCanvasHeight()),
r.modelMatrix.setWidth(2),
r.modelMatrix.setCenterPosition(0, 0),
i(r.live2DModel)
})
},
r.prototype.loadTexture = function (t, i, e) {
d++;
var r = c.getPlatformManager();
this.debugMode && r.log("Load Texture : " + i);
var o = this;
r.loadTexture(this.live2DModel, t, i, function () {
d--,
0 == d && (o.isTexLoaded = !0),
"function" == typeof e && e()
})
},
r.prototype.loadMotion = function (t, i, e) {
var r = c.getPlatformManager();
this.debugMode && r.log("Load Motion : " + i);
var o = null,
n = this;
r.loadBytes(i, function (i) {
o = Live2DMotion.loadMotion(i),
null != t && (n.motions[t] = o),
e(o)
})
},
r.prototype.loadExpression = function (t, i, e) {
var r = c.getPlatformManager();
this.debugMode && r.log("Load Expression : " + i);
var n = this;
r.loadBytes(i, function (i) {
null != t && (n.expressions[t] = o.loadJson(i)),
"function" == typeof e && e()
})
},
r.prototype.loadPose = function (t, i) {
var e = c.getPlatformManager();
this.debugMode && e.log("Load Pose : " + t);
var r = this;
try {
e.loadBytes(t, function (t) {
r.pose = $.load(t),
"function" == typeof i && i()
})
} catch (t) {
console.warn(t)
}
},
r.prototype.loadPhysics = function (t) {
var i = c.getPlatformManager();
this.debugMode && i.log("Load Physics : " + t);
var e = this;
try {
i.loadBytes(t, function (t) {
e.physics = l.load(t)
})
} catch (t) {
console.warn(t)
}
},
r.prototype.hitTestSimple = function (t, i, e) {
if (null === this.live2DModel)
return !1;
var r = this.live2DModel.getDrawDataIndex(t);
if (r < 0)
return !1;
for (var o = this.live2DModel.getTransformedPoints(r), n = this.live2DModel.getCanvasWidth(), s = 0, _ = this.live2DModel.getCanvasHeight(), a = 0, h = 0; h < o.length; h += 2) {
var l = o[h],
$ = o[h + 1];
l < n && (n = l),
l > s && (s = l),
$ < _ && (_ = $),
$ > a && (a = $)
}
var u = this.modelMatrix.invertTransformX(i),
p = this.modelMatrix.invertTransformY(e);
return n <= u && u <= s && _ <= p && p <= a
},
r.prototype.hitTestSimpleCustom = function (t, i, e, r) {
return null !== this.live2DModel && (e >= t[0] && e <= i[0] && r <= t[1] && r >= i[1])
},
o.prototype = new AMotion,
o.EXPRESSION_DEFAULT = "DEFAULT",
o.TYPE_SET = 0,
o.TYPE_ADD = 1,
o.TYPE_MULT = 2,
o.loadJson = function (t) {
var i = new o,
e = c.getPlatformManager(),
r = e.jsonParseFromBytes(t);
if (i.setFadeIn(parseInt(r.fade_in) > 0 ? parseInt(r.fade_in) : 1e3),
i.setFadeOut(parseInt(r.fade_out) > 0 ? parseInt(r.fade_out) : 1e3),
null == r.params)
return i;
var s = r.params,
_ = s.length;
i.paramList = [];
for (var a = 0; a < _; a++) {
var h = s[a],
l = h.id.toString(),
$ = parseFloat(h.val),
u = o.TYPE_ADD,
p = null != h.calc ? h.calc.toString() : "add";
if ((u = "add" === p ? o.TYPE_ADD : "mult" === p ? o.TYPE_MULT : "set" === p ? o.TYPE_SET : o.TYPE_ADD) == o.TYPE_ADD) {
var f = null == h.def ? 0 : parseFloat(h.def);
$ -= f
} else if (u == o.TYPE_MULT) {
var f = null == h.def ? 1 : parseFloat(h.def);
0 == f && (f = 1),
$ /= f
}
var d = new n;
d.id = l,
d.type = u,
d.value = $,
i.paramList.push(d)
}
return i
},
o.prototype.updateParamExe = function (t, i, e, r) {
for (var n = this.paramList.length - 1; n >= 0; --n) {
var s = this.paramList[n];
s.type == o.TYPE_ADD ? t.addToParamFloat(s.id, s.value, e) : s.type == o.TYPE_MULT ? t.multParamFloat(s.id, s.value, e) : s.type == o.TYPE_SET && t.setParamFloat(s.id, s.value, e)
}
},
s.prototype.calcNextBlink = function () {
return UtSystem.getUserTimeMSec() + Math.random() * (2 * this.blinkIntervalMsec - 1)
},
s.prototype.setInterval = function (t) {
this.blinkIntervalMsec = t
},
s.prototype.setEyeMotion = function (t, i, e) {
this.closingMotionMsec = t,
this.closedMotionMsec = i,
this.openingMotionMsec = e
},
s.prototype.updateParam = function (t) {
var i, e = UtSystem.getUserTimeMSec(),
r = 0;
switch (this.eyeState) {
case g.STATE_CLOSING:
r = (e - this.stateStartTime) / this.closingMotionMsec,
r >= 1 && (r = 1,
this.eyeState = g.STATE_CLOSED,
this.stateStartTime = e),
i = 1 - r;
break;
case g.STATE_CLOSED:
r = (e - this.stateStartTime) / this.closedMotionMsec,
r >= 1 && (this.eyeState = g.STATE_OPENING,
this.stateStartTime = e),
i = 0;
break;
case g.STATE_OPENING:
r = (e - this.stateStartTime) / this.openingMotionMsec,
r >= 1 && (r = 1,
this.eyeState = g.STATE_INTERVAL,
this.nextBlinkTime = this.calcNextBlink()),
i = r;
break;
case g.STATE_INTERVAL:
this.nextBlinkTime < e && (this.eyeState = g.STATE_CLOSING,
this.stateStartTime = e),
i = 1;
break;
case g.STATE_FIRST:
default:
this.eyeState = g.STATE_INTERVAL,
this.nextBlinkTime = this.calcNextBlink(),
i = 1
}
this.closeIfZero || (i = -i),
t.setParamFloat(this.eyeID_L, i),
t.setParamFloat(this.eyeID_R, i)
};
var g = function () {};
g.STATE_FIRST = "STATE_FIRST",
g.STATE_INTERVAL = "STATE_INTERVAL",
g.STATE_CLOSING = "STATE_CLOSING",
g.STATE_CLOSED = "STATE_CLOSED",
g.STATE_OPENING = "STATE_OPENING",
_.mul = function (t, i, e) {
var r, o, n, s = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
for (r = 0; r < 4; r++)
for (o = 0; o < 4; o++)
for (n = 0; n < 4; n++)
s[r + 4 * o] += t[r + 4 * n] * i[n + 4 * o];
for (r = 0; r < 16; r++)
e[r] = s[r]
},
_.prototype.identity = function () {
for (var t = 0; t < 16; t++)
this.tr[t] = t % 5 == 0 ? 1 : 0
},
_.prototype.getArray = function () {
return this.tr
},
_.prototype.getCopyMatrix = function () {
return new Float32Array(this.tr)
},
_.prototype.setMatrix = function (t) {
if (null != this.tr && this.tr.length == this.tr.length)
for (var i = 0; i < 16; i++)
this.tr[i] = t[i]
},
_.prototype.getScaleX = function () {
return this.tr[0]
},
_.prototype.getScaleY = function () {
return this.tr[5]
},
_.prototype.transformX = function (t) {
return this.tr[0] * t + this.tr[12]
},
_.prototype.transformY = function (t) {
return this.tr[5] * t + this.tr[13]
},
_.prototype.invertTransformX = function (t) {
return (t - this.tr[12]) / this.tr[0]
},
_.prototype.invertTransformY = function (t) {
return (t - this.tr[13]) / this.tr[5]
},
_.prototype.multTranslate = function (t, i) {
var e = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, t, i, 0, 1];
_.mul(e, this.tr, this.tr)
},
_.prototype.translate = function (t, i) {
this.tr[12] = t,
this.tr[13] = i
},
_.prototype.translateX = function (t) {
this.tr[12] = t
},
_.prototype.translateY = function (t) {
this.tr[13] = t
},
_.prototype.multScale = function (t, i) {
var e = [t, 0, 0, 0, 0, i, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
_.mul(e, this.tr, this.tr)
},
_.prototype.scale = function (t, i) {
this.tr[0] = t,
this.tr[5] = i
},
a.prototype = new _,
a.prototype.setPosition = function (t, i) {
this.translate(t, i)
},
a.prototype.setCenterPosition = function (t, i) {
var e = this.width * this.getScaleX(),
r = this.height * this.getScaleY();
this.translate(t - e / 2, i - r / 2)
},
a.prototype.top = function (t) {
this.setY(t)
},
a.prototype.bottom = function (t) {
var i = this.height * this.getScaleY();
this.translateY(t - i)
},
a.prototype.left = function (t) {
this.setX(t)
},
a.prototype.right = function (t) {
var i = this.width * this.getScaleX();
this.translateX(t - i)
},
a.prototype.centerX = function (t) {
var i = this.width * this.getScaleX();
this.translateX(t - i / 2)
},
a.prototype.centerY = function (t) {
var i = this.height * this.getScaleY();
this.translateY(t - i / 2)
},
a.prototype.setX = function (t) {
this.translateX(t)
},
a.prototype.setY = function (t) {
this.translateY(t)
},
a.prototype.setHeight = function (t) {
var i = t / this.height,
e = -i;
this.scale(i, e)
},
a.prototype.setWidth = function (t) {
var i = t / this.width,
e = -i;
this.scale(i, e)
},
h.prototype = new MotionQueueManager,
h.prototype.getCurrentPriority = function () {
return this.currentPriority
},
h.prototype.getReservePriority = function () {
return this.reservePriority
},
h.prototype.reserveMotion = function (t) {
return !(this.reservePriority >= t) && (!(this.currentPriority >= t) && (this.reservePriority = t,
!0))
},
h.prototype.setReservePriority = function (t) {
this.reservePriority = t
},
h.prototype.updateParam = function (t) {
var i = MotionQueueManager.prototype.updateParam.call(this, t);
return this.isFinished() && (this.currentPriority = 0),
i
},
h.prototype.startMotionPrio = function (t, i) {
return i == this.reservePriority && (this.reservePriority = 0),
this.currentPriority = i,
this.startMotion(t, !1)
},
l.load = function (t) {
for (var i = new l, e = c.getPlatformManager(), r = e.jsonParseFromBytes(t), o = r.physics_hair, n = o.length, s = 0; s < n; s++) {
var _ = o[s],
a = new PhysicsHair,
h = _.setup,
$ = parseFloat(h.length),
u = parseFloat(h.regist),
p = parseFloat(h.mass);
a.setup($, u, p);
for (var f = _.src, d = f.length, g = 0; g < d; g++) {
var y = f[g],
m = y.id,
T = PhysicsHair.Src.SRC_TO_X,
P = y.ptype;
"x" === P ? T = PhysicsHair.Src.SRC_TO_X : "y" === P ? T = PhysicsHair.Src.SRC_TO_Y : "angle" === P ? T = PhysicsHair.Src.SRC_TO_G_ANGLE : UtDebug.error("live2d", "Invalid parameter:PhysicsHair.Src");
var S = parseFloat(y.scale),
v = parseFloat(y.weight);
a.addSrcParam(T, m, S, v)
}
for (var L = _.targets, M = L.length, g = 0; g < M; g++) {
var E = L[g],
m = E.id,
T = PhysicsHair.Target.TARGET_FROM_ANGLE,
P = E.ptype;
"angle" === P ? T = PhysicsHair.Target.TARGET_FROM_ANGLE : "angle_v" === P ? T = PhysicsHair.Target.TARGET_FROM_ANGLE_V : UtDebug.error("live2d", "Invalid parameter:PhysicsHair.Target");
var S = parseFloat(E.scale),
v = parseFloat(E.weight);
a.addTargetParam(T, m, S, v)
}
i.physicsList.push(a)
}
return i
},
l.prototype.updateParam = function (t) {
for (var i = UtSystem.getUserTimeMSec() - this.startTimeMSec, e = 0; e < this.physicsList.length; e++)
this.physicsList[e].update(t, i)
},
$.load = function (t) {
for (var i = new $, e = c.getPlatformManager(), r = e.jsonParseFromBytes(t), o = r.parts_visible, n = o.length, s = 0; s < n; s++) {
for (var _ = o[s], a = _.group, h = a.length, l = new Array, p = 0; p < h; p++) {
var f = a[p],
d = new u(f.id);
if (l[p] = d,
null != f.link) {
var g = f.link,
y = g.length;
d.link = new Array;
for (var m = 0; m < y; m++) {
var T = new u(g[m]);
d.link.push(T)
}
}
}
i.partsGroups.push(l)
}
return i
},
$.prototype.updateParam = function (t) {
if (null != t) {
t != this.lastModel && this.initParam(t),
this.lastModel = t;
var i = UtSystem.getUserTimeMSec(),
e = 0 == this.lastTime ? 0 : (i - this.lastTime) / 1e3;
this.lastTime = i,
e < 0 && (e = 0);
for (var r = 0; r < this.partsGroups.length; r++)
this.normalizePartsOpacityGroup(t, this.partsGroups[r], e),
this.copyOpacityOtherParts(t, this.partsGroups[r])
}
},
$.prototype.initParam = function (t) {
if (null != t)
for (var i = 0; i < this.partsGroups.length; i++)
for (var e = this.partsGroups[i], r = 0; r < e.length; r++) {
e[r].initIndex(t);
var o = e[r].partsIndex,
n = e[r].paramIndex;
if (!(o < 0)) {
var s = 0 != t.getParamFloat(n);
if (t.setPartsOpacity(o, s ? 1 : 0),
t.setParamFloat(n, s ? 1 : 0),
null != e[r].link)
for (var _ = 0; _ < e[r].link.length; _++)
e[r].link[_].initIndex(t)
}
}
},
$.prototype.normalizePartsOpacityGroup = function (t, i, e) {
for (var r = -1, o = 1, n = 0; n < i.length; n++) {
var s = i[n].partsIndex,
_ = i[n].paramIndex;
if (!(s < 0) && 0 != t.getParamFloat(_)) {
if (r >= 0)
break;
r = n,
o = t.getPartsOpacity(s),
o += e / .5,
o > 1 && (o = 1)
}
}
r < 0 && (r = 0,
o = 1);
for (var n = 0; n < i.length; n++) {
var s = i[n].partsIndex;
if (!(s < 0))
if (r == n)
t.setPartsOpacity(s, o);
else {
var a, h = t.getPartsOpacity(s);
a = o < .5 ? -.5 * o / .5 + 1 : .5 * (1 - o) / .5;
var l = (1 - a) * (1 - o);
l > .15 && (a = 1 - .15 / (1 - o)),
h > a && (h = a),
t.setPartsOpacity(s, h)
}
}
},
$.prototype.copyOpacityOtherParts = function (t, i) {
for (var e = 0; e < i.length; e++) {
var r = i[e];
if (null != r.link && !(r.partsIndex < 0))
for (var o = t.getPartsOpacity(r.partsIndex), n = 0; n < r.link.length; n++) {
var s = r.link[n];
s.partsIndex < 0 || t.setPartsOpacity(s.partsIndex, o)
}
}
},
u.prototype.initIndex = function (t) {
this.paramIndex = t.getParamIndex("VISIBLE:" + this.id),
this.partsIndex = t.getPartsDataIndex(PartsDataID.getID(this.id)),
t.setParamFloat(this.paramIndex, 1)
},
p.FRAME_RATE = 30,
p.prototype.setPoint = function (t, i) {
this.faceTargetX = t,
this.faceTargetY = i
},
p.prototype.getX = function () {
return this.faceX
},
p.prototype.getY = function () {
return this.faceY
},
p.prototype.update = function () {
var t = 40 / 7.5 / p.FRAME_RATE;
if (0 == this.lastTimeSec)
return void(this.lastTimeSec = UtSystem.getUserTimeMSec());
var i = UtSystem.getUserTimeMSec(),
e = (i - this.lastTimeSec) * p.FRAME_RATE / 1e3;
this.lastTimeSec = i;
var r = .15 * p.FRAME_RATE,
o = e * t / r,
n = this.faceTargetX - this.faceX,
s = this.faceTargetY - this.faceY;
if (!(Math.abs(n) <= this.EPSILON && Math.abs(s) <= this.EPSILON)) {
var _ = Math.sqrt(n * n + s * s),
a = t * n / _,
h = t * s / _,
l = a - this.faceVX,
$ = h - this.faceVY,
u = Math.sqrt(l * l + $ * $);
(u < -o || u > o) && (l *= o / u,
$ *= o / u,
u = o),
this.faceVX += l,
this.faceVY += $;
var f = .5 * (Math.sqrt(o * o + 16 * o * _ - 8 * o * _) - o),
c = Math.sqrt(this.faceVX * this.faceVX + this.faceVY * this.faceVY);
c > f && (this.faceVX *= f / c,
this.faceVY *= f / c),
this.faceX += this.faceVX,
this.faceY += this.faceVY
}
},
f.prototype = new _,
f.prototype.getMaxScale = function () {
return this.max
},
f.prototype.getMinScale = function () {
return this.min
},
f.prototype.setMaxScale = function (t) {
this.max = t
},
f.prototype.setMinScale = function (t) {
this.min = t
},
f.prototype.isMaxScale = function () {
return this.getScaleX() == this.max
},
f.prototype.isMinScale = function () {
return this.getScaleX() == this.min
},
f.prototype.adjustTranslate = function (t, i) {
this.tr[0] * this.maxLeft + (this.tr[12] + t) > this.screenLeft && (t = this.screenLeft - this.tr[0] * this.maxLeft - this.tr[12]),
this.tr[0] * this.maxRight + (this.tr[12] + t) < this.screenRight && (t = this.screenRight - this.tr[0] * this.maxRight - this.tr[12]),
this.tr[5] * this.maxTop + (this.tr[13] + i) < this.screenTop && (i = this.screenTop - this.tr[5] * this.maxTop - this.tr[13]),
this.tr[5] * this.maxBottom + (this.tr[13] + i) > this.screenBottom && (i = this.screenBottom - this.tr[5] * this.maxBottom - this.tr[13]);
var e = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, t, i, 0, 1];
_.mul(e, this.tr, this.tr)
},
f.prototype.adjustScale = function (t, i, e) {
var r = e * this.tr[0];
r < this.min ? this.tr[0] > 0 && (e = this.min / this.tr[0]) : r > this.max && this.tr[0] > 0 && (e = this.max / this.tr[0]);
var o = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, t, i, 0, 1],
n = [e, 0, 0, 0, 0, e, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
s = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -t, -i, 0, 1];
_.mul(s, this.tr, this.tr),
_.mul(n, this.tr, this.tr),
_.mul(o, this.tr, this.tr)
},
f.prototype.setScreenRect = function (t, i, e, r) {
this.screenLeft = t,
this.screenRight = i,
this.screenTop = r,
this.screenBottom = e
},
f.prototype.setMaxScreenRect = function (t, i, e, r) {
this.maxLeft = t,
this.maxRight = i,
this.maxTop = r,
this.maxBottom = e
},
f.prototype.getScreenLeft = function () {
return this.screenLeft
},
f.prototype.getScreenRight = function () {
return this.screenRight
},
f.prototype.getScreenBottom = function () {
return this.screenBottom
},
f.prototype.getScreenTop = function () {
return this.screenTop
},
f.prototype.getMaxLeft = function () {
return this.maxLeft
},
f.prototype.getMaxRight = function () {
return this.maxRight
},
f.prototype.getMaxBottom = function () {
return this.maxBottom
},
f.prototype.getMaxTop = function () {
return this.maxTop
},
c.platformManager = null,
c.getPlatformManager = function () {
return c.platformManager
},
c.setPlatformManager = function (t) {
c.platformManager = t
},
t.exports = {
L2DTargetPoint: p,
Live2DFramework: c,
L2DViewMatrix: f,
L2DPose: $,
L2DPartsParam: u,
L2DPhysics: l,
L2DMotionManager: h,
L2DModelMatrix: a,
L2DMatrix44: _,
EYE_STATE: g,
L2DEyeBlink: s,
L2DExpressionParam: n,
L2DExpressionMotion: o,
L2DBaseModel: r
}
}, function (t, i, e) {
"use strict";
var r = {
DEBUG_LOG: !1,
DEBUG_MOUSE_LOG: !1,
DEBUG_DRAW_HIT_AREA: !1,
DEBUG_DRAW_ALPHA_MODEL: !1,
VIEW_MAX_SCALE: 2,
VIEW_MIN_SCALE: .8,
VIEW_LOGICAL_LEFT: -1,
VIEW_LOGICAL_RIGHT: 1,
VIEW_LOGICAL_MAX_LEFT: -2,
VIEW_LOGICAL_MAX_RIGHT: 2,
VIEW_LOGICAL_MAX_BOTTOM: -2,
VIEW_LOGICAL_MAX_TOP: 2,
PRIORITY_NONE: 0,
PRIORITY_IDLE: 1,
PRIORITY_SLEEPY: 2,
PRIORITY_NORMAL: 3,
PRIORITY_FORCE: 4,
MOTION_GROUP_IDLE: "idle",
MOTION_GROUP_SLEEPY: "sleepy",
MOTION_GROUP_TAP_BODY: "tap_body",
MOTION_GROUP_FLICK_HEAD: "flick_head",
MOTION_GROUP_PINCH_IN: "pinch_in",
MOTION_GROUP_PINCH_OUT: "pinch_out",
MOTION_GROUP_SHAKE: "shake",
HIT_AREA_HEAD: "head",
HIT_AREA_BODY: "body"
};
t.exports = r
}, function (t, i, e) {
"use strict";
function r(t) {
n = t
}
function o() {
return n
}
Object.defineProperty(i, "__esModule", {
value: !0
}),
i.setContext = r,
i.getContext = o;
var n = void 0
}, function (t, i, e) {
"use strict";
function r() {}
r.matrixStack = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
r.depth = 0,
r.currentMatrix = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
r.tmp = new Array(16),
r.reset = function () {
this.depth = 0
},
r.loadIdentity = function () {
for (var t = 0; t < 16; t++)
this.currentMatrix[t] = t % 5 == 0 ? 1 : 0
},
r.push = function () {
var t = (this.depth,
16 * (this.depth + 1));
this.matrixStack.length < t + 16 && (this.matrixStack.length = t + 16);
for (var i = 0; i < 16; i++)
this.matrixStack[t + i] = this.currentMatrix[i];
this.depth++
},
r.pop = function () {
--this.depth < 0 && (myError("Invalid matrix stack."),
this.depth = 0);
for (var t = 16 * this.depth, i = 0; i < 16; i++)
this.currentMatrix[i] = this.matrixStack[t + i]
},
r.getMatrix = function () {
return this.currentMatrix
},
r.multMatrix = function (t) {
var i, e, r;
for (i = 0; i < 16; i++)
this.tmp[i] = 0;
for (i = 0; i < 4; i++)
for (e = 0; e < 4; e++)
for (r = 0; r < 4; r++)
this.tmp[i + 4 * e] += this.currentMatrix[i + 4 * r] * t[r + 4 * e];
for (i = 0; i < 16; i++)
this.currentMatrix[i] = this.tmp[i]
},
t.exports = r
}, function (t, i, e) {
t.exports = e(5)
}, function (t, i, e) {
"use strict";
function r(t) {
return t && t.__esModule ? t : {
default: t
}
}
function o(t) {
C = document.getElementById(t),
C.addEventListener && (window.addEventListener("click", g),
window.addEventListener("mousedown", g),
window.addEventListener("mousemove", g),
window.addEventListener("mouseup", g),
document.addEventListener("mouseout", g),
window.addEventListener("touchstart", y),
window.addEventListener("touchend", y),
window.addEventListener("touchmove", y))
}
function n(t) {
var i = C.width,
e = C.height;
N = new M.L2DTargetPoint;
var r = e / i,
o = w.default.VIEW_LOGICAL_LEFT,
n = w.default.VIEW_LOGICAL_RIGHT,
_ = -r,
h = r;
if (window.Live2D.captureFrame = !1,
B = new M.L2DViewMatrix,
B.setScreenRect(o, n, _, h),
B.setMaxScreenRect(w.default.VIEW_LOGICAL_MAX_LEFT, w.default.VIEW_LOGICAL_MAX_RIGHT, w.default.VIEW_LOGICAL_MAX_BOTTOM, w.default.VIEW_LOGICAL_MAX_TOP),
B.setMaxScale(w.default.VIEW_MAX_SCALE),
B.setMinScale(w.default.VIEW_MIN_SCALE),
U = new M.L2DMatrix44,
U.multScale(1, i / e),
G = new M.L2DMatrix44,
G.multTranslate(-i / 2, -e / 2),
G.multScale(2 / i, -2 / i),
F = v(),
(0,
D.setContext)(F),
!F)
return console.error("Failed to create WebGL context."),
void(window.WebGLRenderingContext && console.error("Your browser don't support WebGL, check https://get.webgl.org/ for futher information."));
window.Live2D.setGL(F),
F.clearColor(0, 0, 0, 0),
a(t),
s()
}
function s() {
b || (b = !0,
function t() {
_();
var i = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
if (window.Live2D.captureFrame) {
window.Live2D.captureFrame = !1;
var e = document.createElement("a");
document.body.appendChild(e),
e.setAttribute("type", "hidden"),
e.href = C.toDataURL(),
e.download = window.Live2D.captureName || "live2d.png",
e.click()
}
i(t, C)
}())
}
function _() {
O.default.reset(),
O.default.loadIdentity(),
N.update(),
R.setDrag(N.getX(), N.getY()),
F.clear(F.COLOR_BUFFER_BIT),
O.default.multMatrix(U.getArray()),
O.default.multMatrix(B.getArray()),
O.default.push();
for (var t = 0; t < R.numModels(); t++) {
var i = R.getModel(t);
if (null == i)
return;
i.initialized && !i.updating && (i.update(),
i.draw(F))
}
O.default.pop()
}
function a(t) {
R.reloadFlg = !0,
R.count++,
R.changeModel(F, t)
}
function h(t, i) {
return t.x * i.x + t.y * i.y
}
function l(t, i) {
var e = Math.sqrt(t * t + i * i);
return {
x: t / e,
y: i / e
}
}
function $(t, i, e) {
function r(t, i) {
return 180 * Math.acos(h({
x: 0,
y: 1
}, l(t, i))) / Math.PI
}
if (i.x < e.left + e.width && i.y < e.top + e.height && i.x > e.left && i.y > e.top)
return i;
var o = t.x - i.x,
n = t.y - i.y,
s = r(o, n);
i.x < t.x && (s = 360 - s);
var _ = 360 - r(e.left - t.x, -1 * (e.top - t.y)),
a = 360 - r(e.left - t.x, -1 * (e.top + e.height - t.y)),
$ = r(e.left + e.width - t.x, -1 * (e.top - t.y)),
u = r(e.left + e.width - t.x, -1 * (e.top + e.height - t.y)),
p = n / o,
f = {};
if (s < $) {
var c = e.top - t.y,
d = c / p;
f = {
y: t.y + c,
x: t.x + d
}
} else if (s < u) {
var g = e.left + e.width - t.x,
y = g * p;
f = {
y: t.y + y,
x: t.x + g
}
} else if (s < a) {
var m = e.top + e.height - t.y,
T = m / p;
f = {
y: t.y + m,
x: t.x + T
}
} else if (s < _) {
var P = t.x - e.left,
S = P * p;
f = {
y: t.y - S,
x: t.x - P
}
} else {
var v = e.top - t.y,
L = v / p;
f = {
y: t.y + v,
x: t.x + L
}
}
return f
}
function u(t) {
Y = !0;
var i = C.getBoundingClientRect(),
e = P(t.clientX - i.left),
r = S(t.clientY - i.top),
o = $({
x: i.left + i.width / 2,
y: i.top + i.height * X
}, {
x: t.clientX,
y: t.clientY
}, i),
n = m(o.x - i.left),
s = T(o.y - i.top);
w.default.DEBUG_MOUSE_LOG && console.log("onMouseMove device( x:" + t.clientX + " y:" + t.clientY + " ) view( x:" + n + " y:" + s + ")"),
k = e,
V = r,
N.setPoint(n, s)
}
function p(t) {
Y = !0;
var i = C.getBoundingClientRect(),
e = P(t.clientX - i.left),
r = S(t.clientY - i.top),
o = $({
x: i.left + i.width / 2,
y: i.top + i.height * X
}, {
x: t.clientX,
y: t.clientY
}, i),
n = m(o.x - i.left),
s = T(o.y - i.top);
w.default.DEBUG_MOUSE_LOG && console.log("onMouseDown device( x:" + t.clientX + " y:" + t.clientY + " ) view( x:" + n + " y:" + s + ")"),
k = e,
V = r
// R.tapEvent(n, s)
}
function f(t) {
var i = C.getBoundingClientRect(),
e = P(t.clientX - i.left),
r = S(t.clientY - i.top),
o = $({
x: i.left + i.width / 2,
y: i.top + i.height * X
}, {
x: t.clientX,
y: t.clientY
}, i),
n = m(o.x - i.left),
s = T(o.y - i.top);
w.default.DEBUG_MOUSE_LOG && console.log("onMouseMove device( x:" + t.clientX + " y:" + t.clientY + " ) view( x:" + n + " y:" + s + ")"),
Y && (k = e,
V = r,
N.setPoint(n, s))
}
function c() {
Y && (Y = !1),
N.setPoint(0, 0)
}
function d() {
w.default.DEBUG_LOG && console.log("Set Session Storage."),
sessionStorage.setItem("Sleepy", "1")
}
function g(t) {
if ("mousewheel" == t.type)
;
else if ("mousedown" == t.type)
p(t);
else if ("mousemove" == t.type) {
var i = sessionStorage.getItem("Sleepy");
"1" === i && sessionStorage.setItem("Sleepy", "0"),
u(t)
} else if ("mouseup" == t.type) {
if ("button" in t && 0 != t.button)
return
} else if ("mouseout" == t.type) {
w.default.DEBUG_LOG && console.log("Mouse out Window."),
c();
var e = sessionStorage.getItem("SleepyTimer");
window.clearTimeout(e),
e = window.setTimeout(d, 5e4),
sessionStorage.setItem("SleepyTimer", e)
}
}
function y(t) {
var i = t.touches[0];
"touchstart" == t.type ? 1 == t.touches.length && u(i) : "touchmove" == t.type ? f(i) : "touchend" == t.type && c()
}
function m(t) {
var i = G.transformX(t);
return B.invertTransformX(i)
}
function T(t) {
var i = G.transformY(t);
return B.invertTransformY(i)
}
function P(t) {
return G.transformX(t)
}
function S(t) {
return G.transformY(t)
}
function v() {
for (var t = ["webgl", "experimental-webgl", "webkit-3d", "moz-webgl"], i = 0; i < t.length; i++)
try {
var e = C.getContext(t[i], {
premultipliedAlpha: !0
});
if (e)
return e
} catch (t) {}
return null
}
function L(t, i, e) {
X = void 0 === e ? .5 : e,
o(t),
n(i)
}
e(6);
var M = e(0),
E = e(8),
A = r(E),
I = e(1),
w = r(I),
x = e(3),
O = r(x),
D = e(2),
R = (window.navigator.platform.toLowerCase(),
new A.default),
b = !1,
F = null,
C = null,
N = null,
B = null,
U = null,
G = null,
Y = !1,
k = 0,
V = 0,
X = .5;
window.loadlive2d = L
}, function (t, i, e) {
"use strict";
(function (t) {
! function () {
function i() {
At || (this._$MT = null,
this._$5S = null,
this._$NP = 0,
i._$42++,
this._$5S = new Y(this))
}
function e(t) {
if (!At) {
this.clipContextList = new Array,
this.glcontext = t.gl,
this.dp_webgl = t,
this.curFrameNo = 0,
this.firstError_clipInNotUpdate = !0,
this.colorBuffer = 0,
this.isInitGLFBFunc = !1,
this.tmpBoundsOnModel = new S,
at.glContext.length > at.frameBuffers.length && (this.curFrameNo = this.getMaskRenderTexture()),
this.tmpModelToViewMatrix = new R,
this.tmpMatrix2 = new R,
this.tmpMatrixForMask = new R,
this.tmpMatrixForDraw = new R,
this.CHANNEL_COLORS = new Array;
var i = new A;
i = new A,
i.r = 0,
i.g = 0,
i.b = 0,
i.a = 1,
this.CHANNEL_COLORS.push(i),
i = new A,
i.r = 1,
i.g = 0,
i.b = 0,
i.a = 0,
this.CHANNEL_COLORS.push(i),
i = new A,
i.r = 0,
i.g = 1,
i.b = 0,
i.a = 0,
this.CHANNEL_COLORS.push(i),
i = new A,
i.r = 0,
i.g = 0,
i.b = 1,
i.a = 0,
this.CHANNEL_COLORS.push(i);
for (var e = 0; e < this.CHANNEL_COLORS.length; e++)
this.dp_webgl.setChannelFlagAsColor(e, this.CHANNEL_COLORS[e])
}
}
function r(t, i, e) {
this.clipIDList = new Array,
this.clipIDList = e,
this.clippingMaskDrawIndexList = new Array;
for (var r = 0; r < e.length; r++)
this.clippingMaskDrawIndexList.push(i.getDrawDataIndex(e[r]));
this.clippedDrawContextList = new Array,
this.isUsing = !0,
this.layoutChannelNo = 0,
this.layoutBounds = new S,
this.allClippedDrawRect = new S,
this.matrixForMask = new Float32Array(16),
this.matrixForDraw = new Float32Array(16),
this.owner = t
}
function o(t, i) {
this._$gP = t,
this.drawDataIndex = i
}
function n() {
At || (this.color = null)
}
function s() {
At || (this._$dP = null,
this._$eo = null,
this._$V0 = null,
this._$dP = 1e3,
this._$eo = 1e3,
this._$V0 = 1,
this._$a0())
}
function _() {}
function a() {
this._$r = null,
this._$0S = null
}
function h() {
At || (this.x = null,
this.y = null,
this.width = null,
this.height = null)
}
function l(t) {
At || et.prototype.constructor.call(this, t)
}
function $() {}
function u(t) {
At || et.prototype.constructor.call(this, t)
}
function p() {
At || (this._$vo = null,
this._$F2 = null,
this._$ao = 400,
this._$1S = 400,
p._$42++)
}
function f() {
At || (this.p1 = new c,
this.p2 = new c,
this._$Fo = 0,
this._$Db = 0,
this._$L2 = 0,
this._$M2 = 0,
this._$ks = 0,
this._$9b = 0,
this._$iP = 0,
this._$iT = 0,
this._$lL = new Array,
this._$qP = new Array,
this.setup(.3, .5, .1))
}
function c() {
this._$p = 1,
this.x = 0,
this.y = 0,
this.vx = 0,
this.vy = 0,
this.ax = 0,
this.ay = 0,
this.fx = 0,
this.fy = 0,
this._$s0 = 0,
this._$70 = 0,
this._$7L = 0,
this._$HL = 0
}
function d(t, i, e) {
this._$wL = null,
this.scale = null,
this._$V0 = null,
this._$wL = t,
this.scale = i,
this._$V0 = e
}
function g(t, i, e, r) {
d.prototype.constructor.call(this, i, e, r),
this._$tL = null,
this._$tL = t
}
function y(t, i, e) {
this._$wL = null,
this.scale = null,
this._$V0 = null,
this._$wL = t,
this.scale = i,
this._$V0 = e
}
function T(t, i, e, r) {
y.prototype.constructor.call(this, i, e, r),
this._$YP = null,
this._$YP = t
}
function P() {
At || (this._$fL = 0,
this._$gL = 0,
this._$B0 = 1,
this._$z0 = 1,
this._$qT = 0,
this.reflectX = !1,
this.reflectY = !1)
}
function S() {
At || (this.x = null,
this.y = null,
this.width = null,
this.height = null)
}
function v() {}
function L() {
At || (this.x = null,
this.y = null)
}
function M() {
At || (this._$gP = null,
this._$dr = null,
this._$GS = null,
this._$qb = null,
this._$Lb = null,
this._$mS = null,
this.clipID = null,
this.clipIDList = new Array)
}
function E() {
At || (this._$Eb = E._$ps,
this._$lT = 1,
this._$C0 = 1,
this._$tT = 1,
this._$WL = 1,
this.culling = !1,
this.matrix4x4 = new Float32Array(16),
this.premultipliedAlpha = !1,
this.anisotropy = 0,
this.clippingProcess = E.CLIPPING_PROCESS_NONE,
this.clipBufPre_clipContextMask = null,
this.clipBufPre_clipContextDraw = null,
this.CHANNEL_COLORS = new Array)
}
function A() {
At || (this.a = 1,
this.r = 1,
this.g = 1,
this.b = 1,
this.scale = 1,
this._$ho = 1,
this.blendMode = at.L2D_COLOR_BLEND_MODE_MULT)
}
function I() {
At || (this._$kP = null,
this._$dr = null,
this._$Ai = !0,
this._$mS = null)
}
function w() {}
function x() {
At || (this._$VP = 0,
this._$wL = null,
this._$GP = null,
this._$8o = x._$ds,
this._$2r = -1,
this._$O2 = 0,
this._$ri = 0)
}
function O() {}
function D() {
At || (this._$Ob = null)
}
function R() {
this.m = new Float32Array(16),
this.identity()
}
function b(t) {
At || et.prototype.constructor.call(this, t)
}
function F() {
At || (this._$7 = 1,
this._$f = 0,
this._$H = 0,
this._$g = 1,
this._$k = 0,
this._$w = 0,
this._$hi = STATE_IDENTITY,
this._$Z = _$pS)
}
function C() {
At || (s.prototype.constructor.call(this),
this.motions = new Array,
this._$7r = null,
this._$7r = C._$Co++,
this._$D0 = 30,
this._$yT = 0,
this._$E = !0,
this.loopFadeIn = !0,
this._$AS = -1,
_$a0())
}
function N() {
this._$P = new Float32Array(100),
this.size = 0
}
function B() {
this._$4P = null,
this._$I0 = null,
this._$RP = null
}
function U() {}
function G() {}
function Y(t) {
At || (this._$QT = !0,
this._$co = -1,
this._$qo = 0,
this._$pb = new Array(Y._$is),
this._$_2 = new Float32Array(Y._$is),
this._$vr = new Float32Array(Y._$is),
this._$Rr = new Float32Array(Y._$is),
this._$Or = new Float32Array(Y._$is),
this._$fs = new Float32Array(Y._$is),
this._$Js = new Array(Y._$is),
this._$3S = new Array,
this._$aS = new Array,
this._$Bo = null,
this._$F2 = new Array,
this._$db = new Array,
this._$8b = new Array,
this._$Hr = new Array,
this._$Ws = null,
this._$Vs = null,
this._$Er = null,
this._$Es = new Int16Array(U._$Qb),
this._$ZP = new Float32Array(2 * U._$1r),
this._$Ri = t,
this._$b0 = Y._$HP++,
this.clipManager = null,
this.dp_webgl = null)
}
function k() {}
function V() {
At || (this._$12 = null,
this._$bb = null,
this._$_L = null,
this._$jo = null,
this._$iL = null,
this._$0L = null,
this._$Br = null,
this._$Dr = null,
this._$Cb = null,
this._$mr = null,
this._$_L = wt.STATE_FIRST,
this._$Br = 4e3,
this._$Dr = 100,
this._$Cb = 50,
this._$mr = 150,
this._$jo = !0,
this._$iL = "PARAM_EYE_L_OPEN",
this._$0L = "PARAM_EYE_R_OPEN")
}
function X() {
At || (E.prototype.constructor.call(this),
this._$sb = new Int32Array(X._$As),
this._$U2 = new Array,
this.transform = null,
this.gl = null,
null == X._$NT && (X._$NT = X._$9r(256),
X._$vS = X._$9r(256),
X._$no = X._$vb(256)))
}
function z() {
At || (I.prototype.constructor.call(this),
this._$GS = null,
this._$Y0 = null)
}
function H(t) {
_t.prototype.constructor.call(this, t),
this._$8r = I._$ur,
this._$Yr = null,
this._$Wr = null
}
function W() {
At || (M.prototype.constructor.call(this),
this._$gP = null,
this._$dr = null,
this._$GS = null,
this._$qb = null,
this._$Lb = null,
this._$mS = null)
}
function j() {
At || (this._$NL = null,
this._$3S = null,
this._$aS = null,
j._$42++)
}
function q() {
At || (i.prototype.constructor.call(this),
this._$zo = new X)
}
function J() {
At || (s.prototype.constructor.call(this),
this.motions = new Array,
this._$o2 = null,
this._$7r = J._$Co++,
this._$D0 = 30,
this._$yT = 0,
this._$E = !1,
this.loopFadeIn = !0,
this._$rr = -1,
this._$eP = 0)
}
function Q(t, i) {
return String.fromCharCode(t.getUint8(i))
}
function N() {
this._$P = new Float32Array(100),
this.size = 0
}
function B() {
this._$4P = null,
this._$I0 = null,
this._$RP = null
}
function Z() {
At || (I.prototype.constructor.call(this),
this._$o = 0,
this._$A = 0,
this._$GS = null,
this._$Eo = null)
}
function K(t) {
_t.prototype.constructor.call(this, t),
this._$8r = I._$ur,
this._$Cr = null,
this._$hr = null
}
function tt() {
At || (this.visible = !0,
this._$g0 = !1,
this._$NL = null,
this._$3S = null,
this._$aS = null,
tt._$42++)
}
function it(t) {
this._$VS = null,
this._$e0 = null,
this._$e0 = t
}
function et(t) {
At || (this.id = t)
}
function rt() {}
function ot() {
At || (this._$4S = null)
}
function nt(t, i) {
this.canvas = t,
this.context = i,
this.viewport = new Array(0, 0, t.width, t.height),
this._$6r = 1,
this._$xP = 0,
this._$3r = 1,
this._$uP = 0,
this._$Qo = -1,
this.cacheImages = {}
}
function st() {
At || (this._$TT = null,
this._$LT = null,
this._$FS = null,
this._$wL = null)
}
function _t(t) {
At || (this._$e0 = null,
this._$IP = null,
this._$JS = !1,
this._$AT = !0,
this._$e0 = t,
this.totalScale = 1,
this._$7s = 1,
this.totalOpacity = 1)
}
function at() {}
function ht() {}
function lt(t) {
At || (this._$ib = t)
}