Procházet zdrojové kódy

add option to use a custom color mode with a callback

Sean Rennie před 4 roky
rodič
revize
1ede6f4a71
2 změnil soubory, kde provedl 18 přidání a 1 odebrání
  1. 2 0
      src/index.js
  2. 16 1
      src/three/DebugTilesRenderer.js

+ 2 - 0
src/index.js

@@ -8,6 +8,7 @@ import {
 	RELATIVE_DEPTH,
 	IS_LEAF,
 	RANDOM_COLOR,
+	CUSTOM_COLOR_MODE
 } from './three/DebugTilesRenderer.js';
 import { TilesRenderer } from './three/TilesRenderer.js';
 import { B3DMLoader } from './three/B3DMLoader.js';
@@ -49,4 +50,5 @@ export {
 	RELATIVE_DEPTH,
 	IS_LEAF,
 	RANDOM_COLOR,
+	CUSTOM_COLOR_MODE
 };

+ 16 - 1
src/three/DebugTilesRenderer.js

@@ -17,6 +17,7 @@ export const RELATIVE_DEPTH = 5;
 export const IS_LEAF = 6;
 export const RANDOM_COLOR = 7;
 export const RANDOM_NODE_COLOR = 8;
+export const CUSTOM_COLOR_MODE = 9;
 
 export class DebugTilesRenderer extends TilesRenderer {
 
@@ -36,6 +37,7 @@ export class DebugTilesRenderer extends TilesRenderer {
 		this.displayBoxBounds = false;
 		this.displaySphereBounds = false;
 		this.colorMode = NONE;
+		this.customDebugColor = null;
 		this.boxGroup = boxGroup;
 		this.sphereGroup = sphereGroup;
 		this.maxDebugDepth = - 1;
@@ -258,7 +260,6 @@ export class DebugTilesRenderer extends TilesRenderer {
 						delete c.material[ HAS_RANDOM_COLOR ];
 
 					}
-
 					// Set the color on the basic material
 					switch ( colorMode ) {
 
@@ -344,6 +345,20 @@ export class DebugTilesRenderer extends TilesRenderer {
 							break;
 
 						}
+						case CUSTOM_COLOR_MODE: {
+
+							if ( this.customDebugColor ) {
+
+								this.customDebugColor( tile, c );
+
+							} else {
+
+								console.error( 'customDebugColor callback not defined' );
+
+							}
+							break;
+
+						}
 
 					}