Pārlūkot izejas kodu

Merge pull request #13317 from mrdoob/webglrenderstates-cleanup

WebGLRenderStates: Moved count to WebGLLights.
Mr.doob 7 gadi atpakaļ
vecāks
revīzija
335359176b

+ 6 - 3
src/renderers/webgl/WebGLLights.js

@@ -100,12 +100,16 @@ function UniformsCache() {
 
 }
 
-function WebGLLights( stateId ) {
+var count = 0;
+
+function WebGLLights() {
 
 	var cache = new UniformsCache();
 
 	var state = {
 
+		id: count ++,
+
 		hash: '',
 
 		ambient: [ 0, 0, 0 ],
@@ -312,8 +316,7 @@ function WebGLLights( stateId ) {
 		state.point.length = pointLength;
 		state.hemi.length = hemiLength;
 
-		// TODO (sam-g-steel) why aren't we using join
-		state.hash = directionalLength + ',' + pointLength + ',' + spotLength + ',' + rectAreaLength + ',' + hemiLength + ',' + shadows.length + ',' + stateId;
+		state.hash = state.id + ',' + directionalLength + ',' + pointLength + ',' + spotLength + ',' + rectAreaLength + ',' + hemiLength + ',' + shadows.length;
 
 	}
 

+ 1 - 5
src/renderers/webgl/WebGLRenderStates.js

@@ -4,13 +4,9 @@
 
 import { WebGLLights } from './WebGLLights.js';
 
-var count = 0;
-
 function WebGLRenderState() {
 
-	var id = count ++;
-
-	var lights = new WebGLLights( id );
+	var lights = new WebGLLights();
 
 	var lightsArray = [];
 	var shadowsArray = [];