mirror of
https://github.com/RGBCube/rgbcube.github.io
synced 2025-05-28 03:45:10 +00:00
Use Vec3.zero()
This commit is contained in:
parent
784759ce4f
commit
977bbb4ec0
1 changed files with 5 additions and 5 deletions
10
cube.js
10
cube.js
|
@ -8,7 +8,7 @@ class Vec3 {
|
||||||
}
|
}
|
||||||
|
|
||||||
static zero() {
|
static zero() {
|
||||||
return new Vec(0, 0, 0);
|
return new Vec3(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
length() {
|
length() {
|
||||||
|
@ -90,7 +90,7 @@ class Quat {
|
||||||
|
|
||||||
let friction = 3;
|
let friction = 3;
|
||||||
let sensitivity = 0.01;
|
let sensitivity = 0.01;
|
||||||
let velocity = new Vec3(0, 0, 0);
|
let velocity = Vec3.zero();
|
||||||
|
|
||||||
const orientation = {
|
const orientation = {
|
||||||
__cube: document.querySelector(".cube"),
|
__cube: document.querySelector(".cube"),
|
||||||
|
@ -115,7 +115,7 @@ const orientation = {
|
||||||
previous: null,
|
previous: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
let impulseThisFrame = new Vec3(0, 0, 0);
|
let impulseThisFrame = Vec3.zero();
|
||||||
|
|
||||||
const handleUp = () => {
|
const handleUp = () => {
|
||||||
mouse.down = false;
|
mouse.down = false;
|
||||||
|
@ -130,7 +130,7 @@ const orientation = {
|
||||||
|
|
||||||
mouse.down = true;
|
mouse.down = true;
|
||||||
|
|
||||||
velocity = new Vec3(0, 0, 0);
|
velocity = Vec3.zero();
|
||||||
};
|
};
|
||||||
|
|
||||||
document.addEventListener("mousedown", handleDown);
|
document.addEventListener("mousedown", handleDown);
|
||||||
|
@ -187,7 +187,7 @@ const orientation = {
|
||||||
|
|
||||||
if (mouse.down) {
|
if (mouse.down) {
|
||||||
velocity = impulseThisFrame.scale(1 / delta);
|
velocity = impulseThisFrame.scale(1 / delta);
|
||||||
impulseThisFrame = new Vec3(0, 0, 0);
|
impulseThisFrame = Vec3.zero();
|
||||||
} else {
|
} else {
|
||||||
const decay = Math.exp(-delta * friction);
|
const decay = Math.exp(-delta * friction);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue