From 9207036cb9a94280b551d908038e4ea293c26000 Mon Sep 17 00:00:00 2001 From: RGBCube Date: Tue, 19 Dec 2023 20:20:35 +0300 Subject: [PATCH] Spin cube if no mouse event in the last 10 seconds --- cube.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cube.js b/cube.js index 97843fd..498eeb2 100644 --- a/cube.js +++ b/cube.js @@ -111,7 +111,7 @@ const orientation = { { const mouse = { down: false, - lastMove: 0, + lastMove: -10_000, previous: null, }; @@ -207,6 +207,10 @@ const orientation = { velocity.z = 0; } + if (window.performance.now() - mouse.lastMove > 10_000) { + velocity = new Vec3(1, 1, -1); + } + const axis = new Vec3(velocity.x, velocity.y, velocity.z) .normalize() .scale(theta);