untitled-pixi-live2d-engine 1.2.2 → 1.3.1
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/README.md +13 -2
- package/dist/cubism-legacy.es.js +170 -49
- package/dist/cubism-legacy.js +172 -50
- package/dist/cubism-legacy.min.js +1 -1
- package/dist/cubism.es.js +186 -57
- package/dist/cubism.js +188 -58
- package/dist/cubism.min.js +1 -1
- package/dist/index.es.js +191 -60
- package/dist/index.js +193 -61
- package/dist/index.min.js +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +56 -29
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("pixi.js")
|
|
3
|
-
})(this, (function(exports2, pixi_js
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("pixi.js")) : typeof define === "function" && define.amd ? define(["exports", "pixi.js"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory((global.PIXI = global.PIXI || {}, global.PIXI.live2d = global.PIXI.live2d || {}), global.PIXI));
|
|
3
|
+
})(this, (function(exports2, pixi_js) {
|
|
4
4
|
"use strict";var __defProp = Object.defineProperty;
|
|
5
5
|
var __defProps = Object.defineProperties;
|
|
6
6
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
@@ -108,7 +108,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
108
108
|
preserveExpressionOnMotion: true,
|
|
109
109
|
cubism: CubismFrameworkConfig
|
|
110
110
|
};
|
|
111
|
-
const VERSION = "1.
|
|
111
|
+
const VERSION = "1.3.1";
|
|
112
112
|
const logger = {
|
|
113
113
|
log(tag, ...messages) {
|
|
114
114
|
if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
|
|
@@ -827,7 +827,64 @@ var __async = (__this, __arguments, generator) => {
|
|
|
827
827
|
}
|
|
828
828
|
const TAG$2 = "SoundManager";
|
|
829
829
|
const VOLUME = 0.5;
|
|
830
|
-
|
|
830
|
+
const SOUND_ALIAS_PREFIX = "live2d-sound-";
|
|
831
|
+
let soundId = 0;
|
|
832
|
+
let pixiSoundPromise;
|
|
833
|
+
const configuredLibraries = /* @__PURE__ */ new WeakSet();
|
|
834
|
+
function configureSoundLibrary(library) {
|
|
835
|
+
if (!configuredLibraries.has(library)) {
|
|
836
|
+
try {
|
|
837
|
+
library.disableAutoPause = true;
|
|
838
|
+
} catch (e) {
|
|
839
|
+
logger.warn(TAG$2, "Failed to disable @pixi/sound auto pause.", e);
|
|
840
|
+
}
|
|
841
|
+
configuredLibraries.add(library);
|
|
842
|
+
}
|
|
843
|
+
return library;
|
|
844
|
+
}
|
|
845
|
+
function getGlobalSoundLibrary() {
|
|
846
|
+
return typeof PIXI !== "undefined" ? PIXI == null ? void 0 : PIXI.sound : void 0;
|
|
847
|
+
}
|
|
848
|
+
function resolveSoundLibrary() {
|
|
849
|
+
return __async(this, null, function* () {
|
|
850
|
+
const globalLibrary = getGlobalSoundLibrary();
|
|
851
|
+
if (globalLibrary) {
|
|
852
|
+
return configureSoundLibrary(globalLibrary);
|
|
853
|
+
}
|
|
854
|
+
pixiSoundPromise != null ? pixiSoundPromise : pixiSoundPromise = import("@pixi/sound").then(({ sound }) => configureSoundLibrary(sound)).catch((e) => {
|
|
855
|
+
logger.warn(
|
|
856
|
+
TAG$2,
|
|
857
|
+
"@pixi/sound is not available. Load pixi-sound.js before using motion sounds, speak(), or lip sync.",
|
|
858
|
+
e
|
|
859
|
+
);
|
|
860
|
+
return null;
|
|
861
|
+
});
|
|
862
|
+
return pixiSoundPromise;
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
function removeSound(library, alias) {
|
|
866
|
+
try {
|
|
867
|
+
library.remove(alias);
|
|
868
|
+
} catch (e) {
|
|
869
|
+
logger.warn(TAG$2, `Failed to remove sound "${alias}".`, e);
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
function destroySound(audio) {
|
|
873
|
+
try {
|
|
874
|
+
audio.destroy();
|
|
875
|
+
} catch (e) {
|
|
876
|
+
logger.warn(TAG$2, "Failed to destroy audio.", e);
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
function getAudioBuffer(audio) {
|
|
880
|
+
const media = audio.media;
|
|
881
|
+
const buffer = media.buffer;
|
|
882
|
+
if (!buffer || typeof buffer !== "object") {
|
|
883
|
+
return void 0;
|
|
884
|
+
}
|
|
885
|
+
const candidate = buffer;
|
|
886
|
+
return typeof candidate.getChannelData === "function" ? buffer : void 0;
|
|
887
|
+
}
|
|
831
888
|
class SoundManager {
|
|
832
889
|
/**
|
|
833
890
|
* Global volume that applies to all the sounds.
|
|
@@ -848,22 +905,47 @@ var __async = (__this, __arguments, generator) => {
|
|
|
848
905
|
*/
|
|
849
906
|
static add(file, onError) {
|
|
850
907
|
return __async(this, null, function* () {
|
|
908
|
+
let library = null;
|
|
909
|
+
let alias;
|
|
851
910
|
try {
|
|
911
|
+
library = yield resolveSoundLibrary();
|
|
912
|
+
if (!library) {
|
|
913
|
+
throw new Error("@pixi/sound is not available");
|
|
914
|
+
}
|
|
915
|
+
alias = `${SOUND_ALIAS_PREFIX}${soundId++}`;
|
|
916
|
+
const soundLibrary = library;
|
|
917
|
+
const soundAlias = alias;
|
|
852
918
|
const task = new Promise((resolve, reject) => {
|
|
853
|
-
const
|
|
919
|
+
const audio2 = soundLibrary.add(soundAlias, {
|
|
854
920
|
url: file,
|
|
855
921
|
volume: this._volume,
|
|
856
922
|
preload: true,
|
|
857
|
-
loaded: () => {
|
|
858
|
-
if (
|
|
923
|
+
loaded: (error, loadedAudio) => {
|
|
924
|
+
if (error) {
|
|
925
|
+
reject(error);
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
928
|
+
const sound = loadedAudio != null ? loadedAudio : audio2;
|
|
929
|
+
if (!sound) {
|
|
930
|
+
reject(new Error(`Error: ${file} failed to load`));
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
if (!getAudioBuffer(sound)) {
|
|
859
934
|
reject(new Error(`Error: ${file} is not WebAudioMedia`));
|
|
935
|
+
return;
|
|
860
936
|
}
|
|
861
|
-
resolve(
|
|
937
|
+
resolve(sound);
|
|
862
938
|
}
|
|
863
939
|
});
|
|
864
940
|
});
|
|
865
|
-
|
|
941
|
+
const audio = yield task;
|
|
942
|
+
this.aliases.set(audio, { alias: soundAlias, library: soundLibrary });
|
|
943
|
+
this.audios.push(audio);
|
|
944
|
+
return audio;
|
|
866
945
|
} catch (e) {
|
|
946
|
+
if (library && alias) {
|
|
947
|
+
removeSound(library, alias);
|
|
948
|
+
}
|
|
867
949
|
logger.warn(TAG$2, `Error occurred on "${file}"`, e);
|
|
868
950
|
onError == null ? void 0 : onError(e);
|
|
869
951
|
return null;
|
|
@@ -880,14 +962,18 @@ var __async = (__this, __arguments, generator) => {
|
|
|
880
962
|
singleInstance: true,
|
|
881
963
|
complete: () => {
|
|
882
964
|
onFinish == null ? void 0 : onFinish();
|
|
883
|
-
|
|
965
|
+
this.dispose(audio);
|
|
884
966
|
}
|
|
885
967
|
});
|
|
886
968
|
}
|
|
887
969
|
static addAnalyzer(audio, context) {
|
|
888
|
-
const
|
|
970
|
+
const buffer = getAudioBuffer(audio);
|
|
971
|
+
if (!buffer) {
|
|
972
|
+
logger.warn(TAG$2, "Cannot create audio analyzer because WebAudio media is unavailable.");
|
|
973
|
+
return void 0;
|
|
974
|
+
}
|
|
889
975
|
const source = context.createBufferSource();
|
|
890
|
-
source.buffer =
|
|
976
|
+
source.buffer = buffer;
|
|
891
977
|
const analyser = context.createAnalyser();
|
|
892
978
|
analyser.fftSize = config.fftSize;
|
|
893
979
|
analyser.minDecibels = -90;
|
|
@@ -925,7 +1011,18 @@ var __async = (__this, __arguments, generator) => {
|
|
|
925
1011
|
* @param audio - An audio element.
|
|
926
1012
|
*/
|
|
927
1013
|
static dispose(audio) {
|
|
928
|
-
|
|
1014
|
+
try {
|
|
1015
|
+
audio.pause();
|
|
1016
|
+
} catch (e) {
|
|
1017
|
+
logger.warn(TAG$2, "Failed to pause audio.", e);
|
|
1018
|
+
}
|
|
1019
|
+
const managedSound = this.aliases.get(audio);
|
|
1020
|
+
if (managedSound) {
|
|
1021
|
+
removeSound(managedSound.library, managedSound.alias);
|
|
1022
|
+
this.aliases.delete(audio);
|
|
1023
|
+
} else {
|
|
1024
|
+
destroySound(audio);
|
|
1025
|
+
}
|
|
929
1026
|
remove(this.audios, audio);
|
|
930
1027
|
}
|
|
931
1028
|
/**
|
|
@@ -949,6 +1046,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
949
1046
|
__publicField(SoundManager, "audios", []);
|
|
950
1047
|
__publicField(SoundManager, "analysers", []);
|
|
951
1048
|
__publicField(SoundManager, "contexts", []);
|
|
1049
|
+
__publicField(SoundManager, "aliases", /* @__PURE__ */ new WeakMap());
|
|
952
1050
|
__publicField(SoundManager, "_volume", VOLUME);
|
|
953
1051
|
var MotionPreloadStrategy = /* @__PURE__ */ ((MotionPreloadStrategy2) => {
|
|
954
1052
|
MotionPreloadStrategy2["ALL"] = "ALL";
|
|
@@ -1133,7 +1231,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
1133
1231
|
* @returns Promise that resolves with true if the sound is playing, false otherwise.
|
|
1134
1232
|
*/
|
|
1135
1233
|
speak(_0) {
|
|
1136
|
-
return __async(this, arguments, function* (
|
|
1234
|
+
return __async(this, arguments, function* (sound, {
|
|
1137
1235
|
volume = VOLUME,
|
|
1138
1236
|
expression,
|
|
1139
1237
|
resetExpression = true,
|
|
@@ -1150,16 +1248,16 @@ var __async = (__this, __arguments, generator) => {
|
|
|
1150
1248
|
}
|
|
1151
1249
|
}
|
|
1152
1250
|
let soundURL;
|
|
1153
|
-
const isBase64Content =
|
|
1154
|
-
if (
|
|
1251
|
+
const isBase64Content = sound && sound.startsWith("data:");
|
|
1252
|
+
if (sound && !isBase64Content) {
|
|
1155
1253
|
const A = document.createElement("a");
|
|
1156
|
-
A.href =
|
|
1157
|
-
|
|
1158
|
-
soundURL =
|
|
1254
|
+
A.href = sound;
|
|
1255
|
+
sound = A.href;
|
|
1256
|
+
soundURL = sound;
|
|
1159
1257
|
} else {
|
|
1160
1258
|
soundURL = "data:audio/";
|
|
1161
1259
|
}
|
|
1162
|
-
const file =
|
|
1260
|
+
const file = sound;
|
|
1163
1261
|
if (file) {
|
|
1164
1262
|
try {
|
|
1165
1263
|
audio = yield SoundManager.add(file, (e, that = this) => {
|
|
@@ -1170,6 +1268,9 @@ var __async = (__this, __arguments, generator) => {
|
|
|
1170
1268
|
}
|
|
1171
1269
|
that.currentAudio = void 0;
|
|
1172
1270
|
});
|
|
1271
|
+
if (!audio) {
|
|
1272
|
+
return false;
|
|
1273
|
+
}
|
|
1173
1274
|
this.initializeAudio(audio, volume);
|
|
1174
1275
|
} catch (e) {
|
|
1175
1276
|
logger.warn(this.tag, "Failed to create audio", soundURL, e);
|
|
@@ -1219,17 +1320,19 @@ var __async = (__this, __arguments, generator) => {
|
|
|
1219
1320
|
* @param onFinish - Callback when playback finishes.
|
|
1220
1321
|
* @param onError - Callback when playback errors.
|
|
1221
1322
|
* @param ignoreParamIds - The ids to be ignored.
|
|
1323
|
+
* @param loop - Whether the motion should loop. Overrides Cubism 3/4/5 motion JSON loop metadata when specified.
|
|
1222
1324
|
* @return Promise that resolves with true if the motion is successfully started, false otherwise.
|
|
1223
1325
|
*/
|
|
1224
1326
|
startMotion(_0, _1) {
|
|
1225
1327
|
return __async(this, arguments, function* (group, index, priority = MotionPriority.NORMAL, {
|
|
1226
|
-
sound
|
|
1328
|
+
sound = void 0,
|
|
1227
1329
|
volume = VOLUME,
|
|
1228
1330
|
expression = void 0,
|
|
1229
1331
|
resetExpression = true,
|
|
1230
1332
|
onFinish,
|
|
1231
1333
|
onError,
|
|
1232
|
-
ignoreParamIds = []
|
|
1334
|
+
ignoreParamIds = [],
|
|
1335
|
+
loop = void 0
|
|
1233
1336
|
} = {}) {
|
|
1234
1337
|
if (this.destroyed) {
|
|
1235
1338
|
return false;
|
|
@@ -1251,12 +1354,12 @@ var __async = (__this, __arguments, generator) => {
|
|
|
1251
1354
|
}
|
|
1252
1355
|
let audio;
|
|
1253
1356
|
let soundURL;
|
|
1254
|
-
const isBase64Content =
|
|
1255
|
-
if (
|
|
1357
|
+
const isBase64Content = sound && sound.startsWith("data:");
|
|
1358
|
+
if (sound && !isBase64Content) {
|
|
1256
1359
|
const A = document.createElement("a");
|
|
1257
|
-
A.href =
|
|
1258
|
-
|
|
1259
|
-
soundURL =
|
|
1360
|
+
A.href = sound;
|
|
1361
|
+
sound = A.href;
|
|
1362
|
+
soundURL = sound;
|
|
1260
1363
|
} else {
|
|
1261
1364
|
soundURL = this.getSoundFile(definition);
|
|
1262
1365
|
if (soundURL) {
|
|
@@ -1274,7 +1377,9 @@ var __async = (__this, __arguments, generator) => {
|
|
|
1274
1377
|
}
|
|
1275
1378
|
that.currentAudio = void 0;
|
|
1276
1379
|
});
|
|
1277
|
-
|
|
1380
|
+
if (audio) {
|
|
1381
|
+
this.initializeAudio(audio, volume);
|
|
1382
|
+
}
|
|
1278
1383
|
} catch (e) {
|
|
1279
1384
|
logger.warn(this.tag, "Failed to create audio", soundURL, e);
|
|
1280
1385
|
}
|
|
@@ -1312,7 +1417,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
1312
1417
|
}
|
|
1313
1418
|
this.playing = true;
|
|
1314
1419
|
if (motion) {
|
|
1315
|
-
this._startMotion(motion, void 0, ignoreParamIds);
|
|
1420
|
+
this._startMotion(motion, void 0, ignoreParamIds, loop);
|
|
1316
1421
|
}
|
|
1317
1422
|
return true;
|
|
1318
1423
|
});
|
|
@@ -1328,16 +1433,18 @@ var __async = (__this, __arguments, generator) => {
|
|
|
1328
1433
|
* @param crossOrigin - Cross origin setting.
|
|
1329
1434
|
* @param onFinish - Callback when playback finishes.
|
|
1330
1435
|
* @param onError - Callback when playback errors.
|
|
1436
|
+
* @param loop - Whether the motion should loop. Overrides Cubism 3/4/5 motion JSON loop metadata when specified.
|
|
1331
1437
|
* @return Promise that resolves with true if the motion is successfully started, false otherwise.
|
|
1332
1438
|
*/
|
|
1333
1439
|
startRandomMotion(_0, _1) {
|
|
1334
1440
|
return __async(this, arguments, function* (group, priority, {
|
|
1335
|
-
sound
|
|
1441
|
+
sound,
|
|
1336
1442
|
volume = VOLUME,
|
|
1337
1443
|
expression,
|
|
1338
1444
|
resetExpression = true,
|
|
1339
1445
|
onFinish,
|
|
1340
|
-
onError
|
|
1446
|
+
onError,
|
|
1447
|
+
loop = void 0
|
|
1341
1448
|
} = {}) {
|
|
1342
1449
|
var _a, _b;
|
|
1343
1450
|
if (this.destroyed) {
|
|
@@ -1355,12 +1462,13 @@ var __async = (__this, __arguments, generator) => {
|
|
|
1355
1462
|
if (availableIndices.length) {
|
|
1356
1463
|
const index = availableIndices[Math.floor(Math.random() * availableIndices.length)];
|
|
1357
1464
|
return this.startMotion(group, index, priority, {
|
|
1358
|
-
sound
|
|
1465
|
+
sound,
|
|
1359
1466
|
volume,
|
|
1360
1467
|
expression,
|
|
1361
1468
|
resetExpression,
|
|
1362
1469
|
onFinish,
|
|
1363
|
-
onError
|
|
1470
|
+
onError,
|
|
1471
|
+
loop
|
|
1364
1472
|
});
|
|
1365
1473
|
}
|
|
1366
1474
|
}
|
|
@@ -3203,34 +3311,38 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3203
3311
|
* @param [options.resetExpression=true] - Reset the expression to default after the motion is finished.
|
|
3204
3312
|
* @param [options.onFinish] - Callback function when speaking completes.
|
|
3205
3313
|
* @param [options.onError] - Callback function when an error occurs.
|
|
3314
|
+
* @param [options.loop] - Whether the motion should loop. Overrides Cubism 3/4/5 motion JSON loop metadata when specified.
|
|
3206
3315
|
* @return Promise that resolves with true if the motion is successfully started, with false otherwise.
|
|
3207
3316
|
*/
|
|
3208
3317
|
motion(_0, _1, _2) {
|
|
3209
3318
|
return __async(this, arguments, function* (group, index, priority, {
|
|
3210
|
-
sound
|
|
3319
|
+
sound = void 0,
|
|
3211
3320
|
volume = VOLUME,
|
|
3212
3321
|
expression = void 0,
|
|
3213
3322
|
resetExpression = true,
|
|
3214
3323
|
onFinish,
|
|
3215
|
-
onError
|
|
3324
|
+
onError,
|
|
3325
|
+
loop = void 0
|
|
3216
3326
|
} = {}) {
|
|
3217
3327
|
if (index === void 0) {
|
|
3218
3328
|
return this.internalModel.motionManager.startRandomMotion(group, priority, {
|
|
3219
|
-
sound
|
|
3329
|
+
sound,
|
|
3220
3330
|
volume,
|
|
3221
3331
|
expression,
|
|
3222
3332
|
resetExpression,
|
|
3223
3333
|
onFinish,
|
|
3224
|
-
onError
|
|
3334
|
+
onError,
|
|
3335
|
+
loop
|
|
3225
3336
|
});
|
|
3226
3337
|
} else {
|
|
3227
3338
|
return this.internalModel.motionManager.startMotion(group, index, priority, {
|
|
3228
|
-
sound
|
|
3339
|
+
sound,
|
|
3229
3340
|
volume,
|
|
3230
3341
|
expression,
|
|
3231
3342
|
resetExpression,
|
|
3232
3343
|
onFinish,
|
|
3233
|
-
onError
|
|
3344
|
+
onError,
|
|
3345
|
+
loop
|
|
3234
3346
|
});
|
|
3235
3347
|
}
|
|
3236
3348
|
});
|
|
@@ -3248,13 +3360,18 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3248
3360
|
* group: The motion group,
|
|
3249
3361
|
* index: Index in the motion group,
|
|
3250
3362
|
* priority: The priority to be applied. (0: No priority, 1: IDLE, 2:NORMAL, 3:FORCE) (default: 2)
|
|
3363
|
+
* ignoreParamIds: The ids to be ignored,
|
|
3364
|
+
* loop: Whether the motion should loop.
|
|
3251
3365
|
* @return Promise that resolves with a list, indicates the motion is successfully started, with false otherwise.
|
|
3252
3366
|
*/
|
|
3253
3367
|
parallelMotion(motionList) {
|
|
3254
3368
|
return __async(this, null, function* () {
|
|
3255
3369
|
this.internalModel.extendParallelMotionManager(motionList.length);
|
|
3256
3370
|
const result = motionList.map(
|
|
3257
|
-
(m, idx) => this.internalModel.parallelMotionManager[idx].startMotion(m.group, m.index, m.priority
|
|
3371
|
+
(m, idx) => this.internalModel.parallelMotionManager[idx].startMotion(m.group, m.index, m.priority, {
|
|
3372
|
+
ignoreParamIds: m.ignoreParamIds,
|
|
3373
|
+
loop: m.loop
|
|
3374
|
+
})
|
|
3258
3375
|
);
|
|
3259
3376
|
const flags = [];
|
|
3260
3377
|
for (const r of result) {
|
|
@@ -3308,14 +3425,14 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3308
3425
|
* @param [options.onError] - Callback function when an error occurs.
|
|
3309
3426
|
* @returns Promise that resolves with true if the sound is playing, false if it's not.
|
|
3310
3427
|
*/
|
|
3311
|
-
speak(
|
|
3428
|
+
speak(sound, {
|
|
3312
3429
|
volume = VOLUME,
|
|
3313
3430
|
expression,
|
|
3314
3431
|
resetExpression = true,
|
|
3315
3432
|
onFinish,
|
|
3316
3433
|
onError
|
|
3317
3434
|
} = {}) {
|
|
3318
|
-
return this.internalModel.motionManager.speak(
|
|
3435
|
+
return this.internalModel.motionManager.speak(sound, {
|
|
3319
3436
|
volume,
|
|
3320
3437
|
expression,
|
|
3321
3438
|
resetExpression,
|
|
@@ -3642,7 +3759,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3642
3759
|
getSoundFile(definition) {
|
|
3643
3760
|
return definition.sound;
|
|
3644
3761
|
}
|
|
3645
|
-
_startMotion(motion, onFinish, ignoreParamIds) {
|
|
3762
|
+
_startMotion(motion, onFinish, ignoreParamIds, _loop) {
|
|
3646
3763
|
motion.onFinishHandler = onFinish;
|
|
3647
3764
|
if (ignoreParamIds && ignoreParamIds.length > 0) {
|
|
3648
3765
|
motion.motions = motion.motions.filter((item) => {
|
|
@@ -3718,11 +3835,13 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3718
3835
|
* @param index - Index in the motion group.
|
|
3719
3836
|
* @param priority - The priority to be applied. default: 2 (NORMAL)
|
|
3720
3837
|
* @param ignoreParamIds - The ids to be ignored.
|
|
3838
|
+
* @param loop - Whether the motion should loop. Overrides Cubism 3/4/5 motion JSON loop metadata when specified.
|
|
3721
3839
|
* @return Promise that resolves with true if the motion is successfully started, with false otherwise.
|
|
3722
3840
|
*/
|
|
3723
3841
|
startMotion(_0, _1) {
|
|
3724
|
-
return __async(this, arguments, function* (group, index, priority = MotionPriority.NORMAL,
|
|
3842
|
+
return __async(this, arguments, function* (group, index, priority = MotionPriority.NORMAL, options = {}) {
|
|
3725
3843
|
var _a;
|
|
3844
|
+
const { ignoreParamIds = [], loop } = Array.isArray(options) ? { ignoreParamIds: options, loop: void 0 } : options;
|
|
3726
3845
|
if (!this.state.reserve(group, index, priority)) {
|
|
3727
3846
|
return false;
|
|
3728
3847
|
}
|
|
@@ -3737,7 +3856,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3737
3856
|
logger.log(this.tag, "Start motion:", this.getMotionName(definition));
|
|
3738
3857
|
this.emit("motionStart", group, index, void 0);
|
|
3739
3858
|
this.playing = true;
|
|
3740
|
-
this._startMotion(motion, void 0, ignoreParamIds);
|
|
3859
|
+
this._startMotion(motion, void 0, ignoreParamIds, loop);
|
|
3741
3860
|
return true;
|
|
3742
3861
|
});
|
|
3743
3862
|
}
|
|
@@ -3745,10 +3864,11 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3745
3864
|
* Starts a random Motion as given priority.
|
|
3746
3865
|
* @param group - The motion group.
|
|
3747
3866
|
* @param priority - The priority to be applied. (default: 1 `IDLE`)
|
|
3867
|
+
* @param loop - Whether the motion should loop. Overrides Cubism 3/4/5 motion JSON loop metadata when specified.
|
|
3748
3868
|
* @return Promise that resolves with true if the motion is successfully started, with false otherwise.
|
|
3749
3869
|
*/
|
|
3750
|
-
startRandomMotion(
|
|
3751
|
-
return __async(this,
|
|
3870
|
+
startRandomMotion(_0, _1) {
|
|
3871
|
+
return __async(this, arguments, function* (group, priority, { loop = void 0 } = {}) {
|
|
3752
3872
|
var _a;
|
|
3753
3873
|
const groupDefs = this.manager.definitions[group];
|
|
3754
3874
|
if (groupDefs == null ? void 0 : groupDefs.length) {
|
|
@@ -3761,7 +3881,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3761
3881
|
}
|
|
3762
3882
|
if (availableIndices.length) {
|
|
3763
3883
|
const index = availableIndices[Math.floor(Math.random() * availableIndices.length)];
|
|
3764
|
-
return this.startMotion(group, index, priority);
|
|
3884
|
+
return this.startMotion(group, index, priority, { loop });
|
|
3765
3885
|
}
|
|
3766
3886
|
}
|
|
3767
3887
|
return false;
|
|
@@ -3811,7 +3931,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3811
3931
|
getMotionName(definition) {
|
|
3812
3932
|
return definition.file;
|
|
3813
3933
|
}
|
|
3814
|
-
_startMotion(motion, onFinish, ignoreParamIds) {
|
|
3934
|
+
_startMotion(motion, onFinish, ignoreParamIds, _loop) {
|
|
3815
3935
|
motion.onFinishHandler = onFinish;
|
|
3816
3936
|
if (ignoreParamIds && ignoreParamIds.length > 0) {
|
|
3817
3937
|
motion.motions = motion.motions.filter((item) => {
|
|
@@ -3972,7 +4092,9 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3972
4092
|
}
|
|
3973
4093
|
this.motionManager = new CubismLegacyMotionManager(this);
|
|
3974
4094
|
this.parallelMotionManager = [];
|
|
3975
|
-
this.eyeBlink
|
|
4095
|
+
if (this.options.eyeBlink !== false) {
|
|
4096
|
+
this.eyeBlink = new Live2DEyeBlink(coreModel);
|
|
4097
|
+
}
|
|
3976
4098
|
this.eyeballXParamIndex = coreModel.getParamIndex("PARAM_EYE_BALL_X");
|
|
3977
4099
|
this.eyeballYParamIndex = coreModel.getParamIndex("PARAM_EYE_BALL_Y");
|
|
3978
4100
|
this.angleXParamIndex = coreModel.getParamIndex("PARAM_ANGLE_X");
|
|
@@ -9659,8 +9781,9 @@ var __async = (__this, __arguments, generator) => {
|
|
|
9659
9781
|
isFinished() {
|
|
9660
9782
|
return this.queueManager.isFinished();
|
|
9661
9783
|
}
|
|
9662
|
-
_startMotion(motion, onFinish, ignoreParamIds) {
|
|
9784
|
+
_startMotion(motion, onFinish, ignoreParamIds, loop) {
|
|
9663
9785
|
motion.setFinishedMotionHandler(onFinish);
|
|
9786
|
+
motion.setLoop(loop != null ? loop : motion._motionData.loop);
|
|
9664
9787
|
if (ignoreParamIds && ignoreParamIds.length > 0) {
|
|
9665
9788
|
const curves = motion._motionData.curves;
|
|
9666
9789
|
const filtered = createCurveContainer$1(curves);
|
|
@@ -9803,8 +9926,9 @@ var __async = (__this, __arguments, generator) => {
|
|
|
9803
9926
|
isFinished() {
|
|
9804
9927
|
return this.queueManager.isFinished();
|
|
9805
9928
|
}
|
|
9806
|
-
_startMotion(motion, onFinish, ignoreParamIds) {
|
|
9929
|
+
_startMotion(motion, onFinish, ignoreParamIds, loop) {
|
|
9807
9930
|
motion.setFinishedMotionHandler(onFinish);
|
|
9931
|
+
motion.setLoop(loop != null ? loop : motion._motionData.loop);
|
|
9808
9932
|
if (ignoreParamIds && ignoreParamIds.length > 0) {
|
|
9809
9933
|
const curves = motion._motionData.curves;
|
|
9810
9934
|
const filtered = createCurveContainer(curves);
|
|
@@ -12408,7 +12532,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
12408
12532
|
var _a;
|
|
12409
12533
|
super.init();
|
|
12410
12534
|
const eyeBlinkParameters = this.settings.getEyeBlinkParameters();
|
|
12411
|
-
if (eyeBlinkParameters.length) {
|
|
12535
|
+
if (this.options.eyeBlink !== false && eyeBlinkParameters.length) {
|
|
12412
12536
|
const parameterIds = new csmVector();
|
|
12413
12537
|
for (const parameter of eyeBlinkParameters) {
|
|
12414
12538
|
parameterIds.pushBack(this.idManager.getId(parameter));
|
|
@@ -13424,18 +13548,26 @@ var __async = (__this, __arguments, generator) => {
|
|
|
13424
13548
|
parameters.push(id.getString().s);
|
|
13425
13549
|
}
|
|
13426
13550
|
}
|
|
13427
|
-
} else
|
|
13551
|
+
} else {
|
|
13552
|
+
let hasEyeBlinkGroup = false;
|
|
13428
13553
|
const groups = this.json.Groups;
|
|
13429
|
-
|
|
13430
|
-
|
|
13431
|
-
|
|
13432
|
-
|
|
13433
|
-
|
|
13434
|
-
|
|
13435
|
-
|
|
13554
|
+
if (Array.isArray(groups)) {
|
|
13555
|
+
for (const group of groups) {
|
|
13556
|
+
if ((group == null ? void 0 : group.Name) !== "EyeBlink") continue;
|
|
13557
|
+
hasEyeBlinkGroup = true;
|
|
13558
|
+
if (!Array.isArray(group.Ids)) continue;
|
|
13559
|
+
for (const entry of group.Ids) {
|
|
13560
|
+
if (typeof entry === "string") {
|
|
13561
|
+
parameters.push(entry);
|
|
13562
|
+
} else if (entry == null ? void 0 : entry.Id) {
|
|
13563
|
+
parameters.push(entry.Id);
|
|
13564
|
+
}
|
|
13436
13565
|
}
|
|
13437
13566
|
}
|
|
13438
13567
|
}
|
|
13568
|
+
if (hasEyeBlinkGroup) {
|
|
13569
|
+
return parameters;
|
|
13570
|
+
}
|
|
13439
13571
|
}
|
|
13440
13572
|
return parameters.length ? parameters : [...defaultEyeBlinkParameters];
|
|
13441
13573
|
}
|