mirror of
https://github.com/RGBCube/rgbcube.github.io
synced 2025-05-24 18:25:07 +00:00
Change rotation algo
This commit is contained in:
parent
8d4f49e055
commit
b800086988
1 changed files with 4 additions and 6 deletions
10
cube.js
10
cube.js
|
@ -75,7 +75,7 @@ class Quat {
|
||||||
}
|
}
|
||||||
|
|
||||||
apply() {
|
apply() {
|
||||||
__cube.style.transform = `rotate3d(${this.x}, ${this.y}, ${this.z}, ${this.w * 3.1415}rad)`;
|
__cube.style.transform = `rotate3d(${this.x}, ${this.y}, ${this.z}, ${Math.acos(this.w) * 2}rad)`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,11 +132,9 @@ const orientation = {
|
||||||
mouse.previous = newMouse;
|
mouse.previous = newMouse;
|
||||||
mouse.lastMove = window.performance.now();
|
mouse.lastMove = window.performance.now();
|
||||||
|
|
||||||
const rotation = Quat.mul(
|
const axis = new Vec2(-delta.y,delta.x);
|
||||||
Quat.fromAngleAxis(delta.x * sensitivity, Vec3.up),
|
const rotation = Quat.fromAngleAxis(delta.length() * sensitivity, axis);
|
||||||
Quat.fromAngleAxis(delta.y * sensitivity, Vec3.right),
|
|
||||||
);
|
|
||||||
|
|
||||||
orientation.set(Quat.mul(orientation.get(), rotation));
|
orientation.set(Quat.mul(rotation, orientation.get()));
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue