Skip to content

Commit

Permalink
fix: default capsule and sphere collider shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gugustinette committed Oct 22, 2024
1 parent 5b93a7b commit 09a6190
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/3d/src/polyhedrons/FCapsule.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as THREE from 'three'
import type { FScene } from '../core/FScene'
import type { FComponentOptions } from '../core/FComponent'
import { FShapes } from '../types/FShapes'
import type { FRigidBodyOptions } from '../core/FRigidBody'
import type { FColliderOptions } from '../core/FCollider'
import { FPolyhedron } from './FPolyhedron'

/**
Expand Down Expand Up @@ -31,4 +34,25 @@ export class FCapsule extends FPolyhedron {
// Emit the onLoaded event
this.emitOnLoaded()
}

initCollider(options?: FColliderOptions): void {
super.initCollider({
shape: FShapes.CAPSULE,
...options,
})
}

initRigidBody(options?: FRigidBodyOptions): void {
super.initRigidBody({
shape: FShapes.CAPSULE,
...options,
})
}

initSensor(options?: FRigidBodyOptions): void {
super.initSensor({
shape: FShapes.CAPSULE,
...options,
})
}
}
24 changes: 24 additions & 0 deletions packages/3d/src/polyhedrons/FSphere.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as THREE from 'three'
import type { FScene } from '../core/FScene'
import type { FComponentOptions } from '../core/FComponent'
import type { FColliderOptions } from '../core/FCollider'
import { FShapes } from '../types/FShapes'
import type { FRigidBodyOptions } from '../core/FRigidBody'
import { FPolyhedron } from './FPolyhedron'

/**
Expand Down Expand Up @@ -31,4 +34,25 @@ export class FSphere extends FPolyhedron {
// Emit the onLoaded event
this.emitOnLoaded()
}

initCollider(options?: FColliderOptions): void {
super.initCollider({
shape: FShapes.SPHERE,
...options,
})
}

initRigidBody(options?: FRigidBodyOptions): void {
super.initRigidBody({
shape: FShapes.SPHERE,
...options,
})
}

initSensor(options?: FRigidBodyOptions): void {
super.initSensor({
shape: FShapes.SPHERE,
...options,
})
}
}

0 comments on commit 09a6190

Please sign in to comment.