Edge.js 663 B

123456789101112131415161718192021222324252627282930
  1. //墙的边缘线
  2. import Geometry from "./Geometry.js";
  3. import VectorType from "../enum/VectorType.js";
  4. import { mathUtil } from "../Util/MathUtil";
  5. export default class Edge extends Geometry {
  6. constructor(start, end, parentId) {
  7. super();
  8. this.parent = parentId;
  9. this.start = {};
  10. this.end = {};
  11. this.vectorId = null;
  12. this.geoType = VectorType.Edge;
  13. this.setPositions(start, end);
  14. }
  15. setPositions(point1, point2) {
  16. this.start.x = point1.x;
  17. this.start.y = point1.y;
  18. this.end.x = point2.x;
  19. this.end.y = point2.y;
  20. }
  21. getLine() {
  22. let line = mathUtil.createLine(this.start, this.end);
  23. return line;
  24. }
  25. }