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

Method parseBinary

packages/asset-system/src/loaders/FBXLoader.ts:342–430  ·  view source on GitHub ↗

* Parse binary FBX format * 解析二进制 FBX 格式

(buffer: ArrayBuffer)

Source from the content-addressed store, hash-verified

340 * 解析二进制 FBX 格式
341 */
342 private parseBinary(buffer: ArrayBuffer): {
343 geometries: FBXGeometry[];
344 models: FBXModel[];
345 materials: FBXMaterial[];
346 animStacks: FBXAnimationStack[];
347 deformers: FBXDeformer[];
348 connections: FBXConnection[];
349 } {
350 this.buffer = buffer;
351 this.view = new DataView(buffer);
352 this.offset = 0;
353
354 // Read header
355 // 读取头部
356 this.offset = 21; // Skip magic
357 this.offset += 2; // Skip unknown bytes
358 this.version = this.view.getUint32(this.offset, true);
359 this.offset = FBX_HEADER_SIZE;
360
361 // Parse root nodes
362 // 解析根节点
363 const nodes: FBXNode[] = [];
364 while (this.offset < buffer.byteLength) {
365 const node = this.parseNode();
366 if (!node) break;
367 nodes.push(node);
368 }
369
370 // Extract geometry and model data
371 // 提取几何和模型数据
372 const geometries: FBXGeometry[] = [];
373 const models: FBXModel[] = [];
374 const materials: FBXMaterial[] = [];
375
376 // Animation data
377 // 动画数据
378 const animStacks: FBXAnimationStack[] = [];
379 const animLayers: FBXAnimationLayer[] = [];
380 const animCurveNodes: FBXAnimationCurveNode[] = [];
381 const animCurves: FBXAnimationCurve[] = [];
382 const deformers: FBXDeformer[] = [];
383
384 // Find Objects node
385 // 查找 Objects 节点
386 const objectsNode = nodes.find(n => n.name === 'Objects');
387 if (objectsNode) {
388 for (const child of objectsNode.children) {
389 if (child.name === 'Geometry') {
390 const geom = this.extractGeometry(child);
391 if (geom) {
392 geometries.push(geom);
393 }
394 } else if (child.name === 'Model') {
395 const model = this.extractModel(child);
396 if (model) models.push(model);
397 } else if (child.name === 'Material') {
398 const mat = this.extractMaterial(child);
399 if (mat) materials.push(mat);

Callers 1

parseMethod · 0.95

Calls 14

parseNodeMethod · 0.95
extractGeometryMethod · 0.95
extractModelMethod · 0.95
extractMaterialMethod · 0.95
extractAnimationStackMethod · 0.95
extractAnimationLayerMethod · 0.95
extractAnimationCurveMethod · 0.95
extractDeformerMethod · 0.95
parseConnectionsMethod · 0.95
getUint32Method · 0.80

Tested by

no test coverage detected