mg696 commited on
Commit
17ff63d
·
verified ·
1 Parent(s): 53855e0

v89d: dump constraint keys to find correct property names

Browse files
Files changed (1) hide show
  1. app-extra.js +13 -5
app-extra.js CHANGED
@@ -1,14 +1,22 @@
1
- // app-extra.js v89c - constraint dump fixed
2
  (function(){function waitReady(cb){const ck=()=>{if(window.__appReady)cb();else setTimeout(ck,200)};ck()}waitReady(()=>{const domeInput=document.getElementById('dome-input');if(domeInput){domeInput.addEventListener('change',async e=>{if(!e.target.files.length)return;window.__showLoading(true,"ドーム展開中...");await window.__processFiles(e.target.files,'dome');let pmx=window.__findFileInMap('.pmx','dome')||window.__findFileInMap('.pmd','dome');if(pmx){document.getElementById('dome-label').classList.add('ready');window.__loadPmx(pmx,'dome')}else{window.__showLoading(false)}})};['x','y','z'].forEach(axis=>{const sl=document.getElementById('main-light-'+axis);const vl=document.getElementById('main-light-'+axis+'-val');if(!sl||!vl)return;sl.addEventListener('input',()=>{const v=parseFloat(sl.value);vl.value=v;if(window.__mainLight)window.__mainLight.position[axis]=v})});['x','y','z'].forEach(axis=>{const sl=document.getElementById('sub-light-'+axis);const vl=document.getElementById('sub-light-'+axis+'-val');if(!sl||!vl)return;sl.addEventListener('input',()=>{const v=parseFloat(sl.value);vl.value=v;if(window.__subLight)window.__subLight.position[axis]=v})});const mc=document.getElementById('main-light-color');if(mc)mc.addEventListener('input',()=>{if(window.__mainLight)window.__mainLight.color.set(mc.value)});const sc=document.getElementById('sub-light-color');if(sc)sc.addEventListener('input',()=>{if(window.__subLight)window.__subLight.color.set(sc.value)});const ac=document.getElementById('amb-light-color');if(ac)ac.addEventListener('input',()=>{if(window.__ambLight)window.__ambLight.color.set(ac.value)});
3
  function getHairBodies(m){if(!m)return[];const obj=window.helper?.objects?.get(m);if(!obj||!obj.physics)return[];return obj.physics.bodies.filter(b=>b.params&&b.params.name&&b.params.name.startsWith('髪_'))}
4
- function applyHairWeight(val){[window.mesh,window.mesh2].forEach(m=>{getHairBodies(m).forEach(b=>{const seg=parseInt((b.params.name||'').split('_')[2])||1;let w=seg<=1?val:seg<=3?val*0.5:val*0.2;b.params.weight=w})})}
5
  function applyHairDamping(val){[window.mesh,window.mesh2].forEach(m=>{getHairBodies(m).forEach(b=>{if(b.body)b.body.setDamping(val,val);b.params.positionDamping=val;b.params.rotationDamping=val})})}
6
  function applyHairCollision(val){[window.mesh,window.mesh2].forEach(m=>{getHairBodies(m).forEach(b=>{b.params.groupTarget=val})})}
7
  const hwBar=document.getElementById('hair-weight-bar'),hwVal=document.getElementById('hair-weight-val');const hdBar=document.getElementById('hair-damp-bar'),hdVal=document.getElementById('hair-damp-val');const hcBar=document.getElementById('hair-col-bar'),hcVal=document.getElementById('hair-col-val');
8
  if(hwBar){hwBar.addEventListener('input',()=>{hwVal.value=parseFloat(hwBar.value).toFixed(3);applyHairWeight(parseFloat(hwBar.value))});hwVal.addEventListener('blur',()=>{const v=parseFloat(hwVal.value);if(!isNaN(v)){hwBar.value=v;applyHairWeight(v)}});hwVal.addEventListener('keydown',e=>{if(e.key==='Enter')hwVal.blur()})}
9
  if(hdBar){hdBar.addEventListener('input',()=>{hdVal.value=parseFloat(hdBar.value).toFixed(2);applyHairDamping(parseFloat(hdBar.value))});hdVal.addEventListener('blur',()=>{const v=parseFloat(hdVal.value);if(!isNaN(v)){hdBar.value=v;applyHairDamping(v)}});hdVal.addEventListener('keydown',e=>{if(e.key==='Enter')hdVal.blur()})}
10
  if(hcBar){hcBar.addEventListener('input',()=>{hcVal.value=parseInt(hcBar.value);applyHairCollision(parseInt(hcBar.value))});hcVal.addEventListener('blur',()=>{const v=parseInt(hcVal.value);if(!isNaN(v)){hcBar.value=v;applyHairCollision(v)}});hcVal.addEventListener('keydown',e=>{if(e.key==='Enter')hcVal.blur()})}
11
- // ★v89c: constraint自動ダンプ - ポーリング方式
12
  let dumped={};
13
- setInterval(()=>{[{k:'mesh1',m:window.mesh},{k:'mesh2',m:window.mesh2}].forEach(({k,m})=>{if(!m||dumped[k])return;const mmd=m.geometry?.userData?.MMD;if(!mmd||!mmd.constraints)return;dumped[k]=true;const cs=mmd.constraints;const bones=m.skeleton?.bones||[];const rbs=mmd.rigidBodies||mmd.rigidBodies;window.__dbg(`[CstDump] ${k}: ${cs.length}制約`,'info');cs.slice(0,15).forEach((c,i)=>{window.__dbg(` [C${i}] rb${c.rigidBodyIndex1}→rb${c.rigidBodyIndex2} tL1:[${c.translationLimitation1.map(v=>v.toFixed(3))}] tL2:[${c.translationLimitation2.map(v=>v.toFixed(3))}] rL1:[${c.rotationLimitation1.map(v=>v.toFixed(1))}] rL2:[${c.rotationLimitation2.map(v=>v.toFixed(1))}]`)})})},2000);
14
- window.__dbg('[Init] app-extra.js v89c 初期化完了','info')})})();
 
 
 
 
 
 
 
 
 
1
+ // app-extra.js v89d
2
  (function(){function waitReady(cb){const ck=()=>{if(window.__appReady)cb();else setTimeout(ck,200)};ck()}waitReady(()=>{const domeInput=document.getElementById('dome-input');if(domeInput){domeInput.addEventListener('change',async e=>{if(!e.target.files.length)return;window.__showLoading(true,"ドーム展開中...");await window.__processFiles(e.target.files,'dome');let pmx=window.__findFileInMap('.pmx','dome')||window.__findFileInMap('.pmd','dome');if(pmx){document.getElementById('dome-label').classList.add('ready');window.__loadPmx(pmx,'dome')}else{window.__showLoading(false)}})};['x','y','z'].forEach(axis=>{const sl=document.getElementById('main-light-'+axis);const vl=document.getElementById('main-light-'+axis+'-val');if(!sl||!vl)return;sl.addEventListener('input',()=>{const v=parseFloat(sl.value);vl.value=v;if(window.__mainLight)window.__mainLight.position[axis]=v})});['x','y','z'].forEach(axis=>{const sl=document.getElementById('sub-light-'+axis);const vl=document.getElementById('sub-light-'+axis+'-val');if(!sl||!vl)return;sl.addEventListener('input',()=>{const v=parseFloat(sl.value);vl.value=v;if(window.__subLight)window.__subLight.position[axis]=v})});const mc=document.getElementById('main-light-color');if(mc)mc.addEventListener('input',()=>{if(window.__mainLight)window.__mainLight.color.set(mc.value)});const sc=document.getElementById('sub-light-color');if(sc)sc.addEventListener('input',()=>{if(window.__subLight)window.__subLight.color.set(sc.value)});const ac=document.getElementById('amb-light-color');if(ac)ac.addEventListener('input',()=>{if(window.__ambLight)window.__ambLight.color.set(ac.value)});
3
  function getHairBodies(m){if(!m)return[];const obj=window.helper?.objects?.get(m);if(!obj||!obj.physics)return[];return obj.physics.bodies.filter(b=>b.params&&b.params.name&&b.params.name.startsWith('髪_'))}
4
+ function applyHairWeight(val){[window.mesh,window.mesh2].forEach(m=>{getHairBodies(m).forEach(b=>{const seg=parseInt((b.params.name||'').split('_')[2])||1;b.params.weight=seg<=1?val:seg<=3?val*0.5:val*0.2})})}
5
  function applyHairDamping(val){[window.mesh,window.mesh2].forEach(m=>{getHairBodies(m).forEach(b=>{if(b.body)b.body.setDamping(val,val);b.params.positionDamping=val;b.params.rotationDamping=val})})}
6
  function applyHairCollision(val){[window.mesh,window.mesh2].forEach(m=>{getHairBodies(m).forEach(b=>{b.params.groupTarget=val})})}
7
  const hwBar=document.getElementById('hair-weight-bar'),hwVal=document.getElementById('hair-weight-val');const hdBar=document.getElementById('hair-damp-bar'),hdVal=document.getElementById('hair-damp-val');const hcBar=document.getElementById('hair-col-bar'),hcVal=document.getElementById('hair-col-val');
8
  if(hwBar){hwBar.addEventListener('input',()=>{hwVal.value=parseFloat(hwBar.value).toFixed(3);applyHairWeight(parseFloat(hwBar.value))});hwVal.addEventListener('blur',()=>{const v=parseFloat(hwVal.value);if(!isNaN(v)){hwBar.value=v;applyHairWeight(v)}});hwVal.addEventListener('keydown',e=>{if(e.key==='Enter')hwVal.blur()})}
9
  if(hdBar){hdBar.addEventListener('input',()=>{hdVal.value=parseFloat(hdBar.value).toFixed(2);applyHairDamping(parseFloat(hdBar.value))});hdVal.addEventListener('blur',()=>{const v=parseFloat(hdVal.value);if(!isNaN(v)){hdBar.value=v;applyHairDamping(v)}});hdVal.addEventListener('keydown',e=>{if(e.key==='Enter')hdVal.blur()})}
10
  if(hcBar){hcBar.addEventListener('input',()=>{hcVal.value=parseInt(hcBar.value);applyHairCollision(parseInt(hcBar.value))});hcVal.addEventListener('blur',()=>{const v=parseInt(hcVal.value);if(!isNaN(v)){hcBar.value=v;applyHairCollision(v)}});hcVal.addEventListener('keydown',e=>{if(e.key==='Enter')hcVal.blur()})}
11
+ // ★v89d: constraint dump - Object.keysで正しいプロパティ名を特定
12
  let dumped={};
13
+ setInterval(()=>{[{k:'mesh1',m:window.mesh},{k:'mesh2',m:window.mesh2}].forEach(({k,m})=>{if(!m||dumped[k])return;const geo=m.geometry;if(!geo||!geo.userData||!geo.userData.MMD)return;const mmd=geo.userData.MMD;dumped[k]=true;
14
+ // まずMMDオブジェクトのキー一覧
15
+ window.__dbg('[CstDump] MMD keys: '+Object.keys(mmd).join(', '),'info');
16
+ // constraintsを探す
17
+ const cs=mmd.constraints||mmd.joints||mmd.constraint;
18
+ if(!cs||!cs.length){window.__dbg('[CstDump] '+k+': constraints not found','error');return}
19
+ window.__dbg('[CstDump] '+k+': '+cs.length+'制約 keys='+Object.keys(cs[0]).join(','),'info');
20
+ // 先頭5個の全プロパティをダンプ
21
+ cs.slice(0,5).forEach((c,i)=>{window.__dbg(' [C'+i+'] '+JSON.stringify(c).slice(0,200))})})},2000);
22
+ window.__dbg('[Init] app-extra.js v89d 初期化完了','info')})})();