Skip to content

Commit

Permalink
add pythreejs demo
Browse files Browse the repository at this point in the history
  • Loading branch information
scottdraves committed Jun 12, 2018
1 parent 4520316 commit d3f89a8
Showing 1 changed file with 72 additions and 3 deletions.
75 changes: 72 additions & 3 deletions doc/groovy/3D.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
"source": [
"# 3D Visualization and Maps\n",
"\n",
"Ipyvolume and pythreejs demos are below. These require separately installing these widgets.\n",
"[Ipyleaflet](https://github.com/jupyter-widgets/ipyleaflet) will be forthcoming, see [#6903](https://github.com/twosigma/beakerx/issues/6903). We hope these APIs will be included upstream in the original widget repositories.\n",
"\n",
"## ipyvolume\n",
"\n",
"There is an alpha Groovy API for [ipyvolume](https://github.com/maartenbreddels/ipyvolume). For this to work, the widget JS needs to be installed:\n",
"```\n",
"conda install -c conda-forge ipyvolume\n",
"```\n",
"\n",
"[Pythreejs](https://github.com/jupyter-widgets/pythreejs) and [ipyleaflet](https://github.com/jupyter-widgets/ipyleaflet) will be forthcoming, see [#6903](https://github.com/twosigma/beakerx/issues/6903). We hope these APIs will be included upstream in the original widget repositories."
"```"
]
},
{
Expand Down Expand Up @@ -46,6 +49,59 @@
"\n",
"figure = PyLab.volShow(data)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## pythreejs\n",
"\n",
"There is an alpha Groovy API for [pythreejs](https://github.com/jupyter-widgets/pythreejs). For this to work, the widget JS needs to be installed:\n",
"```\n",
"conda install -c conda-forge pythreejs\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%classpath config resolver jitpack.io https://jitpack.io\n",
"%classpath add mvn com.github.lmitusinski:pythreejs:lmitusinski~demo-SNAPSHOT"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pythreejs.*\n",
"\n",
"f = \"function f(origu,origv) {\\n\" +\n",
" \" // scale u and v to the ranges I want: [0, 2*pi]\\n\" +\n",
" \" var u = 2*Math.PI*origu;\\n\" +\n",
" \" var v = 2*Math.PI*origv;\\n\" +\n",
" \" \\n\" +\n",
" \" var x = Math.sin(u);\\n\" +\n",
" \" var y = Math.cos(v);\\n\" +\n",
" \" var z = Math.cos(u+v);\\n\" +\n",
" \" \\n\" +\n",
" \" return new THREE.Vector3(x,y,z)\\n\" +\n",
" \"}\"\n",
"surf_g = new ParametricGeometry(func: f, slices: 16, stacks: 16);\n",
"\n",
"surf = new Mesh(geometry: surf_g, material: new MeshLambertMaterial(color: 'green', side: 'FrontSide'))\n",
"surf2 = new Mesh(geometry: surf_g, material: new MeshLambertMaterial(color: 'yellow', side: 'BackSide'))\n",
"c = new PerspectiveCamera(position: [5, 5, 3], up: [0, 0, 1],\n",
" children: [new DirectionalLight(color: 'white',\n",
" position: [3, 5, 1],\n",
" intensity: 0.6d)])\n",
"scene = new Scene(children: [surf, surf2, c, new AmbientLight(intensity: 0.5d)])\n",
"renderer = new Renderer(camera: c, scene: scene, controls: [new OrbitControls(controlling: c)], _width: 400, _height: 400)"
]
}
],
"metadata": {
Expand All @@ -63,6 +119,19 @@
"name": "Groovy",
"nbconverter_exporter": "",
"version": "2.4.3"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": false,
"sideBar": false,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": false,
"toc_window_display": false
}
},
"nbformat": 4,
Expand Down

0 comments on commit d3f89a8

Please sign in to comment.