Skip to content

Commit

Permalink
Fixed valid state detection
Browse files Browse the repository at this point in the history
  • Loading branch information
glopesdev authored and honnet committed Sep 8, 2019
1 parent 0d11fd3 commit 7e2427d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion hivetracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function TrackerState(messageH, messageV) {
};

this.isValid = function (id) {
return this.hits[id].centroid != 0 && this.hits[id].centroid != 0;
return messageH.centroid[id] != 0 && messageV.centroid[id] != 0;
};
}

Expand Down
7 changes: 4 additions & 3 deletions visualization/visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,21 +173,22 @@ function animate() {
requestAnimationFrame(animate);
controls.update();

if (state1 !== undefined) {
if (state1 !== undefined && state1.isValid(0)) {
var direction = state1.hits[0].direction.clone();
direction.multiplyScalar(-4);
direction.applyMatrix4(base1.mesh.matrixWorld);
directionLine1.setVertices(base1.mesh.getWorldPosition(), direction);
}

if (state2 !== undefined) {
if (state2 !== undefined && state2.isValid(0)) {
var direction = state2.hits[0].direction.clone();
direction.multiplyScalar(-4);
direction.applyMatrix4(base2.mesh.matrixWorld);
directionLine2.setVertices(base2.mesh.getWorldPosition(), direction);
}

if (state1 !== undefined && state2 !== undefined) {
if (state1 !== undefined && state2 !== undefined &&
state1.isValid(0) && state2.isValid(0)) {
var hit1 = state1.hits[0];
var hit2 = state2.hits[0];
var intersection = new SensorIntersection(
Expand Down

0 comments on commit 7e2427d

Please sign in to comment.