Skip to content

Commit

Permalink
[bluetooth] Switch OrientationEvent to use Quaternion for now.
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarron committed Jul 3, 2020
1 parent 69205a7 commit e1e6038
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/bluetooth/bluetooth-puzzle.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BlockMove } from "../alg";
import { Transformation } from "../kpuzzle";
import { BasicRotationTransformer, StreamTransformer } from "./transformer";
import { Quaternion } from "three";

/******** BluetoothPuzzle ********/

Expand All @@ -19,7 +20,7 @@ export interface MoveEvent {

// TODO: Only use the `quaternion` field in the `MoveEvent`?
export interface OrientationEvent {
quaternion: { x: number; y: number; z: number; w: number };
quaternion: Quaternion;
timeStamp: number;
debug?: object;
}
Expand Down
3 changes: 1 addition & 2 deletions src/bluetooth/gan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,9 @@ export class GanCube extends BluetoothPuzzle {
// quaternion: physicalState.rotQuat(),
});
}
const { x, y, z, w } = physicalState.rotQuat();
this.dispatchOrientation({
timeStamp: physicalState.timeStamp,
quaternion: { x, y, z, w },
quaternion: physicalState.rotQuat(),
});
this.lastMoveCounter = physicalState.moveCounter();
}
Expand Down
3 changes: 1 addition & 2 deletions src/bluetooth/gocube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,8 @@ export class GoCube extends BluetoothPuzzle {
this.lastTarget.slerp(targetQuat, 0.5);
this.currentQuat.rotateTowards(this.lastTarget, rotateTowardsRate);

const { x, y, z, w } = this.currentQuat;
this.dispatchOrientation({
quaternion: { x, y, z, w },
quaternion: this.currentQuat,
timeStamp: event.timeStamp,
});
}
Expand Down
7 changes: 1 addition & 6 deletions src/bluetooth/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,7 @@ export class BasicRotationTransformer implements StreamTransformer {
// console.log(maxAxis(U.applyQuaternion(quat)), maxAxis(F.applyQuaternion(quat)));
console.log(q2);

orientationEvent.quaternion = {
x: q2.x,
y: q2.y,
z: q2.z,
w: q2.w,
};
orientationEvent.quaternion = quat;

console.log(orientationEvent.quaternion);
}
Expand Down

0 comments on commit e1e6038

Please sign in to comment.