]>
git.r.bdr.sh - rbdr/lissajous/blob - lib/systems/lissajous_position_updater.js
da90fb26631a34000ea67c0f9c1d6c307dfd3577
1 import { System
} from '@serpentity/serpentity';
2 import LissajousCurve
from '../nodes/lissajous_curve';
6 kPeriod: Math
.PI
* 12000000
9 export default class WebGLRenderer
extends System
{
18 this.curves
= engine
.getNodes(LissajousCurve
);
30 this.time
= (this.time
+ dt
/ 500) % internals
.kPeriod
;
32 for (const curve
of this.curves
) {
33 curve
.position
.x
= this._getPosition(curve
.amplitude
.a
, curve
.frequency
.a
, this.time
, curve
.phase
.a
);
34 curve
.position
.y
= this._getPosition(curve
.amplitude
.b
, curve
.frequency
.b
, this.time
, curve
.phase
.b
);
35 curve
.position
.z
= this._getPosition(curve
.amplitude
.c
, curve
.frequency
.c
, this.time
, curve
.phase
.c
);
39 _getPosition(amplitude
, frequency
, time
, phaseShift
) {
41 return amplitude
* Math
.sin(frequency
* time
+ phaseShift
);