Skip to content

Commit

Permalink
Fixed bugs for FBX rotation order
Browse files Browse the repository at this point in the history
  • Loading branch information
xianfei committed Jul 18, 2024
1 parent f9f8c33 commit e107208
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 39 deletions.
86 changes: 49 additions & 37 deletions mainview/framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,54 +13,66 @@ var remote = null;
var platform = "web";

var mixamorig = {
Hips: {
name: "mixamorigHips",
func: { fx: "-x", fy: "y", fz: "-z" },
"Hips": {
"name": "mixamorigHips",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
},
Neck: {
name: "mixamorigNeck",
func: { fx: "-x", fy: "y", fz: "-z" },
"Neck": {
"name": "mixamorigNeck",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
},
Chest: {
name: "mixamorigSpine2",
func: { fx: "-x", fy: "y", fz: "-z" },
"Chest": {
"name": "mixamorigSpine2",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
},
Spine: {
name: "mixamorigSpine",
func: { fx: "-x", fy: "y", fz: "-z" },
"Spine": {
"name": "mixamorigSpine",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
},
RightUpperArm: {
name: "mixamorigRightArm",
func: { fx: "-z", fy: "x", fz: "-y" },
"RightUpperArm": {
"name": "mixamorigRightArm",
"order": "ZXY",
"func": { "fx": "-z", "fy": "x", "fz": "-y" }
},
RightLowerArm: {
name: "mixamorigRightForeArm",
func: { fx: "-z", fy: "x", fz: "-y" },
"RightLowerArm": {
"name": "mixamorigRightForeArm",
"order": "ZXY",
"func": { "fx": "-z", "fy": "x", "fz": "-y" }
},
LeftUpperArm: {
name: "mixamorigLeftArm",
func: { fx: "z", fy: "-x", fz: "-y" },
"LeftUpperArm": {
"name": "mixamorigLeftArm",
"order": "ZXY",
"func": { "fx": "z", "fy": "-x", "fz": "-y" }
},
LeftLowerArm: {
name: "mixamorigLeftForeArm",
func: { fx: "z", fy: "-x", fz: "-y" },
"LeftLowerArm": {
"name": "mixamorigLeftForeArm",
"order": "ZXY",
"func": { "fx": "z", "fy": "-x", "fz": "-y" }
},
LeftUpperLeg: {
name: "mixamorigLeftUpLeg",
func: { fx: "-x", fy: "y", fz: "-z" },
"LeftUpperLeg": {
"name": "mixamorigLeftUpLeg",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
},
LeftLowerLeg: {
name: "mixamorigLeftLeg",
func: { fx: "-x", fy: "y", fz: "-z" },
"LeftLowerLeg": {
"name": "mixamorigLeftLeg",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
},
RightUpperLeg: {
name: "mixamorigRightUpLeg",
func: { fx: "-x", fy: "y", fz: "-z" },
},
RightLowerLeg: {
name: "mixamorigRightLeg",
func: { fx: "-x", fy: "y", fz: "-z" },
"RightUpperLeg": {
"name": "mixamorigRightUpLeg",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
},
"RightLowerLeg": {
"name": "mixamorigRightLeg",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
}
};

function domBoom(target, onfinish) {
Expand Down
7 changes: 5 additions & 2 deletions mocaprender/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,16 +305,19 @@ const rigRotation = (
z: b.rotation.z,
};
}
var bindingFunc = modelObj.binding[name].func;
const bindingFunc = modelObj.binding[name].func;
const order = modelObj.binding[name].order.toUpperCase();
const x = rotation.x * dampener;
const y = rotation.y * dampener;
const z = rotation.z * dampener;

// console.log("rotation.rotationOrder ",rotation.rotationOrder )

let euler = new THREE.Euler(
initRotation[name].x + eval(bindingFunc.fx),
initRotation[name].y + eval(bindingFunc.fy),
initRotation[name].z + eval(bindingFunc.fz),
rotation.rotationOrder || "XYZ"
order || rotation.rotationOrder || "XYZ"
);
let quaternion = new THREE.Quaternion().setFromEuler(euler);
b.quaternion.slerp(quaternion, lerpAmount); // interpolate
Expand Down
24 changes: 24 additions & 0 deletions models/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,50 +152,62 @@
"binding": {
"Hips": {
"name": "mixamorigHips",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
},
"Neck": {
"name": "mixamorigNeck",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
},
"Chest": {
"name": "mixamorigSpine2",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
},
"Spine": {
"name": "mixamorigSpine",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
},
"RightUpperArm": {
"name": "mixamorigRightArm",
"order": "ZXY",
"func": { "fx": "-z", "fy": "x", "fz": "-y" }
},
"RightLowerArm": {
"name": "mixamorigRightForeArm",
"order": "ZXY",
"func": { "fx": "-z", "fy": "x", "fz": "-y" }
},
"LeftUpperArm": {
"name": "mixamorigLeftArm",
"order": "ZXY",
"func": { "fx": "z", "fy": "-x", "fz": "-y" }
},
"LeftLowerArm": {
"name": "mixamorigLeftForeArm",
"order": "ZXY",
"func": { "fx": "z", "fy": "-x", "fz": "-y" }
},
"LeftUpperLeg": {
"name": "mixamorigLeftUpLeg",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
},
"LeftLowerLeg": {
"name": "mixamorigLeftLeg",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
},
"RightUpperLeg": {
"name": "mixamorigRightUpLeg",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
},
"RightLowerLeg": {
"name": "mixamorigRightLeg",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
}
}
Expand All @@ -210,50 +222,62 @@
"binding": {
"Hips": {
"name": "mixamorigHips",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
},
"Neck": {
"name": "mixamorigNeck",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
},
"Chest": {
"name": "mixamorigSpine2",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
},
"Spine": {
"name": "mixamorigSpine",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
},
"RightUpperArm": {
"name": "mixamorigRightArm",
"order": "ZXY",
"func": { "fx": "-z", "fy": "x", "fz": "-y" }
},
"RightLowerArm": {
"name": "mixamorigRightForeArm",
"order": "ZXY",
"func": { "fx": "-z", "fy": "x", "fz": "-y" }
},
"LeftUpperArm": {
"name": "mixamorigLeftArm",
"order": "ZXY",
"func": { "fx": "z", "fy": "-x", "fz": "-y" }
},
"LeftLowerArm": {
"name": "mixamorigLeftForeArm",
"order": "ZXY",
"func": { "fx": "z", "fy": "-x", "fz": "-y" }
},
"LeftUpperLeg": {
"name": "mixamorigLeftUpLeg",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
},
"LeftLowerLeg": {
"name": "mixamorigLeftLeg",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
},
"RightUpperLeg": {
"name": "mixamorigRightUpLeg",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
},
"RightLowerLeg": {
"name": "mixamorigRightLeg",
"order": "XYZ",
"func": { "fx": "-x", "fy": "y", "fz": "-z" }
}
}
Expand Down

0 comments on commit e107208

Please sign in to comment.