@seayoo-web/pixi-live2d 0.0.10 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cubism4.es-lCEfB7RP.js +3608 -0
- package/dist/index-CuNStzp0.js +18424 -0
- package/dist/index.js +3 -21792
- package/package.json +1 -1
- package/types/index.d.ts +7 -13
|
@@ -0,0 +1,3608 @@
|
|
|
1
|
+
import { M as pt, E as Tt, C as Ie, O as Le, P as Te, T as Ee, u as Et, a as vt } from "./index-CuNStzp0.js";
|
|
2
|
+
var H = Math.pow, b = (s, t, e) => new Promise((i, r) => {
|
|
3
|
+
var a = (l) => {
|
|
4
|
+
try {
|
|
5
|
+
o(e.next(l));
|
|
6
|
+
} catch (h) {
|
|
7
|
+
r(h);
|
|
8
|
+
}
|
|
9
|
+
}, n = (l) => {
|
|
10
|
+
try {
|
|
11
|
+
o(e.throw(l));
|
|
12
|
+
} catch (h) {
|
|
13
|
+
r(h);
|
|
14
|
+
}
|
|
15
|
+
}, o = (l) => l.done ? i(l.value) : Promise.resolve(l.value).then(a, n);
|
|
16
|
+
o((e = e.apply(s, t)).next());
|
|
17
|
+
});
|
|
18
|
+
class Ft {
|
|
19
|
+
constructor() {
|
|
20
|
+
this._breathParameters = [], this._currentTime = 0;
|
|
21
|
+
}
|
|
22
|
+
static create() {
|
|
23
|
+
return new Ft();
|
|
24
|
+
}
|
|
25
|
+
setParameters(t) {
|
|
26
|
+
this._breathParameters = t;
|
|
27
|
+
}
|
|
28
|
+
getParameters() {
|
|
29
|
+
return this._breathParameters;
|
|
30
|
+
}
|
|
31
|
+
updateParameters(t, e) {
|
|
32
|
+
this._currentTime += e;
|
|
33
|
+
const i = this._currentTime * 2 * 3.14159;
|
|
34
|
+
for (let r = 0; r < this._breathParameters.length; ++r) {
|
|
35
|
+
const a = this._breathParameters[r];
|
|
36
|
+
t.addParameterValueById(a.parameterId, a.offset + a.peak * Math.sin(i / a.cycle), a.weight);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
class st {
|
|
41
|
+
constructor(t, e, i, r, a) {
|
|
42
|
+
this.parameterId = t ?? void 0, this.offset = e ?? 0, this.peak = i ?? 0, this.cycle = r ?? 0, this.weight = a ?? 0;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const St = class {
|
|
46
|
+
static create(s) {
|
|
47
|
+
return new St(s);
|
|
48
|
+
}
|
|
49
|
+
setBlinkingInterval(s) {
|
|
50
|
+
this._blinkingIntervalSeconds = s;
|
|
51
|
+
}
|
|
52
|
+
setBlinkingSetting(s, t, e) {
|
|
53
|
+
this._closingSeconds = s, this._closedSeconds = t, this._openingSeconds = e;
|
|
54
|
+
}
|
|
55
|
+
setParameterIds(s) {
|
|
56
|
+
this._parameterIds = s;
|
|
57
|
+
}
|
|
58
|
+
getParameterIds() {
|
|
59
|
+
return this._parameterIds;
|
|
60
|
+
}
|
|
61
|
+
updateParameters(s, t) {
|
|
62
|
+
this._userTimeSeconds += t;
|
|
63
|
+
let e, i = 0;
|
|
64
|
+
switch (this._blinkingState) {
|
|
65
|
+
case A.EyeState_Closing:
|
|
66
|
+
i = (this._userTimeSeconds - this._stateStartTimeSeconds) / this._closingSeconds, i >= 1 && (i = 1, this._blinkingState = A.EyeState_Closed, this._stateStartTimeSeconds = this._userTimeSeconds), e = 1 - i;
|
|
67
|
+
break;
|
|
68
|
+
case A.EyeState_Closed:
|
|
69
|
+
i = (this._userTimeSeconds - this._stateStartTimeSeconds) / this._closedSeconds, i >= 1 && (this._blinkingState = A.EyeState_Opening, this._stateStartTimeSeconds = this._userTimeSeconds), e = 0;
|
|
70
|
+
break;
|
|
71
|
+
case A.EyeState_Opening:
|
|
72
|
+
i = (this._userTimeSeconds - this._stateStartTimeSeconds) / this._openingSeconds, i >= 1 && (i = 1, this._blinkingState = A.EyeState_Interval, this._nextBlinkingTime = this.determinNextBlinkingTiming()), e = i;
|
|
73
|
+
break;
|
|
74
|
+
case A.EyeState_Interval:
|
|
75
|
+
this._nextBlinkingTime < this._userTimeSeconds && (this._blinkingState = A.EyeState_Closing, this._stateStartTimeSeconds = this._userTimeSeconds), e = 1;
|
|
76
|
+
break;
|
|
77
|
+
case A.EyeState_First:
|
|
78
|
+
default:
|
|
79
|
+
this._blinkingState = A.EyeState_Interval, this._nextBlinkingTime = this.determinNextBlinkingTiming(), e = 1;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
St.CloseIfZero || (e = -e);
|
|
83
|
+
for (let r = 0; r < this._parameterIds.length; ++r)
|
|
84
|
+
s.setParameterValueById(this._parameterIds[r], e);
|
|
85
|
+
}
|
|
86
|
+
constructor(s) {
|
|
87
|
+
var t, e;
|
|
88
|
+
this._blinkingState = A.EyeState_First, this._nextBlinkingTime = 0, this._stateStartTimeSeconds = 0, this._blinkingIntervalSeconds = 4, this._closingSeconds = 0.1, this._closedSeconds = 0.05, this._openingSeconds = 0.15, this._userTimeSeconds = 0, this._parameterIds = [], s != null && (this._parameterIds = (e = (t = s.getEyeBlinkParameters()) == null ? void 0 : t.slice()) != null ? e : this._parameterIds);
|
|
89
|
+
}
|
|
90
|
+
determinNextBlinkingTiming() {
|
|
91
|
+
const s = Math.random();
|
|
92
|
+
return this._userTimeSeconds + s * (2 * this._blinkingIntervalSeconds - 1);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
let ue = St;
|
|
96
|
+
ue.CloseIfZero = !0;
|
|
97
|
+
var A = /* @__PURE__ */ ((s) => (s[s.EyeState_First = 0] = "EyeState_First", s[s.EyeState_Interval = 1] = "EyeState_Interval", s[s.EyeState_Closing = 2] = "EyeState_Closing", s[s.EyeState_Closed = 3] = "EyeState_Closed", s[s.EyeState_Opening = 4] = "EyeState_Opening", s))(A || {});
|
|
98
|
+
const Fe = 1e-3, Wt = 0.5;
|
|
99
|
+
class Dt {
|
|
100
|
+
static create(t) {
|
|
101
|
+
const e = new Dt();
|
|
102
|
+
typeof t.FadeInTime == "number" && (e._fadeTimeSeconds = t.FadeInTime, e._fadeTimeSeconds <= 0 && (e._fadeTimeSeconds = Wt));
|
|
103
|
+
const i = t.Groups, r = i.length;
|
|
104
|
+
for (let a = 0; a < r; ++a) {
|
|
105
|
+
const n = i[a], o = n.length;
|
|
106
|
+
let l = 0;
|
|
107
|
+
for (let h = 0; h < o; ++h) {
|
|
108
|
+
const u = n[h], c = new _t();
|
|
109
|
+
c.partId = u.Id;
|
|
110
|
+
const d = u.Link;
|
|
111
|
+
if (d) {
|
|
112
|
+
const _ = d.length;
|
|
113
|
+
for (let p = 0; p < _; ++p) {
|
|
114
|
+
const x = new _t();
|
|
115
|
+
x.partId = d[p], c.link.push(x);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
e._partGroups.push(c), ++l;
|
|
119
|
+
}
|
|
120
|
+
e._partGroupCounts.push(l);
|
|
121
|
+
}
|
|
122
|
+
return e;
|
|
123
|
+
}
|
|
124
|
+
updateParameters(t, e) {
|
|
125
|
+
t != this._lastModel && this.reset(t), this._lastModel = t, e < 0 && (e = 0);
|
|
126
|
+
let i = 0;
|
|
127
|
+
for (let r = 0; r < this._partGroupCounts.length; r++) {
|
|
128
|
+
const a = this._partGroupCounts[r];
|
|
129
|
+
this.doFade(t, e, i, a), i += a;
|
|
130
|
+
}
|
|
131
|
+
this.copyPartOpacities(t);
|
|
132
|
+
}
|
|
133
|
+
reset(t) {
|
|
134
|
+
let e = 0;
|
|
135
|
+
for (let i = 0; i < this._partGroupCounts.length; ++i) {
|
|
136
|
+
const r = this._partGroupCounts[i];
|
|
137
|
+
for (let a = e; a < e + r; ++a) {
|
|
138
|
+
this._partGroups[a].initialize(t);
|
|
139
|
+
const n = this._partGroups[a].partIndex, o = this._partGroups[a].parameterIndex;
|
|
140
|
+
if (!(n < 0)) {
|
|
141
|
+
t.setPartOpacityByIndex(n, a == e ? 1 : 0), t.setParameterValueByIndex(o, a == e ? 1 : 0);
|
|
142
|
+
for (let l = 0; l < this._partGroups[a].link.length; ++l)
|
|
143
|
+
this._partGroups[a].link[l].initialize(t);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
e += r;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
copyPartOpacities(t) {
|
|
150
|
+
for (let e = 0; e < this._partGroups.length; ++e) {
|
|
151
|
+
const i = this._partGroups[e];
|
|
152
|
+
if (i.link.length == 0)
|
|
153
|
+
continue;
|
|
154
|
+
const r = this._partGroups[e].partIndex, a = t.getPartOpacityByIndex(r);
|
|
155
|
+
for (let n = 0; n < i.link.length; ++n) {
|
|
156
|
+
const l = i.link[n].partIndex;
|
|
157
|
+
l < 0 || t.setPartOpacityByIndex(l, a);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
doFade(t, e, i, r) {
|
|
162
|
+
let a = -1, n = 1;
|
|
163
|
+
const o = 0.5, l = 0.15;
|
|
164
|
+
for (let h = i; h < i + r; ++h) {
|
|
165
|
+
const u = this._partGroups[h].partIndex, c = this._partGroups[h].parameterIndex;
|
|
166
|
+
if (t.getParameterValueByIndex(c) > Fe) {
|
|
167
|
+
if (a >= 0)
|
|
168
|
+
break;
|
|
169
|
+
a = h, n = t.getPartOpacityByIndex(u), n += e / this._fadeTimeSeconds, n > 1 && (n = 1);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
a < 0 && (a = 0, n = 1);
|
|
173
|
+
for (let h = i; h < i + r; ++h) {
|
|
174
|
+
const u = this._partGroups[h].partIndex;
|
|
175
|
+
if (a == h)
|
|
176
|
+
t.setPartOpacityByIndex(u, n);
|
|
177
|
+
else {
|
|
178
|
+
let c = t.getPartOpacityByIndex(u), d;
|
|
179
|
+
n < o ? d = n * (o - 1) / o + 1 : d = (1 - n) * o / (1 - o), (1 - d) * (1 - n) > l && (d = 1 - l / (1 - n)), c > d && (c = d), t.setPartOpacityByIndex(u, c);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
constructor() {
|
|
184
|
+
this._fadeTimeSeconds = Wt, this._lastModel = void 0, this._partGroups = [], this._partGroupCounts = [];
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
class _t {
|
|
188
|
+
constructor(t) {
|
|
189
|
+
this.parameterIndex = 0, this.partIndex = 0, this.partId = "", this.link = [], t != null && this.assignment(t);
|
|
190
|
+
}
|
|
191
|
+
assignment(t) {
|
|
192
|
+
return this.partId = t.partId, this.link = t.link.map((e) => e.clone()), this;
|
|
193
|
+
}
|
|
194
|
+
initialize(t) {
|
|
195
|
+
this.parameterIndex = t.getParameterIndex(this.partId), this.partIndex = t.getPartIndex(this.partId), t.setParameterValueByIndex(this.parameterIndex, 1);
|
|
196
|
+
}
|
|
197
|
+
clone() {
|
|
198
|
+
const t = new _t();
|
|
199
|
+
return t.partId = this.partId, t.parameterIndex = this.parameterIndex, t.partIndex = this.partIndex, t.link = this.link.map((e) => e.clone()), t;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
class y {
|
|
203
|
+
constructor(t, e) {
|
|
204
|
+
this.x = t || 0, this.y = e || 0;
|
|
205
|
+
}
|
|
206
|
+
add(t) {
|
|
207
|
+
const e = new y(0, 0);
|
|
208
|
+
return e.x = this.x + t.x, e.y = this.y + t.y, e;
|
|
209
|
+
}
|
|
210
|
+
substract(t) {
|
|
211
|
+
const e = new y(0, 0);
|
|
212
|
+
return e.x = this.x - t.x, e.y = this.y - t.y, e;
|
|
213
|
+
}
|
|
214
|
+
multiply(t) {
|
|
215
|
+
const e = new y(0, 0);
|
|
216
|
+
return e.x = this.x * t.x, e.y = this.y * t.y, e;
|
|
217
|
+
}
|
|
218
|
+
multiplyByScaler(t) {
|
|
219
|
+
return this.multiply(new y(t, t));
|
|
220
|
+
}
|
|
221
|
+
division(t) {
|
|
222
|
+
const e = new y(0, 0);
|
|
223
|
+
return e.x = this.x / t.x, e.y = this.y / t.y, e;
|
|
224
|
+
}
|
|
225
|
+
divisionByScalar(t) {
|
|
226
|
+
return this.division(new y(t, t));
|
|
227
|
+
}
|
|
228
|
+
getLength() {
|
|
229
|
+
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
230
|
+
}
|
|
231
|
+
getDistanceWith(t) {
|
|
232
|
+
return Math.sqrt((this.x - t.x) * (this.x - t.x) + (this.y - t.y) * (this.y - t.y));
|
|
233
|
+
}
|
|
234
|
+
dot(t) {
|
|
235
|
+
return this.x * t.x + this.y * t.y;
|
|
236
|
+
}
|
|
237
|
+
normalize() {
|
|
238
|
+
const t = Math.pow(this.x * this.x + this.y * this.y, 0.5);
|
|
239
|
+
this.x = this.x / t, this.y = this.y / t;
|
|
240
|
+
}
|
|
241
|
+
isEqual(t) {
|
|
242
|
+
return this.x == t.x && this.y == t.y;
|
|
243
|
+
}
|
|
244
|
+
isNotEqual(t) {
|
|
245
|
+
return !this.isEqual(t);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
const gt = class {
|
|
249
|
+
static range(s, t, e) {
|
|
250
|
+
return s < t ? s = t : s > e && (s = e), s;
|
|
251
|
+
}
|
|
252
|
+
static sin(s) {
|
|
253
|
+
return Math.sin(s);
|
|
254
|
+
}
|
|
255
|
+
static cos(s) {
|
|
256
|
+
return Math.cos(s);
|
|
257
|
+
}
|
|
258
|
+
static abs(s) {
|
|
259
|
+
return Math.abs(s);
|
|
260
|
+
}
|
|
261
|
+
static sqrt(s) {
|
|
262
|
+
return Math.sqrt(s);
|
|
263
|
+
}
|
|
264
|
+
static cbrt(s) {
|
|
265
|
+
if (s === 0)
|
|
266
|
+
return s;
|
|
267
|
+
let t = s;
|
|
268
|
+
const e = t < 0;
|
|
269
|
+
e && (t = -t);
|
|
270
|
+
let i;
|
|
271
|
+
return t === 1 / 0 ? i = 1 / 0 : (i = Math.exp(Math.log(t) / 3), i = (t / (i * i) + 2 * i) / 3), e ? -i : i;
|
|
272
|
+
}
|
|
273
|
+
static getEasingSine(s) {
|
|
274
|
+
return s < 0 ? 0 : s > 1 ? 1 : 0.5 - 0.5 * this.cos(s * Math.PI);
|
|
275
|
+
}
|
|
276
|
+
static max(s, t) {
|
|
277
|
+
return s > t ? s : t;
|
|
278
|
+
}
|
|
279
|
+
static min(s, t) {
|
|
280
|
+
return s > t ? t : s;
|
|
281
|
+
}
|
|
282
|
+
static degreesToRadian(s) {
|
|
283
|
+
return s / 180 * Math.PI;
|
|
284
|
+
}
|
|
285
|
+
static radianToDegrees(s) {
|
|
286
|
+
return s * 180 / Math.PI;
|
|
287
|
+
}
|
|
288
|
+
static directionToRadian(s, t) {
|
|
289
|
+
const e = Math.atan2(t.y, t.x), i = Math.atan2(s.y, s.x);
|
|
290
|
+
let r = e - i;
|
|
291
|
+
for (; r < -Math.PI; )
|
|
292
|
+
r += Math.PI * 2;
|
|
293
|
+
for (; r > Math.PI; )
|
|
294
|
+
r -= Math.PI * 2;
|
|
295
|
+
return r;
|
|
296
|
+
}
|
|
297
|
+
static directionToDegrees(s, t) {
|
|
298
|
+
const e = this.directionToRadian(s, t);
|
|
299
|
+
let i = this.radianToDegrees(e);
|
|
300
|
+
return t.x - s.x > 0 && (i = -i), i;
|
|
301
|
+
}
|
|
302
|
+
static radianToDirection(s) {
|
|
303
|
+
const t = new y();
|
|
304
|
+
return t.x = this.sin(s), t.y = this.cos(s), t;
|
|
305
|
+
}
|
|
306
|
+
static quadraticEquation(s, t, e) {
|
|
307
|
+
return this.abs(s) < gt.Epsilon ? this.abs(t) < gt.Epsilon ? -e : -e / t : -(t + this.sqrt(t * t - 4 * s * e)) / (2 * s);
|
|
308
|
+
}
|
|
309
|
+
static cardanoAlgorithmForBezier(s, t, e, i) {
|
|
310
|
+
if (this.sqrt(s) < gt.Epsilon)
|
|
311
|
+
return this.range(this.quadraticEquation(t, e, i), 0, 1);
|
|
312
|
+
const r = t / s, a = e / s, n = i / s, o = (3 * a - r * r) / 3, l = o / 3, h = (2 * r * r * r - 9 * r * a + 27 * n) / 27, u = h / 2, c = u * u + l * l * l, d = 0.5, _ = d + 0.01;
|
|
313
|
+
if (c < 0) {
|
|
314
|
+
const f = -o / 3, v = f * f * f, P = this.sqrt(v), I = -h / (2 * P), M = this.range(I, -1, 1), V = Math.acos(M), N = 2 * this.cbrt(P), Yt = N * this.cos(V / 3) - r / 3;
|
|
315
|
+
if (this.abs(Yt - d) < _)
|
|
316
|
+
return this.range(Yt, 0, 1);
|
|
317
|
+
const Ht = N * this.cos((V + 2 * Math.PI) / 3) - r / 3;
|
|
318
|
+
if (this.abs(Ht - d) < _)
|
|
319
|
+
return this.range(Ht, 0, 1);
|
|
320
|
+
const we = N * this.cos((V + 4 * Math.PI) / 3) - r / 3;
|
|
321
|
+
return this.range(we, 0, 1);
|
|
322
|
+
}
|
|
323
|
+
if (c == 0) {
|
|
324
|
+
let f;
|
|
325
|
+
u < 0 ? f = this.cbrt(-u) : f = -this.cbrt(u);
|
|
326
|
+
const v = 2 * f - r / 3;
|
|
327
|
+
if (this.abs(v - d) < _)
|
|
328
|
+
return this.range(v, 0, 1);
|
|
329
|
+
const P = -f - r / 3;
|
|
330
|
+
return this.range(P, 0, 1);
|
|
331
|
+
}
|
|
332
|
+
const p = this.sqrt(c), x = this.cbrt(p - u), g = this.cbrt(p + u), m = x - g - r / 3;
|
|
333
|
+
return this.range(m, 0, 1);
|
|
334
|
+
}
|
|
335
|
+
constructor() {
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
let S = gt;
|
|
339
|
+
S.Epsilon = 1e-5;
|
|
340
|
+
class R {
|
|
341
|
+
constructor() {
|
|
342
|
+
this._tr = new Float32Array(16), this.loadIdentity();
|
|
343
|
+
}
|
|
344
|
+
static multiply(t, e, i) {
|
|
345
|
+
const r = new Float32Array([
|
|
346
|
+
0,
|
|
347
|
+
0,
|
|
348
|
+
0,
|
|
349
|
+
0,
|
|
350
|
+
0,
|
|
351
|
+
0,
|
|
352
|
+
0,
|
|
353
|
+
0,
|
|
354
|
+
0,
|
|
355
|
+
0,
|
|
356
|
+
0,
|
|
357
|
+
0,
|
|
358
|
+
0,
|
|
359
|
+
0,
|
|
360
|
+
0,
|
|
361
|
+
0
|
|
362
|
+
]), a = 4;
|
|
363
|
+
for (let n = 0; n < a; ++n)
|
|
364
|
+
for (let o = 0; o < a; ++o)
|
|
365
|
+
for (let l = 0; l < a; ++l)
|
|
366
|
+
r[o + n * 4] += t[l + n * 4] * e[o + l * 4];
|
|
367
|
+
for (let n = 0; n < 16; ++n)
|
|
368
|
+
i[n] = r[n];
|
|
369
|
+
}
|
|
370
|
+
loadIdentity() {
|
|
371
|
+
const t = new Float32Array([
|
|
372
|
+
1,
|
|
373
|
+
0,
|
|
374
|
+
0,
|
|
375
|
+
0,
|
|
376
|
+
0,
|
|
377
|
+
1,
|
|
378
|
+
0,
|
|
379
|
+
0,
|
|
380
|
+
0,
|
|
381
|
+
0,
|
|
382
|
+
1,
|
|
383
|
+
0,
|
|
384
|
+
0,
|
|
385
|
+
0,
|
|
386
|
+
0,
|
|
387
|
+
1
|
|
388
|
+
]);
|
|
389
|
+
this.setMatrix(t);
|
|
390
|
+
}
|
|
391
|
+
setMatrix(t) {
|
|
392
|
+
for (let e = 0; e < 16; ++e)
|
|
393
|
+
this._tr[e] = t[e];
|
|
394
|
+
}
|
|
395
|
+
getArray() {
|
|
396
|
+
return this._tr;
|
|
397
|
+
}
|
|
398
|
+
getScaleX() {
|
|
399
|
+
return this._tr[0];
|
|
400
|
+
}
|
|
401
|
+
getScaleY() {
|
|
402
|
+
return this._tr[5];
|
|
403
|
+
}
|
|
404
|
+
getTranslateX() {
|
|
405
|
+
return this._tr[12];
|
|
406
|
+
}
|
|
407
|
+
getTranslateY() {
|
|
408
|
+
return this._tr[13];
|
|
409
|
+
}
|
|
410
|
+
transformX(t) {
|
|
411
|
+
return this._tr[0] * t + this._tr[12];
|
|
412
|
+
}
|
|
413
|
+
transformY(t) {
|
|
414
|
+
return this._tr[5] * t + this._tr[13];
|
|
415
|
+
}
|
|
416
|
+
invertTransformX(t) {
|
|
417
|
+
return (t - this._tr[12]) / this._tr[0];
|
|
418
|
+
}
|
|
419
|
+
invertTransformY(t) {
|
|
420
|
+
return (t - this._tr[13]) / this._tr[5];
|
|
421
|
+
}
|
|
422
|
+
translateRelative(t, e) {
|
|
423
|
+
const i = new Float32Array([
|
|
424
|
+
1,
|
|
425
|
+
0,
|
|
426
|
+
0,
|
|
427
|
+
0,
|
|
428
|
+
0,
|
|
429
|
+
1,
|
|
430
|
+
0,
|
|
431
|
+
0,
|
|
432
|
+
0,
|
|
433
|
+
0,
|
|
434
|
+
1,
|
|
435
|
+
0,
|
|
436
|
+
t,
|
|
437
|
+
e,
|
|
438
|
+
0,
|
|
439
|
+
1
|
|
440
|
+
]);
|
|
441
|
+
R.multiply(i, this._tr, this._tr);
|
|
442
|
+
}
|
|
443
|
+
translate(t, e) {
|
|
444
|
+
this._tr[12] = t, this._tr[13] = e;
|
|
445
|
+
}
|
|
446
|
+
translateX(t) {
|
|
447
|
+
this._tr[12] = t;
|
|
448
|
+
}
|
|
449
|
+
translateY(t) {
|
|
450
|
+
this._tr[13] = t;
|
|
451
|
+
}
|
|
452
|
+
scaleRelative(t, e) {
|
|
453
|
+
const i = new Float32Array([
|
|
454
|
+
t,
|
|
455
|
+
0,
|
|
456
|
+
0,
|
|
457
|
+
0,
|
|
458
|
+
0,
|
|
459
|
+
e,
|
|
460
|
+
0,
|
|
461
|
+
0,
|
|
462
|
+
0,
|
|
463
|
+
0,
|
|
464
|
+
1,
|
|
465
|
+
0,
|
|
466
|
+
0,
|
|
467
|
+
0,
|
|
468
|
+
0,
|
|
469
|
+
1
|
|
470
|
+
]);
|
|
471
|
+
R.multiply(i, this._tr, this._tr);
|
|
472
|
+
}
|
|
473
|
+
scale(t, e) {
|
|
474
|
+
this._tr[0] = t, this._tr[5] = e;
|
|
475
|
+
}
|
|
476
|
+
multiplyByMatrix(t) {
|
|
477
|
+
R.multiply(t.getArray(), this._tr, this._tr);
|
|
478
|
+
}
|
|
479
|
+
clone() {
|
|
480
|
+
const t = new R();
|
|
481
|
+
for (let e = 0; e < this._tr.length; e++)
|
|
482
|
+
t._tr[e] = this._tr[e];
|
|
483
|
+
return t;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
class At {
|
|
487
|
+
initialize(t) {
|
|
488
|
+
this._model = t;
|
|
489
|
+
}
|
|
490
|
+
drawModel() {
|
|
491
|
+
this.getModel() != null && this.doDrawModel();
|
|
492
|
+
}
|
|
493
|
+
setMvpMatrix(t) {
|
|
494
|
+
this._mvpMatrix4x4.setMatrix(t.getArray());
|
|
495
|
+
}
|
|
496
|
+
getMvpMatrix() {
|
|
497
|
+
return this._mvpMatrix4x4;
|
|
498
|
+
}
|
|
499
|
+
setModelColor(t, e, i, r) {
|
|
500
|
+
t < 0 ? t = 0 : t > 1 && (t = 1), e < 0 ? e = 0 : e > 1 && (e = 1), i < 0 ? i = 0 : i > 1 && (i = 1), r < 0 ? r = 0 : r > 1 && (r = 1), this._modelColor.R = t, this._modelColor.G = e, this._modelColor.B = i, this._modelColor.A = r;
|
|
501
|
+
}
|
|
502
|
+
getModelColor() {
|
|
503
|
+
return Object.assign({}, this._modelColor);
|
|
504
|
+
}
|
|
505
|
+
setIsPremultipliedAlpha(t) {
|
|
506
|
+
this._isPremultipliedAlpha = t;
|
|
507
|
+
}
|
|
508
|
+
isPremultipliedAlpha() {
|
|
509
|
+
return this._isPremultipliedAlpha;
|
|
510
|
+
}
|
|
511
|
+
setIsCulling(t) {
|
|
512
|
+
this._isCulling = t;
|
|
513
|
+
}
|
|
514
|
+
isCulling() {
|
|
515
|
+
return this._isCulling;
|
|
516
|
+
}
|
|
517
|
+
setAnisotropy(t) {
|
|
518
|
+
this._anisortopy = t;
|
|
519
|
+
}
|
|
520
|
+
getAnisotropy() {
|
|
521
|
+
return this._anisortopy;
|
|
522
|
+
}
|
|
523
|
+
getModel() {
|
|
524
|
+
return this._model;
|
|
525
|
+
}
|
|
526
|
+
constructor() {
|
|
527
|
+
this._isCulling = !1, this._isPremultipliedAlpha = !1, this._anisortopy = 0, this._modelColor = new at(), this._mvpMatrix4x4 = new R(), this._mvpMatrix4x4.loadIdentity();
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
var z = /* @__PURE__ */ ((s) => (s[s.CubismBlendMode_Normal = 0] = "CubismBlendMode_Normal", s[s.CubismBlendMode_Additive = 1] = "CubismBlendMode_Additive", s[s.CubismBlendMode_Multiplicative = 2] = "CubismBlendMode_Multiplicative", s))(z || {});
|
|
531
|
+
class at {
|
|
532
|
+
constructor() {
|
|
533
|
+
this.R = 1, this.G = 1, this.B = 1, this.A = 1;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
let O = !1, K = !1, Q;
|
|
537
|
+
const xt = {
|
|
538
|
+
vertexOffset: 0,
|
|
539
|
+
vertexStep: 2
|
|
540
|
+
};
|
|
541
|
+
class ht {
|
|
542
|
+
static startUp(t) {
|
|
543
|
+
if (O)
|
|
544
|
+
return rt("CubismFramework.startUp() is already done."), O;
|
|
545
|
+
if (Live2DCubismCore._isStarted)
|
|
546
|
+
return O = !0, !0;
|
|
547
|
+
if (Live2DCubismCore._isStarted = !0, Q = t, Q && Live2DCubismCore.Logging.csmSetLogFunction(Q.logFunction), O = !0, O) {
|
|
548
|
+
const e = Live2DCubismCore.Version.csmGetVersion(), i = (e & 4278190080) >> 24, r = (e & 16711680) >> 16, a = e & 65535, n = e;
|
|
549
|
+
rt("Live2D Cubism Core version: {0}.{1}.{2} ({3})", ("00" + i).slice(-2), ("00" + r).slice(-2), ("0000" + a).slice(-4), n);
|
|
550
|
+
}
|
|
551
|
+
return rt("CubismFramework.startUp() is complete."), O;
|
|
552
|
+
}
|
|
553
|
+
static cleanUp() {
|
|
554
|
+
O = !1, K = !1, Q = void 0;
|
|
555
|
+
}
|
|
556
|
+
static initialize() {
|
|
557
|
+
if (!O) {
|
|
558
|
+
nt("CubismFramework is not started.");
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
if (K) {
|
|
562
|
+
nt("CubismFramework.initialize() skipped, already initialized.");
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
K = !0, rt("CubismFramework.initialize() is complete.");
|
|
566
|
+
}
|
|
567
|
+
static dispose() {
|
|
568
|
+
if (!O) {
|
|
569
|
+
nt("CubismFramework is not started.");
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
if (!K) {
|
|
573
|
+
nt("CubismFramework.dispose() skipped, not initialized.");
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
At.staticRelease(), K = !1, rt("CubismFramework.dispose() is complete.");
|
|
577
|
+
}
|
|
578
|
+
static isStarted() {
|
|
579
|
+
return O;
|
|
580
|
+
}
|
|
581
|
+
static isInitialized() {
|
|
582
|
+
return K;
|
|
583
|
+
}
|
|
584
|
+
static coreLogFunction(t) {
|
|
585
|
+
Live2DCubismCore.Logging.csmGetLogFunction() && Live2DCubismCore.Logging.csmGetLogFunction()(t);
|
|
586
|
+
}
|
|
587
|
+
static getLoggingLevel() {
|
|
588
|
+
return Q != null ? Q.loggingLevel : Y.LogLevel_Off;
|
|
589
|
+
}
|
|
590
|
+
constructor() {
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
var Y = /* @__PURE__ */ ((s) => (s[s.LogLevel_Verbose = 0] = "LogLevel_Verbose", s[s.LogLevel_Debug = 1] = "LogLevel_Debug", s[s.LogLevel_Info = 2] = "LogLevel_Info", s[s.LogLevel_Warning = 3] = "LogLevel_Warning", s[s.LogLevel_Error = 4] = "LogLevel_Error", s[s.LogLevel_Off = 5] = "LogLevel_Off", s))(Y || {});
|
|
594
|
+
const ct = () => {
|
|
595
|
+
};
|
|
596
|
+
function ns(s, ...t) {
|
|
597
|
+
dt.print(Y.LogLevel_Verbose, "[CSM][V]" + s + `
|
|
598
|
+
`, t);
|
|
599
|
+
}
|
|
600
|
+
function qt(s, ...t) {
|
|
601
|
+
dt.print(Y.LogLevel_Debug, "[CSM][D]" + s + `
|
|
602
|
+
`, t);
|
|
603
|
+
}
|
|
604
|
+
function rt(s, ...t) {
|
|
605
|
+
dt.print(Y.LogLevel_Info, "[CSM][I]" + s + `
|
|
606
|
+
`, t);
|
|
607
|
+
}
|
|
608
|
+
function nt(s, ...t) {
|
|
609
|
+
dt.print(Y.LogLevel_Warning, "[CSM][W]" + s + `
|
|
610
|
+
`, t);
|
|
611
|
+
}
|
|
612
|
+
function tt(s, ...t) {
|
|
613
|
+
dt.print(Y.LogLevel_Error, "[CSM][E]" + s + `
|
|
614
|
+
`, t);
|
|
615
|
+
}
|
|
616
|
+
class dt {
|
|
617
|
+
static print(t, e, i) {
|
|
618
|
+
if (t < ht.getLoggingLevel())
|
|
619
|
+
return;
|
|
620
|
+
const r = ht.coreLogFunction;
|
|
621
|
+
if (!r)
|
|
622
|
+
return;
|
|
623
|
+
const a = e.replace(/{(\d+)}/g, (n, o) => i[o]);
|
|
624
|
+
r(a);
|
|
625
|
+
}
|
|
626
|
+
static dumpBytes(t, e, i) {
|
|
627
|
+
for (let r = 0; r < i; r++)
|
|
628
|
+
r % 16 == 0 && r > 0 ? this.print(t, `
|
|
629
|
+
`) : r % 8 == 0 && r > 0 && this.print(t, " "), this.print(t, "{0} ", [e[r] & 255]);
|
|
630
|
+
this.print(t, `
|
|
631
|
+
`);
|
|
632
|
+
}
|
|
633
|
+
constructor() {
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
class De {
|
|
637
|
+
update() {
|
|
638
|
+
this._model.update(), this._model.drawables.resetDynamicFlags();
|
|
639
|
+
}
|
|
640
|
+
getCanvasWidth() {
|
|
641
|
+
return this._model == null ? 0 : this._model.canvasinfo.CanvasWidth / this._model.canvasinfo.PixelsPerUnit;
|
|
642
|
+
}
|
|
643
|
+
getCanvasHeight() {
|
|
644
|
+
return this._model == null ? 0 : this._model.canvasinfo.CanvasHeight / this._model.canvasinfo.PixelsPerUnit;
|
|
645
|
+
}
|
|
646
|
+
saveParameters() {
|
|
647
|
+
const t = this._model.parameters.count, e = this._savedParameters.length;
|
|
648
|
+
for (let i = 0; i < t; ++i)
|
|
649
|
+
i < e ? this._savedParameters[i] = this._parameterValues[i] : this._savedParameters.push(this._parameterValues[i]);
|
|
650
|
+
}
|
|
651
|
+
getModel() {
|
|
652
|
+
return this._model;
|
|
653
|
+
}
|
|
654
|
+
getPartIndex(t) {
|
|
655
|
+
let e;
|
|
656
|
+
const i = this._model.parts.count;
|
|
657
|
+
for (e = 0; e < i; ++e)
|
|
658
|
+
if (t == this._partIds[e])
|
|
659
|
+
return e;
|
|
660
|
+
return t in this._notExistPartId ? this._notExistPartId[t] : (e = i + this._notExistPartId.length, this._notExistPartId[t] = e, this._notExistPartOpacities[e] = 0, e);
|
|
661
|
+
}
|
|
662
|
+
getPartCount() {
|
|
663
|
+
return this._model.parts.count;
|
|
664
|
+
}
|
|
665
|
+
setPartOpacityByIndex(t, e) {
|
|
666
|
+
if (t in this._notExistPartOpacities) {
|
|
667
|
+
this._notExistPartOpacities[t] = e;
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
ct(0 <= t && t < this.getPartCount()), this._partOpacities[t] = e;
|
|
671
|
+
}
|
|
672
|
+
setPartOpacityById(t, e) {
|
|
673
|
+
const i = this.getPartIndex(t);
|
|
674
|
+
i < 0 || this.setPartOpacityByIndex(i, e);
|
|
675
|
+
}
|
|
676
|
+
getPartOpacityByIndex(t) {
|
|
677
|
+
return t in this._notExistPartOpacities ? this._notExistPartOpacities[t] : (ct(0 <= t && t < this.getPartCount()), this._partOpacities[t]);
|
|
678
|
+
}
|
|
679
|
+
getPartOpacityById(t) {
|
|
680
|
+
const e = this.getPartIndex(t);
|
|
681
|
+
return e < 0 ? 0 : this.getPartOpacityByIndex(e);
|
|
682
|
+
}
|
|
683
|
+
getParameterIndex(t) {
|
|
684
|
+
let e;
|
|
685
|
+
const i = this._model.parameters.count;
|
|
686
|
+
for (e = 0; e < i; ++e)
|
|
687
|
+
if (t == this._parameterIds[e])
|
|
688
|
+
return e;
|
|
689
|
+
return t in this._notExistParameterId ? this._notExistParameterId[t] : (e = this._model.parameters.count + Object.keys(this._notExistParameterId).length, this._notExistParameterId[t] = e, this._notExistParameterValues[e] = 0, e);
|
|
690
|
+
}
|
|
691
|
+
getParameterCount() {
|
|
692
|
+
return this._model.parameters.count;
|
|
693
|
+
}
|
|
694
|
+
getParameterMaximumValue(t) {
|
|
695
|
+
return this._model.parameters.maximumValues[t];
|
|
696
|
+
}
|
|
697
|
+
getParameterMinimumValue(t) {
|
|
698
|
+
return this._model.parameters.minimumValues[t];
|
|
699
|
+
}
|
|
700
|
+
getParameterDefaultValue(t) {
|
|
701
|
+
return this._model.parameters.defaultValues[t];
|
|
702
|
+
}
|
|
703
|
+
getParameterValueByIndex(t) {
|
|
704
|
+
return t in this._notExistParameterValues ? this._notExistParameterValues[t] : (ct(0 <= t && t < this.getParameterCount()), this._parameterValues[t]);
|
|
705
|
+
}
|
|
706
|
+
getParameterValueById(t) {
|
|
707
|
+
const e = this.getParameterIndex(t);
|
|
708
|
+
return this.getParameterValueByIndex(e);
|
|
709
|
+
}
|
|
710
|
+
setParameterValueByIndex(t, e, i = 1) {
|
|
711
|
+
if (t in this._notExistParameterValues) {
|
|
712
|
+
this._notExistParameterValues[t] = i == 1 ? e : this._notExistParameterValues[t] * (1 - i) + e * i;
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
ct(0 <= t && t < this.getParameterCount()), this._model.parameters.maximumValues[t] < e && (e = this._model.parameters.maximumValues[t]), this._model.parameters.minimumValues[t] > e && (e = this._model.parameters.minimumValues[t]), this._parameterValues[t] = i == 1 ? e : this._parameterValues[t] = this._parameterValues[t] * (1 - i) + e * i;
|
|
716
|
+
}
|
|
717
|
+
setParameterValueById(t, e, i = 1) {
|
|
718
|
+
const r = this.getParameterIndex(t);
|
|
719
|
+
this.setParameterValueByIndex(r, e, i);
|
|
720
|
+
}
|
|
721
|
+
addParameterValueByIndex(t, e, i = 1) {
|
|
722
|
+
this.setParameterValueByIndex(t, this.getParameterValueByIndex(t) + e * i);
|
|
723
|
+
}
|
|
724
|
+
addParameterValueById(t, e, i = 1) {
|
|
725
|
+
const r = this.getParameterIndex(t);
|
|
726
|
+
this.addParameterValueByIndex(r, e, i);
|
|
727
|
+
}
|
|
728
|
+
multiplyParameterValueById(t, e, i = 1) {
|
|
729
|
+
const r = this.getParameterIndex(t);
|
|
730
|
+
this.multiplyParameterValueByIndex(r, e, i);
|
|
731
|
+
}
|
|
732
|
+
multiplyParameterValueByIndex(t, e, i = 1) {
|
|
733
|
+
this.setParameterValueByIndex(t, this.getParameterValueByIndex(t) * (1 + (e - 1) * i));
|
|
734
|
+
}
|
|
735
|
+
getDrawableIds() {
|
|
736
|
+
return this._drawableIds.slice();
|
|
737
|
+
}
|
|
738
|
+
getDrawableIndex(t) {
|
|
739
|
+
const e = this._model.drawables.count;
|
|
740
|
+
for (let i = 0; i < e; ++i)
|
|
741
|
+
if (this._drawableIds[i] == t)
|
|
742
|
+
return i;
|
|
743
|
+
return -1;
|
|
744
|
+
}
|
|
745
|
+
getDrawableCount() {
|
|
746
|
+
return this._model.drawables.count;
|
|
747
|
+
}
|
|
748
|
+
getDrawableId(t) {
|
|
749
|
+
return this._model.drawables.ids[t];
|
|
750
|
+
}
|
|
751
|
+
getDrawableRenderOrders() {
|
|
752
|
+
return this._model.drawables.renderOrders;
|
|
753
|
+
}
|
|
754
|
+
getDrawableTextureIndices(t) {
|
|
755
|
+
return this._model.drawables.textureIndices[t];
|
|
756
|
+
}
|
|
757
|
+
getDrawableDynamicFlagVertexPositionsDidChange(t) {
|
|
758
|
+
const e = this._model.drawables.dynamicFlags;
|
|
759
|
+
return Live2DCubismCore.Utils.hasVertexPositionsDidChangeBit(e[t]);
|
|
760
|
+
}
|
|
761
|
+
getDrawableVertexIndexCount(t) {
|
|
762
|
+
return this._model.drawables.indexCounts[t];
|
|
763
|
+
}
|
|
764
|
+
getDrawableVertexCount(t) {
|
|
765
|
+
return this._model.drawables.vertexCounts[t];
|
|
766
|
+
}
|
|
767
|
+
getDrawableVertices(t) {
|
|
768
|
+
return this.getDrawableVertexPositions(t);
|
|
769
|
+
}
|
|
770
|
+
getDrawableVertexIndices(t) {
|
|
771
|
+
return this._model.drawables.indices[t];
|
|
772
|
+
}
|
|
773
|
+
getDrawableVertexPositions(t) {
|
|
774
|
+
return this._model.drawables.vertexPositions[t];
|
|
775
|
+
}
|
|
776
|
+
getDrawableVertexUvs(t) {
|
|
777
|
+
return this._model.drawables.vertexUvs[t];
|
|
778
|
+
}
|
|
779
|
+
getDrawableOpacity(t) {
|
|
780
|
+
return this._model.drawables.opacities[t];
|
|
781
|
+
}
|
|
782
|
+
getDrawableCulling(t) {
|
|
783
|
+
const e = this._model.drawables.constantFlags;
|
|
784
|
+
return !Live2DCubismCore.Utils.hasIsDoubleSidedBit(e[t]);
|
|
785
|
+
}
|
|
786
|
+
getDrawableBlendMode(t) {
|
|
787
|
+
const e = this._model.drawables.constantFlags;
|
|
788
|
+
return Live2DCubismCore.Utils.hasBlendAdditiveBit(e[t]) ? z.CubismBlendMode_Additive : Live2DCubismCore.Utils.hasBlendMultiplicativeBit(e[t]) ? z.CubismBlendMode_Multiplicative : z.CubismBlendMode_Normal;
|
|
789
|
+
}
|
|
790
|
+
getDrawableInvertedMaskBit(t) {
|
|
791
|
+
const e = this._model.drawables.constantFlags;
|
|
792
|
+
return Live2DCubismCore.Utils.hasIsInvertedMaskBit(e[t]);
|
|
793
|
+
}
|
|
794
|
+
getDrawableMasks() {
|
|
795
|
+
return this._model.drawables.masks;
|
|
796
|
+
}
|
|
797
|
+
getDrawableMaskCounts() {
|
|
798
|
+
return this._model.drawables.maskCounts;
|
|
799
|
+
}
|
|
800
|
+
isUsingMasking() {
|
|
801
|
+
for (let t = 0; t < this._model.drawables.count; ++t)
|
|
802
|
+
if (!(this._model.drawables.maskCounts[t] <= 0))
|
|
803
|
+
return !0;
|
|
804
|
+
return !1;
|
|
805
|
+
}
|
|
806
|
+
getDrawableDynamicFlagIsVisible(t) {
|
|
807
|
+
const e = this._model.drawables.dynamicFlags;
|
|
808
|
+
return Live2DCubismCore.Utils.hasIsVisibleBit(e[t]);
|
|
809
|
+
}
|
|
810
|
+
getDrawableDynamicFlagVisibilityDidChange(t) {
|
|
811
|
+
const e = this._model.drawables.dynamicFlags;
|
|
812
|
+
return Live2DCubismCore.Utils.hasVisibilityDidChangeBit(e[t]);
|
|
813
|
+
}
|
|
814
|
+
getDrawableDynamicFlagOpacityDidChange(t) {
|
|
815
|
+
const e = this._model.drawables.dynamicFlags;
|
|
816
|
+
return Live2DCubismCore.Utils.hasOpacityDidChangeBit(e[t]);
|
|
817
|
+
}
|
|
818
|
+
getDrawableDynamicFlagRenderOrderDidChange(t) {
|
|
819
|
+
const e = this._model.drawables.dynamicFlags;
|
|
820
|
+
return Live2DCubismCore.Utils.hasRenderOrderDidChangeBit(e[t]);
|
|
821
|
+
}
|
|
822
|
+
loadParameters() {
|
|
823
|
+
let t = this._model.parameters.count;
|
|
824
|
+
const e = this._savedParameters.length;
|
|
825
|
+
t > e && (t = e);
|
|
826
|
+
for (let i = 0; i < t; ++i)
|
|
827
|
+
this._parameterValues[i] = this._savedParameters[i];
|
|
828
|
+
}
|
|
829
|
+
initialize() {
|
|
830
|
+
this._parameterValues = this._model.parameters.values, this._partOpacities = this._model.parts.opacities, this._parameterMaximumValues = this._model.parameters.maximumValues, this._parameterMinimumValues = this._model.parameters.minimumValues;
|
|
831
|
+
{
|
|
832
|
+
const t = this._model.parameters.ids, e = this._model.parameters.count;
|
|
833
|
+
for (let i = 0; i < e; ++i)
|
|
834
|
+
this._parameterIds.push(t[i]);
|
|
835
|
+
}
|
|
836
|
+
{
|
|
837
|
+
const t = this._model.parts.ids, e = this._model.parts.count;
|
|
838
|
+
for (let i = 0; i < e; ++i)
|
|
839
|
+
this._partIds.push(t[i]);
|
|
840
|
+
}
|
|
841
|
+
{
|
|
842
|
+
const t = this._model.drawables.ids, e = this._model.drawables.count;
|
|
843
|
+
for (let i = 0; i < e; ++i)
|
|
844
|
+
this._drawableIds.push(t[i]);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
constructor(t) {
|
|
848
|
+
this._model = t, this._savedParameters = [], this._parameterIds = [], this._drawableIds = [], this._partIds = [], this._notExistPartId = {}, this._notExistParameterId = {}, this._notExistParameterValues = {}, this._notExistPartOpacities = {}, this.initialize();
|
|
849
|
+
}
|
|
850
|
+
release() {
|
|
851
|
+
this._model.release(), this._model = void 0;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
class Bt {
|
|
855
|
+
static create(t) {
|
|
856
|
+
const e = Live2DCubismCore.Moc.fromArrayBuffer(t);
|
|
857
|
+
if (e)
|
|
858
|
+
return new Bt(e);
|
|
859
|
+
throw new Error("Unknown error");
|
|
860
|
+
}
|
|
861
|
+
createModel() {
|
|
862
|
+
let t;
|
|
863
|
+
const e = Live2DCubismCore.Model.fromMoc(this._moc);
|
|
864
|
+
if (e)
|
|
865
|
+
return t = new De(e), ++this._modelCount, t;
|
|
866
|
+
throw new Error("Unknown error");
|
|
867
|
+
}
|
|
868
|
+
deleteModel(t) {
|
|
869
|
+
t != null && --this._modelCount;
|
|
870
|
+
}
|
|
871
|
+
constructor(t) {
|
|
872
|
+
this._moc = t, this._modelCount = 0;
|
|
873
|
+
}
|
|
874
|
+
release() {
|
|
875
|
+
this._moc._release(), this._moc = void 0;
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
class Ae {
|
|
879
|
+
constructor(t, e) {
|
|
880
|
+
this._json = t;
|
|
881
|
+
}
|
|
882
|
+
release() {
|
|
883
|
+
this._json = void 0;
|
|
884
|
+
}
|
|
885
|
+
getUserDataCount() {
|
|
886
|
+
return this._json.Meta.UserDataCount;
|
|
887
|
+
}
|
|
888
|
+
getTotalUserDataSize() {
|
|
889
|
+
return this._json.Meta.TotalUserDataSize;
|
|
890
|
+
}
|
|
891
|
+
getUserDataTargetType(t) {
|
|
892
|
+
return this._json.UserData[t].Target;
|
|
893
|
+
}
|
|
894
|
+
getUserDataId(t) {
|
|
895
|
+
return this._json.UserData[t].Id;
|
|
896
|
+
}
|
|
897
|
+
getUserDataValue(t) {
|
|
898
|
+
return this._json.UserData[t].Value;
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
const Be = "ArtMesh";
|
|
902
|
+
class de {
|
|
903
|
+
static create(t, e) {
|
|
904
|
+
const i = new de();
|
|
905
|
+
return i.parseUserData(t, e), i;
|
|
906
|
+
}
|
|
907
|
+
getArtMeshUserDatas() {
|
|
908
|
+
return this._artMeshUserDataNode;
|
|
909
|
+
}
|
|
910
|
+
parseUserData(t, e) {
|
|
911
|
+
let i = new Ae(t, e);
|
|
912
|
+
const r = Be, a = i.getUserDataCount();
|
|
913
|
+
for (let n = 0; n < a; n++) {
|
|
914
|
+
const o = {
|
|
915
|
+
targetId: i.getUserDataId(n),
|
|
916
|
+
targetType: i.getUserDataTargetType(n),
|
|
917
|
+
value: i.getUserDataValue(n)
|
|
918
|
+
};
|
|
919
|
+
this._userDataNodes.push(o), o.targetType == r && this._artMeshUserDataNode.push(o);
|
|
920
|
+
}
|
|
921
|
+
i.release();
|
|
922
|
+
}
|
|
923
|
+
constructor() {
|
|
924
|
+
this._userDataNodes = [], this._artMeshUserDataNode = [];
|
|
925
|
+
}
|
|
926
|
+
release() {
|
|
927
|
+
this._userDataNodes = null;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
class ce {
|
|
931
|
+
constructor() {
|
|
932
|
+
this._fadeInSeconds = -1, this._fadeOutSeconds = -1, this._weight = 1, this._offsetSeconds = 0, this._firedEventValues = [];
|
|
933
|
+
}
|
|
934
|
+
release() {
|
|
935
|
+
this._weight = 0;
|
|
936
|
+
}
|
|
937
|
+
updateParameters(t, e, i) {
|
|
938
|
+
if (!e.isAvailable() || e.isFinished())
|
|
939
|
+
return;
|
|
940
|
+
if (!e.isStarted()) {
|
|
941
|
+
e.setIsStarted(!0), e.setStartTime(i - this._offsetSeconds), e.setFadeInStartTime(i);
|
|
942
|
+
const o = this.getDuration();
|
|
943
|
+
e.getEndTime() < 0 && e.setEndTime(o <= 0 ? -1 : e.getStartTime() + o);
|
|
944
|
+
}
|
|
945
|
+
let r = this._weight;
|
|
946
|
+
const a = this._fadeInSeconds == 0 ? 1 : S.getEasingSine((i - e.getFadeInStartTime()) / this._fadeInSeconds), n = this._fadeOutSeconds == 0 || e.getEndTime() < 0 ? 1 : S.getEasingSine((e.getEndTime() - i) / this._fadeOutSeconds);
|
|
947
|
+
r = r * a * n, e.setState(i, r), this.doUpdateParameters(t, i, r, e), e.getEndTime() > 0 && e.getEndTime() < i && e.setIsFinished(!0);
|
|
948
|
+
}
|
|
949
|
+
setFadeInTime(t) {
|
|
950
|
+
this._fadeInSeconds = t;
|
|
951
|
+
}
|
|
952
|
+
setFadeOutTime(t) {
|
|
953
|
+
this._fadeOutSeconds = t;
|
|
954
|
+
}
|
|
955
|
+
getFadeOutTime() {
|
|
956
|
+
return this._fadeOutSeconds;
|
|
957
|
+
}
|
|
958
|
+
getFadeInTime() {
|
|
959
|
+
return this._fadeInSeconds;
|
|
960
|
+
}
|
|
961
|
+
setWeight(t) {
|
|
962
|
+
this._weight = t;
|
|
963
|
+
}
|
|
964
|
+
getWeight() {
|
|
965
|
+
return this._weight;
|
|
966
|
+
}
|
|
967
|
+
getDuration() {
|
|
968
|
+
return -1;
|
|
969
|
+
}
|
|
970
|
+
getLoopDuration() {
|
|
971
|
+
return -1;
|
|
972
|
+
}
|
|
973
|
+
setOffsetTime(t) {
|
|
974
|
+
this._offsetSeconds = t;
|
|
975
|
+
}
|
|
976
|
+
getFiredEvent(t, e) {
|
|
977
|
+
return this._firedEventValues;
|
|
978
|
+
}
|
|
979
|
+
setFinishedMotionHandler(t) {
|
|
980
|
+
this._onFinishedMotion = t;
|
|
981
|
+
}
|
|
982
|
+
getFinishedMotionHandler() {
|
|
983
|
+
return this._onFinishedMotion;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
const $t = 1;
|
|
987
|
+
class Rt extends ce {
|
|
988
|
+
constructor() {
|
|
989
|
+
super(), this._parameters = [];
|
|
990
|
+
}
|
|
991
|
+
static create(t) {
|
|
992
|
+
const e = new Rt(), i = t.FadeInTime, r = t.FadeOutTime;
|
|
993
|
+
e.setFadeInTime(i !== void 0 ? i : $t), e.setFadeOutTime(r !== void 0 ? r : $t);
|
|
994
|
+
const a = t.Parameters || [];
|
|
995
|
+
for (let n = 0; n < a.length; ++n) {
|
|
996
|
+
const o = a[n], l = o.Id, h = o.Value;
|
|
997
|
+
let u;
|
|
998
|
+
switch (o.Blend) {
|
|
999
|
+
case "Multiply":
|
|
1000
|
+
u = q.ExpressionBlendType_Multiply;
|
|
1001
|
+
break;
|
|
1002
|
+
case "Overwrite":
|
|
1003
|
+
u = q.ExpressionBlendType_Overwrite;
|
|
1004
|
+
break;
|
|
1005
|
+
default:
|
|
1006
|
+
u = q.ExpressionBlendType_Add;
|
|
1007
|
+
break;
|
|
1008
|
+
}
|
|
1009
|
+
const c = {
|
|
1010
|
+
parameterId: l,
|
|
1011
|
+
blendType: u,
|
|
1012
|
+
value: h
|
|
1013
|
+
};
|
|
1014
|
+
e._parameters.push(c);
|
|
1015
|
+
}
|
|
1016
|
+
return e;
|
|
1017
|
+
}
|
|
1018
|
+
doUpdateParameters(t, e, i, r) {
|
|
1019
|
+
for (let a = 0; a < this._parameters.length; ++a) {
|
|
1020
|
+
const n = this._parameters[a];
|
|
1021
|
+
switch (n.blendType) {
|
|
1022
|
+
case q.ExpressionBlendType_Add: {
|
|
1023
|
+
t.addParameterValueById(n.parameterId, n.value, i);
|
|
1024
|
+
break;
|
|
1025
|
+
}
|
|
1026
|
+
case q.ExpressionBlendType_Multiply: {
|
|
1027
|
+
t.multiplyParameterValueById(n.parameterId, n.value, i);
|
|
1028
|
+
break;
|
|
1029
|
+
}
|
|
1030
|
+
case q.ExpressionBlendType_Overwrite: {
|
|
1031
|
+
t.setParameterValueById(n.parameterId, n.value, i);
|
|
1032
|
+
break;
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
var q = /* @__PURE__ */ ((s) => (s[s.ExpressionBlendType_Add = 0] = "ExpressionBlendType_Add", s[s.ExpressionBlendType_Multiply = 1] = "ExpressionBlendType_Multiply", s[s.ExpressionBlendType_Overwrite = 2] = "ExpressionBlendType_Overwrite", s))(q || {}), ut;
|
|
1039
|
+
((s) => {
|
|
1040
|
+
s.supportMoreMaskDivisions = !0, s.setOpacityFromMotion = !1;
|
|
1041
|
+
})(ut || (ut = {}));
|
|
1042
|
+
var $ = /* @__PURE__ */ ((s) => (s[s.CubismMotionCurveTarget_Model = 0] = "CubismMotionCurveTarget_Model", s[s.CubismMotionCurveTarget_Parameter = 1] = "CubismMotionCurveTarget_Parameter", s[s.CubismMotionCurveTarget_PartOpacity = 2] = "CubismMotionCurveTarget_PartOpacity", s))($ || {}), k = /* @__PURE__ */ ((s) => (s[s.CubismMotionSegmentType_Linear = 0] = "CubismMotionSegmentType_Linear", s[s.CubismMotionSegmentType_Bezier = 1] = "CubismMotionSegmentType_Bezier", s[s.CubismMotionSegmentType_Stepped = 2] = "CubismMotionSegmentType_Stepped", s[s.CubismMotionSegmentType_InverseStepped = 3] = "CubismMotionSegmentType_InverseStepped", s))(k || {});
|
|
1043
|
+
class j {
|
|
1044
|
+
constructor(t = 0, e = 0) {
|
|
1045
|
+
this.time = t, this.value = e;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
class Re {
|
|
1049
|
+
constructor() {
|
|
1050
|
+
this.basePointIndex = 0, this.segmentType = 0;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
class Oe {
|
|
1054
|
+
constructor() {
|
|
1055
|
+
this.id = "", this.type = 0, this.segmentCount = 0, this.baseSegmentIndex = 0, this.fadeInTime = 0, this.fadeOutTime = 0;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
class ke {
|
|
1059
|
+
constructor() {
|
|
1060
|
+
this.fireTime = 0, this.value = "";
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
class Ue {
|
|
1064
|
+
constructor() {
|
|
1065
|
+
this.duration = 0, this.loop = !1, this.curveCount = 0, this.eventCount = 0, this.fps = 0, this.curves = [], this.segments = [], this.points = [], this.events = [];
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
class me {
|
|
1069
|
+
constructor(t) {
|
|
1070
|
+
this._json = t;
|
|
1071
|
+
}
|
|
1072
|
+
release() {
|
|
1073
|
+
this._json = void 0;
|
|
1074
|
+
}
|
|
1075
|
+
getMotionDuration() {
|
|
1076
|
+
return this._json.Meta.Duration;
|
|
1077
|
+
}
|
|
1078
|
+
isMotionLoop() {
|
|
1079
|
+
return this._json.Meta.Loop || !1;
|
|
1080
|
+
}
|
|
1081
|
+
getEvaluationOptionFlag(t) {
|
|
1082
|
+
return Ot.EvaluationOptionFlag_AreBeziersRistricted == t ? !!this._json.Meta.AreBeziersRestricted : !1;
|
|
1083
|
+
}
|
|
1084
|
+
getMotionCurveCount() {
|
|
1085
|
+
return this._json.Meta.CurveCount;
|
|
1086
|
+
}
|
|
1087
|
+
getMotionFps() {
|
|
1088
|
+
return this._json.Meta.Fps;
|
|
1089
|
+
}
|
|
1090
|
+
getMotionTotalSegmentCount() {
|
|
1091
|
+
return this._json.Meta.TotalSegmentCount;
|
|
1092
|
+
}
|
|
1093
|
+
getMotionTotalPointCount() {
|
|
1094
|
+
return this._json.Meta.TotalPointCount;
|
|
1095
|
+
}
|
|
1096
|
+
getMotionFadeInTime() {
|
|
1097
|
+
return this._json.Meta.FadeInTime;
|
|
1098
|
+
}
|
|
1099
|
+
getMotionFadeOutTime() {
|
|
1100
|
+
return this._json.Meta.FadeOutTime;
|
|
1101
|
+
}
|
|
1102
|
+
getMotionCurveTarget(t) {
|
|
1103
|
+
return this._json.Curves[t].Target;
|
|
1104
|
+
}
|
|
1105
|
+
getMotionCurveId(t) {
|
|
1106
|
+
return this._json.Curves[t].Id;
|
|
1107
|
+
}
|
|
1108
|
+
getMotionCurveFadeInTime(t) {
|
|
1109
|
+
return this._json.Curves[t].FadeInTime;
|
|
1110
|
+
}
|
|
1111
|
+
getMotionCurveFadeOutTime(t) {
|
|
1112
|
+
return this._json.Curves[t].FadeOutTime;
|
|
1113
|
+
}
|
|
1114
|
+
getMotionCurveSegmentCount(t) {
|
|
1115
|
+
return this._json.Curves[t].Segments.length;
|
|
1116
|
+
}
|
|
1117
|
+
getMotionCurveSegment(t, e) {
|
|
1118
|
+
return this._json.Curves[t].Segments[e];
|
|
1119
|
+
}
|
|
1120
|
+
getEventCount() {
|
|
1121
|
+
return this._json.Meta.UserDataCount || 0;
|
|
1122
|
+
}
|
|
1123
|
+
getTotalEventValueSize() {
|
|
1124
|
+
return this._json.Meta.TotalUserDataSize;
|
|
1125
|
+
}
|
|
1126
|
+
getEventTime(t) {
|
|
1127
|
+
return this._json.UserData[t].Time;
|
|
1128
|
+
}
|
|
1129
|
+
getEventValue(t) {
|
|
1130
|
+
return this._json.UserData[t].Value;
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
var Ot = /* @__PURE__ */ ((s) => (s[s.EvaluationOptionFlag_AreBeziersRistricted = 0] = "EvaluationOptionFlag_AreBeziersRistricted", s))(Ot || {});
|
|
1134
|
+
const Ve = "EyeBlink", Ne = "LipSync", Ge = "Model", je = "Parameter", ze = "PartOpacity", Xe = !1;
|
|
1135
|
+
function B(s, t, e) {
|
|
1136
|
+
const i = new j();
|
|
1137
|
+
return i.time = s.time + (t.time - s.time) * e, i.value = s.value + (t.value - s.value) * e, i;
|
|
1138
|
+
}
|
|
1139
|
+
function Ye(s, t) {
|
|
1140
|
+
let e = (t - s[0].time) / (s[1].time - s[0].time);
|
|
1141
|
+
return e < 0 && (e = 0), s[0].value + (s[1].value - s[0].value) * e;
|
|
1142
|
+
}
|
|
1143
|
+
function He(s, t) {
|
|
1144
|
+
let e = (t - s[0].time) / (s[3].time - s[0].time);
|
|
1145
|
+
e < 0 && (e = 0);
|
|
1146
|
+
const i = B(s[0], s[1], e), r = B(s[1], s[2], e), a = B(s[2], s[3], e), n = B(i, r, e), o = B(r, a, e);
|
|
1147
|
+
return B(n, o, e).value;
|
|
1148
|
+
}
|
|
1149
|
+
function We(s, t) {
|
|
1150
|
+
const e = t, i = s[0].time, r = s[3].time, a = s[1].time, n = s[2].time, o = r - 3 * n + 3 * a - i, l = 3 * n - 6 * a + 3 * i, h = 3 * a - 3 * i, u = i - e, c = S.cardanoAlgorithmForBezier(o, l, h, u), d = B(s[0], s[1], c), _ = B(s[1], s[2], c), p = B(s[2], s[3], c), x = B(d, _, c), g = B(_, p, c);
|
|
1151
|
+
return B(x, g, c).value;
|
|
1152
|
+
}
|
|
1153
|
+
function qe(s, t) {
|
|
1154
|
+
return s[0].value;
|
|
1155
|
+
}
|
|
1156
|
+
function $e(s, t) {
|
|
1157
|
+
return s[1].value;
|
|
1158
|
+
}
|
|
1159
|
+
function Pt(s, t, e) {
|
|
1160
|
+
const i = s.curves[t];
|
|
1161
|
+
let r = -1;
|
|
1162
|
+
const a = i.baseSegmentIndex + i.segmentCount;
|
|
1163
|
+
let n = 0;
|
|
1164
|
+
for (let l = i.baseSegmentIndex; l < a; ++l)
|
|
1165
|
+
if (n = s.segments[l].basePointIndex + (s.segments[l].segmentType == k.CubismMotionSegmentType_Bezier ? 3 : 1), s.points[n].time > e) {
|
|
1166
|
+
r = l;
|
|
1167
|
+
break;
|
|
1168
|
+
}
|
|
1169
|
+
if (r == -1)
|
|
1170
|
+
return s.points[n].value;
|
|
1171
|
+
const o = s.segments[r];
|
|
1172
|
+
return o.evaluate(s.points.slice(o.basePointIndex), e);
|
|
1173
|
+
}
|
|
1174
|
+
class kt extends ce {
|
|
1175
|
+
constructor() {
|
|
1176
|
+
super(), this._eyeBlinkParameterIds = [], this._lipSyncParameterIds = [], this._sourceFrameRate = 30, this._loopDurationSeconds = -1, this._isLoop = !1, this._isLoopFadeIn = !0, this._lastWeight = 0;
|
|
1177
|
+
}
|
|
1178
|
+
static create(t, e) {
|
|
1179
|
+
const i = new kt();
|
|
1180
|
+
return i.parse(t), i._sourceFrameRate = i._motionData.fps, i._loopDurationSeconds = i._motionData.duration, i._onFinishedMotion = e, i;
|
|
1181
|
+
}
|
|
1182
|
+
doUpdateParameters(t, e, i, r) {
|
|
1183
|
+
this._modelCurveIdEyeBlink == null && (this._modelCurveIdEyeBlink = Ve), this._modelCurveIdLipSync == null && (this._modelCurveIdLipSync = Ne);
|
|
1184
|
+
let a = e - r.getStartTime();
|
|
1185
|
+
a < 0 && (a = 0);
|
|
1186
|
+
let n = Number.MAX_VALUE, o = Number.MAX_VALUE;
|
|
1187
|
+
const l = 64;
|
|
1188
|
+
let h = 0, u = 0;
|
|
1189
|
+
this._eyeBlinkParameterIds.length > l && qt("too many eye blink targets : {0}", this._eyeBlinkParameterIds.length), this._lipSyncParameterIds.length > l && qt("too many lip sync targets : {0}", this._lipSyncParameterIds.length);
|
|
1190
|
+
const c = this._fadeInSeconds <= 0 ? 1 : S.getEasingSine((e - r.getFadeInStartTime()) / this._fadeInSeconds), d = this._fadeOutSeconds <= 0 || r.getEndTime() < 0 ? 1 : S.getEasingSine((r.getEndTime() - e) / this._fadeOutSeconds);
|
|
1191
|
+
let _, p, x, g = a;
|
|
1192
|
+
if (this._isLoop)
|
|
1193
|
+
for (; g > this._motionData.duration; )
|
|
1194
|
+
g -= this._motionData.duration;
|
|
1195
|
+
const m = this._motionData.curves;
|
|
1196
|
+
for (p = 0; p < this._motionData.curveCount && m[p].type == $.CubismMotionCurveTarget_Model; ++p)
|
|
1197
|
+
_ = Pt(this._motionData, p, g), m[p].id == this._modelCurveIdEyeBlink ? o = _ : m[p].id == this._modelCurveIdLipSync && (n = _);
|
|
1198
|
+
for (; p < this._motionData.curveCount && m[p].type == $.CubismMotionCurveTarget_Parameter; ++p) {
|
|
1199
|
+
if (x = t.getParameterIndex(m[p].id), x == -1)
|
|
1200
|
+
continue;
|
|
1201
|
+
const f = t.getParameterValueByIndex(x);
|
|
1202
|
+
if (_ = Pt(this._motionData, p, g), o != Number.MAX_VALUE) {
|
|
1203
|
+
for (let P = 0; P < this._eyeBlinkParameterIds.length && P < l; ++P)
|
|
1204
|
+
if (this._eyeBlinkParameterIds[P] == m[p].id) {
|
|
1205
|
+
_ *= o, u |= 1 << P;
|
|
1206
|
+
break;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
if (n != Number.MAX_VALUE) {
|
|
1210
|
+
for (let P = 0; P < this._lipSyncParameterIds.length && P < l; ++P)
|
|
1211
|
+
if (this._lipSyncParameterIds[P] == m[p].id) {
|
|
1212
|
+
_ += n, h |= 1 << P;
|
|
1213
|
+
break;
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
let v;
|
|
1217
|
+
if (m[p].fadeInTime < 0 && m[p].fadeOutTime < 0)
|
|
1218
|
+
v = f + (_ - f) * i;
|
|
1219
|
+
else {
|
|
1220
|
+
let P, I;
|
|
1221
|
+
m[p].fadeInTime < 0 ? P = c : P = m[p].fadeInTime == 0 ? 1 : S.getEasingSine((e - r.getFadeInStartTime()) / m[p].fadeInTime), m[p].fadeOutTime < 0 ? I = d : I = m[p].fadeOutTime == 0 || r.getEndTime() < 0 ? 1 : S.getEasingSine((r.getEndTime() - e) / m[p].fadeOutTime);
|
|
1222
|
+
const M = this._weight * P * I;
|
|
1223
|
+
v = f + (_ - f) * M;
|
|
1224
|
+
}
|
|
1225
|
+
t.setParameterValueByIndex(x, v, 1);
|
|
1226
|
+
}
|
|
1227
|
+
{
|
|
1228
|
+
if (o != Number.MAX_VALUE)
|
|
1229
|
+
for (let f = 0; f < this._eyeBlinkParameterIds.length && f < l; ++f) {
|
|
1230
|
+
const v = t.getParameterValueById(this._eyeBlinkParameterIds[f]);
|
|
1231
|
+
if (u >> f & 1)
|
|
1232
|
+
continue;
|
|
1233
|
+
const P = v + (o - v) * i;
|
|
1234
|
+
t.setParameterValueById(this._eyeBlinkParameterIds[f], P);
|
|
1235
|
+
}
|
|
1236
|
+
if (n != Number.MAX_VALUE)
|
|
1237
|
+
for (let f = 0; f < this._lipSyncParameterIds.length && f < l; ++f) {
|
|
1238
|
+
const v = t.getParameterValueById(this._lipSyncParameterIds[f]);
|
|
1239
|
+
if (h >> f & 1)
|
|
1240
|
+
continue;
|
|
1241
|
+
const P = v + (n - v) * i;
|
|
1242
|
+
t.setParameterValueById(this._lipSyncParameterIds[f], P);
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
for (; p < this._motionData.curveCount && m[p].type == $.CubismMotionCurveTarget_PartOpacity; ++p)
|
|
1246
|
+
if (_ = Pt(this._motionData, p, g), ut.setOpacityFromMotion)
|
|
1247
|
+
t.setPartOpacityById(m[p].id, _);
|
|
1248
|
+
else {
|
|
1249
|
+
if (x = t.getParameterIndex(m[p].id), x == -1)
|
|
1250
|
+
continue;
|
|
1251
|
+
t.setParameterValueByIndex(x, _);
|
|
1252
|
+
}
|
|
1253
|
+
a >= this._motionData.duration && (this._isLoop ? (r.setStartTime(e), this._isLoopFadeIn && r.setFadeInStartTime(e)) : (this._onFinishedMotion && this._onFinishedMotion(this), r.setIsFinished(!0))), this._lastWeight = i;
|
|
1254
|
+
}
|
|
1255
|
+
setIsLoop(t) {
|
|
1256
|
+
this._isLoop = t;
|
|
1257
|
+
}
|
|
1258
|
+
isLoop() {
|
|
1259
|
+
return this._isLoop;
|
|
1260
|
+
}
|
|
1261
|
+
setIsLoopFadeIn(t) {
|
|
1262
|
+
this._isLoopFadeIn = t;
|
|
1263
|
+
}
|
|
1264
|
+
isLoopFadeIn() {
|
|
1265
|
+
return this._isLoopFadeIn;
|
|
1266
|
+
}
|
|
1267
|
+
getDuration() {
|
|
1268
|
+
return this._isLoop ? -1 : this._loopDurationSeconds;
|
|
1269
|
+
}
|
|
1270
|
+
getLoopDuration() {
|
|
1271
|
+
return this._loopDurationSeconds;
|
|
1272
|
+
}
|
|
1273
|
+
setParameterFadeInTime(t, e) {
|
|
1274
|
+
const i = this._motionData.curves;
|
|
1275
|
+
for (let r = 0; r < this._motionData.curveCount; ++r)
|
|
1276
|
+
if (t == i[r].id) {
|
|
1277
|
+
i[r].fadeInTime = e;
|
|
1278
|
+
return;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
setParameterFadeOutTime(t, e) {
|
|
1282
|
+
const i = this._motionData.curves;
|
|
1283
|
+
for (let r = 0; r < this._motionData.curveCount; ++r)
|
|
1284
|
+
if (t == i[r].id) {
|
|
1285
|
+
i[r].fadeOutTime = e;
|
|
1286
|
+
return;
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
getParameterFadeInTime(t) {
|
|
1290
|
+
const e = this._motionData.curves;
|
|
1291
|
+
for (let i = 0; i < this._motionData.curveCount; ++i)
|
|
1292
|
+
if (t == e[i].id)
|
|
1293
|
+
return e[i].fadeInTime;
|
|
1294
|
+
return -1;
|
|
1295
|
+
}
|
|
1296
|
+
getParameterFadeOutTime(t) {
|
|
1297
|
+
const e = this._motionData.curves;
|
|
1298
|
+
for (let i = 0; i < this._motionData.curveCount; ++i)
|
|
1299
|
+
if (t == e[i].id)
|
|
1300
|
+
return e[i].fadeOutTime;
|
|
1301
|
+
return -1;
|
|
1302
|
+
}
|
|
1303
|
+
setEffectIds(t, e) {
|
|
1304
|
+
this._eyeBlinkParameterIds = t, this._lipSyncParameterIds = e;
|
|
1305
|
+
}
|
|
1306
|
+
release() {
|
|
1307
|
+
this._motionData = void 0;
|
|
1308
|
+
}
|
|
1309
|
+
parse(t) {
|
|
1310
|
+
this._motionData = new Ue();
|
|
1311
|
+
let e = new me(t);
|
|
1312
|
+
this._motionData.duration = e.getMotionDuration(), this._motionData.loop = e.isMotionLoop(), this._motionData.curveCount = e.getMotionCurveCount(), this._motionData.fps = e.getMotionFps(), this._motionData.eventCount = e.getEventCount();
|
|
1313
|
+
const i = e.getEvaluationOptionFlag(Ot.EvaluationOptionFlag_AreBeziersRistricted), r = e.getMotionFadeInTime(), a = e.getMotionFadeOutTime();
|
|
1314
|
+
r !== void 0 ? this._fadeInSeconds = r < 0 ? 1 : r : this._fadeInSeconds = 1, a !== void 0 ? this._fadeOutSeconds = a < 0 ? 1 : a : this._fadeOutSeconds = 1, this._motionData.curves = Array.from({ length: this._motionData.curveCount }).map(() => new Oe()), this._motionData.segments = Array.from({ length: e.getMotionTotalSegmentCount() }).map(() => new Re()), this._motionData.events = Array.from({ length: this._motionData.eventCount }).map(() => new ke()), this._motionData.points = [];
|
|
1315
|
+
let n = 0, o = 0;
|
|
1316
|
+
for (let l = 0; l < this._motionData.curveCount; ++l) {
|
|
1317
|
+
const h = this._motionData.curves[l];
|
|
1318
|
+
switch (e.getMotionCurveTarget(l)) {
|
|
1319
|
+
case Ge:
|
|
1320
|
+
h.type = $.CubismMotionCurveTarget_Model;
|
|
1321
|
+
break;
|
|
1322
|
+
case je:
|
|
1323
|
+
h.type = $.CubismMotionCurveTarget_Parameter;
|
|
1324
|
+
break;
|
|
1325
|
+
case ze:
|
|
1326
|
+
h.type = $.CubismMotionCurveTarget_PartOpacity;
|
|
1327
|
+
break;
|
|
1328
|
+
default:
|
|
1329
|
+
nt('Warning : Unable to get segment type from Curve! The number of "CurveCount" may be incorrect!');
|
|
1330
|
+
}
|
|
1331
|
+
h.id = e.getMotionCurveId(l), h.baseSegmentIndex = o;
|
|
1332
|
+
const u = e.getMotionCurveFadeInTime(l), c = e.getMotionCurveFadeOutTime(l);
|
|
1333
|
+
h.fadeInTime = u !== void 0 ? u : -1, h.fadeOutTime = c !== void 0 ? c : -1;
|
|
1334
|
+
for (let d = 0; d < e.getMotionCurveSegmentCount(l); ) {
|
|
1335
|
+
switch (d == 0 ? (this._motionData.segments[o].basePointIndex = n, this._motionData.points[n] = new j(e.getMotionCurveSegment(l, d), e.getMotionCurveSegment(l, d + 1)), n += 1, d += 2) : this._motionData.segments[o].basePointIndex = n - 1, e.getMotionCurveSegment(l, d)) {
|
|
1336
|
+
case k.CubismMotionSegmentType_Linear: {
|
|
1337
|
+
this._motionData.segments[o].segmentType = k.CubismMotionSegmentType_Linear, this._motionData.segments[o].evaluate = Ye, this._motionData.points[n] = new j(e.getMotionCurveSegment(l, d + 1), e.getMotionCurveSegment(l, d + 2)), n += 1, d += 3;
|
|
1338
|
+
break;
|
|
1339
|
+
}
|
|
1340
|
+
case k.CubismMotionSegmentType_Bezier: {
|
|
1341
|
+
this._motionData.segments[o].segmentType = k.CubismMotionSegmentType_Bezier, i || Xe ? this._motionData.segments[o].evaluate = He : this._motionData.segments[o].evaluate = We, this._motionData.points[n] = new j(e.getMotionCurveSegment(l, d + 1), e.getMotionCurveSegment(l, d + 2)), this._motionData.points[n + 1] = new j(e.getMotionCurveSegment(l, d + 3), e.getMotionCurveSegment(l, d + 4)), this._motionData.points[n + 2] = new j(e.getMotionCurveSegment(l, d + 5), e.getMotionCurveSegment(l, d + 6)), n += 3, d += 7;
|
|
1342
|
+
break;
|
|
1343
|
+
}
|
|
1344
|
+
case k.CubismMotionSegmentType_Stepped: {
|
|
1345
|
+
this._motionData.segments[o].segmentType = k.CubismMotionSegmentType_Stepped, this._motionData.segments[o].evaluate = qe, this._motionData.points[n] = new j(e.getMotionCurveSegment(l, d + 1), e.getMotionCurveSegment(l, d + 2)), n += 1, d += 3;
|
|
1346
|
+
break;
|
|
1347
|
+
}
|
|
1348
|
+
case k.CubismMotionSegmentType_InverseStepped: {
|
|
1349
|
+
this._motionData.segments[o].segmentType = k.CubismMotionSegmentType_InverseStepped, this._motionData.segments[o].evaluate = $e, this._motionData.points[n] = new j(e.getMotionCurveSegment(l, d + 1), e.getMotionCurveSegment(l, d + 2)), n += 1, d += 3;
|
|
1350
|
+
break;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
++h.segmentCount, ++o;
|
|
1354
|
+
}
|
|
1355
|
+
this._motionData.curves.push(h);
|
|
1356
|
+
}
|
|
1357
|
+
for (let l = 0; l < e.getEventCount(); ++l)
|
|
1358
|
+
this._motionData.events[l].fireTime = e.getEventTime(l), this._motionData.events[l].value = e.getEventValue(l);
|
|
1359
|
+
e.release();
|
|
1360
|
+
}
|
|
1361
|
+
getFiredEvent(t, e) {
|
|
1362
|
+
this._firedEventValues.length = 0;
|
|
1363
|
+
for (let i = 0; i < this._motionData.eventCount; ++i)
|
|
1364
|
+
this._motionData.events[i].fireTime > t && this._motionData.events[i].fireTime <= e && this._firedEventValues.push(this._motionData.events[i].value);
|
|
1365
|
+
return this._firedEventValues;
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
class Je {
|
|
1369
|
+
constructor() {
|
|
1370
|
+
this._autoDelete = !1, this._available = !0, this._finished = !1, this._started = !1, this._startTimeSeconds = -1, this._fadeInStartTimeSeconds = 0, this._endTimeSeconds = -1, this._stateTimeSeconds = 0, this._stateWeight = 0, this._lastEventCheckSeconds = 0, this._motionQueueEntryHandle = this, this._fadeOutSeconds = 0, this._isTriggeredFadeOut = !1;
|
|
1371
|
+
}
|
|
1372
|
+
release() {
|
|
1373
|
+
this._autoDelete && this._motion && this._motion.release();
|
|
1374
|
+
}
|
|
1375
|
+
setFadeOut(t) {
|
|
1376
|
+
this._fadeOutSeconds = t, this._isTriggeredFadeOut = !0;
|
|
1377
|
+
}
|
|
1378
|
+
startFadeOut(t, e) {
|
|
1379
|
+
const i = e + t;
|
|
1380
|
+
this._isTriggeredFadeOut = !0, (this._endTimeSeconds < 0 || i < this._endTimeSeconds) && (this._endTimeSeconds = i);
|
|
1381
|
+
}
|
|
1382
|
+
isFinished() {
|
|
1383
|
+
return this._finished;
|
|
1384
|
+
}
|
|
1385
|
+
isStarted() {
|
|
1386
|
+
return this._started;
|
|
1387
|
+
}
|
|
1388
|
+
getStartTime() {
|
|
1389
|
+
return this._startTimeSeconds;
|
|
1390
|
+
}
|
|
1391
|
+
getFadeInStartTime() {
|
|
1392
|
+
return this._fadeInStartTimeSeconds;
|
|
1393
|
+
}
|
|
1394
|
+
getEndTime() {
|
|
1395
|
+
return this._endTimeSeconds;
|
|
1396
|
+
}
|
|
1397
|
+
setStartTime(t) {
|
|
1398
|
+
this._startTimeSeconds = t;
|
|
1399
|
+
}
|
|
1400
|
+
setFadeInStartTime(t) {
|
|
1401
|
+
this._fadeInStartTimeSeconds = t;
|
|
1402
|
+
}
|
|
1403
|
+
setEndTime(t) {
|
|
1404
|
+
this._endTimeSeconds = t;
|
|
1405
|
+
}
|
|
1406
|
+
setIsFinished(t) {
|
|
1407
|
+
this._finished = t;
|
|
1408
|
+
}
|
|
1409
|
+
setIsStarted(t) {
|
|
1410
|
+
this._started = t;
|
|
1411
|
+
}
|
|
1412
|
+
isAvailable() {
|
|
1413
|
+
return this._available;
|
|
1414
|
+
}
|
|
1415
|
+
setIsAvailable(t) {
|
|
1416
|
+
this._available = t;
|
|
1417
|
+
}
|
|
1418
|
+
setState(t, e) {
|
|
1419
|
+
this._stateTimeSeconds = t, this._stateWeight = e;
|
|
1420
|
+
}
|
|
1421
|
+
getStateTime() {
|
|
1422
|
+
return this._stateTimeSeconds;
|
|
1423
|
+
}
|
|
1424
|
+
getStateWeight() {
|
|
1425
|
+
return this._stateWeight;
|
|
1426
|
+
}
|
|
1427
|
+
getLastCheckEventSeconds() {
|
|
1428
|
+
return this._lastEventCheckSeconds;
|
|
1429
|
+
}
|
|
1430
|
+
setLastCheckEventSeconds(t) {
|
|
1431
|
+
this._lastEventCheckSeconds = t;
|
|
1432
|
+
}
|
|
1433
|
+
isTriggeredFadeOut() {
|
|
1434
|
+
return this._isTriggeredFadeOut;
|
|
1435
|
+
}
|
|
1436
|
+
getFadeOutSeconds() {
|
|
1437
|
+
return this._fadeOutSeconds;
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
class Ut {
|
|
1441
|
+
constructor() {
|
|
1442
|
+
this._userTimeSeconds = 0, this._eventCustomData = null, this._motions = [];
|
|
1443
|
+
}
|
|
1444
|
+
release() {
|
|
1445
|
+
for (let t = 0; t < this._motions.length; ++t)
|
|
1446
|
+
this._motions[t] && this._motions[t].release();
|
|
1447
|
+
this._motions = void 0;
|
|
1448
|
+
}
|
|
1449
|
+
startMotion(t, e, i) {
|
|
1450
|
+
if (t == null)
|
|
1451
|
+
return Ze;
|
|
1452
|
+
let r;
|
|
1453
|
+
for (let a = 0; a < this._motions.length; ++a)
|
|
1454
|
+
r = this._motions[a], r?.setFadeOut(r._motion.getFadeOutTime());
|
|
1455
|
+
return r = new Je(), r._autoDelete = e, r._motion = t, this._motions.push(r), r._motionQueueEntryHandle;
|
|
1456
|
+
}
|
|
1457
|
+
isFinished() {
|
|
1458
|
+
let t = 0;
|
|
1459
|
+
for (; t < this._motions.length; ) {
|
|
1460
|
+
const e = this._motions[t];
|
|
1461
|
+
if (e == null) {
|
|
1462
|
+
this._motions.splice(t, 1);
|
|
1463
|
+
continue;
|
|
1464
|
+
}
|
|
1465
|
+
if (e._motion == null) {
|
|
1466
|
+
e.release(), this._motions.splice(t, 1);
|
|
1467
|
+
continue;
|
|
1468
|
+
}
|
|
1469
|
+
if (!e.isFinished())
|
|
1470
|
+
return !1;
|
|
1471
|
+
t++;
|
|
1472
|
+
}
|
|
1473
|
+
return !0;
|
|
1474
|
+
}
|
|
1475
|
+
isFinishedByHandle(t) {
|
|
1476
|
+
for (let e = 0; e < this._motions.length; e++) {
|
|
1477
|
+
const i = this._motions[e];
|
|
1478
|
+
if (i != null && i._motionQueueEntryHandle == t && !i.isFinished())
|
|
1479
|
+
return !1;
|
|
1480
|
+
}
|
|
1481
|
+
return !0;
|
|
1482
|
+
}
|
|
1483
|
+
stopAllMotions() {
|
|
1484
|
+
for (let t = 0; t < this._motions.length; t++) {
|
|
1485
|
+
const e = this._motions[t];
|
|
1486
|
+
e?.release();
|
|
1487
|
+
}
|
|
1488
|
+
this._motions = [];
|
|
1489
|
+
}
|
|
1490
|
+
getCubismMotionQueueEntry(t) {
|
|
1491
|
+
return this._motions.find((e) => e != null && e._motionQueueEntryHandle == t);
|
|
1492
|
+
}
|
|
1493
|
+
setEventCallback(t, e = null) {
|
|
1494
|
+
this._eventCallBack = t, this._eventCustomData = e;
|
|
1495
|
+
}
|
|
1496
|
+
doUpdateMotion(t, e) {
|
|
1497
|
+
let i = !1, r = 0;
|
|
1498
|
+
for (; r < this._motions.length; ) {
|
|
1499
|
+
const a = this._motions[r];
|
|
1500
|
+
if (a == null) {
|
|
1501
|
+
this._motions.splice(r, 1);
|
|
1502
|
+
continue;
|
|
1503
|
+
}
|
|
1504
|
+
const n = a._motion;
|
|
1505
|
+
if (n == null) {
|
|
1506
|
+
a.release(), this._motions.splice(r, 1);
|
|
1507
|
+
continue;
|
|
1508
|
+
}
|
|
1509
|
+
n.updateParameters(t, a, e), i = !0;
|
|
1510
|
+
const o = n.getFiredEvent(a.getLastCheckEventSeconds() - a.getStartTime(), e - a.getStartTime());
|
|
1511
|
+
for (let l = 0; l < o.length; ++l)
|
|
1512
|
+
this._eventCallBack(this, o[l], this._eventCustomData);
|
|
1513
|
+
a.setLastCheckEventSeconds(e), a.isFinished() ? (a.release(), this._motions.splice(r, 1)) : (a.isTriggeredFadeOut() && a.startFadeOut(a.getFadeOutSeconds(), e), r++);
|
|
1514
|
+
}
|
|
1515
|
+
return i;
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
const Ze = -1;
|
|
1519
|
+
class os extends Ut {
|
|
1520
|
+
constructor() {
|
|
1521
|
+
super(), this._currentPriority = 0, this._reservePriority = 0;
|
|
1522
|
+
}
|
|
1523
|
+
getCurrentPriority() {
|
|
1524
|
+
return this._currentPriority;
|
|
1525
|
+
}
|
|
1526
|
+
getReservePriority() {
|
|
1527
|
+
return this._reservePriority;
|
|
1528
|
+
}
|
|
1529
|
+
setReservePriority(t) {
|
|
1530
|
+
this._reservePriority = t;
|
|
1531
|
+
}
|
|
1532
|
+
startMotionPriority(t, e, i) {
|
|
1533
|
+
return i == this._reservePriority && (this._reservePriority = 0), this._currentPriority = i, super.startMotion(t, e, this._userTimeSeconds);
|
|
1534
|
+
}
|
|
1535
|
+
updateMotion(t, e) {
|
|
1536
|
+
this._userTimeSeconds += e;
|
|
1537
|
+
const i = super.doUpdateMotion(t, this._userTimeSeconds);
|
|
1538
|
+
return this.isFinished() && (this._currentPriority = 0), i;
|
|
1539
|
+
}
|
|
1540
|
+
reserveMotion(t) {
|
|
1541
|
+
return t <= this._reservePriority || t <= this._currentPriority ? !1 : (this._reservePriority = t, !0);
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
var bt = /* @__PURE__ */ ((s) => (s[s.CubismPhysicsTargetType_Parameter = 0] = "CubismPhysicsTargetType_Parameter", s))(bt || {}), J = /* @__PURE__ */ ((s) => (s[s.CubismPhysicsSource_X = 0] = "CubismPhysicsSource_X", s[s.CubismPhysicsSource_Y = 1] = "CubismPhysicsSource_Y", s[s.CubismPhysicsSource_Angle = 2] = "CubismPhysicsSource_Angle", s))(J || {});
|
|
1545
|
+
class ls {
|
|
1546
|
+
constructor() {
|
|
1547
|
+
this.gravity = new y(0, 0), this.wind = new y(0, 0);
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
class Ke {
|
|
1551
|
+
constructor() {
|
|
1552
|
+
this.initialPosition = new y(0, 0), this.position = new y(0, 0), this.lastPosition = new y(0, 0), this.lastGravity = new y(0, 0), this.force = new y(0, 0), this.velocity = new y(0, 0);
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
class Qe {
|
|
1556
|
+
constructor() {
|
|
1557
|
+
this.normalizationPosition = {}, this.normalizationAngle = {};
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
class ti {
|
|
1561
|
+
constructor() {
|
|
1562
|
+
this.source = {};
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
class ei {
|
|
1566
|
+
constructor() {
|
|
1567
|
+
this.destination = {}, this.translationScale = new y(0, 0);
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
class ii {
|
|
1571
|
+
constructor() {
|
|
1572
|
+
this.settings = [], this.inputs = [], this.outputs = [], this.particles = [], this.gravity = new y(0, 0), this.wind = new y(0, 0);
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
class si {
|
|
1576
|
+
constructor(t) {
|
|
1577
|
+
this._json = t;
|
|
1578
|
+
}
|
|
1579
|
+
release() {
|
|
1580
|
+
this._json = void 0;
|
|
1581
|
+
}
|
|
1582
|
+
getGravity() {
|
|
1583
|
+
const t = new y(0, 0);
|
|
1584
|
+
return t.x = this._json.Meta.EffectiveForces.Gravity.X, t.y = this._json.Meta.EffectiveForces.Gravity.Y, t;
|
|
1585
|
+
}
|
|
1586
|
+
getWind() {
|
|
1587
|
+
const t = new y(0, 0);
|
|
1588
|
+
return t.x = this._json.Meta.EffectiveForces.Wind.X, t.y = this._json.Meta.EffectiveForces.Wind.Y, t;
|
|
1589
|
+
}
|
|
1590
|
+
getSubRigCount() {
|
|
1591
|
+
return this._json.Meta.PhysicsSettingCount;
|
|
1592
|
+
}
|
|
1593
|
+
getTotalInputCount() {
|
|
1594
|
+
return this._json.Meta.TotalInputCount;
|
|
1595
|
+
}
|
|
1596
|
+
getTotalOutputCount() {
|
|
1597
|
+
return this._json.Meta.TotalOutputCount;
|
|
1598
|
+
}
|
|
1599
|
+
getVertexCount() {
|
|
1600
|
+
return this._json.Meta.VertexCount;
|
|
1601
|
+
}
|
|
1602
|
+
getNormalizationPositionMinimumValue(t) {
|
|
1603
|
+
return this._json.PhysicsSettings[t].Normalization.Position.Minimum;
|
|
1604
|
+
}
|
|
1605
|
+
getNormalizationPositionMaximumValue(t) {
|
|
1606
|
+
return this._json.PhysicsSettings[t].Normalization.Position.Maximum;
|
|
1607
|
+
}
|
|
1608
|
+
getNormalizationPositionDefaultValue(t) {
|
|
1609
|
+
return this._json.PhysicsSettings[t].Normalization.Position.Default;
|
|
1610
|
+
}
|
|
1611
|
+
getNormalizationAngleMinimumValue(t) {
|
|
1612
|
+
return this._json.PhysicsSettings[t].Normalization.Angle.Minimum;
|
|
1613
|
+
}
|
|
1614
|
+
getNormalizationAngleMaximumValue(t) {
|
|
1615
|
+
return this._json.PhysicsSettings[t].Normalization.Angle.Maximum;
|
|
1616
|
+
}
|
|
1617
|
+
getNormalizationAngleDefaultValue(t) {
|
|
1618
|
+
return this._json.PhysicsSettings[t].Normalization.Angle.Default;
|
|
1619
|
+
}
|
|
1620
|
+
getInputCount(t) {
|
|
1621
|
+
return this._json.PhysicsSettings[t].Input.length;
|
|
1622
|
+
}
|
|
1623
|
+
getInputWeight(t, e) {
|
|
1624
|
+
return this._json.PhysicsSettings[t].Input[e].Weight;
|
|
1625
|
+
}
|
|
1626
|
+
getInputReflect(t, e) {
|
|
1627
|
+
return this._json.PhysicsSettings[t].Input[e].Reflect;
|
|
1628
|
+
}
|
|
1629
|
+
getInputType(t, e) {
|
|
1630
|
+
return this._json.PhysicsSettings[t].Input[e].Type;
|
|
1631
|
+
}
|
|
1632
|
+
getInputSourceId(t, e) {
|
|
1633
|
+
return this._json.PhysicsSettings[t].Input[e].Source.Id;
|
|
1634
|
+
}
|
|
1635
|
+
getOutputCount(t) {
|
|
1636
|
+
return this._json.PhysicsSettings[t].Output.length;
|
|
1637
|
+
}
|
|
1638
|
+
getOutputVertexIndex(t, e) {
|
|
1639
|
+
return this._json.PhysicsSettings[t].Output[e].VertexIndex;
|
|
1640
|
+
}
|
|
1641
|
+
getOutputAngleScale(t, e) {
|
|
1642
|
+
return this._json.PhysicsSettings[t].Output[e].Scale;
|
|
1643
|
+
}
|
|
1644
|
+
getOutputWeight(t, e) {
|
|
1645
|
+
return this._json.PhysicsSettings[t].Output[e].Weight;
|
|
1646
|
+
}
|
|
1647
|
+
getOutputDestinationId(t, e) {
|
|
1648
|
+
return this._json.PhysicsSettings[t].Output[e].Destination.Id;
|
|
1649
|
+
}
|
|
1650
|
+
getOutputType(t, e) {
|
|
1651
|
+
return this._json.PhysicsSettings[t].Output[e].Type;
|
|
1652
|
+
}
|
|
1653
|
+
getOutputReflect(t, e) {
|
|
1654
|
+
return this._json.PhysicsSettings[t].Output[e].Reflect;
|
|
1655
|
+
}
|
|
1656
|
+
getParticleCount(t) {
|
|
1657
|
+
return this._json.PhysicsSettings[t].Vertices.length;
|
|
1658
|
+
}
|
|
1659
|
+
getParticleMobility(t, e) {
|
|
1660
|
+
return this._json.PhysicsSettings[t].Vertices[e].Mobility;
|
|
1661
|
+
}
|
|
1662
|
+
getParticleDelay(t, e) {
|
|
1663
|
+
return this._json.PhysicsSettings[t].Vertices[e].Delay;
|
|
1664
|
+
}
|
|
1665
|
+
getParticleAcceleration(t, e) {
|
|
1666
|
+
return this._json.PhysicsSettings[t].Vertices[e].Acceleration;
|
|
1667
|
+
}
|
|
1668
|
+
getParticleRadius(t, e) {
|
|
1669
|
+
return this._json.PhysicsSettings[t].Vertices[e].Radius;
|
|
1670
|
+
}
|
|
1671
|
+
getParticlePosition(t, e) {
|
|
1672
|
+
const i = new y(0, 0);
|
|
1673
|
+
return i.x = this._json.PhysicsSettings[t].Vertices[e].Position.X, i.y = this._json.PhysicsSettings[t].Vertices[e].Position.Y, i;
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
const Jt = "X", Zt = "Y", Kt = "Angle", ri = 5, ge = 100, ai = 1e-3;
|
|
1677
|
+
class Vt {
|
|
1678
|
+
static create(t) {
|
|
1679
|
+
const e = new Vt();
|
|
1680
|
+
return e.parse(t), e._physicsRig.gravity.y = 0, e;
|
|
1681
|
+
}
|
|
1682
|
+
evaluate(t, e) {
|
|
1683
|
+
let i, r, a, n;
|
|
1684
|
+
const o = new y();
|
|
1685
|
+
let l, h, u, c, d, _, p, x;
|
|
1686
|
+
d = t.getModel().parameters.values, _ = t.getModel().parameters.maximumValues, p = t.getModel().parameters.minimumValues, x = t.getModel().parameters.defaultValues;
|
|
1687
|
+
for (let g = 0; g < this._physicsRig.subRigCount; ++g) {
|
|
1688
|
+
i = { angle: 0 }, o.x = 0, o.y = 0, l = this._physicsRig.settings[g], h = this._physicsRig.inputs.slice(l.baseInputIndex), u = this._physicsRig.outputs.slice(l.baseOutputIndex), c = this._physicsRig.particles.slice(l.baseParticleIndex);
|
|
1689
|
+
for (let m = 0; m < l.inputCount; ++m)
|
|
1690
|
+
r = h[m].weight / ge, h[m].sourceParameterIndex == -1 && (h[m].sourceParameterIndex = t.getParameterIndex(h[m].source.id)), h[m].getNormalizedParameterValue(o, i, d[h[m].sourceParameterIndex], p[h[m].sourceParameterIndex], _[h[m].sourceParameterIndex], x[h[m].sourceParameterIndex], l.normalizationPosition, l.normalizationAngle, h[m].reflect, r);
|
|
1691
|
+
a = S.degreesToRadian(-i.angle), o.x = o.x * S.cos(a) - o.y * S.sin(a), o.y = o.x * S.sin(a) + o.y * S.cos(a), yi(c, l.particleCount, o, i.angle, this._options.wind, ai * l.normalizationPosition.maximum, e, ri);
|
|
1692
|
+
for (let m = 0; m < l.outputCount; ++m) {
|
|
1693
|
+
const f = u[m].vertexIndex;
|
|
1694
|
+
if (f < 1 || f >= l.particleCount)
|
|
1695
|
+
break;
|
|
1696
|
+
u[m].destinationParameterIndex == -1 && (u[m].destinationParameterIndex = t.getParameterIndex(u[m].destination.id));
|
|
1697
|
+
const v = new y();
|
|
1698
|
+
v.x = c[f].position.x - c[f - 1].position.x, v.y = c[f].position.y - c[f - 1].position.y, n = u[m].getValue(v, c, f, u[m].reflect, this._options.gravity);
|
|
1699
|
+
const P = u[m].destinationParameterIndex, I = !Float32Array.prototype.slice && "subarray" in Float32Array.prototype ? JSON.parse(JSON.stringify(d.subarray(P))) : d.slice(P);
|
|
1700
|
+
vi(I, p[P], _[P], n, u[m]);
|
|
1701
|
+
for (let M = P, V = 0; M < d.length; M++, V++)
|
|
1702
|
+
d[M] = I[V];
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
setOptions(t) {
|
|
1707
|
+
this._options = t;
|
|
1708
|
+
}
|
|
1709
|
+
getOption() {
|
|
1710
|
+
return this._options;
|
|
1711
|
+
}
|
|
1712
|
+
constructor() {
|
|
1713
|
+
this._options = new ni(), this._options.gravity.y = -1, this._options.gravity.x = 0, this._options.wind.x = 0, this._options.wind.y = 0;
|
|
1714
|
+
}
|
|
1715
|
+
release() {
|
|
1716
|
+
this._physicsRig = void 0;
|
|
1717
|
+
}
|
|
1718
|
+
parse(t) {
|
|
1719
|
+
this._physicsRig = new ii();
|
|
1720
|
+
let e = new si(t);
|
|
1721
|
+
this._physicsRig.gravity = e.getGravity(), this._physicsRig.wind = e.getWind(), this._physicsRig.subRigCount = e.getSubRigCount();
|
|
1722
|
+
let i = 0, r = 0, a = 0;
|
|
1723
|
+
for (let n = 0; n < this._physicsRig.subRigCount; ++n) {
|
|
1724
|
+
const o = new Qe();
|
|
1725
|
+
o.normalizationPosition.minimum = e.getNormalizationPositionMinimumValue(n), o.normalizationPosition.maximum = e.getNormalizationPositionMaximumValue(n), o.normalizationPosition.defalut = e.getNormalizationPositionDefaultValue(n), o.normalizationAngle.minimum = e.getNormalizationAngleMinimumValue(n), o.normalizationAngle.maximum = e.getNormalizationAngleMaximumValue(n), o.normalizationAngle.defalut = e.getNormalizationAngleDefaultValue(n), o.inputCount = e.getInputCount(n), o.baseInputIndex = i, i += o.inputCount;
|
|
1726
|
+
for (let l = 0; l < o.inputCount; ++l) {
|
|
1727
|
+
const h = new ti();
|
|
1728
|
+
switch (h.sourceParameterIndex = -1, h.weight = e.getInputWeight(n, l), h.reflect = e.getInputReflect(n, l), e.getInputType(n, l)) {
|
|
1729
|
+
case Jt:
|
|
1730
|
+
h.type = J.CubismPhysicsSource_X, h.getNormalizedParameterValue = oi;
|
|
1731
|
+
break;
|
|
1732
|
+
case Zt:
|
|
1733
|
+
h.type = J.CubismPhysicsSource_Y, h.getNormalizedParameterValue = li;
|
|
1734
|
+
break;
|
|
1735
|
+
case Kt:
|
|
1736
|
+
h.type = J.CubismPhysicsSource_Angle, h.getNormalizedParameterValue = hi;
|
|
1737
|
+
break;
|
|
1738
|
+
}
|
|
1739
|
+
h.source.targetType = bt.CubismPhysicsTargetType_Parameter, h.source.id = e.getInputSourceId(n, l), this._physicsRig.inputs.push(h);
|
|
1740
|
+
}
|
|
1741
|
+
o.outputCount = e.getOutputCount(n), o.baseOutputIndex = r, r += o.outputCount;
|
|
1742
|
+
for (let l = 0; l < o.outputCount; ++l) {
|
|
1743
|
+
const h = new ei();
|
|
1744
|
+
switch (h.destinationParameterIndex = -1, h.vertexIndex = e.getOutputVertexIndex(n, l), h.angleScale = e.getOutputAngleScale(n, l), h.weight = e.getOutputWeight(n, l), h.destination.targetType = bt.CubismPhysicsTargetType_Parameter, h.destination.id = e.getOutputDestinationId(n, l), e.getOutputType(n, l)) {
|
|
1745
|
+
case Jt:
|
|
1746
|
+
h.type = J.CubismPhysicsSource_X, h.getValue = ui, h.getScale = pi;
|
|
1747
|
+
break;
|
|
1748
|
+
case Zt:
|
|
1749
|
+
h.type = J.CubismPhysicsSource_Y, h.getValue = di, h.getScale = _i;
|
|
1750
|
+
break;
|
|
1751
|
+
case Kt:
|
|
1752
|
+
h.type = J.CubismPhysicsSource_Angle, h.getValue = ci, h.getScale = fi;
|
|
1753
|
+
break;
|
|
1754
|
+
}
|
|
1755
|
+
h.reflect = e.getOutputReflect(n, l), this._physicsRig.outputs.push(h);
|
|
1756
|
+
}
|
|
1757
|
+
o.particleCount = e.getParticleCount(n), o.baseParticleIndex = a, a += o.particleCount;
|
|
1758
|
+
for (let l = 0; l < o.particleCount; ++l) {
|
|
1759
|
+
const h = new Ke();
|
|
1760
|
+
h.mobility = e.getParticleMobility(n, l), h.delay = e.getParticleDelay(n, l), h.acceleration = e.getParticleAcceleration(n, l), h.radius = e.getParticleRadius(n, l), h.position = e.getParticlePosition(n, l), this._physicsRig.particles.push(h);
|
|
1761
|
+
}
|
|
1762
|
+
this._physicsRig.settings.push(o);
|
|
1763
|
+
}
|
|
1764
|
+
this.initialize(), e.release();
|
|
1765
|
+
}
|
|
1766
|
+
initialize() {
|
|
1767
|
+
let t, e, i;
|
|
1768
|
+
for (let r = 0; r < this._physicsRig.subRigCount; ++r) {
|
|
1769
|
+
e = this._physicsRig.settings[r], t = this._physicsRig.particles.slice(e.baseParticleIndex), t[0].initialPosition = new y(0, 0), t[0].lastPosition = new y(t[0].initialPosition.x, t[0].initialPosition.y), t[0].lastGravity = new y(0, -1), t[0].lastGravity.y *= -1, t[0].velocity = new y(0, 0), t[0].force = new y(0, 0);
|
|
1770
|
+
for (let a = 1; a < e.particleCount; ++a)
|
|
1771
|
+
i = new y(0, 0), i.y = t[a].radius, t[a].initialPosition = new y(t[a - 1].initialPosition.x + i.x, t[a - 1].initialPosition.y + i.y), t[a].position = new y(t[a].initialPosition.x, t[a].initialPosition.y), t[a].lastPosition = new y(t[a].initialPosition.x, t[a].initialPosition.y), t[a].lastGravity = new y(0, -1), t[a].lastGravity.y *= -1, t[a].velocity = new y(0, 0), t[a].force = new y(0, 0);
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
class ni {
|
|
1776
|
+
constructor() {
|
|
1777
|
+
this.gravity = new y(0, 0), this.wind = new y(0, 0);
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
function oi(s, t, e, i, r, a, n, o, l, h) {
|
|
1781
|
+
s.x += Nt(e, i, r, a, n.minimum, n.maximum, n.defalut, l) * h;
|
|
1782
|
+
}
|
|
1783
|
+
function li(s, t, e, i, r, a, n, o, l, h) {
|
|
1784
|
+
s.y += Nt(e, i, r, a, n.minimum, n.maximum, n.defalut, l) * h;
|
|
1785
|
+
}
|
|
1786
|
+
function hi(s, t, e, i, r, a, n, o, l, h) {
|
|
1787
|
+
t.angle += Nt(e, i, r, a, o.minimum, o.maximum, o.defalut, l) * h;
|
|
1788
|
+
}
|
|
1789
|
+
function ui(s, t, e, i, r) {
|
|
1790
|
+
let a = s.x;
|
|
1791
|
+
return i && (a *= -1), a;
|
|
1792
|
+
}
|
|
1793
|
+
function di(s, t, e, i, r) {
|
|
1794
|
+
let a = s.y;
|
|
1795
|
+
return i && (a *= -1), a;
|
|
1796
|
+
}
|
|
1797
|
+
function ci(s, t, e, i, r) {
|
|
1798
|
+
let a;
|
|
1799
|
+
return e >= 2 ? r = t[e - 1].position.substract(t[e - 2].position) : r = r.multiplyByScaler(-1), a = S.directionToRadian(r, s), i && (a *= -1), a;
|
|
1800
|
+
}
|
|
1801
|
+
function mi(s, t) {
|
|
1802
|
+
return Math.abs(Math.max(s, t) - Math.min(s, t));
|
|
1803
|
+
}
|
|
1804
|
+
function gi(s, t) {
|
|
1805
|
+
return Math.min(s, t) + mi(s, t) / 2;
|
|
1806
|
+
}
|
|
1807
|
+
function pi(s, t) {
|
|
1808
|
+
return s.x;
|
|
1809
|
+
}
|
|
1810
|
+
function _i(s, t) {
|
|
1811
|
+
return s.y;
|
|
1812
|
+
}
|
|
1813
|
+
function fi(s, t) {
|
|
1814
|
+
return t;
|
|
1815
|
+
}
|
|
1816
|
+
function yi(s, t, e, i, r, a, n, o) {
|
|
1817
|
+
let l, h, u, c, d = new y(0, 0), _ = new y(0, 0), p = new y(0, 0), x = new y(0, 0);
|
|
1818
|
+
s[0].position = new y(e.x, e.y), l = S.degreesToRadian(i), c = S.radianToDirection(l), c.normalize();
|
|
1819
|
+
for (let g = 1; g < t; ++g)
|
|
1820
|
+
s[g].force = c.multiplyByScaler(s[g].acceleration).add(r), s[g].lastPosition = new y(s[g].position.x, s[g].position.y), h = s[g].delay * n * 30, d = s[g].position.substract(s[g - 1].position), u = S.directionToRadian(s[g].lastGravity, c) / o, d.x = S.cos(u) * d.x - d.y * S.sin(u), d.y = S.sin(u) * d.x + d.y * S.cos(u), s[g].position = s[g - 1].position.add(d), _ = s[g].velocity.multiplyByScaler(h), p = s[g].force.multiplyByScaler(h).multiplyByScaler(h), s[g].position = s[g].position.add(_).add(p), x = s[g].position.substract(s[g - 1].position), x.normalize(), s[g].position = s[g - 1].position.add(x.multiplyByScaler(s[g].radius)), S.abs(s[g].position.x) < a && (s[g].position.x = 0), h != 0 && (s[g].velocity = s[g].position.substract(s[g].lastPosition), s[g].velocity = s[g].velocity.divisionByScalar(h), s[g].velocity = s[g].velocity.multiplyByScaler(s[g].mobility)), s[g].force = new y(0, 0), s[g].lastGravity = new y(c.x, c.y);
|
|
1821
|
+
}
|
|
1822
|
+
function vi(s, t, e, i, r) {
|
|
1823
|
+
let a, n, o;
|
|
1824
|
+
a = r.getScale(r.translationScale, r.angleScale), n = i * a, n < t ? (n < r.valueBelowMinimum && (r.valueBelowMinimum = n), n = t) : n > e && (n > r.valueExceededMaximum && (r.valueExceededMaximum = n), n = e), o = r.weight / ge, o >= 1 || (n = s[0] * (1 - o) + n * o), s[0] = n;
|
|
1825
|
+
}
|
|
1826
|
+
function Nt(s, t, e, i, r, a, n, o) {
|
|
1827
|
+
let l = 0;
|
|
1828
|
+
const h = S.max(e, t);
|
|
1829
|
+
h < s && (s = h);
|
|
1830
|
+
const u = S.min(e, t);
|
|
1831
|
+
u > s && (s = u);
|
|
1832
|
+
const c = S.min(r, a), d = S.max(r, a), _ = n, p = gi(u, h), x = s - p;
|
|
1833
|
+
switch (Math.sign(x)) {
|
|
1834
|
+
case 1: {
|
|
1835
|
+
const g = d - _, m = h - p;
|
|
1836
|
+
m != 0 && (l = x * (g / m), l += _);
|
|
1837
|
+
break;
|
|
1838
|
+
}
|
|
1839
|
+
case -1: {
|
|
1840
|
+
const g = c - _, m = u - p;
|
|
1841
|
+
m != 0 && (l = x * (g / m), l += _);
|
|
1842
|
+
break;
|
|
1843
|
+
}
|
|
1844
|
+
case 0: {
|
|
1845
|
+
l = _;
|
|
1846
|
+
break;
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
return o ? l : l * -1;
|
|
1850
|
+
}
|
|
1851
|
+
class wt {
|
|
1852
|
+
constructor(t = 0, e = 0, i = 0, r = 0) {
|
|
1853
|
+
this.x = t, this.y = e, this.width = i, this.height = r;
|
|
1854
|
+
}
|
|
1855
|
+
getCenterX() {
|
|
1856
|
+
return this.x + 0.5 * this.width;
|
|
1857
|
+
}
|
|
1858
|
+
getCenterY() {
|
|
1859
|
+
return this.y + 0.5 * this.height;
|
|
1860
|
+
}
|
|
1861
|
+
getRight() {
|
|
1862
|
+
return this.x + this.width;
|
|
1863
|
+
}
|
|
1864
|
+
getBottom() {
|
|
1865
|
+
return this.y + this.height;
|
|
1866
|
+
}
|
|
1867
|
+
setRect(t) {
|
|
1868
|
+
this.x = t.x, this.y = t.y, this.width = t.width, this.height = t.height;
|
|
1869
|
+
}
|
|
1870
|
+
expand(t, e) {
|
|
1871
|
+
this.x -= t, this.y -= e, this.width += t * 2, this.height += e * 2;
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
const Mt = 4, xi = 10;
|
|
1875
|
+
let W, ot, It;
|
|
1876
|
+
class Ct {
|
|
1877
|
+
getChannelFlagAsColor(t) {
|
|
1878
|
+
return this._channelColors[t];
|
|
1879
|
+
}
|
|
1880
|
+
getMaskRenderTexture() {
|
|
1881
|
+
let t = 0;
|
|
1882
|
+
if (this._maskTexture && this._maskTexture.texture != 0 && (this._maskTexture.frameNo = this._currentFrameNo, t = this._maskTexture.texture), t == 0) {
|
|
1883
|
+
const e = this._clippingMaskBufferSize;
|
|
1884
|
+
this._colorBuffer = this.gl.createTexture(), this.gl.bindTexture(this.gl.TEXTURE_2D, this._colorBuffer), this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, e, e, 0, this.gl.RGBA, this.gl.UNSIGNED_BYTE, null), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR), this.gl.bindTexture(this.gl.TEXTURE_2D, null), t = this.gl.createFramebuffer(), this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, t), this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER, this.gl.COLOR_ATTACHMENT0, this.gl.TEXTURE_2D, this._colorBuffer, 0), this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, It), this._maskTexture = new Pi(this._currentFrameNo, t);
|
|
1885
|
+
}
|
|
1886
|
+
return t;
|
|
1887
|
+
}
|
|
1888
|
+
setGL(t) {
|
|
1889
|
+
this.gl = t;
|
|
1890
|
+
}
|
|
1891
|
+
calcClippedDrawTotalBounds(t, e) {
|
|
1892
|
+
let i = Number.MAX_VALUE, r = Number.MAX_VALUE, a = Number.MIN_VALUE, n = Number.MIN_VALUE;
|
|
1893
|
+
const o = e._clippedDrawableIndexList.length;
|
|
1894
|
+
for (let l = 0; l < o; l++) {
|
|
1895
|
+
const h = e._clippedDrawableIndexList[l], u = t.getDrawableVertexCount(h), c = t.getDrawableVertices(h);
|
|
1896
|
+
let d = Number.MAX_VALUE, _ = Number.MAX_VALUE, p = Number.MIN_VALUE, x = Number.MIN_VALUE;
|
|
1897
|
+
const g = u * xt.vertexStep;
|
|
1898
|
+
for (let m = xt.vertexOffset; m < g; m += xt.vertexStep) {
|
|
1899
|
+
const f = c[m], v = c[m + 1];
|
|
1900
|
+
f < d && (d = f), f > p && (p = f), v < _ && (_ = v), v > x && (x = v);
|
|
1901
|
+
}
|
|
1902
|
+
if (d != Number.MAX_VALUE)
|
|
1903
|
+
if (d < i && (i = d), _ < r && (r = _), p > a && (a = p), x > n && (n = x), i == Number.MAX_VALUE)
|
|
1904
|
+
e._allClippedDrawRect.x = 0, e._allClippedDrawRect.y = 0, e._allClippedDrawRect.width = 0, e._allClippedDrawRect.height = 0, e._isUsing = !1;
|
|
1905
|
+
else {
|
|
1906
|
+
e._isUsing = !0;
|
|
1907
|
+
const m = a - i, f = n - r;
|
|
1908
|
+
e._allClippedDrawRect.x = i, e._allClippedDrawRect.y = r, e._allClippedDrawRect.width = m, e._allClippedDrawRect.height = f;
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
constructor() {
|
|
1913
|
+
this._maskRenderTexture = null, this._colorBuffer = null, this._currentFrameNo = 0, this._clippingMaskBufferSize = 256, this._clippingContextListForMask = [], this._clippingContextListForDraw = [], this._channelColors = [], this._tmpBoundsOnModel = new wt(), this._tmpMatrix = new R(), this._tmpMatrixForMask = new R(), this._tmpMatrixForDraw = new R();
|
|
1914
|
+
let t = new at();
|
|
1915
|
+
t.R = 1, t.G = 0, t.B = 0, t.A = 0, this._channelColors.push(t), t = new at(), t.R = 0, t.G = 1, t.B = 0, t.A = 0, this._channelColors.push(t), t = new at(), t.R = 0, t.G = 0, t.B = 1, t.A = 0, this._channelColors.push(t), t = new at(), t.R = 0, t.G = 0, t.B = 0, t.A = 1, this._channelColors.push(t);
|
|
1916
|
+
}
|
|
1917
|
+
release() {
|
|
1918
|
+
var t, e, i;
|
|
1919
|
+
const r = this;
|
|
1920
|
+
for (let a = 0; a < this._clippingContextListForMask.length; a++)
|
|
1921
|
+
this._clippingContextListForMask[a] && ((t = this._clippingContextListForMask[a]) == null || t.release());
|
|
1922
|
+
r._clippingContextListForMask = void 0, r._clippingContextListForDraw = void 0, this._maskTexture && ((e = this.gl) == null || e.deleteFramebuffer(this._maskTexture.texture), r._maskTexture = void 0), r._channelColors = void 0, (i = this.gl) == null || i.deleteTexture(this._colorBuffer), this._colorBuffer = null;
|
|
1923
|
+
}
|
|
1924
|
+
initialize(t, e, i, r) {
|
|
1925
|
+
for (let a = 0; a < e; a++) {
|
|
1926
|
+
if (r[a] <= 0) {
|
|
1927
|
+
this._clippingContextListForDraw.push(null);
|
|
1928
|
+
continue;
|
|
1929
|
+
}
|
|
1930
|
+
let n = this.findSameClip(i[a], r[a]);
|
|
1931
|
+
n == null && (n = new Mi(this, i[a], r[a]), this._clippingContextListForMask.push(n)), n.addClippedDrawable(a), this._clippingContextListForDraw.push(n);
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
setupClippingContext(t, e) {
|
|
1935
|
+
this._currentFrameNo++;
|
|
1936
|
+
let i = 0;
|
|
1937
|
+
for (let r = 0; r < this._clippingContextListForMask.length; r++) {
|
|
1938
|
+
const a = this._clippingContextListForMask[r];
|
|
1939
|
+
this.calcClippedDrawTotalBounds(t, a), a._isUsing && i++;
|
|
1940
|
+
}
|
|
1941
|
+
if (i > 0) {
|
|
1942
|
+
this.gl.viewport(0, 0, this._clippingMaskBufferSize, this._clippingMaskBufferSize), this._maskRenderTexture = this.getMaskRenderTexture(), e.getMvpMatrix(), e.preDraw(), this.setupLayoutBounds(i), this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, this._maskRenderTexture), this.gl.clearColor(1, 1, 1, 1), this.gl.clear(this.gl.COLOR_BUFFER_BIT);
|
|
1943
|
+
for (let r = 0; r < this._clippingContextListForMask.length; r++) {
|
|
1944
|
+
const a = this._clippingContextListForMask[r], n = a._allClippedDrawRect, o = a._layoutBounds, l = 0.05;
|
|
1945
|
+
this._tmpBoundsOnModel.setRect(n), this._tmpBoundsOnModel.expand(n.width * l, n.height * l);
|
|
1946
|
+
const h = o.width / this._tmpBoundsOnModel.width, u = o.height / this._tmpBoundsOnModel.height;
|
|
1947
|
+
this._tmpMatrix.loadIdentity(), this._tmpMatrix.translateRelative(-1, -1), this._tmpMatrix.scaleRelative(2, 2), this._tmpMatrix.translateRelative(o.x, o.y), this._tmpMatrix.scaleRelative(h, u), this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x, -this._tmpBoundsOnModel.y), this._tmpMatrixForMask.setMatrix(this._tmpMatrix.getArray()), this._tmpMatrix.loadIdentity(), this._tmpMatrix.translateRelative(o.x, o.y), this._tmpMatrix.scaleRelative(h, u), this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x, -this._tmpBoundsOnModel.y), this._tmpMatrixForDraw.setMatrix(this._tmpMatrix.getArray()), a._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray()), a._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray());
|
|
1948
|
+
const c = a._clippingIdCount;
|
|
1949
|
+
for (let d = 0; d < c; d++) {
|
|
1950
|
+
const _ = a._clippingIdList[d];
|
|
1951
|
+
t.getDrawableDynamicFlagVertexPositionsDidChange(_) && (e.setIsCulling(t.getDrawableCulling(_) != !1), e.setClippingContextBufferForMask(a), e.drawMesh(t.getDrawableTextureIndices(_), t.getDrawableVertexIndexCount(_), t.getDrawableVertexCount(_), t.getDrawableVertexIndices(_), t.getDrawableVertices(_), t.getDrawableVertexUvs(_), t.getDrawableOpacity(_), z.CubismBlendMode_Normal, !1));
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, It), e.setClippingContextBufferForMask(null), this.gl.viewport(ot[0], ot[1], ot[2], ot[3]);
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
findSameClip(t, e) {
|
|
1958
|
+
for (let i = 0; i < this._clippingContextListForMask.length; i++) {
|
|
1959
|
+
const r = this._clippingContextListForMask[i], a = r._clippingIdCount;
|
|
1960
|
+
if (a != e)
|
|
1961
|
+
continue;
|
|
1962
|
+
let n = 0;
|
|
1963
|
+
for (let o = 0; o < a; o++) {
|
|
1964
|
+
const l = r._clippingIdList[o];
|
|
1965
|
+
for (let h = 0; h < a; h++)
|
|
1966
|
+
if (t[h] == l) {
|
|
1967
|
+
n++;
|
|
1968
|
+
break;
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
if (n == a)
|
|
1972
|
+
return r;
|
|
1973
|
+
}
|
|
1974
|
+
return null;
|
|
1975
|
+
}
|
|
1976
|
+
setupLayoutBounds(t) {
|
|
1977
|
+
let e = t / Mt, i = t % Mt;
|
|
1978
|
+
e = ~~e, i = ~~i;
|
|
1979
|
+
let r = 0;
|
|
1980
|
+
for (let a = 0; a < Mt; a++) {
|
|
1981
|
+
const n = e + (a < i ? 1 : 0);
|
|
1982
|
+
if (n != 0)
|
|
1983
|
+
if (n == 1) {
|
|
1984
|
+
const o = this._clippingContextListForMask[r++];
|
|
1985
|
+
o._layoutChannelNo = a, o._layoutBounds.x = 0, o._layoutBounds.y = 0, o._layoutBounds.width = 1, o._layoutBounds.height = 1;
|
|
1986
|
+
} else if (n == 2)
|
|
1987
|
+
for (let o = 0; o < n; o++) {
|
|
1988
|
+
let l = o % 2;
|
|
1989
|
+
l = ~~l;
|
|
1990
|
+
const h = this._clippingContextListForMask[r++];
|
|
1991
|
+
h._layoutChannelNo = a, h._layoutBounds.x = l * 0.5, h._layoutBounds.y = 0, h._layoutBounds.width = 0.5, h._layoutBounds.height = 1;
|
|
1992
|
+
}
|
|
1993
|
+
else if (n <= 4)
|
|
1994
|
+
for (let o = 0; o < n; o++) {
|
|
1995
|
+
let l = o % 2, h = o / 2;
|
|
1996
|
+
l = ~~l, h = ~~h;
|
|
1997
|
+
const u = this._clippingContextListForMask[r++];
|
|
1998
|
+
u._layoutChannelNo = a, u._layoutBounds.x = l * 0.5, u._layoutBounds.y = h * 0.5, u._layoutBounds.width = 0.5, u._layoutBounds.height = 0.5;
|
|
1999
|
+
}
|
|
2000
|
+
else if (n <= 9)
|
|
2001
|
+
for (let o = 0; o < n; o++) {
|
|
2002
|
+
let l = o % 3, h = o / 3;
|
|
2003
|
+
l = ~~l, h = ~~h;
|
|
2004
|
+
const u = this._clippingContextListForMask[r++];
|
|
2005
|
+
u._layoutChannelNo = a, u._layoutBounds.x = l / 3, u._layoutBounds.y = h / 3, u._layoutBounds.width = 1 / 3, u._layoutBounds.height = 1 / 3;
|
|
2006
|
+
}
|
|
2007
|
+
else if (ut.supportMoreMaskDivisions && n <= 16)
|
|
2008
|
+
for (let o = 0; o < n; o++) {
|
|
2009
|
+
let l = o % 4, h = o / 4;
|
|
2010
|
+
l = ~~l, h = ~~h;
|
|
2011
|
+
const u = this._clippingContextListForMask[r++];
|
|
2012
|
+
u._layoutChannelNo = a, u._layoutBounds.x = l / 4, u._layoutBounds.y = h / 4, u._layoutBounds.width = 1 / 4, u._layoutBounds.height = 1 / 4;
|
|
2013
|
+
}
|
|
2014
|
+
else
|
|
2015
|
+
tt("not supported mask count : {0}", n);
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
getColorBuffer() {
|
|
2019
|
+
return this._colorBuffer;
|
|
2020
|
+
}
|
|
2021
|
+
getClippingContextListForDraw() {
|
|
2022
|
+
return this._clippingContextListForDraw;
|
|
2023
|
+
}
|
|
2024
|
+
setClippingMaskBufferSize(t) {
|
|
2025
|
+
this._clippingMaskBufferSize = t;
|
|
2026
|
+
}
|
|
2027
|
+
getClippingMaskBufferSize() {
|
|
2028
|
+
return this._clippingMaskBufferSize;
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
class Pi {
|
|
2032
|
+
constructor(t, e) {
|
|
2033
|
+
this.frameNo = t, this.texture = e;
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2036
|
+
class Mi {
|
|
2037
|
+
constructor(t, e, i) {
|
|
2038
|
+
this._isUsing = !1, this._owner = t, this._clippingIdList = e, this._clippingIdCount = i, this._allClippedDrawRect = new wt(), this._layoutBounds = new wt(), this._clippedDrawableIndexList = [], this._matrixForMask = new R(), this._matrixForDraw = new R();
|
|
2039
|
+
}
|
|
2040
|
+
release() {
|
|
2041
|
+
const t = this;
|
|
2042
|
+
t._layoutBounds = void 0, t._allClippedDrawRect = void 0, t._clippedDrawableIndexList = void 0;
|
|
2043
|
+
}
|
|
2044
|
+
addClippedDrawable(t) {
|
|
2045
|
+
this._clippedDrawableIndexList.push(t);
|
|
2046
|
+
}
|
|
2047
|
+
getClippingManager() {
|
|
2048
|
+
return this._owner;
|
|
2049
|
+
}
|
|
2050
|
+
setGl(t) {
|
|
2051
|
+
this._owner.setGL(t);
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
class et {
|
|
2055
|
+
static getInstance() {
|
|
2056
|
+
return W == null && (W = new et()), W;
|
|
2057
|
+
}
|
|
2058
|
+
static deleteInstance() {
|
|
2059
|
+
W && (W.release(), W = void 0);
|
|
2060
|
+
}
|
|
2061
|
+
constructor() {
|
|
2062
|
+
this._shaderSets = [];
|
|
2063
|
+
}
|
|
2064
|
+
release() {
|
|
2065
|
+
this.releaseShaderProgram();
|
|
2066
|
+
}
|
|
2067
|
+
setupShaderProgram(t, e, i, r, a, n, o, l, h, u, c, d, _) {
|
|
2068
|
+
c || tt("NoPremultipliedAlpha is not allowed"), this._shaderSets.length == 0 && this.generateShaders();
|
|
2069
|
+
let p, x, g, m;
|
|
2070
|
+
const f = t.getClippingContextBufferForMask();
|
|
2071
|
+
if (f != null) {
|
|
2072
|
+
const v = this._shaderSets[lt.ShaderNames_SetupMask];
|
|
2073
|
+
this.gl.useProgram(v.shaderProgram), this.gl.activeTexture(this.gl.TEXTURE0), this.gl.bindTexture(this.gl.TEXTURE_2D, e), this.gl.uniform1i(v.samplerTexture0Location, 0), o.vertex == null && (o.vertex = this.gl.createBuffer()), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, o.vertex), this.gl.bufferData(this.gl.ARRAY_BUFFER, r, this.gl.DYNAMIC_DRAW), this.gl.enableVertexAttribArray(v.attributePositionLocation), this.gl.vertexAttribPointer(v.attributePositionLocation, 2, this.gl.FLOAT, !1, 0, 0), o.uv == null && (o.uv = this.gl.createBuffer()), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, o.uv), this.gl.bufferData(this.gl.ARRAY_BUFFER, n, this.gl.DYNAMIC_DRAW), this.gl.enableVertexAttribArray(v.attributeTexCoordLocation), this.gl.vertexAttribPointer(v.attributeTexCoordLocation, 2, this.gl.FLOAT, !1, 0, 0);
|
|
2074
|
+
const P = f._layoutChannelNo, I = f.getClippingManager().getChannelFlagAsColor(P);
|
|
2075
|
+
this.gl.uniform4f(v.uniformChannelFlagLocation, I.R, I.G, I.B, I.A), this.gl.uniformMatrix4fv(v.uniformClipMatrixLocation, !1, f._matrixForMask.getArray());
|
|
2076
|
+
const M = f._layoutBounds;
|
|
2077
|
+
this.gl.uniform4f(v.uniformBaseColorLocation, M.x * 2 - 1, M.y * 2 - 1, M.getRight() * 2 - 1, M.getBottom() * 2 - 1), p = this.gl.ZERO, x = this.gl.ONE_MINUS_SRC_COLOR, g = this.gl.ZERO, m = this.gl.ONE_MINUS_SRC_ALPHA;
|
|
2078
|
+
} else {
|
|
2079
|
+
const v = t.getClippingContextBufferForDraw(), I = v != null ? _ ? 2 : 1 : 0;
|
|
2080
|
+
let M;
|
|
2081
|
+
switch (h) {
|
|
2082
|
+
case z.CubismBlendMode_Normal:
|
|
2083
|
+
default:
|
|
2084
|
+
M = this._shaderSets[lt.ShaderNames_NormalPremultipliedAlpha + I], p = this.gl.ONE, x = this.gl.ONE_MINUS_SRC_ALPHA, g = this.gl.ONE, m = this.gl.ONE_MINUS_SRC_ALPHA;
|
|
2085
|
+
break;
|
|
2086
|
+
case z.CubismBlendMode_Additive:
|
|
2087
|
+
M = this._shaderSets[lt.ShaderNames_AddPremultipliedAlpha + I], p = this.gl.ONE, x = this.gl.ONE, g = this.gl.ZERO, m = this.gl.ONE;
|
|
2088
|
+
break;
|
|
2089
|
+
case z.CubismBlendMode_Multiplicative:
|
|
2090
|
+
M = this._shaderSets[lt.ShaderNames_MultPremultipliedAlpha + I], p = this.gl.DST_COLOR, x = this.gl.ONE_MINUS_SRC_ALPHA, g = this.gl.ZERO, m = this.gl.ONE;
|
|
2091
|
+
break;
|
|
2092
|
+
}
|
|
2093
|
+
if (this.gl.useProgram(M.shaderProgram), o.vertex == null && (o.vertex = this.gl.createBuffer()), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, o.vertex), this.gl.bufferData(this.gl.ARRAY_BUFFER, r, this.gl.DYNAMIC_DRAW), this.gl.enableVertexAttribArray(M.attributePositionLocation), this.gl.vertexAttribPointer(M.attributePositionLocation, 2, this.gl.FLOAT, !1, 0, 0), o.uv == null && (o.uv = this.gl.createBuffer()), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, o.uv), this.gl.bufferData(this.gl.ARRAY_BUFFER, n, this.gl.DYNAMIC_DRAW), this.gl.enableVertexAttribArray(M.attributeTexCoordLocation), this.gl.vertexAttribPointer(M.attributeTexCoordLocation, 2, this.gl.FLOAT, !1, 0, 0), v != null) {
|
|
2094
|
+
this.gl.activeTexture(this.gl.TEXTURE1);
|
|
2095
|
+
const V = v.getClippingManager().getColorBuffer();
|
|
2096
|
+
this.gl.bindTexture(this.gl.TEXTURE_2D, V), this.gl.uniform1i(M.samplerTexture1Location, 1), this.gl.uniformMatrix4fv(M.uniformClipMatrixLocation, !1, v._matrixForDraw.getArray());
|
|
2097
|
+
const Xt = v._layoutChannelNo, N = v.getClippingManager().getChannelFlagAsColor(Xt);
|
|
2098
|
+
this.gl.uniform4f(M.uniformChannelFlagLocation, N.R, N.G, N.B, N.A);
|
|
2099
|
+
}
|
|
2100
|
+
this.gl.activeTexture(this.gl.TEXTURE0), this.gl.bindTexture(this.gl.TEXTURE_2D, e), this.gl.uniform1i(M.samplerTexture0Location, 0), this.gl.uniformMatrix4fv(M.uniformMatrixLocation, !1, d.getArray()), this.gl.uniform4f(M.uniformBaseColorLocation, u.R, u.G, u.B, u.A);
|
|
2101
|
+
}
|
|
2102
|
+
o.index == null && (o.index = this.gl.createBuffer()), this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, o.index), this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, a, this.gl.DYNAMIC_DRAW), this.gl.blendFuncSeparate(p, x, g, m);
|
|
2103
|
+
}
|
|
2104
|
+
releaseShaderProgram() {
|
|
2105
|
+
for (let t = 0; t < this._shaderSets.length; t++)
|
|
2106
|
+
this.gl.deleteProgram(this._shaderSets[t].shaderProgram), this._shaderSets[t].shaderProgram = 0;
|
|
2107
|
+
this._shaderSets = [];
|
|
2108
|
+
}
|
|
2109
|
+
generateShaders() {
|
|
2110
|
+
for (let t = 0; t < xi; t++)
|
|
2111
|
+
this._shaderSets.push({});
|
|
2112
|
+
this._shaderSets[0].shaderProgram = this.loadShaderProgram(Ci, Si), this._shaderSets[1].shaderProgram = this.loadShaderProgram(bi, wi), this._shaderSets[2].shaderProgram = this.loadShaderProgram(Qt, Ii), this._shaderSets[3].shaderProgram = this.loadShaderProgram(Qt, Li), this._shaderSets[4].shaderProgram = this._shaderSets[1].shaderProgram, this._shaderSets[5].shaderProgram = this._shaderSets[2].shaderProgram, this._shaderSets[6].shaderProgram = this._shaderSets[3].shaderProgram, this._shaderSets[7].shaderProgram = this._shaderSets[1].shaderProgram, this._shaderSets[8].shaderProgram = this._shaderSets[2].shaderProgram, this._shaderSets[9].shaderProgram = this._shaderSets[3].shaderProgram, this._shaderSets[0].attributePositionLocation = this.gl.getAttribLocation(this._shaderSets[0].shaderProgram, "a_position"), this._shaderSets[0].attributeTexCoordLocation = this.gl.getAttribLocation(this._shaderSets[0].shaderProgram, "a_texCoord"), this._shaderSets[0].samplerTexture0Location = this.gl.getUniformLocation(this._shaderSets[0].shaderProgram, "s_texture0"), this._shaderSets[0].uniformClipMatrixLocation = this.gl.getUniformLocation(this._shaderSets[0].shaderProgram, "u_clipMatrix"), this._shaderSets[0].uniformChannelFlagLocation = this.gl.getUniformLocation(this._shaderSets[0].shaderProgram, "u_channelFlag"), this._shaderSets[0].uniformBaseColorLocation = this.gl.getUniformLocation(this._shaderSets[0].shaderProgram, "u_baseColor"), this._shaderSets[1].attributePositionLocation = this.gl.getAttribLocation(this._shaderSets[1].shaderProgram, "a_position"), this._shaderSets[1].attributeTexCoordLocation = this.gl.getAttribLocation(this._shaderSets[1].shaderProgram, "a_texCoord"), this._shaderSets[1].samplerTexture0Location = this.gl.getUniformLocation(this._shaderSets[1].shaderProgram, "s_texture0"), this._shaderSets[1].uniformMatrixLocation = this.gl.getUniformLocation(this._shaderSets[1].shaderProgram, "u_matrix"), this._shaderSets[1].uniformBaseColorLocation = this.gl.getUniformLocation(this._shaderSets[1].shaderProgram, "u_baseColor"), this._shaderSets[2].attributePositionLocation = this.gl.getAttribLocation(this._shaderSets[2].shaderProgram, "a_position"), this._shaderSets[2].attributeTexCoordLocation = this.gl.getAttribLocation(this._shaderSets[2].shaderProgram, "a_texCoord"), this._shaderSets[2].samplerTexture0Location = this.gl.getUniformLocation(this._shaderSets[2].shaderProgram, "s_texture0"), this._shaderSets[2].samplerTexture1Location = this.gl.getUniformLocation(this._shaderSets[2].shaderProgram, "s_texture1"), this._shaderSets[2].uniformMatrixLocation = this.gl.getUniformLocation(this._shaderSets[2].shaderProgram, "u_matrix"), this._shaderSets[2].uniformClipMatrixLocation = this.gl.getUniformLocation(this._shaderSets[2].shaderProgram, "u_clipMatrix"), this._shaderSets[2].uniformChannelFlagLocation = this.gl.getUniformLocation(this._shaderSets[2].shaderProgram, "u_channelFlag"), this._shaderSets[2].uniformBaseColorLocation = this.gl.getUniformLocation(this._shaderSets[2].shaderProgram, "u_baseColor"), this._shaderSets[3].attributePositionLocation = this.gl.getAttribLocation(this._shaderSets[3].shaderProgram, "a_position"), this._shaderSets[3].attributeTexCoordLocation = this.gl.getAttribLocation(this._shaderSets[3].shaderProgram, "a_texCoord"), this._shaderSets[3].samplerTexture0Location = this.gl.getUniformLocation(this._shaderSets[3].shaderProgram, "s_texture0"), this._shaderSets[3].samplerTexture1Location = this.gl.getUniformLocation(this._shaderSets[3].shaderProgram, "s_texture1"), this._shaderSets[3].uniformMatrixLocation = this.gl.getUniformLocation(this._shaderSets[3].shaderProgram, "u_matrix"), this._shaderSets[3].uniformClipMatrixLocation = this.gl.getUniformLocation(this._shaderSets[3].shaderProgram, "u_clipMatrix"), this._shaderSets[3].uniformChannelFlagLocation = this.gl.getUniformLocation(this._shaderSets[3].shaderProgram, "u_channelFlag"), this._shaderSets[3].uniformBaseColorLocation = this.gl.getUniformLocation(this._shaderSets[3].shaderProgram, "u_baseColor"), this._shaderSets[4].attributePositionLocation = this.gl.getAttribLocation(this._shaderSets[4].shaderProgram, "a_position"), this._shaderSets[4].attributeTexCoordLocation = this.gl.getAttribLocation(this._shaderSets[4].shaderProgram, "a_texCoord"), this._shaderSets[4].samplerTexture0Location = this.gl.getUniformLocation(this._shaderSets[4].shaderProgram, "s_texture0"), this._shaderSets[4].uniformMatrixLocation = this.gl.getUniformLocation(this._shaderSets[4].shaderProgram, "u_matrix"), this._shaderSets[4].uniformBaseColorLocation = this.gl.getUniformLocation(this._shaderSets[4].shaderProgram, "u_baseColor"), this._shaderSets[5].attributePositionLocation = this.gl.getAttribLocation(this._shaderSets[5].shaderProgram, "a_position"), this._shaderSets[5].attributeTexCoordLocation = this.gl.getAttribLocation(this._shaderSets[5].shaderProgram, "a_texCoord"), this._shaderSets[5].samplerTexture0Location = this.gl.getUniformLocation(this._shaderSets[5].shaderProgram, "s_texture0"), this._shaderSets[5].samplerTexture1Location = this.gl.getUniformLocation(this._shaderSets[5].shaderProgram, "s_texture1"), this._shaderSets[5].uniformMatrixLocation = this.gl.getUniformLocation(this._shaderSets[5].shaderProgram, "u_matrix"), this._shaderSets[5].uniformClipMatrixLocation = this.gl.getUniformLocation(this._shaderSets[5].shaderProgram, "u_clipMatrix"), this._shaderSets[5].uniformChannelFlagLocation = this.gl.getUniformLocation(this._shaderSets[5].shaderProgram, "u_channelFlag"), this._shaderSets[5].uniformBaseColorLocation = this.gl.getUniformLocation(this._shaderSets[5].shaderProgram, "u_baseColor"), this._shaderSets[6].attributePositionLocation = this.gl.getAttribLocation(this._shaderSets[6].shaderProgram, "a_position"), this._shaderSets[6].attributeTexCoordLocation = this.gl.getAttribLocation(this._shaderSets[6].shaderProgram, "a_texCoord"), this._shaderSets[6].samplerTexture0Location = this.gl.getUniformLocation(this._shaderSets[6].shaderProgram, "s_texture0"), this._shaderSets[6].samplerTexture1Location = this.gl.getUniformLocation(this._shaderSets[6].shaderProgram, "s_texture1"), this._shaderSets[6].uniformMatrixLocation = this.gl.getUniformLocation(this._shaderSets[6].shaderProgram, "u_matrix"), this._shaderSets[6].uniformClipMatrixLocation = this.gl.getUniformLocation(this._shaderSets[6].shaderProgram, "u_clipMatrix"), this._shaderSets[6].uniformChannelFlagLocation = this.gl.getUniformLocation(this._shaderSets[6].shaderProgram, "u_channelFlag"), this._shaderSets[6].uniformBaseColorLocation = this.gl.getUniformLocation(this._shaderSets[6].shaderProgram, "u_baseColor"), this._shaderSets[7].attributePositionLocation = this.gl.getAttribLocation(this._shaderSets[7].shaderProgram, "a_position"), this._shaderSets[7].attributeTexCoordLocation = this.gl.getAttribLocation(this._shaderSets[7].shaderProgram, "a_texCoord"), this._shaderSets[7].samplerTexture0Location = this.gl.getUniformLocation(this._shaderSets[7].shaderProgram, "s_texture0"), this._shaderSets[7].uniformMatrixLocation = this.gl.getUniformLocation(this._shaderSets[7].shaderProgram, "u_matrix"), this._shaderSets[7].uniformBaseColorLocation = this.gl.getUniformLocation(this._shaderSets[7].shaderProgram, "u_baseColor"), this._shaderSets[8].attributePositionLocation = this.gl.getAttribLocation(this._shaderSets[8].shaderProgram, "a_position"), this._shaderSets[8].attributeTexCoordLocation = this.gl.getAttribLocation(this._shaderSets[8].shaderProgram, "a_texCoord"), this._shaderSets[8].samplerTexture0Location = this.gl.getUniformLocation(this._shaderSets[8].shaderProgram, "s_texture0"), this._shaderSets[8].samplerTexture1Location = this.gl.getUniformLocation(this._shaderSets[8].shaderProgram, "s_texture1"), this._shaderSets[8].uniformMatrixLocation = this.gl.getUniformLocation(this._shaderSets[8].shaderProgram, "u_matrix"), this._shaderSets[8].uniformClipMatrixLocation = this.gl.getUniformLocation(this._shaderSets[8].shaderProgram, "u_clipMatrix"), this._shaderSets[8].uniformChannelFlagLocation = this.gl.getUniformLocation(this._shaderSets[8].shaderProgram, "u_channelFlag"), this._shaderSets[8].uniformBaseColorLocation = this.gl.getUniformLocation(this._shaderSets[8].shaderProgram, "u_baseColor"), this._shaderSets[9].attributePositionLocation = this.gl.getAttribLocation(this._shaderSets[9].shaderProgram, "a_position"), this._shaderSets[9].attributeTexCoordLocation = this.gl.getAttribLocation(this._shaderSets[9].shaderProgram, "a_texCoord"), this._shaderSets[9].samplerTexture0Location = this.gl.getUniformLocation(this._shaderSets[9].shaderProgram, "s_texture0"), this._shaderSets[9].samplerTexture1Location = this.gl.getUniformLocation(this._shaderSets[9].shaderProgram, "s_texture1"), this._shaderSets[9].uniformMatrixLocation = this.gl.getUniformLocation(this._shaderSets[9].shaderProgram, "u_matrix"), this._shaderSets[9].uniformClipMatrixLocation = this.gl.getUniformLocation(this._shaderSets[9].shaderProgram, "u_clipMatrix"), this._shaderSets[9].uniformChannelFlagLocation = this.gl.getUniformLocation(this._shaderSets[9].shaderProgram, "u_channelFlag"), this._shaderSets[9].uniformBaseColorLocation = this.gl.getUniformLocation(this._shaderSets[9].shaderProgram, "u_baseColor");
|
|
2113
|
+
}
|
|
2114
|
+
loadShaderProgram(t, e) {
|
|
2115
|
+
let i = this.gl.createProgram(), r = this.compileShaderSource(this.gl.VERTEX_SHADER, t);
|
|
2116
|
+
if (!r)
|
|
2117
|
+
return tt("Vertex shader compile error!"), 0;
|
|
2118
|
+
let a = this.compileShaderSource(this.gl.FRAGMENT_SHADER, e);
|
|
2119
|
+
return a ? (this.gl.attachShader(i, r), this.gl.attachShader(i, a), this.gl.linkProgram(i), this.gl.getProgramParameter(i, this.gl.LINK_STATUS) ? (this.gl.deleteShader(r), this.gl.deleteShader(a), i) : (tt("Failed to link program: {0}", i), this.gl.deleteShader(r), this.gl.deleteShader(a), i && this.gl.deleteProgram(i), 0)) : (tt("Vertex shader compile error!"), 0);
|
|
2120
|
+
}
|
|
2121
|
+
compileShaderSource(t, e) {
|
|
2122
|
+
const i = e, r = this.gl.createShader(t);
|
|
2123
|
+
if (this.gl.shaderSource(r, i), this.gl.compileShader(r), !r) {
|
|
2124
|
+
const n = this.gl.getShaderInfoLog(r);
|
|
2125
|
+
tt("Shader compile log: {0} ", n);
|
|
2126
|
+
}
|
|
2127
|
+
return this.gl.getShaderParameter(r, this.gl.COMPILE_STATUS) ? r : (this.gl.deleteShader(r), null);
|
|
2128
|
+
}
|
|
2129
|
+
setGl(t) {
|
|
2130
|
+
this.gl = t;
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
var lt = /* @__PURE__ */ ((s) => (s[s.ShaderNames_SetupMask = 0] = "ShaderNames_SetupMask", s[s.ShaderNames_NormalPremultipliedAlpha = 1] = "ShaderNames_NormalPremultipliedAlpha", s[s.ShaderNames_NormalMaskedPremultipliedAlpha = 2] = "ShaderNames_NormalMaskedPremultipliedAlpha", s[s.ShaderNames_NomralMaskedInvertedPremultipliedAlpha = 3] = "ShaderNames_NomralMaskedInvertedPremultipliedAlpha", s[s.ShaderNames_AddPremultipliedAlpha = 4] = "ShaderNames_AddPremultipliedAlpha", s[s.ShaderNames_AddMaskedPremultipliedAlpha = 5] = "ShaderNames_AddMaskedPremultipliedAlpha", s[s.ShaderNames_AddMaskedPremultipliedAlphaInverted = 6] = "ShaderNames_AddMaskedPremultipliedAlphaInverted", s[s.ShaderNames_MultPremultipliedAlpha = 7] = "ShaderNames_MultPremultipliedAlpha", s[s.ShaderNames_MultMaskedPremultipliedAlpha = 8] = "ShaderNames_MultMaskedPremultipliedAlpha", s[s.ShaderNames_MultMaskedPremultipliedAlphaInverted = 9] = "ShaderNames_MultMaskedPremultipliedAlphaInverted", s))(lt || {});
|
|
2134
|
+
const Ci = "attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_myPos;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_clipMatrix * a_position; v_myPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}", Si = "precision mediump float;varying vec2 v_texCoord;varying vec4 v_myPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;void main(){ float isInside = step(u_baseColor.x, v_myPos.x/v_myPos.w) * step(u_baseColor.y, v_myPos.y/v_myPos.w) * step(v_myPos.x/v_myPos.w, u_baseColor.z) * step(v_myPos.y/v_myPos.w, u_baseColor.w); gl_FragColor = u_channelFlag * texture2D(s_texture0, v_texCoord).a * isInside;}", bi = "attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;uniform mat4 u_matrix;void main(){ gl_Position = u_matrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}", Qt = "attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform mat4 u_matrix;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_matrix * a_position; v_clipPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}", wi = "precision mediump float;varying vec2 v_texCoord;uniform vec4 u_baseColor;uniform sampler2D s_texture0;void main(){ gl_FragColor = texture2D(s_texture0 , v_texCoord) * u_baseColor;}", Ii = "precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;uniform sampler2D s_texture1;void main(){ vec4 col_formask = texture2D(s_texture0 , v_texCoord) * u_baseColor; vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * maskVal; gl_FragColor = col_formask;}", Li = "precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_channelFlag;uniform vec4 u_baseColor;void main(){vec4 col_formask = texture2D(s_texture0, v_texCoord) * u_baseColor;vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag;float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a;col_formask = col_formask * (1.0 - maskVal);gl_FragColor = col_formask;}";
|
|
2135
|
+
class pe extends At {
|
|
2136
|
+
constructor() {
|
|
2137
|
+
super(), this._clippingContextBufferForMask = null, this._clippingContextBufferForDraw = null, this._clippingManager = new Ct(), this.firstDraw = !0, this._textures = {}, this._sortedDrawableIndexList = [], this._bufferData = {
|
|
2138
|
+
vertex: null,
|
|
2139
|
+
uv: null,
|
|
2140
|
+
index: null
|
|
2141
|
+
};
|
|
2142
|
+
}
|
|
2143
|
+
initialize(t) {
|
|
2144
|
+
t.isUsingMasking() && (this._clippingManager = new Ct(), this._clippingManager.initialize(t, t.getDrawableCount(), t.getDrawableMasks(), t.getDrawableMaskCounts()));
|
|
2145
|
+
for (let e = t.getDrawableCount() - 1; e >= 0; e--)
|
|
2146
|
+
this._sortedDrawableIndexList[e] = 0;
|
|
2147
|
+
super.initialize(t);
|
|
2148
|
+
}
|
|
2149
|
+
bindTexture(t, e) {
|
|
2150
|
+
this._textures[t] = e;
|
|
2151
|
+
}
|
|
2152
|
+
getBindedTextures() {
|
|
2153
|
+
return this._textures;
|
|
2154
|
+
}
|
|
2155
|
+
setClippingMaskBufferSize(t) {
|
|
2156
|
+
this._clippingManager.release(), this._clippingManager = new Ct(), this._clippingManager.setClippingMaskBufferSize(t), this._clippingManager.initialize(this.getModel(), this.getModel().getDrawableCount(), this.getModel().getDrawableMasks(), this.getModel().getDrawableMaskCounts());
|
|
2157
|
+
}
|
|
2158
|
+
getClippingMaskBufferSize() {
|
|
2159
|
+
return this._clippingManager.getClippingMaskBufferSize();
|
|
2160
|
+
}
|
|
2161
|
+
release() {
|
|
2162
|
+
var t, e, i;
|
|
2163
|
+
const r = this;
|
|
2164
|
+
this._clippingManager.release(), r._clippingManager = void 0, (t = this.gl) == null || t.deleteBuffer(this._bufferData.vertex), this._bufferData.vertex = null, (e = this.gl) == null || e.deleteBuffer(this._bufferData.uv), this._bufferData.uv = null, (i = this.gl) == null || i.deleteBuffer(this._bufferData.index), this._bufferData.index = null, r._bufferData = void 0, r._textures = void 0;
|
|
2165
|
+
}
|
|
2166
|
+
doDrawModel() {
|
|
2167
|
+
this.preDraw(), this._clippingManager != null && this._clippingManager.setupClippingContext(this.getModel(), this);
|
|
2168
|
+
const t = this.getModel().getDrawableCount(), e = this.getModel().getDrawableRenderOrders();
|
|
2169
|
+
for (let i = 0; i < t; ++i) {
|
|
2170
|
+
const r = e[i];
|
|
2171
|
+
this._sortedDrawableIndexList[r] = i;
|
|
2172
|
+
}
|
|
2173
|
+
for (let i = 0; i < t; ++i) {
|
|
2174
|
+
const r = this._sortedDrawableIndexList[i];
|
|
2175
|
+
this.getModel().getDrawableDynamicFlagIsVisible(r) && (this.setClippingContextBufferForDraw(this._clippingManager != null ? this._clippingManager.getClippingContextListForDraw()[r] : null), this.setIsCulling(this.getModel().getDrawableCulling(r)), this.drawMesh(this.getModel().getDrawableTextureIndices(r), this.getModel().getDrawableVertexIndexCount(r), this.getModel().getDrawableVertexCount(r), this.getModel().getDrawableVertexIndices(r), this.getModel().getDrawableVertices(r), this.getModel().getDrawableVertexUvs(r), this.getModel().getDrawableOpacity(r), this.getModel().getDrawableBlendMode(r), this.getModel().getDrawableInvertedMaskBit(r)));
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
drawMesh(t, e, i, r, a, n, o, l, h) {
|
|
2179
|
+
this.isCulling() ? this.gl.enable(this.gl.CULL_FACE) : this.gl.disable(this.gl.CULL_FACE), this.gl.frontFace(this.gl.CCW);
|
|
2180
|
+
const u = this.getModelColor();
|
|
2181
|
+
this.getClippingContextBufferForMask() == null && (u.A *= o, this.isPremultipliedAlpha() && (u.R *= u.A, u.G *= u.A, u.B *= u.A));
|
|
2182
|
+
let c = null;
|
|
2183
|
+
this._textures[t] != null && (c = this._textures[t]), et.getInstance().setupShaderProgram(this, c, i, a, r, n, this._bufferData, o, l, u, this.isPremultipliedAlpha(), this.getMvpMatrix(), h), this.gl.drawElements(this.gl.TRIANGLES, e, this.gl.UNSIGNED_SHORT, 0), this.gl.useProgram(null), this.setClippingContextBufferForDraw(null), this.setClippingContextBufferForMask(null);
|
|
2184
|
+
}
|
|
2185
|
+
static doStaticRelease() {
|
|
2186
|
+
et.deleteInstance();
|
|
2187
|
+
}
|
|
2188
|
+
setRenderState(t, e) {
|
|
2189
|
+
It = t, ot = e;
|
|
2190
|
+
}
|
|
2191
|
+
preDraw() {
|
|
2192
|
+
this.firstDraw && (this.firstDraw = !1, this._anisortopy = this.gl.getExtension("EXT_texture_filter_anisotropic") || this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic") || this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")), this.gl.disable(this.gl.SCISSOR_TEST), this.gl.disable(this.gl.STENCIL_TEST), this.gl.disable(this.gl.DEPTH_TEST), this.gl.frontFace(this.gl.CW), this.gl.enable(this.gl.BLEND), this.gl.colorMask(!0, !0, !0, !0), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null), this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, null);
|
|
2193
|
+
}
|
|
2194
|
+
setClippingContextBufferForMask(t) {
|
|
2195
|
+
this._clippingContextBufferForMask = t;
|
|
2196
|
+
}
|
|
2197
|
+
getClippingContextBufferForMask() {
|
|
2198
|
+
return this._clippingContextBufferForMask;
|
|
2199
|
+
}
|
|
2200
|
+
setClippingContextBufferForDraw(t) {
|
|
2201
|
+
this._clippingContextBufferForDraw = t;
|
|
2202
|
+
}
|
|
2203
|
+
getClippingContextBufferForDraw() {
|
|
2204
|
+
return this._clippingContextBufferForDraw;
|
|
2205
|
+
}
|
|
2206
|
+
startUp(t) {
|
|
2207
|
+
this.gl = t, this._clippingManager.setGL(t), et.getInstance().setGl(t);
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
At.staticRelease = () => {
|
|
2211
|
+
pe.doStaticRelease();
|
|
2212
|
+
};
|
|
2213
|
+
class _e {
|
|
2214
|
+
constructor(t) {
|
|
2215
|
+
this.groups = t.Groups, this.hitAreas = t.HitAreas, this.layout = t.Layout, this.moc = t.FileReferences.Moc, this.expressions = t.FileReferences.Expressions, this.motions = t.FileReferences.Motions, this.textures = t.FileReferences.Textures, this.physics = t.FileReferences.Physics, this.pose = t.FileReferences.Pose;
|
|
2216
|
+
}
|
|
2217
|
+
getEyeBlinkParameters() {
|
|
2218
|
+
var t, e;
|
|
2219
|
+
return (e = (t = this.groups) == null ? void 0 : t.find((i) => i.Name === "EyeBlink")) == null ? void 0 : e.Ids;
|
|
2220
|
+
}
|
|
2221
|
+
getLipSyncParameters() {
|
|
2222
|
+
var t, e;
|
|
2223
|
+
return (e = (t = this.groups) == null ? void 0 : t.find((i) => i.Name === "LipSync")) == null ? void 0 : e.Ids;
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
const hs = "HitArea", us = "Head", ds = "Body", cs = "Parts01Core", ms = "Parts01Arm_", gs = "Parts01ArmL_", ps = "Parts01ArmR_", Ti = "ParamAngleX", Ei = "ParamAngleY", Fi = "ParamAngleZ", _s = "ParamEyeLOpen", fs = "ParamEyeLSmile", ys = "ParamEyeROpen", vs = "ParamEyeRSmile", Di = "ParamEyeBallX", Ai = "ParamEyeBallY", xs = "ParamEyeBallForm", Ps = "ParamBrowLY", Ms = "ParamBrowRY", Cs = "ParamBrowLX", Ss = "ParamBrowRX", bs = "ParamBrowLAngle", ws = "ParamBrowRAngle", Is = "ParamBrowLForm", Ls = "ParamBrowRForm", Ts = "ParamMouthForm", Es = "ParamMouthOpenY", Fs = "ParamCheek", Bi = "ParamBodyAngleX", Ds = "ParamBodyAngleY", As = "ParamBodyAngleZ", Ri = "ParamBreath", Bs = "ParamArmLA", Rs = "ParamArmRA", Os = "ParamArmLB", ks = "ParamArmRB", Us = "ParamHandL", Vs = "ParamHandR", Ns = "ParamHairFront", Gs = "ParamHairSide", js = "ParamHairBack", zs = "ParamHairFluffy", Xs = "ParamShoulderY", Ys = "ParamBustX", Hs = "ParamBustY", Ws = "ParamBaseX", qs = "ParamBaseY", $s = "NONE:", te = 2, ee = 2;
|
|
2227
|
+
var F;
|
|
2228
|
+
((s) => {
|
|
2229
|
+
s.LOG_LEVEL_VERBOSE = 0, s.LOG_LEVEL_WARNING = 1, s.LOG_LEVEL_ERROR = 2, s.LOG_LEVEL_NONE = 999, s.logLevel = s.LOG_LEVEL_WARNING, s.sound = !0, s.motionSync = !0, s.motionFadingDuration = 500, s.idleMotionFadingDuration = 2e3, s.expressionFadingDuration = 500, s.preserveExpressionOnMotion = !0, s.cubism4 = ut;
|
|
2230
|
+
})(F || (F = {}));
|
|
2231
|
+
const Js = "0.4.0", C = {
|
|
2232
|
+
log(s, ...t) {
|
|
2233
|
+
F.logLevel <= F.LOG_LEVEL_VERBOSE && console.log(`[${s}]`, ...t);
|
|
2234
|
+
},
|
|
2235
|
+
warn(s, ...t) {
|
|
2236
|
+
F.logLevel <= F.LOG_LEVEL_WARNING && console.warn(`[${s}]`, ...t);
|
|
2237
|
+
},
|
|
2238
|
+
error(s, ...t) {
|
|
2239
|
+
F.logLevel <= F.LOG_LEVEL_ERROR && console.error(`[${s}]`, ...t);
|
|
2240
|
+
}
|
|
2241
|
+
};
|
|
2242
|
+
function ie(s, t, e) {
|
|
2243
|
+
return s < t ? t : s > e ? e : s;
|
|
2244
|
+
}
|
|
2245
|
+
function Zs(s, t) {
|
|
2246
|
+
return Math.random() * (t - s) + s;
|
|
2247
|
+
}
|
|
2248
|
+
function Ks(s, t, e, i, r) {
|
|
2249
|
+
const a = t[i];
|
|
2250
|
+
a !== null && typeof a === s && (e[r] = a);
|
|
2251
|
+
}
|
|
2252
|
+
function Qs(s, t, e, i, r) {
|
|
2253
|
+
const a = t[i];
|
|
2254
|
+
Array.isArray(a) && (e[r] = a.filter((n) => n !== null && typeof n === s));
|
|
2255
|
+
}
|
|
2256
|
+
function fe(s, t) {
|
|
2257
|
+
t.forEach((e) => {
|
|
2258
|
+
Object.getOwnPropertyNames(e.prototype).forEach((i) => {
|
|
2259
|
+
i !== "constructor" && Object.defineProperty(s.prototype, i, Object.getOwnPropertyDescriptor(e.prototype, i));
|
|
2260
|
+
});
|
|
2261
|
+
});
|
|
2262
|
+
}
|
|
2263
|
+
function Oi(s) {
|
|
2264
|
+
let t = s.lastIndexOf("/");
|
|
2265
|
+
return t != -1 && (s = s.slice(0, t)), t = s.lastIndexOf("/"), t !== -1 && (s = s.slice(t + 1)), s;
|
|
2266
|
+
}
|
|
2267
|
+
function ki(s, t) {
|
|
2268
|
+
const e = s.indexOf(t);
|
|
2269
|
+
e !== -1 && s.splice(e, 1);
|
|
2270
|
+
}
|
|
2271
|
+
class ye extends Tt {
|
|
2272
|
+
constructor(t, e) {
|
|
2273
|
+
super(), this.expressions = [], this.reserveExpressionIndex = -1, this.destroyed = !1, this.settings = t, this.tag = `ExpressionManager(${t.name})`;
|
|
2274
|
+
}
|
|
2275
|
+
init() {
|
|
2276
|
+
this.defaultExpression = this.createExpression({}, void 0), this.currentExpression = this.defaultExpression, this.stopAllExpressions();
|
|
2277
|
+
}
|
|
2278
|
+
loadExpression(t) {
|
|
2279
|
+
return b(this, null, function* () {
|
|
2280
|
+
if (!this.definitions[t]) {
|
|
2281
|
+
C.warn(this.tag, `Undefined expression at [${t}]`);
|
|
2282
|
+
return;
|
|
2283
|
+
}
|
|
2284
|
+
if (this.expressions[t] === null) {
|
|
2285
|
+
C.warn(this.tag, `Cannot set expression at [${t}] because it's already failed in loading.`);
|
|
2286
|
+
return;
|
|
2287
|
+
}
|
|
2288
|
+
if (this.expressions[t])
|
|
2289
|
+
return this.expressions[t];
|
|
2290
|
+
const e = yield this._loadExpression(t);
|
|
2291
|
+
return this.expressions[t] = e, e;
|
|
2292
|
+
});
|
|
2293
|
+
}
|
|
2294
|
+
_loadExpression(t) {
|
|
2295
|
+
throw new Error("Not implemented.");
|
|
2296
|
+
}
|
|
2297
|
+
setRandomExpression() {
|
|
2298
|
+
return b(this, null, function* () {
|
|
2299
|
+
if (this.definitions.length) {
|
|
2300
|
+
const t = [];
|
|
2301
|
+
for (let e = 0; e < this.definitions.length; e++)
|
|
2302
|
+
this.expressions[e] !== null && this.expressions[e] !== this.currentExpression && e !== this.reserveExpressionIndex && t.push(e);
|
|
2303
|
+
if (t.length) {
|
|
2304
|
+
const e = Math.floor(Math.random() * t.length);
|
|
2305
|
+
return this.setExpression(e);
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
return !1;
|
|
2309
|
+
});
|
|
2310
|
+
}
|
|
2311
|
+
resetExpression() {
|
|
2312
|
+
this._setExpression(this.defaultExpression);
|
|
2313
|
+
}
|
|
2314
|
+
restoreExpression() {
|
|
2315
|
+
this._setExpression(this.currentExpression);
|
|
2316
|
+
}
|
|
2317
|
+
setExpression(t) {
|
|
2318
|
+
return b(this, null, function* () {
|
|
2319
|
+
if (typeof t != "number" && (t = this.getExpressionIndex(t)), !(t > -1 && t < this.definitions.length) || t === this.expressions.indexOf(this.currentExpression))
|
|
2320
|
+
return !1;
|
|
2321
|
+
this.reserveExpressionIndex = t;
|
|
2322
|
+
const e = yield this.loadExpression(t);
|
|
2323
|
+
return !e || this.reserveExpressionIndex !== t ? !1 : (this.reserveExpressionIndex = -1, this.currentExpression = e, this._setExpression(e), !0);
|
|
2324
|
+
});
|
|
2325
|
+
}
|
|
2326
|
+
update(t, e) {
|
|
2327
|
+
return this.isFinished() ? !1 : this.updateParameters(t, e);
|
|
2328
|
+
}
|
|
2329
|
+
destroy() {
|
|
2330
|
+
this.destroyed = !0, this.emit("destroy");
|
|
2331
|
+
const t = this;
|
|
2332
|
+
t.definitions = void 0, t.expressions = void 0;
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
const se = 0.01, Ui = 40 / 7.5, Vi = 1 / (0.15 * 1e3);
|
|
2336
|
+
class Ni {
|
|
2337
|
+
constructor() {
|
|
2338
|
+
this.targetX = 0, this.targetY = 0, this.x = 0, this.y = 0, this.vx = 0, this.vy = 0;
|
|
2339
|
+
}
|
|
2340
|
+
focus(t, e, i = !1) {
|
|
2341
|
+
this.targetX = ie(t, -1, 1), this.targetY = ie(e, -1, 1), i && (this.x = this.targetX, this.y = this.targetY);
|
|
2342
|
+
}
|
|
2343
|
+
update(t) {
|
|
2344
|
+
const e = this.targetX - this.x, i = this.targetY - this.y;
|
|
2345
|
+
if (Math.abs(e) < se && Math.abs(i) < se)
|
|
2346
|
+
return;
|
|
2347
|
+
const r = Math.sqrt(H(e, 2) + H(i, 2)), a = Ui / (1e3 / t);
|
|
2348
|
+
let n = a * (e / r) - this.vx, o = a * (i / r) - this.vy;
|
|
2349
|
+
const l = Math.sqrt(H(n, 2) + H(o, 2)), h = a * Vi * t;
|
|
2350
|
+
l > h && (n *= h / l, o *= h / l), this.vx += n, this.vy += o;
|
|
2351
|
+
const u = Math.sqrt(H(this.vx, 2) + H(this.vy, 2)), c = 0.5 * (Math.sqrt(H(h, 2) + 8 * h * r) - h);
|
|
2352
|
+
u > c && (this.vx *= c / u, this.vy *= c / u), this.x += this.vx, this.y += this.vy;
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
class Gt {
|
|
2356
|
+
constructor(t) {
|
|
2357
|
+
this.json = t;
|
|
2358
|
+
let e = t.url;
|
|
2359
|
+
if (typeof e != "string")
|
|
2360
|
+
throw new TypeError("The `url` field in settings JSON must be defined as a string.");
|
|
2361
|
+
this.url = e, this.name = Oi(this.url);
|
|
2362
|
+
}
|
|
2363
|
+
resolveURL(t) {
|
|
2364
|
+
return Et.resolve(this.url, t);
|
|
2365
|
+
}
|
|
2366
|
+
replaceFiles(t) {
|
|
2367
|
+
this.moc = t(this.moc, "moc"), this.pose !== void 0 && (this.pose = t(this.pose, "pose")), this.physics !== void 0 && (this.physics = t(this.physics, "physics"));
|
|
2368
|
+
for (let e = 0; e < this.textures.length; e++)
|
|
2369
|
+
this.textures[e] = t(this.textures[e], `textures[${e}]`);
|
|
2370
|
+
}
|
|
2371
|
+
getDefinedFiles() {
|
|
2372
|
+
const t = [];
|
|
2373
|
+
return this.replaceFiles((e) => (t.push(e), e)), t;
|
|
2374
|
+
}
|
|
2375
|
+
validateFiles(t) {
|
|
2376
|
+
const e = (a, n) => {
|
|
2377
|
+
const o = this.resolveURL(a);
|
|
2378
|
+
if (!t.includes(o)) {
|
|
2379
|
+
if (n)
|
|
2380
|
+
throw new Error(`File "${a}" is defined in settings, but doesn't exist in given files`);
|
|
2381
|
+
return !1;
|
|
2382
|
+
}
|
|
2383
|
+
return !0;
|
|
2384
|
+
};
|
|
2385
|
+
return [this.moc, ...this.textures].forEach((a) => e(a, !0)), this.getDefinedFiles().filter((a) => e(a, !1));
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
2388
|
+
var Lt = /* @__PURE__ */ ((s) => (s[s.NONE = 0] = "NONE", s[s.IDLE = 1] = "IDLE", s[s.NORMAL = 2] = "NORMAL", s[s.FORCE = 3] = "FORCE", s))(Lt || {});
|
|
2389
|
+
class Gi {
|
|
2390
|
+
constructor() {
|
|
2391
|
+
this.debug = !1, this.currentPriority = 0, this.reservePriority = 0;
|
|
2392
|
+
}
|
|
2393
|
+
reserve(t, e, i) {
|
|
2394
|
+
if (i <= 0)
|
|
2395
|
+
return C.log(this.tag, "Cannot start a motion with MotionPriority.NONE."), !1;
|
|
2396
|
+
if (t === this.currentGroup && e === this.currentIndex)
|
|
2397
|
+
return C.log(this.tag, "Motion is already playing.", this.dump(t, e)), !1;
|
|
2398
|
+
if (t === this.reservedGroup && e === this.reservedIndex || t === this.reservedIdleGroup && e === this.reservedIdleIndex)
|
|
2399
|
+
return C.log(this.tag, "Motion is already reserved.", this.dump(t, e)), !1;
|
|
2400
|
+
if (i === 1) {
|
|
2401
|
+
if (this.currentPriority !== 0)
|
|
2402
|
+
return C.log(this.tag, "Cannot start idle motion because another motion is playing.", this.dump(t, e)), !1;
|
|
2403
|
+
if (this.reservedIdleGroup !== void 0)
|
|
2404
|
+
return C.log(this.tag, "Cannot start idle motion because another idle motion has reserved.", this.dump(t, e)), !1;
|
|
2405
|
+
this.setReservedIdle(t, e);
|
|
2406
|
+
} else {
|
|
2407
|
+
if (i < 3) {
|
|
2408
|
+
if (i <= this.currentPriority)
|
|
2409
|
+
return C.log(this.tag, "Cannot start motion because another motion is playing as an equivalent or higher priority.", this.dump(t, e)), !1;
|
|
2410
|
+
if (i <= this.reservePriority)
|
|
2411
|
+
return C.log(this.tag, "Cannot start motion because another motion has reserved as an equivalent or higher priority.", this.dump(t, e)), !1;
|
|
2412
|
+
}
|
|
2413
|
+
this.setReserved(t, e, i);
|
|
2414
|
+
}
|
|
2415
|
+
return !0;
|
|
2416
|
+
}
|
|
2417
|
+
start(t, e, i, r) {
|
|
2418
|
+
if (r === 1) {
|
|
2419
|
+
if (this.setReservedIdle(void 0, void 0), this.currentPriority !== 0)
|
|
2420
|
+
return C.log(this.tag, "Cannot start idle motion because another motion is playing.", this.dump(e, i)), !1;
|
|
2421
|
+
} else {
|
|
2422
|
+
if (e !== this.reservedGroup || i !== this.reservedIndex)
|
|
2423
|
+
return C.log(this.tag, "Cannot start motion because another motion has taken the place.", this.dump(e, i)), !1;
|
|
2424
|
+
this.setReserved(void 0, void 0, 0);
|
|
2425
|
+
}
|
|
2426
|
+
return t ? (this.setCurrent(e, i, r), !0) : !1;
|
|
2427
|
+
}
|
|
2428
|
+
complete() {
|
|
2429
|
+
this.setCurrent(void 0, void 0, 0);
|
|
2430
|
+
}
|
|
2431
|
+
setCurrent(t, e, i) {
|
|
2432
|
+
this.currentPriority = i, this.currentGroup = t, this.currentIndex = e;
|
|
2433
|
+
}
|
|
2434
|
+
setReserved(t, e, i) {
|
|
2435
|
+
this.reservePriority = i, this.reservedGroup = t, this.reservedIndex = e;
|
|
2436
|
+
}
|
|
2437
|
+
setReservedIdle(t, e) {
|
|
2438
|
+
this.reservedIdleGroup = t, this.reservedIdleIndex = e;
|
|
2439
|
+
}
|
|
2440
|
+
isActive(t, e) {
|
|
2441
|
+
return t === this.currentGroup && e === this.currentIndex || t === this.reservedGroup && e === this.reservedIndex || t === this.reservedIdleGroup && e === this.reservedIdleIndex;
|
|
2442
|
+
}
|
|
2443
|
+
reset() {
|
|
2444
|
+
this.setCurrent(void 0, void 0, 0), this.setReserved(void 0, void 0, 0), this.setReservedIdle(void 0, void 0);
|
|
2445
|
+
}
|
|
2446
|
+
shouldRequestIdleMotion() {
|
|
2447
|
+
return this.currentGroup === void 0 && this.reservedIdleGroup === void 0;
|
|
2448
|
+
}
|
|
2449
|
+
shouldOverrideExpression() {
|
|
2450
|
+
return !F.preserveExpressionOnMotion && this.currentPriority > 1;
|
|
2451
|
+
}
|
|
2452
|
+
dump(t, e) {
|
|
2453
|
+
if (this.debug) {
|
|
2454
|
+
const i = [
|
|
2455
|
+
"currentPriority",
|
|
2456
|
+
"reservePriority",
|
|
2457
|
+
"currentGroup",
|
|
2458
|
+
"currentIndex",
|
|
2459
|
+
"reservedGroup",
|
|
2460
|
+
"reservedIndex",
|
|
2461
|
+
"reservedIdleGroup",
|
|
2462
|
+
"reservedIdleIndex"
|
|
2463
|
+
];
|
|
2464
|
+
return `
|
|
2465
|
+
<Requested> group = "${t}", index = ${e}
|
|
2466
|
+
` + i.map((r) => "[" + r + "] " + this[r]).join(`
|
|
2467
|
+
`);
|
|
2468
|
+
}
|
|
2469
|
+
return "";
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
const ji = "SoundManager", zi = 0.5;
|
|
2473
|
+
class Z {
|
|
2474
|
+
static get volume() {
|
|
2475
|
+
return this._volume;
|
|
2476
|
+
}
|
|
2477
|
+
static set volume(t) {
|
|
2478
|
+
this._volume = (t > 1 ? 1 : t < 0 ? 0 : t) || 0, this.audios.forEach((e) => e.volume = this._volume);
|
|
2479
|
+
}
|
|
2480
|
+
static add(t, e, i) {
|
|
2481
|
+
const r = new Audio(t);
|
|
2482
|
+
return r.volume = this._volume, r.preload = "auto", r.addEventListener("ended", () => {
|
|
2483
|
+
this.dispose(r), e?.();
|
|
2484
|
+
}), r.addEventListener("error", (a) => {
|
|
2485
|
+
this.dispose(r), C.warn(ji, `Error occurred on "${t}"`, a.error), i?.(a.error);
|
|
2486
|
+
}), this.audios.push(r), r;
|
|
2487
|
+
}
|
|
2488
|
+
static play(t) {
|
|
2489
|
+
return new Promise((e, i) => {
|
|
2490
|
+
var r;
|
|
2491
|
+
(r = t.play()) == null || r.catch((a) => {
|
|
2492
|
+
t.dispatchEvent(new ErrorEvent("error", { error: a })), i(a);
|
|
2493
|
+
}), t.readyState === t.HAVE_ENOUGH_DATA ? e() : t.addEventListener("canplaythrough", e);
|
|
2494
|
+
});
|
|
2495
|
+
}
|
|
2496
|
+
static dispose(t) {
|
|
2497
|
+
t.pause(), t.removeAttribute("src"), ki(this.audios, t);
|
|
2498
|
+
}
|
|
2499
|
+
static destroy() {
|
|
2500
|
+
for (let t = this.audios.length - 1; t >= 0; t--)
|
|
2501
|
+
this.dispose(this.audios[t]);
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
Z.audios = [];
|
|
2505
|
+
Z._volume = zi;
|
|
2506
|
+
var Xi = /* @__PURE__ */ ((s) => (s.ALL = "ALL", s.IDLE = "IDLE", s.NONE = "NONE", s))(Xi || {});
|
|
2507
|
+
class jt extends Tt {
|
|
2508
|
+
constructor(t, e) {
|
|
2509
|
+
super(), this.motionGroups = {}, this.state = new Gi(), this.playing = !1, this.destroyed = !1, this.settings = t, this.tag = `MotionManager(${t.name})`, this.state.tag = this.tag;
|
|
2510
|
+
}
|
|
2511
|
+
init(t) {
|
|
2512
|
+
t?.idleMotionGroup && (this.groups.idle = t.idleMotionGroup), this.setupMotions(t), this.stopAllMotions();
|
|
2513
|
+
}
|
|
2514
|
+
setupMotions(t) {
|
|
2515
|
+
for (const i of Object.keys(this.definitions))
|
|
2516
|
+
this.motionGroups[i] = [];
|
|
2517
|
+
let e;
|
|
2518
|
+
switch (t?.motionPreload) {
|
|
2519
|
+
case "NONE":
|
|
2520
|
+
return;
|
|
2521
|
+
case "ALL":
|
|
2522
|
+
e = Object.keys(this.definitions);
|
|
2523
|
+
break;
|
|
2524
|
+
default:
|
|
2525
|
+
e = [this.groups.idle];
|
|
2526
|
+
break;
|
|
2527
|
+
}
|
|
2528
|
+
for (const i of e)
|
|
2529
|
+
if (this.definitions[i])
|
|
2530
|
+
for (let r = 0; r < this.definitions[i].length; r++)
|
|
2531
|
+
this.loadMotion(i, r).then();
|
|
2532
|
+
}
|
|
2533
|
+
loadMotion(t, e) {
|
|
2534
|
+
return b(this, null, function* () {
|
|
2535
|
+
var i;
|
|
2536
|
+
if (!((i = this.definitions[t]) != null && i[e])) {
|
|
2537
|
+
C.warn(this.tag, `Undefined motion at "${t}"[${e}]`);
|
|
2538
|
+
return;
|
|
2539
|
+
}
|
|
2540
|
+
if (this.motionGroups[t][e] === null) {
|
|
2541
|
+
C.warn(this.tag, `Cannot start motion at "${t}"[${e}] because it's already failed in loading.`);
|
|
2542
|
+
return;
|
|
2543
|
+
}
|
|
2544
|
+
if (this.motionGroups[t][e])
|
|
2545
|
+
return this.motionGroups[t][e];
|
|
2546
|
+
const r = yield this._loadMotion(t, e);
|
|
2547
|
+
if (!this.destroyed)
|
|
2548
|
+
return this.motionGroups[t][e] = r ?? null, r;
|
|
2549
|
+
});
|
|
2550
|
+
}
|
|
2551
|
+
_loadMotion(t, e) {
|
|
2552
|
+
throw new Error("Not implemented.");
|
|
2553
|
+
}
|
|
2554
|
+
startMotion(t, e) {
|
|
2555
|
+
return b(this, arguments, function* (i, r, a = Lt.NORMAL) {
|
|
2556
|
+
var n;
|
|
2557
|
+
if (!this.state.reserve(i, r, a))
|
|
2558
|
+
return !1;
|
|
2559
|
+
const o = (n = this.definitions[i]) == null ? void 0 : n[r];
|
|
2560
|
+
if (!o)
|
|
2561
|
+
return !1;
|
|
2562
|
+
this.currentAudio && Z.dispose(this.currentAudio);
|
|
2563
|
+
let l;
|
|
2564
|
+
if (F.sound) {
|
|
2565
|
+
const u = this.getSoundFile(o);
|
|
2566
|
+
if (u)
|
|
2567
|
+
try {
|
|
2568
|
+
l = Z.add(this.settings.resolveURL(u), () => this.currentAudio = void 0, () => this.currentAudio = void 0), this.currentAudio = l;
|
|
2569
|
+
} catch (c) {
|
|
2570
|
+
C.warn(this.tag, "Failed to create audio", u, c);
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
const h = yield this.loadMotion(i, r);
|
|
2574
|
+
if (l) {
|
|
2575
|
+
const u = Z.play(l).catch((c) => C.warn(this.tag, "Failed to play audio", l.src, c));
|
|
2576
|
+
F.motionSync && (yield u);
|
|
2577
|
+
}
|
|
2578
|
+
return this.state.start(h, i, r, a) ? (C.log(this.tag, "Start motion:", this.getMotionName(o)), this.emit("motionStart", i, r, l), this.state.shouldOverrideExpression() && this.expressionManager && this.expressionManager.resetExpression(), this.playing = !0, this._startMotion(h), !0) : (l && (Z.dispose(l), this.currentAudio = void 0), !1);
|
|
2579
|
+
});
|
|
2580
|
+
}
|
|
2581
|
+
startRandomMotion(t, e) {
|
|
2582
|
+
return b(this, null, function* () {
|
|
2583
|
+
const i = this.definitions[t];
|
|
2584
|
+
if (i?.length) {
|
|
2585
|
+
const r = [];
|
|
2586
|
+
for (let a = 0; a < i.length; a++)
|
|
2587
|
+
this.motionGroups[t][a] !== null && !this.state.isActive(t, a) && r.push(a);
|
|
2588
|
+
if (r.length) {
|
|
2589
|
+
const a = Math.floor(Math.random() * r.length);
|
|
2590
|
+
return this.startMotion(t, r[a], e);
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
return !1;
|
|
2594
|
+
});
|
|
2595
|
+
}
|
|
2596
|
+
stopAllMotions() {
|
|
2597
|
+
this._stopAllMotions(), this.state.reset(), this.currentAudio && (Z.dispose(this.currentAudio), this.currentAudio = void 0);
|
|
2598
|
+
}
|
|
2599
|
+
update(t, e) {
|
|
2600
|
+
var i;
|
|
2601
|
+
return this.isFinished() && (this.playing && (this.playing = !1, this.emit("motionFinish")), this.state.shouldOverrideExpression() && ((i = this.expressionManager) == null || i.restoreExpression()), this.state.complete(), this.state.shouldRequestIdleMotion() && this.startRandomMotion(this.groups.idle, Lt.IDLE)), this.updateParameters(t, e);
|
|
2602
|
+
}
|
|
2603
|
+
destroy() {
|
|
2604
|
+
var t;
|
|
2605
|
+
this.destroyed = !0, this.emit("destroy"), this.stopAllMotions(), (t = this.expressionManager) == null || t.destroy();
|
|
2606
|
+
const e = this;
|
|
2607
|
+
e.definitions = void 0, e.motionGroups = void 0;
|
|
2608
|
+
}
|
|
2609
|
+
}
|
|
2610
|
+
const Yi = { x: 0, y: 0, width: 0, height: 0 };
|
|
2611
|
+
class Hi extends Tt {
|
|
2612
|
+
constructor() {
|
|
2613
|
+
super(...arguments), this.focusController = new Ni(), this.originalWidth = 0, this.originalHeight = 0, this.width = 0, this.height = 0, this.localTransform = new pt(), this.drawingMatrix = new pt(), this.hitAreas = {}, this.textureFlipY = !1, this.viewport = [0, 0, 0, 0], this.destroyed = !1;
|
|
2614
|
+
}
|
|
2615
|
+
init() {
|
|
2616
|
+
this.setupLayout(), this.setupHitAreas();
|
|
2617
|
+
}
|
|
2618
|
+
setupLayout() {
|
|
2619
|
+
const t = this, e = this.getSize();
|
|
2620
|
+
t.originalWidth = e[0], t.originalHeight = e[1];
|
|
2621
|
+
const i = Object.assign({
|
|
2622
|
+
width: te,
|
|
2623
|
+
height: ee
|
|
2624
|
+
}, this.getLayout());
|
|
2625
|
+
this.localTransform.scale(i.width / te, i.height / ee), t.width = this.originalWidth * this.localTransform.a, t.height = this.originalHeight * this.localTransform.d;
|
|
2626
|
+
const r = i.x !== void 0 && i.x - i.width / 2 || i.centerX !== void 0 && i.centerX || i.left !== void 0 && i.left - i.width / 2 || i.right !== void 0 && i.right + i.width / 2 || 0, a = i.y !== void 0 && i.y - i.height / 2 || i.centerY !== void 0 && i.centerY || i.top !== void 0 && i.top - i.height / 2 || i.bottom !== void 0 && i.bottom + i.height / 2 || 0;
|
|
2627
|
+
this.localTransform.translate(this.width * r, -this.height * a);
|
|
2628
|
+
}
|
|
2629
|
+
setupHitAreas() {
|
|
2630
|
+
const t = this.getHitAreaDefs().filter((e) => e.index >= 0);
|
|
2631
|
+
for (const e of t)
|
|
2632
|
+
this.hitAreas[e.name] = e;
|
|
2633
|
+
}
|
|
2634
|
+
hitTest(t, e) {
|
|
2635
|
+
return Object.keys(this.hitAreas).filter((i) => this.isHit(i, t, e));
|
|
2636
|
+
}
|
|
2637
|
+
isHit(t, e, i) {
|
|
2638
|
+
if (!this.hitAreas[t])
|
|
2639
|
+
return !1;
|
|
2640
|
+
const r = this.hitAreas[t].index, a = this.getDrawableBounds(r, Yi);
|
|
2641
|
+
return a.x <= e && e <= a.x + a.width && a.y <= i && i <= a.y + a.height;
|
|
2642
|
+
}
|
|
2643
|
+
getDrawableBounds(t, e) {
|
|
2644
|
+
const i = this.getDrawableVertices(t);
|
|
2645
|
+
let r = i[0], a = i[0], n = i[1], o = i[1];
|
|
2646
|
+
for (let l = 0; l < i.length; l += 2) {
|
|
2647
|
+
const h = i[l], u = i[l + 1];
|
|
2648
|
+
r = Math.min(h, r), a = Math.max(h, a), n = Math.min(u, n), o = Math.max(u, o);
|
|
2649
|
+
}
|
|
2650
|
+
return e ?? (e = {}), e.x = r, e.y = n, e.width = a - r, e.height = o - n, e;
|
|
2651
|
+
}
|
|
2652
|
+
updateTransform(t) {
|
|
2653
|
+
this.drawingMatrix.copyFrom(t).append(this.localTransform);
|
|
2654
|
+
}
|
|
2655
|
+
update(t, e) {
|
|
2656
|
+
this.focusController.update(t);
|
|
2657
|
+
}
|
|
2658
|
+
destroy() {
|
|
2659
|
+
this.destroyed = !0, this.emit("destroy"), this.motionManager.destroy(), this.motionManager = void 0;
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
const Wi = "XHRLoader";
|
|
2663
|
+
class re extends Error {
|
|
2664
|
+
constructor(t, e, i, r = !1) {
|
|
2665
|
+
super(t), this.url = e, this.status = i, this.aborted = r;
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
const T = class {
|
|
2669
|
+
static createXHR(s, t, e, i, r) {
|
|
2670
|
+
const a = new XMLHttpRequest();
|
|
2671
|
+
if (T.allXhrSet.add(a), s) {
|
|
2672
|
+
let n = T.xhrMap.get(s);
|
|
2673
|
+
n ? n.add(a) : (n = /* @__PURE__ */ new Set([a]), T.xhrMap.set(s, n)), s.listeners("destroy").includes(T.cancelXHRs) || s.once("destroy", T.cancelXHRs);
|
|
2674
|
+
}
|
|
2675
|
+
return a.open("GET", t), a.responseType = e, a.onload = () => {
|
|
2676
|
+
(a.status === 200 || a.status === 0) && a.response ? i(a.response) : a.onerror();
|
|
2677
|
+
}, a.onerror = () => {
|
|
2678
|
+
C.warn(Wi, `Failed to load resource as ${a.responseType} (Status ${a.status}): ${t}`), r(new re("Network error.", t, a.status));
|
|
2679
|
+
}, a.onabort = () => r(new re("Aborted.", t, a.status, !0)), a.onloadend = () => {
|
|
2680
|
+
var n;
|
|
2681
|
+
T.allXhrSet.delete(a), s && ((n = T.xhrMap.get(s)) == null || n.delete(a));
|
|
2682
|
+
}, a;
|
|
2683
|
+
}
|
|
2684
|
+
static cancelXHRs() {
|
|
2685
|
+
var s;
|
|
2686
|
+
(s = T.xhrMap.get(this)) == null || s.forEach((t) => {
|
|
2687
|
+
t.abort(), T.allXhrSet.delete(t);
|
|
2688
|
+
}), T.xhrMap.delete(this);
|
|
2689
|
+
}
|
|
2690
|
+
static release() {
|
|
2691
|
+
T.allXhrSet.forEach((s) => s.abort()), T.allXhrSet.clear(), T.xhrMap = /* @__PURE__ */ new WeakMap();
|
|
2692
|
+
}
|
|
2693
|
+
};
|
|
2694
|
+
let ft = T;
|
|
2695
|
+
ft.xhrMap = /* @__PURE__ */ new WeakMap();
|
|
2696
|
+
ft.allXhrSet = /* @__PURE__ */ new Set();
|
|
2697
|
+
ft.loader = (s, t) => new Promise((e, i) => {
|
|
2698
|
+
T.createXHR(s.target, s.settings ? s.settings.resolveURL(s.url) : s.url, s.type, (a) => {
|
|
2699
|
+
s.result = a, e();
|
|
2700
|
+
}, i).send();
|
|
2701
|
+
});
|
|
2702
|
+
function ve(s, t) {
|
|
2703
|
+
let e = -1;
|
|
2704
|
+
return i(0);
|
|
2705
|
+
function i(r, a) {
|
|
2706
|
+
if (a)
|
|
2707
|
+
return Promise.reject(a);
|
|
2708
|
+
if (r <= e)
|
|
2709
|
+
return Promise.reject(new Error("next() called multiple times"));
|
|
2710
|
+
e = r;
|
|
2711
|
+
const n = s[r];
|
|
2712
|
+
if (!n)
|
|
2713
|
+
return Promise.resolve();
|
|
2714
|
+
try {
|
|
2715
|
+
return Promise.resolve(n(t, i.bind(null, r + 1)));
|
|
2716
|
+
} catch (o) {
|
|
2717
|
+
return Promise.reject(o);
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
class X {
|
|
2722
|
+
static load(t) {
|
|
2723
|
+
return ve(this.middlewares, t).then(() => t.result);
|
|
2724
|
+
}
|
|
2725
|
+
}
|
|
2726
|
+
X.middlewares = [ft.loader];
|
|
2727
|
+
function qi(s, t = {}) {
|
|
2728
|
+
var e;
|
|
2729
|
+
const i = { resourceOptions: { crossorigin: t.crossOrigin } };
|
|
2730
|
+
if (vt.fromURL)
|
|
2731
|
+
return vt.fromURL(s, i).catch((n) => {
|
|
2732
|
+
if (n instanceof Error)
|
|
2733
|
+
throw n;
|
|
2734
|
+
const o = new Error("Texture loading error");
|
|
2735
|
+
throw o.event = n, o;
|
|
2736
|
+
});
|
|
2737
|
+
i.resourceOptions.autoLoad = !1;
|
|
2738
|
+
const r = vt.from(s, i);
|
|
2739
|
+
if (r.baseTexture.valid)
|
|
2740
|
+
return Promise.resolve(r);
|
|
2741
|
+
const a = r.baseTexture.resource;
|
|
2742
|
+
return (e = a._live2d_load) != null || (a._live2d_load = new Promise((n, o) => {
|
|
2743
|
+
const l = (h) => {
|
|
2744
|
+
a.source.removeEventListener("error", l);
|
|
2745
|
+
const u = new Error("Texture loading error");
|
|
2746
|
+
u.event = h, o(u);
|
|
2747
|
+
};
|
|
2748
|
+
a.source.addEventListener("error", l), a.load().then(() => n(r)).catch(l);
|
|
2749
|
+
})), a._live2d_load;
|
|
2750
|
+
}
|
|
2751
|
+
const ae = "Live2DFactory", xe = (s, t) => b(void 0, null, function* () {
|
|
2752
|
+
if (typeof s.source == "string") {
|
|
2753
|
+
const e = yield X.load({
|
|
2754
|
+
url: s.source,
|
|
2755
|
+
type: "json",
|
|
2756
|
+
target: s.live2dModel
|
|
2757
|
+
});
|
|
2758
|
+
e.url = s.source, s.source = e, s.live2dModel.emit("settingsJSONLoaded", e);
|
|
2759
|
+
}
|
|
2760
|
+
return t();
|
|
2761
|
+
}), Pe = (s, t) => b(void 0, null, function* () {
|
|
2762
|
+
if (s.source instanceof Gt)
|
|
2763
|
+
return s.settings = s.source, t();
|
|
2764
|
+
if (typeof s.source == "object") {
|
|
2765
|
+
const e = w.findRuntime(s.source);
|
|
2766
|
+
if (e) {
|
|
2767
|
+
const i = e.createModelSettings(s.source);
|
|
2768
|
+
return s.settings = i, s.live2dModel.emit("settingsLoaded", i), t();
|
|
2769
|
+
}
|
|
2770
|
+
}
|
|
2771
|
+
throw new TypeError("Unknown settings format.");
|
|
2772
|
+
}), Me = (s, t) => {
|
|
2773
|
+
if (s.settings) {
|
|
2774
|
+
const e = w.findRuntime(s.settings);
|
|
2775
|
+
if (e)
|
|
2776
|
+
return e.ready().then(t);
|
|
2777
|
+
}
|
|
2778
|
+
return t();
|
|
2779
|
+
}, Ce = (s, t) => b(void 0, null, function* () {
|
|
2780
|
+
yield t();
|
|
2781
|
+
const e = s.internalModel;
|
|
2782
|
+
if (e) {
|
|
2783
|
+
const i = s.settings, r = w.findRuntime(i);
|
|
2784
|
+
if (r) {
|
|
2785
|
+
const a = [];
|
|
2786
|
+
i.pose && a.push(X.load({
|
|
2787
|
+
settings: i,
|
|
2788
|
+
url: i.pose,
|
|
2789
|
+
type: "json",
|
|
2790
|
+
target: e
|
|
2791
|
+
}).then((n) => {
|
|
2792
|
+
e.pose = r.createPose(e.coreModel, n), s.live2dModel.emit("poseLoaded", e.pose);
|
|
2793
|
+
}).catch((n) => {
|
|
2794
|
+
s.live2dModel.emit("poseLoadError", n), C.warn(ae, "Failed to load pose.", n);
|
|
2795
|
+
})), i.physics && a.push(X.load({
|
|
2796
|
+
settings: i,
|
|
2797
|
+
url: i.physics,
|
|
2798
|
+
type: "json",
|
|
2799
|
+
target: e
|
|
2800
|
+
}).then((n) => {
|
|
2801
|
+
e.physics = r.createPhysics(e.coreModel, n), s.live2dModel.emit("physicsLoaded", e.physics);
|
|
2802
|
+
}).catch((n) => {
|
|
2803
|
+
s.live2dModel.emit("physicsLoadError", n), C.warn(ae, "Failed to load physics.", n);
|
|
2804
|
+
})), a.length && (yield Promise.all(a));
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
}), Se = (s, t) => b(void 0, null, function* () {
|
|
2808
|
+
if (s.settings) {
|
|
2809
|
+
const e = s.live2dModel, i = s.settings.textures.map((r) => {
|
|
2810
|
+
const a = s.settings.resolveURL(r);
|
|
2811
|
+
return qi(a, { crossOrigin: s.options.crossOrigin });
|
|
2812
|
+
});
|
|
2813
|
+
if (yield t(), s.internalModel)
|
|
2814
|
+
e.internalModel = s.internalModel, e.emit("modelLoaded", s.internalModel);
|
|
2815
|
+
else
|
|
2816
|
+
throw new TypeError("Missing internal model.");
|
|
2817
|
+
e.textures = yield Promise.all(i), e.emit("textureLoaded", e.textures);
|
|
2818
|
+
} else
|
|
2819
|
+
throw new TypeError("Missing settings.");
|
|
2820
|
+
}), be = (s, t) => b(void 0, null, function* () {
|
|
2821
|
+
const e = s.settings;
|
|
2822
|
+
if (e instanceof Gt) {
|
|
2823
|
+
const i = w.findRuntime(e);
|
|
2824
|
+
if (!i)
|
|
2825
|
+
throw new TypeError("Unknown model settings.");
|
|
2826
|
+
const r = yield X.load({
|
|
2827
|
+
settings: e,
|
|
2828
|
+
url: e.moc,
|
|
2829
|
+
type: "arraybuffer",
|
|
2830
|
+
target: s.live2dModel
|
|
2831
|
+
});
|
|
2832
|
+
if (!i.isValidMoc(r))
|
|
2833
|
+
throw new Error("Invalid moc data");
|
|
2834
|
+
const a = i.createCoreModel(r);
|
|
2835
|
+
return s.internalModel = i.createInternalModel(a, e, s.options), t();
|
|
2836
|
+
}
|
|
2837
|
+
throw new TypeError("Missing settings.");
|
|
2838
|
+
}), L = class {
|
|
2839
|
+
static registerRuntime(s) {
|
|
2840
|
+
L.runtimes.push(s), L.runtimes.sort((t, e) => e.version - t.version);
|
|
2841
|
+
}
|
|
2842
|
+
static findRuntime(s) {
|
|
2843
|
+
for (const t of L.runtimes)
|
|
2844
|
+
if (t.test(s))
|
|
2845
|
+
return t;
|
|
2846
|
+
}
|
|
2847
|
+
static setupLive2DModel(s, t, e) {
|
|
2848
|
+
return b(this, null, function* () {
|
|
2849
|
+
const i = new Promise((n) => s.once("textureLoaded", n)), r = new Promise((n) => s.once("modelLoaded", n)), a = Promise.all([i, r]).then(() => s.emit("ready"));
|
|
2850
|
+
yield ve(L.live2DModelMiddlewares, {
|
|
2851
|
+
live2dModel: s,
|
|
2852
|
+
source: t,
|
|
2853
|
+
options: e || {}
|
|
2854
|
+
}), yield a, s.emit("load");
|
|
2855
|
+
});
|
|
2856
|
+
}
|
|
2857
|
+
static loadMotion(s, t, e) {
|
|
2858
|
+
var i, r;
|
|
2859
|
+
const a = (n) => s.emit("motionLoadError", t, e, n);
|
|
2860
|
+
try {
|
|
2861
|
+
const n = (i = s.definitions[t]) == null ? void 0 : i[e];
|
|
2862
|
+
if (!n)
|
|
2863
|
+
return Promise.resolve(void 0);
|
|
2864
|
+
s.listeners("destroy").includes(L.releaseTasks) || s.once("destroy", L.releaseTasks);
|
|
2865
|
+
let o = L.motionTasksMap.get(s);
|
|
2866
|
+
o || (o = {}, L.motionTasksMap.set(s, o));
|
|
2867
|
+
let l = o[t];
|
|
2868
|
+
l || (l = [], o[t] = l);
|
|
2869
|
+
const h = s.getMotionFile(n);
|
|
2870
|
+
return (r = l[e]) != null || (l[e] = X.load({
|
|
2871
|
+
url: h,
|
|
2872
|
+
settings: s.settings,
|
|
2873
|
+
type: s.motionDataType,
|
|
2874
|
+
target: s
|
|
2875
|
+
}).then((u) => {
|
|
2876
|
+
var c;
|
|
2877
|
+
const d = (c = L.motionTasksMap.get(s)) == null ? void 0 : c[t];
|
|
2878
|
+
d && delete d[e];
|
|
2879
|
+
const _ = s.createMotion(u, t, n);
|
|
2880
|
+
return s.emit("motionLoaded", t, e, _), _;
|
|
2881
|
+
}).catch((u) => {
|
|
2882
|
+
C.warn(s.tag, `Failed to load motion: ${h}
|
|
2883
|
+
`, u), a(u);
|
|
2884
|
+
})), l[e];
|
|
2885
|
+
} catch (n) {
|
|
2886
|
+
C.warn(s.tag, `Failed to load motion at "${t}"[${e}]
|
|
2887
|
+
`, n), a(n);
|
|
2888
|
+
}
|
|
2889
|
+
return Promise.resolve(void 0);
|
|
2890
|
+
}
|
|
2891
|
+
static loadExpression(s, t) {
|
|
2892
|
+
var e;
|
|
2893
|
+
const i = (r) => s.emit("expressionLoadError", t, r);
|
|
2894
|
+
try {
|
|
2895
|
+
const r = s.definitions[t];
|
|
2896
|
+
if (!r)
|
|
2897
|
+
return Promise.resolve(void 0);
|
|
2898
|
+
s.listeners("destroy").includes(L.releaseTasks) || s.once("destroy", L.releaseTasks);
|
|
2899
|
+
let a = L.expressionTasksMap.get(s);
|
|
2900
|
+
a || (a = [], L.expressionTasksMap.set(s, a));
|
|
2901
|
+
const n = s.getExpressionFile(r);
|
|
2902
|
+
return (e = a[t]) != null || (a[t] = X.load({
|
|
2903
|
+
url: n,
|
|
2904
|
+
settings: s.settings,
|
|
2905
|
+
type: "json",
|
|
2906
|
+
target: s
|
|
2907
|
+
}).then((o) => {
|
|
2908
|
+
const l = L.expressionTasksMap.get(s);
|
|
2909
|
+
l && delete l[t];
|
|
2910
|
+
const h = s.createExpression(o, r);
|
|
2911
|
+
return s.emit("expressionLoaded", t, h), h;
|
|
2912
|
+
}).catch((o) => {
|
|
2913
|
+
C.warn(s.tag, `Failed to load expression: ${n}
|
|
2914
|
+
`, o), i(o);
|
|
2915
|
+
})), a[t];
|
|
2916
|
+
} catch (r) {
|
|
2917
|
+
C.warn(s.tag, `Failed to load expression at [${t}]
|
|
2918
|
+
`, r), i(r);
|
|
2919
|
+
}
|
|
2920
|
+
return Promise.resolve(void 0);
|
|
2921
|
+
}
|
|
2922
|
+
static releaseTasks() {
|
|
2923
|
+
this instanceof jt ? L.motionTasksMap.delete(this) : L.expressionTasksMap.delete(this);
|
|
2924
|
+
}
|
|
2925
|
+
};
|
|
2926
|
+
let w = L;
|
|
2927
|
+
w.runtimes = [];
|
|
2928
|
+
w.urlToJSON = xe;
|
|
2929
|
+
w.jsonToSettings = Pe;
|
|
2930
|
+
w.waitUntilReady = Me;
|
|
2931
|
+
w.setupOptionals = Ce;
|
|
2932
|
+
w.setupEssentials = Se;
|
|
2933
|
+
w.createInternalModel = be;
|
|
2934
|
+
w.live2DModelMiddlewares = [
|
|
2935
|
+
xe,
|
|
2936
|
+
Pe,
|
|
2937
|
+
Me,
|
|
2938
|
+
Ce,
|
|
2939
|
+
Se,
|
|
2940
|
+
be
|
|
2941
|
+
];
|
|
2942
|
+
w.motionTasksMap = /* @__PURE__ */ new WeakMap();
|
|
2943
|
+
w.expressionTasksMap = /* @__PURE__ */ new WeakMap();
|
|
2944
|
+
jt.prototype._loadMotion = function(s, t) {
|
|
2945
|
+
return w.loadMotion(this, s, t);
|
|
2946
|
+
};
|
|
2947
|
+
ye.prototype._loadExpression = function(s) {
|
|
2948
|
+
return w.loadExpression(this, s);
|
|
2949
|
+
};
|
|
2950
|
+
class $i {
|
|
2951
|
+
constructor() {
|
|
2952
|
+
this._autoInteract = !1;
|
|
2953
|
+
}
|
|
2954
|
+
get autoInteract() {
|
|
2955
|
+
return this._autoInteract;
|
|
2956
|
+
}
|
|
2957
|
+
set autoInteract(t) {
|
|
2958
|
+
t !== this._autoInteract && (t ? this.on("pointertap", ne, this) : this.off("pointertap", ne, this), this._autoInteract = t);
|
|
2959
|
+
}
|
|
2960
|
+
registerInteraction(t) {
|
|
2961
|
+
t !== this.interactionManager && (this.unregisterInteraction(), this._autoInteract && t && (this.interactionManager = t, t.on("pointermove", oe, this)));
|
|
2962
|
+
}
|
|
2963
|
+
unregisterInteraction() {
|
|
2964
|
+
var t;
|
|
2965
|
+
this.interactionManager && ((t = this.interactionManager) == null || t.off("pointermove", oe, this), this.interactionManager = void 0);
|
|
2966
|
+
}
|
|
2967
|
+
}
|
|
2968
|
+
function ne(s) {
|
|
2969
|
+
this.tap(s.data.global.x, s.data.global.y);
|
|
2970
|
+
}
|
|
2971
|
+
function oe(s) {
|
|
2972
|
+
this.focus(s.data.global.x, s.data.global.y);
|
|
2973
|
+
}
|
|
2974
|
+
class Ji extends Ee {
|
|
2975
|
+
}
|
|
2976
|
+
const D = new Te(), Zi = new pt();
|
|
2977
|
+
let G;
|
|
2978
|
+
class Ki extends Ie {
|
|
2979
|
+
constructor(t) {
|
|
2980
|
+
super(), this.tag = "Live2DModel(uninitialized)", this.textures = [], this.transform = new Ji(), this.anchor = new Le(this.onAnchorChange, this, 0, 0), this.glContextID = -1, this.elapsedTime = performance.now(), this.deltaTime = 0, this._autoUpdate = !1, this.once("modelLoaded", () => this.init(t));
|
|
2981
|
+
}
|
|
2982
|
+
static from(t, e) {
|
|
2983
|
+
const i = new this(e);
|
|
2984
|
+
return w.setupLive2DModel(i, t, e).then(() => i);
|
|
2985
|
+
}
|
|
2986
|
+
static fromSync(t, e) {
|
|
2987
|
+
const i = new this(e);
|
|
2988
|
+
return w.setupLive2DModel(i, t, e).then(e?.onLoad).catch(e?.onError), i;
|
|
2989
|
+
}
|
|
2990
|
+
static registerTicker(t) {
|
|
2991
|
+
G = t;
|
|
2992
|
+
}
|
|
2993
|
+
get autoUpdate() {
|
|
2994
|
+
return this._autoUpdate;
|
|
2995
|
+
}
|
|
2996
|
+
set autoUpdate(t) {
|
|
2997
|
+
var e;
|
|
2998
|
+
G || (G = (e = window.PIXI) == null ? void 0 : e.Ticker), t ? this._destroyed || (G ? (G.shared.add(this.onTickerUpdate, this), this._autoUpdate = !0) : C.warn(this.tag, "No Ticker registered, please call Live2DModel.registerTicker(Ticker).")) : (G?.shared.remove(this.onTickerUpdate, this), this._autoUpdate = !1);
|
|
2999
|
+
}
|
|
3000
|
+
init(t) {
|
|
3001
|
+
this.tag = `Live2DModel(${this.internalModel.settings.name})`;
|
|
3002
|
+
const e = Object.assign({
|
|
3003
|
+
autoUpdate: !0,
|
|
3004
|
+
autoInteract: !0
|
|
3005
|
+
}, t);
|
|
3006
|
+
e.autoInteract && (this.interactive = !0), this.autoInteract = e.autoInteract, this.autoUpdate = e.autoUpdate;
|
|
3007
|
+
}
|
|
3008
|
+
onAnchorChange() {
|
|
3009
|
+
this.pivot.set(this.anchor.x * this.internalModel.width, this.anchor.y * this.internalModel.height);
|
|
3010
|
+
}
|
|
3011
|
+
motion(t, e, i) {
|
|
3012
|
+
return e === void 0 ? this.internalModel.motionManager.startRandomMotion(t, i) : this.internalModel.motionManager.startMotion(t, e, i);
|
|
3013
|
+
}
|
|
3014
|
+
expression(t) {
|
|
3015
|
+
return this.internalModel.motionManager.expressionManager ? t === void 0 ? this.internalModel.motionManager.expressionManager.setRandomExpression() : this.internalModel.motionManager.expressionManager.setExpression(t) : Promise.resolve(!1);
|
|
3016
|
+
}
|
|
3017
|
+
focus(t, e, i = !1) {
|
|
3018
|
+
D.x = t, D.y = e, this.toModelPosition(D, D, !0);
|
|
3019
|
+
let r = D.x / this.internalModel.originalWidth * 2 - 1, a = D.y / this.internalModel.originalHeight * 2 - 1, n = Math.atan2(a, r);
|
|
3020
|
+
this.internalModel.focusController.focus(Math.cos(n), -Math.sin(n), i);
|
|
3021
|
+
}
|
|
3022
|
+
tap(t, e) {
|
|
3023
|
+
const i = this.hitTest(t, e);
|
|
3024
|
+
i.length && (C.log(this.tag, "Hit", i), this.emit("hit", i));
|
|
3025
|
+
}
|
|
3026
|
+
hitTest(t, e) {
|
|
3027
|
+
return D.x = t, D.y = e, this.toModelPosition(D, D), this.internalModel.hitTest(D.x, D.y);
|
|
3028
|
+
}
|
|
3029
|
+
toModelPosition(t, e = t.clone(), i) {
|
|
3030
|
+
return i || (this._recursivePostUpdateTransform(), this.parent ? this.displayObjectUpdateTransform() : (this.parent = this._tempDisplayObjectParent, this.displayObjectUpdateTransform(), this.parent = null)), this.transform.worldTransform.applyInverse(t, e), this.internalModel.localTransform.applyInverse(e, e), e;
|
|
3031
|
+
}
|
|
3032
|
+
containsPoint(t) {
|
|
3033
|
+
return this.getBounds(!0).contains(t.x, t.y);
|
|
3034
|
+
}
|
|
3035
|
+
_calculateBounds() {
|
|
3036
|
+
this._bounds.addFrame(this.transform, 0, 0, this.internalModel.width, this.internalModel.height);
|
|
3037
|
+
}
|
|
3038
|
+
onTickerUpdate() {
|
|
3039
|
+
this.update(G.shared.deltaMS);
|
|
3040
|
+
}
|
|
3041
|
+
update(t) {
|
|
3042
|
+
this.deltaTime += t, this.elapsedTime += t;
|
|
3043
|
+
}
|
|
3044
|
+
_render(t) {
|
|
3045
|
+
this.registerInteraction(t.plugins.interaction), t.batch.reset(), t.geometry.reset(), t.shader.reset(), t.state.reset();
|
|
3046
|
+
let e = !1;
|
|
3047
|
+
this.glContextID !== t.CONTEXT_UID && (this.glContextID = t.CONTEXT_UID, this.internalModel.updateWebGLContext(t.gl, this.glContextID), e = !0);
|
|
3048
|
+
for (let a = 0; a < this.textures.length; a++) {
|
|
3049
|
+
const n = this.textures[a];
|
|
3050
|
+
n.valid && ((e || !n.baseTexture._glTextures[this.glContextID]) && (t.gl.pixelStorei(WebGLRenderingContext.UNPACK_FLIP_Y_WEBGL, this.internalModel.textureFlipY), t.texture.bind(n.baseTexture, 0)), this.internalModel.bindTexture(a, n.baseTexture._glTextures[this.glContextID].texture), n.baseTexture.touched = t.textureGC.count);
|
|
3051
|
+
}
|
|
3052
|
+
const i = t.framebuffer.viewport;
|
|
3053
|
+
this.internalModel.viewport = [i.x, i.y, i.width, i.height], this.deltaTime && (this.internalModel.update(this.deltaTime, this.elapsedTime), this.deltaTime = 0);
|
|
3054
|
+
const r = Zi.copyFrom(t.globalUniforms.uniforms.projectionMatrix).append(this.worldTransform);
|
|
3055
|
+
this.internalModel.updateTransform(r), this.internalModel.draw(t.gl), t.state.reset(), t.texture.reset();
|
|
3056
|
+
}
|
|
3057
|
+
destroy(t) {
|
|
3058
|
+
this.emit("destroy"), this.autoUpdate = !1, this.unregisterInteraction(), t?.texture && this.textures.forEach((e) => e.destroy(t.baseTexture)), this.internalModel.destroy(), super.destroy(t);
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
fe(Ki, [$i]);
|
|
3062
|
+
const U = class {
|
|
3063
|
+
static resolveURL(s, t) {
|
|
3064
|
+
var e;
|
|
3065
|
+
const i = (e = U.filesMap[s]) == null ? void 0 : e[t];
|
|
3066
|
+
if (i === void 0)
|
|
3067
|
+
throw new Error("Cannot find this file from uploaded files: " + t);
|
|
3068
|
+
return i;
|
|
3069
|
+
}
|
|
3070
|
+
static upload(s, t) {
|
|
3071
|
+
return b(this, null, function* () {
|
|
3072
|
+
const e = {};
|
|
3073
|
+
for (const i of t.getDefinedFiles()) {
|
|
3074
|
+
const r = decodeURI(Et.resolve(t.url, i)), a = s.find((n) => n.webkitRelativePath === r);
|
|
3075
|
+
a && (e[i] = URL.createObjectURL(a));
|
|
3076
|
+
}
|
|
3077
|
+
U.filesMap[t._objectURL] = e;
|
|
3078
|
+
});
|
|
3079
|
+
}
|
|
3080
|
+
static createSettings(s) {
|
|
3081
|
+
return b(this, null, function* () {
|
|
3082
|
+
const t = s.find((n) => n.name.endsWith("model.json") || n.name.endsWith("model3.json"));
|
|
3083
|
+
if (!t)
|
|
3084
|
+
throw new TypeError("Settings file not found");
|
|
3085
|
+
const e = yield U.readText(t), i = JSON.parse(e);
|
|
3086
|
+
i.url = t.webkitRelativePath;
|
|
3087
|
+
const r = w.findRuntime(i);
|
|
3088
|
+
if (!r)
|
|
3089
|
+
throw new Error("Unknown settings JSON");
|
|
3090
|
+
const a = r.createModelSettings(i);
|
|
3091
|
+
return a._objectURL = URL.createObjectURL(t), a;
|
|
3092
|
+
});
|
|
3093
|
+
}
|
|
3094
|
+
static readText(s) {
|
|
3095
|
+
return b(this, null, function* () {
|
|
3096
|
+
return new Promise((t, e) => {
|
|
3097
|
+
const i = new FileReader();
|
|
3098
|
+
i.onload = () => t(i.result), i.onerror = e, i.readAsText(s, "utf8");
|
|
3099
|
+
});
|
|
3100
|
+
});
|
|
3101
|
+
}
|
|
3102
|
+
};
|
|
3103
|
+
let zt = U;
|
|
3104
|
+
zt.filesMap = {};
|
|
3105
|
+
zt.factory = (s, t) => b(void 0, null, function* () {
|
|
3106
|
+
if (Array.isArray(s.source) && s.source[0] instanceof File) {
|
|
3107
|
+
const e = s.source;
|
|
3108
|
+
let i = e.settings;
|
|
3109
|
+
if (!i)
|
|
3110
|
+
i = yield U.createSettings(e);
|
|
3111
|
+
else if (!i._objectURL)
|
|
3112
|
+
throw new Error('"_objectURL" must be specified in ModelSettings');
|
|
3113
|
+
i.validateFiles(e.map((r) => encodeURI(r.webkitRelativePath))), yield U.upload(e, i), i.resolveURL = function(r) {
|
|
3114
|
+
return U.resolveURL(this._objectURL, r);
|
|
3115
|
+
}, s.source = i, s.live2dModel.once("modelLoaded", (r) => {
|
|
3116
|
+
r.once("destroy", function() {
|
|
3117
|
+
const a = this.settings._objectURL;
|
|
3118
|
+
if (URL.revokeObjectURL(a), U.filesMap[a])
|
|
3119
|
+
for (const n of Object.values(U.filesMap[a]))
|
|
3120
|
+
URL.revokeObjectURL(n);
|
|
3121
|
+
delete U.filesMap[a];
|
|
3122
|
+
});
|
|
3123
|
+
});
|
|
3124
|
+
}
|
|
3125
|
+
return t();
|
|
3126
|
+
});
|
|
3127
|
+
w.live2DModelMiddlewares.unshift(zt.factory);
|
|
3128
|
+
const E = class {
|
|
3129
|
+
static unzip(s, t) {
|
|
3130
|
+
return b(this, null, function* () {
|
|
3131
|
+
const e = yield E.getFilePaths(s), i = [];
|
|
3132
|
+
for (const a of t.getDefinedFiles()) {
|
|
3133
|
+
const n = decodeURI(Et.resolve(t.url, a));
|
|
3134
|
+
e.includes(n) && i.push(n);
|
|
3135
|
+
}
|
|
3136
|
+
const r = yield E.getFiles(s, i);
|
|
3137
|
+
for (let a = 0; a < r.length; a++) {
|
|
3138
|
+
const n = i[a], o = r[a];
|
|
3139
|
+
Object.defineProperty(o, "webkitRelativePath", {
|
|
3140
|
+
value: n
|
|
3141
|
+
});
|
|
3142
|
+
}
|
|
3143
|
+
return r;
|
|
3144
|
+
});
|
|
3145
|
+
}
|
|
3146
|
+
static createSettings(s) {
|
|
3147
|
+
return b(this, null, function* () {
|
|
3148
|
+
const e = (yield E.getFilePaths(s)).find((n) => n.endsWith("model.json") || n.endsWith("model3.json"));
|
|
3149
|
+
if (!e)
|
|
3150
|
+
throw new Error("Settings file not found");
|
|
3151
|
+
const i = yield E.readText(s, e);
|
|
3152
|
+
if (!i)
|
|
3153
|
+
throw new Error("Empty settings file: " + e);
|
|
3154
|
+
const r = JSON.parse(i);
|
|
3155
|
+
r.url = e;
|
|
3156
|
+
const a = w.findRuntime(r);
|
|
3157
|
+
if (!a)
|
|
3158
|
+
throw new Error("Unknown settings JSON");
|
|
3159
|
+
return a.createModelSettings(r);
|
|
3160
|
+
});
|
|
3161
|
+
}
|
|
3162
|
+
static zipReader(s, t) {
|
|
3163
|
+
return b(this, null, function* () {
|
|
3164
|
+
throw new Error("Not implemented");
|
|
3165
|
+
});
|
|
3166
|
+
}
|
|
3167
|
+
static getFilePaths(s) {
|
|
3168
|
+
return b(this, null, function* () {
|
|
3169
|
+
throw new Error("Not implemented");
|
|
3170
|
+
});
|
|
3171
|
+
}
|
|
3172
|
+
static getFiles(s, t) {
|
|
3173
|
+
return b(this, null, function* () {
|
|
3174
|
+
throw new Error("Not implemented");
|
|
3175
|
+
});
|
|
3176
|
+
}
|
|
3177
|
+
static readText(s, t) {
|
|
3178
|
+
return b(this, null, function* () {
|
|
3179
|
+
throw new Error("Not implemented");
|
|
3180
|
+
});
|
|
3181
|
+
}
|
|
3182
|
+
static releaseReader(s) {
|
|
3183
|
+
}
|
|
3184
|
+
};
|
|
3185
|
+
let yt = E;
|
|
3186
|
+
yt.ZIP_PROTOCOL = "zip://";
|
|
3187
|
+
yt.uid = 0;
|
|
3188
|
+
yt.factory = (s, t) => b(void 0, null, function* () {
|
|
3189
|
+
const e = s.source;
|
|
3190
|
+
let i, r, a;
|
|
3191
|
+
if (typeof e == "string" && (e.endsWith(".zip") || e.startsWith(E.ZIP_PROTOCOL)) ? (e.startsWith(E.ZIP_PROTOCOL) ? i = e.slice(E.ZIP_PROTOCOL.length) : i = e, r = yield X.load({
|
|
3192
|
+
url: i,
|
|
3193
|
+
type: "blob",
|
|
3194
|
+
target: s.live2dModel
|
|
3195
|
+
})) : Array.isArray(e) && e.length === 1 && e[0] instanceof File && e[0].name.endsWith(".zip") && (r = e[0], i = URL.createObjectURL(r), a = e.settings), r) {
|
|
3196
|
+
if (!r.size)
|
|
3197
|
+
throw new Error("Empty zip file");
|
|
3198
|
+
const n = yield E.zipReader(r, i);
|
|
3199
|
+
a || (a = yield E.createSettings(n)), a._objectURL = E.ZIP_PROTOCOL + E.uid + "/" + a.url;
|
|
3200
|
+
const o = yield E.unzip(n, a);
|
|
3201
|
+
o.settings = a, s.source = o, i.startsWith("blob:") && s.live2dModel.once("modelLoaded", (l) => {
|
|
3202
|
+
l.once("destroy", function() {
|
|
3203
|
+
URL.revokeObjectURL(i);
|
|
3204
|
+
});
|
|
3205
|
+
}), E.releaseReader(n);
|
|
3206
|
+
}
|
|
3207
|
+
return t();
|
|
3208
|
+
});
|
|
3209
|
+
w.live2DModelMiddlewares.unshift(yt.factory);
|
|
3210
|
+
if (!window.Live2DCubismCore)
|
|
3211
|
+
throw new Error("Could not find Cubism 4 runtime. This plugin requires live2dcubismcore.js to be loaded.");
|
|
3212
|
+
class Qi extends ye {
|
|
3213
|
+
constructor(t, e) {
|
|
3214
|
+
var i;
|
|
3215
|
+
super(t, e), this.queueManager = new Ut(), this.definitions = (i = t.expressions) != null ? i : [], this.init();
|
|
3216
|
+
}
|
|
3217
|
+
isFinished() {
|
|
3218
|
+
return this.queueManager.isFinished();
|
|
3219
|
+
}
|
|
3220
|
+
getExpressionIndex(t) {
|
|
3221
|
+
return this.definitions.findIndex((e) => e.Name === t);
|
|
3222
|
+
}
|
|
3223
|
+
getExpressionFile(t) {
|
|
3224
|
+
return t.File;
|
|
3225
|
+
}
|
|
3226
|
+
createExpression(t, e) {
|
|
3227
|
+
return Rt.create(t);
|
|
3228
|
+
}
|
|
3229
|
+
_setExpression(t) {
|
|
3230
|
+
return this.queueManager.startMotion(t, !1, performance.now());
|
|
3231
|
+
}
|
|
3232
|
+
stopAllExpressions() {
|
|
3233
|
+
this.queueManager.stopAllMotions();
|
|
3234
|
+
}
|
|
3235
|
+
updateParameters(t, e) {
|
|
3236
|
+
return this.queueManager.doUpdateMotion(t, e);
|
|
3237
|
+
}
|
|
3238
|
+
}
|
|
3239
|
+
class it extends Gt {
|
|
3240
|
+
constructor(t) {
|
|
3241
|
+
if (super(t), !it.isValidJSON(t))
|
|
3242
|
+
throw new TypeError("Invalid JSON.");
|
|
3243
|
+
Object.assign(this, new _e(t));
|
|
3244
|
+
}
|
|
3245
|
+
static isValidJSON(t) {
|
|
3246
|
+
var e;
|
|
3247
|
+
return !!t?.FileReferences && typeof t.FileReferences.Moc == "string" && ((e = t.FileReferences.Textures) == null ? void 0 : e.length) > 0 && t.FileReferences.Textures.every((i) => typeof i == "string");
|
|
3248
|
+
}
|
|
3249
|
+
replaceFiles(t) {
|
|
3250
|
+
if (super.replaceFiles(t), this.motions)
|
|
3251
|
+
for (const [e, i] of Object.entries(this.motions))
|
|
3252
|
+
for (let r = 0; r < i.length; r++)
|
|
3253
|
+
i[r].File = t(i[r].File, `motions.${e}[${r}].File`), i[r].Sound !== void 0 && (i[r].Sound = t(i[r].Sound, `motions.${e}[${r}].Sound`));
|
|
3254
|
+
if (this.expressions)
|
|
3255
|
+
for (let e = 0; e < this.expressions.length; e++)
|
|
3256
|
+
this.expressions[e].File = t(this.expressions[e].File, `expressions[${e}].File`);
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
3259
|
+
fe(it, [_e]);
|
|
3260
|
+
class ts extends jt {
|
|
3261
|
+
constructor(t, e) {
|
|
3262
|
+
var i;
|
|
3263
|
+
super(t, e), this.groups = { idle: "Idle" }, this.motionDataType = "json", this.queueManager = new Ut(), this.definitions = (i = t.motions) != null ? i : {}, this.eyeBlinkIds = t.getEyeBlinkParameters() || [], this.lipSyncIds = t.getLipSyncParameters() || [], this.init(e);
|
|
3264
|
+
}
|
|
3265
|
+
init(t) {
|
|
3266
|
+
super.init(t), this.settings.expressions && (this.expressionManager = new Qi(this.settings, t)), this.queueManager.setEventCallback((e, i, r) => {
|
|
3267
|
+
this.emit("motion:" + i);
|
|
3268
|
+
});
|
|
3269
|
+
}
|
|
3270
|
+
isFinished() {
|
|
3271
|
+
return this.queueManager.isFinished();
|
|
3272
|
+
}
|
|
3273
|
+
_startMotion(t, e) {
|
|
3274
|
+
return t.setFinishedMotionHandler(e), this.queueManager.stopAllMotions(), this.queueManager.startMotion(t, !1, performance.now());
|
|
3275
|
+
}
|
|
3276
|
+
_stopAllMotions() {
|
|
3277
|
+
this.queueManager.stopAllMotions();
|
|
3278
|
+
}
|
|
3279
|
+
createMotion(t, e, i) {
|
|
3280
|
+
const r = kt.create(t), a = new me(t), n = (e === this.groups.idle ? F.idleMotionFadingDuration : F.motionFadingDuration) / 1e3;
|
|
3281
|
+
return a.getMotionFadeInTime() === void 0 && r.setFadeInTime(i.FadeInTime > 0 ? i.FadeInTime : n), a.getMotionFadeOutTime() === void 0 && r.setFadeOutTime(i.FadeOutTime > 0 ? i.FadeOutTime : n), r.setEffectIds(this.eyeBlinkIds, this.lipSyncIds), r;
|
|
3282
|
+
}
|
|
3283
|
+
getMotionFile(t) {
|
|
3284
|
+
return t.File;
|
|
3285
|
+
}
|
|
3286
|
+
getMotionName(t) {
|
|
3287
|
+
return t.File;
|
|
3288
|
+
}
|
|
3289
|
+
getSoundFile(t) {
|
|
3290
|
+
return t.Sound;
|
|
3291
|
+
}
|
|
3292
|
+
updateParameters(t, e) {
|
|
3293
|
+
return this.queueManager.doUpdateMotion(t, e);
|
|
3294
|
+
}
|
|
3295
|
+
destroy() {
|
|
3296
|
+
super.destroy(), this.queueManager.release(), this.queueManager = void 0;
|
|
3297
|
+
}
|
|
3298
|
+
}
|
|
3299
|
+
const le = new R();
|
|
3300
|
+
class es extends Hi {
|
|
3301
|
+
constructor(t, e, i) {
|
|
3302
|
+
super(), this.lipSync = !0, this.breath = Ft.create(), this.renderer = new pe(), this.idParamAngleX = Ti, this.idParamAngleY = Ei, this.idParamAngleZ = Fi, this.idParamEyeBallX = Di, this.idParamEyeBallY = Ai, this.idParamBodyAngleX = Bi, this.idParamBreath = Ri, this.pixelsPerUnit = 1, this.centeringTransform = new pt(), this.coreModel = t, this.settings = e, this.motionManager = new ts(e, i), this.init();
|
|
3303
|
+
}
|
|
3304
|
+
init() {
|
|
3305
|
+
var t;
|
|
3306
|
+
super.init(), ((t = this.settings.getEyeBlinkParameters()) == null ? void 0 : t.length) > 0 && (this.eyeBlink = ue.create(this.settings)), this.breath.setParameters([
|
|
3307
|
+
new st(this.idParamAngleX, 0, 15, 6.5345, 0.5),
|
|
3308
|
+
new st(this.idParamAngleY, 0, 8, 3.5345, 0.5),
|
|
3309
|
+
new st(this.idParamAngleZ, 0, 10, 5.5345, 0.5),
|
|
3310
|
+
new st(this.idParamBodyAngleX, 0, 4, 15.5345, 0.5),
|
|
3311
|
+
new st(this.idParamBreath, 0, 0.5, 3.2345, 0.5)
|
|
3312
|
+
]), this.renderer.initialize(this.coreModel), this.renderer.setIsPremultipliedAlpha(!0);
|
|
3313
|
+
}
|
|
3314
|
+
getSize() {
|
|
3315
|
+
return [this.coreModel.getModel().canvasinfo.CanvasWidth, this.coreModel.getModel().canvasinfo.CanvasHeight];
|
|
3316
|
+
}
|
|
3317
|
+
getLayout() {
|
|
3318
|
+
const t = {};
|
|
3319
|
+
if (this.settings.layout)
|
|
3320
|
+
for (const e of Object.keys(this.settings.layout)) {
|
|
3321
|
+
const i = e.charAt(0).toLowerCase() + e.slice(1);
|
|
3322
|
+
t[i] = this.settings.layout[e];
|
|
3323
|
+
}
|
|
3324
|
+
return t;
|
|
3325
|
+
}
|
|
3326
|
+
setupLayout() {
|
|
3327
|
+
super.setupLayout(), this.pixelsPerUnit = this.coreModel.getModel().canvasinfo.PixelsPerUnit, this.centeringTransform.scale(this.pixelsPerUnit, this.pixelsPerUnit).translate(this.originalWidth / 2, this.originalHeight / 2);
|
|
3328
|
+
}
|
|
3329
|
+
updateWebGLContext(t, e) {
|
|
3330
|
+
this.renderer.firstDraw = !0, this.renderer._bufferData = {
|
|
3331
|
+
vertex: null,
|
|
3332
|
+
uv: null,
|
|
3333
|
+
index: null
|
|
3334
|
+
}, this.renderer.startUp(t), this.renderer._clippingManager._currentFrameNo = e, this.renderer._clippingManager._maskTexture = void 0, et.getInstance()._shaderSets = [];
|
|
3335
|
+
}
|
|
3336
|
+
bindTexture(t, e) {
|
|
3337
|
+
this.renderer.bindTexture(t, e);
|
|
3338
|
+
}
|
|
3339
|
+
getHitAreaDefs() {
|
|
3340
|
+
var t, e;
|
|
3341
|
+
return (e = (t = this.settings.hitAreas) == null ? void 0 : t.map((i) => ({
|
|
3342
|
+
id: i.Id,
|
|
3343
|
+
name: i.Name,
|
|
3344
|
+
index: this.coreModel.getDrawableIndex(i.Id)
|
|
3345
|
+
}))) != null ? e : [];
|
|
3346
|
+
}
|
|
3347
|
+
getDrawableIDs() {
|
|
3348
|
+
return this.coreModel.getDrawableIds();
|
|
3349
|
+
}
|
|
3350
|
+
getDrawableIndex(t) {
|
|
3351
|
+
return this.coreModel.getDrawableIndex(t);
|
|
3352
|
+
}
|
|
3353
|
+
getDrawableVertices(t) {
|
|
3354
|
+
if (typeof t == "string" && (t = this.coreModel.getDrawableIndex(t), t === -1))
|
|
3355
|
+
throw new TypeError("Unable to find drawable ID: " + t);
|
|
3356
|
+
const e = this.coreModel.getDrawableVertices(t).slice();
|
|
3357
|
+
for (let i = 0; i < e.length; i += 2)
|
|
3358
|
+
e[i] = e[i] * this.pixelsPerUnit + this.originalWidth / 2, e[i + 1] = -e[i + 1] * this.pixelsPerUnit + this.originalHeight / 2;
|
|
3359
|
+
return e;
|
|
3360
|
+
}
|
|
3361
|
+
updateTransform(t) {
|
|
3362
|
+
this.drawingMatrix.copyFrom(this.centeringTransform).prepend(this.localTransform).prepend(t);
|
|
3363
|
+
}
|
|
3364
|
+
update(t, e) {
|
|
3365
|
+
var i, r, a, n;
|
|
3366
|
+
super.update(t, e), t /= 1e3, e /= 1e3;
|
|
3367
|
+
const o = this.coreModel;
|
|
3368
|
+
this.emit("beforeMotionUpdate");
|
|
3369
|
+
const l = this.motionManager.update(this.coreModel, e);
|
|
3370
|
+
this.emit("afterMotionUpdate"), o.saveParameters(), (i = this.motionManager.expressionManager) == null || i.update(o, e), l || (r = this.eyeBlink) == null || r.updateParameters(o, t), this.updateFocus(), this.updateNaturalMovements(t * 1e3, e * 1e3), (a = this.physics) == null || a.evaluate(o, t), (n = this.pose) == null || n.updateParameters(o, t), this.emit("beforeModelUpdate"), o.update(), o.loadParameters();
|
|
3371
|
+
}
|
|
3372
|
+
updateFocus() {
|
|
3373
|
+
this.coreModel.addParameterValueById(this.idParamEyeBallX, this.focusController.x), this.coreModel.addParameterValueById(this.idParamEyeBallY, this.focusController.y), this.coreModel.addParameterValueById(this.idParamAngleX, this.focusController.x * 30), this.coreModel.addParameterValueById(this.idParamAngleY, this.focusController.y * 30), this.coreModel.addParameterValueById(this.idParamAngleZ, this.focusController.x * this.focusController.y * -30), this.coreModel.addParameterValueById(this.idParamBodyAngleX, this.focusController.x * 10);
|
|
3374
|
+
}
|
|
3375
|
+
updateNaturalMovements(t, e) {
|
|
3376
|
+
var i;
|
|
3377
|
+
(i = this.breath) == null || i.updateParameters(this.coreModel, t / 1e3);
|
|
3378
|
+
}
|
|
3379
|
+
draw(t) {
|
|
3380
|
+
const e = this.drawingMatrix, i = le.getArray();
|
|
3381
|
+
i[0] = e.a, i[1] = e.b, i[4] = -e.c, i[5] = -e.d, i[12] = e.tx, i[13] = e.ty, this.renderer.setMvpMatrix(le), this.renderer.setRenderState(t.getParameter(t.FRAMEBUFFER_BINDING), this.viewport), this.renderer.drawModel();
|
|
3382
|
+
}
|
|
3383
|
+
destroy() {
|
|
3384
|
+
super.destroy(), this.renderer.release(), this.coreModel.release(), this.renderer = void 0, this.coreModel = void 0;
|
|
3385
|
+
}
|
|
3386
|
+
}
|
|
3387
|
+
let mt, he = 20;
|
|
3388
|
+
function is() {
|
|
3389
|
+
return ht.isStarted() ? Promise.resolve() : (mt ?? (mt = new Promise((s, t) => {
|
|
3390
|
+
function e() {
|
|
3391
|
+
try {
|
|
3392
|
+
ss(), s();
|
|
3393
|
+
} catch (i) {
|
|
3394
|
+
if (he--, he < 0) {
|
|
3395
|
+
const r = new Error("Failed to start up Cubism 4 framework.");
|
|
3396
|
+
r.cause = i, t(r);
|
|
3397
|
+
return;
|
|
3398
|
+
}
|
|
3399
|
+
C.log("Cubism4", "Startup failed, retrying 10ms later..."), setTimeout(e, 10);
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
e();
|
|
3403
|
+
})), mt);
|
|
3404
|
+
}
|
|
3405
|
+
function ss(s) {
|
|
3406
|
+
s = Object.assign({
|
|
3407
|
+
logFunction: console.log,
|
|
3408
|
+
loggingLevel: Y.LogLevel_Verbose
|
|
3409
|
+
}, s), ht.startUp(s), ht.initialize();
|
|
3410
|
+
}
|
|
3411
|
+
w.registerRuntime({
|
|
3412
|
+
version: 4,
|
|
3413
|
+
ready: is,
|
|
3414
|
+
test(s) {
|
|
3415
|
+
return s instanceof it || it.isValidJSON(s);
|
|
3416
|
+
},
|
|
3417
|
+
isValidMoc(s) {
|
|
3418
|
+
if (s.byteLength < 4)
|
|
3419
|
+
return !1;
|
|
3420
|
+
const t = new Int8Array(s, 0, 4);
|
|
3421
|
+
return String.fromCharCode(...t) === "MOC3";
|
|
3422
|
+
},
|
|
3423
|
+
createModelSettings(s) {
|
|
3424
|
+
return new it(s);
|
|
3425
|
+
},
|
|
3426
|
+
createCoreModel(s) {
|
|
3427
|
+
const t = Bt.create(s);
|
|
3428
|
+
try {
|
|
3429
|
+
const e = t.createModel();
|
|
3430
|
+
return e.__moc = t, e;
|
|
3431
|
+
} catch (e) {
|
|
3432
|
+
try {
|
|
3433
|
+
t.release();
|
|
3434
|
+
} catch {
|
|
3435
|
+
}
|
|
3436
|
+
throw e;
|
|
3437
|
+
}
|
|
3438
|
+
},
|
|
3439
|
+
createInternalModel(s, t, e) {
|
|
3440
|
+
const i = new es(s, t, e), r = s;
|
|
3441
|
+
return r.__moc && (i.__moc = r.__moc, delete r.__moc, i.once("destroy", rs)), i;
|
|
3442
|
+
},
|
|
3443
|
+
createPhysics(s, t) {
|
|
3444
|
+
return Vt.create(t);
|
|
3445
|
+
},
|
|
3446
|
+
createPose(s, t) {
|
|
3447
|
+
return Dt.create(t);
|
|
3448
|
+
}
|
|
3449
|
+
});
|
|
3450
|
+
function rs() {
|
|
3451
|
+
var s;
|
|
3452
|
+
(s = this.__moc) == null || s.release();
|
|
3453
|
+
}
|
|
3454
|
+
export {
|
|
3455
|
+
ce as ACubismMotion,
|
|
3456
|
+
st as BreathParameterData,
|
|
3457
|
+
ct as CSM_ASSERT,
|
|
3458
|
+
xt as Constant,
|
|
3459
|
+
Qi as Cubism4ExpressionManager,
|
|
3460
|
+
es as Cubism4InternalModel,
|
|
3461
|
+
it as Cubism4ModelSettings,
|
|
3462
|
+
ts as Cubism4MotionManager,
|
|
3463
|
+
z as CubismBlendMode,
|
|
3464
|
+
Ft as CubismBreath,
|
|
3465
|
+
Mi as CubismClippingContext,
|
|
3466
|
+
Ct as CubismClippingManager_WebGL,
|
|
3467
|
+
ut as CubismConfig,
|
|
3468
|
+
dt as CubismDebug,
|
|
3469
|
+
Rt as CubismExpressionMotion,
|
|
3470
|
+
ue as CubismEyeBlink,
|
|
3471
|
+
ht as CubismFramework,
|
|
3472
|
+
qt as CubismLogDebug,
|
|
3473
|
+
tt as CubismLogError,
|
|
3474
|
+
rt as CubismLogInfo,
|
|
3475
|
+
ns as CubismLogVerbose,
|
|
3476
|
+
nt as CubismLogWarning,
|
|
3477
|
+
S as CubismMath,
|
|
3478
|
+
R as CubismMatrix44,
|
|
3479
|
+
Bt as CubismMoc,
|
|
3480
|
+
De as CubismModel,
|
|
3481
|
+
_e as CubismModelSettingsJson,
|
|
3482
|
+
de as CubismModelUserData,
|
|
3483
|
+
Ae as CubismModelUserDataJson,
|
|
3484
|
+
kt as CubismMotion,
|
|
3485
|
+
Oe as CubismMotionCurve,
|
|
3486
|
+
$ as CubismMotionCurveTarget,
|
|
3487
|
+
Ue as CubismMotionData,
|
|
3488
|
+
ke as CubismMotionEvent,
|
|
3489
|
+
me as CubismMotionJson,
|
|
3490
|
+
os as CubismMotionManager,
|
|
3491
|
+
j as CubismMotionPoint,
|
|
3492
|
+
Je as CubismMotionQueueEntry,
|
|
3493
|
+
Ut as CubismMotionQueueManager,
|
|
3494
|
+
Re as CubismMotionSegment,
|
|
3495
|
+
k as CubismMotionSegmentType,
|
|
3496
|
+
Vt as CubismPhysics,
|
|
3497
|
+
ti as CubismPhysicsInput,
|
|
3498
|
+
si as CubismPhysicsJson,
|
|
3499
|
+
ei as CubismPhysicsOutput,
|
|
3500
|
+
Ke as CubismPhysicsParticle,
|
|
3501
|
+
ii as CubismPhysicsRig,
|
|
3502
|
+
J as CubismPhysicsSource,
|
|
3503
|
+
Qe as CubismPhysicsSubRig,
|
|
3504
|
+
bt as CubismPhysicsTargetType,
|
|
3505
|
+
Dt as CubismPose,
|
|
3506
|
+
Pi as CubismRenderTextureResource,
|
|
3507
|
+
At as CubismRenderer,
|
|
3508
|
+
pe as CubismRenderer_WebGL,
|
|
3509
|
+
et as CubismShader_WebGL,
|
|
3510
|
+
at as CubismTextureColor,
|
|
3511
|
+
y as CubismVector2,
|
|
3512
|
+
Ot as EvaluationOptionFlag,
|
|
3513
|
+
q as ExpressionBlendType,
|
|
3514
|
+
ye as ExpressionManager,
|
|
3515
|
+
A as EyeState,
|
|
3516
|
+
zt as FileLoader,
|
|
3517
|
+
Ni as FocusController,
|
|
3518
|
+
ds as HitAreaBody,
|
|
3519
|
+
us as HitAreaHead,
|
|
3520
|
+
hs as HitAreaPrefix,
|
|
3521
|
+
$i as InteractionMixin,
|
|
3522
|
+
Hi as InternalModel,
|
|
3523
|
+
Ze as InvalidMotionQueueEntryHandleValue,
|
|
3524
|
+
ee as LOGICAL_HEIGHT,
|
|
3525
|
+
te as LOGICAL_WIDTH,
|
|
3526
|
+
w as Live2DFactory,
|
|
3527
|
+
X as Live2DLoader,
|
|
3528
|
+
Ki as Live2DModel,
|
|
3529
|
+
Ji as Live2DTransform,
|
|
3530
|
+
Y as LogLevel,
|
|
3531
|
+
Gt as ModelSettings,
|
|
3532
|
+
jt as MotionManager,
|
|
3533
|
+
Xi as MotionPreloadStrategy,
|
|
3534
|
+
Lt as MotionPriority,
|
|
3535
|
+
Gi as MotionState,
|
|
3536
|
+
ni as Options,
|
|
3537
|
+
Ti as ParamAngleX,
|
|
3538
|
+
Ei as ParamAngleY,
|
|
3539
|
+
Fi as ParamAngleZ,
|
|
3540
|
+
Bs as ParamArmLA,
|
|
3541
|
+
Os as ParamArmLB,
|
|
3542
|
+
Rs as ParamArmRA,
|
|
3543
|
+
ks as ParamArmRB,
|
|
3544
|
+
Ws as ParamBaseX,
|
|
3545
|
+
qs as ParamBaseY,
|
|
3546
|
+
Bi as ParamBodyAngleX,
|
|
3547
|
+
Ds as ParamBodyAngleY,
|
|
3548
|
+
As as ParamBodyAngleZ,
|
|
3549
|
+
Ri as ParamBreath,
|
|
3550
|
+
bs as ParamBrowLAngle,
|
|
3551
|
+
Is as ParamBrowLForm,
|
|
3552
|
+
Cs as ParamBrowLX,
|
|
3553
|
+
Ps as ParamBrowLY,
|
|
3554
|
+
ws as ParamBrowRAngle,
|
|
3555
|
+
Ls as ParamBrowRForm,
|
|
3556
|
+
Ss as ParamBrowRX,
|
|
3557
|
+
Ms as ParamBrowRY,
|
|
3558
|
+
Ys as ParamBustX,
|
|
3559
|
+
Hs as ParamBustY,
|
|
3560
|
+
Fs as ParamCheek,
|
|
3561
|
+
xs as ParamEyeBallForm,
|
|
3562
|
+
Di as ParamEyeBallX,
|
|
3563
|
+
Ai as ParamEyeBallY,
|
|
3564
|
+
_s as ParamEyeLOpen,
|
|
3565
|
+
fs as ParamEyeLSmile,
|
|
3566
|
+
ys as ParamEyeROpen,
|
|
3567
|
+
vs as ParamEyeRSmile,
|
|
3568
|
+
js as ParamHairBack,
|
|
3569
|
+
zs as ParamHairFluffy,
|
|
3570
|
+
Ns as ParamHairFront,
|
|
3571
|
+
Gs as ParamHairSide,
|
|
3572
|
+
Us as ParamHandL,
|
|
3573
|
+
Vs as ParamHandR,
|
|
3574
|
+
Ts as ParamMouthForm,
|
|
3575
|
+
Es as ParamMouthOpenY,
|
|
3576
|
+
$s as ParamNONE,
|
|
3577
|
+
Xs as ParamShoulderY,
|
|
3578
|
+
_t as PartData,
|
|
3579
|
+
gs as PartsArmLPrefix,
|
|
3580
|
+
ms as PartsArmPrefix,
|
|
3581
|
+
ps as PartsArmRPrefix,
|
|
3582
|
+
cs as PartsIdCore,
|
|
3583
|
+
ls as PhysicsJsonEffectiveForces,
|
|
3584
|
+
lt as ShaderNames,
|
|
3585
|
+
Z as SoundManager,
|
|
3586
|
+
Js as VERSION,
|
|
3587
|
+
ft as XHRLoader,
|
|
3588
|
+
yt as ZipLoader,
|
|
3589
|
+
fe as applyMixins,
|
|
3590
|
+
ie as clamp,
|
|
3591
|
+
F as config,
|
|
3592
|
+
Qs as copyArray,
|
|
3593
|
+
Ks as copyProperty,
|
|
3594
|
+
wt as csmRect,
|
|
3595
|
+
is as cubism4Ready,
|
|
3596
|
+
Oi as folderName,
|
|
3597
|
+
Li as fragmentShaderSrcMaskInvertedPremultipliedAlpha,
|
|
3598
|
+
Ii as fragmentShaderSrcMaskPremultipliedAlpha,
|
|
3599
|
+
wi as fragmentShaderSrcPremultipliedAlpha,
|
|
3600
|
+
Si as fragmentShaderSrcsetupMask,
|
|
3601
|
+
C as logger,
|
|
3602
|
+
Zs as rand,
|
|
3603
|
+
ki as remove,
|
|
3604
|
+
ss as startUpCubism4,
|
|
3605
|
+
bi as vertexShaderSrc,
|
|
3606
|
+
Qt as vertexShaderSrcMasked,
|
|
3607
|
+
Ci as vertexShaderSrcSetupMask
|
|
3608
|
+
};
|