A JupyterLab extension for rendering JSCAD geometries. Designed to work with IJavascript kernel.
JSCAD is a set of tools for creating parametric 2D and 3D designs with Javascript code.
- JupyterLab >= 3.0
Download the .whl
from the Release page.
pip install [path to downloaded .whl file]
jupyterlab-jscad runs as a MIME renderer extension of JupyterLab.
To render JSCAD geometries in IJavascript:
let jscad = require("@jscad/modeling") // @jscad/modeling has been installed globally, with NODE_PATH environment variable set
let { cube } = jscad.primitives
$$.mime({
"application/jscad-geom": {
geom: cube({ size: 10 }), // <--- feed output geometries here
saveCamera: true, // <--- save camera position
useLastCamera: true, // <--- use last saved camera position
// minHeight: 300, // <--- set minimum height of the canvas to 300
// height: 300 // <--- force the height of canvas to be 300
}
})
// If you don't want such a ceremony, you can define
function jscad_show(geom) {
$$.mime({
"application/jscad-geom": {
geom, // <--- feed output geometries here
saveCamera: true, // <--- save camera position
useLastCamera: true, // <--- use last saved camera position
}
});
}
// ... and call
jscad_show(cube({ size: 10 }))
jlpm install
jlpm run build
jupyter labextension install . --no-build
See tutorials at https://jupyterlab.readthedocs.io/en/stable/extension/extension_tutorial.html and https://github.com/jupyterlab/jupyterlab-mp4/blob/master/tutorial.md
This project was mainly motivated by danmarshall/jscad-now.
The idea of using MIME renderer was learned from n-riesco/ijavascript-plotly.
Given that comm
feature haven't been implemented in IJavascript, this would be probably the most straight-forward approach in rendering a model.
The structure of this project is based on examples in jupyterlab/jupyter-renderers.