@laplace.live/pixijs-live2d 0.5.0 → 0.6.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/dist/index.d.ts +132 -3
- package/dist/index.js +181 -40
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -3337,6 +3337,11 @@ export declare abstract class MotionManager<Motion = unknown, MotionSpec = unkno
|
|
|
3337
3337
|
* is dropped; a higher-priority motion in flight hands over to the new selection when it ends.
|
|
3338
3338
|
*/
|
|
3339
3339
|
setIdleMotion(motion: IdleMotion): void;
|
|
3340
|
+
/**
|
|
3341
|
+
* List a motion file after load, under `group`, so a file written beside the model plays
|
|
3342
|
+
* without a reload. A new group is created; an existing one grows by one index.
|
|
3343
|
+
*/
|
|
3344
|
+
addMotion(group: string, definition: MotionSpec): void;
|
|
3340
3345
|
/** Stop the idle so the next update starts the selection. Cubism eases its parameters home too. */
|
|
3341
3346
|
protected releaseIdle(): void;
|
|
3342
3347
|
/** Start the idle selection at IDLE priority; a chosen motion loops regardless of its own flag. */
|
|
@@ -3560,7 +3565,9 @@ export declare abstract class ExpressionManager<Expression = unknown, Expression
|
|
|
3560
3565
|
*/
|
|
3561
3566
|
tag: string;
|
|
3562
3567
|
/**
|
|
3563
|
-
* Expression definitions copied from ModelSettings.
|
|
3568
|
+
* Expression definitions copied from ModelSettings. An index is not stable across an `await`:
|
|
3569
|
+
* {@link removeDefinition} shifts the ones above it, so a load or activation in flight
|
|
3570
|
+
* re-resolves its definition afterwards rather than trusting the index it started with.
|
|
3564
3571
|
*/
|
|
3565
3572
|
abstract readonly definitions: ExpressionSpec[];
|
|
3566
3573
|
/**
|
|
@@ -3593,6 +3600,14 @@ export declare abstract class ExpressionManager<Expression = unknown, Expression
|
|
|
3593
3600
|
* Active set remembered by {@link resetExpression} for {@link restoreExpression}.
|
|
3594
3601
|
*/
|
|
3595
3602
|
protected suppressedIndices: number[] | null;
|
|
3603
|
+
/**
|
|
3604
|
+
* Indices whose parameters are skipped while they stay active — an editor previewing an
|
|
3605
|
+
* expression's own edit needs the real one silent without touching the active set anyone
|
|
3606
|
+
* persists or observes.
|
|
3607
|
+
*/
|
|
3608
|
+
protected muted: Set<number>;
|
|
3609
|
+
/** Every entry silenced at once (the editor's Solo), on top of {@link muted}. */
|
|
3610
|
+
protected muteAll: boolean;
|
|
3596
3611
|
/**
|
|
3597
3612
|
* Flags the instance has been destroyed.
|
|
3598
3613
|
*/
|
|
@@ -3612,6 +3627,40 @@ export declare abstract class ExpressionManager<Expression = unknown, Expression
|
|
|
3612
3627
|
* @ignore
|
|
3613
3628
|
*/
|
|
3614
3629
|
private _loadExpression;
|
|
3630
|
+
/**
|
|
3631
|
+
* Lists a definition after load, so a file written beside the model activates without a reload.
|
|
3632
|
+
* @return The new index.
|
|
3633
|
+
*/
|
|
3634
|
+
addDefinition(definition: ExpressionSpec): number;
|
|
3635
|
+
/**
|
|
3636
|
+
* Replaces the loaded Expression at `index` — a file the editor just rewrote — keeping an active one
|
|
3637
|
+
* active at its current weight.
|
|
3638
|
+
*/
|
|
3639
|
+
replaceExpression(index: number, expression: Expression): void;
|
|
3640
|
+
/**
|
|
3641
|
+
* Forgets a definition (its file was deleted or renamed away): deactivates it, then shifts every
|
|
3642
|
+
* index above it so the remaining expressions keep their state. An activation of it still loading
|
|
3643
|
+
* settles as a no-op.
|
|
3644
|
+
*/
|
|
3645
|
+
removeDefinition(index: number): void;
|
|
3646
|
+
/**
|
|
3647
|
+
* Mutes or unmutes an Expression: an active one keeps its state and fade but contributes nothing
|
|
3648
|
+
* until unmuted. Unknown indices are ignored.
|
|
3649
|
+
*/
|
|
3650
|
+
setExpressionMuted(index: number | string, muted: boolean): void;
|
|
3651
|
+
/**
|
|
3652
|
+
* Mutes or unmutes every Expression at once, active state untouched; the per-entry mutes stay
|
|
3653
|
+
* as they are underneath.
|
|
3654
|
+
*/
|
|
3655
|
+
setAllMuted(muted: boolean): void;
|
|
3656
|
+
/**
|
|
3657
|
+
* A loaded Expression was swapped for another at `index`; a subclass holding it live re-points.
|
|
3658
|
+
*/
|
|
3659
|
+
protected onExpressionReplaced(_index: number, _expression: Expression): void;
|
|
3660
|
+
/**
|
|
3661
|
+
* The definition at `index` is gone and every index above it moved down by one.
|
|
3662
|
+
*/
|
|
3663
|
+
protected onDefinitionRemoved(_index: number): void;
|
|
3615
3664
|
/**
|
|
3616
3665
|
* Activates a random inactive Expression.
|
|
3617
3666
|
* @return Promise that resolves with true if succeeded, with false otherwise.
|
|
@@ -4675,7 +4724,8 @@ export declare class Live2DFactory {
|
|
|
4675
4724
|
/**
|
|
4676
4725
|
* Load tasks of each expression.
|
|
4677
4726
|
*/
|
|
4678
|
-
|
|
4727
|
+
/** Keyed by the definition object: a removal shifts indices, never the object. */
|
|
4728
|
+
static expressionTasksMap: WeakMap<ExpressionManager<unknown, unknown>, Map<unknown, Promise<any>>>;
|
|
4679
4729
|
/**
|
|
4680
4730
|
* Registers a Live2DRuntime.
|
|
4681
4731
|
*/
|
|
@@ -5761,9 +5811,15 @@ export declare class CubismModelSettings extends ModelSettings {
|
|
|
5761
5811
|
export declare class CubismExpressionManager extends ExpressionManager<CubismExpressionMotion, Expression> {
|
|
5762
5812
|
readonly expressionDataType: "arraybuffer";
|
|
5763
5813
|
readonly definitions: Expression[];
|
|
5814
|
+
/** The settings the listings read; `definitions` was filtered out of them, so both are kept in step. */
|
|
5815
|
+
private readonly cubismSettings;
|
|
5764
5816
|
/** Active fade entries in activation order; deactivated ones stay until fully faded out. */
|
|
5765
5817
|
private entries;
|
|
5766
5818
|
constructor(settings: CubismModelSettings, options?: MotionManagerOptions);
|
|
5819
|
+
addDefinition(definition: Expression): number;
|
|
5820
|
+
removeDefinition(index: number): void;
|
|
5821
|
+
protected onExpressionReplaced(index: number, expression: CubismExpressionMotion): void;
|
|
5822
|
+
protected onDefinitionRemoved(index: number): void;
|
|
5767
5823
|
isFinished(): boolean;
|
|
5768
5824
|
getExpressionIndex(name: string): number;
|
|
5769
5825
|
getExpressionFile(definition: Expression): string;
|
|
@@ -5990,6 +6046,64 @@ declare class PartData {
|
|
|
5990
6046
|
link: Array<PartData>;
|
|
5991
6047
|
}
|
|
5992
6048
|
//#endregion
|
|
6049
|
+
//#region vendor/cubism/src/model/cubismmoc.d.ts
|
|
6050
|
+
/**
|
|
6051
|
+
* Mocデータの管理
|
|
6052
|
+
*
|
|
6053
|
+
* Mocデータの管理を行うクラス。
|
|
6054
|
+
*/
|
|
6055
|
+
declare class CubismMoc {
|
|
6056
|
+
/**
|
|
6057
|
+
* Mocデータの作成
|
|
6058
|
+
*/
|
|
6059
|
+
static create(mocBytes: ArrayBuffer, shouldCheckMocConsistency: boolean): CubismMoc;
|
|
6060
|
+
/**
|
|
6061
|
+
* Mocデータを削除
|
|
6062
|
+
*
|
|
6063
|
+
* Mocデータを削除する
|
|
6064
|
+
*/
|
|
6065
|
+
static delete(moc: CubismMoc): void;
|
|
6066
|
+
/**
|
|
6067
|
+
* モデルを作成する
|
|
6068
|
+
*
|
|
6069
|
+
* @return Mocデータから作成されたモデル
|
|
6070
|
+
*/
|
|
6071
|
+
createModel(): CubismModel;
|
|
6072
|
+
/**
|
|
6073
|
+
* モデルを削除する
|
|
6074
|
+
*/
|
|
6075
|
+
deleteModel(model: CubismModel): void;
|
|
6076
|
+
/**
|
|
6077
|
+
* コンストラクタ
|
|
6078
|
+
*/
|
|
6079
|
+
private constructor();
|
|
6080
|
+
/**
|
|
6081
|
+
* デストラクタ相当の処理
|
|
6082
|
+
*/
|
|
6083
|
+
release(): void;
|
|
6084
|
+
/**
|
|
6085
|
+
* 最新の.moc3 Versionを取得
|
|
6086
|
+
*/
|
|
6087
|
+
getLatestMocVersion(): number;
|
|
6088
|
+
/**
|
|
6089
|
+
* 読み込んだモデルの.moc3 Versionを取得
|
|
6090
|
+
*/
|
|
6091
|
+
getMocVersion(): number;
|
|
6092
|
+
/**
|
|
6093
|
+
* Mocファイルのbufferから.moc3 Versionを取得
|
|
6094
|
+
* @param mocBytes Mocファイルのバイト配列
|
|
6095
|
+
* @returns .moc3 Version番号
|
|
6096
|
+
*/
|
|
6097
|
+
static getMocVersionFromBuffer(mocBytes: ArrayBuffer): number;
|
|
6098
|
+
/**
|
|
6099
|
+
* .moc3 の整合性を検証する
|
|
6100
|
+
*/
|
|
6101
|
+
static hasMocConsistency(mocBytes: ArrayBuffer): boolean;
|
|
6102
|
+
_moc: Live2DCubismCore.Moc;
|
|
6103
|
+
_modelCount: number;
|
|
6104
|
+
_mocVersion: number;
|
|
6105
|
+
}
|
|
6106
|
+
//#endregion
|
|
5993
6107
|
//#region vendor/cubism/src/math/cubismvector2.d.ts
|
|
5994
6108
|
/**
|
|
5995
6109
|
* Copyright(c) Live2D Inc. All rights reserved.
|
|
@@ -6945,6 +7059,12 @@ export declare class CubismMotionManager extends MotionManager<CubismMotion, Mot
|
|
|
6945
7059
|
isFinished(): boolean;
|
|
6946
7060
|
protected _startMotion(motion: CubismMotion, onFinish?: (motion: CubismMotion) => void, ignoreParamIds?: string[], loop?: boolean): number;
|
|
6947
7061
|
protected _stopAllMotions(): void;
|
|
7062
|
+
/**
|
|
7063
|
+
* Fade the queue's motions out over their own fade-out time instead of cutting them; each
|
|
7064
|
+
* ends like a natural finish (idle restart, `motionFinish`), which is how a looping one stops.
|
|
7065
|
+
* The motion's sound stops at once, as it does on {@link stopAllMotions}.
|
|
7066
|
+
*/
|
|
7067
|
+
fadeOutMotions(): void;
|
|
6948
7068
|
createMotion(data: ArrayBuffer, group: string, definition: Motion): CubismMotion;
|
|
6949
7069
|
getMotionFile(definition: Motion): string;
|
|
6950
7070
|
protected getMotionName(definition: Motion): string;
|
|
@@ -6953,6 +7073,13 @@ export declare class CubismMotionManager extends MotionManager<CubismMotion, Mot
|
|
|
6953
7073
|
currentMotionBlinks(): boolean;
|
|
6954
7074
|
/** The parameters the playing motion writes, for a host driver handing them over to it; null when none plays. */
|
|
6955
7075
|
currentMotionParameters(): ReadonlySet<string> | null;
|
|
7076
|
+
/**
|
|
7077
|
+
* The parameters a playing one-shot (anything above IDLE) writes — what a host's tracking
|
|
7078
|
+
* yields to while it plays, as VTS ranks an animation above tracking. Null under the idle.
|
|
7079
|
+
*/
|
|
7080
|
+
oneShotParameters(): ReadonlySet<string> | null;
|
|
7081
|
+
/** A motion above idle priority is current — one the player started, never the idle. */
|
|
7082
|
+
oneShotPlaying(): boolean;
|
|
6956
7083
|
private currentMotion;
|
|
6957
7084
|
private currentMeta;
|
|
6958
7085
|
protected releaseIdle(): void;
|
|
@@ -6996,6 +7123,8 @@ export declare class CubismInternalModel extends InternalModel {
|
|
|
6996
7123
|
pose?: CubismPose;
|
|
6997
7124
|
physics?: CubismPhysics;
|
|
6998
7125
|
renderer: CubismRenderer_WebGL;
|
|
7126
|
+
/** The moc {@link coreModel} was built from; it must outlive the model, so {@link destroy} releases it last. */
|
|
7127
|
+
private readonly moc;
|
|
6999
7128
|
private readonly idManager;
|
|
7000
7129
|
/** Context the renderer was last started up against; also the offscreen-pool refcount key. */
|
|
7001
7130
|
private renderContext?;
|
|
@@ -7015,7 +7144,7 @@ export declare class CubismInternalModel extends InternalModel {
|
|
|
7015
7144
|
* Matrix that scales by {@link pixelsPerUnit}, and moves the origin from top-left to center.
|
|
7016
7145
|
*/
|
|
7017
7146
|
protected modelTransform: Matrix;
|
|
7018
|
-
constructor(coreModel: CubismModel, settings: CubismModelSettings, options?: InternalModelOptions);
|
|
7147
|
+
constructor(coreModel: CubismModel, moc: CubismMoc, settings: CubismModelSettings, options?: InternalModelOptions);
|
|
7019
7148
|
protected init(): void;
|
|
7020
7149
|
protected getIdSafe(id: string | undefined): CubismIdHandle;
|
|
7021
7150
|
protected getSize(): [number, number];
|
package/dist/index.js
CHANGED
|
@@ -2734,6 +2734,14 @@ var ExpressionManager = class extends EventEmitter {
|
|
|
2734
2734
|
*/
|
|
2735
2735
|
suppressedIndices = null;
|
|
2736
2736
|
/**
|
|
2737
|
+
* Indices whose parameters are skipped while they stay active — an editor previewing an
|
|
2738
|
+
* expression's own edit needs the real one silent without touching the active set anyone
|
|
2739
|
+
* persists or observes.
|
|
2740
|
+
*/
|
|
2741
|
+
muted = /* @__PURE__ */ new Set();
|
|
2742
|
+
/** Every entry silenced at once (the editor's Solo), on top of {@link muted}. */
|
|
2743
|
+
muteAll = false;
|
|
2744
|
+
/**
|
|
2737
2745
|
* Flags the instance has been destroyed.
|
|
2738
2746
|
*/
|
|
2739
2747
|
destroyed = false;
|
|
@@ -2751,7 +2759,8 @@ var ExpressionManager = class extends EventEmitter {
|
|
|
2751
2759
|
* @emits {@link ExpressionManagerEvents.expressionLoadError}
|
|
2752
2760
|
*/
|
|
2753
2761
|
async loadExpression(index) {
|
|
2754
|
-
|
|
2762
|
+
const definition = this.definitions[index];
|
|
2763
|
+
if (!definition) {
|
|
2755
2764
|
logger.warn(this.tag, `Undefined expression at [${index}]`);
|
|
2756
2765
|
return;
|
|
2757
2766
|
}
|
|
@@ -2762,7 +2771,11 @@ var ExpressionManager = class extends EventEmitter {
|
|
|
2762
2771
|
if (this.expressions[index]) return this.expressions[index];
|
|
2763
2772
|
const expression = await this._loadExpression(index);
|
|
2764
2773
|
if (this.destroyed) return;
|
|
2765
|
-
|
|
2774
|
+
const slot = this.definitions.indexOf(definition);
|
|
2775
|
+
if (slot < 0) return;
|
|
2776
|
+
const replaced = this.expressions[slot];
|
|
2777
|
+
if (replaced) return replaced;
|
|
2778
|
+
this.expressions[slot] = expression;
|
|
2766
2779
|
return expression;
|
|
2767
2780
|
}
|
|
2768
2781
|
/**
|
|
@@ -2773,6 +2786,66 @@ var ExpressionManager = class extends EventEmitter {
|
|
|
2773
2786
|
throw new Error("Not implemented.");
|
|
2774
2787
|
}
|
|
2775
2788
|
/**
|
|
2789
|
+
* Lists a definition after load, so a file written beside the model activates without a reload.
|
|
2790
|
+
* @return The new index.
|
|
2791
|
+
*/
|
|
2792
|
+
addDefinition(definition) {
|
|
2793
|
+
this.definitions.push(definition);
|
|
2794
|
+
return this.definitions.length - 1;
|
|
2795
|
+
}
|
|
2796
|
+
/**
|
|
2797
|
+
* Replaces the loaded Expression at `index` — a file the editor just rewrote — keeping an active one
|
|
2798
|
+
* active at its current weight.
|
|
2799
|
+
*/
|
|
2800
|
+
replaceExpression(index, expression) {
|
|
2801
|
+
if (!this.definitions[index]) return;
|
|
2802
|
+
this.expressions[index] = expression;
|
|
2803
|
+
this.onExpressionReplaced(index, expression);
|
|
2804
|
+
}
|
|
2805
|
+
/**
|
|
2806
|
+
* Forgets a definition (its file was deleted or renamed away): deactivates it, then shifts every
|
|
2807
|
+
* index above it so the remaining expressions keep their state. An activation of it still loading
|
|
2808
|
+
* settles as a no-op.
|
|
2809
|
+
*/
|
|
2810
|
+
removeDefinition(index) {
|
|
2811
|
+
if (!(index >= 0 && index < this.definitions.length)) return;
|
|
2812
|
+
this.unsetExpression(index);
|
|
2813
|
+
this.definitions.splice(index, 1);
|
|
2814
|
+
this.expressions.splice(index, 1);
|
|
2815
|
+
const shift = (i) => i > index ? i - 1 : i;
|
|
2816
|
+
this.activeIndices = this.activeIndices.map(shift);
|
|
2817
|
+
this.pendingIndices = new Set([...this.pendingIndices].map(shift));
|
|
2818
|
+
this.requestSeqs = new Map([...this.requestSeqs].map(([i, seq]) => [shift(i), seq]));
|
|
2819
|
+
if (this.suppressedIndices) this.suppressedIndices = this.suppressedIndices.filter((i) => i !== index).map(shift);
|
|
2820
|
+
this.muted = new Set([...this.muted].filter((i) => i !== index).map(shift));
|
|
2821
|
+
this.onDefinitionRemoved(index);
|
|
2822
|
+
}
|
|
2823
|
+
/**
|
|
2824
|
+
* Mutes or unmutes an Expression: an active one keeps its state and fade but contributes nothing
|
|
2825
|
+
* until unmuted. Unknown indices are ignored.
|
|
2826
|
+
*/
|
|
2827
|
+
setExpressionMuted(index, muted) {
|
|
2828
|
+
if (typeof index !== "number") index = this.getExpressionIndex(index);
|
|
2829
|
+
if (!this.definitions[index]) return;
|
|
2830
|
+
if (muted) this.muted.add(index);
|
|
2831
|
+
else this.muted.delete(index);
|
|
2832
|
+
}
|
|
2833
|
+
/**
|
|
2834
|
+
* Mutes or unmutes every Expression at once, active state untouched; the per-entry mutes stay
|
|
2835
|
+
* as they are underneath.
|
|
2836
|
+
*/
|
|
2837
|
+
setAllMuted(muted) {
|
|
2838
|
+
this.muteAll = muted;
|
|
2839
|
+
}
|
|
2840
|
+
/**
|
|
2841
|
+
* A loaded Expression was swapped for another at `index`; a subclass holding it live re-points.
|
|
2842
|
+
*/
|
|
2843
|
+
onExpressionReplaced(_index, _expression) {}
|
|
2844
|
+
/**
|
|
2845
|
+
* The definition at `index` is gone and every index above it moved down by one.
|
|
2846
|
+
*/
|
|
2847
|
+
onDefinitionRemoved(_index) {}
|
|
2848
|
+
/**
|
|
2776
2849
|
* Activates a random inactive Expression.
|
|
2777
2850
|
* @return Promise that resolves with true if succeeded, with false otherwise.
|
|
2778
2851
|
*/
|
|
@@ -2837,14 +2910,17 @@ var ExpressionManager = class extends EventEmitter {
|
|
|
2837
2910
|
*/
|
|
2838
2911
|
async setExpression(index, options) {
|
|
2839
2912
|
if (typeof index !== "number") index = this.getExpressionIndex(index);
|
|
2840
|
-
|
|
2913
|
+
const definition = this.definitions[index];
|
|
2914
|
+
if (!definition) return false;
|
|
2841
2915
|
if (this.activeIndices.includes(index) || this.pendingIndices.has(index)) return false;
|
|
2842
2916
|
this.pendingIndices.add(index);
|
|
2843
2917
|
const seq = this.nextRequestSeq++;
|
|
2844
2918
|
this.requestSeqs.set(index, seq);
|
|
2845
2919
|
this.emit("expressionsChanged");
|
|
2846
2920
|
const expression = await this.loadExpression(index);
|
|
2847
|
-
if (this.destroyed
|
|
2921
|
+
if (this.destroyed) return false;
|
|
2922
|
+
index = this.definitions.indexOf(definition);
|
|
2923
|
+
if (index < 0 || this.requestSeqs.get(index) !== seq || !this.pendingIndices.has(index)) return false;
|
|
2848
2924
|
if (!expression) {
|
|
2849
2925
|
this.pendingIndices.delete(index);
|
|
2850
2926
|
this.requestSeqs.delete(index);
|
|
@@ -2911,6 +2987,8 @@ var ExpressionManager = class extends EventEmitter {
|
|
|
2911
2987
|
this.requestSeqs.clear();
|
|
2912
2988
|
this.activeIndices = [];
|
|
2913
2989
|
this.suppressedIndices = null;
|
|
2990
|
+
this.muted.clear();
|
|
2991
|
+
this.muteAll = false;
|
|
2914
2992
|
this.stopAllExpressions();
|
|
2915
2993
|
const self = this;
|
|
2916
2994
|
self.definitions = void 0;
|
|
@@ -3986,6 +4064,16 @@ var MotionManager = class extends EventEmitter {
|
|
|
3986
4064
|
this.state.setReservedIdle(void 0, void 0);
|
|
3987
4065
|
if (this.state.currentPriority === 1) this.releaseIdle();
|
|
3988
4066
|
}
|
|
4067
|
+
/**
|
|
4068
|
+
* List a motion file after load, under `group`, so a file written beside the model plays
|
|
4069
|
+
* without a reload. A new group is created; an existing one grows by one index.
|
|
4070
|
+
*/
|
|
4071
|
+
addMotion(group, definition) {
|
|
4072
|
+
const definitions = this.definitions[group] ?? [];
|
|
4073
|
+
definitions.push(definition);
|
|
4074
|
+
this.definitions[group] = definitions;
|
|
4075
|
+
this.motionGroups[group] ??= [];
|
|
4076
|
+
}
|
|
3989
4077
|
/** Stop the idle so the next update starts the selection. Cubism eases its parameters home too. */
|
|
3990
4078
|
releaseIdle() {
|
|
3991
4079
|
this.stopAllMotions();
|
|
@@ -4871,6 +4959,7 @@ var Live2DFactory = class Live2DFactory {
|
|
|
4871
4959
|
/**
|
|
4872
4960
|
* Load tasks of each expression.
|
|
4873
4961
|
*/
|
|
4962
|
+
/** Keyed by the definition object: a removal shifts indices, never the object. */
|
|
4874
4963
|
static expressionTasksMap = /* @__PURE__ */ new WeakMap();
|
|
4875
4964
|
/**
|
|
4876
4965
|
* Registers a Live2DRuntime.
|
|
@@ -4969,28 +5058,33 @@ var Live2DFactory = class Live2DFactory {
|
|
|
4969
5058
|
expressionManager.once("destroy", () => Live2DFactory.releaseExpressionTasks(expressionManager));
|
|
4970
5059
|
let tasks = Live2DFactory.expressionTasksMap.get(expressionManager);
|
|
4971
5060
|
if (!tasks) {
|
|
4972
|
-
tasks =
|
|
5061
|
+
tasks = /* @__PURE__ */ new Map();
|
|
4973
5062
|
Live2DFactory.expressionTasksMap.set(expressionManager, tasks);
|
|
4974
5063
|
}
|
|
4975
5064
|
const path = expressionManager.getExpressionFile(definition);
|
|
4976
5065
|
const responseType = expressionManager.expressionDataType ?? "json";
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
5066
|
+
let task = tasks.get(definition);
|
|
5067
|
+
if (!task) {
|
|
5068
|
+
task = Live2DLoader.load({
|
|
5069
|
+
url: path,
|
|
5070
|
+
settings: expressionManager.settings,
|
|
5071
|
+
type: responseType,
|
|
5072
|
+
target: expressionManager
|
|
5073
|
+
}).then((data) => {
|
|
5074
|
+
const expressionData = data;
|
|
5075
|
+
const expression = expressionManager.createExpression(expressionData, definition);
|
|
5076
|
+
const current = expressionManager.definitions.indexOf(definition);
|
|
5077
|
+
if (current >= 0) expressionManager.emit("expressionLoaded", current, expression);
|
|
5078
|
+
return expression;
|
|
5079
|
+
}).catch((e) => {
|
|
5080
|
+
logger.warn(expressionManager.tag, `Failed to load expression: ${path}\n`, e);
|
|
5081
|
+
handleError(e);
|
|
5082
|
+
}).finally(() => {
|
|
5083
|
+
Live2DFactory.expressionTasksMap.get(expressionManager)?.delete(definition);
|
|
5084
|
+
});
|
|
5085
|
+
tasks.set(definition, task);
|
|
5086
|
+
}
|
|
5087
|
+
return task;
|
|
4994
5088
|
} catch (e) {
|
|
4995
5089
|
logger.warn(expressionManager.tag, `Failed to load expression at [${index}]\n`, e);
|
|
4996
5090
|
handleError(e);
|
|
@@ -14600,12 +14694,39 @@ let Live2DCubismFramework$2;
|
|
|
14600
14694
|
var CubismExpressionManager = class extends ExpressionManager {
|
|
14601
14695
|
expressionDataType = "arraybuffer";
|
|
14602
14696
|
definitions;
|
|
14697
|
+
/** The settings the listings read; `definitions` was filtered out of them, so both are kept in step. */
|
|
14698
|
+
cubismSettings;
|
|
14603
14699
|
/** Active fade entries in activation order; deactivated ones stay until fully faded out. */
|
|
14604
14700
|
entries = [];
|
|
14605
14701
|
constructor(settings, options) {
|
|
14606
14702
|
super(settings, options);
|
|
14703
|
+
this.cubismSettings = settings;
|
|
14607
14704
|
this.definitions = settings.expressions?.filter((expression) => !!expression && typeof expression.File === "string" && typeof expression.Name === "string") ?? [];
|
|
14608
14705
|
}
|
|
14706
|
+
addDefinition(definition) {
|
|
14707
|
+
const index = super.addDefinition(definition);
|
|
14708
|
+
this.cubismSettings.expressions ??= [];
|
|
14709
|
+
this.cubismSettings.expressions.push(definition);
|
|
14710
|
+
return index;
|
|
14711
|
+
}
|
|
14712
|
+
removeDefinition(index) {
|
|
14713
|
+
const definition = this.definitions[index];
|
|
14714
|
+
super.removeDefinition(index);
|
|
14715
|
+
const listed = this.cubismSettings.expressions;
|
|
14716
|
+
const at = definition && listed ? listed.indexOf(definition) : -1;
|
|
14717
|
+
if (listed && at >= 0) listed.splice(at, 1);
|
|
14718
|
+
}
|
|
14719
|
+
onExpressionReplaced(index, expression) {
|
|
14720
|
+
for (const entry of this.entries) if (entry.index === index) {
|
|
14721
|
+
entry.motion = expression;
|
|
14722
|
+
entry.fadeStartWeight = entry.weight;
|
|
14723
|
+
entry.fadeStartTime = -1;
|
|
14724
|
+
}
|
|
14725
|
+
}
|
|
14726
|
+
onDefinitionRemoved(index) {
|
|
14727
|
+
this.entries = this.entries.filter((entry) => entry.index !== index);
|
|
14728
|
+
for (const entry of this.entries) if (entry.index > index) entry.index -= 1;
|
|
14729
|
+
}
|
|
14609
14730
|
isFinished() {
|
|
14610
14731
|
return this.entries.length === 0;
|
|
14611
14732
|
}
|
|
@@ -14662,6 +14783,7 @@ var CubismExpressionManager = class extends ExpressionManager {
|
|
|
14662
14783
|
if (!this.entries.length) return false;
|
|
14663
14784
|
const states = /* @__PURE__ */ new Map();
|
|
14664
14785
|
for (const entry of this.entries) {
|
|
14786
|
+
if (this.muteAll || this.muted.has(entry.index)) continue;
|
|
14665
14787
|
const weight = entry.weight;
|
|
14666
14788
|
for (const parameter of entry.motion.getExpressionParameters()) {
|
|
14667
14789
|
if (parameter.parameterId == null) continue;
|
|
@@ -14730,7 +14852,8 @@ var CubismMotionManager = class extends MotionManager {
|
|
|
14730
14852
|
release = null;
|
|
14731
14853
|
constructor(parent) {
|
|
14732
14854
|
super(parent);
|
|
14733
|
-
|
|
14855
|
+
parent.settings.motions ??= {};
|
|
14856
|
+
this.definitions = parent.settings.motions;
|
|
14734
14857
|
this.eyeBlinkIds = parent.settings.getEyeBlinkParameters() || [];
|
|
14735
14858
|
const lipSyncIds = parent.settings.getLipSyncParameters();
|
|
14736
14859
|
if (lipSyncIds?.length) this.lipSyncIds = lipSyncIds;
|
|
@@ -14738,7 +14861,7 @@ var CubismMotionManager = class extends MotionManager {
|
|
|
14738
14861
|
}
|
|
14739
14862
|
init(options) {
|
|
14740
14863
|
super.init(options);
|
|
14741
|
-
|
|
14864
|
+
this.expressionManager = new CubismExpressionManager(this.settings, options);
|
|
14742
14865
|
this.queueManager.setEventCallback((_caller, eventValue) => {
|
|
14743
14866
|
const value = eventValue == null ? "undefined" : String(eventValue);
|
|
14744
14867
|
this.emit(`motion:${value}`);
|
|
@@ -14765,6 +14888,15 @@ var CubismMotionManager = class extends MotionManager {
|
|
|
14765
14888
|
_stopAllMotions() {
|
|
14766
14889
|
this.queueManager.stopAllMotions();
|
|
14767
14890
|
}
|
|
14891
|
+
/**
|
|
14892
|
+
* Fade the queue's motions out over their own fade-out time instead of cutting them; each
|
|
14893
|
+
* ends like a natural finish (idle restart, `motionFinish`), which is how a looping one stops.
|
|
14894
|
+
* The motion's sound stops at once, as it does on {@link stopAllMotions}.
|
|
14895
|
+
*/
|
|
14896
|
+
fadeOutMotions() {
|
|
14897
|
+
for (const entry of this.queueManager.getCubismMotionQueueEntries()) entry.setFadeOut(entry._motion.getFadeOutTime());
|
|
14898
|
+
this.stopSpeaking();
|
|
14899
|
+
}
|
|
14768
14900
|
createMotion(data, group, definition) {
|
|
14769
14901
|
const shouldCheckMotionConsistency = !!this.parent.options.checkMotionConsistency;
|
|
14770
14902
|
const motion = CubismMotion.create(data, data.byteLength, void 0, void 0, shouldCheckMotionConsistency);
|
|
@@ -14772,8 +14904,8 @@ var CubismMotionManager = class extends MotionManager {
|
|
|
14772
14904
|
motion.setLoop(json.isMotionLoop());
|
|
14773
14905
|
this.meta.set(motion, motionMeta(motion, this.eyeBlinkIds));
|
|
14774
14906
|
const defaultFadingDuration = (group === this.groups.idle ? config.idleMotionFadingDuration : config.motionFadingDuration) / 1e3;
|
|
14775
|
-
if (json.
|
|
14776
|
-
if (json.
|
|
14907
|
+
if (!json.isExistMotionFadeInTime()) motion.setFadeInTime(definition.FadeInTime > 0 ? definition.FadeInTime : defaultFadingDuration);
|
|
14908
|
+
if (!json.isExistMotionFadeOutTime()) motion.setFadeOutTime(definition.FadeOutTime > 0 ? definition.FadeOutTime : defaultFadingDuration);
|
|
14777
14909
|
motion.setEffectIds(this.createIdList(this.eyeBlinkIds), this.createIdList(this.lipSyncIds));
|
|
14778
14910
|
return motion;
|
|
14779
14911
|
}
|
|
@@ -14794,6 +14926,17 @@ var CubismMotionManager = class extends MotionManager {
|
|
|
14794
14926
|
currentMotionParameters() {
|
|
14795
14927
|
return this.currentMeta()?.animated ?? null;
|
|
14796
14928
|
}
|
|
14929
|
+
/**
|
|
14930
|
+
* The parameters a playing one-shot (anything above IDLE) writes — what a host's tracking
|
|
14931
|
+
* yields to while it plays, as VTS ranks an animation above tracking. Null under the idle.
|
|
14932
|
+
*/
|
|
14933
|
+
oneShotParameters() {
|
|
14934
|
+
return this.oneShotPlaying() ? this.currentMotionParameters() : null;
|
|
14935
|
+
}
|
|
14936
|
+
/** A motion above idle priority is current — one the player started, never the idle. */
|
|
14937
|
+
oneShotPlaying() {
|
|
14938
|
+
return this.state.currentPriority > 1;
|
|
14939
|
+
}
|
|
14797
14940
|
currentMotion() {
|
|
14798
14941
|
const { currentGroup, currentIndex } = this.state;
|
|
14799
14942
|
if (currentGroup === void 0 || currentIndex === void 0) return null;
|
|
@@ -15290,6 +15433,8 @@ var CubismInternalModel = class extends InternalModel {
|
|
|
15290
15433
|
breathEnabled = true;
|
|
15291
15434
|
eyeBlink;
|
|
15292
15435
|
renderer = new CubismRenderer_WebGL(0, 0);
|
|
15436
|
+
/** The moc {@link coreModel} was built from; it must outlive the model, so {@link destroy} releases it last. */
|
|
15437
|
+
moc;
|
|
15293
15438
|
idManager;
|
|
15294
15439
|
/** Context the renderer was last started up against; also the offscreen-pool refcount key. */
|
|
15295
15440
|
renderContext;
|
|
@@ -15309,9 +15454,10 @@ var CubismInternalModel = class extends InternalModel {
|
|
|
15309
15454
|
* Matrix that scales by {@link pixelsPerUnit}, and moves the origin from top-left to center.
|
|
15310
15455
|
*/
|
|
15311
15456
|
modelTransform = new Matrix();
|
|
15312
|
-
constructor(coreModel, settings, options) {
|
|
15457
|
+
constructor(coreModel, moc, settings, options) {
|
|
15313
15458
|
super();
|
|
15314
15459
|
this.coreModel = coreModel;
|
|
15460
|
+
this.moc = moc;
|
|
15315
15461
|
this.settings = settings;
|
|
15316
15462
|
this.options = Object.assign({}, {
|
|
15317
15463
|
breathDepth: 1,
|
|
@@ -15515,7 +15661,8 @@ var CubismInternalModel = class extends InternalModel {
|
|
|
15515
15661
|
detachPooledRenderTargets(this.renderer);
|
|
15516
15662
|
this.renderer.release();
|
|
15517
15663
|
if (gl) releaseOffscreenPool(gl);
|
|
15518
|
-
this.
|
|
15664
|
+
this.moc.deleteModel(this.coreModel);
|
|
15665
|
+
this.moc.release();
|
|
15519
15666
|
this.renderer = void 0;
|
|
15520
15667
|
this.coreModel = void 0;
|
|
15521
15668
|
}
|
|
@@ -16184,6 +16331,8 @@ function reconfigureCubismSDK(config = {}) {
|
|
|
16184
16331
|
}
|
|
16185
16332
|
//#endregion
|
|
16186
16333
|
//#region src/cubism/factory.ts
|
|
16334
|
+
/** Each core model's moc, from createCoreModel to the internal model that takes ownership of both. */
|
|
16335
|
+
const mocs = /* @__PURE__ */ new WeakMap();
|
|
16187
16336
|
Live2DFactory.registerRuntime({
|
|
16188
16337
|
version: 4,
|
|
16189
16338
|
ready: cubismReady,
|
|
@@ -16202,7 +16351,7 @@ Live2DFactory.registerRuntime({
|
|
|
16202
16351
|
const moc = CubismMoc.create(data, !!options?.checkMocConsistency);
|
|
16203
16352
|
try {
|
|
16204
16353
|
const model = moc.createModel();
|
|
16205
|
-
model
|
|
16354
|
+
mocs.set(model, moc);
|
|
16206
16355
|
return model;
|
|
16207
16356
|
} catch (e) {
|
|
16208
16357
|
try {
|
|
@@ -16214,14 +16363,9 @@ Live2DFactory.registerRuntime({
|
|
|
16214
16363
|
}
|
|
16215
16364
|
},
|
|
16216
16365
|
createInternalModel(coreModel, settings, options) {
|
|
16217
|
-
const
|
|
16218
|
-
|
|
16219
|
-
|
|
16220
|
-
model.__moc = coreModelWithMoc.__moc;
|
|
16221
|
-
delete coreModelWithMoc.__moc;
|
|
16222
|
-
model.once("destroy", releaseMoc);
|
|
16223
|
-
}
|
|
16224
|
-
return model;
|
|
16366
|
+
const moc = mocs.get(coreModel);
|
|
16367
|
+
if (!moc) throw new TypeError("Cubism core model was not created by this runtime.");
|
|
16368
|
+
return new CubismInternalModel(coreModel, moc, settings, options);
|
|
16225
16369
|
},
|
|
16226
16370
|
createPhysics(_coreModel, data) {
|
|
16227
16371
|
if (!(data instanceof ArrayBuffer)) throw new TypeError("Cubism physics data must be an ArrayBuffer.");
|
|
@@ -16232,9 +16376,6 @@ Live2DFactory.registerRuntime({
|
|
|
16232
16376
|
return CubismPose.create(data, data.byteLength);
|
|
16233
16377
|
}
|
|
16234
16378
|
});
|
|
16235
|
-
function releaseMoc() {
|
|
16236
|
-
this.__moc?.release();
|
|
16237
|
-
}
|
|
16238
16379
|
//#endregion
|
|
16239
16380
|
export { Constant, CubismExpressionManager, CubismFramework, CubismInternalModel, CubismModelSettings, CubismMotionManager, CubismParallelMotionManager, ExpressionManager, FileLoader, FocusController, InternalModel, LOGICAL_HEIGHT, LOGICAL_WIDTH, Live2DFactory, Live2DLoader, Live2DModel, Live2DPlugin, Live2DTransform, LogLevel, MBToByte, ModelSettings, MotionManager, MotionPreloadStrategy, MotionPriority, MotionState, Option, SoundManager, VOLUME, XHRLoader, applyMixins, clamp, config, configureCubismSDK, copyArray, copyProperty, csmDelete, cubismReady, folderName, logger, normalizeHitAreaDefs, rand, reconfigureCubismSDK, remove, resolveURL, startUpCubism, strtod };
|
|
16240
16381
|
|