* Parse a single FBX node (binary format) * 解析单个 FBX 节点(二进制格式)
()
| 434 | * 解析单个 FBX 节点(二进制格式) |
| 435 | */ |
| 436 | private parseNode(): FBXNode | null { |
| 437 | if (this.offset >= this.buffer.byteLength) return null; |
| 438 | |
| 439 | const is64Bit = this.version >= 7500; |
| 440 | |
| 441 | // Read node record |
| 442 | // 读取节点记录 |
| 443 | let endOffset: number; |
| 444 | let numProperties: number; |
| 445 | |
| 446 | if (is64Bit) { |
| 447 | endOffset = Number(this.view.getBigUint64(this.offset, true)); |
| 448 | numProperties = Number(this.view.getBigUint64(this.offset + 8, true)); |
| 449 | // propertyListLen not used, skip reading it |
| 450 | this.offset += 24; |
| 451 | } else { |
| 452 | endOffset = this.view.getUint32(this.offset, true); |
| 453 | numProperties = this.view.getUint32(this.offset + 4, true); |
| 454 | // propertyListLen not used, skip reading it |
| 455 | this.offset += 12; |
| 456 | } |
| 457 | |
| 458 | // Check for null node (end marker) |
| 459 | // 检查空节点(结束标记) |
| 460 | if (endOffset === 0) { |
| 461 | return null; |
| 462 | } |
| 463 | |
| 464 | // Read name |
| 465 | // 读取名称 |
| 466 | const nameLen = this.view.getUint8(this.offset); |
| 467 | this.offset += 1; |
| 468 | const nameBytes = new Uint8Array(this.buffer, this.offset, nameLen); |
| 469 | const name = String.fromCharCode(...nameBytes); |
| 470 | this.offset += nameLen; |
| 471 | |
| 472 | // Read properties |
| 473 | // 读取属性 |
| 474 | const properties: FBXProperty[] = []; |
| 475 | for (let i = 0; i < numProperties; i++) { |
| 476 | const prop = this.parseProperty(); |
| 477 | properties.push(prop); |
| 478 | } |
| 479 | |
| 480 | // Read child nodes |
| 481 | // 读取子节点 |
| 482 | const children: FBXNode[] = []; |
| 483 | while (this.offset < endOffset) { |
| 484 | // Check for null terminator |
| 485 | // 检查空终止符 |
| 486 | const nullCheck = is64Bit ? 13 : 13; |
| 487 | if (this.offset + nullCheck <= endOffset) { |
| 488 | const testOffset = is64Bit |
| 489 | ? Number(this.view.getBigUint64(this.offset, true)) |
| 490 | : this.view.getUint32(this.offset, true); |
| 491 | if (testOffset === 0) { |
| 492 | this.offset = endOffset; |
| 493 | break; |
no test coverage detected