Implements doodler 0.0.3a

This commit is contained in:
Emma
2023-02-07 22:44:24 -07:00
parent f1c991bd3e
commit ae0575875f
12 changed files with 364 additions and 460 deletions

View File

@@ -1,5 +1,5 @@
import { PathSegment } from "./math/path.ts";
import { Vector } from "./math/vector.ts";
import { Vector } from "doodler";
import { Train } from "./train.ts";
export class Track extends PathSegment {
@@ -57,17 +57,13 @@ export class Track extends PathSegment {
}
getNearestPoint(p: Vector) {
let [closest, closestDistance, closestT] = this.getClosestPoint(p);
// deno-lint-ignore no-this-alias
let mostValid: Track = this;
let [closest, closestDistance] = this.getClosestPoint(p);
if (this.next !== this) {
const [point, distance, t] = this.next.getClosestPoint(p);
if (distance < closestDistance) {
closest = point;
closestDistance = distance;
mostValid = this.next;
closestT = t;
}
}
if (this.prev !== this) {
@@ -75,8 +71,6 @@ export class Track extends PathSegment {
if (distance < closestDistance) {
closest = point;
closestDistance = distance;
mostValid = this.next;
closestT = t;
}
}
@@ -91,10 +85,9 @@ export class Track extends PathSegment {
draw(): void {
super.draw();
if (this.ctx && this.editable)
if (this.editable)
for (const e of this.points) {
this.ctx.fillStyle = 'blue';
e.drawDot(this.ctx);
e.drawDot();
}
}
}