Implements doodler 0.0.3a
This commit is contained in:
15
track.ts
15
track.ts
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user