@@ -918,7 +918,6 @@ export class Viewer implements IDisposable {
918918 defaultMaterial . metallic = 0 ;
919919 defaultMaterial . roughness = 1 ;
920920 defaultMaterial . baseDiffuseRoughness = 1 ;
921- defaultMaterial . environmentIntensity = 0.7 ;
922921 defaultMaterial . microSurface = 0 ;
923922 scene . defaultMaterial = defaultMaterial ;
924923
@@ -1695,8 +1694,11 @@ export class Viewer implements IDisposable {
16951694 }
16961695 } ) ;
16971696
1698- // If there are PBR materials after the model load operation and an environment texture is not loaded, load the default environment.
1699- if ( ! this . _scene . environmentTexture && this . _loadedModels . some ( ( model ) => model . assetContainer . materials . some ( ( material ) => material instanceof PBRMaterial ) ) ) {
1697+ const hasPBRMaterials = this . _loadedModels . some ( ( model ) => model . assetContainer . materials . some ( ( material ) => material instanceof PBRMaterial ) ) ;
1698+ const usesDefaultMaterial = this . _loadedModels . some ( ( model ) => model . assetContainer . meshes . some ( ( mesh ) => ! mesh . material ) ) ;
1699+ // If PBR is used (either explicitly, or implicitly by a mesh not having a material and therefore using the default PBRMaterial)
1700+ // and an environment texture is not already loaded, then load the default environment.
1701+ if ( ! this . _scene . environmentTexture && ( hasPBRMaterials || usesDefaultMaterial ) ) {
17001702 await this . resetEnvironment ( { lighting : true } , abortSignal ) ;
17011703 }
17021704
@@ -2875,13 +2877,12 @@ export class Viewer implements IDisposable {
28752877 } else {
28762878 const hasModelProvidedLights = this . _loadedModels . some ( ( model ) => model . assetContainer . lights . length > 0 ) ;
28772879 const hasImageBasedLighting = ! ! this . _reflectionTexture ;
2878- const hasMaterials = this . _loadedModels . some ( ( model ) => model . assetContainer . materials . length > 0 ) ;
28792880 const hasNonPBRMaterials = this . _loadedModels . some ( ( model ) => model . assetContainer . materials . some ( ( material ) => ! ( material instanceof PBRMaterial ) ) ) ;
28802881
28812882 if ( hasModelProvidedLights ) {
28822883 shouldHaveDefaultLight = false ;
28832884 } else {
2884- shouldHaveDefaultLight = ! hasImageBasedLighting || ! hasMaterials || hasNonPBRMaterials ;
2885+ shouldHaveDefaultLight = ! hasImageBasedLighting || hasNonPBRMaterials ;
28852886 }
28862887 }
28872888
0 commit comments