* Parse a single FBX property * 解析单个 FBX 属性
()
| 509 | * 解析单个 FBX 属性 |
| 510 | */ |
| 511 | private parseProperty(): FBXProperty { |
| 512 | const type = String.fromCharCode(this.view.getUint8(this.offset)); |
| 513 | this.offset += 1; |
| 514 | |
| 515 | switch (type) { |
| 516 | case 'C': // Bool |
| 517 | const boolVal = this.view.getUint8(this.offset) !== 0; |
| 518 | this.offset += 1; |
| 519 | return boolVal; |
| 520 | |
| 521 | case 'Y': // Int16 |
| 522 | const int16Val = this.view.getInt16(this.offset, true); |
| 523 | this.offset += 2; |
| 524 | return int16Val; |
| 525 | |
| 526 | case 'I': // Int32 |
| 527 | const int32Val = this.view.getInt32(this.offset, true); |
| 528 | this.offset += 4; |
| 529 | return int32Val; |
| 530 | |
| 531 | case 'L': // Int64 |
| 532 | const int64Val = this.view.getBigInt64(this.offset, true); |
| 533 | this.offset += 8; |
| 534 | return int64Val; |
| 535 | |
| 536 | case 'F': // Float |
| 537 | const floatVal = this.view.getFloat32(this.offset, true); |
| 538 | this.offset += 4; |
| 539 | return floatVal; |
| 540 | |
| 541 | case 'D': // Double |
| 542 | const doubleVal = this.view.getFloat64(this.offset, true); |
| 543 | this.offset += 8; |
| 544 | return doubleVal; |
| 545 | |
| 546 | case 'S': // String |
| 547 | case 'R': // Raw binary |
| 548 | const strLen = this.view.getUint32(this.offset, true); |
| 549 | this.offset += 4; |
| 550 | if (type === 'S') { |
| 551 | const strBytes = new Uint8Array(this.buffer, this.offset, strLen); |
| 552 | this.offset += strLen; |
| 553 | // FBX strings may contain null bytes |
| 554 | // FBX 字符串可能包含空字节 |
| 555 | let str = ''; |
| 556 | for (let i = 0; i < strLen; i++) { |
| 557 | if (strBytes[i] === 0) break; |
| 558 | str += String.fromCharCode(strBytes[i]); |
| 559 | } |
| 560 | return str; |
| 561 | } else { |
| 562 | const rawData = new Uint8Array(this.buffer, this.offset, strLen); |
| 563 | this.offset += strLen; |
| 564 | return rawData; |
| 565 | } |
| 566 | |
| 567 | case 'b': // Bool array |
| 568 | case 'c': // Bool array (alias) |
no test coverage detected