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/cubism.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;
|
|
@@ -2762,7 +2762,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
2762
2762
|
preserveExpressionOnMotion: true,
|
|
2763
2763
|
cubism: CubismFrameworkConfig
|
|
2764
2764
|
};
|
|
2765
|
-
const VERSION = "1.
|
|
2765
|
+
const VERSION = "1.3.1";
|
|
2766
2766
|
const logger = {
|
|
2767
2767
|
log(tag, ...messages) {
|
|
2768
2768
|
if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
|
|
@@ -3481,7 +3481,64 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3481
3481
|
}
|
|
3482
3482
|
const TAG$2 = "SoundManager";
|
|
3483
3483
|
const VOLUME = 0.5;
|
|
3484
|
-
|
|
3484
|
+
const SOUND_ALIAS_PREFIX = "live2d-sound-";
|
|
3485
|
+
let soundId = 0;
|
|
3486
|
+
let pixiSoundPromise;
|
|
3487
|
+
const configuredLibraries = /* @__PURE__ */ new WeakSet();
|
|
3488
|
+
function configureSoundLibrary(library) {
|
|
3489
|
+
if (!configuredLibraries.has(library)) {
|
|
3490
|
+
try {
|
|
3491
|
+
library.disableAutoPause = true;
|
|
3492
|
+
} catch (e) {
|
|
3493
|
+
logger.warn(TAG$2, "Failed to disable @pixi/sound auto pause.", e);
|
|
3494
|
+
}
|
|
3495
|
+
configuredLibraries.add(library);
|
|
3496
|
+
}
|
|
3497
|
+
return library;
|
|
3498
|
+
}
|
|
3499
|
+
function getGlobalSoundLibrary() {
|
|
3500
|
+
return typeof PIXI !== "undefined" ? PIXI == null ? void 0 : PIXI.sound : void 0;
|
|
3501
|
+
}
|
|
3502
|
+
function resolveSoundLibrary() {
|
|
3503
|
+
return __async(this, null, function* () {
|
|
3504
|
+
const globalLibrary = getGlobalSoundLibrary();
|
|
3505
|
+
if (globalLibrary) {
|
|
3506
|
+
return configureSoundLibrary(globalLibrary);
|
|
3507
|
+
}
|
|
3508
|
+
pixiSoundPromise != null ? pixiSoundPromise : pixiSoundPromise = import("@pixi/sound").then(({ sound }) => configureSoundLibrary(sound)).catch((e) => {
|
|
3509
|
+
logger.warn(
|
|
3510
|
+
TAG$2,
|
|
3511
|
+
"@pixi/sound is not available. Load pixi-sound.js before using motion sounds, speak(), or lip sync.",
|
|
3512
|
+
e
|
|
3513
|
+
);
|
|
3514
|
+
return null;
|
|
3515
|
+
});
|
|
3516
|
+
return pixiSoundPromise;
|
|
3517
|
+
});
|
|
3518
|
+
}
|
|
3519
|
+
function removeSound(library, alias) {
|
|
3520
|
+
try {
|
|
3521
|
+
library.remove(alias);
|
|
3522
|
+
} catch (e) {
|
|
3523
|
+
logger.warn(TAG$2, `Failed to remove sound "${alias}".`, e);
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
3526
|
+
function destroySound(audio) {
|
|
3527
|
+
try {
|
|
3528
|
+
audio.destroy();
|
|
3529
|
+
} catch (e) {
|
|
3530
|
+
logger.warn(TAG$2, "Failed to destroy audio.", e);
|
|
3531
|
+
}
|
|
3532
|
+
}
|
|
3533
|
+
function getAudioBuffer(audio) {
|
|
3534
|
+
const media = audio.media;
|
|
3535
|
+
const buffer = media.buffer;
|
|
3536
|
+
if (!buffer || typeof buffer !== "object") {
|
|
3537
|
+
return void 0;
|
|
3538
|
+
}
|
|
3539
|
+
const candidate = buffer;
|
|
3540
|
+
return typeof candidate.getChannelData === "function" ? buffer : void 0;
|
|
3541
|
+
}
|
|
3485
3542
|
class SoundManager {
|
|
3486
3543
|
/**
|
|
3487
3544
|
* Global volume that applies to all the sounds.
|
|
@@ -3502,22 +3559,47 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3502
3559
|
*/
|
|
3503
3560
|
static add(file, onError) {
|
|
3504
3561
|
return __async(this, null, function* () {
|
|
3562
|
+
let library = null;
|
|
3563
|
+
let alias;
|
|
3505
3564
|
try {
|
|
3565
|
+
library = yield resolveSoundLibrary();
|
|
3566
|
+
if (!library) {
|
|
3567
|
+
throw new Error("@pixi/sound is not available");
|
|
3568
|
+
}
|
|
3569
|
+
alias = `${SOUND_ALIAS_PREFIX}${soundId++}`;
|
|
3570
|
+
const soundLibrary = library;
|
|
3571
|
+
const soundAlias = alias;
|
|
3506
3572
|
const task = new Promise((resolve, reject) => {
|
|
3507
|
-
const
|
|
3573
|
+
const audio2 = soundLibrary.add(soundAlias, {
|
|
3508
3574
|
url: file,
|
|
3509
3575
|
volume: this._volume,
|
|
3510
3576
|
preload: true,
|
|
3511
|
-
loaded: () => {
|
|
3512
|
-
if (
|
|
3577
|
+
loaded: (error, loadedAudio) => {
|
|
3578
|
+
if (error) {
|
|
3579
|
+
reject(error);
|
|
3580
|
+
return;
|
|
3581
|
+
}
|
|
3582
|
+
const sound = loadedAudio != null ? loadedAudio : audio2;
|
|
3583
|
+
if (!sound) {
|
|
3584
|
+
reject(new Error(`Error: ${file} failed to load`));
|
|
3585
|
+
return;
|
|
3586
|
+
}
|
|
3587
|
+
if (!getAudioBuffer(sound)) {
|
|
3513
3588
|
reject(new Error(`Error: ${file} is not WebAudioMedia`));
|
|
3589
|
+
return;
|
|
3514
3590
|
}
|
|
3515
|
-
resolve(
|
|
3591
|
+
resolve(sound);
|
|
3516
3592
|
}
|
|
3517
3593
|
});
|
|
3518
3594
|
});
|
|
3519
|
-
|
|
3595
|
+
const audio = yield task;
|
|
3596
|
+
this.aliases.set(audio, { alias: soundAlias, library: soundLibrary });
|
|
3597
|
+
this.audios.push(audio);
|
|
3598
|
+
return audio;
|
|
3520
3599
|
} catch (e) {
|
|
3600
|
+
if (library && alias) {
|
|
3601
|
+
removeSound(library, alias);
|
|
3602
|
+
}
|
|
3521
3603
|
logger.warn(TAG$2, `Error occurred on "${file}"`, e);
|
|
3522
3604
|
onError == null ? void 0 : onError(e);
|
|
3523
3605
|
return null;
|
|
@@ -3534,14 +3616,18 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3534
3616
|
singleInstance: true,
|
|
3535
3617
|
complete: () => {
|
|
3536
3618
|
onFinish == null ? void 0 : onFinish();
|
|
3537
|
-
|
|
3619
|
+
this.dispose(audio);
|
|
3538
3620
|
}
|
|
3539
3621
|
});
|
|
3540
3622
|
}
|
|
3541
3623
|
static addAnalyzer(audio, context) {
|
|
3542
|
-
const
|
|
3624
|
+
const buffer = getAudioBuffer(audio);
|
|
3625
|
+
if (!buffer) {
|
|
3626
|
+
logger.warn(TAG$2, "Cannot create audio analyzer because WebAudio media is unavailable.");
|
|
3627
|
+
return void 0;
|
|
3628
|
+
}
|
|
3543
3629
|
const source = context.createBufferSource();
|
|
3544
|
-
source.buffer =
|
|
3630
|
+
source.buffer = buffer;
|
|
3545
3631
|
const analyser = context.createAnalyser();
|
|
3546
3632
|
analyser.fftSize = config.fftSize;
|
|
3547
3633
|
analyser.minDecibels = -90;
|
|
@@ -3579,7 +3665,18 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3579
3665
|
* @param audio - An audio element.
|
|
3580
3666
|
*/
|
|
3581
3667
|
static dispose(audio) {
|
|
3582
|
-
|
|
3668
|
+
try {
|
|
3669
|
+
audio.pause();
|
|
3670
|
+
} catch (e) {
|
|
3671
|
+
logger.warn(TAG$2, "Failed to pause audio.", e);
|
|
3672
|
+
}
|
|
3673
|
+
const managedSound = this.aliases.get(audio);
|
|
3674
|
+
if (managedSound) {
|
|
3675
|
+
removeSound(managedSound.library, managedSound.alias);
|
|
3676
|
+
this.aliases.delete(audio);
|
|
3677
|
+
} else {
|
|
3678
|
+
destroySound(audio);
|
|
3679
|
+
}
|
|
3583
3680
|
remove(this.audios, audio);
|
|
3584
3681
|
}
|
|
3585
3682
|
/**
|
|
@@ -3603,6 +3700,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3603
3700
|
__publicField(SoundManager, "audios", []);
|
|
3604
3701
|
__publicField(SoundManager, "analysers", []);
|
|
3605
3702
|
__publicField(SoundManager, "contexts", []);
|
|
3703
|
+
__publicField(SoundManager, "aliases", /* @__PURE__ */ new WeakMap());
|
|
3606
3704
|
__publicField(SoundManager, "_volume", VOLUME);
|
|
3607
3705
|
var MotionPreloadStrategy = /* @__PURE__ */ ((MotionPreloadStrategy2) => {
|
|
3608
3706
|
MotionPreloadStrategy2["ALL"] = "ALL";
|
|
@@ -3787,7 +3885,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3787
3885
|
* @returns Promise that resolves with true if the sound is playing, false otherwise.
|
|
3788
3886
|
*/
|
|
3789
3887
|
speak(_0) {
|
|
3790
|
-
return __async(this, arguments, function* (
|
|
3888
|
+
return __async(this, arguments, function* (sound, {
|
|
3791
3889
|
volume = VOLUME,
|
|
3792
3890
|
expression,
|
|
3793
3891
|
resetExpression = true,
|
|
@@ -3804,16 +3902,16 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3804
3902
|
}
|
|
3805
3903
|
}
|
|
3806
3904
|
let soundURL;
|
|
3807
|
-
const isBase64Content =
|
|
3808
|
-
if (
|
|
3905
|
+
const isBase64Content = sound && sound.startsWith("data:");
|
|
3906
|
+
if (sound && !isBase64Content) {
|
|
3809
3907
|
const A = document.createElement("a");
|
|
3810
|
-
A.href =
|
|
3811
|
-
|
|
3812
|
-
soundURL =
|
|
3908
|
+
A.href = sound;
|
|
3909
|
+
sound = A.href;
|
|
3910
|
+
soundURL = sound;
|
|
3813
3911
|
} else {
|
|
3814
3912
|
soundURL = "data:audio/";
|
|
3815
3913
|
}
|
|
3816
|
-
const file =
|
|
3914
|
+
const file = sound;
|
|
3817
3915
|
if (file) {
|
|
3818
3916
|
try {
|
|
3819
3917
|
audio = yield SoundManager.add(file, (e, that = this) => {
|
|
@@ -3824,6 +3922,9 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3824
3922
|
}
|
|
3825
3923
|
that.currentAudio = void 0;
|
|
3826
3924
|
});
|
|
3925
|
+
if (!audio) {
|
|
3926
|
+
return false;
|
|
3927
|
+
}
|
|
3827
3928
|
this.initializeAudio(audio, volume);
|
|
3828
3929
|
} catch (e) {
|
|
3829
3930
|
logger.warn(this.tag, "Failed to create audio", soundURL, e);
|
|
@@ -3873,17 +3974,19 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3873
3974
|
* @param onFinish - Callback when playback finishes.
|
|
3874
3975
|
* @param onError - Callback when playback errors.
|
|
3875
3976
|
* @param ignoreParamIds - The ids to be ignored.
|
|
3977
|
+
* @param loop - Whether the motion should loop. Overrides Cubism 3/4/5 motion JSON loop metadata when specified.
|
|
3876
3978
|
* @return Promise that resolves with true if the motion is successfully started, false otherwise.
|
|
3877
3979
|
*/
|
|
3878
3980
|
startMotion(_0, _1) {
|
|
3879
3981
|
return __async(this, arguments, function* (group, index, priority = MotionPriority.NORMAL, {
|
|
3880
|
-
sound
|
|
3982
|
+
sound = void 0,
|
|
3881
3983
|
volume = VOLUME,
|
|
3882
3984
|
expression = void 0,
|
|
3883
3985
|
resetExpression = true,
|
|
3884
3986
|
onFinish,
|
|
3885
3987
|
onError,
|
|
3886
|
-
ignoreParamIds = []
|
|
3988
|
+
ignoreParamIds = [],
|
|
3989
|
+
loop = void 0
|
|
3887
3990
|
} = {}) {
|
|
3888
3991
|
if (this.destroyed) {
|
|
3889
3992
|
return false;
|
|
@@ -3905,12 +4008,12 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3905
4008
|
}
|
|
3906
4009
|
let audio;
|
|
3907
4010
|
let soundURL;
|
|
3908
|
-
const isBase64Content =
|
|
3909
|
-
if (
|
|
4011
|
+
const isBase64Content = sound && sound.startsWith("data:");
|
|
4012
|
+
if (sound && !isBase64Content) {
|
|
3910
4013
|
const A = document.createElement("a");
|
|
3911
|
-
A.href =
|
|
3912
|
-
|
|
3913
|
-
soundURL =
|
|
4014
|
+
A.href = sound;
|
|
4015
|
+
sound = A.href;
|
|
4016
|
+
soundURL = sound;
|
|
3914
4017
|
} else {
|
|
3915
4018
|
soundURL = this.getSoundFile(definition);
|
|
3916
4019
|
if (soundURL) {
|
|
@@ -3928,7 +4031,9 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3928
4031
|
}
|
|
3929
4032
|
that.currentAudio = void 0;
|
|
3930
4033
|
});
|
|
3931
|
-
|
|
4034
|
+
if (audio) {
|
|
4035
|
+
this.initializeAudio(audio, volume);
|
|
4036
|
+
}
|
|
3932
4037
|
} catch (e) {
|
|
3933
4038
|
logger.warn(this.tag, "Failed to create audio", soundURL, e);
|
|
3934
4039
|
}
|
|
@@ -3966,7 +4071,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3966
4071
|
}
|
|
3967
4072
|
this.playing = true;
|
|
3968
4073
|
if (motion) {
|
|
3969
|
-
this._startMotion(motion, void 0, ignoreParamIds);
|
|
4074
|
+
this._startMotion(motion, void 0, ignoreParamIds, loop);
|
|
3970
4075
|
}
|
|
3971
4076
|
return true;
|
|
3972
4077
|
});
|
|
@@ -3982,16 +4087,18 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3982
4087
|
* @param crossOrigin - Cross origin setting.
|
|
3983
4088
|
* @param onFinish - Callback when playback finishes.
|
|
3984
4089
|
* @param onError - Callback when playback errors.
|
|
4090
|
+
* @param loop - Whether the motion should loop. Overrides Cubism 3/4/5 motion JSON loop metadata when specified.
|
|
3985
4091
|
* @return Promise that resolves with true if the motion is successfully started, false otherwise.
|
|
3986
4092
|
*/
|
|
3987
4093
|
startRandomMotion(_0, _1) {
|
|
3988
4094
|
return __async(this, arguments, function* (group, priority, {
|
|
3989
|
-
sound
|
|
4095
|
+
sound,
|
|
3990
4096
|
volume = VOLUME,
|
|
3991
4097
|
expression,
|
|
3992
4098
|
resetExpression = true,
|
|
3993
4099
|
onFinish,
|
|
3994
|
-
onError
|
|
4100
|
+
onError,
|
|
4101
|
+
loop = void 0
|
|
3995
4102
|
} = {}) {
|
|
3996
4103
|
var _a, _b;
|
|
3997
4104
|
if (this.destroyed) {
|
|
@@ -4009,12 +4116,13 @@ var __async = (__this, __arguments, generator) => {
|
|
|
4009
4116
|
if (availableIndices.length) {
|
|
4010
4117
|
const index = availableIndices[Math.floor(Math.random() * availableIndices.length)];
|
|
4011
4118
|
return this.startMotion(group, index, priority, {
|
|
4012
|
-
sound
|
|
4119
|
+
sound,
|
|
4013
4120
|
volume,
|
|
4014
4121
|
expression,
|
|
4015
4122
|
resetExpression,
|
|
4016
4123
|
onFinish,
|
|
4017
|
-
onError
|
|
4124
|
+
onError,
|
|
4125
|
+
loop
|
|
4018
4126
|
});
|
|
4019
4127
|
}
|
|
4020
4128
|
}
|
|
@@ -5857,34 +5965,38 @@ var __async = (__this, __arguments, generator) => {
|
|
|
5857
5965
|
* @param [options.resetExpression=true] - Reset the expression to default after the motion is finished.
|
|
5858
5966
|
* @param [options.onFinish] - Callback function when speaking completes.
|
|
5859
5967
|
* @param [options.onError] - Callback function when an error occurs.
|
|
5968
|
+
* @param [options.loop] - Whether the motion should loop. Overrides Cubism 3/4/5 motion JSON loop metadata when specified.
|
|
5860
5969
|
* @return Promise that resolves with true if the motion is successfully started, with false otherwise.
|
|
5861
5970
|
*/
|
|
5862
5971
|
motion(_0, _1, _2) {
|
|
5863
5972
|
return __async(this, arguments, function* (group, index, priority, {
|
|
5864
|
-
sound
|
|
5973
|
+
sound = void 0,
|
|
5865
5974
|
volume = VOLUME,
|
|
5866
5975
|
expression = void 0,
|
|
5867
5976
|
resetExpression = true,
|
|
5868
5977
|
onFinish,
|
|
5869
|
-
onError
|
|
5978
|
+
onError,
|
|
5979
|
+
loop = void 0
|
|
5870
5980
|
} = {}) {
|
|
5871
5981
|
if (index === void 0) {
|
|
5872
5982
|
return this.internalModel.motionManager.startRandomMotion(group, priority, {
|
|
5873
|
-
sound
|
|
5983
|
+
sound,
|
|
5874
5984
|
volume,
|
|
5875
5985
|
expression,
|
|
5876
5986
|
resetExpression,
|
|
5877
5987
|
onFinish,
|
|
5878
|
-
onError
|
|
5988
|
+
onError,
|
|
5989
|
+
loop
|
|
5879
5990
|
});
|
|
5880
5991
|
} else {
|
|
5881
5992
|
return this.internalModel.motionManager.startMotion(group, index, priority, {
|
|
5882
|
-
sound
|
|
5993
|
+
sound,
|
|
5883
5994
|
volume,
|
|
5884
5995
|
expression,
|
|
5885
5996
|
resetExpression,
|
|
5886
5997
|
onFinish,
|
|
5887
|
-
onError
|
|
5998
|
+
onError,
|
|
5999
|
+
loop
|
|
5888
6000
|
});
|
|
5889
6001
|
}
|
|
5890
6002
|
});
|
|
@@ -5902,13 +6014,18 @@ var __async = (__this, __arguments, generator) => {
|
|
|
5902
6014
|
* group: The motion group,
|
|
5903
6015
|
* index: Index in the motion group,
|
|
5904
6016
|
* priority: The priority to be applied. (0: No priority, 1: IDLE, 2:NORMAL, 3:FORCE) (default: 2)
|
|
6017
|
+
* ignoreParamIds: The ids to be ignored,
|
|
6018
|
+
* loop: Whether the motion should loop.
|
|
5905
6019
|
* @return Promise that resolves with a list, indicates the motion is successfully started, with false otherwise.
|
|
5906
6020
|
*/
|
|
5907
6021
|
parallelMotion(motionList) {
|
|
5908
6022
|
return __async(this, null, function* () {
|
|
5909
6023
|
this.internalModel.extendParallelMotionManager(motionList.length);
|
|
5910
6024
|
const result = motionList.map(
|
|
5911
|
-
(m, idx) => this.internalModel.parallelMotionManager[idx].startMotion(m.group, m.index, m.priority
|
|
6025
|
+
(m, idx) => this.internalModel.parallelMotionManager[idx].startMotion(m.group, m.index, m.priority, {
|
|
6026
|
+
ignoreParamIds: m.ignoreParamIds,
|
|
6027
|
+
loop: m.loop
|
|
6028
|
+
})
|
|
5912
6029
|
);
|
|
5913
6030
|
const flags = [];
|
|
5914
6031
|
for (const r of result) {
|
|
@@ -5962,14 +6079,14 @@ var __async = (__this, __arguments, generator) => {
|
|
|
5962
6079
|
* @param [options.onError] - Callback function when an error occurs.
|
|
5963
6080
|
* @returns Promise that resolves with true if the sound is playing, false if it's not.
|
|
5964
6081
|
*/
|
|
5965
|
-
speak(
|
|
6082
|
+
speak(sound, {
|
|
5966
6083
|
volume = VOLUME,
|
|
5967
6084
|
expression,
|
|
5968
6085
|
resetExpression = true,
|
|
5969
6086
|
onFinish,
|
|
5970
6087
|
onError
|
|
5971
6088
|
} = {}) {
|
|
5972
|
-
return this.internalModel.motionManager.speak(
|
|
6089
|
+
return this.internalModel.motionManager.speak(sound, {
|
|
5973
6090
|
volume,
|
|
5974
6091
|
expression,
|
|
5975
6092
|
resetExpression,
|
|
@@ -8743,8 +8860,9 @@ var __async = (__this, __arguments, generator) => {
|
|
|
8743
8860
|
isFinished() {
|
|
8744
8861
|
return this.queueManager.isFinished();
|
|
8745
8862
|
}
|
|
8746
|
-
_startMotion(motion, onFinish, ignoreParamIds) {
|
|
8863
|
+
_startMotion(motion, onFinish, ignoreParamIds, loop) {
|
|
8747
8864
|
motion.setFinishedMotionHandler(onFinish);
|
|
8865
|
+
motion.setLoop(loop != null ? loop : motion._motionData.loop);
|
|
8748
8866
|
if (ignoreParamIds && ignoreParamIds.length > 0) {
|
|
8749
8867
|
const curves = motion._motionData.curves;
|
|
8750
8868
|
const filtered = createCurveContainer$1(curves);
|
|
@@ -8909,11 +9027,13 @@ var __async = (__this, __arguments, generator) => {
|
|
|
8909
9027
|
* @param index - Index in the motion group.
|
|
8910
9028
|
* @param priority - The priority to be applied. default: 2 (NORMAL)
|
|
8911
9029
|
* @param ignoreParamIds - The ids to be ignored.
|
|
9030
|
+
* @param loop - Whether the motion should loop. Overrides Cubism 3/4/5 motion JSON loop metadata when specified.
|
|
8912
9031
|
* @return Promise that resolves with true if the motion is successfully started, with false otherwise.
|
|
8913
9032
|
*/
|
|
8914
9033
|
startMotion(_0, _1) {
|
|
8915
|
-
return __async(this, arguments, function* (group, index, priority = MotionPriority.NORMAL,
|
|
9034
|
+
return __async(this, arguments, function* (group, index, priority = MotionPriority.NORMAL, options = {}) {
|
|
8916
9035
|
var _a;
|
|
9036
|
+
const { ignoreParamIds = [], loop } = Array.isArray(options) ? { ignoreParamIds: options, loop: void 0 } : options;
|
|
8917
9037
|
if (!this.state.reserve(group, index, priority)) {
|
|
8918
9038
|
return false;
|
|
8919
9039
|
}
|
|
@@ -8928,7 +9048,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
8928
9048
|
logger.log(this.tag, "Start motion:", this.getMotionName(definition));
|
|
8929
9049
|
this.emit("motionStart", group, index, void 0);
|
|
8930
9050
|
this.playing = true;
|
|
8931
|
-
this._startMotion(motion, void 0, ignoreParamIds);
|
|
9051
|
+
this._startMotion(motion, void 0, ignoreParamIds, loop);
|
|
8932
9052
|
return true;
|
|
8933
9053
|
});
|
|
8934
9054
|
}
|
|
@@ -8936,10 +9056,11 @@ var __async = (__this, __arguments, generator) => {
|
|
|
8936
9056
|
* Starts a random Motion as given priority.
|
|
8937
9057
|
* @param group - The motion group.
|
|
8938
9058
|
* @param priority - The priority to be applied. (default: 1 `IDLE`)
|
|
9059
|
+
* @param loop - Whether the motion should loop. Overrides Cubism 3/4/5 motion JSON loop metadata when specified.
|
|
8939
9060
|
* @return Promise that resolves with true if the motion is successfully started, with false otherwise.
|
|
8940
9061
|
*/
|
|
8941
|
-
startRandomMotion(
|
|
8942
|
-
return __async(this,
|
|
9062
|
+
startRandomMotion(_0, _1) {
|
|
9063
|
+
return __async(this, arguments, function* (group, priority, { loop = void 0 } = {}) {
|
|
8943
9064
|
var _a;
|
|
8944
9065
|
const groupDefs = this.manager.definitions[group];
|
|
8945
9066
|
if (groupDefs == null ? void 0 : groupDefs.length) {
|
|
@@ -8952,7 +9073,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
8952
9073
|
}
|
|
8953
9074
|
if (availableIndices.length) {
|
|
8954
9075
|
const index = availableIndices[Math.floor(Math.random() * availableIndices.length)];
|
|
8955
|
-
return this.startMotion(group, index, priority);
|
|
9076
|
+
return this.startMotion(group, index, priority, { loop });
|
|
8956
9077
|
}
|
|
8957
9078
|
}
|
|
8958
9079
|
return false;
|
|
@@ -9006,8 +9127,9 @@ var __async = (__this, __arguments, generator) => {
|
|
|
9006
9127
|
isFinished() {
|
|
9007
9128
|
return this.queueManager.isFinished();
|
|
9008
9129
|
}
|
|
9009
|
-
_startMotion(motion, onFinish, ignoreParamIds) {
|
|
9130
|
+
_startMotion(motion, onFinish, ignoreParamIds, loop) {
|
|
9010
9131
|
motion.setFinishedMotionHandler(onFinish);
|
|
9132
|
+
motion.setLoop(loop != null ? loop : motion._motionData.loop);
|
|
9011
9133
|
if (ignoreParamIds && ignoreParamIds.length > 0) {
|
|
9012
9134
|
const curves = motion._motionData.curves;
|
|
9013
9135
|
const filtered = createCurveContainer(curves);
|
|
@@ -11611,7 +11733,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
11611
11733
|
var _a;
|
|
11612
11734
|
super.init();
|
|
11613
11735
|
const eyeBlinkParameters = this.settings.getEyeBlinkParameters();
|
|
11614
|
-
if (eyeBlinkParameters.length) {
|
|
11736
|
+
if (this.options.eyeBlink !== false && eyeBlinkParameters.length) {
|
|
11615
11737
|
const parameterIds = new csmVector();
|
|
11616
11738
|
for (const parameter of eyeBlinkParameters) {
|
|
11617
11739
|
parameterIds.pushBack(this.idManager.getId(parameter));
|
|
@@ -12627,18 +12749,26 @@ var __async = (__this, __arguments, generator) => {
|
|
|
12627
12749
|
parameters.push(id.getString().s);
|
|
12628
12750
|
}
|
|
12629
12751
|
}
|
|
12630
|
-
} else
|
|
12752
|
+
} else {
|
|
12753
|
+
let hasEyeBlinkGroup = false;
|
|
12631
12754
|
const groups = this.json.Groups;
|
|
12632
|
-
|
|
12633
|
-
|
|
12634
|
-
|
|
12635
|
-
|
|
12636
|
-
|
|
12637
|
-
|
|
12638
|
-
|
|
12755
|
+
if (Array.isArray(groups)) {
|
|
12756
|
+
for (const group of groups) {
|
|
12757
|
+
if ((group == null ? void 0 : group.Name) !== "EyeBlink") continue;
|
|
12758
|
+
hasEyeBlinkGroup = true;
|
|
12759
|
+
if (!Array.isArray(group.Ids)) continue;
|
|
12760
|
+
for (const entry of group.Ids) {
|
|
12761
|
+
if (typeof entry === "string") {
|
|
12762
|
+
parameters.push(entry);
|
|
12763
|
+
} else if (entry == null ? void 0 : entry.Id) {
|
|
12764
|
+
parameters.push(entry.Id);
|
|
12765
|
+
}
|
|
12639
12766
|
}
|
|
12640
12767
|
}
|
|
12641
12768
|
}
|
|
12769
|
+
if (hasEyeBlinkGroup) {
|
|
12770
|
+
return parameters;
|
|
12771
|
+
}
|
|
12642
12772
|
}
|
|
12643
12773
|
return parameters.length ? parameters : [...defaultEyeBlinkParameters];
|
|
12644
12774
|
}
|