Skip to content

Commit

Permalink
sound controls
Browse files Browse the repository at this point in the history
  • Loading branch information
jzitelli committed Aug 13, 2017
1 parent 3173f82 commit a305fc0
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 22 deletions.
27 changes: 17 additions & 10 deletions poolvr.css
@@ -1,7 +1,7 @@
#overlay {
position: absolute;
left: 1.25vw;
right: 75vw;
right: 78vw;
top: 2.25vw;
/*width: 85%;*/
/*right: 2vw;*/
Expand Down Expand Up @@ -39,10 +39,10 @@
border: 0;
}
#sound {
margin-left: 5vh;
margin-left: 3vh;
}
#volume {
width: 15%;
width: 30%;
}
.panel {
background-color: rgba(70, 50, 80, 0.5);
Expand Down Expand Up @@ -75,7 +75,8 @@ h1, h2, h3 {
color: #b5e853;
}
h1 {
margin-top: 2vh;
margin-left: 1.75vh;
margin-top: 1.75vh;
font-size: 18pt;
}
h2 {
Expand All @@ -92,18 +93,24 @@ button {
font-size: 12pt;
font-style: bold;
text-align: center;
padding: 0.5vh;
margin-top: 2vh;
margin-bottom: 1.5vh;
margin-left: 1vh;
padding: 0.75vh;
margin-top: 1.75vh;
margin-bottom: 1.0vh;
margin-left: 1.5vh;
margin-right: 0.75vh;
color: #b5e853;
background-color: rgba(150, 40, 40, 0.6);
box-sizing: border-box;
}
a {
font-family: monospace;
font-size: 10pt;
font-size: 9pt;
color: #bef;
padding: 0.5vh;
padding: 0.25vh;
margin-left: 1.25vh;
}
hr {
margin-top: 1.75vh;
margin-bottom: 1.75vh;
width: 92%;
}
24 changes: 20 additions & 4 deletions poolvr_template.html
Expand Up @@ -7,10 +7,11 @@
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">

<title>poolvr {{version}}</title>
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="poolvr.css">

<title>poolvr {{version}}</title>

{{ json_config }}

</head>
Expand All @@ -20,15 +21,28 @@
<canvas id="webgl-canvas"></canvas>

<div id="overlay">

<h1>poolvr {{ version if version else '' }}</h1>{{version_content if version_content else ''}}

<div style="display: inline">

<button id="vrButton"><b>toggle VR</b></button>

<button id="fsButton"><b>toggle fullscreen</b></button>

</div>

<hr>

<div style="display: inline">
<button id="vrButton">toggle VR</button>
<!--
<button id="vrButton">toggle VR</button>
<button id="fsButton">toggle fullscreen</button>
<br>
-->
<label><input type="checkbox" id="sound"/>Sound</label>
<label><input type="range" id="volume" min="0.0", max="1.0" step="0.05"/>vol.</label>

<label><input type="range" id="volume" min="0.0", max="1.0" step="any"/>vol.</label>

<div class="panel" id="graphicsPanel">
<h3>Graphics:</h3>
Expand All @@ -46,7 +60,9 @@ <h3>Leap Motion:</h3>
<br>
<label>Websocket address:<input id="leapAddress" type="text" maxlength="18"/></label>
</div>
</div>{{ extra_overlay_content if extra_overlay_content else "" }}

</div>
{{ extra_overlay_content if extra_overlay_content else "" }}
</div>

{% if config['DEBUG'] %}
Expand Down
5 changes: 3 additions & 2 deletions src/SynthSpeaker.js
Expand Up @@ -2,7 +2,7 @@ module.exports = ( function() {
"use strict";
function SynthSpeaker(options) {
options = options || {};
this.volume = options.volume || 1;
this.volume = (options.volume === undefined ? 1 : options.volume);
this.rate = options.rate || 1;
this.pitch = options.pitch || 1;

Expand Down Expand Up @@ -51,8 +51,9 @@ module.exports = ( function() {
onBegin();
}
this.utterance.text = text;
this.utterance.volume = this.volume;
this.speaking = true;
if (POOLVR.config.soundVolume > 0) {
if (this.utterance.volume > 0) {
speechSynthesis.speak(this.utterance);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/main.js
Expand Up @@ -18,10 +18,10 @@ POOLVR.onLoad = function () {
"use strict";
const INCH2METERS = 0.0254;

// if (Utils.URL_PARAMS.clearLocalStorage) {
if (Utils.URL_PARAMS.clearLocalStorage) {
console.log('clearing localStorage...');
localStorage.clear();
// }
}

THREE.Object3D.DefaultMatrixAutoUpdate = false;

Expand All @@ -41,9 +41,9 @@ POOLVR.onLoad = function () {
rate: POOLVR.config.synthSpeakerRate || 0.75,
pitch: POOLVR.config.synthSpeakerPitch || 0.5
});
if (!loadedConfig) {
POOLVR.synthSpeaker.speak("Hello. Welcome. To. Pool-ver.");
}
// if (!loadedConfig) {
// POOLVR.synthSpeaker.speak("Hello. Welcome. To. Pool-ver.");
// }

var appConfig = {
onResetVRSensor: function () {
Expand Down
25 changes: 25 additions & 0 deletions src/menu.js
Expand Up @@ -18,6 +18,7 @@ POOLVR.setupMenu = function () {
function onFocus() {
POOLVR.keyboard.enabled = false;
}

function onBlur() {
POOLVR.keyboard.enabled = true;
}
Expand All @@ -34,6 +35,30 @@ POOLVR.setupMenu = function () {
var volumeInput = document.getElementById('volume');
volumeInput.value = POOLVR.config.soundVolume;

volumeInput.addEventListener('change', function () {
POOLVR.config.soundVolume = volumeInput.value;
console.log('volume set to', POOLVR.config.soundVolume);
POOLVR.synthSpeaker.volume = POOLVR.config.soundVolume;
if (POOLVR.config.soundVolume > 0.0) {
soundInput.checked = true;
} else {
soundInput.checked = false;
}
});

soundInput.addEventListener('change', function () {
if (soundInput.checked) {
console.log('sound enabled');
POOLVR.config.soundVolume = 0.25;
POOLVR.synthSpeaker.volume = 0.25;
} else {
console.log('sound disabled');
POOLVR.config.soundVolume = 0.0;
POOLVR.synthSpeaker.volume = 0.0;
}
volumeInput.value = POOLVR.config.soundVolume;
});

var useBasicMaterialsInput = document.getElementById('useBasicMaterials');
useBasicMaterialsInput.checked = POOLVR.config.useBasicMaterials;

Expand Down
2 changes: 1 addition & 1 deletion src/sounds.js
Expand Up @@ -24,7 +24,7 @@ POOLVR.playPocketedSound = (function () {
ballPocketedBuffer = buffer;
});
var playPocketedSound = function () {
if (POOLVR.config.soundVolume) {
if (POOLVR.config.soundVolume > 0.0) {
Audio.playBuffer(ballPocketedBuffer, POOLVR.config.soundVolume * 0.5);
}
};
Expand Down

0 comments on commit a305fc0

Please sign in to comment.