untitled-pixi-live2d-engine 1.3.0 → 1.3.2

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.es.js CHANGED
@@ -2759,7 +2759,7 @@ const config = {
2759
2759
  preserveExpressionOnMotion: true,
2760
2760
  cubism: CubismFrameworkConfig
2761
2761
  };
2762
- const VERSION = "1.3.0";
2762
+ const VERSION = "1.3.2";
2763
2763
  const logger = {
2764
2764
  log(tag, ...messages) {
2765
2765
  if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
@@ -5869,6 +5869,8 @@ class Live2DModel extends Container {
5869
5869
  this._boundsRetryAfterDraw = true;
5870
5870
  }
5871
5871
  this._boundsDirty = false;
5872
+ this._didViewChangeTick++;
5873
+ this.onAnchorChange();
5872
5874
  }
5873
5875
  generateUID() {
5874
5876
  return ++this.currentGlId;
@@ -5934,7 +5936,6 @@ class Live2DModel extends Container {
5934
5936
  */
5935
5937
  initializeOnModelLoad(_options) {
5936
5938
  this.tag = `Live2DModel(${this.internalModel.settings.name})`;
5937
- this.onAnchorChange();
5938
5939
  this.updateDrawableBounds();
5939
5940
  }
5940
5941
  /**
@@ -5945,9 +5946,10 @@ class Live2DModel extends Container {
5945
5946
  if (!this.internalModel || !this.pivot) {
5946
5947
  return;
5947
5948
  }
5949
+ const bounds = this.bounds;
5948
5950
  this.pivot.set(
5949
- this.anchor.x * this.internalModel.width,
5950
- this.anchor.y * this.internalModel.height
5951
+ bounds.minX + this.anchor.x * bounds.width,
5952
+ bounds.minY + this.anchor.y * bounds.height
5951
5953
  );
5952
5954
  }
5953
5955
  /**
@@ -6011,13 +6013,18 @@ class Live2DModel extends Container {
6011
6013
  * group: The motion group,
6012
6014
  * index: Index in the motion group,
6013
6015
  * priority: The priority to be applied. (0: No priority, 1: IDLE, 2:NORMAL, 3:FORCE) (default: 2)
6016
+ * ignoreParamIds: The ids to be ignored,
6017
+ * loop: Whether the motion should loop.
6014
6018
  * @return Promise that resolves with a list, indicates the motion is successfully started, with false otherwise.
6015
6019
  */
6016
6020
  parallelMotion(motionList) {
6017
6021
  return __async(this, null, function* () {
6018
6022
  this.internalModel.extendParallelMotionManager(motionList.length);
6019
6023
  const result = motionList.map(
6020
- (m, idx) => this.internalModel.parallelMotionManager[idx].startMotion(m.group, m.index, m.priority)
6024
+ (m, idx) => this.internalModel.parallelMotionManager[idx].startMotion(m.group, m.index, m.priority, {
6025
+ ignoreParamIds: m.ignoreParamIds,
6026
+ loop: m.loop
6027
+ })
6021
6028
  );
6022
6029
  const flags = [];
6023
6030
  for (const r of result) {
@@ -6175,9 +6182,14 @@ class Live2DModel extends Container {
6175
6182
  this.getBounds().set(0, 0, 0, 0);
6176
6183
  return;
6177
6184
  }
6178
- const width = this.internalModel.width;
6179
- const height = this.internalModel.height;
6180
- this.getBounds().addFrame(0, 0, width, height, this.transform.matrix);
6185
+ const bounds = this.bounds;
6186
+ this.getBounds().addFrame(
6187
+ bounds.minX,
6188
+ bounds.minY,
6189
+ bounds.maxX,
6190
+ bounds.maxY,
6191
+ this.transform.matrix
6192
+ );
6181
6193
  }
6182
6194
  /**
6183
6195
  * Updates the model. Note this method just updates the timer,
@@ -9019,11 +9031,13 @@ class ParallelMotionManager extends EventEmitter {
9019
9031
  * @param index - Index in the motion group.
9020
9032
  * @param priority - The priority to be applied. default: 2 (NORMAL)
9021
9033
  * @param ignoreParamIds - The ids to be ignored.
9034
+ * @param loop - Whether the motion should loop. Overrides Cubism 3/4/5 motion JSON loop metadata when specified.
9022
9035
  * @return Promise that resolves with true if the motion is successfully started, with false otherwise.
9023
9036
  */
9024
9037
  startMotion(_0, _1) {
9025
- return __async(this, arguments, function* (group, index, priority = MotionPriority.NORMAL, ignoreParamIds = []) {
9038
+ return __async(this, arguments, function* (group, index, priority = MotionPriority.NORMAL, options = {}) {
9026
9039
  var _a;
9040
+ const { ignoreParamIds = [], loop } = Array.isArray(options) ? { ignoreParamIds: options, loop: void 0 } : options;
9027
9041
  if (!this.state.reserve(group, index, priority)) {
9028
9042
  return false;
9029
9043
  }
@@ -9038,7 +9052,7 @@ class ParallelMotionManager extends EventEmitter {
9038
9052
  logger.log(this.tag, "Start motion:", this.getMotionName(definition));
9039
9053
  this.emit("motionStart", group, index, void 0);
9040
9054
  this.playing = true;
9041
- this._startMotion(motion, void 0, ignoreParamIds);
9055
+ this._startMotion(motion, void 0, ignoreParamIds, loop);
9042
9056
  return true;
9043
9057
  });
9044
9058
  }
@@ -9046,10 +9060,11 @@ class ParallelMotionManager extends EventEmitter {
9046
9060
  * Starts a random Motion as given priority.
9047
9061
  * @param group - The motion group.
9048
9062
  * @param priority - The priority to be applied. (default: 1 `IDLE`)
9063
+ * @param loop - Whether the motion should loop. Overrides Cubism 3/4/5 motion JSON loop metadata when specified.
9049
9064
  * @return Promise that resolves with true if the motion is successfully started, with false otherwise.
9050
9065
  */
9051
- startRandomMotion(group, priority) {
9052
- return __async(this, null, function* () {
9066
+ startRandomMotion(_0, _1) {
9067
+ return __async(this, arguments, function* (group, priority, { loop = void 0 } = {}) {
9053
9068
  var _a;
9054
9069
  const groupDefs = this.manager.definitions[group];
9055
9070
  if (groupDefs == null ? void 0 : groupDefs.length) {
@@ -9062,7 +9077,7 @@ class ParallelMotionManager extends EventEmitter {
9062
9077
  }
9063
9078
  if (availableIndices.length) {
9064
9079
  const index = availableIndices[Math.floor(Math.random() * availableIndices.length)];
9065
- return this.startMotion(group, index, priority);
9080
+ return this.startMotion(group, index, priority, { loop });
9066
9081
  }
9067
9082
  }
9068
9083
  return false;
@@ -11919,8 +11934,15 @@ class CubismInternalModel extends InternalModel {
11919
11934
  array[13] = matrix.ty;
11920
11935
  this.renderer.setMvpMatrix(tempMatrix);
11921
11936
  const framebuffer = gl.getParameter(gl.FRAMEBUFFER_BINDING);
11937
+ const previousCullFaceMode = gl.getParameter(gl.CULL_FACE_MODE);
11938
+ const determinant = array[0] * array[5] - array[1] * array[4];
11939
+ gl.cullFace(determinant < 0 ? gl.FRONT : gl.BACK);
11922
11940
  this.renderer.setRenderState(framebuffer, this.viewport);
11923
- this.renderer.drawModel();
11941
+ try {
11942
+ this.renderer.drawModel();
11943
+ } finally {
11944
+ gl.cullFace(previousCullFaceMode);
11945
+ }
11924
11946
  }
11925
11947
  extendParallelMotionManager(managerCount) {
11926
11948
  while (this.parallelMotionManager.length < managerCount) {
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.0";
2765
+ const VERSION = "1.3.2";
2766
2766
  const logger = {
2767
2767
  log(tag, ...messages) {
2768
2768
  if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
@@ -5872,6 +5872,8 @@ var __async = (__this, __arguments, generator) => {
5872
5872
  this._boundsRetryAfterDraw = true;
5873
5873
  }
5874
5874
  this._boundsDirty = false;
5875
+ this._didViewChangeTick++;
5876
+ this.onAnchorChange();
5875
5877
  }
5876
5878
  generateUID() {
5877
5879
  return ++this.currentGlId;
@@ -5937,7 +5939,6 @@ var __async = (__this, __arguments, generator) => {
5937
5939
  */
5938
5940
  initializeOnModelLoad(_options) {
5939
5941
  this.tag = `Live2DModel(${this.internalModel.settings.name})`;
5940
- this.onAnchorChange();
5941
5942
  this.updateDrawableBounds();
5942
5943
  }
5943
5944
  /**
@@ -5948,9 +5949,10 @@ var __async = (__this, __arguments, generator) => {
5948
5949
  if (!this.internalModel || !this.pivot) {
5949
5950
  return;
5950
5951
  }
5952
+ const bounds = this.bounds;
5951
5953
  this.pivot.set(
5952
- this.anchor.x * this.internalModel.width,
5953
- this.anchor.y * this.internalModel.height
5954
+ bounds.minX + this.anchor.x * bounds.width,
5955
+ bounds.minY + this.anchor.y * bounds.height
5954
5956
  );
5955
5957
  }
5956
5958
  /**
@@ -6014,13 +6016,18 @@ var __async = (__this, __arguments, generator) => {
6014
6016
  * group: The motion group,
6015
6017
  * index: Index in the motion group,
6016
6018
  * priority: The priority to be applied. (0: No priority, 1: IDLE, 2:NORMAL, 3:FORCE) (default: 2)
6019
+ * ignoreParamIds: The ids to be ignored,
6020
+ * loop: Whether the motion should loop.
6017
6021
  * @return Promise that resolves with a list, indicates the motion is successfully started, with false otherwise.
6018
6022
  */
6019
6023
  parallelMotion(motionList) {
6020
6024
  return __async(this, null, function* () {
6021
6025
  this.internalModel.extendParallelMotionManager(motionList.length);
6022
6026
  const result = motionList.map(
6023
- (m, idx) => this.internalModel.parallelMotionManager[idx].startMotion(m.group, m.index, m.priority)
6027
+ (m, idx) => this.internalModel.parallelMotionManager[idx].startMotion(m.group, m.index, m.priority, {
6028
+ ignoreParamIds: m.ignoreParamIds,
6029
+ loop: m.loop
6030
+ })
6024
6031
  );
6025
6032
  const flags = [];
6026
6033
  for (const r of result) {
@@ -6178,9 +6185,14 @@ var __async = (__this, __arguments, generator) => {
6178
6185
  this.getBounds().set(0, 0, 0, 0);
6179
6186
  return;
6180
6187
  }
6181
- const width = this.internalModel.width;
6182
- const height = this.internalModel.height;
6183
- this.getBounds().addFrame(0, 0, width, height, this.transform.matrix);
6188
+ const bounds = this.bounds;
6189
+ this.getBounds().addFrame(
6190
+ bounds.minX,
6191
+ bounds.minY,
6192
+ bounds.maxX,
6193
+ bounds.maxY,
6194
+ this.transform.matrix
6195
+ );
6184
6196
  }
6185
6197
  /**
6186
6198
  * Updates the model. Note this method just updates the timer,
@@ -9022,11 +9034,13 @@ var __async = (__this, __arguments, generator) => {
9022
9034
  * @param index - Index in the motion group.
9023
9035
  * @param priority - The priority to be applied. default: 2 (NORMAL)
9024
9036
  * @param ignoreParamIds - The ids to be ignored.
9037
+ * @param loop - Whether the motion should loop. Overrides Cubism 3/4/5 motion JSON loop metadata when specified.
9025
9038
  * @return Promise that resolves with true if the motion is successfully started, with false otherwise.
9026
9039
  */
9027
9040
  startMotion(_0, _1) {
9028
- return __async(this, arguments, function* (group, index, priority = MotionPriority.NORMAL, ignoreParamIds = []) {
9041
+ return __async(this, arguments, function* (group, index, priority = MotionPriority.NORMAL, options = {}) {
9029
9042
  var _a;
9043
+ const { ignoreParamIds = [], loop } = Array.isArray(options) ? { ignoreParamIds: options, loop: void 0 } : options;
9030
9044
  if (!this.state.reserve(group, index, priority)) {
9031
9045
  return false;
9032
9046
  }
@@ -9041,7 +9055,7 @@ var __async = (__this, __arguments, generator) => {
9041
9055
  logger.log(this.tag, "Start motion:", this.getMotionName(definition));
9042
9056
  this.emit("motionStart", group, index, void 0);
9043
9057
  this.playing = true;
9044
- this._startMotion(motion, void 0, ignoreParamIds);
9058
+ this._startMotion(motion, void 0, ignoreParamIds, loop);
9045
9059
  return true;
9046
9060
  });
9047
9061
  }
@@ -9049,10 +9063,11 @@ var __async = (__this, __arguments, generator) => {
9049
9063
  * Starts a random Motion as given priority.
9050
9064
  * @param group - The motion group.
9051
9065
  * @param priority - The priority to be applied. (default: 1 `IDLE`)
9066
+ * @param loop - Whether the motion should loop. Overrides Cubism 3/4/5 motion JSON loop metadata when specified.
9052
9067
  * @return Promise that resolves with true if the motion is successfully started, with false otherwise.
9053
9068
  */
9054
- startRandomMotion(group, priority) {
9055
- return __async(this, null, function* () {
9069
+ startRandomMotion(_0, _1) {
9070
+ return __async(this, arguments, function* (group, priority, { loop = void 0 } = {}) {
9056
9071
  var _a;
9057
9072
  const groupDefs = this.manager.definitions[group];
9058
9073
  if (groupDefs == null ? void 0 : groupDefs.length) {
@@ -9065,7 +9080,7 @@ var __async = (__this, __arguments, generator) => {
9065
9080
  }
9066
9081
  if (availableIndices.length) {
9067
9082
  const index = availableIndices[Math.floor(Math.random() * availableIndices.length)];
9068
- return this.startMotion(group, index, priority);
9083
+ return this.startMotion(group, index, priority, { loop });
9069
9084
  }
9070
9085
  }
9071
9086
  return false;
@@ -11922,8 +11937,15 @@ var __async = (__this, __arguments, generator) => {
11922
11937
  array[13] = matrix.ty;
11923
11938
  this.renderer.setMvpMatrix(tempMatrix);
11924
11939
  const framebuffer = gl.getParameter(gl.FRAMEBUFFER_BINDING);
11940
+ const previousCullFaceMode = gl.getParameter(gl.CULL_FACE_MODE);
11941
+ const determinant = array[0] * array[5] - array[1] * array[4];
11942
+ gl.cullFace(determinant < 0 ? gl.FRONT : gl.BACK);
11925
11943
  this.renderer.setRenderState(framebuffer, this.viewport);
11926
- this.renderer.drawModel();
11944
+ try {
11945
+ this.renderer.drawModel();
11946
+ } finally {
11947
+ gl.cullFace(previousCullFaceMode);
11948
+ }
11927
11949
  }
11928
11950
  extendParallelMotionManager(managerCount) {
11929
11951
  while (this.parallelMotionManager.length < managerCount) {