Molsoft ActiveIcm for JavaScript (IcmJS) technical manual |
This makes it a perfect tool for data sharing and publishing.
The simplest way to embed a 3D object into your web page is shown in the HTML code below: There are three basic steps:
<html> <head> <script src="lib/acticm.js"> </script> </head> <body> <h2>IcmJS Demo Page</h2> <div id="con" style="width: 800px; height: 600px; border: 2px solid #ABABAB"> </div> <script> function onLoadActiveIcm() { act = new ActiveIcmJS("con"); act.projectFile = "myproject.icb"; // or pdb, mol } </script> </body> </html>
Another part was to port OpenGL calls into WebGL subset. We implemented efficient run-time layer which translates normal OpenGL functions into WebGL compatible calls. That allows us to keep the same code-base and bring highest quality 3D graphics inside the browser almost without any restrictions.
Module.ActiveIcm is a JavaScript object which implements single ICM shell and graphics window. You may have multiple IcmJS object on the same web page.
Methods:
var act = new ActiveIcmJS("con");
Opens ICB,PDB or MOL file from the specified URL
All JavaScript calls which load data are asynchronous which means that function returns immediately while the download is left in the background. If you want to perform some post processing after the load is finished you need to provide a callback function in the options object.
var act.OpenProject( "1xbb_test.icb", { onload: function () { act.RunCommands("color background white"); act.RunCommands("display atom label"); } } )
Runs any icm script
act.RunCommands("display cpk a_H");
IMPORTANT: You cannot use 'read' command in the ICM sciript which called from ActiveIcmJS. You should use ~OpenProject method instead.
The same as above but the last expression is returned
var randomFromIcm = act.RunCommandsValue("Random()");
Loads and runs remote script into the shell. Can be useful to load a set of macros
act.CallScript( "http://domain.org/_macro", function () { act.OpenProject("http://www.rcsb.org/pdb/files/4rws.pdb.gz", { act.RunCommands("cool a_"); } ) } );
Converts the icm variable with icmVarName into an appropriate JavaScript type and returns it
act.GetShellVar("i_out"); act.GetShellVar("c_out");
Properties:
holds ActiveIcmJS version
Holds current project file.
Example:act.projectFile = "myfile.icb"
holds number of active downloads
holds number of slides in the current project
holds current slide
toggles anaglyph stereo mode
toggles rocking mode
returns WebGL context handle. Zero means no context was created
toggles visiblity of sequence view
toggles visiblity of top search bar
toggles visiblity of table view
Holds display state change callback.
Holds global load project callback.