Skip to content
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

ConeGeometry contains degenerate triangles #29454

Open
gkjohnson opened this issue Sep 20, 2024 · 1 comment
Open

ConeGeometry contains degenerate triangles #29454

gkjohnson opened this issue Sep 20, 2024 · 1 comment
Labels

Comments

@gkjohnson
Copy link
Collaborator

Description

ConeGeometry extends CylinderGeometry and simply sets the top radius to 0 resulting in one triangle of all the 2-triangle rectanglar sides being reduced to an edge. Eg a cone with 3 sides should require a total of 6 triangles - but instead consists of 9. 3 of which are degenerate triangles.

image

You can see the triangles that are being reduced to an edge as the top radius gets smaller:

image

Degenerate triangles like this can cause issues with any algorithms that require computing triangle normals, take surface area, generating half-edge structures, etc. It would be great if the core three.js primitives could be properly constructed without degenerate triangle issues.

Reproduction steps

  1. Create a cone geometry
  2. Check the number of triangles
  3. There are are more triangles than necessary

Code

const cone = new THREE.ConeGeometry( 1, 1, 3, 1 );
console.log( cone.index.count / 3 ); // logs 9 instead of 6

Live example

Screenshots

No response

Version

dev

Device

No response

Browser

No response

OS

No response

@gkjohnson gkjohnson added the Bug label Sep 20, 2024
@andrewhodel
Copy link

andrewhodel commented Sep 20, 2024

It's probably using a double instead of an integer with a known range.

You'll need to do this instead of N.DDDDD / N * .DDDDD:

		var currentStep = 0;
		for (var c=0; c<totalSteps; c++) {
			if (desiredRation >= ration_step*c)) {
				currentStep = c;
			}
		}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants