Skip to content

Commit

Permalink
Automated report
Browse files Browse the repository at this point in the history
  • Loading branch information
RaSan147 committed Oct 12, 2023
1 parent 7deba12 commit 06bfbd3
Show file tree
Hide file tree
Showing 9 changed files with 335 additions and 87 deletions.
63 changes: 49 additions & 14 deletions dist/cubism2.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,8 @@ class MotionManager extends EventEmitter {
_loadMotion(group, index) {
throw new Error("Not implemented.");
}
speakUp(sound, volume, expression) {
return __async(this, null, function* () {
speakUp(_0) {
return __async(this, arguments, function* (sound, { volume = 1, expression, resetExpression = true } = {}) {
if (!config.sound) {
return false;
}
Expand Down Expand Up @@ -614,10 +614,10 @@ class MotionManager extends EventEmitter {
if (file) {
try {
audio = SoundManager.add(file, () => {
expression && that.expressionManager && that.expressionManager.resetExpression();
resetExpression && expression && that.expressionManager && that.expressionManager.resetExpression();
that.currentAudio = void 0;
}, () => {
expression && that.expressionManager && that.expressionManager.resetExpression();
resetExpression && expression && that.expressionManager && that.expressionManager.resetExpression();
that.currentAudio = void 0;
});
this.currentAudio = audio;
Expand Down Expand Up @@ -651,7 +651,7 @@ class MotionManager extends EventEmitter {
});
}
startMotion(_0, _1) {
return __async(this, arguments, function* (group, index, priority = MotionPriority.NORMAL, sound, volume, expression) {
return __async(this, arguments, function* (group, index, priority = MotionPriority.NORMAL, { sound = void 0, volume = 1, expression = void 0, resetExpression = true } = {}) {
var _a;
if (this.currentAudio) {
if (!this.currentAudio.ended) {
Expand Down Expand Up @@ -691,10 +691,10 @@ class MotionManager extends EventEmitter {
if (file) {
try {
audio = SoundManager.add(file, () => {
expression && that.expressionManager && that.expressionManager.resetExpression();
resetExpression && expression && that.expressionManager && that.expressionManager.resetExpression();
that.currentAudio = void 0;
}, () => {
expression && that.expressionManager && that.expressionManager.resetExpression();
resetExpression && expression && that.expressionManager && that.expressionManager.resetExpression();
that.currentAudio = void 0;
});
this.currentAudio = audio;
Expand Down Expand Up @@ -740,8 +740,8 @@ class MotionManager extends EventEmitter {
return true;
});
}
startRandomMotion(group, priority, sound, volume) {
return __async(this, null, function* () {
startRandomMotion(_0, _1) {
return __async(this, arguments, function* (group, priority, { sound = void 0, volume = 1, expression = void 0, resetExpression = true } = {}) {
const groupDefs = this.definitions[group];
if (groupDefs == null ? void 0 : groupDefs.length) {
const availableIndices = [];
Expand All @@ -752,7 +752,12 @@ class MotionManager extends EventEmitter {
}
if (availableIndices.length) {
const index = availableIndices[Math.floor(Math.random() * availableIndices.length)];
return this.startMotion(group, index, priority, sound, volume);
return this.startMotion(group, index, priority, {
sound,
volume,
expression,
resetExpression
});
}
}
return false;
Expand Down Expand Up @@ -1398,14 +1403,28 @@ class Live2DModel extends Container {
onAnchorChange() {
this.pivot.set(this.anchor.x * this.internalModel.width, this.anchor.y * this.internalModel.height);
}
motion(group, index, priority, sound, volume, expression) {
return index === void 0 ? this.internalModel.motionManager.startRandomMotion(group, priority) : this.internalModel.motionManager.startMotion(group, index, priority, sound, volume, expression);
motion(group, index, { priority = 2, sound, volume = 1, expression, resetExpression = true } = {}) {
return index === void 0 ? this.internalModel.motionManager.startRandomMotion(group, priority, {
sound,
volume,
expression,
resetExpression
}) : this.internalModel.motionManager.startMotion(group, index, priority, {
sound,
volume,
expression,
resetExpression
});
}
resetMotions() {
return this.internalModel.motionManager.stopAllMotions();
}
speak(sound, volume, expression) {
return this.internalModel.motionManager.speakUp(sound, volume, expression);
speak(sound, { volume = 1, expression, resetExpression = true } = {}) {
return this.internalModel.motionManager.speakUp(sound, {
volume,
expression,
resetExpression
});
}
stopSpeaking() {
return this.internalModel.motionManager.stopSpeaking();
Expand Down Expand Up @@ -1790,6 +1809,7 @@ class Cubism2MotionManager extends MotionManager {
this.queueManager = new MotionQueueManager();
this.definitions = this.settings.motions;
this.init(options);
this.lipSyncIds = ["PARAM_MOUTH_OPEN_Y"];
}
init(options) {
super.init(options);
Expand Down Expand Up @@ -1903,6 +1923,7 @@ class Cubism2InternalModel extends InternalModel {
constructor(coreModel, settings, options) {
super();
this.textureFlipY = true;
this.lipSync = true;
this.drawDataCount = 0;
this.disableCulling = false;
this.coreModel = coreModel;
Expand All @@ -1916,6 +1937,7 @@ class Cubism2InternalModel extends InternalModel {
this.angleZParamIndex = coreModel.getParamIndex("PARAM_ANGLE_Z");
this.bodyAngleXParamIndex = coreModel.getParamIndex("PARAM_BODY_ANGLE_X");
this.breathParamIndex = coreModel.getParamIndex("PARAM_BREATH");
this.mouthFormIndex = coreModel.getParamIndex("PARAM_MOUTH_FORM");
this.init();
}
init() {
Expand Down Expand Up @@ -2024,6 +2046,19 @@ class Cubism2InternalModel extends InternalModel {
}
this.updateFocus();
this.updateNaturalMovements(dt, now);
if (this.lipSync && this.motionManager.currentAudio) {
let value = this.motionManager.mouthSync();
let min_ = 0;
let max_ = 1;
let weight = 1.2;
if (value > 0) {
min_ = 0.4;
}
value = clamp(value * weight, min_, max_);
for (let i = 0; i < this.motionManager.lipSyncIds.length; ++i) {
this.coreModel.setParamFloat(this.coreModel.getParamIndex(this.motionManager.lipSyncIds[i]), value);
}
}
(_c = this.physics) == null ? void 0 : _c.update(now);
(_d = this.pose) == null ? void 0 : _d.update(dt);
this.emit("beforeModelUpdate");
Expand Down
63 changes: 49 additions & 14 deletions dist/cubism2.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,8 @@ var __async = (__this, __arguments, generator) => {
_loadMotion(group, index) {
throw new Error("Not implemented.");
}
speakUp(sound, volume, expression) {
return __async(this, null, function* () {
speakUp(_0) {
return __async(this, arguments, function* (sound, { volume = 1, expression, resetExpression = true } = {}) {
if (!exports2.config.sound) {
return false;
}
Expand Down Expand Up @@ -614,10 +614,10 @@ var __async = (__this, __arguments, generator) => {
if (file) {
try {
audio = SoundManager.add(file, () => {
expression && that.expressionManager && that.expressionManager.resetExpression();
resetExpression && expression && that.expressionManager && that.expressionManager.resetExpression();
that.currentAudio = void 0;
}, () => {
expression && that.expressionManager && that.expressionManager.resetExpression();
resetExpression && expression && that.expressionManager && that.expressionManager.resetExpression();
that.currentAudio = void 0;
});
this.currentAudio = audio;
Expand Down Expand Up @@ -651,7 +651,7 @@ var __async = (__this, __arguments, generator) => {
});
}
startMotion(_0, _1) {
return __async(this, arguments, function* (group, index, priority = MotionPriority.NORMAL, sound, volume, expression) {
return __async(this, arguments, function* (group, index, priority = MotionPriority.NORMAL, { sound = void 0, volume = 1, expression = void 0, resetExpression = true } = {}) {
var _a;
if (this.currentAudio) {
if (!this.currentAudio.ended) {
Expand Down Expand Up @@ -691,10 +691,10 @@ var __async = (__this, __arguments, generator) => {
if (file) {
try {
audio = SoundManager.add(file, () => {
expression && that.expressionManager && that.expressionManager.resetExpression();
resetExpression && expression && that.expressionManager && that.expressionManager.resetExpression();
that.currentAudio = void 0;
}, () => {
expression && that.expressionManager && that.expressionManager.resetExpression();
resetExpression && expression && that.expressionManager && that.expressionManager.resetExpression();
that.currentAudio = void 0;
});
this.currentAudio = audio;
Expand Down Expand Up @@ -740,8 +740,8 @@ var __async = (__this, __arguments, generator) => {
return true;
});
}
startRandomMotion(group, priority, sound, volume) {
return __async(this, null, function* () {
startRandomMotion(_0, _1) {
return __async(this, arguments, function* (group, priority, { sound = void 0, volume = 1, expression = void 0, resetExpression = true } = {}) {
const groupDefs = this.definitions[group];
if (groupDefs == null ? void 0 : groupDefs.length) {
const availableIndices = [];
Expand All @@ -752,7 +752,12 @@ var __async = (__this, __arguments, generator) => {
}
if (availableIndices.length) {
const index = availableIndices[Math.floor(Math.random() * availableIndices.length)];
return this.startMotion(group, index, priority, sound, volume);
return this.startMotion(group, index, priority, {
sound,
volume,
expression,
resetExpression
});
}
}
return false;
Expand Down Expand Up @@ -1398,14 +1403,28 @@ var __async = (__this, __arguments, generator) => {
onAnchorChange() {
this.pivot.set(this.anchor.x * this.internalModel.width, this.anchor.y * this.internalModel.height);
}
motion(group, index, priority, sound, volume, expression) {
return index === void 0 ? this.internalModel.motionManager.startRandomMotion(group, priority) : this.internalModel.motionManager.startMotion(group, index, priority, sound, volume, expression);
motion(group, index, { priority = 2, sound, volume = 1, expression, resetExpression = true } = {}) {
return index === void 0 ? this.internalModel.motionManager.startRandomMotion(group, priority, {
sound,
volume,
expression,
resetExpression
}) : this.internalModel.motionManager.startMotion(group, index, priority, {
sound,
volume,
expression,
resetExpression
});
}
resetMotions() {
return this.internalModel.motionManager.stopAllMotions();
}
speak(sound, volume, expression) {
return this.internalModel.motionManager.speakUp(sound, volume, expression);
speak(sound, { volume = 1, expression, resetExpression = true } = {}) {
return this.internalModel.motionManager.speakUp(sound, {
volume,
expression,
resetExpression
});
}
stopSpeaking() {
return this.internalModel.motionManager.stopSpeaking();
Expand Down Expand Up @@ -1790,6 +1809,7 @@ var __async = (__this, __arguments, generator) => {
this.queueManager = new MotionQueueManager();
this.definitions = this.settings.motions;
this.init(options);
this.lipSyncIds = ["PARAM_MOUTH_OPEN_Y"];
}
init(options) {
super.init(options);
Expand Down Expand Up @@ -1903,6 +1923,7 @@ var __async = (__this, __arguments, generator) => {
constructor(coreModel, settings, options) {
super();
this.textureFlipY = true;
this.lipSync = true;
this.drawDataCount = 0;
this.disableCulling = false;
this.coreModel = coreModel;
Expand All @@ -1916,6 +1937,7 @@ var __async = (__this, __arguments, generator) => {
this.angleZParamIndex = coreModel.getParamIndex("PARAM_ANGLE_Z");
this.bodyAngleXParamIndex = coreModel.getParamIndex("PARAM_BODY_ANGLE_X");
this.breathParamIndex = coreModel.getParamIndex("PARAM_BREATH");
this.mouthFormIndex = coreModel.getParamIndex("PARAM_MOUTH_FORM");
this.init();
}
init() {
Expand Down Expand Up @@ -2024,6 +2046,19 @@ var __async = (__this, __arguments, generator) => {
}
this.updateFocus();
this.updateNaturalMovements(dt, now);
if (this.lipSync && this.motionManager.currentAudio) {
let value = this.motionManager.mouthSync();
let min_ = 0;
let max_ = 1;
let weight = 1.2;
if (value > 0) {
min_ = 0.4;
}
value = clamp(value * weight, min_, max_);
for (let i = 0; i < this.motionManager.lipSyncIds.length; ++i) {
this.coreModel.setParamFloat(this.coreModel.getParamIndex(this.motionManager.lipSyncIds[i]), value);
}
}
(_c = this.physics) == null ? void 0 : _c.update(now);
(_d = this.pose) == null ? void 0 : _d.update(dt);
this.emit("beforeModelUpdate");
Expand Down
2 changes: 1 addition & 1 deletion dist/cubism2.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 06bfbd3

Please sign in to comment.