pixi-live2d-display-advanced 0.5.3 → 0.5.5

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.
@@ -23,7 +23,7 @@ var __async = (__this, __arguments, generator) => {
23
23
  });
24
24
  };
25
25
  import { utils as utils$1, Matrix, Texture, Transform, Point, ObservablePoint } from "@pixi/core";
26
- import { Sound, webaudio } from "@pixi/sound";
26
+ import { sound, Sound, webaudio } from "@pixi/sound";
27
27
  import { Container } from "@pixi/display";
28
28
  const LOGICAL_WIDTH = 2;
29
29
  const LOGICAL_HEIGHT = 2;
@@ -78,7 +78,7 @@ const config = {
78
78
  preserveExpressionOnMotion: true,
79
79
  cubism4: CubismConfig
80
80
  };
81
- const VERSION = "v0.5.3";
81
+ const VERSION = "v0.5.5";
82
82
  const logger = {
83
83
  log(tag, ...messages) {
84
84
  if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
@@ -102,6 +102,9 @@ function clamp(num, lower, upper) {
102
102
  function rand(min, max) {
103
103
  return Math.random() * (max - min) + min;
104
104
  }
105
+ function MBToByte(mb) {
106
+ return 1024 * 1024 * mb;
107
+ }
105
108
  function copyProperty(type2, from, to, fromKey, toKey) {
106
109
  const value = from[fromKey];
107
110
  if (value !== null && typeof value === type2) {
@@ -3695,6 +3698,7 @@ class MotionState {
3695
3698
  }
3696
3699
  const TAG$2 = "SoundManager";
3697
3700
  const VOLUME = 0.5;
3701
+ sound.disableAutoPause = true;
3698
3702
  class SoundManager {
3699
3703
  /**
3700
3704
  * Global volume that applies to all the sounds.
@@ -3744,6 +3748,7 @@ class SoundManager {
3744
3748
  */
3745
3749
  static play(audio, onFinish) {
3746
3750
  audio.play({
3751
+ singleInstance: true,
3747
3752
  complete: () => {
3748
3753
  onFinish == null ? void 0 : onFinish();
3749
3754
  audio.destroy();
@@ -3761,7 +3766,6 @@ class SoundManager {
3761
3766
  analyser.smoothingTimeConstant = 0.85;
3762
3767
  source.connect(analyser);
3763
3768
  source.start(0);
3764
- analyser.connect(context.destination);
3765
3769
  this.analysers.push(analyser);
3766
3770
  return analyser;
3767
3771
  }
@@ -3988,7 +3992,7 @@ class MotionManager extends utils$1.EventEmitter {
3988
3992
  * @returns Promise that resolves with true if the sound is playing, false otherwise.
3989
3993
  */
3990
3994
  speak(_0) {
3991
- return __async(this, arguments, function* (sound, {
3995
+ return __async(this, arguments, function* (sound2, {
3992
3996
  volume = VOLUME,
3993
3997
  expression,
3994
3998
  resetExpression = true,
@@ -4005,16 +4009,16 @@ class MotionManager extends utils$1.EventEmitter {
4005
4009
  }
4006
4010
  }
4007
4011
  let soundURL;
4008
- const isBase64Content = sound && sound.startsWith("data:");
4009
- if (sound && !isBase64Content) {
4012
+ const isBase64Content = sound2 && sound2.startsWith("data:");
4013
+ if (sound2 && !isBase64Content) {
4010
4014
  const A = document.createElement("a");
4011
- A.href = sound;
4012
- sound = A.href;
4013
- soundURL = sound;
4015
+ A.href = sound2;
4016
+ sound2 = A.href;
4017
+ soundURL = sound2;
4014
4018
  } else {
4015
4019
  soundURL = "data:audio/";
4016
4020
  }
4017
- const file = sound;
4021
+ const file = sound2;
4018
4022
  if (file) {
4019
4023
  try {
4020
4024
  audio = yield SoundManager.add(file, (e, that = this) => {
@@ -4078,7 +4082,7 @@ class MotionManager extends utils$1.EventEmitter {
4078
4082
  */
4079
4083
  startMotion(_0, _1) {
4080
4084
  return __async(this, arguments, function* (group, index, priority = MotionPriority.NORMAL, {
4081
- sound = void 0,
4085
+ sound: sound2 = void 0,
4082
4086
  volume = VOLUME,
4083
4087
  expression = void 0,
4084
4088
  resetExpression = true,
@@ -4104,12 +4108,12 @@ class MotionManager extends utils$1.EventEmitter {
4104
4108
  }
4105
4109
  let audio;
4106
4110
  let soundURL;
4107
- const isBase64Content = sound && sound.startsWith("data:");
4108
- if (sound && !isBase64Content) {
4111
+ const isBase64Content = sound2 && sound2.startsWith("data:");
4112
+ if (sound2 && !isBase64Content) {
4109
4113
  const A = document.createElement("a");
4110
- A.href = sound;
4111
- sound = A.href;
4112
- soundURL = sound;
4114
+ A.href = sound2;
4115
+ sound2 = A.href;
4116
+ soundURL = sound2;
4113
4117
  } else {
4114
4118
  soundURL = this.getSoundFile(definition);
4115
4119
  if (soundURL) {
@@ -4183,7 +4187,7 @@ class MotionManager extends utils$1.EventEmitter {
4183
4187
  */
4184
4188
  startRandomMotion(_0, _1) {
4185
4189
  return __async(this, arguments, function* (group, priority, {
4186
- sound,
4190
+ sound: sound2,
4187
4191
  volume = VOLUME,
4188
4192
  expression,
4189
4193
  resetExpression = true,
@@ -4201,7 +4205,7 @@ class MotionManager extends utils$1.EventEmitter {
4201
4205
  if (availableIndices.length) {
4202
4206
  const index = availableIndices[Math.floor(Math.random() * availableIndices.length)];
4203
4207
  return this.startMotion(group, index, priority, {
4204
- sound,
4208
+ sound: sound2,
4205
4209
  volume,
4206
4210
  expression,
4207
4211
  resetExpression,
@@ -5522,7 +5526,7 @@ class Live2DModel extends Container {
5522
5526
  */
5523
5527
  motion(_0, _1, _2) {
5524
5528
  return __async(this, arguments, function* (group, index, priority, {
5525
- sound = void 0,
5529
+ sound: sound2 = void 0,
5526
5530
  volume = VOLUME,
5527
5531
  expression = void 0,
5528
5532
  resetExpression = true,
@@ -5531,7 +5535,7 @@ class Live2DModel extends Container {
5531
5535
  } = {}) {
5532
5536
  if (index === void 0) {
5533
5537
  return this.internalModel.motionManager.startRandomMotion(group, priority, {
5534
- sound,
5538
+ sound: sound2,
5535
5539
  volume,
5536
5540
  expression,
5537
5541
  resetExpression,
@@ -5540,7 +5544,7 @@ class Live2DModel extends Container {
5540
5544
  });
5541
5545
  } else {
5542
5546
  return this.internalModel.motionManager.startMotion(group, index, priority, {
5543
- sound,
5547
+ sound: sound2,
5544
5548
  volume,
5545
5549
  expression,
5546
5550
  resetExpression,
@@ -5623,14 +5627,14 @@ class Live2DModel extends Container {
5623
5627
  * @param [options.onError] - Callback function when an error occurs.
5624
5628
  * @returns Promise that resolves with true if the sound is playing, false if it's not.
5625
5629
  */
5626
- speak(sound, {
5630
+ speak(sound2, {
5627
5631
  volume = VOLUME,
5628
5632
  expression,
5629
5633
  resetExpression = true,
5630
5634
  onFinish,
5631
5635
  onError
5632
5636
  } = {}) {
5633
- return this.internalModel.motionManager.speak(sound, {
5637
+ return this.internalModel.motionManager.speak(sound2, {
5634
5638
  volume,
5635
5639
  expression,
5636
5640
  resetExpression,
@@ -5778,7 +5782,10 @@ class Live2DModel extends Container {
5778
5782
  this.internalModel.update(this.deltaTime, this.elapsedTime);
5779
5783
  this.deltaTime = 0;
5780
5784
  }
5781
- const internalTransform = tempMatrix.copyFrom(renderer.globalUniforms.uniforms.projectionMatrix).append(this.worldTransform);
5785
+ const internalTransform = tempMatrix.copyFrom(renderer.projection.projectionMatrix).append(this.worldTransform);
5786
+ if (this.filters && this.filters.length > 0) {
5787
+ internalTransform.scale(-1, 1);
5788
+ }
5782
5789
  this.internalModel.updateTransform(internalTransform);
5783
5790
  this.internalModel.draw(renderer.gl);
5784
5791
  renderer.state.reset();
@@ -6711,6 +6718,7 @@ export {
6711
6718
  Live2DPhysics,
6712
6719
  Live2DPose,
6713
6720
  Live2DTransform,
6721
+ MBToByte,
6714
6722
  ModelSettings,
6715
6723
  MotionManager,
6716
6724
  MotionPreloadStrategy,
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 = "v0.5.3";
82
+ const VERSION = "v0.5.5";
83
83
  const logger = {
84
84
  log(tag, ...messages) {
85
85
  if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
@@ -103,6 +103,9 @@ var __async = (__this, __arguments, generator) => {
103
103
  function rand(min, max) {
104
104
  return Math.random() * (max - min) + min;
105
105
  }
106
+ function MBToByte(mb) {
107
+ return 1024 * 1024 * mb;
108
+ }
106
109
  function copyProperty(type2, from, to, fromKey, toKey) {
107
110
  const value = from[fromKey];
108
111
  if (value !== null && typeof value === type2) {
@@ -3696,6 +3699,7 @@ var __async = (__this, __arguments, generator) => {
3696
3699
  }
3697
3700
  const TAG$2 = "SoundManager";
3698
3701
  const VOLUME = 0.5;
3702
+ sound.sound.disableAutoPause = true;
3699
3703
  class SoundManager {
3700
3704
  /**
3701
3705
  * Global volume that applies to all the sounds.
@@ -3745,6 +3749,7 @@ var __async = (__this, __arguments, generator) => {
3745
3749
  */
3746
3750
  static play(audio, onFinish) {
3747
3751
  audio.play({
3752
+ singleInstance: true,
3748
3753
  complete: () => {
3749
3754
  onFinish == null ? void 0 : onFinish();
3750
3755
  audio.destroy();
@@ -3762,7 +3767,6 @@ var __async = (__this, __arguments, generator) => {
3762
3767
  analyser.smoothingTimeConstant = 0.85;
3763
3768
  source.connect(analyser);
3764
3769
  source.start(0);
3765
- analyser.connect(context.destination);
3766
3770
  this.analysers.push(analyser);
3767
3771
  return analyser;
3768
3772
  }
@@ -5779,7 +5783,10 @@ var __async = (__this, __arguments, generator) => {
5779
5783
  this.internalModel.update(this.deltaTime, this.elapsedTime);
5780
5784
  this.deltaTime = 0;
5781
5785
  }
5782
- const internalTransform = tempMatrix.copyFrom(renderer.globalUniforms.uniforms.projectionMatrix).append(this.worldTransform);
5786
+ const internalTransform = tempMatrix.copyFrom(renderer.projection.projectionMatrix).append(this.worldTransform);
5787
+ if (this.filters && this.filters.length > 0) {
5788
+ internalTransform.scale(-1, 1);
5789
+ }
5783
5790
  this.internalModel.updateTransform(internalTransform);
5784
5791
  this.internalModel.draw(renderer.gl);
5785
5792
  renderer.state.reset();
@@ -6711,6 +6718,7 @@ var __async = (__this, __arguments, generator) => {
6711
6718
  exports2.Live2DPhysics = Live2DPhysics;
6712
6719
  exports2.Live2DPose = Live2DPose;
6713
6720
  exports2.Live2DTransform = Live2DTransform;
6721
+ exports2.MBToByte = MBToByte;
6714
6722
  exports2.ModelSettings = ModelSettings;
6715
6723
  exports2.MotionManager = MotionManager;
6716
6724
  exports2.MotionPreloadStrategy = MotionPreloadStrategy;