create pallet

This commit is contained in:
Nebel 2020-12-29 11:54:14 +09:00
parent e3be64d253
commit 9d54c18876
2 changed files with 6 additions and 3 deletions

4
src/config/pallet.ts Normal file
View file

@ -0,0 +1,4 @@
/** 使用する色コードの配列 */
const pallet = ["red", "green", "blue", "cyan", "magenta", "yellow"];
export default pallet;

View file

@ -12,6 +12,7 @@ import {
import randomInt from "./randomInt"; import randomInt from "./randomInt";
import keyPosition from "./keyPosition"; import keyPosition from "./keyPosition";
import keyLayouts from "./config/keyLayouts"; import keyLayouts from "./config/keyLayouts";
import pallet from "./config/pallet";
const root = document.body; const root = document.body;
const scene = new Scene(); const scene = new Scene();
@ -37,9 +38,7 @@ function drawRect() {
const [intersect] = raycaster.intersectObjects(panels); const [intersect] = raycaster.intersectObjects(panels);
if (!intersect) return; if (!intersect) return;
const c16s = ["red", "green", "blue", "cyan", "magenta", "yellow"]; const color = pallet[randomInt(pallet.length - 1)];
const c16 = c16s[randomInt(c16s.length - 1)];
const color = new Color(c16);
const geometry = new PlaneGeometry(1, 1); const geometry = new PlaneGeometry(1, 1);
const material = new MeshBasicMaterial({ color }); const material = new MeshBasicMaterial({ color });
const mesh = new Mesh(geometry, material); const mesh = new Mesh(geometry, material);