Răsfoiți Sursa

PMREMGenerator: Fix compile methods and background usage. (#29297)

* PMREMGenerator: Fix compile methods and background usage.

* PMREMGenerator: Make compile*() methods async.
Michael Herzog 1 an în urmă
părinte
comite
b26848e58d

+ 7 - 9
src/renderers/common/extras/PMREMGenerator.js

@@ -176,12 +176,12 @@ class PMREMGenerator {
 	 * Pre-compiles the cubemap shader. You can get faster start-up by invoking this method during
 	 * Pre-compiles the cubemap shader. You can get faster start-up by invoking this method during
 	 * your texture's network fetch for increased concurrency.
 	 * your texture's network fetch for increased concurrency.
 	 */
 	 */
-	compileCubemapShader() {
+	async compileCubemapShader() {
 
 
 		if ( this._cubemapMaterial === null ) {
 		if ( this._cubemapMaterial === null ) {
 
 
 			this._cubemapMaterial = _getCubemapMaterial();
 			this._cubemapMaterial = _getCubemapMaterial();
-			this._compileMaterial( this._cubemapMaterial );
+			await this._compileMaterial( this._cubemapMaterial );
 
 
 		}
 		}
 
 
@@ -191,12 +191,12 @@ class PMREMGenerator {
 	 * Pre-compiles the equirectangular shader. You can get faster start-up by invoking this method during
 	 * Pre-compiles the equirectangular shader. You can get faster start-up by invoking this method during
 	 * your texture's network fetch for increased concurrency.
 	 * your texture's network fetch for increased concurrency.
 	 */
 	 */
-	compileEquirectangularShader() {
+	async compileEquirectangularShader() {
 
 
 		if ( this._equirectMaterial === null ) {
 		if ( this._equirectMaterial === null ) {
 
 
 			this._equirectMaterial = _getEquirectMaterial();
 			this._equirectMaterial = _getEquirectMaterial();
-			this._compileMaterial( this._equirectMaterial );
+			await this._compileMaterial( this._equirectMaterial );
 
 
 		}
 		}
 
 
@@ -316,12 +316,10 @@ class PMREMGenerator {
 
 
 	}
 	}
 
 
-	_compileMaterial( material ) {
+	async _compileMaterial( material ) {
 
 
-		const tmpMesh = this._lodMeshes[ 0 ];
-		tmpMesh.material = material;
-
-		this._renderer.compile( tmpMesh, _flatCamera );
+		const tmpMesh = new Mesh( this._lodPlanes[ 0 ], material );
+		await this._renderer.compile( tmpMesh, _flatCamera );
 
 
 	}
 	}
 
 

+ 3 - 3
src/renderers/common/nodes/Nodes.js

@@ -5,7 +5,7 @@ import { cubeMapNode } from '../../../nodes/utils/CubeMapNode.js';
 import { NodeFrame } from '../../../nodes/Nodes.js';
 import { NodeFrame } from '../../../nodes/Nodes.js';
 import { objectGroup, renderGroup, frameGroup, cubeTexture, texture, rangeFog, densityFog, reference, normalWorld, pmremTexture, viewportUV } from '../../../nodes/TSL.js';
 import { objectGroup, renderGroup, frameGroup, cubeTexture, texture, rangeFog, densityFog, reference, normalWorld, pmremTexture, viewportUV } from '../../../nodes/TSL.js';
 
 
-import { EquirectangularReflectionMapping, EquirectangularRefractionMapping } from '../../../constants.js';
+import { CubeUVReflectionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping } from '../../../constants.js';
 
 
 const outputNodeMap = new WeakMap();
 const outputNodeMap = new WeakMap();
 
 
@@ -272,9 +272,9 @@ class Nodes extends DataMap {
 
 
 				let backgroundNode = null;
 				let backgroundNode = null;
 
 
-				if ( background.isCubeTexture === true || ( background.mapping === EquirectangularReflectionMapping || background.mapping === EquirectangularRefractionMapping ) ) {
+				if ( background.isCubeTexture === true || ( background.mapping === EquirectangularReflectionMapping || background.mapping === EquirectangularRefractionMapping || background.mapping === CubeUVReflectionMapping ) ) {
 
 
-					if ( scene.backgroundBlurriness > 0 ) {
+					if ( scene.backgroundBlurriness > 0 || background.mapping === CubeUVReflectionMapping ) {
 
 
 						backgroundNode = pmremTexture( background, normalWorld );
 						backgroundNode = pmremTexture( background, normalWorld );
 
 

粤ICP备19079148号