Fix should draw condition

This commit is contained in:
schmelczerandras 2020-07-25 17:51:13 +02:00
commit b6bef3c77d
2 changed files with 54 additions and 15 deletions

View file

@ -0,0 +1,15 @@
import { vec2 } from 'gl-matrix';
export class Circle {
public constructor(public center: vec2, public radius: number) {}
public isInside(position: vec2): boolean {
const distance = vec2.distance(this.center, position);
return distance < this.radius;
}
public areIntersecting(other: Circle): boolean {
const distance = vec2.distance(this.center, other.center);
return distance < this.radius + other.radius;
}
}

View file

@ -1,13 +1,10 @@
import { Typed } from '../transport/serializable';
import { vec2 } from 'gl-matrix';
export class Rectangle extends Typed {
export class Rectangle {
public constructor(
public topLeft: vec2 = vec2.create(),
public size: vec2 = vec2.create()
) {
super();
}
) {}
public isInside(position: vec2): boolean {
const translated = vec2.subtract(vec2.create(), position, this.topLeft);