Merge branch 'master' of gitea.iwm-tuebingen.de:IWMBrowser/iwmlib

This commit is contained in:
2019-05-31 13:59:02 +02:00
6 changed files with 879 additions and 64 deletions
+19 -10
View File
@@ -122,12 +122,23 @@ export class PointMap extends MapProxy {
}
export class InteractionDelta {
constructor(x, y, zoom, rotate, about) {
/**
*Creates an instance of InteractionDelta.
* @param {*} x
* @param {*} y
* @param {*} zoom
* @param {*} rotate
* @param {*} about
* @param {*} number - number of involved pointer
* @memberof InteractionDelta
*/
constructor(x, y, zoom, rotate, about, number) {
this.x = x
this.y = y
this.zoom = zoom
this.rotate = rotate
this.about = about
this.number = number
}
toString() {
@@ -201,16 +212,13 @@ export class InteractionPoints {
let p1 = this.previous.get(c1.key)
let p2 = this.previous.get(c2.key)
//let p1 = previous[0]
//let p2 = previous[1]
let d1 = Points.subtract(c1, p1)
let d2 = Points.subtract(c2, p2)
let cm = Points.mean(c1, c2)
//let pm = Points.mean(p1, p2)
// UO: Using the mean lead to jumps between time slices with 3 and 2 fingers
// Using the mean leads to jumps between time slices with 3 and 2 fingers
// We use the mean of deltas instead
let delta = Points.mean(d1, d2) //Points.subtract(cm, pm)
let delta = Points.mean(d1, d2)
let zoom = 1.0
let distance1 = Points.distance(p1, p2)
let distance2 = Points.distance(c1, c2)
@@ -220,13 +228,14 @@ export class InteractionPoints {
let currentAngle = Points.angle(c1, c2)
let previousAngle = Points.angle(p1, p2)
let alpha = this.diffAngle(currentAngle, previousAngle)
return new InteractionDelta(delta.x, delta.y, zoom, alpha, cm)
return new InteractionDelta(delta.x, delta.y, zoom, alpha, cm, csize)
} else if (csize == 1 && psize == 1 && this.current.firstKey() == this.previous.firstKey()) {
// We need to ensure that the keys are the same
// We need to ensure that the keys are the same, since single points with different keys
// can jump
let current = this.current.first()
let previous = this.previous.first()
let delta = Points.subtract(current, previous)
return new InteractionDelta(delta.x, delta.y, 1.0, 0.0, current)
return new InteractionDelta(delta.x, delta.y, 1.0, 0.0, current, csize)
}
return null
}
+4 -2
View File
@@ -127,7 +127,9 @@ class Throwable {
this.lastframe = t
if (dt > 0) {
// Avoid division by zero errors later on
let velocity = { t: t, dt: dt, dx: delta.x, dy: delta.y }
// and consider the number of involved pointers sind addVelocity will be called by the
// onMove events
let velocity = { t: t, dt: dt, dx: delta.x / delta.number, dy: delta.y / delta.number}
this.velocities.push(velocity)
while (this.velocities.length > buffer) {
this.velocities.shift()
@@ -136,7 +138,7 @@ class Throwable {
}
meanVelocity(milliseconds = 30) {
this.addVelocity({ x: 0, y: 0 })
this.addVelocity({ x: 0, y: 0, number: 1 })
let sum = { x: 0, y: 0 }
let count = 0
let t = 0