* Extract model from FBX Model node * 从 FBX Model 节点提取模型
(node: FBXNode)
| 808 | * 从 FBX Model 节点提取模型 |
| 809 | */ |
| 810 | private extractModel(node: FBXNode): FBXModel | null { |
| 811 | const id = node.properties[0] as bigint; |
| 812 | const nameProp = node.properties[1]; |
| 813 | let name = 'Model'; |
| 814 | if (typeof nameProp === 'string') { |
| 815 | name = nameProp.split('\x00')[0] || name; |
| 816 | } |
| 817 | |
| 818 | // Extract transform from Properties70 | 从 Properties70 提取变换 |
| 819 | let position: [number, number, number] = [0, 0, 0]; |
| 820 | let rotation: [number, number, number] = [0, 0, 0]; |
| 821 | let scale: [number, number, number] = [1, 1, 1]; |
| 822 | let preRotation: [number, number, number] | undefined; |
| 823 | |
| 824 | const props70 = node.children.find(c => c.name === 'Properties70'); |
| 825 | if (props70) { |
| 826 | for (const prop of props70.children) { |
| 827 | if (prop.name === 'P' && prop.properties.length >= 5) { |
| 828 | const propName = prop.properties[0] as string; |
| 829 | if (propName === 'Lcl Translation') { |
| 830 | position = [ |
| 831 | Number(prop.properties[4]) || 0, |
| 832 | Number(prop.properties[5]) || 0, |
| 833 | Number(prop.properties[6]) || 0 |
| 834 | ]; |
| 835 | } else if (propName === 'Lcl Rotation') { |
| 836 | rotation = [ |
| 837 | Number(prop.properties[4]) || 0, |
| 838 | Number(prop.properties[5]) || 0, |
| 839 | Number(prop.properties[6]) || 0 |
| 840 | ]; |
| 841 | } else if (propName === 'Lcl Scaling') { |
| 842 | scale = [ |
| 843 | Number(prop.properties[4]) || 1, |
| 844 | Number(prop.properties[5]) || 1, |
| 845 | Number(prop.properties[6]) || 1 |
| 846 | ]; |
| 847 | } else if (propName === 'PreRotation') { |
| 848 | // PreRotation is applied before Lcl Rotation |
| 849 | // PreRotation 在 Lcl Rotation 之前应用 |
| 850 | preRotation = [ |
| 851 | Number(prop.properties[4]) || 0, |
| 852 | Number(prop.properties[5]) || 0, |
| 853 | Number(prop.properties[6]) || 0 |
| 854 | ]; |
| 855 | } |
| 856 | } |
| 857 | } |
| 858 | } |
| 859 | |
| 860 | return { |
| 861 | id, |
| 862 | name, |
| 863 | materialIds: [], |
| 864 | position, |
| 865 | rotation, |
| 866 | scale, |
| 867 | preRotation |