Selaa lähdekoodia

update Kitchen Sink example to use custom color mode

Sean Rennie 4 vuotta sitten
vanhempi
commit
4239bc9606
1 muutettua tiedostoa jossa 13 lisäystä ja 0 poistoa
  1. 13 0
      example/index.js

+ 13 - 0
example/index.js

@@ -9,6 +9,7 @@ import {
 	IS_LEAF,
 	RANDOM_COLOR,
 	RANDOM_NODE_COLOR,
+	CUSTOM_COLOR_MODE
 } from '../src/index.js';
 import {
 	Scene,
@@ -102,6 +103,17 @@ function reinstantiateTiles() {
 	tiles.manager.addHandler( /\.gltf$/, loader );
 	offsetParent.add( tiles.group );
 
+
+	// Used with CUSTOM_COLOR_MODE
+	tiles.customColorCallback = ( tile, child ) => {
+
+		const depthIsEven = tile.__depth % 2 === 0;
+		const color = depthIsEven ? [ 255, 0, 0 ] : [ 255, 255, 255 ];
+
+		child.material.color.setRGB( ...color );
+
+	};
+
 }
 
 function init() {
@@ -253,6 +265,7 @@ function init() {
 		IS_LEAF,
 		RANDOM_COLOR,
 		RANDOM_NODE_COLOR,
+		CUSTOM_COLOR_MODE
 
 	} );
 	debug.open();