(points3D: Map<Point3DId, Point3D>)
| 5 | * PLY is a common format supported by MeshLab, CloudCompare, and other 3D viewers. |
| 6 | */ |
| 7 | export function writePointsPLY(points3D: Map<Point3DId, Point3D>): string { |
| 8 | const header = [ |
| 9 | 'ply', |
| 10 | 'format ascii 1.0', |
| 11 | `element vertex ${points3D.size}`, |
| 12 | 'property float x', |
| 13 | 'property float y', |
| 14 | 'property float z', |
| 15 | 'property uchar red', |
| 16 | 'property uchar green', |
| 17 | 'property uchar blue', |
| 18 | 'end_header', |
| 19 | ].join('\n') + '\n'; |
| 20 | |
| 21 | const data: string[] = []; |
| 22 | for (const pt of points3D.values()) { |
| 23 | data.push(`${pt.xyz[0]} ${pt.xyz[1]} ${pt.xyz[2]} ${pt.rgb[0]} ${pt.rgb[1]} ${pt.rgb[2]}`); |
| 24 | } |
| 25 | |
| 26 | return header + data.join('\n') + '\n'; |
| 27 | } |
no test coverage detected