|
| 1 | +============= |
| 2 | +Introduction |
| 3 | +============= |
| 4 | + |
| 5 | +The pythreejs API attempts to mimic the three.js API as closely as possible, so |
| 6 | +any resource on its API should also be helpful for understanding pythreejs. See for |
| 7 | +example the `official three.js documentation`_. |
| 8 | + |
| 9 | +The major difference between the two is the render loop. As we normally do not |
| 10 | +want to call back to the kernel for every rendered frame, some helper classes |
| 11 | +have been created to allow for user interaction with the scene with minimal |
| 12 | +overhead: |
| 13 | + |
| 14 | + |
| 15 | +Renderer classes |
| 16 | +---------------- |
| 17 | +While the :py:class:`~pythreejs.WebGLRenderer` class mimics its three.js |
| 18 | +counterpart in only rendering frames on demand (one frame per call to its |
| 19 | +:py:meth:`~pythreejs.WebGLRenderer.render` method), the :py:class:`~pythreejs.Renderer` class |
| 20 | +sets up an interactive render loop allowing for `interactive controls`_ and `animation`_. |
| 21 | +Similarly, a :py:class:`~pythreejs.Preview` widget allows for a quick visualization of various |
| 22 | +threejs objects. |
| 23 | + |
| 24 | + |
| 25 | +.. _interactive controls: |
| 26 | + |
| 27 | +Interactive controls |
| 28 | +-------------------- |
| 29 | +These are classes for managing user interaction with the WebGL canvas, |
| 30 | +and translating that into actions. One example is the :py:class:`~pythreejs.OrbitControls` |
| 31 | +class, which allows the user to control the camera by zooming, panning, and orbital rotation |
| 32 | +around a target. Another example is the :py:class:`~pythreejs.Picker` widget, which allows |
| 33 | +for getting the objects and surface coordinates underneath the mouse cursor. |
| 34 | + |
| 35 | + |
| 36 | +.. _animation: |
| 37 | + |
| 38 | +Animation views |
| 39 | +--------------- |
| 40 | +The view widgets for the :py:class:`~pythreejs.AnimationAction` class |
| 41 | +gives interactive controls to the user for controlling a `threejs animation`_. |
| 42 | + |
| 43 | + |
| 44 | +------- |
| 45 | + |
| 46 | + |
| 47 | +Other notable deviations from the threejs API are listed below: |
| 48 | + |
| 49 | +- Buffers are based on `numpy arrays`_, with their inbuilt knowledge of shape and dtype. |
| 50 | + As such, most threejs APIs that take a buffer is slightly modified (fewer options need |
| 51 | + to be specified explicitly). |
| 52 | + |
| 53 | +- The generative geometry objects (e.g. :py:class:`~pythreejs.SphereGeometry` and |
| 54 | + :py:class:`~pythreejs.BoxBufferGeometry`) do not sync their vertices or similar data |
| 55 | + by default. To gain acess to the generated data, convert them to either the |
| 56 | + :py:class:`~pythreejs.Geometry` or :py:class:`~pythreejs.BufferGeometry` type with |
| 57 | + the :py:meth:`~pythreejs.BufferGeometry.from_ref` factory method. See the method |
| 58 | + documentation for further details. |
| 59 | + |
| 60 | +- Methods are often not mirrored to the Python side. However, they can be |
| 61 | + executed with the :py:meth:`~pythreejs.ThreeWidget.exec_three_obj_method` method. |
| 62 | + Consider contributing |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | +.. links |
| 67 | +
|
| 68 | +.. _`official three.js documentation`: https://threejs.org/docs/ |
| 69 | + |
| 70 | +.. _`threejs animation`: https://threejs.org/docs/#manual/introduction/Animation-system |
| 71 | + |
| 72 | +.. _`numpy arrays`: https://www.numpy.org/ |
0 commit comments