Collections:
addBox() - Create 3D Boxes
How to create 3D Boxes with 3Dmol.js addBox() methods?
✍: FYIcenter.com
viewer.addBox() method in the $3Dmol.GLViewer class
allows you to create 3D box objects.
Here is the signature of the addBox() method:
{$3Dmol.GLViewer} addBox({BoxSpec} spec) -> {$3Dmol.GLShape}
Here is an HTML code example, Draw-Box.html, that uses the addBox() method:
<html><head>
<script src="/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.addBox({center:{x:0,y:0,z:0},dimensions: {w:3,h:4,d:2},color:'magenta'});
viewer.zoomTo();
viewer.rotate(45, {x:1,y:1,z:1});
viewer.render();
});
</script>
</body></html>
This example HTML code will display a 3D box as shown below:
⇒ addLabel() - Create Text Labels
⇐ GLViewer Class and Instance Methods
⇑⇑ 3Dmol.js FAQ
2023-09-07, 1250🔥, 0💬
Popular Posts:
Molecule Summary: ID: FYI-1001942 SMILES: [ClH]=[ClH]([ClH][ClH][C lH]1=ClCl=[ClH](/Cl=[ClH ]2[ClH]([C...
Molecule Summary: ID: FYI-1004135 Names: InChIKey: XWFCFMXQTBGXQW-GOSISDBHS A-NSMILES: O=C(O)c6cn(C1...
Molecule Summary: ID: FYI-1005693 Names: InChIKey: GLNOSFGSNDKLOC-OXQOHEQNS A-NSMILES: CCN(CC)C(=O)[...
Molecule Summary: ID: FYI-1004918 Names: InChIKey: LEKMPWWPXLGKGJ-UHFFFAOYS A-NSMILES: COC6CCC5(C)C(...
Molecule Summary: ID: FYI-1001887 SMILES: CC1=C(C(=CC2=CC3=C(C(=C1 2)O)C(=O)C4(C(=O)C=C(C(C 4(C3=O)O)O...