mirror of
https://github.com/3dmol/3Dmol.js.git
synced 2026-06-04 08:39:49 +09:00
don't use requirejs since it wasn't reliable
This commit is contained in:
@@ -455,8 +455,9 @@ $3Dmol.getPropertyRange = function (atomlist, prop) {
|
||||
return [ min, max ];
|
||||
}
|
||||
|
||||
//hackish way to work with requirejs
|
||||
//hackish way to work with requirejs - doesn't actually work yet
|
||||
//since we doing use the require optimizer to combine modules
|
||||
if( typeof(define) === 'function' && define.amd) {
|
||||
define($3Dmol);
|
||||
define('$3Dmol',$3Dmol);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"scrolled": false
|
||||
@@ -22,39 +22,36 @@
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div id=\"3dmolviewer_14628239109\" style=\"position: relative; width: 640px; height: 480px\">\n",
|
||||
"<div id=\"3dmolviewer_146284669593\" style=\"position: relative; width: 640px; height: 480px\">\n",
|
||||
"<script>\n",
|
||||
"requirejs.config({\n",
|
||||
"\tpaths: {\n",
|
||||
"\t'$3Dmol': ['//3dmol.csb.pitt.edu/build/3Dmol-min'],},\n",
|
||||
"});\n",
|
||||
"require(['$3Dmol'], function($3Dmol) {\n",
|
||||
"var viewer = $3Dmol.createViewer($(\"#3dmolviewer_14628239109\"),{backgroundColor:\"white\"});\n",
|
||||
"if(typeof $3Dmolpromise === 'undefined') $3Dmolpromise = $.when($.getScript('http://localhost/3Dmol/build/3Dmol.js'))\n",
|
||||
"$3Dmolpromise.done(function() {\n",
|
||||
"var viewer = $3Dmol.createViewer($(\"#3dmolviewer_146284669593\"),{backgroundColor:\"white\"});\n",
|
||||
"$3Dmol.download(\"pdb:1ycr\", viewer, {}, function() {\n",
|
||||
"\tviewer.setStyle({\"cartoon\": {\"color\": \"spectrum\"}});\n",
|
||||
"viewer.render();\n",
|
||||
"})\n",
|
||||
"return {};});\n",
|
||||
"});\n",
|
||||
"</script>"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.HTML object>"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"p = py3Dmol.view(query='pdb:1ycr')\n",
|
||||
"p = py3Dmol.view(query='pdb:1ycr',js='http://localhost/3Dmol/build/3Dmol.js')\n",
|
||||
"p.setStyle({'cartoon': {'color':'spectrum'}})\n",
|
||||
"p.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -79,21 +76,18 @@
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div id=\"3dmolviewer_146282392081\" style=\"position: relative; width: 400px; height: 400px\">\n",
|
||||
"<div id=\"3dmolviewer_146284669845\" style=\"position: relative; width: 400px; height: 400px\">\n",
|
||||
"<script>\n",
|
||||
"requirejs.config({\n",
|
||||
"\tpaths: {\n",
|
||||
"\t'$3Dmol': ['//3dmol.csb.pitt.edu/build/3Dmol-min'],},\n",
|
||||
"});\n",
|
||||
"require(['$3Dmol'], function($3Dmol) {\n",
|
||||
"var viewer = $3Dmol.createViewer($(\"#3dmolviewer_146282392081\"),{backgroundColor:\"white\"});\n",
|
||||
"if(typeof $3Dmolpromise === 'undefined') $3Dmolpromise = $.when($.getScript('http://3dmol.csb.pitt.edu/build/3Dmol.js'))\n",
|
||||
"$3Dmolpromise.done(function() {\n",
|
||||
"var viewer = $3Dmol.createViewer($(\"#3dmolviewer_146284669845\"),{backgroundColor:\"white\"});\n",
|
||||
"\tviewer.addModel(\"4\\n* (null), Energy -1000.0000000\\nN 0.000005 0.019779 -0.000003 -0.157114 0.000052 -0.012746\\nH 0.931955 -0.364989 0.000003 1.507100 -0.601158 -0.004108\\nH -0.465975 -0.364992 0.807088 0.283368 0.257996 -0.583024\\nH -0.465979 -0.364991 -0.807088 0.392764 0.342436 0.764260\\n\",\"xyz\",{\"vibrate\": {\"frames\": 10, \"amplitude\": 1}});\n",
|
||||
"\tviewer.setStyle({\"stick\": {}});\n",
|
||||
"\tviewer.setBackgroundColor(\"0xeeeeee\");\n",
|
||||
"\tviewer.animate({\"loop\": \"backAndForth\"});\n",
|
||||
"\tviewer.zoomTo();\n",
|
||||
"viewer.render();\n",
|
||||
"return {};});\n",
|
||||
"});\n",
|
||||
"</script>"
|
||||
],
|
||||
"text/plain": [
|
||||
@@ -125,24 +119,21 @@
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div id=\"3dmolviewer_146282392129\" style=\"position: relative; width: 640px; height: 480px\">\n",
|
||||
"<div id=\"3dmolviewer_146284669969\" style=\"position: relative; width: 640px; height: 480px\">\n",
|
||||
"<script>\n",
|
||||
"requirejs.config({\n",
|
||||
"\tpaths: {\n",
|
||||
"\t'$3Dmol': ['//3dmol.csb.pitt.edu/build/3Dmol-min'],},\n",
|
||||
"});\n",
|
||||
"require(['$3Dmol'], function($3Dmol) {\n",
|
||||
"var viewer = $3Dmol.createViewer($(\"#3dmolviewer_146282392129\"),{backgroundColor:\"white\"});\n",
|
||||
"if(typeof $3Dmolpromise === 'undefined') $3Dmolpromise = $.when($.getScript('http://3dmol.csb.pitt.edu/build/3Dmol.js'))\n",
|
||||
"$3Dmolpromise.done(function() {\n",
|
||||
"var viewer = $3Dmol.createViewer($(\"#3dmolviewer_146284669969\"),{backgroundColor:\"white\"});\n",
|
||||
"$3Dmol.download(\"pdb:1dc9\", viewer, {}, function() {\n",
|
||||
"\tviewer.setViewStyle({\"color\": \"black\", \"width\": 0.1, \"style\": \"outline\"});\n",
|
||||
"\tviewer.setStyle({\"cartoon\": {\"color\": \"white\", \"tubes\": true, \"style\": \"oval\", \"arrows\": true}});\n",
|
||||
"viewer.render();\n",
|
||||
"})\n",
|
||||
"return {};});\n",
|
||||
"});\n",
|
||||
"</script>"
|
||||
],
|
||||
"text/plain": [
|
||||
"<py3Dmol.view at 0x7f48b434b250>"
|
||||
"<py3Dmol.view at 0x7fc6d8171410>"
|
||||
]
|
||||
},
|
||||
"execution_count": 6,
|
||||
@@ -167,21 +158,18 @@
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div id=\"3dmolviewer_146282392226\" style=\"position: relative; width: 640px; height: 480px\">\n",
|
||||
"<div id=\"3dmolviewer_146284670035\" style=\"position: relative; width: 640px; height: 480px\">\n",
|
||||
"<script>\n",
|
||||
"requirejs.config({\n",
|
||||
"\tpaths: {\n",
|
||||
"\t'$3Dmol': ['//3dmol.csb.pitt.edu/build/3Dmol-min'],},\n",
|
||||
"});\n",
|
||||
"require(['$3Dmol'], function($3Dmol) {\n",
|
||||
"var viewer = $3Dmol.createViewer($(\"#3dmolviewer_146282392226\"),{backgroundColor:\"white\"});\n",
|
||||
"if(typeof $3Dmolpromise === 'undefined') $3Dmolpromise = $.when($.getScript('http://3dmol.csb.pitt.edu/build/3Dmol.js'))\n",
|
||||
"$3Dmolpromise.done(function() {\n",
|
||||
"var viewer = $3Dmol.createViewer($(\"#3dmolviewer_146284670035\"),{backgroundColor:\"white\"});\n",
|
||||
"$3Dmol.download(\"pdb:1ycr\", viewer, {}, function() {\n",
|
||||
"\tviewer.setStyle({\"chain\": \"A\"},{\"cartoon\": {\"color\": \"spectrum\"}});\n",
|
||||
"\tviewer.addSurface(1,{\"opacity\": 0.7, \"color\": \"white\"},{\"chain\": \"A\"});\n",
|
||||
"\tviewer.setStyle({\"chain\": \"B\"},{\"stick\": {}});\n",
|
||||
"viewer.render();\n",
|
||||
"})\n",
|
||||
"return {};});\n",
|
||||
"});\n",
|
||||
"</script>"
|
||||
],
|
||||
"text/plain": [
|
||||
@@ -213,23 +201,20 @@
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div id=\"3dmolviewer_146282392339\" style=\"position: relative; width: 640px; height: 480px\">\n",
|
||||
"<div id=\"3dmolviewer_146284670167\" style=\"position: relative; width: 640px; height: 480px\">\n",
|
||||
"<script>\n",
|
||||
"requirejs.config({\n",
|
||||
"\tpaths: {\n",
|
||||
"\t'$3Dmol': ['//3dmol.csb.pitt.edu/build/3Dmol-min'],},\n",
|
||||
"});\n",
|
||||
"require(['$3Dmol'], function($3Dmol) {\n",
|
||||
"var viewer = $3Dmol.createViewer($(\"#3dmolviewer_146282392339\"),{backgroundColor:\"white\"});\n",
|
||||
"if(typeof $3Dmolpromise === 'undefined') $3Dmolpromise = $.when($.getScript('http://3dmol.csb.pitt.edu/build/3Dmol.js'))\n",
|
||||
"$3Dmolpromise.done(function() {\n",
|
||||
"var viewer = $3Dmol.createViewer($(\"#3dmolviewer_146284670167\"),{backgroundColor:\"white\"});\n",
|
||||
"$3Dmol.download(\"pdb:5ire\", viewer, {\"doAssembly\": true}, function() {\n",
|
||||
"\tviewer.setStyle({\"cartoon\": {\"color\": \"spectrum\"}});\n",
|
||||
"viewer.render();\n",
|
||||
"})\n",
|
||||
"return {};});\n",
|
||||
"});\n",
|
||||
"</script>"
|
||||
],
|
||||
"text/plain": [
|
||||
"<py3Dmol.view at 0x7f48b43a5510>"
|
||||
"<py3Dmol.view at 0x7fc6d81d9e10>"
|
||||
]
|
||||
},
|
||||
"execution_count": 8,
|
||||
|
||||
@@ -17,7 +17,7 @@ class view(object):
|
||||
the exception that the functions all return None.
|
||||
http://3dmol.csb.pitt.edu/doc/$3Dmol.GLViewer.html
|
||||
'''
|
||||
def __init__(self,width=640,height=480,query='',options=dict(),js='3dmol.csb.pitt.edu/build/3Dmol-min.js'):
|
||||
def __init__(self,width=640,height=480,query='',options=dict(),js='http://3dmol.csb.pitt.edu/build/3Dmol.js'):
|
||||
'''Create a 3Dmol.js view.
|
||||
width -- width in pixels of container
|
||||
height -- height in pixels of container
|
||||
@@ -30,10 +30,11 @@ class view(object):
|
||||
self.startjs += '<script>\n'
|
||||
self.endjs = '</script>';
|
||||
|
||||
#load 3dmol with requirejs
|
||||
self.startjs += "requirejs.config({\n\tpaths: {\n\t'$3Dmol': ['//%s'],},\n});\n" % js.rstrip('.js')
|
||||
self.startjs += "require(['$3Dmol'], function(mol) {\n";
|
||||
self.endjs = "return {};});\n" + self.endjs;
|
||||
#load 3dmol, but only once
|
||||
self.startjs += "if(typeof $3Dmolpromise === 'undefined') $3Dmolpromise = $.when($.getScript('%s'))\n" % js
|
||||
|
||||
self.startjs += "$3Dmolpromise.done(function() {\n";
|
||||
self.endjs = "});\n" + self.endjs
|
||||
|
||||
self.startjs += 'var viewer = $3Dmol.createViewer($("#%s"),{backgroundColor:"white"});\n' % divid
|
||||
if query:
|
||||
|
||||
Reference in New Issue
Block a user