@@ -556,7 +556,6 @@ function loading(p5, fn){
556
556
// Map from source index → Map of material → destination index
557
557
const usedVerts = { } ; // Track colored vertices
558
558
let currentMaterial = null ;
559
- const coloredVerts = new Set ( ) ; //unique vertices with color
560
559
let hasColoredVertices = false ;
561
560
let hasColorlessVertices = false ;
562
561
for ( let line = 0 ; line < lines . length ; ++ line ) {
@@ -622,8 +621,15 @@ function loading(p5, fn){
622
621
if ( currentMaterial
623
622
&& materials [ currentMaterial ]
624
623
&& materials [ currentMaterial ] . diffuseColor ) {
625
- // Mark this vertex as colored
626
- coloredVerts . add ( loadedVerts . v [ vertParts [ 0 ] ] ) ; //since a set would only push unique values
624
+ hasColoredVertices = true ;
625
+ const materialDiffuseColor =
626
+ materials [ currentMaterial ] . diffuseColor ;
627
+ model . vertexColors . push ( materialDiffuseColor [ 0 ] ) ;
628
+ model . vertexColors . push ( materialDiffuseColor [ 1 ] ) ;
629
+ model . vertexColors . push ( materialDiffuseColor [ 2 ] ) ;
630
+ model . vertexColors . push ( 1 ) ;
631
+ } else {
632
+ hasColorlessVertices = true ;
627
633
}
628
634
} else {
629
635
face . push ( usedVerts [ vertString ] [ currentMaterial ] ) ;
@@ -636,24 +642,6 @@ function loading(p5, fn){
636
642
face [ 1 ] !== face [ 2 ]
637
643
) {
638
644
model . faces . push ( face ) ;
639
- //same material for all vertices in a particular face
640
- if ( currentMaterial
641
- && materials [ currentMaterial ]
642
- && materials [ currentMaterial ] . diffuseColor ) {
643
- hasColoredVertices = true ;
644
- //flag to track color or no color model
645
- hasColoredVertices = true ;
646
- const materialDiffuseColor =
647
- materials [ currentMaterial ] . diffuseColor ;
648
- for ( let i = 0 ; i < face . length ; i ++ ) {
649
- model . vertexColors . push ( materialDiffuseColor [ 0 ] ) ;
650
- model . vertexColors . push ( materialDiffuseColor [ 1 ] ) ;
651
- model . vertexColors . push ( materialDiffuseColor [ 2 ] ) ;
652
- model . vertexColors . push ( 1 ) ;
653
- }
654
- } else {
655
- hasColorlessVertices = true ;
656
- }
657
645
}
658
646
}
659
647
}
0 commit comments