Compress a Threejs Mesh using JS Rhino3dm dracoCompression

Hello,

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<@https://files.mcneel.com/rhino3dm/js/latest/rhino3dm.js:8:91019\nBindingError@https://files.mcneel.com/rhino3dm/js/latest/rhino3dm.js 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

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