mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Ignore spurious finger tip position values
This commit is contained in:
parent
784009a9fa
commit
777a0b51c1
1 changed files with 10 additions and 2 deletions
|
@ -70,7 +70,9 @@
|
|||
|
||||
function drawLine(position, width) {
|
||||
// Add a stroke to the polyline if stroke is a sufficient length.
|
||||
var localPosition;
|
||||
var localPosition,
|
||||
distanceToPrevious,
|
||||
MAX_DISTANCE_TO_PREVIOUS = 1.0;
|
||||
|
||||
if (!isDrawingLine) {
|
||||
print("ERROR: drawLine() called when not drawing line");
|
||||
|
@ -78,8 +80,14 @@
|
|||
}
|
||||
|
||||
localPosition = Vec3.subtract(position, basePosition);
|
||||
distanceToPrevious = Vec3.distance(localPosition, strokePoints[strokePoints.length - 1]);
|
||||
|
||||
if (Vec3.distance(localPosition, strokePoints[strokePoints.length - 1]) >= MIN_STROKE_LENGTH
|
||||
if (distanceToPrevious > MAX_DISTANCE_TO_PREVIOUS) {
|
||||
// Ignore occasional spurious finger tip positions.
|
||||
return;
|
||||
}
|
||||
|
||||
if (distanceToPrevious >= MIN_STROKE_LENGTH
|
||||
&& strokePoints.length < MAX_POINTS_PER_LINE) {
|
||||
strokePoints.push(localPosition);
|
||||
strokeNormals.push(strokeNormal());
|
||||
|
|
Loading…
Reference in a new issue