Skip to content

Commit

Permalink
Update for v0.24.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ButzYung committed Oct 9, 2024
1 parent 986c965 commit f382559
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 27 deletions.
42 changes: 36 additions & 6 deletions MMD.js/MMD_SA.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// MMD for System Animator
// (2024-06-10)
// (2024-06-19)

var use_full_spectrum = true

Expand Down Expand Up @@ -1031,7 +1031,7 @@ c.height = MMD_SA_options.height

Object.defineProperty(MMD_SA, "camera_auto_adjust_scale_enabled", {
get: function () {
return MMD_SA_options.camera_auto_adjust && !THREE.MMD.getCameraMotion().length && (this.MMD.motionManager.para_SA.camera_auto_adjust !== false);
return MMD_SA_options.camera_auto_adjust && !THREE.MMD.getCameraMotion().length && (this.MMD.motionManager.para_SA.camera_auto_adjust !== false) && !this.MMD.motionManager.para_SA.use_mother_bone;
}
});

Expand Down Expand Up @@ -1084,6 +1084,15 @@ if (scale != 1) {
cv = c_base.sub(MMD_SA.TEMP_v3.fromArray(MMD_SA_options.camera_position_base)).toArray();
cv[2] *= MMD_SA_options.Dungeon_options.camera_position_z_sign;
}
else if (MMD_SA_options.camera_auto_adjust && ((cv[1] == 0) || this.MMD.motionManager.para_SA.use_mother_bone)) {

const modelX = MMD_SA.THREEX.get_model(0);
let scale_offset = (modelX.para.hip_center.y + modelX.para.spine_length/2) - (11.364640235900879 + 4.97462/2);
scale_offset *= 0.75;
if (scale_offset < 0) scale_offset *= 0.85;
cv[1] += scale_offset*0.5;

}

if (this.camera_auto_adjust_fov_enabled) {
// https://hofk.de/main/discourse.threejs/2022/CalculateCameraDistance/CalculateCameraDistance.html
Expand Down Expand Up @@ -8446,9 +8455,30 @@ return MMD_SA_options.model_para_obj[prop];
return new Proxy({}, handler);
})(),

get_bone_origin_by_MMD_name: function (name) {
return (threeX.enabled) ? this.para.pos0[VRM.bone_map_MMD_to_VRM[name]]?.slice().map(v=>v*this.model_scale) : this.get_bone_by_MMD_name(name)?.pmxBone.origin;
},
get_bone_origin_by_MMD_name: (()=>{
let v1, v2;
window.addEventListener('jThree_ready', ()=>{
v1 = new THREE.Vector3();
v2 = new THREE.Vector3();
});

return function (name, root_origin) {
if (threeX.enabled && !root_origin)
return this.para.pos0[VRM.bone_map_MMD_to_VRM[name]]?.slice().map(v=>v*this.model_scale);

let b = (!threeX.enabled) ? this.get_bone_by_MMD_name(name) : _THREE.MMD.getModels()[0].mesh.bones_by_name[name];
if (!b) return null;
if (!root_origin) return b.pmxBone.origin;

v1.fromArray(b.pmxBone.origin);
while (b.parent?.pmxBone) {
b = b.parent;
v1.sub(v2.fromArray(b.pmxBone.origin));
}

return v1.toArray();
};
})(),

get_bone_position_by_MMD_name: function (name, local_only) {
var bone = this.get_bone_by_MMD_name(name);
Expand Down Expand Up @@ -8927,7 +8957,7 @@ para.left_palm_length = v1.fromArray(para.pos0['leftHand']).distanceTo(v2.fromAr
para.left_leg_length = ((para.pos0['leftUpperLeg'][1] - para.pos0['leftLowerLeg'][1]) + (para.pos0['leftLowerLeg'][1] - para.pos0['leftFoot'][1])) * vrm_scale;
para.spine_length = (para.pos0['neck'][1] - para.pos0['leftUpperLeg'][1]) * vrm_scale;

//para.left_heel_height = para.pos0['leftFoot'][1] * vrm_scale;
para.left_heel_height = para.pos0['leftFoot'][1] * vrm_scale;
para.hip_center = new THREE.Vector3().fromArray(para.pos0['leftUpperLeg']).setX(0).multiplyScalar(vrm_scale);
para.hip_center_offset = new THREE.Vector3().fromArray(para.pos0['hips']).multiplyScalar(vrm_scale).sub(para.hip_center);

Expand Down
16 changes: 5 additions & 11 deletions images/XR Animator/animate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// XR Animator
// (2024-06-10)
// (2024-06-19)

var MMD_SA_options = {

Expand Down Expand Up @@ -1514,13 +1514,7 @@ if (this.center_view_enforced) {
//DEBUG_show(Date.now()+'\n'+cz)
}
else {
// center_view = [0,0,0];

let scale_offset = (modelX.para.hip_center.y + modelX.para.spine_length/2) - (11.364640235900879 + 4.97462/2);
scale_offset *= 0.75;
if (scale_offset < 0) scale_offset *= 0.85;
center_view = [0, scale_offset*0.5, 0];

center_view = [0,0,0];
}

return center_view;
Expand Down Expand Up @@ -3390,15 +3384,15 @@ video:{
// hidden:true,
// hidden_on_webcam: true,
scale:0.4, top:-0.5,
//left:+0.4,top:-1,
//left:-0.25,top:-1,
//scale:0.4*1,top:0,left:-3,
//scale:0.4*2,top:0,left:-1,
},
wireframe:{
// hidden:true,
// align_with_video:true,
top:0.5,
//left:+(0.5),top:-1,
//left:+(0.25),top:-1,
//left:1,
//top:0.8,left:0.4,
//top:0,left:3,
Expand Down Expand Up @@ -9182,7 +9176,7 @@ MMD_SA_options.Dungeon.para_by_grid_id[2].ground_y = explorer_ground_y;
,[
{
message: {
get content() { return 'XR Animator (v0.24.0)\n' + System._browser.translation.get('XR_Animator.UI.UI_options.about_XR_Animator.message'); }
get content() { return 'XR Animator (v0.24.1)\n' + System._browser.translation.get('XR_Animator.UI.UI_options.about_XR_Animator.message'); }
,bubble_index: 3
,branch_list: [
{ key:1, event_id: {
Expand Down
4 changes: 2 additions & 2 deletions images/XR Animator/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -2244,13 +2244,13 @@
},
"sponsor": {
"_translation_": {
"_default_": "XR Animator is sponsored by the following people🙏\n \n<list>\n \nand other supporters",
"_default_": "XR Animator is sponsored by the following persons🙏\n \n<list>\n \nand other supporters",
"ja": "XR Animator は以下の方々にご協賛いただいております🙏\n \n<list>\n \nその他サポーターの皆様",
"zh": "XR Animator 由以下的人士贊助🙏\n \n<list>\n \n及其他支持者"
},
"list": {
"_translation_": {
"_default_": "NewruGuru, Nymph, Shionay, shion, KuraiNoOni, MShade, Kai, ambyshard, Prajzis, LouLi Lou,"
"_default_": "NewruGuru, Nymph, Shionay, shion, KuraiNoOni, MShade, Dominic Renner, Kai, ambyshard, Prajzis, 星洛薊野Azami,"
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion jThree/MMDplugin/v2.1.2_jThree.MMD.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (2024-06-10)
// (2024-06-19)

/*!
* jThree.MMD.js JavaScript Library v1.6.1
Expand Down Expand Up @@ -2737,6 +2737,11 @@ return (this._IK_name_list.indexOf(IK_name) != -1);
}
}

if (self.MMD_SA && (keys.length > 2) && (keys[0].name == '全ての親')) {
if (MMD_SA.TEMP_v3.fromArray(keys[0].pos).lengthSq() || MMD_SA.TEMP_v3.fromArray(keys[keys.length-1].pos).lengthSq())
motion_para.use_mother_bone = true;
}

// AT: skip empty keys (i:bone_idx required)
if (keys.length)
targets.push( { keys:keys, i:bone_idx } );
Expand Down
4 changes: 2 additions & 2 deletions jThree/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (2024-06-10)
// (2024-06-19)

MMD_SA.fn = {
/*
Expand Down Expand Up @@ -642,7 +642,7 @@ if (p_bone.rotation) {
const rot_adjust = p_bone.rotation.align_with_external_point;
if (rot_adjust)
x_object.user_data._rot_default_ = (x_object.user_data._rot_default_ || new THREE.Quaternion()).copy(obj.quaternion);
if (rot_adjust && (!rot_adjust.mocap_only || (System._browser.camera.poseNet.enabled && System._browser.camera.ML_warmed_up))) {
if (rot_adjust && !rot_adjust.disabled && (!rot_adjust.mocap_only || (System._browser.camera.poseNet.enabled && System._browser.camera.ML_warmed_up))) {
const rot_original = MMD_SA._q2.copy(obj.quaternion);

transfer_to_parent_bone = rot_adjust.transfer_to_parent_bone && (System._browser.camera.poseNet.enabled && System._browser.camera.ML_warmed_up);
Expand Down
6 changes: 3 additions & 3 deletions jThree/three.core.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/SA_system_emulation.min.js

Large diffs are not rendered by default.

0 comments on commit f382559

Please sign in to comment.