Hello together, I’m working on a small web app using Rhino.Compute and Rhino3dm.js
Currently, I’m struggling to decode the data for ThreeJs. In this example, I have a simple Box (not converted to a mesh) and I get the following error:
Rhino.Geometry.Box is a struct and does not derive from Rhino.Geometry.GeometryBase (and thus Rhino.Runtime.CommonObject) like Breps and Meshes so it has no way to be “decoded” into a CommonObject.
You could return this as a brep or mesh as you already know and it would be decoded correctly. Alternatively you could still sent it as a box. The data for the object does come through and you could handle it accordingly.
First you can check if the data has a property of ‘opennurbs’. This is a telltale sign that the object is derived from CommonObject
...
else if (typeof data === 'object' && data.hasOwnProperty( 'opennurbs' ) ) {
return rhino.CommonObject.decode(data)
}
So this will avoid the error you are seeing because it will skip objects that are not derived from CommonObject (like Box and Point3d)
If you want to handle boxes specifically you could add a filtering condition with any of the properties that a box has
Breps made in GH don’t have any associated render mesh…threejs has very little idea about NURBS. Your best bet if you want to see them in threejs is to send a mesh.