Three.js: Geometry without faces is still rendered in Mesh

Created on 7 Aug 2017  ·  3Comments  ·  Source: mrdoob/three.js

The idea is that my Geometry always has same vertices, but faces are added optionally. However, it randomly decides to draw stuff regardless. Demo here.

Bug Won't fix

Most helpful comment

I've debugged this issue today. Geometry is internally converted to BufferGeometry. The outcome of this conversion depends on the type of object (Mesh, Line, etc.). So in @makc's example, the geometry is converted as the geometry of a Line object. This will create a position and color attribute. When the instance of Mesh is rendered with the same Geometry object, the renderer returns the same cached instance of BufferGeometry.

https://github.com/mrdoob/three.js/blob/ec67749b0767e2727deebd52da2dbd3a4e7ab6a2/src/renderers/webgl/WebGLGeometries.js#L63-L65

This is the reason why you see these green triangles in the demo. Mesh and Line share the same internal BufferGeometry and interpret it differently. I think we can solve this problem if we try to respect the type of object when caching the BufferGeometry.

Or we just recommend to use BufferGeometry in the first place :sweat_smile:

All 3 comments

An opposite issue here - we don't see faces where they are defined. So maybe this is because Geometry is shared between the Line and Mesh.

I've debugged this issue today. Geometry is internally converted to BufferGeometry. The outcome of this conversion depends on the type of object (Mesh, Line, etc.). So in @makc's example, the geometry is converted as the geometry of a Line object. This will create a position and color attribute. When the instance of Mesh is rendered with the same Geometry object, the renderer returns the same cached instance of BufferGeometry.

https://github.com/mrdoob/three.js/blob/ec67749b0767e2727deebd52da2dbd3a4e7ab6a2/src/renderers/webgl/WebGLGeometries.js#L63-L65

This is the reason why you see these green triangles in the demo. Mesh and Line share the same internal BufferGeometry and interpret it differently. I think we can solve this problem if we try to respect the type of object when caching the BufferGeometry.

Or we just recommend to use BufferGeometry in the first place :sweat_smile:

@mrdoob I suggest to introduce a new label Wont't fix, assign it to the issue and close it. I don't think it makes sense to add a fix to the renderer if the project is going to stop rendering Geometry anyway. The solution for this issue is the usage of BufferGeometry.

Was this page helpful?
0 / 5 - 0 ratings