Line data Source code
1 : import * as THREE from 'three'
2 :
3 : import { parseASCIIPLY } from './ply'
4 :
5 : /**
6 : * Fast ASCII PLY Loader
7 : * Optimized for simple ASCII PLY files with position and color data
8 : * 4-5x faster than Three.js PLYLoader for ASCII files
9 : */
10 24 : export class FastPLYLoader {
11 : parse(arrayBuffer: ArrayBuffer): THREE.BufferGeometry {
12 0 : const plyData = parseASCIIPLY(arrayBuffer)
13 :
14 0 : if (!plyData) {
15 0 : throw new Error('Failed to parse PLY data')
16 : }
17 :
18 0 : const geometry = new THREE.BufferGeometry()
19 0 : geometry.setAttribute(
20 : 'position',
21 : new THREE.BufferAttribute(plyData.positions, 3)
22 : )
23 :
24 0 : if (plyData.colors) {
25 0 : geometry.setAttribute(
26 : 'color',
27 : new THREE.BufferAttribute(plyData.colors, 3)
28 : )
29 : }
30 :
31 0 : return geometry
32 : }
33 : }
|