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/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.0";
108
+ const VERSION = "1.3.2";
109
109
  const logger = {
110
110
  log(tag, ...messages) {
111
111
  if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
@@ -3215,6 +3215,8 @@ class Live2DModel extends Container {
3215
3215
  this._boundsRetryAfterDraw = true;
3216
3216
  }
3217
3217
  this._boundsDirty = false;
3218
+ this._didViewChangeTick++;
3219
+ this.onAnchorChange();
3218
3220
  }
3219
3221
  generateUID() {
3220
3222
  return ++this.currentGlId;
@@ -3280,7 +3282,6 @@ class Live2DModel extends Container {
3280
3282
  */
3281
3283
  initializeOnModelLoad(_options) {
3282
3284
  this.tag = `Live2DModel(${this.internalModel.settings.name})`;
3283
- this.onAnchorChange();
3284
3285
  this.updateDrawableBounds();
3285
3286
  }
3286
3287
  /**
@@ -3291,9 +3292,10 @@ class Live2DModel extends Container {
3291
3292
  if (!this.internalModel || !this.pivot) {
3292
3293
  return;
3293
3294
  }
3295
+ const bounds = this.bounds;
3294
3296
  this.pivot.set(
3295
- this.anchor.x * this.internalModel.width,
3296
- this.anchor.y * this.internalModel.height
3297
+ bounds.minX + this.anchor.x * bounds.width,
3298
+ bounds.minY + this.anchor.y * bounds.height
3297
3299
  );
3298
3300
  }
3299
3301
  /**
@@ -3357,13 +3359,18 @@ class Live2DModel extends Container {
3357
3359
  * group: The motion group,
3358
3360
  * index: Index in the motion group,
3359
3361
  * priority: The priority to be applied. (0: No priority, 1: IDLE, 2:NORMAL, 3:FORCE) (default: 2)
3362
+ * ignoreParamIds: The ids to be ignored,
3363
+ * loop: Whether the motion should loop.
3360
3364
  * @return Promise that resolves with a list, indicates the motion is successfully started, with false otherwise.
3361
3365
  */
3362
3366
  parallelMotion(motionList) {
3363
3367
  return __async(this, null, function* () {
3364
3368
  this.internalModel.extendParallelMotionManager(motionList.length);
3365
3369
  const result = motionList.map(
3366
- (m, idx) => this.internalModel.parallelMotionManager[idx].startMotion(m.group, m.index, m.priority)
3370
+ (m, idx) => this.internalModel.parallelMotionManager[idx].startMotion(m.group, m.index, m.priority, {
3371
+ ignoreParamIds: m.ignoreParamIds,
3372
+ loop: m.loop
3373
+ })
3367
3374
  );
3368
3375
  const flags = [];
3369
3376
  for (const r of result) {
@@ -3521,9 +3528,14 @@ class Live2DModel extends Container {
3521
3528
  this.getBounds().set(0, 0, 0, 0);
3522
3529
  return;
3523
3530
  }
3524
- const width = this.internalModel.width;
3525
- const height = this.internalModel.height;
3526
- this.getBounds().addFrame(0, 0, width, height, this.transform.matrix);
3531
+ const bounds = this.bounds;
3532
+ this.getBounds().addFrame(
3533
+ bounds.minX,
3534
+ bounds.minY,
3535
+ bounds.maxX,
3536
+ bounds.maxY,
3537
+ this.transform.matrix
3538
+ );
3527
3539
  }
3528
3540
  /**
3529
3541
  * Updates the model. Note this method just updates the timer,
@@ -3827,11 +3839,13 @@ class ParallelMotionManager extends EventEmitter {
3827
3839
  * @param index - Index in the motion group.
3828
3840
  * @param priority - The priority to be applied. default: 2 (NORMAL)
3829
3841
  * @param ignoreParamIds - The ids to be ignored.
3842
+ * @param loop - Whether the motion should loop. Overrides Cubism 3/4/5 motion JSON loop metadata when specified.
3830
3843
  * @return Promise that resolves with true if the motion is successfully started, with false otherwise.
3831
3844
  */
3832
3845
  startMotion(_0, _1) {
3833
- return __async(this, arguments, function* (group, index, priority = MotionPriority.NORMAL, ignoreParamIds = []) {
3846
+ return __async(this, arguments, function* (group, index, priority = MotionPriority.NORMAL, options = {}) {
3834
3847
  var _a;
3848
+ const { ignoreParamIds = [], loop } = Array.isArray(options) ? { ignoreParamIds: options, loop: void 0 } : options;
3835
3849
  if (!this.state.reserve(group, index, priority)) {
3836
3850
  return false;
3837
3851
  }
@@ -3846,7 +3860,7 @@ class ParallelMotionManager extends EventEmitter {
3846
3860
  logger.log(this.tag, "Start motion:", this.getMotionName(definition));
3847
3861
  this.emit("motionStart", group, index, void 0);
3848
3862
  this.playing = true;
3849
- this._startMotion(motion, void 0, ignoreParamIds);
3863
+ this._startMotion(motion, void 0, ignoreParamIds, loop);
3850
3864
  return true;
3851
3865
  });
3852
3866
  }
@@ -3854,10 +3868,11 @@ class ParallelMotionManager extends EventEmitter {
3854
3868
  * Starts a random Motion as given priority.
3855
3869
  * @param group - The motion group.
3856
3870
  * @param priority - The priority to be applied. (default: 1 `IDLE`)
3871
+ * @param loop - Whether the motion should loop. Overrides Cubism 3/4/5 motion JSON loop metadata when specified.
3857
3872
  * @return Promise that resolves with true if the motion is successfully started, with false otherwise.
3858
3873
  */
3859
- startRandomMotion(group, priority) {
3860
- return __async(this, null, function* () {
3874
+ startRandomMotion(_0, _1) {
3875
+ return __async(this, arguments, function* (group, priority, { loop = void 0 } = {}) {
3861
3876
  var _a;
3862
3877
  const groupDefs = this.manager.definitions[group];
3863
3878
  if (groupDefs == null ? void 0 : groupDefs.length) {
@@ -3870,7 +3885,7 @@ class ParallelMotionManager extends EventEmitter {
3870
3885
  }
3871
3886
  if (availableIndices.length) {
3872
3887
  const index = availableIndices[Math.floor(Math.random() * availableIndices.length)];
3873
- return this.startMotion(group, index, priority);
3888
+ return this.startMotion(group, index, priority, { loop });
3874
3889
  }
3875
3890
  }
3876
3891
  return false;
@@ -12718,8 +12733,15 @@ class CubismInternalModel extends InternalModel {
12718
12733
  array[13] = matrix.ty;
12719
12734
  this.renderer.setMvpMatrix(tempMatrix);
12720
12735
  const framebuffer = gl.getParameter(gl.FRAMEBUFFER_BINDING);
12736
+ const previousCullFaceMode = gl.getParameter(gl.CULL_FACE_MODE);
12737
+ const determinant = array[0] * array[5] - array[1] * array[4];
12738
+ gl.cullFace(determinant < 0 ? gl.FRONT : gl.BACK);
12721
12739
  this.renderer.setRenderState(framebuffer, this.viewport);
12722
- this.renderer.drawModel();
12740
+ try {
12741
+ this.renderer.drawModel();
12742
+ } finally {
12743
+ gl.cullFace(previousCullFaceMode);
12744
+ }
12723
12745
  }
12724
12746
  extendParallelMotionManager(managerCount) {
12725
12747
  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.0";
111
+ const VERSION = "1.3.2";
112
112
  const logger = {
113
113
  log(tag, ...messages) {
114
114
  if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
@@ -3218,6 +3218,8 @@ var __async = (__this, __arguments, generator) => {
3218
3218
  this._boundsRetryAfterDraw = true;
3219
3219
  }
3220
3220
  this._boundsDirty = false;
3221
+ this._didViewChangeTick++;
3222
+ this.onAnchorChange();
3221
3223
  }
3222
3224
  generateUID() {
3223
3225
  return ++this.currentGlId;
@@ -3283,7 +3285,6 @@ var __async = (__this, __arguments, generator) => {
3283
3285
  */
3284
3286
  initializeOnModelLoad(_options) {
3285
3287
  this.tag = `Live2DModel(${this.internalModel.settings.name})`;
3286
- this.onAnchorChange();
3287
3288
  this.updateDrawableBounds();
3288
3289
  }
3289
3290
  /**
@@ -3294,9 +3295,10 @@ var __async = (__this, __arguments, generator) => {
3294
3295
  if (!this.internalModel || !this.pivot) {
3295
3296
  return;
3296
3297
  }
3298
+ const bounds = this.bounds;
3297
3299
  this.pivot.set(
3298
- this.anchor.x * this.internalModel.width,
3299
- this.anchor.y * this.internalModel.height
3300
+ bounds.minX + this.anchor.x * bounds.width,
3301
+ bounds.minY + this.anchor.y * bounds.height
3300
3302
  );
3301
3303
  }
3302
3304
  /**
@@ -3360,13 +3362,18 @@ var __async = (__this, __arguments, generator) => {
3360
3362
  * group: The motion group,
3361
3363
  * index: Index in the motion group,
3362
3364
  * priority: The priority to be applied. (0: No priority, 1: IDLE, 2:NORMAL, 3:FORCE) (default: 2)
3365
+ * ignoreParamIds: The ids to be ignored,
3366
+ * loop: Whether the motion should loop.
3363
3367
  * @return Promise that resolves with a list, indicates the motion is successfully started, with false otherwise.
3364
3368
  */
3365
3369
  parallelMotion(motionList) {
3366
3370
  return __async(this, null, function* () {
3367
3371
  this.internalModel.extendParallelMotionManager(motionList.length);
3368
3372
  const result = motionList.map(
3369
- (m, idx) => this.internalModel.parallelMotionManager[idx].startMotion(m.group, m.index, m.priority)
3373
+ (m, idx) => this.internalModel.parallelMotionManager[idx].startMotion(m.group, m.index, m.priority, {
3374
+ ignoreParamIds: m.ignoreParamIds,
3375
+ loop: m.loop
3376
+ })
3370
3377
  );
3371
3378
  const flags = [];
3372
3379
  for (const r of result) {
@@ -3524,9 +3531,14 @@ var __async = (__this, __arguments, generator) => {
3524
3531
  this.getBounds().set(0, 0, 0, 0);
3525
3532
  return;
3526
3533
  }
3527
- const width = this.internalModel.width;
3528
- const height = this.internalModel.height;
3529
- this.getBounds().addFrame(0, 0, width, height, this.transform.matrix);
3534
+ const bounds = this.bounds;
3535
+ this.getBounds().addFrame(
3536
+ bounds.minX,
3537
+ bounds.minY,
3538
+ bounds.maxX,
3539
+ bounds.maxY,
3540
+ this.transform.matrix
3541
+ );
3530
3542
  }
3531
3543
  /**
3532
3544
  * Updates the model. Note this method just updates the timer,
@@ -3830,11 +3842,13 @@ var __async = (__this, __arguments, generator) => {
3830
3842
  * @param index - Index in the motion group.
3831
3843
  * @param priority - The priority to be applied. default: 2 (NORMAL)
3832
3844
  * @param ignoreParamIds - The ids to be ignored.
3845
+ * @param loop - Whether the motion should loop. Overrides Cubism 3/4/5 motion JSON loop metadata when specified.
3833
3846
  * @return Promise that resolves with true if the motion is successfully started, with false otherwise.
3834
3847
  */
3835
3848
  startMotion(_0, _1) {
3836
- return __async(this, arguments, function* (group, index, priority = MotionPriority.NORMAL, ignoreParamIds = []) {
3849
+ return __async(this, arguments, function* (group, index, priority = MotionPriority.NORMAL, options = {}) {
3837
3850
  var _a;
3851
+ const { ignoreParamIds = [], loop } = Array.isArray(options) ? { ignoreParamIds: options, loop: void 0 } : options;
3838
3852
  if (!this.state.reserve(group, index, priority)) {
3839
3853
  return false;
3840
3854
  }
@@ -3849,7 +3863,7 @@ var __async = (__this, __arguments, generator) => {
3849
3863
  logger.log(this.tag, "Start motion:", this.getMotionName(definition));
3850
3864
  this.emit("motionStart", group, index, void 0);
3851
3865
  this.playing = true;
3852
- this._startMotion(motion, void 0, ignoreParamIds);
3866
+ this._startMotion(motion, void 0, ignoreParamIds, loop);
3853
3867
  return true;
3854
3868
  });
3855
3869
  }
@@ -3857,10 +3871,11 @@ var __async = (__this, __arguments, generator) => {
3857
3871
  * Starts a random Motion as given priority.
3858
3872
  * @param group - The motion group.
3859
3873
  * @param priority - The priority to be applied. (default: 1 `IDLE`)
3874
+ * @param loop - Whether the motion should loop. Overrides Cubism 3/4/5 motion JSON loop metadata when specified.
3860
3875
  * @return Promise that resolves with true if the motion is successfully started, with false otherwise.
3861
3876
  */
3862
- startRandomMotion(group, priority) {
3863
- return __async(this, null, function* () {
3877
+ startRandomMotion(_0, _1) {
3878
+ return __async(this, arguments, function* (group, priority, { loop = void 0 } = {}) {
3864
3879
  var _a;
3865
3880
  const groupDefs = this.manager.definitions[group];
3866
3881
  if (groupDefs == null ? void 0 : groupDefs.length) {
@@ -3873,7 +3888,7 @@ var __async = (__this, __arguments, generator) => {
3873
3888
  }
3874
3889
  if (availableIndices.length) {
3875
3890
  const index = availableIndices[Math.floor(Math.random() * availableIndices.length)];
3876
- return this.startMotion(group, index, priority);
3891
+ return this.startMotion(group, index, priority, { loop });
3877
3892
  }
3878
3893
  }
3879
3894
  return false;
@@ -12721,8 +12736,15 @@ var __async = (__this, __arguments, generator) => {
12721
12736
  array[13] = matrix.ty;
12722
12737
  this.renderer.setMvpMatrix(tempMatrix);
12723
12738
  const framebuffer = gl.getParameter(gl.FRAMEBUFFER_BINDING);
12739
+ const previousCullFaceMode = gl.getParameter(gl.CULL_FACE_MODE);
12740
+ const determinant = array[0] * array[5] - array[1] * array[4];
12741
+ gl.cullFace(determinant < 0 ? gl.FRONT : gl.BACK);
12724
12742
  this.renderer.setRenderState(framebuffer, this.viewport);
12725
- this.renderer.drawModel();
12743
+ try {
12744
+ this.renderer.drawModel();
12745
+ } finally {
12746
+ gl.cullFace(previousCullFaceMode);
12747
+ }
12726
12748
  }
12727
12749
  extendParallelMotionManager(managerCount) {
12728
12750
  while (this.parallelMotionManager.length < managerCount) {