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/cubism.es.js
CHANGED
|
@@ -2759,7 +2759,7 @@ const config = {
|
|
|
2759
2759
|
preserveExpressionOnMotion: true,
|
|
2760
2760
|
cubism: CubismFrameworkConfig
|
|
2761
2761
|
};
|
|
2762
|
-
const VERSION = "1.3.
|
|
2762
|
+
const VERSION = "1.3.4";
|
|
2763
2763
|
const logger = {
|
|
2764
2764
|
log(tag, ...messages) {
|
|
2765
2765
|
if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
|
|
@@ -5608,6 +5608,7 @@ class Live2DModel extends Container {
|
|
|
5608
5608
|
* @param options - Options for Live2DModel and Automator.
|
|
5609
5609
|
*/
|
|
5610
5610
|
constructor(options) {
|
|
5611
|
+
var _a;
|
|
5611
5612
|
super();
|
|
5612
5613
|
/** @internal */
|
|
5613
5614
|
__publicField(this, "renderPipeId", "live2d");
|
|
@@ -5626,6 +5627,7 @@ class Live2DModel extends Container {
|
|
|
5626
5627
|
*/
|
|
5627
5628
|
__publicField(this, "textures", []);
|
|
5628
5629
|
__publicField(this, "textureOptions");
|
|
5630
|
+
__publicField(this, "anchorMode");
|
|
5629
5631
|
__publicField(this, "textureLODStates", []);
|
|
5630
5632
|
__publicField(this, "textureLODFailures", []);
|
|
5631
5633
|
/** @override
|
|
@@ -5725,7 +5727,7 @@ class Live2DModel extends Container {
|
|
|
5725
5727
|
this.internalModel.updateTransform(internalTransform);
|
|
5726
5728
|
this.internalModel.draw(renderer.gl);
|
|
5727
5729
|
if (this._boundsRetryAfterDraw) {
|
|
5728
|
-
this.updateDrawableBounds();
|
|
5730
|
+
this.updateDrawableBounds(true);
|
|
5729
5731
|
}
|
|
5730
5732
|
renderer.state.resetState();
|
|
5731
5733
|
renderer.texture.resetState();
|
|
@@ -5742,6 +5744,7 @@ class Live2DModel extends Container {
|
|
|
5742
5744
|
}
|
|
5743
5745
|
});
|
|
5744
5746
|
this.textureOptions = options == null ? void 0 : options.textureOptions;
|
|
5747
|
+
this.anchorMode = (_a = options == null ? void 0 : options.anchorMode) != null ? _a : "canvas";
|
|
5745
5748
|
this.anchor = new ObservablePoint(
|
|
5746
5749
|
{
|
|
5747
5750
|
_onUpdate: () => this.onAnchorChange()
|
|
@@ -5826,7 +5829,7 @@ class Live2DModel extends Container {
|
|
|
5826
5829
|
}
|
|
5827
5830
|
return this._bounds;
|
|
5828
5831
|
}
|
|
5829
|
-
updateDrawableBounds() {
|
|
5832
|
+
updateDrawableBounds(applyAnchor = false) {
|
|
5830
5833
|
if (!this.internalModel) {
|
|
5831
5834
|
this._bounds.set(0, 0, 0, 0);
|
|
5832
5835
|
this._boundsDirty = false;
|
|
@@ -5870,7 +5873,25 @@ class Live2DModel extends Container {
|
|
|
5870
5873
|
}
|
|
5871
5874
|
this._boundsDirty = false;
|
|
5872
5875
|
this._didViewChangeTick++;
|
|
5873
|
-
this.
|
|
5876
|
+
if (applyAnchor && this.anchorMode === "drawable") {
|
|
5877
|
+
this.onAnchorChange();
|
|
5878
|
+
}
|
|
5879
|
+
}
|
|
5880
|
+
/**
|
|
5881
|
+
* Updates the model and its drawable bounds before Pixi calculates filter areas.
|
|
5882
|
+
* Filter pipes collect their framebuffer bounds before the Live2D render pipe runs,
|
|
5883
|
+
* so waiting until `renderLive2D()` is too late for animated vertices.
|
|
5884
|
+
*/
|
|
5885
|
+
prepareForRender() {
|
|
5886
|
+
if (!this.internalModel) {
|
|
5887
|
+
return;
|
|
5888
|
+
}
|
|
5889
|
+
const frameDelta = this.deltaTime;
|
|
5890
|
+
this.deltaTime = 0;
|
|
5891
|
+
if (frameDelta) {
|
|
5892
|
+
this.internalModel.update(frameDelta, this.elapsedTime);
|
|
5893
|
+
}
|
|
5894
|
+
this.updateDrawableBounds();
|
|
5874
5895
|
}
|
|
5875
5896
|
generateUID() {
|
|
5876
5897
|
return ++this.currentGlId;
|
|
@@ -5905,6 +5926,9 @@ class Live2DModel extends Container {
|
|
|
5905
5926
|
}
|
|
5906
5927
|
};
|
|
5907
5928
|
const effects = this.effects;
|
|
5929
|
+
if (effects == null ? void 0 : effects.length) {
|
|
5930
|
+
this.prepareForRender();
|
|
5931
|
+
}
|
|
5908
5932
|
if (effects) {
|
|
5909
5933
|
for (let i = 0; i < effects.length; i++) {
|
|
5910
5934
|
const effect = effects[i];
|
|
@@ -5936,7 +5960,10 @@ class Live2DModel extends Container {
|
|
|
5936
5960
|
*/
|
|
5937
5961
|
initializeOnModelLoad(_options) {
|
|
5938
5962
|
this.tag = `Live2DModel(${this.internalModel.settings.name})`;
|
|
5939
|
-
this.updateDrawableBounds();
|
|
5963
|
+
this.updateDrawableBounds(true);
|
|
5964
|
+
if (this.anchorMode === "canvas") {
|
|
5965
|
+
this.onAnchorChange();
|
|
5966
|
+
}
|
|
5940
5967
|
}
|
|
5941
5968
|
/**
|
|
5942
5969
|
* A callback that observes {@link anchor}, invoked when the anchor's values have been changed.
|
|
@@ -5946,11 +5973,18 @@ class Live2DModel extends Container {
|
|
|
5946
5973
|
if (!this.internalModel || !this.pivot) {
|
|
5947
5974
|
return;
|
|
5948
5975
|
}
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5976
|
+
if (this.anchorMode === "drawable") {
|
|
5977
|
+
const bounds = this.bounds;
|
|
5978
|
+
this.pivot.set(
|
|
5979
|
+
bounds.minX + this.anchor.x * bounds.width,
|
|
5980
|
+
bounds.minY + this.anchor.y * bounds.height
|
|
5981
|
+
);
|
|
5982
|
+
} else {
|
|
5983
|
+
this.pivot.set(
|
|
5984
|
+
this.anchor.x * this.internalModel.width,
|
|
5985
|
+
this.anchor.y * this.internalModel.height
|
|
5986
|
+
);
|
|
5987
|
+
}
|
|
5954
5988
|
}
|
|
5955
5989
|
/**
|
|
5956
5990
|
* Shorthand to start a motion.
|
package/dist/cubism.js
CHANGED
|
@@ -2762,7 +2762,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
2762
2762
|
preserveExpressionOnMotion: true,
|
|
2763
2763
|
cubism: CubismFrameworkConfig
|
|
2764
2764
|
};
|
|
2765
|
-
const VERSION = "1.3.
|
|
2765
|
+
const VERSION = "1.3.4";
|
|
2766
2766
|
const logger = {
|
|
2767
2767
|
log(tag, ...messages) {
|
|
2768
2768
|
if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
|
|
@@ -5611,6 +5611,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
5611
5611
|
* @param options - Options for Live2DModel and Automator.
|
|
5612
5612
|
*/
|
|
5613
5613
|
constructor(options) {
|
|
5614
|
+
var _a;
|
|
5614
5615
|
super();
|
|
5615
5616
|
/** @internal */
|
|
5616
5617
|
__publicField(this, "renderPipeId", "live2d");
|
|
@@ -5629,6 +5630,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
5629
5630
|
*/
|
|
5630
5631
|
__publicField(this, "textures", []);
|
|
5631
5632
|
__publicField(this, "textureOptions");
|
|
5633
|
+
__publicField(this, "anchorMode");
|
|
5632
5634
|
__publicField(this, "textureLODStates", []);
|
|
5633
5635
|
__publicField(this, "textureLODFailures", []);
|
|
5634
5636
|
/** @override
|
|
@@ -5728,7 +5730,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
5728
5730
|
this.internalModel.updateTransform(internalTransform);
|
|
5729
5731
|
this.internalModel.draw(renderer.gl);
|
|
5730
5732
|
if (this._boundsRetryAfterDraw) {
|
|
5731
|
-
this.updateDrawableBounds();
|
|
5733
|
+
this.updateDrawableBounds(true);
|
|
5732
5734
|
}
|
|
5733
5735
|
renderer.state.resetState();
|
|
5734
5736
|
renderer.texture.resetState();
|
|
@@ -5745,6 +5747,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
5745
5747
|
}
|
|
5746
5748
|
});
|
|
5747
5749
|
this.textureOptions = options == null ? void 0 : options.textureOptions;
|
|
5750
|
+
this.anchorMode = (_a = options == null ? void 0 : options.anchorMode) != null ? _a : "canvas";
|
|
5748
5751
|
this.anchor = new pixi_js.ObservablePoint(
|
|
5749
5752
|
{
|
|
5750
5753
|
_onUpdate: () => this.onAnchorChange()
|
|
@@ -5829,7 +5832,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
5829
5832
|
}
|
|
5830
5833
|
return this._bounds;
|
|
5831
5834
|
}
|
|
5832
|
-
updateDrawableBounds() {
|
|
5835
|
+
updateDrawableBounds(applyAnchor = false) {
|
|
5833
5836
|
if (!this.internalModel) {
|
|
5834
5837
|
this._bounds.set(0, 0, 0, 0);
|
|
5835
5838
|
this._boundsDirty = false;
|
|
@@ -5873,7 +5876,25 @@ var __async = (__this, __arguments, generator) => {
|
|
|
5873
5876
|
}
|
|
5874
5877
|
this._boundsDirty = false;
|
|
5875
5878
|
this._didViewChangeTick++;
|
|
5876
|
-
this.
|
|
5879
|
+
if (applyAnchor && this.anchorMode === "drawable") {
|
|
5880
|
+
this.onAnchorChange();
|
|
5881
|
+
}
|
|
5882
|
+
}
|
|
5883
|
+
/**
|
|
5884
|
+
* Updates the model and its drawable bounds before Pixi calculates filter areas.
|
|
5885
|
+
* Filter pipes collect their framebuffer bounds before the Live2D render pipe runs,
|
|
5886
|
+
* so waiting until `renderLive2D()` is too late for animated vertices.
|
|
5887
|
+
*/
|
|
5888
|
+
prepareForRender() {
|
|
5889
|
+
if (!this.internalModel) {
|
|
5890
|
+
return;
|
|
5891
|
+
}
|
|
5892
|
+
const frameDelta = this.deltaTime;
|
|
5893
|
+
this.deltaTime = 0;
|
|
5894
|
+
if (frameDelta) {
|
|
5895
|
+
this.internalModel.update(frameDelta, this.elapsedTime);
|
|
5896
|
+
}
|
|
5897
|
+
this.updateDrawableBounds();
|
|
5877
5898
|
}
|
|
5878
5899
|
generateUID() {
|
|
5879
5900
|
return ++this.currentGlId;
|
|
@@ -5908,6 +5929,9 @@ var __async = (__this, __arguments, generator) => {
|
|
|
5908
5929
|
}
|
|
5909
5930
|
};
|
|
5910
5931
|
const effects = this.effects;
|
|
5932
|
+
if (effects == null ? void 0 : effects.length) {
|
|
5933
|
+
this.prepareForRender();
|
|
5934
|
+
}
|
|
5911
5935
|
if (effects) {
|
|
5912
5936
|
for (let i = 0; i < effects.length; i++) {
|
|
5913
5937
|
const effect = effects[i];
|
|
@@ -5939,7 +5963,10 @@ var __async = (__this, __arguments, generator) => {
|
|
|
5939
5963
|
*/
|
|
5940
5964
|
initializeOnModelLoad(_options) {
|
|
5941
5965
|
this.tag = `Live2DModel(${this.internalModel.settings.name})`;
|
|
5942
|
-
this.updateDrawableBounds();
|
|
5966
|
+
this.updateDrawableBounds(true);
|
|
5967
|
+
if (this.anchorMode === "canvas") {
|
|
5968
|
+
this.onAnchorChange();
|
|
5969
|
+
}
|
|
5943
5970
|
}
|
|
5944
5971
|
/**
|
|
5945
5972
|
* A callback that observes {@link anchor}, invoked when the anchor's values have been changed.
|
|
@@ -5949,11 +5976,18 @@ var __async = (__this, __arguments, generator) => {
|
|
|
5949
5976
|
if (!this.internalModel || !this.pivot) {
|
|
5950
5977
|
return;
|
|
5951
5978
|
}
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5979
|
+
if (this.anchorMode === "drawable") {
|
|
5980
|
+
const bounds = this.bounds;
|
|
5981
|
+
this.pivot.set(
|
|
5982
|
+
bounds.minX + this.anchor.x * bounds.width,
|
|
5983
|
+
bounds.minY + this.anchor.y * bounds.height
|
|
5984
|
+
);
|
|
5985
|
+
} else {
|
|
5986
|
+
this.pivot.set(
|
|
5987
|
+
this.anchor.x * this.internalModel.width,
|
|
5988
|
+
this.anchor.y * this.internalModel.height
|
|
5989
|
+
);
|
|
5990
|
+
}
|
|
5957
5991
|
}
|
|
5958
5992
|
/**
|
|
5959
5993
|
* Shorthand to start a motion.
|