SpeckleLoader is an example of such loader that specialises on loading speckle data.
If we take a look at how the viewer loads data:
Loader object that we specify.
The Loader class is abstract and intentionally thin:
- Populate the viewer’s
WorldTreewith nodes - Convert renderable incoming data into types the viewer can understand
- Build a
RenderTree
Converter which takes in raw data, and builds and adds tree nodes to the tree.
Once the tree is populated, we need a way to turn renderable information contained in the tree in any form it may be in, to something that the viewer understands how to render. This is where the GeometryConverter comes in. It’s a thin abstract class again and any geometry converter needs to implement the following:
convertNodeToGeometryData which takes tree nodes and builds GeometryData objects for them, which allow the viewer to render the objects correctly.
Once a geometry converter is implemented, you don’t need to call any of it’s method on your own. Everything will be called automatically in step 3, where we build the RenderTree. A RenderTree is simply a subtree of the WorldTree (or the entirety of it) with added rendering-related functionality. In order to build a RenderTree:
Loader and GeometryConverter you can have a look at :
You can run the live example with the OBJLoader here
or below:
OBJ Loader Example