Fix physics
This commit is contained in:
parent
37954e2ef1
commit
f9f6825776
51 changed files with 832 additions and 541 deletions
|
|
@ -1,21 +1,25 @@
|
|||
import { Physical } from '../physical';
|
||||
import { DynamicPhysical } from '../dynamic-physical';
|
||||
import { BoundingBoxBase } from '../bounding-boxes/bounding-box-base';
|
||||
|
||||
export class BoundingBoxList {
|
||||
constructor(private objects: Array<Physical> = []) {}
|
||||
constructor(private objects: Array<DynamicPhysical> = []) {}
|
||||
|
||||
public insert(object: Physical) {
|
||||
public insert(object: DynamicPhysical) {
|
||||
this.objects.push(object);
|
||||
}
|
||||
|
||||
public remove(object: Physical) {
|
||||
public remove(object: DynamicPhysical) {
|
||||
this.objects.splice(
|
||||
this.objects.findIndex((i) => i === object),
|
||||
1,
|
||||
);
|
||||
}
|
||||
|
||||
public findIntersecting(boundingBox: BoundingBoxBase): Array<Physical> {
|
||||
public forEach(func: (object: DynamicPhysical) => unknown) {
|
||||
this.objects.forEach(func);
|
||||
}
|
||||
|
||||
public findIntersecting(boundingBox: BoundingBoxBase): Array<DynamicPhysical> {
|
||||
return this.objects.filter((b) => b.boundingBox.intersects(boundingBox));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue