From 2851a67ecaee784cca50e404f2ee0d0d56310824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jurij=20Podgor=C5=A1ek?= Date: Sat, 24 Sep 2022 14:09:46 +0200 Subject: [PATCH] Nekaj popravkov --- anim.js | 17 +++++++---------- osctl.js | 21 ++++++--------------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/anim.js b/anim.js index c44d343..f9f1186 100644 --- a/anim.js +++ b/anim.js @@ -179,7 +179,7 @@ function objAnim() { function addObj(w, h) { var col = new THREE.Color(); //col.setHSL(stevec * barva_mod, saturacija, svetlost); - col.setHSL(stevec * barva_mod, saturacija, (Math.sin(stevec/barvapuls) / 6) + 0.3); + col.setHSL(stevec * barva_mod, saturacija, (Math.sin(stevec/barvapuls) / 6) + 0.5); var mat = new THREE.LineBasicMaterial({ color: col @@ -219,16 +219,15 @@ qK = new THREE.Quaternion() function camRotate () { //scene.setRotationFromQuaternion(qKamera) - scene.rotation.x += crotacijaX - scene.rotation.y += crotacijaY - scene.rotation.z += crotacijaZ + scene.rotation.x += crotacijaX; + scene.rotation.y += crotacijaY; + scene.rotation.z += crotacijaZ; } // Inicializiraj document.onreadystatechange = function () { if (document.readyState === 'complete') { document.getElementById("anim-container").appendChild(renderer.domElement); - render(); } }; @@ -256,13 +255,13 @@ const kbdPressed = { window.addEventListener('keydown', (e) => { kbdPressed[e.key] = true; -}) +}); window.addEventListener('keyup', (e) => { if (e.key in kbdPressed) { kbdPressed[e.key] = false; } -}) +}); var prepend = '/ww/0'; @@ -274,8 +273,6 @@ oscCallbacks[prepend + '/keys'] = function(args) { keysPressed[1] |= kbdPressed['s']; keysPressed[2] |= kbdPressed['d']; keysPressed[3] |= kbdPressed['f']; - //console.log(keysPressed, kbdPressed); - console.log(args) }; oscCallbacks[prepend + '/quaternion'] = function (args) { // Popravimo osi (w x y z po defaultu HMM) @@ -286,7 +283,7 @@ oscCallbacks[prepend + '/quaternionDiff'] = function (args) { }; oscCallbacks[prepend + '/eulerDiff'] = function (args) { [dqX, dqY, dqZ] = args.map(getVal); -} +}; /* Ne uporabljamo vec '/gyro/': [ diff --git a/osctl.js b/osctl.js index 357b4dc..d611763 100644 --- a/osctl.js +++ b/osctl.js @@ -3,23 +3,14 @@ var oscPort = new osc.WebSocketPort({ metadata: true }); -oscPort.open(); - oscPort.on("ready", function () { console.log("OSC listening!") - // Example send - /* - oscPort.send({ - address: "/carrier/frequency", - args: [ - { - type: "f", - value: 440 - } - ] - }); - */ oscPort.on("message", function (msg) { - oscCallbacks[msg.address].forEach(cb => cb(msg.args)) + var cb = oscCallbacks[msg.address] + if (cb) { + cb(msg.args) + } }); }); + +oscPort.open();