From b1567a091e02711d867abf5797395ff8ed3a9e40 Mon Sep 17 00:00:00 2001 From: Michael Herzog Date: Thu, 19 Dec 2024 18:10:20 +0100 Subject: [PATCH] Nodes: Ensure `getBackgroundNode()` and `getEnvironmentNode()` only returns nodes. (#30169) --- src/renderers/common/nodes/Nodes.js | 40 +++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/renderers/common/nodes/Nodes.js b/src/renderers/common/nodes/Nodes.js index a061ad9d700584..07cab91c3f32a9 100644 --- a/src/renderers/common/nodes/Nodes.js +++ b/src/renderers/common/nodes/Nodes.js @@ -199,13 +199,49 @@ class Nodes extends DataMap { getEnvironmentNode( scene ) { - return scene.environmentNode || this.get( scene ).environmentNode || null; + let environmentNode = null; + + if ( scene.environmentNode && scene.environmentNode.isNode ) { + + environmentNode = scene.environmentNode; + + } else { + + const sceneData = this.get( scene ); + + if ( sceneData.environmentNode ) { + + environmentNode = sceneData.environmentNode; + + } + + } + + return environmentNode; } getBackgroundNode( scene ) { - return scene.backgroundNode || this.get( scene ).backgroundNode || null; + let backgroundNode = null; + + if ( scene.backgroundNode && scene.backgroundNode.isNode ) { + + backgroundNode = scene.backgroundNode; + + } else { + + const sceneData = this.get( scene ); + + if ( sceneData.backgroundNode ) { + + backgroundNode = sceneData.backgroundNode; + + } + + } + + return backgroundNode; }