You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 12, 2022. It is now read-only.
Repository navigation
This repository was archived by the owner on Dec 12, 2022. It is now read-only.
Explain how to use the extension in the README file #67
I just got started with ThreeJS and the devtool is very nice to experiment with the lights and the scene's composition! Thank you!
I saw on the Chrome Store comments that some users have trouble using the extension though.
Wouldn't it be nice to add an example in the README file to explain to new users how to implement the observer code?
Maybe something like this:
Current API
This API has not been thought out at all, but this will register your
THREE.Scene and THREE.Renderer to be observed by the tools.
// Observe a scene or a rendererif(typeof__THREE_DEVTOOLS__!=='undefined'){__THREE_DEVTOOLS__.dispatchEvent(newCustomEvent('observe',{detail: scene}));__THREE_DEVTOOLS__.dispatchEvent(newCustomEvent('observe',{detail: renderer}));}
Simply add it at the end of your animate loop, like this:
functionanimate(){requestAnimationFrame(animate);// ...// Observe a scene or a rendererif(typeof__THREE_DEVTOOLS__!=="undefined"){__THREE_DEVTOOLS__.dispatchEvent(newCustomEvent("observe",{detail: scene}));__THREE_DEVTOOLS__.dispatchEvent(newCustomEvent("observe",{detail: renderer}));}}
You should be able to interact with your scene's objects:
If you're still having issues, I went through the pain of rebuilding a minimal working example of the legacy solution:
<!DOCTYPE html><html><head><metacharset="utf-8"><title>My first three.js app</title><style>body{margin:0;}</style></head><body><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script><script>constscene=newTHREE.Scene();constcamera=newTHREE.PerspectiveCamera(75,window.innerWidth/window.innerHeight,0.1,1000);constrenderer=newTHREE.WebGLRenderer();renderer.setSize(window.innerWidth,window.innerHeight);document.body.appendChild(renderer.domElement);constgeometry=newTHREE.BoxGeometry();constmaterial=newTHREE.MeshBasicMaterial({color: 0x00ff00});constcube=newTHREE.Mesh(geometry,material);scene.add(cube);camera.position.z=5;functionanimate(){requestAnimationFrame(animate);cube.rotation.x+=0.01;cube.rotation.y+=0.01;renderer.render(scene,camera);/** HERE IS THE CODE THAT WILL ENABLE THE THREEJS EXTENSION **/// Observe a scene or a rendererif(typeof__THREE_DEVTOOLS__!=="undefined"){__THREE_DEVTOOLS__.dispatchEvent(newCustomEvent("observe",{detail: scene}));__THREE_DEVTOOLS__.dispatchEvent(newCustomEvent("observe",{detail: renderer}));}/** END OF THE CODE THAT WILL ENABLE THE THREEJS EXTENSION **/};animate();</script></body></html>
Activity
trusktr commentedon Jan 7, 2022
How do we make the UI appear?
Do we need to dispatch those event on every render? Does it need to happen before or after the scene is rendered?
Can you please add details to README?
RilDev commentedon Jan 9, 2022
Hi @trusktr, I'd give you an answer in a nanosecond but I lost the technology and it would be a painful process to build it back again... https://www.youtube.com/watch?v=6SlTNI0fzJc
Alright, jokes apart, it seems they fixed the issue. Now you just need the extension and open it in your Devtool:
https://chrome.google.com/webstore/detail/threejs-developer-tools/ebpnegggocnnhleeicgljbedjkganaek
You should be able to interact with your scene's objects:
If you're still having issues, I went through the pain of rebuilding a minimal working example of the legacy solution:
Hope it helps!