Loading Speckle data into a non Speckle ThreeJS viewer

Hi @dimitrie @kgoulding I’m trying to understand the converter a little better.

As a bit of background I’m trying to load geometry from Speckle within a Three app without using the Speckle Viewer. Perhaps this is not a good idea but I’d like to get it working as I think I’m very close.

  1. Have I understood correctly that the converter should convert the Speckle objects to Threejs Object3d?

  2. the Converter uses a WorldTree which is something the Viewer uses as I understand. I shouldn’t need this for just converting to Threejs right?
    If I include WorldTree is sets off a long chain of dependancies that goes very deep!

1 Like

Hi Harri! I lost track of this, but I don’t think this is going to be an actually easy one. @alex - who’s on hols, but once he’s back - tomorrow IIRC - can provide more context once he wraps his head around things.

As far as I know, we currently do not have a direct translation to standard threejs objects, and the world tree that you mention is a complete different beast than the threejs one. There’s basically… a ton of low level optimisations that went into our viewer regarding efficient batching of objects per material, ambient occlusion, RTE transforms, etc.

Anyway, I don’t want you to loose all hope yet!

1 Like

Thanks @dimitrie. I should have also copied in @jonathon @teocomi who we had a useful chat with last week.

I think we are really close!


Hi @Harri_Lewis

The viewer’s converter is not yet isolated enough from the rest of the viewer library so that you can use it as standalone directly in another project. However you could strip out the needed parts from the viewer which handle conversion as well as geometry conversion. More on this on the response for #2

  1. The converter does not convert speckle data to three.js objects. What the converter does is, it populates a tree-like data structure with nodes, respecting the original speckle hierarchy.

  2. You could just ignore the WorldTree altogether, and edit the converter to simply not use it. But then you’ll need to implement your own speckle object geometry conversion. What I suggest is to use WorldTree, together with RenderTree and NodeRenderView. If you look at what these import in turn, most of the stuff is interface or enum declarations, from other sources which you can copy-paste yourself. Using these, you can: Convert speckle data to a WorldTree structure, then build it with buildRenderTree or buildRenderTreeAsync from RenderTree. Once the tree is built, all relevant geometry will exist in it’s nodes renderView property with all the information you need (geometry attrbiute, geometry type, material information). From this point on, you can do whatever you want with the data and you don’t need anything else from the viewer library.

Let me know if you need more help with this



Hi @alex,

Many thanks for your detailed reply. This sounds like a nice solution and we will give it a go.

(@iltabe copied in for reference)