The CSG module enables working with Constructive Solid Geometry in the Source
Academy. Users are able to program colored 3D models and interact with them
in a tab.
The main objects in use are called Shapes. Users can create, operate on,
transform, and finally render these Shapes.
There are also Groups, which contain Shapes, but can also contain other
nested Groups. Groups allow many Shapes to be transformed in tandem, as
opposed to having to call transform functions on each Shape individually.
An object that is either a Shape or a Group is called an Operable. Operables
as a whole are stateless, which means that passing them into functions does
not modify the original Operable; instead, the newly created Operable is
returned. Therefore, it is safe to reuse existing Operables after passing
them into functions, as they remain immutable.
When you are done modeling your Operables, pass them to one of the CSG
rendering functions to have them displayed in a tab.
When rendering, you may optionally render with a grid and/or axes displayed,
depending on the rendering function used. The grid appears on the XY-plane
with white lines every 1 unit of distance, and slightly fainter lines every
0.25 units of distance. The axes for x, y, and z are coloured red, green, and
blue respectively. The positive z direction is upwards from the flat plane
(right-handed coordinate system).
The CSG module enables working with Constructive Solid Geometry in the Source Academy. Users are able to program colored 3D models and interact with them in a tab.
The main objects in use are called Shapes. Users can create, operate on, transform, and finally render these Shapes.
There are also Groups, which contain Shapes, but can also contain other nested Groups. Groups allow many Shapes to be transformed in tandem, as opposed to having to call transform functions on each Shape individually.
An object that is either a Shape or a Group is called an Operable. Operables as a whole are stateless, which means that passing them into functions does not modify the original Operable; instead, the newly created Operable is returned. Therefore, it is safe to reuse existing Operables after passing them into functions, as they remain immutable.
When you are done modeling your Operables, pass them to one of the CSG rendering functions to have them displayed in a tab.
When rendering, you may optionally render with a grid and/or axes displayed, depending on the rendering function used. The grid appears on the XY-plane with white lines every 1 unit of distance, and slightly fainter lines every 0.25 units of distance. The axes for x, y, and z are coloured red, green, and blue respectively. The positive z direction is upwards from the flat plane (right-handed coordinate system).
More samples can be found at: https://github.com/source-academy/modules/tree/master/src/bundles/csg/samples
Author
Joel Leow
Author
Liu Muchen
Author
Ng Yin Joe
Author
Yu Chenbo