ipyvolume icon indicating copy to clipboard operation
ipyvolume copied to clipboard

BUGFIX: offline=True kwarg in embed_html was failing to save dependency jupyter-threejs.js

Open GenevieveBuckley opened this issue 5 years ago • 2 comments

This PR adds a function save_jupyterthreejs to embed.py to download and save the jupyter-threejs.js dependency required for offline viewing of ipyvolume html files.

Closes https://github.com/maartenbreddels/ipyvolume/issues/192

The offline=True kwarg in ipyvolume.embed.embed_html() has been failing to save the file at https://unpkg.com/[email protected]/dist/index.js locally as js/jupyter-threejs.js Copying that file manually into js/jupyter-threejs.js fixes the issue and allows offline viewing.

GenevieveBuckley avatar Nov 01 '18 00:11 GenevieveBuckley

As it is now, threejs is embeded in jupyter-threejs's embed.js, although it shouldn't, and it is actually configured using require's path in https://github.com/jupyter-widgets/pythreejs/blob/master/js/src/embed.js @vidartf 's plan is to test making threejs external, exposing the semver version in the Python package, and then we know if it works. Also, ipyvolume should do the same, make the threejs external, and copy the config of https://github.com/jupyter-widgets/pythreejs/blob/master/js/src/embed.js

@GenevieveBuckley it might be that the PR as it is now is working, can you confirm that? ipyvolume and jupyter-threejs have their own version of threejs, which is non-ideal, but if it works, it works.

maartenbreddels avatar Nov 08 '18 10:11 maartenbreddels

Yes, I can confirm that it works for these circumstances:

python version 3.6.6 jupyter notebook 5.7.0 ipywidgets version 7.4.2 ipyvolume developmernt installation 0.5.2-dev.1

I tested using this code while connected to the internet (writing to file won't work if you're not connected):

import numpy as np
import ipyvolume as ipv

y = np.random.randn(1000)
x = np.random.randn(1000)
z = np.random.randn(1000)

fig = ipv.figure()
ipv.scatter(x, y, z)
ipv.embed.embed_html('offline_test.html', fig, offline=True, devmode=True)

Once offline, reading the file is successful across all browsers I have available:

  • Chrome version 70.0.3538.77 (Official Build) (64-bit)
  • Firefox version 63.0.1 (64-bit)
  • Safari version 12.0.1 (14606.2.104.1.1)

GenevieveBuckley avatar Nov 16 '18 04:11 GenevieveBuckley