Skip to content

Commit de7bcf5

Browse files
committed
Update for v0.27.2
1 parent 296666b commit de7bcf5

File tree

6 files changed

+305
-20
lines changed

6 files changed

+305
-20
lines changed

MMD.js/MMD_SA.js

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// MMD for System Animator
2-
// (2024-07-30)
2+
// (2024-08-18)
33

44
var use_full_spectrum = true
55

@@ -1002,8 +1002,7 @@ if (!ao.ontimeupdate)
10021002

10031003
if (json.System_Animator_motion_para) {
10041004
for (const name in json.System_Animator_motion_para) {
1005-
if (MMD_SA_options.motion_para[name])
1006-
MMD_SA_options.motion_para[name] = Object.assign(MMD_SA_options.motion_para[name]||{}, json.System_Animator_motion_para[name]);
1005+
MMD_SA_options.motion_para[name] = Object.assign(MMD_SA_options.motion_para[name]||{}, json.System_Animator_motion_para[name]);
10071006
}
10081007
DEBUG_show('✅Motion config imported', 3);
10091008
}
@@ -12602,7 +12601,8 @@ function MMD_LR(name) {
1260212601
const nj_list = ["0","1","2","3"];
1260312602
function MMD_finger(name) {
1260412603
let j_index;
12605-
var f = finger_map[RegExp.$1.toLowerCase().replace(/middle/, 'mid')];
12604+
// use 'middle' instead of /middle/, as regular expression will change RegExp.$ values
12605+
var f = finger_map[RegExp.$1.toLowerCase().replace('middle', 'mid')];
1260612606
if (f) {
1260712607
j_index = parseInt(RegExp.$2);
1260812608
}
@@ -12636,9 +12636,27 @@ function rig(k, v) {
1263612636
_rig_map[k] = v
1263712637
}
1263812638

12639+
function is_armature(obj) {
12640+
if (!has_armature) return false;
12641+
/*
12642+
// FBX-to-glTF test
12643+
do {
12644+
obj = obj.parent;
12645+
if (!obj) return false;
12646+
if (obj.name == 'Armature') return true;
12647+
}
12648+
while (obj?.name);
12649+
*/
12650+
return false;
12651+
}
12652+
1263912653
const bone_map = [];
12654+
let has_armature;
1264012655
asset.traverse((obj)=>{
12641-
if (obj.isBone) {
12656+
if (obj.name == 'Armature') {
12657+
has_armature = true;
12658+
}
12659+
else if (obj.isBone || is_armature(obj)) {
1264212660
if (bone_map.findIndex(name=>name==obj.name) == -1)
1264312661
bone_map.push(obj.name);
1264412662
}
@@ -12794,6 +12812,9 @@ Object.entries(rig_map.VRM).forEach(kv=>{
1279412812

1279512813
skeletons.forEach(s=>s.pose());
1279612814

12815+
// FBX-to-glTF test
12816+
//if (!skeletons.length) skeletons = [{}];
12817+
1279712818
console.log('bone_clones', bone_clones)
1279812819

1279912820
VRM.fix_rig_map(rig_map.VRM);
@@ -12871,6 +12892,15 @@ const hips_q_inv = hips_q.clone().conjugate();
1287112892

1287212893
console.log('rig_rot,[hips_q]', rig_rot, [hips_q.clone()]);//, motion_hips.quaternion, motion_hips.parent.getWorldQuaternion(new THREE.Quaternion()), new THREE.Quaternion().copy(hips_q_inv).premultiply(motion_hips.quaternion).multiply(q2.copy(motion_hips.quaternion).conjugate()).multiply(hips_q)]);
1287312894
let _rig_rot_perpendicular = Math.abs(rig_rot.w) % 1 < 0.0001;
12895+
/*
12896+
// FBX-to-glTF test
12897+
if (1) {
12898+
hips_q.set(-0.707,0,0,0.707).normalize();
12899+
hips_q_inv.copy(hips_q).conjugate();
12900+
// rig_rot.copy(hips_q)
12901+
}
12902+
else
12903+
*/
1287412904
if (skeletons.length && (bone_clones['hips'].clone.quaternion.w != 1)) {
1287512905
if (_rig_rot_perpendicular) {
1287612906
hips_q.copy(rig_rot);

0 commit comments

Comments
 (0)