let e,t,o,r,i,n,s,a,h,l,c,p,d,u,f,m,v,g,b,y,C,x,w,F="setAttribute",S="createElement",E=tokenData.hash,D=20,k=[[0,1,3,5,8,-2,-4],[0,1,-2],[0]],U=[[0,3,5,7,10,12,-2],[0,1,5,7],[0,5,7,8,10],[0]],A=[0,3,5,7,10],N=[0,3,7,8,-4];function q(){m.toggle()}class B{constructor(){this.buffer=e.createBuffer(2,3*r,r),this.generate()}generate(){for(let e=0;e<2;e++){let t=this.buffer.getChannelData(e),o=t.length;for(let e=0;e<o;e++)t[e]=g.rangeFloat(-1,1)}}}class M{constructor(e,t){this.value=e,this.time=t}}class R{constructor(e,t,o){this.points=e,this.depth=o||1,this.value=[t],t.length&&(this.value=t),this.length=this.getLength(),this.valueNo=this.value.length}getLength(){let e=0,t=this.points.length;for(let o=0;o<t;o++)e+=this.points[o].time;return e}set(t){this.value.cancelScheduledValues(e.currentTime),this.value.value=t}trigger(e,t){this.attack(e,t||1),this.release(e+this.length)}attack(e,t){for(let o=0;o<this.valueNo;o++){this.value[o].cancelScheduledValues(e),this.value[o].setValueAtTime(this.points[0].value*t,e);let r=e,i=this.points.length;for(let e=1;e<i;e++){let i=this.points[e];r+=i.time;i.value;this.value[o].linearRampToValueAtTime(i.value*t,r);let n=this.points[e+1];if(this.depth>1&&n){let e=1/this.depth,s=i.value;for(let i=1;i<this.depth;i++)s=W(s,n.value,.5),this.value[o].linearRampToValueAtTime(s*t,r+W(0,n.time,e*i))}}}}release(e){let t=e+.005;for(let o=0;o<this.valueNo;o++)this.value[o].cancelScheduledValues(e),this.value[o].linearRampToValueAtTime(0,t)}preStop(e,t){let o=e-(t=t||.05);for(let e=0;e<this.valueNo;e++)this.value[e].cancelScheduledValues(o),this.value[e].setTargetAtTime(0,o,t/3)}softStop(e,t){t=t||.05;for(let o=0;o<this.valueNo;o++)this.value[o].cancelScheduledValues(e),this.value[o].setTargetAtTime(0,e,t/3)}}class I{constructor(){this.ampNodes=[new M(1,0),new M(1,.05),new M(0,.16)],this.pitchNodes=[new M(200,0),new M(90,.02),new M(30,.16)],this.length=H(this.ampNodes)}trigger(t){this.ampEnv&&this.ampEnv.preStop(t);let o=e.createGain(),r=e.createOscillator();r.connect(o),o.connect(n),r.start(t),r.stop(t+this.length+.1),this.ampEnv=new R(this.ampNodes,o.gain,5),this.pitchEnv=new R(this.pitchNodes,r.frequency,5),this.ampEnv.trigger(t,.7),this.pitchEnv.attack(t,1)}}class j{constructor(){let e=g.rangeFloat(.05,1.5);this.ampNodes=[new M(1,0),new M(1,.6),new M(0,e)],this.pitchNodes=[new M(3800,0),new M(80,.02),new M(0,.1)],this.length=H(this.ampNodes),this.volume=.01}trigger(t,o){o=o||60,this.ampEnv1&&this.ampEnv1.preStop(t,.01),this.ampEnv2&&this.ampEnv2.preStop(t,.01);let r=e.createGain(),i=e.createGain(),s=e.createOscillator(),a=e.createOscillator(),h=e.createOscillator();s.frequency.value=o,a.frequency.value=o/2,h.frequency.value=4*o,h.type="triangle",s.connect(r),a.connect(r),h.connect(i),r.connect(n),i.connect(n),s.start(t),s.stop(t+this.length+1e-4),a.start(t),a.stop(t+this.length+1e-4),h.start(t),h.stop(t+this.length+1e-4),this.ampEnv1=new R(this.ampNodes,r.gain,5),this.ampEnv2=new R(this.ampNodes,i.gain,5),this.pitchEnv=new R(this.pitchNodes,[s.detune,a.detune,h.detune],5),this.ampEnv1.attack(t,.7*.7),this.ampEnv2.attack(t,.7*.7*this.volume),this.pitchEnv.attack(t,1)}}class O{constructor(){this.ampNodes=[new M(1,0),new M(0,.005)],this.pitchNodes=[new M(9e3,0),new M(g.range(2e3,5e3),.003)],this.length=H(this.ampNodes),this.volume=.5,this.hp=e.createBiquadFilter(),this.hp.type="highpass",this.hp.frequency.value=g.range(1e4,10500),this.hp.connect(o),this.out=new L,this.out.connect(this.hp),this.out.set(g.rangeFloat(-.8,.8))}trigger(t){this.ampEnv&&this.ampEnv.preStop(t,.004);let o=e.createGain(),r=e.createOscillator();r.connect(o),o.connect(this.out.panner),r.start(t),r.stop(t+this.length+.001),this.ampEnv=new R(this.ampNodes,o.gain,4),this.pitchEnv=new R(this.pitchNodes,r.frequency,4),this.ampEnv.trigger(t,.7*this.volume),this.pitchEnv.attack(t,1)}}class T{constructor(){let t=g.rangeFloat(.005,.01);this.ampNodes=[new M(1,0),new M(0,t)],this.length=H(this.ampNodes),this.volume=.4,this.hp=e.createBiquadFilter(),this.hp.type="highpass",this.hp.frequency.value=g.range(1e4,14e3),this.hp.connect(o),this.out=new L,this.out.connect(this.hp),this.out.set(g.rangeFloat(-.8,.8))}trigger(t){this.ampEnv&&this.ampEnv.preStop(t,.005);let o=e.createGain(),r=e.createBufferSource();r.buffer=a.buffer,r.connect(o),o.connect(this.out.panner),r.start(t),r.stop(t+this.length+.1),this.ampEnv=new R(this.ampNodes,o.gain,3),this.ampEnv.trigger(t,.7*this.volume)}}class z{constructor(){this.ampNodes=[new M(1,0),new M(0,.03)],g.percent(40)&&(this.ampNodes=[new M(1,0),new M(.02,.021),new M(1,0),new M(.02,.021),new M(1,0),new M(0,.05)]),this.length=H(this.ampNodes),this.hf=g.range(1500,3100),this.lf=g.range(1e3,1400)}trigger(t){this.ampEnv&&this.ampEnv.preStop(t);let r=e.createGain(),i=e.createBufferSource(),n=e.createBiquadFilter(),s=e.createBiquadFilter();n.type="lowpass",s.type="highpass",n.frequency.value=this.hf,s.frequency.value=this.lf,n.Q.value=1,s.Q.value=5,i.buffer=a.buffer,i.connect(n),n.connect(s),s.connect(r),r.connect(o),i.start(t),i.stop(t+this.length+.1),this.ampEnv=new R(this.ampNodes,r.gain,4),this.ampEnv.trigger(t,.7)}}class P{constructor(){this.ampNodes=[new M(0,0),new M(1,C/2/1e3),new M(0,.001)],this.length=H(this.ampNodes)}trigger(t){this.ampEnv&&this.ampEnv.preStop(t);let r=e.createGain(),i=e.createBufferSource(),n=e.createBiquadFilter();n.type="bandpass",n.frequency.value=9e3,i.buffer=a.buffer,i.connect(n),n.connect(r),r.connect(o),i.start(t),i.stop(t+this.length+.1),this.ampEnv=new R(this.ampNodes,r.gain,1),this.ampEnv.trigger(t,.7)}}class G{constructor(){let e=g.rangeFloat(0,.01),t=g.rangeFloat(.01,.35);g.percent(2)&&(e=g.rangeFloat(.05,.15),t=g.rangeFloat(.01,.02)),this.volume=g.rangeFloat(.05,.05),this.f1=g.rangeFloat(500,600*(v.leadOctave+1)),this.q1=g.rangeFloat(.5,20),this.type=g.item(["sine","sawtooth","triangle","square"]),this.ampNodes=[new M(0,0),new M(1,e),new M(0,t)],this.pitchNodes=[new M(this.f1*g.rangeFloat(.25,3),0),new M(this.f1,.03)],this.length=H(this.ampNodes),this.out=new L,this.out.connect(o),this.out.set(g.rangeFloat(-.8,.8))}trigger(t,o){o=o||60,this.ampEnv&&this.ampEnv.softStop(t,.01);let r=e.createGain(),i=e.createOscillator(),n=e.createBiquadFilter();i.type=this.type,i.frequency.value=o,n.Q.value=this.q1,i.connect(n),n.connect(r),r.connect(this.out.panner),i.start(t),i.stop(t+this.length+1e-4),this.ampEnv=new R(this.ampNodes,r.gain,6),this.filterEnv=new R(this.pitchNodes,n.frequency,4),this.ampEnv.attack(t,.7*this.volume),this.filterEnv.attack(t,1)}}class V{constructor(){let t=g.rangeFloat(0,.01),r=g.rangeFloat(.01,.7),i=!1;g.percent(20)&&(t=g.rangeFloat(.01,.5),r=g.rangeFloat(0,.02),i=!0),this.volume=g.rangeFloat(.9,1),this.q1=g.rangeFloat(50,800),g.percent(20)&&(this.q1=g.rangeFloat(12,20),this.volume=g.rangeFloat(.3,.4),i&&(this.volume=g.rangeFloat(.2,.3))),g.percent(30)&&(this.q1=g.rangeFloat(.1,1),this.volume=g.rangeFloat(.1,.2),i&&(this.volume=g.rangeFloat(.03,.05)),t>.06&&(t=.06),r=g.rangeFloat(.01,.06)),this.ampNodes=[new M(0,0),new M(1,t),new M(0,r)],this.length=H(this.ampNodes),this.hp=e.createBiquadFilter(),this.hp.type="highpass",this.hp.frequency.value=600,this.hp.connect(o),this.out=new L,this.out.connect(this.hp),this.out.set(g.rangeFloat(-.9,.9))}trigger(t,o){o=o||60,this.ampEnv&&this.ampEnv.softStop(t,.01);let r=e.createGain(),i=e.createBufferSource(),n=e.createBiquadFilter();n.type="bandpass",i.buffer=a.buffer,n.frequency.value=o,n.Q.value=this.q1,i.connect(n),n.connect(r),r.connect(this.out.panner),i.start(t),i.stop(t+this.length+1e-4),this.ampEnv=new R(this.ampNodes,r.gain,6),this.ampEnv.attack(t,.7*this.volume)}}class _{constructor(){let e=g.rangeFloat(.3,1);g.percent(40)&&(e=g.rangeFloat(.001,.02));let t=g.rangeFloat(.2,1.5);g.percent(40)&&(t=g.rangeFloat(1.5,4)),this.ampNodes=[new M(0,0),new M(1,e),new M(0,t)],this.length=H(this.ampNodes),this.volume=g.rangeFloat(.02,.03),this.type=g.item(["sawtooth","sine","triangle"]),"triange"==this.type&&(this.volume=g.rangeFloat(.02,.03)),"sawtooth"==this.type&&(this.volume=g.rangeFloat(.01,.02)),this.detune=g.rangeFloat(1,14),this.f1=g.rangeFloat(300,2700),this.q1=g.rangeFloat(0,10),this.split=g.percent(50),this.volume*=.75*this.q1*1}trigger(t,o){o=o||60,this.ampEnv&&this.ampEnv.softStop(t,.04);let r=e.createGain(),i=e.createOscillator(),s=e.createOscillator(),a=e.createOscillator(),h=new L,l=new L,c=e.createBiquadFilter();c.type="bandpass",c.frequency.value=this.f1,c.Q.value=this.q1,i.frequency.value=s.frequency.value=a.frequency.value=o,this.split&&(i.frequency.value=o/2),i.type=s.type=a.type=this.type,s.detune.value=-this.detune,a.detune.value=this.detune,h.set(-this.detune/14),l.set(this.detune/14),i.connect(c),s.connect(h.panner),a.connect(l.panner),h.connect(c),l.connect(c),c.connect(r),r.connect(n),i.start(t),i.stop(t+this.length+1e-4),s.start(t+.002),s.stop(t+this.length+1e-4),a.start(t+.004),a.stop(t+this.length+1e-4),this.ampEnv=new R(this.ampNodes,r.gain,5),this.ampEnv.attack(t,.7*.7*this.volume)}}class L{constructor(){this.active=!1,e.createStereoPanner&&(this.active=!0),this.active?this.panner=e.createStereoPanner():this.panner=e.createGain()}set(e){this.active&&(this.panner.pan.value=e)}connect(e){this.panner.connect(e)}}
class Q{constructor(e,t,o,r){this.instrument=e,this.time=t,this.velocity=o,this.pitch=r||b}schedule(){this.instrument.trigger(e.currentTime+this.time+.1,this.pitch,this.velocity)}}class X{constructor(){this.notes=[],this.beatIndex=0,this.timer=null,this.isPlaying=!1,this.generate()}generate(){this.notes=[],this.beatIndex=0;for(let e=0;e<8;e++){let t={hat:v.hat(e),kick:v.kick(e),snare:v.snare(e),perc:v.perc(e),lead:v.lead(e),pad:v.pad(e)};this.notes.push(t)}}variate(e){let t=Object.assign({},this.notes[e]);g.percent(33)&&(t.hat=v.hat(e)),g.percent(D)&&(t.kick=v.kick(e)),g.percent(15)&&(t.perc=v.perc(e)),g.percent(20)&&(t.lead=v.lead(e));return[].concat(t.hat,t.kick,t.snare,t.perc,t.lead,t.pad)}schedule(){let e=this.variate(this.beatIndex);for(let t=0;t<e.length;t++)e[t].schedule();this.beatIndex++,this.beatIndex>7&&(this.beatIndex=0),this.timer=setTimeout((()=>{this.schedule()}),C)}play(){this.isPlaying=!0,this.beatIndex=0,this.schedule()}stop(){clearTimeout(this.timer),this.isPlaying=!1}toggle(){this.isPlaying?this.stop():this.play()}}class Y{constructor(){this.kickDouble=!0,this.leadFirst=!0,this.leadOctave=g.range(0,2),this.percFirst=!0,this.padMode=0,g.percent(70)?this.padMode=1:this.padMode=2,this.padOctave=g.range(0,3)}snare(e){let t=[];return 2!=e&&6!=e||t.push(new Q(c,0,1)),t}kick(e){let t=[],o=C/1e3;0==e&&t.push(new Q(h,0,1,J(b,0,-2)));let r=J(b,g.item(x),-2);if(0==e&&g.percent(10)&&t.push(new Q(h,o/2,1,r)),1==e&&g.percent(15)&&t.push(new Q(h,o/2,1,r)),3==e&&g.percent(20)&&t.push(new Q(h,0,1,r)),4==e&&g.percent(50)&&t.push(new Q(h,o/2,1,r)),e>4){let i=50;6==e&&(i=4),g.percent(i)&&t.push(new Q(h,0,1,r)),g.percent(60)&&(t.push(new Q(h,o/2,1,r)),g.percent(50)&&this.kickDouble&&(t.push(new Q(h,.75*o,1,r)),this.kickDouble=!1))}return t}hat(e){let t=[],o=1;g.percent(70)&&(o=2),g.percent(5)&&(o=3),g.percent(10)&&(o=4),g.percent(3)&&(o=6),g.percent(3)&&(o=8);let r=C/o/1e3;for(let e=0;e<o;e++)t.push(new Q(l,r*e,1));return t}lead(e){let t=[],o=C/1e3;0==e&&(this.leadFirst=!0);let r=J(b,g.item(w),this.leadOctave);return this.leadFirst&&(r=J(b,0,this.leadOctave)),g.percent(30)&&(g.percent(10)&&(r=J(b,0,this.leadOctave)),t.push(new Q(u,0,1,r)),this.leadFirst=!1),g.percent(30)&&(t.push(new Q(u,o/2,1,r)),this.leadFirst=!1),t}perc(e){let t=[],o=C/1e3;0==e&&(this.percFirst=!0);let r=g.range(-2,4),i=J(b,g.item(A),r);return this.leadFirst&&(i=J(b,[0,7],r)),g.percent(30)&&(t.push(new Q(f,0,1,i)),this.percFirst=!1),g.percent(30)&&(t.push(new Q(f,o/2,1,i)),this.percFirst=!1),t}pad(e){let t=[],o=C/1e3,r=J(b,0,this.padOctave);0==e&&t.push(new Q(d,0,1,r));let i=40;switch(this.padMode){case 1:r=J(b,g.item(N),this.padOctave),4==e&&g.percent(i)&&t.push(new Q(d,o/2,1,r)),e>4&&(g.percent(i)&&t.push(new Q(d,0,1,r)),g.percent(i)&&t.push(new Q(d,o/2,1,r)));break;case 2:i=70,0==e&&g.percent(i)&&t.push(new Q(d,o/2,1,r)),e>0&&(g.percent(i)&&t.push(new Q(d,0,1,r)),g.percent(i)&&t.push(new Q(d,o/2,1,r)))}return t}}class Z{constructor(e){this.seed=parseInt(e.slice(0,16))}random(e){return e=e||1,this.seed^=this.seed<<13,this.seed^=this.seed>>17,this.seed^=this.seed<<5,(this.seed<0?1+~this.seed:this.seed)%1e3/1e3*e}percent(e){return this.random(100)<e}range(e,t){return Math.round(this.rangeFloat(e,t))}rangeFloat(e,t){return e+this.random(t-e)}item(e){let t=e.length;return e[Math.round(this.random(t-1))]}}function W(e,t,o){return e+(t-e)*o}function H(e){let t=0;for(let o=0;o<e.length;o++)t+=e[o].time;return t}function J(e,t,o){let r=e*(1+t/12);return r=e*Math.pow(2,t/12),r*=Math.pow(2,o),r}g=new Z(E),v=new Y,function(){let a=window.AudioContext||window.webkitAudioContext;e=new a({sampleRate:32e3}),t=e.destination,o=t,r=e.sampleRate,i=e.createAnalyser(),i.fftSize=256,i.maxDecibels=0,i.smoothingTimeConstant=0,n=e.createDynamicsCompressor(),n.connect(t),n.threshold.value=-10,n.attack=.001,n.ratio=12,s=e.createDynamicsCompressor(),s.connect(n),s.threshold.value=-32,s.ratio=20,distortion=e.createWaveShaper(),distortion.connect(n),distortion.curve=function(e){for(var t,o="number"==typeof e?e:50,i=r,n=new Float32Array(i),s=Math.PI/180,a=0;a<i;++a)t=2*a/i-1,n[a]=(3+o)*t*20*s/(Math.PI+o*Math.abs(t));return n}(10),distortion.oversample="4x",o=distortion,n.connect(i)}(),y=g.range(100,180),C=6e4/y,b=J(440,g.range(-10,-2),0),x=g.item(k),w=g.item(U),a=new B,h=new I,D=35,g.percent(50)&&(h=new j,D=8),p=new P,f=new V,d=new _,l=g.percent(50)?new T:new O,c=new z,u=new G,m=new X,window.onkeypress=e=>{"Space"==e.code&&q()},window.screen.width<1024&&window.addEventListener("click",(function(){q()}));const K="\nvarying vec2 vUv;\nvoid main(){\nvUv = uv;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}";AFRAME.registerShader("box",{schema:{color:{type:"color",is:"uniform"},stripeColor:{type:"color",is:"uniform"},data:{type:"array",is:"uniform"},border:{type:"bool",is:"uniform"},borderColor:{type:"color",is:"uniform"}},vertexShader:K,fragmentShader:"precision mediump float;\nvarying vec2 vUv;\nuniform vec3 color;\nuniform vec3 stripeColor;\nuniform float[1] data;\nuniform bool border;\nuniform vec3 borderColor;\nvoid main() {\nvec3 colDiff = stripeColor - color;\nvec3 col = color + colDiff*data[0];\nif((vUv.x<0.066||vUv.x>0.933||vUv.y<0.066||vUv.y>0.933)&&border)\ncol = vec3(borderColor);\ngl_FragColor = vec4(col,1.0);\n}"}),AFRAME.registerShader("semisphere",{schema:{color:{type:"color",is:"uniform"},stripeColor:{type:"color",is:"uniform"},data:{type:"array",is:"uniform"},border:{type:"bool",is:"uniform"},borderColor:{type:"color",is:"uniform"}},vertexShader:K,fragmentShader:"precision mediump float;\nvarying vec2 vUv;\nuniform vec3 color;\nuniform vec3 stripeColor;\nuniform float[1] data;\nuniform bool border;\nuniform vec3 borderColor;\nvoid main() {\nvec3 col = color;\nfloat y = vUv.y > 1.0 ? 1.0: vUv.y;\nif(y>(1.0-data[0]))\ncol = stripeColor;\nif(vUv.y<0.1&&border)\ncol = vec3(borderColor);\ngl_FragColor = vec4(col,1.0);\n}"}),AFRAME.registerShader("bar",{schema:{color:{type:"color",is:"uniform"},stripeColor:{type:"color",is:"uniform"},data:{type:"array",is:"uniform"},border:{type:"bool",is:"uniform"},borderColor:{type:"color",is:"uniform"}},vertexShader:K,fragmentShader:"precision mediump float;\nvarying vec2 vUv;\nuniform vec3 color;\nuniform vec3 stripeColor;\nuniform float[50] data;\nuniform bool border;\nuniform vec3 borderColor;\nvoid main() {\nfloat opa = data[(int(vUv.y*50.0))];\nvec3 colDiff = stripeColor - color;\nvec3 col = color + colDiff*opa;\nif((vUv.y<0.05||vUv.y>0.95) && border)\ncol = vec3(borderColor);\t\ngl_FragColor = vec4(col,1.0);\n}"}),AFRAME.registerShader("pyramid",{schema:{color:{type:"color",is:"uniform"},stripeColor:{type:"color",is:"uniform"},data:{type:"array",is:"uniform"},border:{type:"bool",is:"uniform"},borderColor:{type:"color",is:"uniform"}},vertexShader:K,fragmentShader:"precision mediump float;\nvarying vec2 vUv;\nuniform vec3 color;\nuniform vec3 stripeColor;\nuniform float[50] data;\nuniform bool border;\nuniform vec3 borderColor;\nvoid main() {\nint index;\nfloat k = 2.9;\nfloat maxD = 1.0/1.5;\nfloat minD = -k/1.5;\nfloat dDiff = maxD - minD;\nfloat curD = vUv.y-(vUv.x)*(k); \t\t\nif(curD<0.0){\ncurD=abs(minD)+curD;\n}else{\ncurD= curD - minD;\n}\nfloat revIndex = (curD/dDiff)*50.0;\nfloat dist = revIndex - float(int(revIndex));\t\nindex = int(50.0-revIndex);\nfloat opa = data[index];\nvec3 colDiff = stripeColor - color;\nvec3 borderColDiff = borderColor - color;\nopa*=2.0;\nif(opa>1.0)\nopa=1.0;\nvec3 col = color + colDiff*opa;\nif((dist > 0.8 || dist < 0.2 ) && border)\ncol = color + borderColDiff*opa;\t\t\ngl_FragColor = vec4(col,1.0);\n}"}),AFRAME.registerShader("hexagon",{schema:{color:{type:"color",is:"uniform"},stripeColor:{type:"color",is:"uniform"},data:{type:"array",is:"uniform"},border:{type:"bool",is:"uniform"},borderColor:{type:"color",is:"uniform"}},vertexShader:K,fragmentShader:"precision mediump float;\nvarying vec2 vUv;\nuniform vec3 color;\nuniform vec3 stripeColor;\nuniform bool border;\nuniform float[50] data;\nuniform vec3 borderColor;\nvoid main() {\nfloat opa,curD, a = vUv.y, b;\nint index;\nbool cond;\nfloat vUv1 = vUv.y<0.5 ? (vUv.y) : (1.0-vUv.y);\nfloat vUv2 = vUv.y<0.5 ? (0.5-vUv.y) : (vUv.y-0.5);\nif(vUv.y<0.5&&vUv.x<0.5||vUv.y>=0.5&&vUv.x>=0.5){\ncurD = ((vUv.y - vUv.x*(-1.75))-1.375)*(vUv.y*vUv.x>=0.25?1.0:-1.0);\nb = (vUv.x*1.732-0.366);\ncond = vUv.y*vUv.x>=0.25?(a>b):(a<b);\n} else {\ncurD = ((vUv.y - vUv.x*(1.75)) + 0.375)*(vUv.x<0.5?1.0:-1.0);\nb = (vUv.x*-1.732+1.366);\ncond = vUv.x<0.5?(a>b):(a<b);\n}\nif(cond)\nindex = int((vUv1-0.0669 + (vUv2*0.005))/0.433*50.0);\nelse\nindex = int(50.0-curD/0.875* 50.0);\nif(index>49||index<0){\nopa = 0.0;\n} else {\nopa = data[index];\n}\nvec3 colDiff = stripeColor - color;\nvec3 col = color + colDiff*opa;\nif(index==0&&border)\ncol = vec3(borderColor);\ngl_FragColor = vec4(col,1.0);\n}"});
const $=new Z(E);let ee=document[S]("a-scene");ee[F]("beatbox",""),ee[F]("renderer","highRefreshRate:true");let te=document[S]("a-entity");te[F]("id","cameraRig"),te[F]("position","0 1.6 0");let oe=document[S]("a-entity");oe[F]("camera",""),oe[F]("look-controls",""),oe[F]("wasd-controls",""),oe[F]("position-reader",""),oe[F]("id","camera"),te.appendChild(oe);let re=document[S]("a-entity");re[F]("hand-controls","hand: right"),re[F]("rotation-reader",""),te.appendChild(re),ee.appendChild(te),document.body.appendChild(ee);const ie=[{chance:7.5,outerBoxColor:"#102410",semiSphereColor:"#030603",semiSphereStripeColor:"#f1f1f1",boxColor:"#ecf39e",boxStripeColor:"#102410",others:[["#f1f1f1","#dc0c25"],["#000000","#31572c"],["#132a13","#ecf39e"]],borderColor:"#dc0c25",sunColor:"#dc0c25"},{chance:5,outerBoxColor:"#10002b",semiSphereColor:"#05000d",semiSphereStripeColor:"#f1f1f1",boxColor:"#FF005C",boxStripeColor:"#ffffff",others:[["#05000d","#bc00dd"],["#05000d","#c0fdff"],["#05000d","#d51fa5"]],borderColor:"#13F4EF",sunColor:"#13F4EF"},{chance:7.5,outerBoxColor:"#0b0b0b",semiSphereColor:"#000000",semiSphereStripeColor:"#ffffff",boxColor:"#000000",boxStripeColor:"#ffffff",others:[["#000000","#ffffff"],["#000000","#ffffff"],["#000000","#ffffff"]],borderColor:"#ffffff",sunColor:"#ffffff"},{chance:13,outerBoxColor:"#470047",semiSphereColor:"#fdc5ff",semiSphereStripeColor:"#f1f1f1",boxColor:"#bff6ff",boxStripeColor:"#ffffff",others:[["#ffb7cc","#ffffff"],["#a4fcda","#06cf81"],["#ff42fe","#ffffff"]],borderColor:"#c275ef",sunColor:"#cc8af2"},{chance:7.5,outerBoxColor:"#f7cf3b",semiSphereColor:"#4e410f",semiSphereStripeColor:"#f4e4bc",boxColor:"#f4e4bc",boxStripeColor:"#f1f1f1",others:[["#e9c979","#fbf6e9"],["#e5c063","#f8edd2"],["#daa520","#edd290"]],borderColor:"#c4951d",sunColor:"#f8edd2"},{chance:13,outerBoxColor:"#280f36",semiSphereColor:"#160420",semiSphereStripeColor:"#ffffff",boxColor:"#160420",boxStripeColor:"#000000",others:[["#632b6c","#f09f9c"],["#280f36","#ffc1a0"],["#fd9c7f","#fdd2bc"]],borderColor:"#fd9c7f",sunColor:"#c86b98"},{chance:13,outerBoxColor:"#0f0d1b",semiSphereColor:"#160420",semiSphereStripeColor:"#ffffff",boxColor:"#3255b1",boxStripeColor:"#95fde4",others:[["#3f2b5c","#95fde4"],["#161324","#6446aa"],["#71c78a","#0f0d1b"]],borderColor:"#95fde4",sunColor:"#95fde4"},{chance:13,outerBoxColor:"#000000",semiSphereColor:"#000000",semiSphereStripeColor:"#f1f1f1",boxColor:"#c52525",boxStripeColor:"#f1f1f1",others:[["#323232","#000000"],["#000000","#670000"],["#670000","#000000"]],borderColor:"#9f1111",sunColor:"#c50000"},{chance:13,outerBoxColor:"#48396B",semiSphereColor:"#05000d",semiSphereStripeColor:"#f1f1f1",boxColor:"#48396B",boxStripeColor:"#FFF4AD",others:[["#46A3A3","#ffffff"],["#6ABA95","#88fcc7"],["#404F89","#FFF4AD"]],borderColor:"#FFF4AD",sunColor:"#FFF4AD"},{chance:7.5,outerBoxColor:"#03045e",semiSphereColor:"#000013",semiSphereStripeColor:"#f1f1f1",boxColor:"#3f9f7f",boxStripeColor:"#76FFFD",others:[["#4BD1E1","#010223"],["#000017","#4BD1E1"],["#03043d","#2563b1"]],borderColor:"#76FFFD",sunColor:"#76FFFD"}];let ne,se=100*$.random(),ae=0;for(let e=0;e<10;e++)if(ae+=ie[e].chance,se<ae){ne=e;break}const he=ie[ne];he.others=function(e){for(var t,o,r=e.length;0!==r;)o=Math.floor($.random()*r),t=e[r-=1],e[r]=e[o],e[o]=t;return e}(he.others),$.random()<.8&&(he.borderColor=null);const le=[[20,20,20,20,20],[45,10,15,15,15],[15,10,45,15,15],[15,10,15,45,15],[15,10,15,15,45]];const ce=le[parseInt($.random()*le.length)];var pe=new Uint8Array(128);let de=[],ue=[],fe={};AFRAME.registerComponent("rotation-reader",{init:function(){this.el.addEventListener("axismove",this.logThumbstick.bind(this)),this.el.addEventListener("buttondown",(()=>{q()})),this.cameraRig=document.getElementById("cameraRig"),this.camera=document.getElementById("camera"),this.speed=.25},tick:function(){let{z:e,x:t}=this.cameraRig.object3D.position;e>49&&(this.cameraRig.object3D.position.z=49),e<-49&&(this.cameraRig.object3D.position.z=-49),t>49&&(this.cameraRig.object3D.position.x=49),t<-49&&(this.cameraRig.object3D.position.x=-49)},logThumbstick:function(e){let t=e.detail.axis.length,o=e.detail.axis[t-2],r=e.detail.axis[t-1];const i=r*this.speed*Math.cos(this.camera.object3D.rotation.y),n=r*this.speed*Math.sin(this.camera.object3D.rotation.y),s=o*this.speed*Math.cos(this.camera.object3D.rotation.y),a=o*this.speed*Math.sin(this.camera.object3D.rotation.y)*-1;this.cameraRig.object3D.position.z+=a+i,this.cameraRig.object3D.position.x+=s+n}}),AFRAME.registerComponent("position-reader",{tick:function(){let{z:e,x:t}=this.el.object3D.position;e>49&&(this.el.object3D.position.z=49),e<-49&&(this.el.object3D.position.z=-49),t>49&&(this.el.object3D.position.x=49),t<-49&&(this.el.object3D.position.x=-49)}});const me={};let ve;
AFRAME.registerComponent("moving-light",{init:function(){this.intensity=$.random(),this.el[F]("light","type: point; distance: 200; decay: 1; castShadow:true; intensity: "+this.intensity+";color:"+he.sunColor),this.radius=1+1*$.random(),this.el[F]("geometry","primitive: sphere; radius: "+this.radius);let e=$.random()*(50-this.radius)*($.random()<.5?1:-1),t=$.random()*(50-2*this.radius)+this.radius,o=$.random()*(50-this.radius)*($.random()<.5?1:-1);this.el[F]("position",e+" "+t+" "+o),this.el[F]("material","shader:flat;color:"+he.sunColor),this.speedX=.5*$.random(),this.speedY=.5*$.random(),this.speedZ=.5*$.random(),this.pos=this.el.getAttribute("position"),$.random()<.3333&&(this.isDynamicInt=!0)},tick:function(){if(i&&m&&m.isPlaying){if(this.isDynamicInt){let e=this.intensity,t=ve/128>e?ve/128:e>=.01?e-.01:0;this.el.setAttribute("light","intensity",t),this.intensity=t}let e=this.pos;(e.x+this.radius+this.speedX>50||e.x-this.radius+this.speedX<-50)&&(this.speedX*=-1),(e.y+this.radius+this.speedY>50||e.y-this.radius+this.speedY<0)&&(this.speedY*=-1),(e.z+this.radius+this.speedZ>50||e.z-this.radius+this.speedZ<-50)&&(this.speedZ*=-1),e.x+=this.speedX,e.y+=this.speedY,e.z+=this.speedZ,this.el.object3D.position=e}}}),AFRAME.registerComponent("static-light",{init:function(){this.intensity=$.random(),this.el[F]("light","type: point; distance: 200; decay: 1; castShadow:true; intensity: "+this.intensity+";color:"+he.sunColor);let e=49*$.random()*($.random()<.5?1:-1),t=48*$.random()+1,o=49*$.random()*($.random()<.5?1:-1);this.el[F]("position",e+" "+t+" "+o),$.random()<.4285&&(this.isDynamicInt=!0)},tick:function(){if(i&&m&&m.isPlaying&&this.isDynamicInt){let e=this.intensity,t=ve/128>e?ve/128:e>=.01?e-.01:0;this.el.setAttribute("light","intensity",t),this.intensity=t}}});let ge={},be=1,ye={bar:{},hexagon:{}};function Ce(e,t){let o=parseInt(100*$.random())+(e?100:0),r=null;if(me[o]?$.random()<.5?(n(),r||i()):(i(),r||n()):r=o,null===r)return Ce(!e,t);{me[r]=1,e&&(r%=100);let o=r%10*10-50+5,i=5-t;i<0&&(i=0),o+=i*$.random()*($.random()<.5?1:-1);let n=10*parseInt(r/10)-50+5;return n+=i*$.random()*($.random()<.5?1:-1),{x:o,z:n,rot:e?180:0}}function i(){for(let t=o-1;t>=(e?100:0);t--)if(!me[t]){r=t;break}}function n(){for(let t=o+1;t<(e?200:100);t++)if(!me[t]){r=t;break}}}function xe(e){let t,o,r,i,n,s;s=(3*(ye.sphere||$.random())+1)/be,o=0,n=$.random()<.25?Ce(!1,s):Ce(!0,s),t=n.x,r=n.z,i=n.rot,o=n.rot?50-o:o;const a=document[S]("a-sphere");a[F]("material","shader: semisphere;color:"+he.semiSphereColor+";stripeColor:"+he.semiSphereStripeColor),a[F]("theta-length","90"),a[F]("radius",s),a[F]("position",t+" "+o+" "+r),a[F]("rotation",i+" 0 0"),De(a),e.appendChild(a),ue.push("sphere")}function we(e){let t,o,r,i,n;const s=document[S]("a-cylinder"),a=(20*(ye.bar.height||$.random())+15)/be,h=(1*(ye.bar.radius||$.random())+1)/be;o=a/2,n=$.random()>=.5?Ce(!1,h):Ce(!0,h),t=n.x,r=n.z,i=n.rot,o=n.rot?50-o:o,s[F]("material","shader: bar;side:double;color:"+he.others[0][0]+";stripeColor:"+he.others[0][1]),s[F]("radius",h),s[F]("height",a),s[F]("position",t+" "+o+" "+r),s[F]("rotation",i+" 0 0"),s[F]("open-ended","true"),De(s),e.appendChild(s),ue.push("cylinder")}function Fe(e){let t,o,r,i,n;const s=(.5*(ye.hexagon.height||$.random())+.25)/be,a=(3*(ye.hexagon.radius||$.random())+2)/be;o=s/2,n=$.random()>=.3?Ce(!1,a):Ce(!0,a),t=n.x,r=n.z,i=n.rot,o=n.rot?50-o:o;const h=document[S]("a-cylinder");h[F]("radius",a),h[F]("height",s),h[F]("segments-radial","6"),h[F]("position",t+" "+o+" "+r),h[F]("material","shader: hexagon;color:"+he.others[1][0]+";stripeColor:"+he.others[1][1]),h[F]("rotation",i+" "+360*(ge.hexagon||$.random())+" 0"),De(h),e.appendChild(h),ue.push("hexagon")}function Se(e){let t,o,r,i,n=215;const s=(4*(ye.pyramid||$.random())+2)/be;o=s/3,(i=Ce(!1,s)),t=i.x,r=i.z,n+=i.rot,o=i.rot?50-o:o;const a=document[S]("a-tetrahedron");a[F]("material","shader: pyramid;color:"+he.others[2][0]+";stripeColor:"+he.others[2][1]),a[F]("radius",s),a[F]("position",t+" "+o+" "+r),a[F]("rotation",n+" "+360*(ge.pyramid||$.random())+" 45"),De(a),e.appendChild(a),ue.push("pyramid")}function Ee(e){let t,o,r,i,n;const s=((ye.box||$.random())+1)/be;o=s/2+2+20*$.random(),i=0,n=Ce(!1,s/2),t=n.x,r=n.z,o=n.rot?s/2-o:o;const a=document[S]("a-box");a[F]("material","shader: box;color:"+he.boxColor+";stripeColor:"+he.boxStripeColor),a[F]("depth",s),a[F]("width",s),a[F]("height",s),a[F]("position",t+" "+o+" "+r),a[F]("rotation","0 "+360*(ge.box||$.random())+" 0"),De(a),e.appendChild(a),ue.push("box")}function De(e){e[F]("animate","index: "+ue.length),e[F]("shadow","cast:true;receive:false"),he.borderColor&&(e[F]("material","borderColor",he.borderColor),e[F]("material","border","true"))}AFRAME.registerComponent("beatbox",{init:function(){!function(e){let t=[[100,100,"-90 0 0","0 0 0"],[100,100,"90 0 0","0 50 0"],[50,100,"0 180 0","0 25 50"],[50,100,"0 0 0","0 25 -50"],[50,100,"0 -90 0","50 25 0"],[50,100,"0 90 0","-50 25 0"]];for(let o=0;o<6;o++){const r=document[S]("a-plane");r[F]("color",he.outerBoxColor),r[F]("height",t[o][0]),r[F]("width",t[o][1]),r[F]("rotation",t[o][2]),r[F]("position",t[o][3]),r[F]("shadow","receive: true"),e.appendChild(r)}}(this.el);const e=document[S]("a-entity");e[F]("light","type: ambient; intensity: 0.1;"),this.el.appendChild(e);const t=document[S]("a-entity");$.random()<.3?t[F]("moving-light",""):t[F]("static-light",""),this.el.appendChild(t);const o=$.random();if(o<.4)ge.pyramid=$.random()||.001,ge.box=$.random()||.001,ge.hexagon=$.random()||.001;else if(o<.8){let e=$.random()||.001;ge.pyramid=e,ge.box=e,ge.hexagon=e}const r=$.random();r<.3?be=2:r<.8&&(be=1.5);const i=$.random();if(i<.4)ye.pyramid=$.random()||.001,ye.box=$.random()||.001,ye.hexagon.height=$.random()||.001,ye.hexagon.radius=$.random()||.001,ye.bar.radius=$.random()||.001,ye.bar.height=$.random()||.001,ye.sphere=$.random()||.001;else if(i<.5){let e=$.random()||.001;ye.pyramid=e,ye.box=e,ye.hexagon.height=e,ye.hexagon.radius=e,ye.bar.radius=e,ye.bar.height=e,ye.sphere=e}for(var n=0;n<128;n++){let e,t=100*$.random(),o=0;for(let r=0;r<5;r++)if(o+=ce[r],t<o){e=r;break}0==e?xe(this.el):1==e?Ee(this.el):2==e?we(this.el):3==e?Fe(this.el):Se(this.el)}for(let e=0;e<128;e++){let t=[],o=50;"sphere"!=ue[e]&&"box"!==ue[e]||(o=0,t.push($.random()));for(let e=0;e<o;e++)$.random()<.3?t.push($.random()):t.push(0);de.push(t)}},tick:function(){if(i&&m&&m.isPlaying){i.getByteFrequencyData(pe),ve=0;for(let e=0;e<128;e++)if(ve+=pe[e]/255,"sphere"===ue[e]||"box"===ue[e]){let t,o=pe[e]/255,r=de[e][0];t=r>o?r-.01:o,de[e].unshift(t),de[e].pop()}else"pyramid"===ue[e]?(fe[e]=fe[e]||0,fe[e]++,2==fe[e]&&(fe[e]=0,de[e].unshift(pe[e]/255),de[e].pop())):(de[e].unshift(pe[e]/255),de[e].pop())}}}),AFRAME.registerComponent("animate",{schema:{index:{type:"number"}},init:function(){var e=de[this.data.index];this.el[F]("material","data",e)}});
↓ show full (29,709 bytes)