diff --git a/src/sage/plot/plot3d/base.pyx b/src/sage/plot/plot3d/base.pyx
index 688dfbd255f..36ec4d36247 100644
--- a/src/sage/plot/plot3d/base.pyx
+++ b/src/sage/plot/plot3d/base.pyx
@@ -377,28 +377,14 @@ cdef class Graphics3d(SageObject):
options['online'] = True
if options['online']:
- scripts = ( """
-
-
- """ )
+ from sage.misc.package import installed_packages
+ version = installed_packages()['threejs']
+ scripts = """
+
+
+ """.format(version)
else:
- from sage.repl.rich_output.backend_ipython import BackendIPythonNotebook
- if isinstance(backend, BackendIPythonNotebook):
- scripts = ( """
-
-
-
- """ )
- else:
- from sage.env import SAGE_SHARE
- scripts = ( """
-
-
- """.format( SAGE_SHARE ) )
+ scripts = backend.threejs_offline_scripts()
b = self.bounding_box()
bounds = '[{{"x":{}, "y":{}, "z":{}}}, {{"x":{}, "y":{}, "z":{}}}]'.format(
diff --git a/src/sage/repl/rich_output/backend_ipython.py b/src/sage/repl/rich_output/backend_ipython.py
index e5e85105df8..fa98be8bb0b 100644
--- a/src/sage/repl/rich_output/backend_ipython.py
+++ b/src/sage/repl/rich_output/backend_ipython.py
@@ -396,6 +396,24 @@ def is_in_terminal(self):
"""
return True
+ def threejs_offline_scripts(self):
+ """
+ Three.js offline scripts for the IPython command line
+
+ EXAMPLES::
+
+ sage: from sage.repl.rich_output.backend_ipython import BackendIPythonCommandline
+ sage: backend = BackendIPythonCommandline()
+ sage: backend.threejs_offline_scripts()
+ '...
+
+ """.format(SAGE_SHARE)
+
+
IFRAME_TEMPLATE = \
"""
@@ -554,4 +572,25 @@ def displayhook(self, plain_text, rich_output):
else:
raise TypeError('rich_output type not supported')
-
+ def threejs_offline_scripts(self):
+ """
+ Three.js offline scripts for the IPython notebook
+
+ EXAMPLES::
+
+ sage: from sage.repl.rich_output.backend_ipython import BackendIPythonNotebook
+ sage: backend = BackendIPythonNotebook()
+ sage: backend.threejs_offline_scripts()
+ '...
+
+
+ """.format(version)