From 9e479406156ff307e21c4303f768fc45f7c51b6d Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Tue, 29 Dec 2020 17:15:59 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=81=A1=E3=82=89=E3=81=A4=E3=81=8B?= =?UTF-8?q?=E3=81=9B=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index eca12c4..31fe120 100644 --- a/src/main.ts +++ b/src/main.ts @@ -42,7 +42,8 @@ function drawRect() { const geometry = new PlaneGeometry(1, 1); const material = new MeshBasicMaterial({ color }); const mesh = new Mesh(geometry, material); - mesh.scale.set(0.1, 0.1, 1); + const offset = () => 0.05 * (Math.random() - 0.5); + mesh.scale.set(0.075 + offset(), 0.075 + offset(), 0); Object.assign(mesh.position, intersect.point); scene.add(mesh); render(); @@ -66,8 +67,9 @@ function handleKeydown({ key }: KeyboardEvent) { } function handleMouseMove(event: { clientX: number; clientY: number }) { - mouse.x = (event.clientX / canvas.clientWidth) * 2 - 1; - mouse.y = -(event.clientY / canvas.clientHeight) * 2 + 1; + const offset = () => 0.2 * (Math.random() - 0.5); + mouse.x = (event.clientX / canvas.clientWidth) * 2 - 1 + offset(); + mouse.y = -(event.clientY / canvas.clientHeight) * 2 + 1 + offset(); drawRect(); }