Skip to content

Implementation for Flat End Caps on Tube Geometry#19

Open
rfzeg wants to merge 3 commits intoshawn0326:devfrom
rfzeg:flat-end-caps
Open

Implementation for Flat End Caps on Tube Geometry#19
rfzeg wants to merge 3 commits intoshawn0326:devfrom
rfzeg:flat-end-caps

Conversation

@rfzeg
Copy link

@rfzeg rfzeg commented Aug 26, 2024

This pull request tries to addresses the issues described in #18.

It introduces a prototype for implementing flat end caps on the tube geometry. The end caps are designed to close the ends of the tube geometry, which enhances the overall appearance when using a standard material such as MeshPhongMaterial. However, there are a few issues that need to be addressed before this implementation can be considered complete.

Current Functionality: The current changes successfully add flat end caps to the tube geometry, controlled via a simple boolean option.

flat-end-caps-current-implementation

Known Issues

Mesh Topology
When switching to wireframe mode, the mesh topology reveals inconsistencies between the first and second end caps.
The second end cap (end) appears correct, featuring 1 center vertex connected to the last radial segment of the tube.
The first end cap (start), however, has redundant vertices. It includes 1 center vertex + (radialSegments + 1) rim vertices, which makes it geometrically inconsistent with the rest of the tube.

UV Textures
The UV mapping for the last segment of the tube (adjacent to the second end cap) is twisted.
The first end cap (start) also displays UV issues, likely caused by the redundant vertices. These issues prevent proper texture mapping on both ends of the tube.

Extensibility
While the current implementation allows toggling flat end caps, it lacks flexibility for future enhancements.
Future end cap types, such as round (semi-hemisphere) end caps, arrow-shaped end caps or squared (plug) end caps, cannot be easily introduced with the current design.


I have thoroughly investigated potential solutions for the issues above but was unable to resolve them with my current (very limited) knowledge level. I also reviewed the TubeBuilder.js code you provided but could not identify the cause of these problems or a way to fix them. I would appreciate if you could address the current issues (mesh topology und UV texture) and maybe make the implementation more robust for adding other types of end caps in the future. 🙏

@shawn0326
Copy link
Owner

To avoid confusion with normals and UVs, the cap should generally not share vertices with the sides. I will try to address these issues.

@shawn0326
Copy link
Owner

I submitted another PR. #20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants