Skip to content

Commit 8064767

Browse files
committed
Added hasEnvironmentLight.
1 parent 99d3bb1 commit 8064767

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/x_ite/Components/Lighting/EnvironmentLight.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ Object .assign (EnvironmentLightContainer .prototype,
100100
gl .uniform1i (shaderObject .x3d_EnvironmentLightCharlieLUTTexture, CharlieLUTTextureUnit);
101101
}
102102

103-
const i = shaderObject .numLights ++;
103+
const i = shaderObject .numEnvironmentLights ++;
104104

105-
if (shaderObject .hasLight (i, this))
105+
if (shaderObject .hasEnvironmentLight (i, this))
106106
return;
107107

108108
const color = lightNode .getColor ();

src/x_ite/Components/Shaders/X3DProgrammableShaderObject.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ function X3DProgrammableShaderObject (executionContext)
5050

5151
this .fogNode = null;
5252
this .numClipPlanes = 0;
53+
this .numEnvironmentLights = 0;
54+
this .environmentLightNodes = [ ];
5355
this .numLights = 0;
54-
this .numGlobalLights = 0;
5556
this .lightNodes = [ ];
5657
this .numTextureProjectors = 0;
57-
this .numGlobalTextureProjectors = 0;
5858
this .textureProjectorNodes = [ ];
5959
this .textures = new Set ();
6060
}
@@ -924,6 +924,15 @@ Object .assign (X3DProgrammableShaderObject .prototype,
924924

925925
return false;
926926
},
927+
hasEnvironmentLight (i, lightNode)
928+
{
929+
if (this .environmentLightNodes [i] === lightNode)
930+
return true;
931+
932+
this .environmentLightNodes [i] = lightNode;
933+
934+
return false;
935+
},
927936
hasLight (i, lightNode)
928937
{
929938
if (this .lightNodes [i] === lightNode)
@@ -985,14 +994,18 @@ Object .assign (X3DProgrammableShaderObject .prototype,
985994

986995
// Set global lights and global texture projectors.
987996

988-
this .numLights = 0;
989-
this .numTextureProjectors = 0;
997+
this .numEnvironmentLights = 0;
998+
this .numLights = 0;
999+
this .numTextureProjectors = 0;
1000+
1001+
this .environmentLightNodes .length = 0;
9901002
this .lightNodes .length = 0;
9911003
this .textureProjectorNodes .length = 0;
9921004

9931005
for (const globalLights of renderObject .getGlobalLights ())
9941006
globalLights .setShaderUniforms (gl, this, renderObject);
9951007

1008+
this .numGlobalEnvironmentLights = this .numEnvironmentLights;
9961009
this .numGlobalLights = this .numLights;
9971010
this .numGlobalTextureProjectors = this .numTextureProjectors;
9981011

@@ -1032,6 +1045,7 @@ Object .assign (X3DProgrammableShaderObject .prototype,
10321045
// Clip planes and local lights
10331046

10341047
this .numClipPlanes = 0;
1048+
this .numEnvironmentLights = this .numGlobalEnvironmentLights;
10351049
this .numLights = this .numGlobalLights;
10361050
this .numTextureProjectors = this .numGlobalTextureProjectors;
10371051

0 commit comments

Comments
 (0)