瀏覽代碼

update Kitchen Sink example to use custom color mode

Sean Rennie 4 年之前
父節點
當前提交
4239bc9606
共有 1 個文件被更改,包括 13 次插入0 次删除
  1. 13 0
      example/index.js

+ 13 - 0
example/index.js

@@ -9,6 +9,7 @@ import {
 	IS_LEAF,
 	IS_LEAF,
 	RANDOM_COLOR,
 	RANDOM_COLOR,
 	RANDOM_NODE_COLOR,
 	RANDOM_NODE_COLOR,
+	CUSTOM_COLOR_MODE
 } from '../src/index.js';
 } from '../src/index.js';
 import {
 import {
 	Scene,
 	Scene,
@@ -102,6 +103,17 @@ function reinstantiateTiles() {
 	tiles.manager.addHandler( /\.gltf$/, loader );
 	tiles.manager.addHandler( /\.gltf$/, loader );
 	offsetParent.add( tiles.group );
 	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() {
 function init() {
@@ -253,6 +265,7 @@ function init() {
 		IS_LEAF,
 		IS_LEAF,
 		RANDOM_COLOR,
 		RANDOM_COLOR,
 		RANDOM_NODE_COLOR,
 		RANDOM_NODE_COLOR,
+		CUSTOM_COLOR_MODE
 
 
 	} );
 	} );
 	debug.open();
 	debug.open();