()
| 204 | } |
| 205 | |
| 206 | async function main() { |
| 207 | const { FBXLoader } = await import('../packages/asset-system/dist/index.js'); |
| 208 | |
| 209 | const binaryData = readFileSync(filePath); |
| 210 | const loader = new FBXLoader(); |
| 211 | |
| 212 | const context = { |
| 213 | metadata: { |
| 214 | path: filePath, |
| 215 | name: filePath.split(/[\\/]/).pop(), |
| 216 | type: 'model/fbx', |
| 217 | guid: '', |
| 218 | size: binaryData.length, |
| 219 | hash: '', |
| 220 | dependencies: [], |
| 221 | lastModified: Date.now(), |
| 222 | importerVersion: '1.0.0', |
| 223 | labels: [], |
| 224 | tags: [], |
| 225 | version: 1 |
| 226 | }, |
| 227 | loadDependency: async () => null |
| 228 | }; |
| 229 | |
| 230 | const content = { |
| 231 | type: 'binary', |
| 232 | binary: binaryData.buffer |
| 233 | }; |
| 234 | |
| 235 | const asset = await loader.parse(content, context); |
| 236 | |
| 237 | if (!asset.skeleton || !asset.animations?.length) { |
| 238 | console.log('No skeleton or animation data!'); |
| 239 | return; |
| 240 | } |
| 241 | |
| 242 | const clip = asset.animations[0]; |
| 243 | const nodes = asset.nodes; |
| 244 | const skeleton = asset.skeleton; |
| 245 | |
| 246 | console.log(`Animation: "${clip.name}", duration: ${clip.duration}s`); |
| 247 | console.log(`Joints: ${skeleton.joints.length}`); |
| 248 | |
| 249 | // Test at different times |
| 250 | const times = [0, clip.duration * 0.25, clip.duration * 0.5, clip.duration * 0.75, clip.duration]; |
| 251 | |
| 252 | let prevMatrices = null; |
| 253 | for (const time of times) { |
| 254 | const animTransforms = sampleAnimation(clip, time, nodes); |
| 255 | const skinMatrices = calculateBoneMatrices(skeleton, nodes, animTransforms); |
| 256 | |
| 257 | if (prevMatrices) { |
| 258 | // Count how many bones changed |
| 259 | let changedCount = 0; |
| 260 | let maxChange = 0; |
| 261 | for (let i = 0; i < skinMatrices.length; i++) { |
| 262 | const diff = matrixDifference(skinMatrices[i], prevMatrices[i]); |
| 263 | if (diff > 0.001) { |
no test coverage detected