|
1 | 1 | pythreejs
|
2 | 2 | =========
|
3 | 3 |
|
4 |
| -A Python / ThreeJS bridge utilizing the Jupyter widget infrastructure. |
| 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 | + |
| 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 |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +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 | + |
| 18 | +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 | + |
| 20 | +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 | + |
| 22 | +List of relevant files: |
| 23 | + |
| 24 | +``` |
| 25 | +js/package.json |
| 26 | +js/webpack.config.js |
| 27 | +
|
| 28 | +# Files for auto-generation |
| 29 | +js/scripts/clean-generated-files.js |
| 30 | +js/scripts/generate-class-config.js |
| 31 | +js/scripts/generate-wrappers.js |
| 32 | +js/scripts/prop-types.js |
| 33 | +js/scripts/templates/js_index.mustache |
| 34 | +js/scripts/templates/js_param_obj.mustache |
| 35 | +js/scripts/templates/js_wrapper.mustache |
| 36 | +js/scripts/templates/py_top_level_init.mustache |
| 37 | +js/scripts/templates/py_wrapper.mustache |
| 38 | +js/scripts/three-class-config-defaults.js |
| 39 | +js/scripts/three-class-config.js |
| 40 | +js/scripts/three-class-config.js.backup |
| 41 | +
|
| 42 | +# New bases classes for supporting wrapper classes |
| 43 | +js/src/_base/RendererPool.js |
| 44 | +js/src/_base/Three.js |
| 45 | +js/src/_base/enums.js |
| 46 | +pythreejs/_base/Three.py |
| 47 | +pythreejs/enums.py |
| 48 | +pythreejs/traits.py |
| 49 | +
|
| 50 | +# Overridden classes |
| 51 | +js/src/core/Object3D.js |
| 52 | +js/src/textures/DataTexture.js |
| 53 | +js/src/textures/ImageTexture.js # custom classed created to ease image texture loading |
| 54 | +js/src/renderers/WebGLRenderer.js |
| 55 | +pythreejs/core/Object3D.py |
| 56 | +pythreejs/renderers/WebGLRenderer.py |
| 57 | +
|
| 58 | +# Updated examples notesbooks |
| 59 | +examples/Examples.ipynb |
| 60 | +examples/Geometries.ipynb |
| 61 | +examples/Textures.ipynb |
| 62 | +examples/renderer_limit.ipynb |
| 63 | +examples/test.ipynb |
| 64 | +examples/img/checkerboard.png |
| 65 | +examples/img/earth.jpg |
| 66 | +
|
| 67 | +# Pulled in latest version of examples files from three.js source |
| 68 | +js/src/examples/Detector.js |
| 69 | +js/src/examples/controls/MomentumCameraControls.js |
| 70 | +js/src/examples/controls/OrbitControls.js |
| 71 | +js/src/examples/controls/TrackballControls.js |
| 72 | +js/src/examples/js/controls/OrbitControls.js |
| 73 | +js/src/examples/renderers/CanvasRenderer.js |
| 74 | +js/src/examples/renderers/Projector.js |
| 75 | +``` |
5 | 76 |
|
6 |
| - |
7 | 77 |
|
8 | 78 |
|
9 | 79 | Installation
|
|
0 commit comments