Compress a Threejs Mesh using JS Rhino3dm dracoCompression


I’m new using rhino, I’m starting to work around with threejs/rhino3dm/rhinoCompute

I want to create a base64encoded Mesh from an .obj file using the js librairie of rhino3dm

I’m loading my file with the threejs OBJLoader and then I found that DracoCompression.compress(mesh, options) is taking a Mesh as parameter (documentation is in TODO state :slightly_smiling_face: )

But it seem’s a Threejs Mesh is not a Rhino Mesh ??

// The error :

Object { name: "BindingError", message: "Cannot pass \"[object Object]\" as a Mesh const*", stack: "BindingError: Cannot pass \"[object Object]\" as a Mesh const*\nextendError/errorClass<@\nBindingError@ line 8 > 

How can I do to convert my Threejs Mesh into RhinoMesh ?

(I try to implement directly the dracoEncoder but it’s a bit complicated for my level of understanding of virtual 3D objects)

Thank you for your help

Hello. Have you seen this sample: rhino-developer-samples/script.js at 7 · mcneel/rhino-developer-samples · GitHub

const rhinoMesh = rhino.Mesh.createFromThreejsJSON( { data: mesh.geometry } )