hjoykim / THREE

c# port of Three.js
MIT License
135 stars 24 forks source link

Render low quality #39

Closed merco closed 1 month ago

merco commented 1 month ago

What determines this better visualization? Normals?

immagine

O{15}.zip

immagine

O{22}.zip

hjoykim commented 1 month ago

Hello, use below ComputeNormalsGroup function after loading obj file

public void ComputeNormalsGroup(Group group) { group.Traverse(o => { if (o is Mesh) { var tempGeom = new Geometry(); (o.Geometry as BufferGeometry).deleteAttribute("normal"); tempGeom.FromBufferGeometry((BufferGeometry)o.Geometry); tempGeom.MergeVertices(); tempGeom.ComputeVertexNormals(); tempGeom.NormalsNeedUpdate = true; o.Geometry = tempGeom; } }); } ...

OBJLoader loader = new OBJLoader(); var rootObject =loader.Load("../../../../assets/models/obj/O{22}.obj"); ComputeNormalsGroup(rootObject);

you can refer to https://discourse.threejs.org/t/how-to-smooth-an-obj-with-threejs/3950

merco commented 1 month ago

ok. But how can I convert back it to BufferGeometry?

Now I have this problem with raycast

immagine

merco commented 1 month ago

now the objects are really soft!! maybe too much :)

immagine

hjoykim commented 1 month ago

you can convert to BufferGeometry like as below

         //o.Geometry = tempGeom;
         (o.Geometry as BufferGeometry).FromGeometry(tempGeom);