Fix some bugs
This commit is contained in:
parent
345e183e34
commit
15151e53a7
4 changed files with 69 additions and 74 deletions
|
|
@ -1,9 +1,9 @@
|
|||
import { ILight } from './i-light';
|
||||
import { vec2, vec3 } from 'gl-matrix';
|
||||
import { GameObject } from '../../../objects/game-object';
|
||||
import { ImmutableBoundingBox } from '../../../physics/containers/immutable-bounding-box';
|
||||
import { settings } from '../../settings';
|
||||
import { IDrawableDescriptor } from '../i-drawable-descriptor';
|
||||
import { ImmutableBoundingBox } from '../../../physics/containers/immutable-bounding-box';
|
||||
import { GameObject } from '../../../objects/game-object';
|
||||
import { ILight } from './i-light';
|
||||
|
||||
export class CircleLight implements ILight {
|
||||
public static descriptor: IDrawableDescriptor = {
|
||||
|
|
@ -18,7 +18,7 @@ export class CircleLight implements ILight {
|
|||
public radius: number,
|
||||
public color: vec3,
|
||||
public lightness: number
|
||||
) {}
|
||||
) { }
|
||||
|
||||
boundingBox: ImmutableBoundingBox;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { IPrimitive } from './i-primitive';
|
||||
import { ImmutableBoundingBox } from '../../../physics/containers/immutable-bounding-box';
|
||||
import { GameObject } from '../../../objects/game-object';
|
||||
import { ImmutableBoundingBox } from '../../../physics/containers/immutable-bounding-box';
|
||||
import { IPrimitive } from './i-primitive';
|
||||
|
||||
export class Circle implements IPrimitive {
|
||||
public constructor(
|
||||
public readonly owner: GameObject,
|
||||
public center = vec2.create(),
|
||||
public radius = 0
|
||||
) {}
|
||||
) { }
|
||||
|
||||
public serializeToUniforms(uniforms: any): void {
|
||||
throw new Error('Method not implemented.');
|
||||
|
|
@ -40,4 +40,8 @@ export class Circle implements IPrimitive {
|
|||
const distance = vec2.distance(this.center, other.center);
|
||||
return distance < this.radius + other.radius;
|
||||
}
|
||||
|
||||
public clone(): Circle {
|
||||
return new Circle(this.owner, this.center, this.radius);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import { IDrawable } from '../i-drawable';
|
||||
|
||||
export interface IPrimitive extends IDrawable {}
|
||||
export interface IPrimitive extends IDrawable {
|
||||
clone(): IPrimitive
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { IDrawableDescriptor } from '../i-drawable-descriptor';
|
||||
import { IPrimitive } from './i-primitive';
|
||||
import { settings } from '../../settings';
|
||||
import { Circle } from './circle';
|
||||
import { mix } from '../../../helper/mix';
|
||||
import { clamp01 } from '../../../helper/clamp';
|
||||
import { ImmutableBoundingBox } from '../../../physics/containers/immutable-bounding-box';
|
||||
import { mix } from '../../../helper/mix';
|
||||
import { GameObject } from '../../../objects/game-object';
|
||||
import { ImmutableBoundingBox } from '../../../physics/containers/immutable-bounding-box';
|
||||
import { settings } from '../../settings';
|
||||
import { IDrawableDescriptor } from '../i-drawable-descriptor';
|
||||
import { Circle } from './circle';
|
||||
import { IPrimitive } from './i-primitive';
|
||||
|
||||
export class TunnelShape implements IPrimitive {
|
||||
public static descriptor: IDrawableDescriptor = {
|
||||
|
|
@ -73,7 +73,7 @@ export class TunnelShape implements IPrimitive {
|
|||
const targetFromDelta = vec2.subtract(vec2.create(), target, this.from);
|
||||
const h = clamp01(
|
||||
vec2.dot(targetFromDelta, this.toFromDelta) /
|
||||
vec2.dot(this.toFromDelta, this.toFromDelta)
|
||||
vec2.dot(this.toFromDelta, this.toFromDelta)
|
||||
);
|
||||
return (
|
||||
vec2.distance(
|
||||
|
|
@ -86,4 +86,14 @@ export class TunnelShape implements IPrimitive {
|
|||
public minimumDistance(target: vec2): number {
|
||||
return this.boundingCircle.distance(target);
|
||||
}
|
||||
|
||||
public clone(): TunnelShape {
|
||||
return new TunnelShape(
|
||||
this.owner,
|
||||
this.from,
|
||||
this.to,
|
||||
this.fromRadius,
|
||||
this.toRadius
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue