interactive objects integration
This commit is contained in:
+13
-10
@@ -31,29 +31,25 @@ class Physics{
|
||||
let colliderDesc
|
||||
|
||||
switch (colliderType) {
|
||||
case 'cuboid':
|
||||
{
|
||||
case 'cuboid':{
|
||||
const { width, height, depth } = colliderSettings
|
||||
colliderDesc = RAPIER.ColliderDesc.cuboid(width, height, depth)
|
||||
}
|
||||
break
|
||||
|
||||
case 'ball':
|
||||
{
|
||||
case 'ball':{
|
||||
const { radius } = colliderSettings
|
||||
colliderDesc = RAPIER.ColliderDesc.ball(radius)
|
||||
}
|
||||
break
|
||||
|
||||
case 'capsule':
|
||||
{
|
||||
case 'capsule':{
|
||||
const { halfHeight, radius } = colliderSettings
|
||||
colliderDesc = RAPIER.ColliderDesc.capsule(halfHeight, radius)
|
||||
}
|
||||
break
|
||||
|
||||
default:
|
||||
{
|
||||
default:{
|
||||
colliderDesc = RAPIER.ColliderDesc.trimesh(
|
||||
mesh.geometry.attributes.position.array,
|
||||
mesh.geometry.index?.array
|
||||
@@ -74,14 +70,21 @@ class Physics{
|
||||
|
||||
// * Responsible for collision detection
|
||||
const collider = this.world.createCollider(colliderDesc, rigidBody)
|
||||
|
||||
const physicsObject = { mesh, collider, rigidBody, fn: postPhysicsFn, autoAnimate }
|
||||
|
||||
this.physicsObjects.push(physicsObject)
|
||||
|
||||
return physicsObject
|
||||
}
|
||||
|
||||
clear(){
|
||||
this.physicsObjects.forEach(po=>{
|
||||
po.characterController && this.world.removeCharacterController(po.characterController)
|
||||
this.world.removeCollider(po.collider);
|
||||
this.world.removeRigidBody(po.rigidBody);
|
||||
})
|
||||
this.physicsObjects = [];
|
||||
}
|
||||
|
||||
step(){
|
||||
this.world.step(this.eventQueue)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user