/** * @license almond 0.2.9 Copyright (c) 2011-2014, The Dojo Foundation All Rights Reserved. * Available via the MIT or new BSD license. * see: http://github.com/jrburke/almond for details */ // This product includes color specifications and designs developed by Cynthia Brewer (http://colorbrewer.org/). // JavaScript specs as packaged in the D3 library (d3js.org). Please see license at http://colorbrewer.org/export/LICENSE.txt // Underscore.js 1.7.0 // http://underscorejs.org // (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors // Underscore may be freely distributed under the MIT license. !function(e,t){var n=t();"undefined"!=typeof define&&define.amd&&define(n),e.Elegans=n}(this,function(){var e,t,n;return function(a){function i(e,t){return v.call(e,t)}function o(e,t){var n,a,i,o,r,s,c,f,d,u,l,h=t&&t.split("/"),p=_.map,b=p&&p["*"]||{};if(e&&"."===e.charAt(0))if(t){for(h=h.slice(0,h.length-1),e=e.split("/"),r=e.length-1,_.nodeIdCompat&&w.test(e[r])&&(e[r]=e[r].replace(w,"")),e=h.concat(e),d=0;d0&&(e.splice(d-1,2),d-=2)}e=e.join("/")}else 0===e.indexOf("./")&&(e=e.substring(2));if((h||b)&&p){for(n=e.split("/"),d=n.length;d>0;d-=1){if(a=n.slice(0,d).join("/"),h)for(u=h.length;u>0;u-=1)if(i=p[h.slice(0,u).join("/")],i&&(i=i[a])){o=i,s=d;break}if(o)break;!c&&b&&b[a]&&(c=b[a],f=d)}!o&&c&&(o=c,s=f),o&&(n.splice(0,s,o),e=n.join("/"))}return e}function r(e,t){return function(){return h.apply(a,E.call(arguments,0).concat([e,t]))}}function s(e){return function(t){return o(t,e)}}function c(e){return function(t){m[e]=t}}function f(e){if(i(g,e)){var t=g[e];delete g[e],y[e]=!0,l.apply(a,t)}if(!i(m,e)&&!i(y,e))throw new Error("No "+e);return m[e]}function d(e){var t,n=e?e.indexOf("!"):-1;return n>-1&&(t=e.substring(0,n),e=e.substring(n+1,e.length)),[t,e]}function u(e){return function(){return _&&_.config&&_.config[e]||{}}}var l,h,p,b,m={},g={},_={},y={},v=Object.prototype.hasOwnProperty,E=[].slice,w=/\.js$/;p=function(e,t){var n,a=d(e),i=a[0];return e=a[1],i&&(i=o(i,t),n=f(i)),i?e=n&&n.normalize?n.normalize(e,s(t)):o(e,t):(e=o(e,t),a=d(e),i=a[0],e=a[1],i&&(n=f(i))),{f:i?i+"!"+e:e,n:e,pr:i,p:n}},b={require:function(e){return r(e)},exports:function(e){var t=m[e];return"undefined"!=typeof t?t:m[e]={}},module:function(e){return{id:e,uri:"",exports:m[e],config:u(e)}}},l=function(e,t,n,o){var s,d,u,l,h,_,v=[],E=typeof n;if(o=o||e,"undefined"===E||"function"===E){for(t=!t.length&&n.length?["require","exports","module"]:t,h=0;h1?n.normalize():n.z=Math.sqrt(1-o*o),g.copy(u.object.position).sub(u.target),e.copy(u.object.up).setLength(n.y),e.add(t.copy(u.object.up).cross(g).setLength(n.x)),e.add(g.setLength(n.z)),e}}();this.rotateCamera=function(){var e=new THREE.Vector3,t=new THREE.Quaternion;return function(){var n=Math.acos(_.dot(y)/_.length()/y.length());n&&(e.crossVectors(_,y).normalize(),n*=u.rotateSpeed,t.setFromAxisAngle(e,-n),g.applyQuaternion(t),u.object.up.applyQuaternion(t),y.applyQuaternion(t),u.staticMoving?_.copy(y):(t.setFromAxisAngle(e,n*(u.dynamicDampingFactor-1)),_.applyQuaternion(t)))}}(),this.zoomCamera=function(){if(b===l.TOUCH_ZOOM_PAN){var e=w/x;w=x,g.multiplyScalar(e)}else{var e=1+(E.y-v.y)*u.zoomSpeed;1!==e&&e>0&&(g.multiplyScalar(e),u.staticMoving?v.copy(E):v.y+=(E.y-v.y)*this.dynamicDampingFactor)}},this.panCamera=function(){var e=new THREE.Vector2,t=new THREE.Vector3,n=new THREE.Vector3;return function(){e.copy(R).sub(T),e.lengthSq()&&(e.multiplyScalar(g.length()*u.panSpeed),n.copy(g).cross(u.object.up).setLength(e.x),n.add(t.copy(u.object.up).setLength(e.y)),u.object.position.add(n),u.target.add(n),u.staticMoving?T.copy(R):T.add(e.subVectors(R,T).multiplyScalar(u.dynamicDampingFactor)))}}(),this.checkDistances=function(){u.noZoom&&u.noPan||(g.lengthSq()>u.maxDistance*u.maxDistance&&u.object.position.addVectors(u.target,g.setLength(u.maxDistance)),g.lengthSq()h&&(u.dispatchEvent(O),p.copy(u.object.position))},this.reset=function(){b=l.NONE,m=l.NONE,u.target.copy(u.target0),u.object.position.copy(u.position0),u.object.up.copy(u.up0),g.subVectors(u.object.position,u.target),u.object.lookAt(u.target),u.dispatchEvent(O),p.copy(u.object.position)},this.domElement.addEventListener("contextmenu",function(e){e.preventDefault()},!1),this.domElement.addEventListener("mousedown",i,!1),this.domElement.addEventListener("mousewheel",s,!1),this.domElement.addEventListener("DOMMouseScroll",s,!1),this.domElement.addEventListener("touchstart",c,!1),this.domElement.addEventListener("touchend",d,!1),this.domElement.addEventListener("touchmove",f,!1),window.addEventListener("keydown",n,!1),window.addEventListener("keyup",a,!1),this.handleResize(),this.update()};return e.prototype=Object.create(THREE.EventDispatcher.prototype),e.prototype.constructor=e,e}),n("utils/OrthographicTrackballControls",[],function(){var e=function(e,t){function n(e){u.enabled!==!1&&(window.removeEventListener("keydown",n),m=b,b===l.NONE&&(e.keyCode!==u.keys[l.ROTATE]||u.noRotate?e.keyCode!==u.keys[l.ZOOM]||u.noZoom?e.keyCode!==u.keys[l.PAN]||u.noPan||(b=l.PAN):b=l.ZOOM:b=l.ROTATE))}function a(e){u.enabled!==!1&&(b=m,window.addEventListener("keydown",n,!1))}function i(e){u.enabled!==!1&&(e.preventDefault(),e.stopPropagation(),b===l.NONE&&(b=e.button),b!==l.ROTATE||u.noRotate?b!==l.ZOOM||u.noZoom?b!==l.PAN||u.noPan||(R.copy(P(e.pageX,e.pageY)),O.copy(R)):(v.copy(P(e.pageX,e.pageY)),E.copy(v)):(_.copy(S(e.pageX,e.pageY)),y.copy(_)),document.addEventListener("mousemove",o,!1),document.addEventListener("mouseup",r,!1),u.dispatchEvent(A))}function o(e){u.enabled!==!1&&(e.preventDefault(),e.stopPropagation(),b!==l.ROTATE||u.noRotate?b!==l.ZOOM||u.noZoom?b!==l.PAN||u.noPan||O.copy(P(e.pageX,e.pageY)):E.copy(P(e.pageX,e.pageY)):y.copy(S(e.pageX,e.pageY)))}function r(e){u.enabled!==!1&&(e.preventDefault(),e.stopPropagation(),b=l.NONE,document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",r),u.dispatchEvent(H))}function s(e){if(u.enabled!==!1){e.preventDefault(),e.stopPropagation();var t=0;e.wheelDelta?t=e.wheelDelta/40:e.detail&&(t=-e.detail/3),v.y+=.01*t,u.dispatchEvent(A),u.dispatchEvent(H)}}function c(e){if(u.enabled!==!1){switch(e.touches.length){case 1:b=l.TOUCH_ROTATE,_.copy(S(e.touches[0].pageX,e.touches[0].pageY)),y.copy(_);break;case 2:b=l.TOUCH_ZOOM_PAN;var t=e.touches[0].pageX-e.touches[1].pageX,n=e.touches[0].pageY-e.touches[1].pageY;T=x=Math.sqrt(t*t+n*n);var a=(e.touches[0].pageX+e.touches[1].pageX)/2,i=(e.touches[0].pageY+e.touches[1].pageY)/2;R.copy(P(a,i)),O.copy(R);break;default:b=l.NONE}u.dispatchEvent(A)}}function f(e){if(u.enabled!==!1)switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:y.copy(S(e.touches[0].pageX,e.touches[0].pageY));break;case 2:var t=e.touches[0].pageX-e.touches[1].pageX,n=e.touches[0].pageY-e.touches[1].pageY;T=Math.sqrt(t*t+n*n);var a=(e.touches[0].pageX+e.touches[1].pageX)/2,i=(e.touches[0].pageY+e.touches[1].pageY)/2;O.copy(P(a,i));break;default:b=l.NONE}}function d(e){if(u.enabled!==!1){switch(e.touches.length){case 1:y.copy(S(e.touches[0].pageX,e.touches[0].pageY)),_.copy(y);break;case 2:x=T=0;var t=(e.touches[0].pageX+e.touches[1].pageX)/2,n=(e.touches[0].pageY+e.touches[1].pageY)/2;O.copy(P(t,n)),R.copy(O)}b=l.NONE,u.dispatchEvent(H)}}var u=this,l={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4};this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=1,this.zoomSpeed=1.2,this.panSpeed=.3,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.noRoll=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.keys=[65,83,68],this.target=new THREE.Vector3;var h=1e-6,p=new THREE.Vector3,b=l.NONE,m=l.NONE,g=new THREE.Vector3,_=new THREE.Vector3,y=new THREE.Vector3,v=new THREE.Vector2,E=new THREE.Vector2,w=1,x=0,T=0,R=new THREE.Vector2,O=new THREE.Vector2;this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.up0=this.object.up.clone(),this.left0=this.object.left,this.right0=this.object.right,this.top0=this.object.top,this.bottom0=this.object.bottom,this.center0=new THREE.Vector2((this.left0+this.right0)/2,(this.top0+this.bottom0)/2);var M={type:"change"},A={type:"start"},H={type:"end"};this.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight;else{var e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}this.left0=this.object.left,this.right0=this.object.right,this.top0=this.object.top,this.bottom0=this.object.bottom,this.center0.set((this.left0+this.right0)/2,(this.top0+this.bottom0)/2)},this.handleEvent=function(e){"function"==typeof this[e.type]&&this[e.type](e)};var P=function(){var e=new THREE.Vector2;return function(t,n){return e.set((t-u.screen.left)/u.screen.width,(n-u.screen.top)/u.screen.height),e}}(),S=function(){var e=new THREE.Vector3,t=new THREE.Vector3,n=new THREE.Vector3;return function(a,i){n.set((a-.5*u.screen.width-u.screen.left)/(.5*u.screen.width),(.5*u.screen.height+u.screen.top-i)/(.5*u.screen.height),0);var o=n.length();return u.noRoll?o1?n.normalize():n.z=Math.sqrt(1-o*o),g.copy(u.object.position).sub(u.target),e.copy(u.object.up).setLength(n.y),e.add(t.copy(u.object.up).cross(g).setLength(n.x)),e.add(g.setLength(n.z)),e}}();this.rotateCamera=function(){var e=new THREE.Vector3,t=new THREE.Quaternion;return function(){var n=Math.acos(_.dot(y)/_.length()/y.length());n&&(e.crossVectors(_,y).normalize(),n*=u.rotateSpeed,t.setFromAxisAngle(e,-n),g.applyQuaternion(t),u.object.up.applyQuaternion(t),y.applyQuaternion(t),u.staticMoving?_.copy(y):(t.setFromAxisAngle(e,n*(u.dynamicDampingFactor-1)),_.applyQuaternion(t)))}}(),this.zoomCamera=function(){var e;b===l.TOUCH_ZOOM_PAN?(e=x/T,x=T):e=1+(E.y-v.y)*u.zoomSpeed,1!==e&&e>0&&(w*=e,u.object.left=w*u.left0+(1-w)*u.center0.x,u.object.right=w*u.right0+(1-w)*u.center0.x,u.object.top=w*u.top0+(1-w)*u.center0.y,u.object.bottom=w*u.bottom0+(1-w)*u.center0.y,u.staticMoving?v.copy(E):v.y+=(E.y-v.y)*this.dynamicDampingFactor)},this.panCamera=function(){var e=new THREE.Vector2,t=new THREE.Vector3,n=new THREE.Vector3;return function(){e.copy(O).sub(R),e.lengthSq()&&(e.multiplyScalar(g.length()*u.panSpeed),n.copy(g).cross(u.object.up).setLength(e.x),n.add(t.copy(u.object.up).setLength(e.y)),u.object.position.add(n),u.target.add(n),u.staticMoving?R.copy(O):R.add(e.subVectors(O,R).multiplyScalar(u.dynamicDampingFactor)))}}(),this.update=function(){g.subVectors(u.object.position,u.target),u.noRotate||u.rotateCamera(),u.noZoom||(u.zoomCamera(),u.object.updateProjectionMatrix()),u.noPan||u.panCamera(),u.object.position.addVectors(u.target,g),u.object.lookAt(u.target),p.distanceToSquared(u.object.position)>h&&(u.dispatchEvent(M),p.copy(u.object.position))},this.reset=function(){b=l.NONE,m=l.NONE,u.target.copy(u.target0),u.object.position.copy(u.position0),u.object.up.copy(u.up0),g.subVectors(u.object.position,u.target),u.object.left=u.left0,u.object.right=u.right0,u.object.top=u.top0,u.object.bottom=u.bottom0,u.object.lookAt(u.target),u.dispatchEvent(M),p.copy(u.object.position)},this.domElement.addEventListener("contextmenu",function(e){e.preventDefault()},!1),this.domElement.addEventListener("mousedown",i,!1),this.domElement.addEventListener("mousewheel",s,!1),this.domElement.addEventListener("DOMMouseScroll",s,!1),this.domElement.addEventListener("touchstart",c,!1),this.domElement.addEventListener("touchend",d,!1),this.domElement.addEventListener("touchmove",f,!1),window.addEventListener("keydown",n,!1),window.addEventListener("keyup",a,!1),this.handleResize(),this.update()};return e.prototype=Object.create(THREE.EventDispatcher.prototype),e.prototype.constructor=e,e}),n("utils/OrbitControls",[],function(){function e(e){this.object=e,this.target=new THREE.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-(1/0),this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.25;var t,n,a=this,i=1e-6,o=0,r=0,s=1,c=new THREE.Vector3,f=!1;this.getPolarAngle=function(){return n},this.getAzimuthalAngle=function(){return t},this.rotateLeft=function(e){r-=e},this.rotateUp=function(e){o-=e},this.panLeft=function(){var e=new THREE.Vector3;return function(t){var n=this.object.matrix.elements;e.set(n[0],n[1],n[2]),e.multiplyScalar(-t),c.add(e)}}(),this.panUp=function(){var e=new THREE.Vector3;return function(t){var n=this.object.matrix.elements;e.set(n[4],n[5],n[6]),e.multiplyScalar(t),c.add(e)}}(),this.pan=function(e,t,n,i){if(a.object instanceof THREE.PerspectiveCamera){var o=a.object.position,r=o.clone().sub(a.target),s=r.length();s*=Math.tan(a.object.fov/2*Math.PI/180),a.panLeft(2*e*s/i),a.panUp(2*t*s/i)}else a.object instanceof THREE.OrthographicCamera?(a.panLeft(e*(a.object.right-a.object.left)/n),a.panUp(t*(a.object.top-a.object.bottom)/i)):console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.")},this.dollyIn=function(e){a.object instanceof THREE.PerspectiveCamera?s/=e:a.object instanceof THREE.OrthographicCamera?(a.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom*e)),a.object.updateProjectionMatrix(),f=!0):console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.")},this.dollyOut=function(e){a.object instanceof THREE.PerspectiveCamera?s*=e:a.object instanceof THREE.OrthographicCamera?(a.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/e)),a.object.updateProjectionMatrix(),f=!0):console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.")},this.update=function(){var a=new THREE.Vector3,d=(new THREE.Quaternion).setFromUnitVectors(e.up,new THREE.Vector3(0,1,0)),u=d.clone().inverse(),l=new THREE.Vector3,h=new THREE.Quaternion;return function(){var e=this.object.position;a.copy(e).sub(this.target),a.applyQuaternion(d),t=Math.atan2(a.x,a.z),n=Math.atan2(Math.sqrt(a.x*a.x+a.z*a.z),a.y),t+=r,n+=o,t=Math.max(this.minAzimuthAngle,Math.min(this.maxAzimuthAngle,t)),n=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,n)),n=Math.max(i,Math.min(Math.PI-i,n));var p=a.length()*s;return p=Math.max(this.minDistance,Math.min(this.maxDistance,p)),this.target.add(c),a.x=p*Math.sin(n)*Math.sin(t),a.y=p*Math.cos(n),a.z=p*Math.sin(n)*Math.cos(t),a.applyQuaternion(u),e.copy(this.target).add(a),this.object.lookAt(this.target),this.enableDamping===!0?(r*=1-this.dampingFactor,o*=1-this.dampingFactor):(r=0,o=0),s=1,c.set(0,0,0),f||l.distanceToSquared(this.object.position)>i||8*(1-h.dot(this.object.quaternion))>i?(l.copy(this.object.position),h.copy(this.object.quaternion),f=!1,!0):!1}}()}var t=function(t,n){function a(e,t){var n=m.domElement===document?m.domElement.body:m.domElement;b.pan(e,t,n.clientWidth,n.clientHeight)}function i(){return 2*Math.PI/60/60*m.autoRotateSpeed}function o(){return Math.pow(.95,m.zoomSpeed)}function r(e){if(m.enabled!==!1){if(e.preventDefault(),e.button===m.mouseButtons.ORBIT){if(m.enableRotate===!1)return;M=O.ROTATE,g.set(e.clientX,e.clientY)}else if(e.button===m.mouseButtons.ZOOM){if(m.enableZoom===!1)return;M=O.DOLLY,x.set(e.clientX,e.clientY)}else if(e.button===m.mouseButtons.PAN){if(m.enablePan===!1)return;M=O.PAN,v.set(e.clientX,e.clientY)}M!==O.NONE&&(document.addEventListener("mousemove",s,!1),document.addEventListener("mouseup",c,!1),m.dispatchEvent(H))}}function s(e){if(m.enabled!==!1){e.preventDefault();var t=m.domElement===document?m.domElement.body:m.domElement;if(M===O.ROTATE){if(m.enableRotate===!1)return;_.set(e.clientX,e.clientY),y.subVectors(_,g),b.rotateLeft(2*Math.PI*y.x/t.clientWidth*m.rotateSpeed),b.rotateUp(2*Math.PI*y.y/t.clientHeight*m.rotateSpeed),g.copy(_)}else if(M===O.DOLLY){if(m.enableZoom===!1)return;T.set(e.clientX,e.clientY),R.subVectors(T,x),R.y>0?b.dollyIn(o()):R.y<0&&b.dollyOut(o()),x.copy(T)}else if(M===O.PAN){if(m.enablePan===!1)return;E.set(e.clientX,e.clientY),w.subVectors(E,v),a(w.x,w.y),v.copy(E)}M!==O.NONE&&m.update()}}function c(){m.enabled!==!1&&(document.removeEventListener("mousemove",s,!1),document.removeEventListener("mouseup",c,!1),m.dispatchEvent(P),M=O.NONE)}function f(e){if(m.enabled!==!1&&m.enableZoom!==!1&&M===O.NONE){e.preventDefault(),e.stopPropagation();var t=0;void 0!==e.wheelDelta?t=e.wheelDelta:void 0!==e.detail&&(t=-e.detail),t>0?b.dollyOut(o()):0>t&&b.dollyIn(o()),m.update(),m.dispatchEvent(H),m.dispatchEvent(P)}}function d(e){if(m.enabled!==!1&&m.enableKeys!==!1&&m.enablePan!==!1)switch(e.keyCode){case m.keys.UP:a(0,m.keyPanSpeed),m.update();break;case m.keys.BOTTOM:a(0,-m.keyPanSpeed),m.update();break;case m.keys.LEFT:a(m.keyPanSpeed,0),m.update();break;case m.keys.RIGHT:a(-m.keyPanSpeed,0),m.update()}}function u(e){if(m.enabled!==!1){switch(e.touches.length){case 1:if(m.enableRotate===!1)return;M=O.TOUCH_ROTATE,g.set(e.touches[0].pageX,e.touches[0].pageY);break;case 2:if(m.enableZoom===!1)return;M=O.TOUCH_DOLLY;var t=e.touches[0].pageX-e.touches[1].pageX,n=e.touches[0].pageY-e.touches[1].pageY,a=Math.sqrt(t*t+n*n);x.set(0,a);break;case 3:if(m.enablePan===!1)return;M=O.TOUCH_PAN,v.set(e.touches[0].pageX,e.touches[0].pageY);break;default:M=O.NONE}M!==O.NONE&&m.dispatchEvent(H)}}function l(e){if(m.enabled!==!1){e.preventDefault(),e.stopPropagation();var t=m.domElement===document?m.domElement.body:m.domElement;switch(e.touches.length){case 1:if(m.enableRotate===!1)return;if(M!==O.TOUCH_ROTATE)return;_.set(e.touches[0].pageX,e.touches[0].pageY),y.subVectors(_,g),b.rotateLeft(2*Math.PI*y.x/t.clientWidth*m.rotateSpeed),b.rotateUp(2*Math.PI*y.y/t.clientHeight*m.rotateSpeed),g.copy(_),m.update();break;case 2:if(m.enableZoom===!1)return;if(M!==O.TOUCH_DOLLY)return;var n=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY,r=Math.sqrt(n*n+i*i);T.set(0,r),R.subVectors(T,x),R.y>0?b.dollyOut(o()):R.y<0&&b.dollyIn(o()),x.copy(T),m.update();break;case 3:if(m.enablePan===!1)return;if(M!==O.TOUCH_PAN)return;E.set(e.touches[0].pageX,e.touches[0].pageY),w.subVectors(E,v),a(w.x,w.y),v.copy(E),m.update();break;default:M=O.NONE}}}function h(){m.enabled!==!1&&(m.dispatchEvent(P),M=O.NONE)}function p(e){e.preventDefault()}var b=new e(t);this.domElement=void 0!==n?n:document,Object.defineProperty(this,"constraint",{get:function(){return b}}),this.getPolarAngle=function(){return b.getPolarAngle()},this.getAzimuthalAngle=function(){return b.getAzimuthalAngle()},this.enabled=!0,this.center=this.target,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.enableKeys=!0,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},this.mouseButtons={ORBIT:THREE.MOUSE.LEFT,ZOOM:THREE.MOUSE.MIDDLE,PAN:THREE.MOUSE.RIGHT};var m=this,g=new THREE.Vector2,_=new THREE.Vector2,y=new THREE.Vector2,v=new THREE.Vector2,E=new THREE.Vector2,w=new THREE.Vector2,x=new THREE.Vector2,T=new THREE.Vector2,R=new THREE.Vector2,O={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY:4,TOUCH_PAN:5},M=O.NONE;console.log(this.target),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom;var A={type:"change"},H={type:"start"},P={type:"end"};this.update=function(){this.autoRotate&&M===O.NONE&&b.rotateLeft(i()),b.update()===!0&&this.dispatchEvent(A)},this.reset=function(){M=O.NONE,this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(A),this.update()},this.dispose=function(){this.domElement.removeEventListener("contextmenu",p,!1),this.domElement.removeEventListener("mousedown",r,!1),this.domElement.removeEventListener("mousewheel",f,!1),this.domElement.removeEventListener("DOMMouseScroll",f,!1),this.domElement.removeEventListener("touchstart",u,!1),this.domElement.removeEventListener("touchend",h,!1),this.domElement.removeEventListener("touchmove",l,!1),document.removeEventListener("mousemove",s,!1),document.removeEventListener("mouseup",c,!1),window.removeEventListener("keydown",d,!1)},this.domElement.addEventListener("contextmenu",p,!1),this.domElement.addEventListener("mousedown",r,!1),this.domElement.addEventListener("mousewheel",f,!1),this.domElement.addEventListener("DOMMouseScroll",f,!1),this.domElement.addEventListener("touchstart",u,!1),this.domElement.addEventListener("touchend",h,!1),this.domElement.addEventListener("touchmove",l,!1),window.addEventListener("keydown",d,!1),this.update()};return t.prototype=Object.create(THREE.EventDispatcher.prototype),t.prototype.constructor=t,Object.defineProperties(t.prototype,{object:{get:function(){return this.constraint.object}},target:{get:function(){return this.constraint.target},set:function(e){console.warn("OrbitControls: target is now immutable. Use target.set() instead."),this.constraint.target.copy(e)}},minDistance:{get:function(){return this.constraint.minDistance},set:function(e){this.constraint.minDistance=e}},maxDistance:{get:function(){return this.constraint.maxDistance},set:function(e){this.constraint.maxDistance=e}},minZoom:{get:function(){return this.constraint.minZoom},set:function(e){this.constraint.minZoom=e}},maxZoom:{get:function(){return this.constraint.maxZoom},set:function(e){this.constraint.maxZoom=e}},minPolarAngle:{get:function(){return this.constraint.minPolarAngle},set:function(e){this.constraint.minPolarAngle=e}},maxPolarAngle:{get:function(){return this.constraint.maxPolarAngle},set:function(e){this.constraint.maxPolarAngle=e}},minAzimuthAngle:{get:function(){return this.constraint.minAzimuthAngle},set:function(e){this.constraint.minAzimuthAngle=e}},maxAzimuthAngle:{get:function(){return this.constraint.maxAzimuthAngle},set:function(e){this.constraint.maxAzimuthAngle=e}},enableDamping:{get:function(){return this.constraint.enableDamping},set:function(e){this.constraint.enableDamping=e}},dampingFactor:{get:function(){return this.constraint.dampingFactor},set:function(e){this.constraint.dampingFactor=e}},noZoom:{get:function(){return console.warn("OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),!this.enableZoom},set:function(e){console.warn("OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),this.enableZoom=!e}},noRotate:{get:function(){return console.warn("OrbitControls: .noRotate has been deprecated. Use .enableRotate instead."),!this.enableRotate},set:function(e){console.warn("OrbitControls: .noRotate has been deprecated. Use .enableRotate instead."),this.enableRotate=!e}},noPan:{get:function(){return console.warn("OrbitControls: .noPan has been deprecated. Use .enablePan instead."),!this.enablePan},set:function(e){console.warn("OrbitControls: .noPan has been deprecated. Use .enablePan instead."),this.enablePan=!e}},noKeys:{get:function(){return console.warn("OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),!this.enableKeys},set:function(e){console.warn("OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),this.enableKeys=!e}},staticMoving:{get:function(){return console.warn("OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),!this.constraint.enableDamping},set:function(e){console.warn("OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),this.constraint.enableDamping=!e}},dynamicDampingFactor:{get:function(){return console.warn("OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead."),this.constraint.dampingFactor},set:function(e){console.warn("OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead."),this.constraint.dampingFactor=e}}}),t}),n("utils/utils",[],function(){var e=function(e,t){t.call(e)},t=function(e,t){for(var n in t)e[n]=t[n];return e},n={mixin:e,merge:t};return n}),n("components/world",["utils/TrackballControls","utils/OrthographicTrackballControls","utils/OrbitControls","utils/utils"],function(e,t,n,a){function i(i){this.options={width:0,height:0,perspective:!0,bg_color:16777215,orbit:!1,save_image:!1},arguments.length>0&&a.merge(this.options,i),this.scene=new THREE.Scene,this.options.perspective?this.camera=new THREE.PerspectiveCamera(45,this.options.width/this.options.height,1,1e3):this.camera=new THREE.OrthographicCamera(-20,20,-20,20),this.scene.add(this.camera);for(var o=[[1,1,1],[-1,-1,1],[-1,1,1],[1,-1,1]],r=0;4>r;r++){var s=new THREE.DirectionalLight(14540253);s.position.set(o[r][0],o[r][1],1*o[r][2]),this.scene.add(s)}return this.renderer=new THREE.WebGLRenderer({antialias:!0,clearAlpha:1,preserveDrawingBuffer:!this.options.save_image}),this.renderer.setSize(this.options.width,this.options.height),this.renderer.setClearColor(this.options.bg_color,1),this.renderer.sortObjects=!1,this.options.perspective&&this.options.orbit?this.controls=new n(this.camera,this.renderer.domElement):this.options.perspective?this.controls=new e(this.camera,this.renderer.domElement):this.controls=new t(this.camera,this.renderer.domElement),this.controls.screen={left:0,top:0,width:this.options.width,height:this.options.height},this.controls.rotateSpeed=.5,this.camera.position.set(-30,31,42),this.camera.rotation.set(-.6,-.5,.6),this}return i.prototype.begin=function(e){e[0][0].appendChild(this.renderer.domElement);var t=this,n=1e3/30,a=Date.now();this.animate=function(){window.requestAnimationFrame(t.animate);var e=Date.now();e-a>n&&(a=e,t.renderer.render(t.scene,t.camera),t.controls.update())},this.animate()},i.prototype.addMesh=function(e){if(e instanceof Array)for(var t=0;t1&&e.merge(this.options,n);var o=-10,r=10,s=r-o,c=new THREE.PlaneGeometry(s,s),f=new THREE.MeshBasicMaterial({color:15790320,shading:THREE.FlatShading,overdraw:.5,side:THREE.DoubleSide}),d=function(e,t,n){return new THREE.Vector3(e,t,n)};if(this.meshes=[],"solid"==this.options.mode){var u=new THREE.Mesh(c,f),l=new THREE.Mesh(c,f),h=new THREE.Mesh(c,f);l.rotateOnAxis(d(1,0,0),Math.PI/2),l.translateOnAxis(d(0,0,-1),-10),h.rotateOnAxis(d(0,1,0),Math.PI/2),h.translateOnAxis(d(0,0,-1),-10),u.translateOnAxis(d(0,0,1),-10),this.meshes.push(u),this.meshes.push(l),this.meshes.push(h)}else if("wireframe"==this.options.mode){this.meshes}this.scales={},this.scales.x=d3.scale.linear().domain([t.x.max,t.x.min]).range([-10,10]),this.scales.y=d3.scale.linear().domain([t.y.max,t.y.min]).range([10,-10]),this.scales.z=d3.scale.linear().domain([t.z.max,t.z.min]).range([10,-10]); var p=d3.scale.linear().domain([t.x.max,t.x.min]).range([20,0]),b=d3.scale.linear().domain([t.y.max,t.y.min]).range([20,0]),m=d3.scale.linear().domain([t.z.max,t.z.min]).range([20,0]);return this.meshes=this.meshes.concat(a(this.options.axis_labels.x,d(10,10,-10),d(-10,10,-10),d(0,1,0),p)),this.meshes=this.meshes.concat(a(this.options.axis_labels.y,d(-10,-10,-10),d(-10,10,-10),d(-1,0,0),b)),this.meshes=this.meshes.concat(a(this.options.axis_labels.z,d(10,10,-10),d(10,10,10),d(0,1,0),m)),this.options.grid&&(this.meshes.push(i([-10,10],[-10,10],[-10,-10],2)),this.meshes.push(i([-10,10],[-10,-10],[-10,10],2)),this.meshes.push(i([10,10],[-10,10],[-10,10],2))),this}var n=function(e,t){var n=document.createElement("canvas");n.width=100,n.height=100;var a=n.getContext("2d");a.fillStyle="rgb(0, 0, 0)",a.font="60px sans-serif";var i=a.measureText(e).width;a.fillText(e,(100-i)/2,80);var o=new THREE.Texture(n);o.flipY=!0,o.needsUpdate=!0;var r=new THREE.SpriteMaterial({map:o,transparent:!0,useScreenCoordinates:!1}),s=new THREE.Sprite(r);return s.scale.set(1.5,1.5),s.position.set.apply(s.position,t.toArray()),s},a=function(e,t,a,i,o){var r=[],s=new THREE.Geometry,c=(new THREE.Vector3).subVectors(a,t).normalize();s.vertices.push(t),s.vertices.push(a);var f=(new THREE.Vector3).addVectors(a,t).divideScalar(2);f.add(i.clone().multiplyScalar(3)),r.push(n(e,f));for(var d=d3.select("body").append("svg").style("width","500").style("height","500").style("display","none"),u=d.append("g").call(d3.svg.axis().scale(o).orient("left").ticks(5)).selectAll(".tick"),l=0;lr[0]?r[0]:t,r[1]=t1&&e.merge(this.options,a),this.model=t,this.stage=n}return n.prototype.render=function(){var e=t.getRange(),n=this.model.append("div").style("height",27).style("width",500).style("background-color","#fff"),a=this;n.append("button").attr("title","play").style("float","left").text("►").on("click",function(){console.log("huga"),a.start()});var i=n.append("form").style("height",30).style("width",500);i.append("input").attr("type","range").attr("name","range").attr("class","range").attr("max",e[1]).attr("min",e[0]).attr("step",1).attr("value",e[0]).style("width",350).style("float","left").on("change",function(){a.update(this.value)}),i.append("input").attr("type","text").style("width",30).style("float","left").attr("value",e[0]).attr("class","input_label"),i.append("div").style("color","#fff").append("p").style("line-height",25).text(e[1]),this.form=i},n.prototype.start=function(){var e=this,t=window.setInterval("timer_func()",400);window.timer_func=function(){var n,a,i;e.form.select(".range").each(function(){var e=d3.select(this);n=parseInt(this.value),a=parseInt(e.attr("step")),i=parseInt(e.attr("max"))}),i>=n+a?(console.log("called!"),e.form.select(".range").each(function(e){this.value=n+a}),e.update(n+a)):window.clearInterval(t)}},n.prototype.update=function(e){t.seek("",e),this.model.select(".input_label").attr("value",e),this.stage.clear(),this.stage.update()},n}),n("components/menu",["utils/utils"],function(e){function t(t,n){this.options={filename:"plot"},arguments.length>1&&e.merge(this.options,n),this.selection=t}return t.prototype.begin=function(){function e(){d3.selectAll(".download_menu").remove()}function t(t,a){e();var i=d3.select("body").append("ul").on("click",e);i.style({"list-style-type":"none",position:"absolute",left:t[0]+"px",top:t[1]+"px",background:"#f3f3f3",border:"1px solid #fff",padding:10,margin:0}).attr("class","download_menu"),i.append("li").append("a").text("save as png").attr({download:n+".png",href:a.toDataURL("image/png")}),i.append("li").append("a").text("save as jpeg").attr({download:n+".jpg",href:a.toDataURL("image/jpeg")}),i.selectAll("a").style({display:"block","text-decoration":"none","text-align":"left","line-style":"none",color:"#333","font-size":"13px","line-height":"17px"}),i.selectAll("li").style({margin:0})}var n=this.options.filename;this.selection.select("canvas").on("contextmenu",function(){var e=d3.mouse(document.body);t(e,this,n),d3.event.preventDefault()}).on("click",e)},t}),n("utils/range",[],function(){function e(e,t){arguments.length>1?(this.max=e,this.min=t):(this.max=e[1],this.min=e[0])}return e.prototype.divide=function(e){for(var t=new Array,n=Math.ceil((this.max-this.min)/(e-1)),a=0;e>a;a++)t.push(this.min+n*a);return t},e.expand=function(t,n){return new e(Math.max(t.max,n.max),Math.min(t.min,n.min))},e}),n("components/stage",["components/world","components/space","components/player","components/menu","utils/utils","utils/range"],function(e,t,n,a,i,o){function r(t,r){this.options={width:700,height:530,world_width:500,world_height:500,axis_labels:{x:"X",y:"Y",z:"Z"},bg_color:16777215,player:!1,space_mode:"wireframe",range:{x:[0,0],y:[0,0],z:[0,0]},autorange:!0,grid:!0,perspective:!0,orbit:!1,save_image:!1},arguments.length>1&&i.merge(this.options,r);var s=d3.select(t);if(s.style("width",String(this.options.width)),this.world_space=s.append("div").style({"float":"left",width:String(this.options.world_width),height:String(this.options.world_height),save_image:this.options.save_image}),this.legend_space=s.append("div").style({"float":"left",width:String(this.options.width-this.options.world_width),height:String(this.options.height)}),this.options.player){var c=s.append("div").style("width",String(this.options.width)).style("height",String(this.options.height-this.options.world_height));this.player=new n(c,this)}return this.options.save_image&&(this.menu=new a(this.world_space)),this.charts=[],this.world=new e({width:this.options.world_width,height:this.options.world_height,bg_color:this.options.bg_color,perspective:this.options.perspective,orbit:this.options.orbit}),this.data_ranges={x:new o(this.options.range.x[0],this.options.range.x[1]),y:new o(this.options.range.y[0],this.options.range.y[1]),z:new o(this.options.range.z[0],this.options.range.z[1])},this}return r.prototype.add=function(e){if(this.options.autorange){var t=e.getDataRanges(),n=this;["x","y","z"].forEach(function(e){n.data_ranges[e]=o.expand(n.data_ranges[e],t[e])})}this.charts.push(e)},r.prototype.render=function(){this.space=new t(this.data_ranges,{axis_labels:this.options.axis_labels,mode:this.options.space_mode,grid:this.options.grid}),this.world.addMesh(this.space.getMeshes());for(var e=0;e1&&t.merge(this.options,i),this.dataset=new n.Matrix(e),this.ranges=this.dataset.ranges}return i.prototype.generateMesh=function(e){for(var t=this.dataset.raw,n=new THREE.Geometry,a=d3.scale.linear().domain(this.ranges.z.divide(this.options.fill_colors.length)).range(this.options.fill_colors),i=[],o=function(e,t){return e*s+t},r=function(e,t,n,a,i){var o=new THREE.Vector3,r=new THREE.Vector3;o.subVectors(e.vertices[t],e.vertices[n]),r.subVectors(e.vertices[t],e.vertices[a]),r.cross(o).normalize();var s=[i[t],i[n],i[a]];e.faces.push(new THREE.Face3(t,n,a,r,s)),s=[i[a],i[n],i[t]],e.faces.push(new THREE.Face3(a,n,t,r.negate(),s))},s=t.x.length,c=t.x[0].length,f=0;s>f;f++)for(var d=0;c>d;d++)n.vertices.push(new THREE.Vector3(e.x(t.x[f][d]),e.y(t.y[f][d]),e.z(t.z[f][d]))),i.push(new THREE.Color(a(t.z[f][d])));for(var u=0;s-1>u;u++)for(var l=0;c-1>l;l++)r(n,o(u,l),o(u+1,l),o(u,l+1),i),r(n,o(u+1,l),o(u+1,l+1),o(u,l+1),i);var h=new THREE.MeshBasicMaterial({vertexColors:THREE.VertexColors});this.mesh=new THREE.Mesh(n,h)},i.prototype.getDataRanges=function(){return this.ranges},i.prototype.hasLegend=function(){return this.options.has_legend},i.prototype.getLegend=function(){return e.generateContinuousLegend(this.ranges.z,this.options.fill_colors)},i.prototype.getMesh=function(){return this.mesh},i}),n("charts/wireframe",["components/legends","utils/utils","utils/datasets","utils/colorbrewer"],function(e,t,n,a){function i(e,a){this.options={name:"wireframe",color:"#999999",thickness:1,has_legend:!0},arguments.length>1&&t.merge(this.options,a),this.dataset=new n.Matrix(e),this.ranges=this.dataset.ranges}return i.prototype.generateMesh=function(e){for(var t=this.dataset.raw,n=t.x.length,a=t.x[0].length,i=new THREE.LineBasicMaterial({color:this.options.color,linewidth:this.options.thickness,transparent:!0}),o=[],r=0;n>r;r++){for(var s=new THREE.Geometry,c=0;a>c;c++)s.vertices.push(new THREE.Vector3(e.x(t.x[r][c]),e.y(t.y[r][c]),e.z(t.z[r][c])));o.push(new THREE.Line(s,i))}for(var c=0;a>c;c++){for(var s=new THREE.Geometry,r=0;n>r;r++)s.vertices.push(new THREE.Vector3(e.x(t.x[r][c]),e.y(t.y[r][c]),e.z(t.z[r][c]))); o.push(new THREE.Line(s,i))}this.mesh=o},i.prototype.getDataRanges=function(){return this.ranges},i.prototype.hasLegend=function(){return this.options.has_legend},i.prototype.disappear=function(){for(var e=0;ea;a++)t(e[a],a,e);else{var o=p.keys(e);for(a=0,i=o.length;i>a;a++)t(e[o[a]],o[a],e)}return e},p.map=p.collect=function(e,t,n){if(null==e)return[];t=p.iteratee(t,n);for(var a,i=e.length!==+e.length&&p.keys(e),o=(i||e).length,r=Array(o),s=0;o>s;s++)a=i?i[s]:s,r[s]=t(e[a],a,e);return r};var m="Reduce of empty array with no initial value";p.reduce=p.foldl=p.inject=function(e,t,n,a){null==e&&(e=[]),t=b(t,a,4);var i,o=e.length!==+e.length&&p.keys(e),r=(o||e).length,s=0;if(arguments.length<3){if(!r)throw new TypeError(m);n=e[o?o[s++]:s++]}for(;r>s;s++)i=o?o[s]:s,n=t(n,e[i],i,e);return n},p.reduceRight=p.foldr=function(e,t,n,a){null==e&&(e=[]),t=b(t,a,4);var i,o=e.length!==+e.length&&p.keys(e),r=(o||e).length;if(arguments.length<3){if(!r)throw new TypeError(m);n=e[o?o[--r]:--r]}for(;r--;)i=o?o[r]:r,n=t(n,e[i],i,e);return n},p.find=p.detect=function(e,t,n){var a;return t=p.iteratee(t,n),p.some(e,function(e,n,i){return t(e,n,i)?(a=e,!0):void 0}),a},p.filter=p.select=function(e,t,n){var a=[];return null==e?a:(t=p.iteratee(t,n),p.each(e,function(e,n,i){t(e,n,i)&&a.push(e)}),a)},p.reject=function(e,t,n){return p.filter(e,p.negate(p.iteratee(t)),n)},p.every=p.all=function(e,t,n){if(null==e)return!0;t=p.iteratee(t,n);var a,i,o=e.length!==+e.length&&p.keys(e),r=(o||e).length;for(a=0;r>a;a++)if(i=o?o[a]:a,!t(e[i],i,e))return!1;return!0},p.some=p.any=function(e,t,n){if(null==e)return!1;t=p.iteratee(t,n);var a,i,o=e.length!==+e.length&&p.keys(e),r=(o||e).length;for(a=0;r>a;a++)if(i=o?o[a]:a,t(e[i],i,e))return!0;return!1},p.contains=p.include=function(e,t){return null==e?!1:(e.length!==+e.length&&(e=p.values(e)),p.indexOf(e,t)>=0)},p.invoke=function(e,t){var n=s.call(arguments,2),a=p.isFunction(t);return p.map(e,function(e){return(a?t:e[t]).apply(e,n)})},p.pluck=function(e,t){return p.map(e,p.property(t))},p.where=function(e,t){return p.filter(e,p.matches(t))},p.findWhere=function(e,t){return p.find(e,p.matches(t))},p.max=function(e,t,n){var a,i,o=-1/0,r=-1/0;if(null==t&&null!=e){e=e.length===+e.length?e:p.values(e);for(var s=0,c=e.length;c>s;s++)a=e[s],a>o&&(o=a)}else t=p.iteratee(t,n),p.each(e,function(e,n,a){i=t(e,n,a),(i>r||i===-1/0&&o===-1/0)&&(o=e,r=i)});return o},p.min=function(e,t,n){var a,i,o=1/0,r=1/0;if(null==t&&null!=e){e=e.length===+e.length?e:p.values(e);for(var s=0,c=e.length;c>s;s++)a=e[s],o>a&&(o=a)}else t=p.iteratee(t,n),p.each(e,function(e,n,a){i=t(e,n,a),(r>i||1/0===i&&1/0===o)&&(o=e,r=i)});return o},p.shuffle=function(e){for(var t,n=e&&e.length===+e.length?e:p.values(e),a=n.length,i=Array(a),o=0;a>o;o++)t=p.random(0,o),t!==o&&(i[o]=i[t]),i[t]=n[o];return i},p.sample=function(e,t,n){return null==t||n?(e.length!==+e.length&&(e=p.values(e)),e[p.random(e.length-1)]):p.shuffle(e).slice(0,Math.max(0,t))},p.sortBy=function(e,t,n){return t=p.iteratee(t,n),p.pluck(p.map(e,function(e,n,a){return{value:e,index:n,criteria:t(e,n,a)}}).sort(function(e,t){var n=e.criteria,a=t.criteria;if(n!==a){if(n>a||void 0===n)return 1;if(a>n||void 0===a)return-1}return e.index-t.index}),"value")};var g=function(e){return function(t,n,a){var i={};return n=p.iteratee(n,a),p.each(t,function(a,o){var r=n(a,o,t);e(i,a,r)}),i}};p.groupBy=g(function(e,t,n){p.has(e,n)?e[n].push(t):e[n]=[t]}),p.indexBy=g(function(e,t,n){e[n]=t}),p.countBy=g(function(e,t,n){p.has(e,n)?e[n]++:e[n]=1}),p.sortedIndex=function(e,t,n,a){n=p.iteratee(n,a,1);for(var i=n(t),o=0,r=e.length;r>o;){var s=o+r>>>1;n(e[s])t?[]:s.call(e,0,t)},p.initial=function(e,t,n){return s.call(e,0,Math.max(0,e.length-(null==t||n?1:t)))},p.last=function(e,t,n){return null==e?void 0:null==t||n?e[e.length-1]:s.call(e,Math.max(e.length-t,0))},p.rest=p.tail=p.drop=function(e,t,n){return s.call(e,null==t||n?1:t)},p.compact=function(e){return p.filter(e,p.identity)};var _=function(e,t,n,a){if(t&&p.every(e,p.isArray))return c.apply(a,e);for(var i=0,o=e.length;o>i;i++){var s=e[i];p.isArray(s)||p.isArguments(s)?t?r.apply(a,s):_(s,t,n,a):n||a.push(s)}return a};p.flatten=function(e,t){return _(e,t,!1,[])},p.without=function(e){return p.difference(e,s.call(arguments,1))},p.uniq=p.unique=function(e,t,n,a){if(null==e)return[];p.isBoolean(t)||(a=n,n=t,t=!1),null!=n&&(n=p.iteratee(n,a));for(var i=[],o=[],r=0,s=e.length;s>r;r++){var c=e[r];if(t)r&&o===c||i.push(c),o=c;else if(n){var f=n(c,r,e);p.indexOf(o,f)<0&&(o.push(f),i.push(c))}else p.indexOf(i,c)<0&&i.push(c)}return i},p.union=function(){return p.uniq(_(arguments,!0,!0,[]))},p.intersection=function(e){if(null==e)return[];for(var t=[],n=arguments.length,a=0,i=e.length;i>a;a++){var o=e[a];if(!p.contains(t,o)){for(var r=1;n>r&&p.contains(arguments[r],o);r++);r===n&&t.push(o)}}return t},p.difference=function(e){var t=_(s.call(arguments,1),!0,!0,[]);return p.filter(e,function(e){return!p.contains(t,e)})},p.zip=function(e){if(null==e)return[];for(var t=p.max(arguments,"length").length,n=Array(t),a=0;t>a;a++)n[a]=p.pluck(arguments,a);return n},p.object=function(e,t){if(null==e)return{};for(var n={},a=0,i=e.length;i>a;a++)t?n[e[a]]=t[a]:n[e[a][0]]=e[a][1];return n},p.indexOf=function(e,t,n){if(null==e)return-1;var a=0,i=e.length;if(n){if("number"!=typeof n)return a=p.sortedIndex(e,t),e[a]===t?a:-1;a=0>n?Math.max(0,i+n):n}for(;i>a;a++)if(e[a]===t)return a;return-1},p.lastIndexOf=function(e,t,n){if(null==e)return-1;var a=e.length;for("number"==typeof n&&(a=0>n?a+n+1:Math.min(a,n+1));--a>=0;)if(e[a]===t)return a;return-1},p.range=function(e,t,n){arguments.length<=1&&(t=e||0,e=0),n=n||1;for(var a=Math.max(Math.ceil((t-e)/n),0),i=Array(a),o=0;a>o;o++,e+=n)i[o]=e;return i};var y=function(){};p.bind=function(e,t){var n,a;if(h&&e.bind===h)return h.apply(e,s.call(arguments,1));if(!p.isFunction(e))throw new TypeError("Bind must be called on a function");return n=s.call(arguments,2),a=function(){if(!(this instanceof a))return e.apply(t,n.concat(s.call(arguments)));y.prototype=e.prototype;var i=new y;y.prototype=null;var o=e.apply(i,n.concat(s.call(arguments)));return p.isObject(o)?o:i}},p.partial=function(e){var t=s.call(arguments,1);return function(){for(var n=0,a=t.slice(),i=0,o=a.length;o>i;i++)a[i]===p&&(a[i]=arguments[n++]);for(;n=a)throw new Error("bindAll must be passed function names");for(t=1;a>t;t++)n=arguments[t],e[n]=p.bind(e[n],e);return e},p.memoize=function(e,t){var n=function(a){var i=n.cache,o=t?t.apply(this,arguments):a;return p.has(i,o)||(i[o]=e.apply(this,arguments)),i[o]};return n.cache={},n},p.delay=function(e,t){var n=s.call(arguments,2);return setTimeout(function(){return e.apply(null,n)},t)},p.defer=function(e){return p.delay.apply(p,[e,1].concat(s.call(arguments,1)))},p.throttle=function(e,t,n){var a,i,o,r=null,s=0;n||(n={});var c=function(){s=n.leading===!1?0:p.now(),r=null,o=e.apply(a,i),r||(a=i=null)};return function(){var f=p.now();s||n.leading!==!1||(s=f);var d=t-(f-s);return a=this,i=arguments,0>=d||d>t?(clearTimeout(r),r=null,s=f,o=e.apply(a,i),r||(a=i=null)):r||n.trailing===!1||(r=setTimeout(c,d)),o}},p.debounce=function(e,t,n){var a,i,o,r,s,c=function(){var f=p.now()-r;t>f&&f>0?a=setTimeout(c,t-f):(a=null,n||(s=e.apply(o,i),a||(o=i=null)))};return function(){o=this,i=arguments,r=p.now();var f=n&&!a;return a||(a=setTimeout(c,t)),f&&(s=e.apply(o,i),o=i=null),s}},p.wrap=function(e,t){return p.partial(t,e)},p.negate=function(e){return function(){return!e.apply(this,arguments)}},p.compose=function(){var e=arguments,t=e.length-1;return function(){for(var n=t,a=e[t].apply(this,arguments);n--;)a=e[n].call(this,a);return a}},p.after=function(e,t){return function(){return--e<1?t.apply(this,arguments):void 0}},p.before=function(e,t){var n;return function(){return--e>0?n=t.apply(this,arguments):t=null,n}},p.once=p.partial(p.before,2),p.keys=function(e){if(!p.isObject(e))return[];if(l)return l(e);var t=[];for(var n in e)p.has(e,n)&&t.push(n);return t},p.values=function(e){for(var t=p.keys(e),n=t.length,a=Array(n),i=0;n>i;i++)a[i]=e[t[i]];return a},p.pairs=function(e){for(var t=p.keys(e),n=t.length,a=Array(n),i=0;n>i;i++)a[i]=[t[i],e[t[i]]];return a},p.invert=function(e){for(var t={},n=p.keys(e),a=0,i=n.length;i>a;a++)t[e[n[a]]]=n[a];return t},p.functions=p.methods=function(e){var t=[];for(var n in e)p.isFunction(e[n])&&t.push(n);return t.sort()},p.extend=function(e){if(!p.isObject(e))return e;for(var t,n,a=1,i=arguments.length;i>a;a++){t=arguments[a];for(n in t)d.call(t,n)&&(e[n]=t[n])}return e},p.pick=function(e,t,n){var a,i={};if(null==e)return i;if(p.isFunction(t)){t=b(t,n);for(a in e){var o=e[a];t(o,a,e)&&(i[a]=o)}}else{var r=c.apply([],s.call(arguments,1));e=new Object(e);for(var f=0,d=r.length;d>f;f++)a=r[f],a in e&&(i[a]=e[a])}return i},p.omit=function(e,t,n){if(p.isFunction(t))t=p.negate(t);else{var a=p.map(c.apply([],s.call(arguments,1)),String);t=function(e,t){return!p.contains(a,t)}}return p.pick(e,t,n)},p.defaults=function(e){if(!p.isObject(e))return e;for(var t=1,n=arguments.length;n>t;t++){var a=arguments[t];for(var i in a)void 0===e[i]&&(e[i]=a[i])}return e},p.clone=function(e){return p.isObject(e)?p.isArray(e)?e.slice():p.extend({},e):e},p.tap=function(e,t){return t(e),e};var v=function(e,t,n,a){if(e===t)return 0!==e||1/e===1/t;if(null==e||null==t)return e===t;e instanceof p&&(e=e._wrapped),t instanceof p&&(t=t._wrapped);var i=f.call(e);if(i!==f.call(t))return!1;switch(i){case"[object RegExp]":case"[object String]":return""+e==""+t;case"[object Number]":return+e!==+e?+t!==+t:0===+e?1/+e===1/t:+e===+t;case"[object Date]":case"[object Boolean]":return+e===+t}if("object"!=typeof e||"object"!=typeof t)return!1;for(var o=n.length;o--;)if(n[o]===e)return a[o]===t;var r=e.constructor,s=t.constructor;if(r!==s&&"constructor"in e&&"constructor"in t&&!(p.isFunction(r)&&r instanceof r&&p.isFunction(s)&&s instanceof s))return!1;n.push(e),a.push(t);var c,d;if("[object Array]"===i){if(c=e.length,d=c===t.length)for(;c--&&(d=v(e[c],t[c],n,a)););}else{var u,l=p.keys(e);if(c=l.length,d=p.keys(t).length===c)for(;c--&&(u=l[c],d=p.has(t,u)&&v(e[u],t[u],n,a)););}return n.pop(),a.pop(),d};p.isEqual=function(e,t){return v(e,t,[],[])},p.isEmpty=function(e){if(null==e)return!0;if(p.isArray(e)||p.isString(e)||p.isArguments(e))return 0===e.length;for(var t in e)if(p.has(e,t))return!1;return!0},p.isElement=function(e){return!(!e||1!==e.nodeType)},p.isArray=u||function(e){return"[object Array]"===f.call(e)},p.isObject=function(e){var t=typeof e;return"function"===t||"object"===t&&!!e},p.each(["Arguments","Function","String","Number","Date","RegExp"],function(e){p["is"+e]=function(t){return f.call(t)==="[object "+e+"]"}}),p.isArguments(arguments)||(p.isArguments=function(e){return p.has(e,"callee")}),"function"!=typeof/./&&(p.isFunction=function(e){return"function"==typeof e||!1}),p.isFinite=function(e){return isFinite(e)&&!isNaN(parseFloat(e))},p.isNaN=function(e){return p.isNumber(e)&&e!==+e},p.isBoolean=function(e){return e===!0||e===!1||"[object Boolean]"===f.call(e)},p.isNull=function(e){return null===e},p.isUndefined=function(e){return void 0===e},p.has=function(e,t){return null!=e&&d.call(e,t)},p.noConflict=function(){return e._=t,this},p.identity=function(e){return e},p.constant=function(e){return function(){return e}},p.noop=function(){},p.property=function(e){return function(t){return t[e]}},p.matches=function(e){var t=p.pairs(e),n=t.length;return function(e){if(null==e)return!n;e=new Object(e);for(var a=0;n>a;a++){var i=t[a],o=i[0];if(i[1]!==e[o]||!(o in e))return!1}return!0}},p.times=function(e,t,n){var a=Array(Math.max(0,e));t=b(t,n,1);for(var i=0;e>i;i++)a[i]=t(i);return a},p.random=function(e,t){return null==t&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))},p.now=Date.now||function(){return(new Date).getTime()};var E={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},w=p.invert(E),x=function(e){var t=function(t){return e[t]},n="(?:"+p.keys(e).join("|")+")",a=RegExp(n),i=RegExp(n,"g");return function(e){return e=null==e?"":""+e,a.test(e)?e.replace(i,t):e}};p.escape=x(E),p.unescape=x(w),p.result=function(e,t){if(null==e)return void 0;var n=e[t];return p.isFunction(n)?e[t]():n};var T=0;p.uniqueId=function(e){var t=++T+"";return e?e+t:t},p.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var R=/(.)^/,O={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},M=/\\|'|\r|\n|\u2028|\u2029/g,A=function(e){return"\\"+O[e]};p.template=function(e,t,n){!t&&n&&(t=n),t=p.defaults({},t,p.templateSettings);var a=RegExp([(t.escape||R).source,(t.interpolate||R).source,(t.evaluate||R).source].join("|")+"|$","g"),i=0,o="__p+='";e.replace(a,function(t,n,a,r,s){return o+=e.slice(i,s).replace(M,A),i=s+t.length,n?o+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'":a?o+="'+\n((__t=("+a+"))==null?'':__t)+\n'":r&&(o+="';\n"+r+"\n__p+='"),t}),o+="';\n",t.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{var r=new Function(t.variable||"obj","_",o)}catch(s){throw s.source=o,s}var c=function(e){return r.call(this,e,p)},f=t.variable||"obj";return c.source="function("+f+"){\n"+o+"}",c},p.chain=function(e){var t=p(e);return t._chain=!0,t};var H=function(e){return this._chain?p(e).chain():e};p.mixin=function(e){p.each(p.functions(e),function(t){var n=p[t]=e[t];p.prototype[t]=function(){var e=[this._wrapped];return r.apply(e,arguments),H.call(this,n.apply(p,e))}})},p.mixin(p),p.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=a[e];p.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),"shift"!==e&&"splice"!==e||0!==n.length||delete n[0],H.call(this,n)}}),p.each(["concat","join","slice"],function(e){var t=a[e];p.prototype[e]=function(){return H.call(this,t.apply(this._wrapped,arguments))}}),p.prototype.value=function(){return this._wrapped},"function"==typeof n&&n.amd&&n("underscore",[],function(){return p})}.call(this),n("charts/particles",["underscore","components/legends","utils/utils","utils/datasets","utils/colorbrewer"],function(e,t,n,a,i){function o(e,t){this.options={name:"Particle",color:i.Reds[3],size:.3,has_legend:!0,fill_by:null,fill_by_range:null},arguments.length>1&&n.merge(this.options,t),this.data=e}return o.prototype.generateMesh=function(t){for(var n=new a.Array(this.data).raw,i=[],o=0;o1&&t.merge(this.options,n),this.data=e,this.dataset=new a.Array(e),this.ranges=this.dataset.ranges}return o.prototype.generateMesh=function(e){for(var t=new a.Array(this.data).raw,i=new THREE.Geometry,o=new n(t.x.length,0),r=d3.scale.linear().domain(o.divide(this.options.colors.length)).range(this.options.colors),s=0;s1&&t.merge(this.options,i),this.dataset=new n.Array(e),this.ranges=this.dataset.ranges}return i.prototype.generateMesh=function(e){var t={circle:function(e){e.arc(50,50,40,0,2*Math.PI,!1)},rect:function(e){e.beginPath(),e.moveTo(20,20),e.lineTo(80,20),e.lineTo(80,80),e.lineTo(20,80),e.lineTo(20,20)},cross:function(e){var t=[[35,5],[65,5],[65,35],[95,35],[95,65],[65,65],[65,95],[35,95],[35,65],[5,65],[5,35],[35,35]];e.moveTo(t[11][0],t[11][1]);for(var n=0;n-EPS) )__terminate____terminate____terminate__//---------------------------------------------------------__terminate__// CONSTANTS__terminate__//---------------------------------------------------------__terminate____terminate__// 32 48 64 96 128__terminate__#define MAX_STEPS 64__terminate____terminate__//#define uTMK 20.0__terminate__#define TM_MIN 0.05__terminate____terminate____terminate__//---------------------------------------------------------__terminate__// SHADER VARS__terminate__//---------------------------------------------------------__terminate____terminate__varying vec2 vUv;__terminate__varying vec3 vPos0; // position in world coords__terminate__varying vec3 vPos1; // position in object coords__terminate__varying vec3 vPos1n; // normalized 0 to 1, for texture lookup__terminate____terminate__uniform vec3 uOffset; // TESTDEBUG__terminate____terminate__uniform vec3 uCamPos;__terminate____terminate__uniform vec3 uColor; // color of volume__terminate__uniform sampler2D uTex; // 3D(2D) volume texture__terminate__uniform vec3 uTexDim; // dimensions of texture__terminate____terminate__uniform float fPerRow;__terminate__uniform float fPerColumn;__terminate____terminate__uniform float uTMK;__terminate____terminate__float gStepSize;__terminate__float gStepFactor;__terminate____terminate__//---------------------------------------------------------__terminate__// PROGRAM__terminate__//---------------------------------------------------------__terminate____terminate__// TODO: convert world to local volume space__terminate__vec3 toLocal(vec3 p) {__terminate__ return p + vec3(0.5);__terminate__}__terminate____terminate__vec4 sampleVolTex(vec3 pos) {__terminate__ pos = pos;__terminate__ __terminate__ // note: z is up in 3D tex coords, pos.z is tex.y, pos.y is zSlice__terminate__ float zSlice = (1.0-pos.y)*(uTexDim.z-1.0); // float value of slice number, slice 0th to 63rd__terminate____terminate__ float x0 = mod(floor(zSlice), fPerRow)*uTexDim.x +__terminate__ pos.x*(uTexDim.x-1.0) +__terminate__ 0.5;__terminate____terminate__ float y0 = floor(floor(zSlice)/fPerRow)*uTexDim.y +__terminate__ pos.z*(uTexDim.y-1.0) +__terminate__ 0.5;__terminate____terminate__ float width = uTexDim.x*fPerRow;__terminate__ float height = uTexDim.y*fPerColumn;__terminate____terminate__ float uni_x0 = min(x0/width, 1.0);__terminate__ float uni_y0 = min(y0/height, 1.0);__terminate__ float uni_x1;__terminate__ float uni_y1;__terminate____terminate__ if(mod(floor(zSlice)+1.0, fPerRow) == 0.0){__terminate__ uni_x1 = min((pos.x*(uTexDim.x-1.0) + 0.5)/width, 1.0);__terminate__ uni_y1 = min((y0 + uTexDim.y)/height, 1.0);__terminate__ }else{__terminate__ uni_x1 = min((x0 + uTexDim.x)/width, 1.0);__terminate__ uni_y1 = uni_y0;__terminate__ }__terminate____terminate__ // get (bi)linear interped texture reads at two slices__terminate__ vec4 z0 = texture2D(uTex, vec2(uni_x0, uni_y0));__terminate__ vec4 z1 = texture2D(uTex, vec2(uni_x1, uni_y1));__terminate__ return mix(z0, z1, fract(zSlice));__terminate__}__terminate____terminate__vec4 raymarchNoLight(vec3 ro, vec3 rd) {__terminate__ vec3 step = rd*gStepSize;__terminate__ vec3 pos = ro;__terminate__ __terminate__ vec4 col = vec4(0.0);__terminate__ __terminate__ for (int i=0; i 1.0 || pos.x < 0.0 ||__terminate__ pos.y > 1.0 || pos.y < 0.0 ||__terminate__ pos.z > 1.0 || pos.z < 0.0)__terminate__ break;__terminate__ }__terminate__ __terminate__ if(col.r > 1.0)col.r = 1.0;__terminate__ if(col.g > 1.0)col.g = 1.0;__terminate__ if(col.b > 1.0)col.b = 1.0;__terminate__ return vec4(col.rgb, 1.0);__terminate__}__terminate____terminate____terminate__void main() {__terminate__ // in world coords, just for now__terminate__ vec3 ro = vPos1n;__terminate__ vec3 rd = normalize( ro - toLocal(uCamPos) );__terminate__ //vec3 rd = normalize(ro-uCamPos);__terminate__ __terminate__ // step_size = root_three / max_steps ; to get through diagonal __terminate__ gStepSize = ROOTTHREE / float(MAX_STEPS);__terminate__ gStepFactor = 32.0 * gStepSize;__terminate__ __terminate__ gl_FragColor = raymarchNoLight(ro, rd);__terminate__}__terminate__".replace(/__terminate__/g,"\n")}),n("shaders/vs",[],function(){return"#ifdef GL_ES__terminate__precision highp float;__terminate__#endif__terminate____terminate__varying vec2 vUv;__terminate__varying vec3 vPos0;__terminate__varying vec3 vPos1;__terminate__varying vec3 vPos1n;__terminate__varying mat4 vObjMatInv;__terminate____terminate__void main()__terminate__{__terminate__ vUv = uv;__terminate__ __terminate__ gl_Position = projectionMatrix *__terminate__ modelViewMatrix *__terminate__ vec4(position,1.0);__terminate__ __terminate__ vPos0 = ( modelMatrix * vec4(position, 1.0) ).xyz;__terminate__ vPos1 = position;__terminate__ vPos1n = position+vec3(0.5);__terminate__ __terminate__ //vObjMatInv = inverse(modelMatrix);__terminate__}__terminate__".replace(/__terminate__/g,"\n")}),n("charts/volume",["underscore","components/legends","utils/utils","utils/range","utils/datasets","utils/colorbrewer","shaders/fs","shaders/vs"],function(e,t,n,a,i,o,r,s){function c(t,n){this.options={name:"Volume",has_legend:!0,width:100,height:100,depth:100,f_per_row:1,f_per_column:1,filter:f.NearestFilter},arguments.length>1&&e.extend(this.options,n),this.data=new i.Compressed(t),this.ranges={x:[0,1],y:[0,1],z:[0,1]}}var f=window.THREE;return c.prototype.generateMesh=function(t,n){var a=e.bind(function(){var t=new f.Vector3(this.options.width,this.options.height,this.options.depth),a=e.bind(function(){var e=document.createElement("img"),t=new f.Texture(e);return e.onload=function(){console.log("Texture loading finished"),t.needsUpdate=!0},e.src=this.data.raw,t.minFilter=t.magFilter=this.options.filter,t.wrapS=t.wrapT=f.ClampToEdgeWrapping,t.flipX=!0,t.flipY=!1,t},this)(),i=n.world.camera;return{uCamPos:{type:"v3",value:i.position},uColor:{type:"v3",value:new f.Vector3(1,1,1)},uTex:{type:"t",value:a},uTexDim:{type:"v3",value:t},fPerRow:{type:"f",value:this.options.f_per_row},fPerColumn:{type:"f",value:this.options.f_per_column},uOffset:{type:"v3",value:new f.Vector3},uTMK:{type:"f",value:16}}},this)(),i=new f.ShaderMaterial({uniforms:a,vertexShader:s,fragmentShader:r,depthWrite:!1});this.mesh=new f.Mesh(new f.CubeGeometry(1,1,1),i),this.mesh.scale.set(20,20,20)},c.prototype.getDataRanges=function(){return this.ranges},c.prototype.hasLegend=function(){return this.options.has_legend},c.prototype.disappear=function(){this.mesh.material.opacity=0,this.mesh.material.needsUpdate=!0},c.prototype.appear=function(){this.mesh.material.opacity=1},c.prototype.getLegend=function(){return t.generateDiscreteLegend(this.options.name,"#000",this)},c.prototype.getMesh=function(){return this.mesh},c}),n("charts/cylinder",["components/legends","utils/utils","utils/datasets","utils/colorbrewer"],function(e,t,n,a){function i(e,a){this.options={name:"Cylinder",color:"#756bb1",size:.3,has_legend:!0},arguments.length>1&&t.merge(this.options,a),this.data=e,this.dataset=new n.Array(e),this.ranges=this.dataset.ranges}return i.prototype.generateMesh=function(e){for(var t=new n.Array(this.data).raw,a=new THREE.Geometry,i=0;i1&&t.merge(this.options,a),this.data=e,this.dataset=new n.Array(e),this.ranges=this.dataset.ranges}return i.prototype.generateMesh=function(e){for(var a=new n.Array(this.data).raw,i=new THREE.Geometry,o=0;o