Back to the Shapespark home page

Load object from GLB file

Is it possible to add a new Node to the Viewer? I’m looking to position an object from a GLB file and control its animations from javascript.

It is not possible to add new nodes after the scene is loaded.

Can it be done before ?

So far I’ve loaded the file into a separate scene created with three.js, and it works well, including animating the object.
I then tried to add my object to the Shapespark scene found in the viewer.onSceneReadyToDisplay callback arguments. However calling scene.add results in an error about the add function not being declared. I assume that Shapespark has a partial modified version of three.js.

Right, Shapespark has quite a lot of custom renderer logic and it uses Three.js in a limited way. We don’t have APIs and functionality required to be able to extend geometry at runtime. Due to performance reasons, Shapespark merges loaded geometry with the same material to reduce the number of draw calls, it isn’t currently possible to append some additional objects to this merged geometry. Also Shapespark’s renderer doesn’t have support for objects animation. While Shapespark has basic API, the main focus is on use cases that do not require programming, so the API does not match the flexibility of game engines APIs or generic 3D libraries like Three.js.