Skip to content

Commit

Permalink
addShape
Browse files Browse the repository at this point in the history
  • Loading branch information
hainm committed Jun 20, 2024
1 parent 6a2c2a1 commit 03f77d0
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions js/src/widget_ngl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -755,25 +755,12 @@ class NGLView extends widgets.DOMWidgetView{

addShape(name: string, shapes: any[]) {
const shape = new NGL.Shape(name);
const shapeDict = {
'sphere': shape.addSphere,
'ellipsoid': shape.addEllipsoid,
'cylinder': shape.addCylinder,
'cone': shape.addCone,
'mesh': shape.addMesh,
'arrow': shape.addArrow,
'text': shape.addText,
'label': shape.addText,
'tetrahedron': shape.addTetrahedron,
'octahedron': shape.addOctahedron,
'torus': shape.addTorus
};

shapes.forEach(([shapeType, ...params]) => {
const func = shapeDict[shapeType];
func.apply(shape, params);
const func = shape[shapeType];
if (func && typeof func === 'function') {
func.apply(shape, params);
}
});

const shapeComp = this.stage.addComponentFromObject(shape);
}

Expand Down

0 comments on commit 03f77d0

Please sign in to comment.