-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
Src: add CapsuleGeometry #23586
Src: add CapsuleGeometry #23586
Conversation
src/geometries/CapsuleGeometry.js
Outdated
// max here prevents failing when height is 0 | ||
const a = Math.asin( R1 / Math.max( Number.EPSILON, height ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this check to avoid a void geometry.
Problems still arise when passing certain combinations of radii and height, should we add more checks/failsafes?
Not sure what's wrong with the unit tests, maybe I missed something but the action message doesn't help |
Could you remove the builds from the PR? |
✅ Removed them |
2 separate radii or 1? I agree that radius/length is less clumsy to use, and the change is not a big effort 🤷 Let me know which one you prefer |
I vote for a single radius value. |
Yes, |
Removed the double radius situation, only thing missing is this suggestion #23586 (comment) |
✅ simplified code accounting for single radius |
You have to add the new unit test file to this section: three.js/test/unit/three.source.unit.js Lines 85 to 104 in 5d81b27
|
src/geometries/CapsuleGeometry.js
Outdated
|
||
super( path.getPoints( capSegments ), radialSegments ); | ||
|
||
this.translate( 0, - length / 2, 0 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way of doing this offset in the Path
instead? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4ed3391 LGTY?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks! |
@gsimone It seems to me that |
@mrdoob This is what it would look like, I didn't check if it generates the same vertices though, is that something we'd care about 🤔 Screen.Recording.2022-03-01.at.09.55.46.movTry here 👉 https://codesandbox.io/s/three-js-lathe-spheregeometry-vg4bvz?file=/src/LatheSphereGeometry.js |
That's great!
Ideally yes. Including the |
I think it would be an interesting experiment, but maybe not worth it? I'll play with adding the angles and see how it differs from the sphere we have now. It could be good as long as it's not a huge breaking change (eg. UV and normals are close enough to not cause differences if people are relying on constructing spheres with the old geo) |
* feat: adds CapsuleGeometry * . * Update src/geometries/CapsuleGeometry.js * Update docs/api/en/geometries/CapsuleGeometry.html * removes radiusBottom * Update src/geometries/CapsuleGeometry.js * adds test import * fixes test file name typo * . * fixes imports in capsuleGeometry module * . * pre-translate path * lint
* feat: adds CapsuleGeometry * . * Update src/geometries/CapsuleGeometry.js * Update docs/api/en/geometries/CapsuleGeometry.html * removes radiusBottom * Update src/geometries/CapsuleGeometry.js * adds test import * fixes test file name typo * . * fixes imports in capsuleGeometry module * . * pre-translate path * lint
Related issue: #23579
Preview
https://rawcdn.githack.com/gsimone/three.js/feature/capsule-geometry/docs/index.html?q=caps#api/en/geometries/CapsuleGeometry
Description
Adds a simple CapsuleGeometry class that extends LatheGeometry.
Some Notes
Checklist