World editor graph editor additions

World editor graph editor additions

Overview

  • Added the ability to manipulate the graph editor including displaying graphs and adding segments between points.
  • Added event listeners to handle mouse input.
  • Added utility functions for getting distance

File wise changes made

index.html

  • Added scripts to import graphEditor.js and utils.js
  • Replaced direct calls to draw the graph with instantiating a GraphEditor object and calling its display method
  • Added animation to the canvas using requestAnimationFrame

js/graphEditor.js

  • Added GraphEditor class with methods for handling mouse events, selecting and manipulating points and segments, and displaying the graph
  • Added event listeners for mouse down, move, and up events to enable user interaction with the graph

js/math/utils.js

  • Added getNearestPoint function to find the point in a list that is closest to a given location within a certain threshold
  • Added distance function to calculate the distance between two points

Summary

  • Added scripts for the graph editor and math utilities to index.html.
  • Changed the drawing of the graph in index.html to use the GraphEditor class.
  • Added a new GraphEditor class to js/graphEditor.js.
  • Added a function to get the nearest point to a given point in js/math/utils.js.
  • Added a function to calculate the distance between two points in js/math/utils.js.