From 9d54c18876e720702913e9077c30cac921a2ed51 Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Tue, 29 Dec 2020 11:54:14 +0900 Subject: [PATCH] create pallet --- src/config/pallet.ts | 4 ++++ src/main.ts | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 src/config/pallet.ts diff --git a/src/config/pallet.ts b/src/config/pallet.ts new file mode 100644 index 0000000..13def8f --- /dev/null +++ b/src/config/pallet.ts @@ -0,0 +1,4 @@ +/** 使用する色コードの配列 */ +const pallet = ["red", "green", "blue", "cyan", "magenta", "yellow"]; + +export default pallet; diff --git a/src/main.ts b/src/main.ts index 07acf2b..46dba7e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -12,6 +12,7 @@ import { import randomInt from "./randomInt"; import keyPosition from "./keyPosition"; import keyLayouts from "./config/keyLayouts"; +import pallet from "./config/pallet"; const root = document.body; const scene = new Scene(); @@ -37,9 +38,7 @@ function drawRect() { const [intersect] = raycaster.intersectObjects(panels); if (!intersect) return; - const c16s = ["red", "green", "blue", "cyan", "magenta", "yellow"]; - const c16 = c16s[randomInt(c16s.length - 1)]; - const color = new Color(c16); + const color = pallet[randomInt(pallet.length - 1)]; const geometry = new PlaneGeometry(1, 1); const material = new MeshBasicMaterial({ color }); const mesh = new Mesh(geometry, material);