untitled-pixi-live2d-engine 1.3.3 → 1.3.5
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/cubism-legacy.es.js +41 -6
- package/dist/cubism-legacy.js +41 -6
- package/dist/cubism-legacy.min.js +1 -1
- package/dist/cubism.es.js +41 -6
- package/dist/cubism.js +41 -6
- package/dist/cubism.min.js +1 -1
- package/dist/index.es.js +41 -6
- package/dist/index.js +41 -6
- package/dist/index.min.js +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +15 -1
package/dist/index.es.js
CHANGED
|
@@ -105,7 +105,7 @@ const config = {
|
|
|
105
105
|
preserveExpressionOnMotion: true,
|
|
106
106
|
cubism: CubismFrameworkConfig
|
|
107
107
|
};
|
|
108
|
-
const VERSION = "1.3.
|
|
108
|
+
const VERSION = "1.3.5";
|
|
109
109
|
const logger = {
|
|
110
110
|
log(tag, ...messages) {
|
|
111
111
|
if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
|
|
@@ -2854,13 +2854,29 @@ class Live2DPipe {
|
|
|
2854
2854
|
constructor(renderer) {
|
|
2855
2855
|
this.renderer = renderer;
|
|
2856
2856
|
}
|
|
2857
|
+
addPrepare(prepare, instructionSet) {
|
|
2858
|
+
var _a, _b;
|
|
2859
|
+
const renderPipes = this.renderer.renderPipes;
|
|
2860
|
+
(_b = (_a = renderPipes.batch) == null ? void 0 : _a.break) == null ? void 0 : _b.call(_a, instructionSet);
|
|
2861
|
+
instructionSet.add({
|
|
2862
|
+
renderPipeId: "live2d",
|
|
2863
|
+
action: "prepare",
|
|
2864
|
+
canBundle: false,
|
|
2865
|
+
prepare
|
|
2866
|
+
});
|
|
2867
|
+
}
|
|
2857
2868
|
addRenderable(model, instructionSet) {
|
|
2858
2869
|
var _a, _b;
|
|
2859
2870
|
const renderPipes = this.renderer.renderPipes;
|
|
2860
2871
|
(_b = (_a = renderPipes.batch) == null ? void 0 : _a.break) == null ? void 0 : _b.call(_a, instructionSet);
|
|
2861
2872
|
instructionSet.add(model);
|
|
2862
2873
|
}
|
|
2863
|
-
execute(
|
|
2874
|
+
execute(instruction) {
|
|
2875
|
+
if (!(instruction instanceof Live2DModel)) {
|
|
2876
|
+
instruction.prepare();
|
|
2877
|
+
return;
|
|
2878
|
+
}
|
|
2879
|
+
const model = instruction;
|
|
2864
2880
|
if (!model.visible || model.alpha <= 0) {
|
|
2865
2881
|
return;
|
|
2866
2882
|
}
|
|
@@ -3073,7 +3089,7 @@ class Live2DModel extends Container {
|
|
|
3073
3089
|
this.internalModel.updateTransform(internalTransform);
|
|
3074
3090
|
this.internalModel.draw(renderer.gl);
|
|
3075
3091
|
if (this._boundsRetryAfterDraw) {
|
|
3076
|
-
this.updateDrawableBounds();
|
|
3092
|
+
this.updateDrawableBounds(true);
|
|
3077
3093
|
}
|
|
3078
3094
|
renderer.state.resetState();
|
|
3079
3095
|
renderer.texture.resetState();
|
|
@@ -3175,7 +3191,7 @@ class Live2DModel extends Container {
|
|
|
3175
3191
|
}
|
|
3176
3192
|
return this._bounds;
|
|
3177
3193
|
}
|
|
3178
|
-
updateDrawableBounds() {
|
|
3194
|
+
updateDrawableBounds(applyAnchor = false) {
|
|
3179
3195
|
if (!this.internalModel) {
|
|
3180
3196
|
this._bounds.set(0, 0, 0, 0);
|
|
3181
3197
|
this._boundsDirty = false;
|
|
@@ -3219,10 +3235,26 @@ class Live2DModel extends Container {
|
|
|
3219
3235
|
}
|
|
3220
3236
|
this._boundsDirty = false;
|
|
3221
3237
|
this._didViewChangeTick++;
|
|
3222
|
-
if (this.anchorMode === "drawable") {
|
|
3238
|
+
if (applyAnchor && this.anchorMode === "drawable") {
|
|
3223
3239
|
this.onAnchorChange();
|
|
3224
3240
|
}
|
|
3225
3241
|
}
|
|
3242
|
+
/**
|
|
3243
|
+
* Updates the model and its drawable bounds before Pixi calculates filter areas.
|
|
3244
|
+
* Filter pipes collect their framebuffer bounds before the Live2D render pipe runs,
|
|
3245
|
+
* so waiting until `renderLive2D()` is too late for animated vertices.
|
|
3246
|
+
*/
|
|
3247
|
+
prepareForRender() {
|
|
3248
|
+
if (!this.internalModel) {
|
|
3249
|
+
return;
|
|
3250
|
+
}
|
|
3251
|
+
const frameDelta = this.deltaTime;
|
|
3252
|
+
this.deltaTime = 0;
|
|
3253
|
+
if (frameDelta) {
|
|
3254
|
+
this.internalModel.update(frameDelta, this.elapsedTime);
|
|
3255
|
+
}
|
|
3256
|
+
this.updateDrawableBounds();
|
|
3257
|
+
}
|
|
3226
3258
|
generateUID() {
|
|
3227
3259
|
return ++this.currentGlId;
|
|
3228
3260
|
}
|
|
@@ -3257,6 +3289,9 @@ class Live2DModel extends Container {
|
|
|
3257
3289
|
};
|
|
3258
3290
|
const effects = this.effects;
|
|
3259
3291
|
if (effects) {
|
|
3292
|
+
if (effects.length) {
|
|
3293
|
+
renderPipes.live2d.addPrepare(() => this.prepareForRender(), instructionSet);
|
|
3294
|
+
}
|
|
3260
3295
|
for (let i = 0; i < effects.length; i++) {
|
|
3261
3296
|
const effect = effects[i];
|
|
3262
3297
|
const filters = effect.filters;
|
|
@@ -3287,7 +3322,7 @@ class Live2DModel extends Container {
|
|
|
3287
3322
|
*/
|
|
3288
3323
|
initializeOnModelLoad(_options) {
|
|
3289
3324
|
this.tag = `Live2DModel(${this.internalModel.settings.name})`;
|
|
3290
|
-
this.updateDrawableBounds();
|
|
3325
|
+
this.updateDrawableBounds(true);
|
|
3291
3326
|
if (this.anchorMode === "canvas") {
|
|
3292
3327
|
this.onAnchorChange();
|
|
3293
3328
|
}
|
package/dist/index.js
CHANGED
|
@@ -108,7 +108,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
108
108
|
preserveExpressionOnMotion: true,
|
|
109
109
|
cubism: CubismFrameworkConfig
|
|
110
110
|
};
|
|
111
|
-
const VERSION = "1.3.
|
|
111
|
+
const VERSION = "1.3.5";
|
|
112
112
|
const logger = {
|
|
113
113
|
log(tag, ...messages) {
|
|
114
114
|
if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
|
|
@@ -2857,13 +2857,29 @@ var __async = (__this, __arguments, generator) => {
|
|
|
2857
2857
|
constructor(renderer) {
|
|
2858
2858
|
this.renderer = renderer;
|
|
2859
2859
|
}
|
|
2860
|
+
addPrepare(prepare, instructionSet) {
|
|
2861
|
+
var _a, _b;
|
|
2862
|
+
const renderPipes = this.renderer.renderPipes;
|
|
2863
|
+
(_b = (_a = renderPipes.batch) == null ? void 0 : _a.break) == null ? void 0 : _b.call(_a, instructionSet);
|
|
2864
|
+
instructionSet.add({
|
|
2865
|
+
renderPipeId: "live2d",
|
|
2866
|
+
action: "prepare",
|
|
2867
|
+
canBundle: false,
|
|
2868
|
+
prepare
|
|
2869
|
+
});
|
|
2870
|
+
}
|
|
2860
2871
|
addRenderable(model, instructionSet) {
|
|
2861
2872
|
var _a, _b;
|
|
2862
2873
|
const renderPipes = this.renderer.renderPipes;
|
|
2863
2874
|
(_b = (_a = renderPipes.batch) == null ? void 0 : _a.break) == null ? void 0 : _b.call(_a, instructionSet);
|
|
2864
2875
|
instructionSet.add(model);
|
|
2865
2876
|
}
|
|
2866
|
-
execute(
|
|
2877
|
+
execute(instruction) {
|
|
2878
|
+
if (!(instruction instanceof Live2DModel)) {
|
|
2879
|
+
instruction.prepare();
|
|
2880
|
+
return;
|
|
2881
|
+
}
|
|
2882
|
+
const model = instruction;
|
|
2867
2883
|
if (!model.visible || model.alpha <= 0) {
|
|
2868
2884
|
return;
|
|
2869
2885
|
}
|
|
@@ -3076,7 +3092,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3076
3092
|
this.internalModel.updateTransform(internalTransform);
|
|
3077
3093
|
this.internalModel.draw(renderer.gl);
|
|
3078
3094
|
if (this._boundsRetryAfterDraw) {
|
|
3079
|
-
this.updateDrawableBounds();
|
|
3095
|
+
this.updateDrawableBounds(true);
|
|
3080
3096
|
}
|
|
3081
3097
|
renderer.state.resetState();
|
|
3082
3098
|
renderer.texture.resetState();
|
|
@@ -3178,7 +3194,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3178
3194
|
}
|
|
3179
3195
|
return this._bounds;
|
|
3180
3196
|
}
|
|
3181
|
-
updateDrawableBounds() {
|
|
3197
|
+
updateDrawableBounds(applyAnchor = false) {
|
|
3182
3198
|
if (!this.internalModel) {
|
|
3183
3199
|
this._bounds.set(0, 0, 0, 0);
|
|
3184
3200
|
this._boundsDirty = false;
|
|
@@ -3222,10 +3238,26 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3222
3238
|
}
|
|
3223
3239
|
this._boundsDirty = false;
|
|
3224
3240
|
this._didViewChangeTick++;
|
|
3225
|
-
if (this.anchorMode === "drawable") {
|
|
3241
|
+
if (applyAnchor && this.anchorMode === "drawable") {
|
|
3226
3242
|
this.onAnchorChange();
|
|
3227
3243
|
}
|
|
3228
3244
|
}
|
|
3245
|
+
/**
|
|
3246
|
+
* Updates the model and its drawable bounds before Pixi calculates filter areas.
|
|
3247
|
+
* Filter pipes collect their framebuffer bounds before the Live2D render pipe runs,
|
|
3248
|
+
* so waiting until `renderLive2D()` is too late for animated vertices.
|
|
3249
|
+
*/
|
|
3250
|
+
prepareForRender() {
|
|
3251
|
+
if (!this.internalModel) {
|
|
3252
|
+
return;
|
|
3253
|
+
}
|
|
3254
|
+
const frameDelta = this.deltaTime;
|
|
3255
|
+
this.deltaTime = 0;
|
|
3256
|
+
if (frameDelta) {
|
|
3257
|
+
this.internalModel.update(frameDelta, this.elapsedTime);
|
|
3258
|
+
}
|
|
3259
|
+
this.updateDrawableBounds();
|
|
3260
|
+
}
|
|
3229
3261
|
generateUID() {
|
|
3230
3262
|
return ++this.currentGlId;
|
|
3231
3263
|
}
|
|
@@ -3260,6 +3292,9 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3260
3292
|
};
|
|
3261
3293
|
const effects = this.effects;
|
|
3262
3294
|
if (effects) {
|
|
3295
|
+
if (effects.length) {
|
|
3296
|
+
renderPipes.live2d.addPrepare(() => this.prepareForRender(), instructionSet);
|
|
3297
|
+
}
|
|
3263
3298
|
for (let i = 0; i < effects.length; i++) {
|
|
3264
3299
|
const effect = effects[i];
|
|
3265
3300
|
const filters = effect.filters;
|
|
@@ -3290,7 +3325,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3290
3325
|
*/
|
|
3291
3326
|
initializeOnModelLoad(_options) {
|
|
3292
3327
|
this.tag = `Live2DModel(${this.internalModel.settings.name})`;
|
|
3293
|
-
this.updateDrawableBounds();
|
|
3328
|
+
this.updateDrawableBounds(true);
|
|
3294
3329
|
if (this.anchorMode === "canvas") {
|
|
3295
3330
|
this.onAnchorChange();
|
|
3296
3331
|
}
|