@@ -451,11 +451,6 @@ Object.assign(pc, function () {
451
451
material . name = materialData . name ;
452
452
}
453
453
454
- if ( materialData . hasOwnProperty ( 'extensions' ) &&
455
- materialData . extensions . hasOwnProperty ( 'KHR_materials_unlit' ) ) {
456
- material . useLighting = false ;
457
- }
458
-
459
454
var color , texture ;
460
455
if ( materialData . hasOwnProperty ( 'extensions' ) &&
461
456
materialData . extensions . hasOwnProperty ( 'KHR_materials_pbrSpecularGlossiness' ) ) {
@@ -703,6 +698,30 @@ Object.assign(pc, function () {
703
698
material . cull = pc . CULLFACE_BACK ;
704
699
}
705
700
701
+ // handle unlit material by disabling lighting and copying diffuse colours
702
+ // into emissive.
703
+ if ( materialData . hasOwnProperty ( 'extensions' ) &&
704
+ materialData . extensions . hasOwnProperty ( 'KHR_materials_unlit' ) ) {
705
+ material . useLighting = false ;
706
+
707
+ // copy diffuse into emissive
708
+ material . emissive . copy ( material . diffuse ) ;
709
+ material . emissiveTint = material . diffuseTint ;
710
+ material . emissiveMap = material . diffuseMap ;
711
+ material . emissiveMapUv = material . diffuseMapUv ;
712
+ material . emissiveMapTiling . copy ( material . diffuseMapTiling ) ;
713
+ material . emissiveMapOffset . copy ( material . diffuseMapOffset ) ;
714
+ material . emissiveMapChannel = material . diffuseMapChannel ;
715
+ material . emissiveVertexColor = material . diffuseVertexColor ;
716
+ material . emissiveVertexColorChannel = material . diffuseVertexColorChannel ;
717
+
718
+ // blank diffuse
719
+ material . diffuse . set ( 0 , 0 , 0 ) ;
720
+ material . diffuseTint = false ;
721
+ material . diffuseMap = null ;
722
+ material . diffuseVertexColor = false ;
723
+ }
724
+
706
725
material . update ( ) ;
707
726
708
727
return material ;
0 commit comments