Skip to content

Instantly share code, notes, and snippets.

@dominiquesydow
Created March 4, 2021 17:22
Show Gist options
  • Save dominiquesydow/0cc044a9936836bd3ceb096697307870 to your computer and use it in GitHub Desktop.
Save dominiquesydow/0cc044a9936836bd3ceb096697307870 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dominiquesydow
Copy link
Author

Solution (thanks to @hainm's comment):

view = nv.NGLWidget()
for sphere_buffer, name in zip(sphere_buffers, ["blue spheres", "cyan spheres"]):
    print(name)
    js = (
    f"""
    var params = {sphere_buffer};
    var shape = new NGL.Shape('{name}');
    var buffer = new NGL.SphereBuffer(params);
    shape.addBuffer(buffer);
    var shapeComp = this.stage.addComponentFromObject(shape);
    shapeComp.addRepresentation("buffer");
    """
    )
    view._js(js)
view.display(gui=True, style="ngl")

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment