Mr.doob 7 месяцев назад
Родитель
Сommit
d86b81be88
3 измененных файлов с 10 добавлено и 31 удалено
  1. 0 8
      devtools/bridge.js
  2. 2 3
      devtools/content-script.js
  3. 8 20
      devtools/panel/panel.js

+ 0 - 8
devtools/bridge.js

@@ -60,7 +60,6 @@
 
 			reset() {
 
-				// console.log('DevTools: Resetting state');
 
 				// Clear objects map
 				this.objects.clear();
@@ -190,7 +189,6 @@
 		// Listen for Three.js registration
 		devTools.addEventListener( 'register', ( event ) => {
 
-			// console.log('DevTools: Three.js registered with revision:', event.detail.revision);
 			dispatchEvent( 'register', event.detail );
 
 		} );
@@ -313,8 +311,6 @@
 
 		}
 
-		// Start periodic renderer checks
-		// console.log('DevTools: Starting periodic renderer checks');
 
 		// Function to check if bridge is available
 		function checkBridgeAvailability() {
@@ -441,7 +437,6 @@
 
 				if ( ! object || ! object.uuid ) return; // Simplified check
 
-				// console.log('DevTools: Processing object during reload:', object.type || object.constructor.name, object.uuid);
 
 				// Get object data
 				const objectData = getObjectData( object );
@@ -456,7 +451,6 @@
 				// Process children recursively
 				if ( object.children && Array.isArray( object.children ) ) {
 
-					// console.log('DevTools: Processing', object.children.length, 'children of', object.type || object.constructor.name);
 					object.children.forEach( child => observeAndBatchObject( child ) );
 
 				}
@@ -478,8 +472,6 @@
 				// Update the cache
 				sceneObjectCountCache.set( scene.uuid, currentObjectCount );
 
-			} else {
-				// console.log(`DevTools: Scene ${scene.uuid} count unchanged (${currentObjectCount}), skipping dispatch.`);
 			}
 
 		}

+ 2 - 3
devtools/content-script.js

@@ -1,7 +1,6 @@
 /* global chrome */
 
 // This script runs in the context of the web page
-// console.log( 'Three.js DevTools: Content script loaded at document_readyState:', document.readyState ); // Comment out
 
 // Inject the bridge script into the main document or a target (e.g., iframe)
 function injectBridge( target = document ) {
@@ -97,8 +96,8 @@ function handleWindowMessage( event ) {
 
 	}
 
-	const messageWithSource = { ...event.data, source };
-	chrome.runtime.sendMessage( messageWithSource );
+	event.data.source = source;
+	chrome.runtime.sendMessage( event.data );
 
 }
 

+ 8 - 20
devtools/panel/panel.js

@@ -45,7 +45,6 @@ const state = {
 	objects: new Map()
 };
 
-// console.log('Panel script loaded');
 
 // Create a connection to the background page
 const backgroundPageConnection = chrome.runtime.connect( {
@@ -81,7 +80,6 @@ backgroundPageConnection.onDisconnect.addListener( () => {
 
 } );
 
-// console.log('Connected to background page with tab ID:', chrome.devtools.inspectedWindow.tabId);
 
 // Store renderer collapse states
 const rendererCollapsedState = new Map();
@@ -138,9 +136,6 @@ function handleThreeEvent( message ) {
 			// Also update the generic objects map if renderers are stored there too
 			state.objects.set( detail.uuid, detail );
 
-			// The DOM update logic previously here is redundant because updateUI()
-			// rebuilds the entire renderer element anyway, using the updated data
-			// from state.renderers and the persisted open/closed state.
 
 			break;
 
@@ -397,23 +392,16 @@ function renderObject( obj, container, level = 0 ) {
 			.filter( child => child !== undefined )
 			.sort( ( a, b ) => {
 
-				// Sort order: Cameras, Lights, Groups, Meshes, Others
-				const typeOrder = {
-					isCamera: 1,
-					isLight: 2,
-					isGroup: 3,
-					isMesh: 4
+				const getTypeOrder = ( obj ) => {
+					if ( obj.isCamera ) return 1;
+					if ( obj.isLight ) return 2;
+					if ( obj.isGroup ) return 3;
+					if ( obj.isMesh ) return 4;
+					return 5;
 				};
-				// Refactored to avoid optional chaining parser error
-				const findOrder = ( obj ) => {
 
-					const entry = Object.entries( typeOrder ).find( ( [ key ] ) => obj[ key ] );
-					return entry ? entry[ 1 ] : 5; // Check if entry exists, then access index 1 (value)
-
-				};
-
-				const aOrder = findOrder( a );
-				const bOrder = findOrder( b );
+				const aOrder = getTypeOrder( a );
+				const bOrder = getTypeOrder( b );
 
 				return aOrder - bOrder;
 

粤ICP备19079148号