trainsim/track/shapes.ts

49 lines
1.2 KiB
TypeScript

import { Vector } from "@bearmetal/doodler";
import { TrackSegment } from "./system.ts";
export class StraightTrack extends TrackSegment {
constructor(start?: Vector) {
start = start || new Vector(100, 100);
super([
start,
start.copy().add(25, 0),
start.copy().add(75, 0),
start.copy().add(100, 0),
]);
}
}
export class SBendLeft extends StraightTrack {
constructor(start?: Vector) {
start = start || new Vector(100, 100);
super(start);
this.points[2].add(0, -25);
this.points[3].add(0, -25);
}
}
export class SBendRight extends StraightTrack {
constructor(start?: Vector) {
start = start || new Vector(100, 100);
super(start);
this.points[2].add(0, 25);
this.points[3].add(0, 25);
}
}
export class BankLeft extends StraightTrack {
constructor(start?: Vector) {
start = start || new Vector(100, 100);
super(start);
this.points[2].add(0, -25);
this.points[3].add(0, 25);
}
}
export class BankRight extends StraightTrack {
constructor(start?: Vector) {
start = start || new Vector(100, 100);
super(start);
this.points[2].add(0, 25);
this.points[3].add(0, -25);
}
}