Big fixes.

Be more tolerant to losing WebGL context in the middle of rendering
(happens when loading a page with many contexts).   Some more types.
This commit is contained in:
David Koes
2023-06-08 19:57:47 -04:00
parent 50a91e55a4
commit 381da4b862
5 changed files with 28 additions and 21 deletions

View File

@@ -47,7 +47,7 @@
{
"data": {
"text/plain": [
"'2.0.1'"
"'2.0.3'"
]
},
"execution_count": 2,
@@ -68,10 +68,10 @@
"outputs": [
{
"data": {
"application/3dmoljs_load.v0": "<div id=\"3dmolviewer_16760578982848399\" style=\"position: relative; width: 640px; height: 480px\">\n <p id=\"3dmolwarning_16760578982848399\" style=\"background-color:#ffcccc;color:black\">You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension: <br>\n <tt>jupyter labextension install jupyterlab_3dmol</tt></p>\n </div>\n<script>\n\nvar loadScriptAsync = function(uri){\n return new Promise((resolve, reject) => {\n //this is to ignore the existence of requirejs amd\n var savedexports, savedmodule;\n if (typeof exports !== 'undefined') savedexports = exports;\n else exports = {}\n if (typeof module !== 'undefined') savedmodule = module;\n else module = {}\n\n var tag = document.createElement('script');\n tag.src = uri;\n tag.async = true;\n tag.onload = () => {\n exports = savedexports;\n module = savedmodule;\n resolve();\n };\n var firstScriptTag = document.getElementsByTagName('script')[0];\n firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\n});\n};\n\nif(typeof $3Dmolpromise === 'undefined') {\n$3Dmolpromise = null;\n $3Dmolpromise = loadScriptAsync('https://cdnjs.cloudflare.com/ajax/libs/3Dmol/2.0.1/3Dmol-min.js');\n}\n\nvar viewer_16760578982848399 = null;\nvar warn = document.getElementById(\"3dmolwarning_16760578982848399\");\nif(warn) {\n warn.parentNode.removeChild(warn);\n}\n$3Dmolpromise.then(function() {\nviewer_16760578982848399 = $3Dmol.createViewer(document.getElementById(\"3dmolviewer_16760578982848399\"),{backgroundColor:\"white\"});\n$3Dmol.download(\"mmtf:1ycr\", viewer_16760578982848399, {}, function() {\nviewer_16760578982848399.zoomTo();\n\tviewer_16760578982848399.setStyle({\"cartoon\": {\"color\": \"spectrum\"}});\nviewer_16760578982848399.render();\n})\n});\n</script>",
"application/3dmoljs_load.v0": "<div id=\"3dmolviewer_16841544439955416\" style=\"position: relative; width: 640px; height: 480px;\">\n <p id=\"3dmolwarning_16841544439955416\" style=\"background-color:#ffcccc;color:black\">You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension: <br>\n <tt>jupyter labextension install jupyterlab_3dmol</tt></p>\n </div>\n<script>\n\nvar loadScriptAsync = function(uri){\n return new Promise((resolve, reject) => {\n //this is to ignore the existence of requirejs amd\n var savedexports, savedmodule;\n if (typeof exports !== 'undefined') savedexports = exports;\n else exports = {}\n if (typeof module !== 'undefined') savedmodule = module;\n else module = {}\n\n var tag = document.createElement('script');\n tag.src = uri;\n tag.async = true;\n tag.onload = () => {\n exports = savedexports;\n module = savedmodule;\n resolve();\n };\n var firstScriptTag = document.getElementsByTagName('script')[0];\n firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\n});\n};\n\nif(typeof $3Dmolpromise === 'undefined') {\n$3Dmolpromise = null;\n $3Dmolpromise = loadScriptAsync('https://cdnjs.cloudflare.com/ajax/libs/3Dmol/2.0.3/3Dmol-min.js');\n}\n\nvar viewer_16841544439955416 = null;\nvar warn = document.getElementById(\"3dmolwarning_16841544439955416\");\nif(warn) {\n warn.parentNode.removeChild(warn);\n}\n$3Dmolpromise.then(function() {\nviewer_16841544439955416 = $3Dmol.createViewer(document.getElementById(\"3dmolviewer_16841544439955416\"),{backgroundColor:\"white\"});\n$3Dmol.download(\"mmtf:1ycr\", viewer_16841544439955416, {}, function() {\nviewer_16841544439955416.zoomTo();\n\tviewer_16841544439955416.setStyle({\"cartoon\": {\"color\": \"spectrum\"}});\nviewer_16841544439955416.render();\n})\n});\n</script>",
"text/html": [
"<div id=\"3dmolviewer_16760578982848399\" style=\"position: relative; width: 640px; height: 480px\">\n",
" <p id=\"3dmolwarning_16760578982848399\" style=\"background-color:#ffcccc;color:black\">You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension: <br>\n",
"<div id=\"3dmolviewer_16841544439955416\" style=\"position: relative; width: 640px; height: 480px;\">\n",
" <p id=\"3dmolwarning_16841544439955416\" style=\"background-color:#ffcccc;color:black\">You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension: <br>\n",
" <tt>jupyter labextension install jupyterlab_3dmol</tt></p>\n",
" </div>\n",
"<script>\n",
@@ -100,20 +100,20 @@
"\n",
"if(typeof $3Dmolpromise === 'undefined') {\n",
"$3Dmolpromise = null;\n",
" $3Dmolpromise = loadScriptAsync('https://cdnjs.cloudflare.com/ajax/libs/3Dmol/2.0.1/3Dmol-min.js');\n",
" $3Dmolpromise = loadScriptAsync('https://cdnjs.cloudflare.com/ajax/libs/3Dmol/2.0.3/3Dmol-min.js');\n",
"}\n",
"\n",
"var viewer_16760578982848399 = null;\n",
"var warn = document.getElementById(\"3dmolwarning_16760578982848399\");\n",
"var viewer_16841544439955416 = null;\n",
"var warn = document.getElementById(\"3dmolwarning_16841544439955416\");\n",
"if(warn) {\n",
" warn.parentNode.removeChild(warn);\n",
"}\n",
"$3Dmolpromise.then(function() {\n",
"viewer_16760578982848399 = $3Dmol.createViewer(document.getElementById(\"3dmolviewer_16760578982848399\"),{backgroundColor:\"white\"});\n",
"$3Dmol.download(\"mmtf:1ycr\", viewer_16760578982848399, {}, function() {\n",
"viewer_16760578982848399.zoomTo();\n",
"\tviewer_16760578982848399.setStyle({\"cartoon\": {\"color\": \"spectrum\"}});\n",
"viewer_16760578982848399.render();\n",
"viewer_16841544439955416 = $3Dmol.createViewer(document.getElementById(\"3dmolviewer_16841544439955416\"),{backgroundColor:\"white\"});\n",
"$3Dmol.download(\"mmtf:1ycr\", viewer_16841544439955416, {}, function() {\n",
"viewer_16841544439955416.zoomTo();\n",
"\tviewer_16841544439955416.setStyle({\"cartoon\": {\"color\": \"spectrum\"}});\n",
"viewer_16841544439955416.render();\n",
"})\n",
"});\n",
"</script>"
@@ -125,7 +125,7 @@
{
"data": {
"text/plain": [
"<py3Dmol.view at 0x7f93212f3670>"
"<py3Dmol.view at 0x7f21102f4c10>"
]
},
"execution_count": 3,

View File

@@ -23,7 +23,8 @@ setup(
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='2.0.1.post1',
# Keep version in synce with 3Dmol.js version. Use "postX" suffix if needed
version='2.0.3',
description='An IPython interface for embedding 3Dmol.js views in Jupyter notebooks',
long_description=long_description,