Where are you exporting from? The only software that knows how to generate render meshes for extrusions, breps, and subD is Rhino. You’d have to open the file in Rhino to have it generate render meshes (or script the generation of render meshes from within Rhino).
Alternatively, we could bind the SetMesh method of these types to allow users to add their own render mesh to these geometries from outside of Rhino. (I’ll add this issue to our list).
We want to include Rhino in our workflow, so import and export to Rhino
I just noticed that I have to open an exported Rhino file in Render or Shaded Mode (Wireframe is not enough) so that it is possible to import it with the Three.js 3DM Loader.
Don’t know if the mentioned approach would help with that
Right. Render meshes are only generated on breps in Rhino itself. What I can do is bind the SetMesh function for BrepFaces and for Extrusions in rhino3dm so that you can push your own meshes to those objects and save them in the 3dm. Does that sound like a solution for your process?
Hello. I’ve wrapped the SetMesh functionality for breps and extrusions. I’d appreciate if you could try it out by downloading the compiled version that can be found here (available for 15 days).
In theory, you should be able to do do the following:
let myRhinoMesh
// create your Rhino mesh
//object is an object from doc.objects()
//for extrusions:
const resultExtrusion = object.geometry().setMesh( myRhinoMesh, rhino.MeshType.Render ); //result is a bool
//for a brepface with index 0 in the brep
const resultBrepFace = object.geometry().faces().get(0).setMesh( myRhinoMesh, rhino.MeshType.Render ) //result is a bool
of course, this is pretty easy because a sphere brep has one face, so we can just put the sphere mesh in there. Stepping through the faces of a Brep and setting the mesh for the face would require quite some logic to get it right.
I was able to save this file and open it in the threejs editor and the meshes came through. I am working on a sample to demonstrate this, but the above code is the main part.
Hey guys, I’m having a similar issue with this. Basically I’m reading a rhino file using rhino3dm, then I create a new brep and save the file back. Later I open that saved file using the rhino3dmloader but I don’t see the mesh in the browser. Is there no better way of doing this mesh render update? I have also try to create a threejs geometry and use the setMesh method but for some reason it only shows the mesh in the same position. here is my code:
const createSpaceDisk = (values, rhino) => {
// Define cylinder dimensions
const radius = 0.4;
const height = 0.25;
// Define the cylinder's base circle at the provided center
const circle = new rhino.Circle(radius);
circle.center = values.position;
// Create the cylindrical surface (the height is along the Z-axis)
const cylinder = new rhino.Cylinder(circle, height);
// Create the Brep (boundary representation) from the cylinder
const brep = rhino.Brep.createFromCylinder(cylinder, true, true); // Capped at both ends (top and bottom)
// Create cylinder geometry
return brep;
};
const cylinderAttributes = setSpaceAttributes(newDoc, rhino, values);
newDoc.objects().add(newCylinder, cylinderAttributes);
uploadFile(newDoc);
Sorry I forgot to put the part with the three.js geometry:
const createSpaceDisk = (values, rhino) => {
// Define cylinder dimensions
const radius = 0.4;
const height = 0.25;
// Define the cylinder's base circle at the provided center
const circle = new rhino.Circle(radius);
circle.center = values.position;
// Create the cylindrical surface (the height is along the Z-axis)
const cylinder = new rhino.Cylinder(circle, height);
// Create the Brep (boundary representation) from the cylinder
const brep = rhino.Brep.createFromCylinder(cylinder, true, true); // Capped at both ends (top and bottom)
// Create cylinder geometry
const threeGeometry = new THREE.CylinderGeometry(
radius,
radius,
height,
32
);
const rhinoMesh = rhino.Mesh.createFromThreejsJSON({ data: threeGeometry });
console.log(rhinoMesh);
for (let i = 0; i < brep.faces().count; i++) {
brep.faces().get(i).setMesh(rhinoMesh, rhino.MeshType.Render);
}
return brep;
};
Looking at the output of this example, I do see that my meshes are not transformed properly to the actual brep/extrusion location. I will tune this up.