This repository has been archived by the owner on Jun 3, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pinnacle3.min.js
1 lines (1 loc) · 7.98 KB
/
pinnacle3.min.js
1
!function(){"use strict";var t="undefined"==typeof window?global:window;if("function"!=typeof t.require){var e={},i={},s={},r={}.hasOwnProperty,a=/^\.\.?(\/|$)/,n=function(t,e){for(var i,s=[],r=(a.test(e)?t+"/"+e:e).split("/"),n=0,o=r.length;n<o;n++)i=r[n],".."===i?s.pop():"."!==i&&""!==i&&s.push(i);return s.join("/")},o=function(t){return t.split("/").slice(0,-1).join("/")},h=function(e){return function(i){var s=n(o(e),i);return t.require(s,e)}},u=function(t,e){var s=null;s=w&&w.createHot(t);var r={id:t,exports:{},hot:s};return i[t]=r,e(r.exports,h(t),r),r.exports},c=function(t){return s[t]?c(s[t]):t},p=function(t,e){return c(n(o(t),e))},d=function(t,s){null==s&&(s="/");var a=c(t);if(r.call(i,a))return i[a].exports;if(r.call(e,a))return u(a,e[a]);throw new Error("Cannot find module '"+t+"' from '"+s+"'")};d.alias=function(t,e){s[e]=t};var l=/\.[^.\/]+$/,m=/\/index(\.[^\/]+)?$/,f=function(t){if(l.test(t)){var e=t.replace(l,"");r.call(s,e)&&s[e].replace(l,"")!==e+"/index"||(s[e]=t)}if(m.test(t)){var i=t.replace(m,"");r.call(s,i)||(s[i]=t)}};d.register=d.define=function(t,s){if("object"==typeof t)for(var a in t)r.call(t,a)&&d.register(a,t[a]);else e[t]=s,delete i[t],f(t)},d.list=function(){var t=[];for(var i in e)r.call(e,i)&&t.push(i);return t};var w=t._hmr&&new t._hmr(p,d,e,i);d._cache=i,d.hmr=w&&w.wrap,d.brunch=!0,t.require=d}}(),function(){window;require.register("pinnacle3.coffee",function(t,e,i){var s,r;s=e("srcs/bar"),i.exports=r=function(){function t(t,e){this.target=t,this.params=e,this.width=window.innerWidth,this.height=window.innerHeight,this.bars=new Array,this.lights=new Array,this.radius=300,this.paused=!0,this.hue=this.params.color&&this.params.color.hue||0,this.range=this.params.color&&this.params.color.range||180,this.lightOffset=this.params.color&&this.params.color.lightOffset||10,this.initScene()}var e;return e=-1,t.prototype.initScene=function(){var t,e,i;for(this.renderer=new THREE.WebGLRenderer({antialias:!0}),this.renderer.setClearColor(1710618,1),this.renderer.autoClear=!1,this.camera=new THREE.PerspectiveCamera(45,this.width/this.height,.1,1e4),this.scene=new THREE.Scene,this.scene.add(this.camera),this.camera.position.x=0,this.camera.position.y=Math.cos(Math.PI/4)*this.radius,this.camera.position.z=Math.sin(Math.PI/4)*this.radius,this.camera.lookAt(this.scene.position),this.renderer.setSize(this.width,this.height),this.target.appendChild(this.renderer.domElement),t=e=1;e<=99;t=e+=1)this.bars.push(new s(this.scene,t,this.params));if(i=new THREE.AmbientLight(16777215),this.scene.add(i),this.params.particles&&this.params.particles.active&&this.setupParticles(this.params.particles.count||500,this.params.particles.groups||10),this.setupComposer(),this.params.mouse)return this.initMouse()},t.prototype.setupParticles=function(t,e){var i,s,r,a,n,o,h,u,c,p,d,l,m;for(this.particleSystems=[],l=[],r=a=1,p=e;a<=p;r=a+=1){for(c=new THREE.Geometry,o=new THREE.TextureLoader,i=tinycolor("hsl(0, 100%, 50%)").toHsl(),i.h=this.hue,h=new THREE.PointsMaterial({color:new THREE.Color(tinycolor(i).toRgbString()),size:8,map:o.load("img/spark.png"),blending:THREE.AdditiveBlending,transparent:!0}),h.alphaTest=.15,r=n=1,d=t/e;n<=d;r=n+=1)s={x:Math.random()*(2*this.radius)-this.radius,y:Math.random()*(2*this.radius)-this.radius,z:Math.random()*(2*this.radius)-this.radius},u=new THREE.Vector3(s.x,s.y,s.z),c.vertices.push(u);m=new THREE.Points(c,h),m.velocity=new THREE.Vector3(2*Math.random()-1,2*Math.random()-1,2*Math.random()-1),m.hueOffset=50*Math.random()-25,this.particleSystems.push(m),l.push(this.scene.add(m))}return l},t.prototype.setupComposer=function(){var t,e;return this.composer=new THREE.EffectComposer(this.renderer),this.composer.addPass(new THREE.RenderPass(this.scene,this.camera)),(!this.params.shaders||this.params.shaders&&this.params.shaders.shift)&&(e=new THREE.ShaderPass(THREE.RGBShiftShader),e.uniforms.amount.value=.0012,this.composer.addPass(e)),(!this.params.shaders||this.params.shaders&&this.params.shaders.bloom)&&(e=new THREE.BloomPass(.5,25,5,512),this.composer.addPass(e)),(!this.params.shaders||this.params.shaders&&this.params.shaders.unreal)&&(e=new THREE.UnrealBloomPass(512,.3,1.5,.95),this.composer.addPass(e)),(!this.params.shaders||this.params.shaders&&this.params.shaders.vignette)&&(e=new THREE.ShaderPass(THREE.VignetteShader),e.uniforms.offset.value=1,e.uniforms.darkness.value=1.2,this.composer.addPass(e)),e=new THREE.ShaderPass(THREE.CopyShader),e.renderToScreen=!0,this.composer.addPass(e),t=this,window.addEventListener("resize",function(){return t.width=window.innerWidth,t.height=window.innerHeight,t.camera.aspect=t.width/t.height,t.camera.updateProjectionMatrix(),t.renderer.setSize(t.width,t.height),t.composer.setSize(t.width,t.height)})},t.prototype.run=function(t){return this.audio=new Audio(t),this.audio.crossOrigin="anonymous",this.audioCtx=new(window.AudioContext||window.webkitAudioContext),this.audioSrc=this.audioCtx.createMediaElementSource(this.audio),this.analyser=this.audioCtx.createAnalyser(),this.audioSrc.connect(this.analyser),this.audioSrc.connect(this.audioCtx.destination),this.audioData=new Uint8Array(this.analyser.frequencyBinCount),this.play()},t.prototype.initMouse=function(){var t;return t=this,this.renderer.domElement.addEventListener("mousemove",function(e){var i,s;return i={theta:Math.PI/2+e.clientX/t.width*(Math.PI/8)-Math.PI/16,phi:Math.PI/4+e.clientY/t.height*(Math.PI/8)-Math.PI/16},s={x:t.radius*Math.sin(i.phi)*Math.cos(i.theta),y:t.radius*-Math.cos(i.phi),z:t.radius*Math.sin(i.phi)*Math.sin(i.theta)},t.camera.position.x=s.x,t.camera.position.y=s.y,t.camera.position.z=s.z,t.camera.lookAt(t.scene.position)})},t.prototype.freeze=function(){if(this.pause(),e!==-1)return cancelAnimationFrame(e),e=-1},t.prototype.thaw=function(){if(e===-1)return e=requestAnimationFrame(this.animate.bind(this))},t.prototype.play=function(){return this.audio.play(),this.paused=!1,this.target.classList.add("playing"),this.thaw()},t.prototype.stop=function(){return this.pause(),this.audio.currentTime=0},t.prototype.pause=function(){return this.audio.pause(),this.paused=!0,this.target.classList.remove("playing")},t.prototype.toggle=function(){return this.paused?this.play():this.pause()},t.prototype.average=function(t){var e,i,s,r;for(s=0,e=0,i=t.length;e<i;e++)r=t[e],s+=r;return s/t.length},t.prototype.updateParticles=function(){var t,e,i,r,a,n,o,h;for(t=this.average(this.audioData),o=3e-4+Math.pow(t,4)/Math.pow(255,4)/10,a=this.particleSystems,n=[],i=0,r=a.length;i<r;i++)h=a[i],e=s.computeColor(t,(this.hue+h.hueOffset)%360,this.range,this.lightOffset+20),h.rotation.x+=o*h.velocity.x,h.rotation.y+=o*h.velocity.y,h.rotation.z+=o*h.velocity.z,h.material.size=4+Math.pow(t,4)/Math.pow(255,3),n.push(h.material.color=e);return n},t.prototype.animate=function(){var t,i,s,r,a,n,o,h,u,c;for(this.analyser.getByteFrequencyData(this.audioData),u=~~(this.bars.length/2)+1,s=~~(this.audioData.length/u),a=0,c=this.bars,o=0,h=c.length;o<h;o++)i=c[o],n=a<u?u-a-1:a-u+1,r=this.audioData.slice(s*n,s*(n+1)),t=this.average(r),i.update(t,this.hue,this.range,this.lightOffset),a+=1;return this.params.particles&&this.params.particles.active&&this.updateParticles(),this.renderer.clear(),this.composer.render(),this.params.color&&this.params.color.cycle&&e%15===0&&(this.hue=(this.hue+1)%360),e=requestAnimationFrame(this.animate.bind(this))},t}()}),require.register("srcs/bar.coffee",function(t,e,i){var s;i.exports=s=function(){function t(t,e){this.index=e,this.material=new THREE.MeshLambertMaterial({color:16777215}),this.mesh=new THREE.Mesh(new THREE.BoxGeometry(4,4,4),this.material),this.mesh.position.set(4*(this.index-50),0,0),t.add(this.mesh)}return t.computeColor=function(t,e,i,s){var r,a;return r=tinycolor("hsl(0, 100%, 50%)").toHsl(),r.h=(e+i*(t/255))%360,a=Math.min(t/255*100+s,100),a<1&&(a+=1),1===a&&(a=1.1),r.l=a,new THREE.Color(tinycolor(r).toHslString())},t.prototype.update=function(e,i,s,r){var a;return a=Math.abs(e)/10,a<.1&&(a=1e-4),this.mesh.scale.y=a,this.mesh.scale.z=a,this.mesh.material.color=t.computeColor(e,i,s,r)},t}()}),require.register("___globals___",function(t,e,i){})}(),require("___globals___");