@@ -68,9 +68,9 @@ export class GLTFBuilder {
6868 const defaultMaterialIndex = this . addMaterial ( {
6969 name : "Default" ,
7070 pbrMetallicRoughness : {
71- baseColorFactor : [ 0.5 , 0.5 , 0.5 , 0.5 ] ,
72- metallicFactor : 0.1 ,
73- roughnessFactor : 0.8 ,
71+ baseColorFactor : [ 0.35 , 0.35 , 0.35 , 0.5 ] ,
72+ metallicFactor : 0.05 ,
73+ roughnessFactor : 0.95 ,
7474 } ,
7575 alphaMode : "BLEND" ,
7676 } )
@@ -140,27 +140,28 @@ export class GLTFBuilder {
140140 const dissolve = objMaterial . dissolve ?? 1.0
141141 const alpha = 1.0 - dissolve
142142
143- let baseColor : [ number , number , number , number ] = [ 0.5 , 0.5 , 0.5 , alpha ]
143+ let baseColor : [ number , number , number , number ] = [ 0.3 , 0.3 , 0.3 , alpha ]
144144
145145 if ( objMaterial . color ) {
146146 const color = typeof objMaterial . color === "string"
147147 ? this . parseColorString ( objMaterial . color )
148148 : [ objMaterial . color [ 0 ] / 255 , objMaterial . color [ 1 ] / 255 , objMaterial . color [ 2 ] / 255 , alpha ]
149- baseColor = color
150- baseColor [ 3 ] = alpha
149+ baseColor = [ color [ 0 ] ! , color [ 1 ] ! , color [ 2 ] ! , alpha ]
151150 }
152151
153152 const gltfMaterialIndex = this . addMaterial ( {
154153 name : `OBJ_${ name } ` ,
155154 pbrMetallicRoughness : {
156155 baseColorFactor : baseColor ,
157- metallicFactor : 0.1 ,
158- roughnessFactor : 0.8 ,
156+ metallicFactor : 0.05 ,
157+ roughnessFactor : 0.95 ,
159158 } ,
160159 alphaMode : alpha < 1.0 ? "BLEND" : "OPAQUE" ,
161160 } )
162161
163- objMaterialIndices . set ( parseInt ( name ) , gltfMaterialIndex )
162+ // Get the correct material index from the OBJ parsing
163+ const materialIndex = objMesh . materialIndexMap ?. get ( name ) ?? - 1
164+ objMaterialIndices . set ( materialIndex , gltfMaterialIndex )
164165 }
165166
166167 // Create primitives for each material group
@@ -517,8 +518,8 @@ export class GLTFBuilder {
517518 name : `Material_${ this . materials . length } ` ,
518519 pbrMetallicRoughness : {
519520 baseColorFactor : baseColor ,
520- metallicFactor : 0.1 ,
521- roughnessFactor : 0.8 ,
521+ metallicFactor : 0.05 ,
522+ roughnessFactor : 0.95 ,
522523 } ,
523524 alphaMode : makeTransparent ? "BLEND" : "OPAQUE" ,
524525 } )
0 commit comments