untitled-pixi-live2d-engine 1.3.1 → 1.3.3
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 +31 -9
- package/dist/cubism-legacy.js +31 -9
- package/dist/cubism-legacy.min.js +1 -1
- package/dist/cubism.es.js +39 -10
- package/dist/cubism.js +39 -10
- package/dist/cubism.min.js +1 -1
- package/dist/index.es.js +39 -10
- package/dist/index.js +39 -10
- package/dist/index.min.js +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +8 -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.3";
|
|
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
|
|
@@ -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()
|
|
@@ -3215,6 +3218,10 @@ class Live2DModel extends Container {
|
|
|
3215
3218
|
this._boundsRetryAfterDraw = true;
|
|
3216
3219
|
}
|
|
3217
3220
|
this._boundsDirty = false;
|
|
3221
|
+
this._didViewChangeTick++;
|
|
3222
|
+
if (this.anchorMode === "drawable") {
|
|
3223
|
+
this.onAnchorChange();
|
|
3224
|
+
}
|
|
3218
3225
|
}
|
|
3219
3226
|
generateUID() {
|
|
3220
3227
|
return ++this.currentGlId;
|
|
@@ -3280,8 +3287,10 @@ class Live2DModel extends Container {
|
|
|
3280
3287
|
*/
|
|
3281
3288
|
initializeOnModelLoad(_options) {
|
|
3282
3289
|
this.tag = `Live2DModel(${this.internalModel.settings.name})`;
|
|
3283
|
-
this.onAnchorChange();
|
|
3284
3290
|
this.updateDrawableBounds();
|
|
3291
|
+
if (this.anchorMode === "canvas") {
|
|
3292
|
+
this.onAnchorChange();
|
|
3293
|
+
}
|
|
3285
3294
|
}
|
|
3286
3295
|
/**
|
|
3287
3296
|
* A callback that observes {@link anchor}, invoked when the anchor's values have been changed.
|
|
@@ -3291,10 +3300,18 @@ class Live2DModel extends Container {
|
|
|
3291
3300
|
if (!this.internalModel || !this.pivot) {
|
|
3292
3301
|
return;
|
|
3293
3302
|
}
|
|
3294
|
-
this.
|
|
3295
|
-
|
|
3296
|
-
this.
|
|
3297
|
-
|
|
3303
|
+
if (this.anchorMode === "drawable") {
|
|
3304
|
+
const bounds = this.bounds;
|
|
3305
|
+
this.pivot.set(
|
|
3306
|
+
bounds.minX + this.anchor.x * bounds.width,
|
|
3307
|
+
bounds.minY + this.anchor.y * bounds.height
|
|
3308
|
+
);
|
|
3309
|
+
} else {
|
|
3310
|
+
this.pivot.set(
|
|
3311
|
+
this.anchor.x * this.internalModel.width,
|
|
3312
|
+
this.anchor.y * this.internalModel.height
|
|
3313
|
+
);
|
|
3314
|
+
}
|
|
3298
3315
|
}
|
|
3299
3316
|
/**
|
|
3300
3317
|
* Shorthand to start a motion.
|
|
@@ -3526,9 +3543,14 @@ class Live2DModel extends Container {
|
|
|
3526
3543
|
this.getBounds().set(0, 0, 0, 0);
|
|
3527
3544
|
return;
|
|
3528
3545
|
}
|
|
3529
|
-
const
|
|
3530
|
-
|
|
3531
|
-
|
|
3546
|
+
const bounds = this.bounds;
|
|
3547
|
+
this.getBounds().addFrame(
|
|
3548
|
+
bounds.minX,
|
|
3549
|
+
bounds.minY,
|
|
3550
|
+
bounds.maxX,
|
|
3551
|
+
bounds.maxY,
|
|
3552
|
+
this.transform.matrix
|
|
3553
|
+
);
|
|
3532
3554
|
}
|
|
3533
3555
|
/**
|
|
3534
3556
|
* Updates the model. Note this method just updates the timer,
|
|
@@ -12726,8 +12748,15 @@ class CubismInternalModel extends InternalModel {
|
|
|
12726
12748
|
array[13] = matrix.ty;
|
|
12727
12749
|
this.renderer.setMvpMatrix(tempMatrix);
|
|
12728
12750
|
const framebuffer = gl.getParameter(gl.FRAMEBUFFER_BINDING);
|
|
12751
|
+
const previousCullFaceMode = gl.getParameter(gl.CULL_FACE_MODE);
|
|
12752
|
+
const determinant = array[0] * array[5] - array[1] * array[4];
|
|
12753
|
+
gl.cullFace(determinant < 0 ? gl.FRONT : gl.BACK);
|
|
12729
12754
|
this.renderer.setRenderState(framebuffer, this.viewport);
|
|
12730
|
-
|
|
12755
|
+
try {
|
|
12756
|
+
this.renderer.drawModel();
|
|
12757
|
+
} finally {
|
|
12758
|
+
gl.cullFace(previousCullFaceMode);
|
|
12759
|
+
}
|
|
12731
12760
|
}
|
|
12732
12761
|
extendParallelMotionManager(managerCount) {
|
|
12733
12762
|
while (this.parallelMotionManager.length < managerCount) {
|
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.3";
|
|
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
|
|
@@ -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()
|
|
@@ -3218,6 +3221,10 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3218
3221
|
this._boundsRetryAfterDraw = true;
|
|
3219
3222
|
}
|
|
3220
3223
|
this._boundsDirty = false;
|
|
3224
|
+
this._didViewChangeTick++;
|
|
3225
|
+
if (this.anchorMode === "drawable") {
|
|
3226
|
+
this.onAnchorChange();
|
|
3227
|
+
}
|
|
3221
3228
|
}
|
|
3222
3229
|
generateUID() {
|
|
3223
3230
|
return ++this.currentGlId;
|
|
@@ -3283,8 +3290,10 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3283
3290
|
*/
|
|
3284
3291
|
initializeOnModelLoad(_options) {
|
|
3285
3292
|
this.tag = `Live2DModel(${this.internalModel.settings.name})`;
|
|
3286
|
-
this.onAnchorChange();
|
|
3287
3293
|
this.updateDrawableBounds();
|
|
3294
|
+
if (this.anchorMode === "canvas") {
|
|
3295
|
+
this.onAnchorChange();
|
|
3296
|
+
}
|
|
3288
3297
|
}
|
|
3289
3298
|
/**
|
|
3290
3299
|
* A callback that observes {@link anchor}, invoked when the anchor's values have been changed.
|
|
@@ -3294,10 +3303,18 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3294
3303
|
if (!this.internalModel || !this.pivot) {
|
|
3295
3304
|
return;
|
|
3296
3305
|
}
|
|
3297
|
-
this.
|
|
3298
|
-
|
|
3299
|
-
this.
|
|
3300
|
-
|
|
3306
|
+
if (this.anchorMode === "drawable") {
|
|
3307
|
+
const bounds = this.bounds;
|
|
3308
|
+
this.pivot.set(
|
|
3309
|
+
bounds.minX + this.anchor.x * bounds.width,
|
|
3310
|
+
bounds.minY + this.anchor.y * bounds.height
|
|
3311
|
+
);
|
|
3312
|
+
} else {
|
|
3313
|
+
this.pivot.set(
|
|
3314
|
+
this.anchor.x * this.internalModel.width,
|
|
3315
|
+
this.anchor.y * this.internalModel.height
|
|
3316
|
+
);
|
|
3317
|
+
}
|
|
3301
3318
|
}
|
|
3302
3319
|
/**
|
|
3303
3320
|
* Shorthand to start a motion.
|
|
@@ -3529,9 +3546,14 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3529
3546
|
this.getBounds().set(0, 0, 0, 0);
|
|
3530
3547
|
return;
|
|
3531
3548
|
}
|
|
3532
|
-
const
|
|
3533
|
-
|
|
3534
|
-
|
|
3549
|
+
const bounds = this.bounds;
|
|
3550
|
+
this.getBounds().addFrame(
|
|
3551
|
+
bounds.minX,
|
|
3552
|
+
bounds.minY,
|
|
3553
|
+
bounds.maxX,
|
|
3554
|
+
bounds.maxY,
|
|
3555
|
+
this.transform.matrix
|
|
3556
|
+
);
|
|
3535
3557
|
}
|
|
3536
3558
|
/**
|
|
3537
3559
|
* Updates the model. Note this method just updates the timer,
|
|
@@ -12729,8 +12751,15 @@ var __async = (__this, __arguments, generator) => {
|
|
|
12729
12751
|
array[13] = matrix.ty;
|
|
12730
12752
|
this.renderer.setMvpMatrix(tempMatrix);
|
|
12731
12753
|
const framebuffer = gl.getParameter(gl.FRAMEBUFFER_BINDING);
|
|
12754
|
+
const previousCullFaceMode = gl.getParameter(gl.CULL_FACE_MODE);
|
|
12755
|
+
const determinant = array[0] * array[5] - array[1] * array[4];
|
|
12756
|
+
gl.cullFace(determinant < 0 ? gl.FRONT : gl.BACK);
|
|
12732
12757
|
this.renderer.setRenderState(framebuffer, this.viewport);
|
|
12733
|
-
|
|
12758
|
+
try {
|
|
12759
|
+
this.renderer.drawModel();
|
|
12760
|
+
} finally {
|
|
12761
|
+
gl.cullFace(previousCullFaceMode);
|
|
12762
|
+
}
|
|
12734
12763
|
}
|
|
12735
12764
|
extendParallelMotionManager(managerCount) {
|
|
12736
12765
|
while (this.parallelMotionManager.length < managerCount) {
|