diff --git a/assets/sounds/beatHit.ogg b/assets/sounds/beatHit.ogg index 8dd23fd..cc523c6 100644 Binary files a/assets/sounds/beatHit.ogg and b/assets/sounds/beatHit.ogg differ diff --git a/src/components/beat-hit.js b/src/components/beat-hit.js index a6a0e9c..e3478a6 100644 --- a/src/components/beat-hit.js +++ b/src/components/beat-hit.js @@ -1,5 +1,32 @@ var audioContext = new window.AudioContext(); +// Allows for modifying detune. PR has been sent to three.js. +THREE.Audio.prototype.play = function () { + if ( this.isPlaying === true ) { + console.warn( 'THREE.Audio: Audio is already playing.' ); + return; + } + + if ( this.hasPlaybackControl === false ) { + console.warn( 'THREE.Audio: this Audio has no playback control.' ); + return; + } + + var source = this.context.createBufferSource(); + source.buffer = this.buffer; + source.detune.value = this.detune; + source.loop = this.loop; + source.onended = this.onEnded.bind( this ); + source.playbackRate.setValueAtTime( this.playbackRate, this.startTime ); + this.startTime = this.context.currentTime; + source.start( this.startTime, this.offset ); + + this.isPlaying = true; + + this.source = source; + return this.connect(); +}; + /** * Beat hit sound using positional audio and audio buffer source. * Pitch the sound up and down using the song audioanalyser FFT. @@ -20,9 +47,10 @@ AFRAME.registerComponent('beat-hit', { }); }, - processSound: function (sound) { - this.currentBeatEl.object3D.getWorldPosition(sound.position); - console.log(sound.position); - // this.currentBeatEl.setObject3D('sound', sound); + processSound: function (audio) { + // Randomize a bit. + audio.detune = (Math.random() * 1000) - 500; + audio.playbackRate = 0.80 + (Math.random() * .20); + this.currentBeatEl.object3D.getWorldPosition(audio.position); } }); diff --git a/src/index.html b/src/index.html index f110470..63278fe 100644 --- a/src/index.html +++ b/src/index.html @@ -2,7 +2,11 @@ Super Saber - + {% if IS_PRODUCTION %} + + {% else %} + + {% endif %} diff --git a/vendor/aframe.effects.js b/vendor/aframe-master.js similarity index 99% rename from vendor/aframe.effects.js rename to vendor/aframe-master.js index 3064421..a789c6f 100644 --- a/vendor/aframe.effects.js +++ b/vendor/aframe-master.js @@ -51,7 +51,7 @@ function(a){a=P(a);for(var c=v.length;c--;)for(var d=v[c],b=d.animations,f=b.len },{}],3:[function(_dereq_,module,exports){ module.exports = function numtype(num, def) { return typeof num === 'number' - ? num + ? num : (typeof def === 'number' ? def : 0) } },{}],4:[function(_dereq_,module,exports){ @@ -207,7 +207,7 @@ module.exports = { var value = attributes[key]; style.setAttribute('data-' + key, value); } - + if (style.sheet) { // for jsdom and IE9+ style.innerHTML = cssText; style.sheet.cssText = cssText; @@ -416,11 +416,11 @@ module.exports = function (a, b) { if (!Buffer.isBuffer(b)) return undefined; if (typeof a.equals === 'function') return a.equals(b); if (a.length !== b.length) return false; - + for (var i = 0; i < a.length; i++) { if (a[i] !== b[i]) return false; } - + return true; }; @@ -2384,7 +2384,7 @@ function forEach(list, iterator, context) { if (arguments.length < 3) { context = this } - + if (toString.call(list) === '[object Array]') forEachArray(list, iterator, context) else if (typeof list === 'string') @@ -2604,8 +2604,8 @@ var CAP_HEIGHTS = ['H', 'I', 'N', 'E', 'F', 'K', 'L', 'T', 'U', 'V', 'W', 'X', ' var TAB_ID = '\t'.charCodeAt(0) var SPACE_ID = ' '.charCodeAt(0) -var ALIGN_LEFT = 0, - ALIGN_CENTER = 1, +var ALIGN_LEFT = 0, + ALIGN_CENTER = 1, ALIGN_RIGHT = 2 module.exports = function createLayout(opt) { @@ -2629,10 +2629,10 @@ TextLayout.prototype.update = function(opt) { throw new Error('must provide a valid bitmap font') var glyphs = this.glyphs - var text = opt.text||'' + var text = opt.text||'' var font = opt.font this._setupSpaceGlyphs(font) - + var lines = wordWrap.lines(text, opt) var minWidth = opt.width || 0 @@ -2656,7 +2656,7 @@ TextLayout.prototype.update = function(opt) { //draw text along baseline y -= height - + //the metrics for this text layout this._width = maxLineWidth this._height = height @@ -2666,7 +2666,7 @@ TextLayout.prototype.update = function(opt) { this._capHeight = getCapHeight(font) this._lineHeight = lineHeight this._ascender = lineHeight - descender - this._xHeight - + //layout each glyph var self = this lines.forEach(function(line, lineIndex) { @@ -2674,17 +2674,17 @@ TextLayout.prototype.update = function(opt) { var end = line.end var lineWidth = line.width var lastGlyph - + //for each glyph in that line... for (var i=start; i= 0) + if (idx >= 0) return font.chars[idx].height } return 0 @@ -2846,7 +2846,7 @@ function getMGlyph(font) { for (var i=0; i= 0) + if (idx >= 0) return font.chars[idx] } return 0 @@ -2856,7 +2856,7 @@ function getCapHeight(font) { for (var i=0; i= 0) + if (idx >= 0) return font.chars[idx].height } return 0 @@ -2926,7 +2926,7 @@ module.exports = function(opt, cb) { if (!body) return cb(new Error('no body result')) - var binary = false + var binary = false //if the response type is an array buffer, //we need to convert it into a regular Buffer object @@ -2940,9 +2940,9 @@ module.exports = function(opt, cb) { if (isBinaryFormat(body)) { binary = true //if we have a string, turn it into a Buffer - if (typeof body === 'string') + if (typeof body === 'string') body = new Buffer(body, 'binary') - } + } //we are not parsing a binary format, just ASCII/XML/etc if (!binary) { @@ -2980,7 +2980,7 @@ function getBinaryOpts(opt) { //IE10+ and other modern browsers support array buffers if (xml2) return xtend(opt, { responseType: 'arraybuffer' }) - + if (typeof self.XMLHttpRequest === 'undefined') throw new Error('your browser does not support XHR loading') @@ -3146,7 +3146,7 @@ function splitLine(line, idx) { return null var space = line.indexOf(' ') - if (space === -1) + if (space === -1) throw new Error("no named row at line " + idx) var key = line.substring(0, space) @@ -3154,7 +3154,7 @@ function splitLine(line, idx) { line = line.substring(space + 1) //clear "letter" field as it is non-standard and //requires additional complexity to parse " / = symbols - line = line.replace(/letter=[\'\"]\S+[\'\"]/gi, '') + line = line.replace(/letter=[\'\"]\S+[\'\"]/gi, '') line = line.split("=") line = line.map(function(str) { return str.trim().match((/(".*?"|[^"\s]+)+(?=\s*|\s*$)/g)) @@ -3225,7 +3225,7 @@ module.exports = function readBMFontBinary(buf) { var vers = buf.readUInt8(i++) if (vers > 3) throw new Error('Only supports BMFont Binary v3 (BMFont App v1.10)') - + var target = { kernings: [], chars: [] } for (var b=0; b<5; b++) i += readBlock(target, buf, i) @@ -3241,7 +3241,7 @@ function readBlock(target, buf, i) { i += 4 switch(blockID) { - case 1: + case 1: target.info = readInfo(buf, i) break case 2: @@ -3269,11 +3269,11 @@ function readInfo(buf, i) { info.unicode = (bitField >> 6) & 1 info.italic = (bitField >> 5) & 1 info.bold = (bitField >> 4) & 1 - - //fixedHeight is only mentioned in binary spec + + //fixedHeight is only mentioned in binary spec if ((bitField >> 3) & 1) info.fixedHeight = 1 - + info.charset = buf.readUInt8(i+3) || '' info.stretchH = buf.readUInt16LE(i+4) info.aa = buf.readUInt8(i+6) @@ -3359,7 +3359,7 @@ function readKernings(buf, i, blockSize) { function readNameNT(buf, offset) { var pos=offset for (; pos>0),o="attached",u="detached",a="extends",f="ADDITION",l="MODIFICATION",c="REMOVAL",h="DOMAttrModified",p="DOMContentLoaded",d="DOMSubtreeModified",v="<",m="=",g=/^[A-Z][A-Z0-9]*(?:-[A-Z0-9]+)+$/,y=["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"],b=[],w=[],E="",S=n.documentElement,x=b.indexOf||function(e){for(var t=this.length;t--&&this[t]!==e;);return t},T=r.prototype,N=T.hasOwnProperty,C=T.isPrototypeOf,k=r.defineProperty,L=r.getOwnPropertyDescriptor,A=r.getOwnPropertyNames,O=r.getPrototypeOf,M=r.setPrototypeOf,_=!!r.__proto__,D=r.create||function yt(e){return e?(yt.prototype=e,new yt):this},P=M||(_?function(e,t){return e.__proto__=t,e}:A&&L?function(){function e(e,t){for(var n,r=A(t),i=0,s=r.length;i