Skip to content

Commit

Permalink
feat: add hull collider
Browse files Browse the repository at this point in the history
### Description

- Add `convexHull` colliderDesc support
  • Loading branch information
Neosoulink committed Jun 20, 2024
1 parent 8412712 commit 3b366f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/types/collider.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type ColliderShape =
| 'capsule'
| 'cone'
| 'cylinder'
| 'hull'
| 'trimesh'
| 'heightfield'

Expand Down
8 changes: 8 additions & 0 deletions src/utils/collider.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ export const createColliderDesc = (props: CreateColliderDescProps,
colliderDesc = ColliderDesc.trimesh(triMeshMap, triMeshUnit)
break
}
case 'hull': {
const clonedGeometry = mergeVertices(props.object.geometry)
const triMeshMap = clonedGeometry.attributes.position
.array as Float32Array

colliderDesc = ColliderDesc.convexHull(triMeshMap) ?? colliderDesc
break
}
}

// TODO: Unable to retrieve the subdivision number & the Matrix of the given object for #heightfield
Expand Down

0 comments on commit 3b366f6

Please sign in to comment.