2 lines
48 KiB
JavaScript
2 lines
48 KiB
JavaScript
/* 2020-9-22 15:23:18 | 版权所有 军懋国兴 */
|
|
function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(e,t){"object"==("undefined"==typeof exports?"undefined":_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"}function n(e,t,n){Object.defineProperty(e,t,{get:function(){return"RGB"===this.__state.space||H.recalculateRGB(this,t,n),this.__state[t]},set:function(e){"RGB"!==this.__state.space&&(H.recalculateRGB(this,t,n),this.__state.space="RGB"),this.__state[t]=e}})}function o(e,t){Object.defineProperty(e,t,{get:function(){return"HSV"===this.__state.space||H.recalculateHSV(this),this.__state[t]},set:function(e){"HSV"!==this.__state.space&&(H.recalculateHSV(this),this.__state.space="HSV"),this.__state[t]=e}})}function i(e){if("0"===e||C.isUndefined(e))return 0;var t=e.match(z);return C.isNull(t)?0:parseFloat(t[1])}function r(e){var t=e.toString();return-1<t.indexOf(".")?t.length-t.indexOf(".")-1:0}function u(e,t,n,o,i){return o+(e-t)/(n-t)*(i-o)}function p(t,n,o,i){t.style.background="",C.each(q,function(e){t.style.cssText+="background: "+e+"linear-gradient("+n+", "+o+" 0%, "+i+" 100%); "})}function f(e,t,n){var o=document.createElement("li");return t&&o.appendChild(t),n?e.__ul.insertBefore(o,n):e.__ul.appendChild(o),e.onResize(),o}function s(e){M.unbind(window,"resize",e.__resizeHandler),e.saveToLocalStorageIfPossible&&M.unbind(window,"unload",e.saveToLocalStorageIfPossible)}function m(e,t){var n=e.__preset_select[e.__preset_select.selectedIndex];n.innerHTML=t?n.value+"*":n.value}function b(e,t){var n=e.getRoot(),o=n.__rememberedObjects.indexOf(t.object);if(-1!==o){var i=n.__rememberedObjectIndecesToControllers[o];if(void 0===i&&(i={},n.__rememberedObjectIndecesToControllers[o]=i),i[t.property]=t,n.load&&n.load.remembered){var r,s=n.load.remembered,a=void 0;if(s[e.preset])a=s[e.preset];else{if(!s[ue])return;a=s[ue]}a[o]&&void 0!==a[o][t.property]&&(r=a[o][t.property],t.initialValue=r,t.setValue(r))}}}function g(e,t,n,o){if(void 0===t[n])throw new Error('Object "'+t+'" has no property "'+n+'"');var i,r=void 0;r=o.color?new Q(t,n):(i=[t,n].concat(o.factoryArgs),$.apply(e,i)),o.before instanceof j&&(o.before=o.before.__li),b(e,r),M.addClass(r.domElement,"c");var s=document.createElement("span");M.addClass(s,"property-name"),s.innerHTML=r.property;var a=document.createElement("div");a.appendChild(s),a.appendChild(r.domElement);var l,d,c,u,_,h=f(e,a,o.before);return M.addClass(h,ge.CLASS_CONTROLLER_ROW),r instanceof Q?M.addClass(h,"color"):M.addClass(h,L(r.getValue())),l=e,d=h,(c=r).__li=d,c.__gui=l,C.extend(c,{options:function(e){if(1<arguments.length){var t=c.__li.nextElementSibling;return c.remove(),g(l,c.object,c.property,{before:t,factoryArgs:[C.toArray(arguments)]})}if(C.isArray(e)||C.isObject(e)){var n=c.__li.nextElementSibling;return c.remove(),g(l,c.object,c.property,{before:n,factoryArgs:[e]})}},name:function(e){return c.__li.firstElementChild.firstElementChild.innerHTML=e,c},listen:function(){return c.__gui.listen(c),c},remove:function(){return c.__gui.remove(c),c}}),c instanceof J?(u=new Y(c.object,c.property,{min:c.__min,max:c.__max,step:c.__step}),C.each(["updateDisplay","onChange","onFinishChange","step","min","max"],function(e){var t=c[e],n=u[e];c[e]=u[e]=function(){var e=Array.prototype.slice.call(arguments);return n.apply(u,e),t.apply(c,e)}}),M.addClass(d,"has-slider"),c.domElement.insertBefore(u.domElement,c.domElement.firstElementChild)):c instanceof Y?(_=function(e){if(C.isNumber(c.__min)&&C.isNumber(c.__max)){var t=c.__li.firstElementChild.firstElementChild.innerHTML,n=-1<c.__gui.__listening.indexOf(c);c.remove();var o=g(l,c.object,c.property,{before:c.__li.nextElementSibling,factoryArgs:[c.__min,c.__max,c.__step]});return o.name(t),n&&o.listen(),o}return e},c.min=C.compose(_,c.min),c.max=C.compose(_,c.max)):c instanceof G?(M.bind(d,"click",function(){M.fakeEvent(c.__checkbox,"click")}),M.bind(c.__checkbox,"click",function(e){e.stopPropagation()})):c instanceof W?(M.bind(d,"click",function(){M.fakeEvent(c.__button,"click")}),M.bind(d,"mouseover",function(){M.addClass(c.__button,"hover")}),M.bind(d,"mouseout",function(){M.removeClass(c.__button,"hover")})):c instanceof Q&&(M.addClass(d,"color"),c.updateDisplay=C.compose(function(e){return d.style.borderLeftColor=c.__color.toString(),e},c.updateDisplay),c.updateDisplay()),c.setValue=C.compose(function(e){return l.getRoot().__preset_select&&c.isModified()&&m(l.getRoot(),!0),e},c.setValue),e.__controllers.push(r),r}function v(e,t){return document.location.href+"."+t}function c(e,t,n){var o=document.createElement("option");o.innerHTML=t,o.value=t,e.__preset_select.appendChild(o),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function _(e,t){t.style.display=e.useLocalStorage?"block":"none"}function y(e,t){e.domElement.style.width=t+"px",e.__save_row&&e.autoPlace&&(e.__save_row.style.width=t+"px"),e.__closeButton&&(e.__closeButton.style.width=t+"px")}function a(i,r){var s={};return C.each(i.__rememberedObjects,function(e,t){var n={},o=i.__rememberedObjectIndecesToControllers[t];C.each(o,function(e,t){n[t]=r?e.initialValue:e.getValue()}),s[t]=n}),s}function l(e,t,n){null===e&&(e=Function.prototype);var o=Object.getOwnPropertyDescriptor(e,t);if(void 0===o){var i=Object.getPrototypeOf(e);return null===i?void 0:l(i,t,n)}if("value"in o)return o.value;var r=o.get;return void 0!==r?r.call(n):void 0}function d(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+_typeof(t));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var h,w,x=Array.prototype.forEach,E=Array.prototype.slice,C={BREAK:{},extend:function(n){return this.each(E.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(E.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=E.call(arguments);return function(){for(var e=E.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(x&&e.forEach&&e.forEach===x)e.forEach(t,n);else if(e.length===e.length+0){for(var o=void 0,o=0,i=e.length;o<i;o++)if(o in e&&t.call(n,e[o],o)===this.BREAK)return}else for(var r in e)if(t.call(n,e[r],r)===this.BREAK)return},defer:function(e){setTimeout(e,0)},debounce:function(o,i,r){var s=void 0;return function(){var e=this,t=arguments,n=r||!s;clearTimeout(s),s=setTimeout(function(){s=null,r||o.apply(e,t)},i),n&&o.apply(e,t)}},toArray:function(e){return e.toArray?e.toArray():E.call(e)},isUndefined:function(e){return void 0===e},isNull:function(e){return null===e},isNaN:(w=function(e){return isNaN(e)},D.toString=function(){return w.toString()},D),isArray:Array.isArray||function(e){return e.constructor===Array},isObject:function(e){return e===Object(e)},isNumber:function(e){return e===e+0},isString:function(e){return e===e+""},isBoolean:function(e){return!1===e||!0===e},isFunction:function(e){return"[object Function]"===Object.prototype.toString.call(e)}},A=[{litmus:C.isString,conversions:{THREE_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString()+t[1].toString()+t[2].toString()+t[2].toString()+t[3].toString()+t[3].toString(),0)}},write:t},SIX_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9]{6})$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString(),0)}},write:t},CSS_RGB:{read:function(e){var t=e.match(/^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3])}},write:t},CSS_RGBA:{read:function(e){var t=e.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3]),a:parseFloat(t[4])}},write:t}}},{litmus:C.isNumber,conversions:{HEX:{read:function(e){return{space:"HEX",hex:e,conversionName:"HEX"}},write:function(e){return e.hex}}}},{litmus:C.isArray,conversions:{RGB_ARRAY:{read:function(e){return 3===e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2]}},write:function(e){return[e.r,e.g,e.b]}},RGBA_ARRAY:{read:function(e){return 4===e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2],a:e[3]}},write:function(e){return[e.r,e.g,e.b,e.a]}}}},{litmus:C.isObject,conversions:{RGBA_OBJ:{read:function(e){return!!(C.isNumber(e.r)&&C.isNumber(e.g)&&C.isNumber(e.b)&&C.isNumber(e.a))&&{space:"RGB",r:e.r,g:e.g,b:e.b,a:e.a}},write:function(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}},RGB_OBJ:{read:function(e){return!!(C.isNumber(e.r)&&C.isNumber(e.g)&&C.isNumber(e.b))&&{space:"RGB",r:e.r,g:e.g,b:e.b}},write:function(e){return{r:e.r,g:e.g,b:e.b}}},HSVA_OBJ:{read:function(e){return!!(C.isNumber(e.h)&&C.isNumber(e.s)&&C.isNumber(e.v)&&C.isNumber(e.a))&&{space:"HSV",h:e.h,s:e.s,v:e.v,a:e.a}},write:function(e){return{h:e.h,s:e.s,v:e.v,a:e.a}}},HSV_OBJ:{read:function(e){return!!(C.isNumber(e.h)&&C.isNumber(e.s)&&C.isNumber(e.v))&&{space:"HSV",h:e.h,s:e.s,v:e.v}},write:function(e){return{h:e.h,s:e.s,v:e.v}}}}}],k=void 0,S=void 0,O=function(e){S=!1;var n=1<arguments.length?C.toArray(arguments):e;return C.each(A,function(e){if(e.litmus(n))return C.each(e.conversions,function(e,t){if(k=e.read(n),!1===S&&!1!==k)return(S=k).conversionName=t,k.conversion=e,C.BREAK}),C.BREAK}),S},T={hsv_to_rgb:function(e,t,n){var o=Math.floor(e/60)%6,i=e/60-Math.floor(e/60),r=n*(1-t),s=n*(1-i*t),a=n*(1-(1-i)*t),l=[[n,a,r],[s,n,r],[r,n,a],[r,s,n],[a,r,n],[n,r,s]][o];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,n){var o=Math.min(e,t,n),i=Math.max(e,t,n),r=i-o,s=void 0;return 0===i?{h:NaN,s:0,v:0}:(s=e===i?(t-n)/r:t===i?2+(n-e)/r:4+(e-t)/r,(s/=6)<0&&(s+=1),{h:360*s,s:r/i,v:i/255})},rgb_to_hex:function(e,t,n){var o=this.hex_with_component(0,2,e),o=this.hex_with_component(o,1,t);return this.hex_with_component(o,0,n)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,n){return n<<(h=8*t)|e&~(255<<h)}},L="function"==typeof Symbol&&"symbol"==_typeof(Symbol.iterator)?function(e){return _typeof(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":_typeof(e)},R=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},B=function(e,t,n){return t&&P(e.prototype,t),n&&P(e,n),e},N=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=_typeof(t)&&"function"!=typeof t?e:t},H=(B(F,[{key:"toString",value:function(){return t(this)}},{key:"toHexString",value:function(){return t(this,!0)}},{key:"toOriginal",value:function(){return this.__state.conversion.write(this)}}]),F);function F(){if(R(this,F),this.__state=O.apply(this,arguments),!1===this.__state)throw new Error("Failed to interpret color arguments");this.__state.a=this.__state.a||1}function P(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function D(e){return w.apply(this,arguments)}H.recalculateRGB=function(e,t,n){if("HEX"===e.__state.space)e.__state[t]=T.component_from_hex(e.__state.hex,n);else{if("HSV"!==e.__state.space)throw new Error("Corrupted color state");C.extend(e.__state,T.hsv_to_rgb(e.__state.h,e.__state.s,e.__state.v))}},H.recalculateHSV=function(e){var t=T.rgb_to_hsv(e.r,e.g,e.b);C.extend(e.__state,{s:t.s,v:t.v}),C.isNaN(t.h)?C.isUndefined(e.__state.h)&&(e.__state.h=0):e.__state.h=t.h},H.COMPONENTS=["r","g","b","h","s","v","hex","a"],n(H.prototype,"r",2),n(H.prototype,"g",1),n(H.prototype,"b",0),o(H.prototype,"h"),o(H.prototype,"s"),o(H.prototype,"v"),Object.defineProperty(H.prototype,"a",{get:function(){return this.__state.a},set:function(e){this.__state.a=e}}),Object.defineProperty(H.prototype,"hex",{get:function(){return"HEX"!==!this.__state.space&&(this.__state.hex=T.rgb_to_hex(this.r,this.g,this.b)),this.__state.hex},set:function(e){this.__state.space="HEX",this.__state.hex=e}});var j=(B(I,[{key:"onChange",value:function(e){return this.__onChange=e,this}},{key:"onFinishChange",value:function(e){return this.__onFinishChange=e,this}},{key:"setValue",value:function(e){return this.object[this.property]=e,this.__onChange&&this.__onChange.call(this,e),this.updateDisplay(),this}},{key:"getValue",value:function(){return this.object[this.property]}},{key:"updateDisplay",value:function(){return this}},{key:"isModified",value:function(){return this.initialValue!==this.getValue()}}]),I),V={};function I(e,t){R(this,I),this.initialValue=e[t],this.domElement=document.createElement("div"),this.object=e,this.property=t,this.__onChange=void 0,this.__onFinishChange=void 0}C.each({HTMLEvents:["change"],MouseEvents:["click","mousemove","mousedown","mouseup","mouseover"],KeyboardEvents:["keydown"]},function(e,t){C.each(e,function(e){V[e]=t})});var z=/(\d+(\.\d+)?)px/,M={makeSelectable:function(e,t){void 0!==e&&void 0!==e.style&&(e.onselectstart=t?function(){return!1}:function(){},e.style.MozUserSelect=t?"auto":"none",e.style.KhtmlUserSelect=t?"auto":"none",e.unselectable=t?"on":"off")},makeFullscreen:function(e,t,n){var o=n,i=t;C.isUndefined(i)&&(i=!0),C.isUndefined(o)&&(o=!0),e.style.position="absolute",i&&(e.style.left=0,e.style.right=0),o&&(e.style.top=0,e.style.bottom=0)},fakeEvent:function(e,t,n,o){var i=n||{},r=V[t];if(!r)throw new Error("Event type "+t+" not supported.");var s=document.createEvent(r);switch(r){case"MouseEvents":var a=i.x||i.clientX||0,l=i.y||i.clientY||0;s.initMouseEvent(t,i.bubbles||!1,i.cancelable||!0,window,i.clickCount||1,0,0,a,l,!1,!1,!1,!1,0,null);break;case"KeyboardEvents":var d=s.initKeyboardEvent||s.initKeyEvent;C.defaults(i,{cancelable:!0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,keyCode:void 0,charCode:void 0}),d(t,i.bubbles||!1,i.cancelable,window,i.ctrlKey,i.altKey,i.shiftKey,i.metaKey,i.keyCode,i.charCode);break;default:s.initEvent(t,i.bubbles||!1,i.cancelable||!0)}C.defaults(s,o),e.dispatchEvent(s)},bind:function(e,t,n,o){var i=o||!1;return e.addEventListener?e.addEventListener(t,n,i):e.attachEvent&&e.attachEvent("on"+t,n),M},unbind:function(e,t,n,o){var i=o||!1;return e.removeEventListener?e.removeEventListener(t,n,i):e.detachEvent&&e.detachEvent("on"+t,n),M},addClass:function(e,t){var n;return void 0===e.className?e.className=t:e.className===t||-1===(n=e.className.split(/ +/)).indexOf(t)&&(n.push(t),e.className=n.join(" ").replace(/^\s+/,"").replace(/\s+$/,"")),M},removeClass:function(e,t){var n,o;return t?e.className===t?e.removeAttribute("class"):-1!==(o=(n=e.className.split(/ +/)).indexOf(t))&&(n.splice(o,1),e.className=n.join(" ")):e.className=void 0,M},hasClass:function(e,t){return new RegExp("(?:^|\\s+)"+t+"(?:\\s+|$)").test(e.className)||!1},getWidth:function(e){var t=getComputedStyle(e);return i(t["border-left-width"])+i(t["border-right-width"])+i(t["padding-left"])+i(t["padding-right"])+i(t.width)},getHeight:function(e){var t=getComputedStyle(e);return i(t["border-top-width"])+i(t["border-bottom-width"])+i(t["padding-top"])+i(t["padding-bottom"])+i(t.height)},getOffset:function(e){var t=e,n={left:0,top:0};if(t.offsetParent)for(;n.left+=t.offsetLeft,n.top+=t.offsetTop,t=t.offsetParent;);return n},isActive:function(e){return e===document.activeElement&&(e.type||e.href)}},G=(d(ce,j),B(ce,[{key:"setValue",value:function(e){var t=l(ce.prototype.__proto__||Object.getPrototypeOf(ce.prototype),"setValue",this).call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),this.__prev=this.getValue(),t}},{key:"updateDisplay",value:function(){return!0===this.getValue()?(this.__checkbox.setAttribute("checked","checked"),this.__checkbox.checked=!0,this.__prev=!0):(this.__checkbox.checked=!1,this.__prev=!1),l(ce.prototype.__proto__||Object.getPrototypeOf(ce.prototype),"updateDisplay",this).call(this)}}]),ce),U=(d(de,j),B(de,[{key:"setValue",value:function(e){var t=l(de.prototype.__proto__||Object.getPrototypeOf(de.prototype),"setValue",this).call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),t}},{key:"updateDisplay",value:function(){return M.isActive(this.__select)?this:(this.__select.value=this.getValue(),l(de.prototype.__proto__||Object.getPrototypeOf(de.prototype),"updateDisplay",this).call(this))}}]),de),X=(d(le,j),B(le,[{key:"updateDisplay",value:function(){return M.isActive(this.__input)||(this.__input.value=this.getValue()),l(le.prototype.__proto__||Object.getPrototypeOf(le.prototype),"updateDisplay",this).call(this)}}]),le),K=(d(ae,j),B(ae,[{key:"setValue",value:function(e){var t=e;return void 0!==this.__min&&t<this.__min?t=this.__min:void 0!==this.__max&&t>this.__max&&(t=this.__max),void 0!==this.__step&&t%this.__step!=0&&(t=Math.round(t/this.__step)*this.__step),l(ae.prototype.__proto__||Object.getPrototypeOf(ae.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=r(e),this}}]),ae),Y=(d(se,K),B(se,[{key:"updateDisplay",value:function(){return this.__input.value=this.__truncationSuspended?this.getValue():(e=this.getValue(),t=this.__precision,n=Math.pow(10,t),Math.round(e*n)/n),l(se.prototype.__proto__||Object.getPrototypeOf(se.prototype),"updateDisplay",this).call(this);var e,t,n}}]),se),J=(d(re,K),B(re,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",l(re.prototype.__proto__||Object.getPrototypeOf(re.prototype),"updateDisplay",this).call(this)}}]),re),W=(d(ie,j),B(ie,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),ie),Q=(d(oe,j),B(oe,[{key:"updateDisplay",value:function(){var t,n=O(this.getValue());!1!==n&&(t=!1,C.each(H.COMPONENTS,function(e){if(!C.isUndefined(n[e])&&!C.isUndefined(this.__color.__state[e])&&n[e]!==this.__color.__state[e])return t=!0,{}},this),t&&C.extend(this.__color.__state,n)),C.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var e=this.__color.v<.5||.5<this.__color.s?255:0,o=255-e;C.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+e+","+e+","+e+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,p(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),C.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+e+","+e+","+e+")",textShadow:this.__input_textShadow+"rgba("+o+","+o+","+o+",.7)"})}}]),oe),q=["-moz-","-o-","-webkit-","-ms-",""],Z=function(e,t){var n=t||document,o=document.createElement("style");o.type="text/css",o.innerHTML=e;var i=n.getElementsByTagName("head")[0];try{i.appendChild(o)}catch(e){}},$=function(e,t,n,o,i){var r=e[t];return C.isArray(n)||C.isObject(n)?new U(e,t,n):C.isNumber(r)?C.isNumber(n)&&C.isNumber(o)?C.isNumber(i)?new J(e,t,n,o,i):new J(e,t,n,o):C.isNumber(i)?new Y(e,t,{min:n,max:o,step:i}):new Y(e,t,{min:n,max:o}):C.isString(r)?new X(e,t):C.isFunction(r)?new W(e,t,""):C.isBoolean(r)?new G(e,t):null},ee=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)},te=(B(ne,[{key:"show",value:function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),C.defer(function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"})}},{key:"hide",value:function(){function e(){t.domElement.style.display="none",t.backgroundElement.style.display="none",M.unbind(t.domElement,"webkitTransitionEnd",e),M.unbind(t.domElement,"transitionend",e),M.unbind(t.domElement,"oTransitionEnd",e)}var t=this;M.bind(this.domElement,"webkitTransitionEnd",e),M.bind(this.domElement,"transitionend",e),M.bind(this.domElement,"oTransitionEnd",e),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-M.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-M.getHeight(this.domElement)/2+"px"}}]),ne);function ne(){R(this,ne),this.backgroundElement=document.createElement("div"),C.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),M.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),C.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var e=this;M.bind(this.backgroundElement,"click",function(){e.hide()})}function oe(e,t){function n(e){l(e),M.bind(window,"mousemove",l),M.bind(window,"touchmove",l),M.bind(window,"mouseup",i),M.bind(window,"touchend",i)}function o(e){d(e),M.bind(window,"mousemove",d),M.bind(window,"touchmove",d),M.bind(window,"mouseup",r),M.bind(window,"touchend",r)}function i(){M.unbind(window,"mousemove",l),M.unbind(window,"touchmove",l),M.unbind(window,"mouseup",i),M.unbind(window,"touchend",i),a()}function r(){M.unbind(window,"mousemove",d),M.unbind(window,"touchmove",d),M.unbind(window,"mouseup",r),M.unbind(window,"touchend",r),a()}function s(){var e=O(this.value);!1!==e?(u.__color.__state=e,u.setValue(u.__color.toOriginal())):this.value=u.__color.toString()}function a(){u.__onFinishChange&&u.__onFinishChange.call(u,u.__color.toOriginal())}function l(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=u.__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 1<s?s=1:s<0&&(s=0),1<r?r=1:r<0&&(r=0),u.__color.v=s,u.__color.s=r,u.setValue(u.__color.toOriginal()),!1}function d(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=u.__hue_field.getBoundingClientRect(),n=1-((e.touches&&e.touches[0]||e).clientY-t.top)/(t.bottom-t.top);return 1<n?n=1:n<0&&(n=0),u.__color.h=360*n,u.setValue(u.__color.toOriginal()),!1}R(this,oe);var c=N(this,(oe.__proto__||Object.getPrototypeOf(oe)).call(this,e,t));c.__color=new H(c.getValue()),c.__temp=new H(0);var u=c;c.domElement=document.createElement("div"),M.makeSelectable(c.domElement,!1),c.__selector=document.createElement("div"),c.__selector.className="selector",c.__saturation_field=document.createElement("div"),c.__saturation_field.className="saturation-field",c.__field_knob=document.createElement("div"),c.__field_knob.className="field-knob",c.__field_knob_border="2px solid ",c.__hue_knob=document.createElement("div"),c.__hue_knob.className="hue-knob",c.__hue_field=document.createElement("div"),c.__hue_field.className="hue-field",c.__input=document.createElement("input"),c.__input.type="text",c.__input_textShadow="0 1px 1px ",M.bind(c.__input,"keydown",function(e){13===e.keyCode&&s.call(this)}),M.bind(c.__input,"blur",s),M.bind(c.__selector,"mousedown",function(){M.addClass(this,"drag").bind(window,"mouseup",function(){M.removeClass(u.__selector,"drag")})}),M.bind(c.__selector,"touchstart",function(){M.addClass(this,"drag").bind(window,"touchend",function(){M.removeClass(u.__selector,"drag")})});var _,h=document.createElement("div");return C.extend(c.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),C.extend(c.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:c.__field_knob_border+(c.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),C.extend(c.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),C.extend(c.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),C.extend(h.style,{width:"100%",height:"100%",background:"none"}),p(h,"top","rgba(0,0,0,0)","#000"),C.extend(c.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),(_=c.__hue_field).style.background="",_.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",_.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",_.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",_.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",_.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",C.extend(c.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:c.__input_textShadow+"rgba(0,0,0,0.7)"}),M.bind(c.__saturation_field,"mousedown",n),M.bind(c.__saturation_field,"touchstart",n),M.bind(c.__field_knob,"mousedown",n),M.bind(c.__field_knob,"touchstart",n),M.bind(c.__hue_field,"mousedown",o),M.bind(c.__hue_field,"touchstart",o),c.__saturation_field.appendChild(h),c.__selector.appendChild(c.__field_knob),c.__selector.appendChild(c.__saturation_field),c.__selector.appendChild(c.__hue_field),c.__hue_field.appendChild(c.__hue_knob),c.domElement.appendChild(c.__input),c.domElement.appendChild(c.__selector),c.updateDisplay(),c}function ie(e,t,n){R(this,ie);var o=N(this,(ie.__proto__||Object.getPrototypeOf(ie)).call(this,e,t)),i=o;return o.__button=document.createElement("div"),o.__button.innerHTML=void 0===n?"Fire":n,M.bind(o.__button,"click",function(e){return e.preventDefault(),i.fire(),!1}),M.addClass(o.__button,"button"),o.domElement.appendChild(o.__button),o}function re(e,t,n,o,i){function r(e){e.preventDefault();var t=c.__background.getBoundingClientRect();return c.setValue(u(e.clientX,t.left,t.right,c.__min,c.__max)),!1}function s(){M.unbind(window,"mousemove",r),M.unbind(window,"mouseup",s),c.__onFinishChange&&c.__onFinishChange.call(c,c.getValue())}function a(e){var t=e.touches[0].clientX,n=c.__background.getBoundingClientRect();c.setValue(u(t,n.left,n.right,c.__min,c.__max))}function l(){M.unbind(window,"touchmove",a),M.unbind(window,"touchend",l),c.__onFinishChange&&c.__onFinishChange.call(c,c.getValue())}R(this,re);var d=N(this,(re.__proto__||Object.getPrototypeOf(re)).call(this,e,t,{min:n,max:o,step:i})),c=d;return d.__background=document.createElement("div"),d.__foreground=document.createElement("div"),M.bind(d.__background,"mousedown",function(e){document.activeElement.blur(),M.bind(window,"mousemove",r),M.bind(window,"mouseup",s),r(e)}),M.bind(d.__background,"touchstart",function(e){1===e.touches.length&&(M.bind(window,"touchmove",a),M.bind(window,"touchend",l),a(e))}),M.addClass(d.__background,"slider"),M.addClass(d.__foreground,"slider-fg"),d.updateDisplay(),d.__background.appendChild(d.__foreground),d.domElement.appendChild(d.__background),d}function se(e,t,n){function o(){a.__onFinishChange&&a.__onFinishChange.call(a,a.getValue())}function i(e){var t=l-e.clientY;a.setValue(a.getValue()+t*a.__impliedStep),l=e.clientY}function r(){M.unbind(window,"mousemove",i),M.unbind(window,"mouseup",r),o()}R(this,se);var s=N(this,(se.__proto__||Object.getPrototypeOf(se)).call(this,e,t,n));s.__truncationSuspended=!1;var a=s,l=void 0;return s.__input=document.createElement("input"),s.__input.setAttribute("type","text"),M.bind(s.__input,"change",function(){var e=parseFloat(a.__input.value);C.isNaN(e)||a.setValue(e)}),M.bind(s.__input,"blur",function(){o()}),M.bind(s.__input,"mousedown",function(e){M.bind(window,"mousemove",i),M.bind(window,"mouseup",r),l=e.clientY}),M.bind(s.__input,"keydown",function(e){13===e.keyCode&&(a.__truncationSuspended=!0,this.blur(),a.__truncationSuspended=!1,o())}),s.updateDisplay(),s.domElement.appendChild(s.__input),s}function ae(e,t,n){R(this,ae);var o=N(this,(ae.__proto__||Object.getPrototypeOf(ae)).call(this,e,t)),i=n||{};return o.__min=i.min,o.__max=i.max,o.__step=i.step,C.isUndefined(o.__step)?0===o.initialValue?o.__impliedStep=1:o.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(o.initialValue))/Math.LN10))/10:o.__impliedStep=o.__step,o.__precision=r(o.__impliedStep),o}function le(e,t){function n(){i.setValue(i.__input.value)}R(this,le);var o=N(this,(le.__proto__||Object.getPrototypeOf(le)).call(this,e,t)),i=o;return o.__input=document.createElement("input"),o.__input.setAttribute("type","text"),M.bind(o.__input,"keyup",n),M.bind(o.__input,"change",n),M.bind(o.__input,"blur",function(){i.__onFinishChange&&i.__onFinishChange.call(i,i.getValue())}),M.bind(o.__input,"keydown",function(e){13===e.keyCode&&this.blur()}),o.updateDisplay(),o.domElement.appendChild(o.__input),o}function de(e,t,n){R(this,de);var o,i=N(this,(de.__proto__||Object.getPrototypeOf(de)).call(this,e,t)),r=n,s=i;return i.__select=document.createElement("select"),C.isArray(r)&&(o={},C.each(r,function(e){o[e]=e}),r=o),C.each(r,function(e,t){var n=document.createElement("option");n.innerHTML=t,n.setAttribute("value",e),s.__select.appendChild(n)}),i.updateDisplay(),M.bind(i.__select,"change",function(){var e=this.options[this.selectedIndex].value;s.setValue(e)}),i.domElement.appendChild(i.__select),i}function ce(e,t){R(this,ce);var n=N(this,(ce.__proto__||Object.getPrototypeOf(ce)).call(this,e,t)),o=n;return n.__prev=n.getValue(),n.__checkbox=document.createElement("input"),n.__checkbox.setAttribute("type","checkbox"),M.bind(n.__checkbox,"change",function(){o.setValue(!o.__prev)},!1),n.domElement.appendChild(n.__checkbox),n.updateDisplay(),n}Z(function(e){if("undefined"!=typeof window){var t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}}(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.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 ue="Default",_e=function(){try{return!!window.localStorage}catch(e){return!1}}(),he=void 0,pe=!0,fe=void 0,me=!1,be=[],ge=function t(e){var n=this,o=e||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),M.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],o=C.defaults(o,{closeOnTop:!1,autoPlace:!0,width:t.DEFAULT_WIDTH}),o=C.defaults(o,{resizable:o.autoPlace,hideable:o.autoPlace}),C.isUndefined(o.load)?o.load={preset:ue}:o.preset&&(o.load.preset=o.preset),C.isUndefined(o.parent)&&o.hideable&&be.push(this),o.resizable=C.isUndefined(o.parent)&&o.resizable,o.autoPlace&&C.isUndefined(o.scrollable)&&(o.scrollable=!0);var i,r,s,a,l,d=_e&&"true"===localStorage.getItem(v(0,"isLocal")),c=void 0,u=void 0;function _(e){return e.preventDefault(),a.width+=l-e.clientX,a.onResize(),l=e.clientX,!1}function h(){M.removeClass(a.__closeButton,ge.CLASS_DRAG),M.unbind(window,"mousemove",_),M.unbind(window,"mouseup",h)}function p(e){return e.preventDefault(),l=e.clientX,M.addClass(a.__closeButton,ge.CLASS_DRAG),M.bind(window,"mousemove",_),M.bind(window,"mouseup",h),!1}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;t<e.__preset_select.length;t++)e.__preset_select[t].value===e.preset&&(e.__preset_select.selectedIndex=t)}(this),n.revert()}},width:{get:function(){return o.width},set:function(e){o.width=e,y(n,e)}},name:{get:function(){return o.name},set:function(e){o.name=e,u&&(u.innerHTML=o.name)}},closed:{get:function(){return o.closed},set:function(e){o.closed=e,o.closed?M.addClass(n.__ul,t.CLASS_CLOSED):M.removeClass(n.__ul,t.CLASS_CLOSED),this.onResize(),n.__closeButton&&(n.__closeButton.innerHTML=e?t.TEXT_OPEN:t.TEXT_CLOSED)}},load:{get:function(){return o.load}},useLocalStorage:{get:function(){return d},set:function(e){_e&&((d=e)?M.bind(window,"unload",c):M.unbind(window,"unload",c),localStorage.setItem(v(0,"isLocal"),e))}}}),C.isUndefined(o.parent)?(this.closed=o.closed||!1,M.addClass(this.domElement,t.CLASS_MAIN),M.makeSelectable(this.domElement,!1),_e&&d&&(n.useLocalStorage=!0,(i=localStorage.getItem(v(0,"gui")))&&(o.load=JSON.parse(i))),this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=t.TEXT_CLOSED,M.addClass(this.__closeButton,t.CLASS_CLOSE_BUTTON),o.closeOnTop?(M.addClass(this.__closeButton,t.CLASS_CLOSE_TOP),this.domElement.insertBefore(this.__closeButton,this.domElement.childNodes[0])):(M.addClass(this.__closeButton,t.CLASS_CLOSE_BOTTOM),this.domElement.appendChild(this.__closeButton)),M.bind(this.__closeButton,"click",function(){n.closed=!n.closed})):(void 0===o.closed&&(o.closed=!0),r=document.createTextNode(o.name),M.addClass(r,"controller-name"),u=f(n,r),M.addClass(this.__ul,t.CLASS_CLOSED),M.addClass(u,"title"),M.bind(u,"click",function(e){return e.preventDefault(),n.closed=!n.closed,!1}),o.closed||(this.closed=!1)),o.autoPlace&&(C.isUndefined(o.parent)&&(pe&&(fe=document.createElement("div"),M.addClass(fe,"dg"),M.addClass(fe,t.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(fe),pe=!1),fe.appendChild(this.domElement),M.addClass(this.domElement,t.CLASS_AUTO_PLACE)),this.parent||y(n,o.width)),this.__resizeHandler=function(){n.onResizeDebounced()},M.bind(window,"resize",this.__resizeHandler),M.bind(this.__ul,"webkitTransitionEnd",this.__resizeHandler),M.bind(this.__ul,"transitionend",this.__resizeHandler),M.bind(this.__ul,"oTransitionEnd",this.__resizeHandler),this.onResize(),o.resizable&&(l=void 0,(a=this).__resize_handle=document.createElement("div"),C.extend(a.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),M.bind(a.__resize_handle,"mousedown",p),M.bind(a.__closeButton,"mousedown",p),a.domElement.insertBefore(a.__resize_handle,a.domElement.firstElementChild)),c=function(){_e&&"true"===localStorage.getItem(v(0,"isLocal"))&&localStorage.setItem(v(0,"gui"),JSON.stringify(n.getSaveObject()))},this.saveToLocalStorageIfPossible=c,o.parent||((s=n.getRoot()).width+=1,C.defer(function(){--s.width}))};ge.toggleHide=function(){me=!me,C.each(be,function(e){e.domElement.style.display=me?"none":""})},ge.CLASS_AUTO_PLACE="a",ge.CLASS_AUTO_PLACE_CONTAINER="ac",ge.CLASS_MAIN="main",ge.CLASS_CONTROLLER_ROW="cr",ge.CLASS_TOO_TALL="taller-than-window",ge.CLASS_CLOSED="closed",ge.CLASS_CLOSE_BUTTON="close-button",ge.CLASS_CLOSE_TOP="close-top",ge.CLASS_CLOSE_BOTTOM="close-bottom",ge.CLASS_DRAG="drag",ge.DEFAULT_WIDTH=245,ge.TEXT_CLOSED="Close Controls",ge.TEXT_OPEN="Open Controls",ge._keydownHandler=function(e){"text"===document.activeElement.type||72!==e.which&&72!==e.keyCode||ge.toggleHide()},M.bind(window,"keydown",ge._keydownHandler,!1),C.extend(ge.prototype,{add:function(e,t){return g(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return g(this,e,t,{color:!0})},remove:function(e){this.__ul.removeChild(e.__li),this.__controllers.splice(this.__controllers.indexOf(e),1);var t=this;C.defer(function(){t.onResize()})},destroy:function(){if(this.parent)throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");this.autoPlace&&fe.removeChild(this.domElement);var t=this;C.each(this.__folders,function(e){t.removeFolder(e)}),M.unbind(window,"keydown",ge._keydownHandler,!1),s(this)},addFolder:function(e){if(void 0!==this.__folders[e])throw new Error('You already have a folder in this GUI by the name "'+e+'"');var t={name:e,parent:this};t.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[e]&&(t.closed=this.load.folders[e].closed,t.load=this.load.folders[e]);var n=new ge(t);this.__folders[e]=n;var o=f(this,n.domElement);return M.addClass(o,"folder"),n},removeFolder:function(t){this.__ul.removeChild(t.domElement.parentElement),delete this.__folders[t.name],this.load&&this.load.folders&&this.load.folders[t.name]&&delete this.load.folders[t.name],s(t);var e=this;C.each(t.__folders,function(e){t.removeFolder(e)}),C.defer(function(){e.onResize()})},open:function(){this.closed=!1},close:function(){this.closed=!0},onResize:function(){var e,t,n=this.getRoot();n.scrollable&&(e=M.getOffset(n.__ul).top,t=0,C.each(n.__ul.childNodes,function(e){n.autoPlace&&e===n.__save_row||(t+=M.getHeight(e))}),window.innerHeight-e-20<t?(M.addClass(n.domElement,ge.CLASS_TOO_TALL),n.__ul.style.height=window.innerHeight-e-20+"px"):(M.removeClass(n.domElement,ge.CLASS_TOO_TALL),n.__ul.style.height="auto")),n.__resize_handle&&C.defer(function(){n.__resize_handle.style.height=n.__ul.offsetHeight+"px"}),n.__closeButton&&(n.__closeButton.style.width=n.width+"px")},onResizeDebounced:C.debounce(function(){this.onResize()},50),remember:function(){if(C.isUndefined(he)&&((he=new te).domElement.innerHTML='<div id="dg-save" class="dg dialogue">\n\n Here\'s the new load parameter for your <code>GUI</code>\'s constructor:\n\n <textarea id="dg-new-constructor"></textarea>\n\n <div id="dg-save-locally">\n\n <input id="dg-local-storage" type="checkbox"/> Automatically save\n values to <code>localStorage</code> on exit.\n\n <div id="dg-local-explain">The values saved to <code>localStorage</code> will\n override those passed to <code>dat.GUI</code>\'s constructor. This makes it\n easier to work incrementally, but <code>localStorage</code> is fragile,\n and your friends may not see the same values you do.\n\n </div>\n\n </div>\n\n</div>'),this.parent)throw new Error("You can only call remember on a top level GUI.");var t=this;C.each(Array.prototype.slice.call(arguments),function(e){0===t.__rememberedObjects.length&&function(n){var e=n.__save_row=document.createElement("li");M.addClass(n.domElement,"has-save"),n.__ul.insertBefore(e,n.__ul.firstChild),M.addClass(e,"save-row");var t=document.createElement("span");t.innerHTML=" ",M.addClass(t,"button gears");var o=document.createElement("span");o.innerHTML="Save",M.addClass(o,"button"),M.addClass(o,"save");var i=document.createElement("span");i.innerHTML="New",M.addClass(i,"button"),M.addClass(i,"save-as");var r=document.createElement("span");r.innerHTML="Revert",M.addClass(r,"button"),M.addClass(r,"revert");var s,a,l=n.__preset_select=document.createElement("select");n.load&&n.load.remembered?C.each(n.load.remembered,function(e,t){c(n,t,t===n.preset)}):c(n,ue,!1),M.bind(l,"change",function(){for(var e=0;e<n.__preset_select.length;e++)n.__preset_select[e].innerHTML=n.__preset_select[e].value;n.preset=this.value}),e.appendChild(l),e.appendChild(t),e.appendChild(o),e.appendChild(i),e.appendChild(r),_e&&(s=document.getElementById("dg-local-explain"),a=document.getElementById("dg-local-storage"),document.getElementById("dg-save-locally").style.display="block","true"===localStorage.getItem(v(0,"isLocal"))&&a.setAttribute("checked","checked"),_(n,s),M.bind(a,"change",function(){n.useLocalStorage=!n.useLocalStorage,_(n,s)}));var d=document.getElementById("dg-new-constructor");M.bind(d,"keydown",function(e){!e.metaKey||67!==e.which&&67!==e.keyCode||he.hide()}),M.bind(t,"click",function(){d.innerHTML=JSON.stringify(n.getSaveObject(),void 0,2),he.show(),d.focus(),d.select()}),M.bind(o,"click",function(){n.save()}),M.bind(i,"click",function(){var e=prompt("Enter a new preset name.");e&&n.saveAs(e)}),M.bind(r,"click",function(){n.revert()})}(t),-1===t.__rememberedObjects.indexOf(e)&&t.__rememberedObjects.push(e)}),this.autoPlace&&y(this,this.width)},getRoot:function(){for(var e=this;e.parent;)e=e.parent;return e},getSaveObject:function(){var n=this.load;return n.closed=this.closed,0<this.__rememberedObjects.length&&(n.preset=this.preset,n.remembered||(n.remembered={}),n.remembered[this.preset]=a(this)),n.folders={},C.each(this.__folders,function(e,t){n.folders[t]=e.getSaveObject()}),n},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=a(this),m(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[ue]=a(this,!0)),this.load.remembered[e]=a(this),this.preset=e,c(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(t){C.each(this.__controllers,function(e){this.getRoot().load.remembered?b(t||this.getRoot(),e):e.setValue(e.initialValue),e.__onFinishChange&&e.__onFinishChange.call(e,e.getValue())},this),C.each(this.__folders,function(e){e.revert(e)}),t||m(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&function e(t){0!==t.length&&ee.call(window,function(){e(t)}),C.each(t,function(e){e.updateDisplay()})}(this.__listening)},updateDisplay:function(){C.each(this.__controllers,function(e){e.updateDisplay()}),C.each(this.__folders,function(e){e.updateDisplay()})}});var ve={Color:H,math:T,interpret:O},ye={Controller:j,BooleanController:G,OptionController:U,StringController:X,NumberController:K,NumberControllerBox:Y,NumberControllerSlider:J,FunctionController:W,ColorController:Q},we={dom:M},xe={GUI:ge},Ee=ge,Ce={color:ve,controllers:ye,dom:we,gui:xe,GUI:Ee};e.color=ve,e.controllers=ye,e.dom=we,e.gui=xe,e.GUI=Ee,e.default=Ce,Object.defineProperty(e,"__esModule",{value:!0})}); |