3DMLoader for Three.js

Hi @Willem - thanks for your reply. No not yet because there appears to be quite a few methods that sounded similar. Here are the methods that I was going to experiment with:

  • RhinoObject
    .CreateMeshes()
    .GetMeshes()
    .GetRenderMeshes()
    .GetRenderMeshesWithUpdatedTCs()
    .GetRenderPrimitiveList()
    .MeshObjects()

  • RenderPrimitive.Mesh()

  • RhinoDoc
    .GetRenderPrimitives()
    .GetRenderPrimitiveList()

First I will try RhinoDoc.GetRenderPrimitiveList() since I guess this will enumerate all the objects in the document calling RhinoObject.GetRenderPrimitiveList on each one. I donā€™t know if that is identical to RhinoObject.CreateMeshes() but iā€™ll try both. Maybe these all do the same thing?

cheers
dan.

If you know the object is a brep, then you can use the Mesh.CreateFromBrep() method. Something like this:

var rhinoObjs = doc.Objects.FindByObjectType(ObjectType.Brep);
var meshedbreps = new List<Mesh>();
foreach (var item in rhinoObjs) 
{
	var brep = item.Geometry as Brep;
    var mesh = Mesh.CreateFromBrep(brep); //optionally set meshing parameters
    meshedbreps.Add(mesh);
        

}

...

Hi @fraguada

Currently we are working only with breps but I wanted to leave the door open for future other object types.

So yes at the moment I could use Mesh.CreateFromā€¦() methods in c# and send only mesh objects to my threeJs scene but I was hoping to be future proof and send entire 3dm document to the threejs scene relying on your 3DMLoader.js class to convert every type of meshable object that it can to threejs. --That way as you mature your 3DMLoader.js class (perhaps texture/material support etc) i would get the improvements too :slight_smile:

So i think for now I would like to call RhinoDoc.GetRenderPrimitiveList() on my c# side for the entire document so that all objects have a rendermesh present ā€“ then Iā€™ll send the entire doc to JS and rely on your 3DMLoader class to convert to threejs.

Unless performance of 3DMLoader.js is much worse than using Mesh.CreateFromBreps() on only the breps - so Iā€™ll test and compare.

1 Like

Sounds like a decent plan!

Calling the RhinoObject.CreateMeshes() method server-side (c# Compute plugin) hasnā€™t worked for me. :frowning:

The breps are still being reported by 3DMLoader.js as having no render meshes.
Perhaps this is because I am calling .CreateMeshes() in Compute which is headless.
Perhaps the brep.EnsurePrivateCopy() or brep.Compact() steps are removing the rendermeshes from the breps.
For now I have run out of time with this approach.

Instead I will take @fraguada suggestion and instead of sending breps to the webpage iā€™ll create mesh objects directly with Mesh.CreateFromā€¦() methods and send these meshes to the Javascript and convert them to threejs using:

    const loader = new THREE.BufferGeometryLoader()
    const geometry = loader.parse(mesh.toThreejsJSON())
    return new THREE.Mesh(geometry, material)

Iā€™ll try all of this out and see where it might be failing.

I try to load Annotations via threejs and get ā€œTHREE.3DMLoader: Conversion not implemented for ObjectType_Annotationā€, type: ā€œnot implementedā€

the message is clear but i like to know if someone do have some nice workaround to get the informations of the annotations like startpoint and endpoints or length inside the 3dmLoader?

We donā€™t have much in openNURBS to deal with annotations and since openNURBS is the basis for rhino3dm, there isnā€™t much in rhino3dm. I will see what we can do to make some of that info public.

1 Like

Hi,
Is there any news about this topic ( supporting annotations?)
Thank you!

What is it that you would like to do with annotations?

Hi LuĆ­s,

My application displays 3DM Models using R3F + Rhino3dmjs and in the models we have measurements (quotas) and the measurements are text type objects.

At the moment the text objects are not rendered.

In the browser console I get the following warning:
THREE.3DMLoader: Conversion not implemented for ObjectType_Annotation

Iā€™m assuming this has to due with the fact that the object is Type Text. I canā€™t recognized them on the 3DMLoader (just looping the model children and output to console > ā€œchild.Typeā€)

PS: The models are generated through Grasshopper.

Thank you!

For now I would recommend exploding the annotations, or creating some sort of customized data structure from within GH to help you visualize this information on the front end.

Each object type requires a conversion to a three.js type. Meshes in Rhino have a specific data structure that we need to convert to the three.js mesh data structure. Same for curves. There is no three.js Annotation object, so weā€™d need to develop something that can represent an Annotation in three.js. This is not a trivial task, hence why weā€™ve not done it.

In any case, I will take a look at what other Annotation data we can make accessible via rhino3dm.

Hi,

Thank you for your reply!

For now, and to get around this issue, weā€™re changing the model objets to TextDots (theyā€™re supported by 3DMLoader) and converting them into Sprites.

But it would be useful to have some kind of direct conversion :slight_smile: (if possible, of course).

Thank you very much!

1 Like

I totally agree. Iā€™ll keep thinking about this.

1 Like