Collections:
addSphere() - Create Spheres
How to create spheres with 3Dmol.js addSphere() methods?
✍: FYIcenter.com
viewer.addSphere() method in the $3Dmol.GLViewer class
allows you to create sphere objects.
Here is the signature of the addSphere() method:
{$3Dmol.GLViewer} addSphere({SphereStyleSpec} spec) -> {$3Dmol.GLShape}
Here is an HTML code example, Draw-Sphere.html, that uses the addSphere() method:
<html><head>
<script src="https://3Dmol.csb.pitt.edu/build/3Dmol-min.js"></script>
<style>
.mol-container {width: 400px; height: 400px; position: relative;}
</style>
</head>
<body>
<div id="container-01" class="mol-container"></div>
<script>
$(function() {
let element = $('#container-01');
let config = { backgroundColor: 'grey' };
let viewer = $3Dmol.createViewer( element, config );
viewer.addSphere({ center: {x:0, y:0, z:0}, radius: 10.0, color: 'green' });
viewer.zoomTo();
viewer.render();
viewer.zoom(0.8, 2000);
});
</script>
</body></html>
This example HTML code will display a sphere as shown below:
⇒ addModel() - Add Model from Data
⇐ addLabel() - Create Text Labels
⇑⇑ 3Dmol.js FAQ
2023-09-07, 839🔥, 0💬
Popular Posts:
Molecule Summary: ID: FYI-1003546 Names: InChIKey: MIINHRNQLVVCEW-UHFFFAOYS A-NSMILES: c%10ccc9c3nc(...
Molecule Summary: ID: FYI-1000973 SMILES: S=C1S\\C(=C/c2ccc(CC)cc2 )C(=O)N1CCN(C)CReceived at FYIcen...
Molecule Summary: ID: FYI-1006582 Names: InChIKey: KREJOXYCRKVVIR-UHFFFAOYS A-NSMILES: CCN(CC)CCCCC(...
Molecule Summary: ID: FYI-1002808 Names: InChIKey: OZBGWVAREHIEDY-UHFFFAOYS A-NSMILES: NS(=O)(=O)c1c...
Molecule Summary: ID: FYI-1000197 SMILES: CC(C)C1=CC=CC=C1.[CH-]1C =CC=C1.F[Sb-](F)(F)(F)(F )F.[Fe+2]...