diff --git a/.travis.yml b/.travis.yml index 2351c39d..4e27a765 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ language: python services: - xvfb before_install: - - nvm install 12.14 + - nvm install 16.15 before_script: - pip install vtk pixelmatch flask msgpack webdriver_manager selenium scikit-image jupyterlab - npm install webpack webpack-cli -g diff --git a/docs/source/conf.py b/docs/source/conf.py index d0fa3deb..35152226 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -26,6 +26,7 @@ import json from os.path import dirname from source.k3d_directives.plot import K3D_Plot +import shutil here = os.path.dirname(__file__) docs = dirname(dirname(__file__)) @@ -210,9 +211,16 @@ def setup(app): + shutil.copy('./../js/dist/standalone.js', './source/_static/standalone.js') + shutil.copy('./../node_modules/requirejs/require.js', './source/_static/require.js') + try: app.add_stylesheet('style.css') + app.add_javascript('require.js') + app.add_javascript('standalone.js?k3d') except AttributeError: app.add_css_file('style.css') + app.add_js_file('require.js') + app.add_js_file('standalone.js?k3d') app.add_directive('k3d_plot', K3D_Plot) diff --git a/js/package.json b/js/package.json index 8dfa9726..a7166545 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "k3d", - "version": "2.14.0", + "version": "2.14.1", "description": "3D visualization library", "author": "k3d team", "main": "src/index.js", @@ -25,50 +25,49 @@ }, "devDependencies": { "components-webfontloader": "1.5.2", - "copy-webpack-plugin": "^9.0.0", + "copy-webpack-plugin": "^11.0.0", "cors": "2.8.5", - "css-loader": "^5.2.5", - "eslint": "^7.2.0", - "eslint-config-airbnb-base": "^14.2.1", - "eslint-plugin-import": "^2.25.2", + "css-loader": "^6.7.1", + "style-loader": "^3.3.1", + "eslint": "^8.16.0", + "eslint-config-airbnb-base": "^15.0.0", + "eslint-plugin-import": "^2.26.0", "eslint-plugin-markdown": "^2.2.1", - "express": "^4.17.1", - "grunt": "^1.4.0", - "grunt-contrib-clean": "2.0.0", + "express": "^4.18.1", + "grunt": "^1.5.3", + "grunt-contrib-clean": "2.0.1", "grunt-contrib-connect": "^3.0.0", - "grunt-contrib-jshint": "^3.1.1", + "grunt-contrib-jshint": "^3.2.0", "grunt-contrib-watch": "^1.1.0", "grunt-curl": "^2.5.1", - "grunt-eslint": "^23.0.0", + "grunt-eslint": "^24.0.0", "grunt-express-server": "0.5.4", "grunt-jsdoc": "2.4.1", "grunt-open": "^0.2.4", - "grunt-webpack": "^4.0.3", + "grunt-webpack": "^5.0.0", "jshint-stylish": "^2.2.1", - "json-loader": "^0.5.4", + "json-loader": "^0.5.7", "load-grunt-tasks": "5.1.0", "time-grunt": "2.0.0", - "webpack": "^5.60.0", - "webpack-cli": "^4.9.1", + "webpack": "^5.72.1", + "webpack-cli": "^4.9.2", "webpack-combine-loaders": "^2.0.4", "webpack-node-externals": "^3.0.0", "webpack-visualizer-plugin2": "^1.0.0" }, "dependencies": { - "@jupyter-widgets/base": "^4.0.0", - "lil-gui": "^0.16.0", - "es6-promise": "^4.2.8", - "fflate": "^0.7.1", + "@jupyter-widgets/base": "^4.1.0", + "lil-gui": "^0.16.1", + "fflate": "^0.7.3", "file-saver": "^2.0.5", - "katex": "^0.13.19", + "katex": "^0.15.6", "lodash": "^4.17.21", "msgpack-lite": "^0.1.26", - "rasterizehtml": "^1.3.0", + "rasterizehtml": "^1.3.1", "requirejs": "^2.3.6", - "screenfull": "^5.1.0", + "screenfull": "^6.0.1", "stats.js": "^0.17.0", - "style-loader": "^2.0.0", - "three": "^0.138.2", - "three-mesh-bvh": "^0.3.7" + "three": "^0.140.2", + "three-mesh-bvh": "^0.5.11" } } diff --git a/js/src/core/lib/fullscreen.js b/js/src/core/lib/fullscreen.js index dccacd68..1d8ac611 100644 --- a/js/src/core/lib/fullscreen.js +++ b/js/src/core/lib/fullscreen.js @@ -1,4 +1,4 @@ -const screenfull = require('screenfull'); +const screenfull = require('screenfull').default; function fullscreenGUI(container, gui, currentWindow) { const obj = { diff --git a/js/src/core/lib/snapshot_inline.txt b/js/src/core/lib/snapshot_inline.txt index cc8b50ab..4c42dd43 100644 --- a/js/src/core/lib/snapshot_inline.txt +++ b/js/src/core/lib/snapshot_inline.txt @@ -13,38 +13,50 @@ } function loadK3D() { - loadScript('https://unpkg.com/k3d@[VERSION]/dist/standalone.js', function () { - require(['k3d'], function (lib) { - function _base64ToArrayBuffer(base64) { - var binary_string = window.atob(base64); - var len = binary_string.length; - var bytes = new Uint8Array(len); - for (var i = 0; i < len; i++) { - bytes[i] = binary_string.charCodeAt(i); - } - return bytes; + function load(lib) { + function _base64ToArrayBuffer(base64) { + var binary_string = window.atob(base64); + var len = binary_string.length; + var bytes = new Uint8Array(len); + for (var i = 0; i < len; i++) { + bytes[i] = binary_string.charCodeAt(i); } + return bytes; + } - try { - document.getElementById('canvasTarget_[ID]').style.cssText = [ - `height:[HEIGHT]px`, - 'position: relative', - ].join(';'); - - K3DInstance = new lib.CreateK3DAndLoadBinarySnapshot( - _base64ToArrayBuffer(data_[ID]), - document.getElementById('canvasTarget_[ID]'), - ); - - K3DInstance.then(function (K3DInstance) { - [ADDITIONAL] - }); - } catch (e) { - console.log(e); - return; - } - }); - }); + try { + document.getElementById('canvasTarget_[ID]').style.cssText = [ + `height:[HEIGHT]px`, + 'position: relative', + ].join(';'); + + K3DInstance = new lib.CreateK3DAndLoadBinarySnapshot( + _base64ToArrayBuffer(data_[ID]), + document.getElementById('canvasTarget_[ID]'), + ); + + K3DInstance.then(function (K3DInstance) { + [ADDITIONAL] + }); + } catch (e) { + console.log(e); + return; + } + } + + require(['k3d'], + load, + function () { + loadScript('https://unpkg.com/k3d@[VERSION]/dist/standalone.js', function () { + try { + delete require.s.contexts._.registry.k3d; + } catch(err) { + console.log(err); + } + + require(['k3d'], load); + }); + }); } if (typeof (require) === 'undefined') { diff --git a/js/src/development.js b/js/src/development.js index 79c15c8d..b649fbcb 100644 --- a/js/src/development.js +++ b/js/src/development.js @@ -1,4 +1,3 @@ -require('es6-promise'); require('katex/dist/katex.min.css'); require('lil-gui/dist/lil-gui.css'); diff --git a/js/src/k3d.js b/js/src/k3d.js index 5bcdf911..acdfb4cd 100644 --- a/js/src/k3d.js +++ b/js/src/k3d.js @@ -15,8 +15,6 @@ const objectsList = {}; const chunkList = {}; const plotsList = []; -require('es6-promise'); - function runOnEveryPlot(id, cb) { plotsList.forEach((plot) => { if (plot.model.get('object_ids').indexOf(id) !== -1) { diff --git a/js/src/providers/threejs/objects/Voxels.js b/js/src/providers/threejs/objects/Voxels.js index 7ef5eb5b..4a3740ca 100644 --- a/js/src/providers/threejs/objects/Voxels.js +++ b/js/src/providers/threejs/objects/Voxels.js @@ -13,7 +13,7 @@ module.exports = { create(config, K3D) { return VoxelsHelper.create( config, - VoxelsHelper.generateRegularChunks(27, config.voxels.shape, config.voxels.data), + VoxelsHelper.generateRegularChunks(96, config.voxels.shape, config.voxels.data), [config.voxels.shape[2], config.voxels.shape[1], config.voxels.shape[0]], K3D, ); diff --git a/k3d/factory.py b/k3d/factory.py index b8aea6e0..f4420674 100644 --- a/k3d/factory.py +++ b/k3d/factory.py @@ -1816,6 +1816,7 @@ def plot( camera_pan_speed=0.3, camera_damping_factor=0.0, fps=25.0, + fps_meter=False, name=None, custom_data=None ): @@ -1932,5 +1933,6 @@ def plot( camera_pan_speed=camera_pan_speed, auto_rendering=auto_rendering, fps=fps, + fps_meter=fps_meter, custom_data=custom_data ) diff --git a/k3d/test/references/voxels_box.png b/k3d/test/references/voxels_box.png index 29640039..b1d96c5f 100644 Binary files a/k3d/test/references/voxels_box.png and b/k3d/test/references/voxels_box.png differ diff --git a/k3d/test/references/voxels_outline.png b/k3d/test/references/voxels_outline.png index 2f95a12d..f9a8e556 100644 Binary files a/k3d/test/references/voxels_outline.png and b/k3d/test/references/voxels_outline.png differ diff --git a/k3d/test/references/voxels_outline_clipping_plane.png b/k3d/test/references/voxels_outline_clipping_plane.png index 8fa60f84..feaad5c4 100644 Binary files a/k3d/test/references/voxels_outline_clipping_plane.png and b/k3d/test/references/voxels_outline_clipping_plane.png differ diff --git a/k3d/test/references/voxels_outline_dynamic_outlines_color.png b/k3d/test/references/voxels_outline_dynamic_outlines_color.png index c47ce460..3a384b2d 100644 Binary files a/k3d/test/references/voxels_outline_dynamic_outlines_color.png and b/k3d/test/references/voxels_outline_dynamic_outlines_color.png differ diff --git a/k3d/test/references/voxels_outline_opacity.png b/k3d/test/references/voxels_outline_opacity.png index f5b6e395..f5280594 100644 Binary files a/k3d/test/references/voxels_outline_opacity.png and b/k3d/test/references/voxels_outline_opacity.png differ diff --git a/k3d/test/references/voxels_wireframe.png b/k3d/test/references/voxels_wireframe.png index 47f55903..8c4ee8c0 100644 Binary files a/k3d/test/references/voxels_wireframe.png and b/k3d/test/references/voxels_wireframe.png differ diff --git a/package.json b/package.json index bd74fad9..37cee264 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "k3d", - "version": "2.14.0", + "version": "2.14.1", "description": "3D visualization library", "keywords": [ "jupyter", @@ -40,25 +40,24 @@ }, "dependencies": { "@jupyter-widgets/base": "^4.1.0", - "es6-promise": "^4.2.8", - "fflate": "^0.7.1", + "fflate": "^0.7.3", "file-saver": "^2.0.5", - "katex": "^0.13.19", - "lil-gui": "^0.16.0", + "katex": "^0.15.6", + "lil-gui": "^0.16.1", "lodash": "^4.17.21", "msgpack-lite": "^0.1.26", - "rasterizehtml": "^1.3.0", + "rasterizehtml": "^1.3.1", "requirejs": "^2.3.6", - "screenfull": "^5.1.0", + "screenfull": "^6.0.1", "stats.js": "^0.17.0", - "style-loader": "^2.0.0", - "three": "^0.138.2", - "three-mesh-bvh": "^0.3.7" + "three": "^0.140.2", + "three-mesh-bvh": "^0.5.11" }, "devDependencies": { - "@jupyterlab/builder": "^3.4.1", - "prettier": "^2.4.1", - "rimraf": "^3.0.2" + "@jupyterlab/builder": "^3.4.2", + "prettier": "^2.6.2", + "rimraf": "^3.0.2", + "style-loader": "^3.3.1" }, "jupyterlab": { "extension": true,