mirror of
https://github.com/lighttransport/tinyusdz.git
synced 2026-01-18 01:11:17 +01:00
Added comprehensive test models and scripts for skeletal animation features: Skeletal Animation Test Models (models/): - skelanim-empty.usda: Edge case with no animation data - skelanim-mixed.usda: Mixed static and time-sampled (incomplete skeleton binding) - skelanim-rotation-only.usda: Only rotation channels animated - skelanim-single-joint.usda: Single joint animation - skelanim-static.usda: Static values only (incomplete skeleton binding) - skelanim-timesampled.usda: Time-sampled values (incomplete skeleton binding) Synthetic Skin Test Models (models/): - synthetic-skin-8influences.usda: 8 influences per vertex test - synthetic-skin-16influences.usda: 16 influences per vertex test - synthetic-skin-32influences.usda: 32 influences per vertex test Test Scripts (web/js/): - test-anim-debug.js: Animation debugging utility - test-16influences.js: Test 16 influences per vertex - test-all-bone-reduction.js: Bone reduction testing - test-boundaries.js: Boundary condition tests - test-digit-limits.js: Digit parsing limits - test-malicious.js: Malicious input handling - test-number-parsing.js: Number parsing validation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
64 lines
2.3 KiB
JavaScript
64 lines
2.3 KiB
JavaScript
import { TinyUSDZLoader } from './src/tinyusdz/TinyUSDZLoader.js';
|
|
import fs from 'node:fs';
|
|
|
|
async function main() {
|
|
const loader = new TinyUSDZLoader();
|
|
await loader.init();
|
|
|
|
const filePath = '../../models/synthetic-skin-16influences.usda';
|
|
|
|
try {
|
|
const data = fs.readFileSync(filePath);
|
|
|
|
console.log(`Loading ${filePath} (${data.length} bytes)`);
|
|
|
|
// Enable bone reduction in loader
|
|
loader.setEnableBoneReduction(true);
|
|
loader.setTargetBoneCount(4);
|
|
|
|
// Load USD with bone reduction config
|
|
await new Promise((resolve, reject) => {
|
|
loader.parse(
|
|
data,
|
|
'synthetic-skin-16influences.usda',
|
|
(usd) => {
|
|
console.log('\n=== USD loaded successfully ===');
|
|
|
|
// Get mesh info
|
|
const renderScene = usd.getRenderScene();
|
|
console.log('\nScene has', renderScene.meshes.length, 'meshes');
|
|
resolve(usd);
|
|
},
|
|
(error) => {
|
|
console.error('Failed to load USD:', error);
|
|
reject(error);
|
|
},
|
|
{
|
|
maxMemoryLimitMB: 2048
|
|
}
|
|
);
|
|
}).then((usd) => {
|
|
const renderScene = usd.getRenderScene();
|
|
const meshes = renderScene.meshes;
|
|
console.log('\nMeshes found:', meshes.length);
|
|
|
|
for (const mesh of meshes) {
|
|
console.log('\nMesh path:', mesh.abs_path);
|
|
if (mesh.joint_and_weights) {
|
|
console.log(' Joint and weights elementSize:', mesh.joint_and_weights.elementSize);
|
|
console.log(' Weights per vertex:', mesh.joint_and_weights.elementSize);
|
|
console.log(' Total joint indices:', mesh.joint_and_weights.jointIndices?.length);
|
|
console.log(' Total joint weights:', mesh.joint_and_weights.jointWeights?.length);
|
|
|
|
const numVertices = mesh.joint_and_weights.jointIndices.length / mesh.joint_and_weights.elementSize;
|
|
console.log(' Number of vertices:', numVertices);
|
|
}
|
|
}
|
|
});
|
|
|
|
} catch (error) {
|
|
console.error('Error:', error);
|
|
}
|
|
}
|
|
|
|
main(); |