repo: janusweb action: commit revision: path_from: revision_from: 811257593461940555dab971b9cbf0ee66b9fcca: path_to: revision_to:
commit 811257593461940555dab971b9cbf0ee66b9fcca Author: James BaicoianuDate: Thu Aug 17 02:02:55 2017 -0700 Support for pitch, use 2d audio if rect is specified diff --git a/scripts/sound.js b/scripts/sound.js
--- a/scripts/sound.js
+++ b/scripts/sound.js
@@ -40,7 +40,7 @@ elation.require(['janusweb.janusbase'], function() {
}
var listener = this.engine.systems.sound.getRealListener();
if (listener) {
- if (false && this.rect) {
+ if (this.rect) {
this.audio = new THREE.Audio(listener);
} else {
this.audio = new THREE.PositionalAudio(listener);
@@ -57,6 +57,7 @@ elation.require(['janusweb.janusbase'], function() {
this.audio.autoplay = this.auto_play;
this.audio.setLoop(this.loop);
this.audio.setVolume(this.gain);
+ this.audio.setPlaybackRate(this.pitch);
if (src) {
if (soundcache[src]) {
this.audio.setBuffer(soundcache[src]);
@@ -76,12 +77,6 @@ elation.require(['janusweb.janusbase'], function() {
this.objects['3d'].add(this.audio);
}
}
- this.updateSound = function() {
- var sound = elation.engine.assets.find('sound', this.sound_id);
- if (sound) {
- this.createAudio(sound.getProxiedURL(sound.src));
- }
- }
this.load = function(url) {
this.src = url;
if (this.audio.isPlaying) {
@@ -120,6 +115,7 @@ elation.require(['janusweb.janusbase'], function() {
if (this.audio) {
//this.play();
this.audio.setVolume(this.gain);
+ this.audio.setPlaybackRate(this.pitch);
}
if (this.rect) {
var parts = this.rect.split(' ');
@@ -150,6 +146,7 @@ elation.require(['janusweb.janusbase'], function() {
var proxy = elation.engine.things.janussound.extendclass.getProxyObject.call(this, classdef);
proxy._proxydefs = {
gain: [ 'property', 'gain'],
+ pitch: [ 'property', 'pitch'],
play: [ 'function', 'play'],
pause: [ 'function', 'pause'],
stop: [ 'function', 'stop'],
-----END OF PAGE-----