'a'
mh-two-thousand-and-two
2024-04-12 44d2c92345cd156a59fc327b3060292a282d2893
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
export function Friction (e) {
  this._drag = e
  this._dragLog = Math.log(e)
  this._x = 0
  this._v = 0
  this._startTime = 0
}
 
Friction.prototype.set = function (e, t) {
  this._x = e
  this._v = t
  this._startTime = (new Date()).getTime()
}
Friction.prototype.setVelocityByEnd = function (e) {
  this._v = (e - this._x) * this._dragLog / (Math.pow(this._drag, 100) - 1)
}
Friction.prototype.x = function (e) {
  if (e === undefined) {
    e = ((new Date()).getTime() - this._startTime) / 1e3
  }
  var t
  t = e === this._dt && this._powDragDt ? this._powDragDt : this._powDragDt = Math.pow(this._drag, e)
  this._dt = e
  return this._x + this._v * t / this._dragLog - this._v / this._dragLog
}
Friction.prototype.dx = function (e) {
  if (e === undefined) {
    e = ((new Date()).getTime() - this._startTime) / 1e3
  }
  var t
  t = e === this._dt && this._powDragDt ? this._powDragDt : this._powDragDt = Math.pow(this._drag, e)
  this._dt = e
  return this._v * t
}
Friction.prototype.done = function () {
  return Math.abs(this.dx()) < 3
}
Friction.prototype.reconfigure = function (e) {
  var t = this.x()
  var n = this.dx()
  this._drag = e
  this._dragLog = Math.log(e)
  this.set(t, n)
}
Friction.prototype.configuration = function () {
  var e = this
  return [{
    label: 'Friction',
    read: function () {
      return e._drag
    },
    write: function (t) {
      e.reconfigure(t)
    },
    min: 0.001,
    max: 0.1,
    step: 0.001
  }]
}