|
1 |
| -pythreejs |
2 |
| -========= |
| 1 | +# pythreejs |
3 | 2 |
|
4 |
| -This is a _significant_ re-work of the pythreejs extension that introduces an "autogen" script that generates the majority of the ipython-widget code to wrap each of three.js's types. It also takes a different view towards the pythreejs API. Whereas pythreejs adds custom functionality to the classes, sometimes renaming, etc., this approach attempts to mimic the low-level three.js API as closely as possible, opening up the possibility for others to build utility libraries on top of this. |
5 | 3 |
|
6 |
| -This branch does not support all the functionality of the current pythreejs, but it is a significant step forward in terms of the potential to support the majority of three.js's features. Currently supported features: |
7 |
| -- Basic building blocks of a scene: |
8 |
| - - Textures (both Image-based and Data-based) |
9 |
| - - Materials |
10 |
| - - Geometries |
11 |
| - - Meshs |
12 |
| - - Scene, Lights, Cameras, WebGLRenderer |
| 4 | +## Getting Started |
| 5 | + |
| 6 | +### Try it online with [Binder](http://mybinder.org/) |
| 7 | + |
| 8 | +[](http://mybinder.org:/repo/jovyan/pythreejs/notebooks/examples) |
| 9 | + |
| 10 | +### Installation |
| 11 | + |
| 12 | +Using pip: |
| 13 | + |
| 14 | +```bash |
| 15 | +pip install pythreejs |
| 16 | +jupyter nbextension install --py --symlink --sys-prefix pythreejs |
| 17 | +jupyter nbextension enable --py --sys-prefix pythreejs |
| 18 | +``` |
| 19 | + |
| 20 | +Note for developers: the `--symlink` argument on Linux or OS X allows one to |
| 21 | +modify the JavaScript code in-place. This feature is not available |
| 22 | +with Windows. |
| 23 | + |
| 24 | +Using conda |
| 25 | + |
| 26 | +```bash |
| 27 | +conda install -c conda-forge pythreejs |
| 28 | +``` |
| 29 | + |
13 | 30 |
|
14 |
| ---- |
| 31 | +## Developers |
| 32 | + |
| 33 | +### Autogen |
| 34 | + |
| 35 | +This is a _significant_ re-work of the pythreejs extension that introduces an "autogen" script that generates the majority of the ipython-widget code to wrap each of three.js's types. It also takes a different view towards the pythreejs API. Whereas pythreejs adds custom functionality to the classes, sometimes renaming, etc., this approach attempts to mimic the low-level three.js API as closely as possible, opening up the possibility for others to build utility libraries on top of this. |
15 | 36 |
|
16 | 37 | The autogen script, `generate-wrappers.js`, takes advantage of a config file `three-class-config.js` to auto-generate both javascript and python files to define the ipywidget wrappers for each three.js class. The generated javascript files will have `.autogen.js` as the extension. The generated python files have `_autogen.py` as their extension. The script uses the handlebars template system to generate the various code files.
|
17 | 38 |
|
18 | 39 | The autogen solution allows for overriding the default behavior of the generated classes. E.g., if `Object3D.js` is present, then it will be loaded into the namespace as opposed to loading `Object3D.autogen.js`. It is up to the author of the override classe to decide whether to inherit behavior from the autogen class or not. Same goes for the python modules. This allows for writing custom methods on both the python and javascript side when needed.
|
19 | 40 |
|
20 | 41 | The autogen script relies on a json-like config file (`three-class-config.js`) to describe the classes. Reasonable defaults should take care of most, but it allows specifying the base class, constructor args, etc. for each of the wrappers. A base version of this file can be generated by `generate-class-config.js`, but beware, it overwrites any customization to the config file that has already been done.
|
21 | 42 |
|
22 |
| -## Setup |
| 43 | +#### Setup |
23 | 44 |
|
24 |
| -``` |
| 45 | +```bash |
25 | 46 | # Initial setup
|
26 | 47 | cd js
|
27 | 48 | npm install
|
28 | 49 |
|
29 | 50 | # Generate files
|
30 | 51 | npm run autogen
|
| 52 | +pip install -e . |
31 | 53 |
|
32 | 54 | # Build distribution files
|
33 | 55 | npm run build
|
| 56 | +jupyter nbextension install --py --symlink --sys-prefix pythreejs |
34 | 57 |
|
35 | 58 | # Clean out generated files
|
36 | 59 | npm run clean
|
| 60 | + |
37 | 61 | ```
|
38 | 62 |
|
39 | 63 | List of relevant files:
|
40 | 64 |
|
41 |
| -``` |
| 65 | +```bash |
42 | 66 | js/package.json
|
43 | 67 | js/webpack.config.js
|
44 | 68 |
|
@@ -92,43 +116,3 @@ js/src/examples/controls/TrackballControls.js
|
92 | 116 | js/src/examples/renderers/CanvasRenderer.js
|
93 | 117 | js/src/examples/renderers/Projector.js
|
94 | 118 | ```
|
95 |
| - |
96 |
| - |
97 |
| -TODO: Everything below here is probably outdated. |
98 |
| - |
99 |
| -Getting Started |
100 |
| ---------------- |
101 |
| - |
102 |
| -### Try it online with [Binder](http://mybinder.org/) |
103 |
| - |
104 |
| -[](http://mybinder.org:/repo/jovyan/pythreejs/notebooks/examples) |
105 |
| - |
106 |
| -Installation |
107 |
| ------------- |
108 |
| - |
109 |
| -Using pip: |
110 |
| - |
111 |
| -``` |
112 |
| -pip install pythreejs |
113 |
| -jupyter nbextension enable --py --sys-prefix pythreejs |
114 |
| -``` |
115 |
| - |
116 |
| -Using conda |
117 |
| - |
118 |
| -``` |
119 |
| -$ conda install -c conda-forge pythreejs |
120 |
| -``` |
121 |
| - |
122 |
| -For a development installation (requires npm): |
123 |
| - |
124 |
| -``` |
125 |
| -$ git clone https://github.com/jovyan/pythreejs.git |
126 |
| -$ cd pythreejs |
127 |
| -$ pip install -e . |
128 |
| -$ jupyter nbextension install --py --symlink --sys-prefix pythreejs |
129 |
| -$ jupyter nbextension enable --py --sys-prefix pythreejs |
130 |
| -``` |
131 |
| - |
132 |
| -Note for developers: the `--symlink` argument on Linux or OS X allows one to |
133 |
| -modify the JavaScript code in-place. This feature is not available |
134 |
| -with Windows. |
0 commit comments