/** * dat-gui JavaScript Controller Library * http://code.google.com/p/dat-gui * * Copyright 2011 Data Arts Team, Google Creative Lab * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.dat={})}(this,function(e){"use strict";function t(e,t){var n=e.__state.conversionName.toString(),o=Math.round(e.r),i=Math.round(e.g),r=Math.round(e.b),s=e.a,a=Math.round(e.h),l=e.s.toFixed(1),d=e.v.toFixed(1);if(t||"THREE_CHAR_HEX"===n||"SIX_CHAR_HEX"===n){for(var c=e.hex.toString(16);c.length<6;)c="0"+c;return"#"+c}return"CSS_RGB"===n?"rgb("+o+","+i+","+r+")":"CSS_RGBA"===n?"rgba("+o+","+i+","+r+","+s+")":"HEX"===n?"0x"+e.hex.toString(16):"RGB_ARRAY"===n?"["+o+","+i+","+r+"]":"RGBA_ARRAY"===n?"["+o+","+i+","+r+","+s+"]":"RGB_OBJ"===n?"{r:"+o+",g:"+i+",b:"+r+"}":"RGBA_OBJ"===n?"{r:"+o+",g:"+i+",b:"+r+",a:"+s+"}":"HSV_OBJ"===n?"{h:"+a+",s:"+l+",v:"+d+"}":"HSVA_OBJ"===n?"{h:"+a+",s:"+l+",v:"+d+",a:"+s+"}":"unknown format"}var s=Array.prototype.forEach,o=Array.prototype.slice,f={BREAK:{},extend:function(n){return this.each(o.call(arguments,1),function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(e){this.isUndefined(t[e])||(n[e]=t[e])}.bind(this))},this),n},defaults:function(n){return this.each(o.call(arguments,1),function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(e){this.isUndefined(n[e])&&(n[e]=t[e])}.bind(this))},this),n},compose:function(){var n=o.call(arguments);return function(){for(var e=o.call(arguments),t=n.length-1;0<=t;t--)e=[n[t].apply(this,e)];return e[0]}},each:function(e,t,n){if(e)if(s&&e.forEach&&e.forEach===s)e.forEach(t,n);else if(e.length===e.length+0){var o,i=void 0;for(i=0,o=e.length;i>8*t&255},hex_with_component:function(e,t,n){return n<<(l=8*t)|e&~(255<this.__max&&(t=this.__max),void 0!==this.__step&&t%this.__step!=0&&(t=Math.round(t/this.__step)*this.__step),h(r.prototype.__proto__||Object.getPrototypeOf(r.prototype),"setValue",this).call(this,t)}},{key:"min",value:function(e){return this.__min=e,this}},{key:"max",value:function(e){return this.__max=e,this}},{key:"step",value:function(e){return this.__step=e,this.__impliedStep=e,this.__precision=O(e),this}}]),r}();var R=function(e){function d(e,t,n){g(this,d);var o=b(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,e,t,n));o.__truncationSuspended=!1;var i=o,r=void 0;function s(){i.__onFinishChange&&i.__onFinishChange.call(i,i.getValue())}function a(e){var t=r-e.clientY;i.setValue(i.getValue()+t*i.__impliedStep),r=e.clientY}function l(){C.unbind(window,"mousemove",a),C.unbind(window,"mouseup",l),s()}return o.__input=document.createElement("input"),o.__input.setAttribute("type","text"),C.bind(o.__input,"change",function(){var e=parseFloat(i.__input.value);f.isNaN(e)||i.setValue(e)}),C.bind(o.__input,"blur",function(){s()}),C.bind(o.__input,"mousedown",function(e){C.bind(window,"mousemove",a),C.bind(window,"mouseup",l),r=e.clientY}),C.bind(o.__input,"keydown",function(e){13===e.keyCode&&(i.__truncationSuspended=!0,this.blur(),i.__truncationSuspended=!1,s())}),o.updateDisplay(),o.domElement.appendChild(o.__input),o}return n(d,T),_(d,[{key:"updateDisplay",value:function(){var e,t,n;return this.__input.value=this.__truncationSuspended?this.getValue():(e=this.getValue(),t=this.__precision,n=Math.pow(10,t),Math.round(e*n)/n),h(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"updateDisplay",this).call(this)}}]),d}();function L(e,t,n,o,i){return o+(e-t)/(n-t)*(i-o)}var B=function(e){function u(e,t,n,o,i){g(this,u);var r=b(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,e,t,{min:n,max:o,step:i})),s=r;function a(e){e.preventDefault();var t=s.__background.getBoundingClientRect();return s.setValue(L(e.clientX,t.left,t.right,s.__min,s.__max)),!1}function l(){C.unbind(window,"mousemove",a),C.unbind(window,"mouseup",l),s.__onFinishChange&&s.__onFinishChange.call(s,s.getValue())}function d(e){var t=e.touches[0].clientX,n=s.__background.getBoundingClientRect();s.setValue(L(t,n.left,n.right,s.__min,s.__max))}function c(){C.unbind(window,"touchmove",d),C.unbind(window,"touchend",c),s.__onFinishChange&&s.__onFinishChange.call(s,s.getValue())}return r.__background=document.createElement("div"),r.__foreground=document.createElement("div"),C.bind(r.__background,"mousedown",function(e){document.activeElement.blur(),C.bind(window,"mousemove",a),C.bind(window,"mouseup",l),a(e)}),C.bind(r.__background,"touchstart",function(e){if(1!==e.touches.length)return;C.bind(window,"touchmove",d),C.bind(window,"touchend",c),d(e)}),C.addClass(r.__background,"slider"),C.addClass(r.__foreground,"slider-fg"),r.updateDisplay(),r.__background.appendChild(r.__foreground),r.domElement.appendChild(r.__background),r}return n(u,T),_(u,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",h(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"updateDisplay",this).call(this)}}]),u}(),N=function(e){function r(e,t,n){g(this,r);var o=b(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e,t)),i=o;return o.__button=document.createElement("div"),o.__button.innerHTML=void 0===n?"Fire":n,C.bind(o.__button,"click",function(e){return e.preventDefault(),i.fire(),!1}),C.addClass(o.__button,"button"),o.domElement.appendChild(o.__button),o}return n(r,y),_(r,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),r}(),H=function(e){function p(e,t){g(this,p);var n=b(this,(p.__proto__||Object.getPrototypeOf(p)).call(this,e,t));n.__color=new v(n.getValue()),n.__temp=new v(0);var a=n;n.domElement=document.createElement("div"),C.makeSelectable(n.domElement,!1),n.__selector=document.createElement("div"),n.__selector.className="selector",n.__saturation_field=document.createElement("div"),n.__saturation_field.className="saturation-field",n.__field_knob=document.createElement("div"),n.__field_knob.className="field-knob",n.__field_knob_border="2px solid ",n.__hue_knob=document.createElement("div"),n.__hue_knob.className="hue-knob",n.__hue_field=document.createElement("div"),n.__hue_field.className="hue-field",n.__input=document.createElement("input"),n.__input.type="text",n.__input_textShadow="0 1px 1px ",C.bind(n.__input,"keydown",function(e){13===e.keyCode&&c.call(this)}),C.bind(n.__input,"blur",c),C.bind(n.__selector,"mousedown",function(){C.addClass(this,"drag").bind(window,"mouseup",function(){C.removeClass(a.__selector,"drag")})}),C.bind(n.__selector,"touchstart",function(){C.addClass(this,"drag").bind(window,"touchend",function(){C.removeClass(a.__selector,"drag")})});var o,i=document.createElement("div");function r(e){_(e),C.bind(window,"mousemove",_),C.bind(window,"touchmove",_),C.bind(window,"mouseup",l),C.bind(window,"touchend",l)}function s(e){h(e),C.bind(window,"mousemove",h),C.bind(window,"touchmove",h),C.bind(window,"mouseup",d),C.bind(window,"touchend",d)}function l(){C.unbind(window,"mousemove",_),C.unbind(window,"touchmove",_),C.unbind(window,"mouseup",l),C.unbind(window,"touchend",l),u()}function d(){C.unbind(window,"mousemove",h),C.unbind(window,"touchmove",h),C.unbind(window,"mouseup",d),C.unbind(window,"touchend",d),u()}function c(){var e=m(this.value);!1!==e?(a.__color.__state=e,a.setValue(a.__color.toOriginal())):this.value=a.__color.toString()}function u(){a.__onFinishChange&&a.__onFinishChange.call(a,a.__color.toOriginal())}function _(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=a.__saturation_field.getBoundingClientRect(),n=e.touches&&e.touches[0]||e,o=n.clientX,i=n.clientY,r=(o-t.left)/(t.right-t.left),s=1-(i-t.top)/(t.bottom-t.top);return 1ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n"));var z="Default",M=function(){try{return!!window.localStorage}catch(e){return!1}}(),G=void 0,U=!0,X=void 0,K=!1,Y=[],J=function t(e){var n=this,o=e||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),C.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],o=f.defaults(o,{closeOnTop:!1,autoPlace:!0,width:t.DEFAULT_WIDTH}),o=f.defaults(o,{resizable:o.autoPlace,hideable:o.autoPlace}),f.isUndefined(o.load)?o.load={preset:z}:o.preset&&(o.load.preset=o.preset),f.isUndefined(o.parent)&&o.hideable&&Y.push(this),o.resizable=f.isUndefined(o.parent)&&o.resizable,o.autoPlace&&f.isUndefined(o.scrollable)&&(o.scrollable=!0);var i,r=M&&"true"===localStorage.getItem(ee(this,"isLocal")),s=void 0;if(Object.defineProperties(this,{parent:{get:function(){return o.parent}},scrollable:{get:function(){return o.scrollable}},autoPlace:{get:function(){return o.autoPlace}},closeOnTop:{get:function(){return o.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:o.load.preset},set:function(e){n.parent?n.getRoot().preset=e:o.load.preset=e,function(e){for(var t=0;tGUI\'s constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n\n
\n\n
\n\n'),this.parent)throw new Error("You can only call remember on a top level GUI.");var t=this;f.each(Array.prototype.slice.call(arguments),function(e){0===t.__rememberedObjects.length&&function(n){var e=n.__save_row=document.createElement("li");C.addClass(n.domElement,"has-save"),n.__ul.insertBefore(e,n.__ul.firstChild),C.addClass(e,"save-row");var t=document.createElement("span");t.innerHTML=" ",C.addClass(t,"button gears");var o=document.createElement("span");o.innerHTML="Save",C.addClass(o,"button"),C.addClass(o,"save");var i=document.createElement("span");i.innerHTML="New",C.addClass(i,"button"),C.addClass(i,"save-as");var r=document.createElement("span");r.innerHTML="Revert",C.addClass(r,"button"),C.addClass(r,"revert");var s=n.__preset_select=document.createElement("select");n.load&&n.load.remembered?f.each(n.load.remembered,function(e,t){te(n,t,t===n.preset)}):te(n,z,!1);if(C.bind(s,"change",function(){for(var e=0;e