Jelajahi Sumber

Fix random color per tile

Garrett Johnson 5 tahun lalu
induk
melakukan
b8d98f1864
1 mengubah file dengan 11 tambahan dan 3 penghapusan
  1. 11 3
      src/three/DebugTilesRenderer.js

+ 11 - 3
src/three/DebugTilesRenderer.js

@@ -179,6 +179,17 @@ export class DebugTilesRenderer extends TilesRenderer {
 		visibleTiles.forEach( tile => {
 		visibleTiles.forEach( tile => {
 
 
 			const scene = tile.cached.scene;
 			const scene = tile.cached.scene;
+
+			// create a random color per-tile
+			let h, s, l;
+			if ( colorMode === RANDOM_COLOR ) {
+
+				h = Math.random();
+				s = 0.5 + Math.random() * 0.5;
+				l = 0.375 + Math.random() * 0.25;
+
+			}
+
 			scene.traverse( c => {
 			scene.traverse( c => {
 
 
 				const currMaterial = c.material;
 				const currMaterial = c.material;
@@ -280,9 +291,6 @@ export class DebugTilesRenderer extends TilesRenderer {
 
 
 							if ( ! c.material[ HAS_RANDOM_COLOR ] ) {
 							if ( ! c.material[ HAS_RANDOM_COLOR ] ) {
 
 
-								const h = Math.random();
-								const s = 0.5 + Math.random() * 0.5;
-								const l = 0.375 + Math.random() * 0.25;
 								c.material.color.setHSL( h, s, l );
 								c.material.color.setHSL( h, s, l );
 								c.material[ HAS_RANDOM_COLOR ] = true;
 								c.material[ HAS_RANDOM_COLOR ] = true;