diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-03-24 17:08:47 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-03-24 17:08:47 -0400 |
| commit | 0a67e7f8ab74f82212a123dd6c30903124c1e8df (patch) | |
| tree | fa7c46742bf4be85ed0c85e3d5e68787debb7ba8 /public/assets/javascripts/rectangles/engine/scenery/sound.js | |
| parent | e9aaaba09e7872fd6fd164f02ea6cc28251962b8 (diff) | |
sound interpolation
Diffstat (limited to 'public/assets/javascripts/rectangles/engine/scenery/sound.js')
| -rw-r--r-- | public/assets/javascripts/rectangles/engine/scenery/sound.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/public/assets/javascripts/rectangles/engine/scenery/sound.js b/public/assets/javascripts/rectangles/engine/scenery/sound.js new file mode 100644 index 0000000..2f7f8de --- /dev/null +++ b/public/assets/javascripts/rectangles/engine/scenery/sound.js @@ -0,0 +1,17 @@ + +Scenery.sound = {} +Scenery.sound.max_distance = 600 +Scenery.sound.init = function(){ + app.tube.on("move", Scenery.sound.move) +} +Scenery.sound.move = function(){ + var vals = Scenery.map(function(scenery){ + if ((scenery.type == "video" || scenery.type == "audio") && ! scenery.muted()) { + //get distance from A to B + var distance = dist(cam.x, cam.z, + scenery.mx.x, scenery.mx.z) + var volume = 1 - (clamp( distance, 0, Scenery.sound.max_distance ) / Scenery.sound.max_distance) + scenery.setVolume(volume) + } + }) +} |
