untitled-pixi-live2d-engine 1.3.2 → 1.3.4
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 +44 -10
- package/dist/cubism-legacy.js +44 -10
- package/dist/cubism-legacy.min.js +1 -1
- package/dist/cubism.es.js +44 -10
- package/dist/cubism.js +44 -10
- package/dist/cubism.min.js +1 -1
- package/dist/index.es.js +44 -10
- package/dist/index.js +44 -10
- package/dist/index.min.js +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +14 -0
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.4";
|
|
109
109
|
const logger = {
|
|
110
110
|
log(tag, ...messages) {
|
|
111
111
|
if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
|
|
@@ -2954,6 +2954,7 @@ class Live2DModel extends Container {
|
|
|
2954
2954
|
* @param options - Options for Live2DModel and Automator.
|
|
2955
2955
|
*/
|
|
2956
2956
|
constructor(options) {
|
|
2957
|
+
var _a;
|
|
2957
2958
|
super();
|
|
2958
2959
|
/** @internal */
|
|
2959
2960
|
__publicField(this, "renderPipeId", "live2d");
|
|
@@ -2972,6 +2973,7 @@ class Live2DModel extends Container {
|
|
|
2972
2973
|
*/
|
|
2973
2974
|
__publicField(this, "textures", []);
|
|
2974
2975
|
__publicField(this, "textureOptions");
|
|
2976
|
+
__publicField(this, "anchorMode");
|
|
2975
2977
|
__publicField(this, "textureLODStates", []);
|
|
2976
2978
|
__publicField(this, "textureLODFailures", []);
|
|
2977
2979
|
/** @override
|
|
@@ -3071,7 +3073,7 @@ class Live2DModel extends Container {
|
|
|
3071
3073
|
this.internalModel.updateTransform(internalTransform);
|
|
3072
3074
|
this.internalModel.draw(renderer.gl);
|
|
3073
3075
|
if (this._boundsRetryAfterDraw) {
|
|
3074
|
-
this.updateDrawableBounds();
|
|
3076
|
+
this.updateDrawableBounds(true);
|
|
3075
3077
|
}
|
|
3076
3078
|
renderer.state.resetState();
|
|
3077
3079
|
renderer.texture.resetState();
|
|
@@ -3088,6 +3090,7 @@ class Live2DModel extends Container {
|
|
|
3088
3090
|
}
|
|
3089
3091
|
});
|
|
3090
3092
|
this.textureOptions = options == null ? void 0 : options.textureOptions;
|
|
3093
|
+
this.anchorMode = (_a = options == null ? void 0 : options.anchorMode) != null ? _a : "canvas";
|
|
3091
3094
|
this.anchor = new ObservablePoint(
|
|
3092
3095
|
{
|
|
3093
3096
|
_onUpdate: () => this.onAnchorChange()
|
|
@@ -3172,7 +3175,7 @@ class Live2DModel extends Container {
|
|
|
3172
3175
|
}
|
|
3173
3176
|
return this._bounds;
|
|
3174
3177
|
}
|
|
3175
|
-
updateDrawableBounds() {
|
|
3178
|
+
updateDrawableBounds(applyAnchor = false) {
|
|
3176
3179
|
if (!this.internalModel) {
|
|
3177
3180
|
this._bounds.set(0, 0, 0, 0);
|
|
3178
3181
|
this._boundsDirty = false;
|
|
@@ -3216,7 +3219,25 @@ class Live2DModel extends Container {
|
|
|
3216
3219
|
}
|
|
3217
3220
|
this._boundsDirty = false;
|
|
3218
3221
|
this._didViewChangeTick++;
|
|
3219
|
-
this.
|
|
3222
|
+
if (applyAnchor && this.anchorMode === "drawable") {
|
|
3223
|
+
this.onAnchorChange();
|
|
3224
|
+
}
|
|
3225
|
+
}
|
|
3226
|
+
/**
|
|
3227
|
+
* Updates the model and its drawable bounds before Pixi calculates filter areas.
|
|
3228
|
+
* Filter pipes collect their framebuffer bounds before the Live2D render pipe runs,
|
|
3229
|
+
* so waiting until `renderLive2D()` is too late for animated vertices.
|
|
3230
|
+
*/
|
|
3231
|
+
prepareForRender() {
|
|
3232
|
+
if (!this.internalModel) {
|
|
3233
|
+
return;
|
|
3234
|
+
}
|
|
3235
|
+
const frameDelta = this.deltaTime;
|
|
3236
|
+
this.deltaTime = 0;
|
|
3237
|
+
if (frameDelta) {
|
|
3238
|
+
this.internalModel.update(frameDelta, this.elapsedTime);
|
|
3239
|
+
}
|
|
3240
|
+
this.updateDrawableBounds();
|
|
3220
3241
|
}
|
|
3221
3242
|
generateUID() {
|
|
3222
3243
|
return ++this.currentGlId;
|
|
@@ -3251,6 +3272,9 @@ class Live2DModel extends Container {
|
|
|
3251
3272
|
}
|
|
3252
3273
|
};
|
|
3253
3274
|
const effects = this.effects;
|
|
3275
|
+
if (effects == null ? void 0 : effects.length) {
|
|
3276
|
+
this.prepareForRender();
|
|
3277
|
+
}
|
|
3254
3278
|
if (effects) {
|
|
3255
3279
|
for (let i = 0; i < effects.length; i++) {
|
|
3256
3280
|
const effect = effects[i];
|
|
@@ -3282,7 +3306,10 @@ class Live2DModel extends Container {
|
|
|
3282
3306
|
*/
|
|
3283
3307
|
initializeOnModelLoad(_options) {
|
|
3284
3308
|
this.tag = `Live2DModel(${this.internalModel.settings.name})`;
|
|
3285
|
-
this.updateDrawableBounds();
|
|
3309
|
+
this.updateDrawableBounds(true);
|
|
3310
|
+
if (this.anchorMode === "canvas") {
|
|
3311
|
+
this.onAnchorChange();
|
|
3312
|
+
}
|
|
3286
3313
|
}
|
|
3287
3314
|
/**
|
|
3288
3315
|
* A callback that observes {@link anchor}, invoked when the anchor's values have been changed.
|
|
@@ -3292,11 +3319,18 @@ class Live2DModel extends Container {
|
|
|
3292
3319
|
if (!this.internalModel || !this.pivot) {
|
|
3293
3320
|
return;
|
|
3294
3321
|
}
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3322
|
+
if (this.anchorMode === "drawable") {
|
|
3323
|
+
const bounds = this.bounds;
|
|
3324
|
+
this.pivot.set(
|
|
3325
|
+
bounds.minX + this.anchor.x * bounds.width,
|
|
3326
|
+
bounds.minY + this.anchor.y * bounds.height
|
|
3327
|
+
);
|
|
3328
|
+
} else {
|
|
3329
|
+
this.pivot.set(
|
|
3330
|
+
this.anchor.x * this.internalModel.width,
|
|
3331
|
+
this.anchor.y * this.internalModel.height
|
|
3332
|
+
);
|
|
3333
|
+
}
|
|
3300
3334
|
}
|
|
3301
3335
|
/**
|
|
3302
3336
|
* Shorthand to start a motion.
|
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.4";
|
|
112
112
|
const logger = {
|
|
113
113
|
log(tag, ...messages) {
|
|
114
114
|
if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
|
|
@@ -2957,6 +2957,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
2957
2957
|
* @param options - Options for Live2DModel and Automator.
|
|
2958
2958
|
*/
|
|
2959
2959
|
constructor(options) {
|
|
2960
|
+
var _a;
|
|
2960
2961
|
super();
|
|
2961
2962
|
/** @internal */
|
|
2962
2963
|
__publicField(this, "renderPipeId", "live2d");
|
|
@@ -2975,6 +2976,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
2975
2976
|
*/
|
|
2976
2977
|
__publicField(this, "textures", []);
|
|
2977
2978
|
__publicField(this, "textureOptions");
|
|
2979
|
+
__publicField(this, "anchorMode");
|
|
2978
2980
|
__publicField(this, "textureLODStates", []);
|
|
2979
2981
|
__publicField(this, "textureLODFailures", []);
|
|
2980
2982
|
/** @override
|
|
@@ -3074,7 +3076,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3074
3076
|
this.internalModel.updateTransform(internalTransform);
|
|
3075
3077
|
this.internalModel.draw(renderer.gl);
|
|
3076
3078
|
if (this._boundsRetryAfterDraw) {
|
|
3077
|
-
this.updateDrawableBounds();
|
|
3079
|
+
this.updateDrawableBounds(true);
|
|
3078
3080
|
}
|
|
3079
3081
|
renderer.state.resetState();
|
|
3080
3082
|
renderer.texture.resetState();
|
|
@@ -3091,6 +3093,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3091
3093
|
}
|
|
3092
3094
|
});
|
|
3093
3095
|
this.textureOptions = options == null ? void 0 : options.textureOptions;
|
|
3096
|
+
this.anchorMode = (_a = options == null ? void 0 : options.anchorMode) != null ? _a : "canvas";
|
|
3094
3097
|
this.anchor = new pixi_js.ObservablePoint(
|
|
3095
3098
|
{
|
|
3096
3099
|
_onUpdate: () => this.onAnchorChange()
|
|
@@ -3175,7 +3178,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3175
3178
|
}
|
|
3176
3179
|
return this._bounds;
|
|
3177
3180
|
}
|
|
3178
|
-
updateDrawableBounds() {
|
|
3181
|
+
updateDrawableBounds(applyAnchor = false) {
|
|
3179
3182
|
if (!this.internalModel) {
|
|
3180
3183
|
this._bounds.set(0, 0, 0, 0);
|
|
3181
3184
|
this._boundsDirty = false;
|
|
@@ -3219,7 +3222,25 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3219
3222
|
}
|
|
3220
3223
|
this._boundsDirty = false;
|
|
3221
3224
|
this._didViewChangeTick++;
|
|
3222
|
-
this.
|
|
3225
|
+
if (applyAnchor && this.anchorMode === "drawable") {
|
|
3226
|
+
this.onAnchorChange();
|
|
3227
|
+
}
|
|
3228
|
+
}
|
|
3229
|
+
/**
|
|
3230
|
+
* Updates the model and its drawable bounds before Pixi calculates filter areas.
|
|
3231
|
+
* Filter pipes collect their framebuffer bounds before the Live2D render pipe runs,
|
|
3232
|
+
* so waiting until `renderLive2D()` is too late for animated vertices.
|
|
3233
|
+
*/
|
|
3234
|
+
prepareForRender() {
|
|
3235
|
+
if (!this.internalModel) {
|
|
3236
|
+
return;
|
|
3237
|
+
}
|
|
3238
|
+
const frameDelta = this.deltaTime;
|
|
3239
|
+
this.deltaTime = 0;
|
|
3240
|
+
if (frameDelta) {
|
|
3241
|
+
this.internalModel.update(frameDelta, this.elapsedTime);
|
|
3242
|
+
}
|
|
3243
|
+
this.updateDrawableBounds();
|
|
3223
3244
|
}
|
|
3224
3245
|
generateUID() {
|
|
3225
3246
|
return ++this.currentGlId;
|
|
@@ -3254,6 +3275,9 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3254
3275
|
}
|
|
3255
3276
|
};
|
|
3256
3277
|
const effects = this.effects;
|
|
3278
|
+
if (effects == null ? void 0 : effects.length) {
|
|
3279
|
+
this.prepareForRender();
|
|
3280
|
+
}
|
|
3257
3281
|
if (effects) {
|
|
3258
3282
|
for (let i = 0; i < effects.length; i++) {
|
|
3259
3283
|
const effect = effects[i];
|
|
@@ -3285,7 +3309,10 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3285
3309
|
*/
|
|
3286
3310
|
initializeOnModelLoad(_options) {
|
|
3287
3311
|
this.tag = `Live2DModel(${this.internalModel.settings.name})`;
|
|
3288
|
-
this.updateDrawableBounds();
|
|
3312
|
+
this.updateDrawableBounds(true);
|
|
3313
|
+
if (this.anchorMode === "canvas") {
|
|
3314
|
+
this.onAnchorChange();
|
|
3315
|
+
}
|
|
3289
3316
|
}
|
|
3290
3317
|
/**
|
|
3291
3318
|
* A callback that observes {@link anchor}, invoked when the anchor's values have been changed.
|
|
@@ -3295,11 +3322,18 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3295
3322
|
if (!this.internalModel || !this.pivot) {
|
|
3296
3323
|
return;
|
|
3297
3324
|
}
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3325
|
+
if (this.anchorMode === "drawable") {
|
|
3326
|
+
const bounds = this.bounds;
|
|
3327
|
+
this.pivot.set(
|
|
3328
|
+
bounds.minX + this.anchor.x * bounds.width,
|
|
3329
|
+
bounds.minY + this.anchor.y * bounds.height
|
|
3330
|
+
);
|
|
3331
|
+
} else {
|
|
3332
|
+
this.pivot.set(
|
|
3333
|
+
this.anchor.x * this.internalModel.width,
|
|
3334
|
+
this.anchor.y * this.internalModel.height
|
|
3335
|
+
);
|
|
3336
|
+
}
|
|
3303
3337
|
}
|
|
3304
3338
|
/**
|
|
3305
3339
|
* Shorthand to start a motion.
|