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/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.4";
108
+ const VERSION = "1.4.0";
109
109
  const logger = {
110
110
  log(tag, ...messages) {
111
111
  if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
@@ -2193,6 +2193,15 @@ function validMaxLevel(value, fallback) {
2193
2193
  function clamp(value, min, max) {
2194
2194
  return Math.min(max, Math.max(min, value));
2195
2195
  }
2196
+ function getTextureFormat(path) {
2197
+ const [pathname = ""] = path.split(/[?#]/, 1);
2198
+ const filename = pathname.slice(pathname.lastIndexOf("/") + 1);
2199
+ const extensionIndex = filename.lastIndexOf(".");
2200
+ if (extensionIndex <= 0 || extensionIndex === filename.length - 1) {
2201
+ return void 0;
2202
+ }
2203
+ return filename.slice(extensionIndex + 1).toLowerCase();
2204
+ }
2196
2205
  function createTexture(url, options = {}) {
2197
2206
  const config2 = loadTextures.config;
2198
2207
  const previousCrossOrigin = config2 == null ? void 0 : config2.crossOrigin;
@@ -2207,6 +2216,8 @@ function createTexture(url, options = {}) {
2207
2216
  }
2208
2217
  return Assets.load({
2209
2218
  src: url,
2219
+ format: options.format,
2220
+ parser: "texture",
2210
2221
  data: {
2211
2222
  autoGenerateMipmaps: getTextureLODMode(options.lod) === "full"
2212
2223
  }
@@ -2352,7 +2363,9 @@ const setupEssentials = (context, next) => __async(null, null, function* () {
2352
2363
  const loadingTextures = Promise.all(
2353
2364
  context.settings.textures.map((tex) => {
2354
2365
  const url = context.settings.resolveURL(tex);
2355
- return createTexture(url, textureOptions);
2366
+ return createTexture(url, __spreadProps(__spreadValues({}, textureOptions), {
2367
+ format: getTextureFormat(tex)
2368
+ }));
2356
2369
  })
2357
2370
  );
2358
2371
  loadingTextures.catch(noop);
@@ -2854,13 +2867,29 @@ class Live2DPipe {
2854
2867
  constructor(renderer) {
2855
2868
  this.renderer = renderer;
2856
2869
  }
2870
+ addPrepare(prepare, instructionSet) {
2871
+ var _a, _b;
2872
+ const renderPipes = this.renderer.renderPipes;
2873
+ (_b = (_a = renderPipes.batch) == null ? void 0 : _a.break) == null ? void 0 : _b.call(_a, instructionSet);
2874
+ instructionSet.add({
2875
+ renderPipeId: "live2d",
2876
+ action: "prepare",
2877
+ canBundle: false,
2878
+ prepare
2879
+ });
2880
+ }
2857
2881
  addRenderable(model, instructionSet) {
2858
2882
  var _a, _b;
2859
2883
  const renderPipes = this.renderer.renderPipes;
2860
2884
  (_b = (_a = renderPipes.batch) == null ? void 0 : _a.break) == null ? void 0 : _b.call(_a, instructionSet);
2861
2885
  instructionSet.add(model);
2862
2886
  }
2863
- execute(model) {
2887
+ execute(instruction) {
2888
+ if (!(instruction instanceof Live2DModel)) {
2889
+ instruction.prepare();
2890
+ return;
2891
+ }
2892
+ const model = instruction;
2864
2893
  if (!model.visible || model.alpha <= 0) {
2865
2894
  return;
2866
2895
  }
@@ -3272,10 +3301,10 @@ class Live2DModel extends Container {
3272
3301
  }
3273
3302
  };
3274
3303
  const effects = this.effects;
3275
- if (effects == null ? void 0 : effects.length) {
3276
- this.prepareForRender();
3277
- }
3278
3304
  if (effects) {
3305
+ if (effects.length) {
3306
+ renderPipes.live2d.addPrepare(() => this.prepareForRender(), instructionSet);
3307
+ }
3279
3308
  for (let i = 0; i < effects.length; i++) {
3280
3309
  const effect = effects[i];
3281
3310
  const filters = effect.filters;
@@ -12785,7 +12814,6 @@ class CubismInternalModel extends InternalModel {
12785
12814
  destroy() {
12786
12815
  super.destroy();
12787
12816
  this.renderer.release();
12788
- this.coreModel.release();
12789
12817
  this.renderer = void 0;
12790
12818
  this.coreModel = void 0;
12791
12819
  }
@@ -16978,8 +17006,9 @@ Live2DFactory.registerRuntime({
16978
17006
  }
16979
17007
  });
16980
17008
  function releaseMoc() {
16981
- var _a;
16982
- (_a = this.__moc) == null ? void 0 : _a.release();
17009
+ const moc = this.__moc;
17010
+ moc == null ? void 0 : moc.deleteModel(this.coreModel);
17011
+ moc == null ? void 0 : moc.release();
16983
17012
  }
16984
17013
  export {
16985
17014
  CubismExpressionManager,
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.4";
111
+ const VERSION = "1.4.0";
112
112
  const logger = {
113
113
  log(tag, ...messages) {
114
114
  if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
@@ -2196,6 +2196,15 @@ var __async = (__this, __arguments, generator) => {
2196
2196
  function clamp(value, min, max) {
2197
2197
  return Math.min(max, Math.max(min, value));
2198
2198
  }
2199
+ function getTextureFormat(path) {
2200
+ const [pathname = ""] = path.split(/[?#]/, 1);
2201
+ const filename = pathname.slice(pathname.lastIndexOf("/") + 1);
2202
+ const extensionIndex = filename.lastIndexOf(".");
2203
+ if (extensionIndex <= 0 || extensionIndex === filename.length - 1) {
2204
+ return void 0;
2205
+ }
2206
+ return filename.slice(extensionIndex + 1).toLowerCase();
2207
+ }
2199
2208
  function createTexture(url, options = {}) {
2200
2209
  const config2 = pixi_js.loadTextures.config;
2201
2210
  const previousCrossOrigin = config2 == null ? void 0 : config2.crossOrigin;
@@ -2210,6 +2219,8 @@ var __async = (__this, __arguments, generator) => {
2210
2219
  }
2211
2220
  return pixi_js.Assets.load({
2212
2221
  src: url,
2222
+ format: options.format,
2223
+ parser: "texture",
2213
2224
  data: {
2214
2225
  autoGenerateMipmaps: getTextureLODMode(options.lod) === "full"
2215
2226
  }
@@ -2355,7 +2366,9 @@ var __async = (__this, __arguments, generator) => {
2355
2366
  const loadingTextures = Promise.all(
2356
2367
  context.settings.textures.map((tex) => {
2357
2368
  const url = context.settings.resolveURL(tex);
2358
- return createTexture(url, textureOptions);
2369
+ return createTexture(url, __spreadProps(__spreadValues({}, textureOptions), {
2370
+ format: getTextureFormat(tex)
2371
+ }));
2359
2372
  })
2360
2373
  );
2361
2374
  loadingTextures.catch(noop);
@@ -2857,13 +2870,29 @@ var __async = (__this, __arguments, generator) => {
2857
2870
  constructor(renderer) {
2858
2871
  this.renderer = renderer;
2859
2872
  }
2873
+ addPrepare(prepare, instructionSet) {
2874
+ var _a, _b;
2875
+ const renderPipes = this.renderer.renderPipes;
2876
+ (_b = (_a = renderPipes.batch) == null ? void 0 : _a.break) == null ? void 0 : _b.call(_a, instructionSet);
2877
+ instructionSet.add({
2878
+ renderPipeId: "live2d",
2879
+ action: "prepare",
2880
+ canBundle: false,
2881
+ prepare
2882
+ });
2883
+ }
2860
2884
  addRenderable(model, instructionSet) {
2861
2885
  var _a, _b;
2862
2886
  const renderPipes = this.renderer.renderPipes;
2863
2887
  (_b = (_a = renderPipes.batch) == null ? void 0 : _a.break) == null ? void 0 : _b.call(_a, instructionSet);
2864
2888
  instructionSet.add(model);
2865
2889
  }
2866
- execute(model) {
2890
+ execute(instruction) {
2891
+ if (!(instruction instanceof Live2DModel)) {
2892
+ instruction.prepare();
2893
+ return;
2894
+ }
2895
+ const model = instruction;
2867
2896
  if (!model.visible || model.alpha <= 0) {
2868
2897
  return;
2869
2898
  }
@@ -3275,10 +3304,10 @@ var __async = (__this, __arguments, generator) => {
3275
3304
  }
3276
3305
  };
3277
3306
  const effects = this.effects;
3278
- if (effects == null ? void 0 : effects.length) {
3279
- this.prepareForRender();
3280
- }
3281
3307
  if (effects) {
3308
+ if (effects.length) {
3309
+ renderPipes.live2d.addPrepare(() => this.prepareForRender(), instructionSet);
3310
+ }
3282
3311
  for (let i = 0; i < effects.length; i++) {
3283
3312
  const effect = effects[i];
3284
3313
  const filters = effect.filters;
@@ -12788,7 +12817,6 @@ var __async = (__this, __arguments, generator) => {
12788
12817
  destroy() {
12789
12818
  super.destroy();
12790
12819
  this.renderer.release();
12791
- this.coreModel.release();
12792
12820
  this.renderer = void 0;
12793
12821
  this.coreModel = void 0;
12794
12822
  }
@@ -16981,8 +17009,9 @@ var __async = (__this, __arguments, generator) => {
16981
17009
  }
16982
17010
  });
16983
17011
  function releaseMoc() {
16984
- var _a;
16985
- (_a = this.__moc) == null ? void 0 : _a.release();
17012
+ const moc = this.__moc;
17013
+ moc == null ? void 0 : moc.deleteModel(this.coreModel);
17014
+ moc == null ? void 0 : moc.release();
16986
17015
  }
16987
17016
  exports2.CubismExpressionManager = CubismExpressionManager;
16988
17017
  exports2.CubismInternalModel = CubismInternalModel;