kovacsv / occt-import-js

The emscripten interface for OpenCascade import functionalities.
GNU Lesser General Public License v2.1
141 stars 23 forks source link

THREE.js viewer example missing face colors #15

Closed Glavin001 closed 1 year ago

Glavin001 commented 1 year ago

THREE.js viewer example: https://github.com/kovacsv/occt-import-js/blob/main/examples/three_viewer.html#L28-L64

I've added a working (so far in my tests) face_colors implementation to this Codesandbox: https://codesandbox.io/s/convert-step-file-to-glb-with-three-js-occt-import-js-v0-3-5hk66o?file=/src/StepLoader.js

kovacsv commented 1 year ago

I prefer to use material groups instead of vertex colors, but both can work. A Pull Request is always welcome!

Glavin001 commented 1 year ago

Good to know, thanks! I'm relatively new to Threejs and learning these concerns this week. Appreciate your feedback.

I've been trying to learn from https://github.com/kovacsv/Online3DViewer/blob/master/source/engine/import/importerocct.js Could more of the code from Online3DViewer be brought into this library, such as color support, or is this separation intentional?

Thanks for creating this awesome library! 🎉

kovacsv commented 1 year ago

The separation is intentional, actually the dependency is reversed: Online3DViewer uses occt-import-js under the hood. This library should be independent from Online 3D Viewer to make it usable more widely.

hyfbeetle commented 1 year ago

How to show face colors with this library? Will it be done in near future? Thanks very much.

kovacsv commented 1 year ago

I've added face color handling to the example: https://github.com/kovacsv/occt-import-js/blob/main/examples/three_viewer.html#L62-L89

hyfbeetle commented 1 year ago

Appreciate your feedback, thanks very much! Problem is resultMesh.face_colors is undefined, file "dm1-id-214.stp" from test directory has face colors, but cann't display.

kovacsv commented 1 year ago

Oh, that's another issue than. I've created a new issue for this: #23