forked from viamrobotics/prime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RSDK-7089] Orientation format fix, add LengthCapsuleGeometry (viamro…
- Loading branch information
1 parent
72f984e
commit 4d49c75
Showing
6 changed files
with
54 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/blocks/src/lib/capsule-geometry/capsule-geometry.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* eslint-disable max-classes-per-file */ | ||
import { LatheGeometry, Path } from 'three'; | ||
|
||
/** | ||
* An alternate definition of a THREE.CapsuleGeometry: the length | ||
* represents the entire length of the capsule, including the rounded ends, | ||
* rather than just the midsection, which is the default THREE.CapsuleGeometry definition. | ||
*/ | ||
export class LengthCapsuleGeometry extends LatheGeometry { | ||
override type = 'CapsuleGeometry'; | ||
|
||
constructor(radius = 1, length = 1, capSegments = 4, radialSegments = 8) { | ||
const path = new Path(); | ||
const midsectionLength = length - 2 * radius; | ||
|
||
path.absarc( | ||
0, | ||
-midsectionLength / 2 - radius / 2, | ||
radius, | ||
Math.PI * 1.5, | ||
0 | ||
); | ||
|
||
path.absarc(0, midsectionLength / 2 + radius / 2, radius, 0, Math.PI * 0.5); | ||
|
||
super(path.getPoints(capSegments), radialSegments); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters