Răsfoiți Sursa

GLTFLoader: only refresh uniforms on correct material

Simple case: 
1. Load GLTF File with Specular-Glosiness-Material so the ```refreshUnfiorms``` function is being set ```mesh.onBeforeRender = extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ].refreshUniforms;``` 
2. Use an override material for the scene to render, for example use the SAOPass.
3. Get error because u try to work with uniforms of a material which doesn't have any

Suggestion:
Simple check if the material has the property ```isGLTFSpecularGlossinessMaterial``` and it is true. Because the ```refreshUniforms``` function is only set if it is true.
Pascal Häusler 7 ani în urmă
părinte
comite
5e4c762401
1 a modificat fișierele cu 6 adăugiri și 0 ștergeri
  1. 6 0
      examples/js/loaders/GLTFLoader.js

+ 6 - 0
examples/js/loaders/GLTFLoader.js

@@ -714,6 +714,12 @@ THREE.GLTFLoader = ( function () {
 			// Here's based on refreshUniformsCommon() and refreshUniformsStandard() in WebGLRenderer.
 			refreshUniforms: function ( renderer, scene, camera, geometry, material, group ) {
 
+				if ( !material.isGLTFSpecularGlossinessMaterial) {
+
+					return;
+
+				}
+
 				var uniforms = material.uniforms;
 				var defines = material.defines;