1
Fork 0
mirror of https://github.com/RGBCube/rgbcube.github.io synced 2025-05-14 05:54:58 +00:00

Use Vec3.zero()

This commit is contained in:
RGBCube 2023-12-20 09:42:49 +03:00
parent 784759ce4f
commit 977bbb4ec0
No known key found for this signature in database

10
cube.js
View file

@ -8,7 +8,7 @@ class Vec3 {
}
static zero() {
return new Vec(0, 0, 0);
return new Vec3(0, 0, 0);
}
length() {
@ -90,7 +90,7 @@ class Quat {
let friction = 3;
let sensitivity = 0.01;
let velocity = new Vec3(0, 0, 0);
let velocity = Vec3.zero();
const orientation = {
__cube: document.querySelector(".cube"),
@ -115,7 +115,7 @@ const orientation = {
previous: null,
};
let impulseThisFrame = new Vec3(0, 0, 0);
let impulseThisFrame = Vec3.zero();
const handleUp = () => {
mouse.down = false;
@ -130,7 +130,7 @@ const orientation = {
mouse.down = true;
velocity = new Vec3(0, 0, 0);
velocity = Vec3.zero();
};
document.addEventListener("mousedown", handleDown);
@ -187,7 +187,7 @@ const orientation = {
if (mouse.down) {
velocity = impulseThisFrame.scale(1 / delta);
impulseThisFrame = new Vec3(0, 0, 0);
impulseThisFrame = Vec3.zero();
} else {
const decay = Math.exp(-delta * friction);