* Extract material from FBX Material node * 从 FBX Material 节点提取材质
(node: FBXNode)
| 873 | * 从 FBX Material 节点提取材质 |
| 874 | */ |
| 875 | private extractMaterial(node: FBXNode): FBXMaterial | null { |
| 876 | const id = node.properties[0] as bigint; |
| 877 | const nameProp = node.properties[1]; |
| 878 | let name = 'Material'; |
| 879 | if (typeof nameProp === 'string') { |
| 880 | name = nameProp.split('\x00')[0] || name; |
| 881 | } |
| 882 | |
| 883 | // Default values |
| 884 | // 默认值 |
| 885 | let diffuseColor: [number, number, number] = [0.8, 0.8, 0.8]; |
| 886 | let opacity = 1; |
| 887 | |
| 888 | // Find Properties70 node for material properties |
| 889 | // 查找 Properties70 节点获取材质属性 |
| 890 | const props70 = node.children.find(c => c.name === 'Properties70'); |
| 891 | if (props70) { |
| 892 | for (const prop of props70.children) { |
| 893 | if (prop.name === 'P' && prop.properties.length >= 5) { |
| 894 | const propName = prop.properties[0] as string; |
| 895 | if (propName === 'DiffuseColor') { |
| 896 | diffuseColor = [ |
| 897 | Number(prop.properties[4]) || 0.8, |
| 898 | Number(prop.properties[5]) || 0.8, |
| 899 | Number(prop.properties[6]) || 0.8 |
| 900 | ]; |
| 901 | } else if (propName === 'Opacity') { |
| 902 | opacity = Number(prop.properties[4]) || 1; |
| 903 | } |
| 904 | } |
| 905 | } |
| 906 | } |
| 907 | |
| 908 | return { id, name, diffuseColor, opacity }; |
| 909 | } |
| 910 | |
| 911 | // ===== Animation Extraction Methods ===== |
| 912 |