Skip to content

Commit a889569

Browse files
makcmrdoob
authored andcommitted
support texture coordinates in ply parser (mrdoob#9121)
1 parent e6bf5b9 commit a889569

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

examples/js/loaders/PLYLoader.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,20 +346,41 @@ THREE.PLYLoader.prototype = {
346346
} else if ( elementName === "face" ) {
347347

348348
var vertex_indices = element.vertex_indices;
349+
var texcoord = element.texcoord;
349350

350351
if ( vertex_indices.length === 3 ) {
351352

352353
geometry.faces.push(
353354
new THREE.Face3( vertex_indices[ 0 ], vertex_indices[ 1 ], vertex_indices[ 2 ] )
354355
);
355356

357+
if ( texcoord ) {
358+
geometry.faceVertexUvs[ 0 ].push( [
359+
new THREE.Vector2( texcoord[ 0 ], texcoord[ 1 ]),
360+
new THREE.Vector2( texcoord[ 2 ], texcoord[ 3 ]),
361+
new THREE.Vector2( texcoord[ 4 ], texcoord[ 5 ])
362+
] );
363+
}
364+
356365
} else if ( vertex_indices.length === 4 ) {
357366

358367
geometry.faces.push(
359368
new THREE.Face3( vertex_indices[ 0 ], vertex_indices[ 1 ], vertex_indices[ 3 ] ),
360369
new THREE.Face3( vertex_indices[ 1 ], vertex_indices[ 2 ], vertex_indices[ 3 ] )
361370
);
362371

372+
if ( texcoord ) {
373+
geometry.faceVertexUvs[ 0 ].push( [
374+
new THREE.Vector2( texcoord[ 0 ], texcoord[ 1 ]),
375+
new THREE.Vector2( texcoord[ 2 ], texcoord[ 3 ]),
376+
new THREE.Vector2( texcoord[ 6 ], texcoord[ 7 ])
377+
], [
378+
new THREE.Vector2( texcoord[ 2 ], texcoord[ 3 ]),
379+
new THREE.Vector2( texcoord[ 4 ], texcoord[ 5 ]),
380+
new THREE.Vector2( texcoord[ 6 ], texcoord[ 7 ])
381+
] );
382+
}
383+
363384
}
364385

365386
}

0 commit comments

Comments
 (0)