()
| 62 | } |
| 63 | |
| 64 | async function main() { |
| 65 | const { FBXLoader } = await import('../packages/asset-system/dist/index.js'); |
| 66 | |
| 67 | const binaryData = readFileSync(filePath); |
| 68 | const loader = new FBXLoader(); |
| 69 | |
| 70 | const context = { |
| 71 | metadata: { |
| 72 | path: filePath, |
| 73 | name: filePath.split(/[\\/]/).pop(), |
| 74 | type: 'model/fbx', |
| 75 | guid: '', |
| 76 | size: binaryData.length, |
| 77 | hash: '', |
| 78 | dependencies: [], |
| 79 | lastModified: Date.now(), |
| 80 | importerVersion: '1.0.0', |
| 81 | labels: [], |
| 82 | tags: [], |
| 83 | version: 1 |
| 84 | }, |
| 85 | loadDependency: async () => null |
| 86 | }; |
| 87 | |
| 88 | const content = { |
| 89 | type: 'binary', |
| 90 | binary: binaryData.buffer |
| 91 | }; |
| 92 | |
| 93 | const asset = await loader.parse(content, context); |
| 94 | |
| 95 | if (!asset.skeleton) { |
| 96 | console.log('No skeleton data!'); |
| 97 | return; |
| 98 | } |
| 99 | |
| 100 | const { joints, rootJointIndex } = asset.skeleton; |
| 101 | const nodes = asset.nodes; |
| 102 | |
| 103 | console.log(`Skeleton: ${joints.length} joints, rootJointIndex=${rootJointIndex}`); |
| 104 | |
| 105 | // Build parent index map (node hierarchy) |
| 106 | const nodeParentMap = new Map(); |
| 107 | for (const node of nodes) { |
| 108 | if (node.children) { |
| 109 | for (const childIdx of node.children) { |
| 110 | nodeParentMap.set(childIdx, nodes.indexOf(node)); |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | // Calculate world matrices for each joint using node.transform hierarchy |
| 116 | const worldMatrices = new Array(joints.length); |
| 117 | |
| 118 | // Processing order: root first, then children |
| 119 | const processed = new Set(); |
| 120 | const processingOrder = []; |
| 121 |
no test coverage detected