From 5b578d532f1e0325c282b652fdda5f5e65d956e3 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Sat, 7 Mar 2020 19:53:19 -0700 Subject: [PATCH] Work better with only one video source --- convulse.html | 2 +- convulse.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/convulse.html b/convulse.html index 5c45d27..aafbcab 100644 --- a/convulse.html +++ b/convulse.html @@ -39,7 +39,7 @@
UR FACE - +
diff --git a/convulse.js b/convulse.js index c422b2b..694da98 100644 --- a/convulse.js +++ b/convulse.js @@ -55,7 +55,6 @@ class Convulse { navigator.mediaDevices.getUserMedia({video: true, audio: true}) .then(media => { - console.log(media) document.querySelector("#hello").classList.add("hidden") this.webcamVideo.muted = true this.webcamVideo.srcObject = media @@ -161,7 +160,7 @@ class Convulse { } frame(timestamp) { - if (this.webcamVideo.videoWidth > 0) { + if (this.desktopVideo.videoWidth > 0) { this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height) let desktopAR = this.desktopVideo.videoWidth / this.desktopVideo.videoHeight @@ -174,7 +173,9 @@ class Convulse { desktopX, desktopY, desktopWidth, desktopHeight ) - + } + + if (this.webcamVideo.videoWidth > 0) { let webcamAR = this.webcamVideo.videoWidth / this.webcamVideo.videoHeight let webcamHeight = this.canvas.height * this.webcamSize let webcamWidth = webcamHeight * webcamAR @@ -185,6 +186,7 @@ class Convulse { webcamX, webcamY, webcamWidth, webcamHeight ) + console.log(webcamAR) } requestAnimationFrame(ts => this.frame(ts))