untitled-pixi-live2d-engine 1.3.4 → 1.4.0

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.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.4";
2765
+ const VERSION = "1.4.0";
2766
2766
  const logger = {
2767
2767
  log(tag, ...messages) {
2768
2768
  if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
@@ -4850,6 +4850,15 @@ var __async = (__this, __arguments, generator) => {
4850
4850
  function clamp(value, min, max) {
4851
4851
  return Math.min(max, Math.max(min, value));
4852
4852
  }
4853
+ function getTextureFormat(path) {
4854
+ const [pathname = ""] = path.split(/[?#]/, 1);
4855
+ const filename = pathname.slice(pathname.lastIndexOf("/") + 1);
4856
+ const extensionIndex = filename.lastIndexOf(".");
4857
+ if (extensionIndex <= 0 || extensionIndex === filename.length - 1) {
4858
+ return void 0;
4859
+ }
4860
+ return filename.slice(extensionIndex + 1).toLowerCase();
4861
+ }
4853
4862
  function createTexture(url, options = {}) {
4854
4863
  const config2 = pixi_js.loadTextures.config;
4855
4864
  const previousCrossOrigin = config2 == null ? void 0 : config2.crossOrigin;
@@ -4864,6 +4873,8 @@ var __async = (__this, __arguments, generator) => {
4864
4873
  }
4865
4874
  return pixi_js.Assets.load({
4866
4875
  src: url,
4876
+ format: options.format,
4877
+ parser: "texture",
4867
4878
  data: {
4868
4879
  autoGenerateMipmaps: getTextureLODMode(options.lod) === "full"
4869
4880
  }
@@ -5009,7 +5020,9 @@ var __async = (__this, __arguments, generator) => {
5009
5020
  const loadingTextures = Promise.all(
5010
5021
  context.settings.textures.map((tex) => {
5011
5022
  const url = context.settings.resolveURL(tex);
5012
- return createTexture(url, textureOptions);
5023
+ return createTexture(url, __spreadProps(__spreadValues({}, textureOptions), {
5024
+ format: getTextureFormat(tex)
5025
+ }));
5013
5026
  })
5014
5027
  );
5015
5028
  loadingTextures.catch(noop);
@@ -5511,13 +5524,29 @@ var __async = (__this, __arguments, generator) => {
5511
5524
  constructor(renderer) {
5512
5525
  this.renderer = renderer;
5513
5526
  }
5527
+ addPrepare(prepare, instructionSet) {
5528
+ var _a, _b;
5529
+ const renderPipes = this.renderer.renderPipes;
5530
+ (_b = (_a = renderPipes.batch) == null ? void 0 : _a.break) == null ? void 0 : _b.call(_a, instructionSet);
5531
+ instructionSet.add({
5532
+ renderPipeId: "live2d",
5533
+ action: "prepare",
5534
+ canBundle: false,
5535
+ prepare
5536
+ });
5537
+ }
5514
5538
  addRenderable(model, instructionSet) {
5515
5539
  var _a, _b;
5516
5540
  const renderPipes = this.renderer.renderPipes;
5517
5541
  (_b = (_a = renderPipes.batch) == null ? void 0 : _a.break) == null ? void 0 : _b.call(_a, instructionSet);
5518
5542
  instructionSet.add(model);
5519
5543
  }
5520
- execute(model) {
5544
+ execute(instruction) {
5545
+ if (!(instruction instanceof Live2DModel)) {
5546
+ instruction.prepare();
5547
+ return;
5548
+ }
5549
+ const model = instruction;
5521
5550
  if (!model.visible || model.alpha <= 0) {
5522
5551
  return;
5523
5552
  }
@@ -5929,10 +5958,10 @@ var __async = (__this, __arguments, generator) => {
5929
5958
  }
5930
5959
  };
5931
5960
  const effects = this.effects;
5932
- if (effects == null ? void 0 : effects.length) {
5933
- this.prepareForRender();
5934
- }
5935
5961
  if (effects) {
5962
+ if (effects.length) {
5963
+ renderPipes.live2d.addPrepare(() => this.prepareForRender(), instructionSet);
5964
+ }
5936
5965
  for (let i = 0; i < effects.length; i++) {
5937
5966
  const effect = effects[i];
5938
5967
  const filters = effect.filters;
@@ -11989,7 +12018,6 @@ var __async = (__this, __arguments, generator) => {
11989
12018
  destroy() {
11990
12019
  super.destroy();
11991
12020
  this.renderer.release();
11992
- this.coreModel.release();
11993
12021
  this.renderer = void 0;
11994
12022
  this.coreModel = void 0;
11995
12023
  }
@@ -16182,8 +16210,9 @@ var __async = (__this, __arguments, generator) => {
16182
16210
  }
16183
16211
  });
16184
16212
  function releaseMoc() {
16185
- var _a;
16186
- (_a = this.__moc) == null ? void 0 : _a.release();
16213
+ const moc = this.__moc;
16214
+ moc == null ? void 0 : moc.deleteModel(this.coreModel);
16215
+ moc == null ? void 0 : moc.release();
16187
16216
  }
16188
16217
  exports2.Constant = Constant;
16189
16218
  exports2.CubismExpressionManager = CubismExpressionManager;