Spaces:
Running
Running
v89d: dump constraint keys to find correct property names
Browse files- app-extra.js +13 -5
app-extra.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
| 1 |
-
// app-extra.js
|
| 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;
|
| 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 |
-
// ★
|
| 12 |
let dumped={};
|
| 13 |
-
setInterval(()=>{[{k:'mesh1',m:window.mesh},{k:'mesh2',m:window.mesh2}].forEach(({k,m})=>{if(!m||dumped[k])return;const
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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')})})();
|