Skip to content

Commit 8605078

Browse files
committed
Robustness.
1 parent 3cbd00d commit 8605078

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

devtools/bridge.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,16 @@ if (!window.__THREE_DEVTOOLS__) {
376376
}
377377
// Handle request for initial state from panel
378378
else if ( message.name === 'request-initial-state' ) {
379-
// console.log('DevTools: Received request-initial-state, resending objects...');
380-
// Resend all known objects to the panel
381-
devTools.objects.forEach( ( objectData ) => {
382-
dispatchEvent('observe', objectData);
383-
});
384-
// console.log('DevTools: Finished resending objects.');
379+
for (const observedRenderer of observedRenderers) {
380+
const data = getObjectData(observedRenderer);
381+
if (data) {
382+
data.properties = getRendererProperties(observedRenderer);
383+
dispatchEvent('renderer', data);
384+
}
385+
}
386+
for (const observedScene of observedScenes) {
387+
reloadSceneObjects(observedScene);
388+
}
385389
}
386390
});
387391

devtools/content-script.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ function handleBackgroundMessage( message, sender, sendResponse ) {
178178
if ( message.name === 'request-initial-state' ) {
179179

180180
// console.log( 'Content script: Forwarding message to bridge:', message.name );
181-
window.postMessage( message, '*' ); // Forward the message as is to the page
181+
// Ensure the message has the correct ID before forwarding to the page
182+
message.id = 'three-devtools';
183+
window.postMessage( message, '*' ); // Forward the modified message to the page
182184

183185
// Optional: Forward to iframes too, if needed (might cause duplicates if bridge is in iframe)
184186
/*

devtools/panel/panel.js

-4
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,6 @@ function renderObject(obj, container, level = 0) {
387387
function updateUI() {
388388

389389
const container = document.getElementById('scene-tree');
390-
if (!container) {
391-
console.error('Could not find scene-tree container!');
392-
return;
393-
}
394390
container.innerHTML = '';
395391

396392
// Add version info if available

0 commit comments

Comments
 (0)