summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/engine/scenery/sound.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/rectangles/engine/scenery/sound.js')
-rw-r--r--public/assets/javascripts/rectangles/engine/scenery/sound.js17
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)
+ }
+ })
+}