]> git.r.bdr.sh - rbdr/lissajous/blobdiff - lib/systems/lissajous_position_updater.js
Add a few comments
[rbdr/lissajous] / lib / systems / lissajous_position_updater.js
index 39b151ac85d250ead87eaf6356f6b6869944b71a..030d9bab44be5391cc9060a384fe70e9728500e3 100644 (file)
@@ -6,6 +6,12 @@ const internals = {
   kPeriod: Math.PI * 12000000
 };
 
   kPeriod: Math.PI * 12000000
 };
 
+/**
+  * Calculates the lissajous curve over time
+  * NOTE: This shouldn't store data, I should have a different entity for
+  * the actual drawable vertices. Either put the storage in the curve, or
+  * create a separate entity.
+  */
 export default class WebGLRenderer extends System {
 
   constructor() {
 export default class WebGLRenderer extends System {
 
   constructor() {
@@ -30,9 +36,9 @@ export default class WebGLRenderer extends System {
     this.time = (this.time + dt / 500) % internals.kPeriod;
 
     for (const curve of this.curves) {
     this.time = (this.time + dt / 500) % internals.kPeriod;
 
     for (const curve of this.curves) {
-      curve.position.x = this._getPosition(curve.amplitude.a, curve.frequency.a, this.time, 0);
-      curve.position.y = this._getPosition(curve.amplitude.b, curve.frequency.b, this.time, 0);
-      curve.position.z = this._getPosition(curve.amplitude.c, curve.frequency.c, this.time, 0);
+      curve.position.x = this._getPosition(curve.amplitude.a, curve.frequency.a, this.time, curve.phase.a);
+      curve.position.y = this._getPosition(curve.amplitude.b, curve.frequency.b, this.time, curve.phase.b);
+      curve.position.z = this._getPosition(curve.amplitude.c, curve.frequency.c, this.time, curve.phase.c);
     }
   }
 
     }
   }