MCPcopy Create free account
hub / github.com/esengine/esengine / main

Function main

scripts/test-fbxloader-bindpose.mjs:64–197  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

62}
63
64async 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

Callers 1

Calls 12

parseMethod · 0.95
maxDiffFromIdentityFunction · 0.85
popMethod · 0.80
nowMethod · 0.80
addJointFunction · 0.70
identityFunction · 0.70
createTransformMatrixFunction · 0.70
multiplyMatricesFunction · 0.70
isIdentityFunction · 0.70
setMethod · 0.65
pushMethod · 0.65
logMethod · 0.45

Tested by

no test coverage detected