-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mesh with colored faces component #3
Comments
almost there... need to save this spot while i try something else. Re issue #3
This is working, but the output is super heavy and we need a post process function in the viewer side to actually make the colors show up. Took forevah to figure that out. The face materialindex properties were all set to 0, which made all faces the color of the first face. I think deep solution is related to a comment in #4 --- we need to be setting the faces' material indexes in the json file. Not sure if I'll include this one in the 0.2 release either ... If I can get a viewer out there in time, then maybe. |
BUT! I need this for a project quick quick, and the one material per face model prooves to be super heavy with an 11k face mesh - slows the renderer to a crawl. We need to hack the face material index map into the json file somehow, and minimize the number of materials we include the MeshFaceMaterials.Materials array. |
Improved! Much lighter when we only export unique materials. The code on the viewer side isn't too bad either ... not ideal, but good enough for now... |
It is not clear to me why you are trying to give each face its own material. The usual way is to provide a mesh with a single material (or just a few ) and then assign colors to vertices. To show you this, I have added to the Viewer Cookbook a Three.js models with vertex colors. See: http://va3c.github.io/viewer/cookbook/vertex-colors/r1/vertex-colors-r1.html I am now going to add export capability so you can see what the JSON representation of these models looks like. These, hopefully, will give you the clues as to what and how Grasshopper needs to do the export. |
R2 is up http://va3c.github.io/viewer/cookbook/vertex-colors/r2/vertex-colors-r2.html Adds button to export geometry. Exported geometry appears to load correctly in the vA3C Editor and the Three.js Editor. |
@theo-armour thanks for this! Yeah I know I'm missing something here. I'm using the MeshFaceMaterial now, which does need an array of materials to work, but I thought there was also a way to do this with a typical lambert or basic material and set the colors on the three.js faces. I think for the latter to work, I have to assign colors to vertices (and in this case maybe even materials to faces) as described in the format3 spec when authoring the json files, but I haven't taken the time to figure it out / give it a try. Seeing some json files with faces formatted like this would be super helpful, so again , thanks a bunch. related to comments in #4 as well. |
Create a component that takes a mesh and a list of colors (as well as optional attribute names and values) and outputs a json representation of the mesh, and materials for all of the necessary materials.
We'll do typical GH iteration in the component - if there are fewer colors than faces, we'll use the last color for all remaining faces. IF there are fewer faces then colors, we'll ignore the extra colors.
This will be useful for displaying Ladybug/Honeybee meshes, for example.
The text was updated successfully, but these errors were encountered: