-
Notifications
You must be signed in to change notification settings - Fork 211
Closed
Labels
Description
Describe the bug
I am using NextJS as frontend and want to render pdb files. The file could be rendered correctly, but when I switch to other page, the following error would occur:
[.WebGL-0xa280b1f5c00] GL_INVALID_FRAMEBUFFER_OPERATION: Framebuffer is incomplete: Attachment has zero size.)
I am not sure the correct way to dispose/destroy or clean up the viewer, not find any tutorial about that.
To Reproduce
I use the following code to visualize and clean the viewer, but not successful:
const ThreeDmolViewer = ({ pdbData, id }) => {
const viewerRef = useRef(null);
useEffect(() => {
if (viewerRef.current && pdbData) {
const viewer = window.$3Dmol.createViewer(viewerRef.current, {
defaultcolors: window.$3Dmol.rasmolElementColors,
});
viewer.addModel(pdbData, "pdb");
viewer.setStyle({}, { cartoon: { color: "spectrum" } });
viewer.zoomTo();
viewer.render();
viewer.spin(true);
return () => {
viewer.spin(false);
viewer.removeAllModels();
viewer.clear();
viewer.stopAnimate();
};
}
}, [pdbData]);
return (
<div
id={`3DmolViewer_${id}`}
style={{ position: "relative", width: "400px", height: "400px" }}
ref={viewerRef}
></div>
);
};
Expected behavior
No warning when switch pages. Namely the viewer could be destroyed.
Desktop (please complete the following information):
- Ubuntu 20.04
- Browser chrome