@@ -6,20 +6,15 @@ import { Group } from "three";
6
6
// height of 0.9 (eye level) for a perceived height of 1
7
7
const HEIGHT = 0.9 ;
8
8
const RADIUS = 0.2 ;
9
- const SEGMENTS = 12 ;
9
+ const SEGMENTS = 10 ;
10
10
11
11
const SPHERE_SHAPE : ShapeType = "Sphere" ;
12
- const CYLINDER_SHAPE : ShapeType = "Cylinder" ;
13
12
14
13
const sphereProps = { type : SPHERE_SHAPE , args : [ RADIUS , SEGMENTS , SEGMENTS ] } ;
15
- const cylinderProps = {
16
- type : CYLINDER_SHAPE ,
17
- args : [ RADIUS , RADIUS , HEIGHT - RADIUS * 2 , SEGMENTS ] ,
18
- } ;
19
14
20
- const sphere1 = { ...sphereProps , position : [ 0 , - ( HEIGHT - RADIUS ) , 0 ] } ;
21
- const cylinder = { ...cylinderProps , position : [ 0 , - ( HEIGHT / 2 ) , 0 ] } ;
22
- const sphere2 = { ...sphereProps , position : [ 0 , - RADIUS , 0 ] } ;
15
+ const topSphere = { ...sphereProps , position : [ 0 , - RADIUS , 0 ] } ;
16
+ const middleSphere = { ...sphereProps , position : [ 0 , - ( HEIGHT / 2 ) , 0 ] } ;
17
+ const bottomSphere = { ...sphereProps , position : [ 0 , - ( HEIGHT - RADIUS ) , 0 ] } ;
23
18
24
19
export const useCapsuleCollider = ( pos = [ 0 , 0 , 0 ] ) => {
25
20
const vPos = useRef ( pos as Triplet ) ;
@@ -33,7 +28,7 @@ export const useCapsuleCollider = (pos = [0, 0, 0]) => {
33
28
segments : SEGMENTS ,
34
29
fixedRotation : true ,
35
30
type : "Dynamic" ,
36
- shapes : [ sphere1 , cylinder , sphere2 ] ,
31
+ shapes : [ topSphere , middleSphere , bottomSphere ] ,
37
32
} ) ,
38
33
undefined ,
39
34
[ ]
@@ -54,18 +49,11 @@ export function VisibleCapsuleCollider() {
54
49
</ mesh >
55
50
) ;
56
51
57
- const createCylinder = ( cylinder : any ) => (
58
- < mesh position = { cylinder . position } >
59
- < cylinderBufferGeometry args = { cylinder . args } />
60
- < meshStandardMaterial color = "blue" wireframe = { true } />
61
- </ mesh >
62
- ) ;
63
-
64
52
return (
65
53
< group name = "collider" position = { [ 1.5 , - HEIGHT , 0 ] } >
66
- { createSphere ( sphere1 ) }
67
- { createCylinder ( cylinder ) }
68
- { createSphere ( sphere2 ) }
54
+ { createSphere ( topSphere ) }
55
+ { createSphere ( middleSphere ) }
56
+ { createSphere ( bottomSphere ) }
69
57
</ group >
70
58
) ;
71
59
}
0 commit comments