dat.gui/build/dat.gui.min.js

2 lines
47 KiB
JavaScript
Raw Normal View History

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):"object"==typeof exports?exports.dat=t():e.dat=t()}(this,function(){return function(e){function t(i){if(n[i])return n[i].exports;var o=n[i]={exports:{},id:i,loaded:!1};return e[i].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){e.exports={color:{Color:n(2),math:n(6),interpret:n(3)},controllers:{Controller:n(7),BooleanController:n(8),OptionController:n(10),StringController:n(11),NumberController:n(12),NumberControllerBox:n(13),NumberControllerSlider:n(14),FunctionController:n(20),ColorController:n(21)},dom:{dom:n(9)},gui:{GUI:n(22)}}},function(e,t,n){function i(e,t,n){Object.defineProperty(e,t,{get:function(){return"RGB"===this.__state.space?this.__state[t]:(r(this,t,n),this.__state[t])},set:function(e){"RGB"!==this.__state.space&&(r(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?this.__state[t]:(s(this),this.__state[t])},set:function(e){"HSV"!==this.__state.space&&(s(this),this.__state.space="HSV"),this.__state[t]=e}})}function r(e,t,n){if("HEX"===e.__state.space)e.__state[t]=l.component_from_hex(e.__state.hex,n);else{if("HSV"!==e.__state.space)throw"Corrupted color state";c.extend(e.__state,l.hsv_to_rgb(e.__state.h,e.__state.s,e.__state.v))}}function s(e){var t=l.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}var a=n(3),l=n(6),d=n(4),c=n(5),u=function(){if(this.__state=a.apply(this,arguments),this.__state===!1)throw"Failed to interpret color arguments";this.__state.a=this.__state.a||1};u.COMPONENTS=["r","g","b","h","s","v","hex","a"],c.extend(u.prototype,{toString:function(){return d(this)},toOriginal:function(){return this.__state.conversion.write(this)}}),i(u.prototype,"r",2),i(u.prototype,"g",1),i(u.prototype,"b",0),o(u.prototype,"h"),o(u.prototype,"s"),o(u.prototype,"v"),Object.defineProperty(u.prototype,"a",{get:function(){return this.__state.a},set:function(e){this.__state.a=e}}),Object.defineProperty(u.prototype,"hex",{get:function(){return"HEX"!==!this.__state.space&&(this.__state.hex=l.rgb_to_hex(this.r,this.g,this.b)),this.__state.hex},set:function(e){this.__state.space="HEX",this.__state.hex=e}}),e.exports=u},function(e,t,n){var i,o,r=n(4),s=n(5),a=function(){o=!1;var e=arguments.length>1?s.toArray(arguments):arguments[0];return s.each(l,function(t){return t.litmus(e)?(s.each(t.conversions,function(t,n){return i=t.read(e),o===!1&&i!==!1?(o=i,i.conversionName=n,i.conversion=t,s.BREAK):void 0}),s.BREAK):void 0}),o},l=[{litmus:s.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?!1:{space:"HEX",hex:parseInt("0x"+t[1].toString()+t[1].toString()+t[2].toString()+t[2].toString()+t[3].toString()+t[3].toString())}},write:r},SIX_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9]{6})$/i);return null===t?!1:{space:"HEX",hex:parseInt("0x"+t[1].toString())}},write:r},CSS_RGB:{read:function(e){var t=e.match(/^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);return null===t?!1:{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3])}},write:r},CSS_RGBA:{read:function(e){var t=e.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\,\s*(.+)\s*\)/);return null===t?!1:{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3]),a:parseFloat(t[4])}},write:r}}},{litmus:s.isNumber,conversions:{HEX:{read:function(e){return{space:"HEX",hex:e,conversionName:"HEX"}},write:function(e){return e.hex}}}},{litmus:s.isArray,conversions:{RGB_ARRAY:{read:function(e){return 3!=e.length?!1:{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?!1:{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:s.isObject,conversions:{RGBA_OBJ:{read:function(e)
var n={};return O.each(e.__rememberedObjects,function(i,o){var r={},s=e.__rememberedObjectIndecesToControllers[o];O.each(s,function(e,n){r[n]=t?e.initialValue:e.getValue()}),n[o]=r}),n}function h(e,t,n){var i=document.createElement("option");i.innerHTML=t,i.value=t,e.__preset_select.appendChild(i),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function p(e){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].value==e.preset&&(e.__preset_select.selectedIndex=t)}function f(e,t){var n=e.__preset_select[e.__preset_select.selectedIndex];t?n.innerHTML=n.value+"*":n.innerHTML=n.value}function _(e){0!=e.length&&k(function(){_(e)}),O.each(e,function(e){e.updateDisplay()})}var m=n(15),g=n(23),b=n(24),v=n(26),y=n(7),x=n(8),w=n(20),E=n(13),C=n(14),A=(n(10),n(21)),k=n(27),S=n(28),L=n(9),O=n(5);m.inject(b);var T,R,N="dg",B=72,D=20,V="Default",F=function(){try{return"localStorage"in window&&null!==window.localStorage}catch(e){return!1}}(),H=!0,M=!1,I=[],U=function(e){function t(){var e=n.getRoot();e.width+=1,O.defer(function(){e.width-=1})}var n=this;this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),L.addClass(this.domElement,N),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],e=e||{},e=O.defaults(e,{autoPlace:!0,width:U.DEFAULT_WIDTH}),e=O.defaults(e,{resizable:e.autoPlace,hideable:e.autoPlace}),O.isUndefined(e.load)?e.load={preset:V}:e.preset&&(e.load.preset=e.preset),O.isUndefined(e.parent)&&e.hideable&&I.push(this),e.resizable=O.isUndefined(e.parent)&&e.resizable,e.autoPlace&&O.isUndefined(e.scrollable)&&(e.scrollable=!0);var i,r=F&&"true"===localStorage.getItem(a(this,"isLocal"));if(Object.defineProperties(this,{parent:{get:function(){return e.parent}},scrollable:{get:function(){return e.scrollable}},autoPlace:{get:function(){return e.autoPlace}},preset:{get:function(){return n.parent?n.getRoot().preset:e.load.preset},set:function(t){n.parent?n.getRoot().preset=t:e.load.preset=t,p(this),n.revert()}},width:{get:function(){return e.width},set:function(t){e.width=t,c(n,t)}},name:{get:function(){return e.name},set:function(t){e.name=t,l&&(l.innerHTML=e.name)}},closed:{get:function(){return e.closed},set:function(t){e.closed=t,e.closed?L.addClass(n.__ul,U.CLASS_CLOSED):L.removeClass(n.__ul,U.CLASS_CLOSED),this.onResize(),n.__closeButton&&(n.__closeButton.innerHTML=t?U.TEXT_OPEN:U.TEXT_CLOSED)}},load:{get:function(){return e.load}},useLocalStorage:{get:function(){return r},set:function(e){F&&(r=e,e?L.bind(window,"unload",i):L.unbind(window,"unload",i),localStorage.setItem(a(n,"isLocal"),e))}}}),O.isUndefined(e.parent)){if(e.closed=!1,L.addClass(this.domElement,U.CLASS_MAIN),L.makeSelectable(this.domElement,!1),F&&r){n.useLocalStorage=!0;var s=localStorage.getItem(a(this,"gui"));s&&(e.load=JSON.parse(s))}this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=U.TEXT_CLOSED,L.addClass(this.__closeButton,U.CLASS_CLOSE_BUTTON),this.domElement.appendChild(this.__closeButton),L.bind(this.__closeButton,"click",function(){n.closed=!n.closed})}else{void 0===e.closed&&(e.closed=!0);var l=document.createTextNode(e.name);L.addClass(l,"controller-name");var u=o(n,l),h=function(e){return e.preventDefault(),n.closed=!n.closed,!1};L.addClass(this.__ul,U.CLASS_CLOSED),L.addClass(u,"title"),L.bind(u,"click",h),e.closed||(this.closed=!1)}e.autoPlace&&(O.isUndefined(e.parent)&&(H&&(R=document.createElement("div"),L.addClass(R,N),L.addClass(R,U.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(R),H=!1),R.appendChild(this.domElement),L.addClass(this.domElement,U.CLASS_AUTO_PLACE)),this.parent||c(n,e.width)),L.bind(window,"resize",function(){n.onResize()}),L.bind(this.__ul,"webkitTransitionEnd",function(){n.onResize()}),L.bind(this.__ul,"transitionend",function(){n.onResize()}),L.bind(this.__ul,"oTransitionEnd",function(){n.onResize()}),this.onResize(),e.resizable&&d(this),i=function(){F&&"true"===localStorage.getItem(a(n,"isLocal"))&&localStorage