Selaa lähdekoodia

Editor: Fixed pathtracer render when environment is null.

Mr.doob 1 vuosi sitten
vanhempi
commit
1e771e13cb
1 muutettua tiedostoa jossa 17 lisäystä ja 1 poistoa
  1. 17 1
      editor/js/Viewport.Pathtracer.js

+ 17 - 1
editor/js/Viewport.Pathtracer.js

@@ -6,6 +6,16 @@ import {
 	PhysicalPathTracingMaterial
 	PhysicalPathTracingMaterial
 } from 'three-gpu-pathtracer';
 } from 'three-gpu-pathtracer';
 
 
+function buildColorTexture( color ) {
+
+	const data = new Uint8Array( [ color.r * 255, color.g * 255, color.b * 255, 255 ] );
+	const texture = new THREE.DataTexture( data, 1, 1, THREE.RGBAFormat );
+	texture.needsUpdate = true;
+
+	return texture;
+
+}
+
 function ViewportPathtracer( renderer ) {
 function ViewportPathtracer( renderer ) {
 
 
 	let pathtracer = null;
 	let pathtracer = null;
@@ -50,10 +60,16 @@ function ViewportPathtracer( renderer ) {
 		ptMaterial.materials.updateFrom( materials, textures );
 		ptMaterial.materials.updateFrom( materials, textures );
 		ptMaterial.lights.updateFrom( lights );
 		ptMaterial.lights.updateFrom( lights );
 
 
-		if ( scene.environment && scene.environment.isTexture === true ) {
+		const environment = scene.environment;
+
+		if ( environment && environment.isTexture === true ) {
 
 
 			ptMaterial.envMapInfo.updateFrom( scene.environment );
 			ptMaterial.envMapInfo.updateFrom( scene.environment );
 
 
+		} else {
+
+			ptMaterial.envMapInfo.updateFrom( buildColorTexture( new THREE.Color( 0xffffff ) ) );
+
 		}
 		}
 
 
 	}
 	}