pixi-live2d-display-advanced 1.0.0 → 1.0.1

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.
@@ -78,7 +78,7 @@ const config = {
78
78
  preserveExpressionOnMotion: true,
79
79
  cubism4: CubismConfig
80
80
  };
81
- const VERSION = "v1.0.0";
81
+ const VERSION = "v1.0.1";
82
82
  const logger = {
83
83
  log(tag, ...messages) {
84
84
  if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
@@ -6158,8 +6158,8 @@ class Live2DEyeBlink {
6158
6158
  __publicField(this, "openingDuration", 150);
6159
6159
  __publicField(this, "eyeState", 0);
6160
6160
  __publicField(this, "eyeParamValue", 1);
6161
- __publicField(this, "closedTimer", 0);
6162
- __publicField(this, "nextBlinkTimeLeft", this.blinkInterval);
6161
+ __publicField(this, "timer", 0);
6162
+ __publicField(this, "nextBlinkTime", this.blinkInterval + rand(0, 2e3));
6163
6163
  this.coreModel = coreModel;
6164
6164
  this.leftParam = coreModel.getParamIndex("PARAM_EYE_L_OPEN");
6165
6165
  this.rightParam = coreModel.getParamIndex("PARAM_EYE_R_OPEN");
@@ -6172,22 +6172,22 @@ class Live2DEyeBlink {
6172
6172
  update(dt) {
6173
6173
  switch (this.eyeState) {
6174
6174
  case 0:
6175
- this.nextBlinkTimeLeft -= dt;
6176
- if (this.nextBlinkTimeLeft < 0) {
6175
+ this.timer += dt;
6176
+ if (this.timer >= this.nextBlinkTime) {
6177
+ this.timer = 0;
6177
6178
  this.eyeState = 1;
6178
- this.nextBlinkTimeLeft = this.blinkInterval + this.closingDuration + this.closedDuration + this.openingDuration + rand(0, 2e3);
6179
6179
  }
6180
6180
  break;
6181
6181
  case 1:
6182
- this.setEyeParams(this.eyeParamValue + dt / this.closingDuration);
6182
+ this.setEyeParams(this.eyeParamValue - dt / this.closingDuration);
6183
6183
  if (this.eyeParamValue <= 0) {
6184
6184
  this.eyeState = 2;
6185
- this.closedTimer = 0;
6185
+ this.timer = 0;
6186
6186
  }
6187
6187
  break;
6188
6188
  case 2:
6189
- this.closedTimer += dt;
6190
- if (this.closedTimer >= this.closedDuration) {
6189
+ this.timer += dt;
6190
+ if (this.timer >= this.closedDuration) {
6191
6191
  this.eyeState = 3;
6192
6192
  }
6193
6193
  break;
@@ -6195,7 +6195,10 @@ class Live2DEyeBlink {
6195
6195
  this.setEyeParams(this.eyeParamValue + dt / this.openingDuration);
6196
6196
  if (this.eyeParamValue >= 1) {
6197
6197
  this.eyeState = 0;
6198
+ this.timer = 0;
6199
+ this.nextBlinkTime = this.blinkInterval + rand(0, 2e3);
6198
6200
  }
6201
+ break;
6199
6202
  }
6200
6203
  }
6201
6204
  }
@@ -6247,6 +6250,8 @@ class Cubism2InternalModel extends InternalModel {
6247
6250
  */
6248
6251
  __publicField(this, "disableCulling", false);
6249
6252
  __publicField(this, "hasDrawn", false);
6253
+ // TODO: It needs to reforged in future
6254
+ __publicField(this, "autoBlink", true);
6250
6255
  this.coreModel = coreModel;
6251
6256
  this.settings = settings;
6252
6257
  this.options = Object.assign({}, { breathDepth: 1 }, options);
@@ -6364,6 +6369,9 @@ class Cubism2InternalModel extends InternalModel {
6364
6369
  }
6365
6370
  return super.hitTest(x, y);
6366
6371
  }
6372
+ setAutoBlinkEnable(enable) {
6373
+ this.autoBlink = enable;
6374
+ }
6367
6375
  update(dt, now) {
6368
6376
  var _a, _b, _c, _d;
6369
6377
  super.update(dt, now);
@@ -6371,7 +6379,7 @@ class Cubism2InternalModel extends InternalModel {
6371
6379
  const motionUpdated = this.updateMotions(model, now);
6372
6380
  model.saveParam();
6373
6381
  (_a = this.motionManager.expressionManager) == null ? void 0 : _a.update(model, now);
6374
- if (!motionUpdated) {
6382
+ if (!motionUpdated && this.autoBlink) {
6375
6383
  (_b = this.eyeBlink) == null ? void 0 : _b.update(dt);
6376
6384
  }
6377
6385
  this.updateFocus();
package/dist/cubism2.js CHANGED
@@ -79,7 +79,7 @@ var __async = (__this, __arguments, generator) => {
79
79
  preserveExpressionOnMotion: true,
80
80
  cubism4: CubismConfig
81
81
  };
82
- const VERSION = "v1.0.0";
82
+ const VERSION = "v1.0.1";
83
83
  const logger = {
84
84
  log(tag, ...messages) {
85
85
  if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
@@ -6159,8 +6159,8 @@ var __async = (__this, __arguments, generator) => {
6159
6159
  __publicField(this, "openingDuration", 150);
6160
6160
  __publicField(this, "eyeState", 0);
6161
6161
  __publicField(this, "eyeParamValue", 1);
6162
- __publicField(this, "closedTimer", 0);
6163
- __publicField(this, "nextBlinkTimeLeft", this.blinkInterval);
6162
+ __publicField(this, "timer", 0);
6163
+ __publicField(this, "nextBlinkTime", this.blinkInterval + rand(0, 2e3));
6164
6164
  this.coreModel = coreModel;
6165
6165
  this.leftParam = coreModel.getParamIndex("PARAM_EYE_L_OPEN");
6166
6166
  this.rightParam = coreModel.getParamIndex("PARAM_EYE_R_OPEN");
@@ -6173,22 +6173,22 @@ var __async = (__this, __arguments, generator) => {
6173
6173
  update(dt) {
6174
6174
  switch (this.eyeState) {
6175
6175
  case 0:
6176
- this.nextBlinkTimeLeft -= dt;
6177
- if (this.nextBlinkTimeLeft < 0) {
6176
+ this.timer += dt;
6177
+ if (this.timer >= this.nextBlinkTime) {
6178
+ this.timer = 0;
6178
6179
  this.eyeState = 1;
6179
- this.nextBlinkTimeLeft = this.blinkInterval + this.closingDuration + this.closedDuration + this.openingDuration + rand(0, 2e3);
6180
6180
  }
6181
6181
  break;
6182
6182
  case 1:
6183
- this.setEyeParams(this.eyeParamValue + dt / this.closingDuration);
6183
+ this.setEyeParams(this.eyeParamValue - dt / this.closingDuration);
6184
6184
  if (this.eyeParamValue <= 0) {
6185
6185
  this.eyeState = 2;
6186
- this.closedTimer = 0;
6186
+ this.timer = 0;
6187
6187
  }
6188
6188
  break;
6189
6189
  case 2:
6190
- this.closedTimer += dt;
6191
- if (this.closedTimer >= this.closedDuration) {
6190
+ this.timer += dt;
6191
+ if (this.timer >= this.closedDuration) {
6192
6192
  this.eyeState = 3;
6193
6193
  }
6194
6194
  break;
@@ -6196,7 +6196,10 @@ var __async = (__this, __arguments, generator) => {
6196
6196
  this.setEyeParams(this.eyeParamValue + dt / this.openingDuration);
6197
6197
  if (this.eyeParamValue >= 1) {
6198
6198
  this.eyeState = 0;
6199
+ this.timer = 0;
6200
+ this.nextBlinkTime = this.blinkInterval + rand(0, 2e3);
6199
6201
  }
6202
+ break;
6200
6203
  }
6201
6204
  }
6202
6205
  }
@@ -6248,6 +6251,8 @@ var __async = (__this, __arguments, generator) => {
6248
6251
  */
6249
6252
  __publicField(this, "disableCulling", false);
6250
6253
  __publicField(this, "hasDrawn", false);
6254
+ // TODO: It needs to reforged in future
6255
+ __publicField(this, "autoBlink", true);
6251
6256
  this.coreModel = coreModel;
6252
6257
  this.settings = settings;
6253
6258
  this.options = Object.assign({}, { breathDepth: 1 }, options);
@@ -6365,6 +6370,9 @@ var __async = (__this, __arguments, generator) => {
6365
6370
  }
6366
6371
  return super.hitTest(x, y);
6367
6372
  }
6373
+ setAutoBlinkEnable(enable) {
6374
+ this.autoBlink = enable;
6375
+ }
6368
6376
  update(dt, now) {
6369
6377
  var _a, _b, _c, _d;
6370
6378
  super.update(dt, now);
@@ -6372,7 +6380,7 @@ var __async = (__this, __arguments, generator) => {
6372
6380
  const motionUpdated = this.updateMotions(model, now);
6373
6381
  model.saveParam();
6374
6382
  (_a = this.motionManager.expressionManager) == null ? void 0 : _a.update(model, now);
6375
- if (!motionUpdated) {
6383
+ if (!motionUpdated && this.autoBlink) {
6376
6384
  (_b = this.eyeBlink) == null ? void 0 : _b.update(dt);
6377
6385
  }
6378
6386
  this.updateFocus();