Browse Source

Add stats for renderer

Garrett Johnson 5 năm trước cách đây
mục cha
commit
25fbc8501c
1 tập tin đã thay đổi với 11 bổ sung0 xóa
  1. 11 0
      example/index.js

+ 11 - 0
example/index.js

@@ -49,6 +49,7 @@ let params = {
 	'enableUpdate': true,
 	'raycast': NONE,
 	'enableCacheDisplay': false,
+	'enableRendererStats': false,
 	'orthographic': false,
 
 	'errorTarget': 6,
@@ -77,6 +78,7 @@ function reinstantiateTiles() {
 	if ( tiles ) {
 
 		offsetParent.remove( tiles.group );
+		tiles.dispose();
 
 	}
 
@@ -254,6 +256,7 @@ function init() {
 	} );
 	exampleOptions.add( params, 'raycast', { NONE, ALL_HITS, FIRST_HIT_ONLY } );
 	exampleOptions.add( params, 'enableCacheDisplay' );
+	exampleOptions.add( params, 'enableRendererStats' );
 	exampleOptions.open();
 
 	gui.add( params, 'reload' );
@@ -620,6 +623,14 @@ function render() {
 
 	}
 
+	if ( params.enableRendererStats ) {
+
+		const memory = renderer.info.memory;
+		const materialCount = renderer.info.programs.length;
+		str += `<br/>Geometries: ${ memory.geometries } Textures: ${ memory.textures } Materials: ${ materialCount }`;
+
+	}
+
 	if ( statsContainer.innerHTML !== str ) {
 
 		statsContainer.innerHTML = str;