From d3b462fa53b9b5aae9c6ee2c58bd9f67d8f17d50 Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Tue, 29 Dec 2020 17:49:51 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=9F=B3=E3=82=92=E9=B3=B4=E3=82=89?= =?UTF-8?q?=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 ++- src/main.ts | 3 +++ yarn.lock | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index b3e5fa9..263e3f3 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "license": "MIT", "devDependencies": { "snowpack": "^2.18.5", - "three": "^0.124.0" + "three": "^0.124.0", + "tone": "^14.7.58" }, "scripts": { "dev": "snowpack dev", diff --git a/src/main.ts b/src/main.ts index 31fe120..4ff9f0d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,6 +9,7 @@ import { Vector2, WebGLRenderer, } from "three"; +import { Synth } from "tone"; import randomInt from "./randomInt"; import keyPosition from "./keyPosition"; import keyLayouts from "./config/keyLayouts"; @@ -28,6 +29,7 @@ const panels = Array.from({ length: grid.colum * grid.row }, () => { const renderer = new WebGLRenderer(); const canvas = renderer.domElement; const raycaster = new Raycaster(); +const synth = new Synth({ oscillator: { type: "square" } }).toDestination(); function render() { renderer.render(scene, camera); @@ -38,6 +40,7 @@ function drawRect() { const [intersect] = raycaster.intersectObjects(panels); if (!intersect) return; + synth.triggerAttackRelease("C4", "16n"); const color = pallet[randomInt(pallet.length - 1)]; const geometry = new PlaneGeometry(1, 1); const material = new MeshBasicMaterial({ color }); diff --git a/yarn.lock b/yarn.lock index 8acd0ee..08d7559 100644 --- a/yarn.lock +++ b/yarn.lock @@ -23,6 +23,13 @@ chalk "^2.0.0" js-tokens "^4.0.0" +"@babel/runtime@^7.12.5": + version "7.12.5" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.12.5.tgz#410e7e487441e1b360c29be715d870d9b985882e" + integrity sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg== + dependencies: + regenerator-runtime "^0.13.4" + "@npmcli/move-file@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@npmcli/move-file/-/move-file-1.0.1.tgz#de103070dac0f48ce49cf6693c23af59c0f70464" @@ -227,6 +234,14 @@ assert@^1.4.1: object-assign "^4.1.1" util "0.10.3" +automation-events@^3.0.2: + version "3.0.3" + resolved "https://registry.yarnpkg.com/automation-events/-/automation-events-3.0.3.tgz#08de5bdef461bd0c9ed6cd3a7a660afa7112cecd" + integrity sha512-iFZcgSVwp8JnSXCv15LQ/tyKEAm+ToBTseD3bYWwIUUUzWQGwUMKMmIm2hM+KlfC0qBZu1xj/WqidhqvGvA3sA== + dependencies: + "@babel/runtime" "^7.12.5" + tslib "^2.0.3" + balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" @@ -1433,6 +1448,11 @@ readdirp@~3.5.0: dependencies: picomatch "^2.2.1" +regenerator-runtime@^0.13.4: + version "0.13.7" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55" + integrity sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew== + requires-port@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" @@ -1620,6 +1640,15 @@ ssri@^8.0.0: dependencies: minipass "^3.1.1" +standardized-audio-context@^25.0.4: + version "25.1.6" + resolved "https://registry.yarnpkg.com/standardized-audio-context/-/standardized-audio-context-25.1.6.tgz#c1908fe6b8fe221cc2836c9873573474f7992ad0" + integrity sha512-iHvPiwbDctxpmP9sufnADBeiBpYc8km6i53TFGVGkc5usBmAJ8YNhATXXrSFZYR4MGxIImZGWCCH4LrPatPFrQ== + dependencies: + "@babel/runtime" "^7.12.5" + automation-events "^3.0.2" + tslib "^2.0.3" + string-hash@^1.1.1: version "1.1.3" resolved "https://registry.yarnpkg.com/string-hash/-/string-hash-1.1.3.tgz#e8aafc0ac1855b4666929ed7dd1275df5d6c811b" @@ -1680,6 +1709,19 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" +tone@^14.7.58: + version "14.7.58" + resolved "https://registry.yarnpkg.com/tone/-/tone-14.7.58.tgz#c1a31597184115aedf44ea6310a30efe902645e7" + integrity sha512-OzXsCkmaU/tLcNBc4M4dzHAjBzUGm+29DbWmAkAcCvpzWkLqo61RTcJa8tmS63F/7JHPiAJEOpuInMXw3mCvIg== + dependencies: + standardized-audio-context "^25.0.4" + tslib "^2.0.1" + +tslib@^2.0.1, tslib@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.0.3.tgz#8e0741ac45fc0c226e58a17bfc3e64b9bc6ca61c" + integrity sha512-uZtkfKblCEQtZKBF6EBXVZeQNl82yqtDQdv+eck8u7tdPxjLu2/lp5/uPW+um2tpuxINHWy3GhiccY7QgEaVHQ== + uniq@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/uniq/-/uniq-1.0.1.tgz#b31c5ae8254844a3a8281541ce2b04b865a734ff"