AshenDepths / rigtest.html
Quazim0t0's picture
Deploy Ashen Depths: player animated by skeleton_animator.pt
ee5ec19 verified
Raw
History Blame Contribute Delete
1.97 kB
<!DOCTYPE html><html><head><meta charset="utf-8"><title>rig inspect</title>
<style>html,body{margin:0;background:#111;color:#0f0;font:11px monospace}#log{white-space:pre;padding:8px}</style>
<script type="importmap">{"imports":{
"three":"https://unpkg.com/three@0.160.0/build/three.module.js",
"three/addons/":"https://unpkg.com/three@0.160.0/examples/jsm/",
"fflate":"https://unpkg.com/fflate@0.8.2/esm/browser.js"
}}</script></head>
<body><div id="log">loading…</div>
<script type="module">
import * as THREE from 'three';
import {FBXLoader} from 'three/addons/loaders/FBXLoader.js';
const out={};
const L=(m)=>{document.getElementById('log').textContent+='\n'+m;};
const loader=new FBXLoader();
function inspect(path,label){return new Promise(res=>{
loader.load(path,obj=>{
const info={label,meshes:[],bones:[],anims:[],skinned:0};
const box=new THREE.Box3().setFromObject(obj);const sz=new THREE.Vector3();box.getSize(sz);
info.size=[+sz.x.toFixed(1),+sz.y.toFixed(1),+sz.z.toFixed(1)];
info.min=[+box.min.x.toFixed(1),+box.min.y.toFixed(1),+box.min.z.toFixed(1)];
obj.traverse(c=>{
if(c.isSkinnedMesh){info.skinned++;info.meshes.push({name:c.name,verts:c.geometry.attributes.position.count,bones:c.skeleton.bones.length,mats:Array.isArray(c.material)?c.material.length:1});}
else if(c.isMesh){info.meshes.push({name:c.name,verts:c.geometry.attributes.position.count,static:true,mats:Array.isArray(c.material)?c.material.length:1});}
if(c.isBone)info.bones.push(c.name);
});
info.anims=(obj.animations||[]).map(a=>({name:a.name,dur:+a.duration.toFixed(2),tracks:a.tracks.length}));
out[label]=info;
L(label+': '+JSON.stringify(info,null,1));
res();
},undefined,e=>{L(label+' ERROR '+(e.message||e));res();});
});}
(async()=>{
await inspect('assets/chars/player.fbx','PLAYER');
await inspect('assets/chars/malenia.fbx','BOSS');
window.__rig=()=>out;
L('=== DONE ===');
})();
</script></body></html>