@laplace.live/pixijs-live2d 0.0.1 → 0.2.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.d.ts CHANGED
@@ -3024,6 +3024,12 @@ declare abstract class InternalModel extends EventEmitter {
3024
3024
  abstract parallelMotionManager: ParallelMotionManager<CubismMotion>[];
3025
3025
  pose?: unknown;
3026
3026
  physics?: unknown;
3027
+ /**
3028
+ * Retune the idle breath live, where the engine has one — `breathDepth` is a construction
3029
+ * option, and a host that exposes it as a control needs to change it after load. Absent on a
3030
+ * model type with no breath, so callers skip rather than branch.
3031
+ */
3032
+ setBreath?(enabled: boolean, depth?: number): void;
3027
3033
  /**
3028
3034
  * Original canvas width of the model. Note this doesn't represent the model's real size,
3029
3035
  * as the model can overflow from its canvas.
@@ -6949,6 +6955,8 @@ declare class CubismInternalModel extends InternalModel {
6949
6955
  parallelMotionManager: CubismParallelMotionManager[];
6950
6956
  lipSync: boolean;
6951
6957
  breath: CubismBreath;
6958
+ /** Whether the idle breath contributes at all; see {@link setBreath}. */
6959
+ breathEnabled: boolean;
6952
6960
  eyeBlink?: CubismEyeBlink;
6953
6961
  pose?: CubismPose;
6954
6962
  physics?: CubismPhysics;
@@ -6988,6 +6996,16 @@ declare class CubismInternalModel extends InternalModel {
6988
6996
  update(dt: DOMHighResTimeStamp, now: DOMHighResTimeStamp): void;
6989
6997
  updateFocus(): void;
6990
6998
  updateFacialEmotion(mouthForm: number): void;
6999
+ /**
7000
+ * The idle breath set, scaled by `breathDepth`. Amplitudes and periods are the Cubism sample's
7001
+ * own: a head sway across `ParamAngle*`/`ParamBodyAngleX` alongside `ParamBreath` itself.
7002
+ */
7003
+ protected applyBreathParameters(): void;
7004
+ /**
7005
+ * Retune the idle breath live. `enabled: false` stops the contribution outright rather than
7006
+ * scaling it to nothing, so a host can turn it off without losing the depth it returns to.
7007
+ */
7008
+ setBreath(enabled: boolean, depth?: number): void;
6991
7009
  updateNaturalMovements(dt: DOMHighResTimeStamp, _now: DOMHighResTimeStamp): void;
6992
7010
  draw(gl: WebGLRenderingContext): void;
6993
7011
  extendParallelMotionManager(managerCount: number): void;
package/dist/index.js CHANGED
@@ -15140,6 +15140,8 @@ var CubismInternalModel = class extends InternalModel {
15140
15140
  parallelMotionManager;
15141
15141
  lipSync = true;
15142
15142
  breath = CubismBreath.create();
15143
+ /** Whether the idle breath contributes at all; see {@link setBreath}. */
15144
+ breathEnabled = true;
15143
15145
  eyeBlink;
15144
15146
  renderer = new CubismRenderer_WebGL(0, 0);
15145
15147
  idManager;
@@ -15192,13 +15194,7 @@ var CubismInternalModel = class extends InternalModel {
15192
15194
  eyeBlink.setParameterIds?.(parameterIds);
15193
15195
  this.eyeBlink = eyeBlink;
15194
15196
  }
15195
- this.breath.setParameters([
15196
- new BreathParameterData(this.idParamAngleX, 0, 15 * this.options.breathDepth, 6.5345, .5),
15197
- new BreathParameterData(this.idParamAngleY, 0, 8 * this.options.breathDepth, 3.5345, .5),
15198
- new BreathParameterData(this.idParamAngleZ, 0, 10 * this.options.breathDepth, 5.5345, .5),
15199
- new BreathParameterData(this.idParamBodyAngleX, 0, 4 * this.options.breathDepth, 15.5345, .5),
15200
- new BreathParameterData(this.idParamBreath, 0, .5, 3.2345, .5)
15201
- ]);
15197
+ this.applyBreathParameters();
15202
15198
  this.renderer.initialize(this.coreModel, getRequiredMaskRenderTextureCount(this.coreModel));
15203
15199
  this.renderer.useHighPrecisionMask(this.renderer.isUsingHighPrecisionMask() || resolveHighPrecisionMaskOption(this.coreModel, this.options.useHighPrecisionMask));
15204
15200
  this.renderer.setIsPremultipliedAlpha(true);
@@ -15315,8 +15311,31 @@ var CubismInternalModel = class extends InternalModel {
15315
15311
  updateFacialEmotion(mouthForm) {
15316
15312
  this.coreModel.addParameterValueById(this.idParamMouthForm, mouthForm);
15317
15313
  }
15314
+ /**
15315
+ * The idle breath set, scaled by `breathDepth`. Amplitudes and periods are the Cubism sample's
15316
+ * own: a head sway across `ParamAngle*`/`ParamBodyAngleX` alongside `ParamBreath` itself.
15317
+ */
15318
+ applyBreathParameters() {
15319
+ const depth = this.options.breathDepth ?? 1;
15320
+ this.breath.setParameters([
15321
+ new BreathParameterData(this.idParamAngleX, 0, 15 * depth, 6.5345, .5),
15322
+ new BreathParameterData(this.idParamAngleY, 0, 8 * depth, 3.5345, .5),
15323
+ new BreathParameterData(this.idParamAngleZ, 0, 10 * depth, 5.5345, .5),
15324
+ new BreathParameterData(this.idParamBodyAngleX, 0, 4 * depth, 15.5345, .5),
15325
+ new BreathParameterData(this.idParamBreath, 0, .5 * depth, 3.2345, .5)
15326
+ ]);
15327
+ }
15328
+ /**
15329
+ * Retune the idle breath live. `enabled: false` stops the contribution outright rather than
15330
+ * scaling it to nothing, so a host can turn it off without losing the depth it returns to.
15331
+ */
15332
+ setBreath(enabled, depth = this.options.breathDepth ?? 1) {
15333
+ this.breathEnabled = enabled;
15334
+ this.options.breathDepth = depth;
15335
+ this.applyBreathParameters();
15336
+ }
15318
15337
  updateNaturalMovements(dt, _now) {
15319
- this.breath?.updateParameters(this.coreModel, dt / 1e3);
15338
+ if (this.breathEnabled) this.breath?.updateParameters(this.coreModel, dt / 1e3);
15320
15339
  }
15321
15340
  draw(gl) {
15322
15341
  const matrix = this.drawingMatrix;