def export_for_web(self, filepath="brexport.html"): """ This function is used to export a brainrender scene for hosting it online. It saves an html file that can be opened in a web browser to show an interactive brainrender scene """ if not filepath.endswith(".html"): raise ValueError("Filepath should point to a .html file") # prepare settings vedosettings.notebookBackend = "k3d" # Create new plotter and save to file plt = Plotter() plt.add(self.actors) plt = plt.show(interactive=False) plt.camera[-2] = -1 if self.verbose: print( "Ready for exporting. Exporting scenes with many actors might require a few minutes" ) with open(filepath, "w") as fp: fp.write(plt.get_snapshot()) if self.verbose: print( f"The brainrender scene has been exported for web. The results are saved at {filepath}" ) # Reset settings vedosettings.notebookBackend = None self.jupyter = False
def export(self, savepath): """ Exports the scene to a .html file for online renderings. :param savepath: str, Path to a .html file to save the export """ logger.debug(f"Exporting scene to {savepath}") _backend = self.backend if not self.is_rendered: self.render(interactive=False) path = Path(savepath) if path.suffix != ".html": raise ValueError("Savepath should point to a .html file") # prepare settings vsettings.notebookBackend = "k3d" # Create new plotter and save to file plt = Plotter() plt.add(self.renderables) plt = plt.show(interactive=False) plt.camera[-2] = -1 with open(path, "w") as fp: fp.write(plt.get_snapshot()) print( f"The brainrender scene has been exported for web. The results are saved at {path}" ) # Reset settings vsettings.notebookBackend = None self.backend = _backend return str(path)